1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright(c) 2017 Intel Deutschland GmbH
6 * Copyright(c) 2019 - 2020 Intel Corporation
9 #include "ieee80211_i.h"
12 ieee80211_he_cap_ie_to_sta_he_cap(struct ieee80211_sub_if_data
*sdata
,
13 struct ieee80211_supported_band
*sband
,
14 const u8
*he_cap_ie
, u8 he_cap_len
,
17 struct ieee80211_sta_he_cap
*he_cap
= &sta
->sta
.he_cap
;
18 struct ieee80211_he_cap_elem
*he_cap_ie_elem
= (void *)he_cap_ie
;
23 memset(he_cap
, 0, sizeof(*he_cap
));
25 if (!he_cap_ie
|| !ieee80211_get_he_sta_cap(sband
))
28 /* Make sure size is OK */
29 mcs_nss_size
= ieee80211_he_mcs_nss_size(he_cap_ie_elem
);
31 ieee80211_he_ppe_size(he_cap_ie
[sizeof(he_cap
->he_cap_elem
) +
33 he_cap_ie_elem
->phy_cap_info
);
34 he_total_size
= sizeof(he_cap
->he_cap_elem
) + mcs_nss_size
+
36 if (he_cap_len
< he_total_size
)
39 memcpy(&he_cap
->he_cap_elem
, he_cap_ie
, sizeof(he_cap
->he_cap_elem
));
41 /* HE Tx/Rx HE MCS NSS Support Field */
42 memcpy(&he_cap
->he_mcs_nss_supp
,
43 &he_cap_ie
[sizeof(he_cap
->he_cap_elem
)], mcs_nss_size
);
45 /* Check if there are (optional) PPE Thresholds */
46 if (he_cap
->he_cap_elem
.phy_cap_info
[6] &
47 IEEE80211_HE_PHY_CAP6_PPE_THRESHOLD_PRESENT
)
48 memcpy(he_cap
->ppe_thres
,
49 &he_cap_ie
[sizeof(he_cap
->he_cap_elem
) + mcs_nss_size
],
52 he_cap
->has_he
= true;
54 sta
->cur_max_bandwidth
= ieee80211_sta_cap_rx_bw(sta
);
55 sta
->sta
.bandwidth
= ieee80211_sta_cur_vht_bw(sta
);
59 ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif
*vif
,
60 const struct ieee80211_he_operation
*he_op_ie_elem
)
62 struct ieee80211_he_operation
*he_operation
=
63 &vif
->bss_conf
.he_operation
;
66 memset(he_operation
, 0, sizeof(*he_operation
));
70 vif
->bss_conf
.he_operation
= *he_op_ie_elem
;
74 ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif
*vif
,
75 const struct ieee80211_he_spr
*he_spr_ie_elem
)
77 struct ieee80211_he_obss_pd
*he_obss_pd
=
78 &vif
->bss_conf
.he_obss_pd
;
81 memset(he_obss_pd
, 0, sizeof(*he_obss_pd
));
85 data
= he_spr_ie_elem
->optional
;
87 if (he_spr_ie_elem
->he_sr_control
&
88 IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT
)
90 if (he_spr_ie_elem
->he_sr_control
&
91 IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT
) {
92 he_obss_pd
->max_offset
= *data
++;
93 he_obss_pd
->min_offset
= *data
++;
94 he_obss_pd
->enable
= true;