summaryrefslogtreecommitdiff
path: root/net/mac80211/util.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2024-01-29 20:19:35 +0100
committerJohannes Berg <johannes.berg@intel.com>2024-02-08 15:00:44 +0100
commit28aa895bb0b324ed4a0cb441e5fbb882befb5e1c (patch)
treedebb16d61415fa26733ea5942250209de733fc01 /net/mac80211/util.c
parent9d0480a7c05b6482195acafbc5f4f3b4a1cc2b8b (diff)
wifi: mac80211: convert ieee80211_ie_build_he_cap() to SKB use
Convert ieee80211_ie_build_he_cap() to the SKB-put function style, renaming it to ieee80211_put_he_cap(). Link: https://msgid.link/20240129202041.e6ef888980d9.Ied9e014314b5d27611e693e3d4cb63bdc8d7de17@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r--net/mac80211/util.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index c675ac59d2bb..4dcb62e9d4c6 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1352,19 +1352,14 @@ static int ieee80211_put_preq_ies_band(struct sk_buff *skb,
*offset = noffset;
}
- he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif);
- if (he_cap &&
- cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
+ if (cfg80211_any_usable_channels(local->hw.wiphy, BIT(sband->band),
IEEE80211_CHAN_NO_HE)) {
- u8 *pos = skb_tail_pointer(skb);
- u8 *end = pos + skb_tailroom(skb);
-
- pos = ieee80211_ie_build_he_cap(NULL, he_cap, pos, end);
- if (!pos)
- return -ENOBUFS;
- skb_put(skb, pos - skb_tail_pointer(skb));
+ err = ieee80211_put_he_cap(skb, sdata, sband, NULL);
+ if (err)
+ return err;
}
+ he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif);
eht_cap = ieee80211_get_eht_iftype_cap_vif(sband, &sdata->vif);
if (eht_cap &&
@@ -2408,7 +2403,7 @@ u8 *ieee80211_ie_build_vht_cap(u8 *pos, struct ieee80211_sta_vht_cap *vht_cap,
return pos;
}
-/* this may return more than ieee80211_ie_build_he_cap() will need */
+/* this may return more than ieee80211_put_he_6ghz_cap() will need */
u8 ieee80211_ie_len_he_cap(struct ieee80211_sub_if_data *sdata)
{
const struct ieee80211_sta_he_cap *he_cap;
@@ -2479,21 +2474,23 @@ ieee80211_get_adjusted_he_cap(const struct ieee80211_conn_settings *conn,
}
}
-u8 *ieee80211_ie_build_he_cap(const struct ieee80211_conn_settings *conn,
- const struct ieee80211_sta_he_cap *he_cap,
- u8 *pos, u8 *end)
+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)
{
+ const struct ieee80211_sta_he_cap *he_cap;
struct ieee80211_he_cap_elem elem;
+ u8 *len;
u8 n;
u8 ie_len;
- u8 *orig_pos = pos;
if (!conn)
conn = &ieee80211_conn_settings_unlimited;
- /* Make sure we have place for the IE */
+ he_cap = ieee80211_get_he_iftype_cap_vif(sband, &sdata->vif);
if (!he_cap)
- return orig_pos;
+ return 0;
/* modify on stack first to calculate 'n' and 'ie_len' correctly */
ieee80211_get_adjusted_he_cap(conn, he_cap, &elem);
@@ -2504,19 +2501,17 @@ u8 *ieee80211_ie_build_he_cap(const struct ieee80211_conn_settings *conn,
ieee80211_he_ppe_size(he_cap->ppe_thres[0],
he_cap->he_cap_elem.phy_cap_info);
- if ((end - pos) < ie_len)
- return orig_pos;
+ if (skb_tailroom(skb) < ie_len)
+ return -ENOBUFS;
- *pos++ = WLAN_EID_EXTENSION;
- pos++; /* We'll set the size later below */
- *pos++ = WLAN_EID_EXT_HE_CAPABILITY;
+ skb_put_u8(skb, WLAN_EID_EXTENSION);
+ len = skb_put(skb, 1); /* We'll set the size later below */
+ skb_put_u8(skb, WLAN_EID_EXT_HE_CAPABILITY);
/* Fixed data */
- memcpy(pos, &elem, sizeof(elem));
- pos += sizeof(elem);
+ skb_put_data(skb, &elem, sizeof(elem));
- memcpy(pos, &he_cap->he_mcs_nss_supp, n);
- pos += n;
+ skb_put_data(skb, &he_cap->he_mcs_nss_supp, n);
/* Check if PPE Threshold should be present */
if ((he_cap->he_cap_elem.phy_cap_info[6] &
@@ -2540,12 +2535,11 @@ u8 *ieee80211_ie_build_he_cap(const struct ieee80211_conn_settings *conn,
n = DIV_ROUND_UP(n, 8);
/* Copy PPE Thresholds */
- memcpy(pos, &he_cap->ppe_thres, n);
- pos += n;
+ skb_put_data(skb, &he_cap->ppe_thres, n);
end:
- orig_pos[1] = (pos - orig_pos) - 2;
- return pos;
+ *len = skb_tail_pointer(skb) - len - 1;
+ return 0;
}
int ieee80211_put_he_6ghz_cap(struct sk_buff *skb,