From 7fb2f4f4ac193c7deda93c76bc9408163a32b21c Mon Sep 17 00:00:00 2001
From: Carter Chen <carter.chen@infineon.com>
Date: Thu, 13 Oct 2022 06:23:22 -0500
Subject: [PATCH] non-upstream: adding vendor_cmds are with IFX_OUI

Fixes: SWLINUX-2939

Signed-off-by: Carter Chen <carter.chen@infineon.com>
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c    |  2 +-
 .../broadcom/brcm80211/brcmfmac/vendor.c      | 22 ++++++++++
 .../broadcom/brcm80211/brcmfmac/vendor.h      |  1 +
 .../broadcom/brcm80211/brcmfmac/vendor_ifx.h  | 40 +++++++++++++++----
 4 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 772665d40..d272d0dd5 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -8934,7 +8934,7 @@ static int brcmf_setup_wiphy(struct wiphy *wiphy, struct brcmf_if *ifp)
 	}
 	/* vendor commands/events support */
 	wiphy->vendor_commands = brcmf_vendor_cmds;
-	wiphy->n_vendor_commands = BRCMF_VNDR_CMDS_LAST - 1;
+	wiphy->n_vendor_commands = get_brcmf_num_vndr_cmds();
 	wiphy->vendor_events = brcmf_vendor_events;
 	wiphy->n_vendor_events = BRCMF_VNDR_EVTS_LAST;
 	brcmf_fweh_register(cfg->pub, BRCMF_E_PHY_TEMP,
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
index dec1307a0..fe181a5b8 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.c
@@ -15,6 +15,7 @@
 #include "cfg80211.h"
 #include "vendor.h"
 #include "fwil.h"
+#include "vendor_ifx.h"
 
 static int brcmf_cfg80211_vndr_cmds_dcmd_handler(struct wiphy *wiphy,
 						 struct wireless_dev *wdev,
@@ -239,6 +240,20 @@ const struct wiphy_vendor_command brcmf_vendor_cmds[] = {
 		.policy = VENDOR_CMD_RAW_DATA,
 		.doit = brcmf_cfg80211_vndr_cmds_frameburst
 	},
+	{
+		IFX_SUBCMD(DCMD,
+			   (WIPHY_VENDOR_CMD_NEED_WDEV |
+			    WIPHY_VENDOR_CMD_NEED_NETDEV),
+			   VENDOR_CMD_RAW_DATA,
+			   brcmf_cfg80211_vndr_cmds_dcmd_handler)
+	},
+	{
+		IFX_SUBCMD(FRAMEBURST,
+			   (WIPHY_VENDOR_CMD_NEED_WDEV |
+			    WIPHY_VENDOR_CMD_NEED_NETDEV),
+			   VENDOR_CMD_RAW_DATA,
+			   brcmf_cfg80211_vndr_cmds_frameburst)
+	},
 };
 
 const struct nl80211_vendor_cmd_info brcmf_vendor_events[] = {
@@ -247,3 +262,10 @@ const struct nl80211_vendor_cmd_info brcmf_vendor_events[] = {
 		.subcmd = BRCMF_VNDR_EVTS_PHY_TEMP,
 	},
 };
+
+int get_brcmf_num_vndr_cmds(void)
+{
+	int num = ARRAY_SIZE(brcmf_vendor_cmds);
+
+	return num;
+}
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h
index 3c691bbe0..adc559e12 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor.h
@@ -69,5 +69,6 @@ extern const struct nl80211_vendor_cmd_info brcmf_vendor_events[];
 s32 brcmf_wiphy_phy_temp_evt_handler(struct brcmf_if *ifp,
 				     const struct brcmf_event_msg *e,
 				     void *data);
+int get_brcmf_num_vndr_cmds(void);
 
 #endif /* _vendor_h_ */
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor_ifx.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor_ifx.h
index 39fef7f6b..522e61788 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor_ifx.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/vendor_ifx.h
@@ -22,17 +22,43 @@
  * @IFX_VENDOR_SCMD_MAX: This acts as a the tail of cmds list.
  *      Make sure it located at the end of the list.
  */
+#define SCMD(_CMD)	IFX_VENDOR_SCMD_##_CMD
+#define IFX_SUBCMD(_CMD, _FLAGS, _POLICY, _FN) \
+	{	\
+		.vendor_id = OUI_IFX,	\
+		.subcmd = SCMD(_CMD)	\
+	},	\
+	.flags = (_FLAGS),	\
+	.policy = (_POLICY),	\
+	.doit = (_FN)
+
 enum ifx_nl80211_vendor_subcmds {
-	/* TODO: IFX Vendor subcmd enum IDs between 1-15 are reserved
+	/* TODO: IFX Vendor subcmd enum IDs between 2-15 are reserved
 	 * to be filled later with BRCM Vendor subcmds that are
 	 * already used by IFX.
+	 *
+	 * @IFX_VENDOR_SCMD_DCMD: equivilent to SCMD_PRIV_STR in DHD.
+	 *
+	 * @IFX_VENDOR_SCMD_FRAMEBURST: align ID to DHD.
 	 */
-	IFX_VENDOR_SCMD_UNSPEC		= 0,
-	/* Reserved 1-5 */
-	IFX_VENDOR_SCMD_FRAMEBURST	= 6,
-	/* Reserved 7-15 */
-	IFX_VENDOR_SCMD_DCMD		= 16,
-	IFX_VENDOR_SCMD_MAX		= 17
+	/* Reserved 2-5 */
+	SCMD(UNSPEC)		= 0,
+	SCMD(DCMD)		= 1,
+	SCMD(RSV2)		= 2,
+	SCMD(RSV3)		= 3,
+	SCMD(RSV4)		= 4,
+	SCMD(RSV5)		= 5,
+	SCMD(FRAMEBURST)	= 6,
+	SCMD(RSV7)		= 7,
+	SCMD(RSV8)		= 8,
+	SCMD(RSV9)		= 9,
+	SCMD(RSV10)		= 10,
+	SCMD(RSV11)		= 11,
+	SCMD(RSV12)		= 12,
+	SCMD(RSV13)		= 13,
+	SCMD(RSV14)		= 14,
+	SCMD(RSV15)		= 15,
+	SCMD(MAX)		= 16
 };
 
 /* enum ifx_vendor_attr - IFX nl80211 vendor attributes
-- 
2.39.5 (Apple Git-154)

