wifi: iwlwifi: Report link-id for transmitted frames.
Subsystems (2)
PATCH v3 1/2 wifi: iwlwifi: Report link-id for transmitted frames.
From: Ben Greear <[email protected]>
This will let upper stack properly record stats per link.
---
v2: Fix rcu locking
v3: Fix missing v2 change text
Fix long lines
Fix |= that should have been '=' assignment in replace_bits logic.
drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +20 -0
@@ -1709,6 +1709,14 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,u8 lq_color;u16 next_reclaimed, seq_ctl;bool is_ndp = false; +struct ieee80211_link_sta *link_sta; +int link_sta_id =-1 ; + +rcu_read_lock (); + link_sta =rcu_dereference (mvm->fw_id_to_link_sta[sta_id]); +if (link_sta) + link_sta_id = link_sta->link_id; +rcu_read_unlock ();__skb_queue_head_init (&skbs);
@@ -1732,6 +1740,10 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,memset (&info->status,0 ,sizeof (info->status)); info->flags &= ~(IEEE80211_TX_STAT_ACK |IEEE80211_TX_STAT_TX_FILTERED ); +if (link_sta_id !=-1 ) + info->control.flags =u32_replace_bits (info->control.flags, + link_sta_id, +IEEE80211_TX_CTRL_MLO_LINK );/* inform mac80211 about what happened with the frame */ switch (status &TX_STATUS_MSK ) {
@@ -2048,6 +2060,7 @@ static void iwl_mvm_tx_reclaim(struct iwl_mvm *mvm, int sta_id, int tid,struct iwl_mvm_sta *mvmsta =NULL ;struct sk_buff *skb;int freed; +struct ieee80211_link_sta *link_sta; if (WARN_ONCE(sta_id >= mvm->fw->ucode_capa.num_stations || tid > IWL_MAX_TID_COUNT,
@@ -2064,6 +2077,8 @@ static void iwl_mvm_tx_reclaim(struct iwl_mvm *mvm, int sta_id, int tid,return ; } + link_sta =rcu_dereference (mvm->fw_id_to_link_sta[sta_id]); +__skb_queue_head_init (&reclaimed_skbs);/*
@@ -2087,6 +2102,11 @@ static void iwl_mvm_tx_reclaim(struct iwl_mvm *mvm, int sta_id, int tid, info->flags |=IEEE80211_TX_STAT_ACK ; else info->flags &= ~IEEE80211_TX_STAT_ACK; + +if (link_sta) + info->control.flags =u32_replace_bits (info->control.flags, + link_sta->link_id, +IEEE80211_TX_CTRL_MLO_LINK ); }/*
Signature · 1 line
2.42.0
PATCH v3 2/2 wifi: mac80211: Assign tx-stats to the proper link.
From: Ben Greear <[email protected]>
For drivers that can report the tx link-id, account tx stats against that link. If we cannot determine tx link, then use deflink.
---
v3: Rename link_sta_info variable to link_sta to match other code.
net/mac80211/status.c | 74 +++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 21 deletions(-)
net/mac80211/status.c +53 -21
@@ -41,6 +41,26 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, }EXPORT_SYMBOL (ieee80211_tx_status_irqsafe); +static struct link_sta_info * +ieee80211_get_tx_link_sta (struct sta_info *sta,struct ieee80211_tx_info *info) +{ +u8 link_id =IEEE80211_LINK_UNSPECIFIED ; +struct link_sta_info *link_sta; + +if (!sta) +return NULL ; + +if (info) + link_id =u32_get_bits (info->control.flags,IEEE80211_TX_CTRL_MLO_LINK ); + +if (link_id !=IEEE80211_LINK_UNSPECIFIED ) { + link_sta =rcu_access_pointer (sta->link[link_id]); +if (link_sta) +return link_sta; + } +return &sta->deflink; +} +static void ieee80211_handle_filtered_frame (struct ieee80211_local *local,struct sta_info *sta,struct sk_buff *skb)
@@ -48,6 +68,7 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local,struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);struct ieee80211_hdr *hdr = (void *)skb->data;int ac; +struct link_sta_info *link_sta =ieee80211_get_tx_link_sta (sta, info); if (info->flags & (IEEE80211_TX_CTL_NO_PS_BUFFER | IEEE80211_TX_CTL_AMPDU |
@@ -72,7 +93,7 @@ static void ieee80211_handle_filtered_frame(struct ieee80211_local *local, info->flags |=IEEE80211_TX_INTFL_RETRANSMISSION ; info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS ; - sta->deflink.status_stats.filtered++; + link_sta->status_stats.filtered++;/* * Clear more-data bit on filtered frames, it might be set
@@ -826,6 +847,7 @@ static void ieee80211_lost_packet(struct sta_info *sta, {unsigned long pkt_time =STA_LOST_PKT_TIME ;unsigned int pkt_thr =STA_LOST_PKT_THRESHOLD ; +struct link_sta_info *link_sta;/* If driver relies on its own algorithm for station kickout, skip * mac80211 packet loss mechanism.
@@ -838,7 +860,8 @@ static void ieee80211_lost_packet(struct sta_info *sta, !(info->flags & IEEE80211_TX_STAT_AMPDU)) return; - sta->deflink.status_stats.lost_packets++; + link_sta =ieee80211_get_tx_link_sta (sta, info); + link_sta->status_stats.lost_packets++;if (sta->sta.tdls) { pkt_time =STA_LOST_TDLS_PKT_TIME ; pkt_thr =STA_LOST_PKT_THRESHOLD ;
@@ -851,14 +874,14 @@ static void ieee80211_lost_packet(struct sta_info *sta,* mechanism. * For non-TDLS, use STA_LOST_PKT_THRESHOLD and STA_LOST_PKT_TIME */ -if (sta->deflink.status_stats.lost_packets < pkt_thr || - !time_after (jiffies, sta->deflink.status_stats.last_pkt_time + pkt_time)) +if (link_sta->status_stats.lost_packets < pkt_thr || + !time_after (jiffies, link_sta->status_stats.last_pkt_time + pkt_time))return ;cfg80211_cqm_pktloss_notify (sta->sdata->dev, sta->sta.addr, - sta->deflink.status_stats.lost_packets, + link_sta->status_stats.lost_packets,GFP_ATOMIC ); - sta->deflink.status_stats.lost_packets =0 ; + link_sta->status_stats.lost_packets =0 ; } static int ieee80211_tx_get_rates(struct ieee80211_hw *hw,
@@ -970,8 +993,12 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw, fc = hdr->frame_control;if (status->sta) { +struct link_sta_info *link_sta; + sta = container_of(status->sta, struct sta_info, sta); + link_sta =ieee80211_get_tx_link_sta (sta, info); +if (info->flags &IEEE80211_TX_STATUS_EOSP )clear_sta_flag (sta,WLAN_STA_SP );
@@ -988,7 +1015,7 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,if (ieee80211_hw_check (&local->hw,HAS_RATE_CONTROL ) && (ieee80211_is_data (hdr->frame_control)) && (rates_idx !=-1 )) - sta->deflink.tx_stats.last_rate = + link_sta->tx_stats.last_rate = info->status.rates[rates_idx]; if ((info->flags & IEEE80211_TX_STAT_AMPDU_NO_BACK) &&
@@ -1034,9 +1061,9 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,return ; }else if (ieee80211_is_data_present (fc)) {if (!acked && !noack_success) - sta->deflink.status_stats.msdu_failed[tid]++; + link_sta->status_stats.msdu_failed[tid]++; - sta->deflink.status_stats.msdu_retries[tid] += + link_sta->status_stats.msdu_retries[tid] += retry_count; }
@@ -1144,12 +1171,15 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,int rates_idx, retry_count;bool acked, noack_success, ack_signal_valid;u16 tx_time_est; +struct link_sta_info *link_sta;if (pubsta) { sta = container_of(pubsta, struct sta_info, sta); + link_sta =ieee80211_get_tx_link_sta (sta, info); +if (status->n_rates) - sta->deflink.tx_stats.last_rate_info = + link_sta->tx_stats.last_rate_info = status->rates[status->n_rates -1 ].rate_idx; }
@@ -1179,8 +1209,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,struct ieee80211_sub_if_data *sdata = sta->sdata;if (!acked && !noack_success) - sta->deflink.status_stats.retry_failed++; - sta->deflink.status_stats.retry_count += retry_count; + link_sta->status_stats.retry_failed++; + link_sta->status_stats.retry_count += retry_count;if (ieee80211_hw_check (&local->hw,REPORTS_TX_ACK_STATUS )) { if (sdata->vif.type == NL80211_IFTYPE_STATION &&
@@ -1189,13 +1219,12 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw, acked, info->status.tx_time);if (acked) { - sta->deflink.status_stats.last_ack = jiffies; + link_sta->status_stats.last_ack = jiffies; -if (sta->deflink.status_stats.lost_packets) - sta->deflink.status_stats.lost_packets =0 ; + link_sta->status_stats.lost_packets =0 ;/* Track when last packet was ACKed */ - sta->deflink.status_stats.last_pkt_time = jiffies; + link_sta->status_stats.last_pkt_time = jiffies;/* Reset connection monitor */ if (sdata->vif.type == NL80211_IFTYPE_STATION &&
@@ -1203,10 +1232,10 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw, sdata->u.mgd.probe_send_count =0 ;if (ack_signal_valid) { - sta->deflink.status_stats.last_ack_signal = + link_sta->status_stats.last_ack_signal = (s8 )info->status.ack_signal; - sta->deflink.status_stats.ack_signal_filled = true; -ewma_avg_signal_add (&sta->deflink.status_stats.avg_ack_signal, + link_sta->status_stats.ack_signal_filled = true; +ewma_avg_signal_add (&link_sta->status_stats.avg_ack_signal, -info->status.ack_signal); } }else if (test_sta_flag (sta,WLAN_STA_PS_STA )) {
@@ -1270,8 +1299,11 @@ void ieee80211_tx_rate_update(struct ieee80211_hw *hw,rate_control_tx_status (local, &status); -if (ieee80211_hw_check (&local->hw,HAS_RATE_CONTROL )) - sta->deflink.tx_stats.last_rate = info->status.rates[0 ]; +if (ieee80211_hw_check (&local->hw,HAS_RATE_CONTROL )) { +struct link_sta_info *link_sta =ieee80211_get_tx_link_sta (sta, info); + + link_sta->tx_stats.last_rate = info->status.rates[0 ]; + } }EXPORT_SYMBOL (ieee80211_tx_rate_update);
Signature · 1 line
2.42.0
Johannes Berg
maintainerRe: [PATCH v3 2/2] wifi: mac80211: Assign tx-stats to the proper link.
Quoted 5 lines · On Wed, 2024-10-09 at 09:49 -0700, [email protected] wrote:
From: Ben Greear <[email protected]>
For drivers that can report the tx link-id, account tx stats against that link. If we cannot determine tx link, then use deflink.
I was hoping Miri would look at the other patch ... but now that I consider it again, this should probably come with some documentation updates? Right now, it only says:
* @IEEE80211_TX_CTRL_MLO_LINK: If not @IEEE80211_LINK_UNSPECIFIED, this
* frame should be transmitted on the specific link. This really is * only relevant for frames that do not have data present, and is * also not used for 802.3 format frames. Note that even if the frame * is on a specific link, address translation might still apply if * it's intended for an MLD.
and actually it's in the _control_ section of the TX info, so it's not generally even preserved over to the _status_ section.
So rather than reusing this, we probably just need to introduce a new _status_ field for it. And probably make it link_id+1 so 0 means no value (this works because link ID 15 is invalid).
johannes
Re: [PATCH v3 2/2] wifi: mac80211: Assign tx-stats to the proper link.
Quoted 18 lines · Johannes Berg
Quoted 5 lines · On Wed, 2024-10-09 at 09:49 -0700, [email protected] wrote:
From: Ben Greear <[email protected]>
For drivers that can report the tx link-id, account tx stats against that link. If we cannot determine tx link, then use deflink.
I was hoping Miri would look at the other patch ... but now that I consider it again, this should probably come with some documentation updates? Right now, it only says:
* @IEEE80211_TX_CTRL_MLO_LINK: If not @IEEE80211_LINK_UNSPECIFIED, this
* frame should be transmitted on the specific link. This really is * only relevant for frames that do not have data present, and is * also not used for 802.3 format frames. Note that even if the frame * is on a specific link, address translation might still apply if * it's intended for an MLD.
Quoted 6 lines
and actually it's in the _control_ section of the TX info, so it's not generally even preserved over to the _status_ section.
So rather than reusing this, we probably just need to introduce a new _status_ field for it. And probably make it link_id+1 so 0 means no value (this works because link ID 15 is invalid).
Where would you like this new field added?
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Johannes Berg
maintainerRe: [PATCH v3 2/2] wifi: mac80211: Assign tx-stats to the proper link.
Quoted 6 lines · Ben Greear
Quoted 4 lines
So rather than reusing this, we probably just need to introduce a new _status_ field for it. And probably make it link_id+1 so 0 means no value (this works because link ID 15 is invalid).
Where would you like this new field added?
Well I guess we can take four bits from ieee80211_tx_info::status.pad or ieee80211_tx_info::status.pad2. We could also do it out of status.flags, but that doesn't seem worth it as long as we still have the pad?
johannes