1 /* 2 * CmdBldCmdIE.c 3 * 4 * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name Texas Instruments nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 35 /** \file CmdBldCmdIE.c 36 * \brief Command builder. Command information elements 37 * 38 * \see CmdBldCmdIE.h 39 */ 40 #define __FILE_ID__ FILE_ID_94 41 #include "osApi.h" 42 #include "tidef.h" 43 #include "report.h" 44 #include "TWDriver.h" 45 #include "CmdQueue_api.h" 46 #include "CmdBld.h" 47 48 49 /* Local Macros */ 50 51 #define MAC_TO_VENDOR_PREAMBLE(mac) ((mac[0] << 16) | (mac[1] << 8) | mac[2]) 52 53 /******************************************* 54 * Wlan hardware Test (BIT) 55 * ================= 56 * 57 * Tests description: 58 * ================== 59 * FCC = Continuous modulated transmission (should not emit carrier) 60 * TELEC = Continuous unmodulated carrier transmission (carrier only) 61 * PER_TX_STOP = Stops the TX test in progress (FCC or TELEC). 62 * ReadRegister = Read a register value. 63 * WriteRegister = Sets a register value. 64 * 65 * Rx PER test 66 * ======== 67 * PerRxStart = Start or resume the PER measurement. This function will put the device in promiscuous mode, and resume counters update. 68 * PerRxStop = Stop Rx PER measurements. This function stop counters update and make it is safe to read the PER test result. 69 * PerRxGetResults = Get the last Rx PER test results. 70 * PerRxClear = Clear the Rx PER test results. 71 */ 72 73 enum 74 { 75 /* 0 */ TEST_MOD_QPSK, 76 /* 1 */ TEST_MOD_CCK, 77 /* 2 */ TEST_MOD_PBCC, 78 TEST_MOD_NUMOF 79 }; 80 81 enum 82 { 83 /* 0 */ TEST_MOD_LONG_PREAMBLE, 84 /* 1 */ TEST_MOD_SHORT_PREAMBLE 85 }; 86 87 enum 88 { 89 /* 0 */ TEST_BAND_2_4GHZ, 90 /* 1 */ TEST_BAND_5GHZ, 91 /* 2 */ TEST_BAND_4_9GHZ 92 }; 93 94 95 enum 96 { 97 MOD_PBCC = 1, 98 MOD_CCK, 99 MOD_OFDM 100 }; 101 102 103 #define TEST_MOD_MIN_GAP 200 104 #define TEST_MOD_MIN_TX_BODYLEN 0 105 #define TEST_MOD_MAX_TX_BODYLEN 2304 106 107 #define TEST_RX_CAL_SAFE_TIME 5000 /*uSec*/ 108 109 #define TEST_MOD_IS_GAP_OK(gap) ((gap) >= TEST_MOD_MIN_GAP) 110 111 #define TEST_MOD_IS_TX_BODYLEN_OK(len) \ 112 (INRANGE((len), TEST_MOD_MIN_TX_BODYLEN, TEST_MOD_MAX_TX_BODYLEN) && \ 113 (((len) & 3) == 0) ) 114 115 #define TEST_MOD_IS_PREAMBLE_OK(p) \ 116 INRANGE((p), TEST_MOD_LONG_PREAMBLE, TEST_MOD_SHORT_PREAMBLE) 117 118 119 #define RESEARVED_SIZE_FOR_RESPONSE 4 120 121 122 /**************************************************************************** 123 * cmdBld_CmdIeStartBss() 124 **************************************************************************** 125 * DESCRIPTION: Construct the StartBss command fileds and send it to the mailbox 126 * 127 * INPUTS: None 128 * 129 * OUTPUT: None 130 * 131 * RETURNS: TI_OK or TI_NOK 132 ****************************************************************************/ 133 TI_STATUS cmdBld_CmdIeStartBss (TI_HANDLE hCmdBld, BSS_e BssType, void *fJoinCompleteCb, TI_HANDLE hCb) 134 { 135 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 136 StartJoinRequest_t AcxCmd_StartBss; 137 StartJoinRequest_t *pCmd = &AcxCmd_StartBss; 138 TSsid *pSsid = &DB_BSS(hCmdBld).tSsid; 139 TBssInfoParams *pBssInfoParams = &DB_BSS(hCmdBld); 140 TI_UINT8 *BssId; 141 TI_UINT8 *cmdBssId; 142 EHwRateBitFiled HwBasicRatesBitmap; 143 TI_UINT32 i; 144 145 os_memoryZero (pCmdBld->hOs, (void *)pCmd, sizeof(StartJoinRequest_t)); 146 147 /* 148 * Set RxCfg and RxFilterCfg values 149 */ 150 pCmd->rxFilter.ConfigOptions = ENDIAN_HANDLE_LONG (DB_WLAN(hCmdBld).RxConfigOption); 151 pCmd->rxFilter.FilterOptions = ENDIAN_HANDLE_LONG (DB_WLAN(hCmdBld).RxFilterOption); 152 pCmd->beaconInterval = ENDIAN_HANDLE_WORD (DB_BSS(hCmdBld).BeaconInterval); 153 pCmd->dtimInterval = DB_BSS(hCmdBld).DtimInterval; 154 pCmd->channelNumber = DB_BSS(hCmdBld).RadioChannel; 155 pCmd->bssType = BssType; 156 /* Add radio band */ 157 pCmd->bssType |= DB_WLAN(hCmdBld).RadioBand << 4; 158 /* Bits 0-2: Tx-Session-Count. bit 7: indicates if to flush the Tx queues */ 159 pCmd->ctrl = pBssInfoParams->Ctrl; 160 161 /* 162 * BasicRateSet 163 * The wlan hardware uses pHwMboxCmd field to determine the rate at which to transmit 164 * control frame responses (such as ACK or CTS frames) 165 */ 166 cmdBld_ConvertAppRatesBitmap (pBssInfoParams->BasicRateSet, 0, &HwBasicRatesBitmap); 167 pCmd->basicRateSet = ENDIAN_HANDLE_LONG(HwBasicRatesBitmap); 168 169 /* BSS ID - reversed order (see wlan hardware spec) */ 170 BssId = DB_BSS(hCmdBld).BssId; 171 cmdBssId = (TI_UINT8*)&pCmd->bssIdL; 172 for (i = 0; i < MAC_ADDR_LEN; i++) 173 cmdBssId[i] = BssId[MAC_ADDR_LEN - 1 - i]; 174 175 /* SSID string */ 176 pCmd->ssidLength = pSsid->len; 177 os_memoryCopy (pCmdBld->hOs, (void *)pCmd->ssidStr, (void *)pSsid->str, pSsid->len); 178 179 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 180 CMD_START_JOIN, 181 (TI_CHAR *)pCmd, 182 sizeof(*pCmd), 183 fJoinCompleteCb, 184 hCb, 185 NULL); 186 } 187 188 189 /**************************************************************************** 190 * cmdBld_CmdIeEnableRx() 191 **************************************************************************** 192 * DESCRIPTION: Construct the EnableRx command fileds and send it to the mailbox 193 * 194 * INPUTS: None 195 * 196 * OUTPUT: None 197 * 198 * RETURNS: TI_OK or TI_NOK 199 ****************************************************************************/ 200 TI_STATUS cmdBld_CmdIeEnableRx (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 201 { 202 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 203 TI_UINT8 aEnableRx_buf[4]; 204 205 aEnableRx_buf[0] = DB_DEFAULT_CHANNEL (hCmdBld); 206 aEnableRx_buf[1] = 0; /* padding */ 207 aEnableRx_buf[2] = 0; /* padding */ 208 aEnableRx_buf[3] = 0; /* padding */ 209 210 211 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 212 CMD_ENABLE_RX, 213 (TI_CHAR *)aEnableRx_buf, 214 sizeof(aEnableRx_buf), 215 fCb, 216 hCb, 217 NULL); 218 } 219 220 221 /**************************************************************************** 222 * cmdBld_CmdIeEnableTx() 223 **************************************************************************** 224 * DESCRIPTION: Construct the EnableTx command fileds and send it to the mailbox 225 * Note: This Enable_TX command is used also for changing the serving 226 * channel. 227 * 228 * INPUTS: None 229 * 230 * OUTPUT: None 231 * 232 * RETURNS: TI_OK or TI_NOK 233 ****************************************************************************/ 234 TI_STATUS cmdBld_CmdIeEnableTx (TI_HANDLE hCmdBld, TI_UINT8 channel, void *fCb, TI_HANDLE hCb) 235 { 236 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 237 TI_UINT8 aEnableTx_buf[4]; 238 239 aEnableTx_buf[0] = channel; 240 aEnableTx_buf[1] = 0; /* padding */ 241 aEnableTx_buf[2] = 0; /* padding */ 242 aEnableTx_buf[3] = 0; /* padding */ 243 244 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 245 CMD_ENABLE_TX, 246 (TI_CHAR *)aEnableTx_buf, 247 sizeof(aEnableTx_buf), 248 fCb, 249 hCb, 250 NULL); 251 } 252 253 254 /**************************************************************************** 255 * cmdBld_CmdIeDisableRx() 256 **************************************************************************** 257 * DESCRIPTION: Construct the DisableRx command fileds and send it to the mailbox 258 * 259 * INPUTS: None 260 * 261 * OUTPUT: None 262 * 263 * RETURNS: TI_OK or TI_NOK 264 ****************************************************************************/ 265 TI_STATUS cmdBld_CmdIeDisableRx (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 266 { 267 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 268 269 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_DISABLE_RX, NULL, 0, fCb, hCb, NULL); 270 } 271 272 /**************************************************************************** 273 * cmdBld_CmdIeDisableTx() 274 **************************************************************************** 275 * DESCRIPTION: Construct the DisableTx command fileds and send it to the mailbox 276 * 277 * INPUTS: None 278 * 279 * OUTPUT: None 280 * 281 * RETURNS: TI_OK or TI_NOK 282 ****************************************************************************/ 283 TI_STATUS cmdBld_CmdIeDisableTx (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 284 { 285 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 286 287 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_DISABLE_TX, NULL, 0, fCb, hCb, NULL); 288 } 289 290 /**************************************************************************** 291 * cmdBld_CmdIeConfigureTemplateFrame() 292 **************************************************************************** 293 * DESCRIPTION: Generic function which sets the Fw with a template frame according 294 * to the given template type. 295 * 296 * INPUTS: templateType - CMD_BEACON, CMD_PROBE_REQ, CMD_PROBE_RESP etc. 297 * 298 * OUTPUT: None 299 * 300 * RETURNS: TI_OK or TI_NOK 301 ****************************************************************************/ 302 TI_STATUS cmdBld_CmdIeConfigureTemplateFrame (TI_HANDLE hCmdBld, 303 TTemplateParams *pTemplate, 304 TI_UINT16 uFrameSize, 305 TemplateType_e eTemplateType, 306 TI_UINT8 uIndex, 307 void * fCb, 308 TI_HANDLE hCb) 309 { 310 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 311 PktTemplate_t AcxCmd_PktTemplate; 312 PktTemplate_t *pCmd = &AcxCmd_PktTemplate; 313 314 /* If the frame size is too big - we truncate the frame template */ 315 if (uFrameSize > MAX_TEMPLATES_SIZE) 316 { 317 EReportSeverity eReportSeverity = (pTemplate == NULL) ? REPORT_SEVERITY_WARNING : REPORT_SEVERITY_ERROR; 318 319 /* Report as error only if this is the actual template and not just a space holder */ 320 TRACE3(pCmdBld->hReport, eReportSeverity, "cmdBld_CmdIeConfigureTemplateFrame: Frame size (=%d) of CmdType (=%d) is bigger than MAX_TEMPLATES_SIZE(=%d) !!!\n", uFrameSize, eTemplateType, MAX_TEMPLATES_SIZE); 321 322 /* Truncate length to the template size limit */ 323 uFrameSize = MAX_TEMPLATES_SIZE; 324 } 325 /* WLAN_OS_REPORT(("DloadTempl type =%d size=%d\n", eTemplateType, uFrameSize)); */ 326 /* if pTemplate is NULL than it means that we just want to reserve place in Fw, and there is no need to copy */ 327 if (pTemplate != NULL) 328 { 329 os_memoryCopy(pCmdBld->hOs, (void *)&pCmd->templateStart, (void *)(pTemplate->Buffer), uFrameSize); 330 pCmd->templateTxAttribute.enabledRates = pTemplate->uRateMask; 331 } 332 pCmd->len = ENDIAN_HANDLE_WORD(uFrameSize); 333 pCmd->index = uIndex; 334 pCmd->templateType = eTemplateType; 335 pCmd->templateTxAttribute.shortRetryLimit = 10; 336 pCmd->templateTxAttribute.longRetryLimit = 10; 337 338 #ifdef TI_DBG 339 if (pCmdBld->uDbgTemplatesRateMask != 0) 340 { 341 pCmd->templateTxAttribute.enabledRates = pCmdBld->uDbgTemplatesRateMask; 342 } 343 #endif 344 345 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 346 CMD_SET_TEMPLATE, 347 (TI_CHAR *)pCmd, 348 sizeof (PktTemplate_t), 349 fCb, 350 hCb, 351 NULL); 352 } 353 354 355 /**************************************************************************** 356 * cmdBld_CmdIeSetKey() 357 **************************************************************************** 358 * DESCRIPTION: Construct the SetKey command fileds and send it to the mailbox 359 * 360 * INPUTS: 361 * Action - add/remove key 362 * MacAddr - relevant only for mapping keys 363 * KeySize - key size 364 * KeyType - default/mapping/TKIP 365 * KeyId - relevant only for default keys 366 * Key - key data 367 * 368 * OUTPUT: None 369 * 370 * RETURNS: TI_OK or TI_NOK 371 ****************************************************************************/ 372 TI_STATUS cmdBld_CmdIeSetKey (TI_HANDLE hCmdBld, 373 TI_UINT32 action, 374 TI_UINT8 *pMacAddr, 375 TI_UINT32 uKeySize, 376 TI_UINT32 uKeyType, 377 TI_UINT32 uKeyId, 378 TI_UINT8 *pKey, 379 TI_UINT32 uSecuritySeqNumLow, 380 TI_UINT32 uSecuritySeqNumHigh, 381 void *fCb, 382 TI_HANDLE hCb) 383 { 384 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 385 SetKey_t AcxCmd_SetKey; 386 SetKey_t *pCmd = &AcxCmd_SetKey; 387 388 os_memoryZero (pCmdBld->hOs, (void *)pCmd, sizeof(*pCmd)); 389 390 MAC_COPY (pCmd->addr, pMacAddr); 391 392 if (uKeySize > MAX_KEY_SIZE) 393 { 394 os_memoryCopy (pCmdBld->hOs, (void *)pCmd->key, (void *)pKey, MAX_KEY_SIZE); 395 } 396 else 397 { 398 os_memoryCopy (pCmdBld->hOs, (void *)pCmd->key, (void *)pKey, uKeySize); 399 } 400 401 pCmd->action = ENDIAN_HANDLE_WORD((TI_UINT16)action); 402 pCmd->keySize = (TI_UINT8)uKeySize; 403 pCmd->type = (TI_UINT8)uKeyType; 404 pCmd->id = (TI_UINT8)uKeyId; 405 pCmd->ssidProfile = 0; 406 407 /* 408 * Preserve TKIP/AES security sequence number after recovery. 409 * If not in reconfig set to 0 so the FW will ignore it and keep its own number. 410 * Note that our STA Tx is currently using only one sequence-counter 411 * for all ACs (unlike the Rx which is separated per AC). 412 */ 413 if (pCmdBld->bReconfigInProgress == TI_FALSE) 414 { 415 uSecuritySeqNumLow = uSecuritySeqNumHigh = 0; 416 } 417 pCmd->AcSeqNum16[0] = ENDIAN_HANDLE_WORD((TI_UINT16)uSecuritySeqNumLow); 418 pCmd->AcSeqNum16[1] = 0; 419 pCmd->AcSeqNum16[2] = 0; 420 pCmd->AcSeqNum16[3] = 0; 421 422 pCmd->AcSeqNum32[0] = ENDIAN_HANDLE_LONG(uSecuritySeqNumHigh); 423 pCmd->AcSeqNum32[1] = 0; 424 pCmd->AcSeqNum32[2] = 0; 425 pCmd->AcSeqNum32[3] = 0; 426 427 428 TRACE6(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "Addr: %02x:%02x:%02x:%02x:%02x:%02x\n", pCmd->addr[0],pCmd->addr[1],pCmd->addr[2],pCmd->addr[3],pCmd->addr[4],pCmd->addr[5]); 429 430 TRACE7(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "Action=%x,keySize=0x%x,type=%x, id=%x, ssidProfile=%x, AcSeqNum16[0]=%x, AcSeqNum32[0]=%x\n", pCmd->action,pCmd->keySize, pCmd->type,pCmd->id,pCmd->ssidProfile,pCmd->AcSeqNum16[0],pCmd->AcSeqNum32[0] ); 431 432 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_SET_KEYS, (char *)pCmd, sizeof(*pCmd), fCb, hCb, NULL); 433 } 434 435 436 /**************************************************************************** 437 * cmdBld_CmdIeStartScan () 438 **************************************************************************** 439 * DESCRIPTION: Send SCAN Command 440 * 441 * INPUTS: None 442 * 443 * OUTPUT: None 444 * 445 * RETURNS: TI_OK or TI_NOK 446 ****************************************************************************/ 447 TI_STATUS cmdBld_CmdIeStartScan (TI_HANDLE hCmdBld, ScanParameters_t* pScanParams, void *fScanResponseCb, TI_HANDLE hCb) 448 { 449 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 450 451 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 452 CMD_SCAN, 453 (TI_CHAR *)pScanParams, 454 sizeof(ScanParameters_t), 455 fScanResponseCb, 456 hCb, 457 NULL); 458 } 459 460 /**************************************************************************** 461 * cmdBld_CmdIeStartSPSScan () 462 **************************************************************************** 463 * DESCRIPTION: Send SPS SCAN Command 464 * 465 * INPUTS: None 466 * 467 * OUTPUT: None 468 * 469 * RETURNS: TI_OK or TI_NOK 470 ****************************************************************************/ 471 TI_STATUS cmdBld_CmdIeStartSPSScan (TI_HANDLE hCmdBld, ScheduledScanParameters_t* pScanParams, void* fScanResponseCb, TI_HANDLE hCb) 472 { 473 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 474 475 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 476 CMD_SPS_SCAN, 477 (TI_CHAR *)pScanParams, 478 sizeof(ScheduledScanParameters_t), 479 fScanResponseCb, 480 hCb, 481 NULL); 482 } 483 484 485 /**************************************************************************** 486 * cmdBld_CmdIeStopScan () 487 **************************************************************************** 488 * DESCRIPTION: Construct the STOP_SCAN command fields and send it to the 489 * mailbox 490 * 491 * INPUTS: None 492 * 493 * OUTPUT: None 494 * 495 * RETURNS: TI_OK or TI_NOK 496 ****************************************************************************/ 497 TI_STATUS cmdBld_CmdIeStopScan (TI_HANDLE hCmdBld, void *fScanResponseCb, TI_HANDLE hCb) 498 { 499 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 500 501 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_CmdIeStopScan: -------------- \n"); 502 503 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_STOP_SCAN, 0, 0, fScanResponseCb, hCb, NULL); 504 } 505 506 507 /**************************************************************************** 508 * cmdBld_CmdIeStopSPSScan () 509 **************************************************************************** 510 * DESCRIPTION: Construct the STOP_SPS_SCAN command fields and send it to the 511 * mailbox 512 * 513 * INPUTS: None 514 * 515 * OUTPUT: None 516 * 517 * RETURNS: TI_OK or TI_NOK 518 ****************************************************************************/ 519 TI_STATUS cmdBld_CmdIeStopSPSScan (TI_HANDLE hCmdBld, void* fScanResponseCB, TI_HANDLE hCb) 520 { 521 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 522 523 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_CmdIeStopSPSScan: -------------- \n"); 524 525 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_STOP_SPS_SCAN, 0, 0, fScanResponseCB, hCb, NULL); 526 } 527 528 529 TI_STATUS cmdBld_CmdIeSetSplitScanTimeOut (TI_HANDLE hCmdBld, TI_UINT32 uTimeOut, void *fCB, TI_HANDLE hCb) 530 { 531 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 532 enhancedTriggerTO_t Cmd_enhancedTrigger; 533 enhancedTriggerTO_t *pCmd = &Cmd_enhancedTrigger; 534 535 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_CmdIeSetSplitScanTimeOut: uTimeOut=%d -------------- \n", uTimeOut); 536 537 pCmd->slicedScanTimeOut = uTimeOut; 538 539 return cmdQueue_SendCommand(pCmdBld->hCmdQueue, CMD_TRIGGER_SCAN_TO, (char *)pCmd, sizeof(*pCmd), fCB, hCb, NULL); 540 } 541 542 /** 543 * \fn cmdBld_CmdIeScanSsidList 544 * \brief Sets SSID list for periodic scan 545 * 546 * Sets SSID list for periodic scan 547 * 548 * \param hCmdBld - handle to command builder object 549 * \param pSsidList - command data 550 * \param fScanResponseCB - command complete function callback 551 * \param hCb - command complete callback handle 552 * \return TI_OK on success, any other code on error 553 * \sa cmdBld_CmdIePeriodicScanParams, cmdBld_CmdIeStartPeriodicScan, cmdBld_CmdIeStopPeriodicScan 554 */ 555 TI_STATUS cmdBld_CmdIeScanSsidList (TI_HANDLE hCmdBld, ConnScanSSIDList_t *pSsidList, 556 void* fScanResponseCB, TI_HANDLE hCb) 557 { 558 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 559 560 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 561 CMD_CONNECTION_SCAN_SSID_CFG, 562 (char *)pSsidList, 563 sizeof(ConnScanSSIDList_t), 564 fScanResponseCB, 565 hCb, 566 NULL); 567 } 568 569 /** 570 * \fn cmdBld_CmdIePeriodicScanParams 571 * \brief Sets periodic scan parameters 572 * 573 * Sets periodic scan parameters 574 * 575 * \param hCmdBld - handle to command builder object 576 * \param pPeriodicScanParams - command data 577 * \param fScanResponseCB - command complete function callback 578 * \param hCb - command complete callback handle 579 * \return TI_OK on success, any other code on error 580 * \sa cmdBld_CmdIeScanSsidList, cmdBld_CmdIeStartPeriodicScan, cmdBld_CmdIeStopPeriodicScan 581 */ 582 TI_STATUS cmdBld_CmdIePeriodicScanParams (TI_HANDLE hCmdBld, ConnScanParameters_t *pPeriodicScanParams, 583 void* fScanResponseCB, TI_HANDLE hCb) 584 { 585 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 586 587 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 588 CMD_CONNECTION_SCAN_CFG, 589 (char *)pPeriodicScanParams, 590 sizeof(ConnScanParameters_t), 591 fScanResponseCB, 592 hCb, 593 NULL); 594 } 595 596 /** 597 * \fn cmdBld_CmdIeStartPeriodicScan 598 * \brief Starts a periodic scan operation 599 * 600 * Starts a periodic scan operation 601 * 602 * \param hCmdBld - handle to command builder object 603 * \param pPeriodicScanStart - command data 604 * \param fScanResponseCB - command complete function callback 605 * \param hCb - command complete callback handle 606 * \return TI_OK on success, any other code on error 607 * \sa cmdBld_CmdIeScanSsidList, cmdBld_CmdIePeriodicScanParams, cmdBld_CmdIeStopPeriodicScan 608 */ 609 TI_STATUS cmdBld_CmdIeStartPeriodicScan (TI_HANDLE hCmdBld, PeriodicScanTag* pPeriodicScanStart, 610 void* fScanResponseCB, TI_HANDLE hCb) 611 { 612 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 613 614 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 615 CMD_START_PERIODIC_SCAN, 616 pPeriodicScanStart, sizeof (PeriodicScanTag), 617 fScanResponseCB, 618 hCb, 619 NULL); 620 } 621 622 /** 623 * \fn cmdBld_CmdIeStopPeriodicScan 624 * \brief Stops an on-going periodic scan operation 625 * 626 * Stops an on-going periodic scan operation 627 * 628 * \param hCmdBld - handle to command builder object 629 * \param fScanResponseCB - command complete function callback 630 * \param hCb - command complete callback handle 631 * \return TI_OK on success, any other code on error 632 * \sa cmdBld_CmdIeScanSsidList, cmdBld_CmdIePeriodicScanParams, cmdBld_CmdIeStartPeriodicScan 633 */ 634 TI_STATUS cmdBld_CmdIeStopPeriodicScan (TI_HANDLE hCmdBld, 635 PeriodicScanTag* pPeriodicScanStop, 636 void* fScanResponseCB, 637 TI_HANDLE hCb) 638 { 639 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 640 641 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 642 CMD_STOP_PERIODIC_SCAN, 643 pPeriodicScanStop, 644 sizeof(pPeriodicScanStop), 645 fScanResponseCB, 646 hCb, 647 NULL); 648 } 649 650 /**************************************************************************** 651 * cmdBld_CmdIeNoiseHistogram () 652 **************************************************************************** 653 * DESCRIPTION: Send NOISE_HISTOGRAM Command 654 * 655 * INPUTS: None 656 * 657 * OUTPUT: None 658 * 659 * RETURNS: TI_OK or TI_NOK 660 ****************************************************************************/ 661 TI_STATUS cmdBld_CmdIeNoiseHistogram (TI_HANDLE hCmdBld, TNoiseHistogram *pNoiseHistParams, void *fCb, TI_HANDLE hCb) 662 { 663 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 664 NoiseHistRequest_t AcxCmd_NoiseHistogram; 665 NoiseHistRequest_t *pCmd = &AcxCmd_NoiseHistogram; 666 667 os_memoryZero(pCmdBld->hOs, (void *)pCmd, sizeof(*pCmd)); 668 669 pCmd->mode = ENDIAN_HANDLE_WORD((TI_UINT16)pNoiseHistParams->cmd); 670 pCmd->sampleIntervalUSec = ENDIAN_HANDLE_WORD(pNoiseHistParams->sampleInterval); 671 672 os_memoryCopy (pCmdBld->hOs, (void *)&(pCmd->thresholds[0]), (void *)&(pNoiseHistParams->ranges[0]), MEASUREMENT_NOISE_HISTOGRAM_NUM_OF_RANGES); 673 674 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_NOISE_HIST, (TI_CHAR *)pCmd, sizeof(*pCmd), fCb, hCb, NULL); 675 } 676 677 678 /**************************************************************************** 679 * cmdBld_CmdIeSetPsMode() 680 **************************************************************************** 681 * DESCRIPTION: send Command for Power Management configuration 682 * to the mailbox 683 * 684 * INPUTS: None 685 * 686 * OUTPUT: None 687 * 688 * RETURNS: TI_OK or TI_NOK 689 ****************************************************************************/ 690 TI_STATUS cmdBld_CmdIeSetPsMode (TI_HANDLE hCmdBld, TPowerSaveParams* powerSaveParams, void *fCb, TI_HANDLE hCb) 691 { 692 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 693 PSModeParameters_t Cmd_PowerMgmtCnf; 694 PSModeParameters_t * pCmd = &Cmd_PowerMgmtCnf; 695 696 os_memoryZero(pCmdBld->hOs, (void *)pCmd, sizeof(*pCmd)); 697 698 if (powerSaveParams->ps802_11Enable) 699 { 700 pCmd->mode = 1; 701 } 702 else 703 { 704 pCmd->mode = 0; 705 } 706 707 pCmd->hangOverPeriod = powerSaveParams->hangOverPeriod; 708 pCmd->needToSendNullData = powerSaveParams->needToSendNullData; 709 pCmd->rateToTransmitNullData = ENDIAN_HANDLE_LONG(powerSaveParams->NullPktRateModulation); 710 pCmd->numberOfRetries = powerSaveParams->numNullPktRetries; 711 712 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_SET_PS_MODE, (TI_CHAR *)pCmd, sizeof(*pCmd), fCb, hCb, NULL); 713 } 714 715 716 /**************************************************************************** 717 * cmdBld_CmdIeSwitchChannel () 718 **************************************************************************** 719 * DESCRIPTION: Send CMD_SWITCH_CHANNEL Command 720 * 721 * INPUTS: None 722 * 723 * OUTPUT: None 724 * 725 * RETURNS: TI_OK or TI_NOK 726 ****************************************************************************/ 727 TI_STATUS cmdBld_CmdIeSwitchChannel (TI_HANDLE hCmdBld, TSwitchChannelParams *pSwitchChannelCmd, void *fCb, TI_HANDLE hCb) 728 { 729 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 730 ChannelSwitchParameters_t AcxCmd_SwitchChannel; 731 ChannelSwitchParameters_t *pCmd = &AcxCmd_SwitchChannel; 732 733 os_memoryZero (pCmdBld->hOs, (void *)pCmd, sizeof(*pCmd)); 734 735 pCmd->channel = pSwitchChannelCmd->channelNumber; 736 pCmd->switchTime = pSwitchChannelCmd->switchTime; 737 pCmd->txSuspend = pSwitchChannelCmd->txFlag; 738 pCmd->flush = pSwitchChannelCmd->flush; 739 740 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_CHANNEL_SWITCH, (TI_CHAR *)pCmd, sizeof(*pCmd), fCb, hCb, NULL); 741 } 742 743 744 /**************************************************************************** 745 * cmdBld_CmdIeSwitchChannelCancel () 746 **************************************************************************** 747 * DESCRIPTION: Send CMD_SWITCH_CHANNEL_CANCEL Command 748 * 749 * INPUTS: None 750 * 751 * OUTPUT: None 752 * 753 * RETURNS: TI_OK or TI_NOK 754 ****************************************************************************/ 755 TI_STATUS cmdBld_CmdIeSwitchChannelCancel (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 756 { 757 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 758 759 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_STOP_CHANNEL_SWICTH, 0, 0, fCb, hCb, NULL); 760 } 761 762 763 /**************************************************************************** 764 * cmdBld_CmdIeFwDisconnect() 765 **************************************************************************** 766 * DESCRIPTION: Construct the Disconnect command fileds and send it to the mailbox 767 * 768 * INPUTS: None 769 * 770 * OUTPUT: None 771 * 772 * RETURNS: TI_OK or TI_NOK 773 ****************************************************************************/ 774 TI_STATUS cmdBld_CmdIeFwDisconnect (TI_HANDLE hCmdBld, TI_UINT32 uConfigOptions, TI_UINT32 uFilterOptions, DisconnectType_e uDisconType, TI_UINT16 uDisconReason, void *fCb, TI_HANDLE hCb) 775 { 776 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 777 DisconnectParameters_t AcxCmd_Disconnect; 778 779 AcxCmd_Disconnect.rxFilter.ConfigOptions = ENDIAN_HANDLE_LONG(uConfigOptions); 780 AcxCmd_Disconnect.rxFilter.FilterOptions = ENDIAN_HANDLE_LONG(uFilterOptions); 781 AcxCmd_Disconnect.disconnectReason = ENDIAN_HANDLE_LONG(uDisconReason); 782 AcxCmd_Disconnect.disconnectType = uDisconType; 783 784 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 785 CMD_DISCONNECT, 786 (void *)&AcxCmd_Disconnect, 787 sizeof(AcxCmd_Disconnect), 788 fCb, 789 hCb, 790 NULL); 791 } 792 793 794 /**************************************************************************** 795 * cmdBld_CmdIeMeasurement() 796 **************************************************************************** 797 * DESCRIPTION: send Command for measurement configuration 798 * to the mailbox 799 * 800 * INPUTS: None 801 * 802 * OUTPUT: None 803 * 804 * RETURNS: TI_OK or TI_NOK 805 ****************************************************************************/ 806 TI_STATUS cmdBld_CmdIeMeasurement (TI_HANDLE hCmdBld, 807 TMeasurementParams *pMeasurementParams, 808 void *fMeasureResponseCb, 809 TI_HANDLE hCb) 810 { 811 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 812 MeasurementParameters_t Cmd_MeasurementParam; 813 MeasurementParameters_t *pCmd = &Cmd_MeasurementParam; 814 815 os_memoryZero (pCmdBld->hOs, (void *)pCmd, sizeof(*pCmd)); 816 817 pCmd->band = pMeasurementParams->band; 818 pCmd->channel = pMeasurementParams->channel; 819 pCmd->duration = ENDIAN_HANDLE_LONG(pMeasurementParams->duration); 820 pCmd->rxFilter.ConfigOptions = ENDIAN_HANDLE_LONG(pMeasurementParams->ConfigOptions); 821 pCmd->rxFilter.FilterOptions = ENDIAN_HANDLE_LONG(pMeasurementParams->FilterOptions); 822 pCmd->scanTag = (TI_UINT8)pMeasurementParams->eTag; 823 824 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 825 CMD_MEASUREMENT, 826 (TI_CHAR *)pCmd, 827 sizeof(*pCmd), 828 fMeasureResponseCb, 829 hCb, 830 NULL); 831 } 832 833 834 /**************************************************************************** 835 * cmdBld_CmdIeMeasurementStop() 836 **************************************************************************** 837 * DESCRIPTION: send Command for stoping measurement 838 * 839 * INPUTS: None 840 * 841 * OUTPUT: None 842 * 843 * RETURNS: TI_OK or TI_NOK 844 ****************************************************************************/ 845 TI_STATUS cmdBld_CmdIeMeasurementStop (TI_HANDLE hCmdBld, void* fMeasureResponseCb, TI_HANDLE hCb) 846 { 847 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 848 849 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 850 CMD_STOP_MEASUREMENT, 851 0, 852 0, 853 fMeasureResponseCb, 854 hCb, 855 NULL); 856 } 857 858 859 /**************************************************************************** 860 * cmdBld_CmdIeApDiscovery() 861 **************************************************************************** 862 * DESCRIPTION: send Command for AP Discovery 863 * to the mailbox 864 * 865 * INPUTS: None 866 * 867 * OUTPUT: None 868 * 869 * RETURNS: TI_OK or TI_NOK 870 ****************************************************************************/ 871 TI_STATUS cmdBld_CmdIeApDiscovery (TI_HANDLE hCmdBld, TApDiscoveryParams *pApDiscoveryParams, void *fCb, TI_HANDLE hCb) 872 { 873 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 874 ApDiscoveryParameters_t Cmd_ApDiscovery; 875 ApDiscoveryParameters_t *pCmd = &Cmd_ApDiscovery; 876 877 os_memoryZero (pCmdBld->hOs, (void *)pCmd, sizeof(*pCmd)); 878 879 pCmd->txPowerAttenuation = pApDiscoveryParams->txPowerDbm; 880 pCmd->numOfProbRqst = pApDiscoveryParams->numOfProbRqst; 881 pCmd->scanDuration = ENDIAN_HANDLE_LONG(pApDiscoveryParams->scanDuration); 882 pCmd->scanOptions = ENDIAN_HANDLE_WORD(pApDiscoveryParams->scanOptions); 883 pCmd->txdRateSet = ENDIAN_HANDLE_LONG(pApDiscoveryParams->txdRateSet); 884 pCmd->rxFilter.ConfigOptions = ENDIAN_HANDLE_LONG(pApDiscoveryParams->ConfigOptions); 885 pCmd->rxFilter.FilterOptions = ENDIAN_HANDLE_LONG(pApDiscoveryParams->FilterOptions); 886 887 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 888 CMD_AP_DISCOVERY, 889 (void *)pCmd, 890 sizeof(*pCmd), 891 fCb, 892 hCb, 893 NULL); 894 } 895 896 897 /**************************************************************************** 898 * cmdBld_CmdIeApDiscoveryStop() 899 **************************************************************************** 900 * DESCRIPTION: send Command for stoping AP Discovery 901 * 902 * INPUTS: None 903 * 904 * OUTPUT: None 905 * 906 * RETURNS: TI_OK or TI_NOK 907 ****************************************************************************/ 908 TI_STATUS cmdBld_CmdIeApDiscoveryStop (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 909 { 910 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 911 912 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_STOP_AP_DISCOVERY, 0, 0, fCb, hCb, NULL); 913 } 914 915 916 /**************************************************************************** 917 * cmdBld_CmdIeHealthCheck() 918 **************************************************************************** 919 * DESCRIPTION: 920 * 921 * INPUTS: 922 * 923 * OUTPUT: 924 * 925 * RETURNS: 926 ****************************************************************************/ 927 TI_STATUS cmdBld_CmdIeHealthCheck (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 928 { 929 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 930 931 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, CMD_HEALTH_CHECK, NULL, 0, fCb, hCb, NULL); 932 } 933 934 /**************************************************************************** 935 * cmdBld_CmdIeSetStaState() 936 **************************************************************************** 937 * DESCRIPTION: Construct the Disconnect command fileds and send it to the mailbox 938 * 939 * INPUTS: None 940 * 941 * OUTPUT: None 942 * 943 * RETURNS: TI_OK or TI_NOK 944 ****************************************************************************/ 945 TI_STATUS cmdBld_CmdIeSetStaState (TI_HANDLE hCmdBld, TI_UINT8 staState, void *fCb, TI_HANDLE hCb) 946 { 947 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 948 SetStaState_t AcxCmd_SetStaState; 949 950 AcxCmd_SetStaState.staState = staState; 951 952 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 953 CMD_SET_STA_STATE, 954 (void *)&AcxCmd_SetStaState, 955 sizeof(AcxCmd_SetStaState), 956 fCb, 957 hCb, 958 NULL); 959 } 960 961 /**************************************************************************** 962 * cmdBld_BitIeTestCmd() 963 **************************************************************************** 964 * DESCRIPTION: 965 * INPUTS: None 966 * 967 * OUTPUT: None 968 * 969 * RETURNS: TI_OK or TI_NOK 970 ****************************************************************************/ 971 TI_STATUS cmdBld_CmdIeTest (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb, TTestCmd* pTestCmd) 972 { 973 TCmdBld *pCmdBld = (TI_HANDLE)hCmdBld; 974 TI_UINT32 paramLength; 975 TI_BOOL bIsCBfuncNecessary = TI_TRUE; 976 977 if (NULL == pTestCmd) 978 { 979 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_ERROR, " pTestCmd_Buf = NULL!!!\n"); 980 return TI_NOK; 981 } 982 983 if ( (TestCmdID_enum)pTestCmd->testCmdId < MAX_TEST_CMD_ID ) 984 { 985 bIsCBfuncNecessary = TI_TRUE; 986 } 987 else 988 { 989 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_WARNING, " Unsupported testCmdId (%d)\n", pTestCmd->testCmdId); 990 } 991 992 if (bIsCBfuncNecessary && fCb == NULL) 993 { 994 return TI_OK; 995 } 996 997 switch( pTestCmd->testCmdId ) 998 { 999 case TEST_CMD_PD_BUFFER_CAL: 1000 paramLength = sizeof(TTestCmdPdBufferCal); 1001 break; 1002 1003 case TEST_CMD_P2G_CAL: 1004 paramLength = sizeof(TTestCmdP2GCal); 1005 break; 1006 1007 case TEST_CMD_RX_STAT_GET: 1008 paramLength = sizeof(RadioRxStatistics); 1009 break; 1010 1011 /* packet */ 1012 case TEST_CMD_FCC: 1013 paramLength = sizeof(TPacketParam); 1014 break; 1015 1016 /* tone */ 1017 case TEST_CMD_TELEC: 1018 paramLength = sizeof(TToneParam); 1019 break; 1020 1021 case TEST_CMD_PLT_TEMPLATE: 1022 paramLength = sizeof(TTxTemplate); 1023 break; 1024 1025 /* channel tune */ 1026 case TEST_CMD_CHANNEL_TUNE: 1027 paramLength = sizeof(TTestCmdChannel); 1028 break; 1029 1030 case TEST_CMD_GET_FW_VERSIONS: 1031 paramLength = sizeof(TFWVerisons); 1032 break; 1033 1034 case TEST_CMD_INI_FILE_RADIO_PARAM: 1035 paramLength = sizeof(IniFileRadioParam); 1036 break; 1037 1038 case TEST_CMD_INI_FILE_GENERAL_PARAM: 1039 paramLength = sizeof(IniFileGeneralParam); 1040 break; 1041 1042 case TEST_CMD_PLT_GAIN_ADJUST: 1043 paramLength = sizeof(uint32); 1044 break; 1045 1046 case TEST_CMD_RUN_CALIBRATION_TYPE: 1047 paramLength = sizeof(TTestCmdRunCalibration); 1048 break; 1049 1050 case TEST_CMD_TX_GAIN_ADJUST: 1051 paramLength = sizeof(TTxGainAdjust); 1052 break; 1053 case TEST_CMD_TEST_TONE: 1054 paramLength = sizeof(TestToneParams_t); 1055 break; 1056 1057 case TEST_CMD_SET_EFUSE: 1058 paramLength = sizeof(EfuseParameters_t); 1059 break; 1060 case TEST_CMD_GET_EFUSE: 1061 paramLength = sizeof(EfuseParameters_t); 1062 break; 1063 1064 case TEST_CMD_RX_PLT_CAL: 1065 paramLength = sizeof(RadioRxPltCal); 1066 break; 1067 1068 case TEST_CMD_UPDATE_PD_REFERENCE_POINT: 1069 paramLength = sizeof(TTestCmdUpdateReferncePoint); 1070 break; 1071 1072 case TEST_CMD_UPDATE_PD_BUFFER_ERRORS: 1073 paramLength = sizeof(TTestCmdPdBufferErrors); 1074 break; 1075 1076 case TEST_CMD_POWER_MODE: 1077 paramLength = sizeof(TTestCmdPowerMode); 1078 break; 1079 1080 case TEST_CMD_STOP_TX: 1081 case TEST_CMD_RX_STAT_STOP: 1082 case TEST_CMD_RX_STAT_START: 1083 case TEST_CMD_RX_STAT_RESET: 1084 case TEST_CMD_RX_PLT_ENTER: 1085 case TEST_CMD_RX_PLT_EXIT: 1086 paramLength = 0; 1087 break; 1088 1089 default: 1090 paramLength = sizeof(pTestCmd->testCmd_u); 1091 } 1092 1093 return cmdQueue_SendCommand (pCmdBld->hCmdQueue, 1094 CMD_TEST, 1095 (void *)pTestCmd, 1096 paramLength + RESEARVED_SIZE_FOR_RESPONSE, 1097 fCb, 1098 hCb, 1099 (void*)pTestCmd); 1100 } 1101