wifi: rtw88: check if center channel is supported before setting
Ping-Ke Shih
maintainerFrom: Zong-Zhe Yang <[email protected]>
Some unusual center channels may be assigned to driver. However, RF doesn't really expect them, and then warnings happen due to lack of TX power limit configurations. For example, center channel 114/130 with 80MHz. So, add a check before setting the channel.
--- drivers/net/wireless/realtek/rtw88/mac80211.c | 7 +++++-- drivers/net/wireless/realtek/rtw88/main.c | 13 +++++++++++-- drivers/net/wireless/realtek/rtw88/main.h | 2 +- drivers/net/wireless/realtek/rtw88/phy.c | 18 ++++++++++++++++++ drivers/net/wireless/realtek/rtw88/phy.h | 2 ++ 5 files changed, 37 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtw88/mac80211.c +5 -2
@@ -92,8 +92,11 @@ static int rtw_ops_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) } } -if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) -rtw_set_channel (rtwdev); +if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) { + ret =rtw_set_channel (rtwdev); +if (ret) + goto out; + } if ((changed & IEEE80211_CONF_CHANGE_IDLE) && (hw->conf.flags & IEEE80211_CONF_IDLE) &&
drivers/net/wireless/realtek/rtw88/main.c +11 -2
@@ -868,23 +868,30 @@ void rtw_get_channel_params(struct cfg80211_chan_def *chandef, chan_params->primary_chan = channel->hw_value; } -void rtw_set_channel (struct rtw_dev *rtwdev) +int rtw_set_channel (struct rtw_dev *rtwdev) {const struct rtw_chip_info *chip = rtwdev->chip;struct ieee80211_hw *hw = rtwdev->hw;struct rtw_hal *hal = &rtwdev->hal;struct rtw_channel_params ch_param;u8 center_chan, primary_chan, bandwidth, band; +int ch_idx;rtw_get_channel_params (&hw->conf.chandef, &ch_param);if (WARN (ch_param.center_chan ==0 ,"Invalid channel\n" )) -return ; +return -EINVAL ; center_chan = ch_param.center_chan; primary_chan = ch_param.primary_chan; bandwidth = ch_param.bandwidth; band = ch_param.center_chan >14 ?RTW_BAND_5G :RTW_BAND_2G ; + ch_idx =rtw_band_channel_to_idx (band, center_chan); +if (ch_idx <0 ) { +rtw_warn (rtwdev,"not support band %d ch %d\n" , band, center_chan); +return -EOPNOTSUPP ; + } +rtw_update_channel (rtwdev, center_chan, primary_chan, band, bandwidth);if (rtwdev->scan_info.op_chan)
@@ -910,6 +917,8 @@ void rtw_set_channel(struct rtw_dev *rtwdev)*/ if (!test_bit (RTW_FLAG_SCANNING , rtwdev->flags)) rtwdev->need_rfk = true; + +return 0 ; }void rtw_chip_prepare_tx (struct rtw_dev *rtwdev)
drivers/net/wireless/realtek/rtw88/main.h +1 -1
@@ -2241,7 +2241,7 @@ bool ltecoex_reg_write(struct rtw_dev *rtwdev, u16 offset, u32 value);void rtw_restore_reg (struct rtw_dev *rtwdev,struct rtw_backup_info *bckp,u32 num);void rtw_desc_to_mcsrate (u16 rate,u8 *mcs,u8 *nss); -void rtw_set_channel (struct rtw_dev *rtwdev); +int rtw_set_channel (struct rtw_dev *rtwdev);void rtw_chip_prepare_tx (struct rtw_dev *rtwdev);void rtw_vif_port_config (struct rtw_dev *rtwdev,struct rtw_vif *rtwvif,u32 config);
drivers/net/wireless/realtek/rtw88/phy.c +18 -0
@@ -1630,6 +1630,24 @@ static int rtw_channel_to_idx(u8 band, u8 channel)return ch_idx; } +int rtw_band_channel_to_idx (enum rtw_supported_band band,u8 channel) +{ +u8 phy_band; + +switch (band) { +case RTW_BAND_2G : + phy_band =PHY_BAND_2G ; +break ; +case RTW_BAND_5G : + phy_band =PHY_BAND_5G ; +break ; +default : +return -1 ; + } + +return rtw_channel_to_idx (phy_band, channel); +} +static void rtw_phy_set_tx_power_limit (struct rtw_dev *rtwdev,u8 regd,u8 band,u8 bw,u8 rs,u8 ch,s8 pwr_limit) {
drivers/net/wireless/realtek/rtw88/phy.h +2 -0
@@ -201,4 +201,6 @@ enum rtw_phy_cck_pd_lv {#define RRSR_RATE_ORDER_MAX 0xfffff#define RRSR_RATE_ORDER_CCK_LEN 4 +int rtw_band_channel_to_idx (enum rtw_supported_band band,u8 channel); +#endif
Signature · 1 line
2.25.1
Quoted 9 lines · Ping-Ke Shih
From: Zong-Zhe Yang <[email protected]>
Some unusual center channels may be assigned to driver. However, RF doesn't really expect them, and then warnings happen due to lack of TX power limit configurations. For example, center channel 114/130 with 80MHz. So, add a check before setting the channel.
Signed-off-by Zong-Zhe Yang <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>
Hi,
I have tested this patch and it does prevent 80MHz from being used. However, RF seems to accept those center channels with 80MHz just fine. I can get up to 600Mbps with UDP while I can get past 300Mbps after applying this patch.
Should we apply something like [1] instead?
https://lore.kernel.org/linux-wireless/[email protected]
Regards.
Cascardo.
Quoted 129 lines
--- drivers/net/wireless/realtek/rtw88/mac80211.c | 7 +++++-- drivers/net/wireless/realtek/rtw88/main.c | 13 +++++++++++-- drivers/net/wireless/realtek/rtw88/main.h | 2 +- drivers/net/wireless/realtek/rtw88/phy.c | 18 ++++++++++++++++++ drivers/net/wireless/realtek/rtw88/phy.h | 2 ++ 5 files changed, 37 insertions(+), 5 deletions(-)drivers/net/wireless/realtek/rtw88/mac80211.c +5
-2@@ -92,8 +92,11 @@ static int rtw_ops_config(struct ieee80211_hw *hw, int radio_idx, u32 changed) } } -if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) -rtw_set_channel (rtwdev); +if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) { + ret =rtw_set_channel (rtwdev); +if (ret) + goto out; + } if ((changed & IEEE80211_CONF_CHANGE_IDLE) && (hw->conf.flags & IEEE80211_CONF_IDLE) &&drivers/net/wireless/realtek/rtw88/main.c +11
-2@@ -868,23 +868,30 @@ void rtw_get_channel_params(struct cfg80211_chan_def *chandef, chan_params->primary_chan = channel->hw_value; } -void rtw_set_channel (struct rtw_dev *rtwdev) +int rtw_set_channel (struct rtw_dev *rtwdev) {const struct rtw_chip_info *chip = rtwdev->chip;struct ieee80211_hw *hw = rtwdev->hw;struct rtw_hal *hal = &rtwdev->hal;struct rtw_channel_params ch_param;u8 center_chan, primary_chan, bandwidth, band; +int ch_idx;rtw_get_channel_params (&hw->conf.chandef, &ch_param);if (WARN (ch_param.center_chan ==0 ,"Invalid channel\n" )) -return ; +return -EINVAL ; center_chan = ch_param.center_chan; primary_chan = ch_param.primary_chan; bandwidth = ch_param.bandwidth; band = ch_param.center_chan >14 ?RTW_BAND_5G :RTW_BAND_2G ; + ch_idx =rtw_band_channel_to_idx (band, center_chan); +if (ch_idx <0 ) { +rtw_warn (rtwdev,"not support band %d ch %d\n" , band, center_chan); +return -EOPNOTSUPP ; + } +rtw_update_channel (rtwdev, center_chan, primary_chan, band, bandwidth);if (rtwdev->scan_info.op_chan)@@ -910,6 +917,8 @@ void rtw_set_channel(struct rtw_dev *rtwdev)*/ if (!test_bit (RTW_FLAG_SCANNING , rtwdev->flags)) rtwdev->need_rfk = true; + +return 0 ; }void rtw_chip_prepare_tx (struct rtw_dev *rtwdev)drivers/net/wireless/realtek/rtw88/main.h +1
-1@@ -2241,7 +2241,7 @@ bool ltecoex_reg_write(struct rtw_dev *rtwdev, u16 offset, u32 value);void rtw_restore_reg (struct rtw_dev *rtwdev,struct rtw_backup_info *bckp,u32 num);void rtw_desc_to_mcsrate (u16 rate,u8 *mcs,u8 *nss); -void rtw_set_channel (struct rtw_dev *rtwdev); +int rtw_set_channel (struct rtw_dev *rtwdev);void rtw_chip_prepare_tx (struct rtw_dev *rtwdev);void rtw_vif_port_config (struct rtw_dev *rtwdev,struct rtw_vif *rtwvif,u32 config);drivers/net/wireless/realtek/rtw88/phy.c +18
-0@@ -1630,6 +1630,24 @@ static int rtw_channel_to_idx(u8 band, u8 channel)return ch_idx; } +int rtw_band_channel_to_idx (enum rtw_supported_band band,u8 channel) +{ +u8 phy_band; + +switch (band) { +case RTW_BAND_2G : + phy_band =PHY_BAND_2G ; +break ; +case RTW_BAND_5G : + phy_band =PHY_BAND_5G ; +break ; +default : +return -1 ; + } + +return rtw_channel_to_idx (phy_band, channel); +} +static void rtw_phy_set_tx_power_limit (struct rtw_dev *rtwdev,u8 regd,u8 band,u8 bw,u8 rs,u8 ch,s8 pwr_limit) {drivers/net/wireless/realtek/rtw88/phy.h +2
-0@@ -201,4 +201,6 @@ enum rtw_phy_cck_pd_lv {#define RRSR_RATE_ORDER_MAX 0xfffff#define RRSR_RATE_ORDER_CCK_LEN 4 +int rtw_band_channel_to_idx (enum rtw_supported_band band,u8 channel); +#endif Signature · 1 line
2.25.1
Quoted 19 lines · Thadeu Lima de Souza Cascardo
Quoted 9 lines · Ping-Ke Shih
From: Zong-Zhe Yang <[email protected]>
Some unusual center channels may be assigned to driver. However, RF doesn't really expect them, and then warnings happen due to lack of TX power limit configurations. For example, center channel 114/130 with 80MHz. So, add a check before setting the channel.
Signed-off-by Zong-Zhe Yang <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>Hi,
I have tested this patch and it does prevent 80MHz from being used. However, RF seems to accept those center channels with 80MHz just fine. I can get up to 600Mbps with UDP while I can get past 300Mbps after applying this patch.
Quoted 8 lines
Should we apply something like [1] instead?
https://lore.kernel.org/linux-wireless/20260306-rtw88_channel130-v1-1-ff25a5
[email protected]Regards.
Cascardo.
Hi,
The chipsets supported by rtw88 are only verified with the existing center channels before 160MHz. Although you set 80MHz here, but these center channels actually appeared after 160MHz. I also have checked with our HW members. They said they cannot guarantee everything will be right. So, we won't officially allow these center channels.
Maybe you think your test result is fine to you, but throughput test doesn't tell the whole story, e.g., is it really fine for regulatory? So, I suggest that you change the AP configuration to use another center channel with 80MHz.
Thanks.
Quoted 139 lines
drivers/net/wireless/realtek/rtw88/mac80211.c static int rtw_ops_config(struct ieee80211_hw *hw,
Quoted 14 lines
--- drivers/net/wireless/realtek/rtw88/mac80211.c | 7 +++++-- drivers/net/wireless/realtek/rtw88/main.c | 13 +++++++++++-- drivers/net/wireless/realtek/rtw88/main.h | 2 +- drivers/net/wireless/realtek/rtw88/phy.c | 18 ++++++++++++++++++ drivers/net/wireless/realtek/rtw88/phy.h | 2 ++ 5 files changed, 37 insertions(+), 5 deletions(-)drivers/net/wireless/realtek/rtw88/mac80211.c +0
-0@@ -92,8 +92,11 @@ static int rtw_ops_config(struct ieee80211_hw *hw,int
radio_idx, u32 changed)drivers/net/wireless/realtek/rtw88/main.c void rtw_get_channel_params(struct
Quoted 19 lines
drivers/net/wireless/realtek/rtw88/mac80211.c +5
-2} } -if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) -rtw_set_channel (rtwdev); +if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) { + ret =rtw_set_channel (rtwdev); +if (ret) + goto out; + }if ((changed &IEEE80211_CONF_CHANGE_IDLE ) && (hw->conf.flags & IEEE80211_CONF_IDLE) && diff --git
a/drivers/net/wireless/realtek/rtw88/main.cb/drivers/net/wireless/realtek/rtw88/main.c
indexcd9254370fcc..08aebb3c5a78100644drivers/net/wireless/realtek/rtw88/main.c +0
-0@@ -868,23 +868,30 @@ void rtw_get_channel_params(struct
cfg80211_chan_def*chandef,Quoted 11 lines
drivers/net/wireless/realtek/rtw88/main.c +2
-1chan_params->primary_chan = channel->hw_value; } -void rtw_set_channel (struct rtw_dev *rtwdev) +int rtw_set_channel (struct rtw_dev *rtwdev) {const struct rtw_chip_info *chip = rtwdev->chip;struct ieee80211_hw *hw = rtwdev->hw;struct rtw_hal *hal = &rtwdev->hal;struct rtw_channel_params ch_param;u8 center_chan, primary_chan, bandwidth, band; +int ch_idx;drivers/net/wireless/realtek/rtw88/main.c void rtw_get_channel_params(struct cfg80211_chan_def *chandef,
Quoted 10 lines
drivers/net/wireless/realtek/rtw88/main.c +1
-1rtw_get_channel_params (&hw->conf.chandef, &ch_param);if (WARN (ch_param.center_chan ==0 ,"Invalid channel\n" )) -return ; +return -EINVAL ; center_chan = ch_param.center_chan; primary_chan = ch_param.primary_chan; bandwidth = ch_param.bandwidth; band = ch_param.center_chan > 14 ? RTW_BAND_5G :
RTW_BAND_2G;drivers/net/wireless/realtek/rtw88/main.c void rtw_get_channel_params(struct cfg80211_chan_def *chandef,
Quoted 4 lines
drivers/net/wireless/realtek/rtw88/main.c +3
-0+ ch_idx =rtw_band_channel_to_idx (band, center_chan); +if (ch_idx <0 ) { + rtw_warn(rtwdev, "not support band %d ch %d\n", band,
center_chan);drivers/net/wireless/realtek/rtw88/phy.c static int rtw_channel_to_idx(u8 band, u8
Quoted 36 lines
drivers/net/wireless/realtek/rtw88/main.c +5
-0+return -EOPNOTSUPP ; + } +rtw_update_channel (rtwdev, center_chan, primary_chan, band, bandwidth);if (rtwdev->scan_info.op_chan)@@ -910,6 +917,8 @@ void rtw_set_channel(struct rtw_dev *rtwdev)*/ if (!test_bit (RTW_FLAG_SCANNING , rtwdev->flags)) rtwdev->need_rfk = true; + +return 0 ; } void rtw_chip_prepare_tx(struct rtw_dev *rtwdev) diff --git
a/drivers/net/wireless/realtek/rtw88/main.hb/drivers/net/wireless/realtek/rtw88/main.h
index9c0b746540b0..a368f1a4a003100644drivers/net/wireless/realtek/rtw88/main.h +0
-0@@ -2241,7 +2241,7 @@ bool ltecoex_reg_write(struct rtw_dev *rtwdev, u16 offset, u32 value); void rtw_restore_reg(struct rtw_dev *rtwdev,struct rtw_backup_info *bckp,u32 num);void
rtw_desc_to_mcsrate(u16 rate, u8 *mcs, u8 *nss); -voidrtw_set_channel(struct rtw_dev *rtwdev);
+intrtw_set_channel(struct rtw_dev *rtwdev);
voidrtw_chip_prepare_tx(struct rtw_dev *rtwdev); void
rtw_vif_port_config(structrtw_dev*rtwdev, structrtw_vif*rtwvif,u32 config);drivers/net/wireless/realtek/rtw88/phy.c +0
-0@@ -1630,6 +1630,24 @@ static int rtw_channel_to_idx(u8 band, u8channel)
Quoted 11 lines
drivers/net/wireless/realtek/rtw88/phy.c +8
-0return ch_idx; } +int rtw_band_channel_to_idx (enum rtw_supported_band band,u8 channel) +{ +u8 phy_band; + +switch (band) { +case RTW_BAND_2G : + phy_band =PHY_BAND_2G ; +break ;drivers/net/wireless/realtek/rtw88/phy.c static int rtw_channel_to_idx(u8 band, u8 channel)
Quoted 10 lines
drivers/net/wireless/realtek/rtw88/phy.c +9
-0+case RTW_BAND_5G : + phy_band =PHY_BAND_5G ; +break ; +default : +return -1 ; + } + +return rtw_channel_to_idx (phy_band, channel); } + static void rtw_phy_set_tx_power_limit(struct rtw_dev *rtwdev, u8 regd,u8 band,
Quoted 18 lines
drivers/net/wireless/realtek/rtw88/phy.c +0
-0u8 bw, u8 rs, u8 ch, s8
pwr_limit) { diff --gita/drivers/net/wireless/realtek/rtw88/phy.hb/drivers/net/wireless/realtek/rtw88/phy.h
index8449936497bb..98aeb576e24d100644drivers/net/wireless/realtek/rtw88/phy.h +0
-0@@ -201,4 +201,6 @@ enum rtw_phy_cck_pd_lv { #define
RRSR_RATE_ORDER_MAX0xfffff
#defineRRSR_RATE_ORDER_CCK_LEN4drivers/net/wireless/realtek/rtw88/phy.h +3
-1+int rtw_band_channel_to_idx (enum rtw_supported_band band,u8 +channel); +#endif --2.25.1