The branch main has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=768332d619484834a7866fde4bf2695d4262355a

commit 768332d619484834a7866fde4bf2695d4262355a
Author:     Bjoern A. Zeeb <[email protected]>
AuthorDate: 2026-01-20 13:33:16 +0000
Commit:     Bjoern A. Zeeb <[email protected]>
CommitDate: 2026-01-20 15:44:30 +0000

    LinuxKPI: 802.11: factor out rate logic for mandatory channels
    
    I was looking at rate work for another problem and found more flags
    in ath9k (which we will likely never need).  The documentation then
    revealed the "mandatory" flags as well and with discussions about
    cfg80211 going on I decided to use the momentum and split our
    "supp_rates" setup between lkpi_lsta_alloc() and wiphy_register().
    
    There should be no functional change.
    
    While there also initialize max_rc_amsdu_len.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 .../linuxkpi/common/include/linux/ieee80211.h      |  13 ++-
 sys/compat/linuxkpi/common/include/net/cfg80211.h  |   4 +-
 sys/compat/linuxkpi/common/src/linux_80211.c       | 110 ++++++++++++++++-----
 3 files changed, 100 insertions(+), 27 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h 
b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
index 12160df43915..b5051a9f7d21 100644
--- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h
@@ -108,7 +108,18 @@ struct ieee80211_mmie_16 {
 #define        IEEE80211_QOS_CTL_MESH_CONTROL_PRESENT  0x0100
 
 enum ieee80211_rate_flags {
-       IEEE80211_RATE_SHORT_PREAMBLE           = BIT(0),
+       IEEE80211_RATE_SHORT_PREAMBLE           = BIT(0),       /* 2.4Ghz, CCK 
*/
+       IEEE80211_RATE_SUPPORTS_5MHZ            = BIT(1),
+       IEEE80211_RATE_SUPPORTS_10MHZ           = BIT(2),
+       IEEE80211_RATE_ERP_G                    = BIT(3),
+
+       /*
+        * According to documentation these are flags initialized internally.
+        * See lkpi_wiphy_band_annotate().
+        */
+       IEEE80211_RATE_MANDATORY_A              = BIT(4),
+       IEEE80211_RATE_MANDATORY_G              = BIT(5),
+       IEEE80211_RATE_MANDATORY_B              = BIT(6),
 };
 
 enum ieee80211_rate_control_changed_flags {
diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h 
b/sys/compat/linuxkpi/common/include/net/cfg80211.h
index d7ed2bc97c98..4b21f82a0762 100644
--- a/sys/compat/linuxkpi/common/include/net/cfg80211.h
+++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h
@@ -1230,6 +1230,7 @@ struct cfg80211_ops {
 
 struct wiphy *linuxkpi_wiphy_new(const struct cfg80211_ops *, size_t);
 void linuxkpi_wiphy_free(struct wiphy *wiphy);
+int linuxkpi_80211_wiphy_register(struct wiphy *);
 
 void linuxkpi_wiphy_work_queue(struct wiphy *, struct wiphy_work *);
 void linuxkpi_wiphy_work_cancel(struct wiphy *, struct wiphy_work *);
@@ -1749,8 +1750,7 @@ wiphy_net(struct wiphy *wiphy)
 static __inline int
 wiphy_register(struct wiphy *wiphy)
 {
-       TODO();
-       return (0);
+       return (linuxkpi_80211_wiphy_register(wiphy));
 }
 
 static __inline void
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c 
b/sys/compat/linuxkpi/common/src/linux_80211.c
index 1ac28dfef448..7972d9d0f667 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -896,41 +896,34 @@ lkpi_lsta_alloc(struct ieee80211vap *vap, const uint8_t 
mac[IEEE80211_ADDR_LEN],
        /* Deflink information. */
        for (band = 0; band < NUM_NL80211_BANDS; band++) {
                struct ieee80211_supported_band *supband;
+               uint32_t rate_mandatory;;
 
                supband = hw->wiphy->bands[band];
                if (supband == NULL)
                        continue;
 
+               switch (band) {
+               case NL80211_BAND_2GHZ:
+                       /* We have to assume 11g support here. */
+                       rate_mandatory = IEEE80211_RATE_MANDATORY_G |
+                           IEEE80211_RATE_MANDATORY_B;
+                       break;
+               case NL80211_BAND_5GHZ:
+                       rate_mandatory = IEEE80211_RATE_MANDATORY_A;
+                       break;
+               default:
+                       continue;
+               }
+
                for (i = 0; i < supband->n_bitrates; i++) {
-                       switch (band) {
-                       case NL80211_BAND_2GHZ:
-                               switch (supband->bitrates[i].bitrate) {
-                               case 240:       /* 11g only */
-                               case 120:       /* 11g only */
-                               case 110:
-                               case 60:        /* 11g only */
-                               case 55:
-                               case 20:
-                               case 10:
-                                       sta->deflink.supp_rates[band] |= BIT(i);
-                                       break;
-                               }
-                               break;
-                       case NL80211_BAND_5GHZ:
-                               switch (supband->bitrates[i].bitrate) {
-                               case 240:
-                               case 120:
-                               case 60:
-                                       sta->deflink.supp_rates[band] |= BIT(i);
-                                       break;
-                               }
-                               break;
-                       }
+                       if ((supband->bitrates[i].flags & rate_mandatory) != 0)
+                               sta->deflink.supp_rates[band] |= BIT(i);
                }
        }
 
        sta->deflink.smps_mode = IEEE80211_SMPS_OFF;
        sta->deflink.bandwidth = IEEE80211_STA_RX_BW_20;
+       sta->deflink.agg.max_rc_amsdu_len = IEEE80211_MAX_MPDU_LEN_HT_BA;
        sta->deflink.rx_nss = 1;
        sta->deflink.sta = sta;
 
@@ -8028,6 +8021,75 @@ linuxkpi_wiphy_free(struct wiphy *wiphy)
        kfree(lwiphy);
 }
 
+static void
+lkpi_wiphy_band_annotate(struct wiphy *wiphy)
+{
+       int band;
+
+       for (band = 0; band < NUM_NL80211_BANDS; band++) {
+               struct ieee80211_supported_band *supband;
+               int i;
+
+               supband = wiphy->bands[band];
+               if (supband == NULL)
+                       continue;
+
+               switch (band) {
+               case NL80211_BAND_2GHZ:
+               case NL80211_BAND_5GHZ:
+                       break;
+               default:
+                       IMPROVE("band %d(%s) not yet supported",
+                           band, lkpi_nl80211_band_name(band));
+                       /* For bands added here, also check lkpi_lsta_alloc(). 
*/
+                       continue;
+               }
+
+               for (i = 0; i < supband->n_bitrates; i++) {
+                       switch (band) {
+                       case NL80211_BAND_2GHZ:
+                               switch (supband->bitrates[i].bitrate) {
+                               case 110:
+                               case 55:
+                               case 20:
+                               case 10:
+                                       supband->bitrates[i].flags |=
+                                           IEEE80211_RATE_MANDATORY_B;
+                                       /* FALLTHROUGH */
+                               /* 11g only */
+                               case 240:
+                               case 120:
+                               case 60:
+                                       supband->bitrates[i].flags |=
+                                           IEEE80211_RATE_MANDATORY_G;
+                                       break;
+                               }
+                               break;
+                       case NL80211_BAND_5GHZ:
+                               switch (supband->bitrates[i].bitrate) {
+                               case 240:
+                               case 120:
+                               case 60:
+                                       supband->bitrates[i].flags |=
+                                           IEEE80211_RATE_MANDATORY_A;
+                                       break;
+                               }
+                               break;
+                       }
+               }
+       }
+}
+
+int
+linuxkpi_80211_wiphy_register(struct wiphy *wiphy)
+{
+       TODO("Lots of checks and initialization");
+
+       lkpi_wiphy_band_annotate(wiphy);
+
+       return (0);
+}
+
 static uint32_t
 lkpi_cfg80211_calculate_bitrate_ht(struct rate_info *rate)
 {

Reply via email to