wifi: mt76: mt7996: rework radar HWRDD idx
Subsystems (2)
PATCH 3/3 wifi: mt76: mt7996: rework radar HWRDD idx
The definition of MT_RX_SEL (for rdd_rx_sel) is mixed with the definition of HWRDD idx.
For example, MT_RX_SEL2 is for background HWRDD idx, not an option of rdd_rx_sel.
Additionally, HWRDD idx does not exactly map to band idx for Connac 3 chips. So, add mt7996_get_rdd_idx as a helper function.
Finally, remove some parts of the code inherited from the legacy chips. For instance,
1. rdd_state is used for single-band-dual-HWRDD chips (for 80+80), especially the 76xx series.
2. rdd_rx_sel is also used for single-band-dual-HWRDD chips rx_sel = 0 => RDD0 for WF0, RDD1 for WF2rx_sel = 1 => RDD0 for WF1, RDD1 for WF3
Chip Variants | 5G rdd idx | Background rdd idx ---------------------------|----------------|------------------- MT7996 (except 205/255) | 1 | 2 MT7992 | 1 | 2 MT7990 | 1 | 2
Signed-off-by StanleyYP Wang <[email protected]>
Reviewed-by Shayne Chen <[email protected]>
Reviewed-by Money Wang <[email protected]>
--- .../wireless/mediatek/mt76/mt7996/debugfs.c | 17 ++++-- .../net/wireless/mediatek/mt76/mt7996/mac.c | 57 +++++++------------ .../net/wireless/mediatek/mt76/mt7996/mcu.c | 40 ++++++------- .../net/wireless/mediatek/mt76/mt7996/mcu.h | 2 +- .../wireless/mediatek/mt76/mt7996/mt7996.h | 28 ++++++--- 5 files changed, 75 insertions(+), 69 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c +13 -4
@@ -222,18 +222,27 @@ static const struct file_operations mt7996_sys_recovery_ops = {static int mt7996_radar_trigger (void *data,u64 val) { +#define RADAR_MAIN_CHAIN 1 +#define RADAR_BACKGROUND 2struct mt7996_dev *dev = data; +struct mt7996_phy *phy =mt7996_band_phy (dev,NL80211_BAND_5GHZ ); +int rdd_idx; -if (val >MT_RX_SEL2 ) +if (!phy || !val || val >RADAR_BACKGROUND )return -EINVAL ; -if (val ==MT_RX_SEL2 && !dev->rdd2_phy) { +if (val ==RADAR_BACKGROUND && !dev->rdd2_phy) {dev_err (dev->mt76.dev,"Background radar is not enabled\n" );return -EINVAL ; } -return mt7996_mcu_rdd_cmd (dev,RDD_RADAR_EMULATE , - val,0 ,0 ); + rdd_idx =mt7996_get_rdd_idx (phy, val ==RADAR_BACKGROUND ); +if (rdd_idx <0 ) { +dev_err (dev->mt76.dev,"No RDD found\n" ); +return -EINVAL ; + } + +return mt7996_mcu_rdd_cmd (dev,RDD_RADAR_EMULATE , rdd_idx,0 ); } DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_trigger, NULL,
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +20 -37
108 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +21 -19
@@ -364,21 +364,27 @@ mt7996_mcu_rx_radar_detected(struct mt7996_dev *dev, struct sk_buff *skb) r = (struct mt7996_mcu_rdd_report *)skb->data; -if (r->band_idx >=ARRAY_SIZE (dev->mt76.phys)) -return ; - -if (r->band_idx ==MT_RX_SEL2 && !dev->rdd2_phy) -return ; - -if (r->band_idx ==MT_RX_SEL2 ) +switch (r->rdd_idx) { +case MT_RDD_IDX_BAND2 : + mphy = dev->mt76.phys[MT_BAND2 ]; +break ; +case MT_RDD_IDX_BAND1 : + mphy = dev->mt76.phys[MT_BAND1 ]; +break ; +case MT_RDD_IDX_BACKGROUND : +if (!dev->rdd2_phy) +return ; mphy = dev->rdd2_phy->mt76; -else - mphy = dev->mt76.phys[r->band_idx]; +break ; +default : +dev_err (dev->mt76.dev,"Unknown RDD idx %d\n" , r->rdd_idx); +return ; + }if (!mphy)return ; -if (r->band_idx ==MT_RX_SEL2 ) +if (r->rdd_idx ==MT_RDD_IDX_BACKGROUND )cfg80211_background_radar_event (mphy->hw->wiphy, &dev->rdd2_chandef,GFP_ATOMIC );
@@ -3436,11 +3442,10 @@ int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy, struct cfg80211_chan_def *chandef) {struct mt7996_dev *dev = phy->dev; -int err, region; +int err, region, rdd_idx =mt7996_get_rdd_idx (phy, true);if (!chandef) {/* disable offchain */ - err =mt7996_mcu_rdd_cmd (dev,RDD_STOP ,MT_RX_SEL2 , -0 ,0 ); + err =mt7996_mcu_rdd_cmd (dev,RDD_STOP , rdd_idx,0 );if (err)return err;
@@ -3466,8 +3471,7 @@ int mt7996_mcu_rdd_background_enable(struct mt7996_phy *phy,break ; } -return mt7996_mcu_rdd_cmd (dev,RDD_START ,MT_RX_SEL2 , -0 , region); +return mt7996_mcu_rdd_cmd (dev,RDD_START , rdd_idx, region); }int mt7996_mcu_set_chan_info (struct mt7996_phy *phy,u16 tag)
@@ -4333,8 +4337,7 @@ int mt7996_mcu_set_radio_en(struct mt7996_phy *phy, bool enable) &req, sizeof(req), true); } -int mt7996_mcu_rdd_cmd (struct mt7996_dev *dev,int cmd,u8 index, -u8 rx_sel,u8 val) +int mt7996_mcu_rdd_cmd (struct mt7996_dev *dev,int cmd,u8 rdd_idx,u8 val) {struct {u8 _rsv[4 ];
@@ -4351,8 +4354,7 @@ int mt7996_mcu_rdd_cmd(struct mt7996_dev *dev, int cmd, u8 index, .tag = cpu_to_le16(UNI_RDD_CTRL_PARM), .len = cpu_to_le16(sizeof(req) - 4), .ctrl = cmd, - .rdd_idx = index, - .rdd_rx_sel = rx_sel, + .rdd_idx = rdd_idx, .val = val, };
drivers/net/wireless/mediatek/mt76/mt7996/mcu.h +1 -1
@@ -69,7 +69,7 @@ struct mt7996_mcu_rdd_report {__le16 tag;__le16 len; -u8 band_idx; +u8 rdd_idx;u8 long_detected;u8 constant_prf_detected;u8 staggered_prf_detected;
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +20 -8
@@ -281,8 +281,6 @@ struct mt7996_phy {s16 coverage_class;u8 slottime; -u8 rdd_state; -u16 beacon_rate;u32 rx_ampdu_ts;
@@ -405,10 +403,10 @@ enum { __MT_WFDMA_MAX, }; -enum { -MT_RX_SEL0 , -MT_RX_SEL1 , -MT_RX_SEL2 ,/* monitor chain */ +enum rdd_idx { +MT_RDD_IDX_BAND2 ,/* RDD idx for band idx 2 */ +MT_RDD_IDX_BAND1 ,/* RDD idx for band idx 1 */ +MT_RDD_IDX_BACKGROUND ,/* RDD idx for background chain */ };enum mt7996_rdd_cmd {
@@ -427,6 +425,21 @@ enum mt7996_rdd_cmd { RDD_IRQ_OFF, }; +static inline int +mt7996_get_rdd_idx (struct mt7996_phy *phy,bool is_background) +{ +if (!phy->mt76->cap.has_5ghz) +return -1 ; + +if (is_background) +return MT_RDD_IDX_BACKGROUND ; + +if (phy->mt76->band_idx ==MT_BAND2 ) +return MT_RDD_IDX_BAND2 ; + +return MT_RDD_IDX_BAND1 ; +} +static inline struct mt7996_dev *mt7996_hw_dev (struct ieee80211_hw *hw) {
@@ -623,8 +636,7 @@ int mt7996_mcu_get_temperature(struct mt7996_phy *phy);int mt7996_mcu_set_thermal_throttling (struct mt7996_phy *phy,u8 state);int mt7996_mcu_set_thermal_protect (struct mt7996_phy *phy,bool enable);int mt7996_mcu_set_txpower_sku (struct mt7996_phy *phy); -int mt7996_mcu_rdd_cmd (struct mt7996_dev *dev,int cmd,u8 index, -u8 rx_sel,u8 val); +int mt7996_mcu_rdd_cmd (struct mt7996_dev *dev,int cmd,u8 rdd_idx,u8 val);int mt7996_mcu_rdd_background_enable (struct mt7996_phy *phy,struct cfg80211_chan_def *chandef); int mt7996_mcu_set_fixed_rate_table(struct mt7996_phy *phy, u8 table_idx,
Signature · 1 line
2.45.2