1: 79ad7ef98978 ! 1: d044068818b7 wifi: rtw89: fix retry limit and NO_ACK status for injected frames @@ Metadata ## Commit message ## wifi: rtw89: fix retry limit and NO_ACK status for injected frames  - Commit 92608bb5f14f ("wifi: rtw89: honor ASSIGN_SEQ, retries, and - NO_ACK for injected frames") has three issues: + mac80211 clears IEEE80211_TX_CTRL_RATE_INJECT if the injected rate is + unsupported, but still fills rates[0].count. Check RATE_INJECT before + applying rates[0].count in rtw89_core_tx_update_injection().  - 1. rtw89_core_tx_update_injection() uses info->control.rates[0].count - without checking IEEE80211_TX_CTRL_RATE_INJECT. When a radiotap rate - is unsupported on the current band or stream capability, - ieee80211_parse_tx_radiotap() clears IEEE80211_TX_CTRL_RATE_INJECT - while still populating rates[0].count. Gate the per-packet retry - override on IEEE80211_TX_CTRL_RATE_INJECT. + Cap hw->max_rate_tries at min(RTW89_TX_DATA_CNT_LMT_MAX, + IEEE80211_MAX_TX_RETRY) so radiotap retry counts do not overflow the + 5-bit rates[0].count field.  - 2. hw->max_rate_tries is set to RTW89_TX_DATA_CNT_LMT_MAX (63), which - exceeds the 5-bit struct ieee80211_tx_rate::count field and causes - radiotap retry counts above 30 to wrap around. Set - hw->max_rate_tries to IEEE80211_MAX_TX_RETRY (31) and drop the - unused macro. - - 3. rtw89_tx_rpt_tx_status() sets IEEE80211_TX_STAT_NOACK_TRANSMITTED - unconditionally for NO_ACK frames (including RTW89_TX_MACID_DROP and - RTW89_TX_LIFE_TIME) and also sets IEEE80211_TX_STAT_ACK when - tx_status == RTW89_TX_DONE. Because Wi-Fi 6 AX chips lack a TX - descriptor NO_ACK bit and implement NO_ACK via tx_cnt_lmt = 1, - unacknowledged unicast NO_ACK frames complete with - RTW89_TX_RETRY_LIMIT, whereas broadcast, QoS No-Ack, and Wi-Fi 7 BE - NO_ACK frames complete with RTW89_TX_DONE. Clear stale status bits - and report IEEE80211_TX_STAT_NOACK_TRANSMITTED exclusively on - RTW89_TX_DONE or RTW89_TX_RETRY_LIMIT, reserving - IEEE80211_TX_STAT_ACK for frames without IEEE80211_TX_CTL_NO_ACK. + In rtw89_tx_rpt_tx_status(), setting IEEE80211_TX_STAT_NOACK_TRANSMITTED + on dropped NO_ACK skbs (MACID_DROP or LIFE_TIME) makes mac80211 count + them as transmitted instead of failed. Only set NOACK_TRANSMITTED on + RTW89_TX_DONE, or on RTW89_TX_RETRY_LIMIT for AX unicast NO_ACK frames + sent once with tx_cnt_lmt = 1, and do not set IEEE80211_TX_STAT_ACK on + NO_ACK frames.  Fixes: 92608bb5f14f ("wifi: rtw89: honor ASSIGN_SEQ, retries, and NO_ACK for injected frames") Reported-by: Luka Gejak  @@ drivers/net/wireless/realtek/rtw89/core.c: static void rtw89_core_tx_update_inje desc_info->tx_cnt_lmt_en = true; desc_info->tx_cnt_lmt = 1;  - } else if (info->control.rates[0].count) { -+ } else if ((info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT) && ++ } else if (info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT &&  + info->control.rates[0].count) { desc_info->tx_cnt_lmt_en = true; desc_info->tx_cnt_lmt = info->control.rates[0].count; @@ drivers/net/wireless/realtek/rtw89/core.c: static int rtw89_core_register_hw(str hw->max_rx_aggregation_subframes = chip->max_rx_agg_num; hw->max_tx_aggregation_subframes = chip->max_tx_agg_num;  - hw->max_rate_tries = RTW89_TX_DATA_CNT_LMT_MAX; -+ hw->max_rate_tries = IEEE80211_MAX_TX_RETRY; ++ hw->max_rate_tries = min(RTW89_TX_DATA_CNT_LMT_MAX, IEEE80211_MAX_TX_RETRY); hw->uapsd_max_sp_len = IEEE80211_WMM_IE_STA_QOSINFO_SP_ALL;  hw->radiotap_mcs_details |= IEEE80211_RADIOTAP_MCS_HAVE_FEC |  - ## drivers/net/wireless/realtek/rtw89/core.h ## -@@ drivers/net/wireless/realtek/rtw89/core.h: struct rtw89_tx_desc_info { - bool tx_cnt_lmt_en; - u8 sn: 4; - u8 tx_cnt_lmt: 6; --#define RTW89_TX_DATA_CNT_LMT_MAX 0x3f - u8 addr_info_nr; - u8 sec_keyid; - u8 sec_type; - ## drivers/net/wireless/realtek/rtw89/mac.h ##  @@ drivers/net/wireless/realtek/rtw89/mac.h: void rtw89_tx_rpt_tx_status(struct rtw89_dev *rtwdev, struct sk_buff *skb, info = IEEE80211_SKB_CB(skb); @@ drivers/net/wireless/realtek/rtw89/mac.h: void rtw89_tx_rpt_tx_status(struct rtw  - if (info->flags & IEEE80211_TX_CTL_NO_ACK)  - info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED;  - if (tx_status == RTW89_TX_DONE) -+ info->flags &= ~(IEEE80211_TX_STAT_NOACK_TRANSMITTED | -+ IEEE80211_TX_STAT_ACK);  + if (info->flags & IEEE80211_TX_CTL_NO_ACK) {  + if (tx_status == RTW89_TX_DONE ||  + tx_status == RTW89_TX_RETRY_LIMIT) 2: 46ca6c5fce7f ! 2: c8f039302fec wifi: rtw89: pci: fix TX status and counters for NO_ACK frames @@ Metadata Author: Enver Ikromov   ## Commit message ## - wifi: rtw89: pci: fix TX status and counters for NO_ACK frames + wifi: rtw89: pci: fix NO_ACK TX status reporting  - In rtw89_pci_tx_status(), IEEE80211_TX_STAT_NOACK_TRANSMITTED is set - unconditionally whenever IEEE80211_TX_CTL_NO_ACK is present, even when - the frame was dropped (RTW89_TX_MACID_DROP or RTW89_TX_LIFE_TIME) - without being transmitted. In addition, when a NO_ACK frame completes - with RTW89_TX_DONE (broadcast, QoS No-Ack, or Wi-Fi 7 BE NO_ACK), the - subsequent RTW89_TX_DONE branch also sets IEEE80211_TX_STAT_ACK and - increments tx_ring->tx_acked, whereas unacknowledged Wi-Fi 6 AX unicast - NO_ACK frames (tx_cnt_lmt = 1) complete with RTW89_TX_RETRY_LIMIT and - fall into the failure path. + PCIe devices report TX status via rtw89_pci_tx_status() rather than + rtw89_tx_rpt_tx_status(). Currently it sets + IEEE80211_TX_STAT_NOACK_TRANSMITTED even when a NO_ACK skb was dropped + (MACID_DROP or LIFE_TIME), so mac80211 counts dropped frames as sent, + and it also sets IEEE80211_TX_STAT_ACK on RTW89_TX_DONE.  - Clear stale TX status bits and set IEEE80211_TX_STAT_NOACK_TRANSMITTED - exclusively when a NO_ACK frame completes with RTW89_TX_DONE or - RTW89_TX_RETRY_LIMIT, reserving IEEE80211_TX_STAT_ACK and - tx_ring->tx_acked for non-NO_ACK completions while still accounting - RTW89_TX_LIFE_TIME and RTW89_TX_MACID_DROP as failures. + Only set NOACK_TRANSMITTED on RTW89_TX_DONE or RTW89_TX_RETRY_LIMIT, + skip the TX failure debug log in that case, and do not set + IEEE80211_TX_STAT_ACK for NO_ACK frames.  - Fixes: e3ec7017f6a2 ("rtw89: add Realtek 802.11ax driver") - Cc: stable@vger.kernel.org Signed-off-by: Enver Ikromov   ## drivers/net/wireless/realtek/rtw89/pci.c ## @@ drivers/net/wireless/realtek/rtw89/pci.c: static void rtw89_pci_tx_status(struct ieee80211_tx_info_clear_status(info);   - if (info->flags & IEEE80211_TX_CTL_NO_ACK) -+ info->flags &= ~(IEEE80211_TX_STAT_NOACK_TRANSMITTED | -+ IEEE80211_TX_STAT_ACK); -+ if ((info->flags & IEEE80211_TX_CTL_NO_ACK) && -+ (tx_status == RTW89_TX_DONE || tx_status == RTW89_TX_RETRY_LIMIT)) { - info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; -- if (tx_status == RTW89_TX_DONE) { -+ } else if (tx_status == RTW89_TX_DONE) { - info->flags |= IEEE80211_TX_STAT_ACK; +- info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; + if (tx_status == RTW89_TX_DONE) { +- info->flags |= IEEE80211_TX_STAT_ACK; ++ if (info->flags & IEEE80211_TX_CTL_NO_ACK) ++ info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; ++ else ++ info->flags |= IEEE80211_TX_STAT_ACK; tx_ring->tx_acked++; } else { +- if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) ++ if (info->flags & IEEE80211_TX_CTL_NO_ACK && ++ tx_status == RTW89_TX_RETRY_LIMIT) ++ info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; ++ else if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) + rtw89_debug(rtwdev, RTW89_DBG_FW, + "failed to TX of status %x\n", tx_status); + switch (tx_status) {