Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> wrote: > On 19/08/2024 05:52, Ping-Ke Shih wrote: > > A mac_id as an instance in firmware has to be assigned for each station > > including AP and connected stations. Firmware will use the mac_id to > > control TX rate and do statistics. > > > > Assignment rule is to assign mac_id to each vif when adding vif. > > For station mode, sta->mac_id will reuse vif->mac_id. For AP mode, > > dynamically allocate an sta->mac_id to a station, and vif->mac_id is > > used to send broadcast/multicast packets which are not belong to > > a station. For example, > > > > vif->mac_id sta->mac_id > > vif0 (STA mode) 0 0 > > vif1 (AP mode) 1 2... > > > > By the way, remove unused RTW_BC_MC_MACID, which was planed to send > > broadcast/multicast packets on fixed mac_id. > > > > I tested this with RTL8822CE in AP mode with a single vif. It says: > > Aug 19 21:32:47 ideapad2 kernel: rtw_8822ce 0000:02:00.0: change vif 00:45:e2:a1:65:ab (2)->(3), p2p > (0)->(0) > Aug 19 21:32:47 ideapad2 kernel: rtw_8822ce 0000:02:00.0: stop vif 00:45:e2:a1:65:ab mac_id 0 on port 0 > Aug 19 21:32:47 ideapad2 kernel: rtw_8822ce 0000:02:00.0: start vif 00:45:e2:a1:65:ab mac_id 0 on port 0 > Aug 19 21:33:54 ideapad2 kernel: rtw_8822ce 0000:02:00.0: sta b6:bd:3c:c0:39:87 joined with macid 1 > > Then I added another vif: > > # iw dev wlp2s0 interface add my_interface type managed > > Aug 19 21:36:45 ideapad2 kernel: rtw_8822ce 0000:02:00.0: start vif 3e:60:cc:0b:fa:17 mac_id 2 on port 1 > > So in this case the AP vif's rtwvif->mac_id is 0, and the first > station gets 1. The managed vif's rtwvif->mac_id is 2. Is it okay > if the numbers are not assigned like in your example? All mac_id are assigned dynamically. I think your case should be still fine. Is there any problem you met? I can change the real number to algebra vif->mac_id sta->mac_id vif0 (STA mode) n n vif1 (AP mode) m a, b, c ... Where, n, m, a, b, c, ... are all different number. The special number is only 'n' presents on two places. The limit of hardware is AP mode should work on port 0, so you can find the condition to switch port in rtw_core_port_switch(): if (vif->type != NL80211_IFTYPE_AP || rtwvif->port == RTW_PORT_0) return; Ping-Ke