git: 616e13301bcf - main - LinuxKPI: 802.11: adjust code to new structure layout

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Thu, 21 Sep 2023 17:19:37 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=616e13301bcf274b007f84ef99ea857a55bef46d

commit 616e13301bcf274b007f84ef99ea857a55bef46d
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-09-21 12:19:54 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-09-21 17:08:38 +0000

    LinuxKPI: 802.11: adjust code to new structure layout
    
    With past commits new structures were added.  Now switch over some
    bss_conf fields into vif->cfg where they got moved to and remove the
    old fields.  This allows drivers to find the expected values in the
    now expected places and work better.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/include/net/mac80211.h |  9 ++---
 sys/compat/linuxkpi/common/src/linux_80211.c      | 44 +++++++++++------------
 2 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h
index 20371812198a..7e6fb1bce16e 100644
--- a/sys/compat/linuxkpi/common/include/net/mac80211.h
+++ b/sys/compat/linuxkpi/common/include/net/mac80211.h
@@ -280,19 +280,13 @@ struct ieee80211_bss_conf {
 	bool					eht_su_beamformer;
 	bool					eht_mu_beamformer;
 
-	size_t					ssid_len;
-	uint8_t					ssid[IEEE80211_NWID_LEN];
-	uint16_t				aid;
 	uint16_t				ht_operation_mode;
 	int					arp_addr_cnt;
 	uint16_t				eht_puncturing;
 
 	uint8_t					dtim_period;
 	uint8_t					sync_dtim_count;
-	bool					assoc;
-	bool					idle;
 	bool					qos;
-	bool					ps;
 	bool					twt_broadcast;
 	bool					use_cts_prot;
 	bool					use_short_preamble;
@@ -991,6 +985,8 @@ struct ieee80211_ops {
 	void (*config_iface_filter)(struct ieee80211_hw *, struct ieee80211_vif *, unsigned int, unsigned int);
 
 	void (*bss_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64);
+        void (*link_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64);
+
 	int  (*set_rts_threshold)(struct ieee80211_hw *, u32);
 	void (*event_callback)(struct ieee80211_hw *, struct ieee80211_vif *, const struct ieee80211_event *);
 	int  (*get_survey)(struct ieee80211_hw *, int, struct survey_info *);
@@ -1038,7 +1034,6 @@ struct ieee80211_ops {
 
 	int (*set_hw_timestamp)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_set_hw_timestamp *);
 
-        void (*link_info_changed)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, u64);
         void (*vif_cfg_changed)(struct ieee80211_hw *, struct ieee80211_vif *, u64);
 
 	int (*change_vif_links)(struct ieee80211_hw *, struct ieee80211_vif *, u16, u16, struct ieee80211_bss_conf *[IEEE80211_MLD_MAX_NUM_LINKS]);
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 668cb2bc04d8..1fc9f9bcba15 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -743,7 +743,7 @@ lkpi_update_dtim_tsf(struct ieee80211_vif *vif, struct ieee80211_node *ni,
 		    "dtim_period %u sync_dtim_count %u sync_tsf %ju "
 		    "sync_device_ts %u bss_changed %#08x\n",
 			__func__, __LINE__, _f, _l,
-			vif->bss_conf.assoc, vif->bss_conf.aid,
+			vif->cfg.assoc, vif->cfg.aid,
 			vif->bss_conf.beacon_int, vif->bss_conf.dtim_period,
 			vif->bss_conf.sync_dtim_count,
 			(uintmax_t)vif->bss_conf.sync_tsf,
@@ -774,7 +774,7 @@ lkpi_update_dtim_tsf(struct ieee80211_vif *vif, struct ieee80211_node *ni,
 		    "dtim_period %u sync_dtim_count %u sync_tsf %ju "
 		    "sync_device_ts %u bss_changed %#08x\n",
 			__func__, __LINE__, _f, _l,
-			vif->bss_conf.assoc, vif->bss_conf.aid,
+			vif->cfg.assoc, vif->cfg.aid,
 			vif->bss_conf.beacon_int, vif->bss_conf.dtim_period,
 			vif->bss_conf.sync_dtim_count,
 			(uintmax_t)vif->bss_conf.sync_tsf,
@@ -845,7 +845,7 @@ lkpi_disassoc(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
     struct lkpi_hw *lhw)
 {
 	sta->aid = 0;
-	if (vif->bss_conf.assoc) {
+	if (vif->cfg.assoc) {
 		struct ieee80211_hw *hw;
 		enum ieee80211_bss_changed changed;
 
@@ -853,8 +853,8 @@ lkpi_disassoc(struct ieee80211_sta *sta, struct ieee80211_vif *vif,
 		lkpi_update_mcast_filter(lhw->ic, true);
 
 		changed = 0;
-		vif->bss_conf.assoc = false;
-		vif->bss_conf.aid = 0;
+		vif->cfg.assoc = false;
+		vif->cfg.aid = 0;
 		changed |= BSS_CHANGED_ASSOC;
 		/*
 		 * This will remove the sta from firmware for iwlwifi.
@@ -1008,12 +1008,12 @@ lkpi_sta_scan_to_auth(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	bss_changed |= BSS_CHANGED_BSSID;
 	vif->bss_conf.txpower = ni->ni_txpower;
 	bss_changed |= BSS_CHANGED_TXPOWER;
-	vif->bss_conf.idle = false;
+	vif->cfg.idle = false;
 	bss_changed |= BSS_CHANGED_IDLE;
 
 	/* Should almost assert it is this. */
-	vif->bss_conf.assoc = false;
-	vif->bss_conf.aid = 0;
+	vif->cfg.assoc = false;
+	vif->cfg.aid = 0;
 
 	bss_changed |= lkpi_update_dtim_tsf(vif, ni, vap, __func__, __LINE__);
 
@@ -1432,8 +1432,8 @@ _lkpi_sta_assoc_to_down(struct ieee80211vap *vap, enum ieee80211_state nstate, i
 	bss_changed = 0;
 	vif->bss_conf.qos = 0;
 	bss_changed |= BSS_CHANGED_QOS;
-	vif->bss_conf.ssid_len = 0;
-	memset(vif->bss_conf.ssid, '\0', sizeof(vif->bss_conf.ssid));
+	vif->cfg.ssid_len = 0;
+	memset(vif->cfg.ssid, '\0', sizeof(vif->cfg.ssid));
 	bss_changed |= BSS_CHANGED_BSSID;
 	lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed);
 
@@ -1548,14 +1548,14 @@ lkpi_sta_assoc_to_run(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 #ifdef LKPI_80211_WME
 	bss_changed |= lkpi_wme_update(lhw, vap, true);
 #endif
-	if (!vif->bss_conf.assoc || vif->bss_conf.aid != IEEE80211_NODE_AID(ni)) {
-		vif->bss_conf.assoc = true;
-		vif->bss_conf.aid = IEEE80211_NODE_AID(ni);
+	if (!vif->cfg.assoc || vif->cfg.aid != IEEE80211_NODE_AID(ni)) {
+		vif->cfg.assoc = true;
+		vif->cfg.aid = IEEE80211_NODE_AID(ni);
 		bss_changed |= BSS_CHANGED_ASSOC;
 	}
 	/* We set SSID but this is not BSSID! */
-	vif->bss_conf.ssid_len = ni->ni_esslen;
-	memcpy(vif->bss_conf.ssid, ni->ni_essid, ni->ni_esslen);
+	vif->cfg.ssid_len = ni->ni_esslen;
+	memcpy(vif->cfg.ssid, ni->ni_essid, ni->ni_esslen);
 	if ((vap->iv_flags & IEEE80211_F_SHPREAMBLE) !=
 	    vif->bss_conf.use_short_preamble) {
 		vif->bss_conf.use_short_preamble ^= 1;
@@ -1894,8 +1894,8 @@ lkpi_sta_run_to_init(struct ieee80211vap *vap, enum ieee80211_state nstate, int
 	bss_changed = 0;
 	vif->bss_conf.qos = 0;
 	bss_changed |= BSS_CHANGED_QOS;
-	vif->bss_conf.ssid_len = 0;
-	memset(vif->bss_conf.ssid, '\0', sizeof(vif->bss_conf.ssid));
+	vif->cfg.ssid_len = 0;
+	memset(vif->cfg.ssid, '\0', sizeof(vif->cfg.ssid));
 	bss_changed |= BSS_CHANGED_BSSID;
 	lkpi_80211_mo_bss_info_changed(hw, vif, &vif->bss_conf, bss_changed);
 
@@ -2275,16 +2275,16 @@ lkpi_ic_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ],
 #if 1
 	vif->chanctx_conf = NULL;
 	vif->bss_conf.vif = vif;
-	vif->bss_conf.idle = true;
-	vif->bss_conf.ps = false;
 	vif->bss_conf.chandef.width = NL80211_CHAN_WIDTH_20_NOHT;
 	vif->bss_conf.use_short_preamble = false;	/* vap->iv_flags IEEE80211_F_SHPREAMBLE */
 	vif->bss_conf.use_short_slot = false;		/* vap->iv_flags IEEE80211_F_SHSLOT */
 	vif->bss_conf.qos = false;
 	vif->bss_conf.use_cts_prot = false;		/* vap->iv_protmode */
 	vif->bss_conf.ht_operation_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONE;
-	vif->bss_conf.assoc = false;
-	vif->bss_conf.aid = 0;
+	vif->cfg.aid = 0;
+	vif->cfg.assoc = false;
+	vif->cfg.idle = true;
+	vif->cfg.ps = false;
 	/*
 	 * We need to initialize it to something as the bss_info_changed call
 	 * will try to copy from it in iwlwifi and NULL is a panic.
@@ -4694,7 +4694,7 @@ linuxkpi_ieee80211_pspoll_get(struct ieee80211_hw *hw,
 	psp = skb_put_zero(skb, sizeof(*psp));
 	psp->i_fc[0] = IEEE80211_FC0_VERSION_0;
 	psp->i_fc[0] |= IEEE80211_FC0_SUBTYPE_PS_POLL | IEEE80211_FC0_TYPE_CTL;
-	v = htole16(vif->bss_conf.aid | 1<<15 | 1<<16);
+	v = htole16(vif->cfg.aid | 1<<15 | 1<<16);
 	memcpy(&psp->i_aid, &v, sizeof(v));
 	IEEE80211_ADDR_COPY(psp->i_bssid, vap->iv_bss->ni_macaddr);
 	IEEE80211_ADDR_COPY(psp->i_ta, vif->addr);