diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2008-08-27 09:49:33 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2008-08-27 09:49:33 +0000 |
commit | 89faf5dff1932cbf69406d4487d7655e4c5a9c8b (patch) | |
tree | 52a09623b55e5365bd66c16a3b669946d93f891e /sys/dev/usb | |
parent | b10b91a5b2a3c0ec7fb99ae48a404b60b6e32ebe (diff) |
hardware may pass us ACK or CTS frames in some cases, so use
IEEE80211_ACK_LEN instead of IEEE80211_MIN_LEN for ZYD_MIN_RXBUFSZ
and ZYD_MIN_FRAGSZ.
silence some warnings while i'm there.
change ZYD_FILTER_BSS to use the same value as the vendor's driver
that contains some magic (undocumented) bits.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/if_zyd.c | 34 | ||||
-rw-r--r-- | sys/dev/usb/if_zydreg.h | 11 |
2 files changed, 24 insertions, 21 deletions
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index a19985d687f..cc1a3c30a1c 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zyd.c,v 1.70 2008/08/27 09:05:03 damien Exp $ */ +/* $OpenBSD: if_zyd.c,v 1.71 2008/08/27 09:49:32 damien Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -1905,18 +1905,16 @@ zyd_rx_data(struct zyd_softc *sc, const uint8_t *buf, uint16_t len) const struct zyd_plcphdr *plcp; const struct zyd_rx_stat *stat; struct mbuf *m; - int rlen, s; + int s; if (len < ZYD_MIN_FRAGSZ) { - printf("%s: frame too short (length=%d)\n", - sc->sc_dev.dv_xname, len); + DPRINTFN(2, ("frame too short (length=%d)\n", len)); ifp->if_ierrors++; return; } plcp = (const struct zyd_plcphdr *)buf; - stat = (const struct zyd_rx_stat *) - (buf + len - sizeof (struct zyd_rx_stat)); + stat = (const struct zyd_rx_stat *)(buf + len - sizeof (*stat)); if (stat->flags & ZYD_RX_ERROR) { DPRINTF(("%s: RX status indicated error (%x)\n", @@ -1926,30 +1924,31 @@ zyd_rx_data(struct zyd_softc *sc, const uint8_t *buf, uint16_t len) } /* compute actual frame length */ - rlen = len - sizeof (struct zyd_plcphdr) - - sizeof (struct zyd_rx_stat) - IEEE80211_CRC_LEN; + len -= sizeof (*plcp) - sizeof (*stat) - IEEE80211_CRC_LEN; + + if (len > MCLBYTES) { + DPRINTFN(2, ("frame too large (length=%d)\n", len)); + ifp->if_ierrors++; + return; + } /* allocate a mbuf to store the frame */ MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { - printf("%s: could not allocate rx mbuf\n", - sc->sc_dev.dv_xname); ifp->if_ierrors++; return; } - if (rlen > MHLEN) { + if (len > MHLEN) { MCLGET(m, M_DONTWAIT); if (!(m->m_flags & M_EXT)) { - printf("%s: could not allocate rx mbuf cluster\n", - sc->sc_dev.dv_xname); - m_freem(m); ifp->if_ierrors++; + m_freem(m); return; } } + bcopy(plcp + 1, mtod(m, caddr_t), len); m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = m->m_len = rlen; - bcopy((const uint8_t *)(plcp + 1), mtod(m, uint8_t *), rlen); + m->m_pkthdr.len = m->m_len = len; #if NBPFILTER > 0 if (sc->sc_drvbpf != NULL) { @@ -2013,8 +2012,7 @@ zyd_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL); if (len < ZYD_MIN_RXBUFSZ) { - printf("%s: xfer too short (length=%d)\n", - sc->sc_dev.dv_xname, len); + DPRINTFN(2, ("xfer too short (length=%d)\n", len)); ifp->if_ierrors++; goto skip; } diff --git a/sys/dev/usb/if_zydreg.h b/sys/dev/usb/if_zydreg.h index 570265d1bcf..82aa3de5467 100644 --- a/sys/dev/usb/if_zydreg.h +++ b/sys/dev/usb/if_zydreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zydreg.h,v 1.22 2007/11/27 20:30:14 damien Exp $ */ +/* $OpenBSD: if_zydreg.h,v 1.23 2008/08/27 09:49:32 damien Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -947,11 +947,16 @@ #define ZYD_FILTER_CFE_A (1 << 31) /* helpers for register ZYD_MAC_RXFILTER */ -#define ZYD_FILTER_MONITOR 0xffffffff +#define ZYD_FILTER_MONITOR 0x000fffff +#if 1 +/* magic from the vendor's driver */ +#define ZYD_FILTER_BSS 0x2400ffff +#else #define ZYD_FILTER_BSS \ (ZYD_FILTER_ASS_RSP | ZYD_FILTER_REASS_RSP | \ ZYD_FILTER_PRB_RSP | ZYD_FILTER_BCN | ZYD_FILTER_DEASS | \ ZYD_FILTER_AUTH | ZYD_FILTER_DEAUTH) +#endif #define ZYD_FILTER_HOSTAP \ (ZYD_FILTER_ASS_REQ | ZYD_FILTER_REASS_REQ | \ ZYD_FILTER_PRB_REQ | ZYD_FILTER_DEASS | ZYD_FILTER_AUTH | \ @@ -1078,7 +1083,7 @@ struct zyd_notif_retry { (sizeof (struct zyd_tx_desc) + IEEE80211_MAX_LEN) #define ZYD_MIN_FRAGSZ \ - (sizeof (struct zyd_plcphdr) + IEEE80211_MIN_LEN + \ + (sizeof (struct zyd_plcphdr) + IEEE80211_ACK_LEN + \ sizeof (struct zyd_rx_stat)) #define ZYD_MIN_RXBUFSZ ZYD_MIN_FRAGSZ #define ZYX_MAX_RXBUFSZ \ |