Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 2 | * 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 Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 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 CFG functions for processing host messages. |
| 46 | * |
| 47 | * Author: Kevin Nguyen |
| 48 | * Date: 04/09/02 |
| 49 | * History:- |
| 50 | * 04/09/02 Created. |
| 51 | * -------------------------------------------------------------------- |
| 52 | */ |
| 53 | #include "palTypes.h" |
| 54 | #include "aniGlobal.h" |
| 55 | #include "cfgPriv.h" |
| 56 | #include "cfgDebug.h" |
| 57 | #include "wlan_qct_wda.h" |
| 58 | |
| 59 | |
| 60 | /*--------------------------------------------------------------------*/ |
| 61 | /* Static function prototypes */ |
| 62 | /*--------------------------------------------------------------------*/ |
| 63 | static void ProcDnldRsp (tpAniSirGlobal, tANI_U16, tANI_U32*); |
| 64 | static void ProcGetReq (tpAniSirGlobal, tANI_U16, tANI_U32*); |
| 65 | static void ProcSetReq (tpAniSirGlobal, tANI_U16, tANI_U32*); |
| 66 | static void ProcSetReqNoRsp (tpAniSirGlobal, tANI_U16, tANI_U32*); |
| 67 | |
| 68 | static tANI_U8 CheckParam(tpAniSirGlobal, tANI_U16, tANI_U32, tANI_U32, tANI_U32*); |
| 69 | static void GetStrValue(tANI_U8*, tANI_U8*, tANI_U32); |
| 70 | |
| 71 | |
| 72 | /*--------------------------------------------------------------------*/ |
| 73 | /* Module global variables */ |
| 74 | /*--------------------------------------------------------------------*/ |
| 75 | |
| 76 | // CFG function table |
| 77 | void (*gCfgFunc[])(tpAniSirGlobal, tANI_U16, tANI_U32*) = |
| 78 | { ProcDnldRsp, |
| 79 | ProcGetReq, |
| 80 | ProcSetReq, |
| 81 | ProcSetReqNoRsp |
| 82 | }; |
| 83 | |
| 84 | /**--------------------------------------------------------------------- |
| 85 | * cfgProcessMbMsg() |
| 86 | * |
| 87 | *FUNCTION: |
| 88 | * CFG mailbox message processing function. |
| 89 | * |
| 90 | *LOGIC: |
| 91 | * |
| 92 | *ASSUMPTIONS: |
| 93 | * None. |
| 94 | * |
| 95 | *NOTE: |
| 96 | * |
| 97 | * @param pMsg Message pointer |
| 98 | * |
| 99 | * @return None. |
| 100 | * |
| 101 | */ |
| 102 | void |
| 103 | cfgProcessMbMsg(tpAniSirGlobal pMac, tSirMbMsg *pMsg) |
| 104 | { |
| 105 | tANI_U16 index; |
| 106 | tANI_U16 len; |
| 107 | tANI_U32 *pParam; |
| 108 | |
| 109 | // Use type[7:0] as index to function table |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 110 | index = CFG_GET_FUNC_INDX(pMsg->type); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 111 | |
| 112 | if (index >= (sizeof(gCfgFunc) / sizeof(gCfgFunc[0]))) |
Kiran Kumar Lokere | fdf4241 | 2013-07-17 17:40:58 -0700 | [diff] [blame] | 113 | { |
Kiet Lam | 842c3e1 | 2013-11-16 22:40:57 +0530 | [diff] [blame] | 114 | vos_mem_free(pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 115 | return; |
Kiran Kumar Lokere | fdf4241 | 2013-07-17 17:40:58 -0700 | [diff] [blame] | 116 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 117 | len = pMsg->msgLen - WNI_CFG_MB_HDR_LEN; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 118 | pParam = ((tANI_U32*)pMsg) + 1; |
| 119 | |
| 120 | // Call processing function |
| 121 | gCfgFunc[index](pMac, len, pParam); |
| 122 | |
| 123 | // Free up buffer |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 124 | vos_mem_free(pMsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 125 | |
| 126 | } /*** end cfgProcessMbMsg() ***/ |
| 127 | |
| 128 | /**--------------------------------------------------------------------- |
| 129 | * ProcDnldRsp() |
| 130 | * |
| 131 | * FUNCTION: |
| 132 | * This function processes CFG_DNLD_RSP message from host. |
| 133 | * |
| 134 | * LOGIC: |
| 135 | * |
| 136 | * ASSUMPTIONS: |
| 137 | * |
| 138 | * NOTE: |
| 139 | * |
| 140 | * @param length: message length |
| 141 | * @param pParam: parameter list pointer |
| 142 | * |
| 143 | * @return None |
| 144 | * |
| 145 | */ |
| 146 | static void |
| 147 | ProcDnldRsp(tpAniSirGlobal pMac, tANI_U16 length, tANI_U32 *pParam) |
| 148 | { |
| 149 | tANI_S32 i; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 150 | |
| 151 | tANI_U32 expLen, retVal, bufStart, bufEnd; |
| 152 | tANI_U32 *pSrc, *pDst, *pDstEnd; |
| 153 | tANI_U32 strSize, j; |
| 154 | tANI_U8 pStr[CFG_MAX_STR_LEN]; |
| 155 | tpCfgBinHdr pHdr; |
| 156 | tANI_U32 logLevel; |
| 157 | tSirMsgQ mmhMsg; |
| 158 | |
| 159 | // First Dword must contain the AP or STA magic dword |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 160 | PELOGW(cfgLog(pMac, LOGW, FL("CFG size %d bytes MAGIC dword is 0x%x"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 161 | length, sirReadU32N((tANI_U8*)pParam) );) |
| 162 | |
| 163 | // if the string is not correct, return failure |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 164 | if (*pParam == CFG_STA_MAGIC_DWORD) {} |
| 165 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 166 | |
| 167 | |
| 168 | |
| 169 | else |
| 170 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 171 | PELOGE(cfgLog(pMac, LOGE, FL("Invalid magic dword 0x%x"),sirReadU32N((tANI_U8*)pParam) );) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 172 | retVal = WNI_CFG_INVALID_LEN; |
| 173 | goto end; |
| 174 | } |
| 175 | |
| 176 | pParam++; |
| 177 | length -= 4; |
| 178 | |
| 179 | // Verify message length |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 180 | { |
| 181 | pMac->cfg.gCfgMaxIBufSize = CFG_STA_IBUF_MAX_SIZE; |
| 182 | pMac->cfg.gCfgMaxSBufSize = CFG_STA_SBUF_MAX_SIZE; |
| 183 | } |
| 184 | |
| 185 | // Parse the Cfg header |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 186 | pHdr = (tpCfgBinHdr) pParam; |
| 187 | pParam += (sizeof(tCfgBinHdr) >> 2); |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 188 | PELOGW(cfgLog(pMac, LOGW, FL("CFG hdr totParams %d intParams %d strBufSize %d/%d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 189 | pHdr->controlSize, pHdr->iBufSize, pHdr->sBufSize, pMac->cfg.gCfgMaxSBufSize);) |
| 190 | |
| 191 | expLen = ((CFG_PARAM_MAX_NUM + 3 * pMac->cfg.gCfgMaxIBufSize) << 2) + |
| 192 | pHdr->sBufSize + sizeof(tCfgBinHdr); |
| 193 | |
| 194 | if (length != expLen) |
| 195 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 196 | PELOGE(cfgLog(pMac, LOGE, FL("<CFG> DNLD_RSP invalid length %d (exp %d)"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 197 | length, expLen);) |
| 198 | retVal = WNI_CFG_INVALID_LEN; |
| 199 | goto end; |
| 200 | } |
| 201 | |
| 202 | |
| 203 | if (pHdr->controlSize != CFG_PARAM_MAX_NUM) |
| 204 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 205 | PELOGE(cfgLog(pMac, LOGE, FL("<CFG> Total parameter count mismatch"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 206 | retVal = WNI_CFG_INVALID_LEN; |
| 207 | goto end; |
| 208 | } |
| 209 | |
| 210 | if (pHdr->iBufSize != pMac->cfg.gCfgMaxIBufSize) |
| 211 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 212 | PELOGE(cfgLog(pMac, LOGE, FL("<CFG> Integer parameter count mismatch"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 213 | retVal = WNI_CFG_INVALID_LEN; |
| 214 | goto end; |
| 215 | } |
| 216 | |
| 217 | // Copy control array |
| 218 | pDst = (tANI_U32*)pMac->cfg.gCfgEntry; |
| 219 | pDstEnd = pDst + CFG_PARAM_MAX_NUM; |
| 220 | pSrc = pParam; |
| 221 | while (pDst < pDstEnd) |
| 222 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 223 | *pDst++ = *pSrc++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 224 | } |
| 225 | // Copy default values |
| 226 | pDst = pMac->cfg.gCfgIBuf; |
| 227 | pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize; |
| 228 | while (pDst < pDstEnd) |
| 229 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 230 | *pDst++ = *pSrc++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | // Copy min values |
| 234 | pDst = pMac->cfg.gCfgIBufMin; |
| 235 | pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize; |
| 236 | while (pDst < pDstEnd) |
| 237 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 238 | *pDst++ = *pSrc++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | // Copy max values |
| 242 | pDst = pMac->cfg.gCfgIBufMax; |
| 243 | pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize; |
| 244 | while (pDst < pDstEnd) |
| 245 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 246 | *pDst++ = *pSrc++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | for (i=0; i<pMac->cfg.gCfgMaxIBufSize; i++) |
| 250 | if (pMac->cfg.gCfgIBuf[i] < pMac->cfg.gCfgIBufMin[i] || |
| 251 | pMac->cfg.gCfgIBuf[i] > pMac->cfg.gCfgIBufMax[i]) |
| 252 | { |
| 253 | PELOGE(cfgLog(pMac, LOGE, FL("cfg id %d Invalid def value %d " |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 254 | "min %d max %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 255 | i, pMac->cfg.gCfgIBuf[i], pMac->cfg.gCfgIBufMin[i], |
| 256 | pMac->cfg.gCfgIBufMax[i]);) |
| 257 | } |
| 258 | |
| 259 | // Calculate max string buffer lengths for all string parameters |
| 260 | bufEnd = pMac->cfg.gCfgMaxSBufSize; |
| 261 | for (i = CFG_PARAM_MAX_NUM - 1; i >= 0; i--) |
| 262 | { |
| 263 | if ((pMac->cfg.gCfgEntry[i].control & CFG_CTL_INT) != 0) |
| 264 | continue; |
| 265 | |
| 266 | if ((pMac->cfg.gCfgEntry[i].control & CFG_CTL_VALID) == 0) |
| 267 | continue; |
| 268 | |
| 269 | bufStart = pMac->cfg.gCfgEntry[i].control & CFG_BUF_INDX_MASK; |
| 270 | pMac->cfg.gCfgSBuf[bufStart] = (tANI_U8)(bufEnd - bufStart - 2); |
| 271 | |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 272 | PELOG1(cfgLog(pMac, LOG1, FL("id %d max %d bufStart %d bufEnd %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 273 | i, pMac->cfg.gCfgSBuf[bufStart], bufStart, bufEnd);) |
| 274 | |
| 275 | bufEnd = bufStart; |
| 276 | } |
| 277 | |
| 278 | // Initialize string defaults |
| 279 | strSize = pHdr->sBufSize; |
| 280 | while (strSize) |
| 281 | { |
| 282 | tANI_U32 paramId, paramLen, paramLenCeil4; |
| 283 | |
| 284 | if (strSize < 4) |
| 285 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 286 | PELOGE(cfgLog(pMac, LOGE, FL("Error parsing str defaults, rem %d bytes"), strSize);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 287 | retVal = WNI_CFG_INVALID_LEN; |
| 288 | goto end; |
| 289 | } |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 290 | paramId = *pSrc >> 16; |
| 291 | paramLen = *pSrc & 0xff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 292 | pSrc++; |
| 293 | strSize -= 4; |
| 294 | |
| 295 | paramLenCeil4 = ((paramLen + 3) >> 2); |
| 296 | if (strSize < paramLenCeil4 << 2) |
| 297 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 298 | PELOGE(cfgLog(pMac, LOGE, FL("Error parsing str defaults, rem %d bytes"), strSize);) |
| 299 | PELOGE(cfgLog(pMac, LOGE, FL("param id %d len %d bytes"), paramId, paramLen);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 300 | retVal = WNI_CFG_INVALID_LEN; |
| 301 | goto end; |
| 302 | } |
| 303 | for (j=0; j < paramLenCeil4; j++) |
| 304 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 305 | pStr[4*j] = (tANI_U8) (*pSrc >> 24) & 0xff; |
| 306 | pStr[4*j+1] = (tANI_U8) (*pSrc >> 16) & 0xff; |
| 307 | pStr[4*j+2] = (tANI_U8) (*pSrc >> 8) & 0xff; |
| 308 | pStr[4*j+3] = (tANI_U8) (*pSrc) & 0xff; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 309 | |
| 310 | pSrc++; |
| 311 | strSize -= 4; |
| 312 | } |
| 313 | |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 314 | PELOG1(cfgLog(pMac, LOG1, FL("set str id %d len %d"), paramId, paramLen);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 315 | |
| 316 | if (cfgSetStr(pMac, (tANI_U16) paramId, pStr, paramLen) != eSIR_SUCCESS) |
| 317 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 318 | PELOGE(cfgLog(pMac, LOGE, FL("Error setting str default param %d len %d"), paramId, paramLen);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 319 | retVal = WNI_CFG_INVALID_LEN; |
| 320 | goto end; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | // Set the default log level based on config |
| 325 | wlan_cfgGetInt(pMac, WNI_CFG_LOG_LEVEL, &logLevel); |
| 326 | for (i = 0; i < LOG_ENTRY_NUM; i++) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 327 | pMac->utils.gLogEvtLevel[i] = pMac->utils.gLogDbgLevel[i] = logLevel; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 328 | |
| 329 | // Set status to READY |
| 330 | pMac->cfg.gCfgStatus = CFG_SUCCESS; |
| 331 | retVal = WNI_CFG_SUCCESS; |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 332 | PELOG1(cfgLog(pMac, LOG1, "<CFG> Completed successfully");) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 333 | |
| 334 | end: |
| 335 | |
| 336 | if ( retVal != WNI_CFG_SUCCESS ) |
| 337 | pMac->cfg.gCfgStatus = CFG_FAILURE; |
| 338 | |
| 339 | // Send response message to host |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 340 | pMac->cfg.gParamList[WNI_CFG_DNLD_CNF_RES] = retVal; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 341 | cfgSendHostMsg(pMac, WNI_CFG_DNLD_CNF, WNI_CFG_DNLD_CNF_LEN, |
| 342 | WNI_CFG_DNLD_CNF_NUM, pMac->cfg.gParamList, 0, 0); |
| 343 | |
| 344 | // Notify WDA that the config has downloaded |
| 345 | mmhMsg.type = SIR_CFG_DOWNLOAD_COMPLETE_IND; |
| 346 | mmhMsg.bodyptr = NULL; |
| 347 | mmhMsg.bodyval = 0; |
| 348 | |
Jeff Johnson | e724574 | 2012-09-05 17:12:55 -0700 | [diff] [blame] | 349 | MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type)); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 350 | if (wdaPostCtrlMsg(pMac, &mmhMsg) != eSIR_SUCCESS) |
| 351 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 352 | PELOGE(cfgLog(pMac, LOGE, FL("WDAPostMsgApi failed!"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | } /*** end procDnldRsp() ***/ |
| 356 | |
| 357 | |
| 358 | /**--------------------------------------------------------------------- |
| 359 | * ProcGetReq() |
| 360 | * |
| 361 | * FUNCTION: |
| 362 | * This function processes CFG_GET_REQ message from host. |
| 363 | * |
| 364 | * LOGIC: |
| 365 | * |
| 366 | * ASSUMPTIONS: |
| 367 | * |
| 368 | * NOTE: |
| 369 | * For every parameter ID specified on the list, CFG will send a separate |
| 370 | * CFG_GET_RSP back to host. |
| 371 | * |
| 372 | * @param length: message length |
| 373 | * @param pParam: parameter list pointer |
| 374 | * |
| 375 | * @return None |
| 376 | * |
| 377 | */ |
| 378 | static void |
| 379 | ProcGetReq(tpAniSirGlobal pMac, tANI_U16 length, tANI_U32 *pParam) |
| 380 | { |
| 381 | tANI_U16 cfgId, i; |
| 382 | tANI_U32 value, valueLen, result; |
| 383 | tANI_U32 *pValue; |
| 384 | |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 385 | PELOG1(cfgLog(pMac, LOG1, FL("Rcvd cfg get request %d bytes"), length);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 386 | for (i=0; i<length/4; i++) |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 387 | PELOG2(cfgLog(pMac, LOG2, FL("[%2d] 0x%08x"), i, pParam[i]);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 388 | |
| 389 | if (!pMac->cfg.gCfgStatus) |
| 390 | { |
| 391 | cfgId = (tANI_U16)sirReadU32N((tANI_U8*)pParam); |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 392 | PELOGE(cfgLog(pMac, LOGE, FL("CFG not ready, param %d"), cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 393 | pMac->cfg.gParamList[WNI_CFG_GET_RSP_RES] = WNI_CFG_NOT_READY; |
| 394 | pMac->cfg.gParamList[WNI_CFG_GET_RSP_PID] = cfgId; |
| 395 | pMac->cfg.gParamList[WNI_CFG_GET_RSP_PLEN] = 0; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 396 | cfgSendHostMsg(pMac, WNI_CFG_GET_RSP, WNI_CFG_GET_RSP_PARTIAL_LEN, |
| 397 | WNI_CFG_GET_RSP_NUM, pMac->cfg.gParamList, 0, 0); |
| 398 | } |
| 399 | else |
| 400 | { |
| 401 | // Process all parameter ID's on the list |
| 402 | while (length >= sizeof(tANI_U32)) |
| 403 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 404 | cfgId = (tANI_U16)*pParam++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 405 | pValue = 0; |
| 406 | valueLen = 0; |
| 407 | |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 408 | PELOG1(cfgLog(pMac, LOG1, FL("Cfg get param %d"), cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 409 | |
| 410 | // Check for valid parameter ID, etc... |
| 411 | if (CheckParam(pMac, cfgId, CFG_CTL_RE, WNI_CFG_WO_PARAM, &result)) |
| 412 | { |
| 413 | if ((pMac->cfg.gCfgEntry[cfgId].control & CFG_CTL_INT) != 0) |
| 414 | { |
| 415 | // Get integer parameter |
| 416 | result = (wlan_cfgGetInt(pMac, cfgId, &value) == eSIR_SUCCESS ? |
| 417 | WNI_CFG_SUCCESS : WNI_CFG_OTHER_ERROR); |
| 418 | pValue = &value; |
| 419 | valueLen = sizeof(tANI_U32); |
| 420 | } |
| 421 | else |
| 422 | { |
| 423 | // Get string parameter |
| 424 | valueLen = sizeof(pMac->cfg.gSBuffer); |
| 425 | result = (wlan_cfgGetStr(pMac, cfgId, pMac->cfg.gSBuffer, &valueLen) |
| 426 | == eSIR_SUCCESS ? |
| 427 | WNI_CFG_SUCCESS : WNI_CFG_OTHER_ERROR); |
| 428 | pValue = (tANI_U32*)pMac->cfg.gSBuffer; |
| 429 | } |
| 430 | } |
| 431 | else |
| 432 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 433 | PELOGE(cfgLog(pMac, LOGE, FL("Check param failed, param %d"), cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 434 | result = WNI_CFG_INVALID_LEN; |
| 435 | } |
| 436 | |
| 437 | // Send response message to host |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 438 | pMac->cfg.gParamList[WNI_CFG_GET_RSP_RES] = result; |
| 439 | pMac->cfg.gParamList[WNI_CFG_GET_RSP_PID] = cfgId; |
| 440 | pMac->cfg.gParamList[WNI_CFG_GET_RSP_PLEN] = valueLen; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 441 | |
| 442 | // We need to round up buffer length to word-increment |
| 443 | valueLen = (((valueLen + 3) >> 2) << 2); |
| 444 | cfgSendHostMsg(pMac, WNI_CFG_GET_RSP, |
| 445 | WNI_CFG_GET_RSP_PARTIAL_LEN + valueLen, |
| 446 | WNI_CFG_GET_RSP_NUM, pMac->cfg.gParamList, valueLen, pValue); |
| 447 | |
| 448 | // Decrement length |
| 449 | length -= sizeof(tANI_U32); |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | } /*** end procGetReq() ***/ |
| 454 | |
| 455 | |
| 456 | |
| 457 | /**--------------------------------------------------------------------- |
| 458 | * ProcSetReqInternal() |
| 459 | * |
| 460 | * FUNCTION: |
| 461 | * This function processes CFG_SET_REQ message from host. |
| 462 | * |
| 463 | * LOGIC: |
| 464 | * |
| 465 | * ASSUMPTIONS: |
| 466 | * - The message content is coded in TLV format. |
| 467 | * - For string parameter, the length field is byte accurate. However, |
| 468 | * the next TLV set will begin on the next word boundary. |
| 469 | * |
| 470 | * NOTE: |
| 471 | * - For every parameter ID specified on the list, CFG will send a separate |
| 472 | * CFG_SET_RSP back to host. |
| 473 | * |
| 474 | * @param length: message length |
| 475 | * @param pParam: parameter list pointer |
| 476 | * @param fRsp: whether to send response to host. TRUE means sending. |
| 477 | * @return None |
| 478 | * |
| 479 | */ |
| 480 | static void |
| 481 | ProcSetReqInternal(tpAniSirGlobal pMac, tANI_U16 length, tANI_U32 *pParam, tANI_BOOLEAN fRsp) |
| 482 | { |
| 483 | tANI_U16 cfgId, valueLen, valueLenRoundedUp4; |
| 484 | tANI_U32 value, result; |
| 485 | |
Shake M Subhani | 5d80fda | 2013-12-09 17:28:23 +0530 | [diff] [blame^] | 486 | PELOG1(cfgLog(pMac, LOG1, FL("Rcvd cfg set request %d bytes"), length);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 487 | //for (i=0; i<length/4; i++) |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 488 | // PELOG2(cfgLog(pMac, LOG2, FL("[%2d] 0x%08x"), i, pParam[i]);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 489 | |
| 490 | if (!pMac->cfg.gCfgStatus) |
| 491 | { |
| 492 | cfgId = (tANI_U16)sirReadU32N((tANI_U8*)pParam); |
Shake M Subhani | 5d80fda | 2013-12-09 17:28:23 +0530 | [diff] [blame^] | 493 | PELOG1(cfgLog(pMac, LOGW, FL("CFG not ready, param %d"), cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 494 | pMac->cfg.gParamList[WNI_CFG_SET_CNF_RES] = WNI_CFG_NOT_READY; |
| 495 | pMac->cfg.gParamList[WNI_CFG_SET_CNF_PID] = cfgId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 496 | if( fRsp ) |
| 497 | { |
| 498 | cfgSendHostMsg(pMac, WNI_CFG_SET_CNF, WNI_CFG_SET_CNF_LEN, |
| 499 | WNI_CFG_SET_CNF_NUM, pMac->cfg.gParamList, 0, 0); |
| 500 | } |
| 501 | } |
| 502 | else |
| 503 | { |
| 504 | // Process all TLVs in buffer |
| 505 | while (length >= (sizeof(tANI_U32) * 2)) |
| 506 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 507 | cfgId = (tANI_U16) *pParam++; |
| 508 | valueLen = (tANI_U16) *pParam++; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 509 | length -= (sizeof(tANI_U32) * 2); |
| 510 | // value length rounded up to a 4 byte multiple |
| 511 | valueLenRoundedUp4 = (((valueLen + 3) >> 2) << 2); |
| 512 | |
| 513 | // Check for valid request before proceeding |
| 514 | if (CheckParam(pMac, cfgId, CFG_CTL_WE, WNI_CFG_RO_PARAM, &result)) |
| 515 | { |
| 516 | PELOG1(cfgLog(pMac, LOGW, (char *) gCfgParamName[cfgId]);) |
| 517 | // Process integer parameter |
| 518 | if ((pMac->cfg.gCfgEntry[cfgId].control & CFG_CTL_INT) != 0) |
| 519 | { |
| 520 | // Set VALUE |
| 521 | if (valueLen != sizeof(tANI_U32)) |
| 522 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 523 | PELOGE(cfgLog(pMac, LOGE, FL("Invalid value length %d in set param %d (tot %d)"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 524 | valueLen, cfgId, length);) |
| 525 | result = WNI_CFG_INVALID_LEN; |
| 526 | } |
| 527 | else |
| 528 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 529 | value = *pParam; |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 530 | PELOG1(cfgLog(pMac, LOGW, FL("Cfg set int %d len %d(%d) val %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 531 | cfgId, valueLen, valueLenRoundedUp4, value);) |
| 532 | result = (cfgSetInt(pMac, cfgId, value) == eSIR_SUCCESS ? |
| 533 | WNI_CFG_SUCCESS : WNI_CFG_OTHER_ERROR); |
| 534 | if (result == WNI_CFG_SUCCESS) |
| 535 | { |
| 536 | if (cfgNeedRestart(pMac, cfgId)) |
| 537 | { |
| 538 | result = WNI_CFG_NEED_RESTART ; |
| 539 | } |
| 540 | else |
| 541 | if (cfgNeedReload(pMac, cfgId)) |
| 542 | { |
| 543 | result = WNI_CFG_NEED_RELOAD ; |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | // Process string parameter |
| 549 | else |
| 550 | { |
| 551 | if (valueLenRoundedUp4 > length) |
| 552 | { |
Shake M Subhani | 5d80fda | 2013-12-09 17:28:23 +0530 | [diff] [blame^] | 553 | PELOGE(cfgLog(pMac, LOGE, FL("Invalid string length %d" |
| 554 | "in set param %d (tot %d)"), valueLen, |
| 555 | cfgId, length);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 556 | result = WNI_CFG_INVALID_LEN; |
| 557 | } |
| 558 | else |
| 559 | { |
| 560 | GetStrValue((tANI_U8*)pParam, pMac->cfg.gSBuffer, valueLen); |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 561 | PELOG1(cfgLog(pMac, LOGW, FL("Cfg set str %d len %d(%d) bytes"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 562 | cfgId, valueLen, valueLenRoundedUp4);) |
| 563 | result = (cfgSetStr(pMac, cfgId, pMac->cfg.gSBuffer, valueLen) == eSIR_SUCCESS ? |
| 564 | WNI_CFG_SUCCESS : WNI_CFG_OTHER_ERROR); |
| 565 | if (result == WNI_CFG_SUCCESS) |
| 566 | { |
| 567 | if (cfgNeedRestart(pMac, cfgId)) |
| 568 | { |
| 569 | result = WNI_CFG_NEED_RESTART ; |
| 570 | } |
| 571 | else |
| 572 | if (cfgNeedReload(pMac, cfgId)) |
| 573 | { |
| 574 | result = WNI_CFG_NEED_RELOAD ; |
| 575 | } |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | else |
| 581 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 582 | PELOGE(cfgLog(pMac, LOGE, FL("Check param failed, param %d"), cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 583 | result = WNI_CFG_INVALID_LEN; |
| 584 | } |
| 585 | |
| 586 | // Send confirm message to host |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 587 | pMac->cfg.gParamList[WNI_CFG_SET_CNF_RES] = result; |
| 588 | pMac->cfg.gParamList[WNI_CFG_SET_CNF_PID] = cfgId; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 589 | if( fRsp ) |
| 590 | { |
| 591 | cfgSendHostMsg(pMac, WNI_CFG_SET_CNF, WNI_CFG_SET_CNF_LEN, |
| 592 | WNI_CFG_SET_CNF_NUM, pMac->cfg.gParamList, 0, 0); |
| 593 | } |
| 594 | else |
| 595 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 596 | PELOGW(cfgLog( pMac, LOG2, " CFGID %d no rsp", cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | if (valueLenRoundedUp4 > length) |
| 600 | length = 0; |
| 601 | else |
| 602 | { |
| 603 | length -= valueLenRoundedUp4; |
| 604 | pParam += (valueLenRoundedUp4 >> 2); |
| 605 | } |
| 606 | } |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | |
| 611 | |
| 612 | static void |
| 613 | ProcSetReq(tpAniSirGlobal pMac, tANI_U16 length, tANI_U32 *pParam) |
| 614 | { |
| 615 | ProcSetReqInternal( pMac, length, pParam, eANI_BOOLEAN_TRUE ); |
| 616 | } |
| 617 | |
| 618 | static void |
| 619 | ProcSetReqNoRsp(tpAniSirGlobal pMac, tANI_U16 length, tANI_U32 *pParam) |
| 620 | { |
| 621 | ProcSetReqInternal( pMac, length, pParam, eANI_BOOLEAN_FALSE ); |
| 622 | } |
| 623 | |
| 624 | |
| 625 | |
| 626 | /**--------------------------------------------------------------------- |
| 627 | * CheckParam() |
| 628 | * |
| 629 | * FUNCTION: |
| 630 | * This function is called to perform various check on a parameter. |
| 631 | * |
| 632 | * LOGIC: |
| 633 | * - If cfgId is out of bound or parameter is not valid, result |
| 634 | * WNI_CFG_INVALID_PID is returned at address specified in pResult. |
| 635 | * |
| 636 | * - If specified 'flag' is not set in the parameter control entry, |
| 637 | * 'failedResult' is returned at address specified in pResult. |
| 638 | * |
| 639 | * ASSUMPTIONS: |
| 640 | * Since this function is used internally, 'pResult' is always valid. |
| 641 | * |
| 642 | * NOTE: |
| 643 | * |
| 644 | * @param None |
| 645 | * |
| 646 | * @return true: Parameter is valid and matches checked condition \n |
| 647 | * @return false: Parameter either is not valid or does not match |
| 648 | * checked condition. |
| 649 | * |
| 650 | */ |
| 651 | static tANI_U8 |
| 652 | CheckParam(tpAniSirGlobal pMac, tANI_U16 cfgId, tANI_U32 flag, tANI_U32 failedResult, tANI_U32 *pResult) |
| 653 | { |
| 654 | // Check if parameter ID is out of bound |
| 655 | if (cfgId >= CFG_PARAM_MAX_NUM) |
| 656 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 657 | PELOGE(cfgLog(pMac, LOGE, FL("Invalid param id %d"), cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 658 | *pResult = WNI_CFG_INVALID_PID; |
| 659 | } |
| 660 | else |
| 661 | { |
| 662 | // Check if parameter is valid |
| 663 | if ((pMac->cfg.gCfgEntry[cfgId].control & CFG_CTL_VALID) == 0) |
| 664 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 665 | PELOGE(cfgLog(pMac, LOGE, FL("Param id %d not valid"), cfgId);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 666 | *pResult = WNI_CFG_INVALID_PID; |
| 667 | } |
| 668 | else |
| 669 | { |
| 670 | // Check control field against flag |
| 671 | if ((pMac->cfg.gCfgEntry[cfgId].control & flag) == 0) |
| 672 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 673 | PELOGE(cfgLog(pMac, LOGE, FL("Param id %d wrong permissions %x"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 674 | cfgId, pMac->cfg.gCfgEntry[cfgId].control);) |
| 675 | *pResult = failedResult; |
| 676 | } |
| 677 | else |
| 678 | return(true); |
| 679 | } |
| 680 | } |
| 681 | return(false); |
| 682 | |
| 683 | } /*** cfgParamCheck() ***/ |
| 684 | |
| 685 | |
| 686 | /**--------------------------------------------------------------------- |
| 687 | * GetStrValue() |
| 688 | * |
| 689 | * FUNCTION: |
| 690 | * This function copies a string value from the specified buffer. |
| 691 | * |
| 692 | * LOGIC: |
| 693 | * |
| 694 | * ASSUMPTIONS: |
| 695 | * |
| 696 | * NOTE: |
| 697 | * |
| 698 | * @param pBuf: input data buffer |
| 699 | * @param pValue: address where data is returned |
| 700 | * @param length: number of bytes to copy |
| 701 | * |
| 702 | * @return None |
| 703 | * |
| 704 | */ |
| 705 | static void |
| 706 | GetStrValue(tANI_U8 *pBuf, tANI_U8 *pValue, tANI_U32 length) |
| 707 | { |
| 708 | tANI_U8 *pEnd; |
| 709 | |
| 710 | pEnd = pValue + length; |
| 711 | while (pValue < pEnd) |
| 712 | *pValue++ = *pBuf++; |
| 713 | } /*** end GetStrValue() ***/ |
| 714 | |
| 715 | |
| 716 | /**--------------------------------------------------------------------- |
| 717 | * processCfgDownloadReq() |
| 718 | * |
| 719 | * FUNCTION: This function does the Cfg Download and is invoked |
| 720 | * only in the case of Prima or the Integrated SOC |
| 721 | * solutions. Not applicable to Volans or Libra |
| 722 | * |
| 723 | * LOGIC: |
| 724 | * |
| 725 | * ASSUMPTIONS: |
| 726 | * |
| 727 | * NOTE: |
| 728 | * |
| 729 | * @param length: message length |
| 730 | * @param pConfig: parameter list pointer |
| 731 | * |
| 732 | * @return None |
| 733 | * |
| 734 | */ |
| 735 | |
| 736 | void |
| 737 | processCfgDownloadReq(tpAniSirGlobal pMac, tANI_U16 length, |
| 738 | tANI_U32 *pConfig) |
| 739 | { |
| 740 | tANI_S32 i; |
| 741 | |
| 742 | tANI_U32 expLen, retVal, bufStart, bufEnd; |
| 743 | tANI_U32 *pSrc, *pDst, *pDstEnd; |
| 744 | tANI_U32 strSize, j; |
| 745 | tANI_U8 pStr[CFG_MAX_STR_LEN]; |
| 746 | tpCfgBinHdr pHdr; |
| 747 | tANI_U32 logLevel; |
| 748 | |
| 749 | // First Dword must contain the AP or STA magic dword |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 750 | PELOGW(cfgLog(pMac, LOGW, FL("CFG size %d bytes MAGIC dword is 0x%x"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 751 | length, sirReadU32N((tANI_U8*)pConfig) );) |
| 752 | |
| 753 | // if the string is not correct, return failure |
| 754 | if (CFG_STA_MAGIC_DWORD != *pConfig) |
| 755 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 756 | PELOGE(cfgLog(pMac, LOGE, FL("Invalid magic dword 0x%x"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 757 | sirReadU32N((tANI_U8*)pConfig) );) |
| 758 | retVal = WNI_CFG_INVALID_LEN; |
| 759 | goto end; |
| 760 | } |
| 761 | |
| 762 | pConfig++; |
| 763 | length -= 4; |
| 764 | |
| 765 | // Verify message length |
| 766 | pMac->cfg.gCfgMaxIBufSize = CFG_STA_IBUF_MAX_SIZE; |
| 767 | pMac->cfg.gCfgMaxSBufSize = CFG_STA_SBUF_MAX_SIZE; |
| 768 | |
| 769 | // Parse the Cfg header |
| 770 | pHdr = (tpCfgBinHdr) pConfig; |
| 771 | pConfig += (sizeof(tCfgBinHdr) >> 2); |
| 772 | |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 773 | PELOGW(cfgLog(pMac, LOGW, FL("CFG hdr totParams %d intParams %d strBufSize %d/%d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 774 | pHdr->controlSize,pHdr->iBufSize, |
| 775 | pHdr->sBufSize, pMac->cfg.gCfgMaxSBufSize);) |
| 776 | |
| 777 | expLen = ((CFG_PARAM_MAX_NUM + 3 * pMac->cfg.gCfgMaxIBufSize) << 2) + |
| 778 | pHdr->sBufSize + sizeof(tCfgBinHdr); |
| 779 | |
| 780 | if (length != expLen) |
| 781 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 782 | PELOGE(cfgLog(pMac, LOGE, FL("<CFG> DNLD_RSP invalid length %d (exp %d)"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 783 | length, expLen);) |
| 784 | retVal = WNI_CFG_INVALID_LEN; |
| 785 | goto end; |
| 786 | } |
| 787 | |
| 788 | |
| 789 | if (CFG_PARAM_MAX_NUM != pHdr->controlSize ) |
| 790 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 791 | PELOGE(cfgLog(pMac, LOGE, FL("<CFG> Total parameter count mismatch"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 792 | retVal = WNI_CFG_INVALID_LEN; |
| 793 | goto end; |
| 794 | } |
| 795 | |
| 796 | if (pHdr->iBufSize != pMac->cfg.gCfgMaxIBufSize) |
| 797 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 798 | PELOGE(cfgLog(pMac, LOGE, FL("<CFG> Integer parameter count mismatch"));) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 799 | retVal = WNI_CFG_INVALID_LEN; |
| 800 | goto end; |
| 801 | } |
| 802 | |
| 803 | // Copy control array |
| 804 | pDst = (tANI_U32*)pMac->cfg.gCfgEntry; |
| 805 | pDstEnd = pDst + CFG_PARAM_MAX_NUM; |
| 806 | pSrc = pConfig; |
| 807 | while (pDst < pDstEnd) |
| 808 | { |
| 809 | *pDst++ = *pSrc++; |
| 810 | } |
| 811 | |
| 812 | // Copy default values |
| 813 | pDst = pMac->cfg.gCfgIBuf; |
| 814 | pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize; |
| 815 | while (pDst < pDstEnd) |
| 816 | { |
| 817 | *pDst++ = *pSrc++; |
| 818 | } |
| 819 | |
| 820 | // Copy min values |
| 821 | pDst = pMac->cfg.gCfgIBufMin; |
| 822 | pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize; |
| 823 | while (pDst < pDstEnd) |
| 824 | { |
| 825 | *pDst++ = *pSrc++; |
| 826 | } |
| 827 | |
| 828 | // Copy max values |
| 829 | pDst = pMac->cfg.gCfgIBufMax; |
| 830 | pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize; |
| 831 | while (pDst < pDstEnd) |
| 832 | { |
| 833 | *pDst++ = *pSrc++; |
| 834 | } |
| 835 | |
| 836 | for (i=0; i<pMac->cfg.gCfgMaxIBufSize; i++) |
| 837 | { |
| 838 | if (pMac->cfg.gCfgIBuf[i] < pMac->cfg.gCfgIBufMin[i] || |
| 839 | pMac->cfg.gCfgIBuf[i] > pMac->cfg.gCfgIBufMax[i]) |
| 840 | { |
| 841 | PELOGE(cfgLog(pMac, LOGE, FL("cfg id %d Invalid def value %d " |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 842 | "min %d max %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 843 | i, pMac->cfg.gCfgIBuf[i], pMac->cfg.gCfgIBufMin[i], |
| 844 | pMac->cfg.gCfgIBufMax[i]);) |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | // Calculate max string buffer lengths for all string parameters |
| 849 | bufEnd = pMac->cfg.gCfgMaxSBufSize; |
| 850 | for (i = CFG_PARAM_MAX_NUM - 1; i >= 0; i--) |
| 851 | { |
| 852 | if ((pMac->cfg.gCfgEntry[i].control & CFG_CTL_INT) != 0) |
| 853 | continue; |
| 854 | |
| 855 | if ((pMac->cfg.gCfgEntry[i].control & CFG_CTL_VALID) == 0) |
| 856 | continue; |
| 857 | |
| 858 | bufStart = pMac->cfg.gCfgEntry[i].control & CFG_BUF_INDX_MASK; |
| 859 | pMac->cfg.gCfgSBuf[bufStart] = (tANI_U8)(bufEnd - bufStart - 2); |
| 860 | |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 861 | PELOG1(cfgLog(pMac, LOG1, FL("id %d max %d bufStart %d bufEnd %d"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 862 | i, pMac->cfg.gCfgSBuf[bufStart], bufStart, bufEnd);) |
| 863 | |
| 864 | bufEnd = bufStart; |
| 865 | } |
| 866 | |
| 867 | // Initialize string defaults |
| 868 | strSize = pHdr->sBufSize; |
| 869 | while (strSize) |
| 870 | { |
| 871 | tANI_U32 paramId, paramLen, paramLenCeil4; |
| 872 | |
| 873 | if (strSize < 4) |
| 874 | { |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 875 | PELOGE(cfgLog(pMac, LOGE, FL("Error parsing str defaults, rem %d bytes"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 876 | strSize);) |
| 877 | retVal = WNI_CFG_INVALID_LEN; |
| 878 | goto end; |
| 879 | } |
| 880 | paramId = *pSrc >> 16; |
| 881 | paramLen = *pSrc & 0xff; |
| 882 | |
| 883 | pSrc++; |
| 884 | strSize -= 4; |
| 885 | |
| 886 | paramLenCeil4 = ((paramLen + 3) >> 2); |
| 887 | if (strSize < paramLenCeil4 << 2) |
| 888 | { |
| 889 | PELOGE(cfgLog(pMac, LOGE, FL("Error parsing str defaults, rem %d" |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 890 | "bytes"), strSize);) |
| 891 | PELOGE(cfgLog(pMac, LOGE, FL("param id %d len %d bytes"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 892 | paramId, paramLen);) |
| 893 | retVal = WNI_CFG_INVALID_LEN; |
| 894 | goto end; |
| 895 | } |
| 896 | |
| 897 | for (j=0; j < paramLenCeil4; j++) |
| 898 | { |
| 899 | pStr[4*j] = (tANI_U8) (*pSrc >> 24) & 0xff; |
| 900 | pStr[4*j+1] = (tANI_U8) (*pSrc >> 16) & 0xff; |
| 901 | pStr[4*j+2] = (tANI_U8) (*pSrc >> 8) & 0xff; |
| 902 | pStr[4*j+3] = (tANI_U8) (*pSrc) & 0xff; |
| 903 | |
| 904 | pSrc++; |
| 905 | strSize -= 4; |
| 906 | } |
| 907 | |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 908 | PELOG1(cfgLog(pMac, LOG1, FL("set str id %d len %d"), paramId, paramLen);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 909 | |
| 910 | if (cfgSetStrNotify(pMac, (tANI_U16)paramId, pStr, paramLen, FALSE) != eSIR_SUCCESS) |
| 911 | { |
| 912 | PELOGE(cfgLog(pMac, LOGE, FL("Error setting str default param %d " |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 913 | "len %d"), paramId, paramLen);) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 914 | retVal = WNI_CFG_INVALID_LEN; |
| 915 | goto end; |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | // Set the default log level based on config |
| 920 | wlan_cfgGetInt(pMac, WNI_CFG_LOG_LEVEL, &logLevel); |
| 921 | for (i = 0; i < LOG_ENTRY_NUM; i++) |
| 922 | pMac->utils.gLogEvtLevel[i] = pMac->utils.gLogDbgLevel[i] = logLevel; |
| 923 | |
| 924 | // Set status to READY |
| 925 | pMac->cfg.gCfgStatus = CFG_SUCCESS; |
| 926 | retVal = WNI_CFG_SUCCESS; |
Kiran Kumar Lokere | af882c8 | 2013-03-18 16:07:05 -0700 | [diff] [blame] | 927 | PELOG1(cfgLog(pMac, LOG1, "<CFG> Completed successfully");) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 928 | |
| 929 | end: |
| 930 | |
| 931 | if ( WNI_CFG_SUCCESS != retVal ) |
| 932 | pMac->cfg.gCfgStatus = CFG_FAILURE; |
| 933 | |
| 934 | pMac->cfg.gParamList[WNI_CFG_DNLD_CNF_RES] = retVal; |
| 935 | |
| 936 | } /*** end ProcessDownloadReq() ***/ |
| 937 | |
| 938 | |
| 939 | |
| 940 | |