Skip to contentSkip to conversation

ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

PATCH In review Freddy Xin 2 participants 2 messages Feb 27, 2013 – Mar 1, 2013

Subsystems (3)
lore
Share & tools
lore

Freddy Xin

author
#0 lore raw

PATCH 1/1 ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver

From: Freddy Xin <[email protected]>

This is a resubmission.
Fixed endianness issue on big endian systems and verified this driver on iBook G4. Removed steps that change net->features in ax88179_set_features function.
Added "const" to ethtool_ops structure and fixed the coding style of AX88179_BULKIN_SIZE array. Fixed the issue that the default MTU is not 1500.
Added ax88179_change_mtu function and enabled the hardware jumbo frame function to support an MTU higher than 1500.
Fixed indentation and empty line coding style errors.
The _nopm version usb functions were added to access register in suspend and resume functions. Serveral variables allocted dynamically were removed and replaced by stack variables. ax88179_get_eeprom were modified from asix_get_eeprom in asix_common.

This patch adds a driver for ASIX's AX88179 family of USB 3.0/2.0 to gigabit ethernet adapters. It's based on the AX88xxx driver but the usb commands used to access registers for AX88179 are completely different. This driver had been verified on x86 system with AX88179/AX88178A and Sitcomm LN-032 USB dongles.

---
 drivers/net/usb/Kconfig        |   18 +
 drivers/net/usb/Makefile       |    1 +
 drivers/net/usb/ax88179_178a.c | 1455 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1474 insertions(+)
 create mode 100644 drivers/net/usb/ax88179_178a.c
drivers/net/usb/Kconfig +18 -0
index da92ed3..21e084d 100644
@@ -156,6 +156,24 @@ config USB_NET_AX8817X
 	  This driver creates an interface named "ethX", where X depends on
 	  what other networking devices you have in use.
 
+config USB_NET_AX88179_178A
+	tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet"
+	depends on USB_USBNET
+	select CRC32
+	select PHYLIB
+	default y
+	help
+	  This option adds support for ASIX AX88179 based USB 3.0/2.0
+	  to Gigabit Ethernet adapters.
+
+ 	  This driver should work with at least the following devices:
+	    * ASIX AX88179
+	    * ASIX AX88178A
+	    * Sitcomm LN-032
+
+	  This driver creates an interface named "ethX", where X depends on
+	  what other networking devices you have in use.
+
 config USB_NET_CDCETHER
 	tristate "CDC Ethernet support (smart devices such as cable modems)"
 	depends on USB_USBNET
drivers/net/usb/Makefile +1 -0
index 4786913..119b06c 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_USB_RTL8150)	+= rtl8150.o
 obj-$(CONFIG_USB_HSO)		+= hso.o
 obj-$(CONFIG_USB_NET_AX8817X)	+= asix.o
 asix-y := asix_devices.o asix_common.o ax88172a.o
+obj-$(CONFIG_USB_NET_AX88179_178A)      += ax88179_178a.o
 obj-$(CONFIG_USB_NET_CDCETHER)	+= cdc_ether.o
 obj-$(CONFIG_USB_NET_CDC_EEM)	+= cdc_eem.o
 obj-$(CONFIG_USB_NET_DM9601)	+= dm9601.o
drivers/net/usb/ax88179_178a.c new file +1455 -0

1,455 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

From: Freddy Xin <[email protected]>
Date: Wed, 27 Feb 2013 20:01:58 +0800

drivers/net/usb/ax88179_178a.c line 559

Quoted 12 lines
drivers/net/usb/ax88179_178a.c new file +12 -0
+	eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
+			      GFP_KERNEL);
+	if (!eeprom_buff)
+		return -ENOMEM;
+
+	/* ax88179/178A returns 2 bytes from eeprom on read */
+	for (i = first_word; i <= last_word; i++) {
+		ret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2,
+					 &eeprom_buff[i - first_word],
+					 0);
+		if (ret < 0)
+			return -EIO;

In this -EIO error path we will leak eeprom_buff, you must free it in all possible exit cases of this function after the allocation succeeds.

drivers/net/usb/ax88179_178a.c line 606

Quoted 2 lines
drivers/net/usb/ax88179_178a.c new file +2 -0
+	data->rxctl = (__force __le16)(AX_RX_CTL_START | AX_RX_CTL_AB |
+				       AX_RX_CTL_IPE);

You're not storying a __le16 in data->rxctl, you're storing the bits in cpu endianness. So make it a plain u16 instead and get rid of these pointless casts.

drivers/net/usb/ax88179_178a.c line 1452

Quoted 11 lines
drivers/net/usb/ax88179_178a.c new file +11 -0
+static int __init asix_init(void)
+{
+	return usb_register(&asix_driver);
+}
+module_init(asix_init);
+
+static void __exit asix_exit(void)
+{
+	usb_deregister(&asix_driver);
+}
+module_exit(asix_exit);

You can replace all of this with a simple:

module_usb_driver(asix_driver);