blob: afcf20362de17d996445d6c10e9440716fe21aa2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Jeff Johnson0fe596e2017-09-19 08:36:48 -07002 * Copyright (c) 2012-2013, 2017 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
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * 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
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file contains TSPEC and STA admit control related functions
30 * NOTE: applies only to AP builds
31 *
32 * Author: Sandesh Goel
33 * Date: 02/25/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 *
38 */
39#include "limDebug.h"
40#include "sysDef.h"
41#include "limApi.h"
42#include "cfgApi.h" // wlan_cfgGetInt()
43#include "limTrace.h"
44#include "limSendSmeRspMessages.h"
45#include "limTypes.h"
46
47
48#define ADMIT_CONTROL_LOGLEVEL LOG1
49#define ADMIT_CONTROL_POLICY_LOGLEVEL LOG1
50#define ADMIT_CONTROL_MIN_INTERVAL 1000 // min acceptable service interval 1mSec
51
52/* total available bandwidth in bps in each phy mode
53 * these should be defined in hal or dph - replace these later
54 */
55#define LIM_TOTAL_BW_11A 54000000
56#define LIM_MIN_BW_11A 6000000
57#define LIM_TOTAL_BW_11B 11000000
58#define LIM_MIN_BW_11B 1000000
59#define LIM_TOTAL_BW_11G LIM_TOTAL_BW_11A
60#define LIM_MIN_BW_11G LIM_MIN_BW_11B
61
62// conversion factors
63#define LIM_CONVERT_SIZE_BITS(numBytes) ((numBytes) * 8)
64#define LIM_CONVERT_RATE_MBPS(rate) ((rate)/1000000)
65
66/* ANI sta's support enhanced rates, so the effective medium time used is
67 * half that of other stations. This is the same as if they were requesting
68 * half the badnwidth - so we adjust ANI sta's accordingly for bandwidth
69 * calculations. Also enhanced rates apply only in case of non 11B mode.
70 */
71#define LIM_STA_BW_ADJUST(aniPeer, phyMode, bw) \
72 (((aniPeer) && ((phyMode) != WNI_CFG_PHY_MODE_11B)) \
73 ? ((bw)/2) : (bw))
74
75
76//------------------------------------------------------------------------------
77// local protos
78
79static tSirRetStatus
80limCalculateSvcInt(tpAniSirGlobal, tSirMacTspecIE *, tANI_U32 *);
81#if 0 //only EDCA is supported now
82static tSirRetStatus
83limValidateTspecHcca(tpAniSirGlobal, tSirMacTspecIE *);
84#endif
85static tSirRetStatus
86limValidateTspecEdca(tpAniSirGlobal, tSirMacTspecIE *, tpPESession);
87static tSirRetStatus
88limValidateTspec(tpAniSirGlobal, tSirMacTspecIE *, tpPESession);
89static void
90limComputeMeanBwUsed(tpAniSirGlobal, tANI_U32 *, tANI_U32, tpLimTspecInfo, tpPESession);
91static void
92limGetAvailableBw(tpAniSirGlobal, tANI_U32 *, tANI_U32 *, tANI_U32, tANI_U32);
93static tSirRetStatus
94limAdmitPolicyOversubscription(tpAniSirGlobal, tSirMacTspecIE *, tpLimAdmitPolicyInfo, tpLimTspecInfo, tpPESession);
95static tSirRetStatus
96limTspecFindByStaAddr(tpAniSirGlobal, tANI_U8 *, tSirMacTspecIE*, tpLimTspecInfo, tpLimTspecInfo *);
97static tSirRetStatus
98limValidateAccessPolicy(tpAniSirGlobal, tANI_U8, tANI_U16, tpPESession);
99
100
101/** -------------------------------------------------------------
102\fn limCalculateSvcInt
103\brief TSPEC validation and servcie interval determination
104\param tpAniSirGlobal pMac
105\param tSirMacTspecIE *pTspec
106\param tANI_U32 *pSvcInt
107\return eSirRetStatus - status of the comparison
108 -------------------------------------------------------------*/
109
110static tSirRetStatus
111limCalculateSvcInt(
112 tpAniSirGlobal pMac,
113 tSirMacTspecIE *pTspec,
114 tANI_U32 *pSvcInt)
115{
116 tANI_U32 msduSz, dataRate;
117 *pSvcInt = 0;
118
119 // if a service interval is already specified, we are done
120 if ((pTspec->minSvcInterval != 0) || (pTspec->maxSvcInterval != 0))
121 {
122 *pSvcInt = (pTspec->maxSvcInterval != 0)
123 ? pTspec->maxSvcInterval : pTspec->minSvcInterval;
124 return eSIR_SUCCESS;
125 }
126
127 /* Masking off the fixed bits according to definition of MSDU size
128 * in IEEE 802.11-2007 spec (section 7.3.2.30). Nominal MSDU size
129 * is defined as: Bit[0:14]=Size, Bit[15]=Fixed
130 */
131 if (pTspec->nomMsduSz != 0)
132 msduSz = (pTspec->nomMsduSz & 0x7fff);
133 else if (pTspec->maxMsduSz != 0)
134 msduSz = pTspec->maxMsduSz;
135 else
136 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700137 PELOGE(limLog(pMac, LOGE, FL("MsduSize not specified"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 return eSIR_FAILURE;
139 }
140
141 /* need to calculate a reasonable service interval
142 * this is simply the msduSz/meanDataRate
143 */
144 if (pTspec->meanDataRate != 0) dataRate = pTspec->meanDataRate;
145 else if (pTspec->peakDataRate != 0) dataRate = pTspec->peakDataRate;
146 else if (pTspec->minDataRate != 0) dataRate = pTspec->minDataRate;
147 else
148 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700149 PELOGE(limLog(pMac, LOGE, FL("DataRate not specified"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 return eSIR_FAILURE;
151 }
152
153 *pSvcInt = LIM_CONVERT_SIZE_BITS(msduSz) / LIM_CONVERT_RATE_MBPS(dataRate);
154 return eSIR_FAILURE;
155}
156
157#if 0 //only EDCA is supported now
158/** -------------------------------------------------------------
159\fn limValidateTspecHcca
160\brief validate the parameters in the hcca tspec
161 mandatory fields are derived from 11e Annex I (Table I.1)
162\param tpAniSirGlobal pMac
163\param tSirMacTspecIE *pTspec
164\return eSirRetStatus - status
165 -------------------------------------------------------------*/
166static tSirRetStatus
167limValidateTspecHcca(
168 tpAniSirGlobal pMac,
169 tSirMacTspecIE *pTspec)
170{
171 tANI_U32 maxPhyRate, minPhyRate;
172 tANI_U32 phyMode;
173
174 tSirRetStatus retval = eSIR_SUCCESS;
175 /* make sure a TSID is being requested */
176 if (pTspec->tsinfo.traffic.tsid < SIR_MAC_HCCA_TSID_MIN)
177 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700178 limLog(pMac, LOGW, FL("tsid %d must be >%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700179 pTspec->tsinfo.traffic.tsid, SIR_MAC_HCCA_TSID_MIN);
180 retval = eSIR_FAILURE;
181 }
182 /*
183 * With Polaris, there is a limitation in that the tsid cannot be arbitary
184 * but is based on the qid. Thus, we cannot have a tspec which requests
185 * a tsid of 13 and userPrio of 7, the bottom three bits of the tsid must
186 * correspond to the userPrio
187 */
188 if (pTspec->tsinfo.traffic.userPrio !=
189 (pTspec->tsinfo.traffic.tsid - SIR_MAC_HCCA_TSID_MIN))
190 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700191 limLog(pMac, LOGE, FL("TSid=0x%x, userPrio=%d: is not allowed"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 pTspec->tsinfo.traffic.tsid, pTspec->tsinfo.traffic.userPrio);
193 retval = eSIR_FAILURE;
194 }
195 // an inactivity interval is mandatory
196 if (pTspec->inactInterval == 0)
197 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700198 PELOGW(limLog(pMac, LOGW, FL("inactInterval unspecified!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 retval = eSIR_FAILURE;
200 }
201 // surplus BW must be specified if a delay Bound is specified
202 if ((pTspec->delayBound != 0) && (pTspec->surplusBw == 0))
203 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700204 limLog(pMac, LOGW, FL("delayBound %d, but surplusBw unspecified!"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700205 pTspec->delayBound);
206 retval = eSIR_FAILURE;
207 }
208 // minPhyRate must always be specified and cannot exceed maximum supported
209 limGetPhyMode(pMac, &phyMode);
210 //limGetAvailableBw(pMac, &maxPhyRate, &minPhyRate, pMac->dph.gDphPhyMode,
211 // 1 /* bandwidth mult factor */);
212 limGetAvailableBw(pMac, &maxPhyRate, &minPhyRate, phyMode,
213 1 /* bandwidth mult factor */);
214 if ((pTspec->minPhyRate == 0)
215 || (pTspec->minPhyRate > maxPhyRate)
216 || (pTspec->minPhyRate < minPhyRate))
217 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700218 limLog(pMac, LOGW, FL("minPhyRate (%d) invalid"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 pTspec->minPhyRate);
220 retval = eSIR_FAILURE;
221 }
222 /* NOTE: we will require all Tspec's to specify a mean data rate (and so
223 * also the min and peak data rates)
224 */
225 if ((pTspec->minDataRate == 0) ||
226 (pTspec->meanDataRate == 0) ||
227 (pTspec->peakDataRate == 0))
228 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700229 limLog(pMac, LOGW, FL("DataRate must be specified (min %d, mean %d, peak %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 pTspec->minDataRate, pTspec->meanDataRate, pTspec->peakDataRate);
231 retval = eSIR_FAILURE;
232 }
233
234 // mean data rate can't be more than the min phy rate
235 if (pTspec->meanDataRate > pTspec->minPhyRate)
236 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700237 limLog(pMac, LOGW, FL("Data rate (%d) is more than Phyrate %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 pTspec->meanDataRate, pTspec->minPhyRate);
239 return eSIR_FAILURE;
240 }
241
242 /* if the tspec specifies a service interval, we won't accept tspec's
243 * with service interval less than our allowed minimum, also either both
244 * min and max must be specified or neither should be specified (in which
245 * case, HC determines the appropriate service interval
246 */
247 if ((pTspec->minSvcInterval != 0) || (pTspec->maxSvcInterval != 0))
248 {
249 // max < min is ridiculous
250 if (pTspec->maxSvcInterval < pTspec->minSvcInterval)
251 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700252 limLog(pMac, LOGW, FL("maxSvcInt %d > minSvcInterval %d!!"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700253 pTspec->maxSvcInterval, pTspec->minSvcInterval);
254 retval = eSIR_FAILURE;
255 }
256 if (pTspec->maxSvcInterval < ADMIT_CONTROL_MIN_INTERVAL)
257 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700258 limLog(pMac, LOGW, FL("maxSvcInt %d must be >%d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 pTspec->maxSvcInterval, ADMIT_CONTROL_MIN_INTERVAL);
260 retval = eSIR_FAILURE;
261 }
262 }
263 else // min and max both unspecified
264 {
265 /* no service interval is specified, so make sure the parameters
266 * needed to determine one are specified in the tspec
267 * minPhyRate, meanDataRate and nomMsduSz are needed, only nomMsduSz
268 * must be checked here since the other two are already validated
269 */
270 if (pTspec->nomMsduSz == 0)
271 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700272 PELOGW(limLog(pMac, LOGW, FL("No svcInt and no MsduSize specified"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 retval = eSIR_FAILURE;
274 }
275 }
276
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700277 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("return status %d"), retval);
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 return retval;
279}
280
281#endif //only edca is supported now.
282
283/** -------------------------------------------------------------
284\fn limValidateTspecEdca
285\brief validate the parameters in the edca tspec
286 mandatory fields are derived from 11e Annex I (Table I.1)
287\param tpAniSirGlobal pMac
288\param tSirMacTspecIE *pTspec
289\return eSirRetStatus - status
290 -------------------------------------------------------------*/
291static tSirRetStatus
292limValidateTspecEdca(
293 tpAniSirGlobal pMac,
294 tSirMacTspecIE *pTspec,
295 tpPESession psessionEntry)
296{
297 tANI_U32 maxPhyRate, minPhyRate;
298 tANI_U32 phyMode;
299 tSirRetStatus retval = eSIR_SUCCESS;
300
301 limGetPhyMode(pMac, &phyMode, psessionEntry);
302
303 //limGetAvailableBw(pMac, &maxPhyRate, &minPhyRate, pMac->dph.gDphPhyMode,
304 // 1 /* bandwidth mult factor */);
305 limGetAvailableBw(pMac, &maxPhyRate, &minPhyRate, phyMode,
306 1 /* bandwidth mult factor */);
307 // mandatory fields are derived from 11e Annex I (Table I.1)
308 if ((pTspec->nomMsduSz == 0) ||
309 (pTspec->meanDataRate == 0) ||
310 (pTspec->surplusBw == 0) ||
311 (pTspec->minPhyRate == 0) ||
312 (pTspec->minPhyRate > maxPhyRate))
313 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700314 limLog(pMac, LOGW, FL("Invalid EDCA Tspec: NomMsdu %d, meanDataRate %d, surplusBw %d, minPhyRate %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 pTspec->nomMsduSz, pTspec->meanDataRate, pTspec->surplusBw, pTspec->minPhyRate);
316 retval = eSIR_FAILURE;
317 }
318
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700319 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("return status %d"), retval);
Jeff Johnson295189b2012-06-20 16:38:30 -0700320 return retval;
321}
322
323/** -------------------------------------------------------------
324\fn limValidateTspec
325\brief validate the offered tspec
326\param tpAniSirGlobal pMac
327\param tSirMacTspecIE *pTspec
328\return eSirRetStatus - status
329 -------------------------------------------------------------*/
330
331static tSirRetStatus
332limValidateTspec(
333 tpAniSirGlobal pMac,
334 tSirMacTspecIE *pTspec,
335 tpPESession psessionEntry)
336{
337 tSirRetStatus retval = eSIR_SUCCESS;
338 switch (pTspec->tsinfo.traffic.accessPolicy)
339 {
340 case SIR_MAC_ACCESSPOLICY_EDCA:
341 if ((retval = limValidateTspecEdca(pMac, pTspec, psessionEntry)) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700342 PELOGW(limLog(pMac, LOGW, FL("EDCA tspec invalid"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 break;
344
345 case SIR_MAC_ACCESSPOLICY_HCCA:
346#if 0 //Not supported right now.
347 if ((retval = limValidateTspecHcca(pMac, pTspec)) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700348 PELOGW(limLog(pMac, LOGW, FL("HCCA tspec invalid"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 break;
350#endif
351 case SIR_MAC_ACCESSPOLICY_BOTH:
352 // TBD: should we support hybrid tspec as well?? for now, just fall through
353 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700354 limLog(pMac, LOGW, FL("AccessType %d not supported"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700355 pTspec->tsinfo.traffic.accessPolicy);
356 retval = eSIR_FAILURE;
357 break;
358 }
359 return retval;
360}
361
362//-----------------------------------------------------------------------------
363// Admit Control Policy
364
365
366/** -------------------------------------------------------------
367\fn limComputeMeanBwUsed
368\brief determime the used/allocated bandwidth
369\param tpAniSirGlobal pMac
370\param tANI_U32 *pBw
371\param tANI_U32 phyMode
372\param tpLimTspecInfo pTspecInfo
373\return eSirRetStatus - status
374 -------------------------------------------------------------*/
375
376static void
377limComputeMeanBwUsed(
378 tpAniSirGlobal pMac,
379 tANI_U32 *pBw,
380 tANI_U32 phyMode,
381 tpLimTspecInfo pTspecInfo,
382 tpPESession psessionEntry)
383{
384 tANI_U32 ctspec;
385 *pBw = 0;
386 for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecInfo++)
387 {
388 if (pTspecInfo->inuse)
389 {
390 tpDphHashNode pSta = dphGetHashEntry(pMac, pTspecInfo->assocId, &psessionEntry->dph.dphHashTable);
391 if (pSta == NULL)
392 {
393 // maybe we should delete the tspec??
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700394 limLog(pMac, LOGE, FL("Tspec %d (assocId %d): dphNode not found"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 ctspec, pTspecInfo->assocId);
396 continue;
397 }
398 //FIXME: need to take care of taurusPeer, titanPeer, 11npeer too.
399 *pBw += LIM_STA_BW_ADJUST(pSta->aniPeer, phyMode, pTspecInfo->tspec.meanDataRate);
400 }
401 }
402}
403
404/** -------------------------------------------------------------
405\fn limGetAvailableBw
406\brief based on the phy mode and the bw_factor, determine the total bandwidth that
407 can be supported
408\param tpAniSirGlobal pMac
409\param tANI_U32 *pMaxBw
410\param tANI_U32 *pMinBw
411\param tANI_U32 phyMode
412\param tANI_U32 bw_factor
413\return eSirRetStatus - status
414 -------------------------------------------------------------*/
415
416static void
417limGetAvailableBw(
418 tpAniSirGlobal pMac,
419 tANI_U32 *pMaxBw,
420 tANI_U32 *pMinBw,
421 tANI_U32 phyMode,
422 tANI_U32 bw_factor)
423{
424 switch (phyMode)
425 {
426 case WNI_CFG_PHY_MODE_11B:
427 *pMaxBw = LIM_TOTAL_BW_11B;
428 *pMinBw = LIM_MIN_BW_11B;
429 break;
430
431 case WNI_CFG_PHY_MODE_11A:
432 *pMaxBw = LIM_TOTAL_BW_11A;
433 *pMinBw = LIM_MIN_BW_11A;
434 break;
435
436 case WNI_CFG_PHY_MODE_11G:
437 case WNI_CFG_PHY_MODE_NONE:
438 default:
439 *pMaxBw = LIM_TOTAL_BW_11G;
440 *pMinBw = LIM_MIN_BW_11G;
441 break;
442 }
443 *pMaxBw *= bw_factor;
444}
445
446/** -------------------------------------------------------------
447\fn limAdmitPolicyOversubscription
448\brief simple admission control policy based on oversubscription
449 if the total bandwidth of all admitted tspec's exceeds (factor * phy-bw) then
450 reject the tspec, else admit it. The phy-bw is the peak available bw in the
451 current phy mode. The 'factor' is the configured oversubscription factor.
452\param tpAniSirGlobal pMac
453\param tSirMacTspecIE *pTspec
454\param tpLimAdmitPolicyInfo pAdmitPolicy
455\param tpLimTspecInfo pTspecInfo
456\return eSirRetStatus - status
457 -------------------------------------------------------------*/
458
459/*
460 * simple admission control policy based on oversubscription
461 * if the total bandwidth of all admitted tspec's exceeds (factor * phy-bw) then
462 * reject the tspec, else admit it. The phy-bw is the peak available bw in the
463 * current phy mode. The 'factor' is the configured oversubscription factor.
464 */
465static tSirRetStatus
466limAdmitPolicyOversubscription(
467 tpAniSirGlobal pMac,
468 tSirMacTspecIE *pTspec,
469 tpLimAdmitPolicyInfo pAdmitPolicy,
470 tpLimTspecInfo pTspecInfo,
471 tpPESession psessionEntry)
472{
473 tANI_U32 totalbw, minbw, usedbw;
474 tANI_U32 phyMode;
475
476 // determine total bandwidth used so far
477 limGetPhyMode(pMac, &phyMode, psessionEntry);
478
479 //limComputeMeanBwUsed(pMac, &usedbw, pMac->dph.gDphPhyMode, pTspecInfo);
480 limComputeMeanBwUsed(pMac, &usedbw, phyMode, pTspecInfo, psessionEntry);
481
482 // determine how much bandwidth is available based on the current phy mode
483 //limGetAvailableBw(pMac, &totalbw, &minbw, pMac->dph.gDphPhyMode, pAdmitPolicy->bw_factor);
484 limGetAvailableBw(pMac, &totalbw, &minbw, phyMode, pAdmitPolicy->bw_factor);
485
486 if (usedbw > totalbw) // this can't possibly happen
487 return eSIR_FAILURE;
488
489 if ((totalbw - usedbw) < pTspec->meanDataRate)
490 {
491 limLog(pMac, ADMIT_CONTROL_POLICY_LOGLEVEL,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700492 FL("Total BW %d, Used %d, Tspec request %d not possible"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 totalbw, usedbw, pTspec->meanDataRate);
494 return eSIR_FAILURE;
495 }
496 return eSIR_SUCCESS;
497}
498
499/** -------------------------------------------------------------
500\fn limAdmitPolicy
501\brief determine the current admit control policy and apply it for the offered tspec
502\param tpAniSirGlobal pMac
503\param tSirMacTspecIE *pTspec
504\return eSirRetStatus - status
505 -------------------------------------------------------------*/
506
507tSirRetStatus limAdmitPolicy(
508 tpAniSirGlobal pMac,
509 tSirMacTspecIE *pTspec,
510 tpPESession psessionEntry)
511{
512 tSirRetStatus retval = eSIR_FAILURE;
513 tpLimAdmitPolicyInfo pAdmitPolicy = &pMac->lim.admitPolicyInfo;
514
515 switch (pAdmitPolicy->type)
516 {
517 case WNI_CFG_ADMIT_POLICY_ADMIT_ALL:
518 retval = eSIR_SUCCESS;
519 break;
520
521 case WNI_CFG_ADMIT_POLICY_BW_FACTOR:
522 retval = limAdmitPolicyOversubscription(pMac, pTspec,
523 &pMac->lim.admitPolicyInfo, &pMac->lim.tspecInfo[0], psessionEntry);
524 if (retval != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700525 PELOGE(limLog(pMac, LOGE, FL("rejected by BWFactor policy"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 break;
527
528 case WNI_CFG_ADMIT_POLICY_REJECT_ALL:
529 retval = eSIR_FAILURE;
530 break;
531
532 default:
533 retval = eSIR_SUCCESS;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700534 limLog(pMac, LOGE, FL("Admit Policy %d unknown, admitting all traffic"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700535 pAdmitPolicy->type);
536 break;
537 }
538 return retval;
539}
540
541/** -------------------------------------------------------------
542\fn limTspecDelete
543\brief delete the specified tspec
544\param tpAniSirGlobal pMac
545\param tpLimTspecInfo pInfo
546\return eSirRetStatus - status
547 -------------------------------------------------------------*/
548
549//-----------------------------------------------------------------------------
550// delete the specified tspec
551void limTspecDelete(tpAniSirGlobal pMac, tpLimTspecInfo pInfo)
552{
553 if (pInfo == NULL)
554 return;
555 //pierre
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700556 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("tspec entry = %d"), pInfo->idx);
Jeff Johnson0fe596e2017-09-19 08:36:48 -0700557 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("delete tspec %pK"), pInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700558 pInfo->inuse = 0;
559
560 // clear the hcca/parameterized queue indicator
561#if 0
562 if ((pInfo->tspec.tsinfo.traffic.direction == SIR_MAC_DIRECTION_UPLINK) ||
563 (pInfo->tspec.tsinfo.traffic.direction == SIR_MAC_DIRECTION_BIDIR))
564 queue[pInfo->staid][pInfo->tspec.tsinfo.traffic.userPrio][SCH_UL_QUEUE].ts = 0;
565#endif
566
567 return;
568}
569
570/** -------------------------------------------------------------
571\fn limTspecFindByStaAddr
572\brief Send halMsg_AddTs to HAL
573\param tpAniSirGlobal pMac
574\param \param tANI_U8 *pAddr
575\param tSirMacTspecIE *pTspecIE
576\param tpLimTspecInfo pTspecList
577\param tpLimTspecInfo *ppInfo
578\return eSirRetStatus - status
579 -------------------------------------------------------------*/
580
581// find the specified tspec in the list
582static tSirRetStatus
583limTspecFindByStaAddr(
584 tpAniSirGlobal pMac,
585 tANI_U8 *pAddr,
586 tSirMacTspecIE *pTspecIE,
587 tpLimTspecInfo pTspecList,
588 tpLimTspecInfo *ppInfo)
589{
590 int ctspec;
591
592 *ppInfo = NULL;
593
594 for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecList++)
595 {
596 if ((pTspecList->inuse)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530597 && (vos_mem_compare(pAddr, pTspecList->staAddr, sizeof(pTspecList->staAddr)))
598 && (vos_mem_compare((tANI_U8 *) pTspecIE, (tANI_U8 *) &pTspecList->tspec,
599 sizeof(tSirMacTspecIE))))
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 {
601 *ppInfo = pTspecList;
602 return eSIR_SUCCESS;
603 }
604 }
605 return eSIR_FAILURE;
606}
607
608/** -------------------------------------------------------------
609\fn limTspecFindByAssocId
610\brief find tspec with matchin staid and Tspec
611\param tpAniSirGlobal pMac
612\param tANI_U32 staid
613\param tSirMacTspecIE *pTspecIE
614\param tpLimTspecInfo pTspecList
615\param tpLimTspecInfo *ppInfo
616\return eSirRetStatus - status
617 -------------------------------------------------------------*/
618
619tSirRetStatus
620limTspecFindByAssocId(
621 tpAniSirGlobal pMac,
622 tANI_U16 assocId,
623 tSirMacTspecIE *pTspecIE,
624 tpLimTspecInfo pTspecList,
625 tpLimTspecInfo *ppInfo)
626{
627 int ctspec;
628
629 *ppInfo = NULL;
630
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700631 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("Trying to find tspec entry for assocId = %d"), assocId);
632 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("pTsInfo->traffic.direction = %d, pTsInfo->traffic.tsid = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 pTspecIE->tsinfo.traffic.direction, pTspecIE->tsinfo.traffic.tsid);
634
635 for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecList++)
636 {
637 if ((pTspecList->inuse)
638 && (assocId == pTspecList->assocId)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530639 && (vos_mem_compare((tANI_U8 *)pTspecIE, (tANI_U8 *)&pTspecList->tspec,
640 sizeof(tSirMacTspecIE))))
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 {
642 *ppInfo = pTspecList;
643 return eSIR_SUCCESS;
644 }
645 }
646 return eSIR_FAILURE;
647}
648
649/** -------------------------------------------------------------
650\fn limFindTspec
651\brief finding a TSPEC entry with assocId, tsinfo.direction and tsinfo.tsid
652\param tANI_U16 assocId
653\param tpAniSirGlobal pMac
654\param tSirMacTSInfo *pTsInfo
655\param tpLimTspecInfo pTspecList
656\param tpLimTspecInfo *ppInfo
657\return eSirRetStatus - status of the comparison
658 -------------------------------------------------------------*/
659
660tSirRetStatus
661limFindTspec(
662 tpAniSirGlobal pMac,
663 tANI_U16 assocId,
664 tSirMacTSInfo *pTsInfo,
665 tpLimTspecInfo pTspecList,
666 tpLimTspecInfo *ppInfo)
667{
668 int ctspec;
669
670 *ppInfo = NULL;
671
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700672 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("Trying to find tspec entry for assocId = %d"), assocId);
673 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("pTsInfo->traffic.direction = %d, pTsInfo->traffic.tsid = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 pTsInfo->traffic.direction, pTsInfo->traffic.tsid);
675
676 for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecList++)
677 {
678 if ((pTspecList->inuse)
679 && (assocId == pTspecList->assocId)
680 && (pTsInfo->traffic.direction == pTspecList->tspec.tsinfo.traffic.direction)
681 && (pTsInfo->traffic.tsid == pTspecList->tspec.tsinfo.traffic.tsid))
682 {
683 *ppInfo = pTspecList;
684 return eSIR_SUCCESS;
685 }
686 }
687 return eSIR_FAILURE;
688}
689
690/** -------------------------------------------------------------
691\fn limTspecAdd
692\brief add or update the specified tspec to the tspec list
693\param tpAniSirGlobal pMac
694\param tANI_U8 *pAddr
695\param tANI_U16 assocId
696\param tSirMacTspecIE *pTspec
697\param tANI_U32 interval
698\param tpLimTspecInfo *ppInfo
699
700\return eSirRetStatus - status of the comparison
701 -------------------------------------------------------------*/
702
703tSirRetStatus limTspecAdd(
704 tpAniSirGlobal pMac,
705 tANI_U8 *pAddr,
706 tANI_U16 assocId,
707 tSirMacTspecIE *pTspec,
708 tANI_U32 interval,
709 tpLimTspecInfo *ppInfo)
710{
711 tpLimTspecInfo pTspecList = &pMac->lim.tspecInfo[0];
712 *ppInfo = NULL;
713
714 // validate the assocId
715 if (assocId >= pMac->lim.maxStation)
716 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700717 PELOGE(limLog(pMac, LOGE, FL("Invalid assocId 0x%x"), assocId);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 return eSIR_FAILURE;
719 }
720
721 //decide whether to add/update
722 {
723 *ppInfo = NULL;
724
725 if(eSIR_SUCCESS == limFindTspec(pMac, assocId, &pTspec->tsinfo, pTspecList, ppInfo))
726 {
727 //update this entry.
728 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("updating TSPEC table entry = %d"),
729 (*ppInfo)->idx);
730 }
731 else
732 {
733 /* We didn't find one to update. So find a free slot in the
734 * LIM TSPEC list and add this new entry
735 */
736 tANI_U8 ctspec = 0;
737 for (ctspec = 0 , pTspecList = &pMac->lim.tspecInfo[0]; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecList++)
738 {
739 if (! pTspecList->inuse)
740 {
741 limLog(pMac, LOG1, FL("Found free slot in TSPEC list. Add to TSPEC table entry %d"), ctspec);
742 break;
743 }
744 }
745
746 if (ctspec >= LIM_NUM_TSPEC_MAX)
747 return eSIR_FAILURE;
748
749 //Record the new index entry
750 pTspecList->idx = ctspec;
751 }
752 }
753
754 // update the tspec info
755 pTspecList->tspec = *pTspec;
756 pTspecList->assocId = assocId;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530757 vos_mem_copy(pTspecList->staAddr, pAddr, sizeof(pTspecList->staAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700758
759 // for edca tspec's, we are all done
760 if (pTspec->tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA)
761 {
762 pTspecList->inuse = 1;
763 *ppInfo = pTspecList;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700764 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("added entry for EDCA AccessPolicy"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 return eSIR_SUCCESS;
766 }
767
768 /*
769 * for hcca tspec's, must set the parameterized bit in the queues
770 * the 'ts' bit in the queue data structure indicates that the queue is
771 * parameterized (hcca). When the schedule is written this bit is used
772 * in the tsid field (bit 3) and the other three bits (0-2) are simply
773 * filled in as the user priority (or qid). This applies only to uplink
774 * polls where the qos control field must contain the tsid specified in the
775 * tspec.
776 */
777#if 0
778 if ((pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_UPLINK) ||
779 (pTspec->tsinfo.traffic.direction == SIR_MAC_DIRECTION_BIDIR))
780 queue[staid][pTspec->tsinfo.traffic.userPrio][SCH_UL_QUEUE].ts = 1;
781#endif
782 pTspecList->inuse = 1;
783 *ppInfo = pTspecList;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700784 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("added entry for HCCA AccessPolicy"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 return eSIR_SUCCESS;
786}
787
788/** -------------------------------------------------------------
789\fn limValidateAccessPolicy
790\brief Validates Access policy
791\param tpAniSirGlobal pMac
792\param tANI_U8 accessPolicy
793\param tANI_U16 assocId
794\return eSirRetStatus - status
795 -------------------------------------------------------------*/
796
797static tSirRetStatus
798limValidateAccessPolicy(
799 tpAniSirGlobal pMac,
800 tANI_U8 accessPolicy,
801 tANI_U16 assocId,
802 tpPESession psessionEntry)
803{
804 tSirRetStatus retval = eSIR_FAILURE;
805 tpDphHashNode pSta = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
806
807 if ((pSta == NULL) || (! pSta->valid))
808 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700809 PELOGE(limLog(pMac, LOGE, FL("invalid station address passed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 return eSIR_FAILURE;
811 }
812
813 switch (accessPolicy)
814 {
815 case SIR_MAC_ACCESSPOLICY_EDCA:
816 if (pSta->wmeEnabled || pSta->lleEnabled)
817 retval = eSIR_SUCCESS;
818 break;
819
820 case SIR_MAC_ACCESSPOLICY_HCCA:
821 case SIR_MAC_ACCESSPOLICY_BOTH:
822#if 0 //only EDCA supported for now.
823 // TBD: check wsm doesn't support the hybrid access policy
824 if (pSta->wsmEnabled || pSta->lleEnabled)
825 retval = eSIR_SUCCESS;
826 break;
827#endif //only EDCA supported for now.
828 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700829 PELOGE(limLog(pMac, LOGE, FL("Invalid accessPolicy %d"), accessPolicy);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700830 break;
831 }
832
833 if (retval != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700834 limLog(pMac, LOGW, FL("failed (accPol %d, staId %d, lle %d, wme %d, wsm %d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 accessPolicy, pSta->staIndex, pSta->lleEnabled, pSta->wmeEnabled, pSta->wsmEnabled);
836
837 return retval;
838}
839
840/** -------------------------------------------------------------
841\fn limAdmitControlAddTS
842\brief Determine if STA with the specified TSPEC can be admitted. If it can,
843 a schedule element is provided
844\param tpAniSirGlobal pMac
845\param tANI_U8 *pAddr,
846\param tSirAddtsReqInfo *pAddts,
847\param tSirMacQosCapabilityIE *pQos,
848\param tANI_U16 assocId, // assocId, valid only if alloc==true
849\param tANI_U8 alloc, // true=>allocate bw for this tspec,
850 // else determine only if space is available
851\param tSirMacScheduleIE *pSch,
852\param tANI_U8 *pTspecIdx //index to the lim tspec table.
853\return eSirRetStatus - status
854 -------------------------------------------------------------*/
855
856tSirRetStatus limAdmitControlAddTS(
857 tpAniSirGlobal pMac,
858 tANI_U8 *pAddr,
859 tSirAddtsReqInfo *pAddts,
860 tSirMacQosCapabilityStaIE *pQos,
861 tANI_U16 assocId, // assocId, valid only if alloc==true
862 tANI_U8 alloc, // true=>allocate bw for this tspec,
863 // else determine only if space is available
864 tSirMacScheduleIE *pSch,
865 tANI_U8 *pTspecIdx, //index to the lim tspec table.
866 tpPESession psessionEntry
867 )
868{
869 tpLimTspecInfo pTspecInfo;
870 tSirRetStatus retval;
871 tANI_U32 svcInterval;
872 (void) pQos;
873
874 // TBD: modify tspec as needed
875 // EDCA: need to fill in the medium time and the minimum phy rate
876 // to be consistent with the desired traffic parameters.
877
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700878 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("tsid %d, directn %d, start %d, intvl %d, accPolicy %d, up %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 pAddts->tspec.tsinfo.traffic.tsid, pAddts->tspec.tsinfo.traffic.direction,
880 pAddts->tspec.svcStartTime, pAddts->tspec.minSvcInterval,
881 pAddts->tspec.tsinfo.traffic.accessPolicy, pAddts->tspec.tsinfo.traffic.userPrio);
882
883 // check for duplicate tspec
884 retval = (alloc)
885 ? limTspecFindByAssocId(pMac, assocId, &pAddts->tspec, &pMac->lim.tspecInfo[0], &pTspecInfo)
886 : limTspecFindByStaAddr(pMac, pAddr, &pAddts->tspec, &pMac->lim.tspecInfo[0], &pTspecInfo);
887
888 if (retval == eSIR_SUCCESS)
889 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700890 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("duplicate tspec (index %d)!"), pTspecInfo->idx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 return eSIR_FAILURE;
892 }
893
894 // check that the tspec's are well formed and acceptable
895 if (limValidateTspec(pMac, &pAddts->tspec, psessionEntry) != eSIR_SUCCESS)
896 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700897 PELOGW(limLog(pMac, LOGW, FL("tspec validation failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 return eSIR_FAILURE;
899 }
900
901 // determine a service interval for the tspec
902 if (limCalculateSvcInt(pMac, &pAddts->tspec, &svcInterval) != eSIR_SUCCESS)
903 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700904 PELOGW(limLog(pMac, LOGW, FL("SvcInt calculate failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700905 return eSIR_FAILURE;
906 }
907
908 // determine if the tspec can be admitted or not based on current policy
909 if (limAdmitPolicy(pMac, &pAddts->tspec, psessionEntry) != eSIR_SUCCESS)
910 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700911 PELOGW(limLog(pMac, LOGW, FL("tspec rejected by admit control policy"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 return eSIR_FAILURE;
913 }
914
915 // fill in a schedule if requested
916 if (pSch != NULL)
917 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530918 vos_mem_set((tANI_U8 *) pSch, sizeof(*pSch), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 pSch->svcStartTime = pAddts->tspec.svcStartTime;
920 pSch->svcInterval = svcInterval;
921 pSch->maxSvcDuration = (tANI_U16) pSch->svcInterval; // use SP = SI
922 pSch->specInterval = 0x1000; // fixed for now: TBD
923
924 pSch->info.direction = pAddts->tspec.tsinfo.traffic.direction;
925 pSch->info.tsid = pAddts->tspec.tsinfo.traffic.tsid;
926 pSch->info.aggregation = 0; // no support for aggregation for now: TBD
927 }
928
929 // if no allocation is requested, done
930 if (! alloc)
931 return eSIR_SUCCESS;
932
933 // check that we are in the proper mode to deal with the tspec type
934 if (limValidateAccessPolicy(pMac, (tANI_U8) pAddts->tspec.tsinfo.traffic.accessPolicy, assocId, psessionEntry) != eSIR_SUCCESS)
935 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700936 limLog(pMac, LOGW, FL("AccessPolicy %d is not valid in current mode"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 pAddts->tspec.tsinfo.traffic.accessPolicy);
938 return eSIR_FAILURE;
939 }
940
941 // add tspec to list
942 if (limTspecAdd(pMac, pAddr, assocId, &pAddts->tspec, svcInterval, &pTspecInfo)
943 != eSIR_SUCCESS)
944 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700945 PELOGE(limLog(pMac, LOGE, FL("no space in tspec list"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 return eSIR_FAILURE;
947 }
948
949 //passing lim tspec table index to the caller
950 *pTspecIdx = pTspecInfo->idx;
951
952 return eSIR_SUCCESS;
953}
954
955/** -------------------------------------------------------------
956\fn limAdmitControlDeleteTS
957\brief Delete the specified Tspec for the specified STA
958\param tpAniSirGlobal pMac
959\param tANI_U16 assocId
960\param tSirMacTSInfo *pTsInfo
961\param tANI_U8 *pTsStatus
962\param tANI_U8 *ptspecIdx
963\return eSirRetStatus - status
964 -------------------------------------------------------------*/
965
966tSirRetStatus
967limAdmitControlDeleteTS(
968 tpAniSirGlobal pMac,
969 tANI_U16 assocId,
970 tSirMacTSInfo *pTsInfo,
971 tANI_U8 *pTsStatus,
972 tANI_U8 *ptspecIdx)
973{
974 tpLimTspecInfo pTspecInfo = NULL;
975
976 if (pTsStatus != NULL)
977 *pTsStatus = 0;
978
979 if (limFindTspec(pMac, assocId, pTsInfo, &pMac->lim.tspecInfo[0], &pTspecInfo) == eSIR_SUCCESS)
980 {
981 if(pTspecInfo != NULL)
982 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700983 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("Tspec entry %d found"), pTspecInfo->idx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700984
985 *ptspecIdx = pTspecInfo->idx;
986 limTspecDelete(pMac, pTspecInfo);
987 return eSIR_SUCCESS;
988 }
989 }
990 return eSIR_FAILURE;
991}
992
993/** -------------------------------------------------------------
994\fn limAdmitControlDeleteSta
995\brief Delete all TSPEC for the specified STA
996\param tpAniSirGlobal pMac
997\param tANI_U16 assocId
998\return eSirRetStatus - status
999 -------------------------------------------------------------*/
1000
1001tSirRetStatus
1002limAdmitControlDeleteSta(
1003 tpAniSirGlobal pMac,
1004 tANI_U16 assocId)
1005{
1006 tpLimTspecInfo pTspecInfo = &pMac->lim.tspecInfo[0];
1007 int ctspec;
1008
1009 for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecInfo++)
1010 {
1011 if (assocId == pTspecInfo->assocId)
1012 {
1013 limTspecDelete(pMac, pTspecInfo);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001014 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("Deleting TSPEC %d for assocId %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001015 ctspec, assocId);
1016 }
1017 }
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001018 limLog(pMac, ADMIT_CONTROL_LOGLEVEL, FL("assocId %d done"), assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001019
1020 return eSIR_SUCCESS;
1021}
1022
1023/** -------------------------------------------------------------
1024\fn limAdmitControlInit
1025\brief init tspec table
1026\param tpAniSirGlobal pMac
1027\return eSirRetStatus - status
1028 -------------------------------------------------------------*/
1029tSirRetStatus limAdmitControlInit(tpAniSirGlobal pMac)
1030{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301031 vos_mem_set(pMac->lim.tspecInfo, LIM_NUM_TSPEC_MAX * sizeof(tLimTspecInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 return eSIR_SUCCESS;
1033}
1034
1035/** -------------------------------------------------------------
1036\fn limUpdateAdmitPolicy
1037\brief Set the admit control policy based on CFG parameters
1038\param tpAniSirGlobal pMac
1039\return eSirRetStatus - status
1040 -------------------------------------------------------------*/
1041
1042tSirRetStatus limUpdateAdmitPolicy(tpAniSirGlobal pMac)
1043{
1044 tANI_U32 val;
1045 if (wlan_cfgGetInt(pMac, WNI_CFG_ADMIT_POLICY, &val) != eSIR_SUCCESS)
1046 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001047 limLog(pMac, LOGP, FL("Unable to get CFG_ADMIT_POLICY"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 return eSIR_FAILURE;
1049 }
1050 pMac->lim.admitPolicyInfo.type = (tANI_U8) val;
1051 if (wlan_cfgGetInt(pMac, WNI_CFG_ADMIT_BWFACTOR, &val) != eSIR_SUCCESS)
1052 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001053 limLog(pMac, LOGP, FL("Unable to get CFG_ADMIT_BWFACTOR"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 return eSIR_FAILURE;
1055 }
1056 pMac->lim.admitPolicyInfo.bw_factor = (tANI_U8) val;
1057
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001058 PELOG1(limLog(pMac, LOG1, FL("LIM: AdmitPolicy %d, bw_factor %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001059 pMac->lim.admitPolicyInfo.type, pMac->lim.admitPolicyInfo.bw_factor);)
1060
1061 return eSIR_SUCCESS;
1062}
1063
1064
1065/** -------------------------------------------------------------
1066\fn limSendHalMsgAddTs
1067\brief Send halMsg_AddTs to HAL
1068\param tpAniSirGlobal pMac
1069\param tANI_U16 staIdx
1070\param tANI_U8 tspecIdx
1071\param tSirMacTspecIE tspecIE
1072\param tSirTclasInfo *tclasInfo
1073\param tANI_U8 tclasProc
1074\return eSirRetStatus - status
1075 -------------------------------------------------------------*/
1076
1077tSirRetStatus
1078limSendHalMsgAddTs(
1079 tpAniSirGlobal pMac,
1080 tANI_U16 staIdx,
1081 tANI_U8 tspecIdx,
1082 tSirMacTspecIE tspecIE,
1083 tANI_U8 sessionId)
1084{
1085 tSirMsgQ msg;
1086 tpAddTsParams pAddTsParam;
1087
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301088 pAddTsParam = vos_mem_malloc(sizeof(tAddTsParams));
1089 if (NULL == pAddTsParam)
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301091 PELOGW(limLog(pMac, LOGW, FL("AllocateMemory() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 return eSIR_MEM_ALLOC_FAILED;
1093 }
1094
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301095 vos_mem_set((tANI_U8 *)pAddTsParam, sizeof(tAddTsParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 pAddTsParam->staIdx = staIdx;
1097 pAddTsParam->tspecIdx = tspecIdx;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301098 vos_mem_copy(&pAddTsParam->tspec, &tspecIE, sizeof(tSirMacTspecIE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 pAddTsParam->sessionId = sessionId;
1100
1101 msg.type = WDA_ADD_TS_REQ;
1102 msg.bodyptr = pAddTsParam;
1103 msg.bodyval = 0;
1104
1105 /* We need to defer any incoming messages until we get a
1106 * WDA_ADD_TS_RSP from HAL.
1107 */
1108 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07001109 MTRACE(macTraceMsgTx(pMac, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001110
1111 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1112 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001113 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg() failed"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301115 vos_mem_free(pAddTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 return eSIR_FAILURE;
1117 }
1118 return eSIR_SUCCESS;
1119}
1120
1121/** -------------------------------------------------------------
1122\fn limSendHalMsgDelTs
1123\brief Send halMsg_AddTs to HAL
1124\param tpAniSirGlobal pMac
1125\param tANI_U16 staIdx
1126\param tANI_U8 tspecIdx
1127\param tSirAddtsReqInfo addts
1128\return eSirRetStatus - status
1129 -------------------------------------------------------------*/
1130
1131tSirRetStatus
1132limSendHalMsgDelTs(
1133 tpAniSirGlobal pMac,
1134 tANI_U16 staIdx,
1135 tANI_U8 tspecIdx,
Jeff Johnsone7245742012-09-05 17:12:55 -07001136 tSirDeltsReqInfo delts,
Madan Mohan Koyyalamudic0a75a42013-10-07 04:20:49 +05301137 tANI_U8 sessionId,
1138 tANI_U8 *bssId)
Jeff Johnson295189b2012-06-20 16:38:30 -07001139{
1140 tSirMsgQ msg;
1141 tpDelTsParams pDelTsParam;
1142
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301143 pDelTsParam = vos_mem_malloc(sizeof(tDelTsParams));
1144 if (NULL == pDelTsParam)
Jeff Johnson295189b2012-06-20 16:38:30 -07001145 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301146 limLog(pMac, LOGP, FL("AllocateMemory() failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 return eSIR_MEM_ALLOC_FAILED;
1148 }
1149
1150 msg.type = WDA_DEL_TS_REQ;
1151 msg.bodyptr = pDelTsParam;
1152 msg.bodyval = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301153 vos_mem_set((tANI_U8 *)pDelTsParam, sizeof(tDelTsParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
1155 //filling message parameters.
1156 pDelTsParam->staIdx = staIdx;
1157 pDelTsParam->tspecIdx = tspecIdx;
Madan Mohan Koyyalamudic0a75a42013-10-07 04:20:49 +05301158 vos_mem_copy(&pDelTsParam->bssId, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07001159
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001160 PELOGW(limLog(pMac, LOGW, FL("calling wdaPostCtrlMsg()"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001161 MTRACE(macTraceMsgTx(pMac, sessionId, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001162
1163 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
1164 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001165 PELOGW(limLog(pMac, LOGW, FL("wdaPostCtrlMsg() failed"));)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301166 vos_mem_free(pDelTsParam);
Jeff Johnson295189b2012-06-20 16:38:30 -07001167 return eSIR_FAILURE;
1168 }
1169 return eSIR_SUCCESS;
1170}
1171
1172/** -------------------------------------------------------------
1173\fn limProcessHalAddTsRsp
1174\brief This function process the WDA_ADD_TS_RSP from HAL.
1175\ If response is successful, then send back SME_ADDTS_RSP.
1176\ Otherwise, send DELTS action frame to peer and then
1177\ then send back SME_ADDTS_RSP.
1178\
1179\param tpAniSirGlobal pMac
1180\param tpSirMsgQ limMsg
1181-------------------------------------------------------------*/
1182void limProcessHalAddTsRsp(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1183{
1184 tpAddTsParams pAddTsRspMsg = NULL;
1185 tpDphHashNode pSta = NULL;
1186 tANI_U16 assocId =0;
1187 tSirMacAddr peerMacAddr;
1188 tANI_U8 rspReqd = 1;
1189 tpPESession psessionEntry = NULL;
1190
1191
1192 /* Need to process all the deferred messages enqueued
1193 * since sending the WDA_ADD_TS_REQ.
1194 */
1195 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
1196
1197 if (NULL == limMsg->bodyptr)
1198 {
1199 limLog(pMac, LOGP, FL("Received WDA_ADD_TS_RSP with NULL "));
1200 goto end;
1201 }
1202
1203 pAddTsRspMsg = (tpAddTsParams) (limMsg->bodyptr);
1204
1205 // 090803: Use peFindSessionBySessionId() to obtain the PE session context
1206 // from the sessionId in the Rsp Msg from HAL
1207 psessionEntry = peFindSessionBySessionId(pMac, pAddTsRspMsg->sessionId);
1208
1209 if(psessionEntry == NULL)
1210 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001211 PELOGE(limLog(pMac, LOGE,FL("Session does Not exist with given sessionId :%d "), pAddTsRspMsg->sessionId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 limSendSmeAddtsRsp(pMac, rspReqd, eSIR_SME_ADDTS_RSP_FAILED, psessionEntry, pAddTsRspMsg->tspec,
1213 pMac->lim.gLimAddtsReq.sessionId, pMac->lim.gLimAddtsReq.transactionId);
1214 goto end;
1215 }
1216
1217 if(pAddTsRspMsg->status == eHAL_STATUS_SUCCESS)
1218 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301219 limLog(pMac, LOG1, FL("Received successful ADDTS response from HAL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 // Use the smesessionId and smetransactionId from the PE session context
1221 limSendSmeAddtsRsp(pMac, rspReqd, eSIR_SME_SUCCESS, psessionEntry, pAddTsRspMsg->tspec,
1222 psessionEntry->smeSessionId, psessionEntry->transactionId);
1223 goto end;
1224 }
1225 else
1226 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301227 limLog(pMac, LOG1, FL("Received failure ADDTS response from HAL "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001228
1229 // Send DELTS action frame to AP
1230 // 090803: Get peer MAC addr from session
1231#if 0
1232 cfgLen = sizeof(tSirMacAddr);
1233 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMacAddr, &cfgLen) != eSIR_SUCCESS)
1234 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001235 limLog(pMac, LOGP, FL("Fail to retrieve BSSID "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 goto end;
1237 }
1238#endif //TO SUPPORT BT-AMP
1239 sirCopyMacAddr(peerMacAddr,psessionEntry->bssId);
1240
1241 // 090803: Add the SME Session ID
1242 limSendDeltsReqActionFrame(pMac, peerMacAddr, rspReqd, &pAddTsRspMsg->tspec.tsinfo, &pAddTsRspMsg->tspec,
1243 //psessionEntry->smeSessionId);
1244 psessionEntry);
1245
1246 // Delete TSPEC
1247 // 090803: Pull the hash table from the session
1248 pSta = dphLookupAssocId(pMac, pAddTsRspMsg->staIdx, &assocId,
1249 &psessionEntry->dph.dphHashTable);
1250 if (pSta != NULL)
1251 limAdmitControlDeleteTS(pMac, assocId, &pAddTsRspMsg->tspec.tsinfo, NULL, (tANI_U8 *)&pAddTsRspMsg->tspecIdx);
1252
1253 // Send SME_ADDTS_RSP
1254 // 090803: Use the smesessionId and smetransactionId from the PE session context
1255 limSendSmeAddtsRsp(pMac, rspReqd, eSIR_SME_ADDTS_RSP_FAILED, psessionEntry, pAddTsRspMsg->tspec,
1256 psessionEntry->smeSessionId, psessionEntry->transactionId);
1257 goto end;
1258 }
1259
1260end:
1261 if( pAddTsRspMsg != NULL )
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301262 vos_mem_free(pAddTsRspMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 return;
1264}
1265