RE: [PATCH rtw-next 2/3] wifi: rtl8xxxu: honour the retry count of injected frames on gen1 chips

From: Ping-Ke Shih

Date: Sat Nov 21 2026 - 21:01:06 EST


Ahmet Zeren via B4 Relay <devnull+niko3x.proton.me@xxxxxxxxxx> wrote:

[...]

> drivers/net/wireless/realtek/rtl8xxxu/core.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/core.c
> index 969875fd54..b159d9b64c 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
> @@ -5245,6 +5245,24 @@ static bool rtl8xxxu_tx_rate_inject(struct ieee80211_tx_info *tx_info,
> return true;
> }
>
> +/*
> + * Retry limit of an injected frame: none if no ACK is expected, else the
> + * radiotap retry count. -1 leaves it to the hardware.
> + */
> +static int rtl8xxxu_tx_retry_inject(struct ieee80211_tx_info *tx_info)
> +{
> + if (!(tx_info->flags & IEEE80211_TX_CTL_INJECTED))
> + return -1;
> +
> + if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK)
> + return 0;
> +
> + if (tx_info->control.flags & IEEE80211_TX_CTRL_RATE_INJECT)
> + return tx_info->control.rates[0].count - 1;
> +
> + return -1;
> +}
> +
> /*
> * Fill in v1 (gen1) specific TX descriptor bits.
> * This format is used on 8188cu/8192cu/8723au
> @@ -5262,9 +5280,11 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
> u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
> u32 rate = 0;
> u16 seq_number;
> + int retries;
> bool inject;
>
> inject = rtl8xxxu_tx_rate_inject(tx_info, &rate, &sgi);
> + retries = rtl8xxxu_tx_retry_inject(tx_info);
>
> if (rtl8xxxu_debug & RTL8XXXU_DEBUG_TX)
> dev_info(dev, "%s: TX rate: %d, pkt size %u\n",
> @@ -5314,6 +5334,12 @@ rtl8xxxu_fill_txdesc_v1(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
> tx_desc->txdw4 |= cpu_to_le32(TXDESC32_USE_DRIVER_RATE |
> TXDESC_DISABLE_DATA_FB);
>
> + if (retries >= 0) {
> + tx_desc->txdw5 &= ~cpu_to_le32(TXDESC32_RETRY_LIMIT_MASK);

Can we squash this with ieee80211_is_mgmt(hdr->frame_control) case?
Then we don't need to clear the bits again.

> + tx_desc->txdw5 |= cpu_to_le32(retries << TXDESC32_RETRY_LIMIT_SHIFT |
> + TXDESC32_RETRY_LIMIT_ENABLE);

le32_encode_bits(retries, TXDESC32_RETRY_LIMIT_ENABLE) ?

> + }
> +
> /*
> * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled
> */
> @@ -7979,6 +8005,8 @@ static int rtl8xxxu_probe(struct usb_interface *interface,
> SET_IEEE80211_PERM_ADDR(hw, priv->mac_addr);
>
> hw->extra_tx_headroom = priv->fops->tx_desc_size;
> + /* The TX descriptor retry limit is 6 bits wide */
> + hw->max_rate_tries = 64;

define a TXDESC32_RETRY_LIMIT_MAX along TXDESC32_RETRY_LIMIT_ENABLE.
We don't need the comment, and it is clear that 64 is because
TXDESC32_RETRY_LIMIT_ENABLE is 6 bits wide.

> ieee80211_hw_set(hw, SIGNAL_DBM);
>
> /*
>
> --
> 2.56.1
>