AP MLD: Handle DFS in correct link

Link ID is needed for AP MLD to handle DFS events in the correct link.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Chenming Huang 2023-09-04 11:00:01 +05:30 committed by Jouni Malinen
parent f1fee0d1ff
commit d54d0d8983
3 changed files with 32 additions and 4 deletions

View file

@ -2399,26 +2399,31 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
case EVENT_DFS_RADAR_DETECTED: case EVENT_DFS_RADAR_DETECTED:
if (!data) if (!data)
break; break;
hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
hostapd_event_dfs_radar_detected(hapd, &data->dfs_event); hostapd_event_dfs_radar_detected(hapd, &data->dfs_event);
break; break;
case EVENT_DFS_PRE_CAC_EXPIRED: case EVENT_DFS_PRE_CAC_EXPIRED:
if (!data) if (!data)
break; break;
hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
hostapd_event_dfs_pre_cac_expired(hapd, &data->dfs_event); hostapd_event_dfs_pre_cac_expired(hapd, &data->dfs_event);
break; break;
case EVENT_DFS_CAC_FINISHED: case EVENT_DFS_CAC_FINISHED:
if (!data) if (!data)
break; break;
hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
hostapd_event_dfs_cac_finished(hapd, &data->dfs_event); hostapd_event_dfs_cac_finished(hapd, &data->dfs_event);
break; break;
case EVENT_DFS_CAC_ABORTED: case EVENT_DFS_CAC_ABORTED:
if (!data) if (!data)
break; break;
hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
hostapd_event_dfs_cac_aborted(hapd, &data->dfs_event); hostapd_event_dfs_cac_aborted(hapd, &data->dfs_event);
break; break;
case EVENT_DFS_NOP_FINISHED: case EVENT_DFS_NOP_FINISHED:
if (!data) if (!data)
break; break;
hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
hostapd_event_dfs_nop_finished(hapd, &data->dfs_event); hostapd_event_dfs_nop_finished(hapd, &data->dfs_event);
break; break;
case EVENT_CHANNEL_LIST_CHANGED: case EVENT_CHANNEL_LIST_CHANGED:
@ -2432,6 +2437,7 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
case EVENT_DFS_CAC_STARTED: case EVENT_DFS_CAC_STARTED:
if (!data) if (!data)
break; break;
hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
hostapd_event_dfs_cac_started(hapd, &data->dfs_event); hostapd_event_dfs_cac_started(hapd, &data->dfs_event);
break; break;
#endif /* NEED_AP_MLME */ #endif /* NEED_AP_MLME */

View file

@ -6526,6 +6526,7 @@ union wpa_event_data {
/** /**
* struct dfs_event - Data for radar detected events * struct dfs_event - Data for radar detected events
* @freq: Frequency of the channel in MHz * @freq: Frequency of the channel in MHz
* @link_id: If >= 0, Link ID of the MLO link
*/ */
struct dfs_event { struct dfs_event {
int freq; int freq;
@ -6534,6 +6535,7 @@ union wpa_event_data {
enum chan_width chan_width; enum chan_width chan_width;
int cf1; int cf1;
int cf2; int cf2;
int link_id;
} dfs_event; } dfs_event;
/** /**

View file

@ -2455,14 +2455,23 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
{ {
union wpa_event_data data; union wpa_event_data data;
enum nl80211_radar_event event_type; enum nl80211_radar_event event_type;
struct i802_link *mld_link = NULL;
if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT]) if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT])
return; return;
os_memset(&data, 0, sizeof(data)); os_memset(&data, 0, sizeof(data));
data.dfs_event.link_id = NL80211_DRV_LINK_ID_NA;
data.dfs_event.freq = nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]); data.dfs_event.freq = nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]);
event_type = nla_get_u32(tb[NL80211_ATTR_RADAR_EVENT]); event_type = nla_get_u32(tb[NL80211_ATTR_RADAR_EVENT]);
if (data.dfs_event.freq) {
mld_link = nl80211_get_mld_link_by_freq(drv->first_bss,
data.dfs_event.freq);
if (mld_link)
data.dfs_event.link_id = mld_link->link_id;
}
/* Check HT params */ /* Check HT params */
if (tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { if (tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
data.dfs_event.ht_enabled = 1; data.dfs_event.ht_enabled = 1;
@ -2493,10 +2502,12 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
if (tb[NL80211_ATTR_CENTER_FREQ2]) if (tb[NL80211_ATTR_CENTER_FREQ2])
data.dfs_event.cf2 = nla_get_u32(tb[NL80211_ATTR_CENTER_FREQ2]); data.dfs_event.cf2 = nla_get_u32(tb[NL80211_ATTR_CENTER_FREQ2]);
wpa_printf(MSG_DEBUG, "nl80211: DFS event on freq %d MHz, ht: %d, offset: %d, width: %d, cf1: %dMHz, cf2: %dMHz", wpa_printf(MSG_DEBUG,
"nl80211: DFS event on freq %d MHz, ht: %d, offset: %d, width: %d, cf1: %dMHz, cf2: %dMHz, link_id=%d",
data.dfs_event.freq, data.dfs_event.ht_enabled, data.dfs_event.freq, data.dfs_event.ht_enabled,
data.dfs_event.chan_offset, data.dfs_event.chan_width, data.dfs_event.chan_offset, data.dfs_event.chan_width,
data.dfs_event.cf1, data.dfs_event.cf2); data.dfs_event.cf1, data.dfs_event.cf2,
data.dfs_event.link_id);
switch (event_type) { switch (event_type) {
case NL80211_RADAR_DETECTED: case NL80211_RADAR_DETECTED:
@ -2817,6 +2828,7 @@ static void qca_nl80211_dfs_offload_radar_event(
{ {
union wpa_event_data data; union wpa_event_data data;
struct nlattr *tb[NL80211_ATTR_MAX + 1]; struct nlattr *tb[NL80211_ATTR_MAX + 1];
struct i802_link *mld_link = NULL;
wpa_printf(MSG_DEBUG, wpa_printf(MSG_DEBUG,
"nl80211: DFS offload radar vendor event received"); "nl80211: DFS offload radar vendor event received");
@ -2833,9 +2845,17 @@ static void qca_nl80211_dfs_offload_radar_event(
os_memset(&data, 0, sizeof(data)); os_memset(&data, 0, sizeof(data));
data.dfs_event.freq = nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]); data.dfs_event.freq = nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]);
data.dfs_event.link_id = NL80211_DRV_LINK_ID_NA;
wpa_printf(MSG_DEBUG, "nl80211: DFS event on freq %d MHz", if (data.dfs_event.freq) {
mld_link = nl80211_get_mld_link_by_freq(drv->first_bss,
data.dfs_event.freq); data.dfs_event.freq);
if (mld_link)
data.dfs_event.link_id = mld_link->link_id;
}
wpa_printf(MSG_DEBUG, "nl80211: DFS event on freq %d MHz, link=%d",
data.dfs_event.freq, data.dfs_event.link_id);
/* Check HT params */ /* Check HT params */
if (tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { if (tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {