wifi: mt76: mt7915: cache sgi in wcid.
Subsystems (2)
PATCH 1/12 wifi: mt76: mt7915: cache sgi in wcid.
From: Ben Greear <[email protected]>
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.
---
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(-)
drivers/net/wireless/mediatek/mt76/mt76.h +5 -0
@@ -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;
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +11 -4
@@ -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; }
Signature · 1 line
2.20.1
PATCH 2/12 wifi: mt76: mt7915: allow processing TXS for 'NO_SKB' pkt-ids
From: Ben Greear <[email protected]>
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.
--- .../net/wireless/mediatek/mt76/mt7915/mac.c | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +22 -16
@@ -1614,26 +1614,31 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid,struct ieee80211_tx_info *info;struct sk_buff_head list;struct rate_info rate = {}; -struct sk_buff *skb; +struct sk_buff *skb =NULL ; +bool check_status;bool cck = false;u32 txrate, txs, mode; -mt76_tx_status_lock (mdev, &list); - skb =mt76_tx_status_skb_get (mdev, wcid, pid, &list); -if (!skb) - goto out_no_skb; + check_status = (pid >=MT_PACKET_ID_FIRST ); + +if (check_status) { +mt76_tx_status_lock (mdev, &list); + skb =mt76_tx_status_skb_get (mdev, wcid, pid, &list); + } txs =le32_to_cpu (txs_data[0 ]); - info =IEEE80211_SKB_CB (skb); -if (!(txs &MT_TXS0_ACK_ERROR_MASK )) - info->flags |=IEEE80211_TX_STAT_ACK ; +if (skb) { + info =IEEE80211_SKB_CB (skb); +if (!(txs &MT_TXS0_ACK_ERROR_MASK )) + info->flags |=IEEE80211_TX_STAT_ACK ; - info->status.ampdu_len =1 ; - info->status.ampdu_ack_len = !!(info->flags & -IEEE80211_TX_STAT_ACK ); + info->status.ampdu_len =1 ; + info->status.ampdu_ack_len = !!(info->flags & +IEEE80211_TX_STAT_ACK ); - info->status.rates[0 ].idx =-1 ; + info->status.rates[0 ].idx =-1 ; + } txrate =FIELD_GET (MT_TXS0_TX_RATE , txs);
@@ -1721,10 +1726,11 @@ mt7915_mac_add_txs_skb(struct mt7915_dev *dev, struct mt76_wcid *wcid, int pid, wcid->rate = rate; out: -mt76_tx_status_skb_done (mdev, skb, &list); +if (skb) +mt76_tx_status_skb_done (mdev, skb, &list); -out_no_skb: -mt76_tx_status_unlock (mdev, &list); +if (check_status) +mt76_tx_status_unlock (mdev, &list);return !!skb; }
@@ -1743,7 +1749,7 @@ static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data) wcidx =le32_get_bits (txs_data[2 ],MT_TXS2_WCID ); pid =le32_get_bits (txs_data[3 ],MT_TXS3_PID ); -if (pid <MT_PACKET_ID_FIRST ) +if (pid <MT_PACKET_ID_NO_SKB )return ;if (wcidx >=mt7915_wtbl_size (dev))
Signature · 1 line
2.20.1
PATCH 3/12 wifi: mt76: mt7915: debugfs hook to enable TXS for NO_SKB pkt-ids
In reply to [email protected]From: Ben Greear <[email protected]>
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.
--- .../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(-)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +24 -0
@@ -633,6 +633,29 @@ mt7915_fw_util_wa_show(struct seq_file *file, void *data)DEFINE_SHOW_ATTRIBUTE (mt7915_fw_util_wa); +static int +mt7915_txs_for_no_skb_set (void *data,u64 val) +{ +struct mt7915_dev *dev = data; + + dev->txs_for_no_skb_enabled = !!val; + +return 0 ; +} + +static int +mt7915_txs_for_no_skb_get (void *data,u64 *val) +{ +struct mt7915_dev *dev = data; + + *val = dev->txs_for_no_skb_enabled; + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_txs_for_no_skb, mt7915_txs_for_no_skb_get, + mt7915_txs_for_no_skb_set,"%lld\n" ); +static void mt7915_ampdu_stat_read_phy (struct mt7915_phy *phy,struct seq_file *file)
@@ -1017,6 +1040,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) &mt7915_fw_util_wm_fops);debugfs_create_file ("fw_util_wa" ,0400 , dir, dev, &mt7915_fw_util_wa_fops); +debugfs_create_file ("force_txs" ,0600 , dir, dev, &fops_txs_for_no_skb);debugfs_create_file ("implicit_txbf" ,0600 , dir, dev, &fops_implicit_txbf); debugfs_create_file("txpower_sku", 0400, dir, phy,
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +2 -1
@@ -1257,7 +1257,8 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, txwi[4 ] =0 ; val =FIELD_PREP (MT_TXD5_PID , pid); -if (pid >=MT_PACKET_ID_FIRST ) +if (pid >=MT_PACKET_ID_FIRST || + (pid ==MT_PACKET_ID_NO_SKB && dev->txs_for_no_skb_enabled)) val |=MT_TXD5_TX_STATUS_HOST ; txwi[5 ] =cpu_to_le32 (val);
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +5 -0
@@ -294,6 +294,11 @@ struct mt7915_dev {u16 chainmask;u16 chainshift;u32 hif_idx; +/* Should we request TXS for MT_PACKET_ID_NO_SKB? Doing so gives better +* costs but causes a great deal more TXS packet processing by driver and +* creation by firmware, so may be a performance drag. +*/ +bool txs_for_no_skb_enabled;struct work_struct init_work;struct work_struct rc_work;
Signature · 1 line
2.20.1
PATCH 4/12 wifi: mt76: mt7915: txfree status to show txcount instead of latency
In reply to [email protected]From: Ben Greear <[email protected]>
Latency is not obviously that useful, but txcount can let us deduce retries, which may be more interesting.
--- drivers/net/wireless/mediatek/mt76/mt7915/init.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt7915/mac.h | 6 +++++- drivers/net/wireless/mediatek/mt76/mt7915/regs.h | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +3 -0
@@ -460,6 +460,9 @@ static void mt7915_mac_init(struct mt7915_dev *dev)/* enable hardware de-agg */ mt76_set (dev,MT_MDP_DCR0 ,MT_MDP_DCR0_DAMSDU_EN ); +/* disable Tx latency report to enable Tx count in txfree path */ +mt76_clear (dev,MT_PLE_HOST_RPT0 ,MT_PLE_HOST_RPT0_TX_LATENCY ); +for (i =0 ; i <mt7915_wtbl_size (dev); i++)mt7915_mac_wtbl_update (dev, i,MT_WTBL_UPDATE_ADM_COUNT_CLEAR );
drivers/net/wireless/mediatek/mt76/mt7915/mac.h +5 -1
@@ -314,8 +314,12 @@ struct mt7915_tx_free {#define MT_TX_FREE_MSDU_CNT GENMASK(9, 0)#define MT_TX_FREE_MSDU_CNT_V0 GENMASK(6, 0)#define MT_TX_FREE_WLAN_ID GENMASK(23, 14) +/* when configured for txfree latency mode. See MT_PLE_HOST_RPT0_TX_LATENCY +* Not enabled by default now. +*/ #define MT_TX_FREE_LATENCY GENMASK(12, 0) -/* 0: success, others: dropped */ +/* when configured for txcount mode. See MT_PLE_HOST_RPT0_TX_LATENCY. */ +#define MT_TX_FREE_TXCNT GENMASK(12, 0)#define MT_TX_FREE_MSDU_ID GENMASK(30, 16)#define MT_TX_FREE_PAIR BIT(31)#define MT_TX_FREE_MPDU_HEADER BIT(30)
drivers/net/wireless/mediatek/mt76/mt7915/regs.h +4 -0
@@ -132,6 +132,10 @@ enum offs_rev {#define MT_PLE_BASE 0x820c0000#define MT_PLE (ofs) (MT_PLE_BASE + (ofs)) +/* Modify whether txfree struct returns latency or txcount. */ +#define MT_PLE_HOST_RPT0 MT_PLE(0x030) +#define MT_PLE_HOST_RPT0_TX_LATENCY BIT(3) +#define MT_FL_Q_EMPTY MT_PLE(__OFFS(PLE_FL_Q_EMPTY))#define MT_FL_Q0_CTRL MT_PLE(__OFFS(PLE_FL_Q_CTRL))#define MT_FL_Q2_CTRL MT_PLE(__OFFS(PLE_FL_Q_CTRL) + 0x8)
Signature · 1 line
2.20.1
PATCH 5/12 wifi: mt76: mt7915: report tx-retries
In reply to [email protected]From: Ben Greear <[email protected]>
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.
--- 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(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +4 -0
@@ -1628,6 +1628,10 @@ void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi, wi->sta_count++; + data[ei++] += stats->tx_mpdu_attempts; + data[ei++] += stats->tx_mpdu_fail; + data[ei++] += stats->tx_mpdu_retry; + data[ei++] += stats->tx_mpdu_ok; data[ei++] += stats->tx_mode[MT_PHY_TYPE_CCK ]; data[ei++] += stats->tx_mode[MT_PHY_TYPE_OFDM ]; data[ei++] += stats->tx_mode[MT_PHY_TYPE_HT ];
drivers/net/wireless/mediatek/mt76/mt76.h +5 -0
@@ -826,6 +826,11 @@ enum mt76_phy_type { };struct mt76_sta_stats { +unsigned long tx_mpdu_attempts;/* counting any retries */ +unsigned long tx_mpdu_fail;/* frames that failed even after retry */ +/* frames that succeeded, perhaps after retry */ +unsigned long tx_mpdu_ok; +unsigned long tx_mpdu_retry;/* number of times frames were retried */ u64 tx_mode[__MT_PHY_TYPE_HE_MAX];u64 tx_bw[4 ];/* 20, 40, 80, 160 */ u64 tx_nss[4 ];/* 1, 2, 3, 4 */
drivers/net/wireless/mediatek/mt76/mt7915/init.c +1 -0
@@ -329,6 +329,7 @@ mt7915_init_wiphy(struct ieee80211_hw *hw)struct mt7915_dev *dev = phy->dev; hw->queues =4 ; + hw->max_report_rates =1 ; hw->max_rx_aggregation_subframes =IEEE80211_MAX_AMPDU_BUF_HE ; hw->max_tx_aggregation_subframes =IEEE80211_MAX_AMPDU_BUF_HE ; hw->netdev_features =NETIF_F_RXCSUM ;
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +91 -4
150 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mac.h +5 -1
@@ -307,7 +307,7 @@ struct mt7915_tx_free {__le16 rx_byte_cnt;__le16 ctrl;__le32 txd; -__le32 info[]; +__le32 info[];/* DW3+ */ } __packed__aligned(4) ;#define MT_TX_FREE_VER GENMASK(18, 16)
@@ -320,6 +320,10 @@ struct mt7915_tx_free {#define MT_TX_FREE_LATENCY GENMASK(12, 0)/* when configured for txcount mode. See MT_PLE_HOST_RPT0_TX_LATENCY. */ #define MT_TX_FREE_TXCNT GENMASK(12, 0) +/* 0: success, others: dropped */ +#define MT_TX_FREE_STATUS_V1 GENMASK(14, 13) +/* 0: not MPDU, 1: MSDU is head pkt of TXD page (MPDU) */ +#define MT_TX_FREE_HEAD_OF_PAGE BIT(15)#define MT_TX_FREE_MSDU_ID GENMASK(30, 16)#define MT_TX_FREE_PAIR BIT(31)#define MT_TX_FREE_MPDU_HEADER BIT(30)
drivers/net/wireless/mediatek/mt76/mt7915/main.c +4 -0
@@ -1158,6 +1158,10 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = {"rx_ba_cnt" ,/* per vif counters */ +"v_tx_mpdu_attempts" ,/* counting any retries */ +"v_tx_mpdu_fail" ,/* frames that failed even after retry */ +"v_tx_mpdu_retry" ,/* number of times frames were retried */ +"v_tx_mpdu_ok" ,/* frames that succeeded, perhaps after retry */ "v_tx_mode_cck" ,"v_tx_mode_ofdm" , "v_tx_mode_ht",
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -0
@@ -987,6 +987,10 @@ static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = {"rx_ampdu_bytes_cnt" ,"rx_ba_cnt" ,/* per vif counters */ +"v_tx_mpdu_attempts" ,/* counting any retries */ +"v_tx_mpdu_fail" ,/* frames that failed even after retry */ +"v_tx_mpdu_retry" ,/* number of times frames were retried */ +"v_tx_mpdu_ok" ,/* frames that succeeded, perhaps after retry */ "v_tx_mode_cck" ,"v_tx_mode_ofdm" , "v_tx_mode_ht",
drivers/net/wireless/mediatek/mt76/tx.c +15 -3
@@ -62,12 +62,15 @@ mt76_tx_status_unlock(struct mt76_dev *dev, struct sk_buff_head *list) };struct mt76_tx_cb *cb =mt76_tx_skb_cb (skb);struct mt76_wcid *wcid; +struct ieee80211_rate_status status_rate = {0 }; wcid =rcu_dereference (dev->wcid[cb->wcid]);if (wcid) { status.sta =wcid_to_sta (wcid); - status.rates =NULL ; - status.n_rates =0 ; + status.rates = &status_rate; + status.n_rates =1 ; + status_rate.rate_idx = wcid->rate; + status_rate.try_count =1 ; } hw =mt76_tx_status_get_hw (dev, skb);
@@ -228,15 +231,24 @@ void __mt76_tx_complete_skb(struct mt76_dev *dev, u16 wcid_idx, struct sk_buff *struct ieee80211_tx_status status = { .skb = skb, .free_list = free_list, + .info =IEEE80211_SKB_CB (skb), };struct mt76_wcid *wcid =NULL ;struct ieee80211_hw *hw;struct sk_buff_head list; +struct ieee80211_rate_status status_rate = {0 };rcu_read_lock (); -if (wcid_idx <ARRAY_SIZE (dev->wcid)) +if (wcid_idx <ARRAY_SIZE (dev->wcid)) { wcid =rcu_dereference (dev->wcid[wcid_idx]); +if (wcid) { + status.rates = &status_rate; + status.n_rates =1 ; + status_rate.rate_idx = wcid->rate; + status_rate.try_count =1 ; + } + }mt76_tx_check_non_aql (dev, wcid, skb);
Signature · 1 line
2.20.1
Ryder Lee
maintainerRe: [PATCH 05/12] wifi: mt76: mt7915: report tx-retries
Quoted 17 lines · On Wed, 2022-07-27 at 16:01 -0700, [email protected] wrote:
From: Ben Greear <[email protected]>
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_extto take both info andstatus->rateinto account.Signed-off-by Ben Greear <[email protected]>
Quoted 11 lines
--- 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
Re: [PATCH 05/12] wifi: mt76: mt7915: report tx-retries
Quoted 30 lines · Ryder Lee
Quoted 17 lines · On Wed, 2022-07-27 at 16:01 -0700, [email protected] wrote:
From: Ben Greear <[email protected]>
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_extto take both info andstatus->rateinto account.Signed-off-by Ben Greear <[email protected]>Quoted 11 lines
--- 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(-)
Quoted 8 lines
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
Quoted 10 lines
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/25Vsk2xsRyder
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Ryder Lee
maintainerRe: [PATCH 05/12] wifi: mt76: mt7915: report tx-retries
Quoted 51 lines · Ben Greear
Quoted 32 lines · Ryder Lee
Quoted 19 lines · On Wed, 2022-07-27 at 16:01 -0700, [email protected] wrote:
From: Ben Greear <[email protected]>
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 theieee80211_tx_status_extto take both info andstatus->rateinto account.Signed-off-by Ben Greear <[email protected]>Quoted 11 lines
--- 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(-)Quoted 8 lines
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.
Quoted 7 lines
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
Quoted 4 lines
Quoted 4 lines
I made these changes for .net_fill_forward_path (WED) cases. We're doing some throughput tests.
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 6 lines
Ryder
PATCH 6/12 wifi: mt76: mt7915: add support for tx-overrides
In reply to [email protected]From: Ben Greear <[email protected]>
Allow setting fixied rate on transmit without using full testmode logic.
The goal of tx-overrides is to allow receiver sensitivity and other types of testing. Assumption is that the packets we care about are larger data frames, so exclude smaller packets and non data packets.
Setting transmit count to '0' means transmit once, but flag the packet as no-ack.
Allows adjusting the tx power from default value, from -8 to +8 dbm. Adjusting above 0 is probably not a good idea.
The station wtbl logic to read rate-ctrl settings does not work when fixed rates are used. So, read sgi settings from the txo configuration in this case.
--- drivers/net/wireless/mediatek/mt76/mt76.h | 4 + .../wireless/mediatek/mt76/mt7915/debugfs.c | 225 ++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 149 +++++++++--- .../wireless/mediatek/mt76/mt7915/mt7915.h | 2 + 4 files changed, 350 insertions(+), 30 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +4 -0
@@ -611,6 +611,7 @@ struct mt76_testmode_ops {struct mt76_testmode_data {enum mt76_testmode_state state; +u8 txo_active;/* tx overrides are active */ u32 param_set[DIV_ROUND_UP (NUM_MT76_TM_ATTRS ,32 )];struct sk_buff *tx_skb;
@@ -625,6 +626,9 @@ struct mt76_testmode_data {u8 tx_rate_ldpc;u8 tx_rate_stbc;u8 tx_ltf; +u8 txbw;/* specify TX bandwidth: 0 20Mhz, 1 40Mhz, 2 80Mhz, 3 160Mhz */ +u8 tx_xmit_count;/* 0 means no-ack, 1 means one transmit, etc */ +u8 tx_dynbw;/* 0: dynamic bw disabled, 1: dynamic bw enabled */ u8 tx_antenna_mask;u8 tx_spe_idx;
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +225 -0
237 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +119 -30
232 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +2 -0
@@ -132,6 +132,8 @@ struct mt7915_sta {struct mt76_connac_sta_key_conf bip; +struct mt76_testmode_data test; +struct {u8 flowid_mask;struct mt7915_twt_flow flow[MT7915_MAX_STA_TWT_AGRT ];
Signature · 1 line
2.20.1
PATCH 7/12 wifi: mt76: mt7915: support enabling rx group-5 status
In reply to [email protected]From: Ben Greear <[email protected]>
When enabled, this allows per-skb rx rate reporting. Enabling this may degrade RX performance, so it remains disabled by default.
--- .../wireless/mediatek/mt76/mt7915/debugfs.c | 33 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/init.c | 3 +- .../net/wireless/mediatek/mt76/mt7915/main.c | 2 +- .../wireless/mediatek/mt76/mt7915/mt7915.h | 4 +++ 4 files changed, 40 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +33 -0
@@ -879,6 +879,38 @@ mt7915_txs_for_no_skb_get(void *data, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (fops_txs_for_no_skb, mt7915_txs_for_no_skb_get, mt7915_txs_for_no_skb_set,"%lld\n" ); +static int +mt7915_rx_group_5_enable_set (void *data,u64 val) +{ +struct mt7915_dev *dev = data; + +mutex_lock (&dev->mt76.mutex); + + dev->rx_group_5_enable = !!val; + +/* Enabled if we requested enabled OR if monitor mode is enabled. */ +mt76_rmw_field (dev,MT_DMA_DCR0 (0 ),MT_DMA_DCR0_RXD_G5_EN , + dev->rx_group_5_enable); +mt76_testmode_reset (dev->phy.mt76, true); + +mutex_unlock (&dev->mt76.mutex); + +return 0 ; +} + +static int +mt7915_rx_group_5_enable_get (void *data,u64 *val) +{ +struct mt7915_dev *dev = data; + + *val = dev->rx_group_5_enable; + +return 0 ; +} + +DEFINE_DEBUGFS_ATTRIBUTE (fops_rx_group_5_enable, mt7915_rx_group_5_enable_get, + mt7915_rx_group_5_enable_set,"%lld\n" ); +static void mt7915_ampdu_stat_read_phy (struct mt7915_phy *phy,struct seq_file *file)
@@ -1264,6 +1296,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)debugfs_create_file ("fw_util_wa" ,0400 , dir, dev, &mt7915_fw_util_wa_fops);debugfs_create_file ("force_txs" ,0600 , dir, dev, &fops_txs_for_no_skb); +debugfs_create_file ("rx_group_5_enable" ,0600 , dir, dev, &fops_rx_group_5_enable);debugfs_create_file ("implicit_txbf" ,0600 , dir, dev, &fops_implicit_txbf); debugfs_create_file("txpower_sku", 0400, dir, phy,
drivers/net/wireless/mediatek/mt76/mt7915/init.c +2 -1
@@ -440,7 +440,8 @@ mt7915_mac_init_band(struct mt7915_dev *dev, u8 band)mt76_rmw_field (dev,MT_DMA_DCR0 (band),MT_DMA_DCR0_MAX_RX_LEN ,0x680 );/* mt7915: disable rx rate report by default due to hw issues */ -mt76_clear (dev,MT_DMA_DCR0 (band),MT_DMA_DCR0_RXD_G5_EN ); +mt76_rmw_field (dev,MT_DMA_DCR0 (band),MT_DMA_DCR0_RXD_G5_EN , + dev->rx_group_5_enable); }static void mt7915_mac_init (struct mt7915_dev *dev)
drivers/net/wireless/mediatek/mt76/mt7915/main.c +1 -1
@@ -467,7 +467,7 @@ static int mt7915_config(struct ieee80211_hw *hw, u32 changed) phy->rxfilter &= ~MT_WF_RFCR_DROP_OTHER_UC ;mt76_rmw_field (dev,MT_DMA_DCR0 (band),MT_DMA_DCR0_RXD_G5_EN , - enabled); + dev->rx_group_5_enable);mt76_testmode_reset (phy->mt76, true);mt76_wr (dev,MT_WF_RFCR (band), phy->rxfilter); }
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +4 -0
@@ -301,6 +301,10 @@ struct mt7915_dev {* creation by firmware, so may be a performance drag. */ bool txs_for_no_skb_enabled; +/* Should we enable group-5 rx descriptor logic? This may decrease RX +* throughput, but will give per skb rx rate information.. +*/ +bool rx_group_5_enable;struct work_struct init_work;struct work_struct rc_work;
Signature · 1 line
2.20.1
PATCH 8/12 wifi: mt76: mt7915: use nss for calculating rx-chains
In reply to [email protected]From: Ben Greear <[email protected]>
When group-5 is enabled, we can find the actuall NSS used. In that case, update the rx chains info so that the upper stack can give better idea of actual antenna usage.
In case of stbc, the hardware already double nss, but rssi is not reported properly (it is '17') for the secondary chains. So, decrease nss in the status msg so that mac80211 does not try to average the invalid RSSI.
--- .../net/wireless/mediatek/mt76/mt7915/mac.c | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +23 -7
@@ -487,10 +487,10 @@ static int mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, struct mt76_rx_status *status, struct ieee80211_supported_band *sband, - __le32 *rxv, u8 *mode) + __le32 *rxv, u8 *mode, u8 *nss) { u32 v0, v2; -u8 stbc, gi, bw, dcm, nss; +u8 stbc, gi, bw, dcm;int i, idx;bool cck = false;
@@ -498,7 +498,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, v2 =le32_to_cpu (rxv[2 ]); idx = i =FIELD_GET (MT_PRXV_TX_RATE , v0); - nss =FIELD_GET (MT_PRXV_NSTS , v0) +1 ; + *nss =FIELD_GET (MT_PRXV_NSTS , v0) +1 ;if (!is_mt7915 (&dev->mt76)) { stbc =FIELD_GET (MT_PRXV_HT_STBC , v0);
@@ -530,7 +530,6 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev,return -EINVAL ;break ;case MT_PHY_TYPE_VHT : - status->nss = nss; status->encoding =RX_ENC_VHT ;if (gi) status->enc_flags |=RX_ENC_FLAG_SHORT_GI ;
@@ -541,7 +540,6 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev,case MT_PHY_TYPE_HE_SU :case MT_PHY_TYPE_HE_EXT_SU :case MT_PHY_TYPE_HE_TB : - status->nss = nss; status->encoding =RX_ENC_HE ; i &=GENMASK (3 ,0 );
@@ -582,6 +580,17 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev,if (*mode <MT_PHY_TYPE_HE_SU && gi) status->enc_flags |=RX_ENC_FLAG_SHORT_GI ; +/* in case stbc is set, the nss value returned by hardware is already +* correct (ie, 2 instead of 1 for 1 spatial stream). But, at least in cases +* where we are configured for a single antenna, then the second chain RSSI is '17', +* which I take to mean 'not set'. To keep from adding this to the average rssi up in +* mac80211 rx logic, decrease nss here. +*/ +if (stbc) + *nss >>=1 ; + + status->nss = *nss; +return 0 ; }
@@ -755,6 +764,8 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)if (rxd1 &MT_RXD1_NORMAL_GROUP_3 ) {u32 v0, v1;int ret; +int i; +u8 nss; rxv = rxd;/* DW16 assuming group 1,2,3,4 */ rxd +=2 ;
@@ -771,11 +782,11 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)/* TODO: When group-5 is enabled, use nss (and stbc) to * calculate chains properly for this particular skb. */ - status->chains = mphy->antenna_mask; status->chain_signal[0 ] =to_rssi (MT_PRXV_RCPI0 , v1); status->chain_signal[1 ] =to_rssi (MT_PRXV_RCPI1 , v1); status->chain_signal[2 ] =to_rssi (MT_PRXV_RCPI2 , v1); status->chain_signal[3 ] =to_rssi (MT_PRXV_RCPI3 , v1); + nss =hweight8 (mphy->antenna_mask);/* RXD Group 5 - C-RXV */ if (rxd1 &MT_RXD1_NORMAL_GROUP_5 ) {
@@ -786,10 +797,15 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)if (!is_mt7915 (&dev->mt76) || (rxd1 &MT_RXD1_NORMAL_GROUP_5 )) { ret =mt7915_mac_fill_rx_rate (dev, status, sband, rxv, - &mode); + &mode, &nss);if (ret <0 )return ret; + }else { + status->nss = nss; } + +for (i =0 ; i < nss; i++) + status->chains |=BIT (i); } amsdu_info =FIELD_GET (MT_RXD4_NORMAL_PAYLOAD_FORMAT , rxd4);
Signature · 1 line
2.20.1
PATCH 9/12 wifi: mt76: mt7915: ethtool group-5 rx stats information
In reply to [email protected]From: Ben Greear <[email protected]>
Add ethtool support for rx-nss, rx-bw, rx-mode stats. These are only valid when the group-5 rx stats are enabled.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 23 ++++++++++++++- drivers/net/wireless/mediatek/mt76/mt76.h | 10 +++++++ .../net/wireless/mediatek/mt76/mt7915/mac.c | 29 +++++++++++++++++-- .../net/wireless/mediatek/mt76/mt7915/main.c | 21 ++++++++++++++ .../net/wireless/mediatek/mt76/mt7921/main.c | 21 ++++++++++++++ 5 files changed, 101 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +22 -1
@@ -1623,7 +1623,7 @@ EXPORT_SYMBOL_GPL(mt76_calculate_default_rate);void mt76_ethtool_worker (struct mt76_ethtool_worker_info *wi,struct mt76_sta_stats *stats) { -int i, ei = wi->initial_stat_idx; +int i, q, ei = wi->initial_stat_idx;u64 *data = wi->data; wi->sta_count++;
@@ -1648,6 +1648,27 @@ void mt76_ethtool_worker(struct mt76_ethtool_worker_info *wi,for (i =0 ; i <12 ; i++) data[ei++] += stats->tx_mcs[i]; +/* rx stats */ +for (q =0 ; q <ARRAY_SIZE (stats->rx_nss); q++) + data[ei++] += stats->rx_nss[q]; + + data[ei++] += stats->rx_mode[MT_PHY_TYPE_CCK ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_OFDM ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HT ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HT_GF ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_VHT ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_SU ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_EXT_SU ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_TB ]; + data[ei++] += stats->rx_mode[MT_PHY_TYPE_HE_MU ]; + + data[ei++] += stats->rx_bw_20; + data[ei++] += stats->rx_bw_40; + data[ei++] += stats->rx_bw_80; + data[ei++] += stats->rx_bw_160; + data[ei++] += stats->rx_bw_he_ru; + data[ei++] += stats->rx_ru_106; + wi->worker_stat_count = ei - wi->initial_stat_idx; }EXPORT_SYMBOL_GPL (mt76_ethtool_worker);
drivers/net/wireless/mediatek/mt76/mt76.h +10 -0
@@ -839,6 +839,16 @@ struct mt76_sta_stats {u64 tx_bw[4 ];/* 20, 40, 80, 160 */ u64 tx_nss[4 ];/* 1, 2, 3, 4 */ u64 tx_mcs[16 ];/* mcs idx */ + +/* This section requires group-5 in rxd to be enabled for 7915. */ +u32 rx_nss[4 ];/* rx-nss histogram */ +u32 rx_mode[__MT_PHY_TYPE_HE_MAX];/* rx mode histogram */ +u32 rx_bw_20; +u32 rx_bw_40; +u32 rx_bw_80; +u32 rx_bw_160; +u32 rx_bw_he_ru; +u32 rx_ru_106; };struct mt76_ethtool_worker_info {
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +27 -2
@@ -487,7 +487,8 @@ static int mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, struct mt76_rx_status *status, struct ieee80211_supported_band *sband, - __le32 *rxv, u8 *mode, u8 *nss) + __le32 *rxv, u8 *mode, u8 *nss, + struct mt76_sta_stats *stats) { u32 v0, v2;u8 stbc, gi, bw, dcm;
@@ -555,6 +556,8 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev,switch (bw) {case IEEE80211_STA_RX_BW_20 : +if (stats) + stats->rx_bw_20++;break ;case IEEE80211_STA_RX_BW_40 : if (*mode & MT_PHY_TYPE_HE_EXT_SU &&
@@ -562,15 +565,26 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->bw =RATE_INFO_BW_HE_RU ; status->he_ru =NL80211_RATE_INFO_HE_RU_ALLOC_106 ; +if (stats) { + stats->rx_bw_he_ru++; + stats->rx_ru_106++; + } }else { status->bw =RATE_INFO_BW_40 ; +if (stats) + stats->rx_bw_40++; }break ;case IEEE80211_STA_RX_BW_80 : status->bw =RATE_INFO_BW_80 ; +if (stats) + stats->rx_bw_80++; +break ;case IEEE80211_STA_RX_BW_160 : status->bw =RATE_INFO_BW_160 ; +if (stats) + stats->rx_bw_160++;break ;default :return -EINVAL ;
@@ -591,6 +605,15 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->nss = *nss; +if (stats) { +if (*nss >3 ) + stats->rx_nss[3 ]++; +else + stats->rx_nss[*nss -1 ]++; +if (*mode < __MT_PHY_TYPE_HE_MAX) + stats->rx_mode[*mode]++; + } +return 0 ; }
@@ -618,6 +641,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)u16 seq_ctrl =0 ;__le16 fc =0 ;int idx; +struct mt76_sta_stats *stats =NULL ;memset (status,0 ,sizeof (*status));
@@ -652,6 +676,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)struct mt7915_sta *msta; msta = container_of(status->wcid, struct mt7915_sta, wcid); + stats = &msta->stats;spin_lock_bh (&dev->sta_poll_lock);if (list_empty (&msta->poll_list))list_add_tail (&msta->poll_list, &dev->sta_poll_list);
@@ -797,7 +822,7 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)if (!is_mt7915 (&dev->mt76) || (rxd1 &MT_RXD1_NORMAL_GROUP_5 )) { ret =mt7915_mac_fill_rx_rate (dev, status, sband, rxv, - &mode, &nss); + &mode, &nss, stats);if (ret <0 )return ret; }else {
drivers/net/wireless/mediatek/mt76/mt7915/main.c +21 -0
@@ -1187,6 +1187,27 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = {"v_tx_mcs_9" ,"v_tx_mcs_10" ,"v_tx_mcs_11" , + +/* per-vif rx counters */ +"v_rx_nss1" , +"v_rx_nss2" , +"v_rx_nss3" , +"v_rx_nss4" , +"v_rx_mode_cck" , +"v_rx_mode_ofdm" , +"v_rx_mode_ht" , +"v_rx_mode_ht_gf" , +"v_rx_mode_vht" , +"v_rx_mode_he_su" , +"v_rx_mode_he_ext_su" , +"v_rx_mode_he_tb" , +"v_rx_mode_he_mu" , +"v_rx_bw_20" , +"v_rx_bw_40" , +"v_rx_bw_80" , +"v_rx_bw_160" , +"v_rx_bw_he_ru" , + "v_rx_ru_106", };#define MT7915_SSTATS_LEN ARRAY_SIZE(mt7915_gstrings_stats)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +21 -0
@@ -1016,6 +1016,27 @@ static const char mt7921_gstrings_stats[][ETH_GSTRING_LEN] = {"v_tx_mcs_9" ,"v_tx_mcs_10" ,"v_tx_mcs_11" , + +/* per-vif rx counters */ +"v_rx_nss1" , +"v_rx_nss2" , +"v_rx_nss3" , +"v_rx_nss4" , +"v_rx_mode_cck" , +"v_rx_mode_ofdm" , +"v_rx_mode_ht" , +"v_rx_mode_ht_gf" , +"v_rx_mode_vht" , +"v_rx_mode_he_su" , +"v_rx_mode_he_ext_su" , +"v_rx_mode_he_tb" , +"v_rx_mode_he_mu" , +"v_rx_bw_20" , +"v_rx_bw_40" , +"v_rx_bw_80" , +"v_rx_bw_160" , +"v_rx_bw_he_ru" , + "v_rx_ru_106", }; static void
Signature · 1 line
2.20.1
PATCH 10/12 wifi: mt76: mt7915: ethtool counters for driver rx path
In reply to [email protected]From: Ben Greear <[email protected]>
Add some per-phy counters for rx errors in the driver.
--- .../net/wireless/mediatek/mt76/mt7915/mac.c | 48 ++++++++++++++----- .../net/wireless/mediatek/mt76/mt7915/main.c | 22 +++++++++ .../wireless/mediatek/mt76/mt7915/mt7915.h | 11 +++++ 3 files changed, 70 insertions(+), 11 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +37 -11
@@ -488,6 +488,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev,struct mt76_rx_status *status, struct ieee80211_supported_band *sband, __le32 *rxv, u8 *mode, u8 *nss, + struct mib_stats *mib, struct mt76_sta_stats *stats) { u32 v0, v2;
@@ -527,15 +528,19 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->encoding =RX_ENC_HT ;if (gi) status->enc_flags |=RX_ENC_FLAG_SHORT_GI ; -if (i >31 ) +if (i >31 ) { + mib->rx_d_bad_ht_rix++;return -EINVAL ; + }break ;case MT_PHY_TYPE_VHT : status->encoding =RX_ENC_VHT ;if (gi) status->enc_flags |=RX_ENC_FLAG_SHORT_GI ; -if (i >11 ) +if (i >11 ) { + mib->rx_d_bad_vht_rix++;return -EINVAL ; + }break ;case MT_PHY_TYPE_HE_MU :case MT_PHY_TYPE_HE_SU :
@@ -550,6 +555,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, status->he_dcm = dcm;break ;default : + mib->rx_d_bad_mode++;return -EINVAL ; } status->rate_idx = i;
@@ -587,6 +593,7 @@ mt7915_mac_fill_rx_rate(struct mt7915_dev *dev, stats->rx_bw_160++;break ;default : + mib->rx_d_bad_bw++;return -EINVAL ; }
@@ -642,9 +649,12 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)__le16 fc =0 ;int idx;struct mt76_sta_stats *stats =NULL ; +struct mib_stats *mib = &phy->mib;memset (status,0 ,sizeof (*status)); + mib->rx_d_skb++; +if ((rxd1 &MT_RXD1_NORMAL_BAND_IDX ) && !phy->band_idx) { mphy = dev->mt76.phy2;if (!mphy)
@@ -657,8 +667,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)if (!test_bit (MT76_STATE_RUNNING , &mphy->state))return -EINVAL ; -if (rxd2 &MT_RXD2_NORMAL_AMSDU_ERR ) +if (rxd2 &MT_RXD2_NORMAL_AMSDU_ERR ) { + mib->rx_d_rxd2_amsdu_err++;return -EINVAL ; + } hdr_trans = rxd2 &MT_RXD2_NORMAL_HDR_TRANS ;if (hdr_trans && (rxd1 &MT_RXD1_NORMAL_CM ))
@@ -692,8 +704,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)else sband = &mphy->sband_2g.sband; -if (!sband->channels) +if (!sband->channels) { + mib->rx_d_null_channels++;return -EINVAL ; + }if ((rxd0 & csum_mask) == csum_mask) skb->ip_summed =CHECKSUM_UNNECESSARY ;
@@ -713,8 +727,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) remove_pad =FIELD_GET (MT_RXD2_NORMAL_HDR_OFFSET , rxd2); -if (rxd2 &MT_RXD2_NORMAL_MAX_LEN_ERROR ) +if (rxd2 &MT_RXD2_NORMAL_MAX_LEN_ERROR ) { + mib->rx_d_max_len_err++;return -EINVAL ; + } rxd +=6 ;if (rxd1 &MT_RXD1_NORMAL_GROUP_4 ) {
@@ -726,8 +742,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) seq_ctrl =FIELD_GET (MT_RXD8_SEQ_CTRL , v2); rxd +=4 ; -if ((u8 *)rxd - skb->data >= skb->len) +if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++;return -EINVAL ; + } }if (rxd1 &MT_RXD1_NORMAL_GROUP_1 ) {
@@ -758,8 +776,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) } } rxd +=4 ; -if ((u8 *)rxd - skb->data >= skb->len) +if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++;return -EINVAL ; + } }if (rxd1 &MT_RXD1_NORMAL_GROUP_2 ) {
@@ -781,8 +801,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) } rxd +=2 ; -if ((u8 *)rxd - skb->data >= skb->len) +if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++;return -EINVAL ; + } }/* RXD Group 3 - P-RXV */
@@ -794,8 +816,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) rxv = rxd;/* DW16 assuming group 1,2,3,4 */ rxd +=2 ; -if ((u8 *)rxd - skb->data >= skb->len) +if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++;return -EINVAL ; + } v0 =le32_to_cpu (rxv[0 ]);/* DW16, P-VEC1 31:0 */ /* DW17, RX_RCPI copied over P-VEC 64:32 Per RX Format doc. */
@@ -816,13 +840,15 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)/* RXD Group 5 - C-RXV */ if (rxd1 &MT_RXD1_NORMAL_GROUP_5 ) { rxd +=18 ; -if ((u8 *)rxd - skb->data >= skb->len) +if ((u8 *)rxd - skb->data >= skb->len) { + mib->rx_d_too_short++;return -EINVAL ; + } }if (!is_mt7915 (&dev->mt76) || (rxd1 &MT_RXD1_NORMAL_GROUP_5 )) { ret =mt7915_mac_fill_rx_rate (dev, status, sband, rxv, - &mode, &nss, stats); + &mode, &nss, mib, stats);if (ret <0 )return ret; }else {
drivers/net/wireless/mediatek/mt76/mt7915/main.c +22 -0
@@ -1157,6 +1157,17 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = {"rx_vec_queue_overflow_drop_cnt" ,"rx_ba_cnt" , +/* driver rx counters */ +"d_rx_skb" , +"d_rx_rxd2_amsdu_err" , +"d_rx_null_channels" , +"d_rx_max_len_err" , +"d_rx_too_short" , +"d_rx_bad_ht_rix" , +"d_rx_bad_vht_rix" , +"d_rx_bad_mode" , +"d_rx_bad_bw" , +/* per vif counters */ "v_tx_mpdu_attempts" ,/* counting any retries */ "v_tx_mpdu_fail", /* frames that failed even after retry */
@@ -1323,6 +1334,17 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->rx_vec_queue_overflow_drop_cnt; data[ei++] = mib->rx_ba_cnt; +/* rx stats from driver */ + data[ei++] = mib->rx_d_skb; + data[ei++] = mib->rx_d_rxd2_amsdu_err; + data[ei++] = mib->rx_d_null_channels; + data[ei++] = mib->rx_d_max_len_err; + data[ei++] = mib->rx_d_too_short; + data[ei++] = mib->rx_d_bad_ht_rix; + data[ei++] = mib->rx_d_bad_vht_rix; + data[ei++] = mib->rx_d_bad_mode; + data[ei++] = mib->rx_d_bad_bw; +/* Add values for all stations owned by this vif */ wi.initial_stat_idx = ei;ieee80211_iterate_stations_atomic (hw, mt7915_ethtool_worker, &wi);
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +11 -0
@@ -216,6 +216,17 @@ struct mib_stats {u32 tx_amsdu[8 ];u32 tx_amsdu_cnt; + +/* rx stats from the driver */ +u32 rx_d_skb;/* total skb received in rx path */ +u32 rx_d_rxd2_amsdu_err; +u32 rx_d_null_channels; +u32 rx_d_max_len_err; +u32 rx_d_too_short; +u32 rx_d_bad_ht_rix; +u32 rx_d_bad_vht_rix; +u32 rx_d_bad_mode; +u32 rx_d_bad_bw; };struct mt7915_hif {
Signature · 1 line
2.20.1
PATCH 11/12 wifi: mt76: mt7915: add ethtool tx/rx pkts/bytes
In reply to [email protected]From: Ben Greear <[email protected]>
These stats are provided with same name by ath10k and some intel wired NIC drivers. Add them to mt7915 as well to allow user-space code to more easily get some basic stats out of the radio.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 7 +++++++ drivers/net/wireless/mediatek/mt76/mt7915/main.c | 11 +++++++++++ drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 7 +++++++ 3 files changed, 25 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +7 -0
@@ -921,6 +921,9 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)if (rxv && mode >=MT_PHY_TYPE_HE_SU && !(status->flag &RX_FLAG_8023 ))mt7915_mac_decode_he_radiotap (skb, rxv, mode); + mib->rx_pkts_nic++; + mib->rx_bytes_nic += skb->len; +if (!status->wcid || !ieee80211_is_data_qos (fc))return 0 ;
@@ -1584,6 +1587,8 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t,u16 wcid_idx;struct ieee80211_tx_info *info;struct ieee80211_tx_rate *rate; +struct mt7915_phy *phy = &dev->phy; +struct mib_stats *mib = &phy->mib;mt7915_txp_skb_unmap (mdev, t);if (!t->skb)
@@ -1675,6 +1680,8 @@ mt7915_txwi_free(struct mt7915_dev *dev, struct mt76_txwi_cache *t,/* Apply the values that this txfree path reports */ rate->count = tx_cnt;if (tx_status ==0 ) { + mib->tx_pkts_nic++; + mib->tx_bytes_nic += t->skb->len; info->flags |=IEEE80211_TX_STAT_ACK ; info->status.ampdu_ack_len =1 ; }else {
drivers/net/wireless/mediatek/mt76/mt7915/main.c +11 -0
@@ -1094,6 +1094,10 @@ static void mt7915_sta_set_decap_offload(struct ieee80211_hw *hw, }static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN ] = { +"tx_pkts_nic" ,/* from driver, phy tx-ok skb */ +"tx_bytes_nic" ,/* from driver, phy tx-ok bytes */ +"rx_pkts_nic" ,/* from driver, phy rx OK skb */ +"rx_bytes_nic" ,/* from driver, phy rx OK bytes */ "tx_ampdu_cnt" ,"tx_stop_q_empty_cnt" ,"tx_mpdu_attempts" ,
@@ -1275,6 +1279,13 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw,mt7915_mac_update_stats (phy); +/* driver phy-wide stats */ + data[ei++] = mib->tx_pkts_nic; + data[ei++] = mib->tx_bytes_nic; + data[ei++] = mib->rx_pkts_nic; + data[ei++] = mib->rx_bytes_nic; + +/* MIB stats from FW/HW */ data[ei++] = mib->tx_ampdu_cnt; data[ei++] = mib->tx_stop_q_empty_cnt; data[ei++] = mib->tx_mpdu_attempts_cnt;
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +7 -0
@@ -166,6 +166,13 @@ struct mt7915_vif {/* per-phy stats. */ struct mib_stats { +/* phy wide driver stats */ +u32 tx_pkts_nic;/* tx OK skb */ +u32 tx_bytes_nic;/* tx OK bytes */ +u32 rx_pkts_nic;/* rx OK skb */ +u32 rx_bytes_nic;/* rx OK bytes */ + +/* MIB counters from FW/HW */ u32 ack_fail_cnt;u32 fcs_err_cnt;u32 rts_cnt;
Signature · 1 line
2.20.1
PATCH 12/12 wifi: mt76: mt7915: add rx-ppdu-size-out-of-range ethtool counter
In reply to [email protected]From: Ben Greear <[email protected]>
Support this additional MIB counter, it shares register with the rx-fifo-overflow counter.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 1 + drivers/net/wireless/mediatek/mt76/mt7915/main.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 1 + drivers/net/wireless/mediatek/mt76/mt7915/regs.h | 1 + 4 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +1 -0
@@ -2490,6 +2490,7 @@ void mt7915_mac_update_stats(struct mt7915_phy *phy) cnt =mt76_rr (dev,MT_MIB_SDR4 (phy->band_idx)); mib->rx_fifo_full_cnt +=FIELD_GET (MT_MIB_SDR4_RX_FIFO_FULL_MASK , cnt); + mib->rx_oor_cnt +=FIELD_GET (MT_MIB_SDR4_RX_OOR_MASK , cnt); cnt =mt76_rr (dev,MT_MIB_SDR5 (phy->band_idx)); mib->rx_mpdu_cnt += cnt;
drivers/net/wireless/mediatek/mt76/mt7915/main.c +3 -1
@@ -1148,6 +1148,7 @@ static const char mt7915_gstrings_stats[][ETH_GSTRING_LEN] = {/* rx counters */ "rx_fifo_full_cnt" , +"rx_oor_cnt" ,/* rx ppdu length is bad */ "rx_mpdu_cnt" ,"channel_idle_cnt" , "rx_vector_mismatch_cnt",
@@ -1331,7 +1332,8 @@ void mt7915_get_et_stats(struct ieee80211_hw *hw, data[ei++] = mib->tx_amsdu[i];/* rx counters */ - data[ei++] = mib->rx_fifo_full_cnt; + data[ei++] = mib->rx_fifo_full_cnt;/* group-5 might exacerbate this */ + data[ei++] = mib->rx_oor_cnt; data[ei++] = mib->rx_mpdu_cnt; data[ei++] = mib->channel_idle_cnt; data[ei++] = mib->rx_vector_mismatch_cnt;
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +1 -0
@@ -208,6 +208,7 @@ struct mib_stats {/* rx stats */ u32 rx_fifo_full_cnt; +u32 rx_oor_cnt;u32 channel_idle_cnt;u32 rx_vector_mismatch_cnt;u32 rx_delimiter_fail_cnt;
drivers/net/wireless/mediatek/mt76/mt7915/regs.h +1 -0
@@ -292,6 +292,7 @@ enum offs_rev {#define MT_MIB_SDR4 (_band) MT_WF_MIB(_band, __OFFS(MIB_SDR4))#define MT_MIB_SDR4_RX_FIFO_FULL_MASK GENMASK(15, 0) +#define MT_MIB_SDR4_RX_OOR_MASK GENMASK(23, 16)/* rx mpdu counter, full 32 bits */ #define MT_MIB_SDR5 (_band) MT_WF_MIB(_band, __OFFS(MIB_SDR5))
Signature · 1 line
2.20.1