Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp802083rdb; Tue, 5 Dec 2023 23:31:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8GONuJjrOgESb/53TdcsoUqJeoBP1S38KNzCW305vXsavpYdkGD0wZjL8A6OIcDi/O2jO X-Received: by 2002:a05:6e02:1a62:b0:35d:59a2:2ce with SMTP id w2-20020a056e021a6200b0035d59a202cemr809453ilv.110.1701847893976; Tue, 05 Dec 2023 23:31:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701847893; cv=pass; d=google.com; s=arc-20160816; b=c5Cfqb58iG0MehPJAfpHAmRhUtDHgsJgPFMECzvZRDCiOh/8KyGcPSmLzWNjxs0By9 jyXjzDBFJ3VdwhAIkjVOfbz3aV8pqr7ltVzT6geR5Ui5e/iv+WaaCRC3c37f6nCSVWfS zbEat4TbGYWCqU+GVvrh6Ny4X1/LuhFPFQ7Tk8/I1pd3kVDjVH6ncdh9Cg7t0BYkZeGH Ld2F2yodKjv2/YKtaPL3yKSq10YhWbr45qpjjA0vkNmnofvkBc+IEMEKwn84NdHOf2db xDd49DGXF1YowFI0NCSGGDY7i5ssOGMzN8aTfUjDBtBybojk/tMrEMYR6RTVXx+Ia6qR KFRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PZratQVfQBCl5uoVBQ/zQ7PAfRxCUobVD/bahhAth84=; fh=lEi7TWq7sMNvk3IAe55wFeCBsfaZRx5ZDKS29bJlqjY=; b=s0Rv2jVieZBvrxm3a+RSnoiPP7Ya9uNDCxPQObzj8mbO+07US/nTIwIoZX/78xU52D Vcn3VRpjzsweu+uT1+kA68dIXRykHys/aFuiIxb3iYET15bsHnz+OE5RA1d6MvpCZwPF N05ulCilP1X30pB6xsRBPeS+L9+5qAY5S+Jq5RX3lOELdsksQHthzb2gMivLFT9d4qcb nusDncksR+MHhLdcCxrTK+8J8V3wFggB8NXSkxN9kmG+71Y11Hh0lCu5Qn8XTjfCsypP R8WQ/fWKyzdf4qgXRstkkigvrGbayPkTVv9HkXyUjjFH3G70AGzYKlxh23EOFCAxX6AR /wdg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=We+Brr57; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-wireless+bounces-465-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-465-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ca40-20020a056a0206a800b005c6bab48f48si1213526pgb.111.2023.12.05.23.31.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 23:31:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-465-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=We+Brr57; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-wireless+bounces-465-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-465-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6CBD92812F9 for ; Wed, 6 Dec 2023 07:31:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58A7E171DE; Wed, 6 Dec 2023 07:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="We+Brr57" X-Original-To: linux-wireless@vger.kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2074.outbound.protection.outlook.com [40.107.101.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088661732; Tue, 5 Dec 2023 23:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E5HZx+waU7+ZKWJIlqF+O+IxDPxfEwU7BF1JRGIA9D1kNRvXdOqD2eC+YppVN2P+qTDRssJqr+C4I5a26JiWmjjnVQCRwhsojCAmC5T59vSCw1YqtGxUx+SlFbSQsUbqIrJFKuziI37magemCnibiXSeGGvpep/Ybj5zcH4NyRqlq89oi7R7sPsQLJT2oGmZ+3+6Qj9wI4CLMv4n/uz1lR9bPvcrD/TUQLRf7EDDVg2ZEn/7uie9Mw6RNzVEKzbfBXXE+PF+WaYDuX3oT80gvPa7Gvyua561/mH3ZnKkUgipwnjxFafiRAT0PeJS9+6ibmzUzDHZ1V5yB5BkTnEOuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PZratQVfQBCl5uoVBQ/zQ7PAfRxCUobVD/bahhAth84=; b=ZzZYjlkW22DNQlTjUXoF7Yt6ytPdIYwi+mrzY7L/er2CLsUm50p5TsIbiLBJIYiEQf0MBaLPrAIs5pkUaohlet5Z9N48khN8RyfXRiG5z8YOyqi4mYvHH5WBN7qLh1L5uYoY++gLm46oMxl4yyEgNekn3jEa+LqXkbD0myHCyknAERdvce9gaE2lEF7EDiPMijgYNC9RQ93GxWlaJnh83p54hiAfFcFOd891ZdQC8ZCOeISivSY0/msjfv5Bk5y6RNmUpGY+oH7IJN6VrnIKVxrQjPL7kKIpC47gbTxN+SOxQjCj6wfe4gGfKFSghRPLVE2CmrkHzD9xJ++xENFWow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PZratQVfQBCl5uoVBQ/zQ7PAfRxCUobVD/bahhAth84=; b=We+Brr57iQXMsH6t/U/h60R2ar/Aq3FhvrxO+fcQtA75PiX8c6H+5oHiRoZURjaape79mh5+SBMd/uTNyZA5GIXpBxYeV62ryPvyTNX6ZM0EzcDkpUH38df/qHg2aPwpk/zzLi786xZeE6w8gC9zKfsf1RclFE1CwHe1L5730tQ= Received: from MW4PR04CA0235.namprd04.prod.outlook.com (2603:10b6:303:87::30) by SN7PR12MB7369.namprd12.prod.outlook.com (2603:10b6:806:298::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.26; Wed, 6 Dec 2023 07:31:07 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:303:87:cafe::48) by MW4PR04CA0235.outlook.office365.com (2603:10b6:303:87::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 07:31:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.2 via Frontend Transport; Wed, 6 Dec 2023 07:31:07 +0000 Received: from compile-server.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 01:30:34 -0600 From: Ma Jun To: , , , , , , , , , , , , , , , CC: , Evan Quan , Ma Jun Subject: [PATCH v15 4/9] wifi: mac80211: Add support for WBRF features Date: Wed, 6 Dec 2023 15:29:42 +0800 Message-ID: <20231206072947.1331729-5-Jun.Ma2@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231206072947.1331729-1-Jun.Ma2@amd.com> References: <20231206072947.1331729-1-Jun.Ma2@amd.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FD:EE_|SN7PR12MB7369:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d7c2163-1e37-4823-7f70-08dbf62d4fbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SRNKhkxf5LmprSQI+dCH0XWGUbdtBv1Wf61LuWg806C2OjXtIr4cShM8j63UexlWkosAIuuNBUaFOUtEqoSZMHmdozGzpPuh7apyy0RFdgDwsVriiQC2aQMyfc3v9G0d5KUBy9hmLhe4iXKPM74S8VKwr1y0in+auquaqJLE39bl470GfM/NncjVyuFC1NuYxlkBacrkqydbV1sIORa9+S5BDrxftKthsEqmvBkVtuGLMQIujRrdvqkY6dQfmYjpx+b4LK/Caky/ClUl0qA/fG9BrCxH+Bt1ruWX0Ns9uf5IS5V/LBpT//MNy05wkJ6IS+Ep4NM1rB9cGCT7xP196rugRE4SvKGtsjsZC5sJ5V4npXrNc/8UevBSPmikquqJc1SJ9eEY5vXkgkR74SeOEijZxlmyS48Xb/mVORMj432VMxzPYovGqIN59g14BcZYEpXOtJsQ3IHKzC+iw6rxXQN856l+mdYFzy7ECj5lju2eJLt1vls/DHZUdW2xve62VILZ7UpyFuIlzCKCKSEsmtbmyb7tC171BFweQjLtGVF7xrgNRfXQuQaIHaVj4fx+sChUQ1t4asjCpnfu+2uvhGJz9Q5/s32I0EgtLC55EwKrr4CLTTDENHFeOKmgbfjXfjeqFOYVTT8Ycl7QV+k3ZlG+jQKupUe9uWStv6he3Ve2JOQraMLCjrE/MSKLvicQbtAvhL3CZ70y1Mc1XPYgw8NmdX25UarF+NMkM/Qs3XIL8y3Kpn1wT8ltX6J4XSbDa+TFTPfHJHoKOebLM99QJJetRauI/X3ibg1rcce3lN4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(346002)(136003)(396003)(39860400002)(230922051799003)(82310400011)(451199024)(186009)(1800799012)(64100799003)(36840700001)(40470700004)(81166007)(32650700002)(336012)(356005)(36756003)(921008)(82740400003)(70586007)(86362001)(40460700003)(36860700001)(426003)(8676002)(8936002)(40480700001)(7696005)(5660300002)(7416002)(1076003)(110136005)(2906002)(41300700001)(70206006)(4326008)(83380400001)(316002)(54906003)(2616005)(45080400002)(26005)(478600001)(16526019)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 07:31:07.2271 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d7c2163-1e37-4823-7f70-08dbf62d4fbc X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7369 From: Evan Quan To support the WBRF mechanism, Wifi adapters utilized in the system must register the frequencies in use (or unregister those frequencies no longer used) via the dedicated calls. So that, other drivers responding to the frequencies can take proper actions to mitigate possible interference. Co-developed-by: Mario Limonciello Signed-off-by: Mario Limonciello Co-developed-by: Evan Quan Signed-off-by: Evan Quan Signed-off-by: Ma Jun -- v1->v2: - place the new added member(`wbrf_supported`) in ieee80211_local(Johannes) - handle chandefs change scenario properly(Johannes) - some minor fixes around code sharing and possible invalid input checks(Johannes) v2->v3: - drop unnecessary input checks and intermediate APIs(Mario) - Separate some mac80211 common code(Mario, Johannes) v3->v4: - some minor fixes around return values(Johannes) v9->v10: - get ranges_in->num_of_ranges set and passed in(Johannes) v12: - use acpi_amd_wbrf_add_remove to replace the acpi_amd_wbrf_add_exclusion acpi_amd_wbrf_remove_exclusion v13: - Fix the format issue (IIpo Jarvinen) - Remove KHZ_TO_HZ and use HZ_PER_KHZ in linux/units.h (IIpo Jarvinen) v14: - KHZ_PER_MHZ and KHZ_PER_MHZ in linux/units.h (IIpo Jarvinen) --- net/mac80211/Makefile | 2 + net/mac80211/chan.c | 9 ++++ net/mac80211/ieee80211_i.h | 7 +++ net/mac80211/main.c | 2 + net/mac80211/wbrf.c | 95 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 net/mac80211/wbrf.c diff --git a/net/mac80211/Makefile b/net/mac80211/Makefile index c9eb52768133..4406b4f8f3b9 100644 --- a/net/mac80211/Makefile +++ b/net/mac80211/Makefile @@ -67,4 +67,6 @@ mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y) obj-y += tests/ +mac80211-y += wbrf.o + ccflags-y += -DDEBUG diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 1d928f29ad6f..aa24585359ee 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -507,11 +507,16 @@ static void _ieee80211_change_chanctx(struct ieee80211_local *local, WARN_ON(!cfg80211_chandef_compatible(&ctx->conf.def, chandef)); + ieee80211_remove_wbrf(local, &ctx->conf.def); + ctx->conf.def = *chandef; /* check if min chanctx also changed */ changed = IEEE80211_CHANCTX_CHANGE_WIDTH | _ieee80211_recalc_chanctx_min_def(local, ctx, rsvd_for); + + ieee80211_add_wbrf(local, &ctx->conf.def); + drv_change_chanctx(local, ctx, changed); if (!local->use_chanctx) { @@ -667,6 +672,8 @@ static int ieee80211_add_chanctx(struct ieee80211_local *local, lockdep_assert_wiphy(local->hw.wiphy); + ieee80211_add_wbrf(local, &ctx->conf.def); + if (!local->use_chanctx) local->hw.conf.radar_enabled = ctx->conf.radar_enabled; @@ -746,6 +753,8 @@ static void ieee80211_del_chanctx(struct ieee80211_local *local, } ieee80211_recalc_idle(local); + + ieee80211_remove_wbrf(local, &ctx->conf.def); } static void ieee80211_free_chanctx(struct ieee80211_local *local, diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 84df104f272b..9dd51481fb87 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1559,6 +1559,8 @@ struct ieee80211_local { /* extended capabilities provided by mac80211 */ u8 ext_capa[8]; + + bool wbrf_supported; }; static inline struct ieee80211_sub_if_data * @@ -2600,4 +2602,9 @@ ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata, const struct ieee80211_eht_cap_elem *eht_cap_ie_elem, u8 eht_cap_len, struct link_sta_info *link_sta); + +void ieee80211_check_wbrf_support(struct ieee80211_local *local); +void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); +void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef); + #endif /* IEEE80211_I_H */ diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 033a5261ac3a..f2ece7793573 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -1405,6 +1405,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) debugfs_hw_add(local); rate_control_add_debugfs(local); + ieee80211_check_wbrf_support(local); + rtnl_lock(); wiphy_lock(hw->wiphy); diff --git a/net/mac80211/wbrf.c b/net/mac80211/wbrf.c new file mode 100644 index 000000000000..a05c5b971789 --- /dev/null +++ b/net/mac80211/wbrf.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Wifi Band Exclusion Interface for WLAN + * Copyright (C) 2023 Advanced Micro Devices + * + */ + +#include +#include +#include +#include "ieee80211_i.h" + +void ieee80211_check_wbrf_support(struct ieee80211_local *local) +{ + struct wiphy *wiphy = local->hw.wiphy; + struct device *dev; + + if (!wiphy) + return; + + dev = wiphy->dev.parent; + if (!dev) + return; + + local->wbrf_supported = acpi_amd_wbrf_supported_producer(dev); + dev_dbg(dev, "WBRF is %s supported\n", + local->wbrf_supported ? "" : "not"); +} + +static void get_chan_freq_boundary(u32 center_freq, u32 bandwidth, u64 *start, u64 *end) +{ + bandwidth *= KHZ_PER_MHZ; + center_freq *= KHZ_PER_MHZ; + + *start = center_freq - bandwidth / 2; + *end = center_freq + bandwidth / 2; + + /* Frequency in Hz is expected */ + *start = *start * HZ_PER_KHZ; + *end = *end * HZ_PER_KHZ; +} + +static void get_ranges_from_chandef(struct cfg80211_chan_def *chandef, + struct wbrf_ranges_in_out *ranges_in) +{ + u64 start_freq1, end_freq1; + u64 start_freq2, end_freq2; + int bandwidth; + + bandwidth = nl80211_chan_width_to_mhz(chandef->width); + + get_chan_freq_boundary(chandef->center_freq1, bandwidth, &start_freq1, &end_freq1); + + ranges_in->band_list[0].start = start_freq1; + ranges_in->band_list[0].end = end_freq1; + ranges_in->num_of_ranges = 1; + + if (chandef->width == NL80211_CHAN_WIDTH_80P80) { + get_chan_freq_boundary(chandef->center_freq2, bandwidth, &start_freq2, &end_freq2); + + ranges_in->band_list[1].start = start_freq2; + ranges_in->band_list[1].end = end_freq2; + ranges_in->num_of_ranges++; + } +} + +void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in_out ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + get_ranges_from_chandef(chandef, &ranges_in); + + acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_ADD, &ranges_in); +} + +void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef) +{ + struct wbrf_ranges_in_out ranges_in = {0}; + struct device *dev; + + if (!local->wbrf_supported) + return; + + dev = local->hw.wiphy->dev.parent; + + get_ranges_from_chandef(chandef, &ranges_in); + + acpi_amd_wbrf_add_remove(dev, WBRF_RECORD_REMOVE, &ranges_in); +} -- 2.34.1