From patchwork Tue Apr 21 05:20:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 11500477 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA7F1159A for ; Tue, 21 Apr 2020 05:20:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE400214AF for ; Tue, 21 Apr 2020 05:20:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="Gpzlicv3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726017AbgDUFUi (ORCPT ); Tue, 21 Apr 2020 01:20:38 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:3102 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725730AbgDUFUh (ORCPT ); Tue, 21 Apr 2020 01:20:37 -0400 X-UUID: eec92d6cd007435fb1d25157dcb48cf6-20200421 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=5XC0Ao1cIps8tVn+BctDx6S5LvFaIEhA9tJXzNUL478=; b=Gpzlicv3FosIwHe7MJXRw53/0D/FiO8xH67LkLwacq/XDDbHcxGW0iLE0zL5dV6TMMc3c1RoCAHpkNT6FhWrGcJW1Gm0ED5Kf+Q8UMvhbFoNAPZOmpFqIfdyGmBBzAkxoe/0Jpa/GZ6Hdn5d/UlPEyvGpakJcTnhObJHcimLS0Q=; X-UUID: eec92d6cd007435fb1d25157dcb48cf6-20200421 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1498140609; Tue, 21 Apr 2020 13:20:32 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 21 Apr 2020 13:20:27 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 21 Apr 2020 13:20:26 +0800 From: To: , CC: , , , Subject: [PATCH 1/3] mt76: mt7615: Fix up WMM setting for STA mode Date: Tue, 21 Apr 2020 13:20:21 +0800 Message-ID: <1467d47fd111b5711fa74410833153bdc9e01b72.1587445885.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-TM-SNTS-SMTP: 10B04FC7E3FA56E85C2CB57171A57B36D63EF18D6CFE344ED1875DFC912767042000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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; + + 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,