Re: [RFC PATCH v3 0/4] wifi: rtl8xxxu: implement AP mode for 8188EU
From: Bitterblue Smith
Date: Wed Nov 25 2026 - 15:37:20 EST
On 25/11/2026 18:06, Mehmet Fide wrote:
> Hi Georg, Bitterblue,
>
> I tested v3 on rtw-next (18d0bedbb5f0, context fixes in patches 2 and 4
> only) with an Edimax EW-7811Un V2 (RTL8188EUS rev D) as AP and a
> separate sniffer. I found three problems in the AP part, plus an older
> one that explains the duplicate pings.
>
> 1. Beacons. After hostapd starts, the 8188e sends one beacon and then
> none. Probe responses go out, so clients still find the AP by active
> scanning, but association takes about 6 s and a passive scan sees
> nothing. BCN_VALID is set and the beacon function is enabled; the
> hardware clears the beacon queue after the first beacon. In AP mode the
> vendor driver (hw_var_set_opmode()) sets BIT(3) | BIT(4) in
> REG_MBID_NUM, commented "If set 0, hw will clr bcnq when tx becon
> ok/fail". With that there is a beacon at every TBTT and association
> takes 0.5 s.
>
> 2. TBTT hold time. rtl8xxxu_start_tx_beacon() writes 0x80 to
> REG_TBTT_PROHIBIT + 1 and clears bit 0 of + 2; the vendor
> ResumeTxBeacon() writes 0xff and sets bit 0. On channel 6 with several
> neighbour APs, 7 runs of about 120 TBTTs each: 2-5 % of the beacons
> missing (one run 42 %) with the rtl8xxxu value; with the vendor value
> 0 % in 5 runs and 1-3 % in 2.
>
> 3. macid in the TX descriptor, which Bitterblue pointed out:
> rtl8xxxu_fill_txdesc_v3() still does not set it; the vendor driver puts
> mac_id & 0x3f into txdw1. The same function also indexes
> priv->ra_info[macid] now, but for group addressed frames with a key,
> rtl8xxxu_tx() replaces macid with the security CAM index, which can go
> past the 16 entries of ra_info.
RTL8188E_MAX_MAC_ID_NUM should be 64 (hal_spec->macid_num = 64 in
hal/rtl8188e/rtl8188e_hal_init.c).
>
> This is what I use on top of v3 for 1-3:
>
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/core.c b/drivers/net/wireless/realtek/rtl8xxxu/core.c
> index 49c167fd6ee4..9a297b077443 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/core.c
> @@ -1154,6 +1154,14 @@ static void rtl8xxxu_start_tx_beacon(struct rtl8xxxu_priv *priv)
> val8 |= EN_BCNQ_DL >> 16;
> rtl8xxxu_write8(priv, REG_FWHW_TXQ_CTRL + 2, val8);
>
> + if (priv->rtl_chip == RTL8188E) {
> + rtl8xxxu_write8(priv, REG_TBTT_PROHIBIT + 1, 0xff);
> + val8 = rtl8xxxu_read8(priv, REG_TBTT_PROHIBIT + 2);
> + val8 |= BIT(0);
> + rtl8xxxu_write8(priv, REG_TBTT_PROHIBIT + 2, val8);
> + return;
> + }
> +
> rtl8xxxu_write8(priv, REG_TBTT_PROHIBIT + 1, 0x80);
> val8 = rtl8xxxu_read8(priv, REG_TBTT_PROHIBIT + 2);
> val8 &= 0xF0;
> @@ -5572,7 +5580,7 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
> {
> struct rtl8xxxu_priv *priv = hw->priv;
> struct device *dev = &priv->udev->dev;
> - struct rtl8xxxu_ra_info *ra = &priv->ra_info[macid];
> + struct rtl8xxxu_ra_info *ra;
> u8 *qc = ieee80211_get_qos_ctl(hdr);
> u8 tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK;
> u32 rate = 0;
> @@ -5580,6 +5588,10 @@ rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
>
> seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
>
> + /* macid is the security CAM index for group addressed frames */
> + ra = &priv->ra_info[macid < RTL8188E_MAX_MAC_ID_NUM ? macid : 0];
> + tx_desc->txdw1 |= cpu_to_le32(macid & 0x3f);
> +
> if (ieee80211_is_data(hdr->frame_control)) {
> rate = ra->decision_rate;
> tx_desc->txdw5 = cpu_to_le32(rate);
> @@ -7002,6 +7014,13 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw,
> rtl8xxxu_write16(priv, REG_TSFTR_SYN_OFFSET, 0x7fff); /* ~32ms */
> rtl8xxxu_write8(priv, REG_DUAL_TSF_RST, DUAL_TSF_RESET_TSF0);
>
> + /* The 8188e clears the beacon queue after each beacon unless told not to */
> + if (priv->rtl_chip == RTL8188E) {
> + val8 = rtl8xxxu_read8(priv, REG_MBID_NUM);
> + val8 |= BIT(3) | BIT(4);
> + rtl8xxxu_write8(priv, REG_MBID_NUM, val8);
> + }
> +
> /* enable BCN0 function */
> rtl8xxxu_write8(priv, REG_BEACON_CTRL,
> BEACON_DISABLE_TSF_UPDATE |
>
> With these, beacon loss is 0.5-3.4 % at the sniffer and association
> takes 0.5 s.
>
> 4. Duplicate pings. I can reproduce them with two clients, on one of
> the two and in both directions, and not with one client. The captures
> show the client sending the same MSDU again with a new sequence number
> after its retry limit, because many of its frames are not acked: 62-73 %
> of the frames sent to the 8188e carry the retry bit.
>
> This is not AP specific. With the 8188e as a station of an rtw88 AP,
> same dongle, place and traffic, 63 % of the frames to the 8188e are
> retries with rtl8xxxu and 0 % with Realtek's v5.3.9 driver
> (aircrack-ng/rtl8188eus with kernel API fixes only, on a non-RT kernel;
> it crashes on PREEMPT_RT). I dumped the registers of both
> drivers while associated and wrote the vendor values into rtl8xxxu one
> group at a time. The difference is REG_OFDM0_XA_AGC_CORE1:
> rtl8xxxu_start() sets the IGI to 0x1e (see c8bc37602779 ("wifi:
> rtl8xxxu: Simplify setting the initial gain")) and nothing changes it
> later, while the vendor driver had 0x40 in that test. With IGI 0x40 alone the
> retries drop to 1 %.
>
> A fixed value does not solve it, though. In AP mode with the two
> clients at -44 and -52 dBm, IGI 0x40 removes the duplicates but loses
> 35-65 % of the pings. The 8188e seems to need the vendor's dynamic
> initial gain (IGI from the lowest station RSSI and the false alarm
> count). Bitterblue, is there a reason rtl8xxxu has no DIG, or would a
> simple one for the 8188e be acceptable?
I think the reason is just that nobody implemented it yet.
>
> Georg, do you plan a v4? I can send 1-3 as patches on top of your
> series, or include them in a v4 with your patches if you prefer.
>
> Best regards,
> Mehmet