[PATCH 5/6] bss coloring: handle the collision and CCA events coming from the kernel
Ryder Lee
ryder.lee at mediatek.com
Wed Sep 8 02:18:54 PDT 2021
From: John Crispin <john at phrozen.org>
This patch activates the functionality of the previous patches by handling
the actual events that will trigger the CCA process.
Co-developed-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: Lorenzo Bianconi <lorenzo at kernel.org>
Signed-off-by: John Crispin <john at phrozen.org>
Signed-off-by: Ryder Lee <ryder.lee at mediatek.com>
---
src/ap/drv_callbacks.c | 45 ++++++++++++++++++++-
src/drivers/driver.h | 27 +++++++++++++
src/drivers/driver_common.c | 4 ++
src/drivers/driver_nl80211_event.c | 64 ++++++++++++++++++++++++++++++
4 files changed, 139 insertions(+), 1 deletion(-)
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index ec5abf166..f6e61787c 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -43,7 +43,6 @@
#include "fils_hlp.h"
#include "neighbor_db.h"
-
#ifdef CONFIG_FILS
void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd,
struct sta_info *sta)
@@ -1769,6 +1768,39 @@ static void hostapd_event_wds_sta_interface_status(struct hostapd_data *hapd,
}
+#ifdef CONFIG_IEEE80211AX
+static void hostapd_event_bss_color_collision(struct hostapd_data *hapd,
+ u64 bitmap)
+{
+ /* the bss color is shared amongst all BBSs on a specific phy.
+ * therefore we always start the color change on the primary BSS
+ */
+ wpa_printf(MSG_DEBUG, "BSS color collision on %s", hapd->conf->iface);
+ hostapd_switch_color(hapd->iface->bss[0], bitmap);
+}
+
+static void hostapd_event_cca(struct hostapd_data *hapd, enum wpa_event_type event)
+{
+ switch (event) {
+ case EVENT_CCA_STARTED_NOTIFY:
+ wpa_printf(MSG_DEBUG, "CCA started on on %s", hapd->conf->iface);
+ break;
+ case EVENT_CCA_NOTIFY:
+ wpa_printf(MSG_DEBUG, "CCA finished on on %s", hapd->conf->iface);
+ hapd->iface->conf->he_op.he_bss_color = hapd->cca_color;
+ hostapd_cleanup_cca_params(hapd);
+ break;
+ case EVENT_CCA_ABORTED_NOTIFY:
+ wpa_printf(MSG_DEBUG, "CCA aborted on on %s", hapd->conf->iface);
+ hostapd_cleanup_cca_params(hapd);
+ break;
+ default:
+ break;
+ }
+}
+#endif
+
+
#ifdef CONFIG_OWE
static int hostapd_notif_update_dh_ie(struct hostapd_data *hapd,
const u8 *peer, const u8 *ie,
@@ -2075,6 +2107,17 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event,
data->wds_sta_interface.ifname,
data->wds_sta_interface.sta_addr);
break;
+#ifdef CONFIG_IEEE80211AX
+ case EVENT_BSS_COLOR_COLLISION:
+ hostapd_event_bss_color_collision(hapd,
+ data->bss_color_collision.bitmap);
+ break;
+ case EVENT_CCA_STARTED_NOTIFY:
+ case EVENT_CCA_ABORTED_NOTIFY:
+ case EVENT_CCA_NOTIFY:
+ hostapd_event_cca(hapd, event);
+ break;
+#endif
default:
wpa_printf(MSG_DEBUG, "Unknown event %d", event);
break;
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index f762ccccc..cc327fc5a 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -5158,6 +5158,26 @@ enum wpa_event_type {
* is required to provide more details of the frame.
*/
EVENT_UNPROT_BEACON,
+
+ /**
+ * EVENT_BSS_COLOR_COLLISION - Notification of a BSS color collision
+ */
+ EVENT_BSS_COLOR_COLLISION,
+
+ /**
+ * EVENT_CCA_STARTED_NOTIFY - Notification that CCA has started
+ */
+ EVENT_CCA_STARTED_NOTIFY,
+
+ /**
+ * EVENT_CCA_ABORTED_NOTIFY - Notification that CCA has aborted
+ */
+ EVENT_CCA_ABORTED_NOTIFY,
+
+ /**
+ * EVENT_CCA_NOTIFY - Notification that CCA has completed
+ */
+ EVENT_CCA_NOTIFY,
};
@@ -6050,6 +6070,13 @@ union wpa_event_data {
struct unprot_beacon {
const u8 *sa;
} unprot_beacon;
+
+ /**
+ * struct bss_color_collision - Data for EVENT_BSS_COLOR_COLLISION
+ */
+ struct bss_color_collision {
+ u64 bitmap;
+ } bss_color_collision;
};
/**
diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c
index 1cb976011..551851f52 100644
--- a/src/drivers/driver_common.c
+++ b/src/drivers/driver_common.c
@@ -90,6 +90,10 @@ const char * event_to_string(enum wpa_event_type event)
E2S(WDS_STA_INTERFACE_STATUS);
E2S(UPDATE_DH);
E2S(UNPROT_BEACON);
+ E2S(BSS_COLOR_COLLISION);
+ E2S(CCA_STARTED_NOTIFY);
+ E2S(CCA_ABORTED_NOTIFY);
+ E2S(CCA_NOTIFY);
}
return "UNKNOWN";
diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
index 0f0a01d01..8beaa0a77 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -172,6 +172,11 @@ static const char * nl80211_command_to_string(enum nl80211_commands cmd)
C2S(NL80211_CMD_UNPROT_BEACON)
C2S(NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS)
C2S(NL80211_CMD_SET_SAR_SPECS)
+ C2S(NL80211_CMD_OBSS_COLOR_COLLISION)
+ C2S(NL80211_CMD_COLOR_CHANGE_REQUEST)
+ C2S(NL80211_CMD_COLOR_CHANGE_STARTED)
+ C2S(NL80211_CMD_COLOR_CHANGE_ABORTED)
+ C2S(NL80211_CMD_COLOR_CHANGE_COMPLETED)
C2S(__NL80211_CMD_AFTER_LAST)
}
#undef C2S
@@ -2854,6 +2859,51 @@ nl80211_control_port_frame_tx_status(struct wpa_driver_nl80211_data *drv,
wpa_supplicant_event(drv->ctx, EVENT_EAPOL_TX_STATUS, &event);
}
+#ifdef CONFIG_IEEE80211AX
+static void mlme_event_obss_color_collision(struct wpa_driver_nl80211_data *drv,
+ struct nlattr *tb[])
+{
+ union wpa_event_data data;
+
+ if (!tb[NL80211_ATTR_OBSS_COLOR_BITMAP])
+ return;
+
+ os_memset(&data, 0, sizeof(data));
+ data.bss_color_collision.bitmap = nla_get_u64(tb[NL80211_ATTR_OBSS_COLOR_BITMAP]);
+
+ wpa_printf(MSG_DEBUG, "nl80211: BSS color collision - bitmap %08lx",
+ data.bss_color_collision.bitmap);
+
+ wpa_supplicant_event(drv->ctx, EVENT_BSS_COLOR_COLLISION, &data);
+}
+
+static void mlme_event_color_change_announcement_started(struct wpa_driver_nl80211_data *drv)
+{
+ union wpa_event_data data = {};
+
+ wpa_printf(MSG_DEBUG, "nl80211: CCA started");
+
+ wpa_supplicant_event(drv->ctx, EVENT_CCA_STARTED_NOTIFY, &data);
+}
+
+static void mlme_event_color_change_announcement_aborted(struct wpa_driver_nl80211_data *drv)
+{
+ union wpa_event_data data = {};
+
+ wpa_printf(MSG_DEBUG, "nl80211: CCA aborted");
+
+ wpa_supplicant_event(drv->ctx, EVENT_CCA_ABORTED_NOTIFY, &data);
+}
+
+static void mlme_event_color_change_announcement_completed(struct wpa_driver_nl80211_data *drv)
+{
+ union wpa_event_data data = {};
+
+ wpa_printf(MSG_DEBUG, "nl80211: CCA completed");
+
+ wpa_supplicant_event(drv->ctx, EVENT_CCA_NOTIFY, &data);
+}
+#endif
static void do_process_drv_event(struct i802_bss *bss, int cmd,
struct nlattr **tb)
@@ -3101,6 +3151,20 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
tb[NL80211_ATTR_ACK],
tb[NL80211_ATTR_COOKIE]);
break;
+#ifdef CONFIG_IEEE80211AX
+ case NL80211_CMD_OBSS_COLOR_COLLISION:
+ mlme_event_obss_color_collision(drv, tb);
+ break;
+ case NL80211_CMD_COLOR_CHANGE_STARTED:
+ mlme_event_color_change_announcement_started(drv);
+ break;
+ case NL80211_CMD_COLOR_CHANGE_ABORTED:
+ mlme_event_color_change_announcement_aborted(drv);
+ break;
+ case NL80211_CMD_COLOR_CHANGE_COMPLETED:
+ mlme_event_color_change_announcement_completed(drv);
+ break;
+#endif
default:
wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: Ignored unknown event "
"(cmd=%d)", cmd);
--
2.29.2
More information about the Hostap
mailing list