Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp99216pxt; Wed, 4 Aug 2021 06:51:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9J9hmotxWXxko9PhVVZ/NMINbI+yddy+J/UbTcDMpj+pe+IzxqKO4OKQDLEg7ttE/K8oV X-Received: by 2002:a17:907:3e1c:: with SMTP id hp28mr25526026ejc.109.1628085081012; Wed, 04 Aug 2021 06:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628085081; cv=none; d=google.com; s=arc-20160816; b=gdZ0TN+MZAd+9nwDOFwnBsTaPH2erRKFc46haOMfCjW8FJKTg9tkYN++578ut+iwJY poOHxgVOfMAeFVEbMJDgiULbmHvaevS3JWuCfwAB1XJ7VnXYirH+3SZquq3mb1zNQSvx AsEm+ymgD3+ZNPpqQIZZmOdEa7R89p1Q9L4tN1NyiHMdwHeMNbHu6W6rq41hNTowO8Ew JEZGGdUZK3zwNUUDJSXqg02z4JXPYMs219GUYKU0mwCilXcOXJOA7jHg0QIswgSq0imV y7ZduaXt8SFX7J6RlScwggnzAc5q/hH4kEyCdRAnQyLKwmGLzyftjEaTlt2PVOlZp5Qj Yb5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=czVCYoKPZjPIwqmunnOd8FyJNbHAL6qmQaXX1Y60tgc=; b=hn2d2gEhtC8efshm9HTX4yRt+uN22b9b2xpDaiyfXOaMgHSLsNo4VAFfZ08pkMxosl wOi/pvBuPnKLJ757KEp47bEBtU4DpQexyW8pv27CXgzDAgw0uNWhGg9wZoCLtUpdvnP7 0NeczgTLq8Td9ixmphrQDeTbTrtv0eh38CnU4UVx3FMNHxHY22KTnc0ewN9gqmXGUvwD /3rZwpEC8cjZNwmpbdnrw74LR1niAwxm0qfCaL8/rLLFWVs0BZ0Cz6fnycgT+o+/MGrC +9NHXIFNpitLzoheSVHM8dpoEnlZ7xDUDkFmXgjL8OuRGaklH3itHH6Kwv9QatOF519A Xa1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@candelatech.com header.s=default header.b=J4BS75di; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=candelatech.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd12si2298121ejc.121.2021.08.04.06.50.58; Wed, 04 Aug 2021 06:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@candelatech.com header.s=default header.b=J4BS75di; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=candelatech.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238502AbhHDNpb (ORCPT + 99 others); Wed, 4 Aug 2021 09:45:31 -0400 Received: from dispatch1-us1.ppe-hosted.com ([148.163.129.48]:48216 "EHLO dispatch1-us1.ppe-hosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238008AbhHDNp2 (ORCPT ); Wed, 4 Aug 2021 09:45:28 -0400 X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.203]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id DC4652007B for ; Wed, 4 Aug 2021 13:45:14 +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 B34F9AC008C for ; Wed, 4 Aug 2021 13:45:14 +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 18BDA13C2B4; Wed, 4 Aug 2021 06:45:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 mail3.candelatech.com 18BDA13C2B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=candelatech.com; s=default; t=1628084713; bh=vljNj+2o3HDqsS5KIKsqi/nHd4THGk272qVSwU1IoCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4BS75dilWMzqJvD7Herlo2z6sPsE6kfkCwLapdKfB+Zqw5HI+f/oRDln90hFVEBu CJP4w20zyKK7/Q9RJ7lC3JC1u/JYmq4SOmITz71odTMD1z5P0IItcihxmd4+uvFLos DZMeAZI33/NEK9bjHeQhVAlUkiu1GGLWhvnIQq68= From: greearb@candelatech.com To: linux-wireless@vger.kernel.org Cc: Ben Greear Subject: [PATCH v5 03/11] mt76: mt7915: move TXS parsing to its own method Date: Wed, 4 Aug 2021 06:44:57 -0700 Message-Id: <20210804134505.3208-3-greearb@candelatech.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210804134505.3208-1-greearb@candelatech.com> References: <20210804134505.3208-1-greearb@candelatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MDID: 1628084715-4HV7EsBmCjlU 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 | 122 ++++++++++-------- 2 files changed, 74 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 016f563fec39..0cbb4940f590 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -252,7 +252,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_PACKET_ID_MAX + 1]; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index b568d6baa768..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,30 +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); - - /* TODO: Gather stats anyway, even if we are not matching on an skb. */ - 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; @@ -1337,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) { @@ -1365,73 +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; } +} - /* Cache rate for packets that don't get a TXS callback for some - * reason. +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. */ - wcid->rate = rate; + 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) -- 2.20.1