From 11a2638d120b9d998916efb6fc55c6422e469ffa Mon Sep 17 00:00:00 2001
From: Mordechay Goodstein <mordechay.goodstein@intel.com>
Date: Sun, 5 Mar 2023 14:16:19 +0200
Subject: [PATCH] wifi: radiotap: separate vendor TLV into header/content

To be able to use a general function later for any kind of
TLV, separate the vendor TLV header/content in the structs.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230305124407.8ac5195bb3e6.I19ad99c1ad3108453aede64bddf6ef1a7c4a0b74@changeid
[separate from the original combined patch]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 16 +++++++--------
 drivers/net/wireless/mac80211_hwsim.c         | 14 ++++++-------
 include/net/ieee80211_radiotap.h              | 20 +++++++++++++------
 3 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index 2db4f68becff2..71a6555f90d94 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -223,18 +223,18 @@ static void iwl_mvm_add_rtap_sniffer_config(struct iwl_mvm *mvm,
 				    vendor_data_len);
 
 	/* Intel OUI */
-	radiotap->oui[0] = 0xf6;
-	radiotap->oui[1] = 0x54;
-	radiotap->oui[2] = 0x25;
+	radiotap->content.oui[0] = 0xf6;
+	radiotap->content.oui[1] = 0x54;
+	radiotap->content.oui[2] = 0x25;
 	/* radiotap sniffer config sub-namespace */
-	radiotap->oui_subtype = 1;
-	radiotap->vendor_type = 0;
+	radiotap->content.oui_subtype = 1;
+	radiotap->content.vendor_type = 0;
 	/* clear reserved field */
-	radiotap->reserved = 0;
+	radiotap->content.reserved = 0;
 	/* fill the data now */
-	memcpy(radiotap->data, &mvm->cur_aid, sizeof(mvm->cur_aid));
+	memcpy(radiotap->content.data, &mvm->cur_aid, sizeof(mvm->cur_aid));
 	/* and clear the padding */
-	memset(radiotap->data + vendor_data_len, 0, padding);
+	memset(radiotap->content.data + vendor_data_len, 0, padding);
 
 	rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END;
 }
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 152617034d19e..f4bdc243ea0d1 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -1556,14 +1556,14 @@ static void mac80211_hwsim_add_vendor_rtap(struct sk_buff *skb)
 				sizeof(vendor_data));
 	rtap->type = cpu_to_le16(IEEE80211_RADIOTAP_VENDOR_NAMESPACE);
 
-	rtap->oui[0] = HWSIM_RADIOTAP_OUI[0];
-	rtap->oui[1] = HWSIM_RADIOTAP_OUI[1];
-	rtap->oui[2] = HWSIM_RADIOTAP_OUI[2];
-	rtap->oui_subtype = 127;
+	rtap->content.oui[0] = HWSIM_RADIOTAP_OUI[0];
+	rtap->content.oui[1] = HWSIM_RADIOTAP_OUI[1];
+	rtap->content.oui[2] = HWSIM_RADIOTAP_OUI[2];
+	rtap->content.oui_subtype = 127;
 	/* clear reserved field */
-	rtap->reserved = 0;
-	rtap->vendor_type = 0;
-	memcpy(rtap->data, vendor_data, sizeof(vendor_data));
+	rtap->content.reserved = 0;
+	rtap->content.vendor_type = 0;
+	memcpy(rtap->content.data, vendor_data, sizeof(vendor_data));
 
 	IEEE80211_SKB_RXCB(skb)->flag |= RX_FLAG_RADIOTAP_TLV_AT_END;
 #endif
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index 95436686d3fe6..f980a72f2ce6e 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -370,18 +370,14 @@ struct ieee80211_radiotap_tlv {
 } __packed;
 
 /**
- * struct ieee80211_radiotap_vendor_tlv - vendor radiotap data information
- * @type: should always be set to IEEE80211_RADIOTAP_VENDOR_NAMESPACE
- * @len: length of data
+ * struct ieee80211_radiotap_vendor_content - radiotap vendor data content
  * @oui: radiotap vendor namespace OUI
  * @oui_subtype: radiotap vendor sub namespace
  * @vendor_type: radiotap vendor type
  * @reserved: should always be set to zero (to avoid leaking memory)
  * @data: the actual vendor namespace data
  */
-struct ieee80211_radiotap_vendor_tlv {
-	__le16 type; /* IEEE80211_RADIOTAP_VENDOR_NAMESPACE */
-	__le16 len;
+struct ieee80211_radiotap_vendor_content {
 	u8 oui[3];
 	u8 oui_subtype;
 	__le16 vendor_type;
@@ -389,6 +385,18 @@ struct ieee80211_radiotap_vendor_tlv {
 	u8 data[];
 } __packed;
 
+/**
+ * struct ieee80211_radiotap_vendor_tlv - vendor radiotap data information
+ * @type: should always be set to IEEE80211_RADIOTAP_VENDOR_NAMESPACE
+ * @len: length of data
+ * @content: vendor content see @ieee80211_radiotap_vendor_content
+ */
+struct ieee80211_radiotap_vendor_tlv {
+	__le16 type; /* IEEE80211_RADIOTAP_VENDOR_NAMESPACE */
+	__le16 len;
+	struct ieee80211_radiotap_vendor_content content;
+};
+
 /* ieee80211_radiotap_eht_usig - content of U-SIG tlv (type 33)
  * see www.radiotap.org/fields/U-SIG.html for details
  */