xref: /freebsd/contrib/wpa/wpa_supplicant/wmm_ac.h (revision 780fb4a2fa9a9aee5ac48a60b790f567c0dc13e9)
15b9c547cSRui Paulo /*
25b9c547cSRui Paulo  * Wi-Fi Multimedia Admission Control (WMM-AC)
35b9c547cSRui Paulo  * Copyright(c) 2014, Intel Mobile Communication GmbH.
45b9c547cSRui Paulo  * Copyright(c) 2014, Intel Corporation. All rights reserved.
55b9c547cSRui Paulo  *
65b9c547cSRui Paulo  * This software may be distributed under the terms of the BSD license.
75b9c547cSRui Paulo  * See README for more details.
85b9c547cSRui Paulo  */
95b9c547cSRui Paulo 
105b9c547cSRui Paulo #ifndef WMM_AC_H
115b9c547cSRui Paulo #define WMM_AC_H
125b9c547cSRui Paulo 
135b9c547cSRui Paulo #include "common/ieee802_11_defs.h"
145b9c547cSRui Paulo #include "drivers/driver.h"
155b9c547cSRui Paulo 
165b9c547cSRui Paulo struct wpa_supplicant;
175b9c547cSRui Paulo 
185b9c547cSRui Paulo #define WMM_AC_ACCESS_POLICY_EDCA 1
195b9c547cSRui Paulo #define WMM_AC_FIXED_MSDU_SIZE BIT(15)
205b9c547cSRui Paulo 
215b9c547cSRui Paulo #define WMM_AC_MAX_TID 7
225b9c547cSRui Paulo #define WMM_AC_MAX_USER_PRIORITY 7
235b9c547cSRui Paulo #define WMM_AC_MIN_SBA_UNITY 0x2000
245b9c547cSRui Paulo #define WMM_AC_MAX_NOMINAL_MSDU 32767
255b9c547cSRui Paulo 
265b9c547cSRui Paulo /**
275b9c547cSRui Paulo  * struct wmm_ac_assoc_data - WMM Admission Control Association Data
285b9c547cSRui Paulo  *
295b9c547cSRui Paulo  * This struct will store any relevant WMM association data needed by WMM AC.
305b9c547cSRui Paulo  * In case there is a valid WMM association, an instance of this struct will be
315b9c547cSRui Paulo  * created. In case there is no instance of this struct, the station is not
325b9c547cSRui Paulo  * associated to a valid WMM BSS and hence, WMM AC will not be used.
335b9c547cSRui Paulo  */
345b9c547cSRui Paulo struct wmm_ac_assoc_data {
355b9c547cSRui Paulo 	struct {
365b9c547cSRui Paulo 		/*
375b9c547cSRui Paulo 		 * acm - Admission Control Mandatory
385b9c547cSRui Paulo 		 * In case an access category is ACM, the traffic will have
395b9c547cSRui Paulo 		 * to be admitted by WMM-AC's admission mechanism before use.
405b9c547cSRui Paulo 		 */
415b9c547cSRui Paulo 		unsigned int acm:1;
425b9c547cSRui Paulo 
435b9c547cSRui Paulo 		/*
445b9c547cSRui Paulo 		 * uapsd_queues - Unscheduled Automatic Power Save Delivery
455b9c547cSRui Paulo 		 *		  queues.
465b9c547cSRui Paulo 		 * Indicates whether ACs are configured for U-APSD (or legacy
475b9c547cSRui Paulo 		 * PS). Storing this value is necessary in order to set the
485b9c547cSRui Paulo 		 * Power Save Bit (PSB) in ADDTS request Action frames (if not
495b9c547cSRui Paulo 		 * given).
505b9c547cSRui Paulo 		 */
515b9c547cSRui Paulo 		unsigned int uapsd:1;
525b9c547cSRui Paulo 	} ac_params[WMM_AC_NUM];
535b9c547cSRui Paulo };
545b9c547cSRui Paulo 
555b9c547cSRui Paulo /**
565b9c547cSRui Paulo  * wmm_ac_dir - WMM Admission Control Direction
575b9c547cSRui Paulo  */
585b9c547cSRui Paulo enum wmm_ac_dir {
595b9c547cSRui Paulo 	WMM_AC_DIR_UPLINK = 0,
605b9c547cSRui Paulo 	WMM_AC_DIR_DOWNLINK = 1,
615b9c547cSRui Paulo 	WMM_AC_DIR_BIDIRECTIONAL = 3
625b9c547cSRui Paulo };
635b9c547cSRui Paulo 
645b9c547cSRui Paulo /**
655b9c547cSRui Paulo  * ts_dir_idx - indices of internally saved tspecs
665b9c547cSRui Paulo  *
675b9c547cSRui Paulo  * we can have multiple tspecs (downlink + uplink) per ac.
685b9c547cSRui Paulo  * save them in array, and use the enum to directly access
695b9c547cSRui Paulo  * the respective tspec slot (according to the direction).
705b9c547cSRui Paulo  */
715b9c547cSRui Paulo enum ts_dir_idx {
725b9c547cSRui Paulo 	TS_DIR_IDX_UPLINK,
735b9c547cSRui Paulo 	TS_DIR_IDX_DOWNLINK,
745b9c547cSRui Paulo 	TS_DIR_IDX_BIDI,
755b9c547cSRui Paulo 
765b9c547cSRui Paulo 	TS_DIR_IDX_COUNT
775b9c547cSRui Paulo };
785b9c547cSRui Paulo #define TS_DIR_IDX_ALL (BIT(TS_DIR_IDX_COUNT) - 1)
795b9c547cSRui Paulo 
805b9c547cSRui Paulo /**
815b9c547cSRui Paulo  * struct wmm_ac_addts_request - ADDTS Request Information
825b9c547cSRui Paulo  *
835b9c547cSRui Paulo  * The last sent ADDTS request(s) will be saved as element(s) of this struct in
845b9c547cSRui Paulo  * order to be compared with the received ADDTS response in ADDTS response
855b9c547cSRui Paulo  * action frame handling and should be stored until that point.
865b9c547cSRui Paulo  * In case a new traffic stream will be created/replaced/updated, only its
875b9c547cSRui Paulo  * relevant traffic stream information will be stored as a wmm_ac_ts struct.
885b9c547cSRui Paulo  */
895b9c547cSRui Paulo struct wmm_ac_addts_request {
905b9c547cSRui Paulo 	/*
91*780fb4a2SCy Schubert 	 * dialog token - Used to link the received ADDTS response with this
925b9c547cSRui Paulo 	 * saved ADDTS request when ADDTS response is being handled
935b9c547cSRui Paulo 	 */
945b9c547cSRui Paulo 	u8 dialog_token;
955b9c547cSRui Paulo 
965b9c547cSRui Paulo 	/*
975b9c547cSRui Paulo 	 * address - The alleged traffic stream's receiver/transmitter address
985b9c547cSRui Paulo 	 * Address and TID are used to identify the TS (TID is contained in
995b9c547cSRui Paulo 	 * TSPEC)
1005b9c547cSRui Paulo 	 */
1015b9c547cSRui Paulo 	u8 address[ETH_ALEN];
1025b9c547cSRui Paulo 
1035b9c547cSRui Paulo 	/*
1045b9c547cSRui Paulo 	 * tspec - Traffic Stream Specification, will be used to compare the
1055b9c547cSRui Paulo 	 * sent TSPEC in ADDTS request to the received TSPEC in ADDTS response
1065b9c547cSRui Paulo 	 * and act accordingly in ADDTS response handling
1075b9c547cSRui Paulo 	 */
1085b9c547cSRui Paulo 	struct wmm_tspec_element tspec;
1095b9c547cSRui Paulo };
1105b9c547cSRui Paulo 
1115b9c547cSRui Paulo 
1125b9c547cSRui Paulo /**
1135b9c547cSRui Paulo  * struct wmm_ac_ts_setup_params - TS setup parameters
1145b9c547cSRui Paulo  *
1155b9c547cSRui Paulo  * This struct holds parameters which should be provided
1165b9c547cSRui Paulo  * to wmm_ac_ts_setup in order to setup a traffic stream
1175b9c547cSRui Paulo  */
1185b9c547cSRui Paulo struct wmm_ac_ts_setup_params {
1195b9c547cSRui Paulo 	/*
1205b9c547cSRui Paulo 	 * tsid - Traffic ID
1215b9c547cSRui Paulo 	 * TID and address are used to identify the TS
1225b9c547cSRui Paulo 	 */
1235b9c547cSRui Paulo 	int tsid;
1245b9c547cSRui Paulo 
1255b9c547cSRui Paulo 	/*
1265b9c547cSRui Paulo 	 * direction - Traffic Stream's direction
1275b9c547cSRui Paulo 	 */
1285b9c547cSRui Paulo 	enum wmm_ac_dir direction;
1295b9c547cSRui Paulo 
1305b9c547cSRui Paulo 	/*
1315b9c547cSRui Paulo 	 * user_priority - Traffic Stream's user priority
1325b9c547cSRui Paulo 	 */
1335b9c547cSRui Paulo 	int user_priority;
1345b9c547cSRui Paulo 
1355b9c547cSRui Paulo 	/*
1365b9c547cSRui Paulo 	 * nominal_msdu_size - Nominal MAC service data unit size
1375b9c547cSRui Paulo 	 */
1385b9c547cSRui Paulo 	int nominal_msdu_size;
1395b9c547cSRui Paulo 
1405b9c547cSRui Paulo 	/*
1415b9c547cSRui Paulo 	 * fixed_nominal_msdu - Whether the size is fixed
1425b9c547cSRui Paulo 	 * 0 = Nominal MSDU size is not fixed
1435b9c547cSRui Paulo 	 * 1 = Nominal MSDU size is fixed
1445b9c547cSRui Paulo 	 */
1455b9c547cSRui Paulo 	int fixed_nominal_msdu;
1465b9c547cSRui Paulo 
1475b9c547cSRui Paulo 	/*
1485b9c547cSRui Paulo 	 * surplus_bandwidth_allowance - Specifies excess time allocation
1495b9c547cSRui Paulo 	 */
1505b9c547cSRui Paulo 	int mean_data_rate;
1515b9c547cSRui Paulo 
1525b9c547cSRui Paulo 	/*
1535b9c547cSRui Paulo 	 * minimum_phy_rate - Specifies the minimum supported PHY rate in bps
1545b9c547cSRui Paulo 	 */
1555b9c547cSRui Paulo 	int minimum_phy_rate;
1565b9c547cSRui Paulo 
1575b9c547cSRui Paulo 	/*
1585b9c547cSRui Paulo 	 * surplus_bandwidth_allowance - Specifies excess time allocation
1595b9c547cSRui Paulo 	 */
1605b9c547cSRui Paulo 	int surplus_bandwidth_allowance;
1615b9c547cSRui Paulo };
1625b9c547cSRui Paulo 
1635b9c547cSRui Paulo void wmm_ac_notify_assoc(struct wpa_supplicant *wpa_s, const u8 *ies,
1645b9c547cSRui Paulo 			 size_t ies_len, const struct wmm_params *wmm_params);
1655b9c547cSRui Paulo void wmm_ac_notify_disassoc(struct wpa_supplicant *wpa_s);
1665b9c547cSRui Paulo int wpas_wmm_ac_addts(struct wpa_supplicant *wpa_s,
1675b9c547cSRui Paulo 		      struct wmm_ac_ts_setup_params *params);
1685b9c547cSRui Paulo int wpas_wmm_ac_delts(struct wpa_supplicant *wpa_s, u8 tsid);
1695b9c547cSRui Paulo void wmm_ac_rx_action(struct wpa_supplicant *wpa_s, const u8 *da,
1705b9c547cSRui Paulo 			const u8 *sa, const u8 *data, size_t len);
1715b9c547cSRui Paulo int wpas_wmm_ac_status(struct wpa_supplicant *wpa_s, char *buf, size_t buflen);
1725b9c547cSRui Paulo void wmm_ac_save_tspecs(struct wpa_supplicant *wpa_s);
1735b9c547cSRui Paulo void wmm_ac_clear_saved_tspecs(struct wpa_supplicant *wpa_s);
1745b9c547cSRui Paulo int wmm_ac_restore_tspecs(struct wpa_supplicant *wpa_s);
1755b9c547cSRui Paulo 
1765b9c547cSRui Paulo #endif /* WMM_AC_H */
177