Hi,

This patch will allow urtwn(4) to see control frames when monitor mode
is enabled.  I've only tested this with my TP-LINK TL-WN821N v5 card, so
perhaps more checks are needed to avoid breaking other cards.

If you test this, enable monitor mode:

        $ doas ifconfig urtwn0 mediaopt monitor up

Check with tcpdump if you receive any control frames (ack, rts, cts):

        $ doas tcpdump -i urtwn0 -n -v -y IEEE802_11_RADIO


Also, please make sure that the NIC works BSS ("normal") mode as well.


Jesper Wallin


Index: rtwn.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/rtwn.c,v
retrieving revision 1.43
diff -u -p -r1.43 rtwn.c
--- rtwn.c      7 Dec 2018 01:53:20 -0000       1.43
+++ rtwn.c      22 Jan 2019 20:16:55 -0000
@@ -1904,8 +1904,9 @@ rtwn_pa_bias_init(struct rtwn_softc *sc)
 void
 rtwn_rxfilter_init(struct rtwn_softc *sc)
 {
+       struct ieee80211com *ic = &sc->sc_ic;
+
        /* Initialize Rx filter. */
-       /* TODO: use better filter for monitor mode. */
        rtwn_write_4(sc, R92C_RCR,
            R92C_RCR_AAP | R92C_RCR_APM | R92C_RCR_AM | R92C_RCR_AB |
            R92C_RCR_APP_ICV | R92C_RCR_AMF | R92C_RCR_HTC_LOC_CTRL |
@@ -1915,8 +1916,11 @@ rtwn_rxfilter_init(struct rtwn_softc *sc
        rtwn_write_4(sc, R92C_MAR + 4, 0xffffffff);
        /* Accept all management frames. */
        rtwn_write_2(sc, R92C_RXFLTMAP0, 0xffff);
-       /* Reject all control frames. */
-       rtwn_write_2(sc, R92C_RXFLTMAP1, 0x0000);
+       /* Accept all control frames in monitor mode. */
+       if (ic->ic_opmode == IEEE80211_M_MONITOR)
+               rtwn_write_2(sc, R92C_RXFLTMAP1, 0xffff);
+       else
+               rtwn_write_2(sc, R92C_RXFLTMAP1, 0x0000);
        /* Accept all data frames. */
        rtwn_write_2(sc, R92C_RXFLTMAP2, 0xffff);
 }

Reply via email to