Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp38930imn; Wed, 3 Aug 2022 18:38:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+o9l+RidmfSrTiAiA8JRYkDUJtCLz4Ms2mJph1tGp0PQy6R5Ef8B2pgjawkGje80JzVgG X-Received: by 2002:a17:902:ea0e:b0:16f:11bf:efe5 with SMTP id s14-20020a170902ea0e00b0016f11bfefe5mr7539117plg.57.1659577109356; Wed, 03 Aug 2022 18:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659577109; cv=none; d=google.com; s=arc-20160816; b=tviFm0pRih56nIUCZRIB95/dqE/GmO+KNd4qtvcZVyIkMNoJitcr0xDuEIAexuWz6F dNQHm7Tnv2RISkBBdCL5Mfn2ZBADZa1xMOjlqqZShlqrZxP110ITGFyhvtNV8QY7R9Ww +hviOlsVqMj+964XEJ81qfJoDQcPYQqH1VLsp+D3lQ4GDDIcCzvm7IOvm1oB1OKL1IH0 TL/bDDgkX9YmEaIpA/MS/R6LWIC3/XSUVPDGSQz4llXu0WrSnF0LpeFwma6JsznoItx2 CyDwCL//rNvhbdRmupECntjJ4V/yLSvCHNvklSj40nyYKSTIoIWhR4ubDkL+v5nNsXY+ PWrA== 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 :dkim-signature; bh=ShN5Al7J98eU+m9SLdyQUvLe6L2xd8dZtVuQ/xF+kFs=; b=lZ3fEdreCnfV/CMymhjp+XHRChog5d4WVZHoYmLNX4Rk3N5QJPFjvEtxXk7l0bWTm1 cmnly168lr+gsgpGbV5WwC5Hmb86FW59eY80SFSdkTnFAbHqQ07rsGgs6t/PyrXpvC+o PbqWxehBaHssYTsaQtpVEbikK/792Uhhocv++FsKaGVSMiK/KEEA8JIK0o2Gy93yPZgU WEO90WcM46ZHn+WoPnbSvWW/jWAGIQXnut+ZY4rWI+KoBMck+ADeiiabFM2tXm0o69jo FbkLlrF9yjng/7K7VnY6MrKNjsWvK3wloJLCyn/KPt7t6S+zMVnUGPIUR8FTIak6hTcA jJnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=lIwB2IVF; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe5-20020a17090b4f8500b001f3a43f2460si3838757pjb.166.2022.08.03.18.38.12; Wed, 03 Aug 2022 18:38:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=lIwB2IVF; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238924AbiHDBIE (ORCPT + 66 others); Wed, 3 Aug 2022 21:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236360AbiHDBIC (ORCPT ); Wed, 3 Aug 2022 21:08:02 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6986D40BD8 for ; Wed, 3 Aug 2022 18:07:55 -0700 (PDT) X-UUID: 72c6e1a255e846e6bf7f1fff3df857e4-20220804 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=ShN5Al7J98eU+m9SLdyQUvLe6L2xd8dZtVuQ/xF+kFs=; b=lIwB2IVFrVkCRl9JQ2lW1zazaouOmmbHeL7p3/2A0WxwaIRhbeqA51eBwpHhf4AJASA8zp945x/NgQiwuWT+xr7X1rDzaHcfqYdBPjmDGLLfqC2qRdkCf/sYzZlR/cCPkUZakhwLY3wvK3dSrZD4zUkCtLKbEAcO6czVr4sxt1M=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:11499bf4-708a-4049-8258-b7213881c0e2,OB:10,L OB:20,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Release_Ham,A CTION:release,TS:100 X-CID-INFO: VERSION:1.1.8,REQID:11499bf4-708a-4049-8258-b7213881c0e2,OB:10,LOB :20,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,RULE:Spam_GS981B3D,A CTION:quarantine,TS:100 X-CID-META: VersionHash:0f94e32,CLOUDID:da7739d0-a6cf-4fb6-be1b-c60094821ca2,C OID:a6890e36c514,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,QS:nil,BEC:nil,COL:0 X-UUID: 72c6e1a255e846e6bf7f1fff3df857e4-20220804 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1970289718; Thu, 04 Aug 2022 09:07:48 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 4 Aug 2022 09:07:46 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 4 Aug 2022 09:07:46 +0800 From: To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , "Deren Wu" Subject: [PATCH v2] mt76: mt7921: fix antenna signal are way off in monitor mode Date: Thu, 4 Aug 2022 09:07:45 +0800 Message-ID: <0f95fcdb8511ec765040c8fe85c1fa09437e8ef5.1659574985.git.objelf@gmail.com> 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=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAY_BE_FORGED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, T_SPF_TEMPERROR,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 Group 3 in RxD is disabled in monitor mode. We should use the group 5 in RxD instead to fix antenna signal way off issue, e.g we would see the incorrect antenna signal value in wireshark. On the other hand, Group 5 wouldn't be used in STA or AP mode, so the patch shouldn't cause any harm to those modes. Fixes: cbaa0a404f8d ("mt76: mt7921: fix up the monitor mode") Reported-by: Adrian Granados Co-developed-by: Deren Wu Signed-off-by: Deren Wu Signed-off-by: Sean Wang --- v2: drop an unnecessary blank line and fix typo --- .../net/wireless/mediatek/mt76/mt7921/mac.c | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 47f0aa81ab02..1c242f2ae997 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -394,6 +394,27 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) if (v0 & MT_PRXV_HT_AD_CODE) status->enc_flags |= RX_ENC_FLAG_LDPC; + ret = mt76_connac2_mac_fill_rx_rate(&dev->mt76, status, sband, + rxv, &mode); + if (ret < 0) + return ret; + + if (rxd1 & MT_RXD1_NORMAL_GROUP_5) { + rxd += 6; + if ((u8 *)rxd - skb->data >= skb->len) + return -EINVAL; + + rxv = rxd; + /* Monitor mode would use RCPI described in GROUP 5 + * instead. + */ + v1 = le32_to_cpu(rxv[0]); + + rxd += 12; + if ((u8 *)rxd - skb->data >= skb->len) + return -EINVAL; + } + status->chains = mphy->antenna_mask; status->chain_signal[0] = to_rssi(MT_PRXV_RCPI0, v1); status->chain_signal[1] = to_rssi(MT_PRXV_RCPI1, v1); @@ -408,17 +429,6 @@ mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) status->signal = max(status->signal, status->chain_signal[i]); } - - ret = mt76_connac2_mac_fill_rx_rate(&dev->mt76, status, sband, - rxv, &mode); - if (ret < 0) - return ret; - - if (rxd1 & MT_RXD1_NORMAL_GROUP_5) { - rxd += 18; - if ((u8 *)rxd - skb->data >= skb->len) - return -EINVAL; - } } amsdu_info = FIELD_GET(MT_RXD4_NORMAL_PAYLOAD_FORMAT, rxd4); -- 2.25.1