Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Oct 2023 15:23:51 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: a3e10c2b1418 - stable/14 - LinuxKPI: 802.11: fill regulatory_hint() with some life
Message-ID:  <202310041523.394FNpMn087282@gitrepo.freebsd.org>

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

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

commit a3e10c2b141879a68cff691f0176a2f6ac8ea04e
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-09-25 17:54:20 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-10-04 15:19:19 +0000

    LinuxKPI: 802.11: fill regulatory_hint() with some life
    
    Start implementing regulatory_hint() using a .c file based allocation
    helper function so we could change structures in the future with
    better chances to keep compatibility.
    This sets wiphy->regd needed by various LinuxKPI based WiFi drivers.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 673d62fc359b0cb7a70af42c36d2fa54fb29452a)
---
 sys/compat/linuxkpi/common/include/net/cfg80211.h | 20 ++++++++++++++++++--
 sys/compat/linuxkpi/common/src/linux_80211.c      | 10 ++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h
index 56ca9a231d2d..7e57ce67cc26 100644
--- a/sys/compat/linuxkpi/common/include/net/cfg80211.h
+++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h
@@ -1260,6 +1260,8 @@ struct cfg80211_bss *linuxkpi_cfg80211_get_bss(struct wiphy *,
     const uint8_t *, size_t, enum ieee80211_bss_type, enum ieee80211_privacy);
 void linuxkpi_cfg80211_put_bss(struct wiphy *, struct cfg80211_bss *);
 void linuxkpi_cfg80211_bss_flush(struct wiphy *);
+struct linuxkpi_ieee80211_regdomain *
+    lkpi_get_linuxkpi_ieee80211_regdomain(size_t);
 
 /* -------------------------------------------------------------------------- */
 
@@ -1587,8 +1589,22 @@ regulatory_set_wiphy_regd(struct wiphy *wiphy,
 static __inline int
 regulatory_hint(struct wiphy *wiphy, const uint8_t *alpha2)
 {
-	TODO();
-	return (-ENXIO);
+	struct linuxkpi_ieee80211_regdomain *regd;
+
+	if (wiphy->regd != NULL)
+		return (-EBUSY);
+
+	regd = lkpi_get_linuxkpi_ieee80211_regdomain(0);
+	if (regd == NULL)
+		return (-ENOMEM);
+
+	regd->alpha2[0] = alpha2[0];
+	regd->alpha2[1] = alpha2[1];
+	wiphy->regd = regd;
+
+	IMPROVE("are there flags who is managing? update net8011?");
+
+	return (0);
 }
 
 static __inline const char *
diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index c8232e6f33cc..978a82ad2ceb 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -3954,6 +3954,16 @@ linuxkpi_ieee80211_iterate_stations_atomic(struct ieee80211_hw *hw,
 	LKPI_80211_LHW_LVIF_UNLOCK(lhw);
 }
 
+struct linuxkpi_ieee80211_regdomain *
+lkpi_get_linuxkpi_ieee80211_regdomain(size_t n)
+{
+	struct linuxkpi_ieee80211_regdomain *regd;
+
+	regd = kzalloc(sizeof(*regd) + n * sizeof(struct ieee80211_reg_rule),
+	    GFP_KERNEL);
+	return (regd);
+}
+
 int
 linuxkpi_regulatory_set_wiphy_regd_sync(struct wiphy *wiphy,
     struct linuxkpi_ieee80211_regdomain *regd)



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