* [PATCH 1/4] mt76: mt7915: update mt7986 patch in mt7986_wmac_adie_patch_7976()
@ 2022-05-05 8:25 ` Peter Chiu
0 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
Update mt7976 adie patch for different adie version.
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7915/regs.h | 1 +
.../net/wireless/mediatek/mt76/mt7915/soc.c | 19 +++++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
index bac76bc2770f..338dfbee0f93 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
@@ -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)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
index 04e62d569599..c418b5dfda7f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
@@ -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
--
2.18.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 1/4] mt76: mt7915: update mt7986 patch in mt7986_wmac_adie_patch_7976()
@ 2022-05-05 8:25 ` Peter Chiu
0 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
Update mt7976 adie patch for different adie version.
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7915/regs.h | 1 +
.../net/wireless/mediatek/mt76/mt7915/soc.c | 19 +++++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
index bac76bc2770f..338dfbee0f93 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h
@@ -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)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
index 04e62d569599..c418b5dfda7f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/soc.c
@@ -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
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/4] mt76: mt7915: fix twt table_mask to u16 in mt7915_dev
2022-05-05 8:25 ` Peter Chiu
@ 2022-05-05 8:25 ` Peter Chiu
-1 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
mt7915 can support 16 twt stations so modify table_mask to u16.
Fixes: 3782b69d03e7 ("mt76: mt7915: introduce mt7915_mac_add_twt_setup routine")
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 6c590eff14f1..0f51d7657caf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -319,7 +319,7 @@ struct mt7915_dev {
void *cal;
struct {
- u8 table_mask;
+ u16 table_mask;
u8 n_agrt;
} twt;
--
2.18.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/4] mt76: mt7915: fix twt table_mask to u16 in mt7915_dev
@ 2022-05-05 8:25 ` Peter Chiu
0 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
mt7915 can support 16 twt stations so modify table_mask to u16.
Fixes: 3782b69d03e7 ("mt76: mt7915: introduce mt7915_mac_add_twt_setup routine")
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 6c590eff14f1..0f51d7657caf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -319,7 +319,7 @@ struct mt7915_dev {
void *cal;
struct {
- u8 table_mask;
+ u16 table_mask;
u8 n_agrt;
} twt;
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
2022-05-05 8:25 ` Peter Chiu
@ 2022-05-05 8:25 ` Peter Chiu
-1 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
Reject twt flows with the same parameters to prevent some potential issues
causing by duplicated establishment.
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 94a1871fbf43..ff60a3d2d26d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -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);
--
2.18.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
@ 2022-05-05 8:25 ` Peter Chiu
0 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
Reject twt flows with the same parameters to prevent some potential issues
causing by duplicated establishment.
Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 94a1871fbf43..ff60a3d2d26d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -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);
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/4] mt76: mt7915: limit minimum twt duration
2022-05-05 8:25 ` Peter Chiu
@ 2022-05-05 8:25 ` Peter Chiu
-1 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
The 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.
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index ff60a3d2d26d..e912ecacb578 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -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);
--
2.18.0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/4] mt76: mt7915: limit minimum twt duration
@ 2022-05-05 8:25 ` Peter Chiu
0 siblings, 0 replies; 16+ messages in thread
From: Peter Chiu @ 2022-05-05 8:25 UTC (permalink / raw)
To: Felix Fietkau
Cc: Lorenzo Bianconi, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek, Peter Chiu
The 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.
Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index ff60a3d2d26d..e912ecacb578 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -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);
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
2022-05-05 8:25 ` Peter Chiu
@ 2022-05-05 12:22 ` Lorenzo Bianconi
-1 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2022-05-05 12:22 UTC (permalink / raw)
To: Peter Chiu
Cc: Felix Fietkau, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek
[-- Attachment #1.1: Type: text/plain, Size: 2310 bytes --]
> Reject twt flows with the same parameters to prevent some potential issues
> causing by duplicated establishment.
>
> Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
> Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
> ---
> .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index 94a1871fbf43..ff60a3d2d26d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -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
> +{
> + 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);
> --
> 2.18.0
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
@ 2022-05-05 12:22 ` Lorenzo Bianconi
0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2022-05-05 12:22 UTC (permalink / raw)
To: Peter Chiu
Cc: Felix Fietkau, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]
> Reject twt flows with the same parameters to prevent some potential issues
> causing by duplicated establishment.
>
> Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
> Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
> ---
> .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index 94a1871fbf43..ff60a3d2d26d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -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
> +{
> + 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);
> --
> 2.18.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/4] mt76: mt7915: limit minimum twt duration
2022-05-05 8:25 ` Peter Chiu
@ 2022-05-05 12:23 ` Lorenzo Bianconi
-1 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2022-05-05 12:23 UTC (permalink / raw)
To: Peter Chiu
Cc: Felix Fietkau, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek
[-- Attachment #1: Type: text/plain, Size: 1649 bytes --]
> The 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.
>
> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index ff60a3d2d26d..e912ecacb578 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -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
> 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);
> --
> 2.18.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/4] mt76: mt7915: limit minimum twt duration
@ 2022-05-05 12:23 ` Lorenzo Bianconi
0 siblings, 0 replies; 16+ messages in thread
From: Lorenzo Bianconi @ 2022-05-05 12:23 UTC (permalink / raw)
To: Peter Chiu
Cc: Felix Fietkau, Ryder Lee, Evelyn Tsai, Shayne Chen,
linux-wireless, linux-mediatek
[-- Attachment #1.1: Type: text/plain, Size: 1649 bytes --]
> The 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.
>
> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
> ---
> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> index ff60a3d2d26d..e912ecacb578 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
> @@ -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
> 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);
> --
> 2.18.0
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
2022-05-05 12:22 ` Lorenzo Bianconi
@ 2022-05-05 12:26 ` Felix Fietkau
-1 siblings, 0 replies; 16+ messages in thread
From: Felix Fietkau @ 2022-05-05 12:26 UTC (permalink / raw)
To: Lorenzo Bianconi, Peter Chiu
Cc: Ryder Lee, Evelyn Tsai, Shayne Chen, linux-wireless, linux-mediatek
On 05.05.22 14:22, Lorenzo Bianconi wrote:
>> Reject twt flows with the same parameters to prevent some potential issues
>> causing by duplicated establishment.
>>
>> Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
>> Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
>> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
>> ---
>> .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++
>> 1 file changed, 31 insertions(+)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> index 94a1871fbf43..ff60a3d2d26d 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> @@ -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.
I applied the patch already, so I folded in a fix for this.
- Felix
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/4] mt76: mt7915: reject duplicated twt flows
@ 2022-05-05 12:26 ` Felix Fietkau
0 siblings, 0 replies; 16+ messages in thread
From: Felix Fietkau @ 2022-05-05 12:26 UTC (permalink / raw)
To: Lorenzo Bianconi, Peter Chiu
Cc: Ryder Lee, Evelyn Tsai, Shayne Chen, linux-wireless, linux-mediatek
On 05.05.22 14:22, Lorenzo Bianconi wrote:
>> Reject twt flows with the same parameters to prevent some potential issues
>> causing by duplicated establishment.
>>
>> Reviewed-by: Ryder Lee <ryder.lee@mediatek.com>
>> Reviewed-by: Shayne Chen <shayne.chen@mediatek.com>
>> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
>> ---
>> .../net/wireless/mediatek/mt76/mt7915/mac.c | 31 +++++++++++++++++++
>> 1 file changed, 31 insertions(+)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> index 94a1871fbf43..ff60a3d2d26d 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> @@ -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.
I applied the patch already, so I folded in a fix for this.
- Felix
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/4] mt76: mt7915: limit minimum twt duration
2022-05-05 12:23 ` Lorenzo Bianconi
@ 2022-05-05 12:28 ` Felix Fietkau
-1 siblings, 0 replies; 16+ messages in thread
From: Felix Fietkau @ 2022-05-05 12:28 UTC (permalink / raw)
To: Lorenzo Bianconi, Peter Chiu
Cc: Ryder Lee, Evelyn Tsai, Shayne Chen, linux-wireless, linux-mediatek
On 05.05.22 14:23, Lorenzo Bianconi wrote:
>> The 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.
>>
>> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
>> ---
>> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> index ff60a3d2d26d..e912ecacb578 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> @@ -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?
Fixed in my tree.
- Felix
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/4] mt76: mt7915: limit minimum twt duration
@ 2022-05-05 12:28 ` Felix Fietkau
0 siblings, 0 replies; 16+ messages in thread
From: Felix Fietkau @ 2022-05-05 12:28 UTC (permalink / raw)
To: Lorenzo Bianconi, Peter Chiu
Cc: Ryder Lee, Evelyn Tsai, Shayne Chen, linux-wireless, linux-mediatek
On 05.05.22 14:23, Lorenzo Bianconi wrote:
>> The 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.
>>
>> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
>> ---
>> drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> index ff60a3d2d26d..e912ecacb578 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
>> @@ -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?
Fixed in my tree.
- Felix
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-05-05 12:28 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 8:25 [PATCH 1/4] mt76: mt7915: update mt7986 patch in mt7986_wmac_adie_patch_7976() Peter Chiu
2022-05-05 8:25 ` Peter Chiu
2022-05-05 8:25 ` [PATCH 2/4] mt76: mt7915: fix twt table_mask to u16 in mt7915_dev Peter Chiu
2022-05-05 8:25 ` Peter Chiu
2022-05-05 8:25 ` [PATCH 3/4] mt76: mt7915: reject duplicated twt flows Peter Chiu
2022-05-05 8:25 ` Peter Chiu
2022-05-05 12:22 ` Lorenzo Bianconi
2022-05-05 12:22 ` Lorenzo Bianconi
2022-05-05 12:26 ` Felix Fietkau
2022-05-05 12:26 ` Felix Fietkau
2022-05-05 8:25 ` [PATCH 4/4] mt76: mt7915: limit minimum twt duration Peter Chiu
2022-05-05 8:25 ` Peter Chiu
2022-05-05 12:23 ` Lorenzo Bianconi
2022-05-05 12:23 ` Lorenzo Bianconi
2022-05-05 12:28 ` Felix Fietkau
2022-05-05 12:28 ` Felix Fietkau
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.