The branch main has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=9a6695532b3997e4e2bc3fe57481cc49be5e9e93

commit 9a6695532b3997e4e2bc3fe57481cc49be5e9e93
Author:     Bjoern A. Zeeb <b...@freebsd.org>
AuthorDate: 2021-06-06 21:14:28 +0000
Commit:     Bjoern A. Zeeb <b...@freebsd.org>
CommitDate: 2021-10-22 09:55:54 +0000

    net80211/drivers: improve ieee80211_rx_stats for band
    
    While IEEE80211_R_BAND was defined, there was no place to store the
    band.  Add a field for that, adjust ieee80211_lookup_channel_rxstatus()
    to require it, and update drivers passing "R_{FREQ|IEEE}" in already to
    provide the band as well.  For the moment keep the fall-back code
    requiring all three fields.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
    Reviewed by:    adrian
    Differential Revision: https://reviews.freebsd.org/D30662
---
 sys/dev/iwm/if_iwm.c            |  5 +++++
 sys/dev/rtwn/rtl8188e/r88e_rx.c |  2 ++
 sys/dev/rtwn/rtl8812a/r12a_rx.c |  2 ++
 sys/dev/usb/wlan/if_rsu.c       |  2 ++
 sys/net80211/_ieee80211.h       |  3 +++
 sys/net80211/ieee80211.c        | 17 ++++++++++++++---
 6 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index b89c895efb50..f994e8e75307 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -3303,12 +3303,15 @@ iwm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m, 
uint32_t offset,
         */
        bzero(&rxs, sizeof(rxs));
        rxs.r_flags |= IEEE80211_R_IEEE | IEEE80211_R_FREQ;
+       rxs.r_flags |= IEEE80211_R_BAND;
        rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI;
        rxs.c_ieee = le16toh(phy_info->channel);
        if (le16toh(phy_info->phy_flags & IWM_RX_RES_PHY_FLAGS_BAND_24)) {
                rxs.c_freq = ieee80211_ieee2mhz(rxs.c_ieee, 
IEEE80211_CHAN_2GHZ);
+               rxs.c_band = IEEE80211_CHAN_2GHZ;
        } else {
                rxs.c_freq = ieee80211_ieee2mhz(rxs.c_ieee, 
IEEE80211_CHAN_5GHZ);
+               rxs.c_band = IEEE80211_CHAN_5GHZ;
        }
 
        /* rssi is in 1/2db units */
@@ -3414,10 +3417,12 @@ iwm_rx_mpdu_mq(struct iwm_softc *sc, struct mbuf *m, 
uint32_t offset,
         */
        bzero(&rxs, sizeof(rxs));
        rxs.r_flags |= IEEE80211_R_IEEE | IEEE80211_R_FREQ;
+       rxs.r_flags |= IEEE80211_R_BAND;
        rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI;
        rxs.c_ieee = channel;
        rxs.c_freq = ieee80211_ieee2mhz(rxs.c_ieee,
            channel <= 14 ? IEEE80211_CHAN_2GHZ : IEEE80211_CHAN_5GHZ);
+       rxs.c_band = channel <= 14 ? IEEE80211_CHAN_2GHZ : IEEE80211_CHAN_5GHZ;
 
        /* rssi is in 1/2db units */
        rxs.c_rssi = rssi * 2;
diff --git a/sys/dev/rtwn/rtl8188e/r88e_rx.c b/sys/dev/rtwn/rtl8188e/r88e_rx.c
index dad1bc56446a..16510839bd44 100644
--- a/sys/dev/rtwn/rtl8188e/r88e_rx.c
+++ b/sys/dev/rtwn/rtl8188e/r88e_rx.c
@@ -240,8 +240,10 @@ r88e_get_rx_stats(struct rtwn_softc *sc, struct 
ieee80211_rx_stats *rxs,
 
        if (!sc->sc_ht40) {     /* XXX center channel */
                rxs->r_flags |= IEEE80211_R_IEEE | IEEE80211_R_FREQ;
+               rxs->r_flags |= IEEE80211_R_BAND;
                rxs->c_ieee = physt->chan;
                rxs->c_freq = ieee80211_ieee2mhz(rxs->c_ieee,
                    IEEE80211_CHAN_2GHZ);
+               rxs->c_band = IEEE80211_CHAN_2GHZ;
        }
 }
diff --git a/sys/dev/rtwn/rtl8812a/r12a_rx.c b/sys/dev/rtwn/rtl8812a/r12a_rx.c
index d8dcb3de12c5..98e0cabdff7c 100644
--- a/sys/dev/rtwn/rtl8812a/r12a_rx.c
+++ b/sys/dev/rtwn/rtl8812a/r12a_rx.c
@@ -321,8 +321,10 @@ r12a_get_rx_stats(struct rtwn_softc *sc, struct 
ieee80211_rx_stats *rxs,
         */
 #if 0
        rxs->r_flags |= IEEE80211_R_IEEE | IEEE80211_R_FREQ;
+       rxs->r_flags |= IEEE80211_R_BAND;
        rxs->c_ieee = MS(le16toh(physt->phyw1), R12A_PHYW1_CHAN);
        rxs->c_freq = ieee80211_ieee2mhz(rxs->c_ieee,
            (rxs->c_ieee < 36) ? IEEE80211_CHAN_2GHZ : IEEE80211_CHAN_5GHZ);
+       rxs->c_band = (rxs->c_ieee < 36) ? IEEE80211_CHAN_2GHZ : 
IEEE80211_CHAN_5GHZ;
 #endif
 }
diff --git a/sys/dev/usb/wlan/if_rsu.c b/sys/dev/usb/wlan/if_rsu.c
index 4dd1c624b9d0..747e3532cde4 100644
--- a/sys/dev/usb/wlan/if_rsu.c
+++ b/sys/dev/usb/wlan/if_rsu.c
@@ -2081,9 +2081,11 @@ rsu_event_survey(struct rsu_softc *sc, uint8_t *buf, int 
len)
        /* Set channel flags for input path */
        bzero(&rxs, sizeof(rxs));
        rxs.r_flags |= IEEE80211_R_IEEE | IEEE80211_R_FREQ;
+       rxs.r_flags |= IEEE80211_R_BAND;
        rxs.r_flags |= IEEE80211_R_NF | IEEE80211_R_RSSI;
        rxs.c_ieee = le32toh(bss->config.dsconfig);
        rxs.c_freq = ieee80211_ieee2mhz(rxs.c_ieee, IEEE80211_CHAN_2GHZ);
+       rxs.c_band = IEEE80211_CHAN_2GHZ;
        /* This is a number from 0..100; so let's just divide it down a bit */
        rxs.c_rssi = le32toh(bss->rssi) / 2;
        rxs.c_nf = -96;
diff --git a/sys/net80211/_ieee80211.h b/sys/net80211/_ieee80211.h
index dc6773afac09..754e4647e82f 100644
--- a/sys/net80211/_ieee80211.h
+++ b/sys/net80211/_ieee80211.h
@@ -612,6 +612,9 @@ struct ieee80211_rx_stats {
        uint8_t c_ieee;                 /* Channel */
        uint8_t c_width;                /* channel width, FW flags above */
 
+       /* 32 bits */
+       uint32_t c_band;                /* Band; XXX we do not have a real 
band. */
+
        /* Force alignment to DWORD */
        union {
                uint8_t evm[IEEE80211_MAX_CHAINS][IEEE80211_MAX_EVM_PILOTS];
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c
index 2e98e67edc47..35cf7abdbf3b 100644
--- a/sys/net80211/ieee80211.c
+++ b/sys/net80211/ieee80211.c
@@ -1818,6 +1818,8 @@ ieee80211_lookup_channel_rxstatus(struct ieee80211vap 
*vap,
                return (NULL);
        if ((rxs->r_flags & IEEE80211_R_IEEE) == 0)
                return (NULL);
+       if ((rxs->r_flags & IEEE80211_R_BAND) == 0)
+               return (NULL);
 
        /*
         * If the rx status contains a valid ieee/freq, then
@@ -1828,11 +1830,20 @@ ieee80211_lookup_channel_rxstatus(struct ieee80211vap 
*vap,
         */
 
        /* Determine a band */
-       /* XXX should be done by the driver? */
-       if (rxs->c_freq < 3000) {
+       switch (rxs->c_band) {
+       case IEEE80211_CHAN_2GHZ:
                flags = IEEE80211_CHAN_G;
-       } else {
+               break;
+       case IEEE80211_CHAN_5GHZ:
                flags = IEEE80211_CHAN_A;
+               break;
+       default:
+               if (rxs->c_freq < 3000) {
+                       flags = IEEE80211_CHAN_G;
+               } else {
+                       flags = IEEE80211_CHAN_A;
+               }
+               break;
        }
 
        /* Channel lookup */

Reply via email to