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.
This commit is contained in:
parent
e02e924c76
commit
0866194cab
@ -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
|
||||
|
@ -133,8 +133,9 @@ rtwn_usb_alloc_rx_list(struct rtwn_softc *sc)
|
||||
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);
|
||||
|
||||
|
@ -63,7 +63,6 @@ static struct usb_config rtwn_config[RTWN_N_TRANSFER] = {
|
||||
.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_softc *uc)
|
||||
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) {
|
||||
|
@ -158,8 +158,12 @@ rtwn_rxeof(struct rtwn_softc *sc, uint8_t *buf, int len)
|
||||
|
||||
/* 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);
|
||||
|
Loading…
Reference in New Issue
Block a user