]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP MLD: Handle DFS in correct link
authorChenming Huang <quic_chenhuan@quicinc.com>
Mon, 4 Sep 2023 05:30:01 +0000 (11:00 +0530)
committerJouni Malinen <j@w1.fi>
Sun, 26 Nov 2023 15:31:46 +0000 (17:31 +0200)
Link ID is needed for AP MLD to handle DFS events in the correct link.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/ap/drv_callbacks.c
src/drivers/driver.h
src/drivers/driver_nl80211_event.c

index 0e1a8502708ade95e7915ba60929e20fd9bb5a9c..b7b84cfd3e0b3c2c9b0c9235102ea7ff537eb1fd 100644 (file)
@@ -2399,26 +2399,31 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
        case EVENT_DFS_RADAR_DETECTED:
                if (!data)
                        break;
+               hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
                hostapd_event_dfs_radar_detected(hapd, &data->dfs_event);
                break;
        case EVENT_DFS_PRE_CAC_EXPIRED:
                if (!data)
                        break;
+               hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
                hostapd_event_dfs_pre_cac_expired(hapd, &data->dfs_event);
                break;
        case EVENT_DFS_CAC_FINISHED:
                if (!data)
                        break;
+               hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
                hostapd_event_dfs_cac_finished(hapd, &data->dfs_event);
                break;
        case EVENT_DFS_CAC_ABORTED:
                if (!data)
                        break;
+               hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
                hostapd_event_dfs_cac_aborted(hapd, &data->dfs_event);
                break;
        case EVENT_DFS_NOP_FINISHED:
                if (!data)
                        break;
+               hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
                hostapd_event_dfs_nop_finished(hapd, &data->dfs_event);
                break;
        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:
                if (!data)
                        break;
+               hapd = switch_link_hapd(hapd, data->dfs_event.link_id);
                hostapd_event_dfs_cac_started(hapd, &data->dfs_event);
                break;
 #endif /* NEED_AP_MLME */
index d6c490d1c859623505248d44057659e308485366..9e4df1d78842f65803706048bfc8e5c0c1b82f56 100644 (file)
@@ -6526,6 +6526,7 @@ union wpa_event_data {
        /**
         * struct dfs_event - Data for radar detected events
         * @freq: Frequency of the channel in MHz
+        * @link_id: If >= 0, Link ID of the MLO link
         */
        struct dfs_event {
                int freq;
@@ -6534,6 +6535,7 @@ union wpa_event_data {
                enum chan_width chan_width;
                int cf1;
                int cf2;
+               int link_id;
        } dfs_event;
 
        /**
index 463cf6e0ae1a2089157d0b47006358245c24d237..60b4fb51fcd8c3c707b767f85ae86175c454e821 100644 (file)
@@ -2455,14 +2455,23 @@ static void nl80211_radar_event(struct wpa_driver_nl80211_data *drv,
 {
        union wpa_event_data data;
        enum nl80211_radar_event event_type;
+       struct i802_link *mld_link = NULL;
 
        if (!tb[NL80211_ATTR_WIPHY_FREQ] || !tb[NL80211_ATTR_RADAR_EVENT])
                return;
 
        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]);
        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 */
        if (tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
                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])
                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.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) {
        case NL80211_RADAR_DETECTED:
@@ -2817,6 +2828,7 @@ static void qca_nl80211_dfs_offload_radar_event(
 {
        union wpa_event_data data;
        struct nlattr *tb[NL80211_ATTR_MAX + 1];
+       struct i802_link *mld_link = NULL;
 
        wpa_printf(MSG_DEBUG,
                   "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));
        data.dfs_event.freq = nla_get_u32(tb[NL80211_ATTR_WIPHY_FREQ]);
+       data.dfs_event.link_id = NL80211_DRV_LINK_ID_NA;
+
+       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;
+       }
 
-       wpa_printf(MSG_DEBUG, "nl80211: DFS event on freq %d MHz",
-                  data.dfs_event.freq);
+       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 */
        if (tb[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {