Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Feb 2025 00:38:51 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 11450726d3cf - main - LinuxKPI: 802.11: improve cfg80211_chandef_create()
Message-ID:  <202502230038.51N0cpIt014412@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=11450726d3cf8d76d2113d7cabe995f8ef31ec5a

commit 11450726d3cf8d76d2113d7cabe995f8ef31ec5a
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-12-30 06:35:03 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-02-22 22:18:51 +0000

    LinuxKPI: 802.11: improve cfg80211_chandef_create()
    
    Implement cfg80211_chandef_create() to work with HT.  Update enum
    with HT channel types.  When calling the function from LinuxKPI 802.11
    code, pass in NL80211_CHAN_HT20 if HT is supported rather than NO_HT.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/include/linux/nl80211.h |  6 ++--
 sys/compat/linuxkpi/common/include/net/cfg80211.h  | 35 ++++++++++------------
 sys/compat/linuxkpi/common/src/linux_80211.c       |  4 +--
 3 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/nl80211.h b/sys/compat/linuxkpi/common/include/linux/nl80211.h
index 80546e56f0c1..b2a33a28b3a7 100644
--- a/sys/compat/linuxkpi/common/include/linux/nl80211.h
+++ b/sys/compat/linuxkpi/common/include/linux/nl80211.h
@@ -135,9 +135,11 @@ enum nl80211_band {
 	NUM_NL80211_BANDS
 } __packed;
 
-enum nl80211_chan_flags {
-	/* XXX TODO */
+enum nl80211_channel_type {
 	NL80211_CHAN_NO_HT,
+	NL80211_CHAN_HT20,
+	NL80211_CHAN_HT40PLUS,
+	NL80211_CHAN_HT40MINUS,
 };
 
 enum nl80211_chan_width {
diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h
index 338ffb82bd83..4ae31b257ae0 100644
--- a/sys/compat/linuxkpi/common/include/net/cfg80211.h
+++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h
@@ -1483,36 +1483,33 @@ cfg80211_pmsr_report(struct wireless_dev *wdev,
 	TODO();
 }
 
-static __inline void
+static inline void
 cfg80211_chandef_create(struct cfg80211_chan_def *chandef,
-    struct linuxkpi_ieee80211_channel *chan, enum nl80211_chan_flags chan_flag)
+    struct linuxkpi_ieee80211_channel *chan, enum nl80211_channel_type chan_type)
 {
 
 	KASSERT(chandef != NULL, ("%s: chandef is NULL\n", __func__));
 	KASSERT(chan != NULL, ("%s: chan is NULL\n", __func__));
 
-	memset(chandef, 0, sizeof(*chandef));
+	/* memset(chandef, 0, sizeof(*chandef)); */
 	chandef->chan = chan;
-	chandef->center_freq2 = 0;	/* Set here and only overwrite if needed. */
+	chandef->center_freq1 = chan->center_freq;
+	/* chandef->width, center_freq2, punctured */
 
-	switch (chan_flag) {
+	switch (chan_type) {
 	case NL80211_CHAN_NO_HT:
 		chandef->width = NL80211_CHAN_WIDTH_20_NOHT;
-		chandef->center_freq1 = chan->center_freq;
 		break;
-	default:
-		IMPROVE("Also depends on our manual settings");
-		if (chan->flags & IEEE80211_CHAN_NO_HT40)
-			chandef->width = NL80211_CHAN_WIDTH_20;
-		else if (chan->flags & IEEE80211_CHAN_NO_80MHZ)
-			chandef->width = NL80211_CHAN_WIDTH_40;
-		else if (chan->flags & IEEE80211_CHAN_NO_160MHZ)
-			chandef->width = NL80211_CHAN_WIDTH_80;
-		else {
-			chandef->width = NL80211_CHAN_WIDTH_160;
-			IMPROVE("80P80 and 320 ...");
-		}
-		chandef->center_freq1 = chan->center_freq;
+	case NL80211_CHAN_HT20:
+		chandef->width = NL80211_CHAN_WIDTH_20;
+		break;
+	case NL80211_CHAN_HT40MINUS:
+		chandef->width = NL80211_CHAN_WIDTH_40;
+		chandef->center_freq1 -= 10;
+		break;
+	case NL80211_CHAN_HT40PLUS:
+		chandef->width = NL80211_CHAN_WIDTH_40;
+		chandef->center_freq1 += 10;
 		break;
 	};
 }
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 729eb2dcd570..92f308fe9228 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -4118,7 +4118,7 @@ lkpi_ic_set_channel(struct ieee80211com *ic)
 	hw = LHW_TO_HW(lhw);
 	cfg80211_chandef_create(&hw->conf.chandef, chan,
 #ifdef LKPI_80211_HT
-	    (ic->ic_htcaps & IEEE80211_HTC_HT) ? 0 :
+	    (ic->ic_flags_ht & IEEE80211_FHT_HT) ? NL80211_CHAN_HT20 :
 #endif
 	    NL80211_CHAN_NO_HT);
 
@@ -5589,7 +5589,7 @@ linuxkpi_ieee80211_ifattach(struct ieee80211_hw *hw)
 
 			cfg80211_chandef_create(&hw->conf.chandef, &channels[i],
 #ifdef LKPI_80211_HT
-			    (ic->ic_htcaps & IEEE80211_HTC_HT) ? 0 :
+			    (ic->ic_flags_ht & IEEE80211_FHT_HT) ? NL80211_CHAN_HT20 :
 #endif
 			    NL80211_CHAN_NO_HT);
 			break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502230038.51N0cpIt014412>