From patchwork Mon Mar 21 11:10:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1609142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=w/ekEQr7; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=A6ikOnP7; 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4KPXhH6j8xz9s09 for ; Fri, 25 Mar 2022 04:46:07 +1100 (AEDT) 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=+MoVOxejxRWUdmjbe4RG1FYvpBVWZjQ2U1GqhFAwm1U=; b=w/ekEQr71zuBOc 65ZdnGusI1b2Zq9fQj3FrzxlrYvGgkiHesaCy4UpQStnePodoJBO7oYV0YfnpCAoZZMaUl+S5g/0W CwD6CCXDeoDZe9elfWvvbddBlc0B2KBc8c8qJKL3IY97Vil1gDkaex0fwV5zMZBK9zRmzh2Xf2VQv cLOqqZQiMEx6PcvMTf18bpCNXVEvKfLNO165brN/8b2GJEGyw81n0hyoyIsiJ0G02+7HPqDIm8JTZ bf8PIoFz9nBVsOGWw1W2FDmaWFSwpbjpynXJYGIXA06EFHf6vunnh7G3HiPUPKsY5zasEqShhpDIX 4tWLUDeLmTPr2BLbcJpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXRWF-00HPVy-JR; Thu, 24 Mar 2022 17:45:07 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWFwU-007QST-JF for hostap@lists.infradead.org; Mon, 21 Mar 2022 11:11:20 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id AE5A8CE172C; Mon, 21 Mar 2022 11:11:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66CE8C340E8; Mon, 21 Mar 2022 11:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647861073; bh=7B1hnFDYhDG+ye20IjWlYHzABD4ixSjc2oloRx359VE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A6ikOnP7dgCh8xyRswZuzQ860TA3Qmkmkey1qQm8n1ZH/kpODXVIvkahpBTZRSwaM Aq8ahS6pGRgfFayBcNOxztvV7elPsbGXIgE2D1ADJ+zF+VOxDkymuWwZYgKUBmQ3c1 vJ5t5aWlHfw01drzWmRW7pZjv6r9aK3LCw9NqnMi1PVma0ElINLeFpxNCLCyQFgRu1 /yu13nK1cZwtodZSrO1W6W1B4k9jxq33hB3ddPjrnagw7PfDiAC23N4IL9TByuoDSa XnN8SJ/1y7Q/3Bp77QCt/qifG2Vt3R4m2OORTvRetJNQZ3+BDIefQEEzqXgJfcOn3e 9S3P2j2chPspg== From: Lorenzo Bianconi To: j@w1.fi Cc: nbd@nbd.name, hostap@lists.infradead.org, lorenzo.bianconi@redhat.com, ryder.lee@mediatek.com, evelyn.tsai@mediatek.com, chui-hao.chiu@mediatek.com, john@phrozen.org Subject: [PATCH v3 4/5] bss coloring: add the switch_color handler to the nl80211 driver Date: Mon, 21 Mar 2022 12:10:33 +0100 Message-Id: <15e4f46dc9051f1e3c897116e590b117fd68cfd6.1647858924.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220321_041119_014941_5A79CEC6 X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -5.4 (-----) 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. Tested-by: Peter Chiu Co-developed-by: Lorenzo Bianconi Signed-off-by: Lorenzo Bianconi Signed-off-by: John Crispin 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. Tested-by: Peter Chiu 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 | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 403972985..5017e2a5d 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -9955,6 +9955,84 @@ error: } +#ifdef CONFIG_IEEE80211AX +static int nl80211_switch_color(void *priv, struct cca_settings *settings) +{ + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; + struct nlattr *beacon_cca; + struct nl_msg *msg; + 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) { + ret = -ENOBUFS; + goto error; + } + + 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))) { + ret = -ENOBUFS; + goto error; + } + + 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; + +error: + nlmsg_free(msg); + wpa_printf(MSG_DEBUG, "nl80211: Could not build color switch request"); + return ret; +} +#endif /* CONFIG_IEEE80211AX */ + + static int nl80211_add_ts(void *priv, u8 tsid, const u8 *addr, u8 user_priority, u16 admitted_time) { @@ -12249,6 +12327,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 /* CONFIG_IEEE80211AX */ #ifdef ANDROID_P2P .set_noa = wpa_driver_set_p2p_noa, .get_noa = wpa_driver_get_p2p_noa,