From 629ada72f9c0dc7a703d01af2c00782e90728ffc Mon Sep 17 00:00:00 2001
From: Gokul Sivakumar <gokulkumar.sivakumar@infineon.com>
Date: Thu, 13 Oct 2022 04:41:42 -0500
Subject: [PATCH] brcmfmac: introduce a module parameter to disable the 6GHz
 Operation

Add a kernel module parameter "disable_6ghz" to disable the operation of
the STA and SoftAP in the 6GHz band. By default, this module parameter will
be set to zero, so 6GHz operation will be disabled during kernel module
load only when explicity setting "disable_6ghz=1".

Signed-off-by: Gokul Sivakumar <gokulkumar.sivakumar@infineon.com>
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.c    | 5 +++++
 .../net/wireless/broadcom/brcm80211/brcmfmac/common.h    | 2 ++
 .../net/wireless/broadcom/brcm80211/brcmfmac/feature.c   | 5 +++++
 .../net/wireless/broadcom/brcm80211/brcmfmac/feature.h   | 9 +++++++++
 4 files changed, 21 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 1c734f18f..db37b6024 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -92,6 +92,10 @@ static int brcmf_fw_ap_select;
 module_param_named(fw_ap_select, brcmf_fw_ap_select, int, 0400);
 MODULE_PARM_DESC(fw_ap_select, "Allow FW for AP selection");
 
+static int brcmf_disable_6ghz;
+module_param_named(disable_6ghz, brcmf_disable_6ghz, int, 0400);
+MODULE_PARM_DESC(disable_6ghz, "Disable 6GHz Operation");
+
 static struct brcmfmac_platform_data *brcmfmac_pdata;
 struct brcmf_mp_global_t brcmf_mp_global;
 
@@ -609,6 +613,7 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
 	settings->ignore_probe_fail = !!brcmf_ignore_probe_fail;
 #endif
 	settings->fw_ap_select = !!brcmf_fw_ap_select;
+	settings->disable_6ghz = !!brcmf_disable_6ghz;
 
 	if (bus_type == BRCMF_BUSTYPE_SDIO)
 		settings->bus.sdio.txglomsz = brcmf_sdiod_txglomsz;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
index 098d41d17..9246c1052 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
@@ -42,6 +42,7 @@ extern struct brcmf_mp_global_t brcmf_mp_global;
  * @ignore_probe_fail: Ignore probe failure.
  * @trivial_ccode_map: Assume firmware uses ISO3166 country codes with rev 0
  * @fw_ap_select: Allow FW to select AP.
+ * @disable_6ghz: Disable 6GHz operation
  * @country_codes: If available, pointer to struct for translating country codes
  * @bus: Bus specific platform data. Only SDIO at the mmoment.
  */
@@ -56,6 +57,7 @@ struct brcmf_mp_device {
 	bool		ignore_probe_fail;
 	bool		trivial_ccode_map;
 	bool		fw_ap_select;
+	bool		disable_6ghz;
 	struct brcmfmac_pd_cc *country_codes;
 	const char	*board_type;
 	unsigned char	mac[ETH_ALEN];
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
index 030557d83..d73ce92c8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
@@ -386,3 +386,8 @@ bool brcmf_feat_is_quirk_enabled(struct brcmf_if *ifp,
 {
 	return (ifp->drvr->chip_quirks & BIT(quirk));
 }
+
+bool brcmf_feat_is_6ghz_enabled(struct brcmf_if *ifp)
+{
+	return (!ifp->drvr->settings->disable_6ghz);
+}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
index 3039d82ef..9922d3b7f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
@@ -132,4 +132,13 @@ bool brcmf_feat_is_enabled(struct brcmf_if *ifp, enum brcmf_feat_id id);
 bool brcmf_feat_is_quirk_enabled(struct brcmf_if *ifp,
 				 enum brcmf_feat_quirk quirk);
 
+/**
+ * brcmf_feat_is_6ghz_enabled() - Find if 6GHZ Operation is allowed
+ *
+ * @ifp: interface instance.
+ *
+ * Return: true if 6GHz operation is allowed; otherwise false.
+ */
+bool brcmf_feat_is_6ghz_enabled(struct brcmf_if *ifp);
+
 #endif /* _BRCMF_FEATURE_H */
-- 
2.39.5 (Apple Git-154)

