xref: /wlan-driver/qcacld-3.0/core/sme/inc/sme_qos_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #if !defined(__SME_QOSAPI_H)
20 #define __SME_QOSAPI_H
21 
22 /**
23  * \file  sme_qos_api.h
24  *
25  * \brief prototype for SME QoS APIs
26  */
27 
28 /* Include Files */
29 #include "qdf_lock.h"
30 #include "qdf_trace.h"
31 #include "qdf_mem.h"
32 #include "qdf_types.h"
33 #include "ani_global.h"
34 #include "sir_api.h"
35 
36 /* Pre-processor Definitions */
37 #define SME_QOS_UAPSD_VO      0x01
38 #define SME_QOS_UAPSD_VI      0x02
39 #define SME_QOS_UAPSD_BE      0x08
40 #define SME_QOS_UAPSD_BK      0x04
41 
42 /* Enumeration of the various QoS status types that would be reported to HDD */
43 enum sme_qos_statustype {
44 	/*
45 	 * async: once PE notifies successful TSPEC negotiation, or CSR notifies
46 	 * for successful reassoc, notifies HDD with current QoS Params
47 	 */
48 	SME_QOS_STATUS_SETUP_SUCCESS_IND = 0,
49 	/* sync: only when App asked for APSD & it's already set with ACM = 0 */
50 	SME_QOS_STATUS_SETUP_SUCCESS_APSD_SET_ALREADY,
51 	/* sync or async: in case of async notify HDD with current QoS Params */
52 	SME_QOS_STATUS_SETUP_FAILURE_RSP,
53 	/* sync */
54 	SME_QOS_STATUS_SETUP_INVALID_PARAMS_RSP,
55 	/* sync: AP doesn't support QoS (WMM) */
56 	SME_QOS_STATUS_SETUP_NOT_QOS_AP_RSP,
57 	/* sync: either req has been sent down to PE or just buffered in SME */
58 	SME_QOS_STATUS_SETUP_REQ_PENDING_RSP,
59 	/*
60 	 * async: in case of flow aggregation, if the new TSPEC negotiation
61 	 * is successful, OR, notify existing flows that TSPEC is modified with
62 	 * current QoS Params
63 	 */
64 	SME_QOS_STATUS_SETUP_MODIFIED_IND,
65 	/* sync: no APSD asked for & ACM = 0 */
66 	SME_QOS_STATUS_SETUP_SUCCESS_NO_ACM_NO_APSD_RSP,
67 	/*
68 	 * async: In case of UAPSD, once PE notifies successful TSPEC
69 	 * negotiation, or CSR notifies for successful reassoc to SME-QoS,
70 	 * notify HDD if PMC can't put the module in UAPSD mode right away
71 	 * (QDF_STATUS_PMC_PENDING)
72 	 */
73 	SME_QOS_STATUS_SETUP_SUCCESS_IND_APSD_PENDING,
74 	/*
75 	 * async: In case of UAPSD, once PE notifies successful TSPEC
76 	 * negotiation, or CSR notifies for successful reassoc to SME-QoS,
77 	 * notify HDD if PMC can't put the module in UAPSD mode at all
78 	 * (QDF_STATUS_E_FAILURE)
79 	 */
80 	SME_QOS_STATUS_SETUP_SUCCESS_IND_APSD_SET_FAILED,
81 	/*
82 	 * sync: req has been sent down to PE in case of delts or addts
83 	 * for remain flows, OR if the AC doesn't have APSD or ACM
84 	 * async: once the downgrade req for QoS params is successful
85 	 */
86 	SME_QOS_STATUS_RELEASE_SUCCESS_RSP = 100,
87 	/* sync or async: in case of async notify HDD with current QoS Param */
88 	SME_QOS_STATUS_RELEASE_FAILURE_RSP,
89 	/* async: AP sent DELTS indication */
90 	SME_QOS_STATUS_RELEASE_QOS_LOST_IND,
91 	/*
92 	 * sync: an addts req has been sent down to PE to downgrade the
93 	 * QoS params or just buffered in SME
94 	 */
95 	SME_QOS_STATUS_RELEASE_REQ_PENDING_RSP,
96 	/* sync */
97 	SME_QOS_STATUS_RELEASE_INVALID_PARAMS_RSP,
98 	/*
99 	 * async: for QoS modify request if modification is successful,
100 	 * notifies HDD with current QoS Params
101 	 */
102 	SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_IND = 200,
103 	/* sync: only when App asked for APSD & it's already set with ACM = 0 */
104 	SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_APSD_SET_ALREADY,
105 	/* sync or async: in case of async notify HDD with current QoS Param */
106 	SME_QOS_STATUS_MODIFY_SETUP_FAILURE_RSP,
107 	/* sync: either req has been sent down to PE or just buffered in SME */
108 	SME_QOS_STATUS_MODIFY_SETUP_PENDING_RSP,
109 	/* sync: no APSD asked for & ACM = 0 */
110 	SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_NO_ACM_NO_APSD_RSP,
111 	/* sync */
112 	SME_QOS_STATUS_MODIFY_SETUP_INVALID_PARAMS_RSP,
113 	/*
114 	 * async: In case of UAPSD, once PE notifies successful TSPEC
115 	 * negotiation or CSR notifies for successful reassoc to SME-QoS,
116 	 * notify HDD if PMC can't put the module in UAPSD mode right away
117 	 * (QDF_STATUS_PMC_PENDING)
118 	 */
119 	SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_IND_APSD_PENDING,
120 	/*
121 	 * async: In case of UAPSD, once PE notifies successful TSPEC
122 	 * negotiation, or CSR notifies for successful reassoc to SME-QoS,
123 	 * notify HDD if PMC can't put the module in UAPSD mode at all
124 	 * (QDF_STATUS_E_FAILURE)
125 	 */
126 	SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_IND_APSD_SET_FAILED,
127 	/* sync: STA is handing off to a new AP */
128 	SME_QOS_STATUS_HANDING_OFF = 300,
129 	/* async:powersave mode changed by PMC from UAPSD to Full power */
130 	SME_QOS_STATUS_OUT_OF_APSD_POWER_MODE_IND = 400,
131 	/* async:powersave mode changed by PMC from Full power to UAPSD */
132 	SME_QOS_STATUS_INTO_APSD_POWER_MODE_IND,
133 
134 };
135 
136 #define WLAN_MAX_DSCP 0x3f
137 
138 /*
139  * Enumeration of the various User priority (UP) types
140  * From 802.1D/802.11e/WMM specifications (all refer to same table)
141  */
142 enum sme_qos_wmmuptype {
143 	SME_QOS_WMM_UP_BE = 0,
144 	SME_QOS_WMM_UP_BK = 1,
145 	SME_QOS_WMM_UP_RESV = 2,        /* Reserved */
146 	SME_QOS_WMM_UP_EE = 3,
147 	SME_QOS_WMM_UP_CL = 4,
148 	SME_QOS_WMM_UP_VI = 5,
149 	SME_QOS_WMM_UP_VO = 6,
150 	SME_QOS_WMM_UP_NC = 7,
151 	SME_QOS_WMM_UP_MAX
152 };
153 
154 /*
155  * Enumeration of the various TSPEC ack policies.
156  * From 802.11 WMM specification
157  */
158 enum sme_qos_wmmack_policytype {
159 	SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK = 0,
160 	SME_QOS_WMM_TS_ACK_POLICY_RESV1 = 1,
161 	SME_QOS_WMM_TS_ACK_POLICY_RESV2 = 2,    /* Reserved */
162 	SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK = 3,
163 
164 };
165 
166 /*
167  * TS Info field in the WMM TSPEC
168  * See suggestive values above
169  */
170 struct sme_qos_wmmts_infotype {
171 	uint8_t burst_size_defn;
172 	enum sme_qos_wmmack_policytype ack_policy;
173 	enum sme_qos_wmmuptype up;    /* User priority */
174 	uint8_t psb;            /* power-save bit */
175 	enum sme_qos_wmm_dir_type direction;    /* Direction */
176 	uint8_t tid;            /* TID : To be filled up by SME-QoS */
177 };
178 
179 /* The WMM TSPEC Element (from the WMM spec)*/
180 struct sme_qos_wmmtspecinfo {
181 	struct sme_qos_wmmts_infotype ts_info;
182 	uint16_t nominal_msdu_size;
183 	uint16_t maximum_msdu_size;
184 	uint32_t min_service_interval;
185 	uint32_t max_service_interval;
186 	uint32_t inactivity_interval;
187 	uint32_t suspension_interval;
188 	uint32_t svc_start_time;
189 	uint32_t min_data_rate;
190 	uint32_t mean_data_rate;
191 	uint32_t peak_data_rate;
192 	uint32_t max_burst_size;
193 	uint32_t delay_bound;
194 	uint32_t min_phy_rate;
195 	uint16_t surplus_bw_allowance;
196 	uint16_t medium_time;
197 };
198 
qca_wlan_ac_to_sme_qos(u8 priority)199 static inline enum sme_qos_wmmuptype qca_wlan_ac_to_sme_qos(u8 priority)
200 {
201 	switch (priority) {
202 	case QCA_WLAN_AC_BE:
203 		return SME_QOS_WMM_UP_BE;
204 	case QCA_WLAN_AC_BK:
205 		return SME_QOS_WMM_UP_BK;
206 	case QCA_WLAN_AC_VI:
207 		return SME_QOS_WMM_UP_VI;
208 	case QCA_WLAN_AC_VO:
209 		return SME_QOS_WMM_UP_VO;
210 	default:
211 		return SME_QOS_WMM_UP_BE;
212 	}
213 }
214 
215 /* External APIs */
216 typedef QDF_STATUS (*sme_QosCallback)(mac_handle_t mac_handle, void *HDDcontext,
217 		struct sme_qos_wmmtspecinfo *pCurrentQoSInfo,
218 		enum sme_qos_statustype status, uint32_t QosFlowID);
219 enum sme_qos_statustype sme_qos_setup_req(mac_handle_t mac_handle,
220 					  uint32_t sessionId,
221 					  struct sme_qos_wmmtspecinfo *pQoSInfo,
222 					  sme_QosCallback QoSCallback,
223 					  void *HDDcontext,
224 					  enum sme_qos_wmmuptype UPType,
225 					  uint32_t *pQosFlowID);
226 enum sme_qos_statustype sme_qos_modify_req(mac_handle_t mac_handle,
227 		struct sme_qos_wmmtspecinfo *pQoSInfo, uint32_t QosFlowID);
228 enum sme_qos_statustype sme_qos_release_req(mac_handle_t mac_handle,
229 					    uint8_t session_id,
230 					    uint32_t QosFlowID);
231 bool sme_qos_is_ts_info_ack_policy_valid(mac_handle_t mac_handle,
232 					 struct sme_qos_wmmtspecinfo *pQoSInfo,
233 					 uint8_t sessionId);
234 void sme_qos_update_hand_off(uint8_t sessionId, bool updateHandOff);
235 QDF_STATUS sme_update_dsc_pto_up_mapping(mac_handle_t mac_handle,
236 		enum sme_qos_wmmuptype *dscpmapping, uint8_t sessionId);
237 
238 QDF_STATUS sme_offload_qos_process_out_of_uapsd_mode(struct mac_context *mac_ctx,
239 		uint32_t session_id);
240 QDF_STATUS sme_offload_qos_process_into_uapsd_mode(struct mac_context *mac_ctx,
241 		uint32_t session_id);
242 
243 
244 #endif /* #if !defined( __SME_QOSAPI_H ) */
245