Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2716682ybi; Sun, 9 Jun 2019 19:12:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmkm6FNYq28xqXPAW5R2gZ/whPDjv7F1VuL8i6T8BeVB2tyIsC3Dv8Kpau/ajguTQ37YQG X-Received: by 2002:a63:f146:: with SMTP id o6mr13344827pgk.179.1560132766068; Sun, 09 Jun 2019 19:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560132766; cv=none; d=google.com; s=arc-20160816; b=ixeEs7fyKxSmS0u5PfgM6sAnWJPOqMi8Hb9M+GAHlqrOklJR+yMtsD7UF4hFMOnpsA 1cAQtv89a9oaIbdTRbuASVNc0NQXqDvxZdxNwOK/z237fM27WwsG9ktWB+dyKUSaiFOu x7mw++Ohd9t3GCaGR5zWg9OEQDKWVWSviUBOi1cw8wRv2XGe6PYam1uJfa6fF0M+TgnI 7O5U7/NHRKtenTx8D5YMdPgcG8YODG74Z9kBx8rcrS7hAUqamU3hWGuF8eK5jnJ+INa5 cQ86UuAylRE8sDbj8n6ApwLtC/mAcRVkBojGCxJuGDmg0TlL9xjZBuhZYtAOqXTCV29b K/yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=6eI7oi9qSBrV7qp90RV2CSsevIzRwaJYEiH43LHQNxw=; b=PsX1AOTYP4epY4nje3/2bQEb7KTIAF04oaqSS+6Ex+A7pZRN2bgWmkNZVxSHGiZF61 lpY8xLCcA1kKcp5pmvAMJdOF3n0/8tipcRVNFkaJnZ/PvJ0DuGVYW7Z08FDnDkDHRF3o TYsgd9kXYg+gDj5o9axoEzQeRjMrzhW241/u+RzEzpoxXyX2nsgxm3h0rkYhkpvgX0la yKCtivntxLUawEIF8/z8qDVAbqhZalDLkZHmAGiEL6msGuW5M64Qz/N+jqKtQJ74K1uv CoWpnwZY9cHppWVAEpvFxX21R9dkv4O8Mmixd//4btLfw9ZlYNt02+FqwKM5aGMg1dB6 2FBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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 f1si8492893pfb.177.2019.06.09.19.12.12; Sun, 09 Jun 2019 19:12:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730215AbfFJCJ5 (ORCPT + 99 others); Sun, 9 Jun 2019 22:09:57 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:58302 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729916AbfFJCJ4 (ORCPT ); Sun, 9 Jun 2019 22:09:56 -0400 X-UUID: 5257321715514527a3c4db15f5580d4f-20190610 X-UUID: 5257321715514527a3c4db15f5580d4f-20190610 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 574685482; Mon, 10 Jun 2019 10:09:52 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 10 Jun 2019 10:09:50 +0800 Received: from [172.21.77.33] (172.21.77.33) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 10 Jun 2019 10:09:50 +0800 Message-ID: <1560132590.28258.5.camel@mtkswgap22> Subject: Re: [PATCH] mt76: mt7615: add support for per-chain signal strength reporting From: Ryder Lee To: Sebastian Gottschall CC: Felix Fietkau , Lorenzo Bianconi , Sean Wang , Chih-Min Chen , YF Luo , , , Yiwei Chung , , Roy Luo Date: Mon, 10 Jun 2019 10:09:50 +0800 In-Reply-To: References: <3912a2863e858f3623ced61737836e42c7b19149.1560071167.git.ryder.lee@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-TM-SNTS-SMTP: 8D06DDBC87EE4513CDD414093242ECAB5DE3824B96BF2BAF50026F9C7918A2862000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Sun, 2019-06-09 at 16:44 +0200, Sebastian Gottschall wrote: > according to my findings > > MT_RXV4_RCPI1 is part of rx descriptor 4 and not 3 > so it must be rxdg4 = rxd[4] etc. RXV start from 1 in the code. That is: RXV1 <-> rxdg0, RXV2 <-> rxdg1 ...so RXV4 <-> rxdg3 > however rxdg3 contains MT_RXV3_IB_RSSIRX which can be used for signal calculation. > i already wrote a similar code for this driver which i sended to felix a long time ago. > my variant looks like > status->signal = (FIELD_GET(MT_RXV3_IB_RSSIRX, rxdg3) - 220) / 2; > status->chain_signal[0] = (FIELD_GET(MT_RXV4_RCPI0, rxdg4) - 220) / 2; > status->chain_signal[1] = (FIELD_GET(MT_RXV4_RCPI1, rxdg4) - 220) / 2; > status->chain_signal[2] = (FIELD_GET(MT_RXV4_RCPI2, rxdg4) - 220) / 2; > status->chain_signal[3] = (FIELD_GET(MT_RXV4_RCPI3, rxdg4) - 220) / 2; > Am 09.06.2019 um 11:09 schrieb Ryder Lee: > > Fill in RX status->chain_signal to avoid empty value. > > > > Signed-off-by: Ryder Lee > > --- > > .../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..9ee83ea11b8c > > --- 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->signal = status->chain_signal[0]; > > + > > + switch (status->chains) { > > + case 0x3: > > + status->chain_signal[1] = to_rssi(MT_RXV4_RCPI1, rxdg3); > > + status->signal = max(status->signal, > > + status->chain_signal[1]); > > + break; > > + case 0x7: > > + status->chain_signal[2] = to_rssi(MT_RXV4_RCPI2, rxdg3); > > + status->signal = max(status->signal, > > + status->chain_signal[2]); > > + break; > > + case 0xf: > > + status->chain_signal[3] = to_rssi(MT_RXV4_RCPI3, rxdg3); > > + status->signal = max(status->signal, > > + status->chain_signal[3]); > > + 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 > > --- 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, > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek