[PATCH v3 5/5] bss coloring: handle the collision and CCA events coming from the kernel

Lorenzo Bianconi lorenzo at kernel.org
Mon Mar 21 04:10:34 PDT 2022


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.

Tested-by: Peter Chiu <chui-hao.chiu at mediatek.com>
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             | 44 ++++++++++++++++++++++
 src/drivers/driver.h               | 27 ++++++++++++++
 src/drivers/driver_common.c        |  4 ++
 src/drivers/driver_nl80211_event.c | 59 ++++++++++++++++++++++++++++++
 4 files changed, 134 insertions(+)

diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index d97b3535b..93425bb31 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -1777,6 +1777,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 /* CONFIG_IEEE80211AX */
+
+
 #ifdef CONFIG_OWE
 static int hostapd_notif_update_dh_ie(struct hostapd_data *hapd,
 				      const u8 *peer, const u8 *ie,
@@ -2083,6 +2116,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 /* CONFIG_IEEE80211AX */
 	default:
 		wpa_printf(MSG_DEBUG, "Unknown event %d", event);
 		break;
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index 71c10715f..4ece0f8c5 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -5178,6 +5178,26 @@ enum wpa_event_type {
 	 * non-zero wait time and that has not been explicitly cancelled.
 	 */
 	EVENT_TX_WAIT_EXPIRE,
+
+	/**
+	  * 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,
 };
 
 
@@ -6070,6 +6090,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 741521c67..8db786168 100644
--- a/src/drivers/driver_common.c
+++ b/src/drivers/driver_common.c
@@ -91,6 +91,10 @@ const char * event_to_string(enum wpa_event_type event)
 	E2S(UPDATE_DH);
 	E2S(UNPROT_BEACON);
 	E2S(TX_WAIT_EXPIRE);
+	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 085acb85a..fcabcc835 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -2910,6 +2910,51 @@ static void nl80211_assoc_comeback(struct wpa_driver_nl80211_data *drv,
 		   MAC2STR((u8 *) nla_data(mac)), nla_get_u32(timeout));
 }
 
+#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 /* CONFIG_IEEE80211AX */
 
 static void do_process_drv_event(struct i802_bss *bss, int cmd,
 				 struct nlattr **tb)
@@ -3164,6 +3209,20 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
 		nl80211_assoc_comeback(drv, tb[NL80211_ATTR_MAC],
 				       tb[NL80211_ATTR_TIMEOUT]);
 		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 /* CONFIG_IEEE80211AX */
 	default:
 		wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: Ignored unknown event "
 			"(cmd=%d)", cmd);
-- 
2.35.1




More information about the Hostap mailing list