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