blob: 717cc36d572097c39d4c87ce1f47c9b3f2351ea1 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*
43 *
44 * Airgo Networks, Inc proprietary. All rights reserved.
45 * This file contains the source code for CFG API functions.
46 *
47 * Author: Kevin Nguyen
48 * Date: 04/09/02
49 * History:-
50 * 04/09/02 Created.
51 * --------------------------------------------------------------------
52 */
53
54#include "palTypes.h"
55#include "cfgPriv.h"
56#include "cfgDebug.h"
57#include "wlan_qct_wda.h"
58
59//---------------------------------------------------------------------
60// Static Variables
61//----------------------------------------------------------------------
62static tCfgCtl __gCfgEntry[CFG_PARAM_MAX_NUM] ;
63static tANI_U32 __gCfgIBufMin[CFG_STA_IBUF_MAX_SIZE] ;
64static tANI_U32 __gCfgIBufMax[CFG_STA_IBUF_MAX_SIZE] ;
65static tANI_U32 __gCfgIBuf[CFG_STA_IBUF_MAX_SIZE] ;
66static tANI_U8 __gCfgSBuf[CFG_STA_SBUF_MAX_SIZE] ;
67static tANI_U8 __gSBuffer[CFG_MAX_STR_LEN] ;
68static tANI_U32 __gParamList[WNI_CFG_MAX_PARAM_NUM +
69 WNI_CFG_GET_PER_STA_STAT_RSP_NUM];
70
71static void Notify(tpAniSirGlobal, tANI_U16, tANI_U32);
72
73
74// ---------------------------------------------------------------------
75tANI_U32 cfgNeedRestart(tpAniSirGlobal pMac, tANI_U16 cfgId)
76{
77 return !!(pMac->cfg.gCfgEntry[cfgId].control & CFG_CTL_RESTART) ;
78}
79
80// ---------------------------------------------------------------------
81tANI_U32 cfgNeedReload(tpAniSirGlobal pMac, tANI_U16 cfgId)
82{
83 return !!(pMac->cfg.gCfgEntry[cfgId].control & CFG_CTL_RELOAD) ;
84}
85
86// ---------------------------------------------------------------------
87/**
88 * wlan_cfgInit()
89 *
90 * FUNCTION:
91 * CFG initialization function.
92 *
93 * LOGIC:
94 * Please see Configuration & Statistic Collection Micro-Architecture
95 * specification for the pseudocode.
96 *
97 * ASSUMPTIONS:
98 * None.
99 *
100 * NOTE:
101 * This function must be called during system initialization.
102 *
103 * @param None
104 * @return None.
105 */
106
107void
108wlan_cfgInit(tpAniSirGlobal pMac)
109{
110 // Set status to not-ready
111 pMac->cfg.gCfgStatus = CFG_INCOMPLETE;
112
113 // Send CFG_DNLD_REQ to host
114 PELOGW(cfgLog(pMac, LOGW, FL("Sending CFG_DNLD_REQ\n"));)
115 cfgSendHostMsg(pMac, WNI_CFG_DNLD_REQ, WNI_CFG_DNLD_REQ_LEN,
116 WNI_CFG_DNLD_REQ_NUM, 0, 0, 0);
117
118} /*** end wlan_cfgInit() ***/
119
120
121//---------------------------------------------------------------------
Jeff Johnson295189b2012-06-20 16:38:30 -0700122tSirRetStatus cfgInit(tpAniSirGlobal pMac)
123{
124 pMac->cfg.gCfgIBufMin = __gCfgIBufMin;
125 pMac->cfg.gCfgIBufMax = __gCfgIBufMax;
126 pMac->cfg.gCfgIBuf = __gCfgIBuf;
127 pMac->cfg.gCfgSBuf = __gCfgSBuf;
128 pMac->cfg.gSBuffer = __gSBuffer;
129 pMac->cfg.gCfgEntry = __gCfgEntry;
130 pMac->cfg.gParamList = __gParamList;
131
132 return (eSIR_SUCCESS);
133}
134
135//----------------------------------------------------------------------
136void cfgDeInit(tpAniSirGlobal pMac)
137{
138 pMac->cfg.gCfgIBufMin = NULL;
139 pMac->cfg.gCfgIBufMax = NULL;
140 pMac->cfg.gCfgIBuf = NULL;
141 pMac->cfg.gCfgSBuf = NULL;
142 pMac->cfg.gSBuffer = NULL;
143 pMac->cfg.gCfgEntry = NULL;
144 pMac->cfg.gParamList = NULL;
145}
Jeff Johnson295189b2012-06-20 16:38:30 -0700146
147// ---------------------------------------------------------------------
148/**
149 * cfgSetInt()
150 *
151 * FUNCTION:
152 * This function is called to update an integer parameter.
153 *
154 * LOGIC:
155 *
156 * ASSUMPTIONS:
157 * - Range checking is performed by the calling function. In case this
158 * function call is being triggered by a request from host, then host
159 * is responsible for performing range checking before sending the
160 * request.
161 *
162 * - Host RW permission checking should already be done prior to calling
163 * this function by the message processing function.
164 *
165 * NOTE:
166 *
167 * @param cfgId: 16-bit CFG parameter ID
168 * @param value: 32-bit unsigned value
169 *
170 * @return eSIR_SUCCESS : request completed successfully \n
171 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID \n
172 */
173
174tSirRetStatus
175cfgSetInt(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U32 value)
176{
177 tANI_U32 index;
178 tANI_U32 control, mask;
179 tSirRetStatus retVal;
180
181 if (cfgId >= CFG_PARAM_MAX_NUM)
182 {
183 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
184 return eSIR_CFG_INVALID_ID;
185 }
186
187 control = pMac->cfg.gCfgEntry[cfgId].control;
188 index = control & CFG_BUF_INDX_MASK;
189 retVal = eSIR_SUCCESS;
190
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 if (index >= CFG_STA_IBUF_MAX_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 {
193 PELOGE(cfgLog(pMac, LOGE, FL("cfg index out of bounds %d\n"), index);)
194 retVal = eSIR_CFG_INVALID_ID;
195 return retVal;
196 }
197
198 // Check if parameter is valid
199 if ((control & CFG_CTL_VALID) == 0)
200 {
201 PELOGE(cfgLog(pMac, LOGE, FL("Not valid cfg id %d\n"), cfgId);)
202 retVal = eSIR_CFG_INVALID_ID;
203 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 else if ((pMac->cfg.gCfgIBufMin[index] > value) ||
205 (pMac->cfg.gCfgIBufMax[index] < value))
206 {
207 PELOGE(cfgLog(pMac, LOGE, FL("Value %d out of range [%d,%d] cfg id %d\n"),
208 value, pMac->cfg.gCfgIBufMin[index],
209 pMac->cfg.gCfgIBufMax[index], cfgId);)
210 retVal = eSIR_CFG_INVALID_ID;
211 }
212 else
213 {
214 // Write integer value
215 pMac->cfg.gCfgIBuf[index] = value;
216
217 // Update hardware if necessary
218 mask = control & CFG_CTL_NTF_MASK;
219 if ((mask & CFG_CTL_NTF_HW) != 0)
220 PELOGE(cfgLog(pMac, LOGE, FL("CFG Notify HW not supported!!!\n"));)
221
222 // Notify other modules if necessary
223 if ((mask & CFG_CTL_NTF_MASK) != 0)
224 Notify(pMac, cfgId, mask);
225
226 }
227
228 return (retVal);
229
230} /*** end cfgSetInt ***/
231
232// ---------------------------------------------------------------------
233/**
234 * cfgCheckValid()
235 *
236 * FUNCTION:
237 * This function is called to check if a parameter is valid
238 *
239 * LOGIC:
240 *
241 * ASSUMPTIONS:
242 *
243 * NOTE:
244 *
245 * @param cfgId: 16-bit CFG parameter ID
246 *
247 * @return eSIR_SUCCESS: request completed successfully
248 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
249 */
250
251tSirRetStatus
252cfgCheckValid(tpAniSirGlobal pMac, tANI_U16 cfgId)
253{
254 tANI_U32 control;
255
256 if (cfgId >= CFG_PARAM_MAX_NUM)
257 {
258 PELOG3(cfgLog(pMac, LOG3, FL("Invalid cfg id %d\n"), cfgId);)
259 return(eSIR_CFG_INVALID_ID);
260 }
261
262 control = pMac->cfg.gCfgEntry[cfgId].control;
263
264 // Check if parameter is valid
265 if ((control & CFG_CTL_VALID) == 0)
266 {
267 PELOG3(cfgLog(pMac, LOG3, FL("Not valid cfg id %d\n"), cfgId);)
268 return(eSIR_CFG_INVALID_ID);
269 }
270 else
271 return(eSIR_SUCCESS);
272
273} /*** end cfgCheckValid() ***/
274
275// ---------------------------------------------------------------------
276/**
277 * wlan_cfgGetInt()
278 *
279 * FUNCTION:
280 * This function is called to read an integer parameter.
281 *
282 * LOGIC:
283 *
284 * ASSUMPTIONS:
285 *
286 * NOTE:
287 *
288 * @param cfgId: 16-bit CFG parameter ID
289 * @param pVal: address where parameter value will be written
290 *
291 * @return eSIR_SUCCESS: request completed successfully
292 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
293 */
294
295tSirRetStatus
296wlan_cfgGetInt(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U32 *pValue)
297{
298 tANI_U32 index;
299 tANI_U32 control;
300 tSirRetStatus retVal;
301
302 if (cfgId >= CFG_PARAM_MAX_NUM)
303 {
304 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
305 retVal = eSIR_CFG_INVALID_ID;
306 return retVal;
307 }
308
309 control = pMac->cfg.gCfgEntry[cfgId].control;
310 index = control & CFG_BUF_INDX_MASK;
311 retVal = eSIR_SUCCESS;
312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 if (index >= CFG_STA_IBUF_MAX_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 {
315 PELOGE(cfgLog(pMac, LOGE, FL("cfg index out of bounds %d\n"), index);)
316 retVal = eSIR_CFG_INVALID_ID;
317 return retVal;
318 }
319
320 // Check if parameter is valid
321 if ((control & CFG_CTL_VALID) == 0)
322 {
323 PELOGE(cfgLog(pMac, LOGE, FL("Not valid cfg id %d\n"), cfgId);)
324 retVal = eSIR_CFG_INVALID_ID;
325 }
326 else {
327 // Get integer value
Jeff Johnson62c27982013-02-27 17:53:55 -0800328 if (index < CFG_STA_IBUF_MAX_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 *pValue = pMac->cfg.gCfgIBuf[index];
330 }
331
332 return (retVal);
333
334} /*** end wlan_cfgGetInt() ***/
335
336#ifdef NOT_CURRENTLY_USED
337// ---------------------------------------------------------------------
338/**
339 * cfgIncrementInt()
340 *
341 * FUNCTION:
342 * This function is called to increment an integer parameter by n.
343 *
344 * LOGIC:
345 *
346 * ASSUMPTIONS:
347 * - No range checking will be performed.
348 * - Host RW permission should be checked prior to calling this
349 * function.
350 *
351 * NOTE:
352 *
353 * @param cfgId: 16-bit CFG parameter ID
354 * @param value: increment value
355 *
356 * @return eSIR_SUCCESS: request completed successfully
357 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
358 */
359
360tSirRetStatus
361cfgIncrementInt(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U32 value)
362{
363 tANI_U32 index;
364 tANI_U32 control;
365 tSirRetStatus retVal;
366
367 if (cfgId >= CFG_PARAM_MAX_NUM)
368 {
369 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
370 retVal = eSIR_CFG_INVALID_ID;
371 }
372
373 control = pMac->cfg.gCfgEntry[cfgId].control;
374 index = control & CFG_BUF_INDX_MASK;
375 retVal = eSIR_SUCCESS;
376
377 // Check if parameter is valid
378 if ((control & CFG_CTL_VALID) == 0)
379 {
380 PELOGE(cfgLog(pMac, LOGE, FL("Not valid cfg id %d\n"), cfgId);)
381 retVal = eSIR_CFG_INVALID_ID;
382 }
383 else
384 {
385 // Increment integer value
386 pMac->cfg.gCfgIBuf[index] += value;
387
388 }
389
390 return (retVal);
391}
392#endif // NOT_CURRENTLY_USED
393
394// ---------------------------------------------------------------------
395/**
396 * cfgSetStr()
397 *
398 * FUNCTION:
399 * This function is called to set a string parameter.
400 *
401 * LOGIC:
402 * This function invokes the cfgSetStrNotify function passing the notify
403 * boolean value set to TRUE. This basically means that HAL needs to be
404 * notified. This is true in the case of non-integrated SOC's or Libra/Volans.
405 * In the case of Prima the cfgSetStrNotify is invoked with the boolean value
406 * set to FALSE.
407 *
408 * ASSUMPTIONS:
409 * - always Notify has to be called
410 *
411 * NOTE:
412 *
413 * @param cfgId: 16-bit CFG parameter ID
414 * @param pStr: address of string data
415 * @param len: string length
416 *
417 * @return eSIR_SUCCESS: request completed successfully
418 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
419 * @return eSIR_CFG_INVALID_LEN: invalid parameter length
420 *
421 */
422
423tSirRetStatus cfgSetStr(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U8 *pStr,
424 tANI_U32 length)
425{
426 return cfgSetStrNotify( pMac, cfgId, pStr, length, TRUE );
427}
428
429// ---------------------------------------------------------------------
430/**
431 * cfgSetStrNotify()
432 *
433 * FUNCTION:
434 * This function is called to set a string parameter.
435 *
436 * LOGIC:
437 *
438 * ASSUMPTIONS:
439 * - No length checking will be performed. Should be done by calling
440 * module.
441 * - Host RW permission should be checked prior to calling this
442 * function.
443 *
444 * NOTE:
445 *
446 * @param cfgId: 16-bit CFG parameter ID
447 * @param pStr: address of string data
448 * @param len: string length
449 * @param notifyMod. Notify respective Module
450 *
451 * @return eSIR_SUCCESS: request completed successfully
452 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
453 * @return eSIR_CFG_INVALID_LEN: invalid parameter length
454 *
455 */
456
457tSirRetStatus
458cfgSetStrNotify(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U8 *pStr,
459 tANI_U32 length, int notifyMod)
460{
461 tANI_U8 *pDst, *pDstEnd;
462 tANI_U32 index, paramLen, control, mask;
463 tSirRetStatus retVal;
464
465 if (cfgId >= CFG_PARAM_MAX_NUM)
466 {
467 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
468 return eSIR_CFG_INVALID_ID;
469 }
470
471 control = pMac->cfg.gCfgEntry[cfgId].control;
472 index = control & CFG_BUF_INDX_MASK;
473 retVal = eSIR_SUCCESS;
474
475 // Check if parameter is valid
476 if ((control & CFG_CTL_VALID) == 0)
477 {
478 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
479 retVal = eSIR_CFG_INVALID_ID;
480 }
481 else if (index >= CFG_STA_SBUF_MAX_SIZE)
482 {
483 PELOGE(cfgLog(pMac, LOGE, FL("Invalid Sbuf index %d (max size %d)\n"),
484 index, CFG_STA_SBUF_MAX_SIZE);)
485 retVal = eSIR_CFG_INVALID_ID;
486 }
487 else
488 {
489 pDst = &pMac->cfg.gCfgSBuf[index];
490 paramLen = *pDst++;
491 if (length > paramLen)
492 {
493 PELOGE(cfgLog(pMac, LOGE, FL("Invalid length %d (>%d) cfg id %d\n"),
494 length, paramLen, cfgId);)
495 retVal = eSIR_CFG_INVALID_LEN;
496 }
497 else
498 {
499 *pDst++ = (tANI_U8)length;
500 pDstEnd = pDst + length;
501 while (pDst < pDstEnd)
502 {
503 *pDst++ = *pStr++;
504 }
505
506 if(notifyMod)
507 {
508 // Update hardware if necessary
509 mask = control & CFG_CTL_NTF_MASK;
510 if ((mask & CFG_CTL_NTF_HW) != 0)
511 {
512 PELOGE(cfgLog(pMac, LOGE, FL("CFG Notify HW not supported!!!\n"));)
513 }
514
515 // Notify other modules if necessary
516 if ( (mask & CFG_CTL_NTF_MASK) != 0)
517 {
518 Notify(pMac, cfgId, mask);
519 }
520 }
521 }
522
523 }
524
525 return (retVal);
526
527} /*** end cfgSetStrNotify() ***/
528
529// ---------------------------------------------------------------------
530/**
531 * wlan_cfgGetStr()
532 *
533 * FUNCTION:
534 * This function is called to get a string parameter.
535 *
536 * LOGIC:
537 *
538 * ASSUMPTIONS:
539 * - Host RW permission should be checked prior to calling this
540 * function.
541 *
542 * NOTE:
543 *
544 * @param cfgId: 16-bit CFG parameter ID
545 * @param pBuf: address of string buffer
546 * @param pLen: address of max buffer length
547 * actual length will be returned at this address
548 *
549 * @return eSIR_SUCCESS: request completed successfully
550 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
551 * @return eSIR_CFG_INVALID_LEN: invalid parameter length
552 *
553 */
554
555tSirRetStatus
556wlan_cfgGetStr(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U8 *pBuf, tANI_U32 *pLength)
557{
558 tANI_U8 *pSrc, *pSrcEnd;
559 tANI_U32 index, control;
560 tSirRetStatus retVal;
561
562 if (cfgId >= CFG_PARAM_MAX_NUM)
563 {
564 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
565 retVal = eSIR_CFG_INVALID_ID;
566 return retVal;
567 }
568
569 control = pMac->cfg.gCfgEntry[cfgId].control;
570 index = control & CFG_BUF_INDX_MASK;
571 retVal = eSIR_SUCCESS;
572
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 if (index >= CFG_STA_SBUF_MAX_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 {
575 PELOGE(cfgLog(pMac, LOGE, FL("cfg index out of bounds %d\n"), index);)
576 retVal = eSIR_CFG_INVALID_ID;
577 return retVal;
578 }
579
580 // Check if parameter is valid
581 if ((control & CFG_CTL_VALID) == 0)
582 {
583 PELOGE(cfgLog(pMac, LOGE, FL("Not valid cfg id %d\n"), cfgId);)
584 retVal = eSIR_CFG_INVALID_ID;
585 }
586 else
587 {
588 // Get string
589 pSrc = &pMac->cfg.gCfgSBuf[index];
590 pSrc++; // skip over max length
591 if (*pLength < *pSrc)
592 {
593 PELOGE(cfgLog(pMac, LOGE, FL("Invalid length %d (<%d) cfg id %d\n"),
594 *pLength, *pSrc, cfgId);)
595 retVal = eSIR_CFG_INVALID_LEN;
596 }
597 else
598 {
599 *pLength = *pSrc++; // save parameter length
600 pSrcEnd = pSrc + *pLength;
601 while (pSrc < pSrcEnd)
602 *pBuf++ = *pSrc++;
603 }
604 }
605
606 return (retVal);
607
608} /*** end wlan_cfgGetStr() ***/
609
610// ---------------------------------------------------------------------
611/**
612 * wlan_cfgGetStrMaxLen()
613 *
614 * FUNCTION:
615 * This function is called to get a string maximum length.
616 *
617 * LOGIC:
618 *
619 * ASSUMPTIONS:
620 * - Host RW permission should be checked prior to calling this
621 * function.
622 *
623 * NOTE:
624 *
625 * @param cfgId: 16-bit CFG parameter ID
626 * @param pLen: maximum length will be returned at this address
627 *
628 * @return eSIR_SUCCESS: request completed successfully
629 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
630 *
631 */
632
633tSirRetStatus
634wlan_cfgGetStrMaxLen(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U32 *pLength)
635{
636 tANI_U32 index, control;
637 tSirRetStatus retVal;
638
639 if (cfgId >= CFG_PARAM_MAX_NUM)
640 {
641 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
642 retVal = eSIR_CFG_INVALID_ID;
643 }
644
645 control = pMac->cfg.gCfgEntry[cfgId].control;
646 index = control & CFG_BUF_INDX_MASK;
647 retVal = eSIR_SUCCESS;
648
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 if (index >= CFG_STA_SBUF_MAX_SIZE)
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 {
651 PELOGE(cfgLog(pMac, LOGE, FL("cfg index out of bounds %d\n"), index);)
652 retVal = eSIR_CFG_INVALID_ID;
653 return retVal;
654 }
655
656 // Check if parameter is valid
657 if ((control & CFG_CTL_VALID) == 0)
658 {
659 PELOGE(cfgLog(pMac, LOGE, FL("Not valid cfg id %d\n"), cfgId);)
660 retVal = eSIR_CFG_INVALID_ID;
661 }
662 else
663 {
664 *pLength = pMac->cfg.gCfgSBuf[index];
665 }
666
667 return (retVal);
668
669} /*** end wlan_cfgGetStrMaxLen() ***/
670
671// ---------------------------------------------------------------------
672/**
673 * wlan_cfgGetStrLen()
674 *
675 * FUNCTION:
676 * This function is called to get a string length.
677 *
678 * LOGIC:
679 *
680 * ASSUMPTIONS:
681 * - Host RW permission should be checked prior to calling this
682 * function.
683 *
684 * NOTE:
685 *
686 * @param cfgId: 16-bit CFG parameter ID
687 * @param pLen: current length will be returned at this address
688 *
689 * @return eSIR_SUCCESS: request completed successfully
690 * @return eSIR_CFG_INVALID_ID: invalid CFG parameter ID
691 *
692 */
693
694tSirRetStatus
695wlan_cfgGetStrLen(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U32 *pLength)
696{
697 tANI_U32 index, control;
698 tSirRetStatus retVal;
699
700 if (cfgId >= CFG_PARAM_MAX_NUM)
701 {
702 PELOGE(cfgLog(pMac, LOGE, FL("Invalid cfg id %d\n"), cfgId);)
703 retVal = eSIR_CFG_INVALID_ID;
704 }
705
706 control = pMac->cfg.gCfgEntry[cfgId].control;
707 index = control & CFG_BUF_INDX_MASK;
708 retVal = eSIR_SUCCESS;
709
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 if (index >= CFG_STA_SBUF_MAX_SIZE-1)
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 {
712 PELOGE(cfgLog(pMac, LOGE, FL("cfg index out of bounds %d\n"), index);)
713 retVal = eSIR_CFG_INVALID_ID;
714 return retVal;
715 }
716
717 // Check if parameter is valid
718 if ((control & CFG_CTL_VALID) == 0)
719 {
720 PELOGE(cfgLog(pMac, LOGE, FL("Not valid cfg id %d\n"), cfgId);)
721 retVal = eSIR_CFG_INVALID_ID;
722 }
723 else
724 {
725 *pLength = pMac->cfg.gCfgSBuf[index+1];
726 }
727
728 return (retVal);
729
730} /*** end wlan_cfgGetStrLen() ***/
731
732
733
734/*-------------------------------------------------------------
735\fn cfgGetDot11dTransmitPower
736\brief This function returns the regulatory max transmit power
737\param pMac
738\return tPowerdBm - Power
739\-------------------------------------------------------------*/
740static tPowerdBm
741cfgGetDot11dTransmitPower(tpAniSirGlobal pMac, tANI_U16 cfgId,
742 tANI_U32 cfgLength, tANI_U8 channel)
743{
744 tANI_U8 *pCountryInfo = NULL;
745 tANI_U8 count = 0;
746 tPowerdBm maxTxPwr = WDA_MAX_TXPOWER_INVALID;
747 eHalStatus status;
748
749 /* At least one element is present */
750 if(cfgLength < sizeof(tSirMacChanInfo))
751 {
752 PELOGE(cfgLog(pMac, LOGE, FL("Invalid CFGLENGTH %d while getting 11d txpower"), cfgLength);)
753 goto error;
754 }
755
756 status = palAllocateMemory(pMac->hHdd, (void **)&pCountryInfo, cfgLength);
757 if (status != eHAL_STATUS_SUCCESS)
758 {
759 cfgLog(pMac, LOGP, FL(" palAllocateMemory() failed, status = %d"), status);
760 goto error;
761 }
762 /* The CSR will always update this CFG. The contents will be from country IE if regulatory domain
763 * is enabled on AP else will contain EEPROM contents
764 */
765 if (wlan_cfgGetStr(pMac, cfgId, pCountryInfo, &cfgLength) != eSIR_SUCCESS)
766 {
767 palFreeMemory(pMac->hHdd, pCountryInfo);
768 pCountryInfo = NULL;
769
770 cfgLog(pMac, LOGP, FL("Failed to retrieve 11d configuration parameters while retrieving 11d tuples"));
771 goto error;
772 }
773 /* Identify the channel and maxtxpower */
774 while(count <= (cfgLength - (sizeof(tSirMacChanInfo))))
775 {
776 tANI_U8 firstChannel, maxChannels;
777
778 firstChannel = pCountryInfo[count++];
779 maxChannels = pCountryInfo[count++];
780 maxTxPwr = pCountryInfo[count++];
781
782 if((channel >= firstChannel) &&
783 (channel < (firstChannel + maxChannels)))
784 {
785 break;
786 }
787 }
788
789error:
790 if(NULL != pCountryInfo)
791 palFreeMemory(pMac->hHdd, pCountryInfo);
792
793 return maxTxPwr;
794}
795
796
797/**----------------------------------------------------------------------
798\fn cfgGetRegulatoryMaxTransmitPower
799
800\brief Gets regulatory tx power on the current channel.
801
802\param pMac
803\param channel
804\param rfBand
805 -----------------------------------------------------------------------*/
806tPowerdBm cfgGetRegulatoryMaxTransmitPower(tpAniSirGlobal pMac, tANI_U8 channel)
807{
808 tANI_U32 cfgLength = 0;
809 tANI_U16 cfgId = 0;
810 tPowerdBm maxTxPwr;
811 eRfBandMode rfBand = eRF_BAND_UNKNOWN;
812
813 if ((channel >= SIR_11A_CHANNEL_BEGIN) &&
814 (channel <= SIR_11A_CHANNEL_END))
815 rfBand = eRF_BAND_5_GHZ;
816 else
817 rfBand = eRF_BAND_2_4_GHZ;
818
819
820 /* Get the max transmit power for current channel for the current regulatory domain */
821 switch (rfBand)
822 {
823 case eRF_BAND_2_4_GHZ:
824 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
825 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
826 PELOG2(cfgLog(pMac, LOG2, FL("HAL: Reading CFG for 2.4 GHz channels to get regulatory max tx power"));)
827 break;
828
829 case eRF_BAND_5_GHZ:
830 cfgId = WNI_CFG_MAX_TX_POWER_5;
831 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
832 PELOG2(cfgLog(pMac, LOG2, FL("HAL: Reading CFG for 5.0 GHz channels to get regulatory max tx power"));)
833 break;
834
835 case eRF_BAND_UNKNOWN:
836 default:
837 PELOG2(cfgLog(pMac, LOG2, FL("HAL: Invalid current working band for the device"));)
838 return WDA_MAX_TXPOWER_INVALID; //Its return, not break.
839 }
840
841 maxTxPwr = cfgGetDot11dTransmitPower(pMac, cfgId, cfgLength, channel);
842
843 return (maxTxPwr);
844}
845
846// ---------------------------------------------------------------------
847/**
848 * cfgGetCapabilityInfo
849 *
850 * FUNCTION:
851 *
852 * LOGIC:
853 *
854 * ASSUMPTIONS:
855 *
856 * NOTE:
857 *
858 * @param None
859 * @return None
860 */
861
862tSirRetStatus
863cfgGetCapabilityInfo(tpAniSirGlobal pMac, tANI_U16 *pCap,tpPESession sessionEntry)
864{
865 tANI_U32 val = 0;
866 tpSirMacCapabilityInfo pCapInfo;
867 tLimSystemRole systemRole = limGetSystemRole(sessionEntry);
868
869 *pCap = 0;
870 pCapInfo = (tpSirMacCapabilityInfo) pCap;
871
872 if (systemRole == eLIM_STA_IN_IBSS_ROLE)
873 pCapInfo->ibss = 1; // IBSS bit
874 else if ( (systemRole == eLIM_AP_ROLE) ||(systemRole == eLIM_BT_AMP_AP_ROLE)||(systemRole == eLIM_BT_AMP_STA_ROLE) ||
875 (systemRole == eLIM_STA_ROLE) )
876 pCapInfo->ess = 1; // ESS bit
877#if defined WLAN_FEATURE_P2P
878 else if (limGetSystemRole(sessionEntry) == eLIM_P2P_DEVICE_ROLE )
879 {
880 pCapInfo->ess = 0;
881 pCapInfo->ibss = 0;
882 }
883#endif
884 else
885 cfgLog(pMac, LOGP, FL("can't get capability, role is UNKNOWN!!\n"));
886
Jeff Johnson295189b2012-06-20 16:38:30 -0700887
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 if(systemRole == eLIM_AP_ROLE)
889 {
890 val = sessionEntry->privacy;
891 }
892 else
893 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800894 // PRIVACY bit
895 if (wlan_cfgGetInt(pMac, WNI_CFG_PRIVACY_ENABLED, &val) != eSIR_SUCCESS)
896 {
897 cfgLog(pMac, LOGP, FL("cfg get WNI_CFG_PRIVACY_ENABLED failed\n"));
898 return eSIR_FAILURE;
899 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 if (val)
902 pCapInfo->privacy = 1;
903
904 // Short preamble bit
905 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
906 {
907 cfgLog(pMac, LOGP, FL("cfg get WNI_CFG_SHORT_PREAMBLE failed\n"));
908 return eSIR_FAILURE;
909 }
910 if (val)
911 pCapInfo->shortPreamble = 1;
912
913
914 // PBCC bit
915 pCapInfo->pbcc = 0;
916
917 // Channel agility bit
918 pCapInfo->channelAgility = 0;
919 //If STA/AP operating in 11B mode, don't set rest of the capability info bits.
920 if(sessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11B)
921 return eSIR_SUCCESS;
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 // Short slot time bit
924 if (systemRole == eLIM_AP_ROLE)
925 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700926 pCapInfo->shortSlotTime = sessionEntry->shortSlotTimeSupported;
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 }
928 else
929 {
930 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val)
931 != eSIR_SUCCESS)
932 {
933 cfgLog(pMac, LOGP,
934 FL("cfg get WNI_CFG_11G_SHORT_SLOT_TIME failed\n"));
935 return eSIR_FAILURE;
936 }
937 /* When in STA mode, we need to check if short slot is enabled as well as check if the current operating
938 * mode is short slot time and then decide whether to enable short slot or not. It is safe to check both
939 * cfg values to determine short slot value in this funcn since this funcn is always used after assoc when
940 * these cfg values are already set based on peer's capability. Even in case of IBSS, its value is set to
941 * correct value either in delBSS as part of deleting the previous IBSS or in start BSS as part of coalescing
942 */
943 if (val)
944 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700945 pCapInfo->shortSlotTime = sessionEntry->shortSlotTimeSupported;
946 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 }
948
949 // Spectrum Management bit
950 if((eLIM_STA_IN_IBSS_ROLE != systemRole) &&
951 sessionEntry->lim11hEnable )
952 {
953 if (wlan_cfgGetInt(pMac, WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
954 {
955 cfgLog(pMac, LOGP, FL("cfg get WNI_CFG_11H_ENABLED failed\n"));
956 return eSIR_FAILURE;
957 }
958 if (val)
959 pCapInfo->spectrumMgt = 1;
960 }
961
962 // QoS bit
963 if (wlan_cfgGetInt(pMac, WNI_CFG_QOS_ENABLED, &val) != eSIR_SUCCESS)
964 {
965 cfgLog(pMac, LOGP, FL("cfg get WNI_CFG_QOS_ENABLED failed\n"));
966 return eSIR_FAILURE;
967 }
968 if (val)
969 pCapInfo->qos = 1;
970
971 // APSD bit
972 if (wlan_cfgGetInt(pMac, WNI_CFG_APSD_ENABLED, &val) != eSIR_SUCCESS)
973 {
974 cfgLog(pMac, LOGP, FL("cfg get WNI_CFG_APSD_ENABLED failed\n"));
975 return eSIR_FAILURE;
976 }
977 if (val)
978 pCapInfo->apsd = 1;
979
980#if defined WLAN_FEATURE_VOWIFI
981 if ((limGetSystemRole(sessionEntry) == eLIM_STA_ROLE) )
982 {
983 if (wlan_cfgGetInt(pMac, WNI_CFG_RRM_ENABLED, &val) != eSIR_SUCCESS)
984 {
985 cfgLog(pMac, LOGP, FL("cfg get WNI_CFG_RRM_ENABLED failed\n"));
986 return eSIR_FAILURE;
987 }
988#if defined WLAN_VOWIFI_DEBUG
989 PELOGE(cfgLog( pMac, LOGE, "RRM = %d\n",val );)
990#endif
991 if (val)
992 pCapInfo->rrm = 1;
993 }
994#endif
995 //DSSS-OFDM
996 //FIXME : no config defined yet.
997
998 // Block ack bit
999 if (wlan_cfgGetInt(pMac, WNI_CFG_BLOCK_ACK_ENABLED, &val) != eSIR_SUCCESS)
1000 {
1001 cfgLog(pMac, LOGP, FL("cfg get WNI_CFG_BLOCK_ACK_ENABLED failed\n"));
1002 return eSIR_FAILURE;
1003 }
1004 pCapInfo->delayedBA = (tANI_U16)((val >> WNI_CFG_BLOCK_ACK_ENABLED_DELAYED) & 1);
1005 pCapInfo->immediateBA = (tANI_U16)((val >> WNI_CFG_BLOCK_ACK_ENABLED_IMMEDIATE) & 1);
1006
1007 return eSIR_SUCCESS;
1008}
1009
1010// --------------------------------------------------------------------
1011/**
1012 * cfgSetCapabilityInfo
1013 *
1014 * FUNCTION:
1015 * This function is called on BP based on the capabilities
1016 * received in SME_JOIN/REASSOC_REQ message.
1017 *
1018 * LOGIC:
1019 *
1020 * ASSUMPTIONS:
1021 *
1022 * NOTE: 1. ESS/IBSS capabilities are based on system role.
1023 * 2. Since PBCC, Channel agility and Extended capabilities
1024 * are not supported, they're not set at CFG
1025 *
1026 * @param pMac Pointer to global MAC structure
1027 * @param caps 16-bit Capability Info field
1028 * @return None
1029 */
1030
1031void
1032cfgSetCapabilityInfo(tpAniSirGlobal pMac, tANI_U16 caps)
1033{
Jeff Johnson295189b2012-06-20 16:38:30 -07001034}
1035
1036
1037// ---------------------------------------------------------------------
1038/**
1039 * cfgCleanup()
1040 *
1041 * FUNCTION:
1042 * CFG cleanup function.
1043 *
1044 * LOGIC:
1045 *
1046 * ASSUMPTIONS:
1047 * None.
1048 *
1049 * NOTE:
1050 * This function must be called during system shutdown.
1051 *
1052 * @param None
1053 *
1054 * @return None.
1055 *
1056 */
1057
1058void
1059cfgCleanup(tpAniSirGlobal pMac)
1060{
1061 // Set status to not-ready
1062 pMac->cfg.gCfgStatus = CFG_INCOMPLETE;
1063
1064} /*** end CfgCleanup() ***/
1065
1066// ---------------------------------------------------------------------
1067/**
1068 * Notify()
1069 *
1070 * FUNCTION:
1071 * This function is called to notify other modules of parameter update.
1072 *
1073 * LOGIC:
1074 *
1075 * ASSUMPTIONS:
1076 *
1077 * NOTE:
1078 *
1079 * @param cfgId: configuration parameter ID
1080 * @param mask: notification mask
1081 *
1082 * @return None.
1083 *
1084 */
1085
1086static void
1087Notify(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U32 ntfMask)
1088{
1089
1090 tSirMsgQ mmhMsg;
1091
1092 mmhMsg.type = SIR_CFG_PARAM_UPDATE_IND;
1093 mmhMsg.bodyval = (tANI_U32)cfgId;
1094 mmhMsg.bodyptr = NULL;
1095
Jeff Johnsone7245742012-09-05 17:12:55 -07001096 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07001097
1098 if ((ntfMask & CFG_CTL_NTF_SCH) != 0)
1099 schPostMessage(pMac, &mmhMsg);
1100
1101 if ((ntfMask & CFG_CTL_NTF_LIM) != 0)
1102 limPostMsgApi(pMac, &mmhMsg);
1103
1104 if ((ntfMask & CFG_CTL_NTF_HAL) != 0)
1105 wdaPostCtrlMsg(pMac, &mmhMsg);
1106
1107 // Notify ARQ
1108
1109} /*** end Notify() ***/
1110
1111// ---------------------------------------------------------------------
1112
1113
1114
1115
1116
1117
1118