From: Mordechay Goodstein Date: Sun, 5 Mar 2023 12:16:19 +0000 (+0200) Subject: wifi: iwlwifi: mvm: add an helper function radiotap TLVs X-Git-Tag: v6.6.17~4755^2~378^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=056805bcc6bc439de1c9fbb1854042fdf40c8638;p=platform%2Fkernel%2Flinux-rpi.git 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: Mordechay Goodstein Signed-off-by: Gregory Greenman Link: https://lore.kernel.org/r/20230305124407.8ac5195bb3e6.I19ad99c1ad3108453aede64bddf6ef1a7c4a0b74@changeid Signed-off-by: Johannes Berg --- diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c index 71a6555..206b56c 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c @@ -205,36 +205,45 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb, 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, struct sk_buff *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 padding = ALIGN(vendor_data_len, 4) - vendor_data_len; if (!mvm->cur_aid) return; - radiotap = skb_put(skb, sizeof(*radiotap) + vendor_data_len + padding); - radiotap->type = cpu_to_le16(IEEE80211_RADIOTAP_VENDOR_NAMESPACE); - radiotap->len = cpu_to_le16(sizeof(*radiotap) - - sizeof(struct ieee80211_radiotap_tlv) + - vendor_data_len); + radiotap = iwl_mvm_radiotap_put_tlv(skb, + IEEE80211_RADIOTAP_VENDOR_NAMESPACE, + sizeof(*radiotap) + vendor_data_len); /* Intel OUI */ - radiotap->content.oui[0] = 0xf6; - radiotap->content.oui[1] = 0x54; - radiotap->content.oui[2] = 0x25; + radiotap->oui[0] = 0xf6; + radiotap->oui[1] = 0x54; + radiotap->oui[2] = 0x25; /* radiotap sniffer config sub-namespace */ - radiotap->content.oui_subtype = 1; - radiotap->content.vendor_type = 0; - /* clear reserved field */ - radiotap->content.reserved = 0; + radiotap->oui_subtype = 1; + radiotap->vendor_type = 0; + /* fill the data now */ - memcpy(radiotap->content.data, &mvm->cur_aid, sizeof(mvm->cur_aid)); - /* and clear the padding */ - memset(radiotap->content.data + vendor_data_len, 0, padding); + memcpy(radiotap->data, &mvm->cur_aid, sizeof(mvm->cur_aid)); rx_status->flag |= RX_FLAG_RADIOTAP_TLV_AT_END; }