Skip to contentSkip to conversation

usb: eth: add ASIX AX88179 DRIVER

PATCH New Rene Griessl 2 participants 7 messages Sep 3, 2014 – Sep 11, 2014 USB

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 usb: eth: add ASIX AX88179 DRIVER

changes in v2:
-added usb_ether.h to change list
-added 2nd patch to enable driver for arndale board

---
 drivers/usb/eth/Makefile    |   3 +
 drivers/usb/eth/asix88179.c | 641 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/usb/eth/usb_ether.c |   7 +
 include/usb_ether.h         |   6 +
 4 files changed, 657 insertions(+)
 create mode 100644 drivers/usb/eth/asix88179.c
drivers/usb/eth/Makefile +3 -0
index 94551c4..fad4acd 100644
@@ -8,5 +8,8 @@ obj-$(CONFIG_USB_HOST_ETHER) += usb_ether.o
 ifdef CONFIG_USB_ETHER_ASIX
 obj-y += asix.o
 endif
+ifdef CONFIG_USB_ETHER_ASIX_88179
+obj-y += asix88179.o
+endif
 obj-$(CONFIG_USB_ETHER_MCS7830) += mcs7830.o
 obj-$(CONFIG_USB_ETHER_SMSC95XX) += smsc95xx.o
drivers/usb/eth/asix88179.c new file +641 -0

641 lines not on this page · raw message

drivers/usb/eth/usb_ether.c +7 -0
index 1dda54c..59822a6 100644
@@ -30,6 +30,13 @@ static const struct usb_eth_prob_dev prob_dev[] = {
 		.get_info = asix_eth_get_info,
 	},
 #endif
+#ifdef CONFIG_USB_ETHER_ASIX_88179
+	{
+		.before_probe = ax88179_eth_before_probe,
+		.probe = ax88179_eth_probe,
+		.get_info = ax88179_eth_get_info,
+	},
+#endif
 #ifdef CONFIG_USB_ETHER_MCS7830
 	{
 		.before_probe = mcs7830_eth_before_probe,
include/usb_ether.h +6 -0
index 35700a2..b38d037 100644
@@ -49,6 +49,12 @@ int asix_eth_probe(struct usb_device *dev, unsigned int ifnum,
 int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
 		      struct eth_device *eth);
 
+void ax88179_eth_before_probe(void);
+int ax88179_eth_probe(struct usb_device *dev, unsigned int ifnum,
+		      struct ueth_data *ss);
+int ax88179_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
+		      struct eth_device *eth);
+
 void mcs7830_eth_before_probe(void);
 int mcs7830_eth_probe(struct usb_device *dev, unsigned int ifnum,
 		      struct ueth_data *ss);
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 2/2 usb: eth: enable ASIX AX88179 DRIVER for Arndale5250 board

enable this driver for arndale5250 board

---
 include/configs/arndale.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/arndale.h +1 -0
index 75f9933..9bdb66a 100644
@@ -232,6 +232,7 @@
 
 /* Ethernet Controllor Driver */
 #ifdef CONFIG_CMD_NET
+#define CONFIG_USB_ETHER_ASIX_88179
 #define CONFIG_SMC911X
 #define CONFIG_SMC911X_BASE		0x5000000
 #define CONFIG_SMC911X_16_BIT
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/2 usb: eth: add ASIX AX88179 DRIVER

In reply to Rene Griessl
Quoted 5 lines · Rene Griessl

changes in v2:
-added usb_ether.h to change list
-added 2nd patch to enable driver for arndale board

I see that in Linux, there is asix_common.c stuff. Can this driver share any parts with drivers/net/ax88* ?

Quoted 14 lines
---
 drivers/usb/eth/Makefile    |   3 +
 drivers/usb/eth/asix88179.c | 641
++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/eth/usb_ether.c |
  7 +
 include/usb_ether.h         |   6 +
 4 files changed, 657 insertions(+)
 create mode 100644 drivers/usb/eth/asix88179.c
drivers/usb/eth/Makefile +0 -0
index 94551c4..fad4acd 100644

drivers/usb/eth/Makefile obj-$(CONFIG_USB_HOST_ETHER) += usb_ether.o · line 13

Quoted 6 lines
drivers/usb/eth/Makefile +3 -0
@@ -8,5 +8,8 @@ obj-$(CONFIG_USB_HOST_ETHER) += usb_ether.o
 ifdef CONFIG_USB_ETHER_ASIX
 obj-y += asix.o
 endif
+ifdef CONFIG_USB_ETHER_ASIX_88179
+obj-y += asix88179.o
+endif

This should be obj-$(CONFIG....) as seen below. Fix the asix one in a separate patch please.

[...]

drivers/usb/eth/Makefile obj-$(CONFIG_USB_HOST_ETHER) += usb_ether.o

Quoted 7 lines
drivers/usb/eth/Makefile +7 -0
+/* ASIX AX88179 based USB 3.0 Ethernet Devices */
+#define AX88179_PHY_ID				0x03
+#define AX_EEPROM_LEN				0x100
+#define AX88179_EEPROM_MAGIC			0x17900b95
+#define AX_MCAST_FLTSIZE			8
+#define AX_MAX_MCAST				64
+#define AX_INT_PPLS_LINK			((u32)BIT(16))

The u32 cast is not needed. Also, please drop the BIT() macro, it's just obfuscating the code, just use (1 << 16) instead. Please fix globally.

Quoted 13 lines
drivers/usb/eth/Makefile +13 -0
+#define AX_RXHDR_L4_TYPE_MASK			0x1c
+#define AX_RXHDR_L4_TYPE_UDP			4
+#define AX_RXHDR_L4_TYPE_TCP			16
+#define AX_RXHDR_L3CSUM_ERR			2
+#define AX_RXHDR_L4CSUM_ERR			1
+#define AX_RXHDR_CRC_ERR			((u32)BIT(29))
+#define AX_RXHDR_DROP_ERR			((u32)BIT(31))
+#define AX_ACCESS_MAC				0x01
+#define AX_ACCESS_PHY				0x02
+#define AX_ACCESS_EEPROM			0x04
+#define AX_ACCESS_EFUS				0x05
+#define AX_PAUSE_WATERLVL_HIGH			0x54
+#define AX_PAUSE_WATERLVL_LOW			0x55

[...]

drivers/usb/eth/Makefile

Quoted 7 lines
drivers/usb/eth/Makefile +7 -0
+static inline int asix_get_phy_addr(struct ueth_data *dev)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(u8, buf, 2);
+	int ret = -1;
+	if (dev->pusb_dev->descriptor.idProduct == 0x1790) {
+		ret = asix_read_cmd(dev, AX_ACCESS_MAC, 0x10, 6, 6, buf);
+		debug("asix_get_phy_addr() returning 

0x%02x%02x%02x%02x%02x%02x\n",

drivers/usb/eth/Makefile

Quoted 4 lines
drivers/usb/eth/Makefile +4 -0
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+		}
+	else {
+		}

Uh, this check needs some rework, right ? Also, you want to lint your patches with ./scripts/checkpatch.pl tool before resubmitting.

Quoted 13 lines
drivers/usb/eth/Makefile +13 -0
+	return ret;
+}
+
+
+static int asix_read_mac(struct eth_device *eth)
+{
+	struct ueth_data *dev = (struct ueth_data *)eth->priv;
+	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
+
+	if (dev->pusb_dev->descriptor.idProduct == 0x1790) {
+		asix_read_cmd(dev, AX_ACCESS_MAC, 0x10, 6, 6, buf);
+		debug("asix_read_mac() returning 0x%02x%02x%02x%02x%02x%02x\n",
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);

drivers/usb/eth/Makefile

Quoted 10 lines
drivers/usb/eth/Makefile +10 -0
+		memcpy(eth->enetaddr, buf, ETH_ALEN);
+		}
+	return 0;
+}
+
+
+
+static int asix_basic_reset(struct ueth_data *dev)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(u8, buf, 6);

Why does the buffer need to be aligned here ? It's just a buffer that is not used for DMA, no ?

drivers/usb/eth/Makefile

Quoted 1 line
drivers/usb/eth/Makefile +1 -0
+	u16 *tmp16;

Is it because you were getting unaligned accesses , since when the buffer itself was not aligned and you did cast it to u16, the CPU triggered unaligned access ?

Quoted 1 line
drivers/usb/eth/Makefile +1 -0
+	u8 *tmp;

[...]

#3 lore raw

PATCH v2 1/2 usb: eth: add ASIX AX88179 DRIVER

Am 09.09.2014 16:34, schrieb Marek Vasut:

Quoted 8 lines · Rene Griessl
Quoted 5 lines

changes in v2:
-added usb_ether.h to change list
-added 2nd patch to enable driver for arndale board

I see that in Linux, there is asix_common.c stuff. Can this driver share any parts with drivers/net/ax88* ?

The asix_common.c includes asix.h. There you see that the common driver supports following devices:
AX88172
AX88772
AX88178
but it is not supporting AX88179 and AX88178a, they have a separate driver called ax88179_178a.c
These two have a different style in accessing MAC registers and PHY

Quoted 23 lines
Quoted 14 lines
---
  drivers/usb/eth/Makefile    |   3 +
  drivers/usb/eth/asix88179.c | 641
++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/eth/usb_ether.c |
   7 +
  include/usb_ether.h         |   6 +
  4 files changed, 657 insertions(+)

create mode 100644 drivers/usb/eth/asix88179.c

drivers/usb/eth/Makefile +0 -0
index 94551c4..fad4acd 100644

drivers/usb/eth/Makefile obj-$(CONFIG_USB_HOST_ETHER) += usb_ether.o · line 13

Quoted 6 lines
drivers/usb/eth/Makefile +3 -0
@@ -8,5 +8,8 @@ obj-$(CONFIG_USB_HOST_ETHER) += usb_ether.o
  ifdef CONFIG_USB_ETHER_ASIX
  obj-y += asix.o
  endif
+ifdef CONFIG_USB_ETHER_ASIX_88179
+obj-y += asix88179.o
+endif

This should be obj-$(CONFIG....) as seen below. Fix the asix one in a separate patch please.

Quoted 1 line

[...]

OK

Quoted 9 lines

drivers/usb/eth/Makefile

Quoted 7 lines
drivers/usb/eth/Makefile +7 -0
+/* ASIX AX88179 based USB 3.0 Ethernet Devices */
+#define AX88179_PHY_ID				0x03
+#define AX_EEPROM_LEN				0x100
+#define AX88179_EEPROM_MAGIC			0x17900b95
+#define AX_MCAST_FLTSIZE			8
+#define AX_MAX_MCAST				64
+#define AX_INT_PPLS_LINK			((u32)BIT(16))

The u32 cast is not needed. Also, please drop the BIT() macro, it's just obfuscating the code, just use (1 << 16) instead. Please fix globally.

OK (was just copy'n'paste from the linux driver)

Quoted 23 lines
Quoted 13 lines
drivers/usb/eth/Makefile +13 -0
+#define AX_RXHDR_L4_TYPE_MASK			0x1c
+#define AX_RXHDR_L4_TYPE_UDP			4
+#define AX_RXHDR_L4_TYPE_TCP			16
+#define AX_RXHDR_L3CSUM_ERR			2
+#define AX_RXHDR_L4CSUM_ERR			1
+#define AX_RXHDR_CRC_ERR			((u32)BIT(29))
+#define AX_RXHDR_DROP_ERR			((u32)BIT(31))
+#define AX_ACCESS_MAC				0x01
+#define AX_ACCESS_PHY				0x02
+#define AX_ACCESS_EEPROM			0x04
+#define AX_ACCESS_EFUS				0x05
+#define AX_PAUSE_WATERLVL_HIGH			0x54
+#define AX_PAUSE_WATERLVL_LOW			0x55

[...]

drivers/usb/eth/Makefile

Quoted 7 lines
drivers/usb/eth/Makefile +7 -0
+static inline int asix_get_phy_addr(struct ueth_data *dev)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(u8, buf, 2);
+	int ret = -1;
+	if (dev->pusb_dev->descriptor.idProduct == 0x1790) {
+		ret = asix_read_cmd(dev, AX_ACCESS_MAC, 0x10, 6, 6, buf);
+		debug("asix_get_phy_addr() returning

0x%02x%02x%02x%02x%02x%02x\n",

Quoted 6 lines

drivers/usb/eth/Makefile

Quoted 4 lines
drivers/usb/eth/Makefile +4 -0
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+		}
+	else {
+		}

Uh, this check needs some rework, right ? Also, you want to lint your patches with ./scripts/checkpatch.pl tool before resubmitting.

was OK for ./scripts/checkpatch.pl
but I can change that

Quoted 26 lines
Quoted 13 lines
drivers/usb/eth/Makefile +13 -0
+	return ret;
+}
+
+
+static int asix_read_mac(struct eth_device *eth)
+{
+	struct ueth_data *dev = (struct ueth_data *)eth->priv;
+	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
+
+	if (dev->pusb_dev->descriptor.idProduct == 0x1790) {
+		asix_read_cmd(dev, AX_ACCESS_MAC, 0x10, 6, 6, buf);
+		debug("asix_read_mac() returning 0x%02x%02x%02x%02x%02x%02x\n",
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);

drivers/usb/eth/Makefile

Quoted 10 lines
drivers/usb/eth/Makefile +10 -0
+		memcpy(eth->enetaddr, buf, ETH_ALEN);
+		}
+	return 0;
+}
+
+
+
+static int asix_basic_reset(struct ueth_data *dev)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(u8, buf, 6);

Why does the buffer need to be aligned here ? It's just a buffer that is not used for DMA, no ?

Quoted 3 lines

drivers/usb/eth/Makefile

Quoted 1 line
drivers/usb/eth/Makefile +1 -0
+	u16 *tmp16;

Is it because you were getting unaligned accesses , since when the buffer itself was not aligned and you did cast it to u16, the CPU triggered unaligned access ?

Thats right, if I do not align I get unaligned accesses during USB communication.
Is there a smarter solution for that?

Quoted 2 lines
Quoted 1 line
drivers/usb/eth/Makefile +1 -0
+	u8 *tmp;

[...]

#4 lore raw

PATCH v2 1/2 usb: eth: add ASIX AX88179 DRIVER

Quoted 11 lines · Ren? Griessl

Am 09.09.2014 16:34, schrieb Marek Vasut:

Quoted 9 lines · Rene Griessl
Quoted 5 lines

changes in v2:
-added usb_ether.h to change list
-added 2nd patch to enable driver for arndale board

I see that in Linux, there is asix_common.c stuff. Can this driver share any parts with drivers/net/ax88* ?

Quoted 8 lines

The asix_common.c includes asix.h. There you see that the common driver supports following devices:
AX88172
AX88772
AX88178
but it is not supporting AX88179 and AX88178a, they have a separate driver called ax88179_178a.c
These two have a different style in accessing MAC registers and PHY

I didn't look deep enough. The 88179 driver is a completely separate driver, not sharing any code what-so-ever with the other ASIX driver, yes ?

[...]

Quoted 10 lines
Quoted 7 lines

drivers/usb/eth/asix88179.c line 266

Quoted 4 lines
drivers/usb/eth/asix88179.c new file +4 -0
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+		}
+	else {
+		}

Uh, this check needs some rework, right ? Also, you want to lint your patches with ./scripts/checkpatch.pl tool before resubmitting.

was OK for ./scripts/checkpatch.pl
but I can change that

This is rather surprising, but you're right. Please fix this up, the else can be dropped and the trailing } can be indented just under the if () clause.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/eth/asix88179.c new file +7 -0
+	return ret;
+}
+
+
+static int asix_read_mac(struct eth_device *eth)
+{
+	struct ueth_data *dev = (struct ueth_data *)eth->priv;
Quoted 8 lines
Quoted 8 lines

drivers/usb/eth/asix88179.c line 282

Quoted 8 lines
drivers/usb/eth/asix88179.c new file +8 -0
+	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
+
+	if (dev->pusb_dev->descriptor.idProduct == 0x1790) {
+		asix_read_cmd(dev, AX_ACCESS_MAC, 0x10, 6, 6, buf);
+		debug("asix_read_mac() returning 0x%02x%02x%02x%02x%02x%02x\n",
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+		memcpy(eth->enetaddr, buf, ETH_ALEN);
+		}

Same here.

Quoted 18 lines
Quoted 12 lines

drivers/usb/eth/asix88179.c line 290

Quoted 8 lines
drivers/usb/eth/asix88179.c new file +8 -0
+	return 0;
+}
+
+
+
+static int asix_basic_reset(struct ueth_data *dev)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(u8, buf, 6);

Why does the buffer need to be aligned here ? It's just a buffer that is not used for DMA, no ?

Quoted 5 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	u16 *tmp16;

Is it because you were getting unaligned accesses , since when the buffer itself was not aligned and you did cast it to u16, the CPU triggered unaligned access ?

Quoted 3 lines

Thats right, if I do not align I get unaligned accesses during USB communication.
Is there a smarter solution for that?

Oh I see. The smart solution would be to add bounce buffer into the USB stack, but unless you want to dive into this, this solution would be OK here.

#5 lore raw

PATCH v2 1/2 usb: eth: add ASIX AX88179 DRIVER

Am 10.09.2014 17:00, schrieb Marek Vasut:

Quoted 18 lines · Ren? Griessl
Quoted 9 lines

Am 09.09.2014 16:34, schrieb Marek Vasut:

Quoted 8 lines · Rene Griessl
Quoted 5 lines

changes in v2:
-added usb_ether.h to change list
-added 2nd patch to enable driver for arndale board

I see that in Linux, there is asix_common.c stuff. Can this driver share any parts with drivers/net/ax88* ?

Quoted 8 lines

The asix_common.c includes asix.h. There you see that the common driver supports following devices:
AX88172
AX88772
AX88178
but it is not supporting AX88179 and AX88178a, they have a separate driver called ax88179_178a.c
These two have a different style in accessing MAC registers and PHY

Quoted 2 lines

I didn't look deep enough. The 88179 driver is a completely separate driver, not sharing any code what-so-ever with the other ASIX driver, yes ?

The USB read and write cmd functions are similar and the probe function is the same. So they are
sharing 6% of code.
What do you have in mind? Do you want to build one driver supporting all devices?

Quoted 8 lines

[...]

Quoted 6 lines
Quoted 6 lines

drivers/usb/eth/asix88179.c line 266

Quoted 4 lines
drivers/usb/eth/asix88179.c new file +4 -0
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+		}
+	else {
+		}

Uh, this check needs some rework, right ? Also, you want to lint your patches with ./scripts/checkpatch.pl tool before resubmitting.

Quoted 4 lines
Quoted 2 lines

was OK for ./scripts/checkpatch.pl
but I can change that

This is rather surprising, but you're right. Please fix this up, the else can be dropped and the trailing } can be indented just under the if () clause.

OK

Quoted 32 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/usb/eth/asix88179.c new file +7 -0
+	return ret;
+}
+
+
+static int asix_read_mac(struct eth_device *eth)
+{
+	struct ueth_data *dev = (struct ueth_data *)eth->priv;
Quoted 8 lines
Quoted 8 lines

drivers/usb/eth/asix88179.c line 282

Quoted 8 lines
drivers/usb/eth/asix88179.c new file +8 -0
+	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buf, ETH_ALEN);
+
+	if (dev->pusb_dev->descriptor.idProduct == 0x1790) {
+		asix_read_cmd(dev, AX_ACCESS_MAC, 0x10, 6, 6, buf);
+		debug("asix_read_mac() returning 0x%02x%02x%02x%02x%02x%02x\n",
+		      buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
+		memcpy(eth->enetaddr, buf, ETH_ALEN);
+		}

Same here.

Quoted 15 lines
Quoted 15 lines

drivers/usb/eth/asix88179.c line 290

Quoted 8 lines
drivers/usb/eth/asix88179.c new file +8 -0
+	return 0;
+}
+
+
+
+static int asix_basic_reset(struct ueth_data *dev)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(u8, buf, 6);

Why does the buffer need to be aligned here ? It's just a buffer that is not used for DMA, no ?

Review

Quoted 1 line
(quoted diff) +1 -0
+	u16 *tmp16;

Is it because you were getting unaligned accesses , since when the buffer itself was not aligned and you did cast it to u16, the CPU triggered unaligned access ?

Quoted 5 lines
Quoted 3 lines

Thats right, if I do not align I get unaligned accesses during USB communication.
Is there a smarter solution for that?

Oh I see. The smart solution would be to add bounce buffer into the USB stack, but unless you want to dive into this, this solution would be OK here.

OK, then I will leave it this way.

Signature · 13 lines
--------------------------------------------------------

Dipl.-Ing. Ren? Griessl
Universit?t Bielefeld
AG Kognitronik & Sensorik
Exzellenzcluster Cognitive Interaction Technology (CITEC)
Inspiration 1 (Zehlendorfer Damm 199)
33615 Bielefeld

Telefon : +49 521-106-67362
Fax     : +49 521-106-12348
eMail   : rgriessl at cit-ec.uni-bielefeld.de
Internet: http://www.ks.cit-ec.uni-bielefeld.de/
#6 lore raw

PATCH v2 1/2 usb: eth: add ASIX AX88179 DRIVER

On Thursday, September 11, 2014 at 10:33:57 AM, Ren? Griessl wrote:

[...]

Quoted 9 lines
Quoted 3 lines

I didn't look deep enough. The 88179 driver is a completely separate driver, not sharing any code what-so-ever with the other ASIX driver, yes ?

The USB read and write cmd functions are similar and the probe function is the same. So they are
sharing 6% of code.
What do you have in mind? Do you want to build one driver supporting all devices?

Yes, but if that's not easily doable, just like you point out, then I am fine with two drivers.

Thank you!

[..]

Best regards,
Marek Vasut