wifi: mac80211: initial element helper cleanups
Subsystems (2)
Johannes Berg
maintainercover wifi: mac80211: initial element helper cleanups
With the fix here with HE/EHT capabilities I got really annoyed by how the code uses all those bare pointers to create elements, and did some rework. The real reason for all that was the scanning code, but really scanning is rare and we're better off with simpler code, so allocate a temporary SKB for scanning and then operate on SKBs.
johannes
Johannes Berg
maintainerPATCH 1/10 wifi: mac80211: simplify HE/EHT element length functions
From: Johannes Berg <[email protected]>
We don't need to pass the iftype there, we already have it in the sdata. Simplify this code.
--- net/mac80211/ieee80211_i.h | 4 ++-- net/mac80211/mesh.c | 8 +++----- net/mac80211/mesh_plink.c | 8 +++----- net/mac80211/util.c | 15 ++++++++------- 4 files changed, 16 insertions(+), 19 deletions(-)
net/mac80211/ieee80211_i.h +2 -2
@@ -2502,7 +2502,7 @@ u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap, u32 cap);u8 *ieee80211_ie_build_vht_oper (u8 *pos,struct ieee80211_sta_vht_cap *vht_cap,const struct cfg80211_chan_def *chandef); -u8 ieee80211_ie_len_he_cap (struct ieee80211_sub_if_data *sdata,u8 iftype); +u8 ieee80211_ie_len_he_cap (struct ieee80211_sub_if_data *sdata);u8 *ieee80211_ie_build_he_cap (const struct ieee80211_conn_settings *conn,const struct ieee80211_sta_he_cap *he_cap,u8 *pos,u8 *end);
@@ -2651,7 +2651,7 @@ u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,void ieee80211_init_frag_cache (struct ieee80211_fragment_cache *cache);void ieee80211_destroy_frag_cache (struct ieee80211_fragment_cache *cache); -u8 ieee80211_ie_len_eht_cap (struct ieee80211_sub_if_data *sdata,u8 iftype); +u8 ieee80211_ie_len_eht_cap (struct ieee80211_sub_if_data *sdata); u8 *ieee80211_ie_build_eht_cap(u8 *pos, const struct ieee80211_sta_he_cap *he_cap, const struct ieee80211_sta_eht_cap *eht_cap,
net/mac80211/mesh.c +3 -5
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2008, 2009 open80211s Ltd. -* Copyright (C) 2018 - 2023 Intel Corporation +* Copyright (C) 2018 - 2024 Intel Corporation * Authors: Luis Carlos Cobo <[email protected]> * Javier Cardona <[email protected]> */
@@ -981,10 +981,8 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh) band = chanctx_conf->def.chan->band;rcu_read_unlock (); - ie_len_he_cap =ieee80211_ie_len_he_cap (sdata, -NL80211_IFTYPE_MESH_POINT ); - ie_len_eht_cap =ieee80211_ie_len_eht_cap (sdata, -NL80211_IFTYPE_MESH_POINT ); + ie_len_he_cap =ieee80211_ie_len_he_cap (sdata); + ie_len_eht_cap =ieee80211_ie_len_eht_cap (sdata); head_len = hdr_len + 2 + /* NULL SSID *//* Channel Switch Announcement */
net/mac80211/mesh_plink.c +3 -5
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2008, 2009 open80211s Ltd. -* Copyright (C) 2019, 2021-2023 Intel Corporation +* Copyright (C) 2019, 2021-2024 Intel Corporation * Author: Luis Carlos Cobo <[email protected]> */ #include <linux/gfp.h>
@@ -226,10 +226,8 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, int hdr_len = offsetofend(struct ieee80211_mgmt, u.action.u.self_prot);int err = -ENOMEM ; - ie_len_he_cap =ieee80211_ie_len_he_cap (sdata, -NL80211_IFTYPE_MESH_POINT ); - ie_len_eht_cap =ieee80211_ie_len_eht_cap (sdata, -NL80211_IFTYPE_MESH_POINT ); + ie_len_he_cap =ieee80211_ie_len_he_cap (sdata); + ie_len_eht_cap =ieee80211_ie_len_eht_cap (sdata); skb = dev_alloc_skb(local->tx_headroom + hdr_len + 2 + /* capability info */
net/mac80211/util.c +8 -7
@@ -3272,7 +3272,8 @@ u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,return pos; } -u8 ieee80211_ie_len_he_cap (struct ieee80211_sub_if_data *sdata,u8 iftype) +/* this may return more than ieee80211_ie_build_he_cap() will need */ +u8 ieee80211_ie_len_he_cap (struct ieee80211_sub_if_data *sdata) {const struct ieee80211_sta_he_cap *he_cap;struct ieee80211_supported_band *sband;
@@ -3282,7 +3283,7 @@ u8 ieee80211_ie_len_he_cap(struct ieee80211_sub_if_data *sdata, u8 iftype)if (!sband)return 0 ; - he_cap =ieee80211_get_he_iftype_cap (sband, iftype); + he_cap =ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif);if (!he_cap)return 0 ;
@@ -5065,7 +5066,8 @@ u16 ieee80211_encode_usf(int listen_interval)return (u16 ) listen_interval; } -u8 ieee80211_ie_len_eht_cap (struct ieee80211_sub_if_data *sdata,u8 iftype) +/* this may return more than ieee80211_ie_build_eht_cap() will need */ +u8 ieee80211_ie_len_eht_cap (struct ieee80211_sub_if_data *sdata) {const struct ieee80211_sta_he_cap *he_cap;const struct ieee80211_sta_eht_cap *eht_cap;
@@ -5077,13 +5079,12 @@ u8 ieee80211_ie_len_eht_cap(struct ieee80211_sub_if_data *sdata, u8 iftype)if (!sband)return 0 ; - he_cap =ieee80211_get_he_iftype_cap (sband, iftype); - eht_cap =ieee80211_get_eht_iftype_cap (sband, iftype); + he_cap =ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif); + eht_cap =ieee80211_get_eht_iftype_cap_vif (sband, &sdata->vif);if (!he_cap || !eht_cap)return 0 ; - is_ap = iftype ==NL80211_IFTYPE_AP || - iftype ==NL80211_IFTYPE_P2P_GO ; + is_ap = sdata->vif.type ==NL80211_IFTYPE_AP ; n = ieee80211_eht_mcs_nss_size(&he_cap->he_cap_elem, &eht_cap->eht_cap_elem,
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 2/10 wifi: mac80211: adjust EHT capa when lowering bandwidth
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
If intending to associate with a lower bandwidth, remove capabilities related to 320 MHz from the EHT capabilities element. Also change the EHT MCS-NSS set accordingly: if just reducing 320->160 or similar the format doesn't change, just cut off the last bytes. If changing from higher bandwidth to 20 MHz only EHT STA, adjust the format.
Note that this also requires adjusting the caller in mlme.c since the data written can now be shorter than it determined. We need to clean all that up. Since the other callers pass NULL for the conn limit, we don't need to change things there.
--- include/linux/ieee80211.h | 3 + net/mac80211/ieee80211_i.h | 3 +- net/mac80211/mesh.c | 3 +- net/mac80211/mlme.c | 15 +++-- net/mac80211/tdls.c | 5 +- net/mac80211/util.c | 128 +++++++++++++++++++++++++++---------- 6 files changed, 113 insertions(+), 44 deletions(-)
include/linux/ieee80211.h +3 -0
@@ -3060,6 +3060,9 @@ ieee80211_he_spr_size(const u8 *he_spr_ie)#define IEEE80211_EHT_PHY_CAP5_SUPP_EXTRA_EHT_LTF 0x40#define IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK 0x07 +#define IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_80MHZ 0x08 +#define IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_160MHZ 0x30 +#define IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_320MHZ 0x40#define IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK 0x78#define IEEE80211_EHT_PHY_CAP6_EHT_DUP_6GHZ_SUPP 0x80
net/mac80211/ieee80211_i.h +2 -1
@@ -2652,7 +2652,8 @@ void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache);void ieee80211_destroy_frag_cache (struct ieee80211_fragment_cache *cache);u8 ieee80211_ie_len_eht_cap (struct ieee80211_sub_if_data *sdata); -u8 *ieee80211_ie_build_eht_cap(u8 *pos, +u8 *ieee80211_ie_build_eht_cap(const struct ieee80211_conn_settings *conn, + u8 *pos, const struct ieee80211_sta_he_cap *he_cap, const struct ieee80211_sta_eht_cap *eht_cap, u8 *end,
net/mac80211/mesh.c +2 -1
@@ -668,7 +668,8 @@ int mesh_add_eht_cap_ie(struct ieee80211_sub_if_data *sdata,return -ENOMEM ; pos =skb_put (skb, ie_len); -ieee80211_ie_build_eht_cap (pos, he_cap, eht_cap, pos + ie_len, false); +ieee80211_ie_build_eht_cap (NULL , pos, he_cap, eht_cap, pos + ie_len, + false);return 0 ; }
net/mac80211/mlme.c +10 -5
@@ -1072,9 +1072,10 @@ static void ieee80211_add_he_ie(struct ieee80211_sub_if_data *sdata,static void ieee80211_add_eht_ie (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb, -struct ieee80211_supported_band *sband) +struct ieee80211_supported_band *sband, +const struct ieee80211_conn_settings *conn) { -u8 *pos; +u8 *pos, *pre_eht_pos;const struct ieee80211_sta_he_cap *he_cap;const struct ieee80211_sta_eht_cap *eht_cap;u8 eht_cap_size;
@@ -1097,8 +1098,11 @@ static void ieee80211_add_eht_ie(struct ieee80211_sub_if_data *sdata,ieee80211_eht_ppe_size (eht_cap->eht_ppe_thres[0 ], eht_cap->eht_cap_elem.phy_cap_info); pos =skb_put (skb, eht_cap_size); -ieee80211_ie_build_eht_cap (pos, he_cap, eht_cap, pos + eht_cap_size, - false); + pre_eht_pos = pos; + pos =ieee80211_ie_build_eht_cap (conn, pos, he_cap, eht_cap, + pos + eht_cap_size, false); +/* trim excess if any */ +skb_trim (skb, skb->len - (pre_eht_pos + eht_cap_size - pos)); } static void ieee80211_assoc_add_rates(struct sk_buff *skb,
@@ -1453,7 +1457,8 @@ static size_t ieee80211_assoc_link_elems(struct ieee80211_sub_if_data *sdata, present_elems =NULL ;if (assoc_data->link[link_id].conn.mode >=IEEE80211_CONN_MODE_EHT ) -ieee80211_add_eht_ie (sdata, skb, sband); +ieee80211_add_eht_ie (sdata, skb, sband, + &assoc_data->link[link_id].conn);if (sband->band ==NL80211_BAND_S1GHZ ) {ieee80211_add_aid_request_ie (sdata, skb);
net/mac80211/tdls.c +3 -2
@@ -6,7 +6,7 @@* Copyright 2014, Intel Corporation * Copyright 2014 Intel Mobile Communications GmbH * Copyright 2015 - 2016 Intel Deutschland GmbH -* Copyright (C) 2019, 2021-2023 Intel Corporation +* Copyright (C) 2019, 2021-2024 Intel Corporation */ #include <linux/ieee80211.h>
@@ -604,7 +604,8 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_link_data *link,ieee80211_eht_ppe_size (eht_cap->eht_ppe_thres[0 ], eht_cap->eht_cap_elem.phy_cap_info); pos =skb_put (skb, cap_size); -ieee80211_ie_build_eht_cap (pos, he_cap, eht_cap, pos + cap_size, false); +ieee80211_ie_build_eht_cap (NULL , pos, he_cap, eht_cap, + pos + cap_size, false); }/* add any remaining IEs */
net/mac80211/util.c +93 -35
175 lines not on this page · raw message
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 3/10 wifi: mac80211: limit HE RU capabilities when limiting bandwidth
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
When limiting a station's supported bandwidth while connecting, also limit various other HE capabilities according to the bandwidth needed for them.
--- net/mac80211/util.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-)
net/mac80211/util.c +33 -2
@@ -3300,17 +3300,48 @@ ieee80211_get_adjusted_he_cap(const struct ieee80211_conn_settings *conn,const struct ieee80211_sta_he_cap *he_cap, struct ieee80211_he_cap_elem *elem) { + u8 ru_limit, max_ru; + *elem = he_cap->he_cap_elem; -if (conn->bw_limit <IEEE80211_CONN_BW_LIMIT_40 ) +switch (conn->bw_limit) { +case IEEE80211_CONN_BW_LIMIT_20 : + ru_limit =IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_242 ; +break ; +case IEEE80211_CONN_BW_LIMIT_40 : + ru_limit =IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_484 ; +break ; +case IEEE80211_CONN_BW_LIMIT_80 : + ru_limit =IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_996 ; +break ; +default : + ru_limit = IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_2x996; +break ; + } + + max_ru = elem->phy_cap_info[8 ] &IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK ; + max_ru =min (max_ru, ru_limit); + elem->phy_cap_info[8 ] &= ~IEEE80211_HE_PHY_CAP8_DCM_MAX_RU_MASK ; + elem->phy_cap_info[8 ] |= max_ru; + +if (conn->bw_limit <IEEE80211_CONN_BW_LIMIT_40 ) { elem->phy_cap_info[0 ] &= ~(IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_80MHZ_IN_5G |IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_40MHZ_IN_2G ); + elem->phy_cap_info[9 ] &= + ~IEEE80211_HE_PHY_CAP9_LONGER_THAN_16_SIGB_OFDM_SYM ; + } -if (conn->bw_limit <IEEE80211_CONN_BW_LIMIT_160 ) +if (conn->bw_limit <IEEE80211_CONN_BW_LIMIT_160 ) { elem->phy_cap_info[0 ] &= ~(IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G |IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G ); + elem->phy_cap_info[5 ] &= + ~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_ABOVE_80MHZ_MASK ; + elem->phy_cap_info[7 ] &= + ~(IEEE80211_HE_PHY_CAP7_STBC_TX_ABOVE_80MHZ | +IEEE80211_HE_PHY_CAP7_STBC_RX_ABOVE_80MHZ ); + } } u8 *ieee80211_ie_build_he_cap(const struct ieee80211_conn_settings *conn,
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 4/10 wifi: mac80211: rename ieee80211_ie_build_he_6ghz_cap()
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
The term 'IE' isn't really in use in the spec, and I want to rework all of this to use SKBs as the primary method for building elements. Rename this one already.
--- net/mac80211/ieee80211_i.h | 8 +++++--- net/mac80211/mesh.c | 2 +- net/mac80211/mlme.c | 2 +- net/mac80211/util.c | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-)
net/mac80211/ieee80211_i.h +5 -3
@@ -2506,9 +2506,6 @@ u8 ieee80211_ie_len_he_cap(struct ieee80211_sub_if_data *sdata);u8 *ieee80211_ie_build_he_cap (const struct ieee80211_conn_settings *conn,const struct ieee80211_sta_he_cap *he_cap,u8 *pos,u8 *end); -void ieee80211_ie_build_he_6ghz_cap (struct ieee80211_sub_if_data *sdata, -enum ieee80211_smps_mode smps_mode, -struct sk_buff *skb);u8 *ieee80211_ie_build_he_oper (u8 *pos,struct cfg80211_chan_def *chandef);u8 *ieee80211_ie_build_eht_oper (u8 *pos,struct cfg80211_chan_def *chandef,const struct ieee80211_sta_eht_cap *eht_cap);
@@ -2529,6 +2526,11 @@ void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);u8 *ieee80211_ie_build_s1g_cap (u8 *pos,struct ieee80211_sta_s1g_cap *s1g_cap); +/* element building in SKBs */ +void ieee80211_put_he_6ghz_cap (struct sk_buff *skb, +struct ieee80211_sub_if_data *sdata, +enum ieee80211_smps_mode smps_mode); +/* channel management */ bool ieee80211_chandef_ht_oper (const struct ieee80211_ht_operation *ht_oper,struct cfg80211_chan_def *chandef);
net/mac80211/mesh.c +1 -1
@@ -640,7 +640,7 @@ int mesh_add_he_6ghz_cap_ie(struct ieee80211_sub_if_data *sdata,if (!iftd)return 0 ; -ieee80211_ie_build_he_6ghz_cap (sdata, sdata->deflink.smps_mode, skb); +ieee80211_put_he_6ghz_cap (skb, sdata, sdata->deflink.smps_mode);return 0 ; }
net/mac80211/mlme.c +1 -1
@@ -1067,7 +1067,7 @@ static void ieee80211_add_he_ie(struct ieee80211_sub_if_data *sdata,/* trim excess if any */ skb_trim (skb, skb->len - (pre_he_pos + he_cap_size - pos)); -ieee80211_ie_build_he_6ghz_cap (sdata, smps_mode, skb); +ieee80211_put_he_6ghz_cap (skb, sdata, smps_mode); } static void ieee80211_add_eht_ie(struct ieee80211_sub_if_data *sdata,
net/mac80211/util.c +3 -3
@@ -3413,9 +3413,9 @@ u8 *ieee80211_ie_build_he_cap(const struct ieee80211_conn_settings *conn,return pos; } -void ieee80211_ie_build_he_6ghz_cap (struct ieee80211_sub_if_data *sdata, -enum ieee80211_smps_mode smps_mode, -struct sk_buff *skb) +void ieee80211_put_he_6ghz_cap (struct sk_buff *skb, +struct ieee80211_sub_if_data *sdata, +enum ieee80211_smps_mode smps_mode) {struct ieee80211_supported_band *sband;const struct ieee80211_sband_iftype_data *iftd;
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 5/10 wifi: mac80211: tdls: use ieee80211_put_he_6ghz_cap()
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
We don't need to use the write function here since we already have an SKB, so use ieee80211_put_he_6ghz_cap() with the SMPS mode taken from the link we're using.
--- net/mac80211/ieee80211_i.h | 1 - net/mac80211/tdls.c | 11 ++--------- net/mac80211/util.c | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-)
net/mac80211/ieee80211_i.h +0 -1
@@ -2457,7 +2457,6 @@ void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, const u8 *da, const u8 *bssid, u16 stype, u16 reason, bool send_frame, u8 *frame_buf); -u8 *ieee80211_write_he_6ghz_cap (u8 *pos,__le16 cap,u8 *end);enum {IEEE80211_PROBE_FLAG_DIRECTED =BIT (0 ),
net/mac80211/tdls.c +2 -9
@@ -552,7 +552,6 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_link_data *link, (action_code == WLAN_TDLS_SETUP_REQUEST || action_code == WLAN_TDLS_SETUP_RESPONSE || action_code == WLAN_PUB_ACTION_TDLS_DISCOVER_RES)) { -__le16 he_6ghz_capa;u8 cap_size; cap_size =
@@ -564,14 +563,8 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_link_data *link, pos =ieee80211_ie_build_he_cap (NULL , he_cap, pos, pos + cap_size);/* Build HE 6Ghz capa IE from sband */ -if (sband->band ==NL80211_BAND_6GHZ ) { - cap_size =2 +1 +sizeof (struct ieee80211_he_6ghz_capa ); - pos =skb_put (skb, cap_size); - he_6ghz_capa = -ieee80211_get_he_6ghz_capa_vif (sband, &sdata->vif); - pos =ieee80211_write_he_6ghz_cap (pos, he_6ghz_capa, - pos + cap_size); - } +if (sband->band ==NL80211_BAND_6GHZ ) +ieee80211_put_he_6ghz_cap (skb, sdata, link->smps_mode); }/* add any custom IEs that go before EHT capabilities */
net/mac80211/util.c +1 -1
@@ -2035,7 +2035,7 @@ void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata, } } -u8 *ieee80211_write_he_6ghz_cap (u8 *pos,__le16 cap,u8 *end) +static u8 *ieee80211_write_he_6ghz_cap (u8 *pos,__le16 cap,u8 *end) {if ((end - pos) <5 )return pos;
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 6/10 wifi: mac80211: simplify adding supported rates
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Make this a new-style "put" function, and change the parameters to pass more information directly, this makes it usable also for the MLME code.
--- net/mac80211/ieee80211_i.h | 10 ++-- net/mac80211/mesh.c | 20 ++++--- net/mac80211/mesh_plink.c | 16 ++++-- net/mac80211/mlme.c | 53 ++++-------------- net/mac80211/tdls.c | 4 +- net/mac80211/util.c | 107 +++++++++++++------------------------ 6 files changed, 78 insertions(+), 132 deletions(-)
net/mac80211/ieee80211_i.h +4 -6
@@ -2511,12 +2511,6 @@ u8 *ieee80211_ie_build_eht_oper(u8 *pos, struct cfg80211_chan_def *chandef,int ieee80211_parse_bitrates (enum nl80211_chan_width width,const struct ieee80211_supported_band *sband,const u8 *srates,int srates_len,u32 *rates); -int ieee80211_add_srates_ie (struct ieee80211_sub_if_data *sdata, -struct sk_buff *skb,bool need_basic, -enum nl80211_band band); -int ieee80211_add_ext_srates_ie (struct ieee80211_sub_if_data *sdata, -struct sk_buff *skb,bool need_basic, -enum nl80211_band band);u8 *ieee80211_add_wmm_info_ie (u8 *buf,u8 qosinfo); void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata, struct ieee80211_sta_s1g_cap *caps,
@@ -2526,6 +2520,10 @@ void ieee80211_add_aid_request_ie(struct ieee80211_sub_if_data *sdata,u8 *ieee80211_ie_build_s1g_cap (u8 *pos,struct ieee80211_sta_s1g_cap *s1g_cap);/* element building in SKBs */ +int ieee80211_put_srates_elem (struct sk_buff *skb, +const struct ieee80211_supported_band *sband, +u32 basic_rates,u32 rate_flags,u32 masked_rates, +u8 element_id);void ieee80211_put_he_6ghz_cap (struct sk_buff *skb,struct ieee80211_sub_if_data *sdata,enum ieee80211_smps_mode smps_mode);
net/mac80211/mesh.c +12 -8
@@ -968,19 +968,19 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)int head_len, tail_len;struct sk_buff *skb;struct ieee80211_mgmt *mgmt; -struct ieee80211_chanctx_conf *chanctx_conf;struct mesh_csa_settings *csa; -enum nl80211_band band; +const struct ieee80211_supported_band *sband;u8 ie_len_he_cap, ie_len_eht_cap;u8 *pos;struct ieee80211_sub_if_data *sdata; int hdr_len = offsetofend(struct ieee80211_mgmt, u.beacon); +u32 rate_flags; sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh); -rcu_read_lock (); - chanctx_conf =rcu_dereference (sdata->vif.bss_conf.chanctx_conf); - band = chanctx_conf->def.chan->band; -rcu_read_unlock (); + + sband =ieee80211_get_sband (sdata); + rate_flags = +ieee80211_chandef_rate_flags (&sdata->vif.bss_conf.chanreq.oper); ie_len_he_cap =ieee80211_ie_len_he_cap (sdata); ie_len_eht_cap =ieee80211_ie_len_eht_cap (sdata);
@@ -1107,7 +1107,9 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh) }rcu_read_unlock (); -if (ieee80211_add_srates_ie (sdata, skb, true, band) || +if (ieee80211_put_srates_elem (skb, sband, + sdata->vif.bss_conf.basic_rates, + rate_flags,0 ,WLAN_EID_SUPP_RATES ) ||mesh_add_ds_params_ie (sdata, skb)) goto out_free;
@@ -1118,7 +1120,9 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)skb_trim (skb,0 ); bcn->tail = bcn->head + bcn->head_len; - if (ieee80211_add_ext_srates_ie(sdata, skb, true, band) || + if (ieee80211_put_srates_elem(skb, sband, + sdata->vif.bss_conf.basic_rates, + rate_flags, 0, WLAN_EID_EXT_SUPP_RATES) || mesh_add_rsn_ie(sdata, skb) || mesh_add_ht_cap_ie(sdata, skb) || mesh_add_ht_oper_ie(sdata, skb) ||
net/mac80211/mesh_plink.c +12 -4
@@ -264,14 +264,13 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,if (action !=WLAN_SP_MESH_PEERING_CLOSE ) {struct ieee80211_supported_band *sband; -enum nl80211_band band; +u32 rate_flags, basic_rates; sband =ieee80211_get_sband (sdata);if (!sband) { err = -EINVAL ; goto free; } - band = sband->band;/* capability info */ pos =skb_put_zero (skb,2 );
@@ -280,8 +279,17 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, pos =skb_put (skb,2 );put_unaligned_le16 (sta->sta.aid, pos); } -if (ieee80211_add_srates_ie (sdata, skb, true, band) || -ieee80211_add_ext_srates_ie (sdata, skb, true, band) || + + rate_flags = +ieee80211_chandef_rate_flags (&sdata->vif.bss_conf.chanreq.oper); + basic_rates = sdata->vif.bss_conf.basic_rates; + +if (ieee80211_put_srates_elem (skb, sband, basic_rates, + rate_flags,0 , +WLAN_EID_SUPP_RATES ) || +ieee80211_put_srates_elem (skb, sband, basic_rates, + rate_flags,0 , +WLAN_EID_EXT_SUPP_RATES ) ||mesh_add_rsn_ie (sdata, skb) ||mesh_add_meshid_ie (sdata, skb) ||mesh_add_meshconf_ie (sdata, skb))
net/mac80211/mlme.c +10 -43
73 lines not on this page · raw message
net/mac80211/tdls.c +2 -2
@@ -382,8 +382,8 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_link_data *link,if (WARN_ON_ONCE (!sband))return ; -ieee80211_add_srates_ie (sdata, skb, false, sband->band); -ieee80211_add_ext_srates_ie (sdata, skb, false, sband->band); +ieee80211_put_srates_elem (skb, sband,0 ,0 ,0 ,WLAN_EID_SUPP_RATES ); +ieee80211_put_srates_elem (skb, sband,0 ,0 ,0 ,WLAN_EID_EXT_SUPP_RATES );ieee80211_tdls_add_supp_channels (sdata, skb);/* add any custom IEs that go before Extended Capabilities */
net/mac80211/util.c +38 -69
131 lines not on this page · raw message
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 7/10 wifi: mac80211: start building elements in SKBs
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
The building of elements is really mess, and really the only reason we're not doing it in SKBs in the first place is that the scan code in ieee80211_build_preq_ies() doesn't.
Convert ieee80211_build_preq_ies() to use an SKB internally so that we can gradually convert other things to ..._put_*() style interfaces.
--- net/mac80211/ieee80211_i.h | 7 +- net/mac80211/scan.c | 14 +- net/mac80211/util.c | 357 +++++++++++++++++++------------------ 3 files changed, 191 insertions(+), 187 deletions(-)
net/mac80211/ieee80211_i.h +3 -4
@@ -2517,16 +2517,15 @@ void ieee80211_add_s1g_capab_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb);void ieee80211_add_aid_request_ie (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb); -u8 *ieee80211_ie_build_s1g_cap (u8 *pos,struct ieee80211_sta_s1g_cap *s1g_cap);/* element building in SKBs */ int ieee80211_put_srates_elem (struct sk_buff *skb,const struct ieee80211_supported_band *sband,u32 basic_rates,u32 rate_flags,u32 masked_rates,u8 element_id); -void ieee80211_put_he_6ghz_cap (struct sk_buff *skb, -struct ieee80211_sub_if_data *sdata, -enum ieee80211_smps_mode smps_mode); +int ieee80211_put_he_6ghz_cap (struct sk_buff *skb, +struct ieee80211_sub_if_data *sdata, +enum ieee80211_smps_mode smps_mode);/* channel management */ bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
net/mac80211/scan.c +9 -5
@@ -394,6 +394,8 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_sub_if_data *sdata) req->ie, req->ie_len, bands_used, req->rates, &chandef, flags); +if (ielen <0 ) +return false; local->hw_scan_req->req.ie_len = ielen; local->hw_scan_req->req.no_cck = req->no_cck;ether_addr_copy (local->hw_scan_req->req.mac_addr, req->mac_addr);
@@ -1316,10 +1318,12 @@ int __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,ieee80211_prepare_scan_chandef (&chandef); -ieee80211_build_preq_ies (sdata, ie, num_bands * iebufsz, - &sched_scan_ies, req->ie, - req->ie_len, bands_used, rate_masks, &chandef, - flags); + ret =ieee80211_build_preq_ies (sdata, ie, num_bands * iebufsz, + &sched_scan_ies, req->ie, + req->ie_len, bands_used, rate_masks, + &chandef, flags); +if (ret <0 ) + goto error; ret =drv_sched_scan_start (local, sdata, req, &sched_scan_ies);if (ret ==0 ) {
@@ -1327,8 +1331,8 @@ int __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,rcu_assign_pointer (local->sched_scan_req, req); } +error:kfree (ie); - out:if (ret) {/* Clean in case of failure after HW restart or upon resume. */
net/mac80211/util.c +179 -178
516 lines not on this page · raw message
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 8/10 wifi: mac80211: move element parsing to a new file
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
This code got really big, move it to a new file.
Pure code move.
--- net/mac80211/Makefile | 2 +- net/mac80211/parse.c | 926 ++++++++++++++++++++++++++++++++++++++++++ net/mac80211/util.c | 891 ---------------------------------------- 3 files changed, 927 insertions(+), 892 deletions(-) create mode 100644 net/mac80211/parse.c
net/mac80211/Makefile +1 -1
@@ -29,7 +29,7 @@ mac80211-y := \ spectmgmt.o \ tx.o \ key.o \ - util.o \ + util.o parse.o \ wme.o \ chan.o \ trace.o mlme.o \
net/mac80211/parse.c new file +926 -0
926 lines not on this page · raw message
net/mac80211/util.c +0 -891
903 lines not on this page · raw message
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 9/10 wifi: mac80211: convert ieee80211_ie_build_he_cap() to SKB use
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Convert ieee80211_ie_build_he_cap() to the SKB-put function style, renaming it to ieee80211_put_he_cap().
--- net/mac80211/ieee80211_i.h | 7 ++--- net/mac80211/mesh.c | 15 ++--------- net/mac80211/mlme.c | 37 +++----------------------- net/mac80211/tdls.c | 17 +++--------- net/mac80211/util.c | 54 +++++++++++++++++--------------------- 5 files changed, 37 insertions(+), 93 deletions(-)
net/mac80211/ieee80211_i.h +4 -3
@@ -2502,9 +2502,6 @@ u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,u8 *ieee80211_ie_build_vht_oper (u8 *pos,struct ieee80211_sta_vht_cap *vht_cap,const struct cfg80211_chan_def *chandef);u8 ieee80211_ie_len_he_cap (struct ieee80211_sub_if_data *sdata); -u8 *ieee80211_ie_build_he_cap (const struct ieee80211_conn_settings *conn, -const struct ieee80211_sta_he_cap *he_cap, -u8 *pos,u8 *end);u8 *ieee80211_ie_build_he_oper (u8 *pos,struct cfg80211_chan_def *chandef);u8 *ieee80211_ie_build_eht_oper (u8 *pos,struct cfg80211_chan_def *chandef,const struct ieee80211_sta_eht_cap *eht_cap);
@@ -2523,6 +2520,10 @@ int ieee80211_put_srates_elem(struct sk_buff *skb,const struct ieee80211_supported_band *sband, u32 basic_rates, u32 rate_flags, u32 masked_rates, u8 element_id); +int ieee80211_put_he_cap (struct sk_buff *skb, +struct ieee80211_sub_if_data *sdata, +const struct ieee80211_supported_band *sband, +const struct ieee80211_conn_settings *conn);int ieee80211_put_he_6ghz_cap (struct sk_buff *skb,struct ieee80211_sub_if_data *sdata,enum ieee80211_smps_mode smps_mode);
net/mac80211/mesh.c +2 -13
@@ -567,29 +567,18 @@ int mesh_add_vht_oper_ie(struct ieee80211_sub_if_data *sdata,int mesh_add_he_cap_ie (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb,u8 ie_len) { -const struct ieee80211_sta_he_cap *he_cap;struct ieee80211_supported_band *sband; -u8 *pos; sband =ieee80211_get_sband (sdata);if (!sband)return -EINVAL ; - he_cap =ieee80211_get_he_iftype_cap (sband,NL80211_IFTYPE_MESH_POINT ); - -if (!he_cap || - sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_20_NOHT || +if (sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_20_NOHT || sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_5 || sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_10 )return 0 ; -if (skb_tailroom (skb) < ie_len) -return -ENOMEM ; - - pos =skb_put (skb, ie_len); -ieee80211_ie_build_he_cap (NULL , he_cap, pos, pos + ie_len); - -return 0 ; +return ieee80211_put_he_cap (skb, sdata, sband,NULL ); } int mesh_add_he_oper_ie(struct ieee80211_sub_if_data *sdata,
net/mac80211/mlme.c +3 -34
@@ -1038,38 +1038,6 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,return mu_mimo_owner; } -/* This function determines HE capability flags for the association -* and builds the IE. -*/ -static void ieee80211_add_he_ie (struct ieee80211_sub_if_data *sdata, -struct sk_buff *skb, -struct ieee80211_supported_band *sband, -enum ieee80211_smps_mode smps_mode, -const struct ieee80211_conn_settings *conn) -{ -u8 *pos, *pre_he_pos; -const struct ieee80211_sta_he_cap *he_cap; -u8 he_cap_size; - - he_cap =ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif); -if (WARN_ON (!he_cap)) -return ; - -/* get a max size estimate */ - he_cap_size = -2 +1 +sizeof (he_cap->he_cap_elem) + -ieee80211_he_mcs_nss_size (&he_cap->he_cap_elem) + -ieee80211_he_ppe_size (he_cap->ppe_thres[0 ], - he_cap->he_cap_elem.phy_cap_info); - pos =skb_put (skb, he_cap_size); - pre_he_pos = pos; - pos =ieee80211_ie_build_he_cap (conn, he_cap, pos, pos + he_cap_size); -/* trim excess if any */ -skb_trim (skb, skb->len - (pre_he_pos + he_cap_size - pos)); - -ieee80211_put_he_6ghz_cap (skb, sdata, smps_mode); -} - static void ieee80211_add_eht_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, struct ieee80211_supported_band *sband,
@@ -1403,9 +1371,10 @@ static size_t ieee80211_assoc_link_elems(struct ieee80211_sub_if_data *sdata, offset);if (assoc_data->link[link_id].conn.mode >=IEEE80211_CONN_MODE_HE ) { -ieee80211_add_he_ie (sdata, skb, sband, smps_mode, - &assoc_data->link[link_id].conn); +ieee80211_put_he_cap (skb, sdata, sband, + &assoc_data->link[link_id].conn);ADD_PRESENT_EXT_ELEM (WLAN_EID_EXT_HE_CAPABILITY ); +ieee80211_put_he_6ghz_cap (skb, sdata, smps_mode); }/*
net/mac80211/tdls.c +4 -13
@@ -548,19 +548,10 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_link_data *link, }/* build the HE-cap from sband */ -if (he_cap && - (action_code ==WLAN_TDLS_SETUP_REQUEST || - action_code ==WLAN_TDLS_SETUP_RESPONSE || - action_code ==WLAN_PUB_ACTION_TDLS_DISCOVER_RES )) { -u8 cap_size; - - cap_size = -2 +1 +sizeof (he_cap->he_cap_elem) + -ieee80211_he_mcs_nss_size (&he_cap->he_cap_elem) + -ieee80211_he_ppe_size (he_cap->ppe_thres[0 ], - he_cap->he_cap_elem.phy_cap_info); - pos =skb_put (skb, cap_size); - pos =ieee80211_ie_build_he_cap (NULL , he_cap, pos, pos + cap_size); +if (action_code ==WLAN_TDLS_SETUP_REQUEST || + action_code ==WLAN_TDLS_SETUP_RESPONSE || + action_code ==WLAN_PUB_ACTION_TDLS_DISCOVER_RES ) { +ieee80211_put_he_cap (skb, sdata, sband,NULL );/* Build HE 6Ghz capa IE from sband */ if (sband->band ==NL80211_BAND_6GHZ )
net/mac80211/util.c +24 -30
102 lines not on this page · raw message
Signature · 1 line
2.43.0
Johannes Berg
maintainerPATCH 10/10 wifi: mac80211: convert ieee80211_ie_build_eht_cap() to SKB use
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Convert ieee80211_ie_build_eht_cap() to the SKB-put function style, renaming it to ieee80211_put_eht_cap().
--- net/mac80211/ieee80211_i.h | 10 ++--- net/mac80211/mesh.c | 17 +-------- net/mac80211/mlme.c | 39 +------------------- net/mac80211/tdls.c | 20 ++-------- net/mac80211/util.c | 75 +++++++++++++++----------------------- 5 files changed, 42 insertions(+), 119 deletions(-)
net/mac80211/ieee80211_i.h +4 -6
@@ -2527,6 +2527,10 @@ int ieee80211_put_he_cap(struct sk_buff *skb,int ieee80211_put_he_6ghz_cap (struct sk_buff *skb,struct ieee80211_sub_if_data *sdata,enum ieee80211_smps_mode smps_mode); +int ieee80211_put_eht_cap (struct sk_buff *skb, +struct ieee80211_sub_if_data *sdata, +const struct ieee80211_supported_band *sband, +const struct ieee80211_conn_settings *conn);/* channel management */ bool ieee80211_chandef_ht_oper(const struct ieee80211_ht_operation *ht_oper,
@@ -2651,12 +2655,6 @@ void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache);void ieee80211_destroy_frag_cache (struct ieee80211_fragment_cache *cache);u8 ieee80211_ie_len_eht_cap (struct ieee80211_sub_if_data *sdata); -u8 *ieee80211_ie_build_eht_cap (const struct ieee80211_conn_settings *conn, -u8 *pos, -const struct ieee80211_sta_he_cap *he_cap, -const struct ieee80211_sta_eht_cap *eht_cap, -u8 *end, -bool for_ap); void ieee80211_eht_cap_ie_to_sta_eht_cap(struct ieee80211_sub_if_data *sdata,
net/mac80211/mesh.c +2 -15
@@ -636,31 +636,18 @@ int mesh_add_he_6ghz_cap_ie(struct ieee80211_sub_if_data *sdata,int mesh_add_eht_cap_ie (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb,u8 ie_len) { -const struct ieee80211_sta_he_cap *he_cap; -const struct ieee80211_sta_eht_cap *eht_cap;struct ieee80211_supported_band *sband; -u8 *pos; sband =ieee80211_get_sband (sdata);if (!sband)return -EINVAL ; - he_cap =ieee80211_get_he_iftype_cap (sband,NL80211_IFTYPE_MESH_POINT ); - eht_cap =ieee80211_get_eht_iftype_cap (sband,NL80211_IFTYPE_MESH_POINT ); -if (!he_cap || !eht_cap || - sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_20_NOHT || +if (sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_20_NOHT || sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_5 || sdata->vif.bss_conf.chanreq.oper.width ==NL80211_CHAN_WIDTH_10 )return 0 ; -if (skb_tailroom (skb) < ie_len) -return -ENOMEM ; - - pos =skb_put (skb, ie_len); -ieee80211_ie_build_eht_cap (NULL , pos, he_cap, eht_cap, pos + ie_len, - false); - -return 0 ; +return ieee80211_put_eht_cap (skb, sdata, sband,NULL ); }int mesh_add_eht_oper_ie (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb)
net/mac80211/mlme.c +2 -37
@@ -1038,41 +1038,6 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata,return mu_mimo_owner; } -static void ieee80211_add_eht_ie (struct ieee80211_sub_if_data *sdata, -struct sk_buff *skb, -struct ieee80211_supported_band *sband, -const struct ieee80211_conn_settings *conn) -{ -u8 *pos, *pre_eht_pos; -const struct ieee80211_sta_he_cap *he_cap; -const struct ieee80211_sta_eht_cap *eht_cap; -u8 eht_cap_size; - - he_cap =ieee80211_get_he_iftype_cap_vif (sband, &sdata->vif); - eht_cap =ieee80211_get_eht_iftype_cap_vif (sband, &sdata->vif); - -/* -* EHT capabilities element is only added if the HE capabilities element -* was added so assume that 'he_cap' is valid and don't check it. -*/ -if (WARN_ON (!he_cap || !eht_cap)) -return ; - - eht_cap_size = -2 +1 +sizeof (eht_cap->eht_cap_elem) + -ieee80211_eht_mcs_nss_size (&he_cap->he_cap_elem, - &eht_cap->eht_cap_elem, - false) + -ieee80211_eht_ppe_size (eht_cap->eht_ppe_thres[0 ], - eht_cap->eht_cap_elem.phy_cap_info); - pos =skb_put (skb, eht_cap_size); - pre_eht_pos = pos; - pos =ieee80211_ie_build_eht_cap (conn, pos, he_cap, eht_cap, - pos + eht_cap_size, false); -/* trim excess if any */ -skb_trim (skb, skb->len - (pre_eht_pos + eht_cap_size - pos)); -} - static void ieee80211_assoc_add_rates(struct sk_buff *skb, enum nl80211_chan_width width, struct ieee80211_supported_band *sband,
@@ -1393,8 +1358,8 @@ static size_t ieee80211_assoc_link_elems(struct ieee80211_sub_if_data *sdata, present_elems =NULL ;if (assoc_data->link[link_id].conn.mode >=IEEE80211_CONN_MODE_EHT ) -ieee80211_add_eht_ie (sdata, skb, sband, - &assoc_data->link[link_id].conn); +ieee80211_put_eht_cap (skb, sdata, sband, + &assoc_data->link[link_id].conn);if (sband->band ==NL80211_BAND_S1GHZ ) {ieee80211_add_aid_request_ie (sdata, skb);
net/mac80211/tdls.c +4 -16
@@ -575,22 +575,10 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_link_data *link, }/* build the EHT-cap from sband */ -if (he_cap && eht_cap && - (action_code ==WLAN_TDLS_SETUP_REQUEST || - action_code ==WLAN_TDLS_SETUP_RESPONSE || - action_code ==WLAN_PUB_ACTION_TDLS_DISCOVER_RES )) { -u8 cap_size; - - cap_size = -2 +1 +sizeof (eht_cap->eht_cap_elem) + -ieee80211_eht_mcs_nss_size (&he_cap->he_cap_elem, - &eht_cap->eht_cap_elem, false) + -ieee80211_eht_ppe_size (eht_cap->eht_ppe_thres[0 ], - eht_cap->eht_cap_elem.phy_cap_info); - pos =skb_put (skb, cap_size); -ieee80211_ie_build_eht_cap (NULL , pos, he_cap, eht_cap, - pos + cap_size, false); - } +if (action_code ==WLAN_TDLS_SETUP_REQUEST || + action_code ==WLAN_TDLS_SETUP_RESPONSE || + action_code ==WLAN_PUB_ACTION_TDLS_DISCOVER_RES ) +ieee80211_put_eht_cap (skb, sdata, sband,NULL );/* add any remaining IEs */ if (extra_ies_len) {
net/mac80211/util.c +30 -45
129 lines not on this page · raw message
Signature · 1 line
2.43.0