Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13997528pxu; Mon, 4 Jan 2021 10:03:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTsx29kZZIQtV+D2+qfAyYNez1X/DBvq3WFmYqCD0yDwppDtetZ6sDECljcYmIBmPlcSWD X-Received: by 2002:a17:906:fb1a:: with SMTP id lz26mr67252680ejb.194.1609783422987; Mon, 04 Jan 2021 10:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609783422; cv=none; d=google.com; s=arc-20160816; b=RexciVi1legt+zZZfYKsQ4Q7Qgy60uMJuORVPi8OO0Vj47g5mc7DmHsrrWUzujBQay Nsqi/4o1yqSzpOnzZaap1rYprSZBxt+Y0TM0wFfbNR7kph5Ml+mBNcCeE2wTQTtAlAJ6 U/OGqZO3LhkZWAYKhOGsASvzfqjp8DNzXiC9GboDLFPp98Xz5qdr+JDQqlI8TcnR0jri 4mZAYI74gfQoeRizgYoB6m09mPzgQ3Pc2OUvyVcBRy/stse2mOcNZyAJM7C7MUDNsA00 ZthyM1vC0dJLu90g5V380fVdm3xI9Br+3gAA0Qv+rL8esQJLSpPVH9bsmYyV9Hs1Rhh/ rZig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zQg6b3Z0Bxvy2fwrx2txFg7Ll2JvTjQehvbWNbCyuwc=; b=DLlO5b+lxqlOayY/swO2zm4ZmAKYAaqZlZbxQ+v0rD56A+FJGP4Kh/CdXfzJSM27Wg T5ynVzzGcPauUbp0a/CuFgEDwZMw4JGPSHON3KvyVlU8sgIMme8f5DA6myeOz8VIoQYA ynd1igICMcnDG1ieSw2cXti54poBeMEjlZ0h8dA2RawpqLnrzn0vORXJtWQkMxLQPoC0 FvReLFjCBtx0Q0emeZXnB0vNIbgeKjjCMy+Bsl1/ajX95WxG2DGHgImYjAVf+TMi7zCQ PxNcmiwCXHueE4lYYeD0U7J+7gmB/mq+tRZR4V8A/CAiL8h2AnLE3j2Zqu40QJKj5Ikw kcSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr21si30789539ejc.446.2021.01.04.10.03.20; Mon, 04 Jan 2021 10:03:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727217AbhADSBo (ORCPT + 99 others); Mon, 4 Jan 2021 13:01:44 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:33101 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726072AbhADSBo (ORCPT ); Mon, 4 Jan 2021 13:01:44 -0500 X-UUID: ca65faf077274757ada618468d292b43-20210105 X-UUID: ca65faf077274757ada618468d292b43-20210105 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1769995441; Tue, 05 Jan 2021 02:00:24 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 5 Jan 2021 02:00:22 +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, 5 Jan 2021 02:00:22 +0800 From: To: , CC: , , , , , , , , , , Lorenzo Bianconi Subject: [PATCH -next v5 12/15] mt76: mt7921: introduce 802.11 PS support in sta mode Date: Tue, 5 Jan 2021 02:00:16 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 4AD92DE587271B366A083A8AD8E3D63A36979B79EE6382F62C23F7DD18B2B6942000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Enable 802.11 power-save support available in mt7921 firmware Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Co-developed-by: Soul Huang Signed-off-by: Soul Huang Signed-off-by: Sean Wang --- .../net/wireless/mediatek/mt76/mt7921/init.c | 2 ++ .../net/wireless/mediatek/mt76/mt7921/mac.c | 3 +-- .../net/wireless/mediatek/mt76/mt7921/main.c | 3 +++ .../net/wireless/mediatek/mt76/mt7921/mcu.c | 21 +++++++++++++++++++ .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 + 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c index 9aa110f6562b..039f9c206b05 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c @@ -83,6 +83,8 @@ mt7921_init_wiphy(struct ieee80211_hw *hw) ieee80211_hw_set(hw, HAS_RATE_CONTROL); ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD); ieee80211_hw_set(hw, WANT_MONITOR_VIF); + ieee80211_hw_set(hw, SUPPORTS_PS); + ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS); hw->max_tx_fragments = 4; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index a5d3f5023ea4..ca059dc245a7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -690,8 +690,7 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi, txwi[1] = cpu_to_le32(val); txwi[2] = 0; - val = MT_TXD3_SW_POWER_MGMT | - FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count); + val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count); if (key) val |= MT_TXD3_PROTECT_FRAME; if (info->flags & IEEE80211_TX_CTL_NO_ACK) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 2147bcc53148..0af5e536e5cc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -560,6 +560,9 @@ static void mt7921_bss_info_changed(struct ieee80211_hw *hw, if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED)) mt7921_mcu_set_tx(dev, vif); + if (changed & BSS_CHANGED_PS) + mt7921_mcu_set_vif_ps(dev, vif); + mutex_unlock(&dev->mt76.mutex); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index 99fa49a69ae5..ab2630ca31ca 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -2527,3 +2527,24 @@ u32 mt7921_get_wtbl_info(struct mt7921_dev *dev, u16 wlan_idx) return 0; } + +int mt7921_mcu_set_vif_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif) +{ + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + struct { + u8 bss_idx; + u8 ps_state; /* 0: device awake + * 1: static power save + * 2: dynamic power saving + */ + } req = { + .bss_idx = mvif->idx, + .ps_state = vif->bss_conf.ps ? 2 : 0, + }; + + if (vif->type != NL80211_IFTYPE_STATION) + return -EOPNOTSUPP; + + return mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_PS_PROFILE, &req, + sizeof(req), false); +} diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index dc6064100f53..80610fe22af4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -362,4 +362,5 @@ int mt7921_mcu_sched_scan_enable(struct mt7921_phy *phy, int mt7921_mcu_cancel_hw_scan(struct mt7921_phy *phy, struct ieee80211_vif *vif); u32 mt7921_get_wtbl_info(struct mt7921_dev *dev, u16 wlan_idx); +int mt7921_mcu_set_vif_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif); #endif -- 2.25.1