Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb 1) Use ic_curchan consistently
details: https://anonhg.NetBSD.org/src/rev/11af87a98789
branches: trunk
changeset: 784476:11af87a98789
user: christos <christos%NetBSD.org@localhost>
date: Tue Jan 29 13:54:26 2013 +0000
description:
1) Use ic_curchan consistently
2) Ignore frames shorter than sizeof(struct ieee80211_frame).
3) Remove useless/dead code accidentally committed.
diffstat:
sys/dev/usb/if_otus.c | 160 ++++++++--------------------------------------
sys/dev/usb/if_otusvar.h | 8 +--
2 files changed, 30 insertions(+), 138 deletions(-)
diffs (truncated from 320 to 300 lines):
diff -r 69e7af998f00 -r 11af87a98789 sys/dev/usb/if_otus.c
--- a/sys/dev/usb/if_otus.c Tue Jan 29 09:30:11 2013 +0000
+++ b/sys/dev/usb/if_otus.c Tue Jan 29 13:54:26 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_otus.c,v 1.22 2013/01/22 12:40:42 jmcneill Exp $ */
+/* $NetBSD: if_otus.c,v 1.23 2013/01/29 13:54:26 christos Exp $ */
/* $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $ */
/*-
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.22 2013/01/22 12:40:42 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.23 2013/01/29 13:54:26 christos Exp $");
#include <sys/param.h>
#include <sys/sockio.h>
@@ -179,13 +179,6 @@
Static void otus_stop(struct ifnet *);
Static void otus_wait_async(struct otus_softc *);
-#if IEEE80211_INJECTION
-#define IS_INJECTED(m) (((m)->m_flags & M_INJECT) != 0)
-
-static int otus_output(struct ifnet *, struct mbuf *,
- const struct sockaddr *, struct rtentry *);
-#endif /* IEEE80211_INJECTION */
-
/* List of supported channels. */
static const uint8_t ar_chans[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
@@ -872,12 +865,6 @@
ic->ic_delete_key = otus_delete_key;
#endif /* notyet */
-#if IEEE80211_INJECTION
- /* hook our packet injection output routine */
- sc->sc_if_output = ifp->if_output;
- ifp->if_output = otus_output;
-#endif
-
/* Override state transition machine. */
sc->sc_newstate = ic->ic_newstate;
ic->ic_newstate = otus_newstate;
@@ -1381,11 +1368,11 @@
case IEEE80211_S_AUTH:
case IEEE80211_S_ASSOC:
- otus_set_chan(sc, ni->ni_chan, 0);
+ otus_set_chan(sc, ic->ic_curchan, 0);
break;
case IEEE80211_S_RUN:
- otus_set_chan(sc, ni->ni_chan, 1);
+ otus_set_chan(sc, ic->ic_curchan, 1);
switch (ic->ic_opmode) {
case IEEE80211_M_STA:
@@ -1774,12 +1761,16 @@
}
/* Compute MPDU's length. */
mlen = len - AR_PLCP_HDR_LEN - sizeof(*tail);
- /* Make sure there's room for an 802.11 header + FCS. */
- if (__predict_false(mlen < IEEE80211_MIN_LEN)) {
+ mlen -= IEEE80211_CRC_LEN; /* strip 802.11 FCS */
+ /* Make sure there's room for an 802.11 header. */
+ /*
+ * XXX: This will drop most control packets. Do we really
+ * want this in IEEE80211_M_MONITOR mode?
+ */
+ if (__predict_false(mlen < sizeof(*wh))) {
ifp->if_ierrors++;
return;
}
- mlen -= IEEE80211_CRC_LEN; /* strip 802.11 FCS */
/* Provide a 32-bit aligned protocol header to the stack. */
align = (ieee80211_has_qos(wh) ^ ieee80211_has_addr4(wh)) ? 2 : 0;
@@ -1809,8 +1800,8 @@
tap = &sc->sc_rxtap;
tap->wr_flags = 0;
- tap->wr_chan_freq = htole16(ic->ic_ibss_chan->ic_freq);
- tap->wr_chan_flags = htole16(ic->ic_ibss_chan->ic_flags);
+ tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq);
+ tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags);
tap->wr_antsignal = tail->rssi;
tap->wr_rate = 2; /* In case it can't be found below. */
switch (tail->status & AR_RX_STATUS_MT_MASK) {
@@ -1949,9 +1940,6 @@
otus_tx(struct otus_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
struct otus_tx_data *data)
{
-#if IEEE80211_INJECTION
- struct ieee80211_bpf_params *params;
-#endif
struct ieee80211com *ic;
struct otus_node *on;
struct ieee80211_frame *wh;
@@ -1967,16 +1955,8 @@
ic = &sc->sc_ic;
on = (void *)ni;
-#if IEEE80211_INJECTION
- params = ieee80211_bpf_params(m);
-#endif
-
wh = mtod(m, struct ieee80211_frame *);
- if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
-#if IEEE80211_INJECTION
- && !IS_INJECTED(m)
-#endif
- ) {
+ if ((wh->i_fc[1] & IEEE80211_FC1_PROTECTED)) {
/* XXX: derived from upgt_tx_task() and ural_tx_data() */
k = ieee80211_crypto_encap(ic, ni, m);
if (k == NULL)
@@ -2042,38 +2022,6 @@
phyctl |= AR_TX_PHY_ANTMSK(sc->sc_txmask);
}
-#if IEEE80211_INJECTION
- if (params) {
- if (params->ibp_flags & IEEE80211_BPF_NOACK)
- macctl |= AR_TX_MAC_NOACK;
-
- if (params->ibp_flags & IEEE80211_BPF_CTS) {
- macctl &= ~AR_TX_MAC_RTS;
- macctl |= AR_TX_MAC_CTS;
- }
- else if (params->ibp_flags & IEEE80211_BPF_RTS) {
- macctl &= ~AR_TX_MAC_CTS;
- macctl |= AR_TX_MAC_RTS;
- }
- if (params->ibp_flags & IEEE80211_BPF_FCS) {
-// otus_write(sc, AR_MAC_REG_FCS_SELECT, AR_MAC_FCS_SWFCS);
- }
-#if 0 /* XXX: TODO */
- if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
- if (params->ibp_flags & IEEE80211_BPF_CRYPTO)
- if (params->ibp_flags & IEEE80211_BPF_DATAPAD)
-
-#define IEEE80211_BPF_SHORTPRE 0x01 /* tx with short preamble */
-#define IEEE80211_BPF_NOACK 0x02 /* tx with no ack */
-#define IEEE80211_BPF_CRYPTO 0x04 /* tx with h/w encryption */
-#define IEEE80211_BPF_FCS 0x10 /* frame includes FCS */
-#define IEEE80211_BPF_DATAPAD 0x20 /* frame includes data padding */
-#define IEEE80211_BPF_RTS 0x40 /* tx with RTS/CTS */
-#define IEEE80211_BPF_CTS 0x80 /* tx with CTS only */
-#endif /* XXX: TODO */
- }
-#endif /* IEEE80211_INJECTION */
-
/* Update rate control stats for frames that are ACK'ed. */
if (!(macctl & AR_TX_MAC_NOACK))
on->amn.amn_txcnt++;
@@ -2088,9 +2036,11 @@
struct otus_tx_radiotap_header *tap = &sc->sc_txtap;
tap->wt_flags = 0;
+ if (wh->i_fc[1] & IEEE80211_FC1_WEP)
+ tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
tap->wt_rate = otus_rates[ridx].rate;
- tap->wt_chan_freq = htole16(ic->ic_bss->ni_chan->ic_freq);
- tap->wt_chan_flags = htole16(ic->ic_bss->ni_chan->ic_flags);
+ tap->wt_chan_freq = htole16(ic->ic_curchan->ic_freq);
+ tap->wt_chan_flags = htole16(ic->ic_curchan->ic_flags);
bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m);
}
@@ -2141,28 +2091,21 @@
* later. Both must be done inside a single lock.
*/
mutex_enter(&sc->sc_tx_mtx);
- if (data == NULL) {
+ if (data == NULL && !TAILQ_EMPTY(&sc->sc_tx_free_list)) {
data = TAILQ_FIRST(&sc->sc_tx_free_list);
- if (data == NULL) {
- mutex_exit(&sc->sc_tx_mtx);
- /*
- * No data buffers are available. Set
- * the IFF_OACTIVE bit and bail
- * immediately. otus_txeof() will
- * release this bit when it releases a
- * buffer and restarts otus_start().
- */
- ifp->if_flags |= IFF_OACTIVE;
- DPRINTFN(DBG_TX, sc, "empty sc_tx_free_list\n");
- return;
- }
TAILQ_REMOVE(&sc->sc_tx_free_list, data, next);
}
+ mutex_exit(&sc->sc_tx_mtx);
+
+ if (data == NULL) {
+ ifp->if_flags |= IFF_OACTIVE;
+ DPRINTFN(DBG_TX, sc, "empty sc_tx_free_list\n");
+ return;
+ }
/* Send pending management frames first. */
IF_DEQUEUE(&ic->ic_mgtq, m);
if (m != NULL) {
- mutex_exit(&sc->sc_tx_mtx);
ni = (void *)m->m_pkthdr.rcvif;
m->m_pkthdr.rcvif = NULL;
goto sendit;
@@ -2176,8 +2119,6 @@
if (m == NULL)
break;
- mutex_exit(&sc->sc_tx_mtx);
-
if (m->m_len < (int)sizeof(*eh) &&
(m = m_pullup(m, sizeof(*eh))) == NULL) {
ifp->if_oerrors++;
@@ -2221,6 +2162,7 @@
* If here, we have a Tx buffer, but ran out of mbufs to
* transmit. Put the Tx buffer back to the free list.
*/
+ mutex_enter(&sc->sc_tx_mtx);
TAILQ_INSERT_TAIL(&sc->sc_tx_free_list, data, next);
mutex_exit(&sc->sc_tx_mtx);
}
@@ -2246,25 +2188,6 @@
ifp->if_timer = 1;
}
ieee80211_watchdog(&sc->sc_ic);
-
-#if 0
- /* XXX: should we be doing something like this? */
- struct url_chain *c;
- usbd_status stat;
- int s;
-
- ifp->if_oerrors++;
- printf("%s: watchdog timeout\n", device_xname(sc->sc_dev));
-
- s = splusb();
- c = &sc->sc_cdata.url_tx_chain[0];
- usbd_get_xfer_status(c->url_xfer, NULL, NULL, NULL, &stat);
- url_txeof(c->url_xfer, c, stat);
-
- if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
- url_start(ifp);
- splx(s);
-#endif
}
Static int
@@ -2346,7 +2269,7 @@
if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) ==
(IFF_UP | IFF_RUNNING)) {
mutex_enter(&sc->sc_write_mtx);
- otus_set_chan(sc, ic->ic_ibss_chan, 0);
+ otus_set_chan(sc, ic->ic_curchan, 0);
mutex_exit(&sc->sc_write_mtx);
}
error = 0;
@@ -3291,8 +3214,7 @@
(void)otus_write_barrier(sc);
sc->sc_bb_reset = 1; /* Force cold reset. */
- ic->ic_bss->ni_chan = ic->ic_ibss_chan;
- if ((error = otus_set_chan(sc, ic->ic_ibss_chan, 0)) != 0) {
+ if ((error = otus_set_chan(sc, ic->ic_curchan, 0)) != 0) {
mutex_exit(&sc->sc_write_mtx);
aprint_error_dev(sc->sc_dev, "could not set channel\n");
return error;
@@ -3345,27 +3267,3 @@
(void)otus_write_barrier(sc);
mutex_exit(&sc->sc_write_mtx);
}
-
-#if IEEE80211_INJECTION
-static int
-otus_output(struct ifnet *ifp, struct mbuf *m,
- const struct sockaddr *dst, struct rtentry *rt)
-{
- struct otus_softc *sc;
- struct ieee80211com *ic;
-
- sc = ifp->if_softc;
-
- DPRINTFN(DBG_FN, sc, "\n");
-
- ic = &sc->sc_ic;
-
- /*
- * Hand to the 802.3 code if not tagged as a raw 802.11 frame.
- */
- if (dst->sa_family != AF_IEEE80211)
- return sc->sc_if_output(ifp, m, dst, rt);
-
- return ieee80211_output(ifp, m, dst, ic);
-}
-#endif /* IEEE80211_INJECTION */
diff -r 69e7af998f00 -r 11af87a98789 sys/dev/usb/if_otusvar.h
--- a/sys/dev/usb/if_otusvar.h Tue Jan 29 09:30:11 2013 +0000
Home |
Main Index |
Thread Index |
Old Index