Home | History | Annotate | Download | only in ap
      1 /*
      2  * hostapd / IEEE 802.11ax HE
      3  * Copyright (c) 2016-2017, Qualcomm Atheros, Inc.
      4  *
      5  * This software may be distributed under the terms of the BSD license.
      6  * See README for more details.
      7  */
      8 
      9 #include "utils/includes.h"
     10 
     11 #include "utils/common.h"
     12 #include "common/ieee802_11_defs.h"
     13 #include "common/qca-vendor.h"
     14 #include "hostapd.h"
     15 #include "ap_config.h"
     16 #include "beacon.h"
     17 #include "ieee802_11.h"
     18 #include "dfs.h"
     19 
     20 u8 * hostapd_eid_vendor_he_capab(struct hostapd_data *hapd, u8 *eid)
     21 {
     22 	struct ieee80211_he_capabilities *cap;
     23 	u8 *pos = eid;
     24 
     25 	if (!hapd->iface->current_mode)
     26 		return eid;
     27 
     28 	/* For now, use a vendor specific element since the P802.11ax draft is
     29 	 * still subject to changes and the contents of this element may change.
     30 	 * This can be replaced with the actual element once P802.11ax is
     31 	 * finalized. */
     32 	/* Vendor HE Capabilities element */
     33 	*pos++ = WLAN_EID_VENDOR_SPECIFIC;
     34 	*pos++ = 4 /* The Vendor OUI, subtype */ +
     35 		sizeof(struct ieee80211_he_capabilities);
     36 
     37 	WPA_PUT_BE32(pos, (OUI_QCA << 8) | QCA_VENDOR_ELEM_HE_CAPAB);
     38 	pos += 4;
     39 	cap = (struct ieee80211_he_capabilities *) pos;
     40 	os_memset(cap, 0, sizeof(*cap));
     41 
     42 	if (hapd->iface->conf->he_phy_capab.he_su_beamformer)
     43 		cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMER_CAPAB_IDX] |=
     44 			HE_PHYCAP_SU_BEAMFORMER_CAPAB;
     45 
     46 	if (hapd->iface->conf->he_phy_capab.he_su_beamformee)
     47 		cap->he_phy_capab_info[HE_PHYCAP_SU_BEAMFORMEE_CAPAB_IDX] |=
     48 			HE_PHYCAP_SU_BEAMFORMEE_CAPAB;
     49 
     50 	if (hapd->iface->conf->he_phy_capab.he_mu_beamformer)
     51 		cap->he_phy_capab_info[HE_PHYCAP_MU_BEAMFORMER_CAPAB_IDX] |=
     52 			HE_PHYCAP_MU_BEAMFORMER_CAPAB;
     53 
     54 	pos += sizeof(*cap);
     55 
     56 	return pos;
     57 }
     58 
     59 
     60 u8 * hostapd_eid_vendor_he_operation(struct hostapd_data *hapd, u8 *eid)
     61 {
     62 	struct ieee80211_he_operation *oper;
     63 	u8 *pos = eid;
     64 
     65 	if (!hapd->iface->current_mode)
     66 		return eid;
     67 
     68 	/* For now, use a vendor specific element since the P802.11ax draft is
     69 	 * still subject to changes and the contents of this element may change.
     70 	 * This can be replaced with the actual element once P802.11ax is
     71 	 * finalized. */
     72 	/* Vendor HE Operation element */
     73 	*pos++ = WLAN_EID_VENDOR_SPECIFIC;
     74 	*pos++ = 4 /* The Vendor OUI, subtype */ +
     75 		sizeof(struct ieee80211_he_operation);
     76 
     77 	WPA_PUT_BE32(pos, (OUI_QCA << 8) | QCA_VENDOR_ELEM_HE_OPER);
     78 	pos += 4;
     79 	oper = (struct ieee80211_he_operation *) pos;
     80 	os_memset(oper, 0, sizeof(*oper));
     81 
     82 	if (hapd->iface->conf->he_op.he_bss_color)
     83 		oper->he_oper_params |= hapd->iface->conf->he_op.he_bss_color;
     84 
     85 	if (hapd->iface->conf->he_op.he_default_pe_duration)
     86 		oper->he_oper_params |=
     87 			(hapd->iface->conf->he_op.he_default_pe_duration <<
     88 			 HE_OPERATION_DFLT_PE_DURATION_OFFSET);
     89 
     90 	if (hapd->iface->conf->he_op.he_twt_required)
     91 		oper->he_oper_params |= HE_OPERATION_TWT_REQUIRED;
     92 
     93 	if (hapd->iface->conf->he_op.he_rts_threshold)
     94 		oper->he_oper_params |=
     95 			(hapd->iface->conf->he_op.he_rts_threshold <<
     96 			 HE_OPERATION_RTS_THRESHOLD_OFFSET);
     97 
     98 	pos += sizeof(*oper);
     99 
    100 	return pos;
    101 }
    102