2022-05-13 08:43:32

by Ping-Ke Shih

[permalink] [raw]
Subject: [PATCH 5/6] rtw89: convert rtw89_band to nl80211_band precisely

From: Zong-Zhe Yang <[email protected]>

Before 6G band was supported, i.e. only 2G and 5G, they were the same
from the numerical point of view. However, after 6G band support, we
need to do this conversion logically.

Signed-off-by: Zong-Zhe Yang <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
---
drivers/net/wireless/realtek/rtw89/core.c | 11 +++++++----
drivers/net/wireless/realtek/rtw89/core.h | 14 ++++++++++++++
drivers/net/wireless/realtek/rtw89/fw.c | 2 +-
drivers/net/wireless/realtek/rtw89/phy.c | 13 +++++++------
4 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index e3317deafa1d0..a6a90572e74bf 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -1608,10 +1608,13 @@ static void rtw89_core_update_rx_status(struct rtw89_dev *rtwdev,

if (rtwdev->scanning &&
RTW89_CHK_FW_FEATURE(SCAN_OFFLOAD, &rtwdev->fw)) {
- rx_status->freq =
- ieee80211_channel_to_frequency(hal->current_channel,
- hal->current_band_type);
- rx_status->band = rtwdev->hal.current_band_type;
+ u8 chan = hal->current_channel;
+ u8 band = hal->current_band_type;
+ enum nl80211_band nl_band;
+
+ nl_band = rtw89_hw_to_nl80211_band(band);
+ rx_status->freq = ieee80211_channel_to_frequency(chan, nl_band);
+ rx_status->band = nl_band;
}

if (desc_info->icv_err || desc_info->crc32_err)
diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h
index 2921814842ffa..e8a77225a90ff 100644
--- a/drivers/net/wireless/realtek/rtw89/core.h
+++ b/drivers/net/wireless/realtek/rtw89/core.h
@@ -3480,6 +3480,20 @@ static inline u8 rtw89_hw_to_rate_info_bw(enum rtw89_bandwidth hw_bw)
return RATE_INFO_BW_20;
}

+static inline
+enum nl80211_band rtw89_hw_to_nl80211_band(enum rtw89_band hw_band)
+{
+ switch (hw_band) {
+ default:
+ case RTW89_BAND_2G:
+ return NL80211_BAND_2GHZ;
+ case RTW89_BAND_5G:
+ return NL80211_BAND_5GHZ;
+ case RTW89_BAND_6G:
+ return NL80211_BAND_6GHZ;
+ }
+}
+
static inline
enum rtw89_bandwidth nl_to_rtw89_bandwidth(enum nl80211_chan_width width)
{
diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
index e4be785709d10..4718aced1428a 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -2068,7 +2068,7 @@ static void rtw89_release_pkt_list(struct rtw89_dev *rtwdev)
struct rtw89_pktofld_info *info, *tmp;
u8 idx;

- for (idx = RTW89_BAND_2G; idx < NUM_NL80211_BANDS; idx++) {
+ for (idx = NL80211_BAND_2GHZ; idx < NUM_NL80211_BANDS; idx++) {
if (!(rtwdev->chip->support_bands & BIT(idx)))
continue;

diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index 79e4c28495c80..762cdba9d3cfd 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -429,27 +429,28 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
RTW89_HW_RATE_MCS16,
RTW89_HW_RATE_MCS24};
u8 band = rtwdev->hal.current_band_type;
+ enum nl80211_band nl_band = rtw89_hw_to_nl80211_band(band);
u8 tx_nss = rtwdev->hal.tx_nss;
u8 i;

for (i = 0; i < tx_nss; i++)
if (!__check_rate_pattern(&next_pattern, hw_rate_he[i],
RA_MASK_HE_RATES, RTW89_RA_MODE_HE,
- mask->control[band].he_mcs[i],
+ mask->control[nl_band].he_mcs[i],
0, true))
goto out;

for (i = 0; i < tx_nss; i++)
if (!__check_rate_pattern(&next_pattern, hw_rate_vht[i],
RA_MASK_VHT_RATES, RTW89_RA_MODE_VHT,
- mask->control[band].vht_mcs[i],
+ mask->control[nl_band].vht_mcs[i],
0, true))
goto out;

for (i = 0; i < tx_nss; i++)
if (!__check_rate_pattern(&next_pattern, hw_rate_ht[i],
RA_MASK_HT_RATES, RTW89_RA_MODE_HT,
- mask->control[band].ht_mcs[i],
+ mask->control[nl_band].ht_mcs[i],
0, true))
goto out;

@@ -457,18 +458,18 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,
* require at least one basic rate for ieee80211_set_bitrate_mask,
* so the decision just depends on if all bitrates are set or not.
*/
- sband = rtwdev->hw->wiphy->bands[band];
+ sband = rtwdev->hw->wiphy->bands[nl_band];
if (band == RTW89_BAND_2G) {
if (!__check_rate_pattern(&next_pattern, RTW89_HW_RATE_CCK1,
RA_MASK_CCK_RATES | RA_MASK_OFDM_RATES,
RTW89_RA_MODE_CCK | RTW89_RA_MODE_OFDM,
- mask->control[band].legacy,
+ mask->control[nl_band].legacy,
BIT(sband->n_bitrates) - 1, false))
goto out;
} else {
if (!__check_rate_pattern(&next_pattern, RTW89_HW_RATE_OFDM6,
RA_MASK_OFDM_RATES, RTW89_RA_MODE_OFDM,
- mask->control[band].legacy,
+ mask->control[nl_band].legacy,
BIT(sband->n_bitrates) - 1, false))
goto out;
}
--
2.25.1



2022-05-13 18:45:33

by Jeff Johnson

[permalink] [raw]
Subject: Re: [PATCH 5/6] rtw89: convert rtw89_band to nl80211_band precisely

On 5/12/2022 10:42 PM, Ping-Ke Shih wrote:
> From: Zong-Zhe Yang <[email protected]>
>
> Before 6G band was supported, i.e. only 2G and 5G, they were the same
> from the numerical point of view. However, after 6G band support, we
> need to do this conversion logically.

In the ath drivers we've been trying to avoid using the terms 2G/5G/6G
to describe frequencies since that usage conflicts with the cellular use
of similar terms to describe generations of the technology, and further
could cause confusion now that WFA is also defining generations of Wi-Fi
by number instead of by IEEE 802.11 amendment.

To that end it would be nice if we could universally adopt using proper
SI terminology when referring to Wi-Fi frequencies:
2 GHz (or 2.4 GHz), 5 GHz, & 6 GHz

2022-05-16 02:58:13

by Ping-Ke Shih

[permalink] [raw]
Subject: Re: [PATCH 5/6] rtw89: convert rtw89_band to nl80211_band precisely

On Fri, 2022-05-13 at 09:34 -0700, Jeff Johnson wrote:
> On 5/12/2022 10:42 PM, Ping-Ke Shih wrote:
> > From: Zong-Zhe Yang <[email protected]>
> >
> > Before 6G band was supported, i.e. only 2G and 5G, they were the same
> > from the numerical point of view. However, after 6G band support, we
> > need to do this conversion logically.
>
> In the ath drivers we've been trying to avoid using the terms 2G/5G/6G
> to describe frequencies since that usage conflicts with the cellular use
> of similar terms to describe generations of the technology, and further
> could cause confusion now that WFA is also defining generations of Wi-Fi
> by number instead of by IEEE 802.11 amendment.
>
> To that end it would be nice if we could universally adopt using proper
> SI terminology when referring to Wi-Fi frequencies:
> 2 GHz (or 2.4 GHz), 5 GHz, & 6 GHz
>

I will use SI terminology by v2, and share this information with my
members. Also, I will plan to rename the enum(s) of driver in separate
patch later.

--
Ping-Ke