2020-04-21 05:24:13

by Sean Wang

[permalink] [raw]
Subject: [PATCH 1/3] mt76: mt7615: Fix up WMM setting for STA mode

From: Sean Wang <[email protected]>

Have to perform WMM setup until BSS become active according to firmware
usage. Otherwise, the current usage would break WMM setting in STA mode.

Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
Suggested-by: YF Luo <[email protected]>
Suggested-by: Soul Huang <[email protected]>
Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7615/main.c | 11 ++++++-
.../net/wireless/mediatek/mt76/mt7615/mcu.c | 32 ++++++++++++-------
.../wireless/mediatek/mt76/mt7615/mt7615.h | 10 ++++--
3 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
index 417903a8e2ec..cdc8babca85a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
@@ -424,7 +424,13 @@ mt7615_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,

queue += mvif->wmm_idx * MT7615_MAX_WMM_SETS;

- return mt7615_mcu_set_wmm(dev, queue, params);
+ /* Have to set wmm up until BSS become active */
+ mvif->wmm[queue].cw_min = params->cw_min;
+ mvif->wmm[queue].cw_max = params->cw_max;
+ mvif->wmm[queue].aifs = params->aifs;
+ mvif->wmm[queue].txop = params->txop;
+
+ return 0;
}

static void mt7615_configure_filter(struct ieee80211_hw *hw,
@@ -503,6 +509,9 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
}
}

+ if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
+ mt7615_mcu_set_wmm(dev, vif);
+
if (changed & BSS_CHANGED_BEACON_ENABLED) {
mt7615_mcu_add_bss_info(phy, vif, info->enable_beacon);
mt7615_mcu_sta_add(dev, vif, NULL, info->enable_beacon);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
index 8b543e8dadb8..045bde7f554d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
@@ -2269,8 +2269,7 @@ int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val)
&req, sizeof(req), true);
}

-int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
- const struct ieee80211_tx_queue_params *params)
+int mt7615_mcu_set_wmm(struct mt7615_dev *dev, struct ieee80211_vif *vif)
{
#define WMM_AIFS_SET BIT(0)
#define WMM_CW_MIN_SET BIT(1)
@@ -2289,21 +2288,30 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
__le16 txop;
} __packed req = {
.number = 1,
- .queue = queue,
.valid = WMM_PARAM_SET,
- .aifs = params->aifs,
.cw_min = 5,
.cw_max = cpu_to_le16(10),
- .txop = cpu_to_le16(params->txop),
};
+ struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
+ int ac, err;

- if (params->cw_min)
- req.cw_min = fls(params->cw_min);
- if (params->cw_max)
- req.cw_max = cpu_to_le16(fls(params->cw_max));
+ for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
+ req.queue = ac + mvif->wmm_idx * MT7615_MAX_WMM_SETS;
+ req.aifs = mvif->wmm[ac].aifs;
+ req.txop = cpu_to_le16(mvif->wmm[ac].txop);

- return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,
- &req, sizeof(req), true);
+ if (mvif->wmm[ac].cw_min)
+ req.cw_min = fls(mvif->wmm[ac].cw_min);
+ if (mvif->wmm[ac].cw_max)
+ req.cw_max = cpu_to_le16(fls(mvif->wmm[ac].cw_max));
+
+ err = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,
+ &req, sizeof(req), true);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
}

int mt7615_mcu_set_dbdc(struct mt7615_dev *dev)
@@ -3353,7 +3361,7 @@ void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
int i;

mt7615_mcu_set_bss_pm(phy->dev, vif, suspend);
-
+
mt7615_mcu_set_gtk_rekey(phy->dev, vif, suspend);

mt7615_mcu_set_suspend_mode(phy->dev, vif, suspend, 1, true);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
index 3e84c2dc0f93..ad37463a02d6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
@@ -152,6 +152,13 @@ struct mt7615_vif {
u8 scan_seq_num;

struct mt7615_sta sta;
+
+ struct {
+ u16 cw_min;
+ u16 cw_max;
+ u16 txop;
+ u8 aifs;
+ } wmm[IEEE80211_NUM_ACS];
};

struct mib_stats {
@@ -386,8 +393,7 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
struct ieee80211_tx_rate *rates);
int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);
int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd);
-int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
- const struct ieee80211_tx_queue_params *params);
+int mt7615_mcu_set_wmm(struct mt7615_dev *dev, struct ieee80211_vif *vif);
void mt7615_mcu_rx_event(struct mt7615_dev *dev, struct sk_buff *skb);
int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev,
enum mt7615_rdd_cmd cmd, u8 index,
--
2.25.1


2020-04-21 05:24:13

by Sean Wang

[permalink] [raw]
Subject: [PATCH 2/3] mt76: mt7615: add missing code for providing aid info to the mcu

From: Sean Wang <[email protected]>

Parameters in station record should be kept as up to date as BSS being
updated.

Fixes: a90b4ba1f134 ("mt76: mt7615: provide aid info to the mcu")
Suggested-by: YF Luo <[email protected]>
Suggested-by: Lucy Hsu <[email protected]>
Co-developed-by: Soul Huang <[email protected]>
Signed-off-by: Soul Huang <[email protected]>
Co-developed-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7615/main.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
index cdc8babca85a..e5012ad680bb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
@@ -497,9 +497,19 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,

mutex_lock(&dev->mt76.mutex);

- if (changed & BSS_CHANGED_ASSOC)
+ if (changed & BSS_CHANGED_ASSOC) {
+ struct ieee80211_sta *sta;
+
mt7615_mcu_add_bss_info(phy, vif, info->assoc);

+ rcu_read_lock();
+ sta = ieee80211_find_sta(vif, vif->bss_conf.bssid);
+ rcu_read_unlock();
+
+ if (sta)
+ mt7615_mcu_sta_add(dev, vif, sta, info->assoc);
+ }
+
if (changed & BSS_CHANGED_ERP_SLOT) {
int slottime = info->use_short_slot ? 9 : 20;

@@ -557,7 +567,8 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
mt7615_mac_wtbl_update(dev, idx,
MT_WTBL_UPDATE_ADM_COUNT_CLEAR);

- mt7615_mcu_sta_add(dev, vif, sta, true);
+ if (vif->type != NL80211_IFTYPE_STATION)
+ mt7615_mcu_sta_add(dev, vif, sta, true);

return 0;
}
--
2.25.1

2020-04-21 05:59:04

by Ryder Lee

[permalink] [raw]
Subject: Re: [PATCH 2/3] mt76: mt7615: add missing code for providing aid info to the mcu

On Tue, 2020-04-21 at 13:20 +0800, [email protected] wrote:
> From: Sean Wang <[email protected]>
>
> Parameters in station record should be kept as up to date as BSS being
> updated.
>
> Fixes: a90b4ba1f134 ("mt76: mt7615: provide aid info to the mcu")
> Suggested-by: YF Luo <[email protected]>
> Suggested-by: Lucy Hsu <[email protected]>
> Co-developed-by: Soul Huang <[email protected]>
> Signed-off-by: Soul Huang <[email protected]>
> Co-developed-by: Lorenzo Bianconi <[email protected]>
> Signed-off-by: Lorenzo Bianconi <[email protected]>
> Signed-off-by: Sean Wang <[email protected]>
> ---
> drivers/net/wireless/mediatek/mt76/mt7615/main.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
> index cdc8babca85a..e5012ad680bb 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
> @@ -497,9 +497,19 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
>
> mutex_lock(&dev->mt76.mutex);
>
> - if (changed & BSS_CHANGED_ASSOC)
> + if (changed & BSS_CHANGED_ASSOC) {
> + struct ieee80211_sta *sta;
> +
> mt7615_mcu_add_bss_info(phy, vif, info->assoc);
>
> + rcu_read_lock();
> + sta = ieee80211_find_sta(vif, vif->bss_conf.bssid);
> + rcu_read_unlock();
> +
> + if (sta)
> + mt7615_mcu_sta_add(dev, vif, sta, info->assoc);
> + }
> +
how about this -
https://github.com/ryderlee1110/wireless/blob/mt76/drivers/net/wireless/mediatek/mt76/mt7915/main.c#L434

> if (changed & BSS_CHANGED_ERP_SLOT) {
> int slottime = info->use_short_slot ? 9 : 20;
>
> @@ -557,7 +567,8 @@ int mt7615_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
> mt7615_mac_wtbl_update(dev, idx,
> MT_WTBL_UPDATE_ADM_COUNT_CLEAR);
>
> - mt7615_mcu_sta_add(dev, vif, sta, true);
> + if (vif->type != NL80211_IFTYPE_STATION)
> + mt7615_mcu_sta_add(dev, vif, sta, true);
>
> return 0;
> }

2020-04-21 07:24:14

by Felix Fietkau

[permalink] [raw]
Subject: Re: [PATCH 2/3] mt76: mt7615: add missing code for providing aid info to the mcu

On 2020-04-21 07:20, [email protected] wrote:
> From: Sean Wang <[email protected]>
>
> Parameters in station record should be kept as up to date as BSS being
> updated.
Why do we need this change? Johannes posted a mac80211 change that makes
the aid available at the time the station entry is created.

- Felix

2020-04-21 12:33:30

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH 1/3] mt76: mt7615: Fix up WMM setting for STA mode

> From: Sean Wang <[email protected]>
>
> Have to perform WMM setup until BSS become active according to firmware
> usage. Otherwise, the current usage would break WMM setting in STA mode.
>
> Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets")
> Suggested-by: YF Luo <[email protected]>
> Suggested-by: Soul Huang <[email protected]>
> Co-developed-by: Ryder Lee <[email protected]>
> Signed-off-by: Ryder Lee <[email protected]>
> Signed-off-by: Sean Wang <[email protected]>
> ---
> .../net/wireless/mediatek/mt76/mt7615/main.c | 11 ++++++-
> .../net/wireless/mediatek/mt76/mt7615/mcu.c | 32 ++++++++++++-------
> .../wireless/mediatek/mt76/mt7615/mt7615.h | 10 ++++--
> 3 files changed, 38 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
> index 417903a8e2ec..cdc8babca85a 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
> @@ -424,7 +424,13 @@ mt7615_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
>
> queue += mvif->wmm_idx * MT7615_MAX_WMM_SETS;
>
> - return mt7615_mcu_set_wmm(dev, queue, params);
> + /* Have to set wmm up until BSS become active */
> + mvif->wmm[queue].cw_min = params->cw_min;
> + mvif->wmm[queue].cw_max = params->cw_max;
> + mvif->wmm[queue].aifs = params->aifs;
> + mvif->wmm[queue].txop = params->txop;

Hi Sean,

I think we can reuse ieee80211_tx_queue_params here since we are adding the
same fields.

> +
> + return 0;
> }
>
> static void mt7615_configure_filter(struct ieee80211_hw *hw,
> @@ -503,6 +509,9 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
> }
> }
>
> + if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED))
> + mt7615_mcu_set_wmm(dev, vif);
> +
> if (changed & BSS_CHANGED_BEACON_ENABLED) {
> mt7615_mcu_add_bss_info(phy, vif, info->enable_beacon);
> mt7615_mcu_sta_add(dev, vif, NULL, info->enable_beacon);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> index 8b543e8dadb8..045bde7f554d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
> @@ -2269,8 +2269,7 @@ int mt7615_mcu_set_rts_thresh(struct mt7615_phy *phy, u32 val)
> &req, sizeof(req), true);
> }
>
> -int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
> - const struct ieee80211_tx_queue_params *params)
> +int mt7615_mcu_set_wmm(struct mt7615_dev *dev, struct ieee80211_vif *vif)

If we add someting like "mt7615_apply_wmm_parameters()" in main.c we can reuse the
current code

> {
> #define WMM_AIFS_SET BIT(0)
> #define WMM_CW_MIN_SET BIT(1)
> @@ -2289,21 +2288,30 @@ int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
> __le16 txop;
> } __packed req = {
> .number = 1,
> - .queue = queue,
> .valid = WMM_PARAM_SET,
> - .aifs = params->aifs,
> .cw_min = 5,
> .cw_max = cpu_to_le16(10),
> - .txop = cpu_to_le16(params->txop),
> };
> + struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
> + int ac, err;
>
> - if (params->cw_min)
> - req.cw_min = fls(params->cw_min);
> - if (params->cw_max)
> - req.cw_max = cpu_to_le16(fls(params->cw_max));
> + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
> + req.queue = ac + mvif->wmm_idx * MT7615_MAX_WMM_SETS;
> + req.aifs = mvif->wmm[ac].aifs;
> + req.txop = cpu_to_le16(mvif->wmm[ac].txop);
>
> - return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,
> - &req, sizeof(req), true);
> + if (mvif->wmm[ac].cw_min)
> + req.cw_min = fls(mvif->wmm[ac].cw_min);
> + if (mvif->wmm[ac].cw_max)
> + req.cw_max = cpu_to_le16(fls(mvif->wmm[ac].cw_max));
> +
> + err = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EDCA_UPDATE,
> + &req, sizeof(req), true);
> + if (err < 0)
> + return err;
> + }
> +
> + return 0;
> }
>
> int mt7615_mcu_set_dbdc(struct mt7615_dev *dev)
> @@ -3353,7 +3361,7 @@ void mt7615_mcu_set_suspend_iter(void *priv, u8 *mac,
> int i;
>
> mt7615_mcu_set_bss_pm(phy->dev, vif, suspend);
> -
> +
> mt7615_mcu_set_gtk_rekey(phy->dev, vif, suspend);

I have not sent this patch yet :)

>
> mt7615_mcu_set_suspend_mode(phy->dev, vif, suspend, 1, true);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
> index 3e84c2dc0f93..ad37463a02d6 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
> @@ -152,6 +152,13 @@ struct mt7615_vif {
> u8 scan_seq_num;
>
> struct mt7615_sta sta;
> +
> + struct {
> + u16 cw_min;
> + u16 cw_max;
> + u16 txop;
> + u8 aifs;
> + } wmm[IEEE80211_NUM_ACS];

something like ieee80211_tx_queue_params wmm[IEEE80211_NUM_ACS]

> };
>
> struct mib_stats {
> @@ -386,8 +393,7 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
> struct ieee80211_tx_rate *rates);
> int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);
> int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd);
> -int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
> - const struct ieee80211_tx_queue_params *params);
> +int mt7615_mcu_set_wmm(struct mt7615_dev *dev, struct ieee80211_vif *vif);
> void mt7615_mcu_rx_event(struct mt7615_dev *dev, struct sk_buff *skb);
> int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev,
> enum mt7615_rdd_cmd cmd, u8 index,
> --
> 2.25.1


Attachments:
(No filename) (5.64 kB)
signature.asc (235.00 B)
Download all attachments