1 /* 2 * CmdBldCmd.c 3 * 4 * Copyright(c) 1998 - 2009 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 CmdBldCmd.c 36 * \brief Command builder. Commands 37 * 38 * \see CmdBld.h 39 */ 40 41 #define __FILE_ID__ FILE_ID_93 42 #include "tidef.h" 43 #include "report.h" 44 #include "TWDriverInternal.h" 45 #include "CmdBld.h" 46 #include "CmdBldCmdIE.h" 47 #include "CmdBldCfgIE.h" 48 #include "CmdQueue_api.h" 49 #include "eventMbox_api.h" 50 51 52 /* 53 Rx filter field is mostly hard-coded. 54 This filter value basically pass only valid beacons / probe responses. For exact bit description, 55 consult either the DPG or the FPG (or both, and Yoel...) 56 */ 57 #define RX_FILTER_CFG_ (CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN | CFG_RX_RCTS_ACK | CFG_RX_CTL_EN) 58 #define RX_CONFIG_OPTION (CFG_RX_RAW | CFG_UNI_FILTER_EN | CFG_RX_INT_FCS_ERROR | CFG_RX_WR_RX_STATUS | CFG_RX_TIMESTAMP_TSF) 59 60 61 62 TI_STATUS cmdBld_CmdAddWepMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb); 63 TI_STATUS cmdBld_CmdRemoveWepMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb); 64 TI_UINT32 cmdBld_BuildPeriodicScanChannles (TPeriodicScanParams *pPeriodicScanParams, ConnScanChannelInfo_t *pChannelList, EScanType eScanType, ERadioBand eRadioBand, TI_UINT32 uPassiveScanDfsDwellTime); 65 66 67 /** 68 * \fn cmdBld_CmdStartScan 69 * \brief Build a start scan command and send it to the FW 70 * 71 * Build a start scan command and send it to the FW 72 * 73 * \param hCmdBld - handle to the command builder object 74 * \param pScanVals - scan parameters 75 * \param eScanTag - scan tag used for scan complete and result tracking 76 * \param fScanCommandResponseCB - command complete CB 77 * \param hCb - command complete CB 78 * \return command status (OK / NOK) 79 * \sa cmdBld_CmdStopScan 80 */ 81 TI_STATUS cmdBld_CmdStartScan (TI_HANDLE hCmdBld, TScanParams *pScanVals, EScanResultTag eScanTag, 82 TI_BOOL bHighPriority, void* ScanCommandResponseCB, TI_HANDLE hCb) 83 { 84 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 85 BasicScanChannelParameters_t* chanPtr; 86 ScanParameters_t tnetScanParams; 87 TI_UINT8* pBSSID; 88 TI_INT32 i; 89 90 91 /* Convert general scan data to tnet structure */ 92 tnetScanParams.basicScanParameters.tidTrigger = pScanVals->Tid; 93 tnetScanParams.basicScanParameters.numOfProbRqst = pScanVals->probeReqNumber; 94 tnetScanParams.basicScanParameters.ssidLength = pScanVals->desiredSsid.len; 95 os_memoryCopy (pCmdBld->hOs, 96 (void *)tnetScanParams.basicScanParameters.ssidStr, 97 (void *)pScanVals->desiredSsid.str, 98 tnetScanParams.basicScanParameters.ssidLength); 99 100 /* 101 scan options field is composed of scan type and band selection. 102 First, use the lookup table to convert the scan type 103 */ 104 105 tnetScanParams.basicScanParameters.scanOptions = 0; 106 107 switch ( pScanVals->scanType ) 108 { 109 case SCAN_TYPE_NORMAL_ACTIVE : 110 tnetScanParams.basicScanParameters.scanOptions = SCAN_ACTIVE; 111 break; 112 113 case SCAN_TYPE_NORMAL_PASSIVE : 114 tnetScanParams.basicScanParameters.scanOptions = SCAN_PASSIVE; 115 break; 116 117 case SCAN_TYPE_TRIGGERED_ACTIVE : 118 tnetScanParams.basicScanParameters.scanOptions = SCAN_ACTIVE | TRIGGERED_SCAN; 119 break; 120 121 case SCAN_TYPE_TRIGGERED_PASSIVE : 122 tnetScanParams.basicScanParameters.scanOptions = SCAN_PASSIVE | TRIGGERED_SCAN; 123 break; 124 125 default: 126 TRACE1( pCmdBld->hReport, REPORT_SEVERITY_ERROR, "Invalid scan type:%d\n", pScanVals->scanType); 127 return TI_NOK; 128 } 129 130 /* Add the band selection */ 131 if ( RADIO_BAND_5_0_GHZ == pScanVals->band ) 132 { 133 tnetScanParams.basicScanParameters.band = RADIO_BAND_5GHZ; 134 } 135 else 136 { 137 tnetScanParams.basicScanParameters.band = RADIO_BAND_2_4_GHZ; 138 } 139 140 /* Add high priority bit */ 141 if ( bHighPriority ) 142 { 143 tnetScanParams.basicScanParameters.scanOptions |= SCAN_PRIORITY_HIGH; 144 } 145 146 tnetScanParams.basicScanParameters.scanOptions = ENDIAN_HANDLE_WORD( tnetScanParams.basicScanParameters.scanOptions ); 147 148 /* important note: BSSID filter (0x0010) is DISABLED, because the FW sets it according 149 to BSSID value (broadcast does not filter, any other value will */ 150 tnetScanParams.basicScanParameters.rxCfg.ConfigOptions = ENDIAN_HANDLE_LONG(RX_CONFIG_OPTION) ; 151 tnetScanParams.basicScanParameters.rxCfg.FilterOptions = ENDIAN_HANDLE_LONG( RX_FILTER_CFG_ ); 152 153 /* If the SSID is not broadcast SSID, also filter according to SSID */ 154 if (pScanVals->desiredSsid.len != 0) 155 { 156 tnetScanParams.basicScanParameters.rxCfg.ConfigOptions |= 0x0400; 157 } 158 tnetScanParams.basicScanParameters.rxCfg.ConfigOptions = ENDIAN_HANDLE_LONG( tnetScanParams.basicScanParameters.rxCfg.ConfigOptions ); 159 160 /* Rate conversion is done in the HAL */ 161 cmdBld_ConvertAppRatesBitmap (pScanVals->probeRequestRate, 162 0, 163 &tnetScanParams.basicScanParameters.txdRateSet); 164 165 tnetScanParams.basicScanParameters.txdRateSet = ENDIAN_HANDLE_LONG( tnetScanParams.basicScanParameters.txdRateSet ); 166 tnetScanParams.basicScanParameters.numChannels = ENDIAN_HANDLE_WORD( pScanVals->numOfChannels ); 167 168 /* scan result tag */ 169 tnetScanParams.basicScanParameters.scanTag = eScanTag; 170 171 /* copy channel specific scan data to HAL structure */ 172 for ( i = 0; i < pScanVals->numOfChannels; i++ ) 173 { 174 TI_INT32 j; 175 TI_UINT8* macAddr; 176 177 macAddr = (TI_UINT8*)&tnetScanParams.basicScanChannelParameters[ i ].bssIdL; 178 179 /* copy the MAC address, upside down (CHIP structure) */ 180 for ( j = 0; j < MAC_ADDR_LEN; j++ ) 181 { 182 macAddr[ j ] = pScanVals->channelEntry[ i ].normalChannelEntry.bssId[ MAC_ADDR_LEN - 1 - j ]; 183 } 184 tnetScanParams.basicScanChannelParameters[ i ].scanMinDuration = 185 ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].normalChannelEntry.minChannelDwellTime ); 186 tnetScanParams.basicScanChannelParameters[ i ].scanMaxDuration = 187 ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].normalChannelEntry.maxChannelDwellTime ); 188 tnetScanParams.basicScanChannelParameters[ i ].ETCondCount = 189 pScanVals->channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes | 190 pScanVals->channelEntry[ i ].normalChannelEntry.earlyTerminationEvent; 191 tnetScanParams.basicScanChannelParameters[ i ].txPowerAttenuation = 192 pScanVals->channelEntry[ i ].normalChannelEntry.txPowerDbm; 193 tnetScanParams.basicScanChannelParameters[ i ].channel = 194 pScanVals->channelEntry[ i ].normalChannelEntry.channel; 195 } 196 197 TRACE7(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "RxCfg = 0x%x\n RxFilterCfg = 0x%x\n scanOptions = 0x%x\n numChannels = %d\n probeNumber = %d\n probeRateModulation = 0x%x\n tidTrigger = %d\n" , tnetScanParams.basicScanParameters.rxCfg.ConfigOptions, tnetScanParams.basicScanParameters.rxCfg.FilterOptions, tnetScanParams.basicScanParameters.scanOptions, tnetScanParams.basicScanParameters.numChannels, tnetScanParams.basicScanParameters.numOfProbRqst, tnetScanParams.basicScanParameters.txdRateSet, tnetScanParams.basicScanParameters.tidTrigger); 198 199 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Channel BSSID MinTime MaxTime ET TxPower probChan\n"); 200 201 for( i=0; i < pScanVals->numOfChannels; i++) 202 { 203 chanPtr = &tnetScanParams.basicScanChannelParameters[i]; 204 pBSSID = (TI_UINT8*)&chanPtr->bssIdL; 205 206 TRACE12(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "%06d %02x:%02x:%02x:%02x:%02x:%02x %05d %05d %02d %05d %05d\n",i, pBSSID[5],pBSSID[4],pBSSID[3],pBSSID[2],pBSSID[1],pBSSID[0], chanPtr->scanMinDuration, chanPtr->scanMaxDuration, chanPtr->ETCondCount, chanPtr->txPowerAttenuation, chanPtr->channel); 207 } 208 209 return cmdBld_CmdIeStartScan (hCmdBld, &tnetScanParams, ScanCommandResponseCB, hCb); 210 } 211 212 /** 213 * \fn cmdBld_CmdStartSPSScan 214 * \brief Build a start SPS scan command and send it to the FW 215 * 216 * Build a start SPS scan command and send it to the FW 217 * 218 * \param hCmdBld - handle to the command builder object 219 * \param pScanVals - scan parameters 220 * \param eScanTag - scan tag used for scan complete and result tracking 221 * \param fScanCommandResponseCB - command complete CB 222 * \param hCb - command complete CB 223 * \return command status (OK / NOK) 224 * \sa cmdBld_CmdStopSPSScan 225 */ 226 TI_STATUS cmdBld_CmdStartSPSScan (TI_HANDLE hCmdBld, TScanParams *pScanVals, EScanResultTag eScanTag, 227 void* fScanCommandResponseCB, TI_HANDLE hCb) 228 { 229 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 230 ScheduledScanParameters_t tnetSPSScanParams; 231 TI_INT32 i; 232 233 /* Convert general scan data to TNET structure */ 234 tnetSPSScanParams.scheduledGeneralParameters.scanOptions = SCAN_PASSIVE; 235 /* Add the band selection */ 236 if ( RADIO_BAND_5_0_GHZ == pScanVals->band ) 237 { 238 tnetSPSScanParams.scheduledGeneralParameters.band = RADIO_BAND_5GHZ; 239 } 240 else 241 { 242 tnetSPSScanParams.scheduledGeneralParameters.band = RADIO_BAND_2_4_GHZ; 243 } 244 245 246 tnetSPSScanParams.scheduledGeneralParameters.scanOptions = ENDIAN_HANDLE_WORD( tnetSPSScanParams.scheduledGeneralParameters.scanOptions ); 247 248 /* important note: BSSID filter (0x0010) is DISABLED, because the FW sets it according 249 to BSSID value (broadcast does not filter, any other value will */ 250 /* If the SSID is not broadcast SSID, also filter according to SSID */ 251 tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions = ENDIAN_HANDLE_LONG(RX_CONFIG_OPTION); 252 tnetSPSScanParams.scheduledGeneralParameters.rxCfg.FilterOptions = ENDIAN_HANDLE_LONG( RX_FILTER_CFG_ ); 253 tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions = ENDIAN_HANDLE_LONG( tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions ); 254 255 /* latest TSF value - used to discover TSF error (AP recovery) */ 256 tnetSPSScanParams.scheduledGeneralParameters.scanCmdTime_h = ENDIAN_HANDLE_LONG( INT64_HIGHER(pScanVals->latestTSFValue) ); 257 tnetSPSScanParams.scheduledGeneralParameters.scanCmdTime_l = ENDIAN_HANDLE_LONG( INT64_LOWER(pScanVals->latestTSFValue) ); 258 259 /* add scan tag */ 260 tnetSPSScanParams.scheduledGeneralParameters.scanTag = eScanTag; 261 262 tnetSPSScanParams.scheduledGeneralParameters.numChannels = pScanVals->numOfChannels; 263 264 /* copy channel specific scan data to HAL structure */ 265 for ( i = 0; i < pScanVals->numOfChannels; i++ ) 266 { 267 TI_INT32 j; 268 TI_UINT8* macAddr; 269 270 macAddr = (TI_UINT8*)&tnetSPSScanParams.scheduledChannelParameters[ i ].bssIdL; 271 272 /* copy the MAC address, upside down (CHIP structure) */ 273 for ( j = 0; j < MAC_ADDR_LEN; j++ ) 274 { 275 macAddr[ j ] = pScanVals->channelEntry[ i ].normalChannelEntry.bssId[ MAC_ADDR_LEN - 1 - j ]; 276 } 277 tnetSPSScanParams.scheduledChannelParameters[ i ].scanMaxDuration = 278 ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].SPSChannelEntry.scanDuration ); 279 tnetSPSScanParams.scheduledChannelParameters[ i ].scanStartTime = 280 ENDIAN_HANDLE_LONG( pScanVals->channelEntry[ i ].SPSChannelEntry.scanStartTime ); 281 tnetSPSScanParams.scheduledChannelParameters[ i ].ETCondCount = 282 pScanVals->channelEntry[ i ].SPSChannelEntry.ETMaxNumOfAPframes | 283 pScanVals->channelEntry[ i ].SPSChannelEntry.earlyTerminationEvent; 284 tnetSPSScanParams.scheduledChannelParameters[ i ].channel = 285 pScanVals->channelEntry[ i ].SPSChannelEntry.channel; 286 } 287 288 TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "RxCfg = 0x%x\n RxFilterCfg = 0x%x\n scanOptions = 0x%x\n numChannels = %d\n", tnetSPSScanParams.scheduledGeneralParameters.rxCfg.ConfigOptions, tnetSPSScanParams.scheduledGeneralParameters.rxCfg.FilterOptions, tnetSPSScanParams.scheduledGeneralParameters.scanOptions, tnetSPSScanParams.scheduledGeneralParameters.numChannels); 289 290 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Channel BSSID StartTime Duration ET probChan\n"); 291 292 #ifdef TI_DBG 293 for( i=0; i < tnetSPSScanParams.scheduledGeneralParameters.numChannels; i++) 294 { 295 ScheduledChannelParameters_t* chanPtr = &tnetSPSScanParams.scheduledChannelParameters[ i ]; 296 TI_UINT8* pBSSID = (TI_UINT8*)&chanPtr->bssIdL; 297 298 TRACE11(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "%6d %02x:%02x:%02x:%02x:%02x:%02x %5d %5d %2d %5d\n",i, pBSSID[5],pBSSID[4],pBSSID[3],pBSSID[2],pBSSID[1],pBSSID[0], chanPtr->scanStartTime, chanPtr->scanMaxDuration, chanPtr->ETCondCount, chanPtr->channel); 299 } 300 #endif /* TI_DBG */ 301 302 return cmdBld_CmdIeStartSPSScan (hCmdBld, &tnetSPSScanParams, fScanCommandResponseCB, hCb); 303 } 304 305 /** 306 * \fn cmdBld_CmdStopScan 307 * \brief Build a stop scan command and send it to FW 308 * 309 * Build a stop scan command and send it to FW 310 * 311 * \param hCmdBld - handle to the command builder object 312 * \param eScanTag - scan tag, used for scan complete and result tracking 313 * \return command status (OK / NOK) 314 * \sa cmdBld_CmdStartSPSScan 315 */ 316 TI_STATUS cmdBld_CmdStopScan (TI_HANDLE hCmdBld, EScanResultTag eScanTag, 317 void *fScanCommandResponseCB, TI_HANDLE hCb) 318 { 319 return cmdBld_CmdIeStopScan (hCmdBld, fScanCommandResponseCB, hCb); 320 } 321 322 323 /** 324 * \fn cmdBld_CmdStopSPSScan 325 * \brief Build a stop SPS scan command and send it to FW 326 * 327 * Build a stop SPS scan command and send it to FW 328 * 329 * \param hCmdBld - handle to the command builder object 330 * \param eScanTag - scan tag, used for scan complete and result tracking 331 * \return command status (OK / NOK) 332 * \sa cmdBld_CmdStartScan 333 */ TI_STATUS cmdBld_CmdStopSPSScan (TI_HANDLE hCmdBld, EScanResultTag eScanTag, 334 void* fScanCommandResponseCB, TI_HANDLE hCb) 335 { 336 return cmdBld_CmdIeStopSPSScan (hCmdBld, fScanCommandResponseCB, hCb); 337 } 338 339 TI_STATUS cmdBld_CmdSetSplitScanTimeOut (TI_HANDLE hCmdBld, TI_UINT32 uTimeOut) 340 { 341 DB_WLAN(hCmdBld).uSlicedScanTimeOut = uTimeOut; 342 343 return cmdBld_CmdIeSetSplitScanTimeOut (hCmdBld, uTimeOut, NULL, NULL); 344 } 345 346 /** 347 * \fn cmdBld_debugPrintPeriodicScanChannles 348 * \brief Print periodic scan channel list for debug purposes 349 * 350 * Print periodic scan channel list for debug purposes 351 * 352 * \param hCmdBld - handle to the command builder object 353 * \param pChannel - pointer to the channel list to print 354 * \param uChannelCount - number of channles to print 355 * \return None 356 * \sa cmdBld_debugPrintPeriodicScanParams 357 */ 358 void cmdBld_debugPrintPeriodicScanChannles (TI_HANDLE hCmdBld, ConnScanChannelInfo_t* pChannel, 359 TI_UINT32 uChannelCount) 360 { 361 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 362 TI_UINT32 uIndex; 363 364 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Index Channel MinTime MaxTime DFStime PowerLevel\n"); 365 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "-------------------------------------------------------------------\n"); 366 for (uIndex = 0; uIndex < uChannelCount; uIndex++) 367 { 368 TRACE6(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "%-10d %-10d %-10d %-10d %-10d %-11d\n", uIndex, pChannel[ uIndex ].channel, pChannel[ uIndex ].scanMinDuration, pChannel[ uIndex ].scanMaxDuration, pChannel[ uIndex ].passiveScanDuration, pChannel[ uIndex ].txPowerLevelDbm); 369 } 370 } 371 372 /** 373 * \fn cmdBld_debugPrintPeriodicScanParams 374 * \brief Print periodic scan parameters for debug purposes 375 * 376 * Print periodic scan parameters for debug purposes 377 * 378 * \param hCmdBld - handle to the command builder object 379 * \param pCommand - pointer to the periodic scan command to print 380 * \return None 381 * \sa cmdBld_debugPrintPeriodicScanChannles 382 */ 383 void cmdBld_debugPrintPeriodicScanParams (TI_HANDLE hCmdBld, ConnScanParameters_t* pCommand) 384 { 385 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 386 387 /* print periodic scan params command */ 388 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Cycle intervals:\n"); 389 TRACE8(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "0: %-6d %-6d %-6d %-6d %-6d %-6d %-6d %-6d\n", pCommand->cycleIntervals[ 0 ], pCommand->cycleIntervals[ 1 ], pCommand->cycleIntervals[ 2 ], pCommand->cycleIntervals[ 3 ], pCommand->cycleIntervals[ 4 ], pCommand->cycleIntervals[ 5 ], pCommand->cycleIntervals[ 6 ], pCommand->cycleIntervals[ 7 ]); 390 TRACE8(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "8: %-6d %-6d %-6d %-6d %-6d %-6d %-6d %-6d\n", pCommand->cycleIntervals[ 8 ], pCommand->cycleIntervals[ 9 ], pCommand->cycleIntervals[ 10 ], pCommand->cycleIntervals[ 11 ], pCommand->cycleIntervals[ 12 ], pCommand->cycleIntervals[ 13 ], pCommand->cycleIntervals[ 14 ], pCommand->cycleIntervals[ 15 ]); 391 TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "RSSI threshold: %d, SNR threshold: %d, number of cycles: %d, reporth threshold: %d\n", pCommand->rssiThreshold, pCommand->snrThreshold, pCommand->maxNumOfCycles, pCommand->reportThreshold); 392 TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Terminate on report: %d, result tag: %d, BSS type: %d, number of probe requests: %d\n", pCommand->terminateOnReport, pCommand->resultsTag, pCommand->bssType, pCommand->numProbe); 393 TRACE2(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "SSID filter type: %d, SSID length: %d, SSID: \n", pCommand->ssidFilterType, pCommand->ssidLength); 394 /* print channel info */ 395 396 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "2.4 GHz Channels:\n"); 397 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "-----------------\n"); 398 TRACE2(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Number of passive channels: %d, number of active channels: %d\n", pCommand->numOfPassive[ 0 ], pCommand->numOfActive[ 0 ]); 399 cmdBld_debugPrintPeriodicScanChannles (hCmdBld, &(pCommand->channelList[ 0 ]), 400 pCommand->numOfPassive[ 0 ] + 401 pCommand->numOfActive[ 0 ]); 402 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "5.0 GHz Channels:\n"); 403 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "-----------------\n"); 404 TRACE3(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Number of passive channels: %d, number of DFS channels: %d, number of active channels: %d\n", pCommand->numOfPassive[ 1 ], pCommand->numOfDfs, pCommand->numOfActive[ 2 ]); 405 cmdBld_debugPrintPeriodicScanChannles (hCmdBld, &(pCommand->channelList[ CONN_SCAN_MAX_CHANNELS_BG ]), 406 pCommand->numOfPassive[ 1 ] + 407 pCommand->numOfActive[ 1 ] + 408 pCommand->numOfDfs); 409 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "4.9 GHz channles:\n"); 410 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "-----------------\n"); 411 TRACE2(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Number of passive channels: %d, number of active channels: %d\n", pCommand->numOfPassive[ 2 ], pCommand->numOfActive[ 2 ]); 412 cmdBld_debugPrintPeriodicScanChannles (hCmdBld, &(pCommand->channelList[ CONN_SCAN_MAX_CHANNELS_BG + CONN_SCAN_MAX_CHANNELS_A ]), 413 pCommand->numOfPassive[ 2 ] + 414 pCommand->numOfActive[ 2 ]); 415 } 416 417 /** 418 * \fn cmdBld_debugPrintPeriodicScanSsidList 419 * \brief Print periodic scan SSID list for debug purposes 420 * 421 * Print periodic scan SSID list for debug purposes 422 * 423 * \param hCmdBld - handle to the command builder object 424 * \param pCommand - pointer to the periodic scan SSID list command to print 425 * \return None 426 * \sa cmdBld_debugPrintPeriodicScanParams 427 */ 428 void cmdBld_debugPrintPeriodicScanSsidList (TI_HANDLE hCmdBld, ConnScanSSIDList_t* pCommand) 429 { 430 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 431 TI_UINT32 uIndex; 432 433 /* print SSID list command */ 434 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "SSID list:\n"); 435 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "---------\n"); 436 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Num of entries: %d\n", pCommand->numOfSSIDEntries); 437 for (uIndex = 0; uIndex < pCommand->numOfSSIDEntries; uIndex++) 438 { 439 TRACE3(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "index: %d, SSID type: %d, SSID length:% d, SSID string:\n", uIndex, pCommand->SSIDList[ uIndex ].ssidType, pCommand->SSIDList[ uIndex ].ssidLength); 440 } 441 442 } 443 444 /** 445 * \fn cmdBld_BuildPeriodicScanChannlesn 446 * \brief Copy channels info for periodic scan to FW structure for a specific band and scan type 447 * 448 * Copy channels info, from driver structure, to FW structure, for periodic scan, for a specific 449 * band and scan type. 450 * 451 * \param pPeriodicScanParams - driver priodic scan parameters (source) 452 * \param pChannelList - FW scan channel list (destination) 453 * \param eScanType - scan type (passive or active) 454 * \param eRadioBand - band (G, A or J) 455 * \param uPassiveScanDfsDwellTime - Dwell time for passive scan on DFS channels (in milli-secs) 456 * \return Number of channels found for this scan type and band 457 * \sa cmdBld_StartPeriodicScan 458 */ 459 TI_UINT32 cmdBld_BuildPeriodicScanChannles (TPeriodicScanParams *pPeriodicScanParams, 460 ConnScanChannelInfo_t *pChannelList, 461 EScanType eScanType, ERadioBand eRadioBand, 462 TI_UINT32 uPassiveScanDfsDwellTime) 463 { 464 TI_UINT32 uIndex, uNumChannels = 0; 465 466 /* check all channels */ 467 for (uIndex = 0; uIndex < pPeriodicScanParams->uChannelNum; uIndex++) 468 { 469 /* if this channel is on the required band and uses the required scan type */ 470 if ((eRadioBand == pPeriodicScanParams->tChannels[ uIndex ].eBand) && 471 (eScanType == pPeriodicScanParams->tChannels[ uIndex ].eScanType)) 472 { 473 /* update scan parameters */ 474 pChannelList[ uNumChannels ].channel = (TI_UINT8)pPeriodicScanParams->tChannels[ uIndex ].uChannel; 475 pChannelList[ uNumChannels ].passiveScanDuration = ENDIAN_HANDLE_WORD ((TI_UINT16)uPassiveScanDfsDwellTime); 476 pChannelList[ uNumChannels ].scanMaxDuration = 477 ENDIAN_HANDLE_WORD ((TI_UINT16)pPeriodicScanParams->tChannels[ uIndex ].uMaxDwellTimeMs); 478 pChannelList[ uNumChannels ].scanMinDuration = 479 ENDIAN_HANDLE_WORD ((TI_UINT16)pPeriodicScanParams->tChannels[ uIndex ].uMinDwellTimeMs); 480 pChannelList[ uNumChannels ].txPowerLevelDbm = (TI_UINT8)pPeriodicScanParams->tChannels[ uIndex ].uTxPowerLevelDbm; 481 if (SCAN_TYPE_PACTSIVE == eScanType) /* DFS channel */ 482 { 483 pChannelList[ uNumChannels ].passiveScanDuration = ENDIAN_HANDLE_WORD ((TI_UINT16)uPassiveScanDfsDwellTime); 484 pChannelList[ uNumChannels ].channelFlags = 1; /* mark as DFS channel */ 485 } 486 else 487 { 488 pChannelList[ uNumChannels ].channelFlags = 0; /* mark as not DFS channel */ 489 } 490 491 /* advance mathcing channel counter */ 492 uNumChannels++; 493 } 494 } 495 496 /* return channel count */ 497 return uNumChannels; 498 } 499 500 /** 501 * \fn cmdBld_StartPeriodicScan 502 * \brief Copy driver periodic scan parameters to FW structures and send all commands to FW 503 * 504 * Copy driver periodic scan parameters to FW structures (SSID list, parameters including channels 505 * and start command) and send all commands to FW. 506 * 507 * \param hCmdBld - handle to the command builder object 508 * \param pPeriodicScanParams - periodic scan driver parameters (source) 509 * \param eScanTag - scan tag, used for scan complete and result tracking 510 * \param uPassiveScanDfsDwellTimeUs - Passive dwell time for DFS channels 511 * \param fScanCommandResponseCB - scan command complete CB 512 * \param hCb - scan command response handle 513 * \return TI_OK on success, other codes indicate failure 514 * \sa cmdBld_BuildPeriodicScanChannles, cmdBld_StopPeriodicScan 515 */ 516 TI_STATUS cmdBld_StartPeriodicScan (TI_HANDLE hCmdBld, TPeriodicScanParams *pPeriodicScanParams, 517 EScanResultTag eScanTag, TI_UINT32 uPassiveScanDfsDwellTimeMs, 518 void* fScanCommandResponseCB, TI_HANDLE hCb) 519 { 520 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 521 ConnScanParameters_t tFWPeriodicScanParams; 522 ConnScanSSIDList_t *pFWSsidList; 523 PeriodicScanTag tScanStart; 524 TI_UINT32 uIndex; 525 TI_STATUS tStatus; 526 527 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Building start periodic scan commands:\n"); 528 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "--------------------------------------\n"); 529 /* copy parameters to FW structure */ 530 tFWPeriodicScanParams.bssType = (ScanBssType_e)pPeriodicScanParams->eBssType; 531 for (uIndex = 0; uIndex < PERIODIC_SCAN_MAX_INTERVAL_NUM; uIndex ++) 532 { 533 tFWPeriodicScanParams.cycleIntervals[ uIndex ] = 534 ENDIAN_HANDLE_LONG (pPeriodicScanParams->uCycleIntervalMsec[ uIndex ]); 535 } 536 tFWPeriodicScanParams.maxNumOfCycles = (TI_UINT8)pPeriodicScanParams->uCycleNum; 537 tFWPeriodicScanParams.numProbe = (TI_UINT8)pPeriodicScanParams->uProbeRequestNum; 538 tFWPeriodicScanParams.reportThreshold = (TI_UINT8)pPeriodicScanParams->uFrameCountReportThreshold; 539 tFWPeriodicScanParams.rssiThreshold = (TI_UINT8)pPeriodicScanParams->iRssiThreshold; 540 tFWPeriodicScanParams.snrThreshold = (TI_INT8)pPeriodicScanParams->iSnrThreshold; 541 tFWPeriodicScanParams.terminateOnReport = (TI_UINT8)pPeriodicScanParams->bTerminateOnReport; 542 tFWPeriodicScanParams.resultsTag = (TI_UINT8)eScanTag; 543 switch (pPeriodicScanParams->uSsidNum) 544 { 545 case 0: /* No SSIDs defined - no need to filter according to SSID */ 546 tFWPeriodicScanParams.ssidFilterType = (ScanSsidFilterType_e)SCAN_SSID_FILTER_TYPE_ANY; 547 tFWPeriodicScanParams.ssidLength = 0; 548 break; 549 550 default: /* More than one SSID - copy SSIDs to SSID list command */ 551 pFWSsidList = os_memoryAlloc(pCmdBld->hOs, sizeof(ConnScanSSIDList_t)); 552 if (!pFWSsidList) 553 return TI_NOK; 554 555 if ((TI_UINT8)pPeriodicScanParams->uSsidListFilterEnabled == 1) 556 tFWPeriodicScanParams.ssidFilterType = (ScanSsidFilterType_e)SCAN_SSID_FILTER_TYPE_LIST; 557 else 558 tFWPeriodicScanParams.ssidFilterType = (ScanSsidFilterType_e)SCAN_SSID_FILTER_TYPE_LIST_FILTER_DISABLED; 559 tFWPeriodicScanParams.ssidLength = 0; 560 pFWSsidList->numOfSSIDEntries = (TI_UINT8)pPeriodicScanParams->uSsidNum; 561 for (uIndex = 0; uIndex < pPeriodicScanParams->uSsidNum; uIndex++) 562 { 563 pFWSsidList->SSIDList[ uIndex ].ssidType = 564 (TI_UINT8)pPeriodicScanParams->tDesiredSsid[ uIndex ].eVisability; 565 pFWSsidList->SSIDList[ uIndex ].ssidLength = 566 (TI_UINT8)pPeriodicScanParams->tDesiredSsid[ uIndex ].tSsid.len; 567 os_memoryCopy (pCmdBld->hOs, (void*)&(pFWSsidList->SSIDList[ uIndex ].ssid[ 0 ]), 568 (void*)&(pPeriodicScanParams->tDesiredSsid[ uIndex ].tSsid.str[ 0 ]), 569 pFWSsidList->SSIDList[ uIndex ].ssidLength); 570 } 571 572 /* print the SSID list parameters */ 573 cmdBld_debugPrintPeriodicScanSsidList (hCmdBld, pFWSsidList); 574 575 /* send the SSID list command */ 576 tStatus = cmdBld_CmdIeScanSsidList (hCmdBld, pFWSsidList, NULL, NULL); 577 os_memoryFree(pCmdBld->hOs, pFWSsidList, sizeof(ConnScanSSIDList_t)); 578 if (TI_OK != tStatus) 579 { 580 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_ERROR , "cmdBld_StartPeriodicScan: status %d when configuring SSID list", tStatus); 581 return tStatus; 582 } 583 break; 584 } 585 586 /* copy channels */ 587 tFWPeriodicScanParams.numOfPassive[ 0 ] = /* build passive B/G channels */ 588 cmdBld_BuildPeriodicScanChannles (pPeriodicScanParams, &(tFWPeriodicScanParams.channelList[ 0 ]), 589 SCAN_TYPE_NORMAL_PASSIVE, RADIO_BAND_2_4_GHZ, uPassiveScanDfsDwellTimeMs); 590 tFWPeriodicScanParams.numOfActive[ 0 ] = /* build active B/G channels */ 591 cmdBld_BuildPeriodicScanChannles (pPeriodicScanParams, &(tFWPeriodicScanParams.channelList[ tFWPeriodicScanParams.numOfPassive[ 0 ] ]), 592 SCAN_TYPE_NORMAL_ACTIVE, RADIO_BAND_2_4_GHZ, uPassiveScanDfsDwellTimeMs); 593 tFWPeriodicScanParams.numOfPassive[ 1 ] = /* build passive A channels */ 594 cmdBld_BuildPeriodicScanChannles (pPeriodicScanParams, &(tFWPeriodicScanParams.channelList[ CONN_SCAN_MAX_CHANNELS_BG ]), 595 SCAN_TYPE_NORMAL_PASSIVE, RADIO_BAND_5_0_GHZ, uPassiveScanDfsDwellTimeMs); 596 tFWPeriodicScanParams.numOfDfs = /* build DFS A channels */ 597 cmdBld_BuildPeriodicScanChannles (pPeriodicScanParams, &(tFWPeriodicScanParams.channelList[ CONN_SCAN_MAX_CHANNELS_BG + tFWPeriodicScanParams.numOfPassive[ 1 ] ]), 598 SCAN_TYPE_PACTSIVE, RADIO_BAND_5_0_GHZ, uPassiveScanDfsDwellTimeMs); 599 tFWPeriodicScanParams.numOfActive[ 1 ] = /* build active A channels */ 600 cmdBld_BuildPeriodicScanChannles (pPeriodicScanParams, &(tFWPeriodicScanParams.channelList[ CONN_SCAN_MAX_CHANNELS_BG + tFWPeriodicScanParams.numOfPassive[ 1 ] + tFWPeriodicScanParams.numOfDfs ]), 601 SCAN_TYPE_NORMAL_ACTIVE, RADIO_BAND_5_0_GHZ, uPassiveScanDfsDwellTimeMs); 602 603 /* until J is supported, mark zero channels for J passive and active */ 604 tFWPeriodicScanParams.numOfPassive[ 2 ] = 0; 605 tFWPeriodicScanParams.numOfActive[ 2 ] = 0; 606 607 /* print the command */ 608 cmdBld_debugPrintPeriodicScanParams (hCmdBld, &tFWPeriodicScanParams); 609 610 /* Send the periodic scan parameters command */ 611 tStatus = cmdBld_CmdIePeriodicScanParams (hCmdBld, &tFWPeriodicScanParams, NULL, NULL); 612 if (TI_OK != tStatus) 613 { 614 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_ERROR , "cmdBld_StartPeriodicScan: status %d when configuring periodic scan parameters", tStatus); 615 return tStatus; 616 } 617 618 /* send the periodic scan start command */ 619 tScanStart.scanTag = eScanTag; 620 tStatus = cmdBld_CmdIeStartPeriodicScan (hCmdBld, &tScanStart, fScanCommandResponseCB, hCb); 621 return tStatus; 622 } 623 624 /** 625 * \fn cmdBld_StopPeriodicScan 626 * \brief Stops an on-going periodic scan operation 627 * 628 * Stops an on-going periodic scan operation 629 * 630 * \param hCmdBld - handle to the command builder object 631 * \param eScanTag - scan tag, used for scan complete and result tracking 632 * \param fScanCommandResponseCB - scan command complete CB 633 * \param hCb - scan command response handle 634 * \return TI_OK on success, other codes indicate failure 635 * \sa cmdBld_BuildPeriodicScanChannles, cmdBld_StartPeriodicScan 636 */ 637 TI_STATUS cmdBld_StopPeriodicScan (TI_HANDLE hCmdBld, EScanResultTag eScanTag, 638 void* fScanCommandResponseCB, TI_HANDLE hCb) 639 { 640 PeriodicScanTag tScanStop; 641 642 /* send the periodic scan stop command */ 643 tScanStop.scanTag = eScanTag; 644 return cmdBld_CmdIeStopPeriodicScan (hCmdBld, &tScanStop, fScanCommandResponseCB, hCb); 645 } 646 647 /**************************************************************************** 648 * cmdBld_SetBssType() 649 **************************************************************************** 650 * DESCRIPTION: Set Bss type, set RxFilter 651 * 652 * INPUTS: None 653 * 654 * OUTPUT: None 655 * 656 * RETURNS: TI_OK or TI_NOK 657 ****************************************************************************/ 658 static TI_STATUS cmdBld_CmdSetBssType (TI_HANDLE hCmdBld, ScanBssType_e BssType, TI_UINT8 *HwBssType) 659 { 660 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 661 662 switch (BssType) 663 { 664 case BSS_INFRASTRUCTURE: 665 DB_BSS(hCmdBld).BssType = BSS_TYPE_STA_BSS; 666 cmdBld_SetRxFilter (hCmdBld, RX_CONFIG_OPTION_FOR_JOIN, RX_FILTER_OPTION_JOIN); 667 break; 668 669 case BSS_INDEPENDENT: 670 DB_BSS(hCmdBld).BssType = BSS_TYPE_IBSS; 671 cmdBld_SetRxFilter (hCmdBld, RX_CONFIG_OPTION_FOR_IBSS_JOIN, RX_FILTER_OPTION_DEF); 672 break; 673 674 default: 675 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_FATAL_ERROR, "cmdBld_SetBssType: FATAL_ERROR, unknown BssType %d\n", BssType); 676 return TI_NOK; 677 } 678 679 *HwBssType = DB_BSS(hCmdBld).BssType; 680 681 return TI_OK; 682 } 683 684 685 /**************************************************************************** 686 * cmdBld_StartJoin() 687 **************************************************************************** 688 * DESCRIPTION: Enable Rx/Tx and send Start/Join command 689 * 690 * INPUTS: None 691 * 692 * OUTPUT: None 693 * 694 * RETURNS: TI_OK or TI_NOK 695 ****************************************************************************/ 696 TI_STATUS cmdBld_CmdStartJoin (TI_HANDLE hCmdBld, ScanBssType_e BssType, void *fJoinCompleteCB, TI_HANDLE hCb) 697 { 698 TI_UINT8 HwBssType = 0; 699 #ifdef TI_DBG 700 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 701 TI_UINT8 *pBssId = DB_BSS(hCmdBld).BssId; 702 703 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INIT, "cmdBld_StartJoin: Enable Tx, Rx and Start the Bss, type=%d\n", BssType); 704 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INIT, "------------------------------------------------------------\n"); 705 TRACE7(pCmdBld->hReport, REPORT_SEVERITY_INIT, "START/JOIN, SSID=, BSSID=%02X-%02X-%02X-%02X-%02X-%02X, Chan=%d\n", pBssId[0], pBssId[1], pBssId[2], pBssId[3], pBssId[4], pBssId[5], DB_BSS(hCmdBld).RadioChannel); 706 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INIT, "------------------------------------------------------------\n"); 707 #endif /* TI_DBG */ 708 709 /* 710 * set RxFilter (but don't write it to the FW, this is done in the join command), 711 * Configure templates content, ... 712 */ 713 cmdBld_CmdSetBssType (hCmdBld, BssType, &HwBssType); 714 715 return cmdBld_CmdIeStartBss (hCmdBld, HwBssType, fJoinCompleteCB, hCb); 716 } 717 718 719 TI_STATUS cmdBld_CmdJoinBss (TI_HANDLE hCmdBld, TJoinBss *pJoinBssParams, void *fCb, TI_HANDLE hCb) 720 { 721 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 722 TWlanParams *pWlanParams = &DB_WLAN(hCmdBld); 723 TBssInfoParams *pBssInfoParams = &DB_BSS(hCmdBld); 724 #ifdef TI_DBG 725 TI_UINT8 dbgSsidStr[33]; 726 #endif /* TI_DBG */ 727 728 /* for debug purpose, can be removed later*/ 729 if (pJoinBssParams->ssidLength > 32) 730 pJoinBssParams->ssidLength = 32; 731 732 /* Update Tx-Session-Counter in the Ctrl field of the Join command. */ 733 pBssInfoParams->Ctrl &= ~JOIN_CMD_CTRL_TX_SESSION; 734 pBssInfoParams->Ctrl |= (TI_UINT8)(pJoinBssParams->txSessionCount << JOIN_CMD_CTRL_OFFSET_TX_SESSION); 735 736 #ifdef TI_DBG 737 os_memoryCopy (pCmdBld->hOs, (void *)dbgSsidStr, (void *)pJoinBssParams->pSSID, pJoinBssParams->ssidLength); 738 dbgSsidStr[pJoinBssParams->ssidLength] = '\0'; 739 740 TRACE14(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "TWD_JoinBss : bssType = %d, beaconInterval = %d, dtimInterval = %d, channel = %d, BSSID = %x-%x-%x-%x-%x-%x, ssidLength = %d, basicRateSet = 0x%x, RadioBand = %d, Ctrl = 0x%x", pJoinBssParams->bssType, pJoinBssParams->beaconInterval, pJoinBssParams->dtimInterval, pJoinBssParams->channel, pJoinBssParams->pBSSID[0], pJoinBssParams->pBSSID[1], pJoinBssParams->pBSSID[2], pJoinBssParams->pBSSID[3], pJoinBssParams->pBSSID[4], pJoinBssParams->pBSSID[5], pJoinBssParams->ssidLength, pJoinBssParams->basicRateSet, pJoinBssParams->radioBand, pBssInfoParams->Ctrl); 741 #endif /* TI_DBG */ 742 /* 743 * save Bss info parameters 744 */ 745 DB_BSS(hCmdBld).ReqBssType = pJoinBssParams->bssType; 746 MAC_COPY (DB_BSS(hCmdBld).BssId, pJoinBssParams->pBSSID); 747 pBssInfoParams->tSsid.len = pJoinBssParams->ssidLength; 748 os_memoryZero (pCmdBld->hOs, (void *)pBssInfoParams->tSsid.str, sizeof (pBssInfoParams->tSsid.str)); 749 os_memoryCopy (pCmdBld->hOs, (void *)pBssInfoParams->tSsid.str, (void *)pJoinBssParams->pSSID, pJoinBssParams->ssidLength); 750 DB_BSS(hCmdBld).BeaconInterval = pJoinBssParams->beaconInterval; 751 DB_BSS(hCmdBld).DtimInterval = (TI_UINT8)pJoinBssParams->dtimInterval; 752 DB_BSS(hCmdBld).RadioChannel = pJoinBssParams->channel; 753 DB_WLAN(hCmdBld).RadioBand = (TI_UINT8)pJoinBssParams->radioBand; 754 DB_BSS(hCmdBld).BasicRateSet = pJoinBssParams->basicRateSet; 755 756 /* In case we're joining a new BSS, reset the TKIP/AES sequence counter. */ 757 /* The firmware resets its own counter - so we won't have mismatch in the following TX complete events */ 758 pCmdBld->uSecuritySeqNumLow = 0; 759 pCmdBld->uSecuritySeqNumHigh = 0; 760 761 pWlanParams->bJoin = TI_TRUE; 762 pWlanParams->bStaConnected = TI_FALSE; 763 /* 764 * call the hardware to start/join the bss 765 */ 766 return cmdBld_CmdStartJoin (hCmdBld, pJoinBssParams->bssType, fCb, hCb); 767 } 768 769 770 TI_STATUS cmdBld_CmdTemplate (TI_HANDLE hCmdBld, TSetTemplate *pTemplateParams, void *fCb, TI_HANDLE hCb) 771 { 772 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 773 TI_STATUS Stt; 774 TTemplateParams *pTemplate; 775 TI_UINT8 uIndex = 0; 776 TemplateType_e eType; 777 778 TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "cmdBld_CmdTemplate: Type=%d, size=%d, index=%d, RateMask=0x%x\n", pTemplateParams->type, pTemplateParams->len, pTemplateParams->index, pTemplateParams->uRateMask); 779 780 switch (pTemplateParams->type) 781 { 782 case BEACON_TEMPLATE: 783 eType = TEMPLATE_BEACON; 784 pTemplate = &(DB_TEMP(hCmdBld).Beacon); 785 break; 786 787 case PROBE_RESPONSE_TEMPLATE: 788 eType = TEMPLATE_PROBE_RESPONSE; 789 pTemplate = &(DB_TEMP(hCmdBld).ProbeResp); 790 break; 791 792 case PROBE_REQUEST_TEMPLATE: 793 if (pTemplateParams->eBand == RADIO_BAND_2_4_GHZ) 794 { 795 eType = CFG_TEMPLATE_PROBE_REQ_2_4; 796 pTemplate = &(DB_TEMP(hCmdBld).ProbeReq24); 797 } 798 else 799 { 800 eType = CFG_TEMPLATE_PROBE_REQ_5; 801 pTemplate = &(DB_TEMP(hCmdBld).ProbeReq50); 802 } 803 break; 804 805 case NULL_DATA_TEMPLATE: 806 eType = TEMPLATE_NULL_DATA; 807 pTemplate = &(DB_TEMP(hCmdBld).NullData); 808 break; 809 810 case PS_POLL_TEMPLATE: 811 eType = TEMPLATE_PS_POLL; 812 pTemplate = &(DB_TEMP(hCmdBld).PsPoll); 813 break; 814 815 case QOS_NULL_DATA_TEMPLATE: 816 eType = TEMPLATE_QOS_NULL_DATA; 817 pTemplate = &(DB_TEMP(hCmdBld).QosNullData); 818 break; 819 820 case KEEP_ALIVE_TEMPLATE: 821 eType = TEMPLATE_KLV; 822 uIndex = pTemplateParams->index; 823 pTemplate = &(DB_TEMP(hCmdBld).KeepAlive[uIndex]); 824 break; 825 826 case DISCONN_TEMPLATE: 827 eType = TEMPLATE_DISCONNECT; 828 pTemplate = &(DB_TEMP(hCmdBld).Disconn); 829 break; 830 831 default: 832 return TI_NOK; 833 } 834 835 /* Save template information to DB (for recovery) */ 836 pTemplate->Size = pTemplateParams->len; 837 pTemplate->uRateMask = pTemplateParams->uRateMask; 838 os_memoryCopy (pCmdBld->hOs, 839 (void *)(pTemplate->Buffer), 840 (void *)(pTemplateParams->ptr), 841 pTemplateParams->len); 842 843 /* Configure template to FW */ 844 Stt = cmdBld_CmdIeConfigureTemplateFrame (hCmdBld, 845 pTemplate, 846 (TI_UINT16)pTemplateParams->len, 847 eType, 848 uIndex, /* index is only relevant for keep-alive template */ 849 fCb, 850 hCb); 851 852 return Stt; 853 } 854 855 856 /**************************************************************************** 857 * cmdBld_switchChannel() 858 **************************************************************************** 859 * DESCRIPTION: Switching the serving channel 860 * 861 * INPUTS: channel - new channel number 862 * 863 * OUTPUT: None 864 * 865 * RETURNS: TI_OK or TI_NOK 866 ****************************************************************************/ 867 TI_STATUS cmdBld_CmdEnableTx (TI_HANDLE hCmdBld, TI_UINT8 channel, void *fCb, TI_HANDLE hCb) 868 { 869 return cmdBld_CmdIeEnableTx (hCmdBld, channel, fCb, hCb); 870 } 871 872 873 /**************************************************************************** 874 * cmdBld_DisableTx() 875 **************************************************************************** 876 * DESCRIPTION: Disable Tx path. 877 * 878 * INPUTS: None 879 * 880 * OUTPUT: None 881 * 882 * RETURNS: TI_OK or TI_NOK 883 ****************************************************************************/ 884 TI_STATUS cmdBld_CmdDisableTx (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 885 { 886 return cmdBld_CmdIeDisableTx (hCmdBld, fCb, hCb); 887 } 888 889 890 891 /**************************************************************************** 892 * cmdBld_SwitchChannelCmd() 893 **************************************************************************** 894 * DESCRIPTION: Send Switch Channel command 895 * 896 * INPUTS: None 897 * 898 * OUTPUT: None 899 * 900 * RETURNS: TI_OK or TI_NOK 901 ****************************************************************************/ 902 TI_STATUS cmdBld_CmdSwitchChannel (TI_HANDLE hCmdBld, TSwitchChannelParams *pSwitchChannelCmd, void *fCb, TI_HANDLE hCb) 903 { 904 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 905 906 TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "\n SwitchChannelCmd :\n channelNumber = %d\n switchTime = %d\n txFlag = %d\n flush = %d \n ", pSwitchChannelCmd->channelNumber, pSwitchChannelCmd->switchTime, pSwitchChannelCmd->txFlag, pSwitchChannelCmd->flush); 907 908 DB_BSS(hCmdBld).RadioChannel = pSwitchChannelCmd->channelNumber; 909 910 return cmdBld_CmdIeSwitchChannel (hCmdBld, pSwitchChannelCmd, fCb, hCb); 911 } 912 913 914 /**************************************************************************** 915 * cmdBld_SwitchChannelCmd() 916 **************************************************************************** 917 * DESCRIPTION: Send Switch Channel command 918 * 919 * INPUTS: None 920 * 921 * OUTPUT: None 922 * 923 * RETURNS: TI_OK or TI_NOK 924 ****************************************************************************/ 925 TI_STATUS cmdBld_CmdSwitchChannelCancel (TI_HANDLE hCmdBld, TI_UINT8 channel, void *fCb, TI_HANDLE hCb) 926 { 927 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 928 929 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "\n TWD_SwitchChannelCancelCmd :\n "); 930 931 DB_BSS(hCmdBld).RadioChannel = channel; 932 933 return cmdBld_CmdIeSwitchChannelCancel (hCmdBld, fCb, hCb); 934 } 935 936 937 /**************************************************************************** 938 * cmdBld_FwDisconnect() 939 **************************************************************************** 940 * DESCRIPTION: Disconnect. 941 * 942 * INPUTS: None 943 * 944 * OUTPUT: None 945 * 946 * RETURNS: TI_OK or TI_NOK 947 ****************************************************************************/ 948 TI_STATUS cmdBld_CmdFwDisconnect (TI_HANDLE hCmdBld, TI_UINT32 uConfigOptions, TI_UINT32 uFilterOptions, DisconnectType_e uDisconType, TI_UINT16 uDisconReason, void *fCb, TI_HANDLE hCb) 949 { 950 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 951 TWlanParams *pWlanParams = &DB_WLAN(hCmdBld); 952 953 pWlanParams->bJoin = TI_FALSE; 954 pWlanParams->bStaConnected = TI_FALSE; 955 956 TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Sending FW disconnect, ConfigOptions=%x, FilterOPtions=%x, uDisconType=%d, uDisconReason=%d\n",uConfigOptions, uFilterOptions, uDisconType, uDisconReason); 957 958 959 return cmdBld_CmdIeFwDisconnect (hCmdBld, uConfigOptions, uFilterOptions, uDisconType, uDisconReason, fCb, hCb); 960 } 961 962 963 TI_STATUS cmdBld_CmdMeasurement (TI_HANDLE hCmdBld, 964 TMeasurementParams *pMeasurementParams, 965 void *fCommandResponseCB, 966 TI_HANDLE hCb) 967 { 968 return cmdBld_CmdIeMeasurement (hCmdBld, pMeasurementParams, fCommandResponseCB, hCb); 969 } 970 971 972 /**************************************************************************** 973 * cmdBld_measurementStop() 974 **************************************************************************** 975 * DESCRIPTION: send Command for stoping measurement 976 * 977 * INPUTS: None 978 * 979 * OUTPUT: None 980 * 981 * RETURNS: TI_OK or TI_NOK 982 ****************************************************************************/ 983 TI_STATUS cmdBld_CmdMeasurementStop (TI_HANDLE hCmdBld, void* fMeasureCommandResponseCB, TI_HANDLE hCb) 984 { 985 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 986 987 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "cmdBld_measurementStop\n"); 988 989 return cmdBld_CmdIeMeasurementStop (hCmdBld, fMeasureCommandResponseCB, hCb); 990 } 991 992 993 /**************************************************************************** 994 * cmdBld_ApDiscovery() 995 **************************************************************************** 996 * DESCRIPTION: send Command for AP Discovery 997 * to the mailbox 998 * 999 * INPUTS: None 1000 * 1001 * OUTPUT: None 1002 * 1003 * RETURNS: TI_OK or TI_NOK 1004 ****************************************************************************/ 1005 TI_STATUS cmdBld_CmdApDiscovery (TI_HANDLE hCmdBld, TApDiscoveryParams *pApDiscoveryParams, void *fCb, TI_HANDLE hCb) 1006 { 1007 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1008 1009 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_ApDiscovery\n"); 1010 1011 return cmdBld_CmdIeApDiscovery (hCmdBld, pApDiscoveryParams, fCb, hCb); 1012 } 1013 1014 1015 /**************************************************************************** 1016 * cmdBld_ApDiscoveryStop() 1017 **************************************************************************** 1018 * DESCRIPTION: send Command for stoping AP Discovery 1019 * 1020 * INPUTS: None 1021 * 1022 * OUTPUT: None 1023 * 1024 * RETURNS: TI_OK or TI_NOK 1025 ****************************************************************************/ 1026 TI_STATUS cmdBld_CmdApDiscoveryStop (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 1027 { 1028 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1029 1030 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_ApDiscoveryStop\n"); 1031 1032 return cmdBld_CmdIeApDiscoveryStop (hCmdBld, fCb, hCb); 1033 } 1034 1035 1036 TI_STATUS cmdBld_CmdNoiseHistogram (TI_HANDLE hCmdBld, TNoiseHistogram *pNoiseHistParams, void *fCb, TI_HANDLE hCb) 1037 { 1038 return cmdBld_CmdIeNoiseHistogram (hCmdBld, pNoiseHistParams, fCb, hCb); 1039 } 1040 1041 1042 /**************************************************************************** 1043 * cmdBld_PowerMgmtConfigurationSet () 1044 **************************************************************************** 1045 * DESCRIPTION: Set the ACX power management option IE 1046 * 1047 * INPUTS: powerSaveParams 1048 * 1049 * OUTPUT: 1050 * 1051 * RETURNS: TI_OK or TI_NOK 1052 ****************************************************************************/ 1053 TI_STATUS cmdBld_CmdSetPsMode (TI_HANDLE hCmdBld, TPowerSaveParams* powerSaveParams, void *fCb, TI_HANDLE hCb) 1054 { 1055 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1056 1057 /* Rate conversion is done in the HAL */ 1058 cmdBld_ConvertAppRatesBitmap (powerSaveParams->NullPktRateModulation, 1059 0, 1060 &powerSaveParams->NullPktRateModulation); 1061 1062 TRACE5(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, " cmdBld_PowerMgmtConfigurationSet ps802_11Enable=0x%x hangOverPeriod=%d needToSendNullData=0x%x numNullPktRetries=%d NullPktRateModulation=0x%x\n", powerSaveParams->ps802_11Enable, powerSaveParams->hangOverPeriod, powerSaveParams->needToSendNullData, powerSaveParams->numNullPktRetries, powerSaveParams->NullPktRateModulation); 1063 1064 return cmdBld_CmdIeSetPsMode (hCmdBld, powerSaveParams, fCb, hCb); 1065 } 1066 1067 1068 /**************************************************************************** 1069 * cmdBld_EnableRx() 1070 **************************************************************************** 1071 * DESCRIPTION: Enable Rx and send Start/Join command 1072 * 1073 * INPUTS: None 1074 * 1075 * OUTPUT: None 1076 * 1077 * RETURNS: TI_OK or TI_NOK 1078 ****************************************************************************/ 1079 TI_STATUS cmdBld_CmdEnableRx (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 1080 { 1081 return cmdBld_CmdIeEnableRx (hCmdBld, fCb, hCb); 1082 } 1083 1084 1085 TI_STATUS cmdBld_CmdAddKey (TI_HANDLE hCmdBld, TSecurityKeys* pKey, TI_BOOL reconfFlag, void *fCb, TI_HANDLE hCb) 1086 { 1087 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1088 TI_UINT8 keyIdx = (TI_UINT8)pKey->keyIndex; 1089 1090 /* store the security key for reconfigure phase (FW reload)*/ 1091 if (reconfFlag != TI_TRUE) 1092 { 1093 if (keyIdx >= (pCmdBld->tSecurity.uNumOfStations * NO_OF_RECONF_SECUR_KEYS_PER_STATION + NO_OF_EXTRA_RECONF_SECUR_KEYS)) 1094 { 1095 TRACE2(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "cmdBld_CmdAddKey: ERROR Key keyIndex field out of range =%d, range is (0 to %d)\n", pKey->keyIndex, pCmdBld->tSecurity.uNumOfStations * NO_OF_RECONF_SECUR_KEYS_PER_STATION+NO_OF_EXTRA_RECONF_SECUR_KEYS - 1); 1096 1097 return TI_NOK; 1098 } 1099 1100 if (pKey->keyType == KEY_NULL) 1101 { 1102 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "cmdBld_CmdAddKey: ERROR KeyType is NULL_KEY\n"); 1103 1104 return TI_NOK; 1105 } 1106 1107 os_memoryCopy (pCmdBld->hOs, 1108 (void *)(DB_KEYS(pCmdBld).pReconfKeys + keyIdx), 1109 (void *)pKey, 1110 sizeof(TSecurityKeys)); 1111 } 1112 1113 switch (pCmdBld->tSecurity.eSecurityMode) 1114 { 1115 case TWD_CIPHER_WEP: 1116 case TWD_CIPHER_WEP104: 1117 return cmdBld_CmdAddWepDefaultKey (hCmdBld, pKey, fCb, hCb); 1118 1119 case TWD_CIPHER_TKIP: 1120 case TWD_CIPHER_AES_CCMP: 1121 #ifdef GEM_SUPPORTED 1122 case TWD_CIPHER_GEM: 1123 #endif 1124 return cmdBld_CmdAddWpaKey (hCmdBld, pKey, fCb, hCb); 1125 1126 default: 1127 return TI_NOK; 1128 } 1129 } 1130 1131 1132 TI_STATUS cmdBld_CmdAddWpaKey (TI_HANDLE hCmdBld, TSecurityKeys* pKey, void *fCb, TI_HANDLE hCb) 1133 { 1134 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1135 1136 /* Only WEP, TKIP, AES keys are handled*/ 1137 switch (pKey->keyType) 1138 { 1139 case KEY_WEP: 1140 /* Configure the encKeys to the HW - default keys cache*/ 1141 return cmdBld_CmdAddWepDefaultKey (hCmdBld, pKey, fCb, hCb); 1142 1143 case KEY_TKIP: 1144 /* Set the REAL TKIP key into the TKIP key cache*/ 1145 if (cmdBld_CmdAddTkipMicMappingKey (hCmdBld, pKey, fCb, hCb) != TI_OK) 1146 return TI_NOK; 1147 1148 break; 1149 1150 case KEY_AES: 1151 if (cmdBld_CmdAddAesMappingKey (hCmdBld, pKey, fCb, hCb) != TI_OK) 1152 return TI_NOK; 1153 break; 1154 1155 #ifdef GEM_SUPPORTED 1156 case KEY_GEM: 1157 if (cmdBld_CmdAddGemMappingKey (hCmdBld, pKey, fCb, hCb) != TI_OK) 1158 return TI_NOK; 1159 break; 1160 #endif 1161 1162 default: 1163 return TI_NOK; 1164 } 1165 1166 /* AES or TKIP key has been successfully added. Store the current */ 1167 /* key type of the unicast (i.e. transmit !) key */ 1168 if (!MAC_BROADCAST (pKey->macAddress)) 1169 { 1170 pCmdBld->tSecurity.eCurTxKeyType = pKey->keyType; 1171 } 1172 1173 return TI_OK; 1174 } 1175 1176 1177 TI_STATUS cmdBld_CmdRemoveWpaKey (TI_HANDLE hCmdBld, TSecurityKeys* pKey, void *fCb, TI_HANDLE hCb) 1178 { 1179 /* Only WEP, TKIP, AES keys are handled*/ 1180 switch (pKey->keyType) 1181 { 1182 case KEY_WEP: 1183 /* Configure the encKeys to the HW - default keys cache*/ 1184 return cmdBld_CmdRemoveWepDefaultKey (hCmdBld, pKey, fCb, hCb); 1185 1186 case KEY_TKIP: 1187 /* Configure the encKeys to the HW - mapping keys cache*/ 1188 /* configure through SET_KEYS command */ 1189 1190 /* remove the TKIP key from the TKIP key cache*/ 1191 if (cmdBld_CmdRemoveTkipMicMappingKey (hCmdBld, pKey, fCb, hCb) != TI_OK) 1192 return (TI_NOK); 1193 break; 1194 1195 case KEY_AES: 1196 if (cmdBld_CmdRemoveAesMappingKey (hCmdBld, pKey, fCb, hCb) != TI_OK) 1197 return TI_NOK; 1198 break; 1199 1200 #ifdef GEM_SUPPORTED 1201 case KEY_GEM: 1202 if (cmdBld_CmdRemoveGemMappingKey (hCmdBld, pKey, fCb, hCb) != TI_OK) 1203 return TI_NOK; 1204 break; 1205 #endif 1206 1207 default: 1208 return TI_NOK; 1209 } 1210 1211 return TI_OK; 1212 } 1213 1214 1215 /* 1216 * ---------------------------------------------------------------------------- 1217 * Function : cmdBld_CmdRemoveKey 1218 * 1219 * Input : 1220 * Output : 1221 * Process : 1222 * Note(s) : 1223 * ----------------------------------------------------------------------------- 1224 */ 1225 TI_STATUS cmdBld_CmdRemoveKey (TI_HANDLE hCmdBld, TSecurityKeys* pKey, void *fCb, TI_HANDLE hCb) 1226 { 1227 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1228 TI_UINT8 keyIdx = (TI_UINT8)pKey->keyIndex; 1229 1230 /* Clear the remove key in the reconfigure data base */ 1231 (DB_KEYS(pCmdBld).pReconfKeys + keyIdx)->keyType = KEY_NULL; 1232 1233 switch (pCmdBld->tSecurity.eSecurityMode) 1234 { 1235 case TWD_CIPHER_WEP: 1236 case TWD_CIPHER_WEP104: 1237 return cmdBld_CmdRemoveWepDefaultKey (hCmdBld, pKey, fCb, hCb); 1238 case TWD_CIPHER_TKIP: 1239 case TWD_CIPHER_AES_CCMP: 1240 #ifdef GEM_SUPPORTED 1241 case TWD_CIPHER_GEM: 1242 #endif 1243 return cmdBld_CmdRemoveWpaKey (hCmdBld, pKey, fCb, hCb); 1244 1245 default: 1246 return TI_NOK; 1247 } 1248 } 1249 1250 1251 /**************************************************************************** 1252 * cmdBld_WepDefaultKeyAdd() 1253 **************************************************************************** 1254 * DESCRIPTION: Set the actual default key 1255 * 1256 * INPUTS: 1257 * 1258 * OUTPUT: 1259 * 1260 * RETURNS: TI_OK or TI_NOK 1261 ****************************************************************************/ 1262 TI_STATUS cmdBld_CmdAddWepDefaultKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1263 { 1264 TI_STATUS status; 1265 TI_UINT8 sMacAddrDummy[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 1266 1267 /* Non WEP keys are trashed*/ 1268 if (aSecurityKey->keyType != KEY_WEP) 1269 { 1270 return TI_NOK; 1271 } 1272 1273 status = cmdBld_CmdIeSetKey (hCmdBld, 1274 KEY_ADD_OR_REPLACE, 1275 sMacAddrDummy, 1276 aSecurityKey->encLen, 1277 CIPHER_SUITE_WEP, 1278 aSecurityKey->keyIndex, 1279 (TI_UINT8*)aSecurityKey->encKey, 1280 0, 1281 0, 1282 fCb, 1283 hCb); 1284 return status; 1285 } 1286 1287 /**************************************************************************** 1288 * cmdBld_WepDefaultKeyRemove() 1289 **************************************************************************** 1290 * DESCRIPTION: Set the actual default key 1291 * 1292 * INPUTS: 1293 * 1294 * OUTPUT: 1295 * 1296 * RETURNS: TI_OK or TI_NOK 1297 ****************************************************************************/ 1298 TI_STATUS cmdBld_CmdSetWepDefaultKeyId (TI_HANDLE hCmdBld, TI_UINT8 aKeyIdVal, void *fCb, TI_HANDLE hCb) 1299 { 1300 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1301 TI_UINT8 sMacAddrDummy[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 1302 1303 /* Save the deafult key ID for reconfigure phase */ 1304 DB_KEYS(pCmdBld).bDefaultKeyIdValid = TI_TRUE; 1305 DB_KEYS(pCmdBld).uReconfDefaultKeyId = aKeyIdVal; 1306 1307 return cmdBld_CmdIeSetKey (hCmdBld, 1308 KEY_SET_ID, 1309 sMacAddrDummy, 1310 0, 1311 CIPHER_SUITE_WEP, 1312 aKeyIdVal, 1313 0, 1314 0, 1315 0, 1316 fCb, 1317 hCb); 1318 } 1319 1320 1321 /**************************************************************************** 1322 * cmdBld_WepDefaultKeyRemove() 1323 **************************************************************************** 1324 * DESCRIPTION: Set the actual default key 1325 * 1326 * INPUTS: 1327 * 1328 * OUTPUT: 1329 * 1330 * RETURNS: TI_OK or TI_NOK 1331 ****************************************************************************/ 1332 TI_STATUS cmdBld_CmdRemoveWepDefaultKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1333 { 1334 TI_UINT8 sMacAddrDummy[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 1335 1336 /* Non WEP keys are trashed*/ 1337 if (aSecurityKey->keyType != KEY_WEP) 1338 { 1339 return TI_NOK; 1340 } 1341 1342 return cmdBld_CmdIeSetKey (hCmdBld, 1343 KEY_REMOVE, 1344 sMacAddrDummy, 1345 aSecurityKey->encLen, 1346 CIPHER_SUITE_WEP, 1347 aSecurityKey->keyIndex, 1348 (TI_UINT8*)aSecurityKey->encKey, 1349 0, 1350 0, 1351 fCb, 1352 hCb); 1353 } 1354 1355 /**************************************************************************** 1356 * cmdBld_WepMappingKeyAdd() 1357 **************************************************************************** 1358 * DESCRIPTION: Set the actual mapping key 1359 * 1360 * INPUTS: 1361 * 1362 * OUTPUT: 1363 * 1364 * RETURNS: TI_OK or TI_NOK 1365 ****************************************************************************/ 1366 TI_STATUS cmdBld_CmdAddWepMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1367 { 1368 return cmdBld_CmdIeSetKey (hCmdBld, 1369 KEY_ADD_OR_REPLACE, 1370 (TI_UINT8*)aSecurityKey->macAddress, 1371 aSecurityKey->encLen, 1372 CIPHER_SUITE_WEP, 1373 aSecurityKey->keyIndex, 1374 (TI_UINT8*)aSecurityKey->encKey, 1375 0, 1376 0, 1377 fCb, 1378 hCb); 1379 } 1380 1381 /**************************************************************************** 1382 * cmdBld_WepMappingKeyRemove() 1383 **************************************************************************** 1384 * DESCRIPTION: Set the actual mapping key 1385 * 1386 * INPUTS: 1387 * 1388 * OUTPUT: 1389 * 1390 * RETURNS: TI_OK or TI_NOK 1391 ****************************************************************************/ 1392 TI_STATUS cmdBld_CmdRemoveWepMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1393 { 1394 /*In the new security interface it is not allowed to remove uni-cast keys. it will be cleaned on the next join command*/ 1395 if (!MAC_BROADCAST(aSecurityKey->macAddress) ) 1396 { 1397 return TI_OK; 1398 } 1399 return cmdBld_CmdIeSetKey (hCmdBld, 1400 KEY_REMOVE, 1401 (TI_UINT8*)aSecurityKey->macAddress, 1402 aSecurityKey->encLen, 1403 CIPHER_SUITE_WEP, 1404 aSecurityKey->keyIndex, 1405 (TI_UINT8*)aSecurityKey->encKey, 1406 0, 1407 0, 1408 fCb, 1409 hCb); 1410 } 1411 1412 1413 /**************************************************************************** 1414 * cmdBld_TkipMicMappingKeyAdd() 1415 **************************************************************************** 1416 * DESCRIPTION: Set the actual mapping key 1417 * 1418 * INPUTS: 1419 * 1420 * OUTPUT: 1421 * 1422 * RETURNS: TI_OK or TI_NOK 1423 ****************************************************************************/ 1424 TI_STATUS cmdBld_CmdAddTkipMicMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1425 { 1426 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1427 TI_UINT8 keyType; 1428 TI_UINT8 keyBuffer[KEY_SIZE_TKIP]; 1429 1430 keyType = CIPHER_SUITE_TKIP; 1431 1432 os_memoryCopy (pCmdBld->hOs, (void*)(&keyBuffer[0]), (void*)aSecurityKey->encKey, 16); 1433 os_memoryCopy (pCmdBld->hOs, (void*)(&keyBuffer[16]), (void*)aSecurityKey->micRxKey, 8); 1434 os_memoryCopy (pCmdBld->hOs, (void*)(&keyBuffer[24]), (void*)aSecurityKey->micTxKey, 8); 1435 1436 return cmdBld_CmdIeSetKey (hCmdBld, 1437 KEY_ADD_OR_REPLACE, 1438 (TI_UINT8*)aSecurityKey->macAddress, 1439 KEY_SIZE_TKIP, 1440 keyType, 1441 aSecurityKey->keyIndex, 1442 (TI_UINT8*)keyBuffer, 1443 pCmdBld->uSecuritySeqNumLow, 1444 pCmdBld->uSecuritySeqNumHigh, 1445 fCb, 1446 hCb); 1447 } 1448 1449 /**************************************************************************** 1450 * cmdBld_TkipMappingKeyAdd() 1451 **************************************************************************** 1452 * DESCRIPTION: Set the actual mapping key 1453 * 1454 * INPUTS: 1455 * 1456 * OUTPUT: 1457 * 1458 * RETURNS: TI_OK or TI_NOK 1459 ****************************************************************************/ 1460 TI_STATUS cmdBld_CmdRemoveTkipMicMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1461 { 1462 TI_UINT8 keyType; 1463 1464 keyType = CIPHER_SUITE_TKIP; 1465 1466 /*In the new security interface it is not allowed to remove uni-cast keys. it will be cleaned on the next join command*/ 1467 if (!MAC_BROADCAST(aSecurityKey->macAddress) ) 1468 { 1469 return TI_OK; 1470 } 1471 1472 1473 return cmdBld_CmdIeSetKey (hCmdBld, 1474 KEY_REMOVE, 1475 (TI_UINT8*)aSecurityKey->macAddress, 1476 aSecurityKey->encLen, 1477 keyType, 1478 aSecurityKey->keyIndex, 1479 (TI_UINT8*)aSecurityKey->encKey, 1480 0, 1481 0, 1482 fCb, 1483 hCb); 1484 } 1485 1486 1487 /**************************************************************************** 1488 * cmdBld_AesMappingKeyAdd() 1489 **************************************************************************** 1490 * DESCRIPTION: Set the actual Aes mapping key 1491 * 1492 * INPUTS: 1493 * 1494 * OUTPUT: 1495 * 1496 * RETURNS: TI_OK or TI_NOK 1497 ****************************************************************************/ 1498 TI_STATUS cmdBld_CmdAddAesMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1499 { 1500 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1501 TI_UINT8 keyType; 1502 1503 keyType = CIPHER_SUITE_AES; 1504 1505 TRACE2(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_AesMappingKeyAdd: uSecuritySeqNumHigh=%ld, pHwCtrl->uSecuritySeqNumLow=%ld \n", pCmdBld->uSecuritySeqNumHigh, pCmdBld->uSecuritySeqNumLow); 1506 1507 return cmdBld_CmdIeSetKey (hCmdBld, 1508 KEY_ADD_OR_REPLACE, 1509 (TI_UINT8*)aSecurityKey->macAddress, 1510 aSecurityKey->encLen, keyType, 1511 aSecurityKey->keyIndex, 1512 (TI_UINT8*)aSecurityKey->encKey, 1513 pCmdBld->uSecuritySeqNumLow, 1514 pCmdBld->uSecuritySeqNumHigh, 1515 fCb, 1516 hCb); 1517 } 1518 1519 1520 /**************************************************************************** 1521 * cmdBld_AesMappingKeyRemove() 1522 **************************************************************************** 1523 * DESCRIPTION: Remove Aes mapping key 1524 * 1525 * INPUTS: 1526 * 1527 * OUTPUT: 1528 * 1529 * RETURNS: TI_OK or TI_NOK 1530 ****************************************************************************/ 1531 TI_STATUS cmdBld_CmdRemoveAesMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1532 { 1533 TI_UINT8 keyType; 1534 1535 keyType = CIPHER_SUITE_AES; 1536 1537 /*In the new security interface it is not allowed to remove uni-cast keys. it will be cleaned on the next join command*/ 1538 if (!MAC_BROADCAST(aSecurityKey->macAddress) ) 1539 { 1540 return TI_OK; 1541 } 1542 1543 return cmdBld_CmdIeSetKey (hCmdBld, 1544 KEY_REMOVE, 1545 (TI_UINT8*)aSecurityKey->macAddress, 1546 aSecurityKey->encLen, 1547 keyType, 1548 aSecurityKey->keyIndex, 1549 (TI_UINT8*)aSecurityKey->encKey, 1550 0, 1551 0, 1552 fCb, 1553 hCb); 1554 } 1555 1556 /**************************************************************************** 1557 * cmdBld_CmdSetStaState() 1558 **************************************************************************** 1559 * DESCRIPTION: Set station status . 1560 * 1561 * INPUTS: None 1562 * 1563 * OUTPUT: None 1564 * 1565 * RETURNS: TI_OK or TI_NOK 1566 ****************************************************************************/ 1567 TI_STATUS cmdBld_CmdSetStaState (TI_HANDLE hCmdBld, TI_UINT8 staState, void *fCb, TI_HANDLE hCb) 1568 { 1569 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1570 TWlanParams *pWlanParams = &DB_WLAN(hCmdBld); 1571 1572 pWlanParams->bStaConnected = TI_TRUE; 1573 TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Sending StaState %d\n",staState); 1574 1575 return cmdBld_CmdIeSetStaState (hCmdBld, staState, fCb, hCb); 1576 } 1577 1578 #ifdef GEM_SUPPORTED 1579 /**************************************************************************** 1580 * cmdBld_CmdAddGemMappingKey() 1581 **************************************************************************** 1582 * DESCRIPTION: Set the actual GEM mapping key 1583 * 1584 * INPUTS: 1585 * 1586 * OUTPUT: 1587 * 1588 * RETURNS: TI_OK or TI_NOK 1589 ****************************************************************************/ 1590 TI_STATUS cmdBld_CmdAddGemMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1591 { 1592 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1593 TI_UINT8 keyType; 1594 TI_UINT8 keyBuffer[MAX_KEY_SIZE]; 1595 1596 keyType = CIPHER_SUITE_GEM; 1597 1598 os_memoryCopy (pCmdBld->hOs, (void*)(&keyBuffer[0]), (void*)aSecurityKey->encKey, 16); 1599 os_memoryCopy (pCmdBld->hOs, (void*)(&keyBuffer[16]), (void*)aSecurityKey->micRxKey, 16); 1600 1601 return cmdBld_CmdIeSetKey (hCmdBld, 1602 KEY_ADD_OR_REPLACE, 1603 aSecurityKey->macAddress, 1604 MAX_KEY_SIZE, 1605 keyType, 1606 aSecurityKey->keyIndex, 1607 keyBuffer, 1608 pCmdBld->uSecuritySeqNumLow, 1609 pCmdBld->uSecuritySeqNumHigh, 1610 fCb, 1611 hCb); 1612 } 1613 1614 1615 /**************************************************************************** 1616 * cmdBld_CmdRemoveGemMappingKey() 1617 **************************************************************************** 1618 * DESCRIPTION: Remove GEM mapping key 1619 * 1620 * INPUTS: 1621 * 1622 * OUTPUT: 1623 * 1624 * RETURNS: TI_OK or TI_NOK 1625 ****************************************************************************/ 1626 TI_STATUS cmdBld_CmdRemoveGemMappingKey (TI_HANDLE hCmdBld, TSecurityKeys* aSecurityKey, void *fCb, TI_HANDLE hCb) 1627 { 1628 TI_UINT8 keyType; 1629 1630 keyType = CIPHER_SUITE_GEM; 1631 1632 /*In the new security interface it is not allowed to remove uni-cast keys. it will be cleaned on the next join command*/ 1633 if (!MAC_BROADCAST(aSecurityKey->macAddress) ) 1634 { 1635 return TI_OK; 1636 } 1637 1638 return cmdBld_CmdIeSetKey (hCmdBld, 1639 KEY_REMOVE, 1640 aSecurityKey->macAddress, 1641 aSecurityKey->encLen, 1642 keyType, 1643 aSecurityKey->keyIndex, 1644 aSecurityKey->encKey, 1645 0, 1646 0, 1647 fCb, 1648 hCb); 1649 } 1650 #endif /*GEM_SUPPORTED*/ 1651 1652 /**************************************************************************** 1653 * cmdBld_healthCheck() 1654 **************************************************************************** 1655 * DESCRIPTION: 1656 * 1657 * INPUTS: 1658 * 1659 * OUTPUT: 1660 * 1661 * RETURNS: 1662 ****************************************************************************/ 1663 TI_STATUS cmdBld_CmdHealthCheck (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb) 1664 { 1665 TCmdBld *pCmdBld = (TCmdBld *)hCmdBld; 1666 1667 TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_CmdIeHealthCheck\n"); 1668 1669 return cmdBld_CmdIeHealthCheck (hCmdBld, fCb, hCb); 1670 } 1671 1672 TI_STATUS cmdBld_CmdTest (TI_HANDLE hCmdBld, void *fCb, TI_HANDLE hCb, TTestCmd* pTestCmd) 1673 { 1674 return cmdBld_CmdIeTest (hCmdBld, fCb, hCb, pTestCmd); 1675 } 1676 1677