All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 03/22] cfg80211: regulatory: handle S1G channels
@ 2020-08-28  2:28 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2020-08-28  2:28 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7167 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20200827223304.16155-4-thomas@adapt-ip.com>
References: <20200827223304.16155-4-thomas@adapt-ip.com>
TO: Thomas Pedersen <thomas@adapt-ip.com>
TO: Johannes Berg <johannes@sipsolutions.net>
CC: "linux-wireless" <linux-wireless@vger.kernel.org>
CC: Thomas Pedersen <thomas@adapt-ip.com>

Hi Thomas,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20200827]
[also build test WARNING on v5.9-rc2]
[cannot apply to mac80211-next/master mac80211/master wireless-drivers-next/master wireless-drivers/master v5.9-rc2 v5.9-rc1 v5.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Thomas-Pedersen/add-initial-S1G-support/20200828-063630
base:    88abac0b753dfdd85362a26d2da8277cb1e0842b
:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago
compiler: alpha-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck warnings: (new ones prefixed by >>)

>> net/mac80211/util.c:1456:11: warning: Either the condition 'chanctx_conf' is redundant or there is possible null pointer dereference: chanctx_conf. [nullPointerRedundantCheck]
    min_bw = chanctx_conf->def.chan->band == NL80211_BAND_S1GHZ ? 1 : 20;
             ^
   net/mac80211/util.c:1448:6: note: Assuming that condition 'chanctx_conf' is not redundant
    if (chanctx_conf)
        ^
   net/mac80211/util.c:1456:11: note: Null pointer dereference
    min_bw = chanctx_conf->def.chan->band == NL80211_BAND_S1GHZ ? 1 : 20;
             ^
   net/mac80211/util.c:1587:56: warning: Function 'ieee80211_send_auth' argument order different: declaration 'sdata, transaction, auth_alg, status, extra, extra_len, bssid, da, key, key_len, key_idx, tx_flags' definition 'sdata, transaction, auth_alg, status, extra, extra_len, da, bssid, key, key_len, key_idx, tx_flags' [funcArgOrderDifferent]
   void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
                                                          ^
   net/mac80211/ieee80211_i.h:2129:56: note: Function 'ieee80211_send_auth' argument order different: declaration 'sdata, transaction, auth_alg, status, extra, extra_len, bssid, da, key, key_len, key_idx, tx_flags' definition 'sdata, transaction, auth_alg, status, extra, extra_len, da, bssid, key, key_len, key_idx, tx_flags'
   void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
                                                          ^
   net/mac80211/util.c:1587:56: note: Function 'ieee80211_send_auth' argument order different: declaration 'sdata, transaction, auth_alg, status, extra, extra_len, bssid, da, key, key_len, key_idx, tx_flags' definition 'sdata, transaction, auth_alg, status, extra, extra_len, da, bssid, key, key_len, key_idx, tx_flags'
   void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
                                                          ^

# https://github.com/0day-ci/linux/commit/241a925b241ed8977ba3eb94e0b81fd2cc389f2e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Thomas-Pedersen/add-initial-S1G-support/20200828-063630
git checkout 241a925b241ed8977ba3eb94e0b81fd2cc389f2e
vim +/chanctx_conf +1456 net/mac80211/util.c

78ac51f81532c1 Sara Sharon       2019-01-16  1432  
e552af05814849 Haim Dreyfuss     2018-03-28  1433  void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata,
e552af05814849 Haim Dreyfuss     2018-03-28  1434  					   struct ieee80211_tx_queue_params
e552af05814849 Haim Dreyfuss     2018-03-28  1435  					   *qparam, int ac)
e552af05814849 Haim Dreyfuss     2018-03-28  1436  {
e552af05814849 Haim Dreyfuss     2018-03-28  1437  	struct ieee80211_chanctx_conf *chanctx_conf;
e552af05814849 Haim Dreyfuss     2018-03-28  1438  	const struct ieee80211_reg_rule *rrule;
38cb87ee47fb82 Stanislaw Gruszka 2018-08-22  1439  	const struct ieee80211_wmm_ac *wmm_ac;
241a925b241ed8 Thomas Pedersen   2020-08-27  1440  	u16 min_bw, center_freq = 0;
e552af05814849 Haim Dreyfuss     2018-03-28  1441  
e552af05814849 Haim Dreyfuss     2018-03-28  1442  	if (sdata->vif.type != NL80211_IFTYPE_AP &&
e552af05814849 Haim Dreyfuss     2018-03-28  1443  	    sdata->vif.type != NL80211_IFTYPE_STATION)
e552af05814849 Haim Dreyfuss     2018-03-28  1444  		return;
e552af05814849 Haim Dreyfuss     2018-03-28  1445  
e552af05814849 Haim Dreyfuss     2018-03-28  1446  	rcu_read_lock();
e552af05814849 Haim Dreyfuss     2018-03-28  1447  	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
e552af05814849 Haim Dreyfuss     2018-03-28  1448  	if (chanctx_conf)
e552af05814849 Haim Dreyfuss     2018-03-28  1449  		center_freq = chanctx_conf->def.chan->center_freq;
e552af05814849 Haim Dreyfuss     2018-03-28  1450  
e552af05814849 Haim Dreyfuss     2018-03-28  1451  	if (!center_freq) {
e552af05814849 Haim Dreyfuss     2018-03-28  1452  		rcu_read_unlock();
e552af05814849 Haim Dreyfuss     2018-03-28  1453  		return;
e552af05814849 Haim Dreyfuss     2018-03-28  1454  	}
e552af05814849 Haim Dreyfuss     2018-03-28  1455  
241a925b241ed8 Thomas Pedersen   2020-08-27 @1456  	min_bw = chanctx_conf->def.chan->band == NL80211_BAND_S1GHZ ? 1 : 20;
241a925b241ed8 Thomas Pedersen   2020-08-27  1457  	rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq),
241a925b241ed8 Thomas Pedersen   2020-08-27  1458  			      min_bw);
e552af05814849 Haim Dreyfuss     2018-03-28  1459  
38cb87ee47fb82 Stanislaw Gruszka 2018-08-22  1460  	if (IS_ERR_OR_NULL(rrule) || !rrule->has_wmm) {
e552af05814849 Haim Dreyfuss     2018-03-28  1461  		rcu_read_unlock();
e552af05814849 Haim Dreyfuss     2018-03-28  1462  		return;
e552af05814849 Haim Dreyfuss     2018-03-28  1463  	}
e552af05814849 Haim Dreyfuss     2018-03-28  1464  
e552af05814849 Haim Dreyfuss     2018-03-28  1465  	if (sdata->vif.type == NL80211_IFTYPE_AP)
38cb87ee47fb82 Stanislaw Gruszka 2018-08-22  1466  		wmm_ac = &rrule->wmm_rule.ap[ac];
e552af05814849 Haim Dreyfuss     2018-03-28  1467  	else
38cb87ee47fb82 Stanislaw Gruszka 2018-08-22  1468  		wmm_ac = &rrule->wmm_rule.client[ac];
e552af05814849 Haim Dreyfuss     2018-03-28  1469  	qparam->cw_min = max_t(u16, qparam->cw_min, wmm_ac->cw_min);
e552af05814849 Haim Dreyfuss     2018-03-28  1470  	qparam->cw_max = max_t(u16, qparam->cw_max, wmm_ac->cw_max);
e552af05814849 Haim Dreyfuss     2018-03-28  1471  	qparam->aifs = max_t(u8, qparam->aifs, wmm_ac->aifsn);
abd76d255d69d7 Dreyfuss, Haim    2018-08-31  1472  	qparam->txop = min_t(u16, qparam->txop, wmm_ac->cot / 32);
e552af05814849 Haim Dreyfuss     2018-03-28  1473  	rcu_read_unlock();
e552af05814849 Haim Dreyfuss     2018-03-28  1474  }
e552af05814849 Haim Dreyfuss     2018-03-28  1475  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* [PATCH 03/22] cfg80211: regulatory: handle S1G channels
  2020-08-27 22:32 [PATCH 00/22] add initial S1G support Thomas Pedersen
@ 2020-08-27 22:32 ` Thomas Pedersen
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Pedersen @ 2020-08-27 22:32 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Thomas Pedersen

S1G channels have a minimum bandwidth of 1Mhz, and there
is a 1:1 mapping of allowed bandwidth to channel number.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
---
 net/mac80211/util.c    |  6 ++--
 net/wireless/nl80211.c |  3 +-
 net/wireless/reg.c     | 69 ++++++++++++++++++++++++++++++++++--------
 3 files changed, 63 insertions(+), 15 deletions(-)

diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 9ba1afe4ba1f..35798997e521 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1437,7 +1437,7 @@ void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata,
 	struct ieee80211_chanctx_conf *chanctx_conf;
 	const struct ieee80211_reg_rule *rrule;
 	const struct ieee80211_wmm_ac *wmm_ac;
-	u16 center_freq = 0;
+	u16 min_bw, center_freq = 0;
 
 	if (sdata->vif.type != NL80211_IFTYPE_AP &&
 	    sdata->vif.type != NL80211_IFTYPE_STATION)
@@ -1453,7 +1453,9 @@ void ieee80211_regulatory_limit_wmm_params(struct ieee80211_sub_if_data *sdata,
 		return;
 	}
 
-	rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq), 20);
+	min_bw = chanctx_conf->def.chan->band == NL80211_BAND_S1GHZ ? 1 : 20;
+	rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq),
+			      min_bw);
 
 	if (IS_ERR_OR_NULL(rrule) || !rrule->has_wmm) {
 		rcu_read_unlock();
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index dd0f62e942ed..a57872708108 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1012,9 +1012,10 @@ static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy,
 		goto nla_put_failure;
 
 	if (large) {
+		u32 min_bw = chan->band == NL80211_BAND_S1GHZ ? 1 : 20;
 		const struct ieee80211_reg_rule *rule =
 			freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq),
-				      20);
+				      min_bw);
 
 		if (!IS_ERR_OR_NULL(rule) && rule->has_wmm) {
 			if (nl80211_msg_put_wmm_rules(msg, rule))
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 6c130cec22c3..f23ca3103558 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1617,9 +1617,11 @@ __freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 min_bw)
 {
 	const struct ieee80211_regdomain *regd = reg_get_regdomain(wiphy);
 	const struct ieee80211_reg_rule *reg_rule = NULL;
+	const u32 bws[] = {1, 2, 4, 5, 8, 10, 16, 20};
+	int i = sizeof(bws) / sizeof(u32) - 1;
 	u32 bw;
 
-	for (bw = MHZ_TO_KHZ(20); bw >= min_bw; bw = bw / 2) {
+	for (bw = MHZ_TO_KHZ(bws[i]); bw >= min_bw; bw = MHZ_TO_KHZ(bws[i--])) {
 		reg_rule = freq_reg_info_regd(center_freq, regd, bw);
 		if (!IS_ERR(reg_rule))
 			return reg_rule;
@@ -1660,6 +1662,7 @@ static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd
 {
 	const struct ieee80211_freq_range *freq_range = NULL;
 	u32 max_bandwidth_khz, center_freq_khz, bw_flags = 0;
+	bool is_s1g = chan->band == NL80211_BAND_S1GHZ;
 
 	freq_range = &reg_rule->freq_range;
 
@@ -1679,16 +1682,57 @@ static uint32_t reg_rule_to_chan_bw_flags(const struct ieee80211_regdomain *regd
 					MHZ_TO_KHZ(20)))
 		bw_flags |= IEEE80211_CHAN_NO_20MHZ;
 
-	if (max_bandwidth_khz < MHZ_TO_KHZ(10))
-		bw_flags |= IEEE80211_CHAN_NO_10MHZ;
-	if (max_bandwidth_khz < MHZ_TO_KHZ(20))
-		bw_flags |= IEEE80211_CHAN_NO_20MHZ;
-	if (max_bandwidth_khz < MHZ_TO_KHZ(40))
-		bw_flags |= IEEE80211_CHAN_NO_HT40;
-	if (max_bandwidth_khz < MHZ_TO_KHZ(80))
-		bw_flags |= IEEE80211_CHAN_NO_80MHZ;
-	if (max_bandwidth_khz < MHZ_TO_KHZ(160))
-		bw_flags |= IEEE80211_CHAN_NO_160MHZ;
+	if (is_s1g) {
+		/* S1G is strict about non overlapping channels. We can
+		 * calculate which bandwidth is allowed per channel by finding
+		 * the largest bandwidth which cleanly divides the freq_range.
+		 */
+		int edge_offset;
+		int ch_bw = max_bandwidth_khz;
+
+		while (ch_bw) {
+			edge_offset = (center_freq_khz - ch_bw / 2) -
+				      freq_range->start_freq_khz;
+			if (edge_offset % ch_bw == 0) {
+				switch (KHZ_TO_MHZ(ch_bw)) {
+				case 1:
+					bw_flags |= IEEE80211_CHAN_1MHZ;
+					break;
+				case 2:
+					bw_flags |= IEEE80211_CHAN_2MHZ;
+					break;
+				case 4:
+					bw_flags |= IEEE80211_CHAN_4MHZ;
+					break;
+				case 8:
+					bw_flags |= IEEE80211_CHAN_8MHZ;
+					break;
+				case 16:
+					bw_flags |= IEEE80211_CHAN_16MHZ;
+					break;
+				default:
+					/* If we got here, no bandwidths fit on
+					 * this frequency, ie. band edge.
+					 */
+					bw_flags |= IEEE80211_CHAN_DISABLED;
+					break;
+				}
+				break;
+			}
+			ch_bw /= 2;
+		}
+	} else {
+		if (max_bandwidth_khz < MHZ_TO_KHZ(10))
+			bw_flags |= IEEE80211_CHAN_NO_10MHZ;
+		if (max_bandwidth_khz < MHZ_TO_KHZ(20))
+			bw_flags |= IEEE80211_CHAN_NO_20MHZ;
+		if (max_bandwidth_khz < MHZ_TO_KHZ(40))
+			bw_flags |= IEEE80211_CHAN_NO_HT40;
+		if (max_bandwidth_khz < MHZ_TO_KHZ(80))
+			bw_flags |= IEEE80211_CHAN_NO_80MHZ;
+		if (max_bandwidth_khz < MHZ_TO_KHZ(160))
+			bw_flags |= IEEE80211_CHAN_NO_160MHZ;
+	}
 	return bw_flags;
 }
 
@@ -1707,12 +1751,13 @@ static void handle_channel(struct wiphy *wiphy,
 	struct wiphy *request_wiphy = NULL;
 	struct regulatory_request *lr = get_last_request();
 	const struct ieee80211_regdomain *regd;
+	u32 min_bw = chan->band == NL80211_BAND_S1GHZ ? 1 : 20;
 
 	request_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx);
 
 	flags = chan->orig_flags;
 
-	reg_rule = freq_reg_info(wiphy, ieee80211_channel_to_khz(chan), 20);
+	reg_rule = freq_reg_info(wiphy, ieee80211_channel_to_khz(chan), min_bw);
 	if (IS_ERR(reg_rule)) {
 		/*
 		 * We will disable all channels that do not match our
-- 
2.20.1


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

end of thread, other threads:[~2020-08-28  2:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28  2:28 [PATCH 03/22] cfg80211: regulatory: handle S1G channels kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-08-27 22:32 [PATCH 00/22] add initial S1G support Thomas Pedersen
2020-08-27 22:32 ` [PATCH 03/22] cfg80211: regulatory: handle S1G channels Thomas Pedersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.