rtw89: support channel context
Ping-Ke Shih
maintainerv3 cover rtw89: support channel context
In order to support multiple channels, we prepare this patchset to have initial skeleton of channel context, and only SCC (single channel concurrence) is supported for now.
The channel context needs some features, like hardware scan, but not all chips can support these features, so this implement can still support chips without channel context. The chip_info defines a support_chanctx_num field to discriminate a chip can support channel context or not, and we use this as clue to hook channel context ops of mac80211.
To determine if it can use channel context, load firmware header and parse firmware when probing before ieee80211_register_hw(). If chip defines it support channel context but firmware doesn't support hw_scan, it falls back to not use channel context. That means end users don't need additional update to use this driver after this patchset.
When we concentrate stuffs of channel, some patches with a lot of changes are used to adjust code for new struct. But, not really change logic.
v3:
- to have good user experience after applying this patchset. Load firmware header and parse firmware features to determine if we can use channel context. If old firmware is adopted, it still can run well as original.
v2:
- patch 11/13: add link_id argument because ieee80211 ops prototype are changed.
- patch 13/13: change to use module parameter rtw89_use_chanctx to prevent breaking users' setup by default, and users can try to use channel context after they upgrade firmware.
Zong-Zhe Yang (13):
wifi: rtw89: rewrite decision on channel by entity state
wifi: rtw89: introduce rtw89_chan for channel stuffs
wifi: rtw89: re-arrange channel related stuffs under HAL
wifi: rtw89: create rtw89_chan centrally to avoid breakage
wifi: rtw89: txpwr: concentrate channel related control to top
wifi: rtw89: rfk: concentrate parameter control while set_channel()
wifi: rtw89: concentrate parameter control for setting channel
callback
wifi: rtw89: concentrate chandef setting to stack callback
wifi: rtw89: initialize entity and configure default chandef
wifi: rtw89: introduce entity mode and its recalculated prototype
wifi: rtw89: add skeleton of mac80211 chanctx ops support
wifi: rtw89: declare support for mac80211 chanctx ops by chip
wifi: rtw89: early recognize FW feature to decide if chanctx
drivers/net/wireless/realtek/rtw89/Makefile | 1 + drivers/net/wireless/realtek/rtw89/chan.c | 235 ++++++++++++++++ drivers/net/wireless/realtek/rtw89/chan.h | 64 +++++ drivers/net/wireless/realtek/rtw89/coex.c | 11 +- drivers/net/wireless/realtek/rtw89/coex.h | 4 +- drivers/net/wireless/realtek/rtw89/core.c | 263 +++++++++-------- drivers/net/wireless/realtek/rtw89/core.h | 157 ++++++++--- drivers/net/wireless/realtek/rtw89/debug.c | 3 +- drivers/net/wireless/realtek/rtw89/fw.c | 72 ++++- drivers/net/wireless/realtek/rtw89/fw.h | 12 +- drivers/net/wireless/realtek/rtw89/mac.c | 14 +- drivers/net/wireless/realtek/rtw89/mac80211.c | 77 ++++- drivers/net/wireless/realtek/rtw89/pci.c | 20 +- drivers/net/wireless/realtek/rtw89/phy.c | 266 +++++++++++------- drivers/net/wireless/realtek/rtw89/phy.h | 8 +- drivers/net/wireless/realtek/rtw89/regd.c | 2 +- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 111 +++++--- .../net/wireless/realtek/rtw89/rtw8852a_rfk.c | 77 +++-- drivers/net/wireless/realtek/rtw89/rtw8852c.c | 231 ++++++++------- .../net/wireless/realtek/rtw89/rtw8852c_rfk.c | 73 +++-- .../net/wireless/realtek/rtw89/rtw8852c_rfk.h | 2 +- drivers/net/wireless/realtek/rtw89/sar.c | 8 +- drivers/net/wireless/realtek/rtw89/ser.c | 2 + 23 files changed, 1185 insertions(+), 528 deletions(-) create mode 100644 drivers/net/wireless/realtek/rtw89/chan.c create mode 100644 drivers/net/wireless/realtek/rtw89/chan.h
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 1/13 wifi: rtw89: rewrite decision on channel by entity state
From: Zong-Zhe Yang <[email protected]>
We need to invoke the callback of the changed band at the first set_channel() after every power-off. Originally, we forced the channel to be 0 when doing power-off, and then determined things by comparing channel with 0.
However, deciding on such things by channel might be confusing. It's also confusing to use this kind of decision when we consider multiple channels in the follow-up patches. So, another flag, entity_active, is added ahead to HAL to deal with this.
Besides, we also need to check if entity is active when we set TX power.
--- drivers/net/wireless/realtek/rtw89/chan.h | 24 +++++++++++++++++++++ drivers/net/wireless/realtek/rtw89/core.c | 26 +++++++++++++++++++---- drivers/net/wireless/realtek/rtw89/core.h | 15 +++---------- drivers/net/wireless/realtek/rtw89/mac.c | 4 ++-- drivers/net/wireless/realtek/rtw89/regd.c | 2 +- drivers/net/wireless/realtek/rtw89/sar.c | 2 +- 6 files changed, 53 insertions(+), 20 deletions(-) create mode 100644 drivers/net/wireless/realtek/rtw89/chan.h
drivers/net/wireless/realtek/rtw89/chan.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +* Copyright(c) 2020-2022 Realtek Corporation +*/ + +#ifndef __RTW89_CHAN_H__ +#define __RTW89_CHAN_H__ + +#include "core.h" + +static inline bool rtw89_get_entity_state (struct rtw89_dev *rtwdev) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +return READ_ONCE (hal->entity_active); +} + +static inline void rtw89_set_entity_state (struct rtw89_dev *rtwdev,bool active) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +WRITE_ONCE (hal->entity_active, active); +} + +#endif
drivers/net/wireless/realtek/rtw89/core.c +22 -4
@@ -5,6 +5,7 @@#include <linux/udp.h> #include "cam.h" +#include "chan.h" #include "coex.h" #include "core.h" #include "efuse.h"
@@ -352,6 +353,19 @@ static void rtw89_get_channel_params(struct cfg80211_chan_def *chandef, chan_param->subband_type = subband; } +void rtw89_core_set_chip_txpwr (struct rtw89_dev *rtwdev) +{ +const struct rtw89_chip_info *chip = rtwdev->chip; +bool entity_active; + + entity_active =rtw89_get_entity_state (rtwdev); +if (!entity_active) +return ; + +if (chip->ops->set_txpwr) + chip->ops->set_txpwr (rtwdev); +} +void rtw89_set_channel (struct rtw89_dev *rtwdev) {struct ieee80211_hw *hw = rtwdev->hw;
@@ -361,6 +375,9 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev)struct rtw89_channel_help_params bak;u8 center_chan, bandwidth;bool band_changed; +bool entity_active; + + entity_active =rtw89_get_entity_state (rtwdev);rtw89_get_channel_params (&hw->conf.chandef, &ch_param);if (WARN (ch_param.center_chan ==0 ,"Invalid channel\n" ))
@@ -368,8 +385,7 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev) center_chan = ch_param.center_chan; bandwidth = ch_param.bandwidth; - band_changed = hal->current_band_type != ch_param.band_type || - hal->current_channel ==0 ; + band_changed = hal->current_band_type != ch_param.band_type; hal->current_band_width = bandwidth; hal->current_channel = center_chan;
@@ -380,15 +396,17 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev) hal->current_band_type = ch_param.band_type; hal->current_subband = ch_param.subband_type; +rtw89_set_entity_state (rtwdev, true); +rtw89_chip_set_channel_prepare (rtwdev, &bak); chip->ops->set_channel (rtwdev, &ch_param); -rtw89_chip_set_txpwr (rtwdev); +rtw89_core_set_chip_txpwr (rtwdev);rtw89_chip_set_channel_done (rtwdev, &bak); -if (band_changed) { +if (!entity_active || band_changed) {rtw89_btc_ntfy_switch_band (rtwdev,RTW89_PHY_0 , hal->current_band_type);rtw89_chip_rfk_band_changed (rtwdev); }
drivers/net/wireless/realtek/rtw89/core.h +3 -12
@@ -2617,6 +2617,8 @@ struct rtw89_hal {u8 rx_nss;bool support_cckpd;bool support_igi; + +bool entity_active; };#define RTW89_MAX_MAC_ID_NUM 128
@@ -3664,18 +3666,6 @@ static inline void rtw89_chip_set_txpwr_ctrl(struct rtw89_dev *rtwdev) chip->ops->set_txpwr_ctrl (rtwdev); } -static inline void rtw89_chip_set_txpwr (struct rtw89_dev *rtwdev) -{ -const struct rtw89_chip_info *chip = rtwdev->chip; -u8 ch = rtwdev->hal.current_channel; - -if (!ch) -return ; - -if (chip->ops->set_txpwr) - chip->ops->set_txpwr (rtwdev); -} -static inline void rtw89_chip_power_trim (struct rtw89_dev *rtwdev) {const struct rtw89_chip_info *chip = rtwdev->chip;
@@ -3906,6 +3896,7 @@ int rtw89_core_init(struct rtw89_dev *rtwdev);void rtw89_core_deinit (struct rtw89_dev *rtwdev);int rtw89_core_register (struct rtw89_dev *rtwdev);void rtw89_core_unregister (struct rtw89_dev *rtwdev); +void rtw89_core_set_chip_txpwr (struct rtw89_dev *rtwdev);void rtw89_set_channel (struct rtw89_dev *rtwdev);u8 rtw89_core_acquire_bit_map (unsigned long *addr,unsigned long size);void rtw89_core_release_bit_map (unsigned long *addr,u8 bit);
drivers/net/wireless/realtek/rtw89/mac.c +2 -2
@@ -3,6 +3,7 @@*/ #include "cam.h" +#include "chan.h" #include "debug.h" #include "fw.h" #include "mac.h"
@@ -1081,7 +1082,6 @@ static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)const struct rtw89_chip_info *chip = rtwdev->chip;const struct rtw89_pwr_cfg *const *cfg_seq;int (*cfg_func)(struct rtw89_dev *rtwdev); -struct rtw89_hal *hal = &rtwdev->hal;int ret;u8 val;
@@ -1113,7 +1113,7 @@ static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)clear_bit (RTW89_FLAG_POWERON , rtwdev->flags);clear_bit (RTW89_FLAG_FW_RDY , rtwdev->flags);rtw89_write8 (rtwdev,R_AX_SCOREBOARD +3 ,MAC_AX_NOTIFY_PWR_MAJOR ); - hal->current_channel =0 ; +rtw89_set_entity_state (rtwdev, false); }return 0 ;
drivers/net/wireless/realtek/rtw89/regd.c +1 -1
@@ -346,7 +346,7 @@ void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *requestrtw89_debug_regd (rtwdev, rtwdev->regd,"get from initiator %d, alpha2" , request->initiator); -rtw89_chip_set_txpwr (rtwdev); +rtw89_core_set_chip_txpwr (rtwdev); exit:mutex_unlock (&rtwdev->mutex);
drivers/net/wireless/realtek/rtw89/sar.c +1 -1
@@ -228,7 +228,7 @@ static int rtw89_apply_sar_common(struct rtw89_dev *rtwdev, }rtw89_sar_set_src (rtwdev,RTW89_SAR_SOURCE_COMMON , cfg_common, sar); -rtw89_chip_set_txpwr (rtwdev); +rtw89_core_set_chip_txpwr (rtwdev); exit:mutex_unlock (&rtwdev->mutex);
Signature · 1 line
2.25.1
Re: [PATCH v3 01/13] wifi: rtw89: rewrite decision on channel by entity state
Quoted 12 lines · Ping-Ke Shih
From: Zong-Zhe Yang <[email protected]>
We need to invoke the callback of the changed band at the first
set_channel()after every power-off. Originally, we forced the channel to be 0 when doing power-off, and then determined things by comparing channel with 0.However, deciding on such things by channel might be confusing. It's also confusing to use this kind of decision when we consider multiple channels in the follow-up patches. So, another flag,
entity_active, is added ahead to HAL to deal with this.
Quoted 5 lines
Besides, we also need to check if entity is active when we set TX power.
Signed-off-by Zong-Zhe Yang <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>
13 patches applied to wireless-next.git, thanks.
967439c7a2a6 wifi: rtw89: rewrite decision on channel by entity state 3e5831cac1e6 wifi: rtw89: introduce rtw89_chan for channel stuffs cbb145b98b63 wifi: rtw89: re-arrange channel related stuffs under HAL bb8152b386c3 wifi: rtw89: create rtw89_chan centrally to avoid breakage 07ef5f2fa3f3 wifi: rtw89: txpwr: concentrate channel related control to top 010d0051f7ec wifi: rtw89: rfk: concentrate parameter control while set_channel() ce57e55c0b70 wifi: rtw89: concentrate parameter control for setting channel callback 494399b2130c wifi: rtw89: concentrate chandef setting to stack callback a88b6cc483ab wifi: rtw89: initialize entity and configure default chandef 7cf674ffc852 wifi: rtw89: introduce entity mode and its recalculated prototype 84b50f4187fc wifi: rtw89: add skeleton of mac80211 chanctx ops support 7fc06a071cd5 wifi: rtw89: declare support for mac80211 chanctx ops by chip deebea35d699 wifi: rtw89: early recognize FW feature to decide if chanctx
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Ping-Ke Shih
maintainerPATCH v3 2/13 wifi: rtw89: introduce rtw89_chan for channel stuffs
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
Introduce struct rtw89_chan ahead to encapsulate stuffs from struct rtw89_channel_params. These stuffs have a clone in HAL and are used throughout driver. After multiple channels support, it's expected that each channel instance has a configuration of them. So, we refine them with struct rtw89_chan by precise type first, and will re-arrange HAL by struct rtw89_chan in the following as well.
(No logic has changed.)
--- drivers/net/wireless/realtek/rtw89/core.c | 38 ++--- drivers/net/wireless/realtek/rtw89/core.h | 18 +-- drivers/net/wireless/realtek/rtw89/phy.c | 8 +- drivers/net/wireless/realtek/rtw89/phy.h | 2 +- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 37 ++--- drivers/net/wireless/realtek/rtw89/rtw8852c.c | 138 +++++++++--------- .../net/wireless/realtek/rtw89/rtw8852c_rfk.c | 7 +- .../net/wireless/realtek/rtw89/rtw8852c_rfk.h | 2 +- 8 files changed, 128 insertions(+), 122 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +19 -19
@@ -226,7 +226,7 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev, }static void rtw89_get_channel_params (struct cfg80211_chan_def *chandef, -struct rtw89_channel_params *chan_param) +struct rtw89_chan *chan) {struct ieee80211_channel *channel = chandef->chan;enum nl80211_chan_width width = chandef->width;
@@ -344,13 +344,13 @@ static void rtw89_get_channel_params(struct cfg80211_chan_def *chandef,break ; } - chan_param->center_chan = center_chan; - chan_param->center_freq = center_freq; - chan_param->primary_chan = channel->hw_value; - chan_param->bandwidth = bandwidth; - chan_param->pri_ch_idx = primary_chan_idx; - chan_param->band_type = band; - chan_param->subband_type = subband; + chan->channel = center_chan; + chan->freq = center_freq; + chan->primary_channel = channel->hw_value; + chan->band_type = band; + chan->band_width = bandwidth; + chan->subband_type = subband; + chan->pri_ch_idx = primary_chan_idx; }void rtw89_core_set_chip_txpwr (struct rtw89_dev *rtwdev)
@@ -371,7 +371,7 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev)struct ieee80211_hw *hw = rtwdev->hw;const struct rtw89_chip_info *chip = rtwdev->chip;struct rtw89_hal *hal = &rtwdev->hal; -struct rtw89_channel_params ch_param; +struct rtw89_chan chan;struct rtw89_channel_help_params bak;u8 center_chan, bandwidth;bool band_changed;
@@ -379,28 +379,28 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev) entity_active =rtw89_get_entity_state (rtwdev); -rtw89_get_channel_params (&hw->conf.chandef, &ch_param); -if (WARN (ch_param.center_chan ==0 ,"Invalid channel\n" )) +rtw89_get_channel_params (&hw->conf.chandef, &chan); +if (WARN (chan.channel ==0 ,"Invalid channel\n" ))return ; - center_chan = ch_param.center_chan; - bandwidth = ch_param.bandwidth; - band_changed = hal->current_band_type != ch_param.band_type; + center_chan = chan.channel; + bandwidth = chan.band_width; + band_changed = hal->current_band_type != chan.band_type; hal->current_band_width = bandwidth; hal->current_channel = center_chan; - hal->current_freq = ch_param.center_freq; + hal->current_freq = chan.freq; hal->prev_primary_channel = hal->current_primary_channel; hal->prev_band_type = hal->current_band_type; - hal->current_primary_channel = ch_param.primary_chan; - hal->current_band_type = ch_param.band_type; - hal->current_subband = ch_param.subband_type; + hal->current_primary_channel = chan.primary_channel; + hal->current_band_type = chan.band_type; + hal->current_subband = chan.subband_type;rtw89_set_entity_state (rtwdev, true);rtw89_chip_set_channel_prepare (rtwdev, &bak); - chip->ops->set_channel (rtwdev, &ch_param); + chip->ops->set_channel (rtwdev, &chan);rtw89_core_set_chip_txpwr (rtwdev);
drivers/net/wireless/realtek/rtw89/core.h +9 -9
@@ -624,14 +624,14 @@ enum rtw89_sc_offset { RTW89_SC_40_LOWER = 10, }; -struct rtw89_channel_params { -u8 center_chan; -u32 center_freq; -u8 primary_chan; -u8 bandwidth; -u8 pri_ch_idx; -u8 band_type; -u8 subband_type; +struct rtw89_chan { +u8 channel; +u32 freq; +u8 primary_channel; +enum rtw89_band band_type; +enum rtw89_bandwidth band_width; +enum rtw89_subband subband_type; +enum rtw89_sc_offset pri_ch_idx; };struct rtw89_channel_help_params {
@@ -2100,7 +2100,7 @@ struct rtw89_chip_ops {bool (*write_rf)(struct rtw89_dev *rtwdev,enum rtw89_rf_path rf_path,u32 addr,u32 mask,u32 data);void (*set_channel)(struct rtw89_dev *rtwdev, -struct rtw89_channel_params *param); +const struct rtw89_chan *chan);void (*set_channel_help)(struct rtw89_dev *rtwdev,bool enter,struct rtw89_channel_help_params *p);int (*read_efuse)(struct rtw89_dev *rtwdev,u8 *log_map);
drivers/net/wireless/realtek/rtw89/phy.c +4 -4
@@ -542,12 +542,12 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct ieee80211_sta *sta) }u8 rtw89_phy_get_txsc (struct rtw89_dev *rtwdev, -struct rtw89_channel_params *param, +const struct rtw89_chan *chan,enum rtw89_bandwidth dbw) { -enum rtw89_bandwidth cbw = param->bandwidth; -u8 pri_ch = param->primary_chan; -u8 central_ch = param->center_chan; +enum rtw89_bandwidth cbw = chan->band_width; +u8 pri_ch = chan->primary_channel; +u8 central_ch = chan->channel;u8 txsc_idx =0 ;u8 tmp =0 ;
drivers/net/wireless/realtek/rtw89/phy.h +1 -1
@@ -439,7 +439,7 @@ rtw89_rfk_parser(struct rtw89_dev *rtwdev, const struct rtw89_rfk_tbl *tbl);void rtw89_phy_write_reg3_tbl (struct rtw89_dev *rtwdev,const struct rtw89_phy_reg3_tbl *tbl);u8 rtw89_phy_get_txsc (struct rtw89_dev *rtwdev, -struct rtw89_channel_params *param, +const struct rtw89_chan *chan,enum rtw89_bandwidth dbw);u32 rtw89_phy_read_rf (struct rtw89_dev *rtwdev,enum rtw89_rf_path rf_path,u32 addr,u32 mask);
drivers/net/wireless/realtek/rtw89/rtw8852a.c +19 -18
@@ -660,7 +660,7 @@ static void rtw8852a_power_trim(struct rtw89_dev *rtwdev) }static void rtw8852a_set_channel_mac (struct rtw89_dev *rtwdev, -struct rtw89_channel_params *param, +const struct rtw89_chan *chan,u8 mac_idx) {u32 rf_mod =rtw89_mac_reg_by_idx (R_AX_WMAC_RFMOD , mac_idx);
@@ -669,20 +669,20 @@ static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev,u32 chk_rate =rtw89_mac_reg_by_idx (R_AX_TXRATE_CHK , mac_idx);u8 txsc20 =0 , txsc40 =0 ; -switch (param->bandwidth) { +switch (chan->band_width) {case RTW89_CHANNEL_WIDTH_80 : - txsc40 =rtw89_phy_get_txsc (rtwdev, param, + txsc40 =rtw89_phy_get_txsc (rtwdev, chan,RTW89_CHANNEL_WIDTH_40 ); fallthrough;case RTW89_CHANNEL_WIDTH_40 : - txsc20 =rtw89_phy_get_txsc (rtwdev, param, + txsc20 =rtw89_phy_get_txsc (rtwdev, chan,RTW89_CHANNEL_WIDTH_20 );break ;default :break ; } -switch (param->bandwidth) { +switch (chan->band_width) {case RTW89_CHANNEL_WIDTH_80 :rtw89_write8_mask (rtwdev, rf_mod,B_AX_WMAC_RFMOD_MASK ,BIT (1 ));rtw89_write32 (rtwdev, sub_carr, txsc20 | (txsc40 <<4 ));
@@ -699,7 +699,7 @@ static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev,break ; } -if (param->center_chan >14 ) +if (chan->channel >14 )rtw89_write8_set (rtwdev, chk_rate,B_AX_CHECK_CCK_EN |B_AX_RTS_LIMIT_IN_OFDM6 );else
@@ -1130,35 +1130,36 @@ static void rtw8852a_bbrst_for_rfk(struct rtw89_dev *rtwdev, }static void rtw8852a_set_channel_bb (struct rtw89_dev *rtwdev, -struct rtw89_channel_params *param, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) { -bool cck_en = param->center_chan <=14 ; -u8 pri_ch_idx = param->pri_ch_idx; +bool cck_en = chan->channel <=14 ; +u8 pri_ch_idx = chan->pri_ch_idx;if (cck_en) -rtw8852a_ctrl_sco_cck (rtwdev, param->center_chan, - param->primary_chan, param->bandwidth); +rtw8852a_ctrl_sco_cck (rtwdev, chan->channel, + chan->primary_channel, + chan->band_width); -rtw8852a_ctrl_ch (rtwdev, param->center_chan, phy_idx); -rtw8852a_ctrl_bw (rtwdev, pri_ch_idx, param->bandwidth, phy_idx); +rtw8852a_ctrl_ch (rtwdev, chan->channel, phy_idx); +rtw8852a_ctrl_bw (rtwdev, pri_ch_idx, chan->band_width, phy_idx);if (cck_en) {rtw89_phy_write32_mask (rtwdev,R_RXCCA ,B_RXCCA_DIS ,0 ); }else {rtw89_phy_write32_mask (rtwdev,R_RXCCA ,B_RXCCA_DIS ,1 );rtw8852a_bbrst_for_rfk (rtwdev, phy_idx); } -rtw8852a_spur_elimination (rtwdev, param->center_chan); +rtw8852a_spur_elimination (rtwdev, chan->channel);rtw89_phy_write32_mask (rtwdev,R_MAC_PIN_SEL ,B_CH_IDX_SEG0 , - param->primary_chan); + chan->primary_channel);rtw8852a_bb_reset_all (rtwdev, phy_idx); }static void rtw8852a_set_channel (struct rtw89_dev *rtwdev, -struct rtw89_channel_params *params) +const struct rtw89_chan *chan) { -rtw8852a_set_channel_mac (rtwdev, params,RTW89_MAC_0 ); -rtw8852a_set_channel_bb (rtwdev, params,RTW89_PHY_0 ); +rtw8852a_set_channel_mac (rtwdev, chan,RTW89_MAC_0 ); +rtw8852a_set_channel_bb (rtwdev, chan,RTW89_PHY_0 ); }static void rtw8852a_dfs_en (struct rtw89_dev *rtwdev,bool en)
drivers/net/wireless/realtek/rtw89/rtw8852c.c +71 -67
364 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/rtw8852c_rfk.c +4 -3
@@ -3802,11 +3802,12 @@ void rtw8852c_ctrl_bw_ch(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, }void rtw8852c_set_channel_rf (struct rtw89_dev *rtwdev, -struct rtw89_channel_params *param, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) { -rtw8852c_ctrl_bw_ch (rtwdev, phy_idx, param->center_chan, param->band_type, - param->bandwidth); +rtw8852c_ctrl_bw_ch (rtwdev, phy_idx, chan->channel, + chan->band_type, + chan->band_width); }void rtw8852c_mcc_get_ch_info (struct rtw89_dev *rtwdev,enum rtw89_phy_idx phy_idx)
drivers/net/wireless/realtek/rtw89/rtw8852c_rfk.h +1 -1
@@ -21,7 +21,7 @@ void rtw8852c_tssi_cont_en_phyidx(struct rtw89_dev *rtwdev, bool en, u8 phy_idx)void rtw8852c_wifi_scan_notify (struct rtw89_dev *rtwdev,bool scan_start,enum rtw89_phy_idx phy_idx);void rtw8852c_set_channel_rf (struct rtw89_dev *rtwdev, -struct rtw89_channel_params *param, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx);void rtw8852c_lck_init (struct rtw89_dev *rtwdev);void rtw8852c_lck_track (struct rtw89_dev *rtwdev);
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 3/13 wifi: rtw89: re-arrange channel related stuffs under HAL
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
We are planning to support mac80211 chanctx. To reduce future works, the driver architecture is adjusted first to isolate related things.
According to chip, our HW may have multiple sub-entities to support multiple mac80211 chanctx. Struct rtw89_chan has been introduced for things about channel/band/subband/... Now introduce struct rtw89_chan_rcd to record difference after assigning new one of struct rtw89_chan.
We will implement and support chanctx with single channel first, i.e. only use entry in RTW89_SUB_ENTITY_0, before handling dual channels.
Our hierarchy in planning will become as the following. DEV
-> HAL
---> entity (manage status across sub-entities) -----> sub-entity[*] (support mac80211 chanctx) where each sub-entity contains one struct rtw89_chan.
--- drivers/net/wireless/realtek/rtw89/Makefile | 1 + drivers/net/wireless/realtek/rtw89/chan.c | 22 ++++++ drivers/net/wireless/realtek/rtw89/chan.h | 4 ++ drivers/net/wireless/realtek/rtw89/coex.c | 11 ++- drivers/net/wireless/realtek/rtw89/coex.h | 4 +- drivers/net/wireless/realtek/rtw89/core.c | 58 +++++++--------- drivers/net/wireless/realtek/rtw89/core.h | 40 ++++++++--- drivers/net/wireless/realtek/rtw89/debug.c | 3 +- drivers/net/wireless/realtek/rtw89/fw.c | 35 ++++++---- drivers/net/wireless/realtek/rtw89/mac.c | 15 ++-- drivers/net/wireless/realtek/rtw89/mac80211.c | 3 +- drivers/net/wireless/realtek/rtw89/phy.c | 39 +++++++---- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 17 +++-- .../net/wireless/realtek/rtw89/rtw8852a_rfk.c | 68 +++++++++++-------- drivers/net/wireless/realtek/rtw89/rtw8852c.c | 28 +++++--- .../net/wireless/realtek/rtw89/rtw8852c_rfk.c | 66 ++++++++++-------- drivers/net/wireless/realtek/rtw89/sar.c | 6 +- 17 files changed, 257 insertions(+), 163 deletions(-) create mode 100644 drivers/net/wireless/realtek/rtw89/chan.c
drivers/net/wireless/realtek/rtw89/Makefile +1 -0
@@ -12,6 +12,7 @@ rtw89_core-y += core.o \ sar.o \ coex.o \ ps.o \ + chan.o \ ser.o obj-$(CONFIG_RTW89_8852A) += rtw89_8852a.o
drivers/net/wireless/realtek/rtw89/chan.c new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* Copyright(c) 2020-2022 Realtek Corporation +*/ + +#include "chan.h" + +bool rtw89_assign_entity_chan (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx, +const struct rtw89_chan *new) +{ +struct rtw89_hal *hal = &rtwdev->hal; +struct rtw89_chan *chan = &hal->chan[idx]; +struct rtw89_chan_rcd *rcd = &hal->chan_rcd[idx]; +bool band_changed; + + rcd->prev_primary_channel = chan->primary_channel; + rcd->prev_band_type = chan->band_type; + band_changed = new->band_type != chan->band_type; + + *chan = *new; +return band_changed; +}
drivers/net/wireless/realtek/rtw89/chan.h +4 -0
@@ -21,4 +21,8 @@ static inline void rtw89_set_entity_state(struct rtw89_dev *rtwdev, bool active) WRITE_ONCE(hal->entity_active, active); } +bool rtw89_assign_entity_chan (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx, +const struct rtw89_chan *new); +#endif
drivers/net/wireless/realtek/rtw89/coex.c +5 -6
@@ -4150,7 +4150,7 @@ enum btc_wl_mode {void rtw89_btc_ntfy_role_info (struct rtw89_dev *rtwdev,struct rtw89_vif *rtwvif,struct rtw89_sta *rtwsta,enum btc_role_state state) { -struct rtw89_hal *hal = &rtwdev->hal; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );struct ieee80211_vif *vif =rtwvif_to_vif (rtwvif);struct ieee80211_sta *sta =rtwsta_to_sta (rtwsta);struct rtw89_btc *btc = &rtwdev->btc;
@@ -4165,8 +4165,7 @@ void rtw89_btc_ntfy_role_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif vif->type == NL80211_IFTYPE_STATION);rtw89_debug (rtwdev,RTW89_DBG_BTC ,"[BTC], port=%d\n" , rtwvif->port);rtw89_debug (rtwdev,RTW89_DBG_BTC ,"[BTC], band=%d ch=%d bw=%d\n" , - hal->current_band_type, hal->current_channel, - hal->current_band_width); + chan->band_type, chan->channel, chan->band_width);rtw89_debug (rtwdev,RTW89_DBG_BTC ,"[BTC], associated=%d\n" , state ==BTC_ROLE_MSTS_STA_CONN_END ); rtw89_debug(rtwdev, RTW89_DBG_BTC,
@@ -4205,9 +4204,9 @@ void rtw89_btc_ntfy_role_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif r.connected =MLME_LINKED ; r.bcn_period = vif->bss_conf.beacon_int; r.dtim_period = vif->bss_conf.dtim_period; - r.band = hal->current_band_type; - r.ch = hal->current_channel; - r.bw = hal->current_band_width; + r.band = chan->band_type; + r.ch = chan->channel; + r.bw = chan->band_width;ether_addr_copy (r.mac_addr, rtwvif->mac_addr);if (rtwsta && vif->type ==NL80211_IFTYPE_STATION )
drivers/net/wireless/realtek/rtw89/coex.h +2 -2
@@ -167,12 +167,12 @@ static inline u8 rtw89_btc_phymap(struct rtw89_dev *rtwdev,enum rtw89_phy_idx phy_idx, enum rtw89_rf_path_bit paths) { - struct rtw89_hal *hal = &rtwdev->hal; + const struct rtw89_chan *chan = rtw89_chan_get(rtwdev, RTW89_SUB_ENTITY_0);u8 phy_map; phy_map =FIELD_PREP (BTC_RFK_PATH_MAP , paths) |FIELD_PREP (BTC_RFK_PHY_MAP ,BIT (phy_idx)) | -FIELD_PREP (BTC_RFK_BAND_MAP , hal->current_band_type); +FIELD_PREP (BTC_RFK_BAND_MAP , chan->band_type);return phy_map; }
drivers/net/wireless/realtek/rtw89/core.c +25 -33
149 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/core.h +32 -8
@@ -542,6 +542,12 @@ enum rtw89_phy_idx {RTW89_PHY_MAX }; +enum rtw89_sub_entity_idx { +RTW89_SUB_ENTITY_0 =0 , + +NUM_OF_RTW89_SUB_ENTITY , +}; +enum rtw89_rf_path {RF_PATH_A =0 ,RF_PATH_B =1 ,
@@ -634,6 +640,11 @@ struct rtw89_chan {enum rtw89_sc_offset pri_ch_idx; }; +struct rtw89_chan_rcd { +u8 prev_primary_channel; +enum rtw89_band prev_band_type; +}; +struct rtw89_channel_help_params {u32 tx_en; };
@@ -2602,14 +2613,6 @@ struct rtw89_sar_info {struct rtw89_hal {u32 rx_fltr;u8 cv; -u8 current_channel; -u32 current_freq; -u8 prev_primary_channel; -u8 current_primary_channel; -enum rtw89_subband current_subband; -u8 current_band_width; -u8 prev_band_type; -u8 current_band_type;u32 sw_amsdu_max_size;u32 antenna_tx;u32 antenna_rx;
@@ -2619,6 +2622,9 @@ struct rtw89_hal {bool support_igi;bool entity_active; + +struct rtw89_chan chan[NUM_OF_RTW89_SUB_ENTITY ]; +struct rtw89_chan_rcd chan_rcd[NUM_OF_RTW89_SUB_ENTITY ]; };#define RTW89_MAX_MAC_ID_NUM 128
@@ -3602,6 +3608,24 @@ void rtw89_chip_set_channel_done(struct rtw89_dev *rtwdev, rtwdev->chip->ops->set_channel_help (rtwdev, false, p); } +static inline +const struct rtw89_chan *rtw89_chan_get (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +return &hal->chan[idx]; +} + +static inline +const struct rtw89_chan_rcd *rtw89_chan_rcd_get (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +return &hal->chan_rcd[idx]; +} +static inline void rtw89_chip_fem_setup (struct rtw89_dev *rtwdev) {const struct rtw89_chip_info *chip = rtwdev->chip;
drivers/net/wireless/realtek/rtw89/debug.c +2 -1
@@ -525,7 +525,8 @@ static int __print_txpwr_map(struct seq_file *m, struct rtw89_dev *rtwdev,static void __print_regd (struct seq_file *m,struct rtw89_dev *rtwdev) { -u8 band = rtwdev->hal.current_band_type; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 band = chan->band_type;u8 regd =rtw89_regd_get (rtwdev, band);switch (regd) {
drivers/net/wireless/realtek/rtw89/fw.c +20 -15
@@ -3,6 +3,7 @@*/ #include "cam.h" +#include "chan.h" #include "coex.h" #include "debug.h" #include "fw.h"
@@ -926,9 +927,9 @@ int rtw89_fw_h2c_assoc_cmac_tbl(struct rtw89_dev *rtwdev, struct ieee80211_sta *sta) {const struct rtw89_chip_info *chip = rtwdev->chip; -struct rtw89_hal *hal = &rtwdev->hal;struct rtw89_sta *rtwsta =sta_to_rtwsta_safe (sta);struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );struct sk_buff *skb;u8 pads[RTW89_PPE_BW_NUM ];u8 mac_id = rtwsta ? rtwsta->mac_id : rtwvif->mac_id;
@@ -947,7 +948,7 @@ int rtw89_fw_h2c_assoc_cmac_tbl(struct rtw89_dev *rtwdev,SET_CTRL_INFO_OPERATION (skb->data,1 );SET_CMC_TBL_DISRTSFB (skb->data,1 );SET_CMC_TBL_DISDATAFB (skb->data,1 ); -if (hal->current_band_type ==RTW89_BAND_2G ) +if (chan->band_type ==RTW89_BAND_2G )SET_CMC_TBL_RTS_RTY_LOWEST_RATE (skb->data,RTW89_HW_RATE_CCK1 );else SET_CMC_TBL_RTS_RTY_LOWEST_RATE (skb->data,RTW89_HW_RATE_OFDM6 );
@@ -1036,8 +1037,8 @@ int rtw89_fw_h2c_txtime_cmac_tbl(struct rtw89_dev *rtwdev,int rtw89_fw_h2c_update_beacon (struct rtw89_dev *rtwdev,struct rtw89_vif *rtwvif) { -struct rtw89_hal *hal = &rtwdev->hal;struct ieee80211_vif *vif =rtwvif_to_vif (rtwvif); +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );struct sk_buff *skb;struct sk_buff *skb_beacon;u16 tim_offset;
@@ -1066,7 +1067,7 @@ int rtw89_fw_h2c_update_beacon(struct rtw89_dev *rtwdev,SET_BCN_UPD_MACID (skb->data, rtwvif->mac_id);SET_BCN_UPD_SSN_SEL (skb->data,RTW89_MGMT_HW_SSN_SEL );SET_BCN_UPD_SSN_MODE (skb->data,RTW89_MGMT_HW_SEQ_MODE ); -SET_BCN_UPD_RATE (skb->data, hal->current_band_type ==RTW89_BAND_2G ? +SET_BCN_UPD_RATE (skb->data, chan->band_type ==RTW89_BAND_2G ?RTW89_HW_RATE_CCK1 :RTW89_HW_RATE_OFDM6 );skb_put_data (skb, skb_beacon->data, skb_beacon->len);
@@ -1788,6 +1789,7 @@ int rtw89_fw_h2c_rf_reg(struct rtw89_dev *rtwdev,int rtw89_fw_h2c_rf_ntfy_mcc (struct rtw89_dev *rtwdev) { +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );struct rtw89_mcc_info *mcc_info = &rtwdev->mcc;struct rtw89_fw_h2c_rf_get_mccch *mccch;struct sk_buff *skb;
@@ -1804,8 +1806,8 @@ int rtw89_fw_h2c_rf_ntfy_mcc(struct rtw89_dev *rtwdev) mccch->ch_1 =cpu_to_le32 (mcc_info->ch[1 ]); mccch->band_0 =cpu_to_le32 (mcc_info->band[0 ]); mccch->band_1 =cpu_to_le32 (mcc_info->band[1 ]); - mccch->current_channel =cpu_to_le32 (rtwdev->hal.current_channel); - mccch->current_band_type =cpu_to_le32 (rtwdev->hal.current_band_type); + mccch->current_channel =cpu_to_le32 (chan->channel); + mccch->current_band_type =cpu_to_le32 (chan->band_type); rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C, H2C_CAT_OUTSRC, H2C_CL_OUTSRC_RF_FW_NOTIFY,
@@ -2377,18 +2379,21 @@ int rtw89_hw_scan_offload(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif,void rtw89_store_op_chan (struct rtw89_dev *rtwdev,bool backup) {struct rtw89_hw_scan_info *scan_info = &rtwdev->scan_info; -struct rtw89_hal *hal = &rtwdev->hal; +const struct rtw89_chan *cur =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +struct rtw89_chan new;if (backup) { - scan_info->op_pri_ch = hal->current_primary_channel; - scan_info->op_chan = hal->current_channel; - scan_info->op_bw = hal->current_band_width; - scan_info->op_band = hal->current_band_type; + scan_info->op_pri_ch = cur->primary_channel; + scan_info->op_chan = cur->channel; + scan_info->op_bw = cur->band_width; + scan_info->op_band = cur->band_type; }else { - hal->current_primary_channel = scan_info->op_pri_ch; - hal->current_channel = scan_info->op_chan; - hal->current_band_width = scan_info->op_bw; - hal->current_band_type = scan_info->op_band; + new = *cur; + new.primary_channel = scan_info->op_pri_ch; + new.channel = scan_info->op_chan; + new.band_width = scan_info->op_bw; + new.band_type = scan_info->op_band; +rtw89_assign_entity_chan (rtwdev,RTW89_SUB_ENTITY_0 , &new); } }
drivers/net/wireless/realtek/rtw89/mac.c +8 -7
@@ -3655,7 +3655,8 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_dev *rtwdev, struct sk_buff *c2h, u32 len) {struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif; -struct rtw89_hal *hal = &rtwdev->hal; +const struct rtw89_chan *cur =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +struct rtw89_chan new;u8 reason, status, tx_fail, band;u16 chan;
@@ -3681,12 +3682,12 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_dev *rtwdev, struct sk_buff *c2h,rtw89_hw_scan_complete (rtwdev, vif, false);break ;case RTW89_SCAN_ENTER_CH_NOTIFY : - hal->prev_band_type = hal->current_band_type; - hal->current_band_type = band; - hal->prev_primary_channel = hal->current_primary_channel; - hal->current_primary_channel = chan; - hal->current_channel = chan; - hal->current_band_width =RTW89_CHANNEL_WIDTH_20 ; + new = *cur; + new.channel = chan; + new.primary_channel = chan; + new.band_type = band; + new.band_width =RTW89_CHANNEL_WIDTH_20 ; +rtw89_assign_entity_chan (rtwdev,RTW89_SUB_ENTITY_0 , &new);if (rtw89_is_op_chan (rtwdev, band, chan)) {rtw89_store_op_chan (rtwdev, false);ieee80211_wake_queues (rtwdev->hw);
drivers/net/wireless/realtek/rtw89/mac80211.c +2 -1
@@ -235,11 +235,12 @@ static u8 rtw89_aifsn_to_aifs(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif, u8 aifsn) {struct ieee80211_vif *vif =rtwvif_to_vif (rtwvif); +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u8 slot_time;u8 sifs; slot_time = vif->bss_conf.use_short_slot ?9 :20 ; - sifs = rtwdev->hal.current_band_type ==RTW89_BAND_5G ?16 :10 ; + sifs = chan->band_type ==RTW89_BAND_5G ?16 :10 ;return aifsn * slot_time + sifs; }
drivers/net/wireless/realtek/rtw89/phy.c +24 -15
@@ -142,8 +142,8 @@ static u64 rtw89_phy_ra_mask_recover(u64 ra_mask, u64 ra_mask_bak)static u64 rtw89_phy_ra_mask_cfg (struct rtw89_dev *rtwdev,struct rtw89_sta *rtwsta) { -struct rtw89_hal *hal = &rtwdev->hal;struct ieee80211_sta *sta =rtwsta_to_sta (rtwsta); +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );struct cfg80211_bitrate_mask *mask = &rtwsta->mask;enum nl80211_band band;u64 cfg_mask;
@@ -151,7 +151,7 @@ static u64 rtw89_phy_ra_mask_cfg(struct rtw89_dev *rtwdev, struct rtw89_sta *rtwif (!rtwsta->use_cfg_mask)return -1 ; -switch (hal->current_band_type) { +switch (chan->band_type) {case RTW89_BAND_2G : band =NL80211_BAND_2GHZ ; cfg_mask = u64_encode_bits(mask->control[NL80211_BAND_2GHZ].legacy,
@@ -168,7 +168,7 @@ static u64 rtw89_phy_ra_mask_cfg(struct rtw89_dev *rtwdev, struct rtw89_sta *rtw RA_MASK_OFDM_RATES);break ;default : -rtw89_warn (rtwdev,"unhandled band type %d\n" , hal->current_band_type); +rtw89_warn (rtwdev,"unhandled band type %d\n" , chan->band_type);return -1 ; }
@@ -209,6 +209,7 @@ static void rtw89_phy_ra_sta_update(struct rtw89_dev *rtwdev,struct rtw89_vif *rtwvif = rtwsta->rtwvif;struct rtw89_phy_rate_pattern *rate_pattern = &rtwvif->rate_pattern;struct rtw89_ra_info *ra = &rtwsta->ra; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );const u64 *high_rate_masks = rtw89_ra_mask_ht_rates;u8 rssi =ewma_rssi_read (&rtwsta->avg_rssi);u64 ra_mask =0 ;
@@ -260,7 +261,7 @@ static void rtw89_phy_ra_sta_update(struct rtw89_dev *rtwdev, ldpc_en =1 ; } -switch (rtwdev->hal.current_band_type) { +switch (chan->band_type) {case RTW89_BAND_2G : ra_mask |= sta->deflink.supp_rates[NL80211_BAND_2GHZ ];if (sta->deflink.supp_rates[NL80211_BAND_2GHZ ] <=0xf )
@@ -416,6 +417,7 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,struct ieee80211_supported_band *sband;struct rtw89_vif *rtwvif = (struct rtw89_vif *)vif->drv_priv;struct rtw89_phy_rate_pattern next_pattern = {0 }; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );static const u16 hw_rate_he[] = {RTW89_HW_RATE_HE_NSS1_MCS0 ,RTW89_HW_RATE_HE_NSS2_MCS0 ,RTW89_HW_RATE_HE_NSS3_MCS0 ,
@@ -428,7 +430,7 @@ void rtw89_phy_rate_pattern_vif(struct rtw89_dev *rtwdev,RTW89_HW_RATE_MCS8 ,RTW89_HW_RATE_MCS16 , RTW89_HW_RATE_MCS24}; -u8 band = rtwdev->hal.current_band_type; +u8 band = chan->band_type;enum nl80211_band nl_band =rtw89_hw_to_nl80211_band (band);u8 tx_nss = rtwdev->hal.tx_nss;u8 i;
@@ -1471,7 +1473,8 @@ EXPORT_SYMBOL(rtw89_phy_load_txpwr_byrate);s8 rtw89_phy_read_txpwr_byrate (struct rtw89_dev *rtwdev,const struct rtw89_rate_desc *rate_desc) { -enum rtw89_band band = rtwdev->hal.current_band_type; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +enum rtw89_band band = chan->band_type;s8 *byr;u8 idx;
@@ -1542,7 +1545,8 @@ s8 rtw89_phy_read_txpwr_limit(struct rtw89_dev *rtwdev, u8 bw, u8 ntx, u8 rs, u8 bf, u8 ch) { const struct rtw89_chip_info *chip = rtwdev->chip; -u8 band = rtwdev->hal.current_band_type; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 band = chan->band_type;u8 ch_idx =rtw89_channel_to_idx (rtwdev, band, ch);u8 regd =rtw89_regd_get (rtwdev, band);s8 lmt =0 , sar;
@@ -1729,9 +1733,10 @@ void rtw89_phy_fill_txpwr_limit(struct rtw89_dev *rtwdev, struct rtw89_txpwr_limit *lmt, u8 ntx) { -u8 pri_ch = rtwdev->hal.current_primary_channel; -u8 ch = rtwdev->hal.current_channel; -u8 bw = rtwdev->hal.current_band_width; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 pri_ch = chan->primary_channel; +u8 ch = chan->channel; +u8 bw = chan->band_width;memset (lmt,0 ,sizeof (*lmt));
@@ -1756,7 +1761,8 @@ static s8 rtw89_phy_read_txpwr_limit_ru(struct rtw89_dev *rtwdev, u8 ru, u8 ntx, u8 ch) { const struct rtw89_chip_info *chip = rtwdev->chip; -u8 band = rtwdev->hal.current_band_type; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 band = chan->band_type;u8 ch_idx =rtw89_channel_to_idx (rtwdev, band, ch);u8 regd =rtw89_regd_get (rtwdev, band);s8 lmt_ru =0 , sar;
@@ -1883,8 +1889,9 @@ void rtw89_phy_fill_txpwr_limit_ru(struct rtw89_dev *rtwdev, struct rtw89_txpwr_limit_ru *lmt_ru, u8 ntx) { -u8 ch = rtwdev->hal.current_channel; -u8 bw = rtwdev->hal.current_band_width; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel; +u8 bw = chan->band_width;memset (lmt_ru,0 ,sizeof (*lmt_ru));
@@ -3247,10 +3254,11 @@ static void rtw89_phy_dig_update_rssi_info(struct rtw89_dev *rtwdev)static void rtw89_phy_dig_update_para (struct rtw89_dev *rtwdev) {struct rtw89_dig_info *dig = &rtwdev->dig; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );bool is_linked = rtwdev->total_sta_assoc >0 ;const u16 *fa_th_src =NULL ; -switch (rtwdev->hal.current_band_type) { +switch (chan->band_type) {case RTW89_BAND_2G : dig->lna_gain = dig->lna_gain_g; dig->tia_gain = dig->tia_gain_g;
@@ -3483,7 +3491,8 @@ static void rtw89_phy_dig_config_igi(struct rtw89_dev *rtwdev)static void rtw89_phy_dig_dyn_pd_th (struct rtw89_dev *rtwdev,u8 rssi,bool enable) { -enum rtw89_bandwidth cbw = rtwdev->hal.current_band_width; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +enum rtw89_bandwidth cbw = chan->band_width;struct rtw89_dig_info *dig = &rtwdev->dig;u8 final_rssi =0 , under_region = dig->pd_low_th_ofst;u8 ofdm_cca_th;
drivers/net/wireless/realtek/rtw89/rtw8852a.c +11 -6
@@ -1381,7 +1381,8 @@ static void rtw8852a_set_txpwr_ref(struct rtw89_dev *rtwdev,static void rtw8852a_set_txpwr_byrate (struct rtw89_dev *rtwdev,enum rtw89_phy_idx phy_idx) { -u8 ch = rtwdev->hal.current_channel; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel;static const u8 rs[] = {RTW89_RS_CCK ,RTW89_RS_OFDM ,
@@ -1446,8 +1447,9 @@ static void rtw8852a_set_txpwr_limit(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_PAGE_SIZE 40 -u8 ch = rtwdev->hal.current_channel; -u8 bw = rtwdev->hal.current_band_width; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel; +u8 bw = chan->band_width;struct rtw89_txpwr_limit lmt[NTX_NUM_8852A ];u32 addr, val;const s8 *ptr;
@@ -1477,8 +1479,9 @@ static void rtw8852a_set_txpwr_limit_ru(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_RU_PAGE_SIZE 24 -u8 ch = rtwdev->hal.current_channel; -u8 bw = rtwdev->hal.current_band_width; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel; +u8 bw = chan->band_width;struct rtw89_txpwr_limit_ru lmt_ru[NTX_NUM_8852A ];u32 addr, val;const s8 *ptr;
@@ -1593,10 +1596,12 @@ void rtw8852a_bb_set_pmac_tx(struct rtw89_dev *rtwdev, struct rtw8852a_bb_pmac_info *tx_info, enum rtw89_phy_idx idx) { +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +if (!tx_info->en_pmac_tx) {rtw8852a_stop_pmac_tx (rtwdev, tx_info, idx);rtw89_phy_write32_idx (rtwdev,R_PD_CTRL ,B_PD_HIT_DIS ,0 , idx); -if (rtwdev->hal.current_band_type ==RTW89_BAND_2G ) +if (chan->band_type ==RTW89_BAND_2G )rtw89_phy_write32_clr (rtwdev,R_RXCCA ,B_RXCCA_DIS );return ; }
drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c +40 -28
186 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/rtw8852c.c +17 -11
@@ -1532,7 +1532,7 @@ static void rtw8852c_bb_reset_all(struct rtw89_dev *rtwdev,static void rtw8852c_bb_reset_en (struct rtw89_dev *rtwdev,enum rtw89_phy_idx phy_idx,bool en) { -struct rtw89_hal *hal = &rtwdev->hal; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );if (en) { rtw89_phy_write32_idx(rtwdev, R_S0_HW_SI_DIS,
@@ -1541,7 +1541,7 @@ static void rtw8852c_bb_reset_en(struct rtw89_dev *rtwdev, B_S1_HW_SI_DIS_W_R_TRIG, 0x0, phy_idx);rtw89_phy_write32_idx (rtwdev,R_RSTB_ASYNC ,B_RSTB_ASYNC_ALL ,1 , phy_idx); -if (hal->current_band_type ==RTW89_BAND_2G ) +if (chan->band_type ==RTW89_BAND_2G )rtw89_phy_write32_mask (rtwdev,R_RXCCA_V1 ,B_RXCCA_DIS_V1 ,0x0 );rtw89_phy_write32_mask (rtwdev,R_PD_CTRL ,B_PD_HIT_DIS ,0x0 ); }else {
@@ -1964,7 +1964,8 @@ static void rtw8852c_set_txpwr_ref(struct rtw89_dev *rtwdev,static void rtw8852c_set_txpwr_byrate (struct rtw89_dev *rtwdev,enum rtw89_phy_idx phy_idx) { -u8 ch = rtwdev->hal.current_channel; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel;static const u8 rs[] = {RTW89_RS_CCK ,RTW89_RS_OFDM ,
@@ -2049,7 +2050,8 @@ static void rtw8852c_bb_set_tx_shape_dfir(struct rtw89_dev *rtwdev,__DECL_DFIR_ADDR (filter,0x45BC ,0x45CC ,0x45D0 ,0x45D4 ,0x45D8 ,0x45C0 ,0x45C4 ,0x45C8 ); -u8 ch = rtwdev->hal.current_channel; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel;const u32 *param;int i;
@@ -2082,7 +2084,8 @@ static void rtw8852c_bb_set_tx_shape_dfir(struct rtw89_dev *rtwdev,static void rtw8852c_set_tx_shape (struct rtw89_dev *rtwdev,enum rtw89_phy_idx phy_idx) { -u8 band = rtwdev->hal.current_band_type; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 band = chan->band_type;u8 regd =rtw89_regd_get (rtwdev, band);u8 tx_shape_cck = rtw89_8852c_tx_shape[band][RTW89_RS_CCK ][regd];u8 tx_shape_ofdm = rtw89_8852c_tx_shape[band][RTW89_RS_OFDM ][regd];
@@ -2099,8 +2102,9 @@ static void rtw8852c_set_txpwr_limit(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_PAGE_SIZE 40 -u8 ch = rtwdev->hal.current_channel; -u8 bw = rtwdev->hal.current_band_width; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel; +u8 bw = chan->band_width;struct rtw89_txpwr_limit lmt[NTX_NUM_8852C ];u32 addr, val;const s8 *ptr;
@@ -2130,8 +2134,9 @@ static void rtw8852c_set_txpwr_limit_ru(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_RU_PAGE_SIZE 24 -u8 ch = rtwdev->hal.current_channel; -u8 bw = rtwdev->hal.current_band_width; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 ch = chan->channel; +u8 bw = chan->band_width;struct rtw89_txpwr_limit_ru lmt_ru[NTX_NUM_8852C ];u32 addr, val;const s8 *ptr;
@@ -2226,7 +2231,8 @@ rtw8852c_init_txpwr_unit(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)static void rtw8852c_bb_cfg_rx_path (struct rtw89_dev *rtwdev,u8 rx_path) { -struct rtw89_hal *hal = &rtwdev->hal; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 band = chan->band_type;u32 rst_mask0 =B_P0_TXPW_RSTB_MANON |B_P0_TXPW_RSTB_TSSI ;u32 rst_mask1 =B_P1_TXPW_RSTB_MANON |B_P1_TXPW_RSTB_TSSI ;
@@ -2320,7 +2326,7 @@ static void rtw8852c_bb_cfg_rx_path(struct rtw89_dev *rtwdev, u8 rx_path) 1);rtw89_phy_write32_mask (rtwdev,R_RXHE ,B_RXHETB_MAX_NSS ,1 ); -rtw8852c_ctrl_btg (rtwdev, hal->current_band_type ==RTW89_BAND_2G ); +rtw8852c_ctrl_btg (rtwdev, band ==RTW89_BAND_2G );rtw89_phy_write32_mask (rtwdev,R_P0_TXPW_RSTB , rst_mask0,1 ); rtw89_phy_write32_mask(rtwdev, R_P0_TXPW_RSTB,
drivers/net/wireless/realtek/rtw89/rtw8852c_rfk.c +39 -27
169 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/sar.c +3 -3
@@ -81,9 +81,9 @@ static const struct rtw89_sar_span rtw89_sar_overlapping_6ghz[] = {static int rtw89_query_sar_config_common (struct rtw89_dev *rtwdev,s32 *cfg) {struct rtw89_sar_cfg_common *rtwsar = &rtwdev->sar.cfg_common; -struct rtw89_hal *hal = &rtwdev->hal; -enum rtw89_band band = hal->current_band_type; -u32 center_freq = hal->current_freq; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +enum rtw89_band band = chan->band_type; +u32 center_freq = chan->freq;const struct rtw89_sar_span *span =NULL ;enum rtw89_sar_subband subband_l, subband_h;int idx;
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 4/13 wifi: rtw89: create rtw89_chan centrally to avoid breakage
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
Sometimes we need to write current rtw89_chan outside set_channel(), e.g. during HW scan, we adjust it to align FW process through C2H. However, we don't have full parameters to fill entire rtw89_chan. And it will breakage if we update only part of current rtw89_chan. That is what we don't want to see because most flows throughout driver treat rtw89_chan as a whole.
So, we divide struct rtw89_chan to basic part and derived part. The basic part contains the parameters which we are always able to know. And the derived part will be calculated by the basic part. Then, a central function, rtw89_chan_create(), is added to deal with this.
--- drivers/net/wireless/realtek/rtw89/chan.c | 98 +++++++++++++++++++++++ drivers/net/wireless/realtek/rtw89/chan.h | 2 + drivers/net/wireless/realtek/rtw89/core.c | 70 +--------------- drivers/net/wireless/realtek/rtw89/core.h | 6 +- drivers/net/wireless/realtek/rtw89/fw.c | 7 +- drivers/net/wireless/realtek/rtw89/mac.c | 7 +- 6 files changed, 109 insertions(+), 81 deletions(-)
drivers/net/wireless/realtek/rtw89/chan.c +98 -0
@@ -4,6 +4,104 @@#include "chan.h" +static enum rtw89_subband rtw89_get_subband_type (enum rtw89_band band, +u8 center_chan) +{ +switch (band) { +default : +case RTW89_BAND_2G : +switch (center_chan) { +default : + case 1 ... 14: +return RTW89_CH_2G ; + } +case RTW89_BAND_5G : +switch (center_chan) { +default : + case 36 ... 64: +return RTW89_CH_5G_BAND_1 ; + case 100 ... 144: +return RTW89_CH_5G_BAND_3 ; + case 149 ... 177: +return RTW89_CH_5G_BAND_4 ; + } +case RTW89_BAND_6G : +switch (center_chan) { +default : + case 1 ... 29: +return RTW89_CH_6G_BAND_IDX0 ; + case 33 ... 61: +return RTW89_CH_6G_BAND_IDX1 ; + case 65 ... 93: +return RTW89_CH_6G_BAND_IDX2 ; + case 97 ... 125: +return RTW89_CH_6G_BAND_IDX3 ; + case 129 ... 157: +return RTW89_CH_6G_BAND_IDX4 ; + case 161 ... 189: +return RTW89_CH_6G_BAND_IDX5 ; + case 193 ... 221: +return RTW89_CH_6G_BAND_IDX6 ; + case 225 ... 253: +return RTW89_CH_6G_BAND_IDX7 ; + } + } +} + +static enum rtw89_sc_offset rtw89_get_primary_chan_idx (enum rtw89_bandwidth bw, +u32 center_freq, +u32 primary_freq) +{ +u8 primary_chan_idx; +u32 offset; + +switch (bw) { +default : +case RTW89_CHANNEL_WIDTH_20 : + primary_chan_idx =RTW89_SC_DONT_CARE ; +break ; +case RTW89_CHANNEL_WIDTH_40 : +if (primary_freq > center_freq) + primary_chan_idx =RTW89_SC_20_UPPER ; +else + primary_chan_idx =RTW89_SC_20_LOWER ; +break ; +case RTW89_CHANNEL_WIDTH_80 : +case RTW89_CHANNEL_WIDTH_160 : +if (primary_freq > center_freq) { + offset = (primary_freq - center_freq -10 ) /20 ; + primary_chan_idx =RTW89_SC_20_UPPER + offset *2 ; + }else { + offset = (center_freq - primary_freq -10 ) /20 ; + primary_chan_idx =RTW89_SC_20_LOWER + offset *2 ; + } +break ; + } + +return primary_chan_idx; +} + +void rtw89_chan_create (struct rtw89_chan *chan,u8 center_chan,u8 primary_chan, +enum rtw89_band band,enum rtw89_bandwidth bandwidth) +{ +enum nl80211_band nl_band =rtw89_hw_to_nl80211_band (band); +u32 center_freq, primary_freq; + +memset (chan,0 ,sizeof (*chan)); + chan->channel = center_chan; + chan->primary_channel = primary_chan; + chan->band_type = band; + chan->band_width = bandwidth; + + center_freq =ieee80211_channel_to_frequency (center_chan, nl_band); + primary_freq =ieee80211_channel_to_frequency (primary_chan, nl_band); + + chan->freq = center_freq; + chan->subband_type =rtw89_get_subband_type (band, center_chan); + chan->pri_ch_idx =rtw89_get_primary_chan_idx (bandwidth, center_freq, + primary_freq); +} +bool rtw89_assign_entity_chan (struct rtw89_dev *rtwdev,enum rtw89_sub_entity_idx idx,const struct rtw89_chan *new)
drivers/net/wireless/realtek/rtw89/chan.h +2 -0
@@ -21,6 +21,8 @@ static inline void rtw89_set_entity_state(struct rtw89_dev *rtwdev, bool active)WRITE_ONCE (hal->entity_active, active); } +void rtw89_chan_create (struct rtw89_chan *chan,u8 center_chan,u8 primary_chan, +enum rtw89_band band,enum rtw89_bandwidth bandwidth);bool rtw89_assign_entity_chan (struct rtw89_dev *rtwdev,enum rtw89_sub_entity_idx idx,const struct rtw89_chan *new);
drivers/net/wireless/realtek/rtw89/core.c +1 -69
105 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/core.h +5 -1
@@ -632,10 +632,14 @@ enum rtw89_sc_offset {struct rtw89_chan {u8 channel; -u32 freq;u8 primary_channel;enum rtw89_band band_type;enum rtw89_bandwidth band_width; + +/* The follow-up are derived from the above. We must ensure that it +* is assigned correctly in rtw89_chan_create() if new one is added. +*/ +u32 freq;enum rtw89_subband subband_type;enum rtw89_sc_offset pri_ch_idx; };
drivers/net/wireless/realtek/rtw89/fw.c +2 -5
@@ -2388,11 +2388,8 @@ void rtw89_store_op_chan(struct rtw89_dev *rtwdev, bool backup) scan_info->op_bw = cur->band_width; scan_info->op_band = cur->band_type; }else { - new = *cur; - new.primary_channel = scan_info->op_pri_ch; - new.channel = scan_info->op_chan; - new.band_width = scan_info->op_bw; - new.band_type = scan_info->op_band; +rtw89_chan_create (&new, scan_info->op_chan, scan_info->op_pri_ch, + scan_info->op_band, scan_info->op_bw);rtw89_assign_entity_chan (rtwdev,RTW89_SUB_ENTITY_0 , &new); } }
drivers/net/wireless/realtek/rtw89/mac.c +1 -6
@@ -3655,7 +3655,6 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_dev *rtwdev, struct sk_buff *c2h, u32 len) {struct ieee80211_vif *vif = rtwdev->scan_info.scanning_vif; -const struct rtw89_chan *cur =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );struct rtw89_chan new;u8 reason, status, tx_fail, band;u16 chan;
@@ -3682,11 +3681,7 @@ rtw89_mac_c2h_scanofld_rsp(struct rtw89_dev *rtwdev, struct sk_buff *c2h,rtw89_hw_scan_complete (rtwdev, vif, false);break ;case RTW89_SCAN_ENTER_CH_NOTIFY : - new = *cur; - new.channel = chan; - new.primary_channel = chan; - new.band_type = band; - new.band_width =RTW89_CHANNEL_WIDTH_20 ; +rtw89_chan_create (&new, chan, chan, band,RTW89_CHANNEL_WIDTH_20 );rtw89_assign_entity_chan (rtwdev,RTW89_SUB_ENTITY_0 , &new);if (rtw89_is_op_chan (rtwdev, band, chan)) {rtw89_store_op_chan (rtwdev, false);
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 5/13 wifi: rtw89: txpwr: concentrate channel related control to top
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
For future support on multiple channels, it would be disturbing if we still allow scattered leaf functions of TX power to query and manage channel related control by themselves.
So, query rtw89_chan only on top functions. Then, pass it via functions to make sure that the values coming from the same struct rtw89_chan.
Besides, fix rtw8852a_set_txpwr_offset() from rtw8852a_set_txpwr_ctrl() to rtw8852a_set_txpwr(). TX power offset should consider current band, so move it to chip_ops::set_txpwr() which will be called every time that channel is set.
--- drivers/net/wireless/realtek/rtw89/core.c | 4 +- drivers/net/wireless/realtek/rtw89/core.h | 9 +- drivers/net/wireless/realtek/rtw89/phy.c | 235 +++++++++++------- drivers/net/wireless/realtek/rtw89/phy.h | 6 +- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 35 +-- .../net/wireless/realtek/rtw89/rtw8852a_rfk.c | 9 +- drivers/net/wireless/realtek/rtw89/rtw8852c.c | 39 +-- 7 files changed, 206 insertions(+), 131 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +3 -1
@@ -288,14 +288,16 @@ static void rtw89_get_channel_params(struct cfg80211_chan_def *chandef,void rtw89_core_set_chip_txpwr (struct rtw89_dev *rtwdev) {const struct rtw89_chip_info *chip = rtwdev->chip; +const struct rtw89_chan *chan;bool entity_active; entity_active =rtw89_get_entity_state (rtwdev);if (!entity_active)return ; + chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );if (chip->ops->set_txpwr) - chip->ops->set_txpwr (rtwdev); + chip->ops->set_txpwr (rtwdev, chan,RTW89_PHY_0 ); }void rtw89_set_channel (struct rtw89_dev *rtwdev)
drivers/net/wireless/realtek/rtw89/core.h +6 -3
@@ -2127,8 +2127,11 @@ struct rtw89_chip_ops {void (*rfk_scan)(struct rtw89_dev *rtwdev,bool start);void (*rfk_track)(struct rtw89_dev *rtwdev);void (*power_trim)(struct rtw89_dev *rtwdev); -void (*set_txpwr)(struct rtw89_dev *rtwdev); -void (*set_txpwr_ctrl)(struct rtw89_dev *rtwdev); +void (*set_txpwr)(struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan, +enum rtw89_phy_idx phy_idx); +void (*set_txpwr_ctrl)(struct rtw89_dev *rtwdev, +enum rtw89_phy_idx phy_idx);int (*init_txpwr_unit)(struct rtw89_dev *rtwdev,enum rtw89_phy_idx phy_idx);u8 (*get_thermal)(struct rtw89_dev *rtwdev,enum rtw89_rf_path rf_path);void (*ctrl_btg)(struct rtw89_dev *rtwdev,bool btg);
@@ -3691,7 +3694,7 @@ static inline void rtw89_chip_set_txpwr_ctrl(struct rtw89_dev *rtwdev)const struct rtw89_chip_info *chip = rtwdev->chip;if (chip->ops->set_txpwr_ctrl) - chip->ops->set_txpwr_ctrl (rtwdev); + chip->ops->set_txpwr_ctrl (rtwdev,RTW89_PHY_0 ); }static inline void rtw89_chip_power_trim (struct rtw89_dev *rtwdev)
drivers/net/wireless/realtek/rtw89/phy.c +143 -92
456 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/phy.h +4 -2
@@ -460,15 +460,17 @@ void rtw89_phy_write32_idx(struct rtw89_dev *rtwdev, u32 addr, u32 mask, u32 data, enum rtw89_phy_idx phy_idx);void rtw89_phy_load_txpwr_byrate (struct rtw89_dev *rtwdev,const struct rtw89_txpwr_table *tbl); -s8 rtw89_phy_read_txpwr_byrate (struct rtw89_dev *rtwdev, +s8 rtw89_phy_read_txpwr_byrate (struct rtw89_dev *rtwdev,u8 band,const struct rtw89_rate_desc *rate_desc);void rtw89_phy_fill_txpwr_limit (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,struct rtw89_txpwr_limit *lmt,u8 ntx);void rtw89_phy_fill_txpwr_limit_ru (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,struct rtw89_txpwr_limit_ru *lmt_ru,u8 ntx); -s8 rtw89_phy_read_txpwr_limit (struct rtw89_dev *rtwdev, +s8 rtw89_phy_read_txpwr_limit (struct rtw89_dev *rtwdev,u8 band,u8 bw,u8 ntx,u8 rs,u8 bf,u8 ch);void rtw89_phy_ra_assoc (struct rtw89_dev *rtwdev,struct ieee80211_sta *sta);void rtw89_phy_ra_update (struct rtw89_dev *rtwdev);
drivers/net/wireless/realtek/rtw89/rtw8852a.c +21 -14
@@ -1379,9 +1379,10 @@ static void rtw8852a_set_txpwr_ref(struct rtw89_dev *rtwdev, }static void rtw8852a_set_txpwr_byrate (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) { -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 band = chan->band_type;u8 ch = chan->channel;static const u8 rs[] = {RTW89_RS_CCK ,
@@ -1408,7 +1409,8 @@ static void rtw8852a_set_txpwr_byrate(struct rtw89_dev *rtwdev,for (j =0 ; j < rtw89_rs_idx_max[rs[i]]; j++) { cur.idx = j; shf = (j %4 ) *8 ; - tmp =rtw89_phy_read_txpwr_byrate (rtwdev, &cur); + tmp =rtw89_phy_read_txpwr_byrate (rtwdev, band, + &cur); val |= (tmp << shf);if ((j +1 ) %4 )
@@ -1423,8 +1425,10 @@ static void rtw8852a_set_txpwr_byrate(struct rtw89_dev *rtwdev, }static void rtw8852a_set_txpwr_offset (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) { +u8 band = chan->band_type;struct rtw89_rate_desc desc = { .nss =RTW89_NSS_1 , .rs =RTW89_RS_OFFSET ,
@@ -1435,7 +1439,7 @@ static void rtw8852a_set_txpwr_offset(struct rtw89_dev *rtwdev,rtw89_debug (rtwdev,RTW89_DBG_TXPWR ,"[TXPWR] set txpwr offset\n" );for (desc.idx =0 ; desc.idx <RTW89_RATE_OFFSET_MAX ; desc.idx++) { - v =rtw89_phy_read_txpwr_byrate (rtwdev, &desc); + v =rtw89_phy_read_txpwr_byrate (rtwdev, band, &desc); val |= ((v &0xf ) << (4 * desc.idx)); }
@@ -1444,10 +1448,10 @@ static void rtw8852a_set_txpwr_offset(struct rtw89_dev *rtwdev, }static void rtw8852a_set_txpwr_limit (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_PAGE_SIZE 40 -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u8 ch = chan->channel;u8 bw = chan->band_width;struct rtw89_txpwr_limit lmt[NTX_NUM_8852A ];
@@ -1459,7 +1463,7 @@ static void rtw8852a_set_txpwr_limit(struct rtw89_dev *rtwdev, "[TXPWR] set txpwr limit with ch=%d bw=%d\n", ch, bw);for (i =0 ; i <NTX_NUM_8852A ; i++) { -rtw89_phy_fill_txpwr_limit (rtwdev, &lmt[i], i); +rtw89_phy_fill_txpwr_limit (rtwdev, chan, &lmt[i], i);for (j =0 ; j < __MAC_TXPWR_LMT_PAGE_SIZE; j +=4 ) { addr =R_AX_PWR_LMT + j + __MAC_TXPWR_LMT_PAGE_SIZE * i;
@@ -1476,10 +1480,10 @@ static void rtw8852a_set_txpwr_limit(struct rtw89_dev *rtwdev, }static void rtw8852a_set_txpwr_limit_ru (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_RU_PAGE_SIZE 24 -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u8 ch = chan->channel;u8 bw = chan->band_width;struct rtw89_txpwr_limit_ru lmt_ru[NTX_NUM_8852A ];
@@ -1491,7 +1495,7 @@ static void rtw8852a_set_txpwr_limit_ru(struct rtw89_dev *rtwdev, "[TXPWR] set txpwr limit ru with ch=%d bw=%d\n", ch, bw);for (i =0 ; i <NTX_NUM_8852A ; i++) { -rtw89_phy_fill_txpwr_limit_ru (rtwdev, &lmt_ru[i], i); +rtw89_phy_fill_txpwr_limit_ru (rtwdev, chan, &lmt_ru[i], i);for (j =0 ; j < __MAC_TXPWR_LMT_RU_PAGE_SIZE; j +=4 ) { addr = R_AX_PWR_RU_LMT + j +
@@ -1509,17 +1513,20 @@ static void rtw8852a_set_txpwr_limit_ru(struct rtw89_dev *rtwdev,#undef __MAC_TXPWR_LMT_RU_PAGE_SIZE } -static void rtw8852a_set_txpwr (struct rtw89_dev *rtwdev) +static void rtw8852a_set_txpwr (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan, +enum rtw89_phy_idx phy_idx) { -rtw8852a_set_txpwr_byrate (rtwdev,RTW89_PHY_0 ); -rtw8852a_set_txpwr_limit (rtwdev,RTW89_PHY_0 ); -rtw8852a_set_txpwr_limit_ru (rtwdev,RTW89_PHY_0 ); +rtw8852a_set_txpwr_byrate (rtwdev, chan, phy_idx); +rtw8852a_set_txpwr_offset (rtwdev, chan, phy_idx); +rtw8852a_set_txpwr_limit (rtwdev, chan, phy_idx); +rtw8852a_set_txpwr_limit_ru (rtwdev, chan, phy_idx); } -static void rtw8852a_set_txpwr_ctrl (struct rtw89_dev *rtwdev) +static void rtw8852a_set_txpwr_ctrl (struct rtw89_dev *rtwdev, +enum rtw89_phy_idx phy_idx) { -rtw8852a_set_txpwr_ref (rtwdev,RTW89_PHY_0 ); -rtw8852a_set_txpwr_offset (rtwdev,RTW89_PHY_0 ); +rtw8852a_set_txpwr_ref (rtwdev, phy_idx); } static int
drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c +6 -3
@@ -3491,6 +3491,7 @@ static void _tssi_high_power(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy)const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u8 ch = chan->channel, ch_tmp;u8 bw = chan->band_width; +u8 band = chan->band_type;u8 subband = chan->subband_type;s8 power;s32 xdbm;
@@ -3502,7 +3503,7 @@ static void _tssi_high_power(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy)else ch_tmp = ch; - power =rtw89_phy_read_txpwr_limit (rtwdev, bw,RTW89_1TX , + power =rtw89_phy_read_txpwr_limit (rtwdev, band, bw,RTW89_1TX ,RTW89_RS_MCS ,RTW89_NONBF , ch_tmp); xdbm = power *100 /4 ;
@@ -3538,6 +3539,7 @@ static void _tssi_pre_tx(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy)const struct rtw89_chip_info *mac_reg = rtwdev->chip;u8 ch = chan->channel, ch_tmp;u8 bw = chan->band_width; +u8 band = chan->band_type;u32 tx_en;u8 phy_map =rtw89_btc_phymap (rtwdev, phy,0 );s8 power;
@@ -3551,8 +3553,9 @@ static void _tssi_pre_tx(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy)else ch_tmp = ch; - power =rtw89_phy_read_txpwr_limit (rtwdev,RTW89_CHANNEL_WIDTH_20 ,RTW89_1TX , -RTW89_RS_OFDM ,RTW89_NONBF , ch_tmp); + power =rtw89_phy_read_txpwr_limit (rtwdev, band,RTW89_CHANNEL_WIDTH_20 , +RTW89_1TX ,RTW89_RS_OFDM , +RTW89_NONBF , ch_tmp); xdbm = (power *100 ) >> mac_reg->txpwr_factor_mac;
drivers/net/wireless/realtek/rtw89/rtw8852c.c +23 -16
@@ -1962,9 +1962,10 @@ static void rtw8852c_set_txpwr_ref(struct rtw89_dev *rtwdev, }static void rtw8852c_set_txpwr_byrate (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) { -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); +u8 band = chan->band_type;u8 ch = chan->channel;static const u8 rs[] = {RTW89_RS_CCK ,
@@ -1991,7 +1992,8 @@ static void rtw8852c_set_txpwr_byrate(struct rtw89_dev *rtwdev,for (j =0 ; j < rtw89_rs_idx_max[rs[i]]; j++) { cur.idx = j; shf = (j %4 ) *8 ; - tmp =rtw89_phy_read_txpwr_byrate (rtwdev, &cur); + tmp =rtw89_phy_read_txpwr_byrate (rtwdev, band, + &cur); val |= (tmp << shf);if ((j +1 ) %4 )
@@ -2006,8 +2008,10 @@ static void rtw8852c_set_txpwr_byrate(struct rtw89_dev *rtwdev, }static void rtw8852c_set_txpwr_offset (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) { +u8 band = chan->band_type;struct rtw89_rate_desc desc = { .nss =RTW89_NSS_1 , .rs =RTW89_RS_OFFSET ,
@@ -2018,7 +2022,7 @@ static void rtw8852c_set_txpwr_offset(struct rtw89_dev *rtwdev,rtw89_debug (rtwdev,RTW89_DBG_TXPWR ,"[TXPWR] set txpwr offset\n" );for (desc.idx =0 ; desc.idx <RTW89_RATE_OFFSET_MAX ; desc.idx++) { - v =rtw89_phy_read_txpwr_byrate (rtwdev, &desc); + v =rtw89_phy_read_txpwr_byrate (rtwdev, band, &desc); val |= ((v &0xf ) << (4 * desc.idx)); }
@@ -2082,9 +2086,9 @@ static void rtw8852c_bb_set_tx_shape_dfir(struct rtw89_dev *rtwdev, }static void rtw8852c_set_tx_shape (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) { -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u8 band = chan->band_type;u8 regd =rtw89_regd_get (rtwdev, band);u8 tx_shape_cck = rtw89_8852c_tx_shape[band][RTW89_RS_CCK ][regd];
@@ -2099,10 +2103,10 @@ static void rtw8852c_set_tx_shape(struct rtw89_dev *rtwdev, }static void rtw8852c_set_txpwr_limit (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_PAGE_SIZE 40 -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u8 ch = chan->channel;u8 bw = chan->band_width;struct rtw89_txpwr_limit lmt[NTX_NUM_8852C ];
@@ -2114,7 +2118,7 @@ static void rtw8852c_set_txpwr_limit(struct rtw89_dev *rtwdev, "[TXPWR] set txpwr limit with ch=%d bw=%d\n", ch, bw);for (i =0 ; i <NTX_NUM_8852C ; i++) { -rtw89_phy_fill_txpwr_limit (rtwdev, &lmt[i], i); +rtw89_phy_fill_txpwr_limit (rtwdev, chan, &lmt[i], i);for (j =0 ; j < __MAC_TXPWR_LMT_PAGE_SIZE; j +=4 ) { addr =R_AX_PWR_LMT + j + __MAC_TXPWR_LMT_PAGE_SIZE * i;
@@ -2131,10 +2135,10 @@ static void rtw8852c_set_txpwr_limit(struct rtw89_dev *rtwdev, }static void rtw8852c_set_txpwr_limit_ru (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan,enum rtw89_phy_idx phy_idx) {#define __MAC_TXPWR_LMT_RU_PAGE_SIZE 24 -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u8 ch = chan->channel;u8 bw = chan->band_width;struct rtw89_txpwr_limit_ru lmt_ru[NTX_NUM_8852C ];
@@ -2146,7 +2150,7 @@ static void rtw8852c_set_txpwr_limit_ru(struct rtw89_dev *rtwdev, "[TXPWR] set txpwr limit ru with ch=%d bw=%d\n", ch, bw);for (i =0 ; i <NTX_NUM_8852C ; i++) { -rtw89_phy_fill_txpwr_limit_ru (rtwdev, &lmt_ru[i], i); +rtw89_phy_fill_txpwr_limit_ru (rtwdev, chan, &lmt_ru[i], i);for (j =0 ; j < __MAC_TXPWR_LMT_RU_PAGE_SIZE; j +=4 ) { addr = R_AX_PWR_RU_LMT + j +
@@ -2164,18 +2168,21 @@ static void rtw8852c_set_txpwr_limit_ru(struct rtw89_dev *rtwdev,#undef __MAC_TXPWR_LMT_RU_PAGE_SIZE } -static void rtw8852c_set_txpwr (struct rtw89_dev *rtwdev) +static void rtw8852c_set_txpwr (struct rtw89_dev *rtwdev, +const struct rtw89_chan *chan, +enum rtw89_phy_idx phy_idx) { -rtw8852c_set_txpwr_byrate (rtwdev,RTW89_PHY_0 ); -rtw8852c_set_txpwr_offset (rtwdev,RTW89_PHY_0 ); -rtw8852c_set_tx_shape (rtwdev,RTW89_PHY_0 ); -rtw8852c_set_txpwr_limit (rtwdev,RTW89_PHY_0 ); -rtw8852c_set_txpwr_limit_ru (rtwdev,RTW89_PHY_0 ); +rtw8852c_set_txpwr_byrate (rtwdev, chan, phy_idx); +rtw8852c_set_txpwr_offset (rtwdev, chan, phy_idx); +rtw8852c_set_tx_shape (rtwdev, chan, phy_idx); +rtw8852c_set_txpwr_limit (rtwdev, chan, phy_idx); +rtw8852c_set_txpwr_limit_ru (rtwdev, chan, phy_idx); } -static void rtw8852c_set_txpwr_ctrl (struct rtw89_dev *rtwdev) +static void rtw8852c_set_txpwr_ctrl (struct rtw89_dev *rtwdev, +enum rtw89_phy_idx phy_idx) { -rtw8852c_set_txpwr_ref (rtwdev,RTW89_PHY_0 ); +rtw8852c_set_txpwr_ref (rtwdev, phy_idx); } static void
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 6/13 wifi: rtw89: rfk: concentrate parameter control while set_channel()
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
For future support on multiple channels, there will be settings of multiple sub-entities that we need to control. We don't want such settings to be scattered all over the place. So, we centrally manage controls of rtw89_phy_idx for RFK in set_channel().
--- drivers/net/wireless/realtek/rtw89/core.c | 2 +- drivers/net/wireless/realtek/rtw89/core.h | 8 +++++--- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 5 +++-- drivers/net/wireless/realtek/rtw89/rtw8852c.c | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +1 -1
@@ -329,7 +329,7 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev)if (!entity_active || band_changed) {rtw89_btc_ntfy_switch_band (rtwdev,RTW89_PHY_0 , chan.band_type); -rtw89_chip_rfk_band_changed (rtwdev); +rtw89_chip_rfk_band_changed (rtwdev,RTW89_PHY_0 ); } }
drivers/net/wireless/realtek/rtw89/core.h +5 -3
@@ -2123,7 +2123,8 @@ struct rtw89_chip_ops {void (*fem_setup)(struct rtw89_dev *rtwdev);void (*rfk_init)(struct rtw89_dev *rtwdev);void (*rfk_channel)(struct rtw89_dev *rtwdev); -void (*rfk_band_changed)(struct rtw89_dev *rtwdev); +void (*rfk_band_changed)(struct rtw89_dev *rtwdev, +enum rtw89_phy_idx phy_idx);void (*rfk_scan)(struct rtw89_dev *rtwdev,bool start);void (*rfk_track)(struct rtw89_dev *rtwdev);void (*power_trim)(struct rtw89_dev *rtwdev);
@@ -3665,12 +3666,13 @@ static inline void rtw89_chip_rfk_channel(struct rtw89_dev *rtwdev) chip->ops->rfk_channel (rtwdev); } -static inline void rtw89_chip_rfk_band_changed (struct rtw89_dev *rtwdev) +static inline void rtw89_chip_rfk_band_changed (struct rtw89_dev *rtwdev, +enum rtw89_phy_idx phy_idx) {const struct rtw89_chip_info *chip = rtwdev->chip;if (chip->ops->rfk_band_changed) - chip->ops->rfk_band_changed (rtwdev); + chip->ops->rfk_band_changed (rtwdev, phy_idx); }static inline void rtw89_chip_rfk_scan (struct rtw89_dev *rtwdev,bool start)
drivers/net/wireless/realtek/rtw89/rtw8852a.c +3 -2
@@ -1278,9 +1278,10 @@ static void rtw8852a_rfk_channel(struct rtw89_dev *rtwdev)rtw8852a_dpk (rtwdev, phy_idx); } -static void rtw8852a_rfk_band_changed (struct rtw89_dev *rtwdev) +static void rtw8852a_rfk_band_changed (struct rtw89_dev *rtwdev, +enum rtw89_phy_idx phy_idx) { -rtw8852a_tssi_scan (rtwdev,RTW89_PHY_0 ); +rtw8852a_tssi_scan (rtwdev, phy_idx); }static void rtw8852a_rfk_scan (struct rtw89_dev *rtwdev,bool start)
drivers/net/wireless/realtek/rtw89/rtw8852c.c +3 -2
@@ -1851,9 +1851,10 @@ static void rtw8852c_rfk_channel(struct rtw89_dev *rtwdev)rtw89_fw_h2c_rf_ntfy_mcc (rtwdev); } -static void rtw8852c_rfk_band_changed (struct rtw89_dev *rtwdev) +static void rtw8852c_rfk_band_changed (struct rtw89_dev *rtwdev, +enum rtw89_phy_idx phy_idx) { -rtw8852c_tssi_scan (rtwdev,RTW89_PHY_0 ); +rtw8852c_tssi_scan (rtwdev, phy_idx); }static void rtw8852c_rfk_scan (struct rtw89_dev *rtwdev,bool start)
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 7/13 wifi: rtw89: concentrate parameter control for setting channel callback
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
For future support on multiple channels by multiple sub-entities, we need to manage parameters of each channel instance like rtw89_chan, rtw89_mac_idx, rtw89_phy_idx. So, we adjust related channel callback functions and centrally conrtol these parameters in set_channel().
--- drivers/net/wireless/realtek/rtw89/core.c | 8 ++-- drivers/net/wireless/realtek/rtw89/core.h | 25 +++++++++--- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 28 +++++++------ drivers/net/wireless/realtek/rtw89/rtw8852c.c | 40 ++++++++++--------- 4 files changed, 61 insertions(+), 40 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +5 -3
@@ -319,13 +319,15 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev)rtw89_set_entity_state (rtwdev, true); -rtw89_chip_set_channel_prepare (rtwdev, &bak); +rtw89_chip_set_channel_prepare (rtwdev, &bak, &chan, +RTW89_MAC_0 ,RTW89_PHY_0 ); - chip->ops->set_channel (rtwdev, &chan); + chip->ops->set_channel (rtwdev, &chan,RTW89_MAC_0 ,RTW89_PHY_0 );rtw89_core_set_chip_txpwr (rtwdev); -rtw89_chip_set_channel_done (rtwdev, &bak); +rtw89_chip_set_channel_done (rtwdev, &bak, &chan, +RTW89_MAC_0 ,RTW89_PHY_0 );if (!entity_active || band_changed) {rtw89_btc_ntfy_switch_band (rtwdev,RTW89_PHY_0 , chan.band_type);
drivers/net/wireless/realtek/rtw89/core.h +19 -6
@@ -2115,9 +2115,14 @@ struct rtw89_chip_ops {bool (*write_rf)(struct rtw89_dev *rtwdev,enum rtw89_rf_path rf_path,u32 addr,u32 mask,u32 data);void (*set_channel)(struct rtw89_dev *rtwdev, -const struct rtw89_chan *chan); +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx);void (*set_channel_help)(struct rtw89_dev *rtwdev,bool enter, -struct rtw89_channel_help_params *p); +struct rtw89_channel_help_params *p, +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx);int (*read_efuse)(struct rtw89_dev *rtwdev,u8 *log_map);int (*read_phycap)(struct rtw89_dev *rtwdev,u8 *phycap_map);void (*fem_setup)(struct rtw89_dev *rtwdev);
@@ -3604,16 +3609,24 @@ struct rtw89_bssid_cam_entry *rtw89_get_bssid_cam_of(struct rtw89_vif *rtwvif,static inline void rtw89_chip_set_channel_prepare (struct rtw89_dev *rtwdev, -struct rtw89_channel_help_params *p) +struct rtw89_channel_help_params *p, +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx) { - rtwdev->chip->ops->set_channel_help (rtwdev, true, p); + rtwdev->chip->ops->set_channel_help (rtwdev, true, p, chan, + mac_idx, phy_idx); }static inline void rtw89_chip_set_channel_done (struct rtw89_dev *rtwdev, -struct rtw89_channel_help_params *p) +struct rtw89_channel_help_params *p, +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx) { - rtwdev->chip->ops->set_channel_help (rtwdev, false, p); + rtwdev->chip->ops->set_channel_help (rtwdev, false, p, chan, + mac_idx, phy_idx); } static inline
drivers/net/wireless/realtek/rtw89/rtw8852a.c +16 -12
@@ -1156,10 +1156,12 @@ static void rtw8852a_set_channel_bb(struct rtw89_dev *rtwdev, }static void rtw8852a_set_channel (struct rtw89_dev *rtwdev, -const struct rtw89_chan *chan) +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx) { -rtw8852a_set_channel_mac (rtwdev, chan,RTW89_MAC_0 ); -rtw8852a_set_channel_bb (rtwdev, chan,RTW89_PHY_0 ); +rtw8852a_set_channel_mac (rtwdev, chan, mac_idx); +rtw8852a_set_channel_bb (rtwdev, chan, phy_idx); }static void rtw8852a_dfs_en (struct rtw89_dev *rtwdev,bool en)
@@ -1210,25 +1212,27 @@ static void rtw8852a_adc_en(struct rtw89_dev *rtwdev, bool en) }static void rtw8852a_set_channel_help (struct rtw89_dev *rtwdev,bool enter, -struct rtw89_channel_help_params *p) +struct rtw89_channel_help_params *p, +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx) { -u8 phy_idx =RTW89_PHY_0 ; -if (enter) { -rtw89_chip_stop_sch_tx (rtwdev,RTW89_MAC_0 , &p->tx_en,RTW89_SCH_TX_SEL_ALL ); -rtw89_mac_cfg_ppdu_status (rtwdev,RTW89_MAC_0 , false); +rtw89_chip_stop_sch_tx (rtwdev, mac_idx, &p->tx_en, +RTW89_SCH_TX_SEL_ALL ); +rtw89_mac_cfg_ppdu_status (rtwdev, mac_idx, false);rtw8852a_dfs_en (rtwdev, false); -rtw8852a_tssi_cont_en_phyidx (rtwdev, false,RTW89_PHY_0 ); +rtw8852a_tssi_cont_en_phyidx (rtwdev, false, phy_idx);rtw8852a_adc_en (rtwdev, false);fsleep (40 );rtw8852a_bb_reset_en (rtwdev, phy_idx, false); }else { -rtw89_mac_cfg_ppdu_status (rtwdev,RTW89_MAC_0 , true); +rtw89_mac_cfg_ppdu_status (rtwdev, mac_idx, true);rtw8852a_adc_en (rtwdev, true);rtw8852a_dfs_en (rtwdev, true); -rtw8852a_tssi_cont_en_phyidx (rtwdev, true,RTW89_PHY_0 ); +rtw8852a_tssi_cont_en_phyidx (rtwdev, true, phy_idx);rtw8852a_bb_reset_en (rtwdev, phy_idx, true); -rtw89_chip_resume_sch_tx (rtwdev,RTW89_MAC_0 , p->tx_en); +rtw89_chip_resume_sch_tx (rtwdev, mac_idx, p->tx_en); } }
drivers/net/wireless/realtek/rtw89/rtw8852c.c +21 -19
@@ -1529,11 +1529,9 @@ static void rtw8852c_bb_reset_all(struct rtw89_dev *rtwdev, phy_idx); } -static void rtw8852c_bb_reset_en (struct rtw89_dev *rtwdev, +static void rtw8852c_bb_reset_en (struct rtw89_dev *rtwdev,enum rtw89_band band,enum rtw89_phy_idx phy_idx,bool en) { -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 ); -if (en) {rtw89_phy_write32_idx (rtwdev,R_S0_HW_SI_DIS ,B_S0_HW_SI_DIS_W_R_TRIG ,0x0 , phy_idx);
@@ -1541,7 +1539,7 @@ static void rtw8852c_bb_reset_en(struct rtw89_dev *rtwdev, B_S1_HW_SI_DIS_W_R_TRIG, 0x0, phy_idx);rtw89_phy_write32_idx (rtwdev,R_RSTB_ASYNC ,B_RSTB_ASYNC_ALL ,1 , phy_idx); -if (chan->band_type ==RTW89_BAND_2G ) +if (band ==RTW89_BAND_2G )rtw89_phy_write32_mask (rtwdev,R_RXCCA_V1 ,B_RXCCA_DIS_V1 ,0x0 );rtw89_phy_write32_mask (rtwdev,R_PD_CTRL ,B_PD_HIT_DIS ,0x0 ); }else {
@@ -1777,11 +1775,13 @@ static void rtw8852c_set_channel_bb(struct rtw89_dev *rtwdev, }static void rtw8852c_set_channel (struct rtw89_dev *rtwdev, -const struct rtw89_chan *chan) +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx) { -rtw8852c_set_channel_mac (rtwdev, chan,RTW89_MAC_0 ); -rtw8852c_set_channel_bb (rtwdev, chan,RTW89_PHY_0 ); -rtw8852c_set_channel_rf (rtwdev, chan,RTW89_PHY_0 ); +rtw8852c_set_channel_mac (rtwdev, chan, mac_idx); +rtw8852c_set_channel_bb (rtwdev, chan, phy_idx); +rtw8852c_set_channel_rf (rtwdev, chan, phy_idx); }static void rtw8852c_dfs_en (struct rtw89_dev *rtwdev,bool en)
@@ -1803,25 +1803,27 @@ static void rtw8852c_adc_en(struct rtw89_dev *rtwdev, bool en) }static void rtw8852c_set_channel_help (struct rtw89_dev *rtwdev,bool enter, -struct rtw89_channel_help_params *p) +struct rtw89_channel_help_params *p, +const struct rtw89_chan *chan, +enum rtw89_mac_idx mac_idx, +enum rtw89_phy_idx phy_idx) { -u8 phy_idx =RTW89_PHY_0 ; -if (enter) { -rtw89_chip_stop_sch_tx (rtwdev,RTW89_MAC_0 , &p->tx_en,RTW89_SCH_TX_SEL_ALL ); -rtw89_mac_cfg_ppdu_status (rtwdev,RTW89_MAC_0 , false); +rtw89_chip_stop_sch_tx (rtwdev, mac_idx, &p->tx_en, +RTW89_SCH_TX_SEL_ALL ); +rtw89_mac_cfg_ppdu_status (rtwdev, mac_idx, false);rtw8852c_dfs_en (rtwdev, false); -rtw8852c_tssi_cont_en_phyidx (rtwdev, false,RTW89_PHY_0 ); +rtw8852c_tssi_cont_en_phyidx (rtwdev, false, phy_idx);rtw8852c_adc_en (rtwdev, false);fsleep (40 ); -rtw8852c_bb_reset_en (rtwdev, phy_idx, false); +rtw8852c_bb_reset_en (rtwdev, chan->band_type, phy_idx, false); }else { -rtw89_mac_cfg_ppdu_status (rtwdev,RTW89_MAC_0 , true); +rtw89_mac_cfg_ppdu_status (rtwdev, mac_idx, true);rtw8852c_adc_en (rtwdev, true);rtw8852c_dfs_en (rtwdev, true); -rtw8852c_tssi_cont_en_phyidx (rtwdev, true,RTW89_PHY_0 ); -rtw8852c_bb_reset_en (rtwdev, phy_idx, true); -rtw89_chip_resume_sch_tx (rtwdev,RTW89_MAC_0 , p->tx_en); +rtw8852c_tssi_cont_en_phyidx (rtwdev, true, phy_idx); +rtw8852c_bb_reset_en (rtwdev, chan->band_type, phy_idx, true); +rtw89_chip_resume_sch_tx (rtwdev, mac_idx, p->tx_en); } }
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 8/13 wifi: rtw89: concentrate chandef setting to stack callback
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
Originally, we didn't support mac80211 chanctx, so it's expected that ieee80211_hw::conf::chandef would be filled by mac80211. And then, we could just query it whenever we need the current chandef.
However, we are planing to support mac80211 chanctx. After that, the above assumption would be broken. So, we adjust a bit ahead to reduce future works about mac80211 chanctx.
After this, we don't query ieee80211_hw::conf::chandef directly, and we add a map, entity_map, to HAL to indicate which chandef came from stack. And it will later be used to recalcate entity mode.
--- drivers/net/wireless/realtek/rtw89/chan.c | 20 +++++++++++++++++++ drivers/net/wireless/realtek/rtw89/chan.h | 3 +++ drivers/net/wireless/realtek/rtw89/core.c | 14 +++++++------ drivers/net/wireless/realtek/rtw89/core.h | 12 +++++++++++ drivers/net/wireless/realtek/rtw89/mac80211.c | 6 +++++- 5 files changed, 48 insertions(+), 7 deletions(-)
drivers/net/wireless/realtek/rtw89/chan.c +20 -0
@@ -118,3 +118,23 @@ bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev, *chan = *new;return band_changed; } + +static void __rtw89_config_entity_chandef (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx, +const struct cfg80211_chan_def *chandef, +bool from_stack) +{ +struct rtw89_hal *hal = &rtwdev->hal; + + hal->chandef[idx] = *chandef; + +if (from_stack) +set_bit (idx, hal->entity_map); +} + +void rtw89_config_entity_chandef (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx, +const struct cfg80211_chan_def *chandef) +{ +__rtw89_config_entity_chandef (rtwdev, idx, chandef, true); +}
drivers/net/wireless/realtek/rtw89/chan.h +3 -0
@@ -26,5 +26,8 @@ void rtw89_chan_create(struct rtw89_chan *chan, u8 center_chan, u8 primary_chan,bool rtw89_assign_entity_chan (struct rtw89_dev *rtwdev,enum rtw89_sub_entity_idx idx,const struct rtw89_chan *new); +void rtw89_config_entity_chandef (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx, +const struct cfg80211_chan_def *chandef);#endif
drivers/net/wireless/realtek/rtw89/core.c +8 -6
@@ -225,7 +225,7 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev, } } -static void rtw89_get_channel_params (struct cfg80211_chan_def *chandef, +static void rtw89_get_channel_params (const struct cfg80211_chan_def *chandef,struct rtw89_chan *chan) {struct ieee80211_channel *channel = chandef->chan;
@@ -302,7 +302,8 @@ void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev)void rtw89_set_channel (struct rtw89_dev *rtwdev) { -struct ieee80211_hw *hw = rtwdev->hw; +const struct cfg80211_chan_def *chandef = +rtw89_chandef_get (rtwdev,RTW89_SUB_ENTITY_0 );const struct rtw89_chip_info *chip = rtwdev->chip;struct rtw89_chan chan;struct rtw89_channel_help_params bak;
@@ -311,7 +312,7 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev) entity_active =rtw89_get_entity_state (rtwdev); -rtw89_get_channel_params (&hw->conf.chandef, &chan); +rtw89_get_channel_params (chandef, &chan);if (WARN (chan.channel ==0 ,"Invalid channel\n" ))return ;
@@ -1607,14 +1608,15 @@ static void rtw89_core_update_rx_status(struct rtw89_dev *rtwdev,struct rtw89_rx_desc_info *desc_info, struct ieee80211_rx_status *rx_status) { - struct ieee80211_hw *hw = rtwdev->hw; + const struct cfg80211_chan_def *chandef = +rtw89_chandef_get (rtwdev,RTW89_SUB_ENTITY_0 );const struct rtw89_chan *cur =rtw89_chan_get (rtwdev,RTW89_SUB_ENTITY_0 );u16 data_rate;u8 data_rate_mode;/* currently using single PHY */ - rx_status->freq = hw->conf.chandef.chan->center_freq; - rx_status->band = hw->conf.chandef.chan->band; + rx_status->freq = chandef->chan->center_freq; + rx_status->band = chandef->chan->band;if (rtwdev->scanning &&RTW89_CHK_FW_FEATURE (SCAN_OFFLOAD , &rtwdev->fw)) {
drivers/net/wireless/realtek/rtw89/core.h +12 -0
@@ -2634,6 +2634,9 @@ struct rtw89_hal {bool support_cckpd;bool support_igi; +DECLARE_BITMAP (entity_map,NUM_OF_RTW89_SUB_ENTITY ); +struct cfg80211_chan_def chandef[NUM_OF_RTW89_SUB_ENTITY ]; +bool entity_active;struct rtw89_chan chan[NUM_OF_RTW89_SUB_ENTITY ];
@@ -3629,6 +3632,15 @@ void rtw89_chip_set_channel_done(struct rtw89_dev *rtwdev, mac_idx, phy_idx); } +static inline +const struct cfg80211_chan_def *rtw89_chandef_get (struct rtw89_dev *rtwdev, +enum rtw89_sub_entity_idx idx) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +return &hal->chandef[idx]; +} +static inline const struct rtw89_chan *rtw89_chan_get (struct rtw89_dev *rtwdev,enum rtw89_sub_entity_idx idx)
drivers/net/wireless/realtek/rtw89/mac80211.c +5 -1
@@ -3,6 +3,7 @@*/ #include "cam.h" +#include "chan.h" #include "coex.h" #include "debug.h" #include "fw.h"
@@ -85,8 +86,11 @@ static int rtw89_ops_config(struct ieee80211_hw *hw, u32 changed) } } -if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) +if (changed &IEEE80211_CONF_CHANGE_CHANNEL ) { +rtw89_config_entity_chandef (rtwdev,RTW89_SUB_ENTITY_0 , + &hw->conf.chandef);rtw89_set_channel (rtwdev); + }if ((changed &IEEE80211_CONF_CHANGE_IDLE ) && (hw->conf.flags &IEEE80211_CONF_IDLE ))
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 9/13 wifi: rtw89: initialize entity and configure default chandef
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
While idle, we need a default chandef to set channel for things, such as scan. Before support of mac80211 chanctx, mac80211 would configure a default one on ieee80211_hw::conf::chandef. And we just queried it whenever we did set channel. However, after support of mac80211 chanctx, the flow won't work like before.
Besides, we don't now query chandef from ieee80211_hw::conf::chandef either. So, similar to mac80211 without using chanctx, we configure the default chandef with ieee80211_channel of index 0 in 2GHz.
Although we have not added the support of mac80211 chanctx here, this configuration should be compatible before that. So, we commit this ahead.
--- drivers/net/wireless/realtek/rtw89/chan.c | 16 ++++++++++++++++ drivers/net/wireless/realtek/rtw89/chan.h | 1 + drivers/net/wireless/realtek/rtw89/core.c | 7 +++++++ drivers/net/wireless/realtek/rtw89/core.h | 1 + drivers/net/wireless/realtek/rtw89/ser.c | 2 ++ 5 files changed, 27 insertions(+)
drivers/net/wireless/realtek/rtw89/chan.c +16 -0
@@ -138,3 +138,19 @@ void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev, {__rtw89_config_entity_chandef (rtwdev, idx, chandef, true); } + +static void rtw89_config_default_chandef (struct rtw89_dev *rtwdev) +{ +struct cfg80211_chan_def chandef = {0 }; + +rtw89_get_default_chandef (&chandef); +__rtw89_config_entity_chandef (rtwdev,RTW89_SUB_ENTITY_0 , &chandef, false); +} + +void rtw89_entity_init (struct rtw89_dev *rtwdev) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +bitmap_zero (hal->entity_map,NUM_OF_RTW89_SUB_ENTITY ); +rtw89_config_default_chandef (rtwdev); +}
drivers/net/wireless/realtek/rtw89/chan.h +1 -0
@@ -29,5 +29,6 @@ bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,void rtw89_config_entity_chandef (struct rtw89_dev *rtwdev,enum rtw89_sub_entity_idx idx,const struct cfg80211_chan_def *chandef); +void rtw89_entity_init (struct rtw89_dev *rtwdev);#endif
drivers/net/wireless/realtek/rtw89/core.c +7 -0
@@ -225,6 +225,12 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev, } } +void rtw89_get_default_chandef (struct cfg80211_chan_def *chandef) +{ +cfg80211_chandef_create (chandef, &rtw89_channels_2ghz[0 ], +NL80211_CHAN_NO_HT ); +} +static void rtw89_get_channel_params (const struct cfg80211_chan_def *chandef,struct rtw89_chan *chan) {
@@ -2935,6 +2941,7 @@ int rtw89_core_init(struct rtw89_dev *rtwdev)return ret; }rtw89_ser_init (rtwdev); +rtw89_entity_init (rtwdev);return 0 ; }
drivers/net/wireless/realtek/rtw89/core.h +1 -0
@@ -3955,6 +3955,7 @@ void rtw89_core_deinit(struct rtw89_dev *rtwdev);int rtw89_core_register (struct rtw89_dev *rtwdev);void rtw89_core_unregister (struct rtw89_dev *rtwdev);void rtw89_core_set_chip_txpwr (struct rtw89_dev *rtwdev); +void rtw89_get_default_chandef (struct cfg80211_chan_def *chandef);void rtw89_set_channel (struct rtw89_dev *rtwdev);u8 rtw89_core_acquire_bit_map (unsigned long *addr,unsigned long size);void rtw89_core_release_bit_map (unsigned long *addr,u8 bit);
drivers/net/wireless/realtek/rtw89/ser.c +2 -0
@@ -5,6 +5,7 @@#include <linux/devcoredump.h> #include "cam.h" +#include "chan.h" #include "debug.h" #include "fw.h" #include "mac.h"
@@ -601,6 +602,7 @@ static void ser_l2_reset_st_pre_hdl(struct rtw89_ser *ser)ser_reset_mac_binding (rtwdev);rtw89_core_stop (rtwdev); +rtw89_entity_init (rtwdev);INIT_LIST_HEAD (&rtwdev->rtwvifs_list); }
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 10/13 wifi: rtw89: introduce entity mode and its recalculated prototype
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
After supporting more than one channel, we need entity mode to decide how to set current channel(s) on the sub-entities. This decision may happen on set_channel() and rtw89_core_set_chip_txpwr().
For now, we support single one channel and use only first HW entry, i.e. RTW89_SUB_ENTITY_0, RTW89_MAC_0, RTW89_PHY_0. Without something unexpected, the entity mode should always be RTW89_ENT_MODE_SCC after recalcated, where SCC means single channel concurrency. So, an assert is added in set_channel() and rtw89_core_set_chip_txpwr().
--- drivers/net/wireless/realtek/rtw89/chan.c | 25 ++++++++++++ drivers/net/wireless/realtek/rtw89/chan.h | 17 +++++++++ drivers/net/wireless/realtek/rtw89/core.c | 46 ++++++++++++++++------- drivers/net/wireless/realtek/rtw89/core.h | 5 +++ 4 files changed, 79 insertions(+), 14 deletions(-)
drivers/net/wireless/realtek/rtw89/chan.c +25 -0
@@ -3,6 +3,7 @@*/ #include "chan.h" +#include "debug.h" static enum rtw89_subband rtw89_get_subband_type (enum rtw89_band band,u8 center_chan)
@@ -154,3 +155,27 @@ void rtw89_entity_init(struct rtw89_dev *rtwdev)bitmap_zero (hal->entity_map,NUM_OF_RTW89_SUB_ENTITY );rtw89_config_default_chandef (rtwdev); } + +enum rtw89_entity_mode rtw89_entity_recalc (struct rtw89_dev *rtwdev) +{ +struct rtw89_hal *hal = &rtwdev->hal; +enum rtw89_entity_mode mode; +u8 weight; + + weight =bitmap_weight (hal->entity_map,NUM_OF_RTW89_SUB_ENTITY ); +switch (weight) { +default : +rtw89_warn (rtwdev,"unknown ent chan weight: %d\n" , weight); +bitmap_zero (hal->entity_map,NUM_OF_RTW89_SUB_ENTITY ); + fallthrough; +case 0 : +rtw89_config_default_chandef (rtwdev); + fallthrough; +case 1 : + mode =RTW89_ENTITY_MODE_SCC ; +break ; + } + +rtw89_set_entity_mode (rtwdev, mode); +return mode; +}
drivers/net/wireless/realtek/rtw89/chan.h +17 -0
@@ -21,6 +21,22 @@ static inline void rtw89_set_entity_state(struct rtw89_dev *rtwdev, bool active)WRITE_ONCE (hal->entity_active, active); } +static inline +enum rtw89_entity_mode rtw89_get_entity_mode (struct rtw89_dev *rtwdev) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +return READ_ONCE (hal->entity_mode); +} + +static inline void rtw89_set_entity_mode (struct rtw89_dev *rtwdev, +enum rtw89_entity_mode mode) +{ +struct rtw89_hal *hal = &rtwdev->hal; + +WRITE_ONCE (hal->entity_mode, mode); +} +void rtw89_chan_create (struct rtw89_chan *chan,u8 center_chan,u8 primary_chan,enum rtw89_band band,enum rtw89_bandwidth bandwidth); bool rtw89_assign_entity_chan(struct rtw89_dev *rtwdev,
@@ -30,5 +46,6 @@ void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev,enum rtw89_sub_entity_idx idx, const struct cfg80211_chan_def *chandef);void rtw89_entity_init (struct rtw89_dev *rtwdev); +enum rtw89_entity_mode rtw89_entity_recalc (struct rtw89_dev *rtwdev);#endif
drivers/net/wireless/realtek/rtw89/core.c +32 -14
83 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/core.h +5 -0
@@ -2623,6 +2623,10 @@ struct rtw89_sar_info { }; }; +enum rtw89_entity_mode { +RTW89_ENTITY_MODE_SCC , +}; +struct rtw89_hal {u32 rx_fltr;u8 cv;
@@ -2638,6 +2642,7 @@ struct rtw89_hal {struct cfg80211_chan_def chandef[NUM_OF_RTW89_SUB_ENTITY ];bool entity_active; +enum rtw89_entity_mode entity_mode;struct rtw89_chan chan[NUM_OF_RTW89_SUB_ENTITY ];struct rtw89_chan_rcd chan_rcd[NUM_OF_RTW89_SUB_ENTITY ];
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 11/13 wifi: rtw89: add skeleton of mac80211 chanctx ops support
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
Support mac80211 chanctx series ops. Still, currently support single channel. Based on this premise, things should be similar to before. So, we haven't dealt with relationship between vif and chanctx in depth. Instead, we leave both ::assign_vif() and ::unassign_vif() as noops for now.
--- drivers/net/wireless/realtek/rtw89/chan.c | 53 +++++++++++++++ drivers/net/wireless/realtek/rtw89/chan.h | 13 ++++ drivers/net/wireless/realtek/rtw89/core.c | 1 + drivers/net/wireless/realtek/rtw89/core.h | 4 ++ drivers/net/wireless/realtek/rtw89/mac80211.c | 68 +++++++++++++++++++ 5 files changed, 139 insertions(+)
drivers/net/wireless/realtek/rtw89/chan.c +53 -0
@@ -179,3 +179,56 @@ enum rtw89_entity_mode rtw89_entity_recalc(struct rtw89_dev *rtwdev)rtw89_set_entity_mode (rtwdev, mode);return mode; } + +int rtw89_chanctx_ops_add (struct rtw89_dev *rtwdev, +struct ieee80211_chanctx_conf *ctx) +{ +struct rtw89_hal *hal = &rtwdev->hal; +struct rtw89_chanctx_cfg *cfg = (struct rtw89_chanctx_cfg *)ctx->drv_priv; +u8 idx; + + idx =find_first_zero_bit (hal->entity_map,NUM_OF_RTW89_SUB_ENTITY ); +if (idx >RTW89_SUB_ENTITY_0 ) +return -ENOENT ; + +rtw89_config_entity_chandef (rtwdev, idx, &ctx->def); +rtw89_set_channel (rtwdev); + cfg->idx = idx; +return 0 ; +} + +void rtw89_chanctx_ops_remove (struct rtw89_dev *rtwdev, +struct ieee80211_chanctx_conf *ctx) +{ +struct rtw89_hal *hal = &rtwdev->hal; +struct rtw89_chanctx_cfg *cfg = (struct rtw89_chanctx_cfg *)ctx->drv_priv; + +clear_bit (cfg->idx, hal->entity_map); +rtw89_set_channel (rtwdev); +} + +void rtw89_chanctx_ops_change (struct rtw89_dev *rtwdev, +struct ieee80211_chanctx_conf *ctx, +u32 changed) +{ +struct rtw89_chanctx_cfg *cfg = (struct rtw89_chanctx_cfg *)ctx->drv_priv; +u8 idx = cfg->idx; + +if (changed &IEEE80211_CHANCTX_CHANGE_WIDTH ) { +rtw89_config_entity_chandef (rtwdev, idx, &ctx->def); +rtw89_set_channel (rtwdev); + } +} + +int rtw89_chanctx_ops_assign_vif (struct rtw89_dev *rtwdev, +struct rtw89_vif *rtwvif, +struct ieee80211_chanctx_conf *ctx) +{ +return 0 ; +} + +void rtw89_chanctx_ops_unassign_vif (struct rtw89_dev *rtwdev, +struct rtw89_vif *rtwvif, +struct ieee80211_chanctx_conf *ctx) +{ +}
drivers/net/wireless/realtek/rtw89/chan.h +13 -0
@@ -47,5 +47,18 @@ void rtw89_config_entity_chandef(struct rtw89_dev *rtwdev, const struct cfg80211_chan_def *chandef);void rtw89_entity_init (struct rtw89_dev *rtwdev);enum rtw89_entity_mode rtw89_entity_recalc (struct rtw89_dev *rtwdev); +int rtw89_chanctx_ops_add (struct rtw89_dev *rtwdev, +struct ieee80211_chanctx_conf *ctx); +void rtw89_chanctx_ops_remove (struct rtw89_dev *rtwdev, +struct ieee80211_chanctx_conf *ctx); +void rtw89_chanctx_ops_change (struct rtw89_dev *rtwdev, +struct ieee80211_chanctx_conf *ctx, +u32 changed); +int rtw89_chanctx_ops_assign_vif (struct rtw89_dev *rtwdev, +struct rtw89_vif *rtwvif, +struct ieee80211_chanctx_conf *ctx); +void rtw89_chanctx_ops_unassign_vif (struct rtw89_dev *rtwdev, +struct rtw89_vif *rtwvif, +struct ieee80211_chanctx_conf *ctx);#endif
drivers/net/wireless/realtek/rtw89/core.c +1 -0
@@ -3114,6 +3114,7 @@ static int rtw89_core_register_hw(struct rtw89_dev *rtwdev) hw->vif_data_size =sizeof (struct rtw89_vif ); hw->sta_data_size =sizeof (struct rtw89_sta ); hw->txq_data_size =sizeof (struct rtw89_txq ); + hw->chanctx_data_size =sizeof (struct rtw89_chanctx_cfg );SET_IEEE80211_PERM_ADDR (hw, efuse->addr);
drivers/net/wireless/realtek/rtw89/core.h +4 -0
@@ -2623,6 +2623,10 @@ struct rtw89_sar_info { }; }; +struct rtw89_chanctx_cfg { +enum rtw89_sub_entity_idx idx; +}; +enum rtw89_entity_mode {RTW89_ENTITY_MODE_SCC , };
drivers/net/wireless/realtek/rtw89/mac80211.c +68 -0
80 lines not on this page · raw message
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 12/13 wifi: rtw89: declare support for mac80211 chanctx ops by chip
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
Some HW features are required if we hook chanctx ops to mac80211. With it, mac80211 would expect the HW-supported variant ops exists on some behavior, e.g. HW scan. But, HW features may depend on chip's FW or its development. Besides, how many chanctx can be supported also depends on chip design. We can neither decide whether to generally support chanctx ops nor how many chanctx can be supported.
So, support_chanctx_num is added under chip info to deal with this by chip. For now, all chip configure support_chanctx_num as 0. We haven't really hook chanctx ops yet. So, chip can run without mac80211 chanctx as before.
--- drivers/net/wireless/realtek/rtw89/chan.c | 3 +- drivers/net/wireless/realtek/rtw89/core.c | 47 +++++++++++++++++++ drivers/net/wireless/realtek/rtw89/core.h | 6 +++ drivers/net/wireless/realtek/rtw89/pci.c | 20 ++++---- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852c.c | 1 + 6 files changed, 65 insertions(+), 13 deletions(-)
drivers/net/wireless/realtek/rtw89/chan.c +2 -1
@@ -185,10 +185,11 @@ int rtw89_chanctx_ops_add(struct rtw89_dev *rtwdev, {struct rtw89_hal *hal = &rtwdev->hal;struct rtw89_chanctx_cfg *cfg = (struct rtw89_chanctx_cfg *)ctx->drv_priv; +const struct rtw89_chip_info *chip = rtwdev->chip;u8 idx; idx =find_first_zero_bit (hal->entity_map,NUM_OF_RTW89_SUB_ENTITY ); -if (idx >RTW89_SUB_ENTITY_0 ) +if (idx >= chip->support_chanctx_num)return -ENOENT ;rtw89_config_entity_chandef (rtwdev, idx, &ctx->def);
drivers/net/wireless/realtek/rtw89/core.c +47 -0
53 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/core.h +6 -0
@@ -2408,6 +2408,7 @@ struct rtw89_chip_info {const struct rtw89_hfc_param_ini *hfc_param_ini;const struct rtw89_dle_mem *dle_mem;u32 rf_base_addr[2 ]; +u8 support_chanctx_num;u8 support_bands;bool support_bw160;bool hw_sec_hdr;
@@ -3152,6 +3153,7 @@ struct rtw89_phy_efuse_gain {struct rtw89_dev {struct ieee80211_hw *hw;struct device *dev; +const struct ieee80211_ops *ops;bool dbcc_en;struct rtw89_hw_scan_info scan_info;
@@ -3963,6 +3965,10 @@ int rtw89_core_init(struct rtw89_dev *rtwdev);void rtw89_core_deinit (struct rtw89_dev *rtwdev);int rtw89_core_register (struct rtw89_dev *rtwdev);void rtw89_core_unregister (struct rtw89_dev *rtwdev); +struct rtw89_dev *rtw89_alloc_ieee80211_hw (struct device *device, +u32 bus_data_size, +const struct rtw89_chip_info *chip); +void rtw89_free_ieee80211_hw (struct rtw89_dev *rtwdev);void rtw89_core_set_chip_txpwr (struct rtw89_dev *rtwdev);void rtw89_get_default_chandef (struct cfg80211_chan_def *chandef);void rtw89_set_channel (struct rtw89_dev *rtwdev);
drivers/net/wireless/realtek/rtw89/pci.c +8 -12
@@ -3614,27 +3614,23 @@ static const struct rtw89_hci_ops rtw89_pci_ops = {int rtw89_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { -struct ieee80211_hw *hw;struct rtw89_dev *rtwdev;const struct rtw89_driver_info *info;const struct rtw89_pci_info *pci_info; -int driver_data_size;int ret; - driver_data_size =sizeof (struct rtw89_dev ) +sizeof (struct rtw89_pci ); - hw =ieee80211_alloc_hw (driver_data_size, &rtw89_ops); -if (!hw) { + info = (const struct rtw89_driver_info *)id->driver_data; + + rtwdev =rtw89_alloc_ieee80211_hw (&pdev->dev, +sizeof (struct rtw89_pci ), + info->chip); +if (!rtwdev) {dev_err (&pdev->dev,"failed to allocate hw\n" );return -ENOMEM ; } - info = (const struct rtw89_driver_info *)id->driver_data; pci_info = info->bus.pci; - rtwdev = hw->priv; - rtwdev->hw = hw; - rtwdev->dev = &pdev->dev; - rtwdev->chip = info->chip; rtwdev->pci_info = info->bus.pci; rtwdev->hci.ops = &rtw89_pci_ops; rtwdev->hci.type =RTW89_HCI_TYPE_PCIE ;
@@ -3696,7 +3692,7 @@ int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_core_deinit:rtw89_core_deinit (rtwdev); err_release_hw: -ieee80211_free_hw (hw); +rtw89_free_ieee80211_hw (rtwdev);return ret; }
@@ -3715,7 +3711,7 @@ void rtw89_pci_remove(struct pci_dev *pdev)rtw89_pci_clear_resource (rtwdev, pdev);rtw89_pci_declaim_device (rtwdev, pdev);rtw89_core_deinit (rtwdev); -ieee80211_free_hw (hw); +rtw89_free_ieee80211_hw (rtwdev); }EXPORT_SYMBOL (rtw89_pci_remove);
drivers/net/wireless/realtek/rtw89/rtw8852a.c +1 -0
@@ -2133,6 +2133,7 @@ const struct rtw89_chip_info rtw8852a_chip_info = { .txpwr_factor_mac = 1, .dig_table = &rtw89_8852a_phy_dig_table, .tssi_dbw_table = NULL, + .support_chanctx_num = 0, .support_bands =BIT (NL80211_BAND_2GHZ ) | BIT(NL80211_BAND_5GHZ), .support_bw160 = false,
drivers/net/wireless/realtek/rtw89/rtw8852c.c +1 -0
@@ -2981,6 +2981,7 @@ const struct rtw89_chip_info rtw8852c_chip_info = { .txpwr_factor_mac = 1, .dig_table = NULL, .tssi_dbw_table = &rtw89_8852c_tssi_dbw_table, + .support_chanctx_num = 0, .support_bands =BIT (NL80211_BAND_2GHZ ) |BIT (NL80211_BAND_5GHZ ) | BIT(NL80211_BAND_6GHZ),
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v3 13/13 wifi: rtw89: early recognize FW feature to decide if chanctx
In reply to Ping-Ke ShihFrom: Zong-Zhe Yang <[email protected]>
In current flow, FW is asynchronously loaded after alloc_hw(). It defers the decision on FW feature map. It makes things difficult for us to decide whether to hook chanctx ops, which should be decided while alloc_hw() is calling. Still, asynchronous gets its advantages. So, we want to resolve this without dropping them.
Based on multi-FW flag, RTW89_MFW_SIG, we can determine runtime FW is multi-FW (MFW) or single FW (SFW). Both of them have a quite small chunk for header at the head. The difference is that MFW doesn't describe version code in its header while SFW does. So, we plan to extend MFW header for version code. After that, in both cases, we can determine FW feature map by just FW header. And, according to the map, we can decide chanctx.
So, we call request_partial_firmware_into_buf() to request a quite small chunk before alloc_hw() to get a early FW feature map without affecting things much and only use early map to decide whether to hook chanctx ops.
It means that if non-extended MFW is used at runtime, driver just acts without chanctx as before. If extended MFW or SFW, which supports required FW features, is used at runtime, driver can hook chanctx ops to mac80211 if chip has configured support_chanctx_num > 0.
Besides, key point for now to support single one chanctx is whether HW scan is supported at runtime. So, we configure all chip's support_chanctx_num to 1, and check if HW scan is supported at runtime via early FW feature map.
--- drivers/net/wireless/realtek/rtw89/core.c | 12 +++++- drivers/net/wireless/realtek/rtw89/core.h | 12 ++++++ drivers/net/wireless/realtek/rtw89/fw.c | 40 +++++++++++++++++++ drivers/net/wireless/realtek/rtw89/fw.h | 12 +++++- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 2 +- drivers/net/wireless/realtek/rtw89/rtw8852c.c | 2 +- 6 files changed, 76 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +11 -1
@@ -3216,12 +3216,19 @@ struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device,struct rtw89_dev *rtwdev;struct ieee80211_ops *ops;u32 driver_data_size; +u32 early_feat_map =0 ; +bool no_chanctx; + +rtw89_early_fw_feature_recognize (device, chip, &early_feat_map); ops =kmemdup (&rtw89_ops,sizeof (rtw89_ops),GFP_KERNEL );if (!ops) goto err; -if (chip->support_chanctx_num ==0 ) { + no_chanctx = chip->support_chanctx_num ==0 || + !(early_feat_map &BIT (RTW89_FW_FEATURE_SCAN_OFFLOAD )); + +if (no_chanctx) { ops->add_chanctx =NULL ; ops->remove_chanctx =NULL ; ops->change_chanctx =NULL ;
@@ -3240,6 +3247,9 @@ struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device, rtwdev->ops = ops; rtwdev->chip = chip; +rtw89_debug (rtwdev,RTW89_DBG_FW ,"probe driver %s chanctx\n" , + no_chanctx ?"without" :"with" ); +return rtwdev; err:
drivers/net/wireless/realtek/rtw89/core.h +12 -0
@@ -2561,6 +2561,18 @@ struct rtw89_fw_suit {#define RTW89_FW_SUIT_VER_CODE (s) \ RTW89_FW_VER_CODE((s)->major_ver, (s)->minor_ver, (s)->sub_ver, (s)->sub_idex) +#define RTW89_MFW_HDR_VER_CODE (mfw_hdr) \ + RTW89_FW_VER_CODE((mfw_hdr)->ver.major, \ + (mfw_hdr)->ver.minor, \ + (mfw_hdr)->ver.sub, \ + (mfw_hdr)->ver.idx) + +#define RTW89_FW_HDR_VER_CODE (fw_hdr) \ + RTW89_FW_VER_CODE(GET_FW_HDR_MAJOR_VERSION(fw_hdr), \ + GET_FW_HDR_MINOR_VERSION(fw_hdr), \ + GET_FW_HDR_SUBVERSION(fw_hdr), \ + GET_FW_HDR_SUBINDEX(fw_hdr)) +struct rtw89_fw_info {const struct firmware *firmware;struct rtw89_dev *rtwdev;
drivers/net/wireless/realtek/rtw89/fw.c +40 -0
@@ -248,6 +248,46 @@ static void rtw89_fw_recognize_features(struct rtw89_dev *rtwdev) } } +void rtw89_early_fw_feature_recognize (struct device *device, +const struct rtw89_chip_info *chip, +u32 *early_feat_map) +{ +union { +struct rtw89_mfw_hdr mfw_hdr; +u8 fw_hdr[RTW89_FW_HDR_SIZE ]; + } buf = {}; +const struct firmware *firmware; +u32 ver_code; +int ret; +int i; + + ret =request_partial_firmware_into_buf (&firmware, chip->fw_name, + device, &buf,sizeof (buf),0 ); +if (ret) { +dev_err (device,"failed to early request firmware: %d\n" , ret); + goto out; + } + + ver_code = buf.mfw_hdr.sig !=RTW89_MFW_SIG ? +RTW89_FW_HDR_VER_CODE (&buf.fw_hdr) : +RTW89_MFW_HDR_VER_CODE (&buf.mfw_hdr); +if (!ver_code) + goto out; + +for (i =0 ; i <ARRAY_SIZE (fw_feat_tbl); i++) { +const struct __fw_feat_cfg *ent = &fw_feat_tbl[i]; + +if (chip->chip_id != ent->chip_id) +continue ; + +if (ent->cond (ver_code, ent->ver_code)) + *early_feat_map |=BIT (ent->feature); + } + +out: +release_firmware (firmware); +} +int rtw89_fw_recognize (struct rtw89_dev *rtwdev) {int ret;
drivers/net/wireless/realtek/rtw89/fw.h +11 -1
@@ -2446,7 +2446,14 @@ struct rtw89_mfw_info {struct rtw89_mfw_hdr {u8 sig;/* RTW89_MFW_SIG */ u8 fw_nr; -u8 rsvd[14 ]; +u8 rsvd0[2 ]; +struct { +u8 major; +u8 minor; +u8 sub; +u8 idx; + } ver; +u8 rsvd1[8 ];struct rtw89_mfw_info info[]; } __packed;
@@ -2563,6 +2570,9 @@ struct rtw89_fw_h2c_rf_get_mccch {int rtw89_fw_check_rdy (struct rtw89_dev *rtwdev);int rtw89_fw_recognize (struct rtw89_dev *rtwdev); +void rtw89_early_fw_feature_recognize (struct device *device, +const struct rtw89_chip_info *chip, +u32 *early_feat_map);int rtw89_fw_download (struct rtw89_dev *rtwdev,enum rtw89_fw_type type);int rtw89_load_firmware (struct rtw89_dev *rtwdev);void rtw89_unload_firmware (struct rtw89_dev *rtwdev);
drivers/net/wireless/realtek/rtw89/rtw8852a.c +1 -1
@@ -2133,7 +2133,7 @@ const struct rtw89_chip_info rtw8852a_chip_info = { .txpwr_factor_mac = 1, .dig_table = &rtw89_8852a_phy_dig_table, .tssi_dbw_table = NULL, - .support_chanctx_num = 0, + .support_chanctx_num = 1, .support_bands =BIT (NL80211_BAND_2GHZ ) | BIT(NL80211_BAND_5GHZ), .support_bw160 = false,
drivers/net/wireless/realtek/rtw89/rtw8852c.c +1 -1
@@ -2981,7 +2981,7 @@ const struct rtw89_chip_info rtw8852c_chip_info = { .txpwr_factor_mac = 1, .dig_table = NULL, .tssi_dbw_table = &rtw89_8852c_tssi_dbw_table, - .support_chanctx_num = 0, + .support_chanctx_num = 1, .support_bands =BIT (NL80211_BAND_2GHZ ) |BIT (NL80211_BAND_5GHZ ) | BIT(NL80211_BAND_6GHZ),
Signature · 1 line
2.25.1
Re: [PATCH v3 13/13] wifi: rtw89: early recognize FW feature to decide if chanctx
Quoted 30 lines · Ping-Ke Shih
From: Zong-Zhe Yang <[email protected]>
In current flow, FW is asynchronously loaded after
alloc_hw(). It defers the decision on FW feature map. It makes things difficult for us to decide whether to hook chanctx ops, which should be decided whilealloc_hw()is calling. Still, asynchronous gets its advantages. So, we want to resolve this without dropping them.Based on multi-FW flag,
RTW89_MFW_SIG, we can determine runtime FW is multi-FW (MFW) or single FW (SFW). Both of them have a quite small chunk for header at the head. The difference is that MFW doesn't describe version code in its header while SFW does. So, we plan to extend MFW header for version code. After that, in both cases, we can determine FW feature map by just FW header. And, according to the map, we can decide chanctx.So, we call
request_partial_firmware_into_buf()to request a quite small chunk beforealloc_hw()to get a early FW feature map without affecting things much and only use early map to decide whether to hook chanctx ops.It means that if non-extended MFW is used at runtime, driver just acts without chanctx as before. If extended MFW or SFW, which supports required FW features, is used at runtime, driver can hook chanctx ops to mac80211 if chip has configured
support_chanctx_num> 0.Besides, key point for now to support single one chanctx is whether HW scan is supported at runtime. So, we configure all chip's
support_chanctx_numto 1, and check if HW scan is supported at runtime via early FW feature map.Signed-off-by Zong-Zhe Yang <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>
[...]
drivers/net/wireless/realtek/rtw89/fw.c static void rtw89_fw_recognize_features(struct rtw89_dev *rtwdev) · line 273
Quoted 3 lines
drivers/net/wireless/realtek/rtw89/fw.c +3
-0+ ver_code = buf.mfw_hdr.sig !=RTW89_MFW_SIG ? +RTW89_FW_HDR_VER_CODE (&buf.fw_hdr) : +RTW89_MFW_HDR_VER_CODE (&buf.mfw_hdr);
Nitpicking, but in this case a proper if statement is preferred over a '?' operator. You only save one line with the latter.
if (buf.mfw_hdr.sig != RTW89_MFW_SIG)
ver_code = RTW89_FW_HDR_VER_CODE(&buf.fw_hdr);
else
ver_code = RTW89_MFW_HDR_VER_CODE(&buf.mfw_hdr);But no need to resend because of this.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches