Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Fix padding for a full length USB packet in TX:



details:   https://anonhg.NetBSD.org/src/rev/bc14ab7511f1
branches:  trunk
changeset: 448630:bc14ab7511f1
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Feb 06 07:48:33 2019 +0000

description:
Fix padding for a full length USB packet in TX:
- Update boundary length for SS mode, taken from OpenBSD.
- Make sure everything passed to the adapter is little endian.
- Specify padding bits in a similar manner to Linux.

XXX I wonder whether this is really necessary...

diffstat:

 sys/dev/usb/if_axen.c |  37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diffs (63 lines):

diff -r 283c8f81ab8c -r bc14ab7511f1 sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c     Wed Feb 06 07:35:46 2019 +0000
+++ b/sys/dev/usb/if_axen.c     Wed Feb 06 07:48:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axen.c,v 1.27 2019/02/06 07:35:46 rin Exp $ */
+/*     $NetBSD: if_axen.c,v 1.28 2019/02/06 07:48:33 rin Exp $ */
 /*     $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.27 2019/02/06 07:35:46 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.28 2019/02/06 07:48:33 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1277,23 +1277,32 @@
 
        c = &sc->axen_cdata.axen_tx_chain[idx];
 
-       boundary = (sc->axen_udev->ud_speed == USB_SPEED_HIGH) ? 512 : 64;
+       /* XXX Is this need? */
+       switch (sc->axen_udev->ud_speed) {
+       case USB_SPEED_SUPER:
+               boundary = 4096;
+               break;
+       case USB_SPEED_HIGH:
+               boundary = 512;
+               break;
+       default:
+               boundary = 64;
+               break;
+       }
+
+       length = m->m_pkthdr.len + sizeof(hdr);
 
        hdr.plen = htole32(m->m_pkthdr.len);
+
        hdr.gso = 0; /* disable segmentation offloading */
+       if ((length % boundary) == 0) {
+               DPRINTF(("%s: boundary hit\n", device_xname(sc->axen_dev)));
+               hdr.gso |= 0x80008000;  /* XXX enable padding */
+       }
+       hdr.gso = htole32(hdr.gso);
 
        memcpy(c->axen_buf, &hdr, sizeof(hdr));
-       length = sizeof(hdr);
-
-       m_copydata(m, 0, m->m_pkthdr.len, c->axen_buf + length);
-       length += m->m_pkthdr.len;
-
-       if ((length % boundary) == 0) {
-               hdr.plen = 0x0;
-               hdr.gso |= 0x80008000;  /* enable padding */
-               memcpy(c->axen_buf + length, &hdr, sizeof(hdr));
-               length += sizeof(hdr);
-       }
+       m_copydata(m, 0, m->m_pkthdr.len, c->axen_buf + sizeof(hdr));
 
        usbd_setup_xfer(c->axen_xfer, c, c->axen_buf, length,
            USBD_FORCE_SHORT_XFER, 10000, axen_txeof);



Home | Main Index | Thread Index | Old Index