From patchwork Wed Sep 8 09:18:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 1525703 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jCW6h6GC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4Gtx74n7z9sR4 for ; Wed, 8 Sep 2021 19:24:57 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=rX+sGfA9w2pGZHQqF9TLRO15H1L0kWObcbkpBYCTA+A=; b=jCW6h6GCNZvA4y QeEbP81dAV8cyCeOPPaLgrkdo+mjtR7XVNoDMFQW48czu/Tfd6In3koa/6vouLj0S/vFeJVSL8YYt vMkUVulBTuWdUvYycKminrllV9tF3xnnAoRGFc+TbCyhWuHZ3uhe7dvf4Vq91IiUw2Vt9S1cHirHY EjNNYeS2R3RklokYBKUltTD61MYjv23ppHCSJzNPxgiRoEo6VDgKbgUqh74+Nm+qQlwXAeuHi+Zo4 qYlif457iYMC5VXKsDeJzOJARp3p79JZkEolm+ZD3P7JOBrZyTYTtZilZ/tXcM1xUQ4dQbjaseihY 7AcHYxNFbfByvOmtNLzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnl-006Hhk-OK; Wed, 08 Sep 2021 09:23:29 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnC-006HXd-Dj for hostap@lists.infradead.org; Wed, 08 Sep 2021 09:22:56 +0000 X-UUID: 2306fe6bd90242e0923757890a311911-20210908 X-UUID: 2306fe6bd90242e0923757890a311911-20210908 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 139276167; Wed, 08 Sep 2021 02:22:47 -0700 Received: from MTKMBS06N1.mediatek.inc (172.21.101.129) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 02:19:49 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 17:19:48 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 8 Sep 2021 17:19:48 +0800 From: Ryder Lee To: Jouni Malinen CC: Felix Fietkau , Lorenzo Bianconi , Shayne Chen , "Evelyn Tsai" , , John Crispin , Lorenzo Bianconi , Ryder Lee Subject: [PATCH 1/6] bss coloring: add support for handling collision events and triggering CCA Date: Wed, 8 Sep 2021 17:18:50 +0800 Message-ID: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_022254_548409_996E0DB0 X-CRM114-Status: GOOD ( 23.06 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: John Crispin Add the core code for handling bss color collision events and triggering CCA inside the kernel. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: John Crispin Add the core code for handling bss color collision events and triggering CCA inside the kernel. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee --- src/ap/ap_drv_ops.h | 12 ++++ src/ap/hostapd.c | 119 +++++++++++++++++++++++++++++++++++ src/ap/hostapd.h | 16 +++++ src/common/ieee802_11_defs.h | 6 ++ src/drivers/driver.h | 31 +++++++++ 5 files changed, 184 insertions(+) diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index 61c8f64eb..003f0daf7 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -299,6 +299,18 @@ static inline int hostapd_drv_switch_channel(struct hostapd_data *hapd, return hapd->driver->switch_channel(hapd->drv_priv, settings); } +#ifdef CONFIG_IEEE80211AX +static inline int hostapd_drv_switch_color(struct hostapd_data *hapd, + struct cca_settings *settings) +{ + if (hapd->driver == NULL || hapd->driver->switch_color == NULL || + hapd->drv_priv == NULL) + return -1; + + return hapd->driver->switch_color(hapd->drv_priv, settings); +} +#endif + static inline int hostapd_drv_status(struct hostapd_data *hapd, char *buf, size_t buflen) { diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 913a8e29e..57f3772e6 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -66,6 +66,8 @@ static int setup_interface2(struct hostapd_iface *iface); static void channel_list_update_timeout(void *eloop_ctx, void *timeout_ctx); static void hostapd_interface_setup_failure_handler(void *eloop_ctx, void *timeout_ctx); +static void +hostapd_switch_color_timeout_handler(void *eloop_data, void *user_ctx); int hostapd_for_each_interface(struct hapd_interfaces *interfaces, @@ -462,6 +464,9 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd) } eloop_cancel_timeout(auth_sae_process_commit, hapd, NULL); #endif /* CONFIG_SAE */ +#ifdef CONFIG_IEEE80211AX + eloop_cancel_timeout(hostapd_switch_color_timeout_handler, hapd, NULL); +#endif } @@ -3691,6 +3696,120 @@ hostapd_switch_channel_fallback(struct hostapd_iface *iface, hostapd_enable_iface(iface); } + +#ifdef CONFIG_IEEE80211AX +void hostapd_cleanup_cca_params(struct hostapd_data *hapd) +{ + hapd->cca_count = 0; + hapd->cca_color = 0; + hapd->cca_c_off_beacon = 0; + hapd->cca_c_off_proberesp = 0; + hapd->cca_in_progress = 0; +} + + +static int hostapd_fill_cca_settings(struct hostapd_data *hapd, + struct cca_settings *settings) +{ + struct hostapd_iface *iface = hapd->iface; + u8 old_color; + int ret; + + if (!iface || iface->conf->he_op.he_bss_color_disabled) + return -1; + + old_color = iface->conf->he_op.he_bss_color; + iface->conf->he_op.he_bss_color = hapd->cca_color; + ret = hostapd_build_beacon_data(hapd, &settings->beacon_after); + iface->conf->he_op.he_bss_color = old_color; + + settings->cca_count = hapd->cca_count; + settings->cca_color = hapd->cca_color, + hapd->cca_in_progress = 1; + + ret = hostapd_build_beacon_data(hapd, &settings->beacon_cca); + if (ret) { + free_beacon_data(&settings->beacon_after); + return ret; + } + + settings->counter_offset_beacon = hapd->cca_c_off_beacon; + settings->counter_offset_presp = hapd->cca_c_off_proberesp; + + return 0; +} + + +static void +hostapd_switch_color_timeout_handler(void *eloop_data, void *user_ctx) +{ + struct hostapd_data *hapd = (struct hostapd_data *) eloop_data; + struct cca_settings settings; + struct os_time now; + int i, r, b, ret; + + if (os_get_time(&now)) + return; + + /* check if there has been a recent collision */ + if (now.sec - hapd->last_color_collision.sec >= 10) + return; + + r = os_random() % HE_OPERATION_BSS_COLOR_MAX; + for (i = 0; i < HE_OPERATION_BSS_COLOR_MAX; i++) { + if (r && (hapd->color_collision_bitmap & (1 << r)) == 0) + break; + r = (r + 1) % HE_OPERATION_BSS_COLOR_MAX; + } + if (i == HE_OPERATION_BSS_COLOR_MAX) { + /* there are no free colors so turn bss coloring off */ + wpa_printf(MSG_INFO, "no free colors left, turning of BSS coloring"); + hapd->iface->conf->he_op.he_bss_color_disabled = 1; + hapd->iface->conf->he_op.he_bss_color = 1; + for (b = 0; b < hapd->iface->num_bss; b++) + ieee802_11_set_beacon(hapd->iface->bss[b]); + return; + } + + for (b = 0; b < hapd->iface->num_bss; b++) { + struct hostapd_data *bss = hapd->iface->bss[b]; + + hostapd_cleanup_cca_params(bss); + bss->cca_color = r; + bss->cca_count = 10; + + if (hostapd_fill_cca_settings(bss, &settings)) { + hostapd_cleanup_cca_params(bss); + continue; + } + + ret = hostapd_drv_switch_color(bss, &settings); + free_beacon_data(&settings.beacon_cca); + free_beacon_data(&settings.beacon_after); + + if (ret) + hostapd_cleanup_cca_params(bss); + } +} + + +void +hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap) +{ + if (hapd->cca_in_progress) + return; + + if (os_get_time(&hapd->last_color_collision)) + return; + + hapd->color_collision_bitmap = bitmap; + + if (!eloop_is_timeout_registered(hostapd_switch_color_timeout_handler, hapd, NULL)) + eloop_register_timeout(DOT11BSS_COLOR_COLLISION_AP_PERIOD, 0, + hostapd_switch_color_timeout_handler, hapd, NULL); +} +#endif + #endif /* NEED_AP_MLME */ diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 07d0aaa92..330b769ae 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -292,6 +292,16 @@ struct hostapd_data { unsigned int cs_c_off_ecsa_beacon; unsigned int cs_c_off_ecsa_proberesp; +#ifdef CONFIG_IEEE80211AX + int cca_in_progress; + u8 cca_count; + u8 cca_color; + unsigned int cca_c_off_beacon; + unsigned int cca_c_off_proberesp; + struct os_time last_color_collision; + u64 color_collision_bitmap; +#endif + #ifdef CONFIG_P2P struct p2p_data *p2p; struct p2p_group *p2p_group; @@ -645,6 +655,12 @@ void hostapd_periodic_iface(struct hostapd_iface *iface); int hostapd_owe_trans_get_info(struct hostapd_data *hapd); void hostapd_ocv_check_csa_sa_query(void *eloop_ctx, void *timeout_ctx); + +#ifdef CONFIG_IEEE80211AX +void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap); +void hostapd_cleanup_cca_params(struct hostapd_data *hapd); +#endif + /* utils.c */ int hostapd_register_probereq_cb(struct hostapd_data *hapd, int (*cb)(void *ctx, const u8 *sa, diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index 2ed2d37b0..73d2dad03 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -2301,6 +2301,7 @@ struct ieee80211_spatial_reuse { #define HE_OPERATION_BSS_COLOR_PARTIAL ((u32) BIT(30)) #define HE_OPERATION_BSS_COLOR_DISABLED ((u32) BIT(31)) #define HE_OPERATION_BSS_COLOR_OFFSET 24 +#define HE_OPERATION_BSS_COLOR_MAX 64 /* Spatial Reuse defines */ #define SPATIAL_REUSE_SRP_DISALLOWED BIT(0) @@ -2446,4 +2447,9 @@ enum mscs_description_subelem { */ #define FD_MAX_INTERVAL_6GHZ 20 /* TUs */ +/* IEEE802.11/D6.0 - 26.17.3.5.1 + * the minimum default timeout between color collision and color change is defined as 50s + */ +#define DOT11BSS_COLOR_COLLISION_AP_PERIOD 50 + #endif /* IEEE802_11_DEFS_H */ diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 2020184c5..f762ccccc 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2395,6 +2395,26 @@ struct csa_settings { u16 counter_offset_presp[2]; }; +/** + * struct cca_settings - Settings for color switch command + * @cca_count: Count in Beacon frames (TBTT) to perform the switch + * @cca_color: The new color that we are switching to + * @beacon_cca: Beacon/probe resp/asooc resp info for color switch period + * @beacon_after: Next beacon/probe resp/asooc resp info + * @counter_offset_beacon: Offset to the count field in beacon's tail + * @counter_offset_presp: Offset to the count field in probe resp. + */ +struct cca_settings { + u8 cca_count; + u8 cca_color; + + struct beacon_data beacon_cca; + struct beacon_data beacon_after; + + u16 counter_offset_beacon; + u16 counter_offset_presp; +}; + /* TDLS peer capabilities for send_tdls_mgmt() */ enum tdls_peer_capability { TDLS_PEER_HT = BIT(0), @@ -3977,6 +3997,17 @@ struct wpa_driver_ops { */ int (*switch_channel)(void *priv, struct csa_settings *settings); + /** + * switch_color - Announce color switch and migrate the BSS to the + * given color + * @priv: Private driver interface data + * @settings: Settings for CCA period and new color + * Returns: 0 on success, -1 on failure + * + * This function is used to move the BSS to its new color. + */ + int (*switch_color)(void *priv, struct cca_settings *settings); + /** * add_tx_ts - Add traffic stream * @priv: Private driver interface data From patchwork Wed Sep 8 09:18:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 1525698 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=hNqXNWA1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4GrF4gDdz9sR4 for ; Wed, 8 Sep 2021 19:22:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qAwEvtPAaIjbCBD31awNl3sHQcJJoSs/7JATBSry/rM=; b=hNqXNWA1CjlqTV nUTafqZq5rS1cM99fCsBha7PQADt3snKux0Z/O05z1uebTOjhVwT0nDctAdagerpu2+2rcXHwCL2r VYqKUD9cQcxVm56s86X3AzazbNk9e+ud8QLKa7xEnF/t4/0TKy5BybVwRZUC3nYm3eoC+c6/IPSv/ IJ97PeGd+Y0MMUuWUgA/q27ndo+//qcN1r9dQvnUrGj36Hf7z0djq7n9riFO676roAx8nnpcENWig S6YDQsYc48ZLOlRaQ9y+rvzfdsCxo/jiDmjIGPZnialIgUJNE1g20zXLuiWLT+UgzojNEURmrAnNA j1J3C9NA+8d5usocmmlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtlt-006HKy-9B; Wed, 08 Sep 2021 09:21:33 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtlo-006HJR-CO for hostap@lists.infradead.org; Wed, 08 Sep 2021 09:21:31 +0000 X-UUID: c99a5670235a4cef92fc87d6f1793e2f-20210908 X-UUID: c99a5670235a4cef92fc87d6f1793e2f-20210908 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1626727357; Wed, 08 Sep 2021 02:21:23 -0700 Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 02:19:52 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 17:19:50 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 8 Sep 2021 17:19:50 +0800 From: Ryder Lee To: Jouni Malinen CC: Felix Fietkau , Lorenzo Bianconi , Shayne Chen , "Evelyn Tsai" , , John Crispin , Lorenzo Bianconi , Ryder Lee Subject: [PATCH 2/6] bss_coloring: add the code required to generate the CCA IE Date: Wed, 8 Sep 2021 17:18:51 +0800 Message-ID: <68581fa847cf51a25d9df106dee373d66e7628be.1631091272.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_022128_468893_27CA9A7C X-CRM114-Status: GOOD ( 13.31 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: John Crispin This IE is similar to the CSA one. It contains a counter and the target color. Once the counter expired, the change to the new color happens. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: John Crispin This IE is similar to the CSA one. It contains a counter and the target color. Once the counter expired, the change to the new color happens. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee --- src/ap/beacon.c | 12 ++++++++++++ src/ap/ieee802_11.h | 1 + src/ap/ieee802_11_he.c | 13 +++++++++++++ src/common/ieee802_11_defs.h | 1 + 4 files changed, 27 insertions(+) diff --git a/src/ap/beacon.c b/src/ap/beacon.c index 15fc2b3db..76c029823 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -578,11 +578,17 @@ static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd, #ifdef CONFIG_IEEE80211AX if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { + u8 *cca_pos; + pos = hostapd_eid_he_capab(hapd, pos, IEEE80211_MODE_AP); pos = hostapd_eid_he_operation(hapd, pos); pos = hostapd_eid_spatial_reuse(hapd, pos); pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos); pos = hostapd_eid_he_6ghz_band_cap(hapd, pos); + cca_pos = hostapd_eid_cca(hapd, pos); + if (cca_pos != pos) + hapd->cca_c_off_proberesp = cca_pos - (u8 *) resp - 2; + pos = cca_pos; } #endif /* CONFIG_IEEE80211AX */ @@ -1567,12 +1573,18 @@ int ieee802_11_build_ap_params(struct hostapd_data *hapd, #ifdef CONFIG_IEEE80211AX if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { + u8 *cca_pos; + tailpos = hostapd_eid_he_capab(hapd, tailpos, IEEE80211_MODE_AP); tailpos = hostapd_eid_he_operation(hapd, tailpos); tailpos = hostapd_eid_spatial_reuse(hapd, tailpos); tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd, tailpos); tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos); + cca_pos = hostapd_eid_cca(hapd, tailpos); + if (cca_pos != tailpos) + hapd->cca_c_off_beacon = cca_pos - tail - 2; + tailpos = cca_pos; } #endif /* CONFIG_IEEE80211AX */ diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h index ea8c60846..65308ff34 100644 --- a/src/ap/ieee802_11.h +++ b/src/ap/ieee802_11.h @@ -100,6 +100,7 @@ u16 copy_sta_he_6ghz_capab(struct hostapd_data *hapd, struct sta_info *sta, const u8 *he_6ghz_capab); int hostapd_get_he_twt_responder(struct hostapd_data *hapd, enum ieee80211_op_mode mode); +u8 * hostapd_eid_cca(struct hostapd_data *hapd, u8 *eid); void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr, const u8 *buf, size_t len, int ack); void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst, diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c index 6cd6c90dc..756ca3804 100644 --- a/src/ap/ieee802_11_he.c +++ b/src/ap/ieee802_11_he.c @@ -520,3 +520,16 @@ int hostapd_get_he_twt_responder(struct hostapd_data *hapd, return !!(mac_cap[HE_MAC_CAPAB_0] & HE_MACCAP_TWT_RESPONDER) && hapd->iface->conf->he_op.he_twt_responder; } + +u8 * hostapd_eid_cca(struct hostapd_data *hapd, u8 *eid) +{ + if (!hapd->cca_in_progress) + return eid; + *eid++ = WLAN_EID_EXTENSION; + *eid++ = 3; + *eid++ = WLAN_EID_EXT_COLOR_CHANGE_ANNOUNCEMENT; + *eid++ = hapd->cca_count; + *eid++ = hapd->cca_color; + + return eid; +} diff --git a/src/common/ieee802_11_defs.h b/src/common/ieee802_11_defs.h index 73d2dad03..9b39cb387 100644 --- a/src/common/ieee802_11_defs.h +++ b/src/common/ieee802_11_defs.h @@ -479,6 +479,7 @@ #define WLAN_EID_EXT_HE_OPERATION 36 #define WLAN_EID_EXT_HE_MU_EDCA_PARAMS 38 #define WLAN_EID_EXT_SPATIAL_REUSE 39 +#define WLAN_EID_EXT_COLOR_CHANGE_ANNOUNCEMENT 42 #define WLAN_EID_EXT_OCV_OCI 54 #define WLAN_EID_EXT_SHORT_SSID_LIST 58 #define WLAN_EID_EXT_HE_6GHZ_BAND_CAP 59 From patchwork Wed Sep 8 09:18:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 1525702 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=S3vaYFjL; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4Gtd6dYlz9sR4 for ; Wed, 8 Sep 2021 19:24:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uenFguKh403F56xYq5evru+tZZn+qonC8w5WCZL6AEQ=; b=S3vaYFjLViwCWx ZUDoPJR0U6IQ1Do8Ni95sjVF4LtBh6zDLUxhQpgq0JkP0/CB6XLpPLkpd0v4i4/e4f/7bqxIVuHD1 b3kNqRhC1pwETSrnsEn+n9jdE/yxVQYlvRJW0OICihOK5BL5Vs6zRjzeHNZUK4HFaQEPwF2tWpB2Q +jpINLteopRUz5aszMM5k1qdMhVetgv0S2A6LDjQU+0otYJLkozSQL51ZYWXVmXnLGQIIFy3Ro49v YFcplrInc8+a0IgcQjgH3A5/uZIkpMMixiNJX20FFjlPo/6QU9UT7cLOhFTJJ64R7jj6Gf82eF9Dw ISam4g6Wskrvse7/hHaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnX-006He5-Gu; Wed, 08 Sep 2021 09:23:15 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnC-006HXm-FH for hostap@lists.infradead.org; Wed, 08 Sep 2021 09:22:55 +0000 X-UUID: b0f2075f845e42a9a7f7c06ecb8fe4fd-20210908 X-UUID: b0f2075f845e42a9a7f7c06ecb8fe4fd-20210908 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1713387175; Wed, 08 Sep 2021 02:22:47 -0700 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 02:19:55 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 17:19:51 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 8 Sep 2021 17:19:51 +0800 From: Ryder Lee To: Jouni Malinen CC: Felix Fietkau , Lorenzo Bianconi , Shayne Chen , "Evelyn Tsai" , , John Crispin , Lorenzo Bianconi , Ryder Lee Subject: [PATCH 3/6] bss coloring: disable BSS color during CCA Date: Wed, 8 Sep 2021 17:18:52 +0800 Message-ID: <13ec05e4c1607e53d8fbe2854438b6ba2bb1f40e.1631091272.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_022254_560126_0F151086 X-CRM114-Status: GOOD ( 10.90 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: John Crispin While we are doing CCA the bss color disable bit inside the he oper field needs to be set. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: John Crispin While we are doing CCA the bss color disable bit inside the he oper field needs to be set. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee --- src/ap/ieee802_11_he.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c index 756ca3804..82b803685 100644 --- a/src/ap/ieee802_11_he.c +++ b/src/ap/ieee802_11_he.c @@ -195,7 +195,7 @@ u8 * hostapd_eid_he_operation(struct hostapd_data *hapd, u8 *eid) if (hapd->iface->conf->he_op.he_er_su_disable) params |= HE_OPERATION_ER_SU_DISABLE; - if (hapd->iface->conf->he_op.he_bss_color_disabled) + if (hapd->iface->conf->he_op.he_bss_color_disabled || hapd->cca_in_progress) params |= HE_OPERATION_BSS_COLOR_DISABLED; if (hapd->iface->conf->he_op.he_bss_color_partial) params |= HE_OPERATION_BSS_COLOR_PARTIAL; From patchwork Wed Sep 8 09:18:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 1525700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sPanTotl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4GtW56Jwz9sR4 for ; Wed, 8 Sep 2021 19:24:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2G2mKaGRD4WmV+WiL5gS9+mREAnArYAzFAgJ3w13uWA=; b=sPanTotlJYDbzc a/xyy/uxMPkysf037Upg8WQUQ5GeuWwDzkqAfOXyPB2vbawmTlEULRbyacu2QOumgy2AGrc4xK/hd kz9WWPRD53EGZM+ABmVLcpAx3zjoqyqhGPjy+rd/SJhXYoogifJdsE6ycirpcxZwPlQyZ3q+dufyl SEal/lxbMiN/nykYQ5RsrxRx6SbbeUnLf8OwLm7yla2mcHhz24ImNDeOjWLB3slRlQg83f9q/UzJF qaRyg2plTbF8ejzLFlDtVPDA5IJHQzsQzJb1xD4p4Li8Yow1MgKHhR3dC5uGM/0EZKyq5xwVN+iQY dn7CDzvUaisY25Ki/DTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnL-006HbN-Ru; Wed, 08 Sep 2021 09:23:03 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnA-006HXm-VB for hostap@lists.infradead.org; Wed, 08 Sep 2021 09:22:54 +0000 X-UUID: a648815f714248f99de716da3311fee2-20210908 X-UUID: a648815f714248f99de716da3311fee2-20210908 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1725401252; Wed, 08 Sep 2021 02:22:47 -0700 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 02:19:56 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 17:19:54 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 8 Sep 2021 17:19:54 +0800 From: Ryder Lee To: Jouni Malinen CC: Felix Fietkau , Lorenzo Bianconi , Shayne Chen , "Evelyn Tsai" , , John Crispin , Lorenzo Bianconi , Ryder Lee Subject: [PATCH 4/6] bss coloring: add the switch_color handler to the nl80211 driver Date: Wed, 8 Sep 2021 17:18:53 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 In-Reply-To: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_022253_086878_62FF0CB2 X-CRM114-Status: GOOD ( 13.85 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: John Crispin In order to start the CCA process we need to send NL80211_CMD_COLOR_CHANGE to the kernel. This patch adds the required code. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: John Crispin In order to start the CCA process we need to send NL80211_CMD_COLOR_CHANGE to the kernel. This patch adds the required code. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee --- src/drivers/driver_nl80211.c | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index f04934454..927d879de 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -9925,6 +9925,82 @@ error: } +#ifdef CONFIG_IEEE80211AX +static int nl80211_switch_color(void *priv, struct cca_settings *settings) +{ + struct nl_msg *msg; + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + struct nlattr *beacon_cca; + int ret = -ENOBUFS; + + wpa_printf(MSG_DEBUG, "nl80211: Color change request (cca_count=%u color=%d)", + settings->cca_count, settings->cca_color); + + if (drv->nlmode != NL80211_IFTYPE_AP) + return -EOPNOTSUPP; + + if (!settings->beacon_cca.tail) + return -EINVAL; + + if ((settings->beacon_cca.tail_len <= settings->counter_offset_beacon) || + (settings->beacon_cca.tail[settings->counter_offset_beacon] != + settings->cca_count)) + return -EINVAL; + + if (settings->beacon_cca.probe_resp && + ((settings->beacon_cca.probe_resp_len <= + settings->counter_offset_presp) || + (settings->beacon_cca.probe_resp[settings->counter_offset_presp] != + settings->cca_count))) + return -EINVAL; + + if (!(msg = nl80211_bss_msg(bss, 0, NL80211_CMD_COLOR_CHANGE_REQUEST)) || + nla_put_u8(msg, NL80211_ATTR_COLOR_CHANGE_COUNT, + settings->cca_count) || + nla_put_u8(msg, NL80211_ATTR_COLOR_CHANGE_COLOR, + settings->cca_color)) + goto error; + + /* beacon_after params */ + ret = set_beacon_data(msg, &settings->beacon_after); + if (ret) + goto error; + + /* beacon_csa params */ + beacon_cca = nla_nest_start(msg, NL80211_ATTR_COLOR_CHANGE_ELEMS); + if (!beacon_cca) + goto fail; + + ret = set_beacon_data(msg, &settings->beacon_cca); + if (ret) + goto error; + + if (nla_put_u16(msg, NL80211_ATTR_CNTDWN_OFFS_BEACON, + settings->counter_offset_beacon) || + (settings->beacon_cca.probe_resp && + nla_put_u16(msg, NL80211_ATTR_CNTDWN_OFFS_PRESP, + settings->counter_offset_presp))) + goto fail; + + nla_nest_end(msg, beacon_cca); + ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); + if (ret) { + wpa_printf(MSG_DEBUG, "nl80211: switch_color failed err=%d (%s)", + ret, strerror(-ret)); + } + return ret; + +fail: + ret = -ENOBUFS; +error: + nlmsg_free(msg); + wpa_printf(MSG_DEBUG, "nl80211: Could not build color switch request"); + return ret; +} +#endif + + static int nl80211_add_ts(void *priv, u8 tsid, const u8 *addr, u8 user_priority, u16 admitted_time) { @@ -12187,6 +12263,9 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { .get_survey = wpa_driver_nl80211_get_survey, .status = wpa_driver_nl80211_status, .switch_channel = nl80211_switch_channel, +#ifdef CONFIG_IEEE80211AX + .switch_color = nl80211_switch_color, +#endif #ifdef ANDROID_P2P .set_noa = wpa_driver_set_p2p_noa, .get_noa = wpa_driver_get_p2p_noa, From patchwork Wed Sep 8 09:18:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 1525699 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jFDy9/96; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4GrJ2RLTz9t54 for ; Wed, 8 Sep 2021 19:22:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UouRSnwH1UzhPGfxhd1WT8iwgWQmoj8qcMmfmM1nqgo=; b=jFDy9/96sWAani zulrc7FUh4bZ8J5lAlmXQlJjyMqmeHHNFoqRvmXcVEqlNR7TqCMl3309+Li2dVnKHSzvgtvEHWDnl Y/bzEJ4mrkt+DqjkgkD1W5fDESyzNHaDTKtr0PnedkLON5BkKDxJ8IQXY8CTpr0dFLiGROlmH8wG5 OkHiykI9ANwb9dY6QO4aGksXDUsYYAiDaXmpvw9+P70P1WjZL0QBRZUF+sqQDQTleqycAD/2eZQnv jOms0NexdNndMOdeVyJcxvdRQqbrXv+XIQ78GqPT0MIFLoMNe7PhOwYnPCgQzghLFslnc8opeh8Rt rAsZ/UlD002VKyUQH8VQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtm1-006HMn-5S; Wed, 08 Sep 2021 09:21:41 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtlp-006HJX-BT for hostap@lists.infradead.org; Wed, 08 Sep 2021 09:21:31 +0000 X-UUID: 4e36163a377347a2b78f7447550ecd68-20210908 X-UUID: 4e36163a377347a2b78f7447550ecd68-20210908 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 150982414; Wed, 08 Sep 2021 02:21:23 -0700 Received: from mtkexhb01.mediatek.inc (172.21.101.102) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 02:20:04 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkexhb01.mediatek.inc (172.21.101.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 17:19:56 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 8 Sep 2021 17:19:56 +0800 From: Ryder Lee To: Jouni Malinen CC: Felix Fietkau , Lorenzo Bianconi , Shayne Chen , "Evelyn Tsai" , , John Crispin , Lorenzo Bianconi , Ryder Lee Subject: [PATCH 5/6] bss coloring: handle the collision and CCA events coming from the kernel Date: Wed, 8 Sep 2021 17:18:54 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 In-Reply-To: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_022129_444199_FA27AFE7 X-CRM114-Status: GOOD ( 17.44 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: John Crispin 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 Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: John Crispin 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 Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee --- 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); From patchwork Wed Sep 8 09:18:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 1525701 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=cnzhERHV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H4GtX3v7nz9t54 for ; Wed, 8 Sep 2021 19:24:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jiVMIXA5tOJCHDySAtqzqgdHW+nnXYHkHNl+VQues2Q=; b=cnzhERHV+onDUg bPmHzedwF7u6J6N+MyT58RlytQWv6j0fb+A+sQgJSoutIA3z3yyLKJfafdX4QNkTGvn52xEZIB1Ed nhnYL90omDdd8rlj+u3C4/uJMjWMFBACW8z4ixU3EcCcoglaLS0gzqlK9hsNxcKfFhGG2LorHaBBo qj9icWOWaY98fBk4WwDsjDiIrQBu68MOCzay8rkzgbqFd/qA417G2q0E1gvCnkjoGqyNXL0g8W7jb BE6wBmr25f2Nr1jS0Nq53JL+zYUpTnxIlrfXcrTIHdQU7ZF6hVBq4Dn6bvHJhBEeXuoQYP5g4WEmG 3khnM/y4hwPck7hACERw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnD-006HZU-FQ; Wed, 08 Sep 2021 09:22:55 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mNtnA-006HXd-VA for hostap@lists.infradead.org; Wed, 08 Sep 2021 09:22:54 +0000 X-UUID: 9464fd726e6c4beebf7ceff6edb50497-20210908 X-UUID: 9464fd726e6c4beebf7ceff6edb50497-20210908 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1348899873; Wed, 08 Sep 2021 02:22:47 -0700 Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 02:19:59 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 8 Sep 2021 17:19:58 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 8 Sep 2021 17:19:58 +0800 From: Ryder Lee To: Jouni Malinen CC: Felix Fietkau , Lorenzo Bianconi , Shayne Chen , "Evelyn Tsai" , , John Crispin , Lorenzo Bianconi , Ryder Lee Subject: [PATCH 6/6] bss_coloring: allow using a random starting color Date: Wed, 8 Sep 2021 17:18:55 +0800 Message-ID: <46fa29623e1fb485e9070ef9d066a57c2111bad0.1631091272.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> References: <3602d12247be5d7a335ee9e3d57e04664256712b.1631091271.git.ryder.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210908_022253_088750_5B160C0F X-CRM114-Status: GOOD ( 11.91 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: John Crispin Enhance the possible values for he_bss_color. Anything greater than 63 will make hostapd choose a random color. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: John Crispin Enhance the possible values for he_bss_color. Anything greater than 63 will make hostapd choose a random color. Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin Signed-off-by: Ryder Lee --- hostapd/config_file.c | 7 +++++-- hostapd/hostapd.conf | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hostapd/config_file.c b/hostapd/config_file.c index 7b03edf36..70d8809c7 100644 --- a/hostapd/config_file.c +++ b/hostapd/config_file.c @@ -3503,8 +3503,11 @@ static int hostapd_config_fill(struct hostapd_config *conf, } else if (os_strcmp(buf, "he_mu_beamformer") == 0) { conf->he_phy_capab.he_mu_beamformer = atoi(pos); } else if (os_strcmp(buf, "he_bss_color") == 0) { - conf->he_op.he_bss_color = atoi(pos) & 0x3f; - conf->he_op.he_bss_color_disabled = 0; + conf->he_op.he_bss_color = atoi(pos); + if (conf->he_op.he_bss_color > 63) + conf->he_op.he_bss_color = (os_random() % 63) + 1; + if (conf->he_op.he_bss_color) + conf->he_op.he_bss_color_disabled = 0; } else if (os_strcmp(buf, "he_bss_color_partial") == 0) { conf->he_op.he_bss_color_partial = atoi(pos); } else if (os_strcmp(buf, "he_default_pe_duration") == 0) { diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf index dbdd3d7fb..88a2b9b83 100644 --- a/hostapd/hostapd.conf +++ b/hostapd/hostapd.conf @@ -816,7 +816,10 @@ wmm_ac_vo_acm=0 # 1 = supported #he_mu_beamformer=1 -# he_bss_color: BSS color (1-63) +# he_bss_color: +# 0 = disable +# 1-63 = pre-defined color +# 64+ = random color #he_bss_color=1 # he_bss_color_partial: BSS color AID equation