svn commit: r311707 - in head/sys/dev/rtwn: . usb
Andriy Voskoboinyk
avos at FreeBSD.org
Sun Jan 8 23:41:19 UTC 2017
Author: avos
Date: Sun Jan 8 23:41:17 2017
New Revision: 311707
URL: https://svnweb.freebsd.org/changeset/base/311707
Log:
rtwn_usb(4): fix Rx buffer size calculation.
Use device-specific Rx buffer size to ensure that data will not be
truncated + add a warning if truncation was detected (the driver
cannot handle this case correctly yet).
Tested with:
- RTL8188CUS, RTL8188EU and RTL8821AU, STA / AP modes.
Modified:
head/sys/dev/rtwn/if_rtwnvar.h
head/sys/dev/rtwn/usb/rtwn_usb_attach.c
head/sys/dev/rtwn/usb/rtwn_usb_ep.c
head/sys/dev/rtwn/usb/rtwn_usb_rx.c
Modified: head/sys/dev/rtwn/if_rtwnvar.h
==============================================================================
--- head/sys/dev/rtwn/if_rtwnvar.h Sun Jan 8 23:25:46 2017 (r311706)
+++ head/sys/dev/rtwn/if_rtwnvar.h Sun Jan 8 23:41:17 2017 (r311707)
@@ -25,7 +25,6 @@
#define RTWN_TX_DESC_SIZE 64
-#define RTWN_RXBUFSZ (8 * 1024)
#define RTWN_TXBUFSZ (16 * 1024)
#define RTWN_BCN_MAX_SIZE 512
Modified: head/sys/dev/rtwn/usb/rtwn_usb_attach.c
==============================================================================
--- head/sys/dev/rtwn/usb/rtwn_usb_attach.c Sun Jan 8 23:25:46 2017 (r311706)
+++ head/sys/dev/rtwn/usb/rtwn_usb_attach.c Sun Jan 8 23:41:17 2017 (r311707)
@@ -133,8 +133,9 @@ rtwn_usb_alloc_rx_list(struct rtwn_softc
struct rtwn_usb_softc *uc = RTWN_USB_SOFTC(sc);
int error, i;
+ /* XXX recheck */
error = rtwn_usb_alloc_list(sc, uc->uc_rx, RTWN_USB_RX_LIST_COUNT,
- RTWN_RXBUFSZ);
+ sc->rx_dma_size + 1024);
if (error != 0)
return (error);
Modified: head/sys/dev/rtwn/usb/rtwn_usb_ep.c
==============================================================================
--- head/sys/dev/rtwn/usb/rtwn_usb_ep.c Sun Jan 8 23:25:46 2017 (r311706)
+++ head/sys/dev/rtwn/usb/rtwn_usb_ep.c Sun Jan 8 23:41:17 2017 (r311707)
@@ -63,7 +63,6 @@ static struct usb_config rtwn_config[RTW
.type = UE_BULK,
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_IN,
- .bufsize = RTWN_RXBUFSZ,
.flags = {
.pipe_bof = 1,
.short_xfer_ok = 1
@@ -222,6 +221,7 @@ rtwn_usb_setup_endpoints(struct rtwn_usb
break;
}
+ rtwn_config[RTWN_BULK_RX].bufsize = sc->rx_dma_size + 1024;
error = usbd_transfer_setup(uc->uc_udev, &iface_index,
uc->uc_xfer, rtwn_config, RTWN_N_TRANSFER, uc, &sc->sc_mtx);
if (error) {
Modified: head/sys/dev/rtwn/usb/rtwn_usb_rx.c
==============================================================================
--- head/sys/dev/rtwn/usb/rtwn_usb_rx.c Sun Jan 8 23:25:46 2017 (r311706)
+++ head/sys/dev/rtwn/usb/rtwn_usb_rx.c Sun Jan 8 23:41:17 2017 (r311707)
@@ -158,8 +158,12 @@ rtwn_rxeof(struct rtwn_softc *sc, uint8_
/* Make sure everything fits in xfer. */
totlen = sizeof(*stat) + infosz + pktlen;
- if (totlen > len)
+ if (totlen > len) {
+ device_printf(sc->sc_dev,
+ "%s: totlen (%d) > len (%d)!\n",
+ __func__, totlen, len);
break;
+ }
if (m0 == NULL)
m0 = m = rtwn_rx_copy_to_mbuf(sc, stat, totlen);
More information about the svn-src-all
mailing list