diff mbox series

[01/12] wifi: mt76: mt7915: cache sgi in wcid.

Message ID 20220727230122.29842-1-greearb@candelatech.com
State New
Headers show
Series [01/12] wifi: mt76: mt7915: cache sgi in wcid. | expand

Commit Message

Ben Greear July 27, 2022, 11:01 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

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 <greearb@candelatech.com>
---

These patches have mostly been posted before.  They are now rebased on
top of latest 5.19 upstream kernel.  Checkpatch has been run on them,
some patches have been merged, a few dropped per previous requests.
Lightly tested on 5.19, similar code was well tested on 5.17.

 drivers/net/wireless/mediatek/mt76/mt76.h       |  5 +++++
 drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 15 +++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

Comments

Ryder Lee July 28, 2022, 3:20 a.m. UTC | #1
On Wed, 2022-07-27 at 16:01 -0700, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> 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 <greearb@candelatech.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mac80211.c |  4 +
>  drivers/net/wireless/mediatek/mt76/mt76.h     |  5 +
>  .../net/wireless/mediatek/mt76/mt7915/init.c  |  1 +
>  .../net/wireless/mediatek/mt76/mt7915/mac.c   | 95
> ++++++++++++++++++-
>  .../net/wireless/mediatek/mt76/mt7915/mac.h   |  6 +-
>  .../net/wireless/mediatek/mt76/mt7915/main.c  |  4 +
>  .../net/wireless/mediatek/mt76/mt7921/main.c  |  4 +
>  drivers/net/wireless/mediatek/mt76/tx.c       | 18 +++-
>  8 files changed, 129 insertions(+), 8 deletions(-)

Hi Ben,

Looks like we have a similar goal but I don't use txs_for_no_skb. 

What about directly switching to PPDU bases reporting (it should
include MPDUs total/failed/retries counts/bytes) and using
.sta_statistics? I think this might simplify the codes and can use
mac80211 ethtool as is.

I made these changes for .net_fill_forward_path (WED) cases. We're
doing some throughput tests.
https://pastebin.com/raw/qCzNNDzw
https://pastebin.com/raw/25Vsk2xs


Ryder
Ben Greear July 28, 2022, 4:11 a.m. UTC | #2
On 7/27/22 8:20 PM, Ryder Lee wrote:
> On Wed, 2022-07-27 at 16:01 -0700, greearb@candelatech.com wrote:
>> From: Ben Greear <greearb@candelatech.com>
>>
>> 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 <greearb@candelatech.com>
>> ---
>>   drivers/net/wireless/mediatek/mt76/mac80211.c |  4 +
>>   drivers/net/wireless/mediatek/mt76/mt76.h     |  5 +
>>   .../net/wireless/mediatek/mt76/mt7915/init.c  |  1 +
>>   .../net/wireless/mediatek/mt76/mt7915/mac.c   | 95
>> ++++++++++++++++++-
>>   .../net/wireless/mediatek/mt76/mt7915/mac.h   |  6 +-
>>   .../net/wireless/mediatek/mt76/mt7915/main.c  |  4 +
>>   .../net/wireless/mediatek/mt76/mt7921/main.c  |  4 +
>>   drivers/net/wireless/mediatek/mt76/tx.c       | 18 +++-
>>   8 files changed, 129 insertions(+), 8 deletions(-)
> 
> Hi Ben,
> 
> Looks like we have a similar goal but I don't use txs_for_no_skb.
> 
> What about directly switching to PPDU bases reporting (it should
> include MPDUs total/failed/retries counts/bytes) and using
> .sta_statistics? I think this might simplify the codes and can use
> mac80211 ethtool as is.

I like per-packet tx-status because then I can do histograms up in mac80211
(and the driver) to show distributions of nss, mcs, encoding types, etc.

I have not actually coded against the histograms I put in mac80211, but instead I'm using ethtool
to get the histograms directly out of mt76 driver.

At least for 7915, I think you have to enable txs-for-no-skb logic to get
details on mcs, nss and similar rate info?

Thanks,
Ben

> 
> I made these changes for .net_fill_forward_path (WED) cases. We're
> doing some throughput tests.
> https://pastebin.com/raw/qCzNNDzw
> https://pastebin.com/raw/25Vsk2xs
> 
> 
> Ryder
> 
>
Ryder Lee July 28, 2022, 4:22 a.m. UTC | #3
On Wed, 2022-07-27 at 21:11 -0700, Ben Greear wrote:
> On 7/27/22 8:20 PM, Ryder Lee wrote:
> > On Wed, 2022-07-27 at 16:01 -0700, greearb@candelatech.com wrote:
> > > From: Ben Greear <greearb@candelatech.com>
> > > 
> > > 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 <greearb@candelatech.com>
> > > ---
> > >   drivers/net/wireless/mediatek/mt76/mac80211.c |  4 +
> > >   drivers/net/wireless/mediatek/mt76/mt76.h     |  5 +
> > >   .../net/wireless/mediatek/mt76/mt7915/init.c  |  1 +
> > >   .../net/wireless/mediatek/mt76/mt7915/mac.c   | 95
> > > ++++++++++++++++++-
> > >   .../net/wireless/mediatek/mt76/mt7915/mac.h   |  6 +-
> > >   .../net/wireless/mediatek/mt76/mt7915/main.c  |  4 +
> > >   .../net/wireless/mediatek/mt76/mt7921/main.c  |  4 +
> > >   drivers/net/wireless/mediatek/mt76/tx.c       | 18 +++-
> > >   8 files changed, 129 insertions(+), 8 deletions(-)
> > 
> > Hi Ben,
> > 
> > Looks like we have a similar goal but I don't use txs_for_no_skb.
> > 
> > What about directly switching to PPDU bases reporting (it should
> > include MPDUs total/failed/retries counts/bytes) and using
> > .sta_statistics? I think this might simplify the codes and can use
> > mac80211 ethtool as is.
> 
> I like per-packet tx-status because then I can do histograms up in
> mac80211
> (and the driver) to show distributions of nss, mcs, encoding types,
> etc.
> 
> I have not actually coded against the histograms I put in mac80211,
> but instead I'm using ethtool
> to get the histograms directly out of mt76 driver.
> 
> At least for 7915, I think you have to enable txs-for-no-skb logic to
> get
> details on mcs, nss and similar rate info?
> 
> Thanks,
> Ben
> 

Per PPDU txs provides mcs, nss and rate info as well, then we can use
.sta_statistics to report all sinfo we need. This is the way we use
for .net_fill_forward_path (WED) since it bypasses entire mac80211 data
path. We can also use iw station dump or ethtool to get histograms.

Ryder
> > 
> > I made these changes for .net_fill_forward_path (WED) cases. We're
> > doing some throughput tests.
> > 
https://urldefense.com/v3/__https://pastebin.com/raw/qCzNNDzw__;!!CTRNKA9wMg0ARbw!2EM8sO1SfUIboAp28ohdNT0OLwvCmyr-EuYoE-W1-IGsWn2RN8LI5LFNRjLBk3JM$
> >  
> > 
https://urldefense.com/v3/__https://pastebin.com/raw/25Vsk2xs__;!!CTRNKA9wMg0ARbw!2EM8sO1SfUIboAp28ohdNT0OLwvCmyr-EuYoE-W1-IGsWn2RN8LI5LFNRrLTxq5e$
> >  
> > 
> > 
> > Ryder
> > 
> > 
> 
>
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 4e8997c45c1b..f994d1e18ac6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -272,7 +272,12 @@  struct mt76_wcid {
 	struct ewma_signal rssi;
 	int inactive_count;
 
+	/* cached rate, updated from mac_sta_poll() and from TXS callback logic,
+	 * in 7915 at least.
+	 */
 	struct rate_info rate;
+	bool rate_short_gi; /* cached HT/VHT short_gi, from mac_sta_poll() */
+	u8 rate_he_gi; /* cached HE GI, from mac_sta_poll() */
 
 	u16 idx;
 	u8 hw_key_idx;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index 46fc07877b7d..62a2dc47938e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -206,12 +206,16 @@  static void mt7915_mac_sta_poll(struct mt7915_dev *dev)
 			u8 offs = 24 + 2 * bw;
 
 			rate->he_gi = (val & (0x3 << offs)) >> offs;
+			msta->wcid.rate_he_gi = rate->he_gi; /* cache for later */
 		} else if (rate->flags &
 			   (RATE_INFO_FLAGS_VHT_MCS | RATE_INFO_FLAGS_MCS)) {
-			if (val & BIT(12 + bw))
+			if (val & BIT(12 + bw)) {
 				rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
-			else
+				msta->wcid.rate_short_gi = 1;
+			} else {
 				rate->flags &= ~RATE_INFO_FLAGS_SHORT_GI;
+				msta->wcid.rate_short_gi = 0;
+			}
 		}
 	}
 
@@ -1667,7 +1671,7 @@  mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,
 			goto out;
 
 		rate.flags = RATE_INFO_FLAGS_MCS;
-		if (wcid->rate.flags & RATE_INFO_FLAGS_SHORT_GI)
+		if (wcid->rate_short_gi)
 			rate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 		break;
 	case MT_PHY_TYPE_VHT:
@@ -1675,6 +1679,8 @@  mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,
 			goto out;
 
 		rate.flags = RATE_INFO_FLAGS_VHT_MCS;
+		if (wcid->rate_short_gi)
+			rate.flags |= RATE_INFO_FLAGS_SHORT_GI;
 		break;
 	case MT_PHY_TYPE_HE_SU:
 	case MT_PHY_TYPE_HE_EXT_SU:
@@ -1683,11 +1689,12 @@  mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,
 		if (rate.mcs > 11)
 			goto out;
 
-		rate.he_gi = wcid->rate.he_gi;
+		rate.he_gi = wcid->rate_he_gi;
 		rate.he_dcm = FIELD_GET(MT_TX_RATE_DCM, txrate);
 		rate.flags = RATE_INFO_FLAGS_HE_MCS;
 		break;
 	default:
+		WARN_ON_ONCE(true);
 		goto out;
 	}