Commit 056805bc authored by Mordechay Goodstein's avatar Mordechay Goodstein Committed by Johannes Berg

wifi: iwlwifi: mvm: add an helper function radiotap TLVs

Add a helper function setting type, length, zeroing out
TLV data and including adding padding if necessary.
Signed-off-by: default avatarMordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230305124407.8ac5195bb3e6.I19ad99c1ad3108453aede64bddf6ef1a7c4a0b74@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 11a2638d
...@@ -205,36 +205,45 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb, ...@@ -205,36 +205,45 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
return 0; return 0;
} }
/* put a TLV on the skb and return data pointer
*
* Also pad to 4 the len and zero out all data part
*/
static void *
iwl_mvm_radiotap_put_tlv(struct sk_buff *skb, u16 type, u16 len)
{
struct ieee80211_radiotap_tlv *tlv;
tlv = skb_put(skb, sizeof(*tlv));
tlv->type = cpu_to_le16(type);
tlv->len = cpu_to_le16(len);
return skb_put_zero(skb, ALIGN(len, 4));
}
static void iwl_mvm_add_rtap_sniffer_config(struct iwl_mvm *mvm, static void iwl_mvm_add_rtap_sniffer_config(struct iwl_mvm *mvm,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb);
struct ieee80211_radiotap_vendor_tlv *radiotap; struct ieee80211_radiotap_vendor_content *radiotap;
const u16 vendor_data_len = sizeof(mvm->cur_aid); const u16 vendor_data_len = sizeof(mvm->cur_aid);
const u16 padding = ALIGN(vendor_data_len, 4) - vendor_data_len;
if (!mvm->cur_aid) if (!mvm->cur_aid)
return; return;
radiotap = skb_put(skb, sizeof(*radiotap) + vendor_data_len + padding); radiotap = iwl_mvm_radiotap_put_tlv(skb,
radiotap->type = cpu_to_le16(IEEE80211_RADIOTAP_VENDOR_NAMESPACE); IEEE80211_RADIOTAP_VENDOR_NAMESPACE,
radiotap->len = cpu_to_le16(sizeof(*radiotap) - sizeof(*radiotap) + vendor_data_len);
sizeof(struct ieee80211_radiotap_tlv) +
vendor_data_len);
/* Intel OUI */ /* Intel OUI */
radiotap->content.oui[0] = 0xf6; radiotap->oui[0] = 0xf6;
radiotap->content.oui[1] = 0x54; radiotap->oui[1] = 0x54;
radiotap->content.oui[2] = 0x25; radiotap->oui[2] = 0x25;
/* radiotap sniffer config sub-namespace */ /* radiotap sniffer config sub-namespace */
radiotap->content.oui_subtype = 1; radiotap->oui_subtype = 1;
radiotap->content.vendor_type = 0; radiotap->vendor_type = 0;
/* clear reserved field */
radiotap->content.reserved = 0;
/* fill the data now */ /* fill the data now */
memcpy(radiotap->content.data, &mvm->cur_aid, sizeof(mvm->cur_aid)); memcpy(radiotap->data, &mvm->cur_aid, sizeof(mvm->cur_aid));
/* and clear the padding */
memset(radiotap->content.data + vendor_data_len, 0, padding);
rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END; rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment