octeontx2-pf: Fix error return code in otx2_probe()
[linux/fpc-iii.git] / net / mac80211 / he.c
blob1087f715338b5626e81e15bd3c1bfc83bbff5b4a
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * HE handling
5 * Copyright(c) 2017 Intel Deutschland GmbH
6 * Copyright(c) 2019 - 2020 Intel Corporation
7 */
9 #include "ieee80211_i.h"
11 void
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,
15 struct sta_info *sta)
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;
19 u8 he_ppe_size;
20 u8 mcs_nss_size;
21 u8 he_total_size;
23 memset(he_cap, 0, sizeof(*he_cap));
25 if (!he_cap_ie || !ieee80211_get_he_sta_cap(sband))
26 return;
28 /* Make sure size is OK */
29 mcs_nss_size = ieee80211_he_mcs_nss_size(he_cap_ie_elem);
30 he_ppe_size =
31 ieee80211_he_ppe_size(he_cap_ie[sizeof(he_cap->he_cap_elem) +
32 mcs_nss_size],
33 he_cap_ie_elem->phy_cap_info);
34 he_total_size = sizeof(he_cap->he_cap_elem) + mcs_nss_size +
35 he_ppe_size;
36 if (he_cap_len < he_total_size)
37 return;
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],
50 he_ppe_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);
58 void
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;
65 if (!he_op_ie_elem) {
66 memset(he_operation, 0, sizeof(*he_operation));
67 return;
70 vif->bss_conf.he_operation = *he_op_ie_elem;
73 void
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;
79 const u8 *data;
81 memset(he_obss_pd, 0, sizeof(*he_obss_pd));
83 if (!he_spr_ie_elem)
84 return;
85 data = he_spr_ie_elem->optional;
87 if (he_spr_ie_elem->he_sr_control &
88 IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)
89 data++;
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;