Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp480060pxb; Wed, 20 Jan 2021 11:43:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqnPBFyWXve43aMN5o62NuTL0CCmBUqXQionFZLPGIQVJ4OxWIvRw3sMzKtTs0XI4gkPfo X-Received: by 2002:a05:6402:2289:: with SMTP id cw9mr8446231edb.319.1611171808989; Wed, 20 Jan 2021 11:43:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611171808; cv=none; d=google.com; s=arc-20160816; b=tOvzKjHJ8HcUxaqZ13h15RAFkBtcSeCP1+jMv8a4xc3Auh6X0OinALUHOKUOpBP6Pu aCFCZ6USAgbwivHNuYs+eCEeXpZJditBFoeiBZZ+qj1I0hPlDAJOVh1JOSODJCaI20dX Hp2DlIMyoKiihhYIXI/vVr77ktj4NQ8KofC6FCsZt4vpGmlx82bUtiSO7bWnDZbGsZLP jgumBD9VdP4PpTyCF4jQ8hdzgzbNMEZSHxfUk1agjZK/OHSnqqvcEBQj4hXtN3BtMqnN hA5N4NRby3IBbU9HxQueYe/0YXA/eQCqP4VBQYbgokL5lJmEOxHJd5IvrlmywENi6qHU vR+w== 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=Fd37rhm0IjlWZQawQAcOp/G6TJ4mY1J802ayuLv8iMM=; b=elzLg0nh6X7ktJ3ApwaN9hNHmHA1AZT2GHoz78ViKRXGHMukgAba2wf8VEufqC699q TF2cJxr0bscht+sjVk5E8aE/aDuMlAChz8ETgdT9dyQXixcARC28GxbjSujyRv8Mz3yR awVZ+jhsR1hNRqS2jp3pCuhL2k8VmIuFkxYHyq0/irAQeqc+r02yLUzhZ5khgY1ssix4 8l8Bns/mksJp2U0tcvYLgDGFXuL6WAljnu7Vf4Yp59BWFsIZ8OSaq/kB41BXvWrWap0A umkf1XYAcu/XKhA9FmA7GNwVUZ3JZXAmUyko/OYJSbrVR9s0W2Ktjlw9/8jNCcVfLGyS x5yQ== 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 bs18si1213020edb.447.2021.01.20.11.43.05; Wed, 20 Jan 2021 11:43:28 -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 S2387461AbhATThi (ORCPT + 99 others); Wed, 20 Jan 2021 14:37:38 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:43147 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2392625AbhATTfx (ORCPT ); Wed, 20 Jan 2021 14:35:53 -0500 X-UUID: 59d9f4506e554428926130ad74e4ab76-20210121 X-UUID: 59d9f4506e554428926130ad74e4ab76-20210121 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.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 1445758545; Thu, 21 Jan 2021 03:33:57 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 21 Jan 2021 03:33:55 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 21 Jan 2021 03:33:55 +0800 From: To: , CC: , , , , , , , , , , Lorenzo Bianconi Subject: [PATCH -next v6 12/15] mt76: mt7921: introduce 802.11 PS support in sta mode Date: Thu, 21 Jan 2021 03:33:48 +0800 Message-ID: <10f91ffe7c2c8cc35ccf4e174cd46208430c8fc6.1611060302.git.objelf@gmail.com> 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: D8CFF33BBDA2CC56C3BE57B94E486E651C03C70CA0A9C9A0DB2CFAD37C4770BA2000: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 | 37 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7921/mcu.h | 2 +- .../wireless/mediatek/mt76/mt7921/mt7921.h | 1 + 6 files changed, 45 insertions(+), 3 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..f0dda1531899 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_uni_bss_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..1e7be1d58850 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -2527,3 +2527,40 @@ u32 mt7921_get_wtbl_info(struct mt7921_dev *dev, u16 wlan_idx) return 0; } + +int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif) +{ + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + struct { + struct { + u8 bss_idx; + u8 pad[3]; + } __packed hdr; + struct ps_tlv { + __le16 tag; + __le16 len; + u8 ps_state; /* 0: device awake + * 1: static power save + * 2: dynamic power saving + * 3: inter TWT power saving + * 4: leave TWT power saving + */ + u8 pad[3]; + } __packed ps; + } __packed ps_req = { + .hdr = { + .bss_idx = mvif->idx, + }, + .ps = { + .tag = cpu_to_le16(UNI_BSS_INFO_PS), + .len = cpu_to_le16(sizeof(struct ps_tlv)), + .ps_state = vif->bss_conf.ps ? 2 : 0, + }, + }; + + if (vif->type != NL80211_IFTYPE_STATION) + return -EOPNOTSUPP; + + return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_BSS_INFO_UPDATE, + &ps_req, sizeof(ps_req), true); +} diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h index 6894b44ff62d..2103e1d3ac94 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h @@ -185,7 +185,6 @@ struct mt7921_mcu_uni_event { /* offload mcu commands */ enum { MCU_CMD_START_HW_SCAN = MCU_CE_PREFIX | 0x03, - MCU_CMD_SET_PS_PROFILE = MCU_CE_PREFIX | 0x05, MCU_CMD_SET_CHAN_DOMAIN = MCU_CE_PREFIX | 0x0f, MCU_CMD_SET_BSS_CONNECTED = MCU_CE_PREFIX | 0x16, MCU_CMD_SET_BSS_ABORT = MCU_CE_PREFIX | 0x17, @@ -211,6 +210,7 @@ enum { UNI_BSS_INFO_BCN_CONTENT = 7, UNI_BSS_INFO_QBSS = 15, UNI_BSS_INFO_UAPSD = 19, + UNI_BSS_INFO_PS = 21, }; enum { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index dc6064100f53..2e617e85670d 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_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif); #endif -- 2.25.1