From patchwork Wed Jul 27 23:01:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0DCDC19F21 for ; Wed, 27 Jul 2022 23:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbiG0XBt (ORCPT ); Wed, 27 Jul 2022 19:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE79205FE for ; Wed, 27 Jul 2022 16:01:41 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.51.175]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 3E6BE2A0067; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id E843A8C006D; Wed, 27 Jul 2022 23:01:39 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 26E0D13C2B0; Wed, 27 Jul 2022 16:01:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 26E0D13C2B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962899; bh=EC2BmCjurYco6v0Wfnf1T+ug9L/KqD2oY9ZDWW57czs=; h=From:To:Cc:Subject:Date:From; b=ZtdU7pTBcePB7TW/Qz9usM72VzPHPoX3FMWZZuBVCgXAGXUG2iPBoV/mF1FMSZ/KU OqlZxvorXJW/WamJLnsEMcCigixtheyLvFcSE4e8ATJLDr7Z1go28hOHxF/VyUUO5Z tu9wUomI3/B9VPn3TOTlIRM+xSuXnvJHwHH+cmV8= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 01/12] wifi: mt76: mt7915: cache sgi in wcid. Date: Wed, 27 Jul 2022 16:01:11 -0700 Message-Id: <20220727230122.29842-1-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-MDID: 1658962900-L_PJN7FpGswg Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Explicitly cache short_gi and he_gi in wcid, don't try to store it in the wcid.rate object. Slightly less confusing and less fragile when TXS starts parsing lots of frames. Signed-off-by: Ben Greear --- These patches have mostly been posted before. They are now rebased on top of latest 5.19 upstream kernel. Checkpatch has been run on them, some patches have been merged, a few dropped per previous requests. Lightly tested on 5.19, similar code was well tested on 5.17. drivers/net/wireless/mediatek/mt76/mt76.h | 5 +++++ drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 4e8997c45c1b..f994d1e18ac6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -272,7 +272,12 @@ struct mt76_wcid { struct ewma_signal rssi; int inactive_count; + /* cached rate, updated from mac_sta_poll() and from TXS callback logic, + * in 7915 at least. + */ struct rate_info rate; + bool rate_short_gi; /* cached HT/VHT short_gi, from mac_sta_poll() */ + u8 rate_he_gi; /* cached HE GI, from mac_sta_poll() */ u16 idx; u8 hw_key_idx; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 46fc07877b7d..62a2dc47938e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -206,12 +206,16 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev) u8 offs = 24 + 2 * bw; rate->he_gi = (val & (0x3 << offs)) >> offs; + msta->wcid.rate_he_gi = rate->he_gi; /* cache for later */ } else if (rate->flags & (RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) { - if (val & BIT(12 + bw)) + if (val & BIT(12 + bw)) { rate->flags |= RATE_INFO_FLAGS_SHORT_GI; - else + msta->wcid.rate_short_gi = 1; + } else { rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI; + msta->wcid.rate_short_gi = 0; + } } } @@ -1667,7 +1671,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, goto out; rate.flags = RATE_INFO_FLAGS_MCS; - if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI) + if (wcid->rate_short_gi) rate.flags |= RATE_INFO_FLAGS_SHORT_GI; break; case MT_PHY_TYPE_VHT: @@ -1675,6 +1679,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, goto out; rate.flags = RATE_INFO_FLAGS_VHT_MCS; + if (wcid->rate_short_gi) + rate.flags |= RATE_INFO_FLAGS_SHORT_GI; break; case MT_PHY_TYPE_HE_SU: case MT_PHY_TYPE_HE_EXT_SU: @@ -1683,11 +1689,12 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, if (rate.mcs > 11) goto out; - rate.he_gi = wcid->rate.he_gi; + rate.he_gi = wcid->rate_he_gi; rate.he_dcm = FIELD_GET(MT_TX_RATE_DCM, txrate); rate.flags = RATE_INFO_FLAGS_HE_MCS; break; default: + WARN_ON_ONCE(true); goto out; } From patchwork Wed Jul 27 23:01:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FF14C04A68 for ; Wed, 27 Jul 2022 23:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232724AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbiG0XBm (ORCPT ); Wed, 27 Jul 2022 19:01:42 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2D151FCC7 for ; Wed, 27 Jul 2022 16:01:41 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.67.129]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 2B74F1A0080; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id EBC8050007E; Wed, 27 Jul 2022 23:01:39 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 6395C13C2B1; Wed, 27 Jul 2022 16:01:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 6395C13C2B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962899; bh=kXQXO3rSUUuSpLoLuCJGYmcnPbKfMLEcMXz+La9UHF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhM9FsLazDQAoOgxcLYEF7rO8dMEKa43gURamWZCZpyZaQMzis9oVrk/7/RqINPJt SCRK8OHddO/8jY5kk/xGzEUsDIC9j1eKIjEa9uZKCEbqhwbqbp7Fj0lxpYT7OR4tFc MSIac5H/cTpDwY406VtHAQB6dI8/I3BmV5MMU6vw= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 02/12] wifi: mt76: mt7915: allow processing TXS for 'NO_SKB' pkt-ids Date: Wed, 27 Jul 2022 16:01:12 -0700 Message-Id: <20220727230122.29842-2-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962900-tLlJopnbjydw Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear This will let us update stats and wcid.rate for every TXS callback we receive for a particular wcid. For now, the TXS is not requested for NO_SKB frames, however. That will be allowed in next patch. Signed-off-by: Ben Greear --- .../net/wireless/mediatek/mt76/mt7915/mac.c | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 62a2dc47938e..2d1a8d8b04fb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1614,26 +1614,31 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, struct ieee80211_tx_info *info; struct sk_buff_head list; struct rate_info rate = {}; - struct sk_buff *skb; + struct sk_buff *skb = NULL; + bool check_status; bool cck = false; u32 txrate, txs, mode; - mt76_tx_status_lock(mdev, &list); - skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); - if (!skb) - goto out_no_skb; + check_status = (pid >= MT_PACKET_ID_FIRST); + + if (check_status) { + mt76_tx_status_lock(mdev, &list); + skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); + } txs = le32_to_cpu(txs_data[0]); - info = IEEE80211_SKB_CB(skb); - if (!(txs & MT_TXS0_ACK_ERROR_MASK)) - info->flags |= IEEE80211_TX_STAT_ACK; + if (skb) { + info = IEEE80211_SKB_CB(skb); + if (!(txs & MT_TXS0_ACK_ERROR_MASK)) + info->flags |= IEEE80211_TX_STAT_ACK; - info->status.ampdu_len = 1; - info->status.ampdu_ack_len = !!(info->flags & - IEEE80211_TX_STAT_ACK); + info->status.ampdu_len = 1; + info->status.ampdu_ack_len = !!(info->flags & + IEEE80211_TX_STAT_ACK); - info->status.rates[0].idx = -1; + info->status.rates[0].idx = -1; + } txrate = FIELD_GET(MT_TXS0_TX_RATE, txs); @@ -1721,10 +1726,11 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, wcid->rate = rate; out: - mt76_tx_status_skb_done(mdev, skb, &list); + if (skb) + mt76_tx_status_skb_done(mdev, skb, &list); -out_no_skb: - mt76_tx_status_unlock(mdev, &list); + if (check_status) + mt76_tx_status_unlock(mdev, &list); return !!skb; } @@ -1743,7 +1749,7 @@ static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data) wcidx = le32_get_bits(txs_data[2], MT_TXS2_WCID); pid = le32_get_bits(txs_data[3], MT_TXS3_PID); - if (pid < MT_PACKET_ID_FIRST) + if (pid < MT_PACKET_ID_NO_SKB) return; if (wcidx >= mt7915_wtbl_size(dev)) From patchwork Wed Jul 27 23:01:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2864C3F6B0 for ; Wed, 27 Jul 2022 23:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234046AbiG0XBr (ORCPT ); Wed, 27 Jul 2022 19:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231808AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EED2C205E7 for ; Wed, 27 Jul 2022 16:01:41 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.51.165]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 5B91420061; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 0F6679C0066; Wed, 27 Jul 2022 23:01:39 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 8D80813C2B3; Wed, 27 Jul 2022 16:01:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 8D80813C2B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962899; bh=hw54Lh/cn+8Lf1SYZ1CzOHrOZuIUOp2lGdLr85Xg6eI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jJnYj9AB0JLiRaMSrWSytXAPTmwv6tiZAhemcunPRz0dyXikrYWTV2hjnYraWlfmM nTQKse/0+SGNkhiDROzHG9OzOK4/wiDwb7DJy/h+xbi9Kkq/pngY2IsZAqHVXaH3r8 DCm2dipOrRY2Xr+HsctgvpACau0Zzf/cqyUHBHkc= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 03/12] wifi: mt76: mt7915: debugfs hook to enable TXS for NO_SKB pkt-ids Date: Wed, 27 Jul 2022 16:01:13 -0700 Message-Id: <20220727230122.29842-3-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962900-osxRL_D2RqZY Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear This lets user turn on/off this feature. Enabling gives better tx-rate related stats, but will cause extra driver and (maybe) firmware work. Not sure if it actually affects performance or not. Signed-off-by: Ben Greear --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 24 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 3 ++- .../wireless/mediatek/mt76/mt7915/mt7915.h | 5 ++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index cab6e02e1f8c..f71d80cd4002 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -633,6 +633,29 @@ mt7915_fw_util_wa_show(struct seq_file *file, void *data) DEFINE_SHOW_ATTRIBUTE(mt7915_fw_util_wa); +static int +mt7915_txs_for_no_skb_set(void *data, u64 val) +{ + struct mt7915_dev *dev = data; + + dev->txs_for_no_skb_enabled = !!val; + + return 0; +} + +static int +mt7915_txs_for_no_skb_get(void *data, u64 *val) +{ + struct mt7915_dev *dev = data; + + *val = dev->txs_for_no_skb_enabled; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_txs_for_no_skb, mt7915_txs_for_no_skb_get, + mt7915_txs_for_no_skb_set, "%lld\n"); + static void mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy, struct seq_file *file) @@ -1017,6 +1040,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) &mt7915_fw_util_wm_fops); debugfs_create_file("fw_util_wa", 0400, dir, dev, &mt7915_fw_util_wa_fops); + debugfs_create_file("force_txs", 0600, dir, dev, &fops_txs_for_no_skb); debugfs_create_file("implicit_txbf", 0600, dir, dev, &fops_implicit_txbf); debugfs_create_file("txpower_sku", 0400, dir, phy, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 2d1a8d8b04fb..cf4d11c0a88d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1257,7 +1257,8 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, txwi[4] = 0; val = FIELD_PREP(MT_TXD5_PID, pid); - if (pid >= MT_PACKET_ID_FIRST) + if (pid >= MT_PACKET_ID_FIRST || + (pid == MT_PACKET_ID_NO_SKB && dev->txs_for_no_skb_enabled)) val |= MT_TXD5_TX_STATUS_HOST; txwi[5] = cpu_to_le32(val); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 4dcae6991669..fa755bfa223f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -294,6 +294,11 @@ struct mt7915_dev { u16 chainmask; u16 chainshift; u32 hif_idx; + /* Should we request TXS for MT_PACKET_ID_NO_SKB? Doing so gives better + * costs but causes a great deal more TXS packet processing by driver and + * creation by firmware, so may be a performance drag. + */ + bool txs_for_no_skb_enabled; struct work_struct init_work; struct work_struct rc_work; From patchwork Wed Jul 27 23:01:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED24EC19F2B for ; Wed, 27 Jul 2022 23:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234022AbiG0XBp (ORCPT ); Wed, 27 Jul 2022 19:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231587AbiG0XBm (ORCPT ); Wed, 27 Jul 2022 19:01:42 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2F1A1FCF4 for ; Wed, 27 Jul 2022 16:01:41 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.64.31]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 471041C0087; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 1A21B600079; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id B85B613C2B4; Wed, 27 Jul 2022 16:01:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com B85B613C2B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962899; bh=/PN2qJTTJOcxuwObz7TvZN3FTEksAAunF11gXOzaFng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVvca/MPWVPhwnP71N8jaEenMrXmcBnLXOn3GSyte7VWIMsEvmzjMrec9FfCYiAf7 hkFkU3GtP2snRAQk3Y7tUFez2V8eMfu+OmIpshaC+GOe/ypd67cZf3QT+TCVTidMdm o0ob5AaK9QkHe1bqRlTTw5ZepemTiR9ypHRfz/sc= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 04/12] wifi: mt76: mt7915: txfree status to show txcount instead of latency Date: Wed, 27 Jul 2022 16:01:14 -0700 Message-Id: <20220727230122.29842-4-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962900-E5PEqJlAzysd Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Latency is not obviously that useful, but txcount can let us deduce retries, which may be more interesting. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt7915/mac.h | 6 +++++- drivers/net/wireless/mediatek/mt76/mt7915/regs.h | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index 91a31b9d52f2..b4ceb78c6745 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -460,6 +460,9 @@ static void mt7915_mac_init(struct mt7915_dev *dev) /* enable hardware de-agg */ mt76_set(dev, MT_MDP_DCR0, MT_MDP_DCR0_DAMSDU_EN); + /* disable Tx latency report to enable Tx count in txfree path */ + mt76_clear(dev, MT_PLE_HOST_RPT0, MT_PLE_HOST_RPT0_TX_LATENCY); + for (i = 0; i < mt7915_wtbl_size(dev); i++) mt7915_mac_wtbl_update(dev, i, MT_WTBL_UPDATE_ADM_COUNT_CLEAR); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h index 2e6c574ae2dd..503a4b90ad11 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h @@ -314,8 +314,12 @@ struct mt7915_tx_free { #define MT_TX_FREE_MSDU_CNT GENMASK(9, 0) #define MT_TX_FREE_MSDU_CNT_V0 GENMASK(6, 0) #define MT_TX_FREE_WLAN_ID GENMASK(23, 14) +/* when configured for txfree latency mode. See MT_PLE_HOST_RPT0_TX_LATENCY + * Not enabled by default now. + */ #define MT_TX_FREE_LATENCY GENMASK(12, 0) -/* 0: success, others: dropped */ +/* when configured for txcount mode. See MT_PLE_HOST_RPT0_TX_LATENCY. */ +#define MT_TX_FREE_TXCNT GENMASK(12, 0) #define MT_TX_FREE_MSDU_ID GENMASK(30, 16) #define MT_TX_FREE_PAIR BIT(31) #define MT_TX_FREE_MPDU_HEADER BIT(30) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h index 4953be208c5e..8bbc9a0ae699 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h @@ -132,6 +132,10 @@ enum offs_rev { #define MT_PLE_BASE 0x820c0000 #define MT_PLE(ofs) (MT_PLE_BASE + (ofs)) +/* Modify whether txfree struct returns latency or txcount. */ +#define MT_PLE_HOST_RPT0 MT_PLE(0x030) +#define MT_PLE_HOST_RPT0_TX_LATENCY BIT(3) + #define MT_FL_Q_EMPTY MT_PLE(__OFFS(PLE_FL_Q_EMPTY)) #define MT_FL_Q0_CTRL MT_PLE(__OFFS(PLE_FL_Q_CTRL)) #define MT_FL_Q2_CTRL MT_PLE(__OFFS(PLE_FL_Q_CTRL) + 0x8) From patchwork Wed Jul 27 23:01:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89FAAC04A68 for ; Wed, 27 Jul 2022 23:01:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234028AbiG0XBr (ORCPT ); Wed, 27 Jul 2022 19:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232117AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26DAC20BC8 for ; Wed, 27 Jul 2022 16:01:42 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.50.13]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id AD9D82006B; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 6343144007B; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id E383713C2B5; Wed, 27 Jul 2022 16:01:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com E383713C2B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962900; bh=iNPpF5eBazapsbPEYZRJvxx9G/EA3qaLanT0Pqanj2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DvS573ZpwFKBDggh5rNhDZvqT3oNt5xAkWQtaElqBrF+82uVs+3Rli9M0Lf3RspCX 4enOfKGO3zqsUU9CvsYL2p4M7MKr99V91OW67vHz83mtBAEo58JHDpI4G4YKziu7S4 PQpnAmu4x2ES6to8qT9UAHzwNfFPcQLboF9c5zgw= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 05/12] wifi: mt76: mt7915: report tx-retries Date: Wed, 27 Jul 2022 16:01:15 -0700 Message-Id: <20220727230122.29842-5-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962901-AVRoz5JIHZQD Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear mac80211 stack will only report tx-status for skb claiming to be ampdu heads, so lie a bit in mt7915 and set the flag so that mac80211 will record status for each skb. mt7915 appears to report retry status on an individual per-skb manner, so that method above seems to work. Re-constitute the txinfo status rate info so that the rix and flags is also at least close to correct. No direct way to report HE rates that way, so mac80211 might could use some tweaking in the ieee80211_tx_status_ext to take both info and status->rate into account. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mac80211.c | 4 + drivers/net/wireless/mediatek/mt76/mt76.h | 5 + .../net/wireless/mediatek/mt76/mt7915/init.c | 1 + .../net/wireless/mediatek/mt76/mt7915/mac.c | 95 ++++++++++++++++++- .../net/wireless/mediatek/mt76/mt7915/mac.h | 6 +- .../net/wireless/mediatek/mt76/mt7915/main.c | 4 + .../net/wireless/mediatek/mt76/mt7921/main.c | 4 + drivers/net/wireless/mediatek/mt76/tx.c | 18 +++- 8 files changed, 129 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index 18b5de55334c..242e055fa475 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -1628,6 +1628,10 @@ void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, wi->sta_count++; + data[ei++] += stats->tx_mpdu_attempts; + data[ei++] += stats->tx_mpdu_fail; + data[ei++] += stats->tx_mpdu_retry; + data[ei++] += stats->tx_mpdu_ok; data[ei++] += stats->tx_mode[MT_PHY_TYPE_CCK]; data[ei++] += stats->tx_mode[MT_PHY_TYPE_OFDM]; data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT]; diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index f994d1e18ac6..62a5e2ad6764 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -826,6 +826,11 @@ enum mt76_phy_type { }; struct mt76_sta_stats { + unsigned long tx_mpdu_attempts; /* counting any retries */ + unsigned long tx_mpdu_fail; /* frames that failed even after retry */ + /* frames that succeeded, perhaps after retry */ + unsigned long tx_mpdu_ok; + unsigned long tx_mpdu_retry; /* number of times frames were retried */ u64 tx_mode[__MT_PHY_TYPE_HE_MAX]; u64 tx_bw[4]; /* 20, 40, 80, 160 */ u64 tx_nss[4]; /* 1, 2, 3, 4 */ diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index b4ceb78c6745..5af9fade3a17 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -329,6 +329,7 @@ mt7915_init_wiphy(struct ieee80211_hw *hw) struct mt7915_dev *dev = phy->dev; hw->queues = 4; + hw->max_report_rates = 1; hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF_HE; hw->netdev_features = NETIF_F_RXCSUM; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index cf4d11c0a88d..800028a713a0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1428,18 +1428,23 @@ mt7915_txp_skb_unmap(struct mt76_dev *dev, struct mt76_txwi_cache *t) static void mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t, - struct ieee80211_sta *sta, struct list_head *free_list) + struct ieee80211_sta *sta, struct list_head *free_list, + u32 tx_cnt, u32 tx_status, u32 ampdu) { struct mt76_dev *mdev = &dev->mt76; struct mt7915_sta *msta; struct mt76_wcid *wcid; __le32 *txwi; u16 wcid_idx; + struct ieee80211_tx_info *info; + struct ieee80211_tx_rate *rate; mt7915_txp_skb_unmap(mdev, t); if (!t->skb) goto out; + rcu_read_lock(); /* protect wcid access */ + txwi = (__le32 *)mt76_get_txwi_ptr(mdev, t); if (sta) { wcid = (struct mt76_wcid *)sta->drv_priv; @@ -1462,6 +1467,74 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t, if (sta && likely(t->skb->protocol != cpu_to_be16(ETH_P_PAE))) mt7915_tx_check_aggr(sta, txwi); + info = IEEE80211_SKB_CB(t->skb); + + /* Cannot clear all of info->status, we need the driver private + * status intact. + */ + info->status.flags = 0; + + rate = &info->status.rates[0]; + rate->idx = -1; /* will over-write below if we found wcid */ + info->status.rates[1].idx = -1; /* terminate rate list */ + + /* force TX_STAT_AMPDU to be set, or mac80211 will ignore status */ + if (ampdu || (info->flags & IEEE80211_TX_CTL_AMPDU)) { + info->flags |= IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_CTL_AMPDU; + info->status.ampdu_len = 1; + } + + /* update info status based on cached wcid rate info since + * txfree path doesn't give us a lot of info. + */ + if (wcid) { + struct mt7915_sta *msta = container_of(wcid, struct mt7915_sta, wcid); + struct mt76_sta_stats *stats = &msta->stats; + + if (wcid->rate.flags & RATE_INFO_FLAGS_MCS) { + rate->flags |= IEEE80211_TX_RC_MCS; + rate->idx = wcid->rate.mcs + wcid->rate.nss * 8; + } else if (wcid->rate.flags & RATE_INFO_FLAGS_VHT_MCS) { + rate->flags |= IEEE80211_TX_RC_VHT_MCS; + rate->idx = (wcid->rate.nss << 4) | wcid->rate.mcs; + } else if (wcid->rate.flags & RATE_INFO_FLAGS_HE_MCS) { + rate->idx = (wcid->rate.nss << 4) | wcid->rate.mcs; + } else { + rate->idx = wcid->rate.mcs; + } + + switch (wcid->rate.bw) { + case RATE_INFO_BW_160: + rate->flags |= IEEE80211_TX_RC_160_MHZ_WIDTH; + break; + case RATE_INFO_BW_80: + rate->flags |= IEEE80211_TX_RC_80_MHZ_WIDTH; + break; + case RATE_INFO_BW_40: + rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; + break; + } + + stats->tx_mpdu_attempts += tx_cnt; + stats->tx_mpdu_retry += tx_cnt - 1; + + if (tx_status == 0) + stats->tx_mpdu_ok++; + else + stats->tx_mpdu_fail++; + } + + rcu_read_unlock(); + + /* Apply the values that this txfree path reports */ + rate->count = tx_cnt; + if (tx_status == 0) { + info->flags |= IEEE80211_TX_STAT_ACK; + info->status.ampdu_ack_len = 1; + } else { + info->flags &= ~IEEE80211_TX_STAT_ACK; + } + __mt76_tx_complete_skb(mdev, wcid_idx, t->skb, free_list); out: @@ -1527,6 +1600,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) for (cur_info = &free->info[0]; count < total; cur_info++) { u32 msdu, info = le32_to_cpu(*cur_info); u8 i; + u32 tx_cnt, tx_status, ampdu; /* * 1'b1: new wcid pair. @@ -1559,15 +1633,25 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) msdu = (info >> (15 * i)) & MT_TX_FREE_MSDU_ID_V3; if (msdu == MT_TX_FREE_MSDU_ID_V3) continue; + + /* TODO: How to get tx_cnt, tx_status, ampdu*/ + tx_status = 0; + tx_cnt = 1; + ampdu = 1; } else { msdu = FIELD_GET(MT_TX_FREE_MSDU_ID, info); + + tx_cnt = FIELD_GET(MT_TX_FREE_TXCNT, info); + /* 0 = success, 1 dropped-by-hw, 2 dropped-by-cpu */ + tx_status = FIELD_GET(MT_TX_FREE_STATUS_V1, info); + ampdu = FIELD_GET(MT_TX_FREE_HEAD_OF_PAGE, info); } count++; txwi = mt76_token_release(mdev, msdu, &wake); if (!txwi) continue; - mt7915_txwi_free(dev, txwi, sta, &free_list); + mt7915_txwi_free(dev, txwi, sta, &free_list, tx_cnt, tx_status, ampdu); } } @@ -1599,7 +1683,10 @@ mt7915_mac_tx_free_v0(struct mt7915_dev *dev, void *data, int len) if (!txwi) continue; - mt7915_txwi_free(dev, txwi, NULL, &free_list); + /* TODO: Can we report tx_cnt, status, ampdu in this path? */ + mt7915_txwi_free(dev, txwi, NULL, &free_list, + 1 /* tx_cnt */, 0 /* tx-status-ok */, + 0/* ampdu */); } mt7915_mac_tx_free_done(dev, &free_list, wake); @@ -2132,7 +2219,7 @@ void mt7915_tx_token_put(struct mt7915_dev *dev) spin_lock_bh(&dev->mt76.token_lock); idr_for_each_entry(&dev->mt76.token, txwi, id) { - mt7915_txwi_free(dev, txwi, NULL, NULL); + mt7915_txwi_free(dev, txwi, NULL, NULL, 0, 1, 0); dev->mt76.token_count--; } spin_unlock_bh(&dev->mt76.token_lock); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h index 503a4b90ad11..a3774df64e8b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h @@ -307,7 +307,7 @@ struct mt7915_tx_free { __le16 rx_byte_cnt; __le16 ctrl; __le32 txd; - __le32 info[]; + __le32 info[]; /* DW3+ */ } __packed __aligned(4); #define MT_TX_FREE_VER GENMASK(18, 16) @@ -320,6 +320,10 @@ struct mt7915_tx_free { #define MT_TX_FREE_LATENCY GENMASK(12, 0) /* when configured for txcount mode. See MT_PLE_HOST_RPT0_TX_LATENCY. */ #define MT_TX_FREE_TXCNT GENMASK(12, 0) +/* 0: success, others: dropped */ +#define MT_TX_FREE_STATUS_V1 GENMASK(14, 13) +/* 0: not MPDU, 1: MSDU is head pkt of TXD page (MPDU) */ +#define MT_TX_FREE_HEAD_OF_PAGE BIT(15) #define MT_TX_FREE_MSDU_ID GENMASK(30, 16) #define MT_TX_FREE_PAIR BIT(31) #define MT_TX_FREE_MPDU_HEADER BIT(30) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 710ca757fb52..910dc36bacc3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1158,6 +1158,10 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_ba_cnt", /* per vif counters */ + "v_tx_mpdu_attempts", /* counting any retries */ + "v_tx_mpdu_fail", /* frames that failed even after retry */ + "v_tx_mpdu_retry", /* number of times frames were retried */ + "v_tx_mpdu_ok", /* frames that succeeded, perhaps after retry */ "v_tx_mode_cck", "v_tx_mode_ofdm", "v_tx_mode_ht", diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index 80279f342109..ac78fcf285bf 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -987,6 +987,10 @@ static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_ampdu_bytes_cnt", "rx_ba_cnt", /* per vif counters */ + "v_tx_mpdu_attempts", /* counting any retries */ + "v_tx_mpdu_fail", /* frames that failed even after retry */ + "v_tx_mpdu_retry", /* number of times frames were retried */ + "v_tx_mpdu_ok", /* frames that succeeded, perhaps after retry */ "v_tx_mode_cck", "v_tx_mode_ofdm", "v_tx_mode_ht", diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index 1d08d99e298c..4e24116abc14 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c @@ -62,12 +62,15 @@ mt76_tx_status_unlock(struct mt76_dev *dev, struct sk_buff_head *list) }; struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb); struct mt76_wcid *wcid; + struct ieee80211_rate_status status_rate = { 0 }; wcid = rcu_dereference(dev->wcid[cb->wcid]); if (wcid) { status.sta = wcid_to_sta(wcid); - status.rates = NULL; - status.n_rates = 0; + status.rates = &status_rate; + status.n_rates = 1; + status_rate.rate_idx = wcid->rate; + status_rate.try_count = 1; } hw = mt76_tx_status_get_hw(dev, skb); @@ -228,15 +231,24 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff * struct ieee80211_tx_status status = { .skb = skb, .free_list = free_list, + .info = IEEE80211_SKB_CB(skb), }; struct mt76_wcid *wcid = NULL; struct ieee80211_hw *hw; struct sk_buff_head list; + struct ieee80211_rate_status status_rate = { 0 }; rcu_read_lock(); - if (wcid_idx < ARRAY_SIZE(dev->wcid)) + if (wcid_idx < ARRAY_SIZE(dev->wcid)) { wcid = rcu_dereference(dev->wcid[wcid_idx]); + if (wcid) { + status.rates = &status_rate; + status.n_rates = 1; + status_rate.rate_idx = wcid->rate; + status_rate.try_count = 1; + } + } mt76_tx_check_non_aql(dev, wcid, skb); From patchwork Wed Jul 27 23:01:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 541E9C25B07 for ; Wed, 27 Jul 2022 23:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235564AbiG0XBv (ORCPT ); Wed, 27 Jul 2022 19:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233576AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EAD120F56 for ; Wed, 27 Jul 2022 16:01:42 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.64.75]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id AE86C1C0063; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 7983C80078; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 18AFD13C2B6; Wed, 27 Jul 2022 16:01:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 18AFD13C2B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962900; bh=at+iEdlDVxVAKQNcJKd7PyKXREmExs0VaGmwWj8gzHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddzgGHRGXCfFJaUlHhHerF0hnO1qda0XAYLMOUgnbP2JSWQpAOaB/Le8CcSfR0WWr lGUang3D5Pxf+Cz9gET5DpYdAJKUQMIKO0WpAW4dH+3Znoci4I6RbVY/vbKn0W2vgq k4E+Ep/PNinZqoYVmjMMpAFo23+HkCNMDpbe2NA8= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 06/12] wifi: mt76: mt7915: add support for tx-overrides Date: Wed, 27 Jul 2022 16:01:16 -0700 Message-Id: <20220727230122.29842-6-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962901-GJCSCuM-P_Gw Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Allow setting fixied rate on transmit without using full testmode logic. The goal of tx-overrides is to allow receiver sensitivity and other types of testing. Assumption is that the packets we care about are larger data frames, so exclude smaller packets and non data packets. Setting transmit count to '0' means transmit once, but flag the packet as no-ack. Allows adjusting the tx power from default value, from -8 to +8 dbm. Adjusting above 0 is probably not a good idea. The station wtbl logic to read rate-ctrl settings does not work when fixed rates are used. So, read sgi settings from the txo configuration in this case. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mt76.h | 4 + .../wireless/mediatek/mt76/mt7915/debugfs.c | 225 ++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 149 +++++++++--- .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 + 4 files changed, 350 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 62a5e2ad6764..682b554fbcb7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -611,6 +611,7 @@ struct mt76_testmode_ops { struct mt76_testmode_data { enum mt76_testmode_state state; + u8 txo_active; /* tx overrides are active */ u32 param_set[DIV_ROUND_UP(NUM_MT76_TM_ATTRS, 32)]; struct sk_buff *tx_skb; @@ -625,6 +626,9 @@ struct mt76_testmode_data { u8 tx_rate_ldpc; u8 tx_rate_stbc; u8 tx_ltf; + u8 txbw; /* specify TX bandwidth: 0 20Mhz, 1 40Mhz, 2 80Mhz, 3 160Mhz */ + u8 tx_xmit_count; /* 0 means no-ack, 1 means one transmit, etc */ + u8 tx_dynbw; /* 0: dynamic bw disabled, 1: dynamic bw enabled */ u8 tx_antenna_mask; u8 tx_spe_idx; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index f71d80cd4002..6ff1ce6e4cfc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -633,6 +633,229 @@ mt7915_fw_util_wa_show(struct seq_file *file, void *data) DEFINE_SHOW_ATTRIBUTE(mt7915_fw_util_wa); +struct mt7915_txo_worker_info { + char *buf; + int sofar; + int size; +}; + +static void mt7915_txo_worker(void *wi_data, struct ieee80211_sta *sta) +{ + struct mt7915_txo_worker_info *wi = wi_data; + struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv; + struct mt76_testmode_data *td = &msta->test; + struct ieee80211_vif *vif; + struct wireless_dev *wdev; + + if (wi->sofar >= wi->size) + return; /* buffer is full */ + + vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); + wdev = ieee80211_vif_to_wdev(vif); + + wi->sofar += scnprintf(wi->buf + wi->sofar, wi->size - wi->sofar, + "vdev (%s) active=%d tpc=%d sgi=%d mcs=%d nss=%d" + " pream=%d retries=%d dynbw=%d bw=%d\n", + wdev->netdev->name, + td->txo_active, td->tx_power[0], + td->tx_rate_sgi, td->tx_rate_idx, + td->tx_rate_nss, td->tx_rate_mode, + td->tx_xmit_count, td->tx_dynbw, + td->txbw); +} + +static ssize_t mt7915_read_set_rate_override(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct mt7915_dev *dev = file->private_data; + struct ieee80211_hw *hw = dev->mphy.hw; + char *buf2; + int size = 8000; + int rv, sofar; + struct mt7915_txo_worker_info wi; + const char buf[] = + "This allows specify specif tx rate parameters for all DATA" + " frames on a vdev\n" + "To set a value, you specify the dev-name and key-value pairs:\n" + "tpc=10 sgi=1 mcs=x nss=x pream=x retries=x dynbw=0|1 bw=x enable=0|1\n" + "pream: 0=cck, 1=ofdm, 2=HT, 3=VHT, 4=HE_SU\n" + "cck-mcs: 0=1Mbps, 1=2Mbps, 3=5.5Mbps, 3=11Mbps\n" + "ofdm-mcs: 0=6Mbps, 1=9Mbps, 2=12Mbps, 3=18Mbps, 4=24Mbps, 5=36Mbps," + " 6=48Mbps, 7=54Mbps\n" + "tpc: adjust power from defaults, in 1/2 db units 0 - 31, 16 is default\n" + "bw is 0-3 for 20-160\n" + " For example, wlan0:\n" + "echo \"wlan0 tpc=255 sgi=1 mcs=0 nss=1 pream=3 retries=1 dynbw=0 bw=0" + " active=1\" > ...mt76/set_rate_override\n"; + + buf2 = kzalloc(size, GFP_KERNEL); + if (!buf2) + return -ENOMEM; + strcpy(buf2, buf); + sofar = strlen(buf2); + + wi.sofar = sofar; + wi.buf = buf2; + wi.size = size; + + ieee80211_iterate_stations_atomic(hw, mt7915_txo_worker, &wi); + + rv = simple_read_from_buffer(user_buf, count, ppos, buf2, wi.sofar); + kfree(buf2); + return rv; +} + +/* Set the rates for specific types of traffic. + */ +static ssize_t mt7915_write_set_rate_override(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct mt7915_dev *dev = file->private_data; + struct mt7915_sta *msta; + struct ieee80211_vif *vif; + struct mt76_testmode_data *td = NULL; + struct wireless_dev *wdev; + struct mt76_wcid *wcid; + struct mt76_phy *mphy = &dev->mt76.phy; + char buf[180]; + char tmp[20]; + char *tok; + int ret, i, j; + unsigned int vdev_id = 0xFFFF; + char *bufptr = buf; + long rc; + char dev_name_match[IFNAMSIZ + 2]; + + memset(buf, 0, sizeof(buf)); + + simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count); + + /* make sure that buf is null terminated */ + buf[sizeof(buf) - 1] = 0; + + /* drop the possible '\n' from the end */ + if (buf[count - 1] == '\n') + buf[count - 1] = 0; + + mutex_lock(&mphy->dev->mutex); + + /* Ignore empty lines, 'echo' appends them sometimes at least. */ + if (buf[0] == 0) { + ret = count; + goto exit; + } + + /* String starts with vdev name, ie 'wlan0' Find the proper vif that + * matches the name. + */ + for (i = 0; i < ARRAY_SIZE(dev->mt76.wcid_mask); i++) { + u32 mask = dev->mt76.wcid_mask[i]; + u32 phy_mask = dev->mt76.wcid_phy_mask[i]; + + if (!mask) + continue; + + for (j = i * 32; mask; j++, mask >>= 1, phy_mask >>= 1) { + if (!(mask & 1)) + continue; + + wcid = rcu_dereference(dev->mt76.wcid[j]); + if (!wcid) + continue; + + msta = container_of(wcid, struct mt7915_sta, wcid); + + vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv); + + wdev = ieee80211_vif_to_wdev(vif); + + if (!wdev) + continue; + + snprintf(dev_name_match, sizeof(dev_name_match) - 1, "%s ", + wdev->netdev->name); + + if (strncmp(dev_name_match, buf, strlen(dev_name_match)) == 0) { + vdev_id = j; + td = &msta->test; + bufptr = buf + strlen(dev_name_match) - 1; + break; + } + } + } + + if (vdev_id == 0xFFFF) { + if (strstr(buf, "active=0")) { + /* Ignore, we are disabling it anyway */ + ret = count; + goto exit; + } else { + dev_info(dev->mt76.dev, + "mt7915: set-rate-override, unknown netdev name: %s\n", buf); + } + ret = -EINVAL; + goto exit; + } + +#define MT7915_PARSE_LTOK(a, b) \ + do { \ + tok = strstr(bufptr, " " #a "="); \ + if (tok) { \ + char *tspace; \ + tok += 1; /* move past initial space */ \ + strncpy(tmp, tok + strlen(#a "="), sizeof(tmp) - 1); \ + tmp[sizeof(tmp) - 1] = 0; \ + tspace = strstr(tmp, " "); \ + if (tspace) \ + *tspace = 0; \ + if (kstrtol(tmp, 0, &rc) != 0) \ + dev_info(dev->mt76.dev, \ + "mt7915: set-rate-override: " #a \ + "= could not be parsed, tmp: %s\n", \ + tmp); \ + else \ + td->b = rc; \ + } \ + } while (0) + + /* TODO: Allow configuring LTF? */ + td->tx_ltf = 1; /* 0: HTLTF 3.2us, 1: HELTF, 6.4us, 2 HELTF 12,8us */ + + MT7915_PARSE_LTOK(tpc, tx_power[0]); + MT7915_PARSE_LTOK(sgi, tx_rate_sgi); + MT7915_PARSE_LTOK(mcs, tx_rate_idx); + MT7915_PARSE_LTOK(nss, tx_rate_nss); + MT7915_PARSE_LTOK(pream, tx_rate_mode); + MT7915_PARSE_LTOK(retries, tx_xmit_count); + MT7915_PARSE_LTOK(dynbw, tx_dynbw); + MT7915_PARSE_LTOK(bw, txbw); + MT7915_PARSE_LTOK(active, txo_active); + + dev_info(dev->mt76.dev, + "mt7915: set-rate-overrides, vdev %i(%s) active=%d tpc=%d sgi=%d mcs=%d" + " nss=%d pream=%d retries=%d dynbw=%d bw=%d\n", + vdev_id, dev_name_match, + td->txo_active, td->tx_power[0], td->tx_rate_sgi, td->tx_rate_idx, + td->tx_rate_nss, td->tx_rate_mode, td->tx_xmit_count, td->tx_dynbw, + td->txbw); + + ret = count; + +exit: + mutex_unlock(&mphy->dev->mutex); + return ret; +} + +static const struct file_operations fops_set_rate_override = { + .read = mt7915_read_set_rate_override, + .write = mt7915_write_set_rate_override, + .open = simple_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + static int mt7915_txs_for_no_skb_set(void *data, u64 val) { @@ -1057,6 +1280,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) debugfs_create_devm_seqfile(dev->mt76.dev, "rdd_monitor", dir, mt7915_rdd_monitor); } + debugfs_create_file("set_rate_override", 0600, dir, + dev, &fops_set_rate_override); if (!ext_phy) dev->debugfs_dir = dir; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 800028a713a0..17bc64960f04 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -177,6 +177,15 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev) rx_cur); } + /* If we are in tx-override mode, then wtbl doesn't provide useful report + * for the SGI/LGI stuff, so just get it from the override struct. + */ + if (msta->test.txo_active) { + msta->wcid.rate_he_gi = msta->test.tx_rate_sgi; + msta->wcid.rate_short_gi = msta->test.tx_rate_sgi; + continue; + } + /* * We don't support reading GI info from txs packets. * For accurate tx status reporting and AQL improvement, @@ -906,21 +915,32 @@ mt7915_mac_fill_rx_vector(struct mt7915_dev *dev, struct sk_buff *skb) } static void -mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi, +mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, struct mt76_wcid *wcid, __le32 *txwi, struct sk_buff *skb) { -#ifdef CONFIG_NL80211_TESTMODE - struct mt76_testmode_data *td = &phy->mt76->test; + struct mt76_testmode_data *td; const struct ieee80211_rate *r; - u8 bw, mode, nss = td->tx_rate_nss; - u8 rate_idx = td->tx_rate_idx; + struct mt7915_sta *msta; + u8 bw, mode, nss; + u8 rate_idx; u16 rateval = 0; u32 val; bool cck = false; int band; + int xmit_count = 1; - if (skb != phy->mt76->test.tx_skb) - return; + msta = container_of(wcid, struct mt7915_sta, wcid); + + if (msta->test.txo_active) { + td = &msta->test; + } else { + if (skb != phy->mt76->test.tx_skb) + return; + td = &phy->mt76->test; + } + + nss = td->tx_rate_nss; + rate_idx = td->tx_rate_idx; switch (td->tx_rate_mode) { case MT76_TM_TX_MODE_HT: @@ -961,20 +981,24 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi, break; } - switch (phy->mt76->chandef.width) { - case NL80211_CHAN_WIDTH_40: - bw = 1; - break; - case NL80211_CHAN_WIDTH_80: - bw = 2; - break; - case NL80211_CHAN_WIDTH_80P80: - case NL80211_CHAN_WIDTH_160: - bw = 3; - break; - default: - bw = 0; - break; + if (msta->test.txo_active) { + bw = td->txbw; + } else { + switch (phy->mt76->chandef.width) { + case NL80211_CHAN_WIDTH_40: + bw = 1; + break; + case NL80211_CHAN_WIDTH_80: + bw = 2; + break; + case NL80211_CHAN_WIDTH_80P80: + case NL80211_CHAN_WIDTH_160: + bw = 3; + break; + default: + bw = 0; + break; + } } if (td->tx_rate_stbc && nss == 1) { @@ -988,10 +1012,24 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi, txwi[2] |= cpu_to_le32(MT_TXD2_FIX_RATE); - le32p_replace_bits(&txwi[3], 1, MT_TXD3_REM_TX_COUNT); + if (msta->test.txo_active) { + s8 txp = td->tx_power[0] - 16; + + /* Support per-skb txpower, p.15 of tx doc, DW2 29:24. */ + le32p_replace_bits(&txwi[2], txp, MT_TXD2_POWER_OFFSET); + + xmit_count = td->tx_xmit_count; + if (xmit_count == 0) { + xmit_count = 1; + txwi[3] |= cpu_to_le32(MT_TXD3_NO_ACK); + } + } + + le32p_replace_bits(&txwi[3], xmit_count, MT_TXD3_REM_TX_COUNT); if (td->tx_rate_mode < MT76_TM_TX_MODE_HT) txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE); + /* TODO: Take tx_dynbw into account in txo mode. */ val = MT_TXD6_FIXED_BW | FIELD_PREP(MT_TXD6_BW, bw) | FIELD_PREP(MT_TXD6_TX_RATE, rateval) | @@ -1015,9 +1053,29 @@ mt7915_mac_write_txwi_tm(struct mt7915_phy *phy, __le32 *txwi, txwi[3] &= ~cpu_to_le32(MT_TXD3_SN_VALID); txwi[6] |= cpu_to_le32(val); - txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, - phy->test.spe_idx)); -#endif + + if (msta->test.txo_active) { + /* see mt7915_tm_set_tx_frames */ + static const u8 spe_idx_map[] = {0, 0, 1, 0, 3, 2, 4, 0, + 9, 8, 6, 10, 16, 12, 18, 0}; + u32 spe_idx; + + if (td->tx_spe_idx) { + spe_idx = td->tx_spe_idx; + } else { + u8 tx_ant = td->tx_antenna_mask; + + if (!tx_ant) { + /* use antenna mask that matches our nss */ + tx_ant = GENMASK(nss - 1, 0); + } + spe_idx = spe_idx_map[tx_ant]; + } + txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, spe_idx)); + } else { + txwi[7] |= cpu_to_le32(FIELD_PREP(MT_TXD7_SPE_IDX, + phy->test.spe_idx)); + } } static void @@ -1282,8 +1340,29 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE); } - if (mt76_testmode_enabled(mphy)) - mt7915_mac_write_txwi_tm(mphy->priv, txwi, skb); +#ifdef CONFIG_NL80211_TESTMODE + { + struct mt7915_sta *msta; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + __le16 fc; + + if (!is_8023) + fc = hdr->frame_control; + + msta = container_of(wcid, struct mt7915_sta, wcid); + if (mt76_testmode_enabled(mphy) || + (msta->test.txo_active && + /* Only do txo overrides for (larger) data frames, this + * generally allows connection mgt frames to pass but still + * lets us force the data packets we care about. + */ + skb->len >= 400 && + (is_8023 || + ((ieee80211_is_data_qos(fc) || ieee80211_is_data(fc)) && + (!(ieee80211_is_qos_nullfunc(fc) || ieee80211_is_nullfunc(fc))))))) + mt7915_mac_write_txwi_tm(mphy->priv, wcid, txwi, skb); + } +#endif } int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, @@ -1699,7 +1778,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, struct ieee80211_supported_band *sband; struct mt76_dev *mdev = &dev->mt76; struct mt76_phy *mphy; - struct ieee80211_tx_info *info; + struct ieee80211_tx_info *info = NULL; struct sk_buff_head list; struct rate_info rate = {}; struct sk_buff *skb = NULL; @@ -1724,8 +1803,6 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, info->status.ampdu_len = 1; info->status.ampdu_ack_len = !!(info->flags & IEEE80211_TX_STAT_ACK); - - info->status.rates[0].idx = -1; } txrate = FIELD_GET(MT_TXS0_TX_RATE, txs); @@ -1757,6 +1834,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, rate.mcs = mt76_get_rate(mphy->dev, sband, rate.mcs, cck); rate.legacy = sband->bitrates[rate.mcs].bitrate; + if (info) + info->status.rates[0].idx = rate.mcs; break; case MT_PHY_TYPE_HT: case MT_PHY_TYPE_HT_GF: @@ -1766,6 +1845,10 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, rate.flags = RATE_INFO_FLAGS_MCS; if (wcid->rate_short_gi) rate.flags |= RATE_INFO_FLAGS_SHORT_GI; + if (info) { + info->status.rates[0].idx = rate.mcs + rate.nss * 8; + info->status.rates[0].flags |= IEEE80211_TX_RC_MCS; + } break; case MT_PHY_TYPE_VHT: if (rate.mcs > 9) @@ -1774,6 +1857,10 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, rate.flags = RATE_INFO_FLAGS_VHT_MCS; if (wcid->rate_short_gi) rate.flags |= RATE_INFO_FLAGS_SHORT_GI; + if (info) { + info->status.rates[0].idx = (rate.nss << 4) | rate.mcs; + info->status.rates[0].flags |= IEEE80211_TX_RC_VHT_MCS; + } break; case MT_PHY_TYPE_HE_SU: case MT_PHY_TYPE_HE_EXT_SU: @@ -1785,6 +1872,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, rate.he_gi = wcid->rate_he_gi; rate.he_dcm = FIELD_GET(MT_TX_RATE_DCM, txrate); rate.flags = RATE_INFO_FLAGS_HE_MCS; + if (info) + info->status.rates[0].idx = (rate.nss << 4) | rate.mcs; break; default: WARN_ON_ONCE(true); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index fa755bfa223f..e5008190472f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -132,6 +132,8 @@ struct mt7915_sta { struct mt76_connac_sta_key_conf bip; + struct mt76_testmode_data test; + struct { u8 flowid_mask; struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT]; From patchwork Wed Jul 27 23:01:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82FEEC04A68 for ; Wed, 27 Jul 2022 23:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234178AbiG0XBt (ORCPT ); Wed, 27 Jul 2022 19:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232130AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56ADF20BFA for ; Wed, 27 Jul 2022 16:01:42 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.64.218]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id D1C712007F; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 9AD64840082; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 4633D13C2B0; Wed, 27 Jul 2022 16:01:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 4633D13C2B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962900; bh=N6KjDxTz2Zpa2bCEpPdM4wkniDmsvdqYYMbQC6B8yxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bplo4sp5yvOCt5ZQg0F832AkJkgJGTjvMD4vQIjscsqs71O8+ScA0n+Qs54b2+i8c +g80AlsIwiOuL5LATtk5ya7CmlVLbLeZOQbtcDCiPT4st6Qec3BE9uuAP05W47dMCM uwURYbpbiEIyB4iGLBkDrxh6QGGvl7FRq9F68l4s= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 07/12] wifi: mt76: mt7915: support enabling rx group-5 status Date: Wed, 27 Jul 2022 16:01:17 -0700 Message-Id: <20220727230122.29842-7-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962901-OySI5Rfrfjdt Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear When enabled, this allows per-skb rx rate reporting. Enabling this may degrade RX performance, so it remains disabled by default. Signed-off-by: Ben Greear --- .../wireless/mediatek/mt76/mt7915/debugfs.c | 33 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7915/main.c | 2 +- .../wireless/mediatek/mt76/mt7915/mt7915.h | 4 +++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c index 6ff1ce6e4cfc..628d0f1f95be 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -879,6 +879,38 @@ mt7915_txs_for_no_skb_get(void *data, u64 *val) DEFINE_DEBUGFS_ATTRIBUTE(fops_txs_for_no_skb, mt7915_txs_for_no_skb_get, mt7915_txs_for_no_skb_set, "%lld\n"); +static int +mt7915_rx_group_5_enable_set(void *data, u64 val) +{ + struct mt7915_dev *dev = data; + + mutex_lock(&dev->mt76.mutex); + + dev->rx_group_5_enable = !!val; + + /* Enabled if we requested enabled OR if monitor mode is enabled. */ + mt76_rmw_field(dev, MT_DMA_DCR0(0), MT_DMA_DCR0_RXD_G5_EN, + dev->rx_group_5_enable); + mt76_testmode_reset(dev->phy.mt76, true); + + mutex_unlock(&dev->mt76.mutex); + + return 0; +} + +static int +mt7915_rx_group_5_enable_get(void *data, u64 *val) +{ + struct mt7915_dev *dev = data; + + *val = dev->rx_group_5_enable; + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(fops_rx_group_5_enable, mt7915_rx_group_5_enable_get, + mt7915_rx_group_5_enable_set, "%lld\n"); + static void mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy, struct seq_file *file) @@ -1264,6 +1296,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) debugfs_create_file("fw_util_wa", 0400, dir, dev, &mt7915_fw_util_wa_fops); debugfs_create_file("force_txs", 0600, dir, dev, &fops_txs_for_no_skb); + debugfs_create_file("rx_group_5_enable", 0600, dir, dev, &fops_rx_group_5_enable); debugfs_create_file("implicit_txbf", 0600, dir, dev, &fops_implicit_txbf); debugfs_create_file("txpower_sku", 0400, dir, phy, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index 5af9fade3a17..64ccba635113 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -440,7 +440,8 @@ mt7915_mac_init_band(struct mt7915_dev *dev, u8 band) mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_MAX_RX_LEN, 0x680); /* mt7915: disable rx rate report by default due to hw issues */ - mt76_clear(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN); + mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN, + dev->rx_group_5_enable); } static void mt7915_mac_init(struct mt7915_dev *dev) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 910dc36bacc3..1e8f525fa669 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -467,7 +467,7 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed) phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC; mt76_rmw_field(dev, MT_DMA_DCR0(band), MT_DMA_DCR0_RXD_G5_EN, - enabled); + dev->rx_group_5_enable); mt76_testmode_reset(phy->mt76, true); mt76_wr(dev, MT_WF_RFCR(band), phy->rxfilter); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index e5008190472f..39757e7f00e7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -301,6 +301,10 @@ struct mt7915_dev { * creation by firmware, so may be a performance drag. */ bool txs_for_no_skb_enabled; + /* Should we enable group-5 rx descriptor logic? This may decrease RX + * throughput, but will give per skb rx rate information.. + */ + bool rx_group_5_enable; struct work_struct init_work; struct work_struct rc_work; From patchwork Wed Jul 27 23:01:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41B57C19F2B for ; Wed, 27 Jul 2022 23:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236776AbiG0XBx (ORCPT ); Wed, 27 Jul 2022 19:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A18520F57 for ; Wed, 27 Jul 2022 16:01:42 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.137]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 180711C0083; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id CE47114007E; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 7091013C2B1; Wed, 27 Jul 2022 16:01:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 7091013C2B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962900; bh=CB4r0epo/phmbdAeqdcdoUPvSqWWQK2NG+odvpWXl2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=To/Tjs0sZSCdA1SFEwXRFAy9HWAJdW9Kzxwq8NFoGcCFfZ6bYXjIC3IFOyUUbX+Cs JgI83ufa/MZwc2EkpuGxIKFH7/WiewgSX8IWZEZ5d7xgfO+ysz3LWcYGjSiEfZ9FpP nLqJWpWLCwJCmYQKR6tUy1CjAfMZb6JQl9TNsQHg= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 08/12] wifi: mt76: mt7915: use nss for calculating rx-chains Date: Wed, 27 Jul 2022 16:01:18 -0700 Message-Id: <20220727230122.29842-8-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962901-xjM6_qNSDwyJ Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear When group-5 is enabled, we can find the actuall NSS used. In that case, update the rx chains info so that the upper stack can give better idea of actual antenna usage. In case of stbc, the hardware already double nss, but rssi is not reported properly (it is '17') for the secondary chains. So, decrease nss in the status msg so that mac80211 does not try to average the invalid RSSI. Signed-off-by: Ben Greear --- .../net/wireless/mediatek/mt76/mt7915/mac.c | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 17bc64960f04..1d2909c0c04c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -487,10 +487,10 @@ static int mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, struct mt76_rx_status *status, struct ieee80211_supported_band *sband, - __le32 *rxv, u8 *mode) + __le32 *rxv, u8 *mode, u8 *nss) { u32 v0, v2; - u8 stbc, gi, bw, dcm, nss; + u8 stbc, gi, bw, dcm; int i, idx; bool cck = false; @@ -498,7 +498,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, v2 = le32_to_cpu(rxv[2]); idx = i = FIELD_GET(MT_PRXV_TX_RATE, v0); - nss = FIELD_GET(MT_PRXV_NSTS, v0) + 1; + *nss = FIELD_GET(MT_PRXV_NSTS, v0) + 1; if (!is_mt7915(&dev->mt76)) { stbc = FIELD_GET(MT_PRXV_HT_STBC, v0); @@ -530,7 +530,6 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, return -EINVAL; break; case MT_PHY_TYPE_VHT: - status->nss = nss; status->encoding = RX_ENC_VHT; if (gi) status->enc_flags |= RX_ENC_FLAG_SHORT_GI; @@ -541,7 +540,6 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, case MT_PHY_TYPE_HE_SU: case MT_PHY_TYPE_HE_EXT_SU: case MT_PHY_TYPE_HE_TB: - status->nss = nss; status->encoding = RX_ENC_HE; i &= GENMASK(3, 0); @@ -582,6 +580,17 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, if (*mode < MT_PHY_TYPE_HE_SU && gi) status->enc_flags |= RX_ENC_FLAG_SHORT_GI; + /* in case stbc is set, the nss value returned by hardware is already + * correct (ie, 2 instead of 1 for 1 spatial stream). But, at least in cases + * where we are configured for a single antenna, then the second chain RSSI is '17', + * which I take to mean 'not set'. To keep from adding this to the average rssi up in + * mac80211 rx logic, decrease nss here. + */ + if (stbc) + *nss >>= 1; + + status->nss = *nss; + return 0; } @@ -755,6 +764,8 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) if (rxd1 & MT_RXD1_NORMAL_GROUP_3) { u32 v0, v1; int ret; + int i; + u8 nss; rxv = rxd; /* DW16 assuming group 1,2,3,4 */ rxd += 2; @@ -771,11 +782,11 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) /* TODO: When group-5 is enabled, use nss (and stbc) to * calculate chains properly for this particular skb. */ - 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); status->chain_signal[2] = to_rssi(MT_PRXV_RCPI2, v1); status->chain_signal[3] = to_rssi(MT_PRXV_RCPI3, v1); + nss = hweight8(mphy->antenna_mask); /* RXD Group 5 - C-RXV */ if (rxd1 & MT_RXD1_NORMAL_GROUP_5) { @@ -786,10 +797,15 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) if (!is_mt7915(&dev->mt76) || (rxd1 & MT_RXD1_NORMAL_GROUP_5)) { ret = mt7915_mac_fill_rx_rate(dev, status, sband, rxv, - &mode); + &mode, &nss); if (ret < 0) return ret; + } else { + status->nss = nss; } + + for (i = 0; i < nss; i++) + status->chains |= BIT(i); } amsdu_info = FIELD_GET(MT_RXD4_NORMAL_PAYLOAD_FORMAT, rxd4); From patchwork Wed Jul 27 23:01:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92257C19F29 for ; Wed, 27 Jul 2022 23:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234563AbiG0XBu (ORCPT ); Wed, 27 Jul 2022 19:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2F9F21242 for ; Wed, 27 Jul 2022 16:01:42 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.64.75]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 19FFF1C008A; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id D913A80074; Wed, 27 Jul 2022 23:01:40 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 9BCA313C2B3; Wed, 27 Jul 2022 16:01:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 9BCA313C2B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962900; bh=VvX5GinnEZCSHWrYjzLzhuGymQd4uMg7l/CeW6RIRa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxmvhPCqbQ6/UbuLUltAmvE4TiQmozqL1N6sN+8zlH1kpVib1xkSA+0LwCn4VC3fz TnV2KStVNklztW6PE2nF4Q54nSI87pmNaQvX3Sc9ut81JyPAwAXuZjARRM9z7HRpqK vIfN7B8DoMiG26Woyuc6HefiTyJ5hsYODp/CvcDM= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 09/12] wifi: mt76: mt7915: ethtool group-5 rx stats information Date: Wed, 27 Jul 2022 16:01:19 -0700 Message-Id: <20220727230122.29842-9-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962901-dcYSgj9Nnmcf Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Add ethtool support for rx-nss, rx-bw, rx-mode stats. These are only valid when the group-5 rx stats are enabled. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mac80211.c | 23 ++++++++++++++- drivers/net/wireless/mediatek/mt76/mt76.h | 10 +++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 29 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7915/main.c | 21 ++++++++++++++ .../net/wireless/mediatek/mt76/mt7921/main.c | 21 ++++++++++++++ 5 files changed, 101 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index 242e055fa475..574e2c54637a 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -1623,7 +1623,7 @@ EXPORT_SYMBOL_GPL(mt76_calculate_default_rate); void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, struct mt76_sta_stats *stats) { - int i, ei = wi->initial_stat_idx; + int i, q, ei = wi->initial_stat_idx; u64 *data = wi->data; wi->sta_count++; @@ -1648,6 +1648,27 @@ void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, for (i = 0; i < 12; i++) data[ei++] += stats->tx_mcs[i]; + /* rx stats */ + for (q = 0; q < ARRAY_SIZE(stats->rx_nss); q++) + data[ei++] += stats->rx_nss[q]; + + data[ei++] += stats->rx_mode[MT_PHY_TYPE_CCK]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_OFDM]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HT]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HT_GF]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_VHT]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_SU]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_EXT_SU]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_TB]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_MU]; + + data[ei++] += stats->rx_bw_20; + data[ei++] += stats->rx_bw_40; + data[ei++] += stats->rx_bw_80; + data[ei++] += stats->rx_bw_160; + data[ei++] += stats->rx_bw_he_ru; + data[ei++] += stats->rx_ru_106; + wi->worker_stat_count = ei - wi->initial_stat_idx; } EXPORT_SYMBOL_GPL(mt76_ethtool_worker); diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 682b554fbcb7..cbf1a30d3cc9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -839,6 +839,16 @@ struct mt76_sta_stats { u64 tx_bw[4]; /* 20, 40, 80, 160 */ u64 tx_nss[4]; /* 1, 2, 3, 4 */ u64 tx_mcs[16]; /* mcs idx */ + + /* This section requires group-5 in rxd to be enabled for 7915. */ + u32 rx_nss[4]; /* rx-nss histogram */ + u32 rx_mode[__MT_PHY_TYPE_HE_MAX]; /* rx mode histogram */ + u32 rx_bw_20; + u32 rx_bw_40; + u32 rx_bw_80; + u32 rx_bw_160; + u32 rx_bw_he_ru; + u32 rx_ru_106; }; struct mt76_ethtool_worker_info { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 1d2909c0c04c..ca6748d67ce0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -487,7 +487,8 @@ static int mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, struct mt76_rx_status *status, struct ieee80211_supported_band *sband, - __le32 *rxv, u8 *mode, u8 *nss) + __le32 *rxv, u8 *mode, u8 *nss, + struct mt76_sta_stats *stats) { u32 v0, v2; u8 stbc, gi, bw, dcm; @@ -555,6 +556,8 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, switch (bw) { case IEEE80211_STA_RX_BW_20: + if (stats) + stats->rx_bw_20++; break; case IEEE80211_STA_RX_BW_40: if (*mode & MT_PHY_TYPE_HE_EXT_SU && @@ -562,15 +565,26 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->bw = RATE_INFO_BW_HE_RU; status->he_ru = NL80211_RATE_INFO_HE_RU_ALLOC_106; + if (stats) { + stats->rx_bw_he_ru++; + stats->rx_ru_106++; + } } else { status->bw = RATE_INFO_BW_40; + if (stats) + stats->rx_bw_40++; } break; case IEEE80211_STA_RX_BW_80: status->bw = RATE_INFO_BW_80; + if (stats) + stats->rx_bw_80++; + break; case IEEE80211_STA_RX_BW_160: status->bw = RATE_INFO_BW_160; + if (stats) + stats->rx_bw_160++; break; default: return -EINVAL; @@ -591,6 +605,15 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->nss = *nss; + if (stats) { + if (*nss > 3) + stats->rx_nss[3]++; + else + stats->rx_nss[*nss - 1]++; + if (*mode < __MT_PHY_TYPE_HE_MAX) + stats->rx_mode[*mode]++; + } + return 0; } @@ -618,6 +641,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) u16 seq_ctrl = 0; __le16 fc = 0; int idx; + struct mt76_sta_stats *stats = NULL; memset(status, 0, sizeof(*status)); @@ -652,6 +676,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) struct mt7915_sta *msta; msta = container_of(status->wcid, struct mt7915_sta, wcid); + stats = &msta->stats; spin_lock_bh(&dev->sta_poll_lock); if (list_empty(&msta->poll_list)) list_add_tail(&msta->poll_list, &dev->sta_poll_list); @@ -797,7 +822,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) if (!is_mt7915(&dev->mt76) || (rxd1 & MT_RXD1_NORMAL_GROUP_5)) { ret = mt7915_mac_fill_rx_rate(dev, status, sband, rxv, - &mode, &nss); + &mode, &nss, stats); if (ret < 0) return ret; } else { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 1e8f525fa669..db3c32eebb04 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1187,6 +1187,27 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = { "v_tx_mcs_9", "v_tx_mcs_10", "v_tx_mcs_11", + + /* per-vif rx counters */ + "v_rx_nss1", + "v_rx_nss2", + "v_rx_nss3", + "v_rx_nss4", + "v_rx_mode_cck", + "v_rx_mode_ofdm", + "v_rx_mode_ht", + "v_rx_mode_ht_gf", + "v_rx_mode_vht", + "v_rx_mode_he_su", + "v_rx_mode_he_ext_su", + "v_rx_mode_he_tb", + "v_rx_mode_he_mu", + "v_rx_bw_20", + "v_rx_bw_40", + "v_rx_bw_80", + "v_rx_bw_160", + "v_rx_bw_he_ru", + "v_rx_ru_106", }; #define MT7915_SSTATS_LEN ARRAY_SIZE(mt7915_gstrings_stats) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c index ac78fcf285bf..a23dd8f44e28 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c @@ -1016,6 +1016,27 @@ static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = { "v_tx_mcs_9", "v_tx_mcs_10", "v_tx_mcs_11", + + /* per-vif rx counters */ + "v_rx_nss1", + "v_rx_nss2", + "v_rx_nss3", + "v_rx_nss4", + "v_rx_mode_cck", + "v_rx_mode_ofdm", + "v_rx_mode_ht", + "v_rx_mode_ht_gf", + "v_rx_mode_vht", + "v_rx_mode_he_su", + "v_rx_mode_he_ext_su", + "v_rx_mode_he_tb", + "v_rx_mode_he_mu", + "v_rx_bw_20", + "v_rx_bw_40", + "v_rx_bw_80", + "v_rx_bw_160", + "v_rx_bw_he_ru", + "v_rx_ru_106", }; static void From patchwork Wed Jul 27 23:01:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3290BC19F2C for ; Wed, 27 Jul 2022 23:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236090AbiG0XBw (ORCPT ); Wed, 27 Jul 2022 19:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233884AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C985F2126D for ; Wed, 27 Jul 2022 16:01:42 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.64.218]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 4A8831C0083; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 11AB2840082; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id C535013C2B4; Wed, 27 Jul 2022 16:01:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com C535013C2B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962900; bh=U62uDKXFG/RFxHiwu6VCFhIYD7bBNOqB1YVAhzed3QM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lMhmCRVCxL6DzhlsQU32qOOvq6hxMk01bRidq3Vn3sotonGUNGYmD5m0xwE0wxpBy wW3hpuoDcc6kQql1VZbRuaD7jvGao/lP5u7LV1gw+51rfc206/6pPSgkj1f56/8Jwi EdJccFmSEAjxXXA9R15vcUDUHaNANsNL0hKlrsdc= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 10/12] wifi: mt76: mt7915: ethtool counters for driver rx path Date: Wed, 27 Jul 2022 16:01:20 -0700 Message-Id: <20220727230122.29842-10-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962901-Sv54ik0-xyn5 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Add some per-phy counters for rx errors in the driver. Signed-off-by: Ben Greear --- .../net/wireless/mediatek/mt76/mt7915/mac.c | 48 ++++++++++++++----- .../net/wireless/mediatek/mt76/mt7915/main.c | 22 +++++++++ .../wireless/mediatek/mt76/mt7915/mt7915.h | 11 +++++ 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index ca6748d67ce0..408121c4260f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -488,6 +488,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, struct mt76_rx_status *status, struct ieee80211_supported_band *sband, __le32 *rxv, u8 *mode, u8 *nss, + struct mib_stats *mib, struct mt76_sta_stats *stats) { u32 v0, v2; @@ -527,15 +528,19 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->encoding = RX_ENC_HT; if (gi) status->enc_flags |= RX_ENC_FLAG_SHORT_GI; - if (i > 31) + if (i > 31) { + mib->rx_d_bad_ht_rix++; return -EINVAL; + } break; case MT_PHY_TYPE_VHT: status->encoding = RX_ENC_VHT; if (gi) status->enc_flags |= RX_ENC_FLAG_SHORT_GI; - if (i > 11) + if (i > 11) { + mib->rx_d_bad_vht_rix++; return -EINVAL; + } break; case MT_PHY_TYPE_HE_MU: case MT_PHY_TYPE_HE_SU: @@ -550,6 +555,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->he_dcm = dcm; break; default: + mib->rx_d_bad_mode++; return -EINVAL; } status->rate_idx = i; @@ -587,6 +593,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, stats->rx_bw_160++; break; default: + mib->rx_d_bad_bw++; return -EINVAL; } @@ -642,9 +649,12 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) __le16 fc = 0; int idx; struct mt76_sta_stats *stats = NULL; + struct mib_stats *mib = &phy->mib; memset(status, 0, sizeof(*status)); + mib->rx_d_skb++; + if ((rxd1 & MT_RXD1_NORMAL_BAND_IDX) && !phy->band_idx) { mphy = dev->mt76.phy2; if (!mphy) @@ -657,8 +667,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) if (!test_bit(MT76_STATE_RUNNING, &mphy->state)) return -EINVAL; - if (rxd2 & MT_RXD2_NORMAL_AMSDU_ERR) + if (rxd2 & MT_RXD2_NORMAL_AMSDU_ERR) { + mib->rx_d_rxd2_amsdu_err++; return -EINVAL; + } hdr_trans = rxd2 & MT_RXD2_NORMAL_HDR_TRANS; if (hdr_trans && (rxd1 & MT_RXD1_NORMAL_CM)) @@ -692,8 +704,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) else sband = &mphy->sband_2g.sband; - if (!sband->channels) + if (!sband->channels) { + mib->rx_d_null_channels++; return -EINVAL; + } if ((rxd0 & csum_mask) == csum_mask) skb->ip_summed = CHECKSUM_UNNECESSARY; @@ -713,8 +727,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) remove_pad = FIELD_GET(MT_RXD2_NORMAL_HDR_OFFSET, rxd2); - if (rxd2 & MT_RXD2_NORMAL_MAX_LEN_ERROR) + if (rxd2 & MT_RXD2_NORMAL_MAX_LEN_ERROR) { + mib->rx_d_max_len_err++; return -EINVAL; + } rxd += 6; if (rxd1 & MT_RXD1_NORMAL_GROUP_4) { @@ -726,8 +742,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) seq_ctrl = FIELD_GET(MT_RXD8_SEQ_CTRL, v2); rxd += 4; - if ((u8 *)rxd - skb->data >= skb->len) + if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++; return -EINVAL; + } } if (rxd1 & MT_RXD1_NORMAL_GROUP_1) { @@ -758,8 +776,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) } } rxd += 4; - if ((u8 *)rxd - skb->data >= skb->len) + if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++; return -EINVAL; + } } if (rxd1 & MT_RXD1_NORMAL_GROUP_2) { @@ -781,8 +801,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) } rxd += 2; - if ((u8 *)rxd - skb->data >= skb->len) + if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++; return -EINVAL; + } } /* RXD Group 3 - P-RXV */ @@ -794,8 +816,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) rxv = rxd; /* DW16 assuming group 1,2,3,4 */ rxd += 2; - if ((u8 *)rxd - skb->data >= skb->len) + if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++; return -EINVAL; + } v0 = le32_to_cpu(rxv[0]); /* DW16, P-VEC1 31:0 */ /* DW17, RX_RCPI copied over P-VEC 64:32 Per RX Format doc. */ @@ -816,13 +840,15 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) /* RXD Group 5 - C-RXV */ if (rxd1 & MT_RXD1_NORMAL_GROUP_5) { rxd += 18; - if ((u8 *)rxd - skb->data >= skb->len) + if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++; return -EINVAL; + } } if (!is_mt7915(&dev->mt76) || (rxd1 & MT_RXD1_NORMAL_GROUP_5)) { ret = mt7915_mac_fill_rx_rate(dev, status, sband, rxv, - &mode, &nss, stats); + &mode, &nss, mib, stats); if (ret < 0) return ret; } else { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index db3c32eebb04..b99a667ff251 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1157,6 +1157,17 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = { "rx_vec_queue_overflow_drop_cnt", "rx_ba_cnt", + /* driver rx counters */ + "d_rx_skb", + "d_rx_rxd2_amsdu_err", + "d_rx_null_channels", + "d_rx_max_len_err", + "d_rx_too_short", + "d_rx_bad_ht_rix", + "d_rx_bad_vht_rix", + "d_rx_bad_mode", + "d_rx_bad_bw", + /* per vif counters */ "v_tx_mpdu_attempts", /* counting any retries */ "v_tx_mpdu_fail", /* frames that failed even after retry */ @@ -1323,6 +1334,17 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->rx_vec_queue_overflow_drop_cnt; data[ei++] = mib->rx_ba_cnt; + /* rx stats from driver */ + data[ei++] = mib->rx_d_skb; + data[ei++] = mib->rx_d_rxd2_amsdu_err; + data[ei++] = mib->rx_d_null_channels; + data[ei++] = mib->rx_d_max_len_err; + data[ei++] = mib->rx_d_too_short; + data[ei++] = mib->rx_d_bad_ht_rix; + data[ei++] = mib->rx_d_bad_vht_rix; + data[ei++] = mib->rx_d_bad_mode; + data[ei++] = mib->rx_d_bad_bw; + /* Add values for all stations owned by this vif */ wi.initial_stat_idx = ei; ieee80211_iterate_stations_atomic(hw, mt7915_ethtool_worker, &wi); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 39757e7f00e7..c5401e6e3cda 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -216,6 +216,17 @@ struct mib_stats { u32 tx_amsdu[8]; u32 tx_amsdu_cnt; + + /* rx stats from the driver */ + u32 rx_d_skb; /* total skb received in rx path */ + u32 rx_d_rxd2_amsdu_err; + u32 rx_d_null_channels; + u32 rx_d_max_len_err; + u32 rx_d_too_short; + u32 rx_d_bad_ht_rix; + u32 rx_d_bad_vht_rix; + u32 rx_d_bad_mode; + u32 rx_d_bad_bw; }; struct mt7915_hif { From patchwork Wed Jul 27 23:01:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 675FBC19F21 for ; Wed, 27 Jul 2022 23:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236861AbiG0XBy (ORCPT ); Wed, 27 Jul 2022 19:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233969AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09CDF21812 for ; Wed, 27 Jul 2022 16:01:43 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.137]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 76D0C1C008B; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 3D0C114007D; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id F146313C2B0; Wed, 27 Jul 2022 16:01:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com F146313C2B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962901; bh=hz1HcD4sEsCfZlC/PH46frSa+cB/cA0ypTpyYL/iyEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i7FI5Fa2wZryMZ+O/FJLeKy360m0kcq8rSZRKl4P4MMfSO2m7mCfRFtJsnx89yjqP dQ07pECmykxMdT/rNUNKdM72AB6Fc34MOVOA2JHT7BvxutPajizmFIksYu+ghRUbyq OnxAh6c5VPWH4CaEHtIdBJdz8yZT6ShFd6HnDmKk= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 11/12] wifi: mt76: mt7915: add ethtool tx/rx pkts/bytes Date: Wed, 27 Jul 2022 16:01:21 -0700 Message-Id: <20220727230122.29842-11-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962901-cBGrn1bwIROp Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear These stats are provided with same name by ath10k and some intel wired NIC drivers. Add them to mt7915 as well to allow user-space code to more easily get some basic stats out of the radio. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++ drivers/net/wireless/mediatek/mt76/mt7915/main.c | 11 +++++++++++ drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 7 +++++++ 3 files changed, 25 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 408121c4260f..afd480dd255b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -921,6 +921,9 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) if (rxv && mode >= MT_PHY_TYPE_HE_SU && !(status->flag & RX_FLAG_8023)) mt7915_mac_decode_he_radiotap(skb, rxv, mode); + mib->rx_pkts_nic++; + mib->rx_bytes_nic += skb->len; + if (!status->wcid || !ieee80211_is_data_qos(fc)) return 0; @@ -1584,6 +1587,8 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t, u16 wcid_idx; struct ieee80211_tx_info *info; struct ieee80211_tx_rate *rate; + struct mt7915_phy *phy = &dev->phy; + struct mib_stats *mib = &phy->mib; mt7915_txp_skb_unmap(mdev, t); if (!t->skb) @@ -1675,6 +1680,8 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t, /* Apply the values that this txfree path reports */ rate->count = tx_cnt; if (tx_status == 0) { + mib->tx_pkts_nic++; + mib->tx_bytes_nic += t->skb->len; info->flags |= IEEE80211_TX_STAT_ACK; info->status.ampdu_ack_len = 1; } else { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index b99a667ff251..f2e215468a38 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1094,6 +1094,10 @@ static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw, } static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = { + "tx_pkts_nic", /* from driver, phy tx-ok skb */ + "tx_bytes_nic", /* from driver, phy tx-ok bytes */ + "rx_pkts_nic", /* from driver, phy rx OK skb */ + "rx_bytes_nic", /* from driver, phy rx OK bytes */ "tx_ampdu_cnt", "tx_stop_q_empty_cnt", "tx_mpdu_attempts", @@ -1275,6 +1279,13 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, mt7915_mac_update_stats(phy); + /* driver phy-wide stats */ + data[ei++] = mib->tx_pkts_nic; + data[ei++] = mib->tx_bytes_nic; + data[ei++] = mib->rx_pkts_nic; + data[ei++] = mib->rx_bytes_nic; + + /* MIB stats from FW/HW */ data[ei++] = mib->tx_ampdu_cnt; data[ei++] = mib->tx_stop_q_empty_cnt; data[ei++] = mib->tx_mpdu_attempts_cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index c5401e6e3cda..c0bb87bf2a2c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -166,6 +166,13 @@ struct mt7915_vif { /* per-phy stats. */ struct mib_stats { + /* phy wide driver stats */ + u32 tx_pkts_nic; /* tx OK skb */ + u32 tx_bytes_nic; /* tx OK bytes */ + u32 rx_pkts_nic; /* rx OK skb */ + u32 rx_bytes_nic; /* rx OK bytes */ + + /* MIB counters from FW/HW */ u32 ack_fail_cnt; u32 fcs_err_cnt; u32 rts_cnt; From patchwork Wed Jul 27 23:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 594048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 067D1C19F29 for ; Wed, 27 Jul 2022 23:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235229AbiG0XBu (ORCPT ); Wed, 27 Jul 2022 19:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233766AbiG0XBo (ORCPT ); Wed, 27 Jul 2022 19:01:44 -0400 Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35CB42181E for ; Wed, 27 Jul 2022 16:01:43 -0700 (PDT) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.64.75]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id AAB1A2005E; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from mail3.candelatech.com (mail2.candelatech.com [208.74.158.173]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 6B3758007B; Wed, 27 Jul 2022 23:01:41 +0000 (UTC) Received: from ben-dt4.candelatech.com (50-251-239-81-static.hfc.comcastbusiness.net [50.251.239.81]) by mail3.candelatech.com (Postfix) with ESMTP id 28BD213C2B1; Wed, 27 Jul 2022 16:01:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 28BD213C2B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1658962901; bh=pO2GKPhCZ0/STsKTAzAQh3+K4aMTP5A/BqeWnzeSEQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bCuWY0Oi0ycwWjT6jQmbJjLV7SEOvevA3Nc9Sj6tx4RYuoVJwEqW4CudYz7aF5ol1 NY2drWVPzVTFGaVRVaMeI1iFC1yYEAqdRnidDDQCe5ydVMi601933ad04n6HGp2NcV SZMeZk4kfMwQv9dQsECPBM6xiMcNLFlzL6pK+AUE= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: nbd@nbd.name, Ben Greear Subject: [PATCH 12/12] wifi: mt76: mt7915: add rx-ppdu-size-out-of-range ethtool counter Date: Wed, 27 Jul 2022 16:01:22 -0700 Message-Id: <20220727230122.29842-12-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220727230122.29842-1-greearb@candelatech.com> References: <20220727230122.29842-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1658962902-FUVu7abVkSsQ Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Support this additional MIB counter, it shares register with the rx-fifo-overflow counter. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 1 + drivers/net/wireless/mediatek/mt76/mt7915/main.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 1 + drivers/net/wireless/mediatek/mt76/mt7915/regs.h | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index afd480dd255b..921fad4a3873 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -2490,6 +2490,7 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy) cnt = mt76_rr(dev, MT_MIB_SDR4(phy->band_idx)); mib->rx_fifo_full_cnt += FIELD_GET(MT_MIB_SDR4_RX_FIFO_FULL_MASK, cnt); + mib->rx_oor_cnt += FIELD_GET(MT_MIB_SDR4_RX_OOR_MASK, cnt); cnt = mt76_rr(dev, MT_MIB_SDR5(phy->band_idx)); mib->rx_mpdu_cnt += cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index f2e215468a38..4c847aac6de8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1148,6 +1148,7 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = { /* rx counters */ "rx_fifo_full_cnt", + "rx_oor_cnt", /* rx ppdu length is bad */ "rx_mpdu_cnt", "channel_idle_cnt", "rx_vector_mismatch_cnt", @@ -1331,7 +1332,8 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->tx_amsdu[i]; /* rx counters */ - data[ei++] = mib->rx_fifo_full_cnt; + data[ei++] = mib->rx_fifo_full_cnt; /* group-5 might exacerbate this */ + data[ei++] = mib->rx_oor_cnt; data[ei++] = mib->rx_mpdu_cnt; data[ei++] = mib->channel_idle_cnt; data[ei++] = mib->rx_vector_mismatch_cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index c0bb87bf2a2c..895dff9d053c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -208,6 +208,7 @@ struct mib_stats { /* rx stats */ u32 rx_fifo_full_cnt; + u32 rx_oor_cnt; u32 channel_idle_cnt; u32 rx_vector_mismatch_cnt; u32 rx_delimiter_fail_cnt; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h index 8bbc9a0ae699..d8c0caa71122 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h @@ -292,6 +292,7 @@ enum offs_rev { #define MT_MIB_SDR4(_band) MT_WF_MIB(_band, __OFFS(MIB_SDR4)) #define MT_MIB_SDR4_RX_FIFO_FULL_MASK GENMASK(15, 0) +#define MT_MIB_SDR4_RX_OOR_MASK GENMASK(23, 16) /* rx mpdu counter, full 32 bits */ #define MT_MIB_SDR5(_band) MT_WF_MIB(_band, __OFFS(MIB_SDR5))