From patchwork Thu Jul 22 20:28:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 484260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8A6AC4338F for ; Thu, 22 Jul 2021 20:28:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6E4360EB1 for ; Thu, 22 Jul 2021 20:28:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230437AbhGVTsH (ORCPT ); Thu, 22 Jul 2021 15:48:07 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.48]:36872 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbhGVTsG (ORCPT ); Thu, 22 Jul 2021 15:48:06 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.67.131]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 46C692006D for ; Thu, 22 Jul 2021 20:28: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 262F9980068 for ; Thu, 22 Jul 2021 20:28: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 BDCF113C2B3; Thu, 22 Jul 2021 13:28:39 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com BDCF113C2B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1626985719; bh=9KKPZ6s3GCWcEHfupZyr9LoRQZBFKS/9ODda1ZddgQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q3IRUGqHsCL/nWQgpL3w23wr5LcBQTjdLlMIRzOnioKAtSZ8aCDAUSIlm3+D8i23Y XdJ4PwuR9Zob2vv3/XUWQOwIdhXTBO2ZOO31cNlENa7pQuMQPes9rOSLFI7Ig4pHoT Xrg+QZ8ife163IGoW/goAknjNh+kvuQ5HBXTA2Y0= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v2 02/11] mt76 - mt7915: Fix potential NPE in TXS processing. Date: Thu, 22 Jul 2021 13:28:25 -0700 Message-Id: <20210722202834.6826-2-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722202834.6826-1-greearb@candelatech.com> References: <20210722202834.6826-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1626985720-aAIC5e-WkYiN Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear If skb is null, then don't try to dereference it. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 555a2f94d069..fb88332f19ef 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1321,7 +1321,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, /* TODO: Gather stats anyway, even if we are not matching on an skb. */ if (!skb) - goto out; + goto out_no_skb; txs = le32_to_cpu(txs_data[0]); txs5 = le32_to_cpu(txs_data[5]); @@ -1427,6 +1427,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, out: mt76_tx_status_skb_done(mdev, skb, &list, wcid); + +out_no_skb: mt76_tx_status_unlock(mdev, &list); return !!skb; From patchwork Thu Jul 22 20:28:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 484257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 160A3C43216 for ; Thu, 22 Jul 2021 20:28:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F177B60EB1 for ; Thu, 22 Jul 2021 20:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231128AbhGVTsJ (ORCPT ); Thu, 22 Jul 2021 15:48:09 -0400 Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.183]:42778 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbhGVTsH (ORCPT ); Thu, 22 Jul 2021 15:48:07 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.51.174]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id DFD04A0073 for ; Thu, 22 Jul 2021 20:28: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 AB2837C007C for ; Thu, 22 Jul 2021 20:28: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 4158613C2B7; Thu, 22 Jul 2021 13:28:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 4158613C2B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1626985720; bh=J2NAB+Jx+GpEkhYI0EWCXgCzTA2FVa/k2ySwtaJ1OLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RLK6/qT7H4NcMUvj39E2fqTkazUf3LbIGPOUKYJpX9Ahffej+Nrs528faPTsZcyNw Z5hWJpaxgY/TJYPvwdB6qItgMr1z5euOihiiTe3NI2kOCkx1K3Y07nvkqOE1s04S3a +3/icKN/D6oUXrmaMiuy0Au809zWV/kTUfr7Kw24= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v2 05/11] mt76: mt7915: debugfs hook to enable TXS for NO_SKB pkt-ids. Date: Thu, 22 Jul 2021 13:28:28 -0700 Message-Id: <20210722202834.6826-5-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722202834.6826-1-greearb@candelatech.com> References: <20210722202834.6826-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1626985721-SMPGv3nXOsO5 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 a074ecf8ec38..6aa174a78cdb 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c @@ -109,6 +109,29 @@ mt7915_fw_debug_get(void *data, u64 *val) DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug, mt7915_fw_debug_get, mt7915_fw_debug_set, "%lld\n"); +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) @@ -344,6 +367,7 @@ int mt7915_init_debugfs(struct mt7915_dev *dev) mt7915_queues_acq); debugfs_create_file("tx_stats", 0400, dir, dev, &mt7915_tx_stats_fops); debugfs_create_file("fw_debug", 0600, dir, dev, &fops_fw_debug); + debugfs_create_file("txs_for_no_skb", 0600, dir, dev, &fops_txs_for_no_skb); debugfs_create_file("implicit_txbf", 0600, dir, dev, &fops_implicit_txbf); debugfs_create_u32("dfs_hw_pattern", 0400, dir, &dev->hw_pattern); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 4394d9fc2c79..9bd2a5e795b8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1048,7 +1048,8 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, val = FIELD_PREP(MT_TXD5_PID, pid); /* NOTE: mt7916 does NOT request TXS for 'NO_SKB' frames by default. */ - 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 fcc5cd60cfc8..9e2d547d441c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -226,6 +226,11 @@ struct mt7915_dev { u16 chainmask; 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 Thu Jul 22 20:28:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 484259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 964BEC4320E for ; Thu, 22 Jul 2021 20:28:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 800E360EB2 for ; Thu, 22 Jul 2021 20:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230526AbhGVTsI (ORCPT ); Thu, 22 Jul 2021 15:48:08 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.52]:36886 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbhGVTsH (ORCPT ); Thu, 22 Jul 2021 15:48:07 -0400 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 317572006C for ; Thu, 22 Jul 2021 20:28: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 F010984007F for ; Thu, 22 Jul 2021 20:28: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 65D7813C2B8; Thu, 22 Jul 2021 13:28:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 65D7813C2B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1626985720; bh=RYDgFmKktXlmzIt/0/hrcKaV3R5bIJuEK4Argrg8BNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cklPTmw96XgY+mZJ1LsUqAm/VI2KP0ntih8mByqgUKJHkFUby6STE4PjqIgOl8YDT uuKdB8cZ4otZPWo/8Ez/r6rDjPWPEsYlguPfIfG31I5tmiJpxUm9lUQ7tu00NwanMU z3LGBr8k36oD5sMSkpLR/EZc+uUD4K5J8wESt7yg= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v2 06/11] mt76: mt7915: Support parsing TXSFM 0x2. Date: Thu, 22 Jul 2021 13:28:29 -0700 Message-Id: <20210722202834.6826-6-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722202834.6826-1-greearb@candelatech.com> References: <20210722202834.6826-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1626985721-TYXG4-X8sZxe Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear Add code to support this format, but I don't actually see any of these TXS format frames on my test system. Signed-off-by: Ben Greear --- .../net/wireless/mediatek/mt76/mt7915/mac.c | 24 +++++++++++-------- .../net/wireless/mediatek/mt76/mt7915/mac.h | 3 +++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 9bd2a5e795b8..073891850c0c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1317,13 +1317,10 @@ mt7915_mac_parse_txs(struct mt7915_dev *dev, struct mt76_wcid *wcid, { struct ieee80211_supported_band *sband; struct mt76_phy *mphy; - u32 txrate, txs, txs5, txs6, txs7, mode; + u32 txrate, txs, mode; bool cck = false; txs = le32_to_cpu(txs_data[0]); - txs5 = le32_to_cpu(txs_data[5]); - txs6 = le32_to_cpu(txs_data[6]); - txs7 = le32_to_cpu(txs_data[7]); if (!(txs & MT_TXS0_ACK_ERROR_MASK)) info->flags |= IEEE80211_TX_STAT_ACK; @@ -1334,10 +1331,6 @@ mt7915_mac_parse_txs(struct mt7915_dev *dev, struct mt76_wcid *wcid, info->status.rates[0].idx = -1; - stats->tx_mpdu_attempts += FIELD_GET(MT_TXS5_F1_MPDU_TX_COUNT, txs5); - stats->tx_mpdu_fail += FIELD_GET(MT_TXS6_F1_MPDU_FAIL_COUNT, txs6); - stats->tx_mpdu_retry += FIELD_GET(MT_TXS7_F1_MPDU_RETRY_COUNT, txs7); - txrate = FIELD_GET(MT_TXS0_TX_RATE, txs); rate->mcs = FIELD_GET(MT_TX_RATE_IDX, txrate); @@ -1418,6 +1411,19 @@ mt7915_mac_parse_txs(struct mt7915_dev *dev, struct mt76_wcid *wcid, stats->tx_bw[0]++; break; } + + if (FIELD_GET(MT_TXS0_TXS_FORMAT, txs) == 2) { + /* TXSFM == 10 */ + u32 txs5, txs6, txs7; + + txs5 = le32_to_cpu(txs_data[5]); + txs6 = le32_to_cpu(txs_data[6]); + txs7 = le32_to_cpu(txs_data[7]); + + stats->tx_mpdu_attempts += FIELD_GET(MT_TXS5_F1_MPDU_TX_COUNT, txs5); + stats->tx_mpdu_fail += FIELD_GET(MT_TXS6_F1_MPDU_FAIL_COUNT, txs6); + stats->tx_mpdu_retry += FIELD_GET(MT_TXS7_F1_MPDU_RETRY_COUNT, txs7); + } } static void @@ -1469,8 +1475,6 @@ static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data) u8 pid; txs = le32_to_cpu(txs_data[0]); - if (FIELD_GET(MT_TXS0_TXS_FORMAT, txs) > 1) - return; txs = le32_to_cpu(txs_data[2]); wcidx = FIELD_GET(MT_TXS2_WCID, txs); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h index ccce994dc07a..986a65badd1b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h @@ -347,6 +347,9 @@ struct mt7915_tx_free { #define MT_TXS4_TIMESTAMP GENMASK(31, 0) +/* The F0 variables are for TXSFM 0x0 and 0x1. The F1 variables + * are for TXSFM 0x2 aka PPDU format. + */ #define MT_TXS5_F0_FINAL_MPDU BIT(31) #define MT_TXS5_F0_QOS BIT(30) #define MT_TXS5_F0_TX_COUNT GENMASK(29, 25) From patchwork Thu Jul 22 20:28:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 484258 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F05CC4320A for ; Thu, 22 Jul 2021 20:28:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 121D260EB1 for ; Thu, 22 Jul 2021 20:28:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbhGVTsK (ORCPT ); Thu, 22 Jul 2021 15:48:10 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.52]:36894 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230480AbhGVTsH (ORCPT ); Thu, 22 Jul 2021 15:48:07 -0400 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 778AB20071 for ; Thu, 22 Jul 2021 20:28: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 57E44840083 for ; Thu, 22 Jul 2021 20:28: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 133FF13C2BC; Thu, 22 Jul 2021 13:28:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 133FF13C2BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1626985721; bh=CtDZ0o4nlBBBSQXFqDODEbTet004EU95y57Fud6MWtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iszi2+NeMRWubOdx9sxcQe318iQARbRjIo0UDi32h+B1/+eSJE/c/WttKZH5ulX5Q PBCW2K9zwkfwZftfuqD+G0EzRD6nQ+cUYYcVoQWqU+GlQnMUxCaq9y5yXBp2xoeJA3 /cUs834PHPwTHMqy5vFcUegoRYVviD0EQc3CTTKM= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v2 08/11] mt76: mt7915: Fix SGI reporting when using tx-overrides. Date: Thu, 22 Jul 2021 13:28:31 -0700 Message-Id: <20210722202834.6826-8-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722202834.6826-1-greearb@candelatech.com> References: <20210722202834.6826-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1626985721-HOrltSGX62_C Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear 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/mt7915/mac.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 1ef67608d122..d5747d61404a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -176,6 +176,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, From patchwork Thu Jul 22 20:28:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 484255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82E0EC00141 for ; Thu, 22 Jul 2021 20:28:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 669D660EB2 for ; Thu, 22 Jul 2021 20:28:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231162AbhGVTsL (ORCPT ); Thu, 22 Jul 2021 15:48:11 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.48]:36918 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230507AbhGVTsI (ORCPT ); Thu, 22 Jul 2021 15:48:08 -0400 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 1186E1A0063 for ; Thu, 22 Jul 2021 20:28:42 +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 DA82550007A for ; Thu, 22 Jul 2021 20:28: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 7D4E013C2BF; Thu, 22 Jul 2021 13:28:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 7D4E013C2BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1626985721; bh=n38SAAZklKjKKME8OaCnHMhPly0OJoXP7IZB7cn3wM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oT5mu3PO0izis/jVQs+/beUzsoq7gj1OTlNQtIMAXrptmZZfOLsf0h5K48XJnBOe2 wowJOytYmnOTUKmk3dU0AZXda2ao9HbEWeWRpRRGPSVODuwjBIloLnfwjZi75adwUR 5TDuneMOLnN9g1owGHDSNG7GMEbi+YAtqGM0pR3E= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v2 10/11] mt76: mt7915: Report tx-retries Date: Thu, 22 Jul 2021 13:28:33 -0700 Message-Id: <20210722202834.6826-10-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722202834.6826-1-greearb@candelatech.com> References: <20210722202834.6826-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1626985722-ATXFPciktggh 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 --- .../net/wireless/mediatek/mt76/mt7915/init.c | 1 + .../net/wireless/mediatek/mt76/mt7915/mac.c | 82 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7915/mac.h | 4 +- drivers/net/wireless/mediatek/mt76/tx.c | 6 +- 4 files changed, 86 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index a0d282771d77..9dc7a67dd76f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -217,6 +217,7 @@ mt7915_init_wiphy(struct ieee80211_hw *hw) struct wiphy *wiphy = hw->wiphy; hw->queues = 4; + hw->max_report_rates = 1; hw->max_rx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF; hw->max_tx_aggregation_subframes = IEEE80211_MAX_AMPDU_BUF; 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 d5747d61404a..09c91f887ae9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1257,17 +1257,22 @@ 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 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; @@ -1277,6 +1282,64 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t, mt7915_tx_check_aggr(sta, txwi); } else { wcid_idx = FIELD_GET(MT_TXD1_WLAN_IDX, le32_to_cpu(txwi[1])); + wcid = rcu_dereference(mdev->wcid[wcid_idx]); + } + + info = IEEE80211_SKB_CB(t->skb); + + /* Cannot clear all of info->status, we need the driver private + * status intact. + */ + info->status.is_valid_ack_signal = 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) { + 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; + } + } + + 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); @@ -1296,7 +1359,8 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) struct ieee80211_sta *sta = NULL; LIST_HEAD(free_list); struct sk_buff *tmp; - u8 i, count; + u8 i; + u16 count; bool wake = false; /* clean DMA queues and unmap buffers first */ @@ -1312,9 +1376,12 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) * to the time ack is received or dropped by hw (air + hw queue time). * Should avoid accessing WTBL to get Tx airtime, and use it instead. */ + /* free->ctrl is high u16 of first DW in the txfree struct */ count = FIELD_GET(MT_TX_FREE_MSDU_CNT, le16_to_cpu(free->ctrl)); for (i = 0; i < count; i++) { - u32 msdu, info = le32_to_cpu(free->info[i]); + u32 msdu, tx_cnt, tx_status; + u32 info = le32_to_cpu(free->info[i]); /* DW3+ */ + u32 ampdu; /* * 1'b1: new wcid pair. @@ -1345,7 +1412,12 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) if (!txwi) continue; - mt7915_txwi_free(dev, txwi, sta, &free_list); + 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, info); + ampdu = FIELD_GET(MT_TX_FREE_HEAD_OF_PAGE, info); + + mt7915_txwi_free(dev, txwi, sta, &free_list, tx_cnt, tx_status, ampdu); } mt7915_mac_sta_poll(dev); @@ -1873,7 +1945,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 741d51b0fa06..3f8fbed144df 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h @@ -299,7 +299,7 @@ struct mt7915_tx_free { __le16 ctrl; u8 txd_cnt; u8 rsv[3]; - __le32 info[]; + __le32 info[]; /* DW3+ */ } __packed __aligned(4); #define MT_TX_FREE_MSDU_CNT GENMASK(9, 0) @@ -311,6 +311,8 @@ struct mt7915_tx_free { /* when configured for txcount mode. See MT_PLE_HOST_RPT0_TX_LATENCY. */ #define MT_TX_FREE_TXCNT GENMASK(12, 0) #define MT_TX_FREE_STATUS 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) diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index 730f37aede3a..7ab7ea63fa52 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c @@ -263,6 +263,7 @@ 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; @@ -270,8 +271,11 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff * 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.rate = &wcid->rate; + } mt76_tx_check_non_aql(dev, wcid, skb); From patchwork Thu Jul 22 20:28:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 484256 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93FD0C00143 for ; Thu, 22 Jul 2021 20:28:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A93A60EB1 for ; Thu, 22 Jul 2021 20:28:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231156AbhGVTsM (ORCPT ); Thu, 22 Jul 2021 15:48:12 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.52]:36930 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbhGVTsI (ORCPT ); Thu, 22 Jul 2021 15:48:08 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.67.124]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 3E63A1C0071; Thu, 22 Jul 2021 20:28:42 +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 1225294007A; Thu, 22 Jul 2021 20:28:42 +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 AD8D913C2B7; Thu, 22 Jul 2021 13:28:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com AD8D913C2B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1626985721; bh=nhZKt5Lx0h8YJ+iL9eleCnIf9dexS1VuxlBN8T42laA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gi6Fm603DF3KvOzGBcojoSsaSeEKrA5L/abk7WBMZe0+vyhfcLtP/KFPVbisDpNR5 W/LBlL/KjWzBKz4fOvCZqTiLZjvZm4BC3dTm37d0MNjL7lRPLAydUNNl/7mVYPSgff h2qRFVktXnJ5aykCv14IIEMLgf3FVD4gZQ5kcuCs= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ryder Lee Subject: [PATCH v2 11/11] mt76: mt7915: add a missing HT flag for GI parsing Date: Thu, 22 Jul 2021 13:28:34 -0700 Message-Id: <20210722202834.6826-11-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210722202834.6826-1-greearb@candelatech.com> References: <20210722202834.6826-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1626985722-QsgNEEzuMRO8 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ryder Lee The previous commit missed a HT flag. Fixes: 14b220c07188 ("mt76: mt7915: report tx rate directly from tx status") Signed-off-by: Ryder Lee --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 09c91f887ae9..565875813565 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -215,7 +215,8 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev) 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) { + } else if (rate->flags & + (RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) { if (val & BIT(12 + bw)) { rate->flags |= RATE_INFO_FLAGS_SHORT_GI; msta->wcid.rate_short_gi = 1; @@ -224,7 +225,6 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev) msta->wcid.rate_short_gi = 0; } } - /* TODO: Deal with HT_MCS */ } rcu_read_unlock();