Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3645974pxb; Mon, 24 Jan 2022 14:18:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJypdspV6iZ9/cDxpcTTux0fg3upe5qPpEjeiNX2RIyraEqcyGqso0ZsOXRTM1CXRNmUHjBu X-Received: by 2002:a05:6a00:16cc:b0:4bf:3782:22e3 with SMTP id l12-20020a056a0016cc00b004bf378222e3mr15539151pfc.52.1643062734124; Mon, 24 Jan 2022 14:18:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062734; cv=none; d=google.com; s=arc-20160816; b=V8UAijlcFm7s5+wnVBHETgmB8C1PKGy7gA0d+a3ajGQuCKkv9b5bYqDXCCl1zzuYxL xRQNA9VtsdgQ+S84DjCdC2hEy1f/edRjJoZyuyY7K5DRzye3fAQt7MrdVhyIIZY9mlFC 0YK7/3oEIicbM3HgJUXLqz64U+mLJ8jBjyKUob6WpymSPOKTIUryLltg0Qk/cFRaUYUf pEgElIeMBvOwOaxpzZbZrpewrVVaYU6650gipV4pwsI38kEOzdrGe7TznjyDiCuzplZX SM9BXXXNCixFj5X91a+hL/QZV7jwDw4c5i6IEQ0019jT43gOWzIIBovFzhXUZQc6e8RU 2zPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/XuIrRP+/IkzuCjT0TnwJpHFepx5QM5nOOZTHhXr7bM=; b=Cp9LcphpIHK2N7mw3rBIJ/OZ0uvFx/w5UWR4B8Q2si3V0vSmY0kQaMLoFSgo/51UAp usA3kQQ2pxYt1t5L8zpe9D0pNsXHPxY5orcxsE9Tj38zXVOrZBa2G7kBRBjfY1jeMtLA GWd6XT3i/FPqMuczFcs2pcfvb+j1cQoARWqVspBAgpMRecCvVdmlSILR/YLr/4Rhxv5+ eePx+fIMWDMJOjDkEd/ZlRmTyg7c4O0Al+H6yJaAi75XiKdNyjPWmwCsZY7VQVuXy61/ IT+P7fzQy1bdEigpGBzq/RRcjQNA+6P01G328mT5Kwvpj2gEpH1lmAIdjertOJ21ZNZ2 60KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="tTry/dca"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q22si1277716pfk.45.2022.01.24.14.18.29; Mon, 24 Jan 2022 14:18:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="tTry/dca"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1581545AbiAXWL7 (ORCPT + 99 others); Mon, 24 Jan 2022 17:11:59 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:46944 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1452815AbiAXV0l (ORCPT ); Mon, 24 Jan 2022 16:26:41 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E6D1560C60; Mon, 24 Jan 2022 21:26:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4675C340E4; Mon, 24 Jan 2022 21:26:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059598; bh=ziNTfB6MFkrrpKUiqMSsH39v3XYf+3hqHdG+XYLv7Ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tTry/dcazDUc616yY3zyuh1J/dRMC+6QeQC1+Tl/n89SvpWGyBLDJgLfIFbkmqWEA UPUnypGa2+m/VojYc6g/G0UmEo8+/BwU4LSIoQLr5Gkl6rr3Vt2Eag9wgYzDfRlr5S Obnim2d+bJfN6sXQC4/oVW10DMrud2QCwPTZIzJs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fang Zhao , Ryder Lee , Felix Fietkau , Sasha Levin Subject: [PATCH 5.16 0670/1039] mt76: mt7915: fix SMPS operation fail Date: Mon, 24 Jan 2022 19:40:59 +0100 Message-Id: <20220124184147.893810432@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ryder Lee [ Upstream commit 8f05835425ce3f669e4b6d7c2c39a9aa22e1506c ] TGn fails sending SM power save mode action frame to the AP to switch from dynamic SMPS mode to static mode. Reported-by: Fang Zhao Signed-off-by: Fang Zhao Signed-off-by: Ryder Lee Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 81 ++++++++++++------- .../net/wireless/mediatek/mt76/mt7915/mcu.h | 8 ++ 2 files changed, 61 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 852d5d97c70b1..8215b3d79bbdc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -1752,33 +1752,6 @@ int mt7915_mcu_sta_update_hdr_trans(struct mt7915_dev *dev, true); } -int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; - struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; - struct wtbl_req_hdr *wtbl_hdr; - struct tlv *sta_wtbl; - struct sk_buff *skb; - - skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, - MT7915_STA_UPDATE_MAX_SIZE); - if (IS_ERR(skb)) - return PTR_ERR(skb); - - sta_wtbl = mt7915_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv)); - - wtbl_hdr = mt7915_mcu_alloc_wtbl_req(dev, msta, WTBL_SET, sta_wtbl, - &skb); - if (IS_ERR(wtbl_hdr)) - return PTR_ERR(wtbl_hdr); - - mt7915_mcu_wtbl_smps_tlv(skb, sta, sta_wtbl, wtbl_hdr); - - return mt76_mcu_skb_send_msg(&dev->mt76, skb, - MCU_EXT_CMD(STA_REC_UPDATE), true); -} - static inline bool mt7915_is_ebf_supported(struct mt7915_phy *phy, struct ieee80211_vif *vif, struct ieee80211_sta *sta, bool bfee) @@ -2049,6 +2022,21 @@ mt7915_mcu_sta_bfee_tlv(struct mt7915_dev *dev, struct sk_buff *skb, bfee->fb_identity_matrix = (nrow == 1 && tx_ant == 2); } +static enum mcu_mmps_mode +mt7915_mcu_get_mmps_mode(enum ieee80211_smps_mode smps) +{ + switch (smps) { + case IEEE80211_SMPS_OFF: + return MCU_MMPS_DISABLE; + case IEEE80211_SMPS_STATIC: + return MCU_MMPS_STATIC; + case IEEE80211_SMPS_DYNAMIC: + return MCU_MMPS_DYNAMIC; + default: + return MCU_MMPS_DISABLE; + } +} + int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, struct ieee80211_vif *vif, struct ieee80211_sta *sta, @@ -2076,7 +2064,11 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, case RATE_PARAM_FIXED_MCS: case RATE_PARAM_FIXED_GI: case RATE_PARAM_FIXED_HE_LTF: - ra->phy = *phy; + if (phy) + ra->phy = *phy; + break; + case RATE_PARAM_MMPS_UPDATE: + ra->mmps_mode = mt7915_mcu_get_mmps_mode(sta->smps_mode); break; default: break; @@ -2087,6 +2079,39 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev, MCU_EXT_CMD(STA_REC_UPDATE), true); } +int mt7915_mcu_add_smps(struct mt7915_dev *dev, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct mt7915_vif *mvif = (struct mt7915_vif *)vif->drv_priv; + struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; + struct wtbl_req_hdr *wtbl_hdr; + struct tlv *sta_wtbl; + struct sk_buff *skb; + int ret; + + skb = mt7915_mcu_alloc_sta_req(dev, mvif, msta, + MT7915_STA_UPDATE_MAX_SIZE); + if (IS_ERR(skb)) + return PTR_ERR(skb); + + sta_wtbl = mt7915_mcu_add_tlv(skb, STA_REC_WTBL, sizeof(struct tlv)); + + wtbl_hdr = mt7915_mcu_alloc_wtbl_req(dev, msta, WTBL_SET, sta_wtbl, + &skb); + if (IS_ERR(wtbl_hdr)) + return PTR_ERR(wtbl_hdr); + + mt7915_mcu_wtbl_smps_tlv(skb, sta, sta_wtbl, wtbl_hdr); + + ret = mt76_mcu_skb_send_msg(&dev->mt76, skb, + MCU_EXT_CMD(STA_REC_UPDATE), true); + if (ret) + return ret; + + return mt7915_mcu_set_fixed_rate_ctrl(dev, vif, sta, NULL, + RATE_PARAM_MMPS_UPDATE); +} + static int mt7915_mcu_add_rate_ctrl_fixed(struct mt7915_dev *dev, struct ieee80211_vif *vif, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h index 1f5a64ba9b59d..628e90d0c394e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h @@ -365,6 +365,13 @@ enum { MCU_PHY_STATE_OFDMLQ_CNINFO, }; +enum mcu_mmps_mode { + MCU_MMPS_STATIC, + MCU_MMPS_DYNAMIC, + MCU_MMPS_RSV, + MCU_MMPS_DISABLE, +}; + #define STA_TYPE_STA BIT(0) #define STA_TYPE_AP BIT(1) #define STA_TYPE_ADHOC BIT(2) @@ -960,6 +967,7 @@ struct sta_rec_ra_fixed { enum { RATE_PARAM_FIXED = 3, + RATE_PARAM_MMPS_UPDATE = 5, RATE_PARAM_FIXED_HE_LTF = 7, RATE_PARAM_FIXED_MCS, RATE_PARAM_FIXED_GI = 11, -- 2.34.1