tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: axen



Nick Hudson <nick.hudson%gmx.co.uk@localhost> wrote:
>On 04/08/2023 18:52, Robert Swindells wrote:
>>
>> Has anyone used axen(4) recently?
>>
>> I needed to make some changes to get it to work for a USB-C Ethernet
>> adapter but would like to know if the driver in the tree works for any
>> older devices.
>
> thunderx# dmesg | egrep "(NetBSD 10|axen)"
> [     1.000000] NetBSD 10.99.4 (GENERIC64) #138: Thu Apr 27 18:33:42 BST
> 2023
> [     4.320147] axen0 at uhub6 port 3
> [     4.320147] axen0: ASIX Elec. Corp. (0x0b95) AX88179 (0x1790), rev
> 3.00/1.00, addr 4
> [     4.819877] axen0: AX88179
> [     4.819877] rgephy0 at axen0 phy 3: RTL8211E 1000BASE-T media interface
> [     4.889879] axen0: Ethernet address 00:13:3b:79:92:71
> thunderx#

What kind of USB port is that connected to?

The driver currently defaults to the smallest buffer size if the device
is on a speed 5 (USB_SPEED_SUPER_PLUS) port.

The diffs that I'm using are attached, can try moving the check in #if 0
to after the check for 'pkt_len == 0'.

It doesn't work for me at all without the change to the length argument
to usbnet_enqueue().

Index: if_axen.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/if_axen.c,v
retrieving revision 1.94
diff -u -r1.94 if_axen.c
--- if_axen.c	20 Aug 2022 14:08:59 -0000	1.94
+++ if_axen.c	7 Aug 2023 20:58:37 -0000
@@ -614,6 +614,7 @@
 
 	/* decide on what our bufsize will be */
 	switch (dev->ud_speed) {
+	case USB_SPEED_SUPER_PLUS:
 	case USB_SPEED_SUPER:
 		un->un_rx_bufsz = AXEN_BUFSZ_SS * 1024;
 		break;
@@ -759,6 +760,9 @@
 	hdr_offset = (uint16_t)(rx_hdr >> 16);
 	pkt_count  = (uint16_t)(rx_hdr & 0xffff);
 
+	if (pkt_count == 0)
+		return;
+
 	/* sanity check */
 	if (hdr_offset > total_len) {
 		aprint_error_dev(un->un_dev,
@@ -790,15 +794,20 @@
 		rnd_add_uint32(usbnet_rndsrc(un), pkt_count);
 
 	do {
+#if 0
 		if ((buf[0] != 0xee) || (buf[1] != 0xee)) {
 			aprint_error_dev(un->un_dev,
 			    "invalid buffer(pkt#%d), continue\n", pkt_count);
 			if_statadd(ifp, if_ierrors, pkt_count);
 			return;
 		}
-
+#endif
 		pkt_hdr = le32toh(*hdr_p);
 		pkt_len = (pkt_hdr >> 16) & 0x1fff;
+
+		if (pkt_len == 0)
+			goto nextpkt;
+
 		DPRINTFN(10,
 		    ("%s: rxeof: packet#%d, pkt_hdr 0x%08x, pkt_len %zu\n",
 		   device_xname(un->un_dev), pkt_count, pkt_hdr, pkt_len));
@@ -813,7 +822,7 @@
 			goto nextpkt;
 		}
 
-		usbnet_enqueue(un, buf + ETHER_ALIGN, pkt_len - 6,
+		usbnet_enqueue(un, buf + ETHER_ALIGN, pkt_len - 2,
 			       axen_csum_flags_rx(ifp, pkt_hdr), 0, 0);
 
 nextpkt:


Home | Main Index | Thread Index | Old Index