blob: 082fa1ae154dc55dfa20c8551e9dcd3798ee6313 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2013 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Kiet Lamaa8e15a2014-02-11 23:30:06 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028#ifndef _WLAN_HDD_WMM_H
29#define _WLAN_HDD_WMM_H
30/*============================================================================
31 @file wlan_hdd_wmm.h
32
33 This module (wlan_hdd_wmm.h interface + wlan_hdd_wmm.c implementation)
34 houses all the logic for WMM in HDD.
35
36 On the control path, it has the logic to setup QoS, modify QoS and delete
37 QoS (QoS here refers to a TSPEC). The setup QoS comes in two flavors: an
38 explicit application invoked and an internal HDD invoked. The implicit QoS
39 is for applications that do NOT call the custom QCT WLAN OIDs for QoS but
40 which DO mark their traffic for priortization. It also has logic to start,
41 update and stop the U-APSD trigger frame generation. It also has logic to
42 read WMM related config parameters from the registry.
43
44 On the data path, it has the logic to figure out the WMM AC of an egress
45 packet and when to signal TL to serve a particular AC queue. It also has the
46 logic to retrieve a packet based on WMM priority in response to a fetch from
47 TL.
48
49 The remaining functions are utility functions for information hiding.
Jeff Johnson295189b2012-06-20 16:38:30 -070050============================================================================*/
51/* $Header$ */
52
53/*----------------------------------------------------------------------------
54 * Include Files
55 * -------------------------------------------------------------------------*/
56#include <linux/workqueue.h>
57#include <linux/list.h>
58#include <wlan_hdd_main.h>
59#include <wlan_hdd_wext.h>
60#include <wlan_qct_tl.h>
61#include <sme_QosApi.h>
62
63/*----------------------------------------------------------------------------
64 * Preprocessor Definitions and Constants
65 * -------------------------------------------------------------------------*/
66
67// #define HDD_WMM_DEBUG 1
68
69#define HDD_WMM_CTX_MAGIC 0x574d4d58 // "WMMX"
70
71#define HDD_WMM_HANDLE_IMPLICIT 0xFFFFFFFF
72
73#define HDD_WLAN_INVALID_STA_ID 0xFF
74
75/*----------------------------------------------------------------------------
76 * Type Declarations
77 * -------------------------------------------------------------------------*/
78/*! @brief AC/Queue Index values for Linux Qdisc to operate on different traffic.
79*/
80typedef enum
81{
82 HDD_LINUX_AC_VO = 0,
83 HDD_LINUX_AC_VI = 1,
84 HDD_LINUX_AC_BE = 2,
85 HDD_LINUX_AC_BK = 3
86
87} hdd_wmm_linuxac_t;
88
89/*! @brief types of classification supported
90*/
91typedef enum
92{
93 HDD_WMM_CLASSIFICATION_DSCP = 0,
94 HDD_WMM_CLASSIFICATION_802_1Q = 1
95
96} hdd_wmm_classification_t;
97
98/*! @brief UAPSD state
99*/
100typedef enum
101{
102 HDD_WMM_NON_UAPSD = 0,
103 HDD_WMM_UAPSD = 1
104
105} hdd_wmm_uapsd_state_t;
106
107
108typedef enum
109{
110 //STA can associate with any AP, & HDD looks at the SME notification after
111 // association to find out if associated with QAP and acts accordingly
112 HDD_WMM_USER_MODE_AUTO = 0,
113 //SME will add the extra logic to make sure STA associates with a QAP only
114 HDD_WMM_USER_MODE_QBSS_ONLY = 1,
115 //SME will not join a QoS AP, unless the phy mode setting says "Auto". In
116 // that case, STA is free to join 11n AP. Although from HDD point of view,
117 // it will not be doing any packet classifications
118 HDD_WMM_USER_MODE_NO_QOS = 2,
119
120} hdd_wmm_user_mode_t;
121
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +0530122// UAPSD Mask bits
123// (Bit0:VO; Bit1:VI; Bit2:BK; Bit3:BE all other bits are ignored)
124#define HDD_AC_VO 0x1
125#define HDD_AC_VI 0x2
126#define HDD_AC_BK 0x4
127#define HDD_AC_BE 0x8
Jeff Johnson295189b2012-06-20 16:38:30 -0700128
129/*! @brief WMM Qos instance control block
130*/
131typedef struct
132{
133 struct list_head node;
134 v_U32_t handle;
135 v_U32_t qosFlowId;
136 hdd_adapter_t* pAdapter;
137 WLANTL_ACEnumType acType;
138 hdd_wlan_wmm_status_e lastStatus;
139 struct work_struct wmmAcSetupImplicitQos;
140 v_U32_t magic;
141} hdd_wmm_qos_context_t;
142
143/*! @brief WMM related per-AC state & status info
144*/
145typedef struct
146{
147 // does the AP require access to this AC?
148 v_BOOL_t wmmAcAccessRequired;
149
150 // does the worker thread need to acquire access to this AC?
151 v_BOOL_t wmmAcAccessNeeded;
152
153 // is implicit QoS negotiation currently taking place?
154 v_BOOL_t wmmAcAccessPending;
155
156 // has implicit QoS negotiation already failed?
157 v_BOOL_t wmmAcAccessFailed;
158
159 // has implicit QoS negotiation already succeeded?
160 v_BOOL_t wmmAcAccessGranted;
161
162 // is access to this AC allowed, either because we are not doing
163 // WMM, we are not doing implicit QoS, implict QoS has completed,
164 // or explicit QoS has completed?
165 v_BOOL_t wmmAcAccessAllowed;
166
167 // is the wmmAcTspecInfo valid?
168 v_BOOL_t wmmAcTspecValid;
169
170 // are the wmmAcUapsd* fields valid?
171 v_BOOL_t wmmAcUapsdInfoValid;
172
173 // current (possibly aggregate) Tspec for this AC
174 sme_QosWmmTspecInfo wmmAcTspecInfo;
175
176 // current U-APSD parameters
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +0530177 v_BOOL_t wmmAcIsUapsdEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 v_U32_t wmmAcUapsdServiceInterval;
179 v_U32_t wmmAcUapsdSuspensionInterval;
180 sme_QosWmmDirType wmmAcUapsdDirection;
181
182#ifdef FEATURE_WLAN_CCX
183 // Inactivity time parameters for TSPEC
184 v_U32_t wmmInactivityTime;
185 v_U32_t wmmPrevTrafficCnt;
186 vos_timer_t wmmInactivityTimer;
187#endif
188
189} hdd_wmm_ac_status_t;
190
191/*! @brief WMM state & status info
192*/
193typedef struct
194{
195 struct list_head wmmContextList;
196 struct mutex wmmLock;
197 hdd_wmm_ac_status_t wmmAcStatus[WLANTL_MAX_AC];
198 v_BOOL_t wmmQap;
199 v_BOOL_t wmmQosConnection;
200} hdd_wmm_status_t;
201
202extern const v_U8_t hdd_QdiscAcToTlAC[];
203extern const v_U8_t hddWmmUpToAcMap[];
204extern const v_U8_t hddLinuxUpToAcMap[];
205
206/**============================================================================
207 @brief hdd_wmm_init() - Function which will initialize the WMM configuation
208 and status to an initial state. The configuration can later be overwritten
209 via application APIs
210
211 @param pHddCtx : [in] pointer to HDD context
212
213 @return : VOS_STATUS_SUCCESS if succssful
214 : other values if failure
215
216 ===========================================================================*/
217VOS_STATUS hdd_wmm_init ( hdd_context_t* pHddCtx );
218
219/**============================================================================
220 @brief hdd_wmm_adapter_init() - Function which will initialize the WMM configuation
221 and status to an initial state. The configuration can later be overwritten
222 via application APIs
223
224 @param pAdapter : [in] pointer to Adapter context
225
226 @return : VOS_STATUS_SUCCESS if succssful
227 : other values if failure
228
229 ===========================================================================*/
230VOS_STATUS hdd_wmm_adapter_init( hdd_adapter_t *pAdapter );
231
232/**============================================================================
233 @brief hdd_wmm_adapter_close() - Function which will perform any necessary work to
234 to clean up the WMM functionality prior to the kernel module unload
235
236 @param pAdapter : [in] pointer to adapter context
237
238 @return : VOS_STATUS_SUCCESS if succssful
239 : other values if failure
240
241 ===========================================================================*/
242VOS_STATUS hdd_wmm_adapter_close ( hdd_adapter_t* pAdapter );
243
244/**============================================================================
245 @brief hdd_wmm_select_queue() - Function which will classify an OS packet
246 into linux Qdisc expectation
247
248 @param dev : [in] pointer to net_device structure
249 @param skb : [in] pointer to OS packet (sk_buff)
250
251 @return : queue_index/linux AC value.
252 ===========================================================================*/
253v_U16_t hdd_wmm_select_queue(struct net_device * dev, struct sk_buff *skb);
254
255/**============================================================================
256 @brief hdd_hostapd_select_queue() - Function which will classify the packet
257 according to linux qdisc expectation.
258
259
260 @param dev : [in] pointer to net_device structure
261 @param skb : [in] pointer to os packet
262
263 @return : Qdisc queue index
264 ===========================================================================*/
265
266v_U16_t hdd_hostapd_select_queue(struct net_device * dev, struct sk_buff *skb);
267
268
269
270/**============================================================================
271 @brief hdd_wmm_classify_pkt() - Function which will classify an OS packet
272 into a WMM AC based on either 802.1Q or DSCP
273
274 @param pAdapter : [in] pointer to adapter context
275 @param skb : [in] pointer to OS packet (sk_buff)
276 @param pAcType : [out] pointer to WMM AC type of OS packet
277
278 @return : None
279 ===========================================================================*/
280v_VOID_t hdd_wmm_classify_pkt ( hdd_adapter_t* pAdapter,
281 struct sk_buff *skb,
282 WLANTL_ACEnumType* pAcType,
283 sme_QosWmmUpType* pUserPri);
284
285
286/**============================================================================
287 @brief hdd_wmm_acquire_access() - Function which will attempt to acquire
288 admittance for a WMM AC
289
290 @param pAdapter : [in] pointer to adapter context
291 @param acType : [in] WMM AC type of OS packet
292 @param pGranted : [out] pointer to boolean flag when indicates if access
293 has been granted or not
294
295 @return : VOS_STATUS_SUCCESS if succssful
296 : other values if failure
297 ===========================================================================*/
298VOS_STATUS hdd_wmm_acquire_access( hdd_adapter_t* pAdapter,
299 WLANTL_ACEnumType acType,
300 v_BOOL_t * pGranted );
301
302/**============================================================================
303 @brief hdd_wmm_assoc() - Function which will handle the housekeeping
304 required by WMM when association takes place
305
306 @param pAdapter : [in] pointer to adapter context
307 @param pRoamInfo: [in] pointer to roam information
308 @param eBssType : [in] type of BSS
309
310 @return : VOS_STATUS_SUCCESS if succssful
311 : other values if failure
312 ===========================================================================*/
313VOS_STATUS hdd_wmm_assoc( hdd_adapter_t* pAdapter,
314 tCsrRoamInfo *pRoamInfo,
315 eCsrRoamBssType eBssType );
316
317/**============================================================================
318 @brief hdd_wmm_connect() - Function which will handle the housekeeping
319 required by WMM when a connection is established
320
321 @param pAdapter : [in] pointer to adapter context
322 @param pRoamInfo: [in] pointer to roam information
323 @param eBssType : [in] type of BSS
324
325 @return : VOS_STATUS_SUCCESS if succssful
326 : other values if failure
327 ===========================================================================*/
328VOS_STATUS hdd_wmm_connect( hdd_adapter_t* pAdapter,
329 tCsrRoamInfo *pRoamInfo,
330 eCsrRoamBssType eBssType );
331
332/**============================================================================
333 @brief hdd_wmm_get_uapsd_mask() - Function which will calculate the
334 initial value of the UAPSD mask based upon the device configuration
335
336 @param pAdapter : [in] pointer to adapter context
337 @param pUapsdMask: [in] pointer to where the UAPSD Mask is to be stored
338
339 @return : VOS_STATUS_SUCCESS if succssful
340 : other values if failure
341 ===========================================================================*/
342VOS_STATUS hdd_wmm_get_uapsd_mask( hdd_adapter_t* pAdapter,
343 tANI_U8 *pUapsdMask );
344
345/**============================================================================
346 @brief hdd_wmm_is_active() - Function which will determine if WMM is
347 active on the current connection
348
349 @param pAdapter : [in] pointer to adapter context
350
351 @return : VOS_TRUE if WMM is enabled
352 : VOS_FALSE if WMM is not enabled
353 ===========================================================================*/
354v_BOOL_t hdd_wmm_is_active( hdd_adapter_t* pAdapter );
355
356/**============================================================================
357 @brief hdd_wmm_addts() - Function which will add a traffic spec at the
358 request of an application
359
360 @param pAdapter : [in] pointer to adapter context
361 @param handle : [in] handle to uniquely identify a TS
362 @param pTspec : [in] pointer to the traffic spec
363
364 @return : HDD_WLAN_WMM_STATUS_*
365 ===========================================================================*/
366hdd_wlan_wmm_status_e hdd_wmm_addts( hdd_adapter_t* pAdapter,
367 v_U32_t handle,
368 sme_QosWmmTspecInfo* pTspec );
369
370/**============================================================================
371 @brief hdd_wmm_delts() - Function which will delete a traffic spec at the
372 request of an application
373
374 @param pAdapter : [in] pointer to adapter context
375 @param handle : [in] handle to uniquely identify a TS
376
377 @return : HDD_WLAN_WMM_STATUS_*
378 ===========================================================================*/
379hdd_wlan_wmm_status_e hdd_wmm_delts( hdd_adapter_t* pAdapter,
380 v_U32_t handle );
381
382/**============================================================================
383 @brief hdd_wmm_checkts() - Function which will return the status of a traffic
384 spec at the request of an application
385
386 @param pAdapter : [in] pointer to adapter context
387 @param handle : [in] handle to uniquely identify a TS
388
389 @return : HDD_WLAN_WMM_STATUS_*
390 ===========================================================================*/
391hdd_wlan_wmm_status_e hdd_wmm_checkts( hdd_adapter_t* pAdapter,
392 v_U32_t handle );
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530393/**============================================================================
394 @brief hdd_wmm_adapter_clear() - Function which will clear the WMM status
395 of all ACs
396 @param pAdapter : [in] pointer to adapter context
397
398 @return : VOS_STATUS_SUCCESS if succssful
399 : other values if failure
400 ===========================================================================*/
401VOS_STATUS hdd_wmm_adapter_clear( hdd_adapter_t *pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -0700402
403#endif /* #ifndef _WLAN_HDD_WMM_H */