Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp721811pxm; Fri, 25 Feb 2022 18:18:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0qWNXUNW//dnHKbnUT5zDgzOmS3god3Pn93XV7+kuI6W71uXHVLH1NR/8dL3ci0h+UQiP X-Received: by 2002:a17:902:d4ce:b0:14f:cd14:4fe7 with SMTP id o14-20020a170902d4ce00b0014fcd144fe7mr9982273plg.165.1645841926973; Fri, 25 Feb 2022 18:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645841926; cv=none; d=google.com; s=arc-20160816; b=HY2waA4aqhSDDi7+t5Y8KEv1lqfMqfUpHtGR9KjhN5BbHIinYrsRHxUL2PZmd8DIgo eJKh0qIk8A+6zBL13QSpZr4vriKiXTTeQeq1qAOiuq5gldy1YxRCO871yiSnyX3QgvTu AsdnofoqSkzPlq3YXcyMHinUVLA7iaL6WRJ5mJnIHiHCg2UsgcCsFJZGDA8pgta05dsi hytCCxX1f3n/5wnDB30hopxTOza24yfmcz1eWCRov6ujEaOn5QC6pelDR3GN7vticJP/ lLauvEk1mpGdYhgwYiQ6vjseDIE/T7/vhQmpAPrxJyG/kXimPh25OPeayNrE1xU46ryM 0LuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=w2rVgOlCJSE6NrLsYPluYQ2QoPy9bNsV0od4cukWRlI=; b=JOupEnUFBJWgsKPwHH+iidJQV9RchcF8vUuKnTYwyD9RdjvxaYTJvyrU6bw3SUk2VH q2utWG20Ui6cn6YEURSiC0PQ/F0sskDzK55bXKWVbBwfdAorDH+x78s6iBNmC/e06CUm 00dbHD58Z967dR5TaRODVr963HGOIVHuFRnScx3cQg6d5Ud75vt3tZtXm0NZJIF4qQc7 972dZZK7Y60ovg4PBTzSoI6ymIov8GOI2Gtjp9M2eh3Ai3igQb1ExRY8BLhJhV3PSZmP GT5E/lDOIMB1awel8gKSRuce1ROKjL+azF6O26f/w54ztNxgtjfBsfknF9ur195l5+DE MAmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q16-20020a170902dad000b0015011e142f5si3976601plx.55.2022.02.25.18.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 18:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 929212C6C48; Fri, 25 Feb 2022 17:51:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239184AbiBZA1A (ORCPT + 72 others); Fri, 25 Feb 2022 19:27:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232509AbiBZA07 (ORCPT ); Fri, 25 Feb 2022 19:26:59 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 186E1214F87 for ; Fri, 25 Feb 2022 16:26:21 -0800 (PST) X-UUID: 27dbea40fff247529b83dce285e4b566-20220226 X-UUID: 27dbea40fff247529b83dce285e4b566-20220226 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 989229222; Sat, 26 Feb 2022 08:26:19 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Sat, 26 Feb 2022 08:26:17 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 26 Feb 2022 08:26:17 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v2 1/2] mt76: mt7921: fix up the monitor mode Date: Sat, 26 Feb 2022 08:26:14 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Properly set up the monitor mode the firmware can support to fix up RTS/CTS and beacon frames cannot be captured and forwarded to the host. Tested-by: Deren Wu Signed-off-by: Sean Wang --- v2: 1. add Tested-by tag 2. make mt76_connac_mcu_set_sniffer mt7921 specific 3. align the structure declartion --- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 + .../net/wireless/mediatek/mt76/mt7921/main.c | 23 +++++++------- .../net/wireless/mediatek/mt76/mt7921/mcu.c | 30 +++++++++++++++++++ .../wireless/mediatek/mt76/mt7921/mt7921.h | 2 ++ 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index 384c3eab1c8a..e5857d2cf78c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -993,6 +993,7 @@ enum { MCU_UNI_CMD_SUSPEND = 0x05, MCU_UNI_CMD_OFFLOAD = 0x06, MCU_UNI_CMD_HIF_CTRL = 0x07, + MCU_UNI_CMD_SNIFFER = 0x24, }; enum { diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index b6e836a4fad7..0f3c56530e66 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -479,6 +479,16 @@ mt7921_pm_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) mt7921_mcu_set_beacon_filter(dev, vif, dev->pm.enable); } +static void +mt7921_sniffer_interface_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) +{ + struct mt7921_dev *dev = priv; + struct ieee80211_hw *hw = mt76_hw(dev); + bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); + + mt7921_mcu_set_sniffer(dev, vif, enabled); +} + void mt7921_set_runtime_pm(struct mt7921_dev *dev) { struct ieee80211_hw *hw = dev->mphy.hw; @@ -516,16 +526,9 @@ static int mt7921_config(struct ieee80211_hw *hw, u32 changed) } if (changed & IEEE80211_CONF_CHANGE_MONITOR) { - bool enabled = !!(hw->conf.flags & IEEE80211_CONF_MONITOR); - - if (!enabled) - phy->rxfilter |= MT_WF_RFCR_DROP_OTHER_UC; - else - phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC; - - mt76_rmw_field(dev, MT_DMA_DCR0(0), MT_DMA_DCR0_RXD_G5_EN, - enabled); - mt76_wr(dev, MT_WF_RFCR(0), phy->rxfilter); + ieee80211_iterate_active_interfaces(hw, + IEEE80211_IFACE_ITER_RESUME_ALL, + mt7921_sniffer_interface_iter, dev); mt7921_set_runtime_pm(dev); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index 33a836825cca..ab790e5df863 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -1133,3 +1133,33 @@ int mt7921_get_txpwr_info(struct mt7921_dev *dev, struct mt7921_txpwr *txpwr) return 0; } + +int mt7921_mcu_set_sniffer(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable) +{ + struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv; + struct { + struct { + u8 band_idx; + u8 pad[3]; + } __packed hdr; + struct sniffer_enable_tlv { + __le16 tag; + __le16 len; + u8 enable; + u8 pad[3]; + } __packed enable; + } req = { + .hdr = { + .band_idx = mvif->band_idx, + }, + .enable = { + .tag = cpu_to_le16(0), + .len = cpu_to_le16(sizeof(struct sniffer_enable_tlv)), + .enable = enable, + }, + }; + + return mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD(SNIFFER), &req, sizeof(req), + true); +} diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h index 9edc83f06139..9575d571b425 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h @@ -452,4 +452,6 @@ void mt7921s_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e); bool mt7921s_tx_status_data(struct mt76_dev *mdev, u8 *update); void mt7921_mac_add_txs(struct mt7921_dev *dev, void *data); void mt7921_set_runtime_pm(struct mt7921_dev *dev); +int mt7921_mcu_set_sniffer(struct mt7921_dev *dev, struct ieee80211_vif *vif, + bool enable); #endif -- 2.25.1