linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13
@ 2023-11-13  9:34 gregory.greenman
  2023-11-13  9:35 ` [PATCH 1/6] wifi: cfg80211: Extend support for scanning while MLO connected gregory.greenman
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: gregory.greenman @ 2023-11-13  9:34 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Gregory Greenman

From: Gregory Greenman <gregory.greenman@intel.com>

Hi,

A bunch of patches from our internal tree with mac80211 and
cfg80211 changes. It's the usual developement, adding a few small
features.

Thanks,
Gregory

Andrei Otcheretianski (4):
  wifi: cfg80211: reg: Support P2P operation on DFS channels
  wifi: cfg80211: Schedule regulatory check on BSS STA channel change
  wifi: mac80211: Schedule regulatory channels check on bandwith change
  wifi: mac80211_hwsim: Add custom reg for DFS concurrent

Ilan Peer (2):
  wifi: cfg80211: Extend support for scanning while MLO connected
  wifi: mac80211: Extend support for scanning while MLO connected

 drivers/net/wireless/virtual/mac80211_hwsim.c | 19 ++++
 include/net/cfg80211.h                        | 16 ++++
 include/uapi/linux/nl80211.h                  | 25 ++++-
 net/mac80211/mlme.c                           |  1 +
 net/mac80211/scan.c                           | 48 +++++++++-
 net/wireless/chan.c                           | 94 +++++++++++++++++--
 net/wireless/nl80211.c                        | 20 ++++
 net/wireless/reg.c                            |  5 +-
 net/wireless/reg.h                            |  5 +
 net/wireless/sme.c                            |  2 +
 10 files changed, 219 insertions(+), 16 deletions(-)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/6] wifi: cfg80211: Extend support for scanning while MLO connected
  2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
@ 2023-11-13  9:35 ` gregory.greenman
  2023-11-13  9:35 ` [PATCH 2/6] wifi: mac80211: " gregory.greenman
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: gregory.greenman @ 2023-11-13  9:35 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Ilan Peer, Gregory Greenman

From: Ilan Peer <ilan.peer@intel.com>

To extend the support of TSF accounting in scan results for MLO
connections, allow to indicate in the scan request the link ID
corresponding to the BSS whose TSF should be used for the TSF
accounting.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 include/net/cfg80211.h       | 3 +++
 include/uapi/linux/nl80211.h | 8 +++++---
 net/wireless/nl80211.c       | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b137a33a1b68..d36ad4cedf3b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2608,6 +2608,8 @@ struct cfg80211_scan_6ghz_params {
  * @n_6ghz_params: number of 6 GHz params
  * @scan_6ghz_params: 6 GHz params
  * @bssid: BSSID to scan for (most commonly, the wildcard BSSID)
+ * @tsf_report_link_id: for MLO, indicates the link ID of the BSS that should be
+ *      used for TSF reporting. Can be set to -1 to indicate no preference.
  */
 struct cfg80211_scan_request {
 	struct cfg80211_ssid *ssids;
@@ -2636,6 +2638,7 @@ struct cfg80211_scan_request {
 	bool scan_6ghz;
 	u32 n_6ghz_params;
 	struct cfg80211_scan_6ghz_params *scan_6ghz_params;
+	s8 tsf_report_link_id;
 
 	/* keep last */
 	struct ieee80211_channel *channels[] __counted_by(n_channels);
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index dced2c49daec..03e44823355e 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -6241,9 +6241,11 @@ enum nl80211_feature_flags {
  *	the BSS that the interface that requested the scan is connected to
  *	(if available).
  * @NL80211_EXT_FEATURE_BSS_PARENT_TSF: Per BSS, this driver reports the
- *	time the last beacon/probe was received. The time is the TSF of the
- *	BSS that the interface that requested the scan is connected to
- *	(if available).
+ *	time the last beacon/probe was received. For a non MLO connection, the
+ *	time is the TSF of the BSS that the interface that requested the scan is
+ *	connected to (if available). For an MLO connection, the time is the TSF
+ *	of the BSS corresponding with link ID specified in the scan request (if
+ *	specified).
  * @NL80211_EXT_FEATURE_SET_SCAN_DWELL: This driver supports configuration of
  *	channel dwell time.
  * @NL80211_EXT_FEATURE_BEACON_RATE_LEGACY: Driver supports beacon rate
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 569234bc2be6..12b7bd92bb86 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9337,6 +9337,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 	else
 		eth_broadcast_addr(request->bssid);
 
+	request->tsf_report_link_id = nl80211_link_id_or_invalid(info->attrs);
 	request->wdev = wdev;
 	request->wiphy = &rdev->wiphy;
 	request->scan_start = jiffies;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/6] wifi: mac80211: Extend support for scanning while MLO connected
  2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
  2023-11-13  9:35 ` [PATCH 1/6] wifi: cfg80211: Extend support for scanning while MLO connected gregory.greenman
@ 2023-11-13  9:35 ` gregory.greenman
  2023-11-13  9:35 ` [PATCH 3/6] wifi: cfg80211: reg: Support P2P operation on DFS channels gregory.greenman
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: gregory.greenman @ 2023-11-13  9:35 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Ilan Peer, Gregory Greenman

From: Ilan Peer <ilan.peer@intel.com>

- If the scan request includes a link ID, validate that it is
  one of the active links. Otherwise, if the scan request doesn't
  include a valid link ID, select one of the active links.

- When reporting the TSF for a BSS entry, use the link ID information
  from the Rx status or the scan request to set the parent BSSID.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 net/mac80211/scan.c | 48 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 43 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 24fa06105378..1d98877647d8 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -194,11 +194,32 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
 	if (scan_sdata && scan_sdata->vif.type == NL80211_IFTYPE_STATION &&
 	    scan_sdata->vif.cfg.assoc &&
 	    ieee80211_have_rx_timestamp(rx_status)) {
-		bss_meta.parent_tsf =
-			ieee80211_calculate_rx_timestamp(local, rx_status,
-							 len + FCS_LEN, 24);
-		ether_addr_copy(bss_meta.parent_bssid,
-				scan_sdata->vif.bss_conf.bssid);
+		struct ieee80211_bss_conf *link_conf = NULL;
+
+		/* for an MLO connection, set the TSF data only in case we have
+		 * an indication on which of the links the frame was received
+		 */
+		if (ieee80211_vif_is_mld(&scan_sdata->vif)) {
+			if (rx_status->link_valid) {
+				s8 link_id = rx_status->link_id;
+
+				link_conf =
+					rcu_dereference(scan_sdata->vif.link_conf[link_id]);
+			}
+		} else {
+			link_conf = &scan_sdata->vif.bss_conf;
+		}
+
+		if (link_conf) {
+			bss_meta.parent_tsf =
+				ieee80211_calculate_rx_timestamp(local,
+								 rx_status,
+								 len + FCS_LEN,
+								 24);
+
+			ether_addr_copy(bss_meta.parent_bssid,
+					link_conf->bssid);
+		}
 	}
 	rcu_read_unlock();
 
@@ -666,6 +687,21 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
 	if (local->scan_req)
 		return -EBUSY;
 
+	/* For an MLO connection, if a link ID was specified, validate that it
+	 * is indeed active. If no link ID was specified, select one of the
+	 * active links.
+	 */
+	if (ieee80211_vif_is_mld(&sdata->vif)) {
+		if (req->tsf_report_link_id >= 0) {
+			if (!(sdata->vif.active_links &
+			      BIT(req->tsf_report_link_id)))
+				return -EINVAL;
+		} else {
+			req->tsf_report_link_id =
+				__ffs(sdata->vif.active_links);
+		}
+	}
+
 	if (!__ieee80211_can_leave_ch(sdata))
 		return -EBUSY;
 
@@ -714,6 +750,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
 		local->hw_scan_req->req.duration = req->duration;
 		local->hw_scan_req->req.duration_mandatory =
 			req->duration_mandatory;
+		local->hw_scan_req->req.tsf_report_link_id =
+			req->tsf_report_link_id;
 
 		local->hw_scan_band = 0;
 		local->hw_scan_req->req.n_6ghz_params = req->n_6ghz_params;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/6] wifi: cfg80211: reg: Support P2P operation on DFS channels
  2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
  2023-11-13  9:35 ` [PATCH 1/6] wifi: cfg80211: Extend support for scanning while MLO connected gregory.greenman
  2023-11-13  9:35 ` [PATCH 2/6] wifi: mac80211: " gregory.greenman
@ 2023-11-13  9:35 ` gregory.greenman
  2023-11-13  9:35 ` [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change gregory.greenman
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: gregory.greenman @ 2023-11-13  9:35 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski, Gregory Greenman

From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

FCC-594280 D01 Section B.3 allows peer-to-peer and ad hoc devices to
operate on DFS channels while they operate under the control of a
concurrent DFS master. For example, it is possible to have a P2P GO on a
DFS channel as long as BSS connection is active on the same channel.
Allow such operation by adding additional regulatory flags to indicate
DFS concurrent channels and capable devices. Add the required
relaxations in DFS regulatory checks.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 include/net/cfg80211.h       |  2 +
 include/uapi/linux/nl80211.h | 17 +++++++
 net/wireless/chan.c          | 94 +++++++++++++++++++++++++++++++++---
 net/wireless/nl80211.c       |  3 ++
 net/wireless/reg.c           |  3 ++
 5 files changed, 112 insertions(+), 7 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index d36ad4cedf3b..c467d11283f7 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -117,6 +117,7 @@ struct wiphy;
  *	This may be due to the driver or due to regulatory bandwidth
  *	restrictions.
  * @IEEE80211_CHAN_NO_EHT: EHT operation is not permitted on this channel.
+ * @IEEE80211_CHAN_DFS_CONCURRENT: See %NL80211_RRF_DFS_CONCURRENT
  */
 enum ieee80211_channel_flags {
 	IEEE80211_CHAN_DISABLED		= 1<<0,
@@ -140,6 +141,7 @@ enum ieee80211_channel_flags {
 	IEEE80211_CHAN_16MHZ		= 1<<18,
 	IEEE80211_CHAN_NO_320MHZ	= 1<<19,
 	IEEE80211_CHAN_NO_EHT		= 1<<20,
+	IEEE80211_CHAN_DFS_CONCURRENT	= 1<<21,
 };
 
 #define IEEE80211_CHAN_NO_HT40 \
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 03e44823355e..8724d7f72af3 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -4226,6 +4226,10 @@ enum nl80211_wmm_rule {
  *	in current regulatory domain.
  * @NL80211_FREQUENCY_ATTR_PSD: Power spectral density (in dBm) that
  *	is allowed on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_DFS_CONCURRENT: Operation on this channel is
+ *	allowed for peer-to-peer or adhoc communication under the control
+ *	of a DFS master which operates on the same channel (FCC-594280 D01
+ *	Section B.3). Should be used together with %NL80211_RRF_DFS only.
  * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
  *	currently defined
  * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
@@ -4265,6 +4269,7 @@ enum nl80211_frequency_attr {
 	NL80211_FREQUENCY_ATTR_NO_320MHZ,
 	NL80211_FREQUENCY_ATTR_NO_EHT,
 	NL80211_FREQUENCY_ATTR_PSD,
+	NL80211_FREQUENCY_ATTR_DFS_CONCURRENT,
 
 	/* keep last */
 	__NL80211_FREQUENCY_ATTR_AFTER_LAST,
@@ -4470,6 +4475,10 @@ enum nl80211_sched_scan_match_attr {
  * @NL80211_RRF_NO_320MHZ: 320MHz operation not allowed
  * @NL80211_RRF_NO_EHT: EHT operation not allowed
  * @NL80211_RRF_PSD: Ruleset has power spectral density value
+ * @NL80211_RRF_DFS_CONCURRENT: Operation on this channel is allowed for
+	peer-to-peer or adhoc communication under the control of a DFS master
+	which operates on the same channel (FCC-594280 D01 Section B.3).
+	Should be used together with %NL80211_RRF_DFS only.
  */
 enum nl80211_reg_rule_flags {
 	NL80211_RRF_NO_OFDM		= 1<<0,
@@ -4491,6 +4500,7 @@ enum nl80211_reg_rule_flags {
 	NL80211_RRF_NO_320MHZ		= 1<<18,
 	NL80211_RRF_NO_EHT		= 1<<19,
 	NL80211_RRF_PSD			= 1<<20,
+	NL80211_RRF_DFS_CONCURRENT	= 1<<21,
 };
 
 #define NL80211_RRF_PASSIVE_SCAN	NL80211_RRF_NO_IR
@@ -6428,6 +6438,12 @@ enum nl80211_feature_flags {
  * @NL80211_EXT_FEATURE_OWE_OFFLOAD_AP: Driver/Device wants to do OWE DH IE
  *	handling in AP mode.
  *
+ * @NL80211_EXT_FEATURE_DFS_CONCURRENT: The device supports peer-to-peer or
+ *	ad hoc operation on DFS channels under the control of a concurrent
+ *	DFS master on the same channel as described in FCC-594280 D01
+ *	(Section B.3). This, for example, allows P2P GO and P2P clients to
+ *	operate on DFS channels as long as there's a concurrent BSS connection.
+ *
  * @NUM_NL80211_EXT_FEATURES: number of extended features.
  * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
  */
@@ -6501,6 +6517,7 @@ enum nl80211_ext_feature_index {
 	NL80211_EXT_FEATURE_AUTH_AND_DEAUTH_RANDOM_TA,
 	NL80211_EXT_FEATURE_OWE_OFFLOAD,
 	NL80211_EXT_FEATURE_OWE_OFFLOAD_AP,
+	NL80211_EXT_FEATURE_DFS_CONCURRENT,
 
 	/* add new features before the definition below */
 	NUM_NL80211_EXT_FEATURES,
diff --git a/net/wireless/chan.c b/net/wireless/chan.c
index 2d21e423abdb..7d63d95b2178 100644
--- a/net/wireless/chan.c
+++ b/net/wireless/chan.c
@@ -514,9 +514,83 @@ static u32 cfg80211_get_end_freq(u32 center_freq,
 	return end_freq;
 }
 
+static bool
+cfg80211_dfs_permissive_check_wdev(struct cfg80211_registered_device *rdev,
+				   enum nl80211_iftype iftype,
+				   struct wireless_dev *wdev,
+				   struct ieee80211_channel *chan)
+{
+	unsigned int link_id;
+
+	for_each_valid_link(wdev, link_id) {
+		struct ieee80211_channel *other_chan = NULL;
+		struct cfg80211_chan_def chandef = {};
+		int ret;
+
+		/* In order to avoid daisy chaining only allow BSS STA */
+		if (wdev->iftype != NL80211_IFTYPE_STATION ||
+		    !wdev->links[link_id].client.current_bss)
+			continue;
+
+		other_chan =
+			wdev->links[link_id].client.current_bss->pub.channel;
+
+		if (!other_chan)
+			continue;
+
+		if (chan == other_chan)
+			return true;
+
+		/* continue if we can't get the channel */
+		ret = rdev_get_channel(rdev, wdev, link_id, &chandef);
+		if (ret)
+			continue;
+
+		if (cfg80211_is_sub_chan(&chandef, chan, false))
+			return true;
+	}
+
+	return false;
+}
+
+/*
+ * Check if P2P GO is allowed to operate on a DFS channel
+ */
+static bool cfg80211_dfs_permissive_chan(struct wiphy *wiphy,
+					 enum nl80211_iftype iftype,
+					 struct ieee80211_channel *chan)
+{
+	struct wireless_dev *wdev;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+
+	lockdep_assert_held(&rdev->wiphy.mtx);
+
+	if (!wiphy_ext_feature_isset(&rdev->wiphy,
+				     NL80211_EXT_FEATURE_DFS_CONCURRENT) ||
+	    !(chan->flags & IEEE80211_CHAN_DFS_CONCURRENT))
+		return false;
+
+	/* only valid for P2P GO */
+	if (iftype != NL80211_IFTYPE_P2P_GO)
+		return false;
+
+	/*
+	 * Allow only if there's a concurrent BSS
+	 */
+	list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
+		bool ret = cfg80211_dfs_permissive_check_wdev(rdev, iftype,
+							      wdev, chan);
+		if (ret)
+			return ret;
+	}
+
+	return false;
+}
+
 static int cfg80211_get_chans_dfs_required(struct wiphy *wiphy,
 					    u32 center_freq,
-					    u32 bandwidth)
+					    u32 bandwidth,
+					    enum nl80211_iftype iftype)
 {
 	struct ieee80211_channel *c;
 	u32 freq, start_freq, end_freq;
@@ -529,9 +603,11 @@ static int cfg80211_get_chans_dfs_required(struct wiphy *wiphy,
 		if (!c)
 			return -EINVAL;
 
-		if (c->flags & IEEE80211_CHAN_RADAR)
+		if (c->flags & IEEE80211_CHAN_RADAR &&
+		    !cfg80211_dfs_permissive_chan(wiphy, iftype, c))
 			return 1;
 	}
+
 	return 0;
 }
 
@@ -557,7 +633,7 @@ int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
 
 		ret = cfg80211_get_chans_dfs_required(wiphy,
 					ieee80211_chandef_to_khz(chandef),
-					width);
+					width, iftype);
 		if (ret < 0)
 			return ret;
 		else if (ret > 0)
@@ -568,7 +644,7 @@ int cfg80211_chandef_dfs_required(struct wiphy *wiphy,
 
 		ret = cfg80211_get_chans_dfs_required(wiphy,
 					MHZ_TO_KHZ(chandef->center_freq2),
-					width);
+					width, iftype);
 		if (ret < 0)
 			return ret;
 		else if (ret > 0)
@@ -1336,15 +1412,19 @@ static bool _cfg80211_reg_can_beacon(struct wiphy *wiphy,
 				     bool check_no_ir)
 {
 	bool res;
-	u32 prohibited_flags = IEEE80211_CHAN_DISABLED |
-			       IEEE80211_CHAN_RADAR;
+	u32 prohibited_flags = IEEE80211_CHAN_DISABLED;
+	int dfs_required;
 
 	trace_cfg80211_reg_can_beacon(wiphy, chandef, iftype, check_no_ir);
 
 	if (check_no_ir)
 		prohibited_flags |= IEEE80211_CHAN_NO_IR;
 
-	if (cfg80211_chandef_dfs_required(wiphy, chandef, iftype) > 0 &&
+	dfs_required = cfg80211_chandef_dfs_required(wiphy, chandef, iftype);
+	if (dfs_required != 0)
+		prohibited_flags |= IEEE80211_CHAN_RADAR;
+
+	if (dfs_required > 0 &&
 	    cfg80211_chandef_dfs_available(wiphy, chandef)) {
 		/* We can skip IEEE80211_CHAN_NO_IR if chandef dfs available */
 		prohibited_flags = IEEE80211_CHAN_DISABLED;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 12b7bd92bb86..c693ebddd053 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1198,6 +1198,9 @@ static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy,
 		if ((chan->flags & IEEE80211_CHAN_NO_EHT) &&
 		    nla_put_flag(msg, NL80211_FREQUENCY_ATTR_NO_EHT))
 			goto nla_put_failure;
+		if ((chan->flags & IEEE80211_CHAN_DFS_CONCURRENT) &&
+		    nla_put_flag(msg, NL80211_FREQUENCY_ATTR_DFS_CONCURRENT))
+			goto nla_put_failure;
 	}
 
 	if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 2ef4f6cc7a32..552c05bbad47 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1595,6 +1595,9 @@ static u32 map_regdom_flags(u32 rd_flags)
 		channel_flags |= IEEE80211_CHAN_NO_EHT;
 	if (rd_flags & NL80211_RRF_PSD)
 		channel_flags |= IEEE80211_CHAN_PSD;
+	if (rd_flags & NL80211_RRF_DFS_CONCURRENT)
+		channel_flags |= IEEE80211_CHAN_DFS_CONCURRENT;
+
 	return channel_flags;
 }
 
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change
  2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
                   ` (2 preceding siblings ...)
  2023-11-13  9:35 ` [PATCH 3/6] wifi: cfg80211: reg: Support P2P operation on DFS channels gregory.greenman
@ 2023-11-13  9:35 ` gregory.greenman
  2023-11-24 19:13   ` Johannes Berg
  2023-11-13  9:35 ` [PATCH 5/6] wifi: mac80211: Schedule regulatory channels check on bandwith change gregory.greenman
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: gregory.greenman @ 2023-11-13  9:35 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski, Gregory Greenman

From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

Due to different relaxation policies it may be needed to re-check
channels after a BSS station interface is disconnected or performed a
channel switch.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 include/net/cfg80211.h | 11 +++++++++++
 net/wireless/nl80211.c | 16 ++++++++++++++++
 net/wireless/reg.c     |  2 +-
 net/wireless/reg.h     |  5 +++++
 net/wireless/sme.c     |  2 ++
 5 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index c467d11283f7..8477f65f54ce 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -9302,6 +9302,17 @@ bool cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap,
  * case disconnect instead.
  * Also note that the wdev mutex must be held.
  */
+
 void cfg80211_links_removed(struct net_device *dev, u16 link_mask);
 
+/**
+ * cfg80211_schedule_channels_check - schedule regulatory check if needed
+ * @netdev: the device to check
+ *
+ * In case the device supports NO_IR or DFS relaxations, schedule regulatory
+ * channels check, as previous concurrent operation conditions may not
+ * hold anymore.
+ */
+void cfg80211_schedule_channels_check(struct net_device *netdev);
+
 #endif /* __NET_CFG80211_H */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c693ebddd053..413dc2a652a7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -19310,6 +19310,7 @@ void cfg80211_ch_switch_notify(struct net_device *dev,
 		break;
 	}
 
+	cfg80211_schedule_channels_check(dev);
 	cfg80211_sched_dfs_chan_update(rdev);
 
 	nl80211_ch_switch_notify(rdev, dev, link_id, chandef, GFP_KERNEL,
@@ -20067,6 +20068,21 @@ void cfg80211_update_owe_info_event(struct net_device *netdev,
 }
 EXPORT_SYMBOL(cfg80211_update_owe_info_event);
 
+void cfg80211_schedule_channels_check(struct net_device *netdev)
+{
+	struct wireless_dev *wdev = netdev->ieee80211_ptr;
+	struct wiphy *wiphy = wdev->wiphy;
+
+	/* Schedule channels check if NO_IR or DFS relaxations are supported */
+	if (wdev->iftype == NL80211_IFTYPE_STATION &&
+	    (wiphy_ext_feature_isset(wiphy,
+				     NL80211_EXT_FEATURE_DFS_CONCURRENT) ||
+	    (IS_ENABLED(CONFIG_CFG80211_REG_RELAX_NO_IR) &&
+	     wiphy->regulatory_flags & REGULATORY_ENABLE_RELAX_NO_IR)))
+		reg_check_channels();
+}
+EXPORT_SYMBOL(cfg80211_schedule_channels_check);
+
 /* initialisation/exit functions */
 
 int __init nl80211_init(void)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 552c05bbad47..a3210d151653 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -2481,7 +2481,7 @@ static void reg_check_chans_work(struct work_struct *work)
 	rtnl_unlock();
 }
 
-static void reg_check_channels(void)
+void reg_check_channels(void)
 {
 	/*
 	 * Give usermode a chance to do something nicer (move to another
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index a703e53c23ee..a02ef5609f52 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -181,6 +181,11 @@ bool reg_dfs_domain_same(struct wiphy *wiphy1, struct wiphy *wiphy2);
  */
 int reg_reload_regdb(void);
 
+/**
+ * reg_check_channels - schedule regulatory enforcement
+ */
+void reg_check_channels(void);
+
 extern const u8 shipped_regdb_certs[];
 extern unsigned int shipped_regdb_certs_len;
 extern const u8 extra_regdb_certs[];
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index acfe66da7109..c1a880c4af1c 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -1394,6 +1394,8 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
 #endif
 
 	schedule_work(&cfg80211_disconnect_work);
+
+	cfg80211_schedule_channels_check(dev);
 }
 
 void cfg80211_disconnected(struct net_device *dev, u16 reason,
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/6] wifi: mac80211: Schedule regulatory channels check on bandwith change
  2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
                   ` (3 preceding siblings ...)
  2023-11-13  9:35 ` [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change gregory.greenman
@ 2023-11-13  9:35 ` gregory.greenman
  2023-11-13  9:35 ` [PATCH 6/6] wifi: mac80211_hwsim: Add custom reg for DFS concurrent gregory.greenman
  2023-11-24 19:36 ` [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 Johannes Berg
  6 siblings, 0 replies; 14+ messages in thread
From: gregory.greenman @ 2023-11-13  9:35 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski, Gregory Greenman

From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

Some devices may support concurrent DFS operation which relies on the
BSS channel width for its relaxations. Notify cfg80211 about BW change
so it can schedule regulatory checks.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 net/mac80211/mlme.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 887b496f2b81..e464a3984f87 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -595,6 +595,7 @@ static int ieee80211_config_bw(struct ieee80211_link_data *link,
 		return ret;
 	}
 
+	cfg80211_schedule_channels_check(sdata->dev);
 	return 0;
 }
 
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/6] wifi: mac80211_hwsim: Add custom reg for DFS concurrent
  2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
                   ` (4 preceding siblings ...)
  2023-11-13  9:35 ` [PATCH 5/6] wifi: mac80211: Schedule regulatory channels check on bandwith change gregory.greenman
@ 2023-11-13  9:35 ` gregory.greenman
  2023-11-24 19:17   ` Johannes Berg
  2023-11-24 19:36 ` [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 Johannes Berg
  6 siblings, 1 reply; 14+ messages in thread
From: gregory.greenman @ 2023-11-13  9:35 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski, Gregory Greenman

From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>

Add custom regulatory that marks DFS channels as DFS_CONCURRENT.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
---
 drivers/net/wireless/virtual/mac80211_hwsim.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index c7b4414cc6c3..3816b0d335f0 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -190,10 +190,25 @@ static const struct ieee80211_regdomain hwsim_world_regdom_custom_03 = {
 	}
 };
 
+static const struct ieee80211_regdomain hwsim_world_regdom_custom_04 = {
+	.n_reg_rules = 6,
+	.alpha2 =  "99",
+	.reg_rules = {
+		REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0),
+		REG_RULE(2484 - 10, 2484 + 10, 40, 0, 20, 0),
+		REG_RULE(5150 - 10, 5240 + 10, 80, 0, 30, 0),
+		REG_RULE(5260 - 10, 5320 + 10, 80, 0, 30,
+			 NL80211_RRF_DFS_CONCURRENT | NL80211_RRF_DFS),
+		REG_RULE(5745 - 10, 5825 + 10, 80, 0, 30, 0),
+		REG_RULE(5855 - 10, 5925 + 10, 80, 0, 33, 0),
+	}
+};
+
 static const struct ieee80211_regdomain *hwsim_world_regdom_custom[] = {
 	&hwsim_world_regdom_custom_01,
 	&hwsim_world_regdom_custom_02,
 	&hwsim_world_regdom_custom_03,
+	&hwsim_world_regdom_custom_04,
 };
 
 struct hwsim_vif_priv {
@@ -5288,6 +5303,10 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
 		schedule_timeout_interruptible(1);
 	}
 
+	/* TODO: Add param */
+	wiphy_ext_feature_set(hw->wiphy,
+			      NL80211_EXT_FEATURE_DFS_CONCURRENT);
+
 	if (param->no_vif)
 		ieee80211_hw_set(hw, NO_AUTO_VIF);
 
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change
  2023-11-13  9:35 ` [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change gregory.greenman
@ 2023-11-24 19:13   ` Johannes Berg
  2023-11-26  8:58     ` Otcheretianski, Andrei
  0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2023-11-24 19:13 UTC (permalink / raw)
  To: gregory.greenman; +Cc: linux-wireless, Andrei Otcheretianski

On Mon, 2023-11-13 at 11:35 +0200, gregory.greenman@intel.com wrote:
> 
> @@ -9302,6 +9302,17 @@ bool cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap,
>   * case disconnect instead.
>   * Also note that the wdev mutex must be held.
>   */
> +
>  void cfg80211_links_removed(struct net_device *dev, u16 link_mask);

What happened there?
 
> +/**
> + * cfg80211_schedule_channels_check - schedule regulatory check if needed
> + * @netdev: the device to check
> + *
> + * In case the device supports NO_IR or DFS relaxations, schedule regulatory
> + * channels check, as previous concurrent operation conditions may not
> + * hold anymore.
> + */

...

> +void cfg80211_schedule_channels_check(struct net_device *netdev)
> +{
> +	struct wireless_dev *wdev = netdev->ieee80211_ptr;
> +	struct wiphy *wiphy = wdev->wiphy;
> +
> +	/* Schedule channels check if NO_IR or DFS relaxations are supported */
> +	if (wdev->iftype == NL80211_IFTYPE_STATION &&
> +	    (wiphy_ext_feature_isset(wiphy,
> +				     NL80211_EXT_FEATURE_DFS_CONCURRENT) ||
> +	    (IS_ENABLED(CONFIG_CFG80211_REG_RELAX_NO_IR) &&
> +	     wiphy->regulatory_flags & REGULATORY_ENABLE_RELAX_NO_IR)))
> +		reg_check_channels();
> +}

That ... doesn't even use the netdev pointer, apart from going to the
wiphy? Why not have a wiphy argument instead?

johannes


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/6] wifi: mac80211_hwsim: Add custom reg for DFS concurrent
  2023-11-13  9:35 ` [PATCH 6/6] wifi: mac80211_hwsim: Add custom reg for DFS concurrent gregory.greenman
@ 2023-11-24 19:17   ` Johannes Berg
  2023-11-28  8:39     ` Otcheretianski, Andrei
  0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2023-11-24 19:17 UTC (permalink / raw)
  To: gregory.greenman; +Cc: linux-wireless, Andrei Otcheretianski

On Mon, 2023-11-13 at 11:35 +0200, gregory.greenman@intel.com wrote:
>  
> +static const struct ieee80211_regdomain hwsim_world_regdom_custom_04 = {
> +	.n_reg_rules = 6,
> +	.alpha2 =  "99",
> +	.reg_rules = {
> +		REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0),
> +		REG_RULE(2484 - 10, 2484 + 10, 40, 0, 20, 0),
> +		REG_RULE(5150 - 10, 5240 + 10, 80, 0, 30, 0),

Didn't you say that could be 160? But that'd need merging with the next
range or auto-bw.

> +	/* TODO: Add param */
> +	wiphy_ext_feature_set(hw->wiphy,
> +			      NL80211_EXT_FEATURE_DFS_CONCURRENT);

Hm, yes? :)

johannes

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13
  2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
                   ` (5 preceding siblings ...)
  2023-11-13  9:35 ` [PATCH 6/6] wifi: mac80211_hwsim: Add custom reg for DFS concurrent gregory.greenman
@ 2023-11-24 19:36 ` Johannes Berg
  6 siblings, 0 replies; 14+ messages in thread
From: Johannes Berg @ 2023-11-24 19:36 UTC (permalink / raw)
  To: gregory.greenman; +Cc: linux-wireless

> 
> Ilan Peer (2):
>   wifi: cfg80211: Extend support for scanning while MLO connected
>   wifi: mac80211: Extend support for scanning while MLO connected
> 

For the record, I've applied these two, didn't seem appropriate to only
partially apply the DFS-concurrent patches.

johannes

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change
  2023-11-24 19:13   ` Johannes Berg
@ 2023-11-26  8:58     ` Otcheretianski, Andrei
  2023-11-26 13:19       ` Johannes Berg
  0 siblings, 1 reply; 14+ messages in thread
From: Otcheretianski, Andrei @ 2023-11-26  8:58 UTC (permalink / raw)
  To: Johannes Berg, Greenman, Gregory; +Cc: linux-wireless

> cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap,
> >   * case disconnect instead.
> >   * Also note that the wdev mutex must be held.
> >   */
> > +
> >  void cfg80211_links_removed(struct net_device *dev, u16 link_mask);
> 
> What happened there?

No idea, it wasn't in the original patch.. Will recheck with Gregory and fix it.

> 
> > +void cfg80211_schedule_channels_check(struct net_device *netdev) {
> > +	struct wireless_dev *wdev = netdev->ieee80211_ptr;
> > +	struct wiphy *wiphy = wdev->wiphy;
> > +
> > +	/* Schedule channels check if NO_IR or DFS relaxations are
> supported */
> > +	if (wdev->iftype == NL80211_IFTYPE_STATION &&
> > +	    (wiphy_ext_feature_isset(wiphy,
> > +
> NL80211_EXT_FEATURE_DFS_CONCURRENT) ||
> > +	    (IS_ENABLED(CONFIG_CFG80211_REG_RELAX_NO_IR) &&
> > +	     wiphy->regulatory_flags &
> REGULATORY_ENABLE_RELAX_NO_IR)))
> > +		reg_check_channels();
> > +}
> 
> That ... doesn't even use the netdev pointer, apart from going to the wiphy?
> Why not have a wiphy argument instead?

We do need wdev here, I will change it to be wireless device instead

> 
> johannes


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change
  2023-11-26  8:58     ` Otcheretianski, Andrei
@ 2023-11-26 13:19       ` Johannes Berg
  2023-11-28  8:26         ` Otcheretianski, Andrei
  0 siblings, 1 reply; 14+ messages in thread
From: Johannes Berg @ 2023-11-26 13:19 UTC (permalink / raw)
  To: Otcheretianski, Andrei, Greenman, Gregory; +Cc: linux-wireless

> 
> > 
> > > +void cfg80211_schedule_channels_check(struct net_device *netdev) {
> > > +	struct wireless_dev *wdev = netdev->ieee80211_ptr;
> > > +	struct wiphy *wiphy = wdev->wiphy;
> > > +
> > > +	/* Schedule channels check if NO_IR or DFS relaxations are
> > supported */
> > > +	if (wdev->iftype == NL80211_IFTYPE_STATION &&
> > > +	    (wiphy_ext_feature_isset(wiphy,
> 
> We do need wdev here, 
> 

Oh right, I missed that, sorry.

> I will change it to be wireless device instead
> 

No need I guess, if we're only going to check for it being a station?
Would we ever have a reason to call this for a p2p/nan device? I guess
not, since that doesn't affect regulatory in the same way?

johannes

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change
  2023-11-26 13:19       ` Johannes Berg
@ 2023-11-28  8:26         ` Otcheretianski, Andrei
  0 siblings, 0 replies; 14+ messages in thread
From: Otcheretianski, Andrei @ 2023-11-28  8:26 UTC (permalink / raw)
  To: Johannes Berg, Greenman, Gregory; +Cc: linux-wireless

> > > > +void cfg80211_schedule_channels_check(struct net_device *netdev)
> {
> > > > +	struct wireless_dev *wdev = netdev->ieee80211_ptr;
> > > > +	struct wiphy *wiphy = wdev->wiphy;
> > > > +
> > > > +	/* Schedule channels check if NO_IR or DFS relaxations are
> > > supported */
> > > > +	if (wdev->iftype == NL80211_IFTYPE_STATION &&
> > > > +	    (wiphy_ext_feature_isset(wiphy,
> >
> > We do need wdev here,
> >
> 
> Oh right, I missed that, sorry.
> 
> > I will change it to be wireless device instead
> >
> 
> No need I guess, if we're only going to check for it being a station?
> Would we ever have a reason to call this for a p2p/nan device? I guess
> not, since that doesn't affect regulatory in the same way?

No, I don't think P2P/NAN devices can anyhow affect regulatory, for sure not for concurrent DFS case.

> 
> johannes

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 6/6] wifi: mac80211_hwsim: Add custom reg for DFS concurrent
  2023-11-24 19:17   ` Johannes Berg
@ 2023-11-28  8:39     ` Otcheretianski, Andrei
  0 siblings, 0 replies; 14+ messages in thread
From: Otcheretianski, Andrei @ 2023-11-28  8:39 UTC (permalink / raw)
  To: Johannes Berg, Greenman, Gregory; +Cc: linux-wireless

> > +static const struct ieee80211_regdomain
> hwsim_world_regdom_custom_04 = {
> > +	.n_reg_rules = 6,
> > +	.alpha2 =  "99",
> > +	.reg_rules = {
> > +		REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0),
> > +		REG_RULE(2484 - 10, 2484 + 10, 40, 0, 20, 0),
> > +		REG_RULE(5150 - 10, 5240 + 10, 80, 0, 30, 0),
> 
> Didn't you say that could be 160? But that'd need merging with the next
> range or auto-bw.

The entire range here is 80, so 160 doesn't make sense here.
I will add auto_bw here similar to what we have in world_regdom.
And also the second DFS range with 160.

> 
> > +	/* TODO: Add param */
> > +	wiphy_ext_feature_set(hw->wiphy,
> > +			      NL80211_EXT_FEATURE_DFS_CONCURRENT);
> 
> Hm, yes? :)

Actually, as ,mac80211_hwsim should be anyway started with custom regdom, I don't think now that an addition module param is still needed.
I will just remove the TODO here.

> 
> johannes

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-11-28  8:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13  9:34 [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 gregory.greenman
2023-11-13  9:35 ` [PATCH 1/6] wifi: cfg80211: Extend support for scanning while MLO connected gregory.greenman
2023-11-13  9:35 ` [PATCH 2/6] wifi: mac80211: " gregory.greenman
2023-11-13  9:35 ` [PATCH 3/6] wifi: cfg80211: reg: Support P2P operation on DFS channels gregory.greenman
2023-11-13  9:35 ` [PATCH 4/6] wifi: cfg80211: Schedule regulatory check on BSS STA channel change gregory.greenman
2023-11-24 19:13   ` Johannes Berg
2023-11-26  8:58     ` Otcheretianski, Andrei
2023-11-26 13:19       ` Johannes Berg
2023-11-28  8:26         ` Otcheretianski, Andrei
2023-11-13  9:35 ` [PATCH 5/6] wifi: mac80211: Schedule regulatory channels check on bandwith change gregory.greenman
2023-11-13  9:35 ` [PATCH 6/6] wifi: mac80211_hwsim: Add custom reg for DFS concurrent gregory.greenman
2023-11-24 19:17   ` Johannes Berg
2023-11-28  8:39     ` Otcheretianski, Andrei
2023-11-24 19:36 ` [PATCH 0/6] cfg80211/mac80211 patches from our internal tree 2023-11-13 Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).