rtw88: update regulatory settings
v6 cover rtw88: update regulatory settings
From: Yan-Hsuan Chuang <[email protected]>
This patchset applies regulatory rules for Realtek's chip set.
Some of the modules are programmed country-specific code in the efuse. And for this kind of modules, driver doesn't want the regulatory to be changed, so the driver tends to not listen to the regulatory hint that is notified by the stack. Otherwise if the modules are not programmed to a country-specific code, then the world-wide (WW) settings will be adopted. If the regulatory is WW, the driver will apply the settings notified by the stack.
If anyone wants to allow regulatory being set from user-space tools (ex: iw reg set), a compile option flag RTW88_REGD_USER_REG_HINTS should be set to allow regulatory hist from user.
Also add "Adaptivity" support for some special country codes, because they have to stop TX immediately if there's any energy detected.
v2 -> v3
* split patch set for further discussion
v3 -> v4
* squash patch set, since nobody has different idea for it
* "rtw88: add regulatory process strategy for different chipset" and "rtw88: support dynamic user regulatory setting" are squashed
* modify the commit log to better describe it
* add a new patch for adaptivity support "rtw88: add adaptivity support for EU/JP regulatory"
v4 -> v5
* check return value of kstrtobool()
v5 -> v6
* remove custom world-wide, use stack world-wide
* surface err codes by printing logs
* fix incorrect debugfs set parameter for edcca enable
Tzu-En Huang (2):
rtw88: add regulatory process strategy for different chipset
rtw88: add adaptivity support for EU/JP regulatory
drivers/net/wireless/realtek/rtw88/Kconfig | 10 +++ drivers/net/wireless/realtek/rtw88/debug.c | 40 ++++++++++ drivers/net/wireless/realtek/rtw88/main.c | 6 +- drivers/net/wireless/realtek/rtw88/main.h | 32 ++++++++ drivers/net/wireless/realtek/rtw88/phy.c | 60 +++++++++++++++ drivers/net/wireless/realtek/rtw88/phy.h | 2 + drivers/net/wireless/realtek/rtw88/reg.h | 2 + drivers/net/wireless/realtek/rtw88/regd.c | 75 ++++++++++++++++--- drivers/net/wireless/realtek/rtw88/regd.h | 2 + drivers/net/wireless/realtek/rtw88/rtw8822b.c | 41 ++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822b.h | 6 ++ drivers/net/wireless/realtek/rtw88/rtw8822c.c | 45 +++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822c.h | 2 + 13 files changed, 311 insertions(+), 12 deletions(-)
Signature · 1 line
2.17.1
PATCH v6 2/2 rtw88: add adaptivity support for EU/JP regulatory
From: Tzu-En Huang <[email protected]>
From MIC Ordinance Regulating Radio Equipment article 49.20, ETSI EN-300-328 and EN-301-893, the device should be able to dynamically pause TX activity when energy detected on the air.
To achieve this, add Energy Detected CCA (EDCCA) support to detect the energy in the channel. Driver will set corresponding thresholds to the device, if the energy detected exceeds the threshold, the TX activity will be halted immediately.
As this could lead to performance downgrade when the environment is noisy, add a debugfs to disable this for debugging usage.
---
v4
* first added
v4 -> v5
* check return value of kstrtobool()
v5 -> v6
* fix incorrect edcca set parameter
drivers/net/wireless/realtek/rtw88/debug.c | 40 +++++++++++++ drivers/net/wireless/realtek/rtw88/main.c | 1 + drivers/net/wireless/realtek/rtw88/main.h | 32 ++++++++++ drivers/net/wireless/realtek/rtw88/phy.c | 60 +++++++++++++++++++ drivers/net/wireless/realtek/rtw88/phy.h | 2 + drivers/net/wireless/realtek/rtw88/reg.h | 2 + drivers/net/wireless/realtek/rtw88/regd.c | 21 +++++++ drivers/net/wireless/realtek/rtw88/regd.h | 2 + drivers/net/wireless/realtek/rtw88/rtw8822b.c | 41 +++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822b.h | 6 ++ drivers/net/wireless/realtek/rtw88/rtw8822c.c | 45 ++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8822c.h | 2 + 12 files changed, 254 insertions(+)
drivers/net/wireless/realtek/rtw88/debug.c +40 -0
@@ -694,6 +694,40 @@ static int rtw_debugfs_get_phy_info(struct seq_file *m, void *v)return 0 ; } +static ssize_t rtw_debugfs_set_edcca_enable (struct file *filp, +const char __user *buffer, +size_t count,loff_t *loff) +{ +struct seq_file *seqpriv = (struct seq_file *)filp->private_data; +struct rtw_debugfs_priv *debugfs_priv = seqpriv->private; +struct rtw_dev *rtwdev = debugfs_priv->rtwdev; +char tmp[32 +1 ]; +int ret; + +rtw_debugfs_copy_from_user (tmp,sizeof (tmp), buffer, count,1 ); + + ret =kstrtobool (tmp, &rtw_edcca_enabled); +if (ret) { +rtw_warn (rtwdev,"invalid arguments\n" ); +return ret; + } + +rtw_phy_adaptivity_set_mode (rtwdev); + +return count; +} + +static int rtw_debugfs_get_edcca_enable (struct seq_file *m,void *v) +{ +struct rtw_debugfs_priv *debugfs_priv = m->private; +struct rtw_dev *rtwdev = debugfs_priv->rtwdev; +struct rtw_dm_info *dm_info = &rtwdev->dm_info; + +seq_printf (m,"EDCCA mode %d\n" , dm_info->edcca_mode); + +return 0 ; +} +#define rtw_debug_impl_mac (page, addr) \ static struct rtw_debugfs_priv rtw_debug_priv_mac_ ##page = { \ .cb_read = rtw_debug_get_mac_page, \
@@ -784,6 +818,11 @@ static struct rtw_debugfs_priv rtw_debug_priv_phy_info = { .cb_read = rtw_debugfs_get_phy_info, }; +static struct rtw_debugfs_priv rtw_debug_priv_edcca_enable = { + .cb_write = rtw_debugfs_set_edcca_enable, + .cb_read = rtw_debugfs_get_edcca_enable, +}; +#define rtw_debugfs_add_core (name, mode, fopname, parent) \ do { \ rtw_debug_priv_ ##name.rtwdev = rtwdev; \
@@ -854,6 +893,7 @@ void rtw_debugfs_init(struct rtw_dev *rtwdev) }rtw_debugfs_add_r (rf_dump);rtw_debugfs_add_r (tx_pwr_tbl); +rtw_debugfs_add_rw (edcca_enable); }#endif /* CONFIG_RTW88_DEBUGFS */
drivers/net/wireless/realtek/rtw88/main.c +1 -0
@@ -21,6 +21,7 @@ EXPORT_SYMBOL(rtw_fw_lps_deep_mode);bool rtw_bf_support = true;unsigned int rtw_debug_mask;EXPORT_SYMBOL (rtw_debug_mask); +bool rtw_edcca_enabled = true;module_param_named (lps_deep_mode, rtw_fw_lps_deep_mode, uint,0644 );module_param_named (support_bf, rtw_bf_support, bool,0644 );
drivers/net/wireless/realtek/rtw88/main.h +32 -0
@@ -38,6 +38,7 @@extern bool rtw_bf_support;extern unsigned int rtw_fw_lps_deep_mode;extern unsigned int rtw_debug_mask; +extern bool rtw_edcca_enabled;extern const struct ieee80211_ops rtw_ops;extern struct rtw_chip_info rtw8822b_hw_spec;extern struct rtw_chip_info rtw8822c_hw_spec;
@@ -327,6 +328,8 @@ enum rtw_trx_desc_rate { DESC_RATE_MAX, }; +#define RTW_REGION_INVALID 0xff +enum rtw_regulatory_domains {RTW_REGD_FCC =0 ,RTW_REGD_MKK =1 ,
@@ -515,6 +518,11 @@ struct rtw_hw_reg {u32 mask; }; +struct rtw_hw_reg_offset { +struct rtw_hw_reg hw_reg; +u8 offset; +}; +struct rtw_backup_info {u8 len;u32 reg;
@@ -765,6 +773,7 @@ struct rtw_regulatory {char alpha2[2 ];u8 chplan;u8 txpwr_regd; +enum nl80211_dfs_regions region; };struct rtw_chip_ops {
@@ -798,6 +807,8 @@ struct rtw_chip_ops { struct ieee80211_bss_conf *conf);void (*cfg_csi_rate)(struct rtw_dev *rtwdev,u8 rssi,u8 cur_rate,u8 fixrate_en,u8 *new_rate); +void (*adaptivity_init)(struct rtw_dev *rtwdev); +void (*adaptivity)(struct rtw_dev *rtwdev);/* for coex */ void (*coex_set_init)(struct rtw_dev *rtwdev);
@@ -1086,6 +1097,10 @@ struct rtw_chip_info {u8 bfer_su_max_num;u8 bfer_mu_max_num; +struct rtw_hw_reg_offset *edcca_th; +s8 l2h_th_ini_cs; +s8 l2h_th_ini_ad; +const char *wow_fw_name;const struct wiphy_wowlan_support *wowlan_stub;const u8 max_sched_scan_ssids;
@@ -1355,6 +1370,20 @@ struct rtw_pkt_count {DECLARE_EWMA (evm,10 ,4 );DECLARE_EWMA (snr,10 ,4 ); +#define EDCCA_TH_L2H_IDX 0 +#define EDCCA_TH_H2L_IDX 1 +#define EDCCA_TH_L2H_LB 48 +#define EDCCA_ADC_BACKOFF 12 +#define EDCCA_IGI_BASE 50 +#define EDCCA_IGI_L2H_DIFF 8 +#define EDCCA_L2H_H2L_DIFF 7 +#define EDCCA_L2H_H2L_DIFF_NORMAL 8 + +enum rtw_edcca_mode { +RTW_EDCCA_NORMAL =0 , +RTW_EDCCA_ADAPTIVITY =1 , +}; +struct rtw_dm_info {u32 cck_fa_cnt;u32 ofdm_fa_cnt;
@@ -1414,6 +1443,9 @@ struct rtw_dm_info {struct rtw_pkt_count last_pkt_count;struct ewma_evm ewma_evm[RTW_EVM_NUM ];struct ewma_snr ewma_snr[RTW_SNR_NUM ]; + +s8 l2h_th_ini; +enum rtw_edcca_mode edcca_mode; };struct rtw_efuse {
drivers/net/wireless/realtek/rtw88/phy.c +60 -0
90 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/phy.h +2 -0
@@ -56,6 +56,8 @@ s8 rtw_phy_pwrtrack_get_pwridx(struct rtw_dev *rtwdev,bool rtw_phy_pwrtrack_need_iqk (struct rtw_dev *rtwdev);void rtw_phy_config_swing_table (struct rtw_dev *rtwdev,struct rtw_swing_table *swing_table); +void rtw_phy_set_edcca_th (struct rtw_dev *rtwdev,u8 l2h,u8 h2l); +void rtw_phy_adaptivity_set_mode (struct rtw_dev *rtwdev);struct rtw_txpwr_lmt_cfg_pair {u8 regd;
drivers/net/wireless/realtek/rtw88/reg.h +2 -0
@@ -265,9 +265,11 @@#define BIT_SHIFT_SIFS_OFDM_TRX 24#define REG_SLOT 0x051B#define REG_TX_PTCL_CTRL 0x0520 +#define BIT_DIS_EDCCA BIT(15)#define BIT_SIFS_BK_EN BIT(12)#define REG_TXPAUSE 0x0522#define REG_RD_CTRL 0x0524 +#define BIT_EDCCA_MSK_CNTDOWN_EN BIT(11)#define BIT_DIS_TXOP_CFE BIT(10)#define BIT_DIS_LSIG_CFE BIT(9)#define BIT_DIS_STBC_CFE BIT(8)
drivers/net/wireless/realtek/rtw88/regd.c +21 -0
@@ -347,6 +347,22 @@ static bool rtw_regd_is_ww(struct rtw_regulatory *reg)return false; } +void rtw_regd_init_dfs_region (struct rtw_dev *rtwdev, +enum nl80211_dfs_regions curr_region) +{ +struct ieee80211_hw *hw = rtwdev->hw; +const struct ieee80211_regdomain *wiphy_regd =NULL ; + +if (curr_region !=RTW_REGION_INVALID ) +return ; + +rcu_read_lock (); + wiphy_regd =rcu_dereference (hw->wiphy->regd); +if (wiphy_regd) + rtwdev->regd.region = wiphy_regd->dfs_region; +rcu_read_unlock (); +} +static int rtw_regd_notifier_apply (struct rtw_dev *rtwdev,struct wiphy *wiphy,struct regulatory_request *request)
@@ -364,11 +380,13 @@ static int rtw_regd_notifier_apply(struct rtw_dev *rtwdev,/* return to the efuse setting */ country_code = rtwdev->efuse.country_code; rtwdev->regd =rtw_regd_find_reg_by_name (country_code); +rtw_regd_init_dfs_region (rtwdev,RTW_REGION_INVALID );return 0 ; } rtwdev->regd =rtw_regd_find_reg_by_name (request->alpha2);rtw_regd_apply_world_flags (wiphy, request->initiator); + rtwdev->regd.region = request->dfs_region;return 0 ; }
@@ -404,6 +422,7 @@ int rtw_regd_init(struct rtw_dev *rtwdev, rtwdev->regd =rtw_regd_find_reg_by_name (rtwdev->efuse.country_code);rtw_regd_init_wiphy (rtwdev, wiphy, reg_notifier); + rtwdev->regd.region =RTW_REGION_INVALID ;return 0 ; }
@@ -428,5 +447,7 @@ void rtw_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request) request->initiator, rtwdev->regd.chplan, rtwdev->regd.txpwr_regd); +rtw_phy_adaptivity_set_mode (rtwdev); +rtw_phy_set_tx_power_level (rtwdev, hal->current_channel); }
drivers/net/wireless/realtek/rtw88/regd.h +2 -0
@@ -68,4 +68,6 @@ int rtw_regd_init(struct rtw_dev *rtwdev,void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request));void rtw_regd_notifier (struct wiphy *wiphy,struct regulatory_request *request); +void rtw_regd_init_dfs_region (struct rtw_dev *rtwdev, +enum nl80211_dfs_regions curr_region);#endif
drivers/net/wireless/realtek/rtw88/rtw8822b.c +41 -0
65 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw8822b.h +6 -0
@@ -152,11 +152,17 @@ _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)#define REG_L1PKWT 0x840#define REG_MRC 0x850#define REG_CLKTRK 0x860 +#define REG_EDCCA_POW_MA 0x8a0 +#define BIT_MA_LEVEL GENMASK(1, 0)#define REG_ADCCLK 0x8ac#define REG_ADC160 0x8c4#define REG_ADC40 0x8c8 +#define REG_EDCCA_DECISION 0x8dc +#define BIT_EDCCA_OPTION BIT(5)#define REG_CDDTXP 0x93c#define REG_TXPSEL1 0x940 +#define REG_EDCCA_SOURCE 0x944 +#define BIT_SOURCE_OPTION GENMASK(29, 28)#define REG_ACBB0 0x948#define REG_ACBBRXFIR 0x94c#define REG_ACGG2TBL 0x958
drivers/net/wireless/realtek/rtw88/rtw8822c.c +45 -0
69 lines not on this page · raw message
drivers/net/wireless/realtek/rtw88/rtw8822c.h +2 -0
@@ -171,6 +171,8 @@ const struct rtw_table name ## _tbl = { \#define REG_DFIRBW 0x810#define REG_ANTMAP0 0x820#define REG_ANTMAP 0x824 +#define REG_EDCCA_DECISION 0x844 +#define BIT_EDCCA_OPTION GENMASK(30, 29)#define REG_DYMPRITH 0x86c#define REG_DYMENTH0 0x870#define REG_DYMENTH 0x874
Signature · 1 line
2.17.1
PATCH v6 1/2 rtw88: add regulatory process strategy for different chipset
In reply to [email protected]From: Tzu-En Huang <[email protected]>
If the country code in efuse is not set to a specific regulatory, then the efuse setting is WW (world-wide).
For the country codes that are set to a specific country, the driver is not going to apply any new setting notified from the stack.
For the country codes that are not set, which is treated as WW, the driver hints stack with "00" country code. But when there's any other regulatory found in IE, notified by NL80211_REGDOM_SET_BY_COUNTRY_IE, the driver will apply the setting found in the IE for 802.11d.
We want all of the regulatory rules being set strictly, not to loose the restrictions of the country setting, so apply REGULATORY_STRICT_REG to all of the regulatory settings.
For user notification (NL80211_REGDOM_SET_BY_USER), we'd like to default disable it because as FCC publication 594280 states:
"In particular, users must not be relied on to set a country code or location code to ensure compliance". If any distributions or OSes want to set regulatory through user space tool (ex, iw reg set), then they should honor the compile flag option RTW88_REGD_USER_REG_HINTS.
---
v3 -> v4
* squashed with "rtw88: support dynamic user regulatory setting"
* modify the commit log
v4 -> v5
* no change
v5 -> v6
* remove custom world-wide, use stack world-wide
* surface error codes
drivers/net/wireless/realtek/rtw88/Kconfig | 10 ++++ drivers/net/wireless/realtek/rtw88/main.c | 5 +- drivers/net/wireless/realtek/rtw88/regd.c | 54 ++++++++++++++++++---- 3 files changed, 57 insertions(+), 12 deletions(-)
drivers/net/wireless/realtek/rtw88/Kconfig +10 -0
@@ -52,4 +52,14 @@ config RTW88_DEBUGFS If unsure, say Y to simplify debug problems +config RTW88_REGD_USER_REG_HINTS + bool "Realtek rtw88 user regulatory hints" + depends on RTW88_CORE + default n + help + Enable regulatoy user hints + + If unsure, say N. This should only be allowed on distributions + that need this to correct the regulatory. + endif
drivers/net/wireless/realtek/rtw88/main.c +3 -2
@@ -1501,8 +1501,9 @@ int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw)return ret; } -if (regulatory_hint (hw->wiphy, rtwdev->regd.alpha2)) -rtw_err (rtwdev,"regulatory_hint fail\n" ); + ret =regulatory_hint (hw->wiphy, rtwdev->efuse.country_code); +if (ret) +rtw_warn (rtwdev,"failed to hint regulatory: %d\n" , ret);rtw_debugfs_init (rtwdev);
drivers/net/wireless/realtek/rtw88/regd.c +44 -10
91 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v6 1/2] rtw88: add regulatory process strategy for different chipset
Hi,
Quoted 6 lines · On Tue, Mar 24, 2020 at 03:52:15PM +0800, [email protected] wrote:
drivers/net/wireless/realtek/rtw88/Kconfig +0
-0@@ -52,4 +52,14 @@ config RTW88_DEBUGFS If unsure, say Y to simplify debug problems
drivers/net/wireless/realtek/rtw88/Kconfig config RTW88_DEBUGFS · line 64
Quoted 10 lines
drivers/net/wireless/realtek/rtw88/Kconfig +10
-0+config RTW88_REGD_USER_REG_HINTS + bool "Realtek rtw88 user regulatory hints" + depends on RTW88_CORE + default n + help + Enable regulatoy user hints + + If unsure, say N. This should only be allowed on distributions + that need this to correct the regulatory. +
I'm still not sure why rtw88 needs this, and nobody else does. I read your commit message, but that doesn't sound like something that belongs in a single driver still.
Quoted 6 lines
drivers/net/wireless/realtek/rtw88/Kconfig +0
-0endifdrivers/net/wireless/realtek/rtw88/main.c +0
-0
drivers/net/wireless/realtek/rtw88/main.c int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw) · line 1506
Quoted 8 lines
drivers/net/wireless/realtek/rtw88/main.c +3
-2@@ -1501,8 +1501,9 @@ int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw)return ret; } -if (regulatory_hint (hw->wiphy, rtwdev->regd.alpha2)) -rtw_err (rtwdev,"regulatory_hint fail\n" ); + ret =regulatory_hint (hw->wiphy, rtwdev->efuse.country_code); +if (ret) +rtw_warn (rtwdev,"failed to hint regulatory: %d\n" , ret);
I don't think this is what you want; you had it right in previous revisions:
if (!rtwdev->efuse.country_worldwide) {
if (regulatory_hint(hw->wiphy, rtwdev->efuse.country_code))
rtw_err( ... );
}Without the 'country_worlwide' check, you start "hinting" (even on worldwide chips) that you really wanted "country" 00 only, and so we *never* adapt to more strict country settings. That's not how world-wide settings are supposed to work.
drivers/net/wireless/realtek/rtw88/regd.c static struct rtw_regulatory rtw_regd_find_reg_by_name(char *alpha2) · line 354
Quoted 13 lines
drivers/net/wireless/realtek/rtw88/main.c +0
-0rtw_debugfs_init (rtwdev);drivers/net/wireless/realtek/rtw88/regd.c +1
-1static int rtw_regd_notifier_apply (struct rtw_dev *rtwdev,struct wiphy *wiphy,struct regulatory_request *request) { -if (request->initiator ==NL80211_REGDOM_SET_BY_USER ) +if (request->initiator ==NL80211_REGDOM_SET_BY_DRIVER )
Why are you ignoring SET_BY_DRIVER? That's what happens when (a few lines up) you call regulatory_hint(). At a minimum, that doesn't deserve a loud error print when we "fail" this function -- you should handle it properly.
Brian
Quoted 18 lines
drivers/net/wireless/realtek/rtw88/regd.c +14
-0+return -ENOTSUPP ; + +if (request->initiator ==NL80211_REGDOM_SET_BY_USER && + !IS_ENABLED (CONFIG_RTW88_REGD_USER_REG_HINTS )) +return -EPERM ; + +if (request->initiator ==NL80211_REGDOM_SET_BY_CORE ) { +char *country_code; + +/* return to the efuse setting */ + country_code = rtwdev->efuse.country_code; + rtwdev->regd =rtw_regd_find_reg_by_name (country_code);return 0 ; + } + rtwdev->regd =rtw_regd_find_reg_by_name (request->alpha2);rtw_regd_apply_world_flags (wiphy, request->initiator);
RE: [PATCH v6 1/2] rtw88: add regulatory process strategy for different chipset
Quoted 10 lines
Hi,
Quoted 6 lines · On Tue, Mar 24, 2020 at 03:52:15PM +0800, [email protected] wrote:
drivers/net/wireless/realtek/rtw88/Kconfig +0
-0@@ -52,4 +52,14 @@ config RTW88_DEBUGFS If unsure, say Y to simplify debug problems
Quoted 12 lines
drivers/net/wireless/realtek/rtw88/Kconfig config RTW88_DEBUGFS · line 64
Quoted 10 lines
drivers/net/wireless/realtek/rtw88/Kconfig +10
-0+config RTW88_REGD_USER_REG_HINTS + bool "Realtek rtw88 user regulatory hints" + depends on RTW88_CORE + default n + help + Enable regulatoy user hints + + If unsure, say N. This should only be allowed on distributions + that need this to correct the regulatory. +I'm still not sure why rtw88 needs this, and nobody else does. I read
I think in Atheros driver, ATH_REG_DYNAMIC_USER_REG_HINTS config serves the same purpose.
Quoted 3 lines
your commit message, but that doesn't sound like something that belongs in a single driver still.
As our previous commit message claims, it is due to FCC publication 594280 statement, "In particular, users must not be relied on to set a country code or location code to ensure compliance".
Quoted 25 lines
Review
Quoted 2 lines
drivers/net/wireless/realtek/rtw88/Kconfig +0
-0endif(quoted diff) +0
-0
b/drivers/net/wireless/realtek/rtw88/main.cdrivers/net/wireless/realtek/rtw88/main.c int rtw_register_hw(struct rtw_dev *rtwdev,
Quoted 4 lines
index
7640e97706f5..5d43bef91a3c100644drivers/net/wireless/realtek/rtw88/main.c +0
-0@@ -1501,8 +1501,9 @@ int rtw_register_hw(struct rtw_dev *rtwdev,struct
ieee80211_hw*hw)drivers/net/wireless/realtek/rtw88/main.c int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw) · line 1506
Quoted 8 lines
drivers/net/wireless/realtek/rtw88/main.c +3
-2return ret; } -if (regulatory_hint (hw->wiphy, rtwdev->regd.alpha2)) -rtw_err (rtwdev,"regulatory_hint fail\n" ); + ret =regulatory_hint (hw->wiphy, rtwdev->efuse.country_code); +if (ret) +rtw_warn (rtwdev,"failed to hint regulatory: %d\n" , ret);I don't think this is what you want; you had it right in previous revisions:
if (!rtwdev->efuse.country_worldwide) { if (regulatory_hint(hw->wiphy, rtwdev->efuse.country_code)) rtw_err( ... ); }
Quoted 5 lines
Without the '
country_worlwide' check, you start "hinting" (even on worldwide chips) that you really wanted "country" 00 only, and so we *never* adapt to more strict country settings. That's not how world-wide settings are supposed to work.
It doesn't mean that we want country 00 only, we will get country notifies from stack, and we will apply it if we accept it. We don't want stack to change the channel plan for us.
And this is also related to RTW88_REGD_USER_REG_HINTS config, since we do not want stack to change the channel plan set from user space without this config.
Quoted 20 lines
Review
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/main.c +0
-0rtw_debugfs_init (rtwdev);(quoted diff) +0
-0
b/drivers/net/wireless/realtek/rtw88/regd.cdrivers/net/wireless/realtek/rtw88/regd.c static struct rtw_regulatory rtw_regd_find_reg_by_name(char *alpha2) · line 354
Quoted 9 lines
index
69744dd65968..4cc1234bfb9a100644drivers/net/wireless/realtek/rtw88/regd.c +1
-1static int rtw_regd_notifier_apply (struct rtw_dev *rtwdev,struct wiphy *wiphy,struct regulatory_request *request) { -if (request->initiator ==NL80211_REGDOM_SET_BY_USER ) +if (request->initiator ==NL80211_REGDOM_SET_BY_DRIVER )Why are you ignoring
SET_BY_DRIVER? That's what happens when (a few lines up) you callregulatory_hint(). At a minimum, that doesn't deserve a loud error print when we "fail" this function -- you should handle it properly.
Quoted 1 line
Brian
Since the notification with NL80211_REGDOM_SET_BY_DRIVER flag might comes from an another chipset's regulatory_hint().
Tzu-En
Quoted 21 lines
Quoted 9 lines
drivers/net/wireless/realtek/rtw88/regd.c +7
-0+return -ENOTSUPP ; + +if (request->initiator ==NL80211_REGDOM_SET_BY_USER && + !IS_ENABLED (CONFIG_RTW88_REGD_USER_REG_HINTS )) +return -EPERM ; + +if (request->initiator ==NL80211_REGDOM_SET_BY_CORE ) {drivers/net/wireless/realtek/rtw88/regd.c static struct rtw_regulatory rtw_regd_find_reg_by_name(char *alpha2) · line 371
Quoted 10 lines
drivers/net/wireless/realtek/rtw88/regd.c +7
-0+char *country_code; + +/* return to the efuse setting */ + country_code = rtwdev->efuse.country_code; + rtwdev->regd =rtw_regd_find_reg_by_name (country_code);return 0 ; + } + rtwdev->regd =rtw_regd_find_reg_by_name (request->alpha2);rtw_regd_apply_world_flags (wiphy, request->initiator);------Please consider the environment before printing this e-mail.
Re: [PATCH v6 1/2] rtw88: add regulatory process strategy for different chipset
[ I'll preface this by saying that the more I look at the regulatory core, the more I realize I'm confused or wrong at times. So forgive me if I've made errors along the way, and please do correct me. ]
Quoted 8 lines · Andy Huang
Quoted 5 lines · On Tue, Mar 24, 2020 at 03:52:15PM +0800, [email protected] wrote:
drivers/net/wireless/realtek/rtw88/Kconfig
Quoted 2 lines
drivers/net/wireless/realtek/rtw88/Kconfig +0
-0I'm still not sure why rtw88 needs this, and nobody else does. I read
I think in Atheros driver,
ATH_REG_DYNAMIC_USER_REG_HINTSconfig serves the same purpose.
Ah, I forgot about that one, sorry.
Quoted 5 lines
Quoted 3 lines
your commit message, but that doesn't sound like something that belongs in a single driver still.
As our previous commit message claims, it is due to FCC [...]
Yes, I saw that: my point was that effectively all drivers are subject to this FCC rule, and so this could be a common CONFIG_*. But if we already have the ATH_* one (I missed that, above), I guess we can have an rtw88 one too. It might be less confusing (and more straightforwardly-implemented) if we moved this stuff to the core someday, though.
Quoted 12 lines
Quoted 12 lines
drivers/net/wireless/realtek/rtw88/Kconfig
Quoted 3 lines
drivers/net/wireless/realtek/rtw88/Kconfig +3
-0+ ret = regulatory_hint(hw->wiphy, rtwdev->efuse.country_code); + if (ret) + rtw_warn(rtwdev, "failed to hint regulatory: %d\n", ret);I don't think this is what you want; you had it right in previous revisions:
if (!rtwdev->efuse.country_worldwide) { if (regulatory_hint(hw->wiphy, rtwdev->efuse.country_code)) rtw_err( ... ); }
Quoted 8 lines
Quoted 4 lines
Without the '
country_worlwide' check, you start "hinting" (even on worldwide chips) that you really wanted "country" 00 only, and so we *never* adapt to more strict country settings. That's not how world-wide settings are supposed to work.It doesn't mean that we want country 00 only, we will get country notifies from stack, and we will apply it if we accept it. We don't want stack to change the channel plan for us.
I noted this to you privately, but I don't believe it's expected to call regulatory_hint() with "00". See the kerneldoc:
* @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
* should be in. If @rd is set this should be NULL. Note that if you * set this to NULL you should still set rd->alpha2 to some accepted * alpha2.
Note that "00" is *not* actually an ISO 3166 alpha2 code.
The key problem I'm seeing: once you do this, you establish a wiphy-specific regd, and this regd never updates its country code or DFS region according to IE updates. So attributes like NL80211_ATTR_DFS_REGION and NL80211_ATTR_REG_ALPHA2 remain unset.
Your previous revision -- which for WW settings used wiphy_apply_custom_regulatory() and *not* regulatory_hint() -- did not have that problem.
Quoted 4 lines
Quoted 1 line
Why are you ignoring
SET_BY_DRIVER?Since the notification with
NL80211_REGDOM_SET_BY_DRIVERflag might comes from an another chipset'sregulatory_hint().
Ack.
Brian
RE: [PATCH v6 1/2] rtw88: add regulatory process strategy for different chipset
Quoted 59 lines
[ I'll preface this by saying that the more I look at the regulatory core, the more I realize I'm confused or wrong at times. So forgive me if I've made errors along the way, and please do correct me. ]
Quoted 1 line · Andy Huang
Quoted 1 line
On Tue, Mar 24, 2020 at 03:52:15PM +0800, [email protected]
Quoted 6 lines · wrote:
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/Kconfig
Quoted 2 lines
drivers/net/wireless/realtek/rtw88/Kconfig +0
-0I'm still not sure why rtw88 needs this, and nobody else does. I read
I think in Atheros driver,
ATH_REG_DYNAMIC_USER_REG_HINTSconfigserves
Quoted 1 line
the same purpose.
Ah, I forgot about that one, sorry.
Quoted 5 lines
Quoted 3 lines
your commit message, but that doesn't sound like something that belongs in a single driver still.
As our previous commit message claims, it is due to FCC [...]
Yes, I saw that: my point was that effectively all drivers are subject to this FCC rule, and so this could be a common CONFIG_*. But if we already have the ATH_* one (I missed that, above), I guess we can have an rtw88 one too. It might be less confusing (and more straightforwardly-implemented) if we moved this stuff to the core someday, though.
Quoted 9 lines
Quoted 9 lines
drivers/net/wireless/realtek/rtw88/Kconfig
Quoted 3 lines
drivers/net/wireless/realtek/rtw88/Kconfig +3
-0+ ret = regulatory_hint(hw->wiphy, rtwdev->efuse.country_code); + if (ret) + rtw_warn(rtwdev, "failed to hint regulatory: %d\n", ret);I don't think this is what you want; you had it right in previous revisions:
if (!rtwdev->efuse.country_worldwide) { if (regulatory_hint(hw->wiphy,
rtwdev->efuse.country_code))Quoted 10 lines
Quoted 7 lines
rtw_err( ... ); }Without the '
country_worlwide' check, you start "hinting" (even on worldwide chips) that you really wanted "country" 00 only, and so we *never* adapt to more strict country settings. That's not how world-wide settings are supposed to work.It doesn't mean that we want country 00 only, we will get country notifies from stack, and we will apply it if we accept it. We don't want stack to
change
Quoted 1 line
the channel plan for us.
I noted this to you privately, but I don't believe it's expected to call
regulatory_hint()with "00". See the kerneldoc:
Quoted 7 lines
* @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
* should be in. If @rd is set this should be NULL. Note that if you * set this to NULL you should still set rd->alpha2 to some accepted * alpha2.Note that "00" is *not* actually an ISO 3166 alpha2 code.
Yes, I think you make sense, we will provide v7, which will be similar to v5 with more detailed explain in commit log.
Tzu-En
Quoted 19 lines
The key problem I'm seeing: once you do this, you establish a wiphy-specific regd, and this regd never updates its country code or DFS region according to IE updates. So attributes like
NL80211_ATTR_DFS_REGIONandNL80211_ATTR_REG_ALPHA2remain unset.Your previous revision -- which for WW settings used
wiphy_apply_custom_regulatory()and *not*regulatory_hint()-- did not have that problem.Quoted 4 lines
Quoted 1 line
Why are you ignoring
SET_BY_DRIVER?Since the notification with
NL80211_REGDOM_SET_BY_DRIVERflag might comes from an another chipset'sregulatory_hint().Ack.
Brian
------Please consider the environment before printing this e-mail.