wifi: mac80211: simplify HE/EHT element length functions
authorJohannes Berg <johannes.berg@intel.com>
Mon, 29 Jan 2024 19:19:27 +0000 (20:19 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 8 Feb 2024 14:00:43 +0000 (15:00 +0100)
We don't need to pass the iftype there, we already have it
in the sdata. Simplify this code.

Link: https://msgid.link/20240129202041.5890eb1d4184.Ibce7e5abcc7887630da03ac2263d8004ec541418@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/ieee80211_i.h
net/mac80211/mesh.c
net/mac80211/mesh_plink.c
net/mac80211/util.c

index e11297b4dc63570e3ed8e1357a24b6b6597afc37..44400ce9a0b17ab2e04a2234403b97414733632e 100644 (file)
@@ -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,
index e06d9ed2d31b49c926881b97b2434add25466ca7..9fd209e4ca19f4e93f01629719ab652356ff48d4 100644 (file)
@@ -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 <luisca@cozybit.com>
  *            Javier Cardona <javier@cozybit.com>
  */
@@ -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 */
index e3aad60f68ab9cf65c3e5dbd61f3bd3ca74b3194..7ba0f01805a4ab6165dbdd4b32d30de492b71e97 100644 (file)
@@ -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 <luisca@cozybit.com>
  */
 #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 */
index d85a9c5cde2677dcf9c1b499da91d7c5ebdd89e5..e9a7978d47d42aafa12b799cd2e88fca3e5e1084 100644 (file)
@@ -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,