Import the axge(4) driver for the ASIX AX88178A and AX88179 USB Ethernet

adapters. Both devices support Gigabit Ethernet and USB 2.0, and the AX88179
supports USB 3.0. The driver was written by kevlo@ and lwhsu@, with a few
bug fixes from me.

MFC after:	2 months
This commit is contained in:
Mark Johnston 2013-11-19 00:37:53 +00:00
parent 3bd40bb188
commit da089c1410
7 changed files with 1399 additions and 3 deletions

View File

@ -67,6 +67,7 @@ MAN= aac.4 \
auditpipe.4 \
aue.4 \
axe.4 \
axge.4 \
bce.4 \
bfe.4 \
bge.4 \

149
share/man/man4/axge.4 Normal file
View File

@ -0,0 +1,149 @@
.\" Copyright (c) 1997, 1998, 1999, 2000-2003
.\" Bill Paul <wpaul@windriver.com>. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by Bill Paul.
.\" 4. Neither the name of the author nor the names of any co-contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd November 12, 2013
.Dt AXGE 4
.Os
.Sh NAME
.Nm axge
.Nd "ASIX Electronics AX88178A/AX88179 USB Gigabit Ethernet driver"
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device ehci"
.Cd "device uhci"
.Cd "device ohci"
.Cd "device usb"
.Cd "device miibus"
.Cd "device axge"
.Ed
.Pp
Alternatively, to load the driver as a
module at boot time, place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
if_axge_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver provides support for USB Gigabit Ethernet adapters based on the ASIX
Electronics AX88179 USB 3.0 and AX88178A USB 2.0 chipsets.
.Pp
The AX88179 and AX88178A contain a 10/100/1000 Ethernet MAC with a GMII
interface for interfacing with the Gigabit Ethernet PHY.
.Pp
These devices will operate with both USB 1.x and USB 2.0 controllers, and the
AX88179 will operate with USB 3.0 controllers.
Packets are received and transmitted over separate USB bulk transfer endpoints.
.Pp
The
.Nm
driver supports the following media types:
.Bl -tag -width ".Cm 10baseT/UTP"
.It Cm autoselect
Enable autoselection of the media type and options.
The user can manually override
the autoselected mode by adding media options to
.Xr rc.conf 5 .
.It Cm 10baseT/UTP
Set 10Mbps operation.
The
.Xr ifconfig 8
.Cm mediaopt
option can also be used to select either
.Cm full-duplex
or
.Cm half-duplex
modes.
.It Cm 100baseTX
Set 100Mbps (Fast Ethernet) operation.
The
.Xr ifconfig 8
.Cm mediaopt
option can also be used to select either
.Cm full-duplex
or
.Cm half-duplex
modes.
.It Cm 1000baseT
Set 1000Mbps (Gigabit Ethernet) operation (AX88178 only).
The
.Xr ifconfig 8
.Cm mediaopt
option can also be used to select either
.Cm full-duplex
or
.Cm half-duplex
modes.
.El
.Pp
The
.Nm
driver supports the following media options:
.Bl -tag -width ".Cm full-duplex"
.It Cm full-duplex
Force full duplex operation.
.It Cm half-duplex
Force half duplex operation.
.El
.Pp
For more information on configuring this device, see
.Xr ifconfig 8 .
.Sh SEE ALSO
.Xr altq 4 ,
.Xr arp 4 ,
.Xr miibus 4 ,
.Xr netintro 4 ,
.Xr ng_ether 4 ,
.Xr rgephy 4 ,
.Xr vlan 4 ,
.Xr ifconfig 8
.Sh HISTORY
The
.Nm
device driver first appeared in
.Fx 10.1 .
.Sh AUTHORS
The
.Nm
driver was written by
.An Kevin Lo Aq kevlo@FreeBSD.org
and
.An Li-Wen Hsu Aq lwhsu@FreeBSD.org .
This manual page was adapted by
.An Mark Johnston Aq markj@FreeBSD.org
from the
.Xr axe 4
manual page.

View File

@ -2311,6 +2311,7 @@ dev/usb/usb_util.c optional usb
#
dev/usb/net/if_aue.c optional aue
dev/usb/net/if_axe.c optional axe
dev/usb/net/if_axge.c optional axge
dev/usb/net/if_cdce.c optional cdce
dev/usb/net/if_cue.c optional cue
dev/usb/net/if_ipheth.c optional ipheth
@ -2321,8 +2322,8 @@ dev/usb/net/if_smsc.c optional smsc
dev/usb/net/if_udav.c optional udav
dev/usb/net/if_usie.c optional usie
dev/usb/net/ruephy.c optional rue
dev/usb/net/usb_ethernet.c optional aue | axe | cdce | cue | kue | mos | \
rue | smsc | udav | ipheth
dev/usb/net/usb_ethernet.c optional aue | axe | axge | cdce | cue | kue | \
mos | rue | smsc | udav | ipheth
dev/usb/net/uhso.c optional uhso
#
# USB WLAN drivers

1023
sys/dev/usb/net/if_axge.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,212 @@
/*-
* Copyright (c) 2013 Kevin Lo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#define AX88179_PHY_ID 0x03
#define AXGE_MCAST_FILTER_SIZE 8
#define AXGE_MAXGE_MCAST 64
#define AXGE_EEPROM_LEN 0x40
#define AXGE_RX_CHECKSUM 1
#define AXGE_TX_CHECKSUM 2
#define AXGE_ACCESS_MAC 0x01
#define AXGE_ACCESS_PHY 0x02
#define AXGE_ACCESS_WAKEUP 0x03
#define AXGE_ACCESS_EEPROM 0x04
#define AXGE_ACCESS_EFUSE 0x05
#define AXGE_RELOAD_EEPROM_EFUSE 0x06
#define AXGE_WRITE_EFUSE_EN 0x09
#define AXGE_WRITE_EFUSE_DIS 0x0A
#define AXGE_ACCESS_MFAB 0x10
#define AXGE_LINK_STATUS 0x02
#define AXGE_LINK_STATUS_USB_FS 0x01
#define AXGE_LINK_STATUS_USB_HS 0x02
#define AXGE_LINK_STATUS_USB_SS 0x04
#define AXGE_SROM_ADDR 0x07
#define AXGE_SROM_DATA_LOW 0x08
#define AXGE_SROM_DATA_HIGH 0x09
#define AXGE_SROM_CMD 0x0a
#define AXGE_SROM_CMD_RD 0x04 /* EEprom read command */
#define AXGE_SROM_CMD_WR 0x08 /* EEprom write command */
#define AXGE_SROM_CMD_BUSY 0x10 /* EEprom access module busy */
#define AXGE_RX_CTL 0x0b
#define AXGE_RX_CTL_DROPCRCERR 0x0100 /* Drop CRC error packet */
#define AXGE_RX_CTL_IPE 0x0200 /* 4-byte IP header alignment */
#define AXGE_RX_CTL_TXPADCRC 0x0400 /* Csum value in rx header 3 */
#define AXGE_RX_CTL_START 0x0080 /* Ethernet MAC start */
#define AXGE_RX_CTL_AP 0x0020 /* Accept physical address from
multicast array */
#define AXGE_RX_CTL_AM 0x0010
#define AXGE_RX_CTL_AB 0x0008
#define AXGE_RX_CTL_HA8B 0x0004
#define AXGE_RX_CTL_AMALL 0x0002 /* Accept all multicast frames */
#define AXGE_RX_CTL_PRO 0x0001 /* Promiscuous Mode */
#define AXGE_RX_CTL_STOP 0x0000 /* Stop MAC */
#define AXGE_NODE_ID 0x10
#define AXGE_MULTI_FILTER_ARRY 0x16
#define AXGE_MEDIUM_STATUS_MODE 0x22
#define AXGE_MEDIUM_GIGAMODE 0x0001
#define AXGE_MEDIUM_FULL_DUPLEX 0x0002
#define AXGE_MEDIUM_ALWAYS_ONE 0x0004
#define AXGE_MEDIUM_EN_125MHZ 0x0008
#define AXGE_MEDIUM_RXFLOW_CTRLEN 0x0010
#define AXGE_MEDIUM_TXFLOW_CTRLEN 0x0020
#define AXGE_MEDIUM_RECEIVE_EN 0x0100
#define AXGE_MEDIUM_PS 0x0200
#define AXGE_MEDIUM_JUMBO_EN 0x8040
#define AXGE_MONITOR_MODE 0x24
#define AXGE_MONITOR_MODE_RWLC 0x02
#define AXGE_MONITOR_MODE_RWMP 0x04
#define AXGE_MONITOR_MODE_RWWF 0x08
#define AXGE_MONITOR_MODE_RW_FLAG 0x10
#define AXGE_MONITOR_MODE_PMEPOL 0x20
#define AXGE_MONITOR_MODE_PMETYPE 0x40
#define AXGE_GPIO_CTRL 0x25
#define AXGE_GPIO_CTRL_GPIO3EN 0x80
#define AXGE_GPIO_CTRL_GPIO2EN 0x40
#define AXGE_GPIO_CTRL_GPIO1EN 0x20
#define AXGE_PHYPWR_RSTCTL 0x26
#define AXGE_PHYPWR_RSTCTL_BZ 0x0010
#define AXGE_PHYPWR_RSTCTL_IPRL 0x0020
#define AXGE_PHYPWR_RSTCTL_AUTODETACH 0x1000
#define AXGE_RX_BULKIN_QCTRL 0x2e
#define AXGE_RX_BULKIN_QCTRL_TIME 0x01
#define AXGE_RX_BULKIN_QCTRL_IFG 0x02
#define AXGE_RX_BULKIN_QCTRL_SIZE 0x04
#define AXGE_RX_BULKIN_QTIMR_LOW 0x2f
#define AXGE_RX_BULKIN_QTIMR_HIGH 0x30
#define AXGE_RX_BULKIN_QSIZE 0x31
#define AXGE_RX_BULKIN_QIFG 0x32
#define AXGE_CLK_SELECT 0x33
#define AXGE_CLK_SELECT_BCS 0x01
#define AXGE_CLK_SELECT_ACS 0x02
#define AXGE_CLK_SELECT_ACSREQ 0x10
#define AXGE_CLK_SELECT_ULR 0x08
#define AXGE_RXCOE_CTL 0x34
#define AXGE_RXCOE_IP 0x01
#define AXGE_RXCOE_TCP 0x02
#define AXGE_RXCOE_UDP 0x04
#define AXGE_RXCOE_ICMP 0x08
#define AXGE_RXCOE_IGMP 0x10
#define AXGE_RXCOE_TCPV6 0x20
#define AXGE_RXCOE_UDPV6 0x40
#define AXGE_RXCOE_ICMV6 0x80
#define AXGE_TXCOE_CTL 0x35
#define AXGE_TXCOE_IP 0x01
#define AXGE_TXCOE_TCP 0x02
#define AXGE_TXCOE_UDP 0x04
#define AXGE_TXCOE_ICMP 0x08
#define AXGE_TXCOE_IGMP 0x10
#define AXGE_TXCOE_TCPV6 0x20
#define AXGE_TXCOE_UDPV6 0x40
#define AXGE_TXCOE_ICMV6 0x80
#define AXGE_PAUSE_WATERLVL_HIGH 0x54
#define AXGE_PAUSE_WATERLVL_LOW 0x55
#define AXGE_EEP_EFUSE_CORRECT 0x00
#define AX88179_EEPROM_MAGIC 0x17900b95
#define AXGE_CONFIG_IDX 0 /* config number 1 */
#define AXGE_IFACE_IDX 0
#define AXGE_RXHDR_CRC_ERR 0x80000000
#define AXGE_RXHDR_L4_ERR (1 << 8)
#define AXGE_RXHDR_L3_ERR (1 << 9)
#define AXGE_RXHDR_L4_TYPE_ICMP 2
#define AXGE_RXHDR_L4_TYPE_IGMP 3
#define AXGE_RXHDR_L4_TYPE_TCMPV6 5
#define AXGE_RXHDR_L3_TYPE_IP 1
#define AXGE_RXHDR_L3_TYPE_IPV6 2
#define AXGE_RXHDR_L4_TYPE_MASK 0x1c
#define AXGE_RXHDR_L4_TYPE_UDP 4
#define AXGE_RXHDR_L4_TYPE_TCP 16
#define AXGE_RXHDR_L3CSUM_ERR 2
#define AXGE_RXHDR_L4CSUM_ERR 1
#define AXGE_RXHDR_CRC_ERR 0x80000000
#define AXGE_RXHDR_DROP_ERR 0x40000000
struct axge_csum_hdr {
uint16_t cstatus;
#define AXGE_CSUM_HDR_L4_CSUM_ERR 0x0001
#define AXGE_CSUM_HDR_L3_CSUM_ERR 0x0002
#define AXGE_CSUM_HDR_L4_TYPE_UDP 0x0004
#define AXGE_CSUM_HDR_L4_TYPE_ICMP 0x0008
#define AXGE_CSUM_HDR_L4_TYPE_IGMP 0x000C
#define AXGE_CSUM_HDR_L4_TYPE_TCP 0x0010
#define AXGE_CSUM_HDR_L4_TYPE_TCPV6 0x0014
#define AXGE_CSUM_HDR_L4_TYPE_MASK 0x001C
#define AXGE_CSUM_HDR_L3_TYPE_IPV4 0x0020
#define AXGE_CSUM_HDR_L3_TYPE_IPV6 0x0040
#define AXGE_CSUM_HDR_VLAN_MASK 0x0700
uint16_t len;
#define AXGE_CSUM_HDR_LEN_MASK 0x1FFF
#define AXGE_CSUM_HDR_CRC_ERR 0x2000
#define AXGE_CSUM_HDR_MII_ERR 0x4000
#define AXGE_CSUM_HDR_DROP 0x8000
} __packed;
#define AXGE_CSUM_RXBYTES(x) ((x) & AXGE_CSUM_HDR_LEN_MASK)
#define GET_MII(sc) uether_getmii(&(sc)->sc_ue)
/* The interrupt endpoint is currently unused by the ASIX part. */
enum {
AXGE_BULK_DT_WR,
AXGE_BULK_DT_RD,
AXGE_N_TRANSFER,
};
struct axge_softc {
struct usb_ether sc_ue;
struct mtx sc_mtx;
struct usb_xfer *sc_xfer[AXGE_N_TRANSFER];
int sc_phyno;
int sc_flags;
#define AXGE_FLAG_LINK 0x0001 /* got a link */
};
#define AXGE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
#define AXGE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
#define AXGE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t)

View File

@ -38,7 +38,7 @@ SUBDIR += ${_urtwn} ${_urtwnfw}
SUBDIR += atp uhid ukbd ums udbp ufm uep
SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom ufoma uftdi ugensa uipaq ulpt \
umct umcs umodem umoscom uplcom uslcom uvisor uvscom
SUBDIR += uether aue axe cdce cue ${_kue} mos rue smsc udav uhso ipheth
SUBDIR += uether aue axe axge cdce cue ${_kue} mos rue smsc udav uhso ipheth
SUBDIR += usfs umass urio
SUBDIR += quirk template
SUBDIR += ${_g_audio} ${_g_keyboard} ${_g_modem} ${_g_mouse}

View File

@ -0,0 +1,10 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../../dev/usb/net
KMOD= if_axge
SRCS+= if_axge.c usbdevs.h
SRCS+= bus_if.h device_if.h miibus_if.h usb_if.h \
opt_bus.h opt_inet.h opt_usb.h
.include <bsd.kmod.mk>