git: f71daf6a11b7 - stable/13 - LinuxKPI: 802.11: start adding rate control to ieee80211_tx_status()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Apr 2022 09:33:54 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=f71daf6a11b7b67bba34e6be5c737acedbeda803 commit f71daf6a11b7b67bba34e6be5c737acedbeda803 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-04-15 13:39:38 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-04-18 09:32:58 +0000 LinuxKPI: 802.11: start adding rate control to ieee80211_tx_status() Start adding rate control feedback in ieee80211_tx_status() in order for net80211 to be able to report something back (which may not yet be the view of the firmware). iwlwifi is reporting back an MSC 0 even with HT disabled (to be investigated) so we cannot (yet) use the firmware/driver rate feedback directly. Sponsored by: The FreeBSD Foundation (cherry picked from commit 383b3e8f509f9658329d33d7da5473b881c37349) --- sys/compat/linuxkpi/common/include/net/mac80211.h | 38 +-------- sys/compat/linuxkpi/common/src/linux_80211.c | 93 +++++++++++++++++++++++ 2 files changed, 96 insertions(+), 35 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h index 59101e334376..601c240ee553 100644 --- a/sys/compat/linuxkpi/common/include/net/mac80211.h +++ b/sys/compat/linuxkpi/common/include/net/mac80211.h @@ -907,6 +907,7 @@ void linuxkpi_ieee80211_connection_loss(struct ieee80211_vif *); void linuxkpi_ieee80211_beacon_loss(struct ieee80211_vif *); struct sk_buff *linuxkpi_ieee80211_probereq_get(struct ieee80211_hw *, uint8_t *, uint8_t *, size_t, size_t); +void linuxkpi_ieee80211_tx_status(struct ieee80211_hw *, struct sk_buff *); /* -------------------------------------------------------------------------- */ @@ -1754,41 +1755,8 @@ ieee80211_sta_set_buffered(struct ieee80211_sta *sta, uint8_t tid, bool t) static __inline void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct ieee80211_tx_info *info; - int status; - - info = IEEE80211_SKB_CB(skb); - - /* XXX-BZ this check is probably over-simplified? */ - /* XXX-BZ but then we have no full feedback in net80211 yet. */ - if (info->flags & IEEE80211_TX_STAT_ACK) - status = 0; /* No error. */ - else - status = 1; -#if 0 - printf("XXX-BZ: %s: hw %p skb %p status %d : flags %#x " - "band %u hw_queue %u tx_time_est %d : " - "rates [ %u %u %#x, %u %u %#x, %u %u %#x, %u %u %#x ] " - "ack_signal %u ampdu_ack_len %u ampdu_len %u antenna %u tx_time %u " - "is_valid_ack_signal %u status_driver_data [ %p %p ]\n", - __func__, hw, skb, status, info->flags, - info->band, info->hw_queue, info->tx_time_est, - info->status.rates[0].idx, info->status.rates[0].count, - info->status.rates[0].flags, - info->status.rates[1].idx, info->status.rates[1].count, - info->status.rates[1].flags, - info->status.rates[2].idx, info->status.rates[2].count, - info->status.rates[2].flags, - info->status.rates[3].idx, info->status.rates[3].count, - info->status.rates[3].flags, - info->status.ack_signal, info->status.ampdu_ack_len, - info->status.ampdu_len, info->status.antenna, - info->status.tx_time, info->status.is_valid_ack_signal, - info->status.status_driver_data[0], - info->status.status_driver_data[1]); -#endif - IMPROVE(); - linuxkpi_ieee80211_free_txskb(hw, skb, status); + + linuxkpi_ieee80211_tx_status(hw, skb); } static __inline void diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 9355098295a9..b80d8b62087b 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -4180,6 +4180,99 @@ linuxkpi_ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb, kfree_skb(skb); } +void +linuxkpi_ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct ieee80211_tx_info *info; + struct ieee80211_ratectl_tx_status txs; + struct ieee80211_node *ni; + int status; + + info = IEEE80211_SKB_CB(skb); + + if (skb->m != NULL) { + struct mbuf *m; + + m = skb->m; + ni = m->m_pkthdr.PH_loc.ptr; + memset(&txs, 0, sizeof(txs)); + } else { + ni = NULL; + } + + if (info->flags & IEEE80211_TX_STAT_ACK) { + status = 0; /* No error. */ + txs.status = IEEE80211_RATECTL_TX_SUCCESS; + } else { + status = 1; + txs.status = IEEE80211_RATECTL_TX_FAIL_UNSPECIFIED; + } + + if (ni != NULL) { + int ridx __diagused; +#ifdef LINUXKPI_DEBUG_80211 + int old_rate; + + old_rate = ni->ni_vap->iv_bss->ni_txrate; +#endif + txs.pktlen = skb->len; + txs.flags |= IEEE80211_RATECTL_STATUS_PKTLEN; + if (info->status.rates[0].count > 1) { + txs.long_retries = info->status.rates[0].count - 1; /* 1 + retries in drivers. */ + txs.flags |= IEEE80211_RATECTL_STATUS_LONG_RETRY; + } +#if 0 /* Unused in net80211 currently. */ + /* XXX-BZ conver;t check .flags for MCS/VHT/.. */ + txs.final_rate = info->status.rates[0].idx; + txs.flags |= IEEE80211_RATECTL_STATUS_FINAL_RATE; +#endif + if (info->status.is_valid_ack_signal) { + txs.rssi = info->status.ack_signal; /* XXX-BZ CONVERT? */ + txs.flags |= IEEE80211_RATECTL_STATUS_RSSI; + } + + IMPROVE("only update of rate matches but that requires us to get a proper rate"); + ieee80211_ratectl_tx_complete(ni, &txs); + ridx = ieee80211_ratectl_rate(ni->ni_vap->iv_bss, NULL, 0); + +#ifdef LINUXKPI_DEBUG_80211 + if (linuxkpi_debug_80211 & D80211_TRACE_TX) { + printf("TX-RATE: %s: old %d new %d ridx %d, " + "long_retries %d\n", __func__, + old_rate, ni->ni_vap->iv_bss->ni_txrate, + ridx, txs.long_retries); + } +#endif + } + +#ifdef LINUXKPI_DEBUG_80211 + if (linuxkpi_debug_80211 & D80211_TRACE_TX) + printf("TX-STATUS: %s: hw %p skb %p status %d : flags %#x " + "band %u hw_queue %u tx_time_est %d : " + "rates [ %u %u %#x, %u %u %#x, %u %u %#x, %u %u %#x ] " + "ack_signal %u ampdu_ack_len %u ampdu_len %u antenna %u " + "tx_time %u is_valid_ack_signal %u " + "status_driver_data [ %p %p ]\n", + __func__, hw, skb, status, info->flags, + info->band, info->hw_queue, info->tx_time_est, + info->status.rates[0].idx, info->status.rates[0].count, + info->status.rates[0].flags, + info->status.rates[1].idx, info->status.rates[1].count, + info->status.rates[1].flags, + info->status.rates[2].idx, info->status.rates[2].count, + info->status.rates[2].flags, + info->status.rates[3].idx, info->status.rates[3].count, + info->status.rates[3].flags, + info->status.ack_signal, info->status.ampdu_ack_len, + info->status.ampdu_len, info->status.antenna, + info->status.tx_time, info->status.is_valid_ack_signal, + info->status.status_driver_data[0], + info->status.status_driver_data[1]); +#endif + + linuxkpi_ieee80211_free_txskb(hw, skb, status); +} + /* * This is an internal bandaid for the moment for the way we glue * skbs and mbufs together for TX. Once we have skbs backed by