NetBSD-Bugs archive

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

kern/49659: axen patch



>Number:         49659
>Category:       kern
>Synopsis:       axen patch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 12 12:20:00 +0000 2015
>Originator:     Takahiro HAYASHI
>Release:        NetBSD 7.99.4
>Organization:
>Environment:
System: NetBSD 7.99.4 amd64
Architecture: x86_64
Machine: amd64
>Description:
1)
Each packet in RX transaction seem to have 4 extra trailing bytes,
so the actual length of each packet is pkt_len - 2(0xeeee header) - 4.
This eliminates 'discarding oversize frame' messages.
Hint from FreeBSD axge code.

2)
Calculate size of buffer in case of USB_SPEED_SUPER too.
This reduces 'crc err', 'invalid buffer', and 'Too many packets' messages.

>How-To-Repeat:

>Fix:
Here is the patch.

--- src/sys/dev/usb/if_axen.c.orig	2014-08-11 15:54:27.000000000 +0900
+++ src/sys/dev/usb/if_axen.c	2015-02-12 18:38:26.000000000 +0900
@@ -688,10 +758,17 @@ axen_attach(device_t parent, device_t se
  
  	id = usbd_get_interface_descriptor(sc->axen_iface);
  
-	/* XXX fix when USB3.0 HC is supported */
  	/* decide on what our bufsize will be */
-	sc->axen_bufsz = (sc->axen_udev->speed == USB_SPEED_HIGH) ?
-	    AXEN_BUFSZ_HS * 1024 : AXEN_BUFSZ_LS * 1024;
+	switch (sc->axen_udev->speed) {
+	case USB_SPEED_SUPER:
+		sc->axen_bufsz = AXEN_BUFSZ_SS * 1024;
+		break;
+	case USB_SPEED_HIGH:
+		sc->axen_bufsz = AXEN_BUFSZ_HS * 1024;
+		break;
+	default:
+		sc->axen_bufsz = AXEN_BUFSZ_LS * 1024;
+	}
  
  	/* Find endpoints. */
  	for (i = 0; i < id->bNumEndpoints; i++) {
@@ -1071,7 +1167,7 @@ axen_rxeof(usbd_xfer_handle xfer, usbd_p
  		/* skip pseudo header (2byte) */
  		ifp->if_ipackets++;
  		m->m_pkthdr.rcvif = ifp;
-		m->m_pkthdr.len = m->m_len = pkt_len - 2;
+		m->m_pkthdr.len = m->m_len = pkt_len - 6;
  
  #ifdef AXEN_TOE
  		/* cheksum err */
@@ -1094,7 +1193,7 @@ axen_rxeof(usbd_xfer_handle xfer, usbd_p
  		}
  #endif
  
-		memcpy(mtod(m, char *), buf + 2, pkt_len - 2);
+		memcpy(mtod(m, char *), buf + 2, pkt_len - 6);
  
  		/* push the packet up */
  		s = splnet();

-- 
t-hash



Home | Main Index | Thread Index | Old Index