2 * hostapd / IEEE 802.11ac VHT
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of BSD license
8 * See README and COPYING for more details.
11 #include "utils/includes.h"
13 #include "utils/common.h"
14 #include "common/ieee802_11_defs.h"
16 #include "ap_config.h"
19 #include "ieee802_11.h"
22 u8 * hostapd_eid_vht_capabilities(struct hostapd_data *hapd, u8 *eid)
24 struct ieee80211_vht_capabilities *cap;
27 if (!hapd->iconf->ieee80211ac || !hapd->iface->current_mode ||
28 hapd->conf->disable_11ac)
31 *pos++ = WLAN_EID_VHT_CAP;
32 *pos++ = sizeof(*cap);
34 cap = (struct ieee80211_vht_capabilities *) pos;
35 os_memset(cap, 0, sizeof(*cap));
36 cap->vht_capabilities_info = host_to_le32(
37 hapd->iface->conf->vht_capab);
39 /* Supported MCS set comes from hw */
40 os_memcpy(&cap->vht_supported_mcs_set,
41 hapd->iface->current_mode->vht_mcs_set, 8);
49 u8 * hostapd_eid_vht_operation(struct hostapd_data *hapd, u8 *eid)
51 struct ieee80211_vht_operation *oper;
54 if (!hapd->iconf->ieee80211ac || hapd->conf->disable_11ac)
57 *pos++ = WLAN_EID_VHT_OPERATION;
58 *pos++ = sizeof(*oper);
60 oper = (struct ieee80211_vht_operation *) pos;
61 os_memset(oper, 0, sizeof(*oper));
64 * center freq = 5 GHz + (5 * index)
65 * So index 42 gives center freq 5.210 GHz
66 * which is channel 42 in 5G band
68 oper->vht_op_info_chan_center_freq_seg0_idx =
69 hapd->iconf->vht_oper_centr_freq_seg0_idx;
70 oper->vht_op_info_chan_center_freq_seg1_idx =
71 hapd->iconf->vht_oper_centr_freq_seg1_idx;
73 oper->vht_op_info_chwidth = hapd->iconf->vht_oper_chwidth;
75 /* VHT Basic MCS set comes from hw */
76 /* Hard code 1 stream, MCS0-7 is a min Basic VHT MCS rates */
77 oper->vht_basic_mcs_set = host_to_le16(0xfffc);
84 u16 copy_sta_vht_capab(struct hostapd_data *hapd, struct sta_info *sta,
85 const u8 *vht_capab, size_t vht_capab_len)
87 /* Disable VHT caps for STAs associated to no-VHT BSSes. */
89 vht_capab_len < sizeof(struct ieee80211_vht_capabilities) ||
90 hapd->conf->disable_11ac) {
91 sta->flags &= ~WLAN_STA_VHT;
92 os_free(sta->vht_capabilities);
93 sta->vht_capabilities = NULL;
94 return WLAN_STATUS_SUCCESS;
97 if (sta->vht_capabilities == NULL) {
98 sta->vht_capabilities =
99 os_zalloc(sizeof(struct ieee80211_vht_capabilities));
100 if (sta->vht_capabilities == NULL)
101 return WLAN_STATUS_UNSPECIFIED_FAILURE;
104 sta->flags |= WLAN_STA_VHT;
105 os_memcpy(sta->vht_capabilities, vht_capab,
106 sizeof(struct ieee80211_vht_capabilities));
108 return WLAN_STATUS_SUCCESS;
111 void hostapd_get_vht_capab(struct hostapd_data *hapd,
112 struct ieee80211_vht_capabilities *vht_cap,
113 struct ieee80211_vht_capabilities *neg_vht_cap)
115 u32 cap, own_cap, sym_caps;
119 os_memcpy(neg_vht_cap, vht_cap, sizeof(*neg_vht_cap));
121 cap = le_to_host32(neg_vht_cap->vht_capabilities_info);
122 own_cap = hapd->iconf->vht_capab;
124 /* mask out symmetric VHT capabilities we don't support */
125 sym_caps = VHT_CAP_SHORT_GI_80 | VHT_CAP_SHORT_GI_160;
126 cap &= ~sym_caps | (own_cap & sym_caps);
128 /* mask out beamformer/beamformee caps if not supported */
129 if (!(own_cap & VHT_CAP_SU_BEAMFORMER_CAPABLE))
130 cap &= ~(VHT_CAP_SU_BEAMFORMEE_CAPABLE |
131 VHT_CAP_BEAMFORMEE_STS_MAX);
133 if (!(own_cap & VHT_CAP_SU_BEAMFORMEE_CAPABLE))
134 cap &= ~(VHT_CAP_SU_BEAMFORMER_CAPABLE |
135 VHT_CAP_SOUNDING_DIMENSION_MAX);
137 if (!(own_cap & VHT_CAP_MU_BEAMFORMER_CAPABLE))
138 cap &= ~VHT_CAP_MU_BEAMFORMEE_CAPABLE;
140 if (!(own_cap & VHT_CAP_MU_BEAMFORMEE_CAPABLE))
141 cap &= ~VHT_CAP_MU_BEAMFORMER_CAPABLE;
143 /* mask channel widths we don't support */
144 switch (own_cap & VHT_CAP_SUPP_CHAN_WIDTH_MASK) {
145 case VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ:
147 case VHT_CAP_SUPP_CHAN_WIDTH_160MHZ:
148 if (cap & VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ) {
149 cap &= ~VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
150 cap |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
154 cap &= ~VHT_CAP_SUPP_CHAN_WIDTH_MASK;
158 if (!(cap & VHT_CAP_SUPP_CHAN_WIDTH_MASK))
159 cap &= ~VHT_CAP_SHORT_GI_160;
162 * if we don't support RX STBC, mask out TX STBC in the STA's HT caps
163 * if we don't support TX STBC, mask out RX STBC in the STA's HT caps
165 if (!(own_cap & VHT_CAP_RXSTBC_MASK))
166 cap &= ~VHT_CAP_TXSTBC;
167 if (!(own_cap & VHT_CAP_TXSTBC))
168 cap &= ~VHT_CAP_RXSTBC_MASK;
170 neg_vht_cap->vht_capabilities_info = host_to_le32(cap);