blob: b709a53960f95c8748050b7b080e3b8ea189f3f9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -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/*============================================================================
29 @file wlan_hdd_wmm.c
30
31 This module (wlan_hdd_wmm.h interface + wlan_hdd_wmm.c implementation)
32 houses all the logic for WMM in HDD.
33
34 On the control path, it has the logic to setup QoS, modify QoS and delete
35 QoS (QoS here refers to a TSPEC). The setup QoS comes in two flavors: an
36 explicit application invoked and an internal HDD invoked. The implicit QoS
37 is for applications that do NOT call the custom QCT WLAN OIDs for QoS but
38 which DO mark their traffic for priortization. It also has logic to start,
39 update and stop the U-APSD trigger frame generation. It also has logic to
40 read WMM related config parameters from the registry.
41
42 On the data path, it has the logic to figure out the WMM AC of an egress
43 packet and when to signal TL to serve a particular AC queue. It also has the
44 logic to retrieve a packet based on WMM priority in response to a fetch from
45 TL.
46
47 The remaining functions are utility functions for information hiding.
48
49
Jeff Johnson295189b2012-06-20 16:38:30 -070050============================================================================*/
51
52/*---------------------------------------------------------------------------
53 Include files
54 -------------------------------------------------------------------------*/
55#include <wlan_hdd_tx_rx.h>
56#include <wlan_hdd_dp_utils.h>
57#include <wlan_hdd_wmm.h>
58#include <wlan_hdd_ether.h>
59#include <linux/netdevice.h>
60#include <linux/skbuff.h>
61#include <linux/etherdevice.h>
62#include <linux/if_vlan.h>
63#include <linux/ip.h>
64#include <linux/semaphore.h>
65#include <wlan_hdd_hostapd.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070066#include <wlan_hdd_softap_tx_rx.h>
Kiet Lam40009862014-02-13 12:33:22 -080067#include <vos_sched.h>
Mukul Sharma74a01e52014-07-21 15:14:23 +053068#include "sme_Api.h"
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +053069#include "sapInternal.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070070// change logging behavior based upon debug flag
71#ifdef HDD_WMM_DEBUG
72#define WMM_TRACE_LEVEL_FATAL VOS_TRACE_LEVEL_FATAL
73#define WMM_TRACE_LEVEL_ERROR VOS_TRACE_LEVEL_FATAL
74#define WMM_TRACE_LEVEL_WARN VOS_TRACE_LEVEL_FATAL
75#define WMM_TRACE_LEVEL_INFO VOS_TRACE_LEVEL_FATAL
76#define WMM_TRACE_LEVEL_INFO_HIGH VOS_TRACE_LEVEL_FATAL
77#define WMM_TRACE_LEVEL_INFO_LOW VOS_TRACE_LEVEL_FATAL
78#else
79#define WMM_TRACE_LEVEL_FATAL VOS_TRACE_LEVEL_FATAL
80#define WMM_TRACE_LEVEL_ERROR VOS_TRACE_LEVEL_ERROR
81#define WMM_TRACE_LEVEL_WARN VOS_TRACE_LEVEL_WARN
82#define WMM_TRACE_LEVEL_INFO VOS_TRACE_LEVEL_INFO
83#define WMM_TRACE_LEVEL_INFO_HIGH VOS_TRACE_LEVEL_INFO_HIGH
84#define WMM_TRACE_LEVEL_INFO_LOW VOS_TRACE_LEVEL_INFO_LOW
85#endif
86
87
Jeff Johnson295189b2012-06-20 16:38:30 -070088#define WLAN_HDD_MAX_DSCP 0x3f
89
Madan Mohan Koyyalamudifd3b7a92013-10-10 15:02:58 +053090// DHCP Port number
91#define DHCP_SOURCE_PORT 0x4400
92#define DHCP_DESTINATION_PORT 0x4300
93
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -080094#define HDD_WMM_UP_TO_AC_MAP_SIZE 8
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -070095
Jeff Johnson295189b2012-06-20 16:38:30 -070096const v_U8_t hddWmmUpToAcMap[] = {
97 WLANTL_AC_BE,
98 WLANTL_AC_BK,
99 WLANTL_AC_BK,
100 WLANTL_AC_BE,
101 WLANTL_AC_VI,
102 WLANTL_AC_VI,
103 WLANTL_AC_VO,
104 WLANTL_AC_VO
105};
106
107//Linux based UP -> AC Mapping
108const v_U8_t hddLinuxUpToAcMap[8] = {
109 HDD_LINUX_AC_BE,
110 HDD_LINUX_AC_BK,
111 HDD_LINUX_AC_BK,
112 HDD_LINUX_AC_BE,
113 HDD_LINUX_AC_VI,
114 HDD_LINUX_AC_VI,
115 HDD_LINUX_AC_VO,
116 HDD_LINUX_AC_VO
117};
118
119#ifndef WLAN_MDM_CODE_REDUCTION_OPT
120/**
121 @brief hdd_wmm_enable_tl_uapsd() - function which decides whether and
122 how to update UAPSD parameters in TL
123
124 @param pQosContext : [in] the pointer the QoS instance control block
125
126 @return
127 None
128*/
129static void hdd_wmm_enable_tl_uapsd (hdd_wmm_qos_context_t* pQosContext)
130{
131 hdd_adapter_t* pAdapter = pQosContext->pAdapter;
132 WLANTL_ACEnumType acType = pQosContext->acType;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530133 hdd_wmm_ac_status_t *pAc = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 VOS_STATUS status;
135 v_U32_t service_interval;
136 v_U32_t suspension_interval;
137 sme_QosWmmDirType direction;
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +0530138 v_BOOL_t psb;
Jeff Johnson295189b2012-06-20 16:38:30 -0700139
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530140 if (acType >= WLANTL_MAX_AC)
141 {
142 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
143 "%s: Invalid AC: %d", __func__, acType);
144 return;
145 }
146
147 pAc = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
Jeff Johnson295189b2012-06-20 16:38:30 -0700148
149 // The TSPEC must be valid
150 if (pAc->wmmAcTspecValid == VOS_FALSE)
151 {
152 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
153 "%s: Invoked with invalid TSPEC",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700154 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 return;
156 }
157
158 // determine the service interval
159 if (pAc->wmmAcTspecInfo.min_service_interval)
160 {
161 service_interval = pAc->wmmAcTspecInfo.min_service_interval;
162 }
163 else if (pAc->wmmAcTspecInfo.max_service_interval)
164 {
165 service_interval = pAc->wmmAcTspecInfo.max_service_interval;
166 }
167 else
168 {
169 // no service interval is present in the TSPEC
170 // this is OK, there just won't be U-APSD
171 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
172 "%s: No service interval supplied",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700173 __func__);
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +0530174 service_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 }
176
177 // determine the suspension interval & direction
178 suspension_interval = pAc->wmmAcTspecInfo.suspension_interval;
179 direction = pAc->wmmAcTspecInfo.ts_info.direction;
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +0530180 psb = pAc->wmmAcTspecInfo.ts_info.psb;
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
182 // if we have previously enabled U-APSD, have any params changed?
183 if ((pAc->wmmAcUapsdInfoValid) &&
184 (pAc->wmmAcUapsdServiceInterval == service_interval) &&
185 (pAc->wmmAcUapsdSuspensionInterval == suspension_interval) &&
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +0530186 (pAc->wmmAcUapsdDirection == direction) &&
187 (pAc->wmmAcIsUapsdEnabled == psb))
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 {
189 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
190 "%s: No change in U-APSD parameters",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700191 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 return;
193 }
194
195 // are we in the appropriate power save modes?
196 if (!sme_IsPowerSaveEnabled(WLAN_HDD_GET_HAL_CTX(pAdapter), ePMC_BEACON_MODE_POWER_SAVE))
197 {
198 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
199 "%s: BMPS is not enabled",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700200 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 return;
202 }
203
204 if (!sme_IsPowerSaveEnabled(WLAN_HDD_GET_HAL_CTX(pAdapter), ePMC_UAPSD_MODE_POWER_SAVE))
205 {
206 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
207 "%s: U-APSD is not enabled",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700208 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 return;
210 }
211
212 // everything is in place to notify TL
213 status = WLANTL_EnableUAPSDForAC((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
214 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
215 acType,
216 pAc->wmmAcTspecInfo.ts_info.tid,
217 pAc->wmmAcTspecInfo.ts_info.up,
218 service_interval,
219 suspension_interval,
220 direction);
221
222 if ( !VOS_IS_STATUS_SUCCESS( status ) )
223 {
224 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
225 "%s: Failed to enable U-APSD for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700226 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -0700227 return;
228 }
229
230 // stash away the parameters that were used
231 pAc->wmmAcUapsdInfoValid = VOS_TRUE;
232 pAc->wmmAcUapsdServiceInterval = service_interval;
233 pAc->wmmAcUapsdSuspensionInterval = suspension_interval;
234 pAc->wmmAcUapsdDirection = direction;
Madan Mohan Koyyalamudi198ade32013-09-29 03:52:25 +0530235 pAc->wmmAcIsUapsdEnabled = psb;
Jeff Johnson295189b2012-06-20 16:38:30 -0700236
237 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700238 "%s: Enabled UAPSD in TL srv_int=%d "
239 "susp_int=%d dir=%d AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700240 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700241 service_interval,
242 suspension_interval,
243 direction,
244 acType);
245
246}
247
248/**
249 @brief hdd_wmm_disable_tl_uapsd() - function which decides whether
250 to disable UAPSD parameters in TL
251
252 @param pQosContext : [in] the pointer the QoS instance control block
253
254 @return
255 None
256*/
257static void hdd_wmm_disable_tl_uapsd (hdd_wmm_qos_context_t* pQosContext)
258{
259 hdd_adapter_t* pAdapter = pQosContext->pAdapter;
260 WLANTL_ACEnumType acType = pQosContext->acType;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530261 hdd_wmm_ac_status_t *pAc = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 VOS_STATUS status;
Padma, Santhosh Kumar859d3712014-11-13 18:00:41 +0530263 v_U32_t service_interval;
264 v_U32_t suspension_interval;
265 v_U8_t uapsd_mask;
266 v_U8_t ActiveTspec = INVALID_TSPEC;
Jeff Johnson295189b2012-06-20 16:38:30 -0700267
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530268 if (acType >= WLANTL_MAX_AC)
269 {
270 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
271 "%s: Invalid AC: %d", __func__, acType);
272 return;
273 }
274
275 pAc = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
276
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 // have we previously enabled UAPSD?
278 if (pAc->wmmAcUapsdInfoValid == VOS_TRUE)
279 {
Padma, Santhosh Kumar859d3712014-11-13 18:00:41 +0530280 uapsd_mask = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
Jeff Johnson295189b2012-06-20 16:38:30 -0700281
Padma, Santhosh Kumar859d3712014-11-13 18:00:41 +0530282 //Finding uapsd_mask as per AC
283 uapsd_mask = uapsd_mask & (1 << (WLANTL_AC_VO - acType));
284
285 sme_QosTspecActive((tpAniSirGlobal)WLAN_HDD_GET_HAL_CTX(pAdapter), acType,
286 pAdapter->sessionId, &ActiveTspec);
287
288 //Call WLANTL_EnableUAPSDForAC only when static uapsd mask is present and
289 // no active tspecs. TODO: Need to change naming convention as Enable
290 // UAPSD function is called in hdd_wmm_disable_tl_uapsd. Purpose of
291 // calling WLANTL_EnableUAPSDForAC is to update UAPSD intervals to fw
292
293 if(uapsd_mask && !ActiveTspec)
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 {
Padma, Santhosh Kumar859d3712014-11-13 18:00:41 +0530295 switch(acType)
296 {
297 case WLANTL_AC_VO:
298 service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdVoSrvIntv;
299 suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdVoSuspIntv;
300 break;
301 case WLANTL_AC_VI:
302 service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdViSrvIntv;
303 suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdViSuspIntv;
304 break;
305 case WLANTL_AC_BE:
306 service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBeSrvIntv;
307 suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBeSuspIntv;
308 break;
309 case WLANTL_AC_BK:
310 service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBkSrvIntv;
311 suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBkSuspIntv;
312 break;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +0530313 default:
314 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
315 "%s: Invalid AC %d", __func__, acType );
316 return;
Padma, Santhosh Kumar859d3712014-11-13 18:00:41 +0530317 }
318
319 status = WLANTL_EnableUAPSDForAC((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
320 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
321 acType,
322 pAc->wmmAcTspecInfo.ts_info.tid,
323 pAc->wmmAcTspecInfo.ts_info.up,
324 service_interval,
325 suspension_interval,
326 pAc->wmmAcTspecInfo.ts_info.direction);
327
328 if ( !VOS_IS_STATUS_SUCCESS( status ) )
329 {
330 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
331 "%s: Failed to update U-APSD params for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700332 __func__, acType );
Padma, Santhosh Kumar859d3712014-11-13 18:00:41 +0530333 }
334 else
335 {
336 // TL no longer has valid UAPSD info
337 pAc->wmmAcUapsdInfoValid = VOS_FALSE;
338 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
339 "%s: Updated UAPSD params in TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700340 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 acType);
Padma, Santhosh Kumar859d3712014-11-13 18:00:41 +0530342 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 }
344 }
345}
346
347#endif
348
349/**
350 @brief hdd_wmm_free_context() - function which frees a QoS context
351
352 @param pQosContext : [in] the pointer the QoS instance control block
353
354 @return
355 None
356*/
357static void hdd_wmm_free_context (hdd_wmm_qos_context_t* pQosContext)
358{
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530359 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
360 hdd_context_t *pHddCtx;
361
362 if (NULL != pVosContext)
363 {
364 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
365 if (NULL == pHddCtx)
366 {
367 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
368 FL("HddCtx is NULL"));
369 return;
370 }
371 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700372
373 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
374 "%s: Entered, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700375 __func__, pQosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700376
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530377 // take the wmmLock since we're manipulating the context list
378 mutex_lock(&pHddCtx->wmmLock);
379
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 if (unlikely((NULL == pQosContext) ||
381 (HDD_WMM_CTX_MAGIC != pQosContext->magic)))
382 {
383 // must have been freed in another thread
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530384 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 return;
386 }
387
Jeff Johnson295189b2012-06-20 16:38:30 -0700388 // make sure nobody thinks this is a valid context
389 pQosContext->magic = 0;
390
391 // unlink the context
392 list_del(&pQosContext->node);
393
394 // done manipulating the list
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530395 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700396
397 // reclaim memory
398 kfree(pQosContext);
399
400}
401
402#ifndef WLAN_MDM_CODE_REDUCTION_OPT
403/**
404 @brief hdd_wmm_notify_app() - function which notifies an application
405 changes in state of it flow
406
407 @param pQosContext : [in] the pointer the QoS instance control block
408
409 @return
410 None
411*/
412#define MAX_NOTIFY_LEN 50
413static void hdd_wmm_notify_app (hdd_wmm_qos_context_t* pQosContext)
414{
415 hdd_adapter_t* pAdapter;
416 union iwreq_data wrqu;
417 char buf[MAX_NOTIFY_LEN+1];
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530418 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
419 hdd_context_t *pHddCtx;
420
421 if (NULL != pVosContext)
422 {
423 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
424 if (NULL == pHddCtx)
425 {
426 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
427 FL("HddCtx is NULL"));
428 return;
429 }
430 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700431
432 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
433 "%s: Entered, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700434 __func__, pQosContext);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530435 mutex_lock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 if (unlikely((NULL == pQosContext) ||
437 (HDD_WMM_CTX_MAGIC != pQosContext->magic)))
438 {
439 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
440 "%s: Invalid QoS Context",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700441 __func__);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530442 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700443 return;
444 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530445 // get pointer to the adapter
446 pAdapter = pQosContext->pAdapter;
447 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700448
449 // create the event
450 memset(&wrqu, 0, sizeof(wrqu));
451 memset(buf, 0, sizeof(buf));
452
453 snprintf(buf, MAX_NOTIFY_LEN, "QCOM: TS change[%u: %u]",
454 (unsigned int)pQosContext->handle,
455 (unsigned int)pQosContext->lastStatus);
456
457 wrqu.data.pointer = buf;
458 wrqu.data.length = strlen(buf);
459
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530460
Jeff Johnson295189b2012-06-20 16:38:30 -0700461
462 // send the event
463 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700464 "%s: Sending [%s]", __func__, buf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700465 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
466}
467
468
469/**
470 @brief hdd_wmm_is_access_allowed() - function which determines if access
471 is allowed for the given AC. this is designed to be called during SME
472 callback processing since that is when access can be granted or removed
473
474 @param pAdapter : [in] pointer to adapter context
475 @param pAc : [in] pointer to the per-AC status
476
477 @return : VOS_TRUE - access is allowed
478 : VOS_FALSE - access is not allowed
479 None
480*/
481static v_BOOL_t hdd_wmm_is_access_allowed(hdd_adapter_t* pAdapter,
482 hdd_wmm_ac_status_t* pAc)
483{
484 // if we don't want QoS or the AP doesn't support QoS
485 // or we don't want to do implicit QoS
486 // or if AP doesn't require admission for this AC
487 // then we have access
488 if (!hdd_wmm_is_active(pAdapter) ||
489 !(WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->bImplicitQosEnabled ||
490 !pAc->wmmAcAccessRequired)
491 {
492 return VOS_TRUE;
493 }
494
495 // if implicit QoS has already completed, successfully or not,
496 // then access is allowed
497 if (pAc->wmmAcAccessGranted || pAc->wmmAcAccessFailed)
498 {
499 return VOS_TRUE;
500 }
501
502 // admission is required and implicit QoS hasn't completed
503 // however explicit QoS may have completed and we'll have
504 // a Tspec
505 // if we don't have a Tspec then access is not allowed
506 if (!pAc->wmmAcTspecValid)
507 {
508 return VOS_FALSE;
509 }
510
511 // we have a Tspec -- does it allow upstream or bidirectional traffic?
512 // if it only allows downstream traffic then access is not allowed
513 if (pAc->wmmAcTspecInfo.ts_info.direction == SME_QOS_WMM_TS_DIR_DOWNLINK)
514 {
515 return VOS_FALSE;
516 }
517
518 // we meet all of the criteria for access
519 return VOS_TRUE;
520}
521
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800522#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700523/**
524 @brief hdd_wmm_inactivity_timer_cb() - timer handler function which is
525 called for every inactivity interval per AC. This function gets the
526 current transmitted packets on the given AC, and checks if there where
527 any TX activity from the previous interval. If there was no traffic
528 then it would delete the TS that was negotiated on that AC.
529
530 @param pUserData : [in] pointer to pQosContext
531
532 @return : NONE
533*/
534void hdd_wmm_inactivity_timer_cb( v_PVOID_t pUserData )
535{
536 hdd_wmm_qos_context_t* pQosContext = (hdd_wmm_qos_context_t*)pUserData;
537 hdd_adapter_t* pAdapter;
538 hdd_wmm_ac_status_t *pAc;
539 hdd_wlan_wmm_status_e status;
540 VOS_STATUS vos_status;
541 v_U32_t currentTrafficCnt = 0;
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530542 WLANTL_ACEnumType acType = 0;
543 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
544 hdd_context_t *pHddCtx;
545 if (NULL != pVosContext)
546 {
547 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
548 if (NULL == pHddCtx)
549 {
550 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
551 FL("HddCtx is NULL"));
552 return;
553 }
554 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530556 mutex_lock(&pHddCtx->wmmLock);
557 if (unlikely((NULL == pQosContext) ||
558 (HDD_WMM_CTX_MAGIC != pQosContext->magic)))
559 {
560 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
561 "%s: Invalid QoS Context",
562 __func__);
563 mutex_unlock(&pHddCtx->wmmLock);
564 return;
565 }
566 mutex_unlock(&pHddCtx->wmmLock);
567
568 acType = pQosContext->acType;
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 pAdapter = pQosContext->pAdapter;
570 pAc = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
571
572 // Get the Tx stats for this AC.
573 currentTrafficCnt = pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[pQosContext->acType];
574
575 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800576 FL("WMM inactivity Timer for AC=%d, currentCnt=%d, prevCnt=%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700577 acType, (int)currentTrafficCnt, (int)pAc->wmmPrevTrafficCnt);
578 if (pAc->wmmPrevTrafficCnt == currentTrafficCnt)
579 {
580 // If there is no traffic activity, delete the TSPEC for this AC
581 status = hdd_wmm_delts(pAdapter, pQosContext->handle);
582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
583 FL("Deleted TS on AC %d, due to inactivity with status = %d!!!"),
584 acType, status);
585 }
586 else
587 {
588 pAc->wmmPrevTrafficCnt = currentTrafficCnt;
589 if (pAc->wmmInactivityTimer.state == VOS_TIMER_STATE_STOPPED)
590 {
591 // Restart the timer
592 vos_status = vos_timer_start(&pAc->wmmInactivityTimer, pAc->wmmInactivityTime);
593 if (!VOS_IS_STATUS_SUCCESS(vos_status))
594 {
595 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
596 FL("Restarting inactivity timer failed on AC %d"), acType);
597 }
598 }
599 else
600 {
601 VOS_ASSERT(vos_timer_getCurrentState(
602 &pAc->wmmInactivityTimer) == VOS_TIMER_STATE_STOPPED);
603 }
604 }
605
606 return;
607}
608
609
610/**
611 @brief hdd_wmm_enable_inactivity_timer() - function to enable the
612 traffic inactivity timer for the given AC, if the inactivity_interval
613 specified in the ADDTS parameters is non-zero
614
615 @param pQosContext : [in] pointer to pQosContext
616 @param inactivityTime: [in] value of the inactivity interval in millisecs
617
618 @return : VOS_STATUS_E_FAILURE
619 VOS_STATUS_SUCCESS
620*/
621VOS_STATUS hdd_wmm_enable_inactivity_timer(hdd_wmm_qos_context_t* pQosContext, v_U32_t inactivityTime)
622{
623 VOS_STATUS vos_status = VOS_STATUS_E_FAILURE;
624 hdd_adapter_t* pAdapter = pQosContext->pAdapter;
625 WLANTL_ACEnumType acType = pQosContext->acType;
626 hdd_wmm_ac_status_t *pAc;
627
628 pAdapter = pQosContext->pAdapter;
629 pAc = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
630
631
632 // If QoS-Tspec is successfully setup and if the inactivity timer is non-zero,
633 // a traffic inactivity timer needs to be started for the given AC
634 vos_status = vos_timer_init(
635 &pAc->wmmInactivityTimer,
636 VOS_TIMER_TYPE_SW,
637 hdd_wmm_inactivity_timer_cb,
638 (v_PVOID_t)pQosContext );
639 if ( !VOS_IS_STATUS_SUCCESS(vos_status))
640 {
641 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
642 FL("Initializing inactivity timer failed on AC %d"), acType);
643 return vos_status;
644 }
645
646 // Start the inactivity timer
647 vos_status = vos_timer_start(
648 &pAc->wmmInactivityTimer,
649 inactivityTime);
650 if ( !VOS_IS_STATUS_SUCCESS(vos_status))
651 {
652 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
653 FL("Starting inactivity timer failed on AC %d"), acType);
654 return vos_status;
655 }
656 pAc->wmmInactivityTime = inactivityTime;
657 // Initialize the current tx traffic count on this AC
658 pAc->wmmPrevTrafficCnt = pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[pQosContext->acType];
659
660 return vos_status;
661}
662
663/**
664 @brief hdd_wmm_enable_inactivity_timer() - function to disable the
665 traffic inactivity timer for the given AC. This would be called when
666 deleting the TS.
667
668 @param pQosContext : [in] pointer to pQosContext
669
670 @return : VOS_STATUS_E_FAILURE
671 VOS_STATUS_SUCCESS
672*/
673VOS_STATUS hdd_wmm_disable_inactivity_timer(hdd_wmm_qos_context_t* pQosContext)
674{
675 hdd_adapter_t* pAdapter = pQosContext->pAdapter;
676 WLANTL_ACEnumType acType = pQosContext->acType;
677 hdd_wmm_ac_status_t *pAc = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
678 VOS_STATUS vos_status = VOS_STATUS_E_FAILURE;
679
680 // Clear the timer and the counter
681 pAc->wmmInactivityTime = 0;
682 pAc->wmmPrevTrafficCnt = 0;
683 vos_timer_stop(&pAc->wmmInactivityTimer);
684 vos_status = vos_timer_destroy(&pAc->wmmInactivityTimer);
685
686 return vos_status;
687}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800688#endif // FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700689
690/**
691 @brief hdd_wmm_sme_callback() - callback registered by HDD with SME for receiving
692 QoS notifications. Even though this function has a static scope it gets called
693 externally through some function pointer magic (so there is a need for
694 rigorous parameter checking)
695
696 @param hHal : [in] the HAL handle
697 @param HddCtx : [in] the HDD specified handle
698 @param pCurrentQosInfo : [in] the TSPEC params
699 @param SmeStatus : [in] the QoS related SME status
700
701 @return
702 eHAL_STATUS_SUCCESS if all good, eHAL_STATUS_FAILURE otherwise
703*/
704static eHalStatus hdd_wmm_sme_callback (tHalHandle hHal,
705 void * hddCtx,
706 sme_QosWmmTspecInfo* pCurrentQosInfo,
707 sme_QosStatusType smeStatus,
708 v_U32_t qosFlowId)
709{
710 hdd_wmm_qos_context_t* pQosContext = hddCtx;
711 hdd_adapter_t* pAdapter;
712 WLANTL_ACEnumType acType;
713 hdd_wmm_ac_status_t *pAc;
714 VOS_STATUS status;
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530715 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
716 hdd_context_t *pHddCtx;
717
718 if (NULL != pVosContext)
719 {
720 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
721 if (NULL == pHddCtx)
722 {
723 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
724 FL("HddCtx is NULL"));
725 return eHAL_STATUS_FAILURE;
726 }
727 }
728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729
730 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
731 "%s: Entered, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700732 __func__, pQosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700733
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530734 mutex_lock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 if (unlikely((NULL == pQosContext) ||
736 (HDD_WMM_CTX_MAGIC != pQosContext->magic)))
737 {
738 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
739 "%s: Invalid QoS Context",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700740 __func__);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530741 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 return eHAL_STATUS_FAILURE;
743 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +0530744 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -0700745
746 pAdapter = pQosContext->pAdapter;
747 acType = pQosContext->acType;
748 pAc = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
749
750 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
751 "%s: status %d flowid %d info %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700752 __func__, smeStatus, qosFlowId, pCurrentQosInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700753
754 switch (smeStatus)
755 {
756
757 case SME_QOS_STATUS_SETUP_SUCCESS_IND:
758 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
759 "%s: Setup is complete",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700760 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700761
762 // there will always be a TSPEC returned with this status, even if
763 // a TSPEC is not exchanged OTA
764 if (pCurrentQosInfo)
765 {
766 pAc->wmmAcTspecValid = VOS_TRUE;
767 memcpy(&pAc->wmmAcTspecInfo,
768 pCurrentQosInfo,
769 sizeof(pAc->wmmAcTspecInfo));
770 }
771
772 if (HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
773 {
774
775 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
776 "%s: Implicit Qos, notifying TL for TL AC %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700777 __func__, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700778
779 // this was triggered by implicit QoS so we know packets are pending
780 // update state
781 pAc->wmmAcAccessAllowed = VOS_TRUE;
782 pAc->wmmAcAccessGranted = VOS_TRUE;
783 pAc->wmmAcAccessPending = VOS_FALSE;
784
785 // notify TL that packets are pending
786 status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
787 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
788 acType );
789
790 if ( !VOS_IS_STATUS_SUCCESS( status ) )
791 {
792 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
793 "%s: Failed to signal TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700794 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 }
796 }
797 else
798 {
799 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
800 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700801 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700802
803 // this was triggered by an application
804 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_SETUP_SUCCESS;
805 hdd_wmm_notify_app(pQosContext);
806 }
807
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800808#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 // Check if the inactivity interval is specified
Jeff Johnson8795e422013-04-03 08:59:22 -0700810 if (pCurrentQosInfo && pCurrentQosInfo->inactivity_interval) {
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800812 "%s: Inactivity timer value = %d for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700813 __func__, pCurrentQosInfo->inactivity_interval, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 hdd_wmm_enable_inactivity_timer(pQosContext, pCurrentQosInfo->inactivity_interval);
815 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800816#endif // FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700817
818 // notify TL to enable trigger frames if necessary
819 hdd_wmm_enable_tl_uapsd(pQosContext);
820
821 break;
822
823 case SME_QOS_STATUS_SETUP_SUCCESS_APSD_SET_ALREADY:
824 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
825 "%s: Setup is complete (U-APSD set previously)",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700826 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700827
828 if (HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
829 {
830
831 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
832 "%s: Implicit Qos, notifying TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700833 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834
835 // this was triggered by implicit QoS so we know packets are pending
836 // update state
837 pAc->wmmAcAccessAllowed = VOS_TRUE;
838 pAc->wmmAcAccessGranted = VOS_TRUE;
839 pAc->wmmAcAccessPending = VOS_FALSE;
840
841 // notify TL that packets are pending
842 status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
843 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
844 acType );
845
846 if ( !VOS_IS_STATUS_SUCCESS( status ) )
847 {
848 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
849 "%s: Failed to signal TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700850 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 }
852 }
853 else
854 {
855 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
856 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700857 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700858
859 // this was triggered by an application
860 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_SETUP_SUCCESS_NO_ACM_UAPSD_EXISTING;
861 hdd_wmm_notify_app(pQosContext);
862 }
863
864 break;
865
866 case SME_QOS_STATUS_SETUP_FAILURE_RSP:
867 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
868 "%s: Setup failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700869 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 // QoS setup failed
871
872 if (HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
873 {
874
875 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
876 "%s: Implicit Qos, notifying TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700877 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878
879 // we note the failure, but we also mark access as allowed so that
880 // the packets will flow. Note that the MAC will "do the right thing"
881 pAc->wmmAcAccessPending = VOS_FALSE;
882 pAc->wmmAcAccessFailed = VOS_TRUE;
883 pAc->wmmAcAccessAllowed = VOS_TRUE;
884
885 // this was triggered by implicit QoS so we know packets are pending
886 status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
887 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
888 acType );
889
890 if ( !VOS_IS_STATUS_SUCCESS( status ) )
891 {
892 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
893 "%s: Failed to signal TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700894 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 }
896 }
897 else
898 {
899 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
900 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700901 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700902
903 // this was triggered by an application
904 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED;
905 hdd_wmm_notify_app(pQosContext);
906 }
907
908 /* Setting up QoS Failed, QoS context can be released.
909 * SME is releasing this flow information and if HDD doen't release this context,
910 * next time if application uses the same handle to set-up QoS, HDD (as it has
911 * QoS context for this handle) will issue Modify QoS request to SME but SME will
912 * reject as no it has no information for this flow.
913 */
914 hdd_wmm_free_context(pQosContext);
915 break;
916
917 case SME_QOS_STATUS_SETUP_INVALID_PARAMS_RSP:
918 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
919 "%s: Setup Invalid Params, notify TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700920 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 // QoS setup failed
922
923 if (HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
924 {
925
926 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
927 "%s: Implicit Qos, notifying TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700928 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700929
930 // we note the failure, but we also mark access as allowed so that
931 // the packets will flow. Note that the MAC will "do the right thing"
932 pAc->wmmAcAccessPending = VOS_FALSE;
933 pAc->wmmAcAccessFailed = VOS_TRUE;
934 pAc->wmmAcAccessAllowed = VOS_TRUE;
935
936 // this was triggered by implicit QoS so we know packets are pending
937 status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
938 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
939 acType );
940
941 if ( !VOS_IS_STATUS_SUCCESS( status ) )
942 {
943 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
944 "%s: Failed to signal TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700945 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 }
947 }
948 else
949 {
950 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
951 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700952 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700953
954 // this was triggered by an application
955 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
956 hdd_wmm_notify_app(pQosContext);
957 }
958 break;
959
960 case SME_QOS_STATUS_SETUP_NOT_QOS_AP_RSP:
961 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800962 "%s: Setup failed, not a QoS AP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700963 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 if (!HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
965 {
966 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
967 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700968 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700969
970 // this was triggered by an application
971 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_SETUP_FAILED_NO_WMM;
972 hdd_wmm_notify_app(pQosContext);
973 }
974 break;
975
976 case SME_QOS_STATUS_SETUP_REQ_PENDING_RSP:
977 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
978 "%s: Setup pending",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700979 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 // not a callback status -- ignore if we get it
981 break;
982
983 case SME_QOS_STATUS_SETUP_MODIFIED_IND:
984 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
985 "%s: Setup modified",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700986 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 if (pCurrentQosInfo)
988 {
989 // update the TSPEC
990 pAc->wmmAcTspecValid = VOS_TRUE;
991 memcpy(&pAc->wmmAcTspecInfo,
992 pCurrentQosInfo,
993 sizeof(pAc->wmmAcTspecInfo));
994
995 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
996 {
997 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
998 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700999 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001000
1001 // this was triggered by an application
1002 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_MODIFIED;
1003 hdd_wmm_notify_app(pQosContext);
1004 }
1005
1006 // need to tell TL to update its UAPSD handling
1007 hdd_wmm_enable_tl_uapsd(pQosContext);
1008 }
1009 break;
1010
1011 case SME_QOS_STATUS_SETUP_SUCCESS_NO_ACM_NO_APSD_RSP:
1012 if (HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
1013 {
1014
1015 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1016 "%s: Implicit Qos, notifying TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001017 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001018
1019 // this was triggered by implicit QoS so we know packets are pending
1020 pAc->wmmAcAccessPending = VOS_FALSE;
1021 pAc->wmmAcAccessGranted = VOS_TRUE;
1022 pAc->wmmAcAccessAllowed = VOS_TRUE;
1023
1024 // notify TL that packets are pending
1025 status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1026 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
1027 acType );
1028
1029 if ( !VOS_IS_STATUS_SUCCESS( status ) )
1030 {
1031 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1032 "%s: Failed to signal TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001033 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 }
1035 }
1036 else
1037 {
1038 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1039 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001040 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
1042 // this was triggered by an application
1043 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_SETUP_SUCCESS_NO_ACM_NO_UAPSD;
1044 hdd_wmm_notify_app(pQosContext);
1045 }
1046 break;
1047
1048 case SME_QOS_STATUS_SETUP_SUCCESS_IND_APSD_PENDING:
1049 // nothing to do for now
1050 break;
1051
1052 case SME_QOS_STATUS_SETUP_SUCCESS_IND_APSD_SET_FAILED:
1053 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1054 "%s: Setup successful but U-APSD failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001055 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001056
1057 if (HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
1058 {
1059
1060 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1061 "%s: Implicit Qos, notifying TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001062 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
1064 // QoS setup was successful but setting U=APSD failed
1065 // Since the OTA part of the request was successful, we don't mark
1066 // this as a failure.
1067 // the packets will flow. Note that the MAC will "do the right thing"
1068 pAc->wmmAcAccessGranted = VOS_TRUE;
1069 pAc->wmmAcAccessAllowed = VOS_TRUE;
1070 pAc->wmmAcAccessFailed = VOS_FALSE;
1071 pAc->wmmAcAccessPending = VOS_FALSE;
1072
1073 // this was triggered by implicit QoS so we know packets are pending
1074 status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1075 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
1076 acType );
1077
1078 if ( !VOS_IS_STATUS_SUCCESS( status ) )
1079 {
1080 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1081 "%s: Failed to signal TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001082 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 }
1084 }
1085 else
1086 {
1087 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1088 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001089 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001090
1091 // this was triggered by an application
1092 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_SETUP_UAPSD_SET_FAILED;
1093 hdd_wmm_notify_app(pQosContext);
1094 }
1095
1096 // Since U-APSD portion failed disabled trigger frame generation
1097 hdd_wmm_disable_tl_uapsd(pQosContext);
1098
1099 break;
1100
1101 case SME_QOS_STATUS_RELEASE_SUCCESS_RSP:
1102 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1103 "%s: Release is complete",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001104 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001105
1106 if (pCurrentQosInfo)
1107 {
1108 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1109 "%s: flows still active",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001110 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001111
1112 // there is still at least one flow active for this AC
1113 // so update the AC state
1114 memcpy(&pAc->wmmAcTspecInfo,
1115 pCurrentQosInfo,
1116 sizeof(pAc->wmmAcTspecInfo));
1117
1118 // need to tell TL to update its UAPSD handling
1119 hdd_wmm_enable_tl_uapsd(pQosContext);
1120 }
1121 else
1122 {
1123 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1124 "%s: last flow",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001125 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
1127 // this is the last flow active for this AC so update the AC state
1128 pAc->wmmAcTspecValid = VOS_FALSE;
1129
1130 // need to tell TL to update its UAPSD handling
1131 hdd_wmm_disable_tl_uapsd(pQosContext);
1132 }
1133
1134 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1135 {
1136 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1137 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001138 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001139
1140 // this was triggered by an application
1141 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_RELEASE_SUCCESS;
1142 hdd_wmm_notify_app(pQosContext);
1143 }
1144
1145 // we are done with this flow
1146 hdd_wmm_free_context(pQosContext);
1147 break;
1148
1149 case SME_QOS_STATUS_RELEASE_FAILURE_RSP:
1150 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1151 "%s: Release failure",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001152 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001153
1154 // we don't need to update our state or TL since nothing has changed
1155 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1156 {
1157 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1158 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001159 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001160
1161 // this was triggered by an application
1162 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_RELEASE_FAILED;
1163 hdd_wmm_notify_app(pQosContext);
1164 }
1165
1166 break;
1167
1168 case SME_QOS_STATUS_RELEASE_QOS_LOST_IND:
1169 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1170 "%s: QOS Lost indication received",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001171 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001172
1173 // current TSPEC is no longer valid
1174 pAc->wmmAcTspecValid = VOS_FALSE;
1175
1176 // need to tell TL to update its UAPSD handling
1177 hdd_wmm_disable_tl_uapsd(pQosContext);
1178
1179 if (HDD_WMM_HANDLE_IMPLICIT == pQosContext->handle)
1180 {
1181 // we no longer have implicit access granted
1182 pAc->wmmAcAccessGranted = VOS_FALSE;
1183 pAc->wmmAcAccessFailed = VOS_FALSE;
1184 }
1185 else
1186 {
1187 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1188 "%s: Explicit Qos, notifying userspace",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001189 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001190
1191 // this was triggered by an application
1192 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_LOST;
1193 hdd_wmm_notify_app(pQosContext);
1194 }
1195
1196 // we are done with this flow
1197 hdd_wmm_free_context(pQosContext);
1198 break;
1199
1200 case SME_QOS_STATUS_RELEASE_REQ_PENDING_RSP:
1201 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1202 "%s: Release pending",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001203 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 // not a callback status -- ignore if we get it
1205 break;
1206
1207 case SME_QOS_STATUS_RELEASE_INVALID_PARAMS_RSP:
1208 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1209 "%s: Release Invalid Params",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001210 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001211 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1212 {
1213 // this was triggered by an application
1214 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_RELEASE_FAILED_BAD_PARAM;
1215 hdd_wmm_notify_app(pQosContext);
1216 }
1217 break;
1218
1219 case SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_IND:
1220 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1221 "%s: Modification is complete, notify TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001222 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001223
1224 // there will always be a TSPEC returned with this status, even if
1225 // a TSPEC is not exchanged OTA
1226 if (pCurrentQosInfo)
1227 {
1228 pAc->wmmAcTspecValid = VOS_TRUE;
1229 memcpy(&pAc->wmmAcTspecInfo,
1230 pCurrentQosInfo,
1231 sizeof(pAc->wmmAcTspecInfo));
1232 }
1233
1234 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1235 {
1236 // this was triggered by an application
1237 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS;
1238 hdd_wmm_notify_app(pQosContext);
1239 }
1240
1241 // notify TL to enable trigger frames if necessary
1242 hdd_wmm_enable_tl_uapsd(pQosContext);
1243
1244 break;
1245
1246 case SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_APSD_SET_ALREADY:
1247 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1248 {
1249 // this was triggered by an application
1250 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS_NO_ACM_UAPSD_EXISTING;
1251 hdd_wmm_notify_app(pQosContext);
1252 }
1253 break;
1254
1255 case SME_QOS_STATUS_MODIFY_SETUP_FAILURE_RSP:
1256 // the flow modification failed so we'll leave in place
1257 // whatever existed beforehand
1258
1259 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1260 {
1261 // this was triggered by an application
1262 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_MODIFY_FAILED;
1263 hdd_wmm_notify_app(pQosContext);
1264 }
1265 break;
1266
1267 case SME_QOS_STATUS_MODIFY_SETUP_PENDING_RSP:
1268 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1269 "%s: modification pending",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001270 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001271 // not a callback status -- ignore if we get it
1272 break;
1273
1274 case SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_NO_ACM_NO_APSD_RSP:
1275 // the flow modification was successful but no QoS changes required
1276
1277 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1278 {
1279 // this was triggered by an application
1280 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS_NO_ACM_NO_UAPSD;
1281 hdd_wmm_notify_app(pQosContext);
1282 }
1283 break;
1284
1285 case SME_QOS_STATUS_MODIFY_SETUP_INVALID_PARAMS_RSP:
1286 // invalid params -- notify the application
1287 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1288 {
1289 // this was triggered by an application
1290 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_MODIFY_FAILED_BAD_PARAM;
1291 hdd_wmm_notify_app(pQosContext);
1292 }
1293 break;
1294
1295 case SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_IND_APSD_PENDING:
1296 // nothing to do for now. when APSD is established we'll have work to do
1297 break;
1298
1299 case SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_IND_APSD_SET_FAILED:
1300 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1301 "%s: Modify successful but U-APSD failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001302 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001303
1304 // QoS modification was successful but setting U=APSD failed.
1305 // This will always be an explicit QoS instance, so all we can
1306 // do is notify the application and let it clean up.
1307 if (HDD_WMM_HANDLE_IMPLICIT != pQosContext->handle)
1308 {
1309 // this was triggered by an application
1310 pQosContext->lastStatus = HDD_WLAN_WMM_STATUS_MODIFY_UAPSD_SET_FAILED;
1311 hdd_wmm_notify_app(pQosContext);
1312 }
1313
1314 // Since U-APSD portion failed disabled trigger frame generation
1315 hdd_wmm_disable_tl_uapsd(pQosContext);
1316
1317 break;
1318
1319 case SME_QOS_STATUS_HANDING_OFF:
1320 // no roaming so we won't see this
1321 break;
1322
1323 case SME_QOS_STATUS_OUT_OF_APSD_POWER_MODE_IND:
1324 // need to tell TL to stop trigger frame generation
1325 hdd_wmm_disable_tl_uapsd(pQosContext);
1326 break;
1327
1328 case SME_QOS_STATUS_INTO_APSD_POWER_MODE_IND:
1329 // need to tell TL to start sending trigger frames again
1330 hdd_wmm_enable_tl_uapsd(pQosContext);
1331 break;
1332
1333 default:
1334 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001335 "%s: unexpected SME Status=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001336 __func__, smeStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001337 VOS_ASSERT(0);
1338 }
1339
1340 // our access to the particular access category may have changed.
1341 // some of the implicit QoS cases above may have already set this
1342 // prior to invoking TL (so that we will properly service the
1343 // Tx queues) but let's consistently handle all cases here
1344 pAc->wmmAcAccessAllowed = hdd_wmm_is_access_allowed(pAdapter, pAc);
1345
1346 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1347 "%s: complete, access for TL AC %d is%sallowed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001348 __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 acType,
1350 pAc->wmmAcAccessAllowed ? " " : " not ");
1351
1352 return eHAL_STATUS_SUCCESS;
1353}
1354#endif
1355
Kiet Lamf040f472013-11-20 21:15:23 +05301356/**========================================================================
1357 @brief hdd_wmmps_helper() - Function to set uapsd psb dynamically
1358
1359 @param pAdapter : [in] pointer to adapter structure
1360
1361 @param ptr : [in] pointer to command buffer
1362
1363 @return : Zero on success, appropriate error on failure.
1364 =======================================================================*/
1365int hdd_wmmps_helper(hdd_adapter_t *pAdapter, tANI_U8 *ptr)
1366{
1367 if (NULL == pAdapter)
1368 {
1369 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1370 "%s: pAdapter is NULL", __func__);
1371 return -EINVAL;
1372 }
1373 if (NULL == ptr)
1374 {
1375 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1376 "%s: ptr is NULL", __func__);
1377 return -EINVAL;
1378 }
1379 /* convert ASCII to integer */
1380 pAdapter->configuredPsb = ptr[9] - '0';
1381 pAdapter->psbChanged = HDD_PSB_CHANGED;
1382
1383 return 0;
1384}
1385
Jeff Johnson295189b2012-06-20 16:38:30 -07001386/**============================================================================
1387 @brief hdd_wmm_do_implicit_qos() - Function which will attempt to setup
1388 QoS for any AC requiring it
1389
1390 @param work : [in] pointer to work structure
1391
1392 @return : void
1393 ===========================================================================*/
Mukul Sharmaec9dcc62015-02-24 18:00:04 +05301394static void __hdd_wmm_do_implicit_qos(struct work_struct *work)
Jeff Johnson295189b2012-06-20 16:38:30 -07001395{
1396 hdd_wmm_qos_context_t* pQosContext =
1397 container_of(work, hdd_wmm_qos_context_t, wmmAcSetupImplicitQos);
1398 hdd_adapter_t* pAdapter;
1399 WLANTL_ACEnumType acType;
1400 hdd_wmm_ac_status_t *pAc;
1401#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1402 VOS_STATUS status;
1403 sme_QosStatusType smeStatus;
1404#endif
1405 sme_QosWmmTspecInfo qosInfo;
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301406 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1407 hdd_context_t *pHddCtx;
Mukul Sharmaec9dcc62015-02-24 18:00:04 +05301408 int ret = 0;
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301409
1410 if (NULL != pVosContext)
1411 {
1412 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1413 if (NULL == pHddCtx)
1414 {
1415 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1416 FL("HddCtx is NULL"));
1417 return;
1418 }
1419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001420
Mukul Sharmaec9dcc62015-02-24 18:00:04 +05301421 ret = wlan_hdd_validate_context(pHddCtx);
1422 if (0 != ret)
1423 {
1424 hddLog(LOGE, FL("HDD context is invalid"));
1425 return;
1426 }
1427
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1429 "%s: Entered, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001430 __func__, pQosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07001431
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301432 mutex_lock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 if (unlikely(HDD_WMM_CTX_MAGIC != pQosContext->magic))
1434 {
1435 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1436 "%s: Invalid QoS Context",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001437 __func__);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301438 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 return;
1440 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301441 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001442
1443 pAdapter = pQosContext->pAdapter;
1444 acType = pQosContext->acType;
1445 pAc = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
1446
1447 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1448 "%s: pAdapter %p acType %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001449 __func__, pAdapter, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001450
1451 if (!pAc->wmmAcAccessNeeded)
1452 {
1453 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1454 "%s: AC %d doesn't need service",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001455 __func__, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -07001456 pQosContext->magic = 0;
1457 kfree(pQosContext);
1458 return;
1459 }
1460
1461 pAc->wmmAcAccessPending = VOS_TRUE;
1462 pAc->wmmAcAccessNeeded = VOS_FALSE;
1463
1464 memset(&qosInfo, 0, sizeof(qosInfo));
1465
Kiet Lamf040f472013-11-20 21:15:23 +05301466 qosInfo.ts_info.psb = pAdapter->configuredPsb;
1467
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 switch (acType)
1469 {
1470 case WLANTL_AC_VO:
1471 qosInfo.ts_info.up = SME_QOS_WMM_UP_VO;
Kiet Lamf040f472013-11-20 21:15:23 +05301472 /* Check if there is any valid configuration from framework */
1473 if (HDD_PSB_CFG_INVALID == pAdapter->configuredPsb)
1474 {
1475 qosInfo.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
1476 SME_QOS_UAPSD_VO) ? 1 : 0;
1477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 qosInfo.ts_info.direction = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraDirAcVo;
1479 qosInfo.ts_info.tid = 255;
1480 qosInfo.mean_data_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMeanDataRateAcVo;
1481 qosInfo.min_phy_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMinPhyRateAcVo;
1482 qosInfo.min_service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdVoSrvIntv;
1483 qosInfo.nominal_msdu_size = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraNomMsduSizeAcVo;
1484 qosInfo.surplus_bw_allowance = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraSbaAcVo;
1485 qosInfo.suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdVoSuspIntv;
1486 break;
1487 case WLANTL_AC_VI:
1488 qosInfo.ts_info.up = SME_QOS_WMM_UP_VI;
Kiet Lamf040f472013-11-20 21:15:23 +05301489 /* Check if there is any valid configuration from framework */
1490 if (HDD_PSB_CFG_INVALID == pAdapter->configuredPsb)
1491 {
1492 qosInfo.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
1493 SME_QOS_UAPSD_VI) ? 1 : 0;
1494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001495 qosInfo.ts_info.direction = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraDirAcVi;
1496 qosInfo.ts_info.tid = 255;
1497 qosInfo.mean_data_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMeanDataRateAcVi;
1498 qosInfo.min_phy_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMinPhyRateAcVi;
1499 qosInfo.min_service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdViSrvIntv;
1500 qosInfo.nominal_msdu_size = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraNomMsduSizeAcVi;
1501 qosInfo.surplus_bw_allowance = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraSbaAcVi;
1502 qosInfo.suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdViSuspIntv;
1503 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 case WLANTL_AC_BE:
1505 qosInfo.ts_info.up = SME_QOS_WMM_UP_BE;
Kiet Lamf040f472013-11-20 21:15:23 +05301506 /* Check if there is any valid configuration from framework */
1507 if (HDD_PSB_CFG_INVALID == pAdapter->configuredPsb)
1508 {
1509 qosInfo.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
1510 SME_QOS_UAPSD_BE) ? 1 : 0;
1511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 qosInfo.ts_info.direction = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraDirAcBe;
1513 qosInfo.ts_info.tid = 255;
1514 qosInfo.mean_data_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMeanDataRateAcBe;
1515 qosInfo.min_phy_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMinPhyRateAcBe;
1516 qosInfo.min_service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBeSrvIntv;
1517 qosInfo.nominal_msdu_size = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraNomMsduSizeAcBe;
1518 qosInfo.surplus_bw_allowance = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraSbaAcBe;
1519 qosInfo.suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBeSuspIntv;
1520 break;
1521 case WLANTL_AC_BK:
1522 qosInfo.ts_info.up = SME_QOS_WMM_UP_BK;
Kiet Lamf040f472013-11-20 21:15:23 +05301523 /* Check if there is any valid configuration from framework */
1524 if (HDD_PSB_CFG_INVALID == pAdapter->configuredPsb)
1525 {
1526 qosInfo.ts_info.psb = ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask &
1527 SME_QOS_UAPSD_BK) ? 1 : 0;
1528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 qosInfo.ts_info.direction = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraDirAcBk;
1530 qosInfo.ts_info.tid = 255;
1531 qosInfo.mean_data_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMeanDataRateAcBk;
1532 qosInfo.min_phy_rate = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraMinPhyRateAcBk;
1533 qosInfo.min_service_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBkSrvIntv;
1534 qosInfo.nominal_msdu_size = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraNomMsduSizeAcBk;
1535 qosInfo.surplus_bw_allowance = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraSbaAcBk;
1536 qosInfo.suspension_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBkSuspIntv;
1537 break;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301538 default:
1539 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1540 "%s: Invalid AC %d", __func__, acType );
1541 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001543#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 qosInfo.inactivity_interval = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraInactivityInterval;
1545#endif
1546 qosInfo.ts_info.burst_size_defn = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->burstSizeDefinition;
1547
1548 switch ((WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->tsInfoAckPolicy)
1549 {
1550 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_NORMAL_ACK:
1551 qosInfo.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
1552 break;
1553
1554 case HDD_WLAN_WMM_TS_INFO_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK:
1555 qosInfo.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK;
1556 break;
1557
1558 default:
1559 // unknown
1560 qosInfo.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
1561 }
1562
1563 if(qosInfo.ts_info.ack_policy == SME_QOS_WMM_TS_ACK_POLICY_HT_IMMEDIATE_BLOCK_ACK)
1564 {
1565 if(!sme_QosIsTSInfoAckPolicyValid((tpAniSirGlobal)WLAN_HDD_GET_HAL_CTX(pAdapter), &qosInfo, pAdapter->sessionId))
1566 {
1567 qosInfo.ts_info.ack_policy = SME_QOS_WMM_TS_ACK_POLICY_NORMAL_ACK;
1568 }
1569 }
1570
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301571 mutex_lock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001572 list_add(&pQosContext->node, &pAdapter->hddWmmStatus.wmmContextList);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301573 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07001574
1575#ifndef WLAN_MDM_CODE_REDUCTION_OPT
1576 smeStatus = sme_QosSetupReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
1577 pAdapter->sessionId,
1578 &qosInfo,
1579 hdd_wmm_sme_callback,
1580 pQosContext,
1581 qosInfo.ts_info.up,
1582 &pQosContext->qosFlowId);
1583
1584 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1585 "%s: sme_QosSetupReq returned %d flowid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001586 __func__, smeStatus, pQosContext->qosFlowId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001587
1588 // need to check the return values and act appropriately
1589 switch (smeStatus)
1590 {
1591 case SME_QOS_STATUS_SETUP_REQ_PENDING_RSP:
1592 case SME_QOS_STATUS_SETUP_SUCCESS_IND_APSD_PENDING:
1593 // setup is pending, so no more work to do now.
1594 // all further work will be done in hdd_wmm_sme_callback()
1595 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1596 "%s: Setup is pending, no further work",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001597 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001598
1599 break;
1600
1601
1602 case SME_QOS_STATUS_SETUP_FAILURE_RSP:
1603 // we can't tell the difference between when a request fails because
1604 // AP rejected it versus when SME encountered an internal error
1605
1606 // in either case SME won't ever reference this context so
1607 // free the record
1608 hdd_wmm_free_context(pQosContext);
1609
1610 // fall through and start packets flowing
1611 case SME_QOS_STATUS_SETUP_SUCCESS_NO_ACM_NO_APSD_RSP:
1612 // no ACM in effect, no need to setup U-APSD
1613 case SME_QOS_STATUS_SETUP_SUCCESS_APSD_SET_ALREADY:
1614 // no ACM in effect, U-APSD is desired but was already setup
1615
1616 // for these cases everything is already setup so we can
1617 // signal TL that it has work to do
1618 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1619 "%s: Setup is complete, notify TL",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001620 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621
1622 pAc->wmmAcAccessAllowed = VOS_TRUE;
1623 pAc->wmmAcAccessGranted = VOS_TRUE;
1624 pAc->wmmAcAccessPending = VOS_FALSE;
1625
1626 status = WLANTL_STAPktPending( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1627 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
1628 acType );
1629
1630 if ( !VOS_IS_STATUS_SUCCESS( status ) )
1631 {
1632 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1633 "%s: Failed to signal TL for AC=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001634 __func__, acType );
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636
1637 break;
1638
1639
1640 default:
1641 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001642 "%s: unexpected SME Status=%d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001643 __func__, smeStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 VOS_ASSERT(0);
1645 }
1646#endif
1647
1648}
1649
Mukul Sharmaec9dcc62015-02-24 18:00:04 +05301650static void hdd_wmm_do_implicit_qos(struct work_struct *work)
1651{
1652 vos_ssr_protect(__func__);
1653 __hdd_wmm_do_implicit_qos( work );
1654 vos_ssr_unprotect(__func__);
1655}
1656
Jeff Johnson295189b2012-06-20 16:38:30 -07001657/**============================================================================
1658 @brief hdd_wmm_init() - Function which will initialize the WMM configuation
1659 and status to an initial state. The configuration can later be overwritten
1660 via application APIs
1661
Kumar Anand82c009f2014-05-29 00:29:42 -07001662 @param pAdapter : [in] pointer to Adapter context
Jeff Johnson295189b2012-06-20 16:38:30 -07001663
Kumar Anand82c009f2014-05-29 00:29:42 -07001664 @return : VOS_STATUS_SUCCESS if successful
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 : other values if failure
1666
1667 ===========================================================================*/
Kumar Anand82c009f2014-05-29 00:29:42 -07001668VOS_STATUS hdd_wmm_init ( hdd_adapter_t *pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07001669{
Kumar Anand82c009f2014-05-29 00:29:42 -07001670 sme_QosWmmUpType* hddWmmDscpToUpMap = pAdapter->hddWmmDscpToUpMap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 v_U8_t dscp;
1672
1673 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001674 "%s: Entered", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001675
1676 // DSCP to User Priority Lookup Table
1677 for (dscp = 0; dscp <= WLAN_HDD_MAX_DSCP; dscp++)
1678 {
1679 hddWmmDscpToUpMap[dscp] = SME_QOS_WMM_UP_BE;
1680 }
1681 hddWmmDscpToUpMap[8] = SME_QOS_WMM_UP_BK;
1682 hddWmmDscpToUpMap[16] = SME_QOS_WMM_UP_RESV;
1683 hddWmmDscpToUpMap[24] = SME_QOS_WMM_UP_EE;
1684 hddWmmDscpToUpMap[32] = SME_QOS_WMM_UP_CL;
1685 hddWmmDscpToUpMap[40] = SME_QOS_WMM_UP_VI;
1686 hddWmmDscpToUpMap[48] = SME_QOS_WMM_UP_VO;
1687 hddWmmDscpToUpMap[56] = SME_QOS_WMM_UP_NC;
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 return VOS_STATUS_SUCCESS;
1689}
1690
1691/**============================================================================
1692 @brief hdd_wmm_adapter_init() - Function which will initialize the WMM configuation
1693 and status to an initial state. The configuration can later be overwritten
1694 via application APIs
1695
1696 @param pAdapter : [in] pointer to Adapter context
1697
1698 @return : VOS_STATUS_SUCCESS if succssful
1699 : other values if failure
1700
1701 ===========================================================================*/
1702VOS_STATUS hdd_wmm_adapter_init( hdd_adapter_t *pAdapter )
1703{
1704 hdd_wmm_ac_status_t *pAcStatus;
1705 WLANTL_ACEnumType acType;
1706
1707 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001708 "%s: Entered", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001709
1710 pAdapter->hddWmmStatus.wmmQap = VOS_FALSE;
1711 INIT_LIST_HEAD(&pAdapter->hddWmmStatus.wmmContextList);
Jeff Johnson295189b2012-06-20 16:38:30 -07001712
1713 for (acType = 0; acType < WLANTL_MAX_AC; acType++)
1714 {
1715 pAcStatus = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
1716 pAcStatus->wmmAcAccessRequired = VOS_FALSE;
1717 pAcStatus->wmmAcAccessNeeded = VOS_FALSE;
1718 pAcStatus->wmmAcAccessPending = VOS_FALSE;
1719 pAcStatus->wmmAcAccessFailed = VOS_FALSE;
1720 pAcStatus->wmmAcAccessGranted = VOS_FALSE;
1721 pAcStatus->wmmAcAccessAllowed = VOS_FALSE;
1722 pAcStatus->wmmAcTspecValid = VOS_FALSE;
1723 pAcStatus->wmmAcUapsdInfoValid = VOS_FALSE;
1724 }
Kiet Lamf040f472013-11-20 21:15:23 +05301725 // Invalid value(0xff) to indicate psb not configured through framework initially.
1726 pAdapter->configuredPsb = HDD_PSB_CFG_INVALID;
Jeff Johnson295189b2012-06-20 16:38:30 -07001727
1728 return VOS_STATUS_SUCCESS;
1729}
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301730
1731/**============================================================================
1732 @brief hdd_wmm_adapter_clear() - Function which will clear the WMM status
1733 for all the ACs
1734
1735 @param pAdapter : [in] pointer to Adapter context
1736
1737 @return : VOS_STATUS_SUCCESS if succssful
1738 : other values if failure
1739
1740 ===========================================================================*/
1741VOS_STATUS hdd_wmm_adapter_clear( hdd_adapter_t *pAdapter )
1742{
1743 hdd_wmm_ac_status_t *pAcStatus;
1744 WLANTL_ACEnumType acType;
1745 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1746 "%s: Entered", __func__);
1747 for (acType = 0; acType < WLANTL_MAX_AC; acType++)
1748 {
1749 pAcStatus = &pAdapter->hddWmmStatus.wmmAcStatus[acType];
1750 pAcStatus->wmmAcAccessRequired = VOS_FALSE;
1751 pAcStatus->wmmAcAccessNeeded = VOS_FALSE;
1752 pAcStatus->wmmAcAccessPending = VOS_FALSE;
1753 pAcStatus->wmmAcAccessFailed = VOS_FALSE;
1754 pAcStatus->wmmAcAccessGranted = VOS_FALSE;
1755 pAcStatus->wmmAcAccessAllowed = VOS_FALSE;
1756 pAcStatus->wmmAcTspecValid = VOS_FALSE;
1757 pAcStatus->wmmAcUapsdInfoValid = VOS_FALSE;
1758 }
1759 return VOS_STATUS_SUCCESS;
1760}
1761
Jeff Johnson295189b2012-06-20 16:38:30 -07001762/**============================================================================
1763 @brief hdd_wmm_close() - Function which will perform any necessary work to
1764 to clean up the WMM functionality prior to the kernel module unload
1765
1766 @param pAdapter : [in] pointer to adapter context
1767
1768 @return : VOS_STATUS_SUCCESS if succssful
1769 : other values if failure
1770
1771 ===========================================================================*/
1772VOS_STATUS hdd_wmm_adapter_close ( hdd_adapter_t* pAdapter )
1773{
1774 hdd_wmm_qos_context_t* pQosContext;
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301775 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1776 hdd_context_t *pHddCtx;
1777
1778 if (NULL != pVosContext)
1779 {
1780 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1781 if (NULL == pHddCtx)
1782 {
1783 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
1784 FL("HddCtx is NULL"));
1785 return VOS_STATUS_E_FAILURE;
1786 }
1787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001788
1789 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001790 "%s: Entered", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001791
1792 // free any context records that we still have linked
1793 while (!list_empty(&pAdapter->hddWmmStatus.wmmContextList))
1794 {
1795 pQosContext = list_first_entry(&pAdapter->hddWmmStatus.wmmContextList,
1796 hdd_wmm_qos_context_t, node);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001797#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 hdd_wmm_disable_inactivity_timer(pQosContext);
1799#endif
Sameer Thalappilbee426e2013-10-30 10:30:30 -07001800#ifdef WLAN_OPEN_SOURCE
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301801 mutex_lock(&pHddCtx->wmmLock);
Anand N Sunkad4b25a2f2014-11-13 16:01:08 +05301802 if (pQosContext->handle == HDD_WMM_HANDLE_IMPLICIT
1803 && pQosContext->magic == HDD_WMM_CTX_MAGIC)
1804 {
1805
Sameer Thalappilbee426e2013-10-30 10:30:30 -07001806 cancel_work_sync(&pQosContext->wmmAcSetupImplicitQos);
Anand N Sunkad4b25a2f2014-11-13 16:01:08 +05301807 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05301808 mutex_unlock(&pHddCtx->wmmLock);
Sameer Thalappilbee426e2013-10-30 10:30:30 -07001809#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001810 hdd_wmm_free_context(pQosContext);
1811 }
1812
1813 return VOS_STATUS_SUCCESS;
1814}
1815
1816/**============================================================================
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301817 @brief hdd_is_dhcp_packet() - Function which will check OS packet for
Madan Mohan Koyyalamudifd3b7a92013-10-10 15:02:58 +05301818 DHCP packet
1819
1820 @param skb : [in] pointer to OS packet (sk_buff)
1821 @return : VOS_TRUE if the OS packet is DHCP packet
1822 : otherwise VOS_FALSE
1823 ===========================================================================*/
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301824v_BOOL_t hdd_is_dhcp_packet(struct sk_buff *skb)
Madan Mohan Koyyalamudifd3b7a92013-10-10 15:02:58 +05301825{
1826 if (*((u16*)((u8*)skb->data+34)) == DHCP_SOURCE_PORT ||
1827 *((u16*)((u8*)skb->data+34)) == DHCP_DESTINATION_PORT)
1828 return VOS_TRUE;
1829
1830 return VOS_FALSE;
1831}
1832
1833/**============================================================================
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301834 @brief hdd_skb_is_eapol_or_wai_packet() - Function which will check OS packet
1835 for Eapol/Wapi packet
1836
1837 @param skb : [in] pointer to OS packet (sk_buff)
1838 @return : VOS_TRUE if the OS packet is an Eapol or a Wapi packet
1839 : otherwise VOS_FALSE
1840 ===========================================================================*/
1841v_BOOL_t hdd_skb_is_eapol_or_wai_packet(struct sk_buff *skb)
1842{
1843 if ((*((u16*)((u8*)skb->data+HDD_ETHERTYPE_802_1_X_FRAME_OFFSET))
1844 == vos_cpu_to_be16(HDD_ETHERTYPE_802_1_X))
1845#ifdef FEATURE_WLAN_WAPI
1846 || (*((u16*)((u8*)skb->data+HDD_ETHERTYPE_802_1_X_FRAME_OFFSET))
1847 == vos_cpu_to_be16(HDD_ETHERTYPE_WAI))
1848#endif
1849 )
1850 return VOS_TRUE;
1851
1852 return VOS_FALSE;
1853}
1854
1855/**============================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -07001856 @brief hdd_wmm_classify_pkt() - Function which will classify an OS packet
1857 into a WMM AC based on either 802.1Q or DSCP
1858
1859 @param pAdapter : [in] pointer to adapter context
1860 @param skb : [in] pointer to OS packet (sk_buff)
1861 @param pAcType : [out] pointer to WMM AC type of OS packet
1862
1863 @return : None
1864 ===========================================================================*/
1865v_VOID_t hdd_wmm_classify_pkt ( hdd_adapter_t* pAdapter,
1866 struct sk_buff *skb,
1867 WLANTL_ACEnumType* pAcType,
1868 sme_QosWmmUpType *pUserPri)
1869{
1870 unsigned char * pPkt;
1871 union generic_ethhdr *pHdr;
1872 struct iphdr *pIpHdr;
1873 unsigned char tos;
1874 unsigned char dscp;
1875 sme_QosWmmUpType userPri;
1876 WLANTL_ACEnumType acType;
1877
1878 // this code is executed for every packet therefore
1879 // all debug code is kept conditional
1880
1881#ifdef HDD_WMM_DEBUG
1882 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001883 "%s: Entered", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001884#endif // HDD_WMM_DEBUG
1885
1886 pPkt = skb->data;
1887 pHdr = (union generic_ethhdr *)pPkt;
1888
1889#ifdef HDD_WMM_DEBUG
1890 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1891 "%s: proto/length is 0x%04x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001892 __func__, pHdr->eth_II.h_proto);
Jeff Johnson295189b2012-06-20 16:38:30 -07001893#endif // HDD_WMM_DEBUG
1894
1895 if (HDD_WMM_CLASSIFICATION_DSCP == (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->PktClassificationBasis)
1896 {
1897 if (pHdr->eth_II.h_proto == htons(ETH_P_IP))
1898 {
1899 // case 1: Ethernet II IP packet
1900 pIpHdr = (struct iphdr *)&pPkt[sizeof(pHdr->eth_II)];
1901 tos = pIpHdr->tos;
1902#ifdef HDD_WMM_DEBUG
1903 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1904 "%s: Ethernet II IP Packet, tos is %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001905 __func__, tos);
Jeff Johnson295189b2012-06-20 16:38:30 -07001906#endif // HDD_WMM_DEBUG
1907
1908 }
1909 else if ((ntohs(pHdr->eth_II.h_proto) < WLAN_MIN_PROTO) &&
1910 (pHdr->eth_8023.h_snap.dsap == WLAN_SNAP_DSAP) &&
1911 (pHdr->eth_8023.h_snap.ssap == WLAN_SNAP_SSAP) &&
1912 (pHdr->eth_8023.h_snap.ctrl == WLAN_SNAP_CTRL) &&
1913 (pHdr->eth_8023.h_proto == htons(ETH_P_IP)))
1914 {
1915 // case 2: 802.3 LLC/SNAP IP packet
1916 pIpHdr = (struct iphdr *)&pPkt[sizeof(pHdr->eth_8023)];
1917 tos = pIpHdr->tos;
1918#ifdef HDD_WMM_DEBUG
1919 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1920 "%s: 802.3 LLC/SNAP IP Packet, tos is %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001921 __func__, tos);
Jeff Johnson295189b2012-06-20 16:38:30 -07001922#endif // HDD_WMM_DEBUG
1923 }
1924 else if (pHdr->eth_II.h_proto == htons(ETH_P_8021Q))
1925 {
1926 // VLAN tagged
1927
1928 if (pHdr->eth_IIv.h_vlan_encapsulated_proto == htons(ETH_P_IP))
1929 {
1930 // case 3: Ethernet II vlan-tagged IP packet
1931 pIpHdr = (struct iphdr *)&pPkt[sizeof(pHdr->eth_IIv)];
1932 tos = pIpHdr->tos;
1933#ifdef HDD_WMM_DEBUG
1934 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1935 "%s: Ethernet II VLAN tagged IP Packet, tos is %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001936 __func__, tos);
Jeff Johnson295189b2012-06-20 16:38:30 -07001937#endif // HDD_WMM_DEBUG
1938 }
1939 else if ((ntohs(pHdr->eth_IIv.h_vlan_encapsulated_proto) < WLAN_MIN_PROTO) &&
1940 (pHdr->eth_8023v.h_snap.dsap == WLAN_SNAP_DSAP) &&
1941 (pHdr->eth_8023v.h_snap.ssap == WLAN_SNAP_SSAP) &&
1942 (pHdr->eth_8023v.h_snap.ctrl == WLAN_SNAP_CTRL) &&
1943 (pHdr->eth_8023v.h_proto == htons(ETH_P_IP)))
1944 {
1945 // case 4: 802.3 LLC/SNAP vlan-tagged IP packet
1946 pIpHdr = (struct iphdr *)&pPkt[sizeof(pHdr->eth_8023v)];
1947 tos = pIpHdr->tos;
1948#ifdef HDD_WMM_DEBUG
1949 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
1950 "%s: 802.3 LLC/SNAP VLAN tagged IP Packet, tos is %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001951 __func__, tos);
Jeff Johnson295189b2012-06-20 16:38:30 -07001952#endif // HDD_WMM_DEBUG
1953 }
1954 else
1955 {
1956 // default
1957#ifdef HDD_WMM_DEBUG
1958 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_WARN,
1959 "%s: VLAN tagged Unhandled Protocol, using default tos",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001960 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001961#endif // HDD_WMM_DEBUG
1962 tos = 0;
1963 }
1964 }
1965 else
1966 {
1967 // default
1968#ifdef HDD_WMM_DEBUG
1969 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_WARN,
1970 "%s: Unhandled Protocol, using default tos",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001971 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001972#endif // HDD_WMM_DEBUG
1973 //Give the highest priority to 802.1x packet
1974 if (pHdr->eth_II.h_proto == htons(HDD_ETHERTYPE_802_1_X))
1975 tos = 0xC0;
1976 else
1977 tos = 0;
1978 }
1979
1980 dscp = (tos>>2) & 0x3f;
Kumar Anand82c009f2014-05-29 00:29:42 -07001981 userPri = pAdapter->hddWmmDscpToUpMap[dscp];
1982
Jeff Johnson295189b2012-06-20 16:38:30 -07001983#ifdef HDD_WMM_DEBUG
1984 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1985 "%s: tos is %d, dscp is %d, up is %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001986 __func__, tos, dscp, userPri);
Jeff Johnson295189b2012-06-20 16:38:30 -07001987#endif // HDD_WMM_DEBUG
1988
1989 }
1990 else if (HDD_WMM_CLASSIFICATION_802_1Q == (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->PktClassificationBasis)
1991 {
1992 if (pHdr->eth_IIv.h_vlan_proto == htons(ETH_P_8021Q))
1993 {
1994 // VLAN tagged
1995 userPri = (ntohs(pHdr->eth_IIv.h_vlan_TCI)>>13) & 0x7;
1996#ifdef HDD_WMM_DEBUG
1997 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
1998 "%s: Tagged frame, UP is %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001999 __func__, userPri);
Jeff Johnson295189b2012-06-20 16:38:30 -07002000#endif // HDD_WMM_DEBUG
2001 }
2002 else
2003 {
2004 // not VLAN tagged, use default
2005#ifdef HDD_WMM_DEBUG
2006 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_WARN,
2007 "%s: Untagged frame, using default UP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002008 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002009#endif // HDD_WMM_DEBUG
2010 //Give the highest priority to 802.1x packet
2011 if (pHdr->eth_II.h_proto == htons(HDD_ETHERTYPE_802_1_X))
2012 userPri = SME_QOS_WMM_UP_VO;
2013 else
2014 userPri = SME_QOS_WMM_UP_BE;
2015 }
2016 }
2017 else
2018 {
2019 // default
2020#ifdef HDD_WMM_DEBUG
2021 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
2022 "%s: Unknown classification scheme, using default UP",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002023 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002024#endif // HDD_WMM_DEBUG
2025 userPri = SME_QOS_WMM_UP_BE;
2026 }
2027
2028 acType = hddWmmUpToAcMap[userPri];
2029
2030#ifdef HDD_WMM_DEBUG
2031 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
2032 "%s: UP is %d, AC is %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002033 __func__, userPri, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002034#endif // HDD_WMM_DEBUG
2035
2036 *pUserPri = userPri;
2037 *pAcType = acType;
2038
2039 return;
2040}
2041
2042/**============================================================================
2043 @brief hdd_hostapd_select_quueue() - Function which will classify the packet
2044 according to linux qdisc expectation.
2045
2046
2047 @param dev : [in] pointer to net_device structure
2048 @param skb : [in] pointer to os packet
2049
2050 @return : Qdisc queue index
2051 ===========================================================================*/
2052v_U16_t hdd_hostapd_select_queue(struct net_device * dev, struct sk_buff *skb)
2053{
2054 WLANTL_ACEnumType ac;
2055 sme_QosWmmUpType up = SME_QOS_WMM_UP_BE;
2056 v_USHORT_t queueIndex;
2057 v_MACADDR_t *pDestMacAddress = (v_MACADDR_t*)skb->data;
2058 hdd_adapter_t *pAdapter = (hdd_adapter_t *)netdev_priv(dev);
2059 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 v_U8_t STAId;
2061 v_U8_t *pSTAId = (v_U8_t *)(((v_U8_t *)(skb->data)) - 1);
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302062 v_CONTEXT_t pVosContext = ( WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
2063 ptSapContext pSapCtx = NULL;
2064 pSapCtx = VOS_GET_SAP_CB(pVosContext);
2065 if(pSapCtx == NULL){
2066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2067 FL("psapCtx is NULL"));
2068 *pSTAId = HDD_WLAN_INVALID_STA_ID;
2069 goto done;
2070 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 /*Get the Station ID*/
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 if (VOS_STATUS_SUCCESS != hdd_softap_GetStaId(pAdapter, pDestMacAddress, &STAId))
2073 {
Agarwal Ashisha64c9542014-03-04 00:14:43 +05302074 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002075 "%s: Failed to find right station", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 *pSTAId = HDD_WLAN_INVALID_STA_ID;
2077 goto done;
2078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002079
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302080 spin_lock_bh( &pSapCtx->staInfo_lock );
2081 if (FALSE == vos_is_macaddr_equal(&pSapCtx->aStaInfo[STAId].macAddrSTA, pDestMacAddress))
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 {
Agarwal Ashisha64c9542014-03-04 00:14:43 +05302083 VOS_TRACE( VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_INFO,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002084 "%s: Station MAC address does not matching", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002085
2086 *pSTAId = HDD_WLAN_INVALID_STA_ID;
2087 goto release_lock;
2088 }
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302089 if (pSapCtx->aStaInfo[STAId].isUsed && pSapCtx->aStaInfo[STAId].isQosEnabled && (HDD_WMM_USER_MODE_NO_QOS != pHddCtx->cfg_ini->WmmMode))
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 {
2091 /* Get the user priority from IP header & corresponding AC */
2092 hdd_wmm_classify_pkt (pAdapter, skb, &ac, &up);
Madan Mohan Koyyalamudifd3b7a92013-10-10 15:02:58 +05302093 //If 3/4th of Tx queue is used then place the DHCP packet in VOICE AC queue
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302094 if (pSapCtx->aStaInfo[STAId].vosLowResource && hdd_is_dhcp_packet(skb))
Madan Mohan Koyyalamudifd3b7a92013-10-10 15:02:58 +05302095 {
2096 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_WARN,
2097 "%s: Making priority of DHCP packet as VOICE", __func__);
2098 up = SME_QOS_WMM_UP_VO;
2099 ac = hddWmmUpToAcMap[up];
2100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 }
2102 *pSTAId = STAId;
2103
2104release_lock:
Sachin Ahujabcb0b7e2014-11-07 13:01:24 +05302105 spin_unlock_bh( &pSapCtx->staInfo_lock );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106done:
2107 skb->priority = up;
Mukul Sharmad82cb7d2014-07-03 14:53:30 +05302108 if(skb->priority < SME_QOS_WMM_UP_MAX)
2109 queueIndex = hddLinuxUpToAcMap[skb->priority];
2110 else
2111 {
2112 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
2113 "%s: up=%d is going beyond max value", __func__, up);
2114 queueIndex = hddLinuxUpToAcMap[SME_QOS_WMM_UP_BE];
2115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002116
2117 return queueIndex;
2118}
2119
2120/**============================================================================
2121 @brief hdd_wmm_select_quueue() - Function which will classify the packet
2122 according to linux qdisc expectation.
2123
2124
2125 @param dev : [in] pointer to net_device structure
2126 @param skb : [in] pointer to os packet
2127
2128 @return : Qdisc queue index
2129 ===========================================================================*/
2130v_U16_t hdd_wmm_select_queue(struct net_device * dev, struct sk_buff *skb)
2131{
2132 WLANTL_ACEnumType ac;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002133 sme_QosWmmUpType up = SME_QOS_WMM_UP_BE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 v_USHORT_t queueIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2136
Kiet Lam40009862014-02-13 12:33:22 -08002137 if (isWDresetInProgress()) {
2138 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2139 FL("called during WDReset"));
2140 skb->priority = SME_QOS_WMM_UP_BE;
2141 return HDD_LINUX_AC_BE;
2142 }
2143
Shailender Karmuchia734f332013-04-19 14:02:48 -07002144 /*Get the Station ID*/
2145 if (WLAN_HDD_IBSS == pAdapter->device_mode)
2146 {
2147 v_U8_t *pSTAId = (v_U8_t *)(((v_U8_t *)(skb->data)) - 1);
2148 v_MACADDR_t *pDestMacAddress = (v_MACADDR_t*)skb->data;
2149
2150 if ( VOS_STATUS_SUCCESS !=
2151 hdd_Ibss_GetStaId(&pAdapter->sessionCtx.station,
2152 pDestMacAddress, pSTAId))
2153 {
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302154 *pSTAId = HDD_WLAN_INVALID_STA_ID;
2155 if ( !vos_is_macaddr_broadcast( pDestMacAddress ) &&
2156 !vos_is_macaddr_group(pDestMacAddress))
2157 {
2158 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Jeff Johnsonb9fb9ce2013-05-03 08:11:02 -07002159 "%s: Failed to find right station pDestMacAddress: "
2160 MAC_ADDRESS_STR , __func__,
2161 MAC_ADDR_ARRAY(pDestMacAddress->bytes));
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302162 goto done;
2163 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002164 }
2165 }
Agarwal Ashish8b343f12015-01-08 20:06:44 +05302166 /* All traffic will get equal opportuniy to transmit data frames. */
2167 /* Get the user priority from IP header & corresponding AC */
2168 hdd_wmm_classify_pkt (pAdapter, skb, &ac, &up);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302169
Agarwal Ashish8b343f12015-01-08 20:06:44 +05302170 /* If 3/4th of BE AC Tx queue is full,
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302171 * then place the DHCP packet in VOICE AC queue.
2172 * Doing this for IBSS alone, since for STA interface
2173 * types, these packets will be queued to the new queue.
Agarwal Ashish8b343f12015-01-08 20:06:44 +05302174 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302175 if ((WLAN_HDD_IBSS == pAdapter->device_mode) &&
2176 pAdapter->isVosLowResource && hdd_is_dhcp_packet(skb))
Agarwal Ashish8b343f12015-01-08 20:06:44 +05302177 {
2178 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_WARN,
2179 "%s: BestEffort Tx Queue is 3/4th full"
2180 " Make DHCP packet's pri as VO", __func__);
2181 up = SME_QOS_WMM_UP_VO;
2182 ac = hddWmmUpToAcMap[up];
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 }
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302184
Shailender Karmuchia734f332013-04-19 14:02:48 -07002185done:
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 skb->priority = up;
Mukul Sharmad82cb7d2014-07-03 14:53:30 +05302187 if(skb->priority < SME_QOS_WMM_UP_MAX)
2188 queueIndex = hddLinuxUpToAcMap[skb->priority];
2189 else
2190 {
2191 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
2192 "%s: up=%d is going beyond max value", __func__, up);
2193 queueIndex = hddLinuxUpToAcMap[SME_QOS_WMM_UP_BE];
2194 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002195
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302196 if ((WLAN_HDD_IBSS != pAdapter->device_mode) &&
2197 (hdd_is_dhcp_packet(skb) ||
2198 hdd_skb_is_eapol_or_wai_packet(skb)))
2199 {
2200 /* If the packet is a DHCP packet or a Eapol packet or
2201 * a Wapi packet, then queue it to the new queue for
2202 * STA interfaces alone.
2203 */
2204 queueIndex = WLANTL_AC_HIGH_PRIO;
2205 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2206 "%s: up=%d QIndex:%d", __func__, up, queueIndex);
2207 }
2208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 return queueIndex;
2210}
2211
Kiet Lamf040f472013-11-20 21:15:23 +05302212/**==========================================================================
2213 @brief hdd_wmm_acquire_access_required() - Function which will determine
2214 acquire admittance for a WMM AC is required or not based on psb configuration
2215 done in framework
2216
2217 @param pAdapter : [in] pointer to adapter structure
2218
2219 @param acType : [in] WMM AC type of OS packet
2220
2221 @return : void
2222 ===========================================================================*/
2223void hdd_wmm_acquire_access_required(hdd_adapter_t *pAdapter,
2224 WLANTL_ACEnumType acType)
2225{
2226/* Each bit in the LSB nibble indicates 1 AC.
2227 * Clearing the particular bit in LSB nibble to indicate
2228 * access required
2229 */
2230 switch(acType)
2231 {
2232 case WLANTL_AC_BK:
2233 pAdapter->psbChanged &= ~SME_QOS_UAPSD_CFG_BK_CHANGED_MASK; /* clear first bit */
2234 break;
2235 case WLANTL_AC_BE:
2236 pAdapter->psbChanged &= ~SME_QOS_UAPSD_CFG_BE_CHANGED_MASK; /* clear second bit */
2237 break;
2238 case WLANTL_AC_VI:
2239 pAdapter->psbChanged &= ~SME_QOS_UAPSD_CFG_VI_CHANGED_MASK; /* clear third bit */
2240 break;
2241 case WLANTL_AC_VO:
2242 pAdapter->psbChanged &= ~SME_QOS_UAPSD_CFG_VO_CHANGED_MASK; /* clear fourth bit */
2243 break;
2244 default:
2245 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
2246 "%s: Invalid AC Type", __func__);
2247 break;
2248 }
2249}
2250
Jeff Johnson295189b2012-06-20 16:38:30 -07002251/**============================================================================
2252 @brief hdd_wmm_acquire_access() - Function which will attempt to acquire
2253 admittance for a WMM AC
2254
2255 @param pAdapter : [in] pointer to adapter context
2256 @param acType : [in] WMM AC type of OS packet
2257 @param pGranted : [out] pointer to boolean flag when indicates if access
2258 has been granted or not
2259
2260 @return : VOS_STATUS_SUCCESS if succssful
2261 : other values if failure
2262 ===========================================================================*/
2263VOS_STATUS hdd_wmm_acquire_access( hdd_adapter_t* pAdapter,
2264 WLANTL_ACEnumType acType,
2265 v_BOOL_t * pGranted )
2266{
2267 hdd_wmm_qos_context_t *pQosContext;
2268
2269 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002270 "%s: Entered for AC %d", __func__, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002271
2272 if (!hdd_wmm_is_active(pAdapter) || !(WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->bImplicitQosEnabled)
2273 {
2274 // either we don't want QoS or the AP doesn't support QoS
2275 // or we don't want to do implicit QoS
2276 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002277 "%s: QoS not configured on both ends ", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002278
2279 pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessAllowed = VOS_TRUE;
2280 *pGranted = VOS_TRUE;
2281 return VOS_STATUS_SUCCESS;
2282 }
2283
2284 // do we already have an implicit QoS request pending for this AC?
2285 if ((pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessNeeded) ||
2286 (pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessPending))
2287 {
2288 // request already pending so we need to wait for that response
2289 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2290 "%s: Implicit QoS for TL AC %d already scheduled",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002291 __func__, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002292
2293 *pGranted = VOS_FALSE;
2294 return VOS_STATUS_SUCCESS;
2295 }
2296
2297 // did we already fail to establish implicit QoS for this AC?
2298 // (if so, access should have been granted when the failure was handled)
2299 if (pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessFailed)
2300 {
2301 // request previously failed
2302 // allow access, but we'll be downgraded
2303 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2304 "%s: Implicit QoS for TL AC %d previously failed",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002305 __func__, acType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002306
2307 pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessAllowed = VOS_TRUE;
2308 *pGranted = VOS_TRUE;
2309 return VOS_STATUS_SUCCESS;
2310 }
2311
2312 // we need to establish implicit QoS
2313 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
2314 "%s: Need to schedule implicit QoS for TL AC %d, pAdapter is %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002315 __func__, acType, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002316
2317 pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessNeeded = VOS_TRUE;
2318
Mohit Khanna217ea8d2012-09-11 17:42:42 -07002319 pQosContext = kmalloc(sizeof(*pQosContext), GFP_ATOMIC);
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 if (NULL == pQosContext)
2321 {
2322 // no memory for QoS context. Nothing we can do but let data flow
2323 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002324 "%s: Unable to allocate context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcAccessAllowed = VOS_TRUE;
2326 *pGranted = VOS_TRUE;
2327 return VOS_STATUS_SUCCESS;
2328 }
2329
2330 pQosContext->acType = acType;
2331 pQosContext->pAdapter = pAdapter;
2332 pQosContext->qosFlowId = 0;
2333 pQosContext->handle = HDD_WMM_HANDLE_IMPLICIT;
2334 pQosContext->magic = HDD_WMM_CTX_MAGIC;
2335 INIT_WORK(&pQosContext->wmmAcSetupImplicitQos,
2336 hdd_wmm_do_implicit_qos);
2337
2338 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
2339 "%s: Scheduling work for AC %d, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002340 __func__, acType, pQosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002341
2342 schedule_work(&pQosContext->wmmAcSetupImplicitQos);
2343
2344 // caller will need to wait until the work takes place and
2345 // TSPEC negotiation completes
2346 *pGranted = VOS_FALSE;
2347 return VOS_STATUS_SUCCESS;
2348}
2349
2350/**============================================================================
2351 @brief hdd_wmm_assoc() - Function which will handle the housekeeping
2352 required by WMM when association takes place
2353
2354 @param pAdapter : [in] pointer to adapter context
2355 @param pRoamInfo: [in] pointer to roam information
2356 @param eBssType : [in] type of BSS
2357
2358 @return : VOS_STATUS_SUCCESS if succssful
2359 : other values if failure
2360 ===========================================================================*/
2361VOS_STATUS hdd_wmm_assoc( hdd_adapter_t* pAdapter,
2362 tCsrRoamInfo *pRoamInfo,
2363 eCsrRoamBssType eBssType )
2364{
2365 tANI_U8 uapsdMask;
2366 VOS_STATUS status;
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -07002367 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368
2369 // when we associate we need to notify TL if it needs to enable
2370 // UAPSD for any access categories
2371
2372 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002373 "%s: Entered", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002374
2375 if (pRoamInfo->fReassocReq)
2376 {
2377 // when we reassociate we should continue to use whatever
2378 // parameters were previously established. if we are
2379 // reassociating due to a U-APSD change for a particular
2380 // Access Category, then the change will be communicated
2381 // to HDD via the QoS callback associated with the given
2382 // flow, and U-APSD parameters will be updated there
2383
2384 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002385 "%s: Reassoc so no work, Exiting", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002386
2387 return VOS_STATUS_SUCCESS;
2388 }
2389
2390 // get the negotiated UAPSD Mask
2391 uapsdMask = pRoamInfo->u.pConnectedProfile->modifyProfileFields.uapsd_mask;
2392
2393 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002394 "%s: U-APSD mask is 0x%02x", __func__, (int) uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002395
2396 if (uapsdMask & HDD_AC_VO)
2397 {
2398 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2399 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2400 WLANTL_AC_VO,
2401 7,
2402 7,
2403 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdVoSrvIntv,
2404 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdVoSuspIntv,
2405 WLANTL_BI_DIR );
2406
2407 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ));
2408 }
2409
2410 if (uapsdMask & HDD_AC_VI)
2411 {
2412 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2413 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2414 WLANTL_AC_VI,
2415 5,
2416 5,
2417 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdViSrvIntv,
2418 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdViSuspIntv,
2419 WLANTL_BI_DIR );
2420
2421 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ));
2422 }
2423
2424 if (uapsdMask & HDD_AC_BK)
2425 {
2426 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2427 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2428 WLANTL_AC_BK,
2429 2,
2430 2,
2431 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBkSrvIntv,
2432 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBkSuspIntv,
2433 WLANTL_BI_DIR );
2434
2435 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ));
2436 }
2437
2438 if (uapsdMask & HDD_AC_BE)
2439 {
2440 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
2441 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.staId[0],
2442 WLANTL_AC_BE,
2443 3,
2444 3,
2445 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBeSrvIntv,
2446 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBeSuspIntv,
2447 WLANTL_BI_DIR );
2448
2449 VOS_ASSERT( VOS_IS_STATUS_SUCCESS( status ));
2450 }
Kumar Anand82c009f2014-05-29 00:29:42 -07002451
2452 status = sme_UpdateDSCPtoUPMapping(pHddCtx->hHal,
2453 pAdapter->hddWmmDscpToUpMap, pAdapter->sessionId);
2454
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -07002455 if (!VOS_IS_STATUS_SUCCESS( status ))
2456 {
Kumar Anand82c009f2014-05-29 00:29:42 -07002457 hdd_wmm_init( pAdapter );
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -07002458 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002459
2460 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002461 "%s: Exiting", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002462
2463 return VOS_STATUS_SUCCESS;
2464}
2465
2466
2467
2468static const v_U8_t acmMaskBit[WLANTL_MAX_AC] =
2469 {
2470 0x4, /* WLANTL_AC_BK */
2471 0x8, /* WLANTL_AC_BE */
2472 0x2, /* WLANTL_AC_VI */
2473 0x1 /* WLANTL_AC_VO */
2474 };
2475
2476/**============================================================================
2477 @brief hdd_wmm_connect() - Function which will handle the housekeeping
2478 required by WMM when a connection is established
2479
2480 @param pAdapter : [in] pointer to adapter context
2481 @param pRoamInfo: [in] pointer to roam information
2482 @param eBssType : [in] type of BSS
2483
2484 @return : VOS_STATUS_SUCCESS if succssful
2485 : other values if failure
2486 ===========================================================================*/
2487VOS_STATUS hdd_wmm_connect( hdd_adapter_t* pAdapter,
2488 tCsrRoamInfo *pRoamInfo,
2489 eCsrRoamBssType eBssType )
2490{
2491 int ac;
2492 v_BOOL_t qap;
2493 v_BOOL_t qosConnection;
2494 v_U8_t acmMask;
2495
2496 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002497 "%s: Entered", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002498
2499 if ((eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) &&
2500 pRoamInfo &&
2501 pRoamInfo->u.pConnectedProfile)
2502 {
2503 qap = pRoamInfo->u.pConnectedProfile->qap;
2504 qosConnection = pRoamInfo->u.pConnectedProfile->qosConnection;
2505 acmMask = pRoamInfo->u.pConnectedProfile->acm_mask;
2506 }
2507 else
2508 {
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302509 /* TODO: if a non-qos IBSS peer joins the group make qap and qosConnection false.
2510 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002511 qap = VOS_TRUE;
2512 qosConnection = VOS_TRUE;
2513 acmMask = 0x0;
2514 }
2515
2516 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2517 "%s: qap is %d, qosConnection is %d, acmMask is 0x%x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002518 __func__, qap, qosConnection, acmMask);
Jeff Johnson295189b2012-06-20 16:38:30 -07002519
2520 pAdapter->hddWmmStatus.wmmQap = qap;
2521 pAdapter->hddWmmStatus.wmmQosConnection = qosConnection;
2522
2523 for (ac = 0; ac < WLANTL_MAX_AC; ac++)
2524 {
2525 if (qap &&
2526 qosConnection &&
2527 (acmMask & acmMaskBit[ac]))
2528 {
2529 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2530 "%s: ac %d on",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002531 __func__, ac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002532
2533 // admission is required
2534 pAdapter->hddWmmStatus.wmmAcStatus[ac].wmmAcAccessRequired = VOS_TRUE;
2535 pAdapter->hddWmmStatus.wmmAcStatus[ac].wmmAcAccessAllowed = VOS_FALSE;
2536 pAdapter->hddWmmStatus.wmmAcStatus[ac].wmmAcAccessGranted = VOS_FALSE;
Mukul Sharma74a01e52014-07-21 15:14:23 +05302537
2538 /* Making TSPEC invalid here so downgrading can be happen while roaming
2539 * It is expected this will be SET in hdd_wmm_sme_callback,once sme is
Padma, Santhosh Kumard02afd62014-11-04 12:16:06 +05302540 * done with the AddTspec.Here we avoid 11r and ccx based association.
2541 This change is done only when reassoc to different AP.
Mukul Sharma74a01e52014-07-21 15:14:23 +05302542 */
Mukul Sharma9ca96b22014-11-15 19:40:04 +05302543 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2544 FL( "fReassocReq = %d"
2545#if defined (FEATURE_WLAN_ESE)
2546 "isESEAssoc = %d"
2547#endif
2548#if defined (WLAN_FEATURE_VOWIFI_11R)
2549 "is11rAssoc = %d"
2550#endif
2551 ),
2552 pRoamInfo->fReassocReq
2553#if defined (FEATURE_WLAN_ESE)
2554 ,pRoamInfo->isESEAssoc
2555#endif
2556#if defined (WLAN_FEATURE_VOWIFI_11R)
2557 ,pRoamInfo->is11rAssoc
2558#endif
2559 );
2560
Padma, Santhosh Kumard02afd62014-11-04 12:16:06 +05302561 if ( !pRoamInfo->fReassocReq
Mukul Sharma74a01e52014-07-21 15:14:23 +05302562#if defined (WLAN_FEATURE_VOWIFI_11R)
Padma, Santhosh Kumard02afd62014-11-04 12:16:06 +05302563 &&
Mukul Sharma9ca96b22014-11-15 19:40:04 +05302564 !pRoamInfo->is11rAssoc
Padma, Santhosh Kumard02afd62014-11-04 12:16:06 +05302565#endif
Mukul Sharma74a01e52014-07-21 15:14:23 +05302566#if defined (FEATURE_WLAN_ESE)
2567 &&
Mukul Sharma9ca96b22014-11-15 19:40:04 +05302568 !pRoamInfo->isESEAssoc
Mukul Sharma74a01e52014-07-21 15:14:23 +05302569#endif
2570 )
Mukul Sharma74a01e52014-07-21 15:14:23 +05302571 {
2572 pAdapter->hddWmmStatus.wmmAcStatus[ac].wmmAcTspecValid = VOS_FALSE;
2573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 }
2575 else
2576 {
2577 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2578 "%s: ac %d off",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002579 __func__, ac);
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 // admission is not required so access is allowed
2581 pAdapter->hddWmmStatus.wmmAcStatus[ac].wmmAcAccessRequired = VOS_FALSE;
2582 pAdapter->hddWmmStatus.wmmAcStatus[ac].wmmAcAccessAllowed = VOS_TRUE;
2583 }
2584
2585 }
2586
2587 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002588 "%s: Exiting", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589
2590 return VOS_STATUS_SUCCESS;
2591}
2592
2593/**============================================================================
2594 @brief hdd_wmm_get_uapsd_mask() - Function which will calculate the
2595 initial value of the UAPSD mask based upon the device configuration
2596
2597 @param pAdapter : [in] pointer to adapter context
2598 @param pUapsdMask: [in] pointer to where the UAPSD Mask is to be stored
2599
2600 @return : VOS_STATUS_SUCCESS if succssful
2601 : other values if failure
2602 ===========================================================================*/
2603VOS_STATUS hdd_wmm_get_uapsd_mask( hdd_adapter_t* pAdapter,
2604 tANI_U8 *pUapsdMask )
2605{
2606 tANI_U8 uapsdMask;
2607
2608 if (HDD_WMM_USER_MODE_NO_QOS == (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
2609 {
2610 // no QOS then no UAPSD
2611 uapsdMask = 0;
2612 }
2613 else
2614 {
2615 // start with the default mask
2616 uapsdMask = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
2617
2618 // disable UAPSD for any ACs with a 0 Service Interval
2619 if( (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdVoSrvIntv == 0 )
2620 {
2621 uapsdMask &= ~HDD_AC_VO;
2622 }
2623
2624 if( (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdViSrvIntv == 0 )
2625 {
2626 uapsdMask &= ~HDD_AC_VI;
2627 }
2628
2629 if( (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBkSrvIntv == 0 )
2630 {
2631 uapsdMask &= ~HDD_AC_BK;
2632 }
2633
2634 if( (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->InfraUapsdBeSrvIntv == 0 )
2635 {
2636 uapsdMask &= ~HDD_AC_BE;
2637 }
2638 }
2639
2640 // return calculated mask
2641 *pUapsdMask = uapsdMask;
2642 return VOS_STATUS_SUCCESS;
2643}
2644
2645
2646/**============================================================================
2647 @brief hdd_wmm_is_active() - Function which will determine if WMM is
2648 active on the current connection
2649
2650 @param pAdapter : [in] pointer to adapter context
2651
2652 @return : VOS_TRUE if WMM is enabled
2653 : VOS_FALSE if WMM is not enabled
2654 ===========================================================================*/
2655v_BOOL_t hdd_wmm_is_active( hdd_adapter_t* pAdapter )
2656{
2657 if ((!pAdapter->hddWmmStatus.wmmQosConnection) ||
2658 (!pAdapter->hddWmmStatus.wmmQap))
2659 {
2660 return VOS_FALSE;
2661 }
2662 else
2663 {
2664 return VOS_TRUE;
2665 }
2666}
2667
2668/**============================================================================
2669 @brief hdd_wmm_addts() - Function which will add a traffic spec at the
2670 request of an application
2671
2672 @param pAdapter : [in] pointer to adapter context
2673 @param handle : [in] handle to uniquely identify a TS
2674 @param pTspec : [in] pointer to the traffic spec
2675
2676 @return : HDD_WLAN_WMM_STATUS_*
2677 ===========================================================================*/
2678hdd_wlan_wmm_status_e hdd_wmm_addts( hdd_adapter_t* pAdapter,
2679 v_U32_t handle,
2680 sme_QosWmmTspecInfo* pTspec )
2681{
2682 hdd_wmm_qos_context_t *pQosContext;
2683 hdd_wlan_wmm_status_e status = HDD_WLAN_WMM_STATUS_SETUP_SUCCESS ;
2684#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2685 sme_QosStatusType smeStatus;
2686#endif
2687 v_BOOL_t found = VOS_FALSE;
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302688 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2689 hdd_context_t *pHddCtx;
2690 if (NULL != pVosContext)
2691 {
2692 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2693 if (NULL == pHddCtx)
2694 {
2695 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
2696 FL("HddCtx is NULL"));
2697 return HDD_WLAN_WMM_STATUS_SETUP_FAILED;
2698 }
2699 }
2700
Jeff Johnson295189b2012-06-20 16:38:30 -07002701
2702 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002703 "%s: Entered with handle 0x%x", __func__, handle);
Jeff Johnson295189b2012-06-20 16:38:30 -07002704
2705 // see if a context already exists with the given handle
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302706 mutex_lock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 list_for_each_entry(pQosContext,
2708 &pAdapter->hddWmmStatus.wmmContextList,
2709 node)
2710 {
2711 if (pQosContext->handle == handle)
2712 {
2713 found = VOS_TRUE;
2714 break;
2715 }
2716 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302717 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 if (found)
2719 {
2720 // record with that handle already exists
2721 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
2722 "%s: Record already exists with handle 0x%x",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002723 __func__, handle);
Jeff Johnson295189b2012-06-20 16:38:30 -07002724
2725 /* Application is trying to modify some of the Tspec params. Allow it */
2726 smeStatus = sme_QosModifyReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
2727 pTspec,
2728 pQosContext->qosFlowId);
2729
2730 // need to check the return value and act appropriately
2731 switch (smeStatus)
2732 {
2733 case SME_QOS_STATUS_MODIFY_SETUP_PENDING_RSP:
2734 status = HDD_WLAN_WMM_STATUS_MODIFY_PENDING;
2735 break;
2736 case SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_NO_ACM_NO_APSD_RSP:
2737 status = HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS_NO_ACM_NO_UAPSD;
2738 break;
2739 case SME_QOS_STATUS_MODIFY_SETUP_SUCCESS_APSD_SET_ALREADY:
2740 status = HDD_WLAN_WMM_STATUS_MODIFY_SUCCESS_NO_ACM_UAPSD_EXISTING;
2741 break;
2742 case SME_QOS_STATUS_MODIFY_SETUP_INVALID_PARAMS_RSP:
2743 status = HDD_WLAN_WMM_STATUS_MODIFY_FAILED_BAD_PARAM;
2744 break;
2745 case SME_QOS_STATUS_MODIFY_SETUP_FAILURE_RSP:
2746 status = HDD_WLAN_WMM_STATUS_MODIFY_FAILED;
2747 break;
2748 case SME_QOS_STATUS_SETUP_NOT_QOS_AP_RSP:
2749 status = HDD_WLAN_WMM_STATUS_SETUP_FAILED_NO_WMM;
2750 break;
2751 default:
2752 // we didn't get back one of the SME_QOS_STATUS_MODIFY_* status codes
2753 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002754 "%s: unexpected SME Status=%d", __func__, smeStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 VOS_ASSERT(0);
2756 return HDD_WLAN_WMM_STATUS_MODIFY_FAILED;
2757 }
2758
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302759 mutex_lock(&pHddCtx->wmmLock);
c_hpothu48e31712014-12-23 16:59:03 +05302760 if (pQosContext->magic == HDD_WMM_CTX_MAGIC)
2761 {
2762 pQosContext->lastStatus = status;
2763 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302764 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 return status;
2766 }
2767
2768 pQosContext = kmalloc(sizeof(*pQosContext), GFP_KERNEL);
2769 if (NULL == pQosContext)
2770 {
2771 // no memory for QoS context. Nothing we can do
2772 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002773 "%s: Unable to allocate QoS context", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 return HDD_WLAN_WMM_STATUS_INTERNAL_FAILURE;
2775 }
2776
2777 // we assume the tspec has already been validated by the caller
2778
2779 pQosContext->handle = handle;
Mingcheng Zhu87f22fc2014-01-30 19:23:32 -08002780 if (pTspec->ts_info.up < HDD_WMM_UP_TO_AC_MAP_SIZE)
2781 pQosContext->acType = hddWmmUpToAcMap[pTspec->ts_info.up];
2782 else {
2783 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
2784 "%s: ts_info.up (%d) larger than max value (%d), "
2785 "use default acType (%d)",
2786 __func__, pTspec->ts_info.up,
2787 HDD_WMM_UP_TO_AC_MAP_SIZE - 1, hddWmmUpToAcMap[0]);
2788 pQosContext->acType = hddWmmUpToAcMap[0];
2789 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302790
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 pQosContext->pAdapter = pAdapter;
2792 pQosContext->qosFlowId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002793
2794 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
2795 "%s: Setting up QoS, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002796 __func__, pQosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002797
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302798 mutex_lock(&pHddCtx->wmmLock);
2799 pQosContext->magic = HDD_WMM_CTX_MAGIC;
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 list_add(&pQosContext->node, &pAdapter->hddWmmStatus.wmmContextList);
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302801 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002802
2803#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2804 smeStatus = sme_QosSetupReq(WLAN_HDD_GET_HAL_CTX(pAdapter),
2805 pAdapter->sessionId,
2806 pTspec,
2807 hdd_wmm_sme_callback,
2808 pQosContext,
2809 pTspec->ts_info.up,
2810 &pQosContext->qosFlowId);
2811
2812 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO,
2813 "%s: sme_QosSetupReq returned %d flowid %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002814 __func__, smeStatus, pQosContext->qosFlowId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002815
2816 // need to check the return value and act appropriately
2817 switch (smeStatus)
2818 {
2819 case SME_QOS_STATUS_SETUP_REQ_PENDING_RSP:
2820 status = HDD_WLAN_WMM_STATUS_SETUP_PENDING;
2821 break;
2822 case SME_QOS_STATUS_SETUP_SUCCESS_NO_ACM_NO_APSD_RSP:
2823 status = HDD_WLAN_WMM_STATUS_SETUP_SUCCESS_NO_ACM_NO_UAPSD;
2824 break;
2825 case SME_QOS_STATUS_SETUP_SUCCESS_APSD_SET_ALREADY:
2826 status = HDD_WLAN_WMM_STATUS_SETUP_SUCCESS_NO_ACM_UAPSD_EXISTING;
2827 break;
2828 case SME_QOS_STATUS_SETUP_SUCCESS_IND_APSD_PENDING:
2829 status = HDD_WLAN_WMM_STATUS_SETUP_PENDING;
2830 break;
2831 case SME_QOS_STATUS_SETUP_INVALID_PARAMS_RSP:
2832 hdd_wmm_free_context(pQosContext);
2833 return HDD_WLAN_WMM_STATUS_SETUP_FAILED_BAD_PARAM;
2834 case SME_QOS_STATUS_SETUP_FAILURE_RSP:
2835 // we can't tell the difference between when a request fails because
2836 // AP rejected it versus when SME encounterd an internal error
2837 hdd_wmm_free_context(pQosContext);
2838 return HDD_WLAN_WMM_STATUS_SETUP_FAILED;
2839 case SME_QOS_STATUS_SETUP_NOT_QOS_AP_RSP:
2840 hdd_wmm_free_context(pQosContext);
2841 return HDD_WLAN_WMM_STATUS_SETUP_FAILED_NO_WMM;
2842 default:
2843 // we didn't get back one of the SME_QOS_STATUS_SETUP_* status codes
2844 hdd_wmm_free_context(pQosContext);
2845 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002846 "%s: unexpected SME Status=%d", __func__, smeStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 VOS_ASSERT(0);
2848 return HDD_WLAN_WMM_STATUS_SETUP_FAILED;
2849 }
2850#endif
2851
2852 // we were successful, save the status
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302853 mutex_lock(&pHddCtx->wmmLock);
c_hpothu48e31712014-12-23 16:59:03 +05302854 if (pQosContext->magic == HDD_WMM_CTX_MAGIC)
2855 {
2856 pQosContext->lastStatus = status;
2857 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302858 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002859
2860 return status;
2861}
2862
2863/**============================================================================
2864 @brief hdd_wmm_delts() - Function which will delete a traffic spec at the
2865 request of an application
2866
2867 @param pAdapter : [in] pointer to adapter context
2868 @param handle : [in] handle to uniquely identify a TS
2869
2870 @return : HDD_WLAN_WMM_STATUS_*
2871 ===========================================================================*/
2872hdd_wlan_wmm_status_e hdd_wmm_delts( hdd_adapter_t* pAdapter,
2873 v_U32_t handle )
2874{
2875 hdd_wmm_qos_context_t *pQosContext;
2876 v_BOOL_t found = VOS_FALSE;
2877 WLANTL_ACEnumType acType = 0;
2878 v_U32_t qosFlowId = 0;
2879 hdd_wlan_wmm_status_e status = HDD_WLAN_WMM_STATUS_SETUP_SUCCESS ;
2880#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2881 sme_QosStatusType smeStatus;
2882#endif
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302883 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2884 hdd_context_t *pHddCtx;
2885
2886 if (NULL != pVosContext)
2887 {
2888 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2889 if (NULL == pHddCtx)
2890 {
2891 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
2892 FL("HddCtx is NULL"));
2893 return HDD_WLAN_WMM_STATUS_RELEASE_FAILED;
2894 }
2895 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002896
2897 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002898 "%s: Entered with handle 0x%x", __func__, handle);
Jeff Johnson295189b2012-06-20 16:38:30 -07002899
2900 // locate the context with the given handle
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302901 mutex_lock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 list_for_each_entry(pQosContext,
2903 &pAdapter->hddWmmStatus.wmmContextList,
2904 node)
2905 {
2906 if (pQosContext->handle == handle)
2907 {
2908 found = VOS_TRUE;
2909 acType = pQosContext->acType;
2910 qosFlowId = pQosContext->qosFlowId;
2911 break;
2912 }
2913 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302914 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002915
2916 if (VOS_FALSE == found)
2917 {
2918 // we didn't find the handle
2919 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002920 "%s: handle 0x%x not found", __func__, handle);
Jeff Johnson295189b2012-06-20 16:38:30 -07002921 return HDD_WLAN_WMM_STATUS_RELEASE_FAILED_BAD_PARAM;
2922 }
2923
2924
2925 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2926 "%s: found handle 0x%x, flow %d, AC %d, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002927 __func__, handle, qosFlowId, acType, pQosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07002928
2929#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2930 smeStatus = sme_QosReleaseReq( WLAN_HDD_GET_HAL_CTX(pAdapter), qosFlowId );
2931
2932 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
2933 "%s: SME flow %d released, SME status %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002934 __func__, qosFlowId, smeStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07002935
2936 switch(smeStatus)
2937 {
2938 case SME_QOS_STATUS_RELEASE_SUCCESS_RSP:
2939 // this flow is the only one on that AC, so go ahead and update
2940 // our TSPEC state for the AC
2941 pAdapter->hddWmmStatus.wmmAcStatus[acType].wmmAcTspecValid = VOS_FALSE;
2942
2943 // need to tell TL to stop trigger timer, etc
2944 hdd_wmm_disable_tl_uapsd(pQosContext);
2945
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002946#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 // disable the inactivity timer
2948 hdd_wmm_disable_inactivity_timer(pQosContext);
2949#endif
2950 // we are done with this context
2951 hdd_wmm_free_context(pQosContext);
2952
2953 // SME must not fire any more callbacks for this flow since the context
2954 // is no longer valid
2955
2956 return HDD_WLAN_WMM_STATUS_RELEASE_SUCCESS;
2957
2958 case SME_QOS_STATUS_RELEASE_REQ_PENDING_RSP:
2959 // do nothing as we will get a response from SME
2960 status = HDD_WLAN_WMM_STATUS_RELEASE_PENDING;
2961 break;
2962
2963 case SME_QOS_STATUS_RELEASE_INVALID_PARAMS_RSP:
2964 // nothing we can do with the existing flow except leave it
2965 status = HDD_WLAN_WMM_STATUS_RELEASE_FAILED_BAD_PARAM;
2966 break;
2967
2968 case SME_QOS_STATUS_RELEASE_FAILURE_RSP:
2969 // nothing we can do with the existing flow except leave it
2970 status = HDD_WLAN_WMM_STATUS_RELEASE_FAILED;
2971
2972 default:
2973 // we didn't get back one of the SME_QOS_STATUS_RELEASE_* status codes
2974 VOS_TRACE( VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002975 "%s: unexpected SME Status=%d", __func__, smeStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 VOS_ASSERT(0);
2977 status = HDD_WLAN_WMM_STATUS_RELEASE_FAILED;
2978 }
2979
2980#endif
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302981 mutex_lock(&pHddCtx->wmmLock);
c_hpothu48e31712014-12-23 16:59:03 +05302982 if (pQosContext->magic == HDD_WMM_CTX_MAGIC)
2983 {
2984 pQosContext->lastStatus = status;
2985 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05302986 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 return status;
2988}
2989
2990/**============================================================================
2991 @brief hdd_wmm_checkts() - Function which will return the status of a traffic
2992 spec at the request of an application
2993
2994 @param pAdapter : [in] pointer to adapter context
2995 @param handle : [in] handle to uniquely identify a TS
2996
2997 @return : HDD_WLAN_WMM_STATUS_*
2998 ===========================================================================*/
2999hdd_wlan_wmm_status_e hdd_wmm_checkts( hdd_adapter_t* pAdapter,
3000 v_U32_t handle )
3001{
3002 hdd_wmm_qos_context_t *pQosContext;
3003 hdd_wlan_wmm_status_e status = HDD_WLAN_WMM_STATUS_LOST;
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05303004 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
3005 hdd_context_t *pHddCtx;
3006
3007 if (NULL != pVosContext)
3008 {
3009 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
3010 if (NULL == pHddCtx)
3011 {
3012 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_ERROR,
3013 FL("HddCtx is NULL"));
3014 return HDD_WLAN_WMM_STATUS_LOST;
3015 }
3016 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003017
3018 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003019 "%s: Entered with handle 0x%x", __func__, handle);
Jeff Johnson295189b2012-06-20 16:38:30 -07003020
3021 // locate the context with the given handle
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05303022 mutex_lock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 list_for_each_entry(pQosContext,
3024 &pAdapter->hddWmmStatus.wmmContextList,
3025 node)
3026 {
3027 if (pQosContext->handle == handle)
3028 {
3029 VOS_TRACE(VOS_MODULE_ID_HDD, WMM_TRACE_LEVEL_INFO_LOW,
3030 "%s: found handle 0x%x, context %p",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003031 __func__, handle, pQosContext);
Jeff Johnson295189b2012-06-20 16:38:30 -07003032
3033 status = pQosContext->lastStatus;
3034 break;
3035 }
3036 }
Mukul Sharma1fd6efd2015-02-14 00:29:14 +05303037 mutex_unlock(&pHddCtx->wmmLock);
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 return status;
3039}