Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev/pci Adapt to common bpf/radiotap handling in n...
details: https://anonhg.NetBSD.org/src-all/rev/414b4086a674
branches: trunk
changeset: 360326:414b4086a674
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Sun Jun 06 14:44:56 2021 +0200
description:
Adapt to common bpf/radiotap handling in new ieee80211 stack
diffstat:
sys/dev/pci/if_iwm.c | 66 +++++++++++-------------------------------------
sys/dev/pci/if_iwmvar.h | 2 -
sys/dev/pci/if_iwn.c | 61 ++++++++------------------------------------
sys/dev/pci/if_iwnvar.h | 2 -
4 files changed, 27 insertions(+), 104 deletions(-)
diffs (263 lines):
diff -r 1005393c7420 -r 414b4086a674 sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c Sun Jun 06 14:30:17 2021 +0200
+++ b/sys/dev/pci/if_iwm.c Sun Jun 06 14:44:56 2021 +0200
@@ -513,7 +513,6 @@
static void iwm_init_task(void *);
static void iwm_wakeup(struct iwm_softc *);
#endif
-static void iwm_radiotap_attach(struct iwm_softc *, struct ifnet *);
static int iwm_sysctl_fw_loaded_handler(SYSCTLFN_PROTO);
static int iwm_sysctl_root_num;
@@ -4086,7 +4085,7 @@
if (le32toh(phy_info->channel) < __arraycount(ic->ic_channels))
c = &ic->ic_channels[le32toh(phy_info->channel)];
- if (__predict_false(sc->sc_drvbpf != NULL)) {
+ if (__predict_false(ic->ic_flags_ext & IEEE80211_FEXT_BPF)) {
struct iwm_rx_radiotap_header *tap = &sc->sc_rxtap;
tap->wr_flags = 0;
@@ -4127,8 +4126,6 @@
default: tap->wr_rate = 0;
}
}
-
- bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m, BPF_D_IN);
}
ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
@@ -4749,7 +4746,6 @@
struct ieee80211_frame *wh;
struct ieee80211_key *k = NULL;
struct mbuf *m1;
- const struct iwm_rate *rinfo;
uint32_t flags;
u_int hdrlen;
bus_dma_segment_t *seg;
@@ -4779,29 +4775,7 @@
tx = (void *)cmd->data;
memset(tx, 0, sizeof(*tx));
- rinfo = iwm_tx_fill_cmd(sc, in, wh, tx);
-
- if (__predict_false(sc->sc_drvbpf != NULL)) {
- struct iwm_tx_radiotap_header *tap = &sc->sc_txtap;
-
- tap->wt_flags = 0;
- tap->wt_chan_freq = htole16(ni->ni_chan->ic_freq);
- tap->wt_chan_flags = htole16(ni->ni_chan->ic_flags);
-#ifndef IEEE80211_NO_HT
- if ((ni->ni_flags & IEEE80211_NODE_HT) &&
- !IEEE80211_IS_MULTICAST(wh->i_addr1) &&
- type == IEEE80211_FC0_TYPE_DATA &&
- rinfo->plcp == IWM_RATE_INVM_PLCP) {
- tap->wt_rate = (0x80 | rinfo->ht_plcp);
- } else
-#endif
- tap->wt_rate = rinfo->rate;
- tap->wt_hwqueue = ac;
- if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
- tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
-
- bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m, BPF_D_OUT);
- }
+ iwm_tx_fill_cmd(sc, in, wh, tx);
/* Encrypt the frame if need be. */
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
@@ -8280,6 +8254,19 @@
panic("%s: could not create workqueue: htprot",
device_xname(self));
#endif
+
+ sc->sc_rxtap_len = sizeof sc->sc_rxtapu;
+ sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
+ sc->sc_rxtap.wr_ihdr.it_present = htole32(IWM_RX_RADIOTAP_PRESENT);
+
+ sc->sc_txtap_len = sizeof sc->sc_txtapu;
+ sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
+ sc->sc_txtap.wt_ihdr.it_present = htole32(IWM_TX_RADIOTAP_PRESENT);
+
+ /* let the stack know we support radiotap */
+ ic->ic_rh = &sc->sc_rxtapu.th.wr_ihdr;
+ ic->ic_th = &sc->sc_txtapu.th.wt_ihdr;
+
sc->sc_flags |= IWM_FLAG_STOPPED;
ieee80211_announce(ic);
@@ -8400,13 +8387,6 @@
ic->ic_opmode = opmode;
sc->sc_des_esslen = 0;
- /*
- * XXX is this good enough at attach time?
- * How doe we handle detach?
- */
- if (opmode == IEEE80211_M_MONITOR && ic->ic_montaps > 0)
- iwm_radiotap_attach(sc, vap->vap.iv_ifp);
-
return &vap->vap;
}
@@ -8516,22 +8496,6 @@
#endif
}
-static void
-iwm_radiotap_attach(struct iwm_softc *sc, struct ifnet *ifp)
-{
- bpf_attach2(ifp, DLT_IEEE802_11_RADIO,
- sizeof (struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
- &sc->sc_drvbpf);
-
- sc->sc_rxtap_len = sizeof sc->sc_rxtapu;
- sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
- sc->sc_rxtap.wr_ihdr.it_present = htole32(IWM_RX_RADIOTAP_PRESENT);
-
- sc->sc_txtap_len = sizeof sc->sc_txtapu;
- sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
- sc->sc_txtap.wt_ihdr.it_present = htole32(IWM_TX_RADIOTAP_PRESENT);
-}
-
#if 0
static void
iwm_init_task(void *arg)
diff -r 1005393c7420 -r 414b4086a674 sys/dev/pci/if_iwmvar.h
--- a/sys/dev/pci/if_iwmvar.h Sun Jun 06 14:30:17 2021 +0200
+++ b/sys/dev/pci/if_iwmvar.h Sun Jun 06 14:44:56 2021 +0200
@@ -503,8 +503,6 @@
struct sysctllog *sc_clog;
- struct bpf_if *sc_drvbpf;
-
/* XXX */
kmutex_t sc_media_mtx __aligned(CACHE_LINE_SIZE);
/* hardware and softc */
diff -r 1005393c7420 -r 414b4086a674 sys/dev/pci/if_iwn.c
--- a/sys/dev/pci/if_iwn.c Sun Jun 06 14:30:17 2021 +0200
+++ b/sys/dev/pci/if_iwn.c Sun Jun 06 14:44:56 2021 +0200
@@ -214,7 +214,6 @@
static int iwn_config_complete(device_t);
static int iwn4965_attach(struct iwn_softc *, pci_product_id_t);
static int iwn5000_attach(struct iwn_softc *, pci_product_id_t);
-static void iwn_radiotap_attach(struct iwn_softc *, struct ifnet *);
static int iwn_detach(device_t , int);
#if 0
static void iwn_power(int, void *);
@@ -804,8 +803,16 @@
sc->amrr.amrr_min_success_threshold = 1;
sc->amrr.amrr_max_success_threshold = 15;
- /* Use common softint-based if_input */
- /* XXX NetBSD add call to ieee80211_announce for dmesg. */
+ /* Setup radiotap */
+ sc->sc_rxtap_len = sizeof sc->sc_rxtapu;
+ sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
+ sc->sc_rxtap.wr_ihdr.it_present = htole32(IWN_RX_RADIOTAP_PRESENT);
+
+ sc->sc_txtap_len = sizeof sc->sc_txtapu;
+ sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
+ sc->sc_txtap.wt_ihdr.it_present = htole32(IWN_TX_RADIOTAP_PRESENT);
+ ic->ic_rh = &sc->sc_rxtapu.th.wr_ihdr;
+ ic->ic_th = &sc->sc_txtapu.th.wt_ihdr;
sc->sc_flags |= IWN_FLAG_ATTACHED;
@@ -1016,17 +1023,7 @@
sc->sc_newstate = vap->iv_newstate;
vap->iv_newstate = iwn_newstate;
-#if 0
- /* Attach the packet filter */
- bpf_attach2(vap->iv_ifp, DLT_IEEE802_11_RADIO,
- sizeof(struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
- &sc->sc_drvbpf);
-#endif
-
ieee80211_init(ifp);
-
- iwn_radiotap_attach(sc, vap->iv_ifp);
-
return vap;
}
@@ -1191,25 +1188,6 @@
return 0;
}
-/*
- * Attach the interface to 802.11 radiotap.
- */
-static void
-iwn_radiotap_attach(struct iwn_softc *sc, struct ifnet *ifp)
-{
- bpf_attach2(ifp, DLT_IEEE802_11_RADIO,
- sizeof (struct ieee80211_frame) + IEEE80211_RADIOTAP_HDRLEN,
- &sc->sc_drvbpf);
-
- sc->sc_rxtap_len = sizeof sc->sc_rxtapu;
- sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);
- sc->sc_rxtap.wr_ihdr.it_present = htole32(IWN_RX_RADIOTAP_PRESENT);
-
- sc->sc_txtap_len = sizeof sc->sc_txtapu;
- sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);
- sc->sc_txtap.wt_ihdr.it_present = htole32(IWN_TX_RADIOTAP_PRESENT);
-}
-
static int
iwn_detach(device_t self, int flags __unused)
{
@@ -2546,7 +2524,8 @@
iwn_fix_channel(ic, m, stat);
#endif
- if (sc->sc_drvbpf != NULL) {
+ /* update radiotap data if needed */
+ if (__predict_false(ic->ic_flags_ext & IEEE80211_FEXT_BPF)) {
struct iwn_rx_radiotap_header *tap = &sc->sc_rxtap;
tap->wr_flags = 0;
@@ -2577,8 +2556,6 @@
/* Unknown rate: should not happen. */
default: tap->wr_rate = 0;
}
-
- bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m, BPF_D_IN);
}
/*
@@ -3465,20 +3442,6 @@
#endif
rinfo = &iwn_rates[ridx];
- if (sc->sc_drvbpf != NULL) {
- struct iwn_tx_radiotap_header *tap = &sc->sc_txtap;
-
- tap->wt_flags = 0;
- tap->wt_chan_freq = htole16(ni->ni_chan->ic_freq);
- tap->wt_chan_flags = htole16(ni->ni_chan->ic_flags);
- tap->wt_rate = rinfo->rate;
- tap->wt_hwqueue = ac;
- if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
- tap->wt_flags |= IEEE80211_RADIOTAP_F_WEP;
-
- bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_txtap_len, m, BPF_D_OUT);
- }
-
/* Encrypt the frame if need be. */
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
k = ieee80211_crypto_encap(ni, m);
diff -r 1005393c7420 -r 414b4086a674 sys/dev/pci/if_iwnvar.h
--- a/sys/dev/pci/if_iwnvar.h Sun Jun 06 14:30:17 2021 +0200
+++ b/sys/dev/pci/if_iwnvar.h Sun Jun 06 14:44:56 2021 +0200
@@ -321,8 +321,6 @@
int sc_tx_timer;
void *powerhook;
- struct bpf_if * sc_drvbpf;
-
kmutex_t sc_media_mtx; /* XXX */
union {
Home |
Main Index |
Thread Index |
Old Index