From patchwork Sat Dec 28 03:05:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11311433 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F336139A for ; Sat, 28 Dec 2019 03:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31C9B208C4 for ; Sat, 28 Dec 2019 03:06:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="V1Fmr/vx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbfL1DGc (ORCPT ); Fri, 27 Dec 2019 22:06:32 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:42727 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725957AbfL1DGc (ORCPT ); Fri, 27 Dec 2019 22:06:32 -0500 X-UUID: 6e18bea4fded4b338d5f7cdaee77f323-20191228 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=uSTVEK+nsIniuJAECvz0aav3uObqmPZflDTTEqMVwi4=; b=V1Fmr/vxZ1I7HA7CDRWwWElz89uYJHWOgd0RFarg6OXXEmDbNvuk28r/dofIdTkkAltENQzQIQmdg9tFUhc1yk0IeEMxMJgHlGA2uuswkjYR3cLIpWcyHN7tqEUgSfgjDh2QV8u1i5Hh6UIpddLznEB5kHLMH8RpOhy3RGPxu3s=; X-UUID: 6e18bea4fded4b338d5f7cdaee77f323-20191228 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1878609012; Sat, 28 Dec 2019 11:06:26 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 28 Dec 2019 11:07:07 +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; Sat, 28 Dec 2019 11:05:49 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , Roy Luo , Sean Wang , , , Ryder Lee Subject: [PATCH v1 1/3] mt76: mt7615: report TSF information Date: Sat, 28 Dec 2019 11:05:10 +0800 Message-ID: <769aba6e014b8e7650c3909d6adb8427c1d5c5ae.1577501739.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This adds a get_tsf() callback for ibss. Signed-off-by: Ryder Lee --- changes since v1 - modify commit msg and variable name. --- .../net/wireless/mediatek/mt76/mt7615/main.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index 2a85859da754..fa67331918ea 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -628,6 +628,26 @@ mt7615_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, IEEE80211_STA_NOTEXIST); } +static u64 +mt7615_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct mt7615_dev *dev = mt7615_hw_dev(hw); + union { + u64 t64; + u32 t32[2]; + } tsf; + + mutex_lock(&dev->mt76.mutex); + + mt76_set(dev, MT_LPON_T0CR, MT_LPON_T0CR_MODE); /* TSF read */ + tsf.t32[0] = mt76_rr(dev, MT_LPON_UTTR0); + tsf.t32[1] = mt76_rr(dev, MT_LPON_UTTR1); + + mutex_unlock(&dev->mt76.mutex); + + return tsf.t64; +} + static void mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class) { @@ -659,6 +679,7 @@ const struct ieee80211_ops mt7615_ops = { .release_buffered_frames = mt76_release_buffered_frames, .get_txpower = mt76_get_txpower, .channel_switch_beacon = mt7615_channel_switch_beacon, + .get_tsf = mt7615_get_tsf, .get_survey = mt76_get_survey, .get_antenna = mt76_get_antenna, .set_coverage_class = mt7615_set_coverage_class, From patchwork Sat Dec 28 03:05:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11311437 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8EDB13A4 for ; Sat, 28 Dec 2019 03:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87D04208C4 for ; Sat, 28 Dec 2019 03:06:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="hKYZLPZ0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726195AbfL1DGe (ORCPT ); Fri, 27 Dec 2019 22:06:34 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:7642 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726044AbfL1DGe (ORCPT ); Fri, 27 Dec 2019 22:06:34 -0500 X-UUID: 151799096d1f4dd88a029efcc2fa0a77-20191228 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=59pqvoAaU68tyt/+uUeT/9cG7cvBamrg76YhqKNa9Pk=; b=hKYZLPZ05IiBvbdU58ITmdL0+bPNqlclAToDaQCyFAgAjUv67n8H2+vk/fk8K0+1oKGhzZNXE9POA05im4m2kx+paxsZZdsRJlgXLeJBrtNVUIwY2tH2u+PwrLMl6CKjLCZNEYaNyw8+G6e2PoRIH7D8jvCD+wlOfssWVW5fTEg=; X-UUID: 151799096d1f4dd88a029efcc2fa0a77-20191228 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 945095895; Sat, 28 Dec 2019 11:06:30 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 28 Dec 2019 11:06:27 +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; Sat, 28 Dec 2019 11:05:51 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , Roy Luo , Sean Wang , , , Ryder Lee Subject: [PATCH v1 2/3] mt76: mt7615: add per-phy mib statistics Date: Sat, 28 Dec 2019 11:05:11 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 In-Reply-To: <769aba6e014b8e7650c3909d6adb8427c1d5c5ae.1577501739.git.ryder.lee@mediatek.com> References: <769aba6e014b8e7650c3909d6adb8427c1d5c5ae.1577501739.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 2DCC9F50CED6423EB6868D28408D639660D286A3AC266B14C66630E41025135D2000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Update per-phy mib counters every 500ms. Signed-off-by: Ryder Lee --- changes since v1 - mark mt7615_mac_update_mib_stats() as a static function. --- .../net/wireless/mediatek/mt76/mt7615/mac.c | 56 +++++++++++++------ .../wireless/mediatek/mt76/mt7615/mt7615.h | 9 +++ .../net/wireless/mediatek/mt76/mt7615/regs.h | 16 ++++-- 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index 1b52d8b79496..d6cb6532a883 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -1480,25 +1480,14 @@ static void mt7615_mac_scs_check(struct mt7615_phy *phy) { struct mt7615_dev *dev = phy->dev; - u32 val, rts_cnt = 0, rts_retries_cnt = 0, rts_err_rate = 0; + struct mib_stats *mib = &phy->mib; + u32 val, rts_err_rate = 0; u32 mdrdy_cck, mdrdy_ofdm, pd_cck, pd_ofdm; bool ext_phy = phy != &dev->phy; - int i; if (!dev->scs_en) return; - for (i = 0; i < 4; i++) { - u32 data; - - val = mt76_rr(dev, MT_MIB_MB_SDR(ext_phy, i)); - data = FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK, val); - if (data > rts_retries_cnt) { - rts_cnt = FIELD_GET(MT_MIB_RTS_COUNT_MASK, val); - rts_retries_cnt = data; - } - } - val = mt76_rr(dev, MT_WF_PHY_R0_PHYCTRL_STS0(ext_phy)); pd_cck = FIELD_GET(MT_WF_PHYCTRL_STAT_PD_CCK, val); pd_ofdm = FIELD_GET(MT_WF_PHYCTRL_STAT_PD_OFDM, val); @@ -1511,9 +1500,9 @@ mt7615_mac_scs_check(struct mt7615_phy *phy) phy->false_cca_cck = pd_cck - mdrdy_cck; mt7615_mac_cca_stats_reset(phy); - if (rts_cnt + rts_retries_cnt) - rts_err_rate = MT_FRAC(rts_retries_cnt, - rts_cnt + rts_retries_cnt); + if (mib->rts_cnt + mib->rts_retries_cnt) + rts_err_rate = MT_FRAC(mib->rts_retries_cnt, + mib->rts_cnt + mib->rts_retries_cnt); /* cck */ mt7615_mac_adjust_sensitivity(phy, rts_err_rate, false); @@ -1588,6 +1577,36 @@ void mt7615_update_channel(struct mt76_dev *mdev) mt76_set(dev, MT_WF_RMAC_MIB_TIME0, MT_WF_RMAC_MIB_RXTIME_CLR); } +static void +mt7615_mac_update_mib_stats(struct mt7615_phy *phy) +{ + struct mt7615_dev *dev = phy->dev; + struct mib_stats *mib = &phy->mib; + bool ext_phy = phy != &dev->phy; + int i; + + memset(mib, 0, sizeof(*mib)); + + mib->fcs_err_cnt = mt76_get_field(dev, MT_MIB_SDR3(ext_phy), + MT_MIB_SDR3_FCS_ERR_MASK); + + for (i = 0; i < 4; i++) { + u32 data, val, val2; + + val = mt76_get_field(dev, MT_MIB_MB_SDR1(ext_phy, i), + MT_MIB_ACK_FAIL_COUNT_MASK); + if (val > mib->ack_fail_cnt) + mib->ack_fail_cnt = val; + + val2 = mt76_rr(dev, MT_MIB_MB_SDR0(ext_phy, i)); + data = FIELD_GET(MT_MIB_RTS_RETRIES_COUNT_MASK, val2); + if (data > mib->rts_retries_cnt) { + mib->rts_cnt = FIELD_GET(MT_MIB_RTS_COUNT_MASK, val2); + mib->rts_retries_cnt = data; + } + } +} + void mt7615_mac_work(struct work_struct *work) { struct mt7615_dev *dev; @@ -1602,9 +1621,12 @@ void mt7615_mac_work(struct work_struct *work) if (++dev->mac_work_count == 5) { ext_phy = mt7615_ext_phy(dev); + mt7615_mac_update_mib_stats(&dev->phy); mt7615_mac_scs_check(&dev->phy); - if (ext_phy) + if (ext_phy) { + mt7615_mac_update_mib_stats(ext_phy); mt7615_mac_scs_check(ext_phy); + } dev->mac_work_count = 0; } diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index eaafae9cc279..d215a84d6c49 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -87,6 +87,13 @@ struct mt7615_vif { struct mt7615_sta sta; }; +struct mib_stats { + u32 ack_fail_cnt; + u32 fcs_err_cnt; + u32 rts_cnt; + u32 rts_retries_cnt; +}; + struct mt7615_phy { struct mt76_phy *mt76; struct mt7615_dev *dev; @@ -112,6 +119,8 @@ struct mt7615_phy { __le32 rx_ampdu_ts; u32 ampdu_ref; + + struct mib_stats mib; }; struct mt7615_dev { diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h index b0c14067a832..40e58b332e75 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h @@ -333,10 +333,9 @@ #define MT_WF_MIB(ofs) (MT_WF_MIB_BASE + (ofs)) #define MT_MIB_M0_MISC_CR MT_WF_MIB(0x00c) -#define MT_MIB_MB_SDR(_band, n) MT_WF_MIB(0x100 + ((_band) << 9) + \ - ((n) << 4)) -#define MT_MIB_RTS_RETRIES_COUNT_MASK GENMASK(31, 16) -#define MT_MIB_RTS_COUNT_MASK GENMASK(15, 0) + +#define MT_MIB_SDR3(n) MT_WF_MIB(0x014 + ((n) << 9)) +#define MT_MIB_SDR3_FCS_ERR_MASK GENMASK(15, 0) #define MT_MIB_SDR9(n) MT_WF_MIB(0x02c + ((n) << 9)) #define MT_MIB_SDR9_BUSY_MASK GENMASK(23, 0) @@ -349,6 +348,15 @@ #define MT_MIB_SDR37(n) MT_WF_MIB(0x09c + ((n) << 9)) #define MT_MIB_SDR37_RXTIME_MASK GENMASK(23, 0) +#define MT_MIB_MB_SDR0(_band, n) MT_WF_MIB(0x100 + ((_band) << 9) + \ + ((n) << 4)) +#define MT_MIB_RTS_RETRIES_COUNT_MASK GENMASK(31, 16) +#define MT_MIB_RTS_COUNT_MASK GENMASK(15, 0) + +#define MT_MIB_MB_SDR1(_band, n) MT_WF_MIB(0x104 + ((_band) << 9) + \ + ((n) << 4)) +#define MT_MIB_ACK_FAIL_COUNT_MASK GENMASK(31, 16) + #define MT_TX_AGG_CNT(n) MT_WF_MIB(0xa8 + ((n) << 2)) #define MT_LED_BASE_PHYS 0x80024000 From patchwork Sat Dec 28 03:05:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11311435 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E6B117EE for ; Sat, 28 Dec 2019 03:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5D02C20CC7 for ; Sat, 28 Dec 2019 03:06:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="cOcFuJqe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726106AbfL1DGc (ORCPT ); Fri, 27 Dec 2019 22:06:32 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:7575 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726044AbfL1DGc (ORCPT ); Fri, 27 Dec 2019 22:06:32 -0500 X-UUID: 5cbc3f8681d24474b03547c3bba3cf04-20191228 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=ij959lRItOwY5+DCQXFnh/qX3GVtKszFINCfTg2rMt0=; b=cOcFuJqeNqJzsxEgXG0pEyElfAwG+mNT6edzRkGVUhUMcrIJTeR45dYM2Nvi8B6gnb5GmTxnurXqGnzNThjEGcXudf60Ysd3HAfVODm0peL3SjTtNW3p8BPVJkNJz7wwMSncmk464g8+pmLZvnsLGKDVlox1+LITRSQwB71bf5c=; X-UUID: 5cbc3f8681d24474b03547c3bba3cf04-20191228 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 1336383943; Sat, 28 Dec 2019 11:06:29 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 28 Dec 2019 11:05:52 +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; Sat, 28 Dec 2019 11:05:52 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , Roy Luo , Sean Wang , , , Ryder Lee Subject: [PATCH v1 3/3] mt76: mt7615: add a get_stats() callback Date: Sat, 28 Dec 2019 11:05:12 +0800 Message-ID: <294f99d401beeee1e7f1e65bf32d580d1568aa24.1577501739.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <769aba6e014b8e7650c3909d6adb8427c1d5c5ae.1577501739.git.ryder.lee@mediatek.com> References: <769aba6e014b8e7650c3909d6adb8427c1d5c5ae.1577501739.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: C67F8ACB24958420C070F8DC06EF8CBC01D642FFE0CBF873142BF4F0890688832000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add a get_stats() callback for mib statistics. Signed-off-by: Ryder Lee --- drivers/net/wireless/mediatek/mt76/mt7615/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index fa67331918ea..4a2bf689c795 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -628,6 +628,21 @@ mt7615_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, IEEE80211_STA_NOTEXIST); } +static int +mt7615_get_stats(struct ieee80211_hw *hw, + struct ieee80211_low_level_stats *stats) +{ + struct mt7615_phy *phy = mt7615_hw_phy(hw); + struct mib_stats *mib = &phy->mib; + + stats->dot11RTSSuccessCount = mib->rts_cnt; + stats->dot11RTSFailureCount = mib->rts_retries_cnt; + stats->dot11FCSErrorCount = mib->fcs_err_cnt; + stats->dot11ACKFailureCount = mib->ack_fail_cnt; + + return 0; +} + static u64 mt7615_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -679,6 +694,7 @@ const struct ieee80211_ops mt7615_ops = { .release_buffered_frames = mt76_release_buffered_frames, .get_txpower = mt76_get_txpower, .channel_switch_beacon = mt7615_channel_switch_beacon, + .get_stats = mt7615_get_stats, .get_tsf = mt7615_get_tsf, .get_survey = mt76_get_survey, .get_antenna = mt76_get_antenna,