> From: Sean Wang > > 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 > Suggested-by: Soul Huang > Co-developed-by: Ryder Lee > Signed-off-by: Ryder Lee > Signed-off-by: Sean Wang > --- > .../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