Skip to content

Commit fa2b73b

Browse files
ilanpeer2jmberg-intel
authored andcommitted
wifi: mac80211: Pull link space calculation to a function
Pull the calculation of the size needed for a link in an association request frame to a function, so it could also be used during the construction of other frames as well, e.g., ML link configuration request frame. Signed-off-by: Ilan Peer <[email protected]> Reviewed-by: Johannes Berg <[email protected]> Signed-off-by: Miri Korenblit <[email protected]> Link: https://patch.msgid.link/20250102161730.ac16adfa39d4.I9e28c2fcd5ca252341c817fc03ea8df7b807fcbf@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 136a4e8 commit fa2b73b

File tree

1 file changed

+53
-31
lines changed

1 file changed

+53
-31
lines changed

net/mac80211/mlme.c

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,55 @@ ieee80211_assoc_add_ml_elem(struct ieee80211_sub_if_data *sdata,
18641864
ieee80211_fragment_element(skb, ml_elem_len, WLAN_EID_FRAGMENT);
18651865
}
18661866

1867+
static int
1868+
ieee80211_link_common_elems_size(struct ieee80211_sub_if_data *sdata,
1869+
enum nl80211_iftype iftype,
1870+
struct cfg80211_bss *cbss,
1871+
size_t elems_len)
1872+
{
1873+
struct ieee80211_local *local = sdata->local;
1874+
const struct ieee80211_sband_iftype_data *iftd;
1875+
struct ieee80211_supported_band *sband;
1876+
size_t size = 0;
1877+
1878+
if (!cbss)
1879+
return size;
1880+
1881+
sband = local->hw.wiphy->bands[cbss->channel->band];
1882+
1883+
/* add STA profile elements length */
1884+
size += elems_len;
1885+
1886+
/* and supported rates length */
1887+
size += 4 + sband->n_bitrates;
1888+
1889+
/* supported channels */
1890+
size += 2 + 2 * sband->n_channels;
1891+
1892+
iftd = ieee80211_get_sband_iftype_data(sband, iftype);
1893+
if (iftd)
1894+
size += iftd->vendor_elems.len;
1895+
1896+
/* power capability */
1897+
size += 4;
1898+
1899+
/* HT, VHT, HE, EHT */
1900+
size += 2 + sizeof(struct ieee80211_ht_cap);
1901+
size += 2 + sizeof(struct ieee80211_vht_cap);
1902+
size += 2 + 1 + sizeof(struct ieee80211_he_cap_elem) +
1903+
sizeof(struct ieee80211_he_mcs_nss_supp) +
1904+
IEEE80211_HE_PPE_THRES_MAX_LEN;
1905+
1906+
if (sband->band == NL80211_BAND_6GHZ)
1907+
size += 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa);
1908+
1909+
size += 2 + 1 + sizeof(struct ieee80211_eht_cap_elem) +
1910+
sizeof(struct ieee80211_eht_mcs_nss_supp) +
1911+
IEEE80211_EHT_PPE_THRES_MAX_LEN;
1912+
1913+
return size;
1914+
}
1915+
18671916
static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
18681917
{
18691918
struct ieee80211_local *local = sdata->local;
@@ -1902,42 +1951,15 @@ static int ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
19021951

19031952
for (link_id = 0; link_id < IEEE80211_MLD_MAX_NUM_LINKS; link_id++) {
19041953
struct cfg80211_bss *cbss = assoc_data->link[link_id].bss;
1905-
const struct ieee80211_sband_iftype_data *iftd;
1906-
struct ieee80211_supported_band *sband;
1954+
size_t elems_len = assoc_data->link[link_id].elems_len;
19071955

19081956
if (!cbss)
19091957
continue;
19101958

1911-
sband = local->hw.wiphy->bands[cbss->channel->band];
1912-
19131959
n_links++;
1914-
/* add STA profile elements length */
1915-
size += assoc_data->link[link_id].elems_len;
1916-
/* and supported rates length */
1917-
size += 4 + sband->n_bitrates;
1918-
/* supported channels */
1919-
size += 2 + 2 * sband->n_channels;
1920-
1921-
iftd = ieee80211_get_sband_iftype_data(sband, iftype);
1922-
if (iftd)
1923-
size += iftd->vendor_elems.len;
1924-
1925-
/* power capability */
1926-
size += 4;
1927-
1928-
/* HT, VHT, HE, EHT */
1929-
size += 2 + sizeof(struct ieee80211_ht_cap);
1930-
size += 2 + sizeof(struct ieee80211_vht_cap);
1931-
size += 2 + 1 + sizeof(struct ieee80211_he_cap_elem) +
1932-
sizeof(struct ieee80211_he_mcs_nss_supp) +
1933-
IEEE80211_HE_PPE_THRES_MAX_LEN;
1934-
1935-
if (sband->band == NL80211_BAND_6GHZ)
1936-
size += 2 + 1 + sizeof(struct ieee80211_he_6ghz_capa);
1937-
1938-
size += 2 + 1 + sizeof(struct ieee80211_eht_cap_elem) +
1939-
sizeof(struct ieee80211_eht_mcs_nss_supp) +
1940-
IEEE80211_EHT_PPE_THRES_MAX_LEN;
1960+
1961+
size += ieee80211_link_common_elems_size(sdata, iftype, cbss,
1962+
elems_len);
19411963

19421964
/* non-inheritance element */
19431965
size += 2 + 2 + PRESENT_ELEMS_MAX;

0 commit comments

Comments
 (0)