mt76: mt7915: update mt7986 patch in mt7986_wmac_adie_patch_7976()
Subsystems (2)
PATCH 1/4 mt76: mt7915: update mt7986 patch in mt7986_wmac_adie_patch_7976()
Update mt7976 adie patch for different adie version.
--- .../net/wireless/mediatek/mt76/mt7915/regs.h | 1 + .../net/wireless/mediatek/mt76/mt7915/soc.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/regs.h +1 -0
@@ -797,6 +797,7 @@ enum offs_rev {/* ADIE */ #define MT_ADIE_CHIP_ID 0x02c +#define MT_ADIE_VERSION_MASK GENMASK(15, 0)#define MT_ADIE_CHIP_ID_MASK GENMASK(31, 16)#define MT_ADIE_IDX0 GENMASK(15, 0)#define MT_ADIE_IDX1 GENMASK(31, 16)
drivers/net/wireless/mediatek/mt76/mt7915/soc.c +17 -2
@@ -470,17 +470,32 @@ static int mt7986_wmac_adie_xtal_trim_7976(struct mt7915_dev *dev, u8 adie)static int mt7986_wmac_adie_patch_7976 (struct mt7915_dev *dev,u8 adie) { +u32 id, version, rg_xo_01, rg_xo_03;int ret; + ret =mt76_wmac_spi_read (dev, adie,MT_ADIE_CHIP_ID , &id); +if (ret) +return ret; + + version =FIELD_GET (MT_ADIE_VERSION_MASK , id); + ret =mt76_wmac_spi_write (dev, adie,MT_ADIE_RG_TOP_THADC ,0x4a563b00 );if (ret)return ret; - ret =mt76_wmac_spi_write (dev, adie,MT_ADIE_RG_XO_01 ,0x1d59080f ); +if (version ==0x8a00 || version ==0x8a10 || version ==0x8b00 ) { + rg_xo_01 =0x1d59080f ; + rg_xo_03 =0x34c00fe0 ; + }else { + rg_xo_01 =0x1959f80f ; + rg_xo_03 =0x34d00fe0 ; + } + + ret =mt76_wmac_spi_write (dev, adie,MT_ADIE_RG_XO_01 , rg_xo_01);if (ret)return ret; -return mt76_wmac_spi_write (dev, adie,MT_ADIE_RG_XO_03 ,0x34c00fe0 ); +return mt76_wmac_spi_write (dev, adie,MT_ADIE_RG_XO_03 , rg_xo_03); } static int
Signature · 1 line
2.18.0
PATCH 2/4 mt76: mt7915: fix twt table_mask to u16 in mt7915_dev
mt7915 can support 16 twt stations so modify table_mask to u16.
--- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +1 -1
@@ -319,7 +319,7 @@ struct mt7915_dev {void *cal;struct { -u8 table_mask; +u16 table_mask;u8 n_agrt; } twt;
Signature · 1 line
2.18.0
PATCH 3/4 mt76: mt7915: reject duplicated twt flows
In reply to Peter ChiuReject twt flows with the same parameters to prevent some potential issues causing by duplicated establishment.
--- .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +31 -0
@@ -2601,6 +2601,34 @@ static int mt7915_mac_check_twt_req(struct ieee80211_twt_setup *twt)return 0 ; } +static inline bool +mt7915_mac_twt_param_equal (struct mt7915_sta *msta, +struct ieee80211_twt_params *twt_agrt) +{ +u16 type =le16_to_cpu (twt_agrt->req_type); +u8 exp; +int i; + + exp =FIELD_GET (IEEE80211_TWT_REQTYPE_WAKE_INT_EXP , type); +for (i =0 ; i <MT7915_MAX_STA_TWT_AGRT ; i++) { +struct mt7915_twt_flow *f; + +if (!(msta->twt.flowid_mask &BIT (i))) +continue ; + + f = &msta->twt.flow[i]; +if (f->duration == twt_agrt->min_twt_dur && + f->mantissa == twt_agrt->mantissa && + f->exp == exp && + f->protection == !!(type &IEEE80211_TWT_REQTYPE_PROTECTION ) && + f->flowtype == !!(type &IEEE80211_TWT_REQTYPE_FLOWTYPE ) && + f->trigger == !!(type &IEEE80211_TWT_REQTYPE_TRIGGER )) +return true; + } + +return false; +} +void mt7915_mac_add_twt_setup (struct ieee80211_hw *hw,struct ieee80211_sta *sta,struct ieee80211_twt_setup *twt)
@@ -2634,6 +2662,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, exp =FIELD_GET (IEEE80211_TWT_REQTYPE_WAKE_INT_EXP , req_type); sta_setup_cmd =FIELD_GET (IEEE80211_TWT_REQTYPE_SETUP_CMD , req_type); +if (mt7915_mac_twt_param_equal (msta, twt_agrt)) + goto unlock; + flow = &msta->twt.flow[flowid];memset (flow,0 ,sizeof (*flow));INIT_LIST_HEAD (&flow->list);
Signature · 1 line
2.18.0
Re: [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
Quoted 15 lines
Reject twt flows with the same parameters to prevent some potential issues causing by duplicated establishment.
Reviewed-by Ryder Lee <[email protected]>Reviewed-by Shayne Chen <[email protected]>Signed-off-by Peter Chiu <[email protected]>--- .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/net/wireless/mediatek/mt76/mt7915/mac.c +0
-0
drivers/net/wireless/mediatek/mt76/mt7915/mac.c static int mt7915_mac_check_twt_req(struct ieee80211_twt_setup *twt) · line 2606
Quoted 6 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +3
-0@@ -2601,6 +2601,34 @@ static int mt7915_mac_check_twt_req(struct ieee80211_twt_setup *twt)return 0 ; } +static inline bool +mt7915_mac_twt_param_equal (struct mt7915_sta *msta, +struct ieee80211_twt_params *twt_agrt)
nit: please do not use inline in .c files.
Regards,
Lorenzo
Quoted 41 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +28
-0+{ +u16 type =le16_to_cpu (twt_agrt->req_type); +u8 exp; +int i; + + exp =FIELD_GET (IEEE80211_TWT_REQTYPE_WAKE_INT_EXP , type); +for (i =0 ; i <MT7915_MAX_STA_TWT_AGRT ; i++) { +struct mt7915_twt_flow *f; + +if (!(msta->twt.flowid_mask &BIT (i))) +continue ; + + f = &msta->twt.flow[i]; +if (f->duration == twt_agrt->min_twt_dur && + f->mantissa == twt_agrt->mantissa && + f->exp == exp && + f->protection == !!(type &IEEE80211_TWT_REQTYPE_PROTECTION ) && + f->flowtype == !!(type &IEEE80211_TWT_REQTYPE_FLOWTYPE ) && + f->trigger == !!(type &IEEE80211_TWT_REQTYPE_TRIGGER )) +return true; + } + +return false; +} +void mt7915_mac_add_twt_setup (struct ieee80211_hw *hw,struct ieee80211_sta *sta,struct ieee80211_twt_setup *twt)@@ -2634,6 +2662,9 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, exp =FIELD_GET (IEEE80211_TWT_REQTYPE_WAKE_INT_EXP , req_type); sta_setup_cmd =FIELD_GET (IEEE80211_TWT_REQTYPE_SETUP_CMD , req_type); +if (mt7915_mac_twt_param_equal (msta, twt_agrt)) + goto unlock; + flow = &msta->twt.flow[flowid];memset (flow,0 ,sizeof (*flow));INIT_LIST_HEAD (&flow->list);Signature · 1 line
2.18.0
Felix Fietkau
maintainerRe: [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
Quoted 18 lines · Lorenzo Bianconi
Quoted 18 lines
Reject twt flows with the same parameters to prevent some potential issues causing by duplicated establishment.
Reviewed-by Ryder Lee <[email protected]>Reviewed-by Shayne Chen <[email protected]>Signed-off-by Peter Chiu <[email protected]>--- .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/net/wireless/mediatek/mt76/mt7915/mac.c +0
-0@@ -2601,6 +2601,34 @@ static int mt7915_mac_check_twt_req(struct ieee80211_twt_setup *twt)return 0 ; }
Quoted 5 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c static int mt7915_mac_check_twt_req(struct ieee80211_twt_setup *twt) · line 2606
Quoted 3 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +3
-0+static inline bool +mt7915_mac_twt_param_equal (struct mt7915_sta *msta, +struct ieee80211_twt_params *twt_agrt)nit: please do not use inline in .c files.
I applied the patch already, so I folded in a fix for this.
- Felix
PATCH 4/4 mt76: mt7915: limit minimum twt duration
In reply to Peter ChiuThe minimum twt duration supported by mt7915 is 64 according to hardware design. Reply station with TWT_SETUP_CMD_DICTATE if min_twt_dur smaller than 64.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +7 -0
@@ -2633,6 +2633,7 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,struct ieee80211_sta *sta, struct ieee80211_twt_setup *twt) { +#define MT7915_MIN_TWT_DUR 64 enum ieee80211_twt_setup_cmd setup_cmd = TWT_SETUP_CMD_REJECT;struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;struct ieee80211_twt_params *twt_agrt = (void *)twt->params;
@@ -2654,6 +2655,12 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,if (hweight8 (msta->twt.flowid_mask) ==ARRAY_SIZE (msta->twt.flow)) goto unlock; +if (twt_agrt->min_twt_dur <MT7915_MIN_TWT_DUR ) { + setup_cmd =TWT_SETUP_CMD_DICTATE ; + twt_agrt->min_twt_dur =MT7915_MIN_TWT_DUR ; + goto unlock; + } + flowid =ffs (~msta->twt.flowid_mask) -1 ;le16p_replace_bits (&twt_agrt->req_type, flowid,IEEE80211_TWT_REQTYPE_FLOWID );
Signature · 1 line
2.18.0
Re: [PATCH 4/4] mt76: mt7915: limit minimum twt duration
Quoted 14 lines
The minimum twt duration supported by mt7915 is 64 according to hardware design. Reply station with
TWT_SETUP_CMD_DICTATEifmin_twt_dursmaller than 64.Signed-off-by Peter Chiu <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/net/wireless/mediatek/mt76/mt7915/mac.c +0
-0
drivers/net/wireless/mediatek/mt76/mt7915/mac.c void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, · line 2636
Quoted 4 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +1
-0@@ -2633,6 +2633,7 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,struct ieee80211_sta *sta, struct ieee80211_twt_setup *twt) { +#define MT7915_MIN_TWT_DUR 64
nit: can you please move MT7915_MIN_TWT_DUR in mt7915.h since we have other twt defs there?
Regards,
Lorenzo
Quoted 19 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +6
-0enum ieee80211_twt_setup_cmd setup_cmd =TWT_SETUP_CMD_REJECT ;struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;struct ieee80211_twt_params *twt_agrt = (void *)twt->params;@@ -2654,6 +2655,12 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,if (hweight8 (msta->twt.flowid_mask) ==ARRAY_SIZE (msta->twt.flow)) goto unlock; +if (twt_agrt->min_twt_dur <MT7915_MIN_TWT_DUR ) { + setup_cmd =TWT_SETUP_CMD_DICTATE ; + twt_agrt->min_twt_dur =MT7915_MIN_TWT_DUR ; + goto unlock; + } + flowid =ffs (~msta->twt.flowid_mask) -1 ;le16p_replace_bits (&twt_agrt->req_type, flowid,IEEE80211_TWT_REQTYPE_FLOWID );Signature · 1 line
2.18.0
Felix Fietkau
maintainerRe: [PATCH 4/4] mt76: mt7915: limit minimum twt duration
Quoted 9 lines · Lorenzo Bianconi
Quoted 9 lines
The minimum twt duration supported by mt7915 is 64 according to hardware design. Reply station with
TWT_SETUP_CMD_DICTATEifmin_twt_dursmaller than 64.Signed-off-by Peter Chiu <[email protected]>--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 12 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw, · line 2636
Quoted 9 lines
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +1
-0@@ -2633,6 +2633,7 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,struct ieee80211_sta *sta, struct ieee80211_twt_setup *twt) { +#define MT7915_MIN_TWT_DUR 64nit: can you please move
MT7915_MIN_TWT_DURinmt7915.hsince we have other twt defs there?
Fixed in my tree.
- Felix