Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1645086pxb; Sat, 23 Jan 2021 00:38:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMETdhD5cLFwaJpy2tkXx5sFiPegScv9hIOe7s0oM71eS+N25vRQFNf3ihBi8SpDW+F7Nu X-Received: by 2002:a17:907:948d:: with SMTP id dm13mr56968ejc.545.1611391137912; Sat, 23 Jan 2021 00:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611391137; cv=none; d=google.com; s=arc-20160816; b=DW8A63qEj11GP5IBwcoIMd7fGfLHTvviTKkurFqEtey1HrXvayq2k8sQjFj40zttae X6gWVEnj14+82qQwAOYMQttf1S9Grk4QfjNKgreqdRXWk444XmK+48IzvXz7PflXIzxd tFWq9S4QIHYSDtEdgzLoc/QxmXYajIv8JafKUqcASyFEC8nJc3QoNseTIwODkkwN3YRo 8iR55kDhPbg4t/X9T46wdXQbOXg1YfV/ojXv9bmXJjZ7wpo5ajbupHjRl2QrCb6kREMG jchVjIMc4oujmN6JyVe0ygkGORW1B9w9+y1IQv89DyTBzA1h/b/laNsH6TtcUjJHlWTZ cDjQ== 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=e3mSTEVrU2SuxBmKXKd1F9oLAO+NDu7JgzK7OqmievY=; b=zGupEt+3bzHd4cywdRiVU1VDGEOCs3Q53KuiwJH8vN2s2/TDo/JxA1PRu6OOAIX3wj oZjprF4F3weTJFkSDLHj0CFNBfk3hECTXkav822IDH4vcqspidKCkufXf5Jg3Bx8XjNo a+OKi/x5+jwieIn5Z8CK5YsvCU0YRWaShagpuTxk0U2v/8DujJreJF9FHmkseed/YQki bq8Js1hZiihOfgrPKqHGBKqeuIv1f7ORFbpGarDdlZ5/3mXw/xD3tpsUc7YGqnGncDtV FA084Ckf+BIOeFngNOghkI/0S8Fj9j/KCvxY62e4H+bySXsAJIgyy76opkWLxQAxJBfP ekkA== 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 q21si3793926eja.525.2021.01.23.00.38.35; Sat, 23 Jan 2021 00:38:57 -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 S1726699AbhAWIgS (ORCPT + 99 others); Sat, 23 Jan 2021 03:36:18 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:54837 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725766AbhAWIgD (ORCPT ); Sat, 23 Jan 2021 03:36:03 -0500 X-UUID: ce652b1f05174704a4be60faafd27151-20210123 X-UUID: ce652b1f05174704a4be60faafd27151-20210123 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] 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 1108110024; Sat, 23 Jan 2021 16:35:17 +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; Sat, 23 Jan 2021 16:35:15 +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; Sat, 23 Jan 2021 16:35:16 +0800 From: To: , CC: , , , , , , , , , , Lorenzo Bianconi Subject: [PATCH -next v7 11/22] mt76: mt7921: introduce support for hardware beacon filter Date: Sat, 23 Jan 2021 16:35:02 +0800 Message-ID: <501a4e58991eeb7d1cfbd9c9d4758eaf3523466e.1611389300.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: 01375A47BFC12CE786A73FCD19F248AA4914751E6EF20B1AB8FCDDF40618D3FF2000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Introduce support for hw beacon filter available in the mt7921 firmware. According to mt7921e firmware, enabling hardware filter would rely on mt7921_mcu_uni_bss_bcnft and disabling hardware filter still rely on legacy mt7921_mcu_set_bss_pm. 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/mcu.c | 75 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7921/mcu.h | 1 + .../wireless/mediatek/mt76/mt7921/mt7921.h | 4 + 3 files changed, 80 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index 913b56065de6..768456c7aa7f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -2500,3 +2500,78 @@ int mt7921_mcu_uni_bss_ps(struct mt7921_dev *dev, struct ieee80211_vif *vif) return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_BSS_INFO_UPDATE, &ps_req, sizeof(ps_req), true); } + +int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable) +{ + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + struct { + struct { + u8 bss_idx; + u8 pad[3]; + } __packed hdr; + struct bcnft_tlv { + __le16 tag; + __le16 len; + __le16 bcn_interval; + u8 dtim_period; + u8 pad; + } __packed bcnft; + } __packed bcnft_req = { + .hdr = { + .bss_idx = mvif->mt76.idx, + }, + .bcnft = { + .tag = cpu_to_le16(UNI_BSS_INFO_BCNFT), + .len = cpu_to_le16(sizeof(struct bcnft_tlv)), + .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int), + .dtim_period = vif->bss_conf.dtim_period, + }, + }; + + if (vif->type != NL80211_IFTYPE_STATION) + return 0; + + return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_BSS_INFO_UPDATE, + &bcnft_req, sizeof(bcnft_req), true); +} + +int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable) +{ + struct mt7921_vif *mvif = (struct mt7921_vif *)vif->drv_priv; + struct { + u8 bss_idx; + u8 dtim_period; + __le16 aid; + __le16 bcn_interval; + __le16 atim_window; + u8 uapsd; + u8 bmc_delivered_ac; + u8 bmc_triggered_ac; + u8 pad; + } req = { + .bss_idx = mvif->mt76.idx, + .aid = cpu_to_le16(vif->bss_conf.aid), + .dtim_period = vif->bss_conf.dtim_period, + .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int), + }; + struct { + u8 bss_idx; + u8 pad[3]; + } req_hdr = { + .bss_idx = mvif->mt76.idx, + }; + int err; + + if (vif->type != NL80211_IFTYPE_STATION) + return 0; + + err = mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_BSS_ABORT, &req_hdr, + sizeof(req_hdr), false); + if (err < 0 || !enable) + return err; + + return mt76_mcu_send_msg(&dev->mt76, MCU_CMD_SET_BSS_CONNECTED, &req, + sizeof(req), false); +} diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h index 2103e1d3ac94..de3a9aabec04 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h @@ -211,6 +211,7 @@ enum { UNI_BSS_INFO_QBSS = 15, UNI_BSS_INFO_UAPSD = 19, UNI_BSS_INFO_PS = 21, + UNI_BSS_INFO_BCNFT = 22, }; enum { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index f4435cc1712f..161e328fc4ee 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -356,4 +356,8 @@ 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); +int mt7921_mcu_uni_bss_bcnft(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable); +int mt7921_mcu_set_bss_pm(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable); #endif -- 2.25.1