1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright(c) 2017 Intel Deutschland GmbH
8 #include "ieee80211_i.h"
11 ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data
*sdata
,
12 struct ieee80211_supported_band
*sband
,
13 const u8
*he_cap_ie
, u8 he_cap_len
,
16 struct ieee80211_sta_he_cap
*he_cap
= &sta
->sta
.he_cap
;
17 struct ieee80211_he_cap_elem
*he_cap_ie_elem
= (void *)he_cap_ie
;
22 memset(he_cap
, 0, sizeof(*he_cap
));
24 if (!he_cap_ie
|| !ieee80211_get_he_sta_cap(sband
))
27 /* Make sure size is OK */
28 mcs_nss_size
= ieee80211_he_mcs_nss_size(he_cap_ie_elem
);
30 ieee80211_he_ppe_size(he_cap_ie
[sizeof(he_cap
->he_cap_elem
) +
32 he_cap_ie_elem
->phy_cap_info
);
33 he_total_size
= sizeof(he_cap
->he_cap_elem
) + mcs_nss_size
+
35 if (he_cap_len
< he_total_size
)
38 memcpy(&he_cap
->he_cap_elem
, he_cap_ie
, sizeof(he_cap
->he_cap_elem
));
40 /* HE Tx/Rx HE MCS NSS Support Field */
41 memcpy(&he_cap
->he_mcs_nss_supp
,
42 &he_cap_ie
[sizeof(he_cap
->he_cap_elem
)], mcs_nss_size
);
44 /* Check if there are (optional) PPE Thresholds */
45 if (he_cap
->he_cap_elem
.phy_cap_info
[6] &
46 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT
)
47 memcpy(he_cap
->ppe_thres
,
48 &he_cap_ie
[sizeof(he_cap
->he_cap_elem
) + mcs_nss_size
],
51 he_cap
->has_he
= true;