From patchwork Thu Aug 19 20:49:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500122 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, 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 7C2EDC4338F for ; Thu, 19 Aug 2021 20:50:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 606BF6108E for ; Thu, 19 Aug 2021 20:50:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235622AbhHSUuz (ORCPT ); Thu, 19 Aug 2021 16:50:55 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.49]:40962 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235563AbhHSUuy (ORCPT ); Thu, 19 Aug 2021 16:50:54 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.202]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 2E2B11C0069 for ; Thu, 19 Aug 2021 20:50:16 +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 01F988007D for ; Thu, 19 Aug 2021 20:50:15 +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 4B60413C2B1; Thu, 19 Aug 2021 13:49:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 4B60413C2B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406195; bh=fi3p6mUjaKj8NPoDcxaPuge/ESbAWXaVFnYe16yZJfg=; h=From:To:Cc:Subject:Date:From; b=QZvzB5a4hiXWt3Ga/ZwuYlIr5ipozeGYRNikdgwBeo/KLbNYcWtTGINkIVZiObNYJ yURxVhUHpPC1xc2ZU2xFdDd8Z+Br4sz00sMHyVvNXbAXoxOpGjnk4+K79vGhp4pndA /P3h/gy01nrxnzD9IGeLi6ee+zKWB+ltOKO37nes= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 1/9] mt76: add hash lookup for skb on TXS status_list Date: Thu, 19 Aug 2021 13:49:42 -0700 Message-Id: <20210819204950.12150-1-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-MDID: 1629406216-VzFZlG0mso4U Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear This improves performance when sending lots of frames that are requesting being mapped to a TXS callback. Add comments to help next person understood the tx path better. Signed-off-by: Ben Greear --- v8: Re-do the txs hash per Felix's suggestions. Remove the tx-overrides patch from this series per Kalle. drivers/net/wireless/mediatek/mt76/mt76.h | 48 +++++++--- .../net/wireless/mediatek/mt76/mt7603/mac.c | 2 +- .../net/wireless/mediatek/mt76/mt7615/mac.c | 2 +- .../net/wireless/mediatek/mt76/mt76x02_mac.c | 2 +- .../net/wireless/mediatek/mt76/mt7915/mac.c | 4 +- .../net/wireless/mediatek/mt76/mt7921/mac.c | 9 +- drivers/net/wireless/mediatek/mt76/tx.c | 94 ++++++++++++++++--- 7 files changed, 130 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 436bf2b8e2cd..3ea4936753c2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -235,6 +235,16 @@ DECLARE_EWMA(signal, 10, 8); #define MT_WCID_TX_INFO_TXPWR_ADJ GENMASK(25, 18) #define MT_WCID_TX_INFO_SET BIT(31) +#define MT_PACKET_ID_MASK GENMASK(6, 0) +#define MT_PACKET_ID_NO_ACK 0 +/* Request TXS, but don't try to match with skb. */ +#define MT_PACKET_ID_NO_SKB 1 +#define MT_PACKET_ID_FIRST 2 +#define MT_PACKET_ID_HAS_RATE BIT(7) +#define MT_PACKET_ID_MAX (GENMASK(7, 0) - 1) +#define MT_NUM_STATUS_PACKETS \ + (MT_PACKET_ID_MAX + 1 - MT_PACKET_ID_FIRST) + struct mt76_wcid { struct mt76_rx_tid __rcu *aggr[IEEE80211_NUM_TIDS]; @@ -246,6 +256,8 @@ struct mt76_wcid { struct rate_info rate; + struct sk_buff *skb_status_array[MT_NUM_STATUS_PACKETS]; + u16 idx; u8 hw_key_idx; u8 hw_key_idx2; @@ -302,16 +314,16 @@ struct mt76_rx_tid { #define MT_TX_CB_TXS_DONE BIT(1) #define MT_TX_CB_TXS_FAILED BIT(2) -#define MT_PACKET_ID_MASK GENMASK(6, 0) -#define MT_PACKET_ID_NO_ACK 0 -#define MT_PACKET_ID_NO_SKB 1 -#define MT_PACKET_ID_FIRST 2 -#define MT_PACKET_ID_HAS_RATE BIT(7) - -#define MT_TX_STATUS_SKB_TIMEOUT HZ +/* This is timer for when to give up when waiting for TXS callback, + * with starting time being the time at which the DMA_DONE callback + * was seen (so, we know packet was processed then, it should not take + * long after that for firmware to send the TXS callback if it is going + * to do so.) + */ +#define MT_TX_STATUS_SKB_TIMEOUT (HZ / 4) struct mt76_tx_cb { - unsigned long jiffies; + unsigned long jiffies; /* for when DMA_DONE was reported. */ u16 wcid; u8 pktid; u8 flags; @@ -651,6 +663,7 @@ struct mt76_dev { spinlock_t cc_lock; u32 cur_cc_bss_rx; + unsigned long next_status_jiffies; struct mt76_rx_status rx_ampdu_status; u32 rx_ampdu_len; @@ -1090,7 +1103,7 @@ struct sk_buff *mt76_tx_status_skb_get(struct mt76_dev *dev, struct mt76_wcid *wcid, int pktid, struct sk_buff_head *list); void mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb, - struct sk_buff_head *list); + struct sk_buff_head *list, struct mt76_wcid *wcid); void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid, struct sk_buff *skb, struct list_head *free_list); static inline void @@ -1297,13 +1310,24 @@ mt76_token_put(struct mt76_dev *dev, int token) } static inline int -mt76_get_next_pkt_id(struct mt76_wcid *wcid) +mt76_get_next_pkt_id(struct mt76_dev *dev, struct mt76_wcid *wcid, + struct sk_buff *skb) { + struct sk_buff *qskb; + + lockdep_assert_held(&dev->status_list.lock); + wcid->packet_id = (wcid->packet_id + 1) & MT_PACKET_ID_MASK; - if (wcid->packet_id == MT_PACKET_ID_NO_ACK || - wcid->packet_id == MT_PACKET_ID_NO_SKB) + if (wcid->packet_id < MT_PACKET_ID_FIRST) wcid->packet_id = MT_PACKET_ID_FIRST; + qskb = wcid->skb_status_array[wcid->packet_id - MT_PACKET_ID_FIRST]; + if (qskb) + /* bummer, already waiting on this pid. Other logic + * will clean up stale entries. + */ + return MT_PACKET_ID_NO_SKB; + return wcid->packet_id; } #endif diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c index 3972c56136a2..2f268eb7c1e6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c @@ -1230,7 +1230,7 @@ mt7603_mac_add_txs_skb(struct mt7603_dev *dev, struct mt7603_sta *sta, int pid, info->status.rates[0].idx = -1; } - mt76_tx_status_skb_done(mdev, skb, &list); + mt76_tx_status_skb_done(mdev, skb, &list, &sta->wcid); } mt76_tx_status_unlock(mdev, &list); diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index ff3f85e4087c..381a998817d4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -1433,7 +1433,7 @@ static bool mt7615_mac_add_txs_skb(struct mt7615_dev *dev, info->status.rates[0].idx = -1; } - mt76_tx_status_skb_done(mdev, skb, &list); + mt76_tx_status_skb_done(mdev, skb, &list, &sta->wcid); } mt76_tx_status_unlock(mdev, &list); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c index c32e6dc68773..fce020e64678 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c @@ -622,7 +622,7 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev, info = *status.info; len = status.skb->len; ac = skb_get_queue_mapping(status.skb); - mt76_tx_status_skb_done(mdev, status.skb, &list); + mt76_tx_status_skb_done(mdev, status.skb, &list, wcid); } else if (msta) { len = status.info->status.ampdu_len * ewma_pktlen_read(&msta->pktlen); ac = FIELD_GET(MT_PKTID_AC, cur_pktid); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index d9f52e2611a7..c8432054a63e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1318,6 +1318,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, mt76_tx_status_lock(mdev, &list); skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); + if (!skb) goto out; @@ -1417,10 +1418,11 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, stats->tx_bw[0]++; break; } + wcid->rate = rate; out: - mt76_tx_status_skb_done(mdev, skb, &list); + mt76_tx_status_skb_done(mdev, skb, &list, wcid); mt76_tx_status_unlock(mdev, &list); return !!skb; diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 76985a6b3be5..219c17d77e46 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -732,7 +732,9 @@ mt7921_mac_write_txwi_80211(struct mt7921_dev *dev, __le32 *txwi, txwi[7] |= cpu_to_le32(val); } -static void mt7921_update_txs(struct mt76_wcid *wcid, __le32 *txwi) +static void mt7921_update_txs(struct mt7921_dev *dev, + struct mt76_wcid *wcid, __le32 *txwi, + struct sk_buff *skb) { struct mt7921_sta *msta = container_of(wcid, struct mt7921_sta, wcid); u32 pid, frame_type = FIELD_GET(MT_TXD2_FRAME_TYPE, txwi[2]); @@ -744,7 +746,7 @@ static void mt7921_update_txs(struct mt76_wcid *wcid, __le32 *txwi) return; msta->next_txs_ts = jiffies + msecs_to_jiffies(250); - pid = mt76_get_next_pkt_id(wcid); + pid = mt76_get_next_pkt_id(&dev->mt76, wcid, skb); txwi[5] |= cpu_to_le32(MT_TXD5_TX_STATUS_MCU | FIELD_PREP(MT_TXD5_PID, pid)); } @@ -771,7 +773,6 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi, { struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_vif *vif = info->control.vif; - struct mt76_phy *mphy = &dev->mphy; u8 p_fmt, q_idx, omac_idx = 0, wmm_idx = 0; bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP; u16 tx_count = 15; @@ -839,7 +840,7 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi, txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE); } - mt7921_update_txs(wcid, txwi); + mt7921_update_txs(dev, wcid, txwi, skb); } static void diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index 6f302acb6e69..7b281cd062c9 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c @@ -36,6 +36,7 @@ mt76_tx_check_agg_ssn(struct ieee80211_sta *sta, struct sk_buff *skb) } EXPORT_SYMBOL_GPL(mt76_tx_check_agg_ssn); +/* Lock list, and initialize the timed-out-skb list object. */ void mt76_tx_status_lock(struct mt76_dev *dev, struct sk_buff_head *list) __acquires(&dev->status_list.lock) @@ -45,6 +46,9 @@ mt76_tx_status_lock(struct mt76_dev *dev, struct sk_buff_head *list) } EXPORT_SYMBOL_GPL(mt76_tx_status_lock); +/* Unlock list, and use last-received status for any skbs that + * timed out getting TXS callback (they are on the list passed in + */ void mt76_tx_status_unlock(struct mt76_dev *dev, struct sk_buff_head *list) __releases(&dev->status_list.lock) @@ -80,20 +84,44 @@ EXPORT_SYMBOL_GPL(mt76_tx_status_unlock); static void __mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb, u8 flags, - struct sk_buff_head *list) + struct sk_buff_head *list, struct mt76_wcid *wcid) { struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb); u8 done = MT_TX_CB_DMA_DONE | MT_TX_CB_TXS_DONE; + lockdep_assert_held(&dev->status_list.lock); + + /* Start timer for TXS callback expiration. */ + if (flags & MT_TX_CB_DMA_DONE) + cb->jiffies = jiffies; + flags |= cb->flags; cb->flags = flags; + /* Only process skb with TXS status has been received and also + * the txfree (DMA_DONE) callback has happened. + */ if ((flags & done) != done) return; __skb_unlink(skb, &dev->status_list); + rcu_read_lock(); + /* calling code may not know wcid, for instance in the tx_status_check + * path, look it up in that case. + */ + if (!wcid) + wcid = rcu_dereference(dev->wcid[cb->wcid]); + + /* Make sure we clear any cached skb. */ + if (wcid) { + if (!(WARN_ON_ONCE(cb->pktid - MT_PACKET_ID_FIRST + >= ARRAY_SIZE(wcid->skb_status_array)))) + wcid->skb_status_array[cb->pktid - MT_PACKET_ID_FIRST] = NULL; + } + rcu_read_unlock(); + /* Tx status can be unreliable. if it fails, mark the frame as ACKed */ if (flags & MT_TX_CB_TXS_FAILED) { info->status.rates[0].count = 0; @@ -106,9 +134,9 @@ __mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb, u8 flags, void mt76_tx_status_skb_done(struct mt76_dev *dev, struct sk_buff *skb, - struct sk_buff_head *list) + struct sk_buff_head *list, struct mt76_wcid *wcid) { - __mt76_tx_status_skb_done(dev, skb, MT_TX_CB_TXS_DONE, list); + __mt76_tx_status_skb_done(dev, skb, MT_TX_CB_TXS_DONE, list, wcid); } EXPORT_SYMBOL_GPL(mt76_tx_status_skb_done); @@ -133,12 +161,16 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid, spin_lock_bh(&dev->status_list.lock); memset(cb, 0, sizeof(*cb)); - pid = mt76_get_next_pkt_id(wcid); + pid = mt76_get_next_pkt_id(dev, wcid, skb); cb->wcid = wcid->idx; cb->pktid = pid; - cb->jiffies = jiffies; - __skb_queue_tail(&dev->status_list, skb); + if (cb->pktid != MT_PACKET_ID_NO_SKB) { + __skb_queue_tail(&dev->status_list, skb); + /* cache this skb for fast lookup by packet-id */ + wcid->skb_status_array[pid - MT_PACKET_ID_FIRST] = skb; + } + spin_unlock_bh(&dev->status_list.lock); return pid; @@ -150,25 +182,65 @@ mt76_tx_status_skb_get(struct mt76_dev *dev, struct mt76_wcid *wcid, int pktid, struct sk_buff_head *list) { struct sk_buff *skb, *tmp; + struct sk_buff *rvskb = NULL; + /* If pktid is < first-valid-id, then it is not something we requested + * TXS for, so we will not find SKB. Bail out early in that case, + * unless we need to walk due to stale-skb-reaper timeout. + */ + if (pktid < MT_PACKET_ID_FIRST) { + if (!time_after(jiffies, dev->next_status_jiffies)) + return NULL; + goto check_list; + } + + if (wcid) { + lockdep_assert_held(&dev->status_list.lock); + if (WARN_ON_ONCE(pktid - MT_PACKET_ID_FIRST + >= ARRAY_SIZE(wcid->skb_status_array))) { + dev_err(dev->dev, "invalid pktid: %d status-array-size: %d\n", + pktid, (int)(ARRAY_SIZE(wcid->skb_status_array))); + WARN_ON_ONCE(true); + goto check_list; + } + + skb = wcid->skb_status_array[pktid - MT_PACKET_ID_FIRST]; + + if (skb && !time_after(jiffies, dev->next_status_jiffies)) + return skb; + } + +check_list: skb_queue_walk_safe(&dev->status_list, skb, tmp) { struct mt76_tx_cb *cb = mt76_tx_skb_cb(skb); if (wcid && cb->wcid != wcid->idx) continue; - if (cb->pktid == pktid) - return skb; + if (cb->pktid == pktid) { + /* Found our skb, but check for timeouts too */ + rvskb = skb; + continue; + } + + /* Cannot time out anything that does not have DMA completed. */ + if (!(cb->flags & MT_TX_CB_DMA_DONE)) + continue; + /* Check if it has been too long since DMA_DONE was reported. */ if (pktid >= 0 && !time_after(jiffies, cb->jiffies + MT_TX_STATUS_SKB_TIMEOUT)) continue; + /* It has been too long since DMA_DONE, time out this packet + * and stop waiting for TXS callback. + */ __mt76_tx_status_skb_done(dev, skb, MT_TX_CB_TXS_FAILED | - MT_TX_CB_TXS_DONE, list); + MT_TX_CB_TXS_DONE, list, wcid); } + dev->next_status_jiffies = jiffies + MT_TX_STATUS_SKB_TIMEOUT + 1; - return NULL; + return rvskb; } EXPORT_SYMBOL_GPL(mt76_tx_status_skb_get); @@ -238,7 +310,7 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff * } mt76_tx_status_lock(dev, &list); - __mt76_tx_status_skb_done(dev, skb, MT_TX_CB_DMA_DONE, &list); + __mt76_tx_status_skb_done(dev, skb, MT_TX_CB_DMA_DONE, &list, wcid); mt76_tx_status_unlock(dev, &list); out: From patchwork Thu Aug 19 20:49:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500846 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, 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 50C63C432BE for ; Thu, 19 Aug 2021 20:50:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31595610A0 for ; Thu, 19 Aug 2021 20:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235605AbhHSUus (ORCPT ); Thu, 19 Aug 2021 16:50:48 -0400 Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.164]:37524 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235669AbhHSUur (ORCPT ); Thu, 19 Aug 2021 16:50:47 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.51.167]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id C1AF9A0073 for ; Thu, 19 Aug 2021 20:50:09 +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 95E02240069 for ; Thu, 19 Aug 2021 20:50:09 +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 7CCC613C2B3; Thu, 19 Aug 2021 13:49:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 7CCC613C2B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406195; bh=KppOMUbNWFVwiVZmMA7VJzVyk5Br8QdOQVIDyRBVy/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rB/GK6pqniUPyXamdJVVqyPqbWUWlsV5hyMUh4yuhh8VvPRpfxMb/VvQd0Aef6a4/ eUKdP7Jfvnu8FfDosF16T5yY4lJK0/eWu0ofVgJLAwryDxDr2SaZ1aWZ2KS7r1v2TK 6h/tyjDIwFqh4eQyJ0Gw0ChvQrRvQd4pcPK4/7ek= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 2/9] mt76: mt7915: fix potential NPE in TXS processing Date: Thu, 19 Aug 2021 13:49:43 -0700 Message-Id: <20210819204950.12150-2-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406210-nzjLHkHJRsHE 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 c8432054a63e..05c80a8dd82a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1320,7 +1320,7 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); if (!skb) - goto out; + goto out_no_skb; txs = le32_to_cpu(txs_data[0]); @@ -1423,6 +1423,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 Aug 19 20:49:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500849 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, 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 2E20FC4338F for ; Thu, 19 Aug 2021 20:49:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 121AD6108E for ; Thu, 19 Aug 2021 20:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235439AbhHSUue (ORCPT ); Thu, 19 Aug 2021 16:50:34 -0400 Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.184]:38406 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235388AbhHSUue (ORCPT ); Thu, 19 Aug 2021 16:50:34 -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 864932005E for ; Thu, 19 Aug 2021 20:49:56 +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 4B5A87C007A for ; Thu, 19 Aug 2021 20:49:56 +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 AC08913C2B4; Thu, 19 Aug 2021 13:49:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com AC08913C2B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406195; bh=5c22tKtIgiOfEKNdxFMT3/AD7f/rJ8P34Ud31x8labM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=II2tZNoaiQ5VdXxBivZIuXL6/i0VDV8ixnFljyx+AiVrntxDIypcmVIyg8OZVjeh7 ORxg58OqBmsGPKd66EGpqrFS7ofYx07K5Jo/ZUe57ggQ6cnv1LOJr03FbB3JJmoJ3K mQFouOhHA2AtqQmP2Vy6JzHQxLPc8qgxNurrdS0c= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 3/9] mt76: mt7915: move TXS parsing to its own method Date: Thu, 19 Aug 2021 13:49:44 -0700 Message-Id: <20210819204950.12150-3-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406197-o6f6zKhXlfmu Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear This will allow us to also parse TXS when we have no skb on the status callback list in future patches. 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 --- drivers/net/wireless/mediatek/mt76/mt76.h | 5 + .../net/wireless/mediatek/mt76/mt7915/mac.c | 120 ++++++++++-------- 2 files changed, 75 insertions(+), 50 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 3ea4936753c2..9f0d6449fe9b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -254,7 +254,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() */ struct sk_buff *skb_status_array[MT_NUM_STATUS_PACKETS]; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 05c80a8dd82a..6f92e207680f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -205,12 +205,17 @@ 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) { - 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; + } } + /* TODO: Deal with HT_MCS */ } rcu_read_unlock(); @@ -1302,29 +1307,19 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) } } -static bool -mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, - __le32 *txs_data, struct mt7915_sta_stats *stats) +static void +mt7915_mac_parse_txs(struct mt7915_dev *dev, struct mt76_wcid *wcid, + __le32 *txs_data, struct mt7915_sta_stats *stats, + struct rate_info *rate, + struct ieee80211_tx_info *info) { struct ieee80211_supported_band *sband; - struct mt76_dev *mdev = &dev->mt76; struct mt76_phy *mphy; - struct ieee80211_tx_info *info; - struct sk_buff_head list; - struct rate_info rate = {}; - struct sk_buff *skb; - 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; + bool cck = false; 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; @@ -1336,18 +1331,18 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, txrate = FIELD_GET(MT_TXS0_TX_RATE, txs); - rate.mcs = FIELD_GET(MT_TX_RATE_IDX, txrate); - rate.nss = FIELD_GET(MT_TX_RATE_NSS, txrate) + 1; + rate->mcs = FIELD_GET(MT_TX_RATE_IDX, txrate); + rate->nss = FIELD_GET(MT_TX_RATE_NSS, txrate) + 1; - stats->tx_nss[rate.nss - 1]++; + stats->tx_nss[rate->nss - 1]++; /* It appears that rate.mcs even for HT may be small, considering in HT * code below it is multiplied... but not certain on that, * so code safely. */ - if (rate.mcs >= ARRAY_SIZE(stats->tx_mcs)) + if (rate->mcs >= ARRAY_SIZE(stats->tx_mcs)) stats->tx_mcs[ARRAY_SIZE(stats->tx_mcs) - 1]++; else - stats->tx_mcs[rate.mcs]++; + stats->tx_mcs[rate->mcs]++; mode = FIELD_GET(MT_TX_RATE_MODE, txrate); switch (mode) { @@ -1364,70 +1359,95 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, else sband = &mphy->sband_2g.sband; - rate.mcs = mt76_get_rate(mphy->dev, sband, rate.mcs, cck); - rate.legacy = sband->bitrates[rate.mcs].bitrate; + rate->mcs = mt76_get_rate(mphy->dev, sband, rate->mcs, cck); + rate->legacy = sband->bitrates[rate->mcs].bitrate; break; case MT_PHY_TYPE_HT: case MT_PHY_TYPE_HT_GF: - rate.mcs += (rate.nss - 1) * 8; - if (rate.mcs > 31) - goto out; + rate->mcs += (rate->nss - 1) * 8; + if (rate->mcs > 31) + break; - rate.flags = RATE_INFO_FLAGS_MCS; - if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI) - rate.flags |= RATE_INFO_FLAGS_SHORT_GI; + rate->flags = RATE_INFO_FLAGS_MCS; + if (wcid->rate_short_gi) + rate->flags |= RATE_INFO_FLAGS_SHORT_GI; break; case MT_PHY_TYPE_VHT: - if (rate.mcs > 9) - goto out; + if (rate->mcs > 9) + break; - rate.flags = RATE_INFO_FLAGS_VHT_MCS; + 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: case MT_PHY_TYPE_HE_TB: case MT_PHY_TYPE_HE_MU: - if (rate.mcs > 11) - goto out; + if (rate->mcs > 11) + break; - rate.he_gi = wcid->rate.he_gi; - rate.he_dcm = FIELD_GET(MT_TX_RATE_DCM, txrate); - rate.flags = RATE_INFO_FLAGS_HE_MCS; + 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: - goto out; + WARN_ON_ONCE(true); + mode = 0; } stats->tx_mode[mode]++; switch (FIELD_GET(MT_TXS0_BW, txs)) { case IEEE80211_STA_RX_BW_160: - rate.bw = RATE_INFO_BW_160; + rate->bw = RATE_INFO_BW_160; stats->tx_bw[3]++; break; case IEEE80211_STA_RX_BW_80: - rate.bw = RATE_INFO_BW_80; + rate->bw = RATE_INFO_BW_80; stats->tx_bw[2]++; break; case IEEE80211_STA_RX_BW_40: - rate.bw = RATE_INFO_BW_40; + rate->bw = RATE_INFO_BW_40; stats->tx_bw[1]++; break; default: - rate.bw = RATE_INFO_BW_20; + rate->bw = RATE_INFO_BW_20; stats->tx_bw[0]++; break; } +} - wcid->rate = rate; +static void +mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, + __le32 *txs_data, struct mt7915_sta_stats *stats) +{ + struct mt76_dev *mdev = &dev->mt76; + struct ieee80211_tx_info *info; + struct ieee80211_tx_info info_stack; + struct sk_buff_head list; + /* rate is cached in wcid->rate for skbs that do not request to be + * paired with TXS data. This is normal datapath. + */ + struct rate_info *rate = &wcid->rate; + struct sk_buff *skb; -out: - mt76_tx_status_skb_done(mdev, skb, &list, wcid); + mt76_tx_status_lock(mdev, &list); + skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); -out_no_skb: - mt76_tx_status_unlock(mdev, &list); + memset(rate, 0, sizeof(*rate)); - return !!skb; + if (skb) + info = IEEE80211_SKB_CB(skb); + else + info = &info_stack; + + mt7915_mac_parse_txs(dev, wcid, txs_data, stats, rate, info); + + if (skb) + mt76_tx_status_skb_done(mdev, skb, &list, wcid); + + mt76_tx_status_unlock(mdev, &list); } static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data) From patchwork Thu Aug 19 20:49:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500848 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, 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 4D85EC4320A for ; Thu, 19 Aug 2021 20:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29E75610A1 for ; Thu, 19 Aug 2021 20:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235310AbhHSUuk (ORCPT ); Thu, 19 Aug 2021 16:50:40 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.49]:52736 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235533AbhHSUuj (ORCPT ); Thu, 19 Aug 2021 16:50:39 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.67.132]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 7E46B1A0068 for ; Thu, 19 Aug 2021 20:50:00 +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 5CC76500077 for ; Thu, 19 Aug 2021 20:50:00 +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 D4AC513C2B5; Thu, 19 Aug 2021 13:49:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com D4AC513C2B5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406195; bh=1bEtj1Ib3f4Uf08FKQ7wd6mqy8Ya3kvyoEy3613pNao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WmagER++JrFy13wOsOwx7zgmkDFNiGXsQu5gh/muXTZ5Sx12jrrx3u7UVwP10xtJH jENFDFUDNmSBjd5WjemD3VqPCiMIU7N7jFWjNoq2lKI6G0tWJs0nBgkbnS+rOGognx qFDgL1J6T4uefAQhuKgVd0Y2nEH7huIQy+vJ52b0= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 4/9] mt76: mt7915: allow processing TXS for 'NO_SKB' pkt-ids Date: Thu, 19 Aug 2021 13:49:45 -0700 Message-Id: <20210819204950.12150-4-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406201-gEFAqCX105eg 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 --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 6f92e207680f..f6ed5d5febb7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1430,10 +1430,16 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, * paired with TXS data. This is normal datapath. */ struct rate_info *rate = &wcid->rate; - struct sk_buff *skb; + struct sk_buff *skb = NULL; + bool check_status; - mt76_tx_status_lock(mdev, &list); - skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); + check_status = ((pid >= MT_PACKET_ID_FIRST) || + time_after(jiffies, mdev->next_status_jiffies)); + + if (check_status) { + mt76_tx_status_lock(mdev, &list); + skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); + } memset(rate, 0, sizeof(*rate)); @@ -1447,7 +1453,8 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, if (skb) mt76_tx_status_skb_done(mdev, skb, &list, wcid); - mt76_tx_status_unlock(mdev, &list); + if (check_status) + mt76_tx_status_unlock(mdev, &list); } static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data) @@ -1469,7 +1476,7 @@ static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data) txs = le32_to_cpu(txs_data[3]); pid = FIELD_GET(MT_TXS3_PID, txs); - if (pid < MT_PACKET_ID_FIRST) + if (pid < MT_PACKET_ID_NO_SKB) return; if (wcidx >= MT7915_WTBL_SIZE) From patchwork Thu Aug 19 20:49:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500124 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, 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 E645AC432BE for ; Thu, 19 Aug 2021 20:50:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBE426108E for ; Thu, 19 Aug 2021 20:50:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235519AbhHSUul (ORCPT ); Thu, 19 Aug 2021 16:50:41 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.49]:52760 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235563AbhHSUuk (ORCPT ); Thu, 19 Aug 2021 16:50:40 -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 3056B2007B for ; Thu, 19 Aug 2021 20:50:01 +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 03C3D840081 for ; Thu, 19 Aug 2021 20:50:00 +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 0964713C2B7; Thu, 19 Aug 2021 13:49:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 0964713C2B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406196; bh=YrgFfZcW1ojgO28V6RfxOrnq4jxixsnrt8Xi/DcixjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JBvt9S5+bz2WhhDm6puD05aYqO5j0pIKT1cazK40T3Jwah8sX+5eziMj8Mw6hKuAd oMTtW503LNdiXL+ogpA5x/wPjJDcMIscz3LGsyMsUw34nrqcV/7BDuxuQhpDOWKLcn uoo/QUqVB112VilD6gGicZ0QZdKvLFonPMjcF3Mc= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 5/9] mt76: mt7915: debugfs hook to enable TXS for NO_SKB pkt-ids Date: Thu, 19 Aug 2021 13:49:46 -0700 Message-Id: <20210819204950.12150-5-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406201-3bhV85xKob7H 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 91664ac63a8d..b2df42802868 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("force_txs", 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 f6ed5d5febb7..39d2175862bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1047,7 +1047,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 ea6da6b4e92d..1c0a1bf91c1c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -223,6 +223,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 Aug 19 20:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500123 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, 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 C2347C4338F for ; Thu, 19 Aug 2021 20:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A57E2610A0 for ; Thu, 19 Aug 2021 20:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235631AbhHSUuq (ORCPT ); Thu, 19 Aug 2021 16:50:46 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.49]:52998 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235560AbhHSUup (ORCPT ); Thu, 19 Aug 2021 16:50:45 -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 E3DEF1C0073 for ; Thu, 19 Aug 2021 20:50:07 +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 C3804500083 for ; Thu, 19 Aug 2021 20:50:07 +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 30B2213C2B8; Thu, 19 Aug 2021 13:49:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 30B2213C2B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406196; bh=jaPe5aCo0puDjlL/Yjg9OUAOkqrjKfpVDF9GVEcjijs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c89LeZ6zBc/c3MNaoMRFLMq9gHBzbTEyoO6G2ada7Jp8yzuJeY/3wTMj1Ri+1L4jw ENf4NfVsbqd/ebOIgKqBp/apEq2/ptG10ahg8tcZNnsTzHOWhs2cs+3cRoawCagEr/ tDX+CS0XQ8+I/aGXySASzuIvffThsROzH+xEuS0U= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 6/9] mt76: mt7915: add note about TXSFM 0x2 Date: Thu, 19 Aug 2021 13:49:47 -0700 Message-Id: <20210819204950.12150-6-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406208-ZlXnlBwbafOy Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ben Greear This format is not supported by any current hardware, add note to mention this. Signed-off-by: Ben Greear --- drivers/net/wireless/mediatek/mt76/mt7915/mac.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h index ccce994dc07a..65dba1061376 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h @@ -347,6 +347,10 @@ 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. TXSFM 0x2 not supported + * at this time. + */ #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 Aug 19 20:49:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500125 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, 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 4C667C4338F for ; Thu, 19 Aug 2021 20:50:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DBA3610A5 for ; Thu, 19 Aug 2021 20:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235556AbhHSUuj (ORCPT ); Thu, 19 Aug 2021 16:50:39 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.49]:52734 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235388AbhHSUui (ORCPT ); Thu, 19 Aug 2021 16:50:38 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.67.132]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id B2EFA1C0073 for ; Thu, 19 Aug 2021 20:50:00 +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 92E6E500086 for ; Thu, 19 Aug 2021 20:50:00 +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 5E58C13C2BB; Thu, 19 Aug 2021 13:49:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 5E58C13C2BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406196; bh=dno2s6vpZpYzObc7adrbYSpkD2upB9f0haLZnDxJ2yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bVtjnUSzNVhWDvUF0OYcZnCdkLO9Hzjm+9urBtxslGQqJh2cQi8FJy6U9oNZdEjS0 krQHhRUSMoq7MBCuWP/9To26j4dzkwMs8RzP16tK9I4zma22g0vtWtsJsZUOnJDPJm mi3f0k14jrBSwUy7jpe5xwlQAsfOEXnd9LvHvel4= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 7/9] mt76: mt7915: txfree status to show txcount instead of latency Date: Thu, 19 Aug 2021 13:49:48 -0700 Message-Id: <20210819204950.12150-7-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406201-OC-rhcB4c_0A 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 | 8 +++++--- drivers/net/wireless/mediatek/mt76/mt7915/regs.h | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index f174cf219724..a0d282771d77 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -304,6 +304,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; 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 65dba1061376..3f5a80158866 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.h @@ -304,13 +304,15 @@ struct mt7915_tx_free { #define MT_TX_FREE_MSDU_CNT GENMASK(9, 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_STATUS GENMASK(14, 13) #define MT_TX_FREE_MSDU_ID GENMASK(30, 16) #define MT_TX_FREE_PAIR BIT(31) -/* will support this field in further revision */ -#define MT_TX_FREE_RATE GENMASK(13, 0) #define MT_TXS0_FIXED_RATE BIT(31) #define MT_TXS0_BW GENMASK(30, 29) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h index 62cc32a098fc..ac4d233b8cf2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/regs.h @@ -22,6 +22,10 @@ #define MT_PLE_BASE 0x8000 #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_PLE_FL_Q0_CTRL MT_PLE(0x1b0) #define MT_PLE_FL_Q1_CTRL MT_PLE(0x1b4) #define MT_PLE_FL_Q2_CTRL MT_PLE(0x1b8) From patchwork Thu Aug 19 20:49:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500845 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, 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 EBEEBC4320A for ; Thu, 19 Aug 2021 20:50:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D645E610A0 for ; Thu, 19 Aug 2021 20:50:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235671AbhHSUu4 (ORCPT ); Thu, 19 Aug 2021 16:50:56 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.52]:41020 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235541AbhHSUu4 (ORCPT ); Thu, 19 Aug 2021 16:50:56 -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 1605120079 for ; Thu, 19 Aug 2021 20:50:18 +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 DB73E500028 for ; Thu, 19 Aug 2021 20:50:17 +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 85E6913C2BC; Thu, 19 Aug 2021 13:49:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 85E6913C2BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406196; bh=3Uz8P7Xi5ypoSYRko52powQighxCDZ2cHZIMR8XqXGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OrrLFhgjSqAm5lDbX25SmYnIlyQ/2wU1pqosy2TUjHQ6IjULABLpM9+dZ9OiIovPa Ah2yPFSA7L15bihz3klD0tKpsnPnYKGIAQXgwyc6+e35AJ+E3KWnazbLK5o/fMAg8x pmJpvGhf9ADgDAUOScx84EH0W9Zfm/IIIPPQyYv8= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v8 8/9] mt76: mt7915: report tx-retries Date: Thu, 19 Aug 2021 13:49:49 -0700 Message-Id: <20210819204950.12150-8-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406218-d93q8VwIf5zF 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 | 93 ++++++++++++++++++- .../net/wireless/mediatek/mt76/mt7915/mac.h | 4 +- .../net/wireless/mediatek/mt76/mt7915/main.c | 8 ++ .../wireless/mediatek/mt76/mt7915/mt7915.h | 4 + drivers/net/wireless/mediatek/mt76/tx.c | 6 +- 6 files changed, 109 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 39d2175862bd..f5332e2c5e4e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1202,17 +1202,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; @@ -1222,6 +1227,75 @@ 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) { + struct mt7915_sta *msta = container_of(wcid, struct mt7915_sta, wcid); + struct mt7915_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); @@ -1241,7 +1315,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 */ @@ -1257,9 +1332,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. @@ -1290,7 +1368,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); @@ -1817,7 +1900,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 3f5a80158866..c53eca81476f 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/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c index 4a37c4dc49e4..ff945540c460 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c @@ -1093,6 +1093,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", @@ -1165,6 +1169,10 @@ static void mt7915_ethtool_worker(void *wi_data, struct ieee80211_sta *sta) wi->sta_count++; + data[ei++] += mstats->tx_mpdu_attempts; + data[ei++] += mstats->tx_mpdu_fail; + data[ei++] += mstats->tx_mpdu_retry; + data[ei++] += mstats->tx_mpdu_ok; data[ei++] += mstats->tx_mode[MT_PHY_TYPE_CCK]; data[ei++] += mstats->tx_mode[MT_PHY_TYPE_OFDM]; data[ei++] += mstats->tx_mode[MT_PHY_TYPE_HT]; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 1c0a1bf91c1c..b41c6a093354 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -65,6 +65,10 @@ enum mt7915_rxq_id { }; struct mt7915_sta_stats { + unsigned long tx_mpdu_attempts; /* counting any retries */ + unsigned long tx_mpdu_fail; /* frames that failed even after retry */ + unsigned long tx_mpdu_ok; /* frames that succeeded, perhaps after retry */ + unsigned long tx_mpdu_retry; /* number of times frames were retried */ unsigned long tx_mode[MT_PHY_TYPE_HE_LAST]; /* See mt76_phy_type */ unsigned long tx_bw[4]; /* 20, 40, 80, 160 */ unsigned long tx_nss[4]; /* 1, 2, 3, 4 */ diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index 7b281cd062c9..9fec9613c67f 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c @@ -276,6 +276,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; @@ -283,8 +284,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 Aug 19 20:49:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Greear X-Patchwork-Id: 500847 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, 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 69987C4338F for ; Thu, 19 Aug 2021 20:50:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AD826108E for ; Thu, 19 Aug 2021 20:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235628AbhHSUun (ORCPT ); Thu, 19 Aug 2021 16:50:43 -0400 Received: from dispatch1-us1.ppe-hosted.com ([67.231.154.184]:37302 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235563AbhHSUun (ORCPT ); Thu, 19 Aug 2021 16:50:43 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.110.48.61]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id AE2B520061; Thu, 19 Aug 2021 20:50:05 +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 72A29C0076; Thu, 19 Aug 2021 20:50:05 +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 AF73C13C2BE; Thu, 19 Aug 2021 13:49:56 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com AF73C13C2BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1629406196; bh=Wuh5dOzI8THzLhn2SA/cFW1xGtRgxaBEPaFiOuobEaw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cdFw5ViBeZ3EFHD5ohx5StNNF7Pgiy9UoUwXDa7UFW2lS37FoXB+ytTbBpwvSrJ2t 7o51OeL5iV7paWdn9fZ2VS1ijLr7K9qJ5BFs9vecU6SLMzj7KR2olzK17scnyzS4za twjJ5K+JYgAgp3pA97SGl6SNU+asMtiBjKfutkJU= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ryder Lee Subject: [PATCH v8 9/9] mt76: mt7915: add a missing HT flag for GI parsing Date: Thu, 19 Aug 2021 13:49:50 -0700 Message-Id: <20210819204950.12150-9-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210819204950.12150-1-greearb@candelatech.com> References: <20210819204950.12150-1-greearb@candelatech.com> MIME-Version: 1.0 X-MDID: 1629406206-pzfPfx-yFnet 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 f5332e2c5e4e..10f4001d8d92 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -206,7 +206,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; @@ -215,7 +216,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();