diff mbox series

[02/22] cfg80211: regulatory: pass min. bandwidth to regulatory rule extractor

Message ID 20200827223304.16155-3-thomas@adapt-ip.com (mailing list archive)
State Superseded
Delegated to: Johannes Berg
Headers show
Series add initial S1G support | expand

Commit Message

Thomas Pedersen Aug. 27, 2020, 10:32 p.m. UTC
The regulatory code assumed 20Mhz is the minimum channel
bandwidth supported. Make this a parameter so S1G code can
pass smaller bandwidths.

Signed-off-by: Thomas Pedersen <thomas@adapt-ip.com>
---
 drivers/net/wireless/ath/regd.c                            | 2 +-
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c | 3 ++-
 drivers/net/wireless/realtek/rtlwifi/regd.c                | 7 ++++---
 include/net/cfg80211.h                                     | 3 ++-
 net/mac80211/util.c                                        | 2 +-
 net/wireless/nl80211.c                                     | 3 ++-
 net/wireless/reg.c                                         | 7 ++++---
 7 files changed, 16 insertions(+), 11 deletions(-)

Comments

kernel test robot Aug. 28, 2020, 1:38 a.m. UTC | #1
Hi Thomas,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20200827]
[also build test ERROR 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
config: riscv-allyesconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=riscv 

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

All errors (new ones prefixed by >>):

   drivers/net/wireless/realtek/rtw88/regd.c: In function 'rtw_regd_apply_beaconing_flags':
>> drivers/net/wireless/realtek/rtw88/regd.c:279:15: error: too few arguments to function 'freq_reg_info'
     279 |    reg_rule = freq_reg_info(wiphy,
         |               ^~~~~~~~~~~~~
   In file included from include/net/mac80211.h:21,
                    from drivers/net/wireless/realtek/rtw88/main.h:8,
                    from drivers/net/wireless/realtek/rtw88/regd.c:5:
   include/net/cfg80211.h:5880:34: note: declared here
    5880 | const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
         |                                  ^~~~~~~~~~~~~
   In file included from include/linux/energy_model.h:10,
                    from include/linux/device.h:16,
                    from include/linux/dma-mapping.h:7,
                    from include/linux/skbuff.h:31,
                    from include/linux/if_ether.h:19,
                    from include/net/mac80211.h:18,
                    from drivers/net/wireless/realtek/rtw88/main.h:8,
                    from drivers/net/wireless/realtek/rtw88/regd.c:5:
   At top level:
   include/linux/sched/topology.h:40:3: warning: 'sd_flag_debug' defined but not used [-Wunused-const-variable=]
      40 | } sd_flag_debug[] = {
         |   ^~~~~~~~~~~~~
   In file included from include/linux/energy_model.h:10,
                    from include/linux/device.h:16,
                    from include/linux/dma-mapping.h:7,
                    from include/linux/skbuff.h:31,
                    from include/linux/if_ether.h:19,
                    from include/net/mac80211.h:18,
                    from drivers/net/wireless/realtek/rtw88/main.h:8,
                    from drivers/net/wireless/realtek/rtw88/regd.c:5:
   include/linux/sched/topology.h:30:27: warning: 'SD_DEGENERATE_GROUPS_MASK' defined but not used [-Wunused-const-variable=]
      30 | static const unsigned int SD_DEGENERATE_GROUPS_MASK =
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~

# https://github.com/0day-ci/linux/commit/cc241e6d10cc9d9bef4ab40d2989677df2623bd9
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 cc241e6d10cc9d9bef4ab40d2989677df2623bd9
vim +/freq_reg_info +279 drivers/net/wireless/realtek/rtw88/regd.c

e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  261  
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  262  static void rtw_regd_apply_beaconing_flags(struct wiphy *wiphy,
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  263  					   enum nl80211_reg_initiator initiator)
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  264  {
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  265  	enum nl80211_band band;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  266  	struct ieee80211_supported_band *sband;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  267  	const struct ieee80211_reg_rule *reg_rule;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  268  	struct ieee80211_channel *ch;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  269  	unsigned int i;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  270  
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  271  	for (band = 0; band < NUM_NL80211_BANDS; band++) {
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  272  		if (!wiphy->bands[band])
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  273  			continue;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  274  
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  275  		sband = wiphy->bands[band];
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  276  		for (i = 0; i < sband->n_channels; i++) {
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  277  			ch = &sband->channels[i];
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  278  
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26 @279  			reg_rule = freq_reg_info(wiphy,
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  280  						 MHZ_TO_KHZ(ch->center_freq));
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  281  			if (IS_ERR(reg_rule))
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  282  				continue;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  283  
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  284  			ch->flags &= ~IEEE80211_CHAN_DISABLED;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  285  
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  286  			if (!(reg_rule->flags & NL80211_RRF_NO_IR))
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  287  				ch->flags &= ~IEEE80211_CHAN_NO_IR;
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  288  		}
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  289  	}
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  290  }
e3037485c68ec1a Yan-Hsuan Chuang 2019-04-26  291  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Thomas Pedersen Aug. 28, 2020, 6:21 a.m. UTC | #2
On 2020-08-27 15:32, Thomas Pedersen wrote:

> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index 35b8847a2f6d..6c130cec22c3 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -1629,9 +1629,10 @@ __freq_reg_info(struct wiphy *wiphy, u32
> center_freq, u32 min_bw)
>  }
> 
>  const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
> -					       u32 center_freq)
> +					       u32 center_freq,
> +					       u32 min_bw)
>  {
> -	return __freq_reg_info(wiphy, center_freq, MHZ_TO_KHZ(20));
> +	return __freq_reg_info(wiphy, center_freq, MHZ_TO_KHZ(min_bw));
>  }
>  EXPORT_SYMBOL(freq_reg_info);

Actually, it would be cleaner to keep the freq_reg_info() interface 
intact,
then set min_bw = 1 if center_freq is in the S1G band. The call to
freq_reg_info() for successively smaller bandwidths in the next patch 
could
just call __freq_reg_info() directly. Will fix in v2.
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index bee9110b91f3..f9c9ac16d2da 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -268,7 +268,7 @@  static void ath_force_clear_no_ir_chan(struct wiphy *wiphy,
 {
 	const struct ieee80211_reg_rule *reg_rule;
 
-	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
+	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq), 20);
 	if (IS_ERR(reg_rule))
 		return;
 
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c
index 5a6d9c86552a..d85b2707e2fa 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c
@@ -677,7 +677,8 @@  brcms_reg_apply_beaconing_flags(struct wiphy *wiphy,
 
 			if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
 				rule = freq_reg_info(wiphy,
-						     MHZ_TO_KHZ(ch->center_freq));
+						MHZ_TO_KHZ(ch->center_freq),
+						20);
 				if (IS_ERR(rule))
 					continue;
 
diff --git a/drivers/net/wireless/realtek/rtlwifi/regd.c b/drivers/net/wireless/realtek/rtlwifi/regd.c
index 8be31e0ad878..3f9dd4941bb1 100644
--- a/drivers/net/wireless/realtek/rtlwifi/regd.c
+++ b/drivers/net/wireless/realtek/rtlwifi/regd.c
@@ -151,7 +151,8 @@  static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
 				continue;
 			if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
 				reg_rule = freq_reg_info(wiphy,
-							 ch->center_freq);
+							 ch->center_freq,
+							 20);
 				if (IS_ERR(reg_rule))
 					continue;
 				/*
@@ -213,7 +214,7 @@  static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
 	 */
 
 	ch = &sband->channels[11];	/* CH 12 */
-	reg_rule = freq_reg_info(wiphy, ch->center_freq);
+	reg_rule = freq_reg_info(wiphy, ch->center_freq, 20);
 	if (!IS_ERR(reg_rule)) {
 		if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
 			if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
@@ -221,7 +222,7 @@  static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
 	}
 
 	ch = &sband->channels[12];	/* CH 13 */
-	reg_rule = freq_reg_info(wiphy, ch->center_freq);
+	reg_rule = freq_reg_info(wiphy, ch->center_freq, 20);
 	if (!IS_ERR(reg_rule)) {
 		if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
 			if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 3db0444086e2..2c737d6be9a1 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5862,6 +5862,7 @@  void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
  * freq_reg_info - get regulatory information for the given frequency
  * @wiphy: the wiphy for which we want to process this rule for
  * @center_freq: Frequency in KHz for which we want regulatory information for
+ * @min_bw: Minimum channel bandwidth in MHz for which we want regulatory information for
  *
  * Use this function to get the regulatory rule for a specific frequency on
  * a given wireless device. If the device has a specific regulatory domain
@@ -5877,7 +5878,7 @@  void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
  * purely subjective and right now it's 802.11 specific.
  */
 const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
-					       u32 center_freq);
+					       u32 center_freq, u32 min_bw);
 
 /**
  * reg_initiator_name - map regulatory request initiator enum to name
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index c8504ffc71a1..9ba1afe4ba1f 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1453,7 +1453,7 @@  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));
+	rrule = freq_reg_info(sdata->wdev.wiphy, MHZ_TO_KHZ(center_freq), 20);
 
 	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 5aded5de35cd..dd0f62e942ed 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1013,7 +1013,8 @@  static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy,
 
 	if (large) {
 		const struct ieee80211_reg_rule *rule =
-			freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq));
+			freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq),
+				      20);
 
 		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 35b8847a2f6d..6c130cec22c3 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1629,9 +1629,10 @@  __freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 min_bw)
 }
 
 const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
-					       u32 center_freq)
+					       u32 center_freq,
+					       u32 min_bw)
 {
-	return __freq_reg_info(wiphy, center_freq, MHZ_TO_KHZ(20));
+	return __freq_reg_info(wiphy, center_freq, MHZ_TO_KHZ(min_bw));
 }
 EXPORT_SYMBOL(freq_reg_info);
 
@@ -1711,7 +1712,7 @@  static void handle_channel(struct wiphy *wiphy,
 
 	flags = chan->orig_flags;
 
-	reg_rule = freq_reg_info(wiphy, ieee80211_channel_to_khz(chan));
+	reg_rule = freq_reg_info(wiphy, ieee80211_channel_to_khz(chan), 20);
 	if (IS_ERR(reg_rule)) {
 		/*
 		 * We will disable all channels that do not match our