Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5349810ybi; Wed, 12 Jun 2019 00:43:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqysj97vHvyjqF/2pd2Xb6iivLU5DkchN0XJLlVX6Jz0Hc11r2cTPCvOo3IGUQsK8gmdB9VC X-Received: by 2002:a63:5d54:: with SMTP id o20mr22905294pgm.97.1560325400770; Wed, 12 Jun 2019 00:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560325400; cv=none; d=google.com; s=arc-20160816; b=ZdA8J3w2Oik7rA5D2Fnq6cSkCUlHBME1MARxiOOxbjQ+LLdWpDkHde1BJHL7GSG5S+ fbjuA+lp085ykj2PRfU9YhKHWcrGVUQtAR/W6pI9zU8pxaEnjweWBCEAKgfyaTI054jR 3w6FFb4hW6SsiMXttMzeGbG4RkikS6xUJPkccAhCOwBmZKnHUJDeR+sSxHgiTalvxcrh jInXG9CWD3vUKPtXKYvnULikjVNtWncdCwbbgoMwTjo2/T0B88CDQzeyuNdH0/GvCW0s 9lxEYPts+X73l+ojpgLL/Rl3khXn0n/w2gxzFujxiAeXAC5L133zCIWtND7FVqo4ASC/ ALQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=q2ZDXd0C0zbATUf8ScgQ8buQGf6F/7yZ1XpXjvqA+LU=; b=KwdFuKOFR9yCOvt0aDWNo5nhpR3I47yDTMLhLKqiHngWmWKfC6+uCZUZ+7fp5rPY9n RIkWGUf6ozfN3DwF69lvvyZDYTFieIlwm2Z+hJYAjj+OK0Gi5fUdVThj14TelxksZtXg M2WT9DTEoetLw54XvNX0clxuz5ItGpsOWA3XeWqPfKvnrWlfS90wuptYNrq50BFbEk3C bPAM98e5XCqU/1YqWMM85cPh09W+36uuK9EIiREanqnclK4P5U8YB4FnvO5NRgWa71KE OF4dbMlZhcCiF6XOMkAm0z/FGCBjSdpY0YdHHLjjdlLUwX8F5PL2ctcWdZCH2cKq7n0e TyNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si5265594plc.253.2019.06.12.00.43.05; Wed, 12 Jun 2019 00:43:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437108AbfFLDMr (ORCPT + 99 others); Tue, 11 Jun 2019 23:12:47 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:62965 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2406968AbfFLDMq (ORCPT ); Tue, 11 Jun 2019 23:12:46 -0400 X-UUID: 258c2d2ab540419aa812d3d847caffb7-20190612 X-UUID: 258c2d2ab540419aa812d3d847caffb7-20190612 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1835256952; Wed, 12 Jun 2019 11:12:40 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 12 Jun 2019 11:12:39 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 12 Jun 2019 11:12:38 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Roy Luo , YF Luo , Yiwei Chung , Sean Wang , , , , Ryder Lee Subject: [PATCH v2] mt76: mt7615: add support for per-chain signal strength reporting Date: Wed, 12 Jun 2019 11:12:32 +0800 Message-ID: <22e5caff3581dc92fd6fec2f25966d86b7276bba.1560220443.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fill in RX status->chain_signal to avoid empty value. Signed-off-by: Ryder Lee --- Changes since v2 - correct calculation sequence --- .../net/wireless/mediatek/mt76/mt7615/mac.c | 30 ++++++++++++++++++- .../net/wireless/mediatek/mt76/mt7615/mac.h | 5 ++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index b60d42b5923d..2f49a99e77b1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -13,6 +13,11 @@ #include "../dma.h" #include "mac.h" +static inline s8 to_rssi(u32 field, u32 rxv) +{ + return (FIELD_GET(field, rxv) - 220) / 2; +} + static struct mt76_wcid *mt7615_rx_get_wcid(struct mt7615_dev *dev, u8 idx, bool unicast) { @@ -120,6 +125,7 @@ int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) if (rxd0 & MT_RXD0_NORMAL_GROUP_3) { u32 rxdg0 = le32_to_cpu(rxd[0]); u32 rxdg1 = le32_to_cpu(rxd[1]); + u32 rxdg3 = le32_to_cpu(rxd[3]); u8 stbc = FIELD_GET(MT_RXV1_HT_STBC, rxdg0); bool cck = false; @@ -169,7 +175,29 @@ int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) status->enc_flags |= RX_ENC_FLAG_STBC_MASK * stbc; - /* TODO: RSSI */ + status->chains = dev->mt76.antenna_mask; + status->chain_signal[0] = to_rssi(MT_RXV4_RCPI0, rxdg3); + status->chain_signal[1] = to_rssi(MT_RXV4_RCPI1, rxdg3); + status->chain_signal[2] = to_rssi(MT_RXV4_RCPI2, rxdg3); + status->chain_signal[3] = to_rssi(MT_RXV4_RCPI3, rxdg3); + status->signal = status->chain_signal[0]; + + switch (status->chains) { + case 0xf: + status->signal = max(status->signal, + status->chain_signal[3]); + /* fall through */ + case 0x7: + status->signal = max(status->signal, + status->chain_signal[2]); + /* fall through */ + case 0x3: + status->signal = max(status->signal, + status->chain_signal[1]); + break; + default: + break; + } rxd += 6; if ((u8 *)rxd - skb->data >= skb->len) return -EINVAL; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.h b/drivers/net/wireless/mediatek/mt76/mt7615/mac.h index 18ad4b8a3807..b00ce8db58e9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.h @@ -98,6 +98,11 @@ enum rx_pkt_type { #define MT_RXV2_GROUP_ID GENMASK(26, 21) #define MT_RXV2_LENGTH GENMASK(20, 0) +#define MT_RXV4_RCPI3 GENMASK(31, 24) +#define MT_RXV4_RCPI2 GENMASK(23, 16) +#define MT_RXV4_RCPI1 GENMASK(15, 8) +#define MT_RXV4_RCPI0 GENMASK(7, 0) + enum tx_header_format { MT_HDR_FORMAT_802_3, MT_HDR_FORMAT_CMD, -- 2.18.0