git: 3dd980267f4e - main - LinuxKPI: 802.11: enhance lkpi_scan_ies_add() for HT and VHT

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Tue, 31 Jan 2023 23:05:00 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=3dd980267f4e53df259eb6d322e7332a8bc5bb0a

commit 3dd980267f4e53df259eb6d322e7332a8bc5bb0a
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-01-31 23:00:28 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-01-31 23:00:28 +0000

    LinuxKPI: 802.11: enhance lkpi_scan_ies_add() for HT and VHT
    
    Add code (currently disabled by #ifdef) for HT and VHT to
    lkpi_scan_ies_add().  Switch to a local variable for ic given
    the new code also needs the value.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index cf0c1755c499..491002cd6df5 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -2484,11 +2484,13 @@ lkpi_scan_ies_add(uint8_t *p, struct ieee80211_scan_ies *scan_ies,
 {
 	struct ieee80211_supported_band *supband;
 	struct linuxkpi_ieee80211_channel *channels;
+	struct ieee80211com *ic;
 	const struct ieee80211_channel *chan;
 	const struct ieee80211_rateset *rs;
 	uint8_t *pb;
 	int band, i;
 
+	ic = vap->iv_ic;
 	for (band = 0; band < NUM_NL80211_BANDS; band++) {
 		if ((band_mask & (1 << band)) == 0)
 			continue;
@@ -2509,7 +2511,7 @@ lkpi_scan_ies_add(uint8_t *p, struct ieee80211_scan_ies *scan_ies,
 			if (channels[i].flags & IEEE80211_CHAN_DISABLED)
 				continue;
 
-			chan = ieee80211_find_channel(vap->iv_ic,
+			chan = ieee80211_find_channel(ic,
 			    channels[i].center_freq, 0);
 			if (chan != NULL)
 				break;
@@ -2520,10 +2522,31 @@ lkpi_scan_ies_add(uint8_t *p, struct ieee80211_scan_ies *scan_ies,
 			continue;
 
 		pb = p;
-		rs = ieee80211_get_suprates(vap->iv_ic, chan);	/* calls chan2mode */
+		rs = ieee80211_get_suprates(ic, chan);	/* calls chan2mode */
 		p = ieee80211_add_rates(p, rs);
 		p = ieee80211_add_xrates(p, rs);
 
+#if defined(LKPI_80211_HT)
+		if ((vap->iv_flags_ht & IEEE80211_FHT_HT) != 0) {
+			struct ieee80211_channel *c;
+
+			c = ieee80211_ht_adjust_channel(ic, ic->ic_curchan,
+			    vap->iv_flags_ht);
+			p = ieee80211_add_htcap_ch(p, vap, c);
+		}
+#endif
+#if defined(LKPI_80211_VHT)
+		if ((vap->iv_vht_flags & IEEE80211_FVHT_VHT) != 0) {
+			struct ieee80211_channel *c;
+
+			c = ieee80211_ht_adjust_channel(ic, ic->ic_curchan,
+			    vap->iv_flags_ht);
+			c = ieee80211_vht_adjust_channel(ic, c,
+			    vap->iv_vht_flags);
+			p = ieee80211_add_vhtcap_ch(p, vap, c);
+		}
+#endif
+
 		scan_ies->ies[band] = pb;
 		scan_ies->len[band] = p - pb;
 	}