mbox series

[v4,00/18] wifi: rtl8xxxu: Add AP mode support for 8188f

Message ID 20230428150833.218605-1-martin.kaistra@linutronix.de
Headers show
Series wifi: rtl8xxxu: Add AP mode support for 8188f | expand

Message

Martin Kaistra April 28, 2023, 3:08 p.m. UTC
This series intends to bring AP mode support to the rtl8xxxu driver,
more specifically for the 8188f, because this is the HW I have.
The work is based on the vendor driver as I do not have access to
datasheets.

The iperf3 measurements for TCP in AP mode still look slower in the
AP->STA direction compared to the vendor driver, UDP looks fine. I still
hope, this can be fixed by future patches.

Thanks,
  Martin

v4 changelog:
- restructured beacon enable code in bss_info_changed 
v3 changelog:
- add some R-bs
- remove priv->beacon_enabled
- rename max_sta_num to max_macid_num
v2 changelog:
- dropped RFC prefix
- rebase patches to newest wireless-next
- add some R-bs
- new patch: "Add parameter force to rtl8xxxu_refresh_rate_mask"
- new patch: "Remove usage of ieee80211_get_tx_rate()"
- new patch: "Remove usage of tx_info->control.rates[0].flags"
- new patch: "Set maximum number of supported stations"
- add macro for broadcast/multicast frames macid
- add more explanation about beacon queue in commit message of patch 2
- add macros for bit definitions for beacon functions
- implement enable_beacon = false case
- fix beacon valid loop so that error condition is actually reached
- add more explanation about setting mac address register in add_interface
  in commit message of patch 6
- rename role macros for connect report h2c
- use bitmap for assigning macids
- add helper function for looking up assigned macids
- move patch 7 so we can use rtl8xxxu_get_macid helper
- add sta_remove callback
- do things in sta_add only in AP mode
- use IEEE80211_TX_CTL_ASSIGN_SEQ flag to determine when to use HW sequence
  numbers
- add priv->vif null pointer check in configure_filter, rework setting
  BSSID_BEACON/BSSID_MATCH in RCR

v1: https://lore.kernel.org/linux-wireless/20230322171905.492855-1-martin.kaistra@linutronix.de/
v2: https://lore.kernel.org/linux-wireless/20230419100145.159191-1-martin.kaistra@linutronix.de/
v3: https://lore.kernel.org/linux-wireless/20230427090922.165088-1-martin.kaistra@linutronix.de/

Martin Kaistra (18):
  wifi: rtl8xxxu: Add start_ap() callback
  wifi: rtl8xxxu: Select correct queue for beacon frames
  wifi: rtl8xxxu: Add beacon functions
  wifi: rtl8xxxu: Add set_tim() callback
  wifi: rtl8xxxu: Allow setting rts threshold to -1
  wifi: rtl8xxxu: Allow creating interface in AP mode
  wifi: rtl8xxxu: Actually use macid in rtl8xxxu_gen2_report_connect
  wifi: rtl8xxxu: Add parameter role to report_connect
  wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask
  wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks
  wifi: rtl8xxxu: Put the macid in txdesc
  wifi: rtl8xxxu: Add parameter macid to update_rate_mask
  wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames
  wifi: rtl8xxxu: Clean up filter configuration
  wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate()
  wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags
  wifi: rtl8xxxu: Declare AP mode support for 8188f
  wifi: rtl8xxxu: Set maximum number of supported stations

 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h  |  37 +-
 .../realtek/rtl8xxxu/rtl8xxxu_8188e.c         |   3 +-
 .../realtek/rtl8xxxu/rtl8xxxu_8188f.c         |   2 +
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 337 ++++++++++++++----
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h |   5 +
 5 files changed, 300 insertions(+), 84 deletions(-)

Comments

Reto Schneider May 7, 2023, 11:09 p.m. UTC | #1
Hi Martin,

On 28.04.23 17:08, Martin Kaistra wrote:
 > This series intends to bring AP mode support to the rtl8xxxu driver,
 > more specifically for the 8188f, because this is the HW I have.

Awesome work, thanks a lot!

I have access to and will try getting AP mode working on the RTL8192CUS 
by filling in the gen1 implementation parts.

If someone is already working on gen1 support, please let me know. Same 
if there are know pitfalls I might encounter. :)

Kind regards,
Reto
Georg Müller July 5, 2023, 9 a.m. UTC | #2
Hi Martin,

Am 28.04.23 um 17:08 schrieb Martin Kaistra:
> This series intends to bring AP mode support to the rtl8xxxu driver,
> more specifically for the 8188f, because this is the HW I have.
> The work is based on the vendor driver as I do not have access to
> datasheets.

I tried to enable AP mode for a 8188EU device (TP-Link TL-WN725N) with
some mixed results.

I added .supports_ap = 1 and .max_macid_num = 16 to rtl8188eu_fops.

The AP was visible and I once was able to connect to it. When connected,
the link was stable, but I didn't do any benchmarks.

Most of my tries I was not able to establish a connection (looks like
timeouts) and once I got this message:

     usb 1-4: rtl8xxxu_send_beacon_frame: Failed to read beacon valid bit

The driver I am using currently is the out-of-tree driver rtl8188eu [1],
which has a stable AP mode, but has some stability issues in managed mode.

Please give me a hint if and how I may help tracking down the issue to
enable AP mode for 8188EU as well.

Best regards,
Georg

[1]
https://github.com/lwfinger/rtl8188eu/tree/v5.2.2.4
Martin Kaistra July 7, 2023, 7:23 a.m. UTC | #3
Hi Georg,

Am 05.07.23 um 11:00 schrieb Georg Müller:
> Hi Martin,
> 
> Am 28.04.23 um 17:08 schrieb Martin Kaistra:
>> This series intends to bring AP mode support to the rtl8xxxu driver,
>> more specifically for the 8188f, because this is the HW I have.
>> The work is based on the vendor driver as I do not have access to
>> datasheets.
> 
> I tried to enable AP mode for a 8188EU device (TP-Link TL-WN725N) with
> some mixed results.
> 
> I added .supports_ap = 1 and .max_macid_num = 16 to rtl8188eu_fops.

According to [1], you might be able to increase max_macid_num to 64.

> 
> The AP was visible and I once was able to connect to it. When connected,
> the link was stable, but I didn't do any benchmarks.
> 
> Most of my tries I was not able to establish a connection (looks like
> timeouts) and once I got this message:
> 
>      usb 1-4: rtl8xxxu_send_beacon_frame: Failed to read beacon valid bit
> 
> The driver I am using currently is the out-of-tree driver rtl8188eu [1],
> which has a stable AP mode, but has some stability issues in managed mode.
> 
> Please give me a hint if and how I may help tracking down the issue to
> enable AP mode for 8188EU as well.

I would suggest the following:
- in rtl8xxxu_fill_txdesc_v3, set macid, HW_SEQ like in the v2 function
- 8188e does decide on the tx rate in software, so 
rtl8188e_handle_ra_tx_report2() will probably need some adjustments to handle 
multiple macids (maybe ra_info in rtl8xxxu_priv should be an array of size 
RTL8XXXU_MAX_MAC_ID_NUM?)

For testing I use a separate machine (or at least separate wifi interface) in 
monitoring mode, which I can set to the correct channel and then see in 
wireshark, if all beacons, ACKs and other frames get sent correctly.

If you have a wireshark trace of a problematic behavior and need some help with 
determining the cause or have some further questions, let me know.

Thanks,
Martin

> 
> Best regards,
> Georg
> 
> [1]
> https://github.com/lwfinger/rtl8188eu/tree/v5.2.2.4


[1] 
https://lore.kernel.org/linux-wireless/27e83382-4c84-1841-c428-d1e5143ea20c@gmail.com/
Bitterblue Smith July 7, 2023, 5:55 p.m. UTC | #4
On 07/07/2023 10:23, Martin Kaistra wrote:
> Hi Georg,
> 
> Am 05.07.23 um 11:00 schrieb Georg Müller:
>> Hi Martin,
>>

[...]

>> Please give me a hint if and how I may help tracking down the issue to
>> enable AP mode for 8188EU as well.
> 
> I would suggest the following:
> - in rtl8xxxu_fill_txdesc_v3, set macid, HW_SEQ like in the v2 function
> - 8188e does decide on the tx rate in software, so rtl8188e_handle_ra_tx_report2() will probably need some adjustments to handle multiple macids (maybe ra_info in rtl8xxxu_priv should be an array of size RTL8XXXU_MAX_MAC_ID_NUM?)

ra_info should be an array(?), except the dynamic_tx_rpt_timing_counter
member should be moved to rtl8xxxu_priv. In the vendor driver it was
a static variable in the odm_rate_decision_8188e() function.

An array or some dynamic data structure? The array would take up at
least 3072 bytes, including when the driver is handling some other
chip which doesn't need the array.

Additionally, rtl8xxxu_sta_add() and rtl8xxxu_sta_remove() need to
increase/decrease REG_TX_REPORT_CTRL + 1, otherwise you will only get
correct rate control for the first station which connects to the AP.