1 /* 2 * cu_cmd.c 3 * 4 * Copyright 2001-2009 Texas Instruments, Inc. - http://www.ti.com/ 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /**************************************************************************** 20 * 21 * MODULE: cu_cmd.c 22 * 23 * PURPOSE: 24 * 25 * DESCRIPTION: 26 * ============ 27 * 28 * 29 ****************************************************************************/ 30 31 /* includes */ 32 /************/ 33 34 #include <stdio.h> 35 36 #include "cu_osapi.h" 37 #include "TWDriver.h" 38 #include "convert.h" 39 #include "console.h" 40 #include "cu_common.h" 41 #include "cu_os.h" 42 #include "ipc_event.h" 43 #include "wpa_core.h" 44 #include "cu_cmd.h" 45 #include "oserr.h" 46 47 /* defines */ 48 /***********/ 49 #define print_available_values(arr) \ 50 { \ 51 S32 i; \ 52 for(i=0; i<SIZE_ARR(arr); i++) \ 53 os_error_printf(CU_MSG_INFO2, (PS8)"%d - %s%s", arr[i].value, arr[i].name, (i>=SIZE_ARR(arr)-1) ? (PS8)"\n" : (PS8)", " ); \ 54 } 55 56 #define CU_CMD_FIND_NAME_ARRAY(index, arr, val) \ 57 for ( index = 0; index < SIZE_ARR(arr); index++ ) \ 58 if ( arr[ index ].value == (val) ) \ 59 break; \ 60 61 #define CHAN_FREQ_TABLE_SIZE (sizeof(ChanFreq) / sizeof(struct CHAN_FREQ)) 62 63 #define IS_BASIC_RATE(a) ((a) & NET_BASIC_MASK) 64 65 #define RATE_2_MBPS(a) ((F32)((a) & (NET_BASIC_MASK-1))/2) 66 67 #define NET_BASIC_MASK 0x80 /* defined in common/src/utils/utils.c */ 68 69 #define BIT_TO_BYTE_FACTOR 8 70 71 #define NVS_FILE_TX_PARAMETERS_UPDATE 0 72 #define NVS_FILE_RX_PARAMETERS_UPDATE 1 73 74 75 /* local types */ 76 /***************/ 77 /* Module control block */ 78 typedef struct CuCmd_t 79 { 80 THandle hCuWext; 81 THandle hCuCommon; 82 THandle hConsole; 83 THandle hIpcEvent; 84 THandle hWpaCore; 85 86 U32 isDeviceRunning; 87 88 scan_Params_t appScanParams; 89 TPeriodicScanParams tPeriodicAppScanParams; 90 scan_Policy_t scanPolicy; 91 92 } CuCmd_t; 93 94 /* local variables */ 95 /*******************/ 96 struct CHAN_FREQ { 97 U8 chan; 98 U32 freq; 99 } ChanFreq[] = { 100 {1,2412000}, {2,2417000}, {3,2422000}, {4,2427000}, 101 {5,2432000}, {6,2437000}, {7,2442000}, {8,2447000}, 102 {9,2452000}, 103 {10,2457000}, {11,2462000}, {12,2467000}, {13,2472000}, 104 {14,2484000}, {36,5180000}, {40,5200000}, {44,5220000}, 105 {48,5240000}, {52,5260000}, {56,5280000}, {60,5300000}, 106 {64,5320000}, 107 {100,5500000}, {104,5520000}, {108,5540000}, {112,5560000}, 108 {116,5580000}, {120,5600000}, {124,5620000}, {128,5640000}, 109 {132,5660000}, {136,5680000}, {140,5700000}, {149,5745000}, 110 {153,5765000}, {157,5785000}, {161,5805000} }; 111 112 static named_value_t BSS_type[] = 113 { 114 { os802_11IBSS, (PS8)"AD-Hoc" }, 115 { os802_11Infrastructure, (PS8)"Infr." }, 116 { os802_11AutoUnknown, (PS8)"Auto" }, 117 }; 118 119 static named_value_t Current_mode[] = 120 { 121 { 0, (PS8)"SME Auto" }, 122 { 1, (PS8)"SME Manual" }, 123 }; 124 125 static named_value_t BeaconFilter_use[] = 126 { 127 { 0, (PS8)"INACTIVE" }, 128 { 1, (PS8)"ACTIVE" }, 129 }; 130 131 static named_value_t event_type[] = { 132 { IPC_EVENT_ASSOCIATED, (PS8)"Associated" }, 133 { IPC_EVENT_DISASSOCIATED, (PS8)"Disassociated" }, 134 { IPC_EVENT_LINK_SPEED, (PS8)"LinkSpeed" }, 135 { IPC_EVENT_AUTH_SUCC, (PS8)"Authentication Success" }, 136 { IPC_EVENT_SCAN_COMPLETE, (PS8)"ScanComplete" }, 137 { IPC_EVENT_SCAN_STOPPED, (PS8)"ScanStopped" }, 138 #ifdef XCC_MODULE_INCLUDED 139 { IPC_EVENT_CCKM_START, (PS8)"CCKM_Start" }, 140 #endif 141 { IPC_EVENT_MEDIA_SPECIFIC, (PS8)"Media_Specific" }, 142 { IPC_EVENT_EAPOL, (PS8)"EAPOL" }, 143 { IPC_EVENT_RE_AUTH_STARTED, (PS8)"IPC_EVENT_RE_AUTH_STARTED" }, 144 { IPC_EVENT_RE_AUTH_COMPLETED, (PS8)"IPC_EVENT_RE_AUTH_COMPLETED" }, 145 { IPC_EVENT_RE_AUTH_TERMINATED, (PS8)"IPC_EVENT_RE_AUTH_TERMINATED" }, 146 { IPC_EVENT_BOUND, (PS8)"Bound" }, 147 { IPC_EVENT_UNBOUND, (PS8)"Unbound" }, 148 #ifdef WPA_ENTERPRISE 149 { IPC_EVENT_PREAUTH_EAPOL, (PS8)"PreAuth EAPOL"}, 150 #endif 151 { IPC_EVENT_LOW_RSSI, (PS8)"Low RSSI" }, 152 { IPC_EVENT_TSPEC_STATUS, (PS8)"IPC_EVENT_TSPEC_STATUS" }, 153 { IPC_EVENT_TSPEC_RATE_STATUS, (PS8)"IPC_EVENT_TSPEC_RATE_STATUS" }, 154 { IPC_EVENT_MEDIUM_TIME_CROSS, (PS8)"IPC_EVENT_MEDIUM_TIME_CROSS" }, 155 { IPC_EVENT_ROAMING_COMPLETE, (PS8)"ROAMING_COMPLETE"}, 156 { IPC_EVENT_EAP_AUTH_FAILURE, (PS8)"EAP-FAST/LEAP Auth Failed"}, 157 { IPC_EVENT_WPA2_PREAUTHENTICATION, (PS8)"IPC_EVENT_WPA2_PREAUTHENTICATION" }, 158 { IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, (PS8)"IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED" }, 159 { IPC_EVENT_SCAN_FAILED, (PS8)"ScanFailed" }, 160 { IPC_EVENT_WPS_SESSION_OVERLAP, (PS8)"IPC_EVENT_WPS_SESSION_OVERLAP" }, 161 { IPC_EVENT_RSSI_SNR_TRIGGER_0, (PS8)"IPC_EVENT_RSSI_SNR_TRIGGER_0" }, 162 { IPC_EVENT_RSSI_SNR_TRIGGER_1, (PS8)"IPC_EVENT_RSSI_SNR_TRIGGER_1" }, 163 { IPC_EVENT_TIMEOUT, (PS8)"Timeout" } 164 }; 165 166 static named_value_t report_module[] = 167 { 168 { FILE_ID_0 , (PS8)"timer " }, 169 { FILE_ID_1 , (PS8)"measurementMgr " }, 170 { FILE_ID_2 , (PS8)"measurementMgrSM " }, 171 { FILE_ID_3 , (PS8)"regulatoryDomain " }, 172 { FILE_ID_4 , (PS8)"requestHandler " }, 173 { FILE_ID_5 , (PS8)"SoftGemini " }, 174 { FILE_ID_6 , (PS8)"spectrumMngmntMgr " }, 175 { FILE_ID_7 , (PS8)"SwitchChannel " }, 176 { FILE_ID_8 , (PS8)"roamingMngr " }, 177 { FILE_ID_9 , (PS8)"scanMngr " }, 178 { FILE_ID_10 , (PS8)"admCtrlXCC " }, 179 { FILE_ID_11 , (PS8)"XCCMngr " }, 180 { FILE_ID_12 , (PS8)"XCCRMMngr " }, 181 { FILE_ID_13 , (PS8)"XCCTSMngr " }, 182 { FILE_ID_14 , (PS8)"rogueAp " }, 183 { FILE_ID_15 , (PS8)"TransmitPowerXCC " }, 184 { FILE_ID_16 , (PS8)"admCtrl " }, 185 { FILE_ID_17 , (PS8)"admCtrlNone " }, 186 { FILE_ID_18 , (PS8)"admCtrlWep " }, 187 { FILE_ID_19 , (PS8)"admCtrlWpa " }, 188 { FILE_ID_20 , (PS8)"admCtrlWpa2 " }, 189 { FILE_ID_21 , (PS8)"apConn " }, 190 { FILE_ID_22 , (PS8)"broadcastKey802_1x " }, 191 { FILE_ID_23 , (PS8)"broadcastKeyNone " }, 192 { FILE_ID_24 , (PS8)"broadcastKeySM " }, 193 { FILE_ID_25 , (PS8)"conn " }, 194 { FILE_ID_26 , (PS8)"connIbss " }, 195 { FILE_ID_27 , (PS8)"connInfra " }, 196 { FILE_ID_28 , (PS8)"keyDerive " }, 197 { FILE_ID_29 , (PS8)"keyDeriveAes " }, 198 { FILE_ID_30 , (PS8)"keyDeriveCkip " }, 199 { FILE_ID_31 , (PS8)"keyDeriveTkip " }, 200 { FILE_ID_32 , (PS8)"keyDeriveWep " }, 201 { FILE_ID_33 , (PS8)"keyParser " }, 202 { FILE_ID_34 , (PS8)"keyParserExternal " }, 203 { FILE_ID_35 , (PS8)"keyParserWep " }, 204 { FILE_ID_36 , (PS8)"mainKeysSm " }, 205 { FILE_ID_37 , (PS8)"mainSecKeysOnly " }, 206 { FILE_ID_38 , (PS8)"mainSecNull " }, 207 { FILE_ID_39 , (PS8)"mainSecSm " }, 208 { FILE_ID_40 , (PS8)"rsn " }, 209 { FILE_ID_41 , (PS8)"sme " }, 210 { FILE_ID_42 , (PS8)"smeSelect " }, 211 { FILE_ID_43 , (PS8)"smeSm " }, 212 { FILE_ID_44 , (PS8)"unicastKey802_1x " }, 213 { FILE_ID_45 , (PS8)"unicastKeyNone " }, 214 { FILE_ID_46 , (PS8)"unicastKeySM " }, 215 { FILE_ID_47 , (PS8)"CmdDispatcher " }, 216 { FILE_ID_48 , (PS8)"CmdHndlr " }, 217 { FILE_ID_49 , (PS8)"DrvMain " }, 218 { FILE_ID_50 , (PS8)"EvHandler " }, 219 { FILE_ID_51 , (PS8)"Ctrl " }, 220 { FILE_ID_52 , (PS8)"GeneralUtil " }, 221 { FILE_ID_53 , (PS8)"RateAdaptation " }, 222 { FILE_ID_54 , (PS8)"rx " }, 223 { FILE_ID_55 , (PS8)"TrafficMonitor " }, 224 { FILE_ID_56 , (PS8)"txCtrl " }, 225 { FILE_ID_57 , (PS8)"txCtrlParams " }, 226 { FILE_ID_58 , (PS8)"txCtrlServ " }, 227 { FILE_ID_59 , (PS8)"TxDataClsfr " }, 228 { FILE_ID_60 , (PS8)"txDataQueue " }, 229 { FILE_ID_61 , (PS8)"txMgmtQueue " }, 230 { FILE_ID_62 , (PS8)"txPort " }, 231 { FILE_ID_63 , (PS8)"assocSM " }, 232 { FILE_ID_64 , (PS8)"authSm " }, 233 { FILE_ID_65 , (PS8)"currBss " }, 234 { FILE_ID_66 , (PS8)"healthMonitor " }, 235 { FILE_ID_67 , (PS8)"mlmeBuilder " }, 236 { FILE_ID_68 , (PS8)"mlmeParser " }, 237 { FILE_ID_69 , (PS8)"mlmeSm " }, 238 { FILE_ID_70 , (PS8)"openAuthSm " }, 239 { FILE_ID_71 , (PS8)"PowerMgr " }, 240 { FILE_ID_72 , (PS8)"PowerMgrDbgPrint " }, 241 { FILE_ID_73 , (PS8)"PowerMgrKeepAlive " }, 242 { FILE_ID_74 , (PS8)"qosMngr " }, 243 { FILE_ID_75 , (PS8)"roamingInt " }, 244 { FILE_ID_76 , (PS8)"ScanCncn " }, 245 { FILE_ID_77 , (PS8)"ScanCncnApp " }, 246 { FILE_ID_78 , (PS8)"ScanCncnOsSm " }, 247 { FILE_ID_79 , (PS8)"ScanCncnSm " }, 248 { FILE_ID_80 , (PS8)"ScanCncnSmSpecific " }, 249 { FILE_ID_81 , (PS8)"scanResultTable " }, 250 { FILE_ID_82 , (PS8)"scr " }, 251 { FILE_ID_83 , (PS8)"sharedKeyAuthSm " }, 252 { FILE_ID_84 , (PS8)"siteHash " }, 253 { FILE_ID_85 , (PS8)"siteMgr " }, 254 { FILE_ID_86 , (PS8)"StaCap " }, 255 { FILE_ID_87 , (PS8)"systemConfig " }, 256 { FILE_ID_88 , (PS8)"templates " }, 257 { FILE_ID_89 , (PS8)"trafficAdmControl " }, 258 { FILE_ID_90 , (PS8)"CmdBld " }, 259 { FILE_ID_91 , (PS8)"CmdBldCfg " }, 260 { FILE_ID_92 , (PS8)"CmdBldCfgIE " }, 261 { FILE_ID_93 , (PS8)"CmdBldCmd " }, 262 { FILE_ID_94 , (PS8)"CmdBldCmdIE " }, 263 { FILE_ID_95 , (PS8)"CmdBldItr " }, 264 { FILE_ID_96 , (PS8)"CmdBldItrIE " }, 265 { FILE_ID_97 , (PS8)"CmdQueue " }, 266 { FILE_ID_98 , (PS8)"RxQueue " }, 267 { FILE_ID_99 , (PS8)"txCtrlBlk " }, 268 { FILE_ID_100 , (PS8)"txHwQueue " }, 269 { FILE_ID_101 , (PS8)"CmdMBox " }, 270 { FILE_ID_102 , (PS8)"eventMbox " }, 271 { FILE_ID_103 , (PS8)"fwDebug " }, 272 { FILE_ID_104 , (PS8)"FwEvent " }, 273 { FILE_ID_105 , (PS8)"HwInit " }, 274 { FILE_ID_106 , (PS8)"RxXfer " }, 275 { FILE_ID_107 , (PS8)"txResult " }, 276 { FILE_ID_108 , (PS8)"txXfer " }, 277 { FILE_ID_109 , (PS8)"MacServices " }, 278 { FILE_ID_110 , (PS8)"MeasurementSrv " }, 279 { FILE_ID_111 , (PS8)"measurementSrvDbgPrint " }, 280 { FILE_ID_112 , (PS8)"MeasurementSrvSM " }, 281 { FILE_ID_113 , (PS8)"PowerSrv " }, 282 { FILE_ID_114 , (PS8)"PowerSrvSM " }, 283 { FILE_ID_115 , (PS8)"ScanSrv " }, 284 { FILE_ID_116 , (PS8)"ScanSrvSM " }, 285 { FILE_ID_117 , (PS8)"TWDriver " }, 286 { FILE_ID_118 , (PS8)"TWDriverCtrl " }, 287 { FILE_ID_119 , (PS8)"TWDriverRadio " }, 288 { FILE_ID_120 , (PS8)"TWDriverTx " }, 289 { FILE_ID_121 , (PS8)"TwIf " }, 290 { FILE_ID_122 , (PS8)"SdioBusDrv " }, 291 { FILE_ID_123 , (PS8)"TxnQueue " }, 292 { FILE_ID_124 , (PS8)"WspiBusDrv " }, 293 { FILE_ID_125 , (PS8)"context " }, 294 { FILE_ID_126 , (PS8)"freq " }, 295 { FILE_ID_127 , (PS8)"fsm " }, 296 { FILE_ID_128 , (PS8)"GenSM " }, 297 { FILE_ID_129 , (PS8)"mem " }, 298 { FILE_ID_130 , (PS8)"queue " }, 299 { FILE_ID_131 , (PS8)"rate " }, 300 { FILE_ID_132 , (PS8)"report " }, 301 { FILE_ID_133 , (PS8)"stack " } 302 }; 303 304 static named_value_t report_severity[] = { 305 { 0, (PS8)"----" }, 306 { REPORT_SEVERITY_INIT, (PS8)"INIT", }, 307 { REPORT_SEVERITY_INFORMATION, (PS8)"INFORMATION", }, 308 { REPORT_SEVERITY_WARNING, (PS8)"WARNING", }, 309 { REPORT_SEVERITY_ERROR, (PS8)"ERROR", }, 310 { REPORT_SEVERITY_FATAL_ERROR, (PS8)"FATAL_ERROR", }, 311 { REPORT_SEVERITY_SM, (PS8)"SM", }, 312 { REPORT_SEVERITY_CONSOLE, (PS8)"CONSOLE" } 313 }; 314 315 static named_value_t power_level[] = { 316 { OS_POWER_LEVEL_ELP, (PS8)"Extreme Low Power" }, 317 { OS_POWER_LEVEL_PD, (PS8)"Power Down" }, 318 { OS_POWER_LEVEL_AWAKE, (PS8)"Awake" }, 319 }; 320 321 static named_value_t band2Str[] = { 322 { RADIO_BAND_2_4_GHZ, (PS8)"2.4 GHz" }, 323 { RADIO_BAND_5_0_GHZ, (PS8)"5.0 GHz" }, 324 { RADIO_BAND_DUAL, (PS8)"Both " } 325 }; 326 327 static named_value_t EtEvent2Str[] = { 328 { SCAN_ET_COND_DISABLE, (PS8)"ET disabled " }, 329 { SCAN_ET_COND_BEACON, (PS8)"ET on Beacon " }, 330 { SCAN_ET_COND_PROBE_RESP, (PS8)"ET on Prb Rsp" }, 331 { SCAN_ET_COND_ANY_FRAME, (PS8)"ET on both " } 332 }; 333 334 static named_value_t rate2Str[] = { 335 { DRV_RATE_MASK_AUTO, (PS8)"Auto " }, 336 { DRV_RATE_MASK_1_BARKER, (PS8)"1 Mbps " }, 337 { DRV_RATE_MASK_2_BARKER, (PS8)"2 Mbps " }, 338 { DRV_RATE_MASK_5_5_CCK, (PS8)"5.5 Mbps" }, 339 { DRV_RATE_MASK_11_CCK, (PS8)"11 Mbps " }, 340 { DRV_RATE_MASK_22_PBCC, (PS8)"22 Mbps " }, 341 { DRV_RATE_MASK_6_OFDM, (PS8)"6 Mbps " }, 342 { DRV_RATE_MASK_9_OFDM, (PS8)"9 Mbps " }, 343 { DRV_RATE_MASK_12_OFDM, (PS8)"12 Mbps " }, 344 { DRV_RATE_MASK_18_OFDM, (PS8)"18 Mbps " }, 345 { DRV_RATE_MASK_24_OFDM, (PS8)"24 Mbps " }, 346 { DRV_RATE_MASK_36_OFDM, (PS8)"36 Mbps " }, 347 { DRV_RATE_MASK_48_OFDM, (PS8)"48 Mbps " }, 348 { DRV_RATE_MASK_54_OFDM, (PS8)"54 Mbps " } 349 }; 350 351 static named_value_t scanType2Str[] = { 352 { SCAN_TYPE_NORMAL_PASSIVE, (PS8)"Passive Normal Scan" }, 353 { SCAN_TYPE_NORMAL_ACTIVE, (PS8)"Active Normal Scan" }, 354 { SCAN_TYPE_SPS, (PS8)"Scheduled Passive Scan (SPS)" }, 355 { SCAN_TYPE_TRIGGERED_PASSIVE, (PS8)"Passive Triggered Scan" }, 356 { SCAN_TYPE_TRIGGERED_ACTIVE, (PS8)"Active Triggered Scan" } 357 }; 358 359 static named_value_t booleanStr[] = { 360 { FALSE, (PS8)"False" }, 361 { TRUE, (PS8)"True" } 362 }; 363 364 static named_value_t ssidVisabilityStr[] = { 365 { SCAN_SSID_VISABILITY_PUBLIC, (PS8)"Public" }, 366 { SCAN_SSID_VISABILITY_HIDDEN, (PS8)"Hidden" } 367 }; 368 369 static named_value_t bssTypeStr[] = { 370 { BSS_INDEPENDENT, (PS8)"Independent" }, 371 { BSS_INFRASTRUCTURE, (PS8)"Infrastructure" }, 372 { BSS_ANY, (PS8)"Any" } 373 }; 374 375 static named_value_t power_mode_val[] = { 376 { OS_POWER_MODE_AUTO, (PS8)"AUTO" }, 377 { OS_POWER_MODE_ACTIVE, (PS8)"ACTIVE" }, 378 { OS_POWER_MODE_SHORT_DOZE, (PS8)"SHORT_DOZE" }, 379 { OS_POWER_MODE_LONG_DOZE, (PS8)"LONG_DOZE" } 380 }; 381 382 static named_value_t encrypt_type[] = { 383 { OS_ENCRYPTION_TYPE_NONE, (PS8)"None" }, 384 { OS_ENCRYPTION_TYPE_WEP, (PS8)"WEP" }, 385 { OS_ENCRYPTION_TYPE_TKIP, (PS8)"TKIP" }, 386 { OS_ENCRYPTION_TYPE_AES, (PS8)"AES" } 387 }; 388 389 static named_value_t tKeepAliveTriggerTypes[] = { 390 { KEEP_ALIVE_TRIG_TYPE_NO_TX, (PS8)"When Idle" }, 391 { KEEP_ALIVE_TRIG_TYPE_PERIOD_ONLY, (PS8)"Always" } 392 }; 393 394 #if 0 /* need to create debug logic for CLI */ 395 static named_value_t cli_level_type[] = { 396 { CU_MSG_DEBUG, (PS8)"CU_MSG_DEBUG" }, 397 { CU_MSG_INFO1, (PS8)"CU_MSG_INFO1" }, 398 { CU_MSG_WARNING, (PS8)"CU_MSG_WARNING" }, 399 { CU_MSG_ERROR, (PS8)"CU_MSG_ERROR" }, 400 { CU_MSG_INFO2, (PS8)"CU_MSG_INFO2" } 401 }; 402 #endif 403 404 405 /* local fucntions */ 406 /*******************/ 407 static S32 CuCmd_Str2MACAddr(PS8 str, PU8 mac) 408 { 409 S32 i; 410 411 for( i=0; i<MAC_ADDR_LEN; i++ ) 412 { 413 mac[i] = (U8) os_strtoul(str, &str, 16); 414 str++; 415 } 416 return TRUE; 417 } 418 419 /* used in get_bssid_list() */ 420 static U8 CuCmd_Freq2Chan(U32 freq) 421 { 422 U32 i; 423 424 for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++) 425 if(ChanFreq[i].freq == freq) 426 return ChanFreq[i].chan; 427 428 return 0; 429 } 430 431 /* Converts a single ASCII character to a hex value (i.e. '0'-'9' = 0-9, 'a'-'f' = a-f, 'A'-'F' = a-f) */ 432 static U8 CuCmd_atox(U8 c) 433 { 434 if (('0' <= c) && ('9' >= c)) 435 { 436 return c - '0'; 437 } 438 else if (('a' <= c) && ('f' >= c)) 439 { 440 return c - 'a' + 10; 441 } 442 else /* assuming input is valid */ 443 { 444 return c - 'A' + 10; 445 } 446 } 447 448 /* converts an ASCII string to a buffer */ 449 static void CuCmd_atox_string (U8* srcString, U8* dstBuffer) 450 { 451 U32 uIndex, uLength; 452 453 uLength = os_strlen ((PS8)srcString); 454 455 /* clear the destination buffer */ 456 os_memset (dstBuffer, 0, (uLength / 2) + 1); 457 458 for (uIndex = 0; uIndex < uLength; uIndex++) 459 { 460 if (0 == (uIndex % 2)) 461 { 462 dstBuffer[ uIndex / 2 ] |= (CuCmd_atox (srcString[ uIndex ]) << 4); 463 } 464 else 465 { 466 dstBuffer[ uIndex / 2 ] |= CuCmd_atox (srcString[ uIndex ]); 467 } 468 } 469 } 470 471 static void CuCmd_xtoa_string (U8* srcBuffer, U32 srcBufferLength, U8* dstString) 472 { 473 U32 uIndex; 474 475 for (uIndex = 0; uIndex < srcBufferLength; uIndex++) 476 { 477 os_sprintf ((PS8)&(dstString[ uIndex * 2 ]), (PS8)"%02x", srcBuffer[ uIndex ]); 478 } 479 } 480 481 static VOID CuCmd_Init_Scan_Params(CuCmd_t* pCuCmd) 482 { 483 U8 i,j; 484 485 /* init application scan default params */ 486 pCuCmd->appScanParams.desiredSsid.len = 0; 487 pCuCmd->appScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE; 488 pCuCmd->appScanParams.band = RADIO_BAND_2_4_GHZ; 489 pCuCmd->appScanParams.probeReqNumber = 3; 490 pCuCmd->appScanParams.probeRequestRate = RATE_MASK_UNSPECIFIED; /* Let the FW select */; 491 pCuCmd->appScanParams.numOfChannels = 14; 492 for ( i = 0; i < 14; i++ ) 493 { 494 for ( j = 0; j < 6; j++ ) 495 { 496 pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry.bssId[ j ] = 0xff; 497 } 498 pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE; 499 pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes = 0; 500 pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 60000; 501 pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 30000; 502 pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry.txPowerDbm = DEF_TX_POWER; 503 pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry.channel = i + 1; 504 } 505 506 /* init periodic application scan params */ 507 pCuCmd->tPeriodicAppScanParams.uSsidNum = 0; 508 pCuCmd->tPeriodicAppScanParams.uSsidListFilterEnabled = 1; 509 pCuCmd->tPeriodicAppScanParams.uCycleNum = 0; /* forever */ 510 pCuCmd->tPeriodicAppScanParams.uCycleIntervalMsec[ 0 ] = 3; 511 for (i = 1; i < PERIODIC_SCAN_MAX_INTERVAL_NUM; i++) 512 { 513 pCuCmd->tPeriodicAppScanParams.uCycleIntervalMsec[ i ] = 30000; 514 } 515 pCuCmd->tPeriodicAppScanParams.iRssiThreshold = -80; 516 pCuCmd->tPeriodicAppScanParams.iSnrThreshold = 0; 517 pCuCmd->tPeriodicAppScanParams.uFrameCountReportThreshold = 1; 518 pCuCmd->tPeriodicAppScanParams.bTerminateOnReport = TRUE; 519 pCuCmd->tPeriodicAppScanParams.eBssType = BSS_ANY; 520 pCuCmd->tPeriodicAppScanParams.uProbeRequestNum = 3; 521 pCuCmd->tPeriodicAppScanParams.uChannelNum = 14; 522 for ( i = 0; i < 14; i++ ) 523 { 524 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].eBand = RADIO_BAND_2_4_GHZ; 525 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uChannel = i + 1; 526 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].eScanType = SCAN_TYPE_NORMAL_ACTIVE; 527 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uMinDwellTimeMs = 5; 528 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uMaxDwellTimeMs = 20; 529 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uTxPowerLevelDbm = DEF_TX_POWER; 530 } 531 532 /* init default scan policy */ 533 pCuCmd->scanPolicy.normalScanInterval = 10000; 534 pCuCmd->scanPolicy.deterioratingScanInterval = 5000; 535 pCuCmd->scanPolicy.maxTrackFailures = 3; 536 pCuCmd->scanPolicy.BSSListSize = 4; 537 pCuCmd->scanPolicy.BSSNumberToStartDiscovery = 1; 538 pCuCmd->scanPolicy.numOfBands = 1; 539 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].band = RADIO_BAND_2_4_GHZ; 540 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].rxRSSIThreshold = -80; 541 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].numOfChannles = 14; 542 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].numOfChannlesForDiscovery = 3; 543 for ( i = 0; i < 14; i++ ) 544 { 545 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].channelList[ i ] = i + 1; 546 } 547 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE; 548 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE; 549 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0; 550 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.maxChannelDwellTime = 30000; 551 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.minChannelDwellTime = 15000; 552 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.bitrate = RATE_MASK_UNSPECIFIED; /* Let the FW select */ 553 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3; 554 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = DEF_TX_POWER; 555 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE; 556 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE; 557 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0; 558 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.maxChannelDwellTime = 30000; 559 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.minChannelDwellTime = 15000; 560 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.bitrate = RATE_MASK_UNSPECIFIED; /* Let the FW select */; 561 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3; 562 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = DEF_TX_POWER; 563 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE; 564 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE; 565 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0; 566 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = 30000; 567 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.minChannelDwellTime = 15000; 568 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = RATE_MASK_UNSPECIFIED; /* Let the FW select */; 569 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3; 570 pCuCmd->scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = DEF_TX_POWER; 571 } 572 573 char* PrintSSID(OS_802_11_SSID* ssid) 574 { 575 if(ssid->SsidLength < 32) 576 ssid->Ssid[ssid->SsidLength] = 0; 577 else 578 ssid->Ssid[31] = 0; 579 580 return (char*)&ssid->Ssid[0]; 581 } 582 583 584 static VOID CuCmd_PrintBssidList(OS_802_11_BSSID_LIST_EX* bssidList, S32 IsFullPrint, TMacAddr CurrentBssid) 585 { 586 U32 i; 587 S8 connectionTypeStr[50]; 588 POS_802_11_BSSID_EX pBssid = &bssidList->Bssid[0]; 589 590 os_error_printf(CU_MSG_INFO2, (PS8)"BssId List: Num=%u\n", bssidList->NumberOfItems); 591 os_error_printf(CU_MSG_INFO2, (PS8)" MAC Privacy Rssi Mode Channel SSID\n"); 592 for(i=0; i<bssidList->NumberOfItems; i++) 593 { 594 switch (pBssid->InfrastructureMode) 595 { 596 case os802_11IBSS: 597 os_strcpy (connectionTypeStr, (PS8)"Adhoc"); 598 break; 599 case os802_11Infrastructure: 600 os_strcpy (connectionTypeStr, (PS8)"Infra"); 601 break; 602 case os802_11AutoUnknown: 603 os_strcpy (connectionTypeStr, (PS8)"Auto"); 604 break; 605 default: 606 os_strcpy (connectionTypeStr, (PS8)" --- "); 607 break; 608 } 609 os_error_printf(CU_MSG_INFO2, (PS8)"%s%02x.%02x.%02x.%02x.%02x.%02x %3u %4d %s %6d %s\n", 610 (!os_memcmp(CurrentBssid, pBssid->MacAddress, MAC_ADDR_LEN))?"*":" ", 611 pBssid->MacAddress[0], 612 pBssid->MacAddress[1], 613 pBssid->MacAddress[2], 614 pBssid->MacAddress[3], 615 pBssid->MacAddress[4], 616 pBssid->MacAddress[5], 617 pBssid->Privacy, 618 (char)pBssid->Rssi | 0xffffff00, /* need the 0xffffff00 to get negative value display */ 619 connectionTypeStr, 620 CuCmd_Freq2Chan(pBssid->Configuration.Union.channel), 621 (pBssid->Ssid.Ssid[0] == '\0')?(PS8)"****":((PS8)pBssid->Ssid.Ssid) ); 622 623 if (IsFullPrint) 624 { 625 os_error_printf(CU_MSG_INFO2, (PS8)" BeaconInterval %d\n", pBssid->Configuration.BeaconPeriod); 626 os_error_printf(CU_MSG_INFO2, (PS8)" Capabilities 0x%x\n", pBssid->Capabilities); 627 } 628 #ifdef _WINDOWS 629 pBssid = (POS_802_11_BSSID_EX)((S8*)pBssid + (pBssid->Length ? pBssid->Length : sizeof(OS_802_11_BSSID_EX))); 630 #else /*for Linux*/ 631 pBssid = &bssidList->Bssid[i+1]; 632 #endif 633 } 634 } 635 636 static U8 CuCmd_Char2Hex( S8 c ) 637 { 638 if( c >= '0' && c <= '9' ) 639 return c - '0'; 640 else if( os_tolower(c) >= 'a' && os_tolower(c) <= 'f' ) 641 return (U8) (os_tolower(c) - 'a' + 0x0a); 642 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Char2Hex - invalid symbol '%c'\n", c ); 643 return ((U8)-1); 644 } 645 646 static PS8 CuCmd_CreateRateStr(PS8 str, U8 rate) 647 { 648 if( rate == 0 ) 649 return os_strcpy(str,(PS8)"Auto (0)"); 650 651 os_sprintf(str, (PS8)"%.3g Mbps", 652 RATE_2_MBPS(rate)); 653 654 return str; 655 } 656 657 static VOID CuCmd_PrintScanMethod(scan_Method_t* scanMethod) 658 { 659 S32 i; 660 os_error_printf(CU_MSG_INFO2, (PS8)"Scan type: %s\n", scanType2Str[ scanMethod->scanType ].name); 661 switch (scanMethod->scanType) 662 { 663 case SCAN_TYPE_NORMAL_ACTIVE: 664 case SCAN_TYPE_NORMAL_PASSIVE: 665 os_error_printf(CU_MSG_INFO2, (PS8)"Max channel dwell time: %d, Min channel dwell time: %d\n", 666 scanMethod->method.basicMethodParams.maxChannelDwellTime, 667 scanMethod->method.basicMethodParams.minChannelDwellTime); 668 669 CU_CMD_FIND_NAME_ARRAY(i, EtEvent2Str, scanMethod->method.basicMethodParams.earlyTerminationEvent); 670 os_error_printf(CU_MSG_INFO2 ,(PS8)"ET condition: %s, ET number of frames: %d\n", 671 EtEvent2Str[i].name, 672 scanMethod->method.basicMethodParams.ETMaxNumberOfApFrames); 673 674 CU_CMD_FIND_NAME_ARRAY(i, rate2Str, scanMethod->method.basicMethodParams.probReqParams.bitrate); 675 os_error_printf(CU_MSG_INFO2 ,(PS8)"Probe request number: %d, probe request rate: %s, TX level: %d\n", 676 scanMethod->method.basicMethodParams.probReqParams.numOfProbeReqs, 677 rate2Str[i].name, 678 scanMethod->method.basicMethodParams.probReqParams.txPowerDbm); 679 break; 680 681 case SCAN_TYPE_TRIGGERED_ACTIVE: 682 case SCAN_TYPE_TRIGGERED_PASSIVE: 683 os_error_printf(CU_MSG_INFO2, (PS8)"Triggering Tid: %d\n", scanMethod->method.TidTriggerdMethodParams.triggeringTid); 684 os_error_printf(CU_MSG_INFO2, (PS8)"Max channel dwell time: %d, Min channel dwell time: %d\n", 685 scanMethod->method.basicMethodParams.maxChannelDwellTime, 686 scanMethod->method.basicMethodParams.minChannelDwellTime); 687 688 CU_CMD_FIND_NAME_ARRAY(i, EtEvent2Str, scanMethod->method.basicMethodParams.earlyTerminationEvent); 689 os_error_printf(CU_MSG_INFO2, (PS8)"ET condition: %s, ET number of frames: %d\n", 690 EtEvent2Str[i].name, 691 scanMethod->method.basicMethodParams.ETMaxNumberOfApFrames); 692 693 CU_CMD_FIND_NAME_ARRAY(i, rate2Str, scanMethod->method.basicMethodParams.probReqParams.bitrate); 694 os_error_printf(CU_MSG_INFO2, (PS8)"Probe request number: %d, probe request rate: %s, TX level: %d\n", 695 scanMethod->method.basicMethodParams.probReqParams.numOfProbeReqs, 696 rate2Str[i].name, 697 scanMethod->method.basicMethodParams.probReqParams.txPowerDbm); 698 break; 699 700 case SCAN_TYPE_SPS: 701 CU_CMD_FIND_NAME_ARRAY(i, EtEvent2Str, scanMethod->method.spsMethodParams.earlyTerminationEvent); 702 os_error_printf(CU_MSG_INFO2, (PS8)"ET condition: %s, ET number of frames: %d\n", 703 EtEvent2Str[i].name, 704 scanMethod->method.spsMethodParams.ETMaxNumberOfApFrames); 705 os_error_printf(CU_MSG_INFO2, (PS8)"Scan duration: %d\n", scanMethod->method.spsMethodParams.scanDuration); 706 break; 707 708 case SCAN_TYPE_NO_SCAN: 709 case SCAN_TYPE_PACTSIVE: 710 break; 711 } 712 } 713 714 static VOID CuCmd_PrintScanBand(scan_bandPolicy_t* pBandPolicy) 715 { 716 S32 j; 717 718 os_error_printf(CU_MSG_INFO2, (PS8)"\nBand: %s\n", band2Str[ pBandPolicy->band ].name); 719 os_error_printf(CU_MSG_INFO2, (PS8)"RSSI Threshold: %d dBm\n", pBandPolicy->rxRSSIThreshold); 720 os_error_printf(CU_MSG_INFO2, (PS8)"Number of channels for each discovery interval: %d\n", pBandPolicy->numOfChannlesForDiscovery); 721 os_error_printf(CU_MSG_INFO2, (PS8)"\nTracking Method:\n"); 722 CuCmd_PrintScanMethod( &(pBandPolicy->trackingMethod) ); 723 os_error_printf(CU_MSG_INFO2, (PS8)"\nDiscovery Method:\n"); 724 CuCmd_PrintScanMethod( &(pBandPolicy->discoveryMethod) ); 725 os_error_printf(CU_MSG_INFO2, (PS8)"\nImmediate Scan Method:\n"); 726 CuCmd_PrintScanMethod( &(pBandPolicy->immediateScanMethod) ); 727 if ( pBandPolicy->numOfChannles > 0 ) 728 { 729 os_error_printf(CU_MSG_INFO2, (PS8)"\nChannel list: "); 730 for ( j = 0; j < pBandPolicy->numOfChannles; j++ ) 731 { 732 os_error_printf(CU_MSG_INFO2, (PS8)"%3d ", pBandPolicy->channelList[ j ]); 733 } 734 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 735 } 736 else 737 { 738 os_error_printf(CU_MSG_INFO2, (PS8)"\nNo channels defined.\n"); 739 } 740 } 741 742 static U32 CuCmd_IsValueRate(U32 rate) 743 { 744 745 switch (rate) 746 { 747 case 1: 748 case 2: 749 case 5: 750 case 6: 751 case 9: 752 case 11: 753 case 12: 754 case 18: 755 case 24: 756 case 36: 757 case 48: 758 case 54: 759 return (TRUE); 760 761 default: 762 return (FALSE); 763 } 764 } 765 766 static VOID CuCmd_ParseMaskString(PS8 pString, PU8 pBuffer, PU8 pLength) 767 { 768 S8 ch; 769 S32 iter = 0; 770 U8 val; 771 772 while ((ch = pString[iter])) 773 { 774 val = (ch == '1' ? 1 : 0); 775 776 if (iter % BIT_TO_BYTE_FACTOR) 777 pBuffer[iter / BIT_TO_BYTE_FACTOR] |= (val << (iter % BIT_TO_BYTE_FACTOR)); 778 else 779 pBuffer[iter / BIT_TO_BYTE_FACTOR] = val; 780 781 ++iter; 782 } 783 784 /* iter = 0 len = 0, iter = 1 len = 1, iter = 8 len = 1, and so on... */ 785 *pLength = (U8) (iter + BIT_TO_BYTE_FACTOR - 1) / BIT_TO_BYTE_FACTOR; 786 } 787 788 static VOID CuCmd_ParsePatternString(PS8 pString, PU8 pBuffer, PU8 pLength) 789 { 790 S8 ch; 791 S32 iter = 0; 792 U8 val; 793 794 while ((ch = pString[iter])) 795 { 796 val = ((ch >= '0' && ch <= '9') ? (ch - '0') : 797 (ch >= 'A' && ch <= 'F') ? (0xA + ch - 'A') : 798 (ch >= 'a' && ch <= 'f') ? (0xA + ch - 'a') : 0); 799 800 /* even indexes go to the lower nibble, odd indexes push them to the */ 801 /* higher nibble and then go themselves to the lower nibble. */ 802 if (iter % 2) 803 pBuffer[iter / 2] = ((pBuffer[iter / 2] << (BIT_TO_BYTE_FACTOR / 2)) | val); 804 else 805 pBuffer[iter / 2] = val; 806 807 ++iter; 808 } 809 810 /* iter = 0 len = 0, iter = 1 len = 1, iter = 2 len = 1, and so on... */ 811 *pLength = (U8) (iter + 1) / 2; 812 } 813 814 /* functions */ 815 /*************/ 816 THandle CuCmd_Create(const PS8 device_name, THandle hConsole, S32 BypassSupplicant, PS8 pSupplIfFile) 817 { 818 THandle hIpcSta; 819 820 CuCmd_t* pCuCmd = (CuCmd_t*)os_MemoryCAlloc(sizeof(CuCmd_t), sizeof(U8)); 821 if(pCuCmd == NULL) 822 { 823 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Create - cant allocate control block\n"); 824 return NULL; 825 } 826 827 pCuCmd->isDeviceRunning = FALSE; 828 pCuCmd->hConsole = hConsole; 829 830 pCuCmd->hCuCommon= CuCommon_Create(&hIpcSta, device_name); 831 if(pCuCmd->hCuCommon == NULL) 832 { 833 CuCmd_Destroy(pCuCmd); 834 return NULL; 835 } 836 837 pCuCmd->hCuWext= CuOs_Create(hIpcSta); 838 if(pCuCmd->hCuWext == NULL) 839 { 840 CuCmd_Destroy(pCuCmd); 841 return NULL; 842 } 843 844 pCuCmd->hIpcEvent = (THandle) IpcEvent_Create(); 845 if(pCuCmd->hIpcEvent == NULL) 846 { 847 CuCmd_Destroy(pCuCmd); 848 return NULL; 849 } 850 851 if(BypassSupplicant) 852 { 853 /* specify that there is no supplicant */ 854 pCuCmd->hWpaCore = NULL; 855 } 856 else 857 { 858 #ifndef NO_WPA_SUPPL 859 S32 res; 860 861 pCuCmd->hWpaCore = WpaCore_Create(&res, pSupplIfFile); 862 if((pCuCmd->hWpaCore == NULL) && (res != EOALERR_IPC_WPA_ERROR_CANT_CONNECT_TO_SUPPL)) 863 { 864 CuCmd_Destroy(pCuCmd); 865 return NULL; 866 } 867 868 if(res == EOALERR_IPC_WPA_ERROR_CANT_CONNECT_TO_SUPPL) 869 { 870 os_error_printf(CU_MSG_ERROR, (PS8)"******************************************************\n"); 871 os_error_printf(CU_MSG_ERROR, (PS8)"Connection to supplicant failed\n"); 872 os_error_printf(CU_MSG_ERROR, (PS8)"******************************************************\n"); 873 } 874 else 875 { 876 os_error_printf(CU_MSG_INFO2, (PS8)"Connection established with supplicant\n"); 877 } 878 #endif 879 } 880 881 CuCmd_Init_Scan_Params(pCuCmd); 882 883 return pCuCmd; 884 } 885 886 VOID CuCmd_Destroy(THandle hCuCmd) 887 { 888 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 889 890 if(pCuCmd->hCuCommon) 891 { 892 CuCommon_Destroy(pCuCmd->hCuCommon); 893 } 894 895 if(pCuCmd->hCuWext) 896 { 897 CuOs_Destroy(pCuCmd->hCuWext); 898 } 899 900 if(pCuCmd->hIpcEvent) 901 { 902 IpcEvent_Destroy(pCuCmd->hIpcEvent); 903 } 904 905 #ifndef NO_WPA_SUPPL 906 if(pCuCmd->hWpaCore) 907 { 908 WpaCore_Destroy(pCuCmd->hWpaCore); 909 } 910 #endif 911 912 os_MemoryFree(pCuCmd); 913 } 914 915 S32 CuCmd_GetDeviceStatus(THandle hCuCmd) 916 { 917 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 918 S32 status; 919 920 status = CuCommon_GetU32(pCuCmd->hCuCommon, DRIVER_STATUS_PARAM, &pCuCmd->isDeviceRunning); 921 922 if ((status == OK) && pCuCmd->isDeviceRunning) 923 return OK; 924 925 return ECUERR_CU_CMD_ERROR_DEVICE_NOT_LOADED; 926 } 927 928 VOID CuCmd_StartDriver(THandle hCuCmd) 929 { 930 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 931 U32 uDummyBuf; 932 933 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, DRIVER_START_PARAM, &uDummyBuf, sizeof(uDummyBuf))) 934 { 935 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - Failed to start driver!\n"); 936 } 937 } 938 939 VOID CuCmd_StopDriver(THandle hCuCmd) 940 { 941 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 942 U32 uDummyBuf; 943 944 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, DRIVER_STOP_PARAM, &uDummyBuf, sizeof(uDummyBuf))) 945 { 946 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - Failed to stop driver!\n"); 947 } 948 } 949 950 #ifdef XCC_MODULE_INCLUDED 951 THandle CuCmd_GetCuCommonHandle(THandle hCuCmd) 952 { 953 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 954 955 return pCuCmd->hCuCommon; 956 } 957 958 THandle CuCmd_GetCuWpaHandle (THandle hCuCmd) 959 { 960 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 961 962 return pCuCmd->hWpaCore; 963 964 } 965 #endif 966 967 VOID CuCmd_Show_Status(THandle hCuCmd, ConParm_t parm[], U16 nParms) 968 { 969 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 970 971 TMacAddr Mac; 972 OS_802_11_SSID ssid; 973 TMacAddr bssid; 974 U32 channel, threadid=0; 975 976 if(OK != CuCmd_GetDeviceStatus(hCuCmd)) 977 { 978 os_error_printf(CU_MSG_INFO2, (PS8)"Driver is stopped!\n"); 979 return; 980 } 981 982 CuOs_GetDriverThreadId(pCuCmd->hCuWext, &threadid); 983 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, CTRL_DATA_MAC_ADDRESS, Mac, sizeof(TMacAddr))) return; 984 if(OK != CuOs_Get_SSID(pCuCmd->hCuWext, &ssid)) return; 985 if(OK != CuOs_Get_BSSID(pCuCmd->hCuWext, bssid)) return; 986 if(OK != CuOs_GetCurrentChannel(pCuCmd->hCuWext, &channel)) return; 987 988 if (threadid != 0) 989 { 990 os_error_printf(CU_MSG_INFO2, (PS8)"Thread id: %u (0x%x)\n\n", threadid, threadid); 991 } 992 os_error_printf(CU_MSG_INFO2, (PS8)"==========================\n"); 993 os_error_printf(CU_MSG_INFO2, (PS8)"Status : running\n"); 994 os_error_printf(CU_MSG_INFO2, (PS8)"MAC : %02x.%02x.%02x.%02x.%02x.%02x\n",Mac[0],Mac[1],Mac[2],Mac[3],Mac[4],Mac[5]); 995 os_error_printf(CU_MSG_INFO2, (PS8)"SSID : %s\n",(ssid.SsidLength)?PrintSSID(&ssid):"<empty>"); 996 os_error_printf(CU_MSG_INFO2, (PS8)"BSSID : %02x.%02x.%02x.%02x.%02x.%02x\n",bssid[0],bssid[1],bssid[2],bssid[3],bssid[4],bssid[5]); 997 if(channel) 998 os_error_printf(CU_MSG_INFO2, (PS8)"Channel : %d\n",channel); 999 else 1000 os_error_printf(CU_MSG_INFO2, (PS8)"Channel : <empty>\n"); 1001 os_error_printf(CU_MSG_INFO2, (PS8)"==========================\n"); 1002 1003 } 1004 1005 VOID CuCmd_BssidList(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1006 { 1007 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1008 U32 SizeOfBssiList=0; 1009 OS_802_11_BSSID_LIST_EX* bssidList; 1010 TMacAddr bssid; 1011 1012 if(OK != CuCommon_Get_BssidList_Size(pCuCmd->hCuCommon, &SizeOfBssiList)) 1013 { 1014 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Bssid_List - cant get Bssid list size\n"); 1015 return; 1016 } 1017 1018 /* allocate the bssidList */ 1019 bssidList = os_MemoryCAlloc(SizeOfBssiList, sizeof(U8)); 1020 if(bssidList == NULL) 1021 { 1022 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Bssid_List - cant allocate Bssid list\n"); 1023 return; 1024 } 1025 1026 if(SizeOfBssiList == sizeof(U32)) 1027 { 1028 /* means that bssidList is empty*/ 1029 bssidList->NumberOfItems = 0; 1030 /* os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Bssid_List - size of list is %d, indicating empty list\n", 1031 sizeof(U32)); */ 1032 } 1033 else 1034 { 1035 if (OK != CuOs_GetBssidList(pCuCmd->hCuWext, bssidList)) 1036 { 1037 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Bssid_List - cant get Bssid list\n"); 1038 os_MemoryFree(bssidList); 1039 return; 1040 } 1041 } 1042 1043 /* get currently connected bssid */ 1044 if(OK != CuOs_Get_BSSID(pCuCmd->hCuWext, bssid)) 1045 { 1046 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Bssid_List - cant get current BSSID\n"); 1047 os_MemoryFree(bssidList); 1048 return; 1049 } 1050 1051 /* print the list to the terminal */ 1052 CuCmd_PrintBssidList(bssidList, FALSE, bssid); 1053 1054 /* free the bssidList */ 1055 os_MemoryFree(bssidList); 1056 1057 } 1058 1059 VOID CuCmd_FullBssidList(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1060 { 1061 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1062 U32 SizeOfBssiList=0; 1063 OS_802_11_BSSID_LIST_EX* bssidList; 1064 TMacAddr bssid; 1065 1066 if(OK != CuCommon_Get_BssidList_Size(pCuCmd->hCuCommon, &SizeOfBssiList)) return; 1067 1068 /* allocate the bssidList */ 1069 bssidList = os_MemoryCAlloc(SizeOfBssiList, sizeof(U8)); 1070 if(bssidList == NULL) 1071 { 1072 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_Bssid_List - cant allocate Bssid list\n"); 1073 return; 1074 } 1075 1076 if(SizeOfBssiList == sizeof(U32)) 1077 { 1078 /* means that bssidList is empty*/ 1079 bssidList->NumberOfItems = 0; 1080 1081 } 1082 else 1083 { 1084 if(OK != CuOs_GetBssidList(pCuCmd->hCuWext, bssidList) ) return; 1085 } 1086 1087 /* get currently connected bssid */ 1088 if(OK != CuOs_Get_BSSID(pCuCmd->hCuWext, bssid)) return; 1089 1090 /* print the list to the terminal */ 1091 CuCmd_PrintBssidList(bssidList, TRUE, bssid); 1092 1093 /* free the bssidList */ 1094 os_MemoryFree(bssidList); 1095 } 1096 1097 #if defined(CONFIG_EAP_WSC) && !defined(NO_WPA_SUPPL) 1098 VOID CuCmd_StartEnrolleePIN(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1099 { 1100 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1101 1102 if (pCuCmd->hWpaCore == NULL) 1103 { 1104 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - Cannot start Enrollee without connection to supplicant\n"); 1105 return; 1106 } 1107 1108 WpaCore_StartWpsPIN(pCuCmd->hWpaCore); 1109 os_error_printf(CU_MSG_INFO2, (PS8)"WPS in PIN mode started\n"); 1110 } 1111 1112 VOID CuCmd_StartEnrolleePBC(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1113 { 1114 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1115 1116 if (pCuCmd->hWpaCore == NULL) 1117 { 1118 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - Cannot start Enrollee push button without connection to supplicant\n"); 1119 return; 1120 } 1121 1122 WpaCore_StartWpsPBC(pCuCmd->hWpaCore); 1123 os_error_printf(CU_MSG_INFO2, (PS8)"WPS in PBC mode started\n"); 1124 } 1125 1126 VOID CuCmd_StopEnrollee(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1127 { 1128 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1129 if (pCuCmd->hWpaCore == NULL) 1130 { 1131 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - Cannot Stop Enrollee without connection to supplicant\n"); 1132 return; 1133 } 1134 1135 WpaCore_StopWps(pCuCmd->hWpaCore); 1136 os_error_printf(CU_MSG_INFO2, (PS8)"WPS mode stopped\n"); 1137 } 1138 1139 VOID CuCmd_SetPin(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1140 { 1141 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1142 1143 if (pCuCmd->hWpaCore == NULL) 1144 { 1145 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - Cannot set PIN without connection to supplicant\n"); 1146 return; 1147 } 1148 1149 WpaCore_SetPin(pCuCmd->hWpaCore, (PS8)parm[0].value); 1150 os_error_printf(CU_MSG_INFO2, (PS8)"WPS PIN set %s\n", parm[0].value); 1151 } 1152 1153 #endif /* CONFIG_EAP_WSC */ 1154 1155 VOID CuCmd_Connect(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1156 { 1157 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1158 TMacAddr bssid = { 0xff,0xff,0xff,0xff,0xff,0xff }; 1159 OS_802_11_SSID ssid; 1160 U32 BssType; 1161 1162 switch (nParms) 1163 { 1164 case 0 : 1165 /* 1166 * No SSID & No BSSID are set - 1167 * Use Any SSID & Any BSSID. 1168 */ 1169 ssid.SsidLength = 0; 1170 ssid.Ssid[0] = 0; 1171 break; 1172 case 1: 1173 /* 1174 * SSID set & BSSID insn't set - 1175 * Use CLI's SSID & Any BSSID. 1176 */ 1177 ssid.SsidLength = os_strlen( (PS8)parm[0].value); 1178 os_memcpy((PVOID)ssid.Ssid, (PVOID) parm[0].value, ssid.SsidLength); 1179 ssid.Ssid[ssid.SsidLength] = '\0'; 1180 break; 1181 case 2: 1182 /* 1183 * Both SSID & BSSID are set - 1184 * Use CLI's SSID & BSSID. 1185 */ 1186 if(!CuCmd_Str2MACAddr( (PS8)parm[1].value, bssid) ) 1187 return; 1188 ssid.SsidLength = os_strlen((PS8) parm[0].value); 1189 os_memcpy((PVOID)ssid.Ssid, (PVOID) parm[0].value, ssid.SsidLength); 1190 ssid.Ssid[ssid.SsidLength] = '\0'; 1191 break; 1192 } 1193 1194 if(pCuCmd->hWpaCore == NULL) 1195 { 1196 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, CTRL_DATA_CURRENT_BSS_TYPE_PARAM, &BssType)) return; 1197 1198 if((BssType == os802_11IBSS/* Ad-Hoc */) && (ssid.SsidLength == 0)) 1199 { 1200 os_error_printf(CU_MSG_INFO2, (PS8)"SSID string is needed due to fact that BSS Type set to Ad-Hoc.\n"); 1201 return; 1202 } 1203 1204 if(OK != CuOs_Set_BSSID(pCuCmd->hCuWext, bssid ) ) return; 1205 if(OK != CuOs_Set_ESSID(pCuCmd->hCuWext, &ssid) ) return; 1206 } 1207 else 1208 { 1209 #ifndef NO_WPA_SUPPL 1210 if(OK != WpaCore_GetBssType(pCuCmd->hWpaCore, &BssType)) return; 1211 1212 if((BssType == os802_11IBSS/* Ad-Hoc */) && (ssid.SsidLength == 0)) 1213 { 1214 os_error_printf(CU_MSG_INFO2, (PS8)"SSID string is needed due to fact BSS Type set to Ad-Hoc\n"); 1215 return; 1216 } 1217 1218 WpaCore_SetSsid(pCuCmd->hWpaCore, &ssid, bssid); 1219 #endif 1220 } 1221 } 1222 1223 VOID CuCmd_Disassociate(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1224 { 1225 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1226 1227 if(pCuCmd->hWpaCore == NULL) 1228 { 1229 OS_802_11_SSID ssid; 1230 1231 ssid.SsidLength = MAX_SSID_LEN; 1232 os_memset(ssid.Ssid, 0, MAX_SSID_LEN); 1233 1234 CuOs_Set_ESSID(pCuCmd->hCuWext, &ssid); 1235 } 1236 else 1237 { 1238 #ifndef NO_WPA_SUPPL 1239 WpaCore_Disassociate(pCuCmd->hWpaCore); 1240 #endif 1241 } 1242 } 1243 1244 VOID CuCmd_ModifySsid(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1245 { 1246 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1247 OS_802_11_SSID ssid; 1248 TMacAddr bssid = { 0xff,0xff,0xff,0xff,0xff,0xff }; 1249 1250 if( nParms == 0 ) 1251 { 1252 OS_802_11_SSID ssid; 1253 if(OK != CuOs_Get_SSID(pCuCmd->hCuWext, &ssid)) return; 1254 os_error_printf(CU_MSG_INFO2, (PS8)"SSID: %s\n",(ssid.SsidLength)?(PS8)PrintSSID(&ssid):(PS8)"<empty>"); 1255 } 1256 else 1257 { 1258 /* Setting the new SSID, BRCS BSSID is set to clean pre-set BSSID */ 1259 ssid.SsidLength = os_strlen((PS8) parm[0].value); 1260 os_memcpy((PVOID)ssid.Ssid, (PVOID) parm[0].value, ssid.SsidLength); 1261 if(ssid.SsidLength < MAX_SSID_LEN) 1262 { 1263 ssid.Ssid[ssid.SsidLength] = 0; 1264 } 1265 1266 if(OK != CuOs_Set_BSSID(pCuCmd->hCuWext, bssid ) ) return; 1267 if(OK != CuOs_Set_ESSID(pCuCmd->hCuWext, &ssid) ) return; 1268 } 1269 } 1270 1271 VOID CuCmd_ModifyConnectMode(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1272 { 1273 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1274 U32 i; 1275 1276 if( nParms == 0 ) 1277 { 1278 U32 uConnectMode; 1279 1280 if(OK != CuCommon_GetU32 (pCuCmd->hCuCommon, SME_CONNECTION_MODE_PARAM, &uConnectMode)) return; 1281 CU_CMD_FIND_NAME_ARRAY (i, Current_mode, uConnectMode); 1282 os_error_printf (CU_MSG_INFO2, (PS8)"Current mode = %s\n", Current_mode[i].name); 1283 print_available_values (Current_mode); 1284 } 1285 else 1286 { 1287 U32 uConnectMode = parm[0].value; 1288 1289 /* check if the param is valid */ 1290 CU_CMD_FIND_NAME_ARRAY (i, Current_mode, uConnectMode); 1291 if(i == SIZE_ARR(Current_mode)) 1292 { 1293 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_ModifyConnectMode, Connect Mode %d is not defined!\n", uConnectMode); 1294 print_available_values (Current_mode); 1295 return; 1296 } 1297 else 1298 { 1299 CuCommon_SetU32(pCuCmd->hCuCommon, SME_CONNECTION_MODE_PARAM, uConnectMode); 1300 } 1301 } 1302 } 1303 1304 VOID CuCmd_ModifyChannel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1305 { 1306 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1307 1308 if( nParms == 0 ) 1309 { 1310 U8 desiredChannel = 0; 1311 U32 currentChannel = 0; 1312 1313 1314 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, SITE_MGR_DESIRED_CHANNEL_PARAM, &desiredChannel)) return; 1315 if(OK != CuOs_GetCurrentChannel(pCuCmd->hCuWext, ¤tChannel)) return; 1316 1317 os_error_printf(CU_MSG_INFO2, (PS8)"Channel=%d (desired: %d)\n",currentChannel,desiredChannel); 1318 } 1319 else 1320 { 1321 CuCommon_SetU32(pCuCmd->hCuCommon, SITE_MGR_DESIRED_CHANNEL_PARAM, parm[0].value); 1322 } 1323 } 1324 1325 VOID CuCmd_GetTxRate(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1326 { 1327 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1328 1329 if( nParms == 0) 1330 { 1331 U8 CurrentTxRate; 1332 S8 CurrentTxRateStr[50]; 1333 1334 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, TIWLN_802_11_CURRENT_RATES_GET, &CurrentTxRate)) return; 1335 1336 CuCmd_CreateRateStr(CurrentTxRateStr, CurrentTxRate); 1337 os_error_printf(CU_MSG_INFO2, (PS8)"Rate: %s\n", CurrentTxRateStr); 1338 } 1339 } 1340 1341 VOID CuCmd_ModifyBssType(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1342 { 1343 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1344 U8 BssType; 1345 S32 i; 1346 1347 if( nParms == 0 ) 1348 { 1349 if(pCuCmd->hWpaCore == NULL) 1350 { 1351 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, CTRL_DATA_CURRENT_BSS_TYPE_PARAM, &BssType)) return; 1352 } 1353 else 1354 { 1355 #ifndef NO_WPA_SUPPL 1356 if(OK != WpaCore_GetBssType(pCuCmd->hWpaCore, (U32*)&BssType)) return; 1357 #endif 1358 } 1359 1360 CU_CMD_FIND_NAME_ARRAY(i, BSS_type, BssType); 1361 if(i == SIZE_ARR(BSS_type)) 1362 { 1363 os_error_printf(CU_MSG_INFO2, (PS8)"Error getting the current BssType! BssType=0x%x\n",BssType); 1364 return; 1365 } 1366 else 1367 { 1368 os_error_printf(CU_MSG_INFO2, (PS8)"Current mode = %s\n", BSS_type[i].name); 1369 } 1370 print_available_values(BSS_type); 1371 } 1372 else 1373 { 1374 BssType = parm[0].value; 1375 /* check if the param is valid */ 1376 CU_CMD_FIND_NAME_ARRAY(i, BSS_type, BssType); 1377 if(i == SIZE_ARR(BSS_type)) 1378 { 1379 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_ModifyBssType, BssType %d is not defined!\n", BssType); 1380 return; 1381 } 1382 if(pCuCmd->hWpaCore == NULL) 1383 { 1384 CuCommon_SetU8(pCuCmd->hCuCommon, CTRL_DATA_CURRENT_BSS_TYPE_PARAM, BssType); 1385 } 1386 else 1387 { 1388 #ifndef NO_WPA_SUPPL 1389 WpaCore_SetBssType(pCuCmd->hWpaCore, BssType); 1390 #endif 1391 } 1392 } 1393 } 1394 1395 VOID CuCmd_ModifyFragTh(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1396 { 1397 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1398 S32 FragTh; 1399 1400 if( nParms == 0 ) 1401 { 1402 if(OK != CuOs_GetFragTh(pCuCmd->hCuWext, &FragTh)) return; 1403 os_error_printf(CU_MSG_INFO2, (PS8)"Frag. threshold = %d\n", FragTh); 1404 } 1405 else 1406 { 1407 FragTh = parm[0].value; 1408 CuOs_SetFragTh(pCuCmd->hCuWext, FragTh); 1409 } 1410 } 1411 1412 VOID CuCmd_ModifyRtsTh(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1413 { 1414 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1415 S32 RtsTh; 1416 1417 if( nParms == 0 ) 1418 { 1419 if(OK != CuOs_GetRtsTh(pCuCmd->hCuWext, &RtsTh)) return; 1420 os_error_printf(CU_MSG_INFO2, (PS8)"RTS threshold = %d\n", RtsTh); 1421 } 1422 else 1423 { 1424 RtsTh = parm[0].value; 1425 CuOs_SetRtsTh(pCuCmd->hCuWext, RtsTh); 1426 } 1427 } 1428 1429 VOID CuCmd_ModifyPreamble(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1430 { 1431 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1432 EPreamble Preamble; 1433 S32 i; 1434 named_value_t preamble_type[] = { 1435 { PREAMBLE_LONG, (PS8)"PREAMBLE_LONG" }, 1436 { PREAMBLE_SHORT, (PS8)"PREAMBLE_SHORT" } 1437 }; 1438 1439 if(nParms) 1440 { 1441 Preamble = parm[0].value; 1442 /* check if the param is valid */ 1443 CU_CMD_FIND_NAME_ARRAY(i, preamble_type, Preamble); 1444 if(i == SIZE_ARR(preamble_type)) 1445 { 1446 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_ModifyPreamble, Preamble %d is not defined!\n", Preamble); 1447 return; 1448 } 1449 CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_802_11_SHORT_PREAMBLE_SET, Preamble); 1450 } 1451 else 1452 { 1453 S32 PreambleData; 1454 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_802_11_SHORT_PREAMBLE_GET, (PU32)&PreambleData)) return; 1455 Preamble = PreambleData; 1456 os_error_printf(CU_MSG_INFO2, (PS8)"Preamble = %d\n", Preamble); 1457 print_available_values(preamble_type); 1458 } 1459 } 1460 1461 VOID CuCmd_ModifyShortSlot(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1462 { 1463 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1464 slotTime_e SlotTime; 1465 S32 i; 1466 named_value_t SlotTime_type[] = { 1467 { PHY_SLOT_TIME_LONG, (PS8)"PHY_SLOT_TIME_LONG" }, 1468 { PHY_SLOT_TIME_SHORT, (PS8)"PHY_SLOT_TIME_SHORT" } 1469 }; 1470 1471 if(nParms) 1472 { 1473 SlotTime = parm[0].value; 1474 /* check if the param is valid */ 1475 CU_CMD_FIND_NAME_ARRAY(i, SlotTime_type, SlotTime); 1476 if(i == SIZE_ARR(SlotTime_type)) 1477 { 1478 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_ModifyShortSlot, SlotTime %d is not defined!\n", SlotTime); 1479 return; 1480 } 1481 CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_SHORT_SLOT_SET, SlotTime); 1482 } 1483 else 1484 { 1485 S32 SlotTimeData; 1486 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_SHORT_SLOT_GET, (PU32)&SlotTimeData)) return; 1487 SlotTime = SlotTimeData; 1488 os_error_printf(CU_MSG_INFO2, (PS8)"SlotTime = %d\n", SlotTime); 1489 print_available_values(SlotTime_type); 1490 } 1491 } 1492 1493 1494 VOID CuCmd_RadioOnOff(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1495 { 1496 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1497 U32 on_off; 1498 1499 if(nParms) 1500 { 1501 on_off = parm[0].value; 1502 CuCommon_SetU32(pCuCmd->hCuCommon, SME_RADIO_ON_PARAM, on_off); 1503 } 1504 else 1505 { 1506 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, SME_RADIO_ON_PARAM, &on_off)) { 1507 os_error_printf(CU_MSG_ERROR, (PS8)"CuCmd_RadioOnOff error, Cannot get radio state!\n"); 1508 return; 1509 } 1510 os_error_printf(CU_MSG_ERROR, (PS8)"Radio state = %s\n", on_off ? "ON" : "OFF"); 1511 os_error_printf(CU_MSG_ERROR, (PS8)"Turn radio on/off. 0=OFF, 1=ON\n"); 1512 } 1513 } 1514 1515 1516 VOID CuCmd_GetSelectedBssidInfo(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1517 { 1518 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1519 OS_802_11_SSID ssid; 1520 TMacAddr bssid; 1521 1522 if(OK != CuOs_Get_SSID(pCuCmd->hCuWext, &ssid)) return; 1523 if(OK != CuOs_Get_BSSID(pCuCmd->hCuWext, bssid)) return; 1524 1525 os_error_printf(CU_MSG_INFO2, (PS8)"Selected BSSID Info:\n"); 1526 os_error_printf(CU_MSG_INFO2, (PS8)"--------------------\n"); 1527 os_error_printf(CU_MSG_INFO2, (PS8)"SSID : %s\n",(ssid.SsidLength)?(PS8)PrintSSID(&ssid):(PS8)"<empty>"); 1528 os_error_printf(CU_MSG_INFO2, (PS8)"BSSID : %02x.%02x.%02x.%02x.%02x.%02x\n",bssid[0],bssid[1],bssid[2],bssid[3],bssid[4],bssid[5]); 1529 } 1530 1531 VOID CuCmd_GetRsiiLevel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1532 { 1533 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1534 S8 dRssi, bRssi; 1535 1536 if(OK != CuCommon_GetRssi(pCuCmd->hCuCommon, &dRssi, &bRssi)) return; 1537 /* need the 0xffffff00 to get negative value display */ 1538 os_error_printf(CU_MSG_INFO2, (PS8)"Current dataRSSI=%d beaconRssi=%d\n", dRssi?dRssi|0xffffff00:dRssi, bRssi?bRssi|0xffffff00:bRssi); 1539 } 1540 1541 VOID CuCmd_GetSnrRatio(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1542 { 1543 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1544 U32 dSnr, bSnr; 1545 1546 if(OK != CuCommon_GetSnr(pCuCmd->hCuCommon, &dSnr, &bSnr)) return; 1547 os_error_printf(CU_MSG_INFO2, (PS8)"Current dataSNR=%d beaconSnr=%d\n", dSnr, bSnr); 1548 } 1549 1550 VOID CuCmd_ShowTxPowerLevel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1551 { 1552 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1553 1554 S32 txPowerLevel; 1555 if(OK != CuOs_GetTxPowerLevel(pCuCmd->hCuWext, &txPowerLevel)) return; 1556 1557 os_error_printf(CU_MSG_INFO2, (PS8)"Tx Power level = %d\n", txPowerLevel); 1558 } 1559 1560 VOID CuCmd_ShowTxPowerTable(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1561 { 1562 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1563 TpowerLevelTable_t txPowerLevel; 1564 S32 i, res; 1565 1566 res = CuCommon_GetBuffer(pCuCmd->hCuCommon, REGULATORY_DOMAIN_TX_POWER_LEVEL_TABLE_PARAM, &txPowerLevel, sizeof(txPowerLevel)); 1567 1568 if( !res ) 1569 { 1570 os_error_printf(CU_MSG_INFO2, (PS8)"Power level table (Dbm/10)\n"); 1571 for (i = 0; i < NUMBER_OF_SUB_BANDS_E; i++) 1572 { 1573 os_error_printf(CU_MSG_INFO2, (PS8)"sub-band %i: %d %d %d %d\n", i, 1574 txPowerLevel.uDbm[i][0], 1575 txPowerLevel.uDbm[i][1], 1576 txPowerLevel.uDbm[i][2], 1577 txPowerLevel.uDbm[i][3]); 1578 } 1579 } 1580 else 1581 { 1582 os_error_printf(CU_MSG_INFO2, (PS8)"Tx Power level table ERROR !!!\n"); 1583 } 1584 } 1585 1586 VOID CuCmd_TxPowerDbm(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1587 { 1588 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1589 U8 txPowerLevelDbm = (U8)parm[0].value; 1590 1591 if(nParms == 0) 1592 { 1593 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, TIWLN_802_11_TX_POWER_DBM_GET, (PU8)&txPowerLevelDbm)) return; 1594 } 1595 else 1596 { 1597 if (parm[0].value > MAX_TX_POWER) 1598 { 1599 os_error_printf(CU_MSG_INFO2, (PS8)"Please use values between %d and %d\n", MIN_TX_POWER, MAX_TX_POWER); return; 1600 } 1601 else 1602 { 1603 if(OK != CuCommon_SetU8(pCuCmd->hCuCommon, TIWLN_802_11_TX_POWER_DBM_GET, (U8)txPowerLevelDbm)) return; 1604 } 1605 } 1606 1607 os_error_printf(CU_MSG_INFO2, (PS8)"Tx Power in DBM = %d\n", txPowerLevelDbm); 1608 } 1609 1610 VOID CuCmd_ModifyState_802_11d(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1611 { 1612 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1613 U32 Enabled_802_11d; 1614 1615 if(nParms == 0) 1616 { 1617 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_GET_802_11D, &Enabled_802_11d)) return; 1618 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d enabled = %s\n", (Enabled_802_11d)?"TRUE":"FALSE"); 1619 } 1620 else 1621 { 1622 Enabled_802_11d = parm[0].value; 1623 if(OK != CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11D, Enabled_802_11d)) 1624 { 1625 U32 Enabled_802_11h; 1626 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_GET_802_11H, &Enabled_802_11h)) return; 1627 if(Enabled_802_11h && (!Enabled_802_11d)) 1628 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d cannot be disabled while 802_11h is enabled!!\n" ); 1629 1630 } 1631 else 1632 { 1633 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d status is updated to = %s\n", (Enabled_802_11d)?"TRUE":"FALSE" ); 1634 } 1635 } 1636 } 1637 1638 VOID CuCmd_ModifyState_802_11h(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1639 { 1640 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1641 U32 Enabled_802_11h; 1642 1643 if(nParms == 0) 1644 { 1645 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_GET_802_11H, &Enabled_802_11h)) return; 1646 os_error_printf(CU_MSG_INFO2, (PS8)"802_11h enabled = %s\n", (Enabled_802_11h)?"TRUE":"FALSE"); 1647 } 1648 else 1649 { 1650 Enabled_802_11h = parm[0].value; 1651 if(OK != CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_ENABLE_DISABLE_802_11H, Enabled_802_11h)) return; 1652 if(Enabled_802_11h) 1653 os_error_printf(CU_MSG_INFO2, (PS8)"802_11h enables automatically 802_11d!!\n" ); 1654 1655 os_error_printf(CU_MSG_INFO2, (PS8)"802_11h status is updated to =%d\n", Enabled_802_11h ); 1656 } 1657 } 1658 1659 VOID CuCmd_D_Country_2_4Ie(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1660 { 1661 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1662 1663 if( nParms == 0 ) 1664 { 1665 U8 CountryString[DOT11_COUNTRY_STRING_LEN+1]; 1666 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_GET_COUNTRY_2_4, 1667 CountryString, DOT11_COUNTRY_STRING_LEN+1)) return; 1668 CountryString[DOT11_COUNTRY_STRING_LEN] = '\0'; 1669 if (CountryString[0] == '\0') 1670 { 1671 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d Country for 2.4 GHz is not found\n"); 1672 } 1673 else 1674 { 1675 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d Country for 2.4 GHz is %s \n", CountryString ); 1676 } 1677 } 1678 else 1679 { 1680 country_t CountryWorld; 1681 1682 CountryWorld.elementId = COUNTRY_IE_ID; 1683 CountryWorld.len = 6; 1684 os_memcpy( (PVOID)CountryWorld.countryIE.CountryString,(PVOID)"GB ", 3); 1685 CountryWorld.countryIE.tripletChannels[0].firstChannelNumber = 1; 1686 CountryWorld.countryIE.tripletChannels[0].maxTxPowerLevel = 23; 1687 CountryWorld.countryIE.tripletChannels[0].numberOfChannels = 11; 1688 1689 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_SET_COUNTRY_2_4, 1690 &CountryWorld, sizeof(country_t))) return; 1691 1692 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d Start Setting GB Country for 2.4 GHz\n"); 1693 } 1694 } 1695 1696 1697 VOID CuCmd_D_Country_5Ie(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1698 { 1699 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1700 1701 if( nParms == 0 ) 1702 { 1703 U8 CountryString[DOT11_COUNTRY_STRING_LEN+1]; 1704 1705 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_GET_COUNTRY_5, 1706 CountryString, DOT11_COUNTRY_STRING_LEN+1)) return; 1707 1708 CountryString[DOT11_COUNTRY_STRING_LEN] = '\0'; 1709 if (CountryString[0] == '\0') 1710 { 1711 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d Country for 5 GHz is not found\n"); 1712 } 1713 else 1714 { 1715 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d Country for 5 GHz is %s\n", CountryString ); 1716 } 1717 } 1718 else 1719 { 1720 country_t CountryWorld; 1721 1722 CountryWorld.elementId = COUNTRY_IE_ID; 1723 CountryWorld.len = 6; 1724 os_memcpy((PVOID) CountryWorld.countryIE.CountryString,(PVOID)"US ", 3); 1725 CountryWorld.countryIE.tripletChannels[0].firstChannelNumber = 36; 1726 CountryWorld.countryIE.tripletChannels[0].maxTxPowerLevel = 13; 1727 CountryWorld.countryIE.tripletChannels[0].numberOfChannels = 8; 1728 1729 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REG_DOMAIN_SET_COUNTRY_5, 1730 &CountryWorld, sizeof(country_t))) return; 1731 1732 os_error_printf(CU_MSG_INFO2, (PS8)"802_11d Start Setting US Country for 5 GHz\n"); 1733 } 1734 } 1735 1736 VOID CuCmd_ModifyDfsRange(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1737 { 1738 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1739 U16 minDFS_channelNum; 1740 U16 maxDFS_channelNum; 1741 1742 if( nParms == 0 ) 1743 { 1744 if(OK != CuCommon_GetDfsChannels(pCuCmd->hCuCommon, &minDFS_channelNum, &maxDFS_channelNum)) return; 1745 1746 os_error_printf(CU_MSG_INFO2, (PS8)"DFS min channel is %d, DFS max channel is %d\n", 1747 minDFS_channelNum, maxDFS_channelNum); 1748 } 1749 else 1750 { 1751 minDFS_channelNum = (U16) parm[0].value; 1752 maxDFS_channelNum = (U16) parm[1].value; 1753 1754 if(OK != CuCommon_SetDfsChannels(pCuCmd->hCuCommon, minDFS_channelNum, maxDFS_channelNum)) return; 1755 1756 os_error_printf(CU_MSG_INFO2, (PS8)"Setting DFS min channel %d, DFS max channel %d\n", 1757 minDFS_channelNum, maxDFS_channelNum); 1758 } 1759 } 1760 1761 VOID CuCmd_SetBeaconFilterDesiredState(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1762 { 1763 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1764 1765 if( nParms == 0 ) 1766 { 1767 print_available_values(BeaconFilter_use); 1768 } 1769 else 1770 { 1771 CuCommon_SetU8(pCuCmd->hCuCommon, TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_SET, (U8)parm[0].value); 1772 } 1773 } 1774 1775 VOID CuCmd_GetBeaconFilterDesiredState(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1776 { 1777 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1778 U8 beaconFilterDesiredState = 0; 1779 1780 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, TIWLN_802_11_BEACON_FILTER_DESIRED_STATE_GET, &beaconFilterDesiredState)) return; 1781 1782 os_error_printf(CU_MSG_INFO2, (PS8)"Desired State is %s\n", (beaconFilterDesiredState == 0)?"FILTER INACTIVE":"FILTER ACTIVE" ); 1783 } 1784 1785 VOID CuCmd_ModifySupportedRates(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1786 { 1787 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1788 rates_t SupportedRates; 1789 S32 i; 1790 1791 if( nParms == 0 ) 1792 { 1793 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SUPPORTED_RATES, 1794 &SupportedRates, sizeof(rates_t))) return; 1795 1796 os_error_printf(CU_MSG_INFO2, (PS8)" Rates: "); 1797 for( i=0; i < SupportedRates.len; i++ ) 1798 { 1799 os_error_printf(CU_MSG_INFO2, 1800 (PS8)"%g Mbps(%u%s)%s", 1801 /* patch in order to support NET_RATE_MCS7 values that equal to NET_RATE_1M_BASIC */ 1802 (RATE_2_MBPS(SupportedRates.ratesString[i]) == 63.5) ? 65 : RATE_2_MBPS(SupportedRates.ratesString[i]), 1803 /* patch in order to support NET_RATE_MCS7 values that equal to NET_RATE_1M_BASIC */ 1804 (SupportedRates.ratesString[i] == 0x7f) ? 0x83 : SupportedRates.ratesString[i], 1805 IS_BASIC_RATE(SupportedRates.ratesString[i]) ? " - basic" : "", 1806 (i < SupportedRates.len-1) ? "," : "" ); 1807 } 1808 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 1809 } 1810 else 1811 { 1812 PS8 buf = (PS8) parm[0].value; 1813 PS8 end_p; 1814 U32 val; 1815 U32 MaxVal = ((1 << (sizeof(SupportedRates.ratesString[i]) * 8))-1); 1816 1817 os_error_printf(CU_MSG_INFO2, (PS8)"param: %s\n", buf ); 1818 1819 for( i=0; *buf && i < DOT11_MAX_SUPPORTED_RATES; i++ ) 1820 { 1821 val = os_strtoul(buf, &end_p, 0); 1822 if(val == 0) 1823 { 1824 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_ModifySupportedRates: invalid value - %s\n", buf ); 1825 return; 1826 } 1827 if(val > MaxVal) 1828 { 1829 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_ModifySupportedRates: out of range %d\n", val ); 1830 return; 1831 } 1832 /* patch in order to support NET_RATE_MCS7 values that equal to NET_RATE_1M_BASIC */ 1833 if (val == 0x83) 1834 { 1835 val = 0x7f; 1836 } 1837 SupportedRates.ratesString[i] = (U8)(val); 1838 buf = end_p; 1839 while( *buf==' ' || *buf == ',' ) buf++; 1840 } 1841 if(*buf) 1842 { 1843 os_error_printf(CU_MSG_INFO2, (PS8)"too many parameters. Max=%d\n", DOT11_MAX_SUPPORTED_RATES ); 1844 return; 1845 } 1846 1847 SupportedRates.len = (U8) i; 1848 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SUPPORTED_RATES, 1849 &SupportedRates, sizeof(rates_t)); 1850 } 1851 } 1852 1853 VOID CuCmd_SendHealthCheck(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1854 { 1855 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1856 1857 if (OK != CuCommon_SetU32(pCuCmd->hCuCommon, HEALTH_MONITOR_CHECK_DEVICE, TRUE)) return; 1858 1859 os_error_printf(CU_MSG_INFO2, (PS8)"Send health check...\n"); 1860 } 1861 1862 VOID CuCmd_EnableRxDataFilters(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1863 { 1864 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1865 1866 if (OK != CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_ENABLE_DISABLE_RX_DATA_FILTERS, TRUE)) return; 1867 1868 os_error_printf(CU_MSG_INFO2, (PS8)"Enabling Rx data filtering...\n"); 1869 } 1870 1871 VOID CuCmd_DisableRxDataFilters(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1872 { 1873 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1874 1875 if (OK != CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_ENABLE_DISABLE_RX_DATA_FILTERS, FALSE)) return; 1876 1877 os_error_printf(CU_MSG_INFO2, (PS8)"Disabling Rx data filtering...\n"); 1878 } 1879 1880 VOID CuCmd_AddRxDataFilter(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1881 { 1882 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1883 S32 res; 1884 TRxDataFilterRequest request; 1885 PS8 mask = (PS8) parm[1].value; 1886 PS8 pattern = (PS8) parm[2].value; 1887 1888 request.offset = (U8)parm[0].value; 1889 CuCmd_ParseMaskString(mask, request.mask, &request.maskLength); 1890 CuCmd_ParsePatternString(pattern, request.pattern, &request.patternLength); 1891 1892 res = CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_ADD_RX_DATA_FILTER, 1893 &request, sizeof(TRxDataFilterRequest)); 1894 1895 if(res == OK) 1896 os_error_printf(CU_MSG_INFO2, (PS8)"Filter added.\n"); 1897 else 1898 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_AddRxDataFilter - Couldn't add Rx data filter...\n"); 1899 1900 } 1901 1902 VOID CuCmd_RemoveRxDataFilter(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1903 { 1904 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1905 S32 res; 1906 TRxDataFilterRequest request; 1907 PS8 mask = (PS8) parm[1].value; 1908 PS8 pattern = (PS8) parm[2].value; 1909 1910 request.offset = (U8)parm[0].value; 1911 CuCmd_ParseMaskString(mask, request.mask, &request.maskLength); 1912 CuCmd_ParsePatternString(pattern, request.pattern, &request.patternLength); 1913 1914 res = CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REMOVE_RX_DATA_FILTER, 1915 &request, sizeof(TRxDataFilterRequest)); 1916 1917 if(res == OK) 1918 os_error_printf(CU_MSG_INFO2, (PS8)"Filter Removed.\n"); 1919 else 1920 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_AddRxDataFilter - Couldn't remove Rx data filter...\n"); 1921 } 1922 1923 VOID CuCmd_GetRxDataFiltersStatistics(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1924 { 1925 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1926 U32 UnmatchedPacketsCount; 1927 U32 MatchedPacketsCount[4]; 1928 1929 if (OK != CuCommon_GetRxDataFiltersStatistics(pCuCmd->hCuCommon, &UnmatchedPacketsCount, MatchedPacketsCount)) return; 1930 1931 os_error_printf(CU_MSG_INFO2, (PS8)"Rx data filtering statistics:\n"); 1932 os_error_printf(CU_MSG_INFO2, (PS8)"Unmatched packets: %u\n", UnmatchedPacketsCount); 1933 os_error_printf(CU_MSG_INFO2, (PS8)"Packets matching filter #1: %u\n", MatchedPacketsCount[0]); 1934 os_error_printf(CU_MSG_INFO2, (PS8)"Packets matching filter #2: %u\n", MatchedPacketsCount[1]); 1935 os_error_printf(CU_MSG_INFO2, (PS8)"Packets matching filter #3: %u\n", MatchedPacketsCount[2]); 1936 os_error_printf(CU_MSG_INFO2, (PS8)"Packets matching filter #4: %u\n", MatchedPacketsCount[3]); 1937 } 1938 1939 VOID CuCmd_ShowStatistics(THandle hCuCmd, ConParm_t parm[], U16 nParms) 1940 { 1941 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 1942 1943 U32 powerMode; 1944 TMacAddr Mac; 1945 OS_802_11_SSID ssid; 1946 U8 desiredChannel; 1947 S32 rtsTh; 1948 S32 fragTh; 1949 S32 txPowerLevel; 1950 U8 bssType; 1951 U32 desiredPreambleType; 1952 TIWLN_COUNTERS driverCounters; 1953 U32 AuthMode; 1954 U8 CurrentTxRate; 1955 S8 CurrentTxRateStr[20]; 1956 U8 CurrentRxRate; 1957 S8 CurrentRxRateStr[20]; 1958 U32 DefaultKeyId; 1959 U32 WepStatus; 1960 S8 dRssi, bRssi; 1961 #ifdef XCC_MODULE_INCLUDED 1962 U32 XCCNetEap; 1963 #endif 1964 1965 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, CTRL_DATA_MAC_ADDRESS, 1966 Mac, sizeof(TMacAddr))) return; 1967 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_POWER_MODE_GET, &powerMode, sizeof(U32))) return; 1968 if(OK != CuOs_Get_SSID(pCuCmd->hCuWext, &ssid)) return; 1969 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, SITE_MGR_DESIRED_CHANNEL_PARAM, &desiredChannel)) return; 1970 if(OK != CuOs_GetRtsTh(pCuCmd->hCuWext, &rtsTh)) return; 1971 if(OK != CuOs_GetFragTh(pCuCmd->hCuWext, &fragTh)) return; 1972 if(OK != CuOs_GetTxPowerLevel(pCuCmd->hCuWext, &txPowerLevel)) return; 1973 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, CTRL_DATA_CURRENT_BSS_TYPE_PARAM, &bssType)) return; 1974 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_802_11_SHORT_PREAMBLE_GET, &desiredPreambleType)) return; 1975 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, SITE_MGR_TI_WLAN_COUNTERS_PARAM, &driverCounters, sizeof(TIWLN_COUNTERS))) return; 1976 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_ENCRYPTION_STATUS_PARAM, &WepStatus)) return; 1977 if(OK != CuCommon_GetRssi(pCuCmd->hCuCommon, &dRssi, &bRssi)) return; 1978 if (pCuCmd->hWpaCore == NULL) 1979 { 1980 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_EXT_AUTHENTICATION_MODE, &AuthMode)) return; 1981 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_DEFAULT_KEY_ID, &DefaultKeyId)) return; 1982 } 1983 else 1984 { 1985 #ifndef NO_WPA_SUPPL 1986 if(OK != WpaCore_GetAuthMode(pCuCmd->hWpaCore, &AuthMode)) return; 1987 if(OK != WpaCore_GetDefaultKey(pCuCmd->hWpaCore, &DefaultKeyId)) return; 1988 #endif 1989 } 1990 1991 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, TIWLN_802_11_CURRENT_RATES_GET, &CurrentTxRate)) return; 1992 CuCmd_CreateRateStr(CurrentTxRateStr, CurrentTxRate); 1993 1994 if(OK != CuCommon_GetU8(pCuCmd->hCuCommon, TIWLN_GET_RX_DATA_RATE, &CurrentRxRate)) return; 1995 CuCmd_CreateRateStr(CurrentRxRateStr, CurrentRxRate); 1996 1997 #ifdef XCC_MODULE_INCLUDED 1998 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_XCC_NETWORK_EAP, &XCCNetEap)) return; 1999 #endif 2000 2001 os_error_printf(CU_MSG_INFO2, (PS8)"******************\n"); 2002 os_error_printf(CU_MSG_INFO2, (PS8)"Driver Statistics:\n"); 2003 os_error_printf(CU_MSG_INFO2, (PS8)"******************\n"); 2004 2005 os_error_printf(CU_MSG_INFO2, (PS8)" dot11CurrentTxRate : %s\n", CurrentTxRateStr); 2006 os_error_printf(CU_MSG_INFO2, (PS8)" CurrentRxRate : %s\n", CurrentRxRateStr); 2007 os_error_printf(CU_MSG_INFO2, (PS8)" dot11DesiredChannel : %d\n", desiredChannel); 2008 os_error_printf(CU_MSG_INFO2, (PS8)" currentMACAddress : %02x.%02x.%02x.%02x.%02x.%02x\n",Mac[0],Mac[1],Mac[2],Mac[3],Mac[4],Mac[5]); 2009 os_error_printf(CU_MSG_INFO2, (PS8)" dot11DesiredSSID : %s\n", ssid.Ssid); 2010 os_error_printf(CU_MSG_INFO2, (PS8)" dot11BSSType : %d\n", bssType); 2011 os_error_printf(CU_MSG_INFO2, (PS8)" AuthenticationMode : %d\n", AuthMode ); 2012 os_error_printf(CU_MSG_INFO2, (PS8)" bShortPreambleUsed : %d\n", desiredPreambleType ); 2013 os_error_printf(CU_MSG_INFO2, (PS8)" RTSThreshold : %d\n", rtsTh ); 2014 os_error_printf(CU_MSG_INFO2, (PS8)"FragmentationThreshold : %d\n", fragTh ); 2015 os_error_printf(CU_MSG_INFO2, (PS8)" bDefaultWEPKeyDefined : %d\n", DefaultKeyId); 2016 os_error_printf(CU_MSG_INFO2, (PS8)" WEPStatus : %d\n", WepStatus); 2017 os_error_printf(CU_MSG_INFO2, (PS8)" TxPowerLevel : %d\n", txPowerLevel ); 2018 os_error_printf(CU_MSG_INFO2, (PS8)" PowerMode : %d\n", powerMode ); 2019 os_error_printf(CU_MSG_INFO2, (PS8)" dataRssi : %d\n", dRssi); 2020 os_error_printf(CU_MSG_INFO2, (PS8)" beaconRssi : %d\n", bRssi); 2021 /**/ 2022 /* network layer statistics*/ 2023 /**/ 2024 os_error_printf(CU_MSG_INFO2, (PS8)" RecvOk : %d\n", driverCounters.RecvOk ); 2025 os_error_printf(CU_MSG_INFO2, (PS8)" RecvError : %d\n", driverCounters.RecvError ); 2026 os_error_printf(CU_MSG_INFO2, (PS8)" DirectedBytesRecv : %d\n", driverCounters.DirectedBytesRecv ); 2027 os_error_printf(CU_MSG_INFO2, (PS8)" DirectedFramesRecv : %d\n", driverCounters.DirectedFramesRecv ); 2028 os_error_printf(CU_MSG_INFO2, (PS8)" MulticastBytesRecv : %d\n", driverCounters.MulticastBytesRecv ); 2029 os_error_printf(CU_MSG_INFO2, (PS8)" MulticastFramesRecv : %d\n", driverCounters.MulticastFramesRecv ); 2030 os_error_printf(CU_MSG_INFO2, (PS8)" BroadcastBytesRecv : %d\n", driverCounters.BroadcastBytesRecv ); 2031 os_error_printf(CU_MSG_INFO2, (PS8)" BroadcastFramesRecv : %d\n", driverCounters.BroadcastFramesRecv ); 2032 os_error_printf(CU_MSG_INFO2, (PS8)" FcsErrors : %d\n", driverCounters.FcsErrors ); 2033 os_error_printf(CU_MSG_INFO2, (PS8)" BeaconsRecv : %d\n", driverCounters.BeaconsRecv ); 2034 os_error_printf(CU_MSG_INFO2, (PS8)" AssocRejects : %d\n", driverCounters.AssocRejects ); 2035 os_error_printf(CU_MSG_INFO2, (PS8)" AssocTimeouts : %d\n", driverCounters.AssocTimeouts ); 2036 os_error_printf(CU_MSG_INFO2, (PS8)" AuthRejects : %d\n", driverCounters.AuthRejects ); 2037 os_error_printf(CU_MSG_INFO2, (PS8)" AuthTimeouts : %d\n", driverCounters.AuthTimeouts ); 2038 2039 /**/ 2040 /* other statistics*/ 2041 /**/ 2042 #ifdef XCC_MODULE_INCLUDED 2043 os_error_printf(CU_MSG_INFO2, (PS8)" dwSecuritySuit : %d\n", XCCNetEap); 2044 #endif 2045 } 2046 2047 VOID CuCmd_ShowTxStatistics(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2048 { 2049 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2050 TIWLN_TX_STATISTICS txCounters; 2051 U32 TxQid; 2052 U32 AverageDelay; 2053 U32 AverageFWDelay; 2054 U32 AverageMacDelay; 2055 2056 if( nParms == 0 ) 2057 { 2058 if(OK != CuCommon_GetTxStatistics(pCuCmd->hCuCommon, &txCounters, 0)) return; 2059 } 2060 else 2061 { 2062 if(OK != CuCommon_GetTxStatistics(pCuCmd->hCuCommon, &txCounters, parm[0].value)) return; 2063 } 2064 2065 os_error_printf(CU_MSG_INFO2, (PS8)"*********************\n"); 2066 os_error_printf(CU_MSG_INFO2, (PS8)"Tx Queues Statistics:\n"); 2067 os_error_printf(CU_MSG_INFO2, (PS8)"*********************\n"); 2068 2069 for (TxQid = 0; TxQid < MAX_NUM_OF_AC; TxQid++) 2070 { 2071 os_error_printf(CU_MSG_INFO2, (PS8)"\nTx Queue %d:\n", TxQid); 2072 os_error_printf(CU_MSG_INFO2, (PS8)"===========\n"); 2073 2074 os_error_printf(CU_MSG_INFO2, (PS8)" Total Good Frames : %d\n", txCounters.txCounters[TxQid].XmitOk ); 2075 os_error_printf(CU_MSG_INFO2, (PS8)" Unicast Bytes : %d\n", txCounters.txCounters[TxQid].DirectedBytesXmit ); 2076 os_error_printf(CU_MSG_INFO2, (PS8)" Unicast Frames : %d\n", txCounters.txCounters[TxQid].DirectedFramesXmit ); 2077 os_error_printf(CU_MSG_INFO2, (PS8)" Multicast Bytes : %d\n", txCounters.txCounters[TxQid].MulticastBytesXmit ); 2078 os_error_printf(CU_MSG_INFO2, (PS8)" Multicast Frames : %d\n", txCounters.txCounters[TxQid].MulticastFramesXmit ); 2079 os_error_printf(CU_MSG_INFO2, (PS8)" Broadcast Bytes : %d\n", txCounters.txCounters[TxQid].BroadcastBytesXmit ); 2080 os_error_printf(CU_MSG_INFO2, (PS8)" Broadcast Frames : %d\n", txCounters.txCounters[TxQid].BroadcastFramesXmit ); 2081 os_error_printf(CU_MSG_INFO2, (PS8)" Retry Failures : %d\n", txCounters.txCounters[TxQid].RetryFailCounter ); 2082 os_error_printf(CU_MSG_INFO2, (PS8)" Tx Timeout Failures : %d\n", txCounters.txCounters[TxQid].TxTimeoutCounter ); 2083 os_error_printf(CU_MSG_INFO2, (PS8)" No Link Failures : %d\n", txCounters.txCounters[TxQid].NoLinkCounter ); 2084 os_error_printf(CU_MSG_INFO2, (PS8)" Other Failures : %d\n", txCounters.txCounters[TxQid].OtherFailCounter ); 2085 os_error_printf(CU_MSG_INFO2, (PS8)" Max Consecutive Retry Failures : %d\n\n", txCounters.txCounters[TxQid].MaxConsecutiveRetryFail ); 2086 2087 os_error_printf(CU_MSG_INFO2, (PS8)" Retry histogram:\n"); 2088 os_error_printf(CU_MSG_INFO2, (PS8)" ----------------\n\n"); 2089 os_error_printf(CU_MSG_INFO2, (PS8)" Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 0, 1, 2, 3, 4, 5, 6, 7); 2090 os_error_printf(CU_MSG_INFO2, (PS8)" packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n", 2091 txCounters.txCounters[TxQid].RetryHistogram[ 0 ], 2092 txCounters.txCounters[TxQid].RetryHistogram[ 1 ], 2093 txCounters.txCounters[TxQid].RetryHistogram[ 2 ], 2094 txCounters.txCounters[TxQid].RetryHistogram[ 3 ], 2095 txCounters.txCounters[TxQid].RetryHistogram[ 4 ], 2096 txCounters.txCounters[TxQid].RetryHistogram[ 5 ], 2097 txCounters.txCounters[TxQid].RetryHistogram[ 6 ], 2098 txCounters.txCounters[TxQid].RetryHistogram[ 7 ]); 2099 os_error_printf(CU_MSG_INFO2, (PS8)" Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 8, 9, 10, 11, 12, 13, 14, 15); 2100 os_error_printf(CU_MSG_INFO2, (PS8)" packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n", 2101 txCounters.txCounters[TxQid].RetryHistogram[ 8 ], 2102 txCounters.txCounters[TxQid].RetryHistogram[ 9 ], 2103 txCounters.txCounters[TxQid].RetryHistogram[ 10 ], 2104 txCounters.txCounters[TxQid].RetryHistogram[ 11 ], 2105 txCounters.txCounters[TxQid].RetryHistogram[ 12 ], 2106 txCounters.txCounters[TxQid].RetryHistogram[ 13 ], 2107 txCounters.txCounters[TxQid].RetryHistogram[ 14 ], 2108 txCounters.txCounters[TxQid].RetryHistogram[ 15 ]); 2109 2110 if (txCounters.txCounters[TxQid].NumPackets) 2111 { 2112 AverageDelay = txCounters.txCounters[TxQid].SumTotalDelayMs / txCounters.txCounters[TxQid].NumPackets; 2113 AverageFWDelay = txCounters.txCounters[TxQid].SumFWDelayUs / txCounters.txCounters[TxQid].NumPackets; 2114 AverageMacDelay = txCounters.txCounters[TxQid].SumMacDelayUs / txCounters.txCounters[TxQid].NumPackets; 2115 } 2116 else 2117 { 2118 AverageDelay = 0; 2119 AverageFWDelay = 0; 2120 AverageMacDelay = 0; 2121 } 2122 2123 os_error_printf(CU_MSG_INFO2, (PS8)" Total Delay ms (average/sum) : %d / %d\n", AverageDelay, txCounters.txCounters[TxQid].SumTotalDelayMs); 2124 os_error_printf(CU_MSG_INFO2, (PS8)" FW Delay us (average/sum) : %d / %d\n", AverageFWDelay, txCounters.txCounters[TxQid].SumFWDelayUs); 2125 os_error_printf(CU_MSG_INFO2, (PS8)" MAC Delay us (average/sum) : %d / %d\n\n", AverageMacDelay, txCounters.txCounters[TxQid].SumMacDelayUs); 2126 2127 os_error_printf(CU_MSG_INFO2, (PS8)" Delay Ranges [msec] : Num of packets\n"); 2128 os_error_printf(CU_MSG_INFO2, (PS8)" ------------------- : --------------\n"); 2129 os_error_printf(CU_MSG_INFO2, (PS8)" 0 - 1 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_0_TO_1] ); 2130 os_error_printf(CU_MSG_INFO2, (PS8)" 1 - 10 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_1_TO_10] ); 2131 os_error_printf(CU_MSG_INFO2, (PS8)" 10 - 20 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_10_TO_20] ); 2132 os_error_printf(CU_MSG_INFO2, (PS8)" 20 - 40 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_20_TO_40] ); 2133 os_error_printf(CU_MSG_INFO2, (PS8)" 40 - 60 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_40_TO_60] ); 2134 os_error_printf(CU_MSG_INFO2, (PS8)" 60 - 80 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_60_TO_80] ); 2135 os_error_printf(CU_MSG_INFO2, (PS8)" 80 - 100 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_80_TO_100] ); 2136 os_error_printf(CU_MSG_INFO2, (PS8)" 100 - 200 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_100_TO_200] ); 2137 os_error_printf(CU_MSG_INFO2, (PS8)" Above 200 : %d\n", txCounters.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_ABOVE_200] ); 2138 } 2139 } 2140 2141 VOID CuCmd_ShowAdvancedParams(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2142 { 2143 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2144 2145 U32 AuthMode; 2146 TPowerMgr_PowerMode Mode; 2147 S32 txPowerLevel; 2148 #ifndef NO_WPA_SUPPL 2149 OS_802_11_ENCRYPTION_TYPES EncryptionTypePairwise; 2150 OS_802_11_ENCRYPTION_TYPES EncryptionTypeGroup; 2151 #endif 2152 S32 Preamble; 2153 S32 FragTh; 2154 S32 RtsTh; 2155 2156 if (pCuCmd->hWpaCore == NULL) 2157 { 2158 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_EXT_AUTHENTICATION_MODE, &AuthMode)) return; 2159 } 2160 else 2161 { 2162 #ifndef NO_WPA_SUPPL 2163 if(OK != WpaCore_GetAuthMode(pCuCmd->hWpaCore, &AuthMode)) return; 2164 #endif 2165 } 2166 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_POWER_MODE_GET, &Mode, sizeof(TPowerMgr_PowerMode))) return; 2167 if(OK != CuOs_GetTxPowerLevel(pCuCmd->hCuWext, &txPowerLevel)) return; 2168 #ifndef NO_WPA_SUPPL 2169 if(OK != WpaCore_GetEncryptionPairWise(pCuCmd->hWpaCore, &EncryptionTypePairwise)) return; 2170 if(OK != WpaCore_GetEncryptionGroup(pCuCmd->hWpaCore, &EncryptionTypeGroup)) return; 2171 #endif 2172 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_802_11_SHORT_PREAMBLE_GET, (PU32)&Preamble)) return; 2173 if(OK != CuOs_GetFragTh(pCuCmd->hCuWext, &FragTh)) return; 2174 if(OK != CuOs_GetRtsTh(pCuCmd->hCuWext, &RtsTh)) return; 2175 2176 2177 os_error_printf(CU_MSG_INFO2, (PS8)"********************\n"); 2178 os_error_printf(CU_MSG_INFO2, (PS8)"Advanced Statistics:\n"); 2179 os_error_printf(CU_MSG_INFO2, (PS8)"********************\n"); 2180 2181 os_error_printf(CU_MSG_INFO2, (PS8)" Authentication : %u\n", AuthMode ); 2182 os_error_printf(CU_MSG_INFO2, (PS8)" Power mode : %d\n", Mode.PowerMode ); 2183 os_error_printf(CU_MSG_INFO2, (PS8)" Tx Power level : %d\n", txPowerLevel ); 2184 #ifndef NO_WPA_SUPPL 2185 os_error_printf(CU_MSG_INFO2, (PS8)" Encryption Pairwise: %u\n", EncryptionTypePairwise ); 2186 os_error_printf(CU_MSG_INFO2, (PS8)" Encryption Group: %u\n", EncryptionTypeGroup ); 2187 #endif 2188 os_error_printf(CU_MSG_INFO2, (PS8)" Preamble : <%s>\n", (Preamble) ? "short" : "long"); 2189 os_error_printf(CU_MSG_INFO2, (PS8)" Frag. threshold : %u\n", FragTh); 2190 os_error_printf(CU_MSG_INFO2, (PS8)" RTS threshold : %u\n", RtsTh ); 2191 os_error_printf(CU_MSG_INFO2, (PS8)" Power mode: "); 2192 print_available_values(power_mode_val); 2193 os_error_printf(CU_MSG_INFO2, (PS8)" Encryption type: "); 2194 print_available_values(encrypt_type); 2195 2196 } 2197 2198 2199 VOID Cucmd_ShowPowerConsumptionStats(THandle hCuCmd,ConParm_t parm[],U16 nParms) 2200 { 2201 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2202 ACXPowerConsumptionTimeStat_t tStatistics; 2203 2204 os_memset( &tStatistics, 0, sizeof(ACXPowerConsumptionTimeStat_t) ); 2205 2206 if (OK != CuCommon_GetPowerConsumptionStat(pCuCmd->hCuCommon,&tStatistics)) 2207 { 2208 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - Failed to read power consumption statistic!\n"); 2209 return; 2210 } 2211 2212 2213 2214 os_error_printf(CU_MSG_INFO2, (PS8)"\nPower Consumption Statistics:\n"); 2215 os_error_printf(CU_MSG_INFO2, (PS8)"-----------------------------\n"); 2216 os_error_printf(CU_MSG_INFO2, (PS8)"activeTimeCnt:0x%x%x\n", tStatistics.awakeTimeCnt_Hi,tStatistics.awakeTimeCnt_Low ); 2217 os_error_printf(CU_MSG_INFO2, (PS8)"elpTimeCnt: 0x%x%x\n", tStatistics.elpTimeCnt_Hi,tStatistics.elpTimeCnt_Low); 2218 os_error_printf(CU_MSG_INFO2, (PS8)"powerDownTimeCnt: 0x%x%x\n", tStatistics.powerDownTimeCnt_Hi,tStatistics.powerDownTimeCnt_Low); 2219 os_error_printf(CU_MSG_INFO2, (PS8)"ListenMode11BTimeCnt: 0x%x%x\n", tStatistics.ListenMode11BTimeCnt_Hi,tStatistics.ListenMode11BTimeCnt_Low); 2220 os_error_printf(CU_MSG_INFO2, (PS8)"ListenModeOFDMTimeCnt: 0x%x%x\n", tStatistics.ListenModeOFDMTimeCnt_Hi,tStatistics.ListenModeOFDMTimeCnt_Low); 2221 2222 } 2223 2224 2225 2226 VOID CuCmd_ScanAppGlobalConfig(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2227 { 2228 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2229 2230 if ( 0 == os_strcmp( (PS8)"<empty>", (PS8)parm[0].value) ) 2231 { 2232 pCuCmd->appScanParams.desiredSsid.len = 0; 2233 pCuCmd->appScanParams.desiredSsid.str[ 0 ] = '\0'; 2234 } 2235 else 2236 { 2237 pCuCmd->appScanParams.desiredSsid.len = (U8) os_strlen((PS8)parm[0].value); 2238 os_memcpy( (PVOID)&(pCuCmd->appScanParams.desiredSsid.str), (PVOID)parm[0].value, pCuCmd->appScanParams.desiredSsid.len ); 2239 if(pCuCmd->appScanParams.desiredSsid.len < MAX_SSID_LEN) 2240 { 2241 pCuCmd->appScanParams.desiredSsid.str[pCuCmd->appScanParams.desiredSsid.len] = 0; 2242 } 2243 } 2244 pCuCmd->appScanParams.scanType = parm[1].value; 2245 pCuCmd->appScanParams.band = parm[2].value; 2246 pCuCmd->appScanParams.probeReqNumber = (U8)parm[3].value; 2247 pCuCmd->appScanParams.probeRequestRate = parm[4].value; 2248 #ifdef TI_DBG 2249 pCuCmd->appScanParams.Tid = (U8)parm[5].value; 2250 pCuCmd->appScanParams.numOfChannels = (U8)parm[6].value; 2251 #else 2252 pCuCmd->appScanParams.Tid = 0; 2253 pCuCmd->appScanParams.numOfChannels = (U8)parm[5].value; 2254 #endif 2255 } 2256 2257 VOID CuCmd_ScanAppChannelConfig(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2258 { 2259 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2260 2261 scan_normalChannelEntry_t* pChannelEntry = 2262 &(pCuCmd->appScanParams.channelEntry[ parm[0].value ].normalChannelEntry); 2263 2264 if (parm[2].value < parm[3].value) 2265 { 2266 os_error_printf(CU_MSG_INFO2, (PS8)"Max Dwell Time must be larger than or equal to Min Dwell Time...\n"); 2267 return; 2268 } 2269 2270 CuCmd_Str2MACAddr ((PS8)parm[1].value, pChannelEntry->bssId); 2271 pChannelEntry->maxChannelDwellTime = parm[2].value; 2272 pChannelEntry->minChannelDwellTime = parm[3].value; 2273 pChannelEntry->earlyTerminationEvent = parm[4].value; 2274 pChannelEntry->ETMaxNumOfAPframes = (U8)parm[5].value; 2275 pChannelEntry->txPowerDbm = (U8)parm[6].value; 2276 pChannelEntry->channel = (U8)parm[7].value; 2277 } 2278 2279 VOID CuCmd_ScanAppClear(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2280 { 2281 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2282 os_memset( &pCuCmd->appScanParams, 0, sizeof(scan_Params_t) ); 2283 os_error_printf(CU_MSG_INFO2, (PS8)"Application scan parameters cleared.\n"); 2284 } 2285 2286 VOID CuCmd_ScanAppDisplay(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2287 { 2288 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2289 S32 i,j; 2290 scan_normalChannelEntry_t* pNormalChannel; 2291 2292 CU_CMD_FIND_NAME_ARRAY(j, rate2Str, pCuCmd->appScanParams.probeRequestRate); 2293 os_error_printf(CU_MSG_INFO2, (PS8)"Application Scan params:\n"); 2294 os_error_printf(CU_MSG_INFO2, (PS8)"SSID: %s, Type: %s\n", 2295 pCuCmd->appScanParams.desiredSsid.str, 2296 scanType2Str[ pCuCmd->appScanParams.scanType ].name); 2297 os_error_printf(CU_MSG_INFO2, (PS8)"Band: %s, Number of probe req:%d, probe req. rate:%s\n", 2298 band2Str[ pCuCmd->appScanParams.band ].name, 2299 pCuCmd->appScanParams.probeReqNumber, 2300 rate2Str[j].name); 2301 #ifdef TI_DBG 2302 os_error_printf(CU_MSG_INFO2, (PS8)"Tid :%d\n\n", pCuCmd->appScanParams.Tid); 2303 #else 2304 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 2305 #endif 2306 os_error_printf(CU_MSG_INFO2, (PS8)"Channel BSS ID Max time Min time ET event ET frame num Power\n"); 2307 os_error_printf(CU_MSG_INFO2, (PS8)"-------------------------------------------------------------------------------\n"); 2308 for ( i = 0; i < pCuCmd->appScanParams.numOfChannels; i++ ) 2309 { 2310 pNormalChannel = &(pCuCmd->appScanParams.channelEntry[ i ].normalChannelEntry); 2311 CU_CMD_FIND_NAME_ARRAY(j, EtEvent2Str, pNormalChannel->earlyTerminationEvent); 2312 os_error_printf(CU_MSG_INFO2, (PS8)"%2d %02x.%02x.%02x.%02x.%02x.%02x %7d %7d %s%3d %1d\n", 2313 pNormalChannel->channel, 2314 pNormalChannel->bssId[0],pNormalChannel->bssId[1],pNormalChannel->bssId[2],pNormalChannel->bssId[3],pNormalChannel->bssId[4],pNormalChannel->bssId[5], 2315 pNormalChannel->maxChannelDwellTime, 2316 pNormalChannel->minChannelDwellTime, 2317 EtEvent2Str[j].name, 2318 pNormalChannel->ETMaxNumOfAPframes, 2319 pNormalChannel->txPowerDbm); 2320 } 2321 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 2322 } 2323 2324 VOID CuCmd_StartScan(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2325 { 2326 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2327 2328 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_START_APP_SCAN_SET, 2329 &pCuCmd->appScanParams, sizeof(scan_Params_t))) 2330 { 2331 return; 2332 } 2333 2334 os_error_printf(CU_MSG_INFO2, (PS8)"Application scan started\n"); 2335 2336 /* 2337 * In order to have ability to set the application scan we are using application scan priver command 2338 * exsample for using supplicant scan command below: 2339 * #ifndef NO_WPA_SUPPL 2340 * CuOs_Start_Scan(pCuCmd->hCuWext, &ssid); 2341 * #endif 2342 */ 2343 } 2344 2345 VOID CuCmd_WextStartScan(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2346 { 2347 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2348 OS_802_11_SSID ssid; 2349 2350 switch (nParms) 2351 { 2352 case 0 : 2353 /* 2354 * No SSID & No BSSID are set - 2355 * Use Any SSID & Any BSSID. 2356 */ 2357 ssid.SsidLength = 0; 2358 ssid.Ssid[0] = 0; 2359 break; 2360 case 1: 2361 /* 2362 * SSID set 2363 * Use CLI's SSID & Any BSSID. 2364 */ 2365 ssid.SsidLength = os_strlen( (PS8)parm[0].value); 2366 os_memcpy((PVOID)ssid.Ssid, (PVOID) parm[0].value, ssid.SsidLength); 2367 ssid.Ssid[ssid.SsidLength] = '\0'; 2368 break; 2369 2370 default: 2371 os_error_printf(CU_MSG_INFO2, (PS8)"w <ssid Name As optional>\n"); 2372 return; 2373 } 2374 2375 #ifndef NO_WPA_SUPPL 2376 CuOs_Start_Scan(pCuCmd->hCuWext, &ssid); 2377 #else 2378 os_error_printf(CU_MSG_INFO2, (PS8)"WEXT not build, Scan Not Started\n"); 2379 #endif 2380 2381 } 2382 2383 VOID CuCmd_StopScan (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2384 { 2385 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2386 2387 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_STOP_APP_SCAN_SET, NULL, 0)) 2388 { 2389 return; 2390 } 2391 os_error_printf(CU_MSG_INFO2, (PS8)"Application scan stopped\n"); 2392 } 2393 2394 VOID CuCmd_ConfigPeriodicScanGlobal (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2395 { 2396 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2397 2398 pCuCmd->tPeriodicAppScanParams.iRssiThreshold = (S8)parm[ 0 ].value; 2399 pCuCmd->tPeriodicAppScanParams.iSnrThreshold = (S8)parm[ 1 ].value; 2400 pCuCmd->tPeriodicAppScanParams.uFrameCountReportThreshold = parm[ 2 ].value; 2401 pCuCmd->tPeriodicAppScanParams.bTerminateOnReport = parm[ 3 ].value; 2402 pCuCmd->tPeriodicAppScanParams.eBssType = (ScanBssType_e )parm[ 4 ].value; 2403 pCuCmd->tPeriodicAppScanParams.uProbeRequestNum = parm[ 5 ].value; 2404 pCuCmd->tPeriodicAppScanParams.uCycleNum = parm[ 6 ].value; 2405 pCuCmd->tPeriodicAppScanParams.uSsidNum = parm[ 7 ].value; 2406 pCuCmd->tPeriodicAppScanParams.uSsidListFilterEnabled = (U8)(parm[ 8 ].value); 2407 pCuCmd->tPeriodicAppScanParams.uChannelNum = parm[ 9 ].value; 2408 } 2409 2410 VOID CuCmd_ConfigPeriodicScanInterval (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2411 { 2412 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2413 2414 pCuCmd->tPeriodicAppScanParams.uCycleIntervalMsec[ parm[ 0 ].value ] = parm[ 1 ].value; 2415 } 2416 2417 VOID CuCmd_ConfigurePeriodicScanSsid (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2418 { 2419 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2420 TSsid *pSsid = &pCuCmd->tPeriodicAppScanParams.tDesiredSsid[ parm[ 0 ].value ].tSsid; 2421 2422 pCuCmd->tPeriodicAppScanParams.tDesiredSsid[ parm[ 0 ].value ].eVisability = parm[ 1 ].value; 2423 pSsid->len = (U8)os_strlen ((PS8)parm[ 2 ].value); 2424 os_memcpy ((PVOID)&(pSsid->str), 2425 (PVOID)parm[ 2 ].value, 2426 pSsid->len); 2427 if(pSsid->len < MAX_SSID_LEN) 2428 { 2429 pSsid->str[pSsid->len] = 0; 2430 } 2431 } 2432 2433 VOID CuCmd_ConfigurePeriodicScanChannel (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2434 { 2435 CuCmd_t *pCuCmd = (CuCmd_t*)hCuCmd; 2436 TPeriodicChannelEntry *pChannelEnrty = &(pCuCmd->tPeriodicAppScanParams.tChannels[ parm[ 0 ].value ]); 2437 2438 pChannelEnrty->eBand = parm[ 1 ].value; 2439 pChannelEnrty->uChannel = parm[ 2 ].value; 2440 pChannelEnrty->eScanType = parm[ 3 ].value; 2441 pChannelEnrty->uMinDwellTimeMs = parm[ 4 ].value;; 2442 pChannelEnrty->uMaxDwellTimeMs = parm[ 5 ].value; 2443 pChannelEnrty->uTxPowerLevelDbm = parm[ 6 ].value; 2444 } 2445 2446 VOID CuCmd_ClearPeriodicScanConfiguration (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2447 { 2448 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2449 2450 os_memset (&(pCuCmd->tPeriodicAppScanParams), 0, sizeof (TPeriodicScanParams)); 2451 os_error_printf(CU_MSG_INFO2, (PS8)"Periodic application scan parameters cleared.\n"); 2452 } 2453 2454 VOID CuCmd_DisplayPeriodicScanConfiguration (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2455 { 2456 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2457 S32 i, j, k; 2458 2459 os_error_printf(CU_MSG_INFO2, (PS8)"Application Periodic Scan parameters:\n"); 2460 os_error_printf(CU_MSG_INFO2, (PS8)"RSSI Threshold: %d, SNR Threshold: %d, Report Threshold: %d Number of cycles: %d\n", 2461 pCuCmd->tPeriodicAppScanParams.iRssiThreshold, pCuCmd->tPeriodicAppScanParams.iSnrThreshold, 2462 pCuCmd->tPeriodicAppScanParams.uFrameCountReportThreshold, pCuCmd->tPeriodicAppScanParams.uCycleNum); 2463 CU_CMD_FIND_NAME_ARRAY (i, booleanStr, pCuCmd->tPeriodicAppScanParams.bTerminateOnReport); 2464 CU_CMD_FIND_NAME_ARRAY (j, bssTypeStr, pCuCmd->tPeriodicAppScanParams.eBssType); 2465 os_error_printf(CU_MSG_INFO2, (PS8)"Terminate on Report: %s, BSS type: %s, Probe Request Number: %d\n", 2466 booleanStr[ i ].name, bssTypeStr[ j ].name, pCuCmd->tPeriodicAppScanParams.uProbeRequestNum); 2467 2468 os_error_printf(CU_MSG_INFO2, (PS8)"\nIntervals (msec):\n"); 2469 for (i = 0; i < PERIODIC_SCAN_MAX_INTERVAL_NUM; i++) 2470 { 2471 os_error_printf(CU_MSG_INFO2, (PS8)"%d ", pCuCmd->tPeriodicAppScanParams.uCycleIntervalMsec[ i ]); 2472 } 2473 os_error_printf(CU_MSG_INFO2, (PS8)"\n\nSSIDs:\n"); 2474 for (i = 0; i < (S32)pCuCmd->tPeriodicAppScanParams.uSsidNum; i++) 2475 { 2476 CU_CMD_FIND_NAME_ARRAY (j, ssidVisabilityStr, pCuCmd->tPeriodicAppScanParams.tDesiredSsid[ i ].eVisability); 2477 os_error_printf(CU_MSG_INFO2, (PS8)"%s (%s), ", pCuCmd->tPeriodicAppScanParams.tDesiredSsid[ i ].tSsid.str, 2478 ssidVisabilityStr[ j ].name); 2479 } 2480 os_error_printf(CU_MSG_INFO2, (PS8)"\n\nSSID List Filter Enabled: %d\n", pCuCmd->tPeriodicAppScanParams.uSsidListFilterEnabled ); 2481 2482 os_error_printf(CU_MSG_INFO2, (PS8)"\n\nChannels:\n"); 2483 os_error_printf(CU_MSG_INFO2, (PS8)"%-15s %-10s %-20s %-15s %-15s %-20s\n", 2484 (PS8)"Band", (PS8)"Channel", (PS8)"Scan type", (PS8)"Min dwell time", (PS8)"Max dwell time", (PS8)"Power level (dBm*10)"); 2485 os_error_printf(CU_MSG_INFO2, (PS8)"----------------------------------------------------------------------------------------------------\n"); 2486 for (i = 0; i < (S32)pCuCmd->tPeriodicAppScanParams.uChannelNum; i++) 2487 { 2488 CU_CMD_FIND_NAME_ARRAY (j, band2Str, pCuCmd->tPeriodicAppScanParams.tChannels[ i ].eBand); 2489 CU_CMD_FIND_NAME_ARRAY (k, scanType2Str, pCuCmd->tPeriodicAppScanParams.tChannels[ i ].eScanType); 2490 os_error_printf(CU_MSG_INFO2, (PS8)"%-15s %-10d %-20s %-15d %-15d %-20d\n", 2491 band2Str[ j ].name, 2492 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uChannel, 2493 scanType2Str[ k ].name, 2494 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uMinDwellTimeMs, 2495 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uMaxDwellTimeMs, 2496 pCuCmd->tPeriodicAppScanParams.tChannels[ i ].uTxPowerLevelDbm); 2497 } 2498 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 2499 } 2500 2501 VOID CuCmd_StartPeriodicScan (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2502 { 2503 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2504 2505 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, SCAN_CNCN_START_PERIODIC_SCAN, 2506 &(pCuCmd->tPeriodicAppScanParams), sizeof(TPeriodicScanParams))) 2507 { 2508 return; 2509 } 2510 os_error_printf(CU_MSG_INFO2, (PS8)"Periodic application scan started.\n"); 2511 } 2512 2513 VOID CuCmd_StopPeriodicScan (THandle hCuCmd, ConParm_t parm[], U16 nParms) 2514 { 2515 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2516 2517 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, SCAN_CNCN_STOP_PERIODIC_SCAN, 2518 NULL, 0)) 2519 { 2520 return; 2521 } 2522 os_error_printf(CU_MSG_INFO2, (PS8)"Periodic application scan stopped.\n"); 2523 } 2524 2525 VOID CuCmd_ConfigScanPolicy(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2526 { 2527 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2528 2529 pCuCmd->scanPolicy.normalScanInterval = parm[ 0 ].value; 2530 pCuCmd->scanPolicy.deterioratingScanInterval = parm[ 1 ].value; 2531 pCuCmd->scanPolicy.maxTrackFailures = (U8)(parm[ 2 ].value); 2532 pCuCmd->scanPolicy.BSSListSize = (U8)(parm[ 3 ].value); 2533 pCuCmd->scanPolicy.BSSNumberToStartDiscovery = (U8)(parm[ 4 ].value); 2534 pCuCmd->scanPolicy.numOfBands = (U8)(parm[ 5 ].value); 2535 } 2536 2537 VOID CuCmd_ConfigScanBand(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2538 { 2539 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2540 scan_bandPolicy_t* pBandPolicy = &(pCuCmd->scanPolicy.bandScanPolicy[ parm [ 0 ].value ]); 2541 2542 pBandPolicy->band = parm[ 1 ].value; 2543 pBandPolicy->rxRSSIThreshold = (S8)(parm[ 2 ].value); 2544 pBandPolicy->numOfChannlesForDiscovery = (U8)(parm[ 3 ].value); 2545 pBandPolicy->numOfChannles = (U8)(parm[ 4 ].value); 2546 } 2547 2548 VOID CuCmd_ConfigScanBandChannel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2549 { 2550 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2551 scan_bandPolicy_t* pBandPolicy = &(pCuCmd->scanPolicy.bandScanPolicy[ parm [ 0 ].value ]); 2552 2553 pBandPolicy->channelList[ parm[ 1 ].value ] = (U8)(parm[ 2 ].value); 2554 } 2555 2556 VOID CuCmd_ConfigScanBandTrack(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2557 { 2558 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2559 scan_bandPolicy_t* pBandPolicy = &(pCuCmd->scanPolicy.bandScanPolicy[ parm [ 0 ].value ]); 2560 2561 if (parm[6].value < parm[7].value) 2562 { 2563 os_error_printf(CU_MSG_INFO2, (PS8)"Max Dwell Time must be larger than or equal to Min Dwell Time...\n"); 2564 return; 2565 } 2566 2567 pBandPolicy->trackingMethod.scanType = parm[ 1 ].value; 2568 2569 switch (pBandPolicy->trackingMethod.scanType) 2570 { 2571 case SCAN_TYPE_NORMAL_ACTIVE: 2572 case SCAN_TYPE_NORMAL_PASSIVE: 2573 pBandPolicy->trackingMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value); 2574 pBandPolicy->trackingMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value); 2575 pBandPolicy->trackingMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2576 pBandPolicy->trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2577 pBandPolicy->trackingMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value; 2578 pBandPolicy->trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (U8)(parm[ 8 ].value); 2579 pBandPolicy->trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = (U8)(parm[ 10 ].value); 2580 break; 2581 2582 case SCAN_TYPE_TRIGGERED_ACTIVE: 2583 case SCAN_TYPE_TRIGGERED_PASSIVE: 2584 /* Check if valid TID */ 2585 if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255)) 2586 { 2587 os_error_printf (CU_MSG_INFO2, (PS8)"ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value)); 2588 parm[ 4 ].value = 255; 2589 } 2590 2591 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.triggeringTid = (U8)(parm[ 4 ].value); 2592 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value); 2593 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value); 2594 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2595 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2596 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value; 2597 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (U8)(parm[ 8 ].value); 2598 pBandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (U8)(parm[ 10 ].value); 2599 break; 2600 2601 case SCAN_TYPE_SPS: 2602 pBandPolicy->trackingMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2603 pBandPolicy->trackingMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2604 pBandPolicy->trackingMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value; 2605 break; 2606 2607 default: 2608 pBandPolicy->trackingMethod.scanType = SCAN_TYPE_NO_SCAN; 2609 break; 2610 } 2611 } 2612 2613 VOID CuCmd_ConfigScanBandDiscover(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2614 { 2615 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2616 scan_bandPolicy_t* pBandPolicy = &(pCuCmd->scanPolicy.bandScanPolicy[ parm [ 0 ].value ]); 2617 2618 if (parm[6].value < parm[7].value) 2619 { 2620 os_error_printf(CU_MSG_INFO2, (PS8)"Max Dwell Time must be larger than or equal to Min Dwell Time...\n"); 2621 return; 2622 } 2623 2624 pBandPolicy->discoveryMethod.scanType = parm[ 1 ].value; 2625 2626 switch (pBandPolicy->discoveryMethod.scanType) 2627 { 2628 case SCAN_TYPE_NORMAL_ACTIVE: 2629 case SCAN_TYPE_NORMAL_PASSIVE: 2630 pBandPolicy->discoveryMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value); 2631 pBandPolicy->discoveryMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value); 2632 pBandPolicy->discoveryMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2633 pBandPolicy->discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2634 pBandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value; 2635 pBandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (U8)(parm[ 8 ].value); 2636 pBandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = (U8)(parm[ 10 ].value); 2637 break; 2638 2639 case SCAN_TYPE_TRIGGERED_ACTIVE: 2640 case SCAN_TYPE_TRIGGERED_PASSIVE: 2641 /* Check if valid TID */ 2642 if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255)) 2643 { 2644 os_error_printf(CU_MSG_INFO2, (PS8)"ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value)); 2645 parm[ 4 ].value = 255; 2646 } 2647 2648 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.triggeringTid = (U8)(parm[ 4 ].value); 2649 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value); 2650 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value); 2651 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2652 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2653 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value; 2654 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (U8)(parm[ 8 ].value); 2655 pBandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (U8)(parm[ 10 ].value); 2656 break; 2657 2658 case SCAN_TYPE_SPS: 2659 pBandPolicy->discoveryMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2660 pBandPolicy->discoveryMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2661 pBandPolicy->discoveryMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value; 2662 break; 2663 2664 default: 2665 pBandPolicy->discoveryMethod.scanType = SCAN_TYPE_NO_SCAN; 2666 break; 2667 } 2668 } 2669 2670 VOID CuCmd_ConfigScanBandImmed(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2671 { 2672 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2673 scan_bandPolicy_t* pBandPolicy = &(pCuCmd->scanPolicy.bandScanPolicy[ parm [ 0 ].value ]); 2674 2675 if (parm[6].value < parm[7].value) 2676 { 2677 os_error_printf(CU_MSG_INFO2, (PS8)"Max Dwell Time must be larger than or equal to Min Dwell Time...\n"); 2678 return; 2679 } 2680 2681 pBandPolicy->immediateScanMethod.scanType = parm[ 1 ].value; 2682 2683 switch (pBandPolicy->immediateScanMethod.scanType) 2684 { 2685 case SCAN_TYPE_NORMAL_ACTIVE: 2686 case SCAN_TYPE_NORMAL_PASSIVE: 2687 pBandPolicy->immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value); 2688 pBandPolicy->immediateScanMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value); 2689 pBandPolicy->immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2690 pBandPolicy->immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2691 pBandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value; 2692 pBandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (U8)(parm[ 8 ].value); 2693 pBandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = (U8)(parm[ 10 ].value); 2694 break; 2695 2696 case SCAN_TYPE_TRIGGERED_ACTIVE: 2697 case SCAN_TYPE_TRIGGERED_PASSIVE: 2698 /* Check if valid TID */ 2699 if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255)) 2700 { 2701 os_error_printf (CU_MSG_INFO2, (PS8)"ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value)); 2702 parm[ 4 ].value = 255; 2703 } 2704 2705 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.triggeringTid = (U8)(parm[ 4 ].value); 2706 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value); 2707 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value); 2708 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2709 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2710 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value; 2711 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (U8)(parm[ 8 ].value); 2712 pBandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (U8)(parm[ 10 ].value); 2713 break; 2714 2715 case SCAN_TYPE_SPS: 2716 pBandPolicy->immediateScanMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value; 2717 pBandPolicy->immediateScanMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (U8)(parm[ 3 ].value); 2718 pBandPolicy->immediateScanMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value; 2719 break; 2720 2721 default: 2722 pBandPolicy->immediateScanMethod.scanType = SCAN_TYPE_NO_SCAN; 2723 break; 2724 } 2725 } 2726 2727 VOID CuCmd_DisplayScanPolicy(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2728 { 2729 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2730 S32 i; 2731 2732 os_error_printf(CU_MSG_INFO2, (PS8)"Scan Policy:\n"); 2733 os_error_printf(CU_MSG_INFO2, (PS8)"Normal scan interval: %d, deteriorating scan interval: %d\n", 2734 pCuCmd->scanPolicy.normalScanInterval, pCuCmd->scanPolicy.deterioratingScanInterval); 2735 os_error_printf(CU_MSG_INFO2, (PS8)"Max track attempt failures: %d\n", pCuCmd->scanPolicy.maxTrackFailures); 2736 os_error_printf(CU_MSG_INFO2, (PS8)"BSS list size: %d, number of BSSes to start discovery: %d\n", 2737 pCuCmd->scanPolicy.BSSListSize, pCuCmd->scanPolicy.BSSNumberToStartDiscovery); 2738 os_error_printf(CU_MSG_INFO2, (PS8)"Number of configured bands: %d\n", pCuCmd->scanPolicy.numOfBands); 2739 for ( i = 0; i < pCuCmd->scanPolicy.numOfBands; i++ ) 2740 { 2741 CuCmd_PrintScanBand(&(pCuCmd->scanPolicy.bandScanPolicy[ i ])); 2742 } 2743 } 2744 2745 VOID CuCmd_ClearScanPolicy(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2746 { 2747 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2748 2749 os_memset( &pCuCmd->scanPolicy, 0, sizeof(scan_Policy_t) ); 2750 os_error_printf(CU_MSG_INFO2, (PS8)"Scan policy cleared.\n"); 2751 } 2752 2753 VOID CuCmd_SetScanPolicy(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2754 { 2755 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2756 2757 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SCAN_POLICY_PARAM_SET, 2758 &pCuCmd->scanPolicy, sizeof(scan_Policy_t))) return; 2759 os_error_printf(CU_MSG_INFO2, (PS8)"Scan policy stored.\n"); 2760 } 2761 2762 VOID CuCmd_GetScanBssList(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2763 { 2764 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2765 bssList_t list; 2766 S32 i; 2767 2768 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SCAN_BSS_LIST_GET, 2769 &list, sizeof(bssList_t))) return; 2770 2771 /* os_error_printf list */ 2772 os_error_printf(CU_MSG_INFO2, (PS8)"BSS List:\n"); 2773 os_error_printf(CU_MSG_INFO2, (PS8)"%-17s %-7s %-6s %-4s %-10s\n", (PS8)"BSSID", (PS8)"Band", (PS8)"Channel", (PS8)"RSSI", (PS8)"Neighbor?"); 2774 os_error_printf(CU_MSG_INFO2, (PS8)"-----------------------------------------------------\n"); 2775 for ( i = 0; i < list.numOfEntries; i++ ) 2776 { 2777 os_error_printf(CU_MSG_INFO2, (PS8)"%02x.%02x.%02x.%02x.%02x.%02x %s %-7d %-4d %s\n", 2778 list.BSSList[i].BSSID[0], list.BSSList[i].BSSID[1], list.BSSList[i].BSSID[2], list.BSSList[i].BSSID[3], list.BSSList[i].BSSID[4], list.BSSList[i].BSSID[5], 2779 band2Str[ list.BSSList[ i ].band ].name, 2780 list.BSSList[ i ].channel, list.BSSList[ i ].RSSI, 2781 (TRUE == list.BSSList[ i ].bNeighborAP ? (PS8)"Yes" : (PS8)"No") ); 2782 } 2783 } 2784 2785 VOID CuCmd_RoamingEnable(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2786 { 2787 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2788 roamingMngrConfigParams_t roamingMngrConfigParams; 2789 2790 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2791 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t))) return; 2792 roamingMngrConfigParams.roamingMngrConfig.enableDisable = ROAMING_ENABLED; 2793 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2794 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2795 os_error_printf(CU_MSG_INFO2, (PS8)"Roaming is enabled \n"); 2796 } 2797 2798 VOID CuCmd_RoamingDisable(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2799 { 2800 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2801 roamingMngrConfigParams_t roamingMngrConfigParams; 2802 2803 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2804 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2805 roamingMngrConfigParams.roamingMngrConfig.enableDisable = ROAMING_DISABLED; 2806 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2807 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2808 os_error_printf(CU_MSG_INFO2, (PS8)"Roaming is disabled \n"); 2809 } 2810 2811 VOID CuCmd_RoamingLowPassFilter(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2812 { 2813 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2814 roamingMngrConfigParams_t roamingMngrConfigParams; 2815 2816 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2817 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2818 if( nParms != 0 ) 2819 { 2820 roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt = (U16) parm[0].value; 2821 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2822 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2823 } 2824 os_error_printf(CU_MSG_INFO2, (PS8)"Time in sec to wait before low quality Roaming Triggers, \n lowPassFilterRoamingAttempt = %d sec\n", 2825 roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt); 2826 } 2827 2828 VOID CuCmd_RoamingQualityIndicator(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2829 { 2830 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2831 roamingMngrConfigParams_t roamingMngrConfigParams; 2832 2833 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2834 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2835 if( nParms != 0 ) 2836 { 2837 roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold = (S8) parm[0].value; 2838 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2839 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2840 } 2841 os_error_printf(CU_MSG_INFO2, (PS8)"Quality indicator (RSSI) to be used when comparing AP List matching quality, \n apQualityThreshold = %d \n", 2842 (roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold)); 2843 } 2844 2845 VOID CuCmd_RoamingDataRetryThreshold(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2846 { 2847 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2848 roamingMngrConfigParams_t roamingMngrConfigParams; 2849 2850 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2851 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2852 if( nParms != 0 ) 2853 { 2854 roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold = (S8) parm[0].value; 2855 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2856 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2857 } 2858 os_error_printf(CU_MSG_INFO2, (PS8)"dataRetryThreshold = %d \n", 2859 roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold); 2860 2861 } 2862 VOID CuCmd_RoamingNumExpectedTbttForBSSLoss(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2863 { 2864 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2865 roamingMngrConfigParams_t roamingMngrConfigParams; 2866 2867 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2868 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2869 if( nParms != 0 ) 2870 { 2871 roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss = (S8) parm[0].value; 2872 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2873 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2874 } 2875 os_error_printf(CU_MSG_INFO2, (PS8)"Number of expected TBTTs for BSS Loss event, \n numExpectedTbttForBSSLoss = %d \n", 2876 roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss); 2877 2878 } 2879 VOID CuCmd_RoamingTxRateThreshold(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2880 { 2881 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2882 roamingMngrConfigParams_t roamingMngrConfigParams; 2883 2884 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2885 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2886 if( nParms != 0 ) 2887 { 2888 roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold = (S8 )parm[0].value; 2889 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2890 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2891 } 2892 os_error_printf(CU_MSG_INFO2, (PS8)"txRateThreshold = %d \n", 2893 roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold); 2894 2895 } 2896 2897 VOID CuCmd_RoamingLowRssiThreshold(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2898 { 2899 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2900 roamingMngrConfigParams_t roamingMngrConfigParams; 2901 2902 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2903 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2904 if( nParms != 0 ) 2905 { 2906 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold = (S8) parm[0].value; 2907 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2908 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2909 } 2910 os_error_printf(CU_MSG_INFO2, (PS8)"lowRssiThreshold = %d \n", 2911 (roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold)); 2912 2913 } 2914 2915 VOID CuCmd_RoamingLowSnrThreshold(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2916 { 2917 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2918 roamingMngrConfigParams_t roamingMngrConfigParams; 2919 2920 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2921 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2922 if( nParms != 0 ) 2923 { 2924 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold = (S8)parm[0].value; 2925 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2926 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2927 } 2928 os_error_printf(CU_MSG_INFO2, (PS8)"lowSnrThreshold = %d \n", roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold); 2929 } 2930 2931 VOID CuCmd_RoamingLowQualityForBackgroungScanCondition(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2932 { 2933 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2934 roamingMngrConfigParams_t roamingMngrConfigParams; 2935 2936 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2937 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2938 if( nParms != 0 ) 2939 { 2940 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition = (S8) parm[0].value; 2941 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2942 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2943 } 2944 os_error_printf(CU_MSG_INFO2, (PS8)"Indicator used to increase the background scan period when quality is low, \n lowQualityForBackgroungScanCondition = %d \n", 2945 (roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition)); 2946 2947 } 2948 2949 VOID CuCmd_RoamingNormalQualityForBackgroungScanCondition(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2950 { 2951 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2952 roamingMngrConfigParams_t roamingMngrConfigParams; 2953 2954 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2955 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2956 if( nParms != 0 ) 2957 { 2958 roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition = (S8) parm[0].value; 2959 if(OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2960 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2961 } 2962 os_error_printf(CU_MSG_INFO2, (PS8)"Indicator used to reduce the background scan period when quality is normal, \n normalQualityForBackgroungScanCondition = %d \n", 2963 (roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition)); 2964 2965 } 2966 2967 VOID CuCmd_RoamingGetConfParams(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2968 { 2969 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 2970 roamingMngrConfigParams_t roamingMngrConfigParams; 2971 2972 if(OK != CuCommon_GetBuffer (pCuCmd->hCuCommon, ROAMING_MNGR_APPLICATION_CONFIGURATION, 2973 &roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t)) ) return; 2974 2975 os_error_printf(CU_MSG_INFO2, (PS8)"Roaming is: %s \n", roamingMngrConfigParams.roamingMngrConfig.enableDisable ? "Enabled" : "Disabled\n"); 2976 os_error_printf(CU_MSG_INFO2, (PS8)" lowPassFilterRoamingAttempt = %d sec,\n apQualityThreshold = %d\n", 2977 roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt, 2978 roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold); 2979 os_error_printf(CU_MSG_INFO2, (PS8)" Roaming Triggers' thresholds are: \n"); 2980 os_error_printf(CU_MSG_INFO2, (PS8)" dataRetryThreshold = %d,\n lowQualityForBackgroungScanCondition = %d,\n lowRssiThreshold = %d,\n lowSnrThreshold = %d,\n normalQualityForBackgroungScanCondition = %d,\n numExpectedTbttForBSSLoss = %d,\n txRateThreshold = %d \n", 2981 roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold, 2982 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition, 2983 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold, 2984 roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold, 2985 roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition, 2986 roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss, 2987 roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold); 2988 } 2989 2990 VOID CuCmd_CurrBssUserDefinedTrigger(THandle hCuCmd, ConParm_t parm[], U16 nParms) 2991 { 2992 CuCmd_t *pCuCmd = (CuCmd_t*)hCuCmd; 2993 TUserDefinedQualityTrigger userTrigger; 2994 2995 if (nParms == 0) 2996 return; 2997 2998 userTrigger.uIndex = (U8)parm[0].value; 2999 userTrigger.iThreshold = (U16)parm[1].value; 3000 userTrigger.uPacing = (U16)parm[2].value; 3001 userTrigger.uMetric = (U8)parm[3].value; 3002 userTrigger.uType = (U8)parm[4].value; 3003 userTrigger.uDirection = (U8)parm[5].value; 3004 userTrigger.uHystersis = (U8)parm[6].value; 3005 userTrigger.uEnable = (U8)parm[7].value; 3006 3007 userTrigger.uClientID = 0; /* '0' means that external application with no clientId has registered for the event */ 3008 3009 if (OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, CURR_BSS_REGISTER_LINK_QUALITY_EVENT_PARAM, 3010 &userTrigger, sizeof(TUserDefinedQualityTrigger)) ) 3011 return; 3012 3013 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_RoamingUserDefinedTrigger: \n \ 3014 index = %d, \n \ 3015 threshold = %d, \n \ 3016 pacing = %d, \n \ 3017 metric = %d, \n \ 3018 type = %d, \n \ 3019 direction = %d, \n \ 3020 hystersis = %d, \n \ 3021 enable = %d \n", 3022 userTrigger.uIndex, 3023 userTrigger.iThreshold, 3024 userTrigger.uPacing, 3025 userTrigger.uMetric, 3026 userTrigger.uType, 3027 userTrigger.uDirection, 3028 userTrigger.uHystersis, 3029 userTrigger.uEnable); 3030 } 3031 3032 VOID CuCmd_AddTspec(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3033 { 3034 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3035 OS_802_11_QOS_TSPEC_PARAMS TspecParams; 3036 3037 TspecParams.uUserPriority = parm[0].value; 3038 TspecParams.uNominalMSDUsize = parm[1].value; 3039 TspecParams.uMeanDataRate = parm[2].value; 3040 TspecParams.uMinimumPHYRate = parm[3].value * 1000 * 1000; 3041 TspecParams.uSurplusBandwidthAllowance = parm[4].value << 13; 3042 TspecParams.uAPSDFlag = parm[5].value; 3043 TspecParams.uMinimumServiceInterval = parm[6].value; 3044 TspecParams.uMaximumServiceInterval = parm[7].value; 3045 3046 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_ADD_TSPEC, 3047 &TspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS))) return; 3048 3049 os_error_printf(CU_MSG_INFO2, (PS8)"TSpec request sent to driver...\n uUserPriority = %d\n uNominalMSDUsize = %d\n uMeanDataRate = %d\n uMinimumPHYRate = %d\n uSurplusBandwidthAllowance = %d\n uAPSDFlag = %d uMinimumServiceInterval = %d uMaximumServiceInterval = %d\n", 3050 parm[0].value, 3051 parm[1].value, 3052 parm[2].value, 3053 parm[3].value, 3054 parm[4].value, 3055 parm[5].value, 3056 parm[6].value, 3057 parm[7].value); 3058 3059 } 3060 3061 VOID CuCmd_GetTspec(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3062 { 3063 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3064 OS_802_11_QOS_TSPEC_PARAMS TspecParams; 3065 3066 TspecParams.uUserPriority = parm[0].value; 3067 3068 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_TSPEC_PARAMS, 3069 &TspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS))) return; 3070 3071 os_error_printf(CU_MSG_INFO2, (PS8)"TSpec parameters retrieved:\nuUserPriority = %d\nuNominalMSDUsize = %d\nuMeanDataRate = %d\nuMinimumPHYRate = %d\nuSurplusBandwidthAllowance = %d\nuUAPSD_Flag = %d\nuMinimumServiceInterval = %d\nuMaximumServiceInterval = %d\nuMediumTime = %d\n", 3072 TspecParams.uUserPriority, 3073 TspecParams.uNominalMSDUsize, 3074 TspecParams.uMeanDataRate, 3075 TspecParams.uMinimumPHYRate, 3076 TspecParams.uSurplusBandwidthAllowance, 3077 TspecParams.uAPSDFlag, 3078 TspecParams.uMinimumServiceInterval, 3079 TspecParams.uMaximumServiceInterval, 3080 TspecParams.uMediumTime); 3081 } 3082 3083 VOID CuCmd_DeleteTspec(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3084 { 3085 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3086 OS_802_11_QOS_DELETE_TSPEC_PARAMS TspecParams; 3087 3088 TspecParams.uUserPriority = parm[0].value; 3089 TspecParams.uReasonCode = parm[1].value; 3090 3091 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_DELETE_TSPEC, 3092 &TspecParams, sizeof(OS_802_11_QOS_TSPEC_PARAMS))) return; 3093 3094 os_error_printf(CU_MSG_INFO2, (PS8)"TSPEC Delete request sent to driver...\n uUserPriority = %d\n uReasonCode = %d\n", 3095 TspecParams.uUserPriority, 3096 TspecParams.uReasonCode); 3097 } 3098 3099 VOID CuCmd_GetApQosParams(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3100 { 3101 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3102 OS_802_11_AC_QOS_PARAMS AcQosParams; 3103 S32 i = 0; 3104 3105 /* test if we can get the AC QOS Params */ 3106 AcQosParams.uAC = i; 3107 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_AP_QOS_PARAMS, 3108 &AcQosParams, sizeof(AcQosParams))) return; 3109 3110 os_error_printf(CU_MSG_INFO2, (PS8)"AP QOS Parameters:\n"); 3111 os_error_printf(CU_MSG_INFO2, (PS8)"+----+-------------+----------+-----------+-----------+-----------+\n"); 3112 os_error_printf(CU_MSG_INFO2, (PS8)"| AC | AdmCtrlFlag | AIFS | CwMin | CwMax | TXOPLimit |\n"); 3113 os_error_printf(CU_MSG_INFO2, (PS8)"+----+-------------+----------+-----------+-----------+-----------+\n"); 3114 os_error_printf(CU_MSG_INFO2, (PS8)"| %2d | %11d | %8d | %9d | %9d | %9d |\n", 3115 i, 3116 AcQosParams.uAssocAdmissionCtrlFlag, 3117 AcQosParams.uAIFS, 3118 AcQosParams.uCwMin, 3119 AcQosParams.uCwMax, 3120 AcQosParams.uTXOPLimit); 3121 3122 for (i=1; i<4; i++) 3123 { 3124 AcQosParams.uAC = i; 3125 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_AP_QOS_PARAMS, 3126 &AcQosParams, sizeof(AcQosParams))) return; 3127 3128 os_error_printf(CU_MSG_INFO2, (PS8)"| %2d | %11d | %8d | %9d | %9d | %9d |\n", 3129 i, 3130 AcQosParams.uAssocAdmissionCtrlFlag, 3131 AcQosParams.uAIFS, 3132 AcQosParams.uCwMin, 3133 AcQosParams.uCwMax, 3134 AcQosParams.uTXOPLimit); 3135 } 3136 os_error_printf(CU_MSG_INFO2, (PS8)"+----+-------------+----------+-----------+-----------+-----------+\n"); 3137 } 3138 3139 VOID CuCmd_GetPsRxStreamingParams(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3140 { 3141 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3142 TPsRxStreaming tPsRxStreaming; 3143 S32 i = 0; 3144 3145 os_error_printf(CU_MSG_INFO2, (PS8)"PS Rx Streaming Parameters:\n"); 3146 os_error_printf(CU_MSG_INFO2, (PS8)"+-----+--------------+------------+---------+\n"); 3147 os_error_printf(CU_MSG_INFO2, (PS8)"| TID | StreamPeriod | uTxTimeout | Enabled |\n"); 3148 os_error_printf(CU_MSG_INFO2, (PS8)"+-----+--------------+------------+---------+\n"); 3149 3150 for (i=0; i<8; i++) 3151 { 3152 tPsRxStreaming.uTid = i; 3153 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, QOS_MNGR_PS_RX_STREAMING, 3154 &tPsRxStreaming, sizeof(TPsRxStreaming))) return; 3155 3156 os_error_printf(CU_MSG_INFO2, (PS8)"| %3d | %12d | %10d | %7d |\n", 3157 tPsRxStreaming.uTid, 3158 tPsRxStreaming.uStreamPeriod, 3159 tPsRxStreaming.uTxTimeout, 3160 tPsRxStreaming.bEnabled); 3161 } 3162 os_error_printf(CU_MSG_INFO2, (PS8)"+-----+--------------+------------+---------+\n"); 3163 } 3164 3165 VOID CuCmd_GetApQosCapabilities(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3166 { 3167 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3168 3169 OS_802_11_AP_QOS_CAPABILITIES_PARAMS ApQosCapabiltiesParams; 3170 3171 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_AP_QOS_CAPABILITIES, 3172 &ApQosCapabiltiesParams, sizeof(OS_802_11_AP_QOS_CAPABILITIES_PARAMS))) return; 3173 3174 os_error_printf(CU_MSG_INFO2, (PS8)"AP Qos Capabilities:\n QOSFlag = %d\n APSDFlag = %d\n", 3175 ApQosCapabiltiesParams.uQOSFlag, 3176 ApQosCapabiltiesParams.uAPSDFlag); 3177 3178 } 3179 3180 VOID CuCmd_GetAcStatus(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3181 { 3182 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3183 OS_802_11_AC_UPSD_STATUS_PARAMS AcStatusParams; 3184 3185 AcStatusParams.uAC = parm[0].value; 3186 3187 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_CURRENT_AC_STATUS, 3188 &AcStatusParams, sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS))) return; 3189 3190 os_error_printf(CU_MSG_INFO2, (PS8)"AC %d Status:\n", AcStatusParams.uAC); 3191 os_error_printf(CU_MSG_INFO2, (PS8)"PS Scheme = %d (0=LEGACY, 1=UPSD)\n", AcStatusParams.uCurrentUAPSDStatus); 3192 os_error_printf(CU_MSG_INFO2, (PS8)"Admission Status = %d (0=NOT_ADMITTED, 1=WAIT_ADMISSION, 2=ADMITTED)\n", AcStatusParams.pCurrentAdmissionStatus); 3193 } 3194 3195 VOID CuCmd_ModifyMediumUsageTh(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3196 { 3197 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3198 OS_802_11_THRESHOLD_CROSS_PARAMS ThCrossParams; 3199 3200 if (nParms == 3) /* If user supplied 3 parameters - this is a SET operation */ 3201 { 3202 ThCrossParams.uAC = parm[0].value; 3203 ThCrossParams.uHighThreshold = parm[1].value; 3204 ThCrossParams.uLowThreshold = parm[2].value; 3205 3206 if (ThCrossParams.uLowThreshold > ThCrossParams.uHighThreshold) 3207 { 3208 os_error_printf(CU_MSG_INFO2, (PS8)"Low threshold cannot be higher than the High threshold...Aborting...\n"); 3209 return; 3210 } 3211 3212 if(OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SET_MEDIUM_USAGE_THRESHOLD, 3213 &ThCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS))) return; 3214 3215 os_error_printf(CU_MSG_INFO2, (PS8)"Medium usage threshold for AC %d has been set to:\n LowThreshold = %d\n HighThreshold = %d\n", 3216 ThCrossParams.uAC, 3217 ThCrossParams.uLowThreshold, 3218 ThCrossParams.uHighThreshold); 3219 } 3220 else if (nParms == 1) /* Only 1 parameter means a GET operation */ 3221 { 3222 ThCrossParams.uAC = parm[0].value; 3223 ThCrossParams.uLowThreshold = 0; 3224 ThCrossParams.uHighThreshold = 0; 3225 3226 if(OK != CuCommon_GetSetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_MEDIUM_USAGE_THRESHOLD, 3227 &ThCrossParams, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS))) return; 3228 3229 os_error_printf(CU_MSG_INFO2, (PS8)"Medium usage threshold for AC %d:\n LowThreshold = %d\n HighThreshold = %d\n", 3230 ThCrossParams.uAC, 3231 ThCrossParams.uLowThreshold, 3232 ThCrossParams.uHighThreshold); 3233 } 3234 } 3235 3236 3237 VOID CuCmd_GetDesiredPsMode(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3238 { 3239 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3240 OS_802_11_QOS_DESIRED_PS_MODE DesiredPsMode; 3241 3242 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_DESIRED_PS_MODE, 3243 &DesiredPsMode, sizeof(OS_802_11_QOS_DESIRED_PS_MODE))) return; 3244 3245 os_error_printf(CU_MSG_INFO2, (PS8)"Desired PS Mode (0=PS_POLL, 1=UPSD, 2=PS_NONE):\n"); 3246 os_error_printf(CU_MSG_INFO2, (PS8)"===============================================\n"); 3247 os_error_printf(CU_MSG_INFO2, (PS8)" +-----------+------+\n"); 3248 os_error_printf(CU_MSG_INFO2, (PS8)" | AC | Mode |\n"); 3249 os_error_printf(CU_MSG_INFO2, (PS8)" +-----------+------+\n"); 3250 os_error_printf(CU_MSG_INFO2, (PS8)" | General | %d |\n", DesiredPsMode.uDesiredPsMode); 3251 os_error_printf(CU_MSG_INFO2, (PS8)" | BE_AC | %d |\n", DesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_BE]); 3252 os_error_printf(CU_MSG_INFO2, (PS8)" | BK_AC | %d |\n", DesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_BK]); 3253 os_error_printf(CU_MSG_INFO2, (PS8)" | VI_AC | %d |\n", DesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_VI]); 3254 os_error_printf(CU_MSG_INFO2, (PS8)" | VO_AC | %d |\n", DesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_VO]); 3255 os_error_printf(CU_MSG_INFO2, (PS8)" +-----------+------+\n"); 3256 } 3257 3258 3259 VOID CuCmd_InsertClsfrEntry(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3260 { 3261 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3262 clsfr_tableEntry_t newUserTableEntry; 3263 S32 i; 3264 3265 if (nParms >=2) 3266 newUserTableEntry.DTag = (U8) parm[1].value; 3267 3268 switch(parm[0].value) 3269 { 3270 case D_TAG_CLSFR: 3271 os_error_printf(CU_MSG_INFO2, (PS8)"Cannot insert D_TAG classifier entry!\n"); 3272 return; 3273 case DSCP_CLSFR: 3274 if (nParms != 3) 3275 { 3276 os_error_printf(CU_MSG_INFO2, (PS8)"DSCP_CLSFR Entry type, wrong number of parameters(too many?)\n"); 3277 return; 3278 } 3279 newUserTableEntry.Dscp.CodePoint = (U8) parm[2].value; 3280 os_error_printf(CU_MSG_INFO2, (PS8)"Inserting new DSCP_CLSFR classifier entry\nD-Tag = %d\nCodePoint = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.CodePoint); 3281 break; 3282 case PORT_CLSFR: 3283 if (nParms != 3) 3284 { 3285 os_error_printf(CU_MSG_INFO2, (PS8)"PORT_CLSFR Entry type, wrong number of parameters(too many?)\n"); 3286 return; 3287 } 3288 newUserTableEntry.Dscp.DstPortNum = (U16) parm[2].value; 3289 os_error_printf(CU_MSG_INFO2, (PS8)"Inserting new PORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.DstPortNum); 3290 break; 3291 case IPPORT_CLSFR: 3292 if (nParms != 7) 3293 { 3294 os_error_printf(CU_MSG_INFO2, (PS8)"PORT_CLSFR Entry type, wrong number of parameters\n"); 3295 return; 3296 } 3297 newUserTableEntry.Dscp.DstIPPort.DstPortNum = (U16) parm[2].value; 3298 newUserTableEntry.Dscp.DstIPPort.DstIPAddress = 0; 3299 for(i=0; i<4; i++) 3300 { 3301 newUserTableEntry.Dscp.DstIPPort.DstIPAddress |= parm[i+3].value << i * 8; 3302 } 3303 os_error_printf(CU_MSG_INFO2, (PS8)"Inserting new IPPORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\nIP = %3d.%d.%d.%d\n", 3304 newUserTableEntry.DTag, 3305 newUserTableEntry.Dscp.DstIPPort.DstPortNum, 3306 (S32)parm[3].value,(S32)parm[4].value,(S32)parm[5].value,(S32)parm[6].value); 3307 break; 3308 default: 3309 os_error_printf(CU_MSG_INFO2, (PS8)"Unknown Classifier Type - Command aborted!\n"); 3310 return; 3311 } 3312 3313 if(CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_CONFIG_TX_CLASS, 3314 &newUserTableEntry, sizeof(clsfr_tableEntry_t))) 3315 { 3316 os_error_printf(CU_MSG_INFO2, (PS8)"Failed to insert new classifier entry...\n"); 3317 } 3318 } 3319 3320 VOID CuCmd_RemoveClsfrEntry(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3321 { 3322 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3323 clsfr_tableEntry_t newUserTableEntry; 3324 S32 i; 3325 3326 if (nParms >=2) 3327 newUserTableEntry.DTag = (U8) parm[1].value; 3328 3329 switch(parm[0].value) 3330 { 3331 case D_TAG_CLSFR: 3332 os_error_printf(CU_MSG_INFO2, (PS8)"Cannot remove D_TAG classifier entry!\n"); 3333 return; 3334 case DSCP_CLSFR: 3335 if (nParms != 3) 3336 { 3337 os_error_printf(CU_MSG_INFO2, (PS8)"DSCP_CLSFR Entry type, wrong number of parameters(too many?)\n"); 3338 return; 3339 } 3340 newUserTableEntry.Dscp.CodePoint = (U8) parm[2].value; 3341 os_error_printf(CU_MSG_INFO2, (PS8)"Removing DSCP_CLSFR classifier entry\nD-Tag = %d\nCodePoint = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.CodePoint); 3342 break; 3343 case PORT_CLSFR: 3344 if (nParms != 3) 3345 { 3346 os_error_printf(CU_MSG_INFO2, (PS8)"PORT_CLSFR Entry type, wrong number of parameters(too many?)\n"); 3347 return; 3348 } 3349 newUserTableEntry.Dscp.DstPortNum = (U16) parm[2].value; 3350 os_error_printf(CU_MSG_INFO2, (PS8)"Removing PORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.DstPortNum); 3351 break; 3352 case IPPORT_CLSFR: 3353 if (nParms != 7) 3354 { 3355 os_error_printf(CU_MSG_INFO2, (PS8)"PORT_CLSFR Entry type, wrong number of parameters\n"); 3356 return; 3357 } 3358 newUserTableEntry.Dscp.DstIPPort.DstPortNum = (U16) parm[2].value; 3359 newUserTableEntry.Dscp.DstIPPort.DstIPAddress = 0; 3360 for(i=0; i<4; i++) 3361 { 3362 newUserTableEntry.Dscp.DstIPPort.DstIPAddress |= parm[i+3].value << i * 8; 3363 } 3364 os_error_printf(CU_MSG_INFO2, (PS8)"Removing IPPORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\nIP = %3d.%d.%d.%d\n", 3365 newUserTableEntry.DTag, 3366 newUserTableEntry.Dscp.DstIPPort.DstPortNum, 3367 (S32)parm[3].value,(S32)parm[4].value,(S32)parm[5].value,(S32)parm[6].value); 3368 break; 3369 default: 3370 os_error_printf(CU_MSG_INFO2, (PS8)"Unknown Classifier Type - Command aborted!\n"); 3371 return; 3372 break; 3373 } 3374 3375 if(CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_REMOVE_CLSFR_ENTRY, 3376 &newUserTableEntry, sizeof(clsfr_tableEntry_t))) 3377 { 3378 os_error_printf(CU_MSG_INFO2, (PS8)"Failed to remove classifier entry...\n"); 3379 } 3380 } 3381 3382 3383 VOID CuCmd_SetPsRxDelivery(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3384 { 3385 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3386 TPsRxStreaming tPsRxStreaming; 3387 3388 tPsRxStreaming.uTid = parm[0].value; 3389 tPsRxStreaming.uStreamPeriod = parm[1].value; 3390 tPsRxStreaming.uTxTimeout = parm[2].value; 3391 tPsRxStreaming.bEnabled = parm[3].value; 3392 3393 if (CuCommon_SetBuffer(pCuCmd->hCuCommon, QOS_MNGR_PS_RX_STREAMING, 3394 &tPsRxStreaming, sizeof(TPsRxStreaming)) == OK) 3395 { 3396 os_error_printf(CU_MSG_INFO2, (PS8)"Sent PS Rx Delivery to driver..."); 3397 } 3398 else 3399 { 3400 os_error_printf(CU_MSG_INFO2, (PS8)"Error: could not set PS Rx Delivery in driver...\n"); 3401 } 3402 os_error_printf(CU_MSG_INFO2, 3403 (PS8)"TID = %d \n RxPeriod = %d \n TxTimeout = %d\n Enabled = %d\n", 3404 tPsRxStreaming.uTid, 3405 tPsRxStreaming.uStreamPeriod, 3406 tPsRxStreaming.uTxTimeout, 3407 tPsRxStreaming.bEnabled); 3408 } 3409 3410 3411 VOID CuCmd_SetQosParams(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3412 { 3413 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3414 OS_802_11_QOS_PARAMS QosParams; 3415 3416 QosParams.acID=parm[0].value; 3417 QosParams.MaxLifeTime=parm[1].value; 3418 QosParams.PSDeliveryProtocol = parm[2].value; 3419 3420 if (CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SET_QOS_PARAMS, 3421 &QosParams, sizeof(OS_802_11_QOS_PARAMS)) == OK) 3422 { 3423 os_error_printf(CU_MSG_INFO2, (PS8)"Sent QOS params to driver...\n AC Number=%d \n MaxLifeTime=%d \n PSDeliveryProtocol = %d\n", 3424 QosParams.acID, 3425 QosParams.MaxLifeTime, 3426 QosParams.PSDeliveryProtocol); 3427 } 3428 else 3429 { 3430 os_error_printf(CU_MSG_INFO2, (PS8)"Error: could not set QOS params...\n"); 3431 } 3432 } 3433 3434 VOID CuCmd_SetRxTimeOut(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3435 { 3436 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3437 OS_802_11_QOS_RX_TIMEOUT_PARAMS rxTimeOut; 3438 3439 rxTimeOut.psPoll = parm[0].value; 3440 rxTimeOut.UPSD = parm[1].value; 3441 3442 if (nParms != 2) 3443 { 3444 os_error_printf(CU_MSG_INFO2, (PS8)"Please enter Rx Time Out:\n"); 3445 os_error_printf(CU_MSG_INFO2, (PS8)"Param 0 - psPoll (0 - 65000)\n"); 3446 os_error_printf(CU_MSG_INFO2, (PS8)"Param 1 - UPSD (1 - 65000)\n"); 3447 } 3448 else 3449 { 3450 if(CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SET_RX_TIMEOUT, 3451 &rxTimeOut, sizeof(OS_802_11_QOS_RX_TIMEOUT_PARAMS)) == OK) 3452 { 3453 os_error_printf(CU_MSG_INFO2, (PS8)"Sent QOS Rx TimeOut params to driver...\n PsPoll = %d\n UPSD = %d\n", 3454 rxTimeOut.psPoll, 3455 rxTimeOut.UPSD); 3456 } 3457 else 3458 { 3459 os_error_printf(CU_MSG_INFO2, (PS8)"Error: could not set Rx TimeOut..\n"); 3460 } 3461 } 3462 } 3463 3464 VOID CuCmd_RegisterEvents(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3465 { 3466 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3467 3468 if( nParms ) 3469 { 3470 U32 event; 3471 S32 res, i; 3472 3473 event = (U32)parm[0].value; 3474 3475 CU_CMD_FIND_NAME_ARRAY(i, event_type, event); 3476 if(i == SIZE_ARR(event_type)) 3477 { 3478 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_RegisterEvents, event %d is not defined!\n", event); 3479 return; 3480 } 3481 3482 res = IpcEvent_EnableEvent(pCuCmd->hIpcEvent, event); 3483 if (res == EOALERR_IPC_EVENT_ERROR_EVENT_ALREADY_ENABLED) 3484 { 3485 CU_CMD_FIND_NAME_ARRAY(i, event_type, event); 3486 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_RegisterEvents, event %s is already enabled!\n", event_type[i].name); 3487 return; 3488 } 3489 3490 } 3491 else 3492 { 3493 print_available_values(event_type); 3494 } 3495 } 3496 3497 VOID CuCmd_UnregisterEvents(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3498 { 3499 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3500 3501 if( nParms ) 3502 { 3503 U32 event; 3504 S32 res, i; 3505 3506 event = (U32)parm[0].value; 3507 3508 CU_CMD_FIND_NAME_ARRAY(i, event_type, event); 3509 if(i == SIZE_ARR(event_type)) 3510 { 3511 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_RegisterEvents, event %d is not defined!\n", event); 3512 return; 3513 } 3514 3515 res = IpcEvent_DisableEvent(pCuCmd->hIpcEvent, event); 3516 if (res == EOALERR_IPC_EVENT_ERROR_EVENT_ALREADY_DISABLED) 3517 { 3518 CU_CMD_FIND_NAME_ARRAY(i, event_type, event); 3519 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_RegisterEvents, event %s is already disabled!\n", event_type[i].name); 3520 return; 3521 } 3522 3523 } 3524 else 3525 { 3526 print_available_values(event_type); 3527 } 3528 } 3529 3530 VOID CuCmd_EnableBtCoe(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3531 { 3532 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3533 ESoftGeminiEnableModes BtMode; 3534 S32 i; 3535 3536 named_value_t BtCoe_Mode[] = 3537 { 3538 { SG_DISABLE, (PS8)"Disable" }, 3539 { SG_PROTECTIVE, (PS8)"Protective" }, 3540 { SG_OPPORTUNISTIC, (PS8)"Opportunistic" }, 3541 }; 3542 3543 3544 if(nParms) 3545 { 3546 CU_CMD_FIND_NAME_ARRAY(i, BtCoe_Mode, parm[0].value); 3547 if(i == SIZE_ARR(BtCoe_Mode)) 3548 { 3549 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_EnableBtCoe, mode %d is not defined!\n", parm[0].value); 3550 return; 3551 } 3552 BtMode = parm[0].value; 3553 CuCommon_SetU32(pCuCmd->hCuCommon, SOFT_GEMINI_SET_ENABLE, BtMode); 3554 } 3555 else 3556 { 3557 print_available_values(BtCoe_Mode); 3558 } 3559 } 3560 3561 VOID CuCmd_ConfigBtCoe(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3562 { 3563 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3564 U32 Values[NUM_OF_CONFIG_PARAMS_IN_SG]; 3565 U8 Index; 3566 3567 if( nParms != NUM_OF_CONFIG_PARAMS_IN_SG ) 3568 { 3569 os_error_printf(CU_MSG_INFO2, (PS8)"Please enter <index (0,1..)> <value> \n"); 3570 3571 os_error_printf(CU_MSG_INFO2, (PS8)"Param 0 - coexBtPerThreshold (0 - 10000000) PER threshold in PPM of the BT voice \n"); 3572 os_error_printf(CU_MSG_INFO2, (PS8)"Param 1 - coexAutoScanCompensationMaxTime (0 - 10000000 usec) \n"); 3573 os_error_printf(CU_MSG_INFO2, (PS8)"Param 2 - coexBtNfsSampleInterval (1 - 65000 msec) \n"); 3574 os_error_printf(CU_MSG_INFO2, (PS8)"Param 3 - coexBtLoadRatio (0 - 100 %) \n"); 3575 os_error_printf(CU_MSG_INFO2, (PS8)"Param 4 - coexAutoPsMode (0 = Disabled, 1 = Enabled) Auto Power Save \n"); 3576 os_error_printf(CU_MSG_INFO2, (PS8)"Param 5 - coexAutoScanEnlargedNumOfProbeReqPercent (%) \n"); 3577 os_error_printf(CU_MSG_INFO2, (PS8)"Param 6 - coexAutoScanEnlargedScanWindowPercent (%) \n"); 3578 os_error_printf(CU_MSG_INFO2, (PS8)"Param 7 - coexAntennaConfiguration (0 = Single, 1 = Dual)\n"); 3579 os_error_printf(CU_MSG_INFO2, (PS8)"Param 8 - coexMaxConsecutiveBeaconMissPrecent (1 - 100 %) \n"); 3580 os_error_printf(CU_MSG_INFO2, (PS8)"Param 9 - coexAPRateAdapationThr - rates (1 - 54)\n"); 3581 os_error_printf(CU_MSG_INFO2, (PS8)"Param 10 - coexAPRateAdapationSnr (-128 - 127)\n"); 3582 os_error_printf(CU_MSG_INFO2, (PS8)"Param 11 - coexWlanPsBtAclMasterMinBR (msec) \n"); 3583 os_error_printf(CU_MSG_INFO2, (PS8)"Param 12 - coexWlanPsBtAclMasterMaxBR (msec) \n"); 3584 os_error_printf(CU_MSG_INFO2, (PS8)"Param 13 - coexWlanPsMaxBtAclMasterBR (msec) \n"); 3585 os_error_printf(CU_MSG_INFO2, (PS8)"Param 14 - coexWlanPsBtAclSlaveMinBR (msec) \n"); 3586 os_error_printf(CU_MSG_INFO2, (PS8)"Param 15 - coexWlanPsBtAclSlaveMaxBR (msec) \n"); 3587 os_error_printf(CU_MSG_INFO2, (PS8)"Param 16 - coexWlanPsMaxBtAclSlaveBR (msec) \n"); 3588 os_error_printf(CU_MSG_INFO2, (PS8)"Param 17 - coexWlanPsBtAclMasterMinEDR (msec) \n"); 3589 os_error_printf(CU_MSG_INFO2, (PS8)"Param 18 - coexWlanPsBtAclMasterMaxEDR (msec) \n"); 3590 os_error_printf(CU_MSG_INFO2, (PS8)"Param 19 - coexWlanPsMaxBtAclMasterEDR (msec) \n"); 3591 os_error_printf(CU_MSG_INFO2, (PS8)"Param 20 - coexWlanPsBtAclSlaveMinEDR (msec) \n"); 3592 os_error_printf(CU_MSG_INFO2, (PS8)"Param 21 - coexWlanPsBtAclSlaveMaxEDR (msec) \n"); 3593 os_error_printf(CU_MSG_INFO2, (PS8)"Param 22 - coexWlanPsMaxBtAclSlaveEDR (msec) \n"); 3594 os_error_printf(CU_MSG_INFO2, (PS8)"Param 23 - coexRxt (usec) \n"); 3595 os_error_printf(CU_MSG_INFO2, (PS8)"Param 24 - coexTxt (usec) \n"); 3596 os_error_printf(CU_MSG_INFO2, (PS8)"Param 25 - coexAdaptiveRxtTxt (0 = Disable, 1 = Enable) \n"); 3597 os_error_printf(CU_MSG_INFO2, (PS8)"Param 26 - coexPsPollTimeout (msec) \n"); 3598 os_error_printf(CU_MSG_INFO2, (PS8)"Param 27 - coexUpsdTimeout (msec) \n"); 3599 os_error_printf(CU_MSG_INFO2, (PS8)"Param 28 - coexWlanActiveBtAclMasterMinEDR (msec) \n"); 3600 os_error_printf(CU_MSG_INFO2, (PS8)"Param 29 - coexWlanActiveBtAclMasterMaxEDR (msec) \n"); 3601 os_error_printf(CU_MSG_INFO2, (PS8)"Param 30 - coexWlanActiveMaxBtAclMasterEDR (msec) \n"); 3602 os_error_printf(CU_MSG_INFO2, (PS8)"Param 31 - coexWlanActiveBtAclSlaveMinEDR (msec) \n"); 3603 os_error_printf(CU_MSG_INFO2, (PS8)"Param 32 - coexWlanActiveBtAclSlaveMaxEDR (msec) \n"); 3604 os_error_printf(CU_MSG_INFO2, (PS8)"Param 33 - coexWlanActiveMaxBtAclSlaveEDR (msec) \n"); 3605 os_error_printf(CU_MSG_INFO2, (PS8)"Param 34 - coexWlanActiveBtAclMinBR (msec) \n"); 3606 os_error_printf(CU_MSG_INFO2, (PS8)"Param 35 - coexWlanActiveBtAclMaxBR (msec) \n"); 3607 os_error_printf(CU_MSG_INFO2, (PS8)"Param 36 - coexWlanActiveMaxBtAclBR (msec) \n"); 3608 os_error_printf(CU_MSG_INFO2, (PS8)"Param 37 - coexTempParam1 \n"); 3609 os_error_printf(CU_MSG_INFO2, (PS8)"Param 38 - coexTempParam2 \n"); 3610 os_error_printf(CU_MSG_INFO2, (PS8)"Param 39 - coexTempParam3 \n"); 3611 os_error_printf(CU_MSG_INFO2, (PS8)"Param 40 - coexTempParam4 \n"); 3612 os_error_printf(CU_MSG_INFO2, (PS8)"Param 41 - coexTempParam5 \n"); 3613 3614 return; 3615 } 3616 if ((parm[0].value == SOFT_GEMINI_RATE_ADAPT_THRESH) && (CuCmd_IsValueRate(parm[1].value) == FALSE)) 3617 { 3618 os_error_printf(CU_MSG_INFO2, (PS8)"Invalid rate - PHY rate valid values are: 1,2,5,6,9,11,12,18,24,36,48,54\n"); 3619 } 3620 else 3621 { 3622 for (Index = 0; Index < NUM_OF_CONFIG_PARAMS_IN_SG; Index++ ) 3623 { 3624 Values[Index] = parm[Index].value; 3625 /* value[0] - parmater index, value[1] - parameter value */ 3626 } 3627 CuCommon_SetBuffer(pCuCmd->hCuCommon, SOFT_GEMINI_SET_CONFIG, Values, sizeof(Values)); 3628 } 3629 } 3630 3631 VOID CuCmd_GetBtCoeStatus(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3632 { 3633 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3634 U32 uDummyBuf; 3635 3636 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, SOFT_GEMINI_GET_CONFIG, 3637 &uDummyBuf, sizeof(U32))) 3638 { 3639 return; 3640 } 3641 } 3642 3643 VOID CuCmd_ConfigCoexActivity(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3644 { 3645 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3646 TCoexActivity tCoexActivity; 3647 3648 if( nParms != NUM_OF_COEX_ACTIVITY_PARAMS_IN_SG ) 3649 { 3650 os_error_printf(CU_MSG_INFO2, (PS8)"Param 1 - coexIp (0 - 1) BT-0, WLAN-1 \n"); 3651 os_error_printf(CU_MSG_INFO2, (PS8)"Param 2 - activityId (0 - 24) \n"); 3652 os_error_printf(CU_MSG_INFO2, (PS8)"Param 3 - defaultPriority (0 - 255) \n"); 3653 os_error_printf(CU_MSG_INFO2, (PS8)"Param 4 - raisedPriority (0 - 255) \n"); 3654 os_error_printf(CU_MSG_INFO2, (PS8)"Param 5 - minService (0 - 65535) \n"); 3655 os_error_printf(CU_MSG_INFO2, (PS8)"Param 6 - maxService (0 - 65535) \n"); 3656 } 3657 else 3658 { 3659 tCoexActivity.coexIp = (U8)parm[0].value; 3660 tCoexActivity.activityId = (U8)parm[1].value; 3661 tCoexActivity.defaultPriority = (U8)parm[2].value; 3662 tCoexActivity.raisedPriority = (U8)parm[3].value; 3663 tCoexActivity.minService = (U16)parm[4].value; 3664 tCoexActivity.maxService = (U16)parm[5].value; 3665 3666 CuCommon_SetBuffer(pCuCmd->hCuCommon, TWD_COEX_ACTIVITY_PARAM, 3667 &tCoexActivity, sizeof(tCoexActivity)); 3668 } 3669 } 3670 3671 VOID CuCmd_ConfigFmCoex(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3672 { 3673 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3674 TFmCoexParams tFmCoexParams; 3675 3676 if (nParms != 10) 3677 { 3678 os_error_printf(CU_MSG_INFO2, (PS8)"1 - Enable (0 - 1) \n"); 3679 os_error_printf(CU_MSG_INFO2, (PS8)"2 - SwallowPeriod (0 - 255) \n"); 3680 os_error_printf(CU_MSG_INFO2, (PS8)"3 - NDividerFrefSet1 (0 - 255) \n"); 3681 os_error_printf(CU_MSG_INFO2, (PS8)"4 - NDividerFrefSet2 (0 - 255) \n"); 3682 os_error_printf(CU_MSG_INFO2, (PS8)"5 - MDividerFrefSet1 (0 - 65535) \n"); 3683 os_error_printf(CU_MSG_INFO2, (PS8)"6 - MDividerFrefSet2 (0 - 65535) \n"); 3684 os_error_printf(CU_MSG_INFO2, (PS8)"7 - CoexPllStabilizationTime (0 - 4294967295) \n"); 3685 os_error_printf(CU_MSG_INFO2, (PS8)"8 - LdoStabilizationTime (0 - 65535) \n"); 3686 os_error_printf(CU_MSG_INFO2, (PS8)"9 - FmDisturbedBandMargin (0 - 255) \n"); 3687 os_error_printf(CU_MSG_INFO2, (PS8)"10- SwallowClkDif (0 - 255) \n"); 3688 } 3689 else 3690 { 3691 tFmCoexParams.uEnable = (TI_UINT8)parm[0].value; 3692 tFmCoexParams.uSwallowPeriod = (TI_UINT8)parm[1].value; 3693 tFmCoexParams.uNDividerFrefSet1 = (TI_UINT8)parm[2].value; 3694 tFmCoexParams.uNDividerFrefSet2 = (TI_UINT8)parm[3].value; 3695 tFmCoexParams.uMDividerFrefSet1 = (TI_UINT16)parm[4].value; 3696 tFmCoexParams.uMDividerFrefSet2 = (TI_UINT16)parm[5].value; 3697 tFmCoexParams.uCoexPllStabilizationTime = parm[6].value; 3698 tFmCoexParams.uLdoStabilizationTime = (TI_UINT16)parm[7].value; 3699 tFmCoexParams.uFmDisturbedBandMargin = (TI_UINT8)parm[8].value; 3700 tFmCoexParams.uSwallowClkDif = (TI_UINT8)parm[9].value; 3701 3702 CuCommon_SetBuffer(pCuCmd->hCuCommon, TWD_FM_COEX_PARAM, &tFmCoexParams, sizeof(TFmCoexParams)); 3703 } 3704 } 3705 3706 VOID CuCmd_SetPowerMode(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3707 { 3708 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3709 TPowerMgr_PowerMode Mode; 3710 S32 i; 3711 3712 if( nParms ) 3713 { 3714 CU_CMD_FIND_NAME_ARRAY(i, power_mode_val, parm[0].value); 3715 if(i == SIZE_ARR(power_mode_val)) 3716 { 3717 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetPowerMode, mode %d is not defined!\n", parm[0].value); 3718 return; 3719 } 3720 Mode.PowerMode = parm[0].value; 3721 Mode.PowerMngPriority = POWER_MANAGER_USER_PRIORITY; 3722 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_POWER_MODE_SET, 3723 &Mode, sizeof(TPowerMgr_PowerMode)); 3724 } 3725 else 3726 { 3727 if(!CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_POWER_MODE_GET, &Mode, sizeof(TPowerMgr_PowerMode))) 3728 { 3729 os_error_printf(CU_MSG_INFO2, (PS8)"Power mode: %d\n", Mode.PowerMode); 3730 print_available_values(power_mode_val); 3731 } 3732 } 3733 } 3734 3735 VOID CuCmd_SetPowerSavePowerLevel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3736 { 3737 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3738 U32 PowerSavePowerLevel; 3739 S32 i; 3740 3741 if( nParms ) 3742 { 3743 CU_CMD_FIND_NAME_ARRAY(i, power_level, parm[0].value); 3744 if(i == SIZE_ARR(power_level)) 3745 { 3746 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetPowerSavePowerLevel, level %d is not defined!\n", parm[0].value); 3747 return; 3748 } 3749 PowerSavePowerLevel = parm[0].value; 3750 CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_802_11_POWER_LEVEL_PS_SET, PowerSavePowerLevel); 3751 } 3752 else 3753 { 3754 if(!CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_802_11_POWER_LEVEL_PS_GET, &PowerSavePowerLevel)) 3755 { 3756 CU_CMD_FIND_NAME_ARRAY(i, power_level, PowerSavePowerLevel); 3757 os_error_printf(CU_MSG_INFO2, (PS8)"Power Level PowerSave is: %s\n", power_level[i].name); 3758 print_available_values(power_level); 3759 } 3760 } 3761 } 3762 3763 VOID CuCmd_SetDefaultPowerLevel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3764 { 3765 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3766 U32 DefaultPowerLevel; 3767 S32 i; 3768 3769 if( nParms ) 3770 { 3771 CU_CMD_FIND_NAME_ARRAY(i, power_level, parm[0].value); 3772 if(i == SIZE_ARR(power_level)) 3773 { 3774 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetDefaultPowerLevel, level %d is not defined!\n", parm[0].value); 3775 return; 3776 } 3777 DefaultPowerLevel = parm[0].value; 3778 CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_802_11_POWER_LEVEL_DEFAULT_SET, DefaultPowerLevel); 3779 } 3780 else 3781 { 3782 if(!CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_802_11_POWER_LEVEL_DEFAULT_GET, &DefaultPowerLevel)) 3783 { 3784 CU_CMD_FIND_NAME_ARRAY(i, power_level, DefaultPowerLevel); 3785 os_error_printf(CU_MSG_INFO2, (PS8)"Power Level Default is: %s\n", power_level[i].name); 3786 print_available_values(power_level); 3787 } 3788 } 3789 } 3790 3791 VOID CuCmd_SetDozeModeInAutoPowerLevel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3792 { 3793 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3794 U32 DozeModeInAutoPowerLevel; 3795 S32 i; 3796 3797 if( nParms ) 3798 { 3799 DozeModeInAutoPowerLevel = parm[0].value; 3800 3801 if((DozeModeInAutoPowerLevel > AUTO_POWER_MODE_DOZE_MODE_MAX_VALUE) || (DozeModeInAutoPowerLevel < AUTO_POWER_MODE_DOZE_MODE_MIN_VALUE)) 3802 { 3803 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetDozeModeInAutoPowerLevel, level %d is not defined!\n", DozeModeInAutoPowerLevel); 3804 return; 3805 } 3806 CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_802_11_POWER_LEVEL_DOZE_MODE_SET, DozeModeInAutoPowerLevel); 3807 } 3808 else 3809 { 3810 /* set Short or Long Doze. no use of other parameters */ 3811 if(!CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_802_11_POWER_LEVEL_DOZE_MODE_GET, &DozeModeInAutoPowerLevel)) 3812 { 3813 CU_CMD_FIND_NAME_ARRAY(i, power_mode_val, DozeModeInAutoPowerLevel); 3814 os_error_printf(CU_MSG_INFO2, (PS8)"Doze power level in auto mode is: %s\n", power_mode_val[i].name); 3815 } 3816 } 3817 } 3818 3819 VOID CuCmd_SetTrafficIntensityTh(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3820 { 3821 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3822 OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS TrafficIntensityTh; 3823 3824 if (nParms == 3) 3825 { 3826 TrafficIntensityTh.uHighThreshold = parm[0].value; 3827 TrafficIntensityTh.uLowThreshold = parm[1].value; 3828 TrafficIntensityTh.TestInterval = parm[2].value; 3829 3830 if (TrafficIntensityTh.uLowThreshold >= TrafficIntensityTh.uHighThreshold) 3831 { 3832 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetTrafficIntensityTh - low threshold equal or greater than the high threshold...aborting...\n"); 3833 } 3834 3835 if(OK == CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_SET_TRAFFIC_INTENSITY_THRESHOLDS, 3836 &TrafficIntensityTh, sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS))) 3837 { 3838 os_error_printf(CU_MSG_INFO2, (PS8)"Successfully set traffic intensity thresholds...\n"); 3839 } 3840 else 3841 { 3842 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetTrafficIntensityTh - cannot set thresholds\n"); 3843 } 3844 } 3845 else if (nParms == 0) 3846 { 3847 if(OK == CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_GET_TRAFFIC_INTENSITY_THRESHOLDS, 3848 &TrafficIntensityTh, sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS))) 3849 { 3850 os_error_printf(CU_MSG_INFO2, (PS8)"Traffic intensity thresholds :\n HighThreshold = %d\n LowThreshold = %d\n TestInterval = %d\n", 3851 TrafficIntensityTh.uHighThreshold, 3852 TrafficIntensityTh.uLowThreshold, 3853 TrafficIntensityTh.TestInterval); 3854 } 3855 else 3856 { 3857 os_error_printf (CU_MSG_ERROR, (PS8)"Error - CuCmd_SetTrafficIntensityTh - cannot get thresholds\n"); 3858 } 3859 } 3860 } 3861 3862 VOID CuCmd_EnableTrafficEvents(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3863 { 3864 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3865 if(OK != CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_802_11_TOGGLE_TRAFFIC_INTENSITY_EVENTS, TRUE) ) return; 3866 os_error_printf(CU_MSG_INFO2, (PS8)"Traffic intensity thresholds enabled...\n"); 3867 } 3868 3869 VOID CuCmd_DisableTrafficEvents(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3870 { 3871 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3872 if(OK != CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_802_11_TOGGLE_TRAFFIC_INTENSITY_EVENTS, FALSE) ) return; 3873 os_error_printf(CU_MSG_INFO2, (PS8)"Traffic intensity thresholds disabled...\n"); 3874 } 3875 3876 3877 VOID CuCmd_LogAddReport(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3878 { 3879 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3880 U8 ModuleTable[REPORT_FILES_NUM], ModuleValue[REPORT_FILES_NUM] = {0}; 3881 int index = 0; 3882 3883 os_memcpy((THandle)ModuleValue, (THandle)(parm[0].value), nParms); 3884 3885 for (index = 0; index < REPORT_FILES_NUM; index ++) 3886 { 3887 if (ModuleValue[index] == '1') 3888 { 3889 ModuleTable[index] = '1'; 3890 } 3891 else 3892 { 3893 ModuleTable[index] = '0'; 3894 } 3895 } 3896 CuCommon_SetBuffer(pCuCmd->hCuCommon, REPORT_MODULE_TABLE_PARAM, ModuleTable, REPORT_FILES_NUM); 3897 } 3898 3899 VOID CuCmd_LogReportSeverityLevel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3900 { 3901 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3902 U8 SeverityTable[REPORT_SEVERITY_MAX]; 3903 S32 index = 0; 3904 PS8 SeverityValue = (PS8)(parm[0].value); 3905 3906 /* Get the current report severity */ 3907 if (!CuCommon_GetBuffer(pCuCmd->hCuCommon, REPORT_SEVERITY_TABLE_PARAM, SeverityTable, REPORT_SEVERITY_MAX)) 3908 { 3909 if(nParms == 0) 3910 { 3911 S32 i; 3912 3913 os_error_printf(CU_MSG_INFO2, (PS8)"Severity:\n"); 3914 os_error_printf(CU_MSG_INFO2, (PS8)"-------------------------------\n"); 3915 os_error_printf(CU_MSG_INFO2, (PS8)"%14s\tState\t%s\n", (PS8)"Severity level", (PS8)"Desc"); 3916 3917 for( i=1; i<SIZE_ARR(report_severity); i++ ) 3918 { 3919 os_error_printf(CU_MSG_INFO2, (PS8)"%d\t%c\t%s\n", report_severity[i].value, (SeverityTable[i] == '1') ? '+' : ' ', report_severity[i].name ); 3920 } 3921 3922 os_error_printf(CU_MSG_INFO2, (PS8)"* Use '0' to clear all table.\n"); 3923 os_error_printf(CU_MSG_INFO2, (PS8)"* Use '%d' (max index) to set all table.\n", REPORT_SEVERITY_MAX); 3924 } 3925 else 3926 { 3927 for (index = 0; index < REPORT_SEVERITY_MAX; index ++) 3928 { 3929 if (SeverityValue[index] == '0') 3930 { 3931 SeverityTable[index] = '0'; 3932 } 3933 else 3934 { 3935 SeverityTable[index] = '1'; 3936 } 3937 } 3938 CuCommon_SetBuffer(pCuCmd->hCuCommon, REPORT_SEVERITY_TABLE_PARAM, SeverityTable, REPORT_SEVERITY_MAX); 3939 } 3940 } 3941 else 3942 { 3943 os_error_printf(CU_MSG_ERROR, (PS8)"Error retriving the severity table from the driver\n"); 3944 } 3945 } 3946 3947 VOID CuCmd_SetReport(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3948 { 3949 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3950 U8 *pModuleTable = (U8 *)parm[0].value; 3951 3952 if( nParms != 1) 3953 { 3954 U8 ModuleTable[REPORT_FILES_NUM]; 3955 S32 i; 3956 3957 if (!CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_GET, ModuleTable, REPORT_FILES_NUM)) 3958 { 3959 os_error_printf(CU_MSG_INFO2, (PS8)"-------------------------------\n"); 3960 os_error_printf(CU_MSG_INFO2, (PS8)"%.5s\tState\t %s\n", (PS8)"Index", (PS8)"Desc"); 3961 3962 for( i = 0; i < SIZE_ARR(report_module); i++) 3963 { 3964 /* Check if there is string content (the first character is not ZERO) */ 3965 if( report_module[i].name[0] ) 3966 { 3967 U8 module_num = (U8) report_module[i].value; 3968 os_error_printf(CU_MSG_INFO2, (PS8)"%3d\t%c\t%s\n", 3969 module_num, 3970 (ModuleTable[module_num] == '1') ? '+' : ' ', 3971 report_module[i].name ); 3972 } 3973 } 3974 } 3975 else 3976 { 3977 os_error_printf(CU_MSG_ERROR, (PS8)"Error reading the report table form the driver\n"); 3978 } 3979 } 3980 else 3981 { 3982 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_SET, pModuleTable, REPORT_FILES_NUM); 3983 } 3984 } 3985 3986 VOID CuCmd_AddReport(THandle hCuCmd, ConParm_t parm[], U16 nParms) 3987 { 3988 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 3989 U8 ModuleTable[REPORT_FILES_NUM]; 3990 3991 if( nParms != 1) 3992 { 3993 S32 i; 3994 if (!CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_GET, ModuleTable, REPORT_FILES_NUM)) 3995 { 3996 os_error_printf(CU_MSG_INFO2, (PS8)"-------------------------------\n"); 3997 os_error_printf(CU_MSG_INFO2, (PS8)"%.5s\tState\t %s\n", (PS8)"Index", (PS8)"Desc"); 3998 3999 for( i = 0; i < SIZE_ARR(report_module); i++) 4000 { 4001 /* Check if there is string content (the first character is not ZERO) */ 4002 if( report_module[i].name[0] ) 4003 { 4004 os_error_printf(CU_MSG_INFO2, (PS8)"%3d\t%c\t%s\n", report_module[i].value, (ModuleTable[i] == '1') ? '+' : ' ', report_module[i].name ); 4005 } 4006 } 4007 } 4008 else 4009 { 4010 os_error_printf(CU_MSG_ERROR, (PS8)"Error reading the report table form the driver\n"); 4011 } 4012 os_error_printf(CU_MSG_INFO2, (PS8)"* Use '%d' (max index) to set all table.\n", REPORT_FILES_NUM); 4013 } 4014 else if(!CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_GET, ModuleTable, REPORT_FILES_NUM)) 4015 { 4016 if (parm[0].value == REPORT_FILES_NUM) 4017 { 4018 os_memset(ModuleTable, '1', REPORT_FILES_NUM); 4019 } 4020 else if(parm[0].value < REPORT_FILES_NUM) 4021 { 4022 ModuleTable[parm[0].value] = '1'; 4023 } 4024 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_SET, ModuleTable, REPORT_FILES_NUM); 4025 } 4026 } 4027 4028 VOID CuCmd_ClearReport(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4029 { 4030 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4031 U8 ModuleTable[REPORT_FILES_NUM]; 4032 4033 if( nParms != 1) 4034 { 4035 S32 i; 4036 if (!CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_GET, ModuleTable, REPORT_FILES_NUM)) 4037 { 4038 os_error_printf(CU_MSG_INFO2, (PS8)"-------------------------------\n"); 4039 os_error_printf(CU_MSG_INFO2, (PS8)"%.5s\tState\t %s\n", (PS8)"Index", (PS8)"Desc"); 4040 4041 for( i = 0; i < SIZE_ARR(report_module); i++) 4042 { 4043 /* Check if there is string content (the first character is not ZERO) */ 4044 if( report_module[i].name[0] ) 4045 { 4046 os_error_printf(CU_MSG_INFO2, (PS8)"%3d\t%c\t%s\n", report_module[i].value, (ModuleTable[i] == '1') ? '+' : ' ', report_module[i].name ); 4047 } 4048 } 4049 } 4050 else 4051 { 4052 os_error_printf(CU_MSG_ERROR, (PS8)"Error reading the report table form the driver\n"); 4053 } 4054 os_error_printf(CU_MSG_INFO2, (PS8)"* Use '%d' (max index) to clear all table.\n", REPORT_FILES_NUM); 4055 } 4056 else if(!CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_GET, ModuleTable, REPORT_FILES_NUM)) 4057 { 4058 if (parm[0].value == REPORT_FILES_NUM) 4059 { 4060 os_memset(ModuleTable, '0', REPORT_FILES_NUM); 4061 } 4062 else if(parm[0].value < REPORT_FILES_NUM) 4063 { 4064 ModuleTable[parm[0].value] = '0'; 4065 } 4066 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_MODULE_SET, ModuleTable, REPORT_FILES_NUM); 4067 } 4068 } 4069 4070 VOID CuCmd_ReportSeverityLevel(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4071 { 4072 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4073 U8 SeverityTable[REPORT_SEVERITY_MAX]; 4074 4075 /* Get the current report severity */ 4076 if (!CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_SEVERITY_GET, SeverityTable, REPORT_SEVERITY_MAX)) 4077 { 4078 if(nParms == 0) 4079 { 4080 S32 i; 4081 4082 os_error_printf(CU_MSG_INFO2, (PS8)"Severity:\n"); 4083 os_error_printf(CU_MSG_INFO2, (PS8)"-------------------------------\n"); 4084 os_error_printf(CU_MSG_INFO2, (PS8)"%14s\tState\t%s\n", (PS8)"Severity level", (PS8)"Desc"); 4085 4086 for( i=1; i<SIZE_ARR(report_severity); i++ ) 4087 { 4088 os_error_printf(CU_MSG_INFO2, (PS8)"%d\t%c\t%s\n", report_severity[i].value, (SeverityTable[i] == '1') ? '+' : ' ', report_severity[i].name ); 4089 } 4090 4091 os_error_printf(CU_MSG_INFO2, (PS8)"* Use '0' to clear all table.\n"); 4092 os_error_printf(CU_MSG_INFO2, (PS8)"* Use '%d' (max index) to set all table.\n", REPORT_SEVERITY_MAX); 4093 } 4094 else 4095 { 4096 if (parm[0].value == 0) 4097 { 4098 /* Disable all severity levels */ 4099 os_memset(SeverityTable, '0', sizeof(SeverityTable)); 4100 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_SEVERITY_SET, SeverityTable, REPORT_SEVERITY_MAX); 4101 } 4102 else if (parm[0].value == REPORT_SEVERITY_MAX) 4103 { 4104 /* Enable all severity levels */ 4105 os_memset(SeverityTable, '1', sizeof(SeverityTable)); 4106 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_SEVERITY_SET, SeverityTable, REPORT_SEVERITY_MAX); 4107 } 4108 else if (parm[0].value < REPORT_SEVERITY_MAX) 4109 { 4110 os_error_printf(CU_MSG_INFO2, (PS8)"Toggle severity level %#lx\n", parm[0].value); 4111 if (SeverityTable[parm[0].value] == '1') 4112 { 4113 /* The level is enabled - Disable it */ 4114 SeverityTable[parm[0].value] = '0'; 4115 } 4116 else 4117 { 4118 /* The bit is disabled - Enable it */ 4119 SeverityTable[parm[0].value] = '1'; 4120 } 4121 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_REPORT_SEVERITY_SET, SeverityTable, REPORT_SEVERITY_MAX); 4122 } 4123 else 4124 { 4125 os_error_printf(CU_MSG_INFO2, (PS8)"invalid level value: %#lx\n", parm[0].value ); 4126 } 4127 } 4128 } 4129 else 4130 { 4131 os_error_printf(CU_MSG_ERROR, (PS8)"Error retriving the severity table from the driver\n"); 4132 } 4133 } 4134 4135 VOID CuCmd_SetReportLevelCLI(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4136 { 4137 #if 0 /* need to create debug logic for CLI */ 4138 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4139 S32 i, cli_debug_level; 4140 4141 if(nParms) 4142 { 4143 cli_debug_level = parm[0].value; 4144 /* check if the param is valid */ 4145 CU_CMD_FIND_NAME_ARRAY(i, cli_level_type, cli_debug_level); 4146 if(i == SIZE_ARR(cli_level_type)) 4147 { 4148 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetReportLevelCLI, cli_debug_level %d is not defined!\n", cli_debug_level); 4149 return; 4150 } 4151 4152 g_debug_level = cli_debug_level; 4153 IpcEvent_UpdateDebugLevel(pCuCmd->hIpcEvent, cli_debug_level); 4154 os_error_printf(CU_MSG_INFO2, (PS8)"set CLI debug value = %s \n", cli_level_type[i].name); 4155 } 4156 else 4157 { 4158 cli_debug_level = g_debug_level; 4159 CU_CMD_FIND_NAME_ARRAY(i, cli_level_type, cli_debug_level); 4160 os_error_printf(CU_MSG_INFO2, (PS8)"CLI debug value = %s (%d)\n", cli_level_type[i].name, cli_debug_level); 4161 print_available_values(cli_level_type); 4162 } 4163 #endif 4164 } 4165 4166 4167 char* SkipSpaces(char* str) 4168 { 4169 char* tmp = str; 4170 4171 while(*tmp == ' ') tmp++; 4172 return tmp; 4173 } 4174 4175 #define ti_isdigit(c) ('0' <= (c) && (c) <= '9') 4176 #define ti_islower(c) ('a' <= (c) && (c) <= 'z') 4177 #define ti_toupper(c) (ti_islower(c) ? ((c) - 'a' + 'A') : (c)) 4178 4179 #define ti_isxdigit(c) (('0' <= (c) && (c) <= '9') \ 4180 || ('a' <= (c) && (c) <= 'f') \ 4181 || ('A' <= (c) && (c) <= 'F')) 4182 4183 #define ti_atol(x) strtoul(x, 0) 4184 4185 4186 unsigned long ti_strtoul(char *cp, char** endp, unsigned int base) 4187 { 4188 unsigned long result = 0, value; 4189 4190 if (!base) { 4191 base = 10; 4192 if (*cp == '0') { 4193 base = 8; 4194 cp++; 4195 if ((ti_toupper(*cp) == 'X') && ti_isxdigit(cp[1])) { 4196 cp++; 4197 base = 16; 4198 } 4199 } 4200 } else if (base == 16) { 4201 if (cp[0] == '0' && ti_toupper(cp[1]) == 'X') 4202 cp += 2; 4203 } 4204 while (ti_isxdigit(*cp) && 4205 (value = ti_isdigit(*cp) ? *cp-'0' : ti_toupper(*cp)-'A'+10) < base) { 4206 result = result*base + value; 4207 cp++; 4208 } 4209 4210 if(endp) 4211 *endp = (char *)cp; 4212 4213 return result; 4214 } 4215 4216 4217 VOID CuCmd_FwDebug(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4218 { 4219 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4220 U32 *buf_ptr, *pbuf; 4221 char *pstr = (char *)parm[0].value; 4222 U32 parm_length; 4223 4224 os_error_printf(CU_MSG_INFO2, (PS8)"FwDebug parm: %s\n", parm[0].value); 4225 4226 buf_ptr = (U32*)os_MemoryCAlloc(252, sizeof(U32)); 4227 if(!buf_ptr) 4228 return; 4229 4230 pbuf = buf_ptr + 2; 4231 4232 pstr = SkipSpaces(pstr); 4233 while(*pstr) { 4234 *pbuf++ = ti_strtoul(pstr, &pstr, 0); 4235 pstr = SkipSpaces(pstr); 4236 } 4237 4238 parm_length = (U32)((U8*)pbuf-(U8*)buf_ptr); 4239 4240 os_error_printf(CU_MSG_INFO2, (PS8)"Parms buf size = %d\n", parm_length); 4241 4242 *buf_ptr = 2210; 4243 *(buf_ptr+1) = parm_length - 2*sizeof(U32); 4244 4245 CuCommon_PrintDriverDebug(pCuCmd->hCuCommon, (PVOID)buf_ptr, parm_length); 4246 4247 os_MemoryFree(buf_ptr); 4248 4249 } 4250 4251 VOID CuCmd_SetRateMngDebug(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4252 { 4253 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4254 RateMangeParams_t RateParams; 4255 4256 RateParams.paramIndex = (TI_UINT8)parm[0].value; 4257 4258 4259 if( nParms == 2 ) 4260 { 4261 switch (RateParams.paramIndex) 4262 { 4263 case RATE_MGMT_RETRY_SCORE_PARAM: 4264 RateParams.RateRetryScore = (TI_UINT16)parm[1].value; 4265 break; 4266 case RATE_MGMT_PER_ADD_PARAM: 4267 RateParams.PerAdd = (TI_UINT16)parm[1].value; 4268 break; 4269 case RATE_MGMT_PER_TH1_PARAM: 4270 RateParams.PerTh1 = (TI_UINT16)parm[1].value; 4271 break; 4272 case RATE_MGMT_PER_TH2_PARAM: 4273 RateParams.PerTh2 = (TI_UINT16)parm[1].value; 4274 break; 4275 case RATE_MGMT_MAX_PER_PARAM: 4276 RateParams.MaxPer = (TI_UINT16)parm[1].value; 4277 break; 4278 case RATE_MGMT_INVERSE_CURIOSITY_FACTOR_PARAM: 4279 RateParams.InverseCuriosityFactor = (TI_UINT8)parm[1].value; 4280 break; 4281 case RATE_MGMT_TX_FAIL_LOW_TH_PARAM: 4282 RateParams.TxFailLowTh = (TI_UINT8)parm[1].value; 4283 break; 4284 case RATE_MGMT_TX_FAIL_HIGH_TH_PARAM: 4285 RateParams.TxFailHighTh = (TI_UINT8)parm[1].value; 4286 break; 4287 case RATE_MGMT_PER_ALPHA_SHIFT_PARAM: 4288 RateParams.PerAlphaShift = (TI_UINT8)parm[1].value; 4289 break; 4290 case RATE_MGMT_PER_ADD_SHIFT_PARAM: 4291 RateParams.PerAddShift = (TI_UINT8)parm[1].value; 4292 break; 4293 case RATE_MGMT_PER_BETA1_SHIFT_PARAM: 4294 RateParams.PerBeta1Shift = (TI_UINT8)parm[1].value; 4295 break; 4296 case RATE_MGMT_PER_BETA2_SHIFT_PARAM: 4297 RateParams.PerBeta2Shift = (TI_UINT8)parm[1].value; 4298 break; 4299 case RATE_MGMT_RATE_CHECK_UP_PARAM: 4300 RateParams.RateCheckUp = (TI_UINT8)parm[1].value; 4301 break; 4302 case RATE_MGMT_RATE_CHECK_DOWN_PARAM: 4303 RateParams.RateCheckDown = (TI_UINT8)parm[1].value; 4304 break; 4305 default: 4306 os_error_printf(CU_MSG_INFO2,"Error: index is not valid! \n"); 4307 return; 4308 4309 } 4310 } 4311 else if ((nParms == NUM_OF_RATE_MNGT_PARAMS_MAX) && (parm[0].value == RATE_MGMT_RATE_RETRY_POLICY_PARAM )) 4312 { 4313 int i=0; 4314 for (i=1; i < NUM_OF_RATE_MNGT_PARAMS_MAX; i++) 4315 { 4316 RateParams.RateRetryPolicy[i-1] = (TI_UINT8)parm[i].value; 4317 } 4318 } 4319 else 4320 { 4321 os_error_printf(CU_MSG_INFO2,"(0) RateMngRateRetryScore \n"); 4322 os_error_printf(CU_MSG_INFO2,"(1) RateMngPerAdd \n"); 4323 os_error_printf(CU_MSG_INFO2,"(2) RateMngPerTh1 \n"); 4324 os_error_printf(CU_MSG_INFO2,"(3) RateMngPerTh2 \n"); 4325 os_error_printf(CU_MSG_INFO2,"(4) RateMngMaxPer \n"); 4326 os_error_printf(CU_MSG_INFO2,"(5) RateMngInverseCuriosityFactor \n"); 4327 os_error_printf(CU_MSG_INFO2,"(6) RateMngTxFailLowTh \n"); 4328 os_error_printf(CU_MSG_INFO2,"(7) RateMngTxFailHighTh \n"); 4329 os_error_printf(CU_MSG_INFO2,"(8) RateMngPerAlphaShift \n"); 4330 os_error_printf(CU_MSG_INFO2,"(9) RateMngPerAddShift \n"); 4331 os_error_printf(CU_MSG_INFO2,"(10) RateMngPerBeta1Shift \n"); 4332 os_error_printf(CU_MSG_INFO2,"(11) RateMngPerBeta2Shift \n"); 4333 os_error_printf(CU_MSG_INFO2,"(12) RateMngRateCheckUp \n"); 4334 os_error_printf(CU_MSG_INFO2,"(13) RateMngRateCheckDown \n"); 4335 os_error_printf(CU_MSG_INFO2,"(14) RateMngRateRetryPolicy[13] \n"); 4336 return; 4337 } 4338 4339 CuCommon_SetBuffer(pCuCmd->hCuCommon, TIWLN_RATE_MNG_SET,&RateParams, sizeof(RateMangeParams_t)); 4340 } 4341 4342 VOID CuCmd_GetRateMngDebug(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4343 { 4344 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4345 AcxRateMangeParams ReadRateParams; 4346 int i; 4347 4348 os_memset(&ReadRateParams,0,sizeof(AcxRateMangeParams)); 4349 4350 CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_RATE_MNG_GET, &ReadRateParams, sizeof(AcxRateMangeParams)); 4351 4352 if (0 == nParms) 4353 { 4354 parm[0].value = RATE_MGMT_ALL_PARAMS; 4355 } 4356 4357 switch (parm[0].value) 4358 { 4359 case RATE_MGMT_RETRY_SCORE_PARAM: 4360 os_error_printf(CU_MSG_INFO2,"RateMngRateRetryScore = %d \n", ReadRateParams.RateRetryScore); 4361 break; 4362 case RATE_MGMT_PER_ADD_PARAM: 4363 os_error_printf(CU_MSG_INFO2,"RateMngPerAdd = %d\n" , ReadRateParams.PerAdd); 4364 break; 4365 case RATE_MGMT_PER_TH1_PARAM: 4366 os_error_printf(CU_MSG_INFO2,"RateMngPerTh1 = %d\n" , ReadRateParams.PerTh1); 4367 break; 4368 case RATE_MGMT_PER_TH2_PARAM: 4369 os_error_printf(CU_MSG_INFO2,"RateMngPerTh2 = %d\n" , ReadRateParams.PerTh2); 4370 break; 4371 case RATE_MGMT_MAX_PER_PARAM: 4372 os_error_printf(CU_MSG_INFO2,"RateMngMaxPer = %d\n" , ReadRateParams.MaxPer); 4373 break; 4374 case RATE_MGMT_INVERSE_CURIOSITY_FACTOR_PARAM: 4375 os_error_printf(CU_MSG_INFO2,"RateMngInverseCuriosityFactor = %d \n" , ReadRateParams.InverseCuriosityFactor); 4376 break; 4377 case RATE_MGMT_TX_FAIL_LOW_TH_PARAM: 4378 os_error_printf(CU_MSG_INFO2,"RateMngTxFailLowTh = %d\n" , ReadRateParams.TxFailLowTh); 4379 break; 4380 case RATE_MGMT_TX_FAIL_HIGH_TH_PARAM: 4381 os_error_printf(CU_MSG_INFO2,"RateMngTxFailHighTh = %d\n" , ReadRateParams.TxFailHighTh); 4382 break; 4383 case RATE_MGMT_PER_ALPHA_SHIFT_PARAM: 4384 os_error_printf(CU_MSG_INFO2,"RateMngPerAlphaShift = %d\n" , ReadRateParams.PerAlphaShift); 4385 break; 4386 case RATE_MGMT_PER_ADD_SHIFT_PARAM: 4387 os_error_printf(CU_MSG_INFO2,"RateMngPerAddShift = %d\n" , ReadRateParams.PerAddShift); 4388 break; 4389 case RATE_MGMT_PER_BETA1_SHIFT_PARAM: 4390 os_error_printf(CU_MSG_INFO2,"RateMngPerBeta1Shift = %d\n" , ReadRateParams.PerBeta1Shift); 4391 break; 4392 case RATE_MGMT_PER_BETA2_SHIFT_PARAM: 4393 os_error_printf(CU_MSG_INFO2,"RateMngPerBeta2Shift = %d\n" , ReadRateParams.PerBeta2Shift); 4394 break; 4395 case RATE_MGMT_RATE_CHECK_UP_PARAM: 4396 os_error_printf(CU_MSG_INFO2,"RateMngRateCheckUp = %d\n" , ReadRateParams.RateCheckUp); 4397 break; 4398 case RATE_MGMT_RATE_CHECK_DOWN_PARAM: 4399 os_error_printf(CU_MSG_INFO2,"RateMngRateCheckDown = %d\n" , ReadRateParams.RateCheckDown); 4400 break; 4401 case RATE_MGMT_RATE_RETRY_POLICY_PARAM: 4402 os_error_printf(CU_MSG_INFO2,"RateMngRateRetryPolicy = "); 4403 4404 for (i=0 ; i< RATE_MNG_MAX_RETRY_POLICY_PARAMS_LEN ; i++) 4405 { 4406 os_error_printf(CU_MSG_INFO2,"%d ",ReadRateParams.RateRetryPolicy[i]); 4407 } 4408 4409 os_error_printf(CU_MSG_INFO2,"\n"); 4410 4411 break; 4412 4413 case RATE_MGMT_ALL_PARAMS: 4414 os_error_printf(CU_MSG_INFO2,"RateMngRateRetryScore = %d \n", ReadRateParams.RateRetryScore); 4415 os_error_printf(CU_MSG_INFO2,"RateMngPerAdd = %d\n" , ReadRateParams.PerAdd); 4416 os_error_printf(CU_MSG_INFO2,"RateMngPerTh1 = %d\n" , ReadRateParams.PerTh1); 4417 os_error_printf(CU_MSG_INFO2,"RateMngPerTh2 = %d\n" , ReadRateParams.PerTh2); 4418 os_error_printf(CU_MSG_INFO2,"RateMngMaxPer = %d\n" , ReadRateParams.MaxPer); 4419 os_error_printf(CU_MSG_INFO2,"RateMngInverseCuriosityFactor = %d \n" , ReadRateParams.InverseCuriosityFactor); 4420 os_error_printf(CU_MSG_INFO2,"RateMngTxFailLowTh = %d\n" , ReadRateParams.TxFailLowTh); 4421 os_error_printf(CU_MSG_INFO2,"RateMngTxFailHighTh = %d\n" , ReadRateParams.TxFailHighTh); 4422 os_error_printf(CU_MSG_INFO2,"RateMngPerAlphaShift = %d\n" , ReadRateParams.PerAlphaShift); 4423 os_error_printf(CU_MSG_INFO2,"RateMngPerAddShift = %d\n" , ReadRateParams.PerAddShift); 4424 os_error_printf(CU_MSG_INFO2,"RateMngPerBeta1Shift = %d\n" , ReadRateParams.PerBeta1Shift); 4425 os_error_printf(CU_MSG_INFO2,"RateMngPerBeta2Shift = %d\n" , ReadRateParams.PerBeta2Shift); 4426 os_error_printf(CU_MSG_INFO2,"RateMngRateCheckUp = %d\n" , ReadRateParams.RateCheckUp); 4427 os_error_printf(CU_MSG_INFO2,"RateMngRateCheckDown = %d\n" , ReadRateParams.RateCheckDown); 4428 os_error_printf(CU_MSG_INFO2,"RateMngRateRetryPolicy = "); 4429 4430 for (i=0 ; i< RATE_MNG_MAX_RETRY_POLICY_PARAMS_LEN ; i++) 4431 { 4432 os_error_printf(CU_MSG_INFO2,"%d ",ReadRateParams.RateRetryPolicy[i]); 4433 } 4434 os_error_printf(CU_MSG_INFO2,"\n"); 4435 break; 4436 4437 default: 4438 os_error_printf(CU_MSG_INFO2,"Error: index is not valid! \n"); 4439 return; 4440 } 4441 4442 } 4443 4444 4445 VOID CuCmd_PrintDriverDebug(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4446 { 4447 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4448 U32 size = 0; 4449 TTwdDebug data; 4450 4451 /* check if nParam is invalid */ 4452 if (( nParms == 0 ) || ( nParms > 4 )) 4453 { 4454 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_PrintDriverDebug: Invalid number of Parameters %d\n", nParms); 4455 return; 4456 } 4457 4458 /* init */ 4459 os_memset( &data.debug_data.mem_debug.UBuf.buf8, 0, sizeof(data.debug_data.mem_debug.UBuf.buf8) ); 4460 data.func_id = parm[0].value; 4461 size = sizeof(data.func_id); 4462 4463 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_PrintDriverDebug: FUN_ID: %u\n", data.func_id); 4464 4465 /* if R reg request - read data */ 4466 if ( nParms == 2 ) 4467 { 4468 data.debug_data.opt_param = 4; 4469 data.debug_data.opt_param = parm[1].value; 4470 size += sizeof(data.debug_data.opt_param); 4471 } 4472 else 4473 /* if W reg request - read data */ 4474 if ( nParms > 2 ) 4475 { 4476 data.debug_data.mem_debug.addr = 0; 4477 4478 data.debug_data.mem_debug.length = 4; 4479 size += sizeof(data.debug_data.mem_debug.length); 4480 4481 data.debug_data.mem_debug.addr = parm[1].value; 4482 size += sizeof(data.debug_data.mem_debug.addr); 4483 4484 data.debug_data.mem_debug.UBuf.buf32[0] = parm[2].value; 4485 size += sizeof(data.debug_data.mem_debug.UBuf.buf32[0]); 4486 4487 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_PrintDriverDebug: addr: 0x%x\n", data.debug_data.opt_param); 4488 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_PrintDriverDebug: data: 0x%x\n", data.debug_data.mem_debug.UBuf.buf32[0]); 4489 } 4490 CuCommon_PrintDriverDebug(pCuCmd->hCuCommon, (PVOID)&data, size); 4491 } 4492 4493 VOID CuCmd_PrintDriverDebugBuffer(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4494 { 4495 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4496 4497 U32 func_id = ( nParms > 0 ) ? parm[0].value : 0; 4498 U32 opt_param = ( nParms > 1 ) ? parm[1].value : 0; 4499 4500 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_PrintDriverDebugBuffer: FUNC:%u, PARAM:%u\n", func_id, opt_param); 4501 4502 CuCommon_PrintDriverDebugBuffer(pCuCmd->hCuCommon, func_id, opt_param); 4503 } 4504 4505 /*-------------------*/ 4506 /* Radio Debug Tests */ 4507 /*-------------------*/ 4508 /* Set the RX channel --> Radio Tune */ 4509 VOID CuCmd_RadioDebug_ChannelTune(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4510 { 4511 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4512 TPowerMgr_PowerMode Mode; 4513 TTestCmd data; 4514 4515 if ((nParms == 0) || (nParms > 2)) 4516 { 4517 os_error_printf(CU_MSG_INFO2, (PS8)"Param 0 - Band (0-2.4Ghz, 1-5Ghz, 2-4.9Ghz)\n"); 4518 os_error_printf(CU_MSG_INFO2, (PS8)"Param 1 - Channel\n"); 4519 } 4520 else 4521 { 4522 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, TIWLN_802_11_POWER_MODE_GET, 4523 &Mode, sizeof(TPowerMgr_PowerMode))) return; 4524 if(Mode.PowerMode != OS_POWER_MODE_ACTIVE) 4525 { 4526 os_error_printf(CU_MSG_INFO2, (PS8)"Radio tune was not performed becouse Default power-mode is not ACTIVE\n"); 4527 } 4528 else 4529 { 4530 os_memset(&data, 0, sizeof(TTestCmd)); 4531 data.testCmdId = TEST_CMD_CHANNEL_TUNE; 4532 data.testCmd_u.Channel.iChannel = (U8)parm[1].value; 4533 data.testCmd_u.Channel.iBand = (U8)parm[0].value; 4534 4535 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4536 { 4537 os_error_printf(CU_MSG_INFO2, (PS8)"Channel %d tune failed\n",data.testCmd_u.Channel.iChannel); 4538 return; 4539 } 4540 os_error_printf(CU_MSG_INFO2, (PS8)"Channel tune of channel %d was performed OK\n",(U8)data.testCmd_u.Channel.iChannel); 4541 } 4542 } 4543 } 4544 4545 /* Start CW test (TELEC) */ 4546 VOID CuCmd_RadioDebug_StartTxCw(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4547 { 4548 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4549 TTestCmd data; 4550 4551 /* check # of params OK */ 4552 if ((nParms == 0) || (nParms > 2)) 4553 { 4554 /* print help */ 4555 os_error_printf(CU_MSG_INFO2, (PS8)"Param 0 - Power (0-25000 1/1000 db)\n"); 4556 os_error_printf(CU_MSG_INFO2, (PS8)"Param 1 - Tone Type (1-Single Tone, 2-Carrier Feed Through)\n"); 4557 4558 /* os_error_printf(CU_MSG_INFO2, (PS8)"Param 2 - Band\n"); 4559 os_error_printf(CU_MSG_INFO2, (PS8)"Param 3 - Channel\n"); 4560 os_error_printf(CU_MSG_INFO2, (PS8)"Param 4 - PPA Step\n"); 4561 os_error_printf(CU_MSG_INFO2, (PS8)"Param 5 - Tone no. Single Tones\n"); 4562 os_error_printf(CU_MSG_INFO2, (PS8)"Param 6 - Tone no. Two Tones\n"); 4563 os_error_printf(CU_MSG_INFO2, (PS8)"Param 7 - Use digital DC\n"); 4564 os_error_printf(CU_MSG_INFO2, (PS8)"Param 8 - Invert\n"); 4565 os_error_printf(CU_MSG_INFO2, (PS8)"Param 9 - Eleven N Span\n"); 4566 os_error_printf(CU_MSG_INFO2, (PS8)"Param 10 - Digital DC\n"); 4567 os_error_printf(CU_MSG_INFO2, (PS8)"Param 11 - Analog DC Fine\n"); 4568 os_error_printf(CU_MSG_INFO2, (PS8)"Param 12 - Analog DC Course\n");*/ 4569 } 4570 else 4571 { 4572 os_memset(&data, 0, sizeof(TTestCmd)); 4573 data.testCmdId = TEST_CMD_TELEC; 4574 data.testCmd_u.TxToneParams.iPower = (U16)parm[0].value; 4575 data.testCmd_u.TxToneParams.iToneType = (U8)parm[1].value; 4576 /* data.testCmd_u.TxToneParams.iPpaStep = (U8)parm[4].value; 4577 data.testCmd_u.TxToneParams.iToneNumberSingleTones = (U8)parm[5].value; 4578 data.testCmd_u.TxToneParams.iToneNumberTwoTones = (U8)parm[6].value; 4579 data.testCmd_u.TxToneParams.iUseDigitalDC = (U8)parm[7].value; 4580 data.testCmd_u.TxToneParams.iInvert = (U8)parm[8].value; 4581 data.testCmd_u.TxToneParams.iElevenNSpan = (U8)parm[9].value; 4582 data.testCmd_u.TxToneParams.iDigitalDC = (U8)parm[10].value; 4583 data.testCmd_u.TxToneParams.iAnalogDCFine = (U8)parm[11].value; 4584 data.testCmd_u.TxToneParams.iAnalogDCCoarse = (U8)parm[12].value;*/ 4585 4586 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4587 { 4588 os_error_printf(CU_MSG_INFO2, (PS8)"CW test failed\n"); 4589 return; 4590 } 4591 os_error_printf(CU_MSG_INFO2, (PS8)"CW test was performed OK\n"); 4592 } 4593 } 4594 4595 /* Start TX continues test (FCC) */ 4596 VOID CuCmd_RadioDebug_StartContinuousTx(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4597 { 4598 TMacAddr mac_addr_mask = { 0xff,0xff,0xff,0xff,0xff,0xff }; 4599 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4600 TTestCmd data; 4601 4602 if ((nParms == 0) || (nParms > 15)) 4603 { 4604 /* print help */ 4605 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 4606 os_error_printf(CU_MSG_INFO2, (PS8)"Param 0 - Delay\n"); 4607 os_error_printf(CU_MSG_INFO2, (PS8)"Param 1 - Rate\n"); 4608 os_error_printf(CU_MSG_INFO2, (PS8)"Param 2 - Size\n"); 4609 os_error_printf(CU_MSG_INFO2, (PS8)"Param 3 - Amount\n"); 4610 os_error_printf(CU_MSG_INFO2, (PS8)"Param 4 - Power\n"); 4611 os_error_printf(CU_MSG_INFO2, (PS8)"Param 5 - Seed\n"); 4612 os_error_printf(CU_MSG_INFO2, (PS8)"Param 6 - Packet Mode\n"); 4613 os_error_printf(CU_MSG_INFO2, (PS8)"Param 7 - DCF On/Off\n"); 4614 os_error_printf(CU_MSG_INFO2, (PS8)"Param 8 - GI\n"); 4615 os_error_printf(CU_MSG_INFO2, (PS8)"Param 9 - Preamble\n"); 4616 os_error_printf(CU_MSG_INFO2, (PS8)"Param 10 - Type\n"); 4617 os_error_printf(CU_MSG_INFO2, (PS8)"Param 11 - Scrambler\n"); 4618 os_error_printf(CU_MSG_INFO2, (PS8)"Param 12 - Enable CLPC\n"); 4619 os_error_printf(CU_MSG_INFO2, (PS8)"Param 13 - Sequance no. Mode\n"); 4620 /* future use. for now the oregenal source address are use. 4621 os_error_printf(CU_MSG_INFO2, (PS8)"Param 14 - Source MAC Address\n"); 4622 */ 4623 os_error_printf(CU_MSG_INFO2, (PS8)"Param 14 - Destination MAC Address\n"); 4624 } 4625 else 4626 { 4627 os_memset(&data, 0, sizeof(TTestCmd)); 4628 data.testCmdId = TEST_CMD_FCC; 4629 data.testCmd_u.TxPacketParams.iDelay = (U32)parm[0].value; 4630 data.testCmd_u.TxPacketParams.iRate = (U32)parm[1].value; 4631 data.testCmd_u.TxPacketParams.iSize = (U16)parm[2].value; 4632 data.testCmd_u.TxPacketParams.iAmount = (U16)parm[3].value; 4633 data.testCmd_u.TxPacketParams.iPower = (U16)parm[4].value; 4634 data.testCmd_u.TxPacketParams.iSeed = (U16)parm[5].value; 4635 data.testCmd_u.TxPacketParams.iPacketMode = (U8)parm[6].value; 4636 data.testCmd_u.TxPacketParams.iDcfOnOff = (U8)parm[7].value; 4637 data.testCmd_u.TxPacketParams.iGI = (U8)parm[8].value; 4638 data.testCmd_u.TxPacketParams.iPreamble = (U8)parm[9].value; 4639 data.testCmd_u.TxPacketParams.iType = (U8)parm[10].value; 4640 data.testCmd_u.TxPacketParams.iScrambler = (U8)parm[11].value; 4641 data.testCmd_u.TxPacketParams.iEnableCLPC = (U8)parm[12].value; 4642 data.testCmd_u.TxPacketParams.iSeqNumMode = (U8)parm[13].value; 4643 /* future use. for now the oregenal source address are use. 4644 if(!CuCmd_Str2MACAddr((PS8)parm[16].value, (PU8)mac_addr_mask) ) 4645 { 4646 os_error_printf(CU_MSG_INFO2, (PS8)"Continuous Tx start has failed to read source MAC Address \n"); 4647 return; 4648 } 4649 */ 4650 os_memcpy((PVOID)data.testCmd_u.TxPacketParams.iSrcMacAddr, 4651 (PVOID)mac_addr_mask, 4652 sizeof(mac_addr_mask)); 4653 if(!CuCmd_Str2MACAddr((PS8)parm[14].value, (PU8)mac_addr_mask) ) 4654 { 4655 os_error_printf(CU_MSG_INFO2, (PS8)"Continuous Tx start has failed to read destination MAC Address \n"); 4656 return; 4657 } 4658 os_memcpy((PVOID)data.testCmd_u.TxPacketParams.iDstMacAddr, 4659 (PVOID)mac_addr_mask, 4660 sizeof(mac_addr_mask)); 4661 4662 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4663 { 4664 os_error_printf(CU_MSG_INFO2, (PS8)"Continuous Tx start has failed\n"); 4665 return; 4666 } 4667 os_error_printf(CU_MSG_INFO2, (PS8)"Continuous Tx started OK\n"); 4668 } 4669 } 4670 4671 /* Stop FCC/TELEC (Radio Debug) */ 4672 VOID CuCmd_RadioDebug_StopTx(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4673 { 4674 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4675 TTestCmd data; 4676 4677 os_memset(&data, 0, sizeof(TTestCmd)); 4678 data.testCmdId = TEST_CMD_STOP_TX; 4679 4680 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4681 { 4682 os_error_printf(CU_MSG_INFO2, (PS8)"Plt Tx Stop has failed\n"); 4683 return; 4684 } 4685 os_error_printf(CU_MSG_INFO2, (PS8)"Plt Tx Stop was OK\n"); 4686 } 4687 4688 /* download packet template for transmissions 4689 the template shall be set before calling TX Debug */ 4690 VOID CuCmd_RadioDebug_Template(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4691 { 4692 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4693 TTestCmd data; 4694 4695 if ((nParms == 0) || (nParms > 3)) 4696 { 4697 /* print help */ 4698 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 4699 os_error_printf(CU_MSG_INFO2, (PS8)"Param 1 - Buffer Offset\n"); 4700 os_error_printf(CU_MSG_INFO2, (PS8)"Param 2 - Buffer Data\n"); 4701 } 4702 else 4703 { 4704 os_memset(&data, 0, sizeof(TTestCmd)); 4705 data.testCmdId = TEST_CMD_PLT_TEMPLATE; 4706 data.testCmd_u.TxTemplateParams.bufferOffset = (U16)parm[0].value; 4707 data.testCmd_u.TxTemplateParams.bufferLength = (U16)os_strlen((PS8)parm[1].value); 4708 /* check that length is valid */ 4709 if( data.testCmd_u.TxTemplateParams.bufferOffset + data.testCmd_u.TxTemplateParams.bufferLength > TX_TEMPLATE_MAX_BUF_LEN ) 4710 { 4711 os_error_printf(CU_MSG_INFO2, (PS8)"Plt Template has failed because of invalid buffer length\n"); 4712 return; 4713 } 4714 /* convert the string to hexadeciaml values, and copy it */ 4715 CuCmd_atox_string ((U8*)parm[1].value,(U8*)data.testCmd_u.TxTemplateParams.buffer); 4716 4717 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4718 { 4719 os_error_printf(CU_MSG_INFO2, (PS8)"Plt Template has failed\n"); 4720 return; 4721 } 4722 os_error_printf(CU_MSG_INFO2, (PS8)"Plt Template was OK\n"); 4723 } 4724 } 4725 4726 4727 /* Start RX Statistics */ 4728 VOID CuCmd_RadioDebug_StartRxStatistics(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4729 { 4730 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4731 TTestCmd data; 4732 4733 os_memset(&data, 0, sizeof(TTestCmd)); 4734 data.testCmdId = TEST_CMD_RX_STAT_START; 4735 4736 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4737 { 4738 os_error_printf(CU_MSG_INFO2, (PS8)"Start RX Statistics has failed\n"); 4739 return; 4740 } 4741 os_error_printf(CU_MSG_INFO2, (PS8)"Start RX Statistics OK\n"); 4742 } 4743 4744 /* Stop RX Statistics */ 4745 VOID CuCmd_RadioDebug_StopRxStatistics(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4746 { 4747 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4748 TTestCmd data; 4749 4750 os_memset(&data, 0, sizeof(TTestCmd)); 4751 data.testCmdId = TEST_CMD_RX_STAT_STOP; 4752 4753 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4754 { 4755 os_error_printf(CU_MSG_INFO2, (PS8)"Stop RX Statistics has failed\n"); 4756 return; 4757 } 4758 os_error_printf(CU_MSG_INFO2, (PS8)"Stop RX Statistics OK\n"); 4759 } 4760 4761 /* Reset RX Statistics */ 4762 VOID CuCmd_RadioDebug_ResetRxStatistics(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4763 { 4764 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4765 TTestCmd data; 4766 4767 os_memset(&data, 0, sizeof(TTestCmd)); 4768 data.testCmdId = TEST_CMD_RX_STAT_RESET; 4769 4770 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4771 { 4772 os_error_printf(CU_MSG_INFO2, (PS8)"Reset RX Statistics has failed\n"); 4773 return; 4774 } 4775 os_error_printf(CU_MSG_INFO2, (PS8)"Reset RX Statistics OK\n"); 4776 } 4777 4778 4779 /* Get HDK Version*/ 4780 VOID CuCmd_RadioDebug_GetHDKVersion(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4781 { 4782 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4783 TTestCmd data; 4784 4785 os_memset(&data, 0, sizeof(TTestCmd)); 4786 4787 data.testCmdId = TEST_CMD_GET_FW_VERSIONS; 4788 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4789 { 4790 os_error_printf(CU_MSG_INFO2, (PS8)"Get FW version function has failed\n"); 4791 return; 4792 } 4793 os_error_printf(CU_MSG_INFO2, (PS8)"ProductName: %d\n", data.testCmd_u.fwVersions.hdkVersion.ProductName); 4794 os_error_printf(CU_MSG_INFO2, (PS8)"PgNumber: %d\n", data.testCmd_u.fwVersions.hdkVersion.PgNumber); 4795 os_error_printf(CU_MSG_INFO2, (PS8)"SoftwareVersionLevel: %d\n", data.testCmd_u.fwVersions.hdkVersion.SoftwareVersionLevel); 4796 os_error_printf(CU_MSG_INFO2, (PS8)"radioModuleType: %d\n", data.testCmd_u.fwVersions.hdkVersion.radioModuleType); 4797 os_error_printf(CU_MSG_INFO2, (PS8)"SoftwareVersionDelivery: %d\n", data.testCmd_u.fwVersions.hdkVersion.SoftwareVersionDelivery); 4798 os_error_printf(CU_MSG_INFO2, (PS8)"numberOfReferenceDesignsSupported: %d\n", data.testCmd_u.fwVersions.hdkVersion.numberOfReferenceDesignsSupported); 4799 #ifdef FIX_HDK_VERSION_API /* HDK version struct should be changed aligned and without pointer */ 4800 os_error_printf(CU_MSG_INFO2, (PS8)"referenceDesignsSupported->referenceDesignId: %d\n", data.testCmd_u.fwVersions.hdkVersion.referenceDesignsSupported->referenceDesignId); 4801 os_error_printf(CU_MSG_INFO2, (PS8)"referenceDesignsSupported->nvsMajorVersion: %d\n", data.testCmd_u.fwVersions.hdkVersion.referenceDesignsSupported->nvsMajorVersion); 4802 os_error_printf(CU_MSG_INFO2, (PS8)"referenceDesignsSupported->nvsMinorVersion: %d\n", data.testCmd_u.fwVersions.hdkVersion.referenceDesignsSupported->nvsMinorVersion); 4803 os_error_printf(CU_MSG_INFO2, (PS8)"referenceDesignsSupported->nvsMinorMinorVersion: %d\n", data.testCmd_u.fwVersions.hdkVersion.referenceDesignsSupported->nvsMinorMinorVersion); 4804 #endif 4805 } 4806 4807 /* Get RX Statistics */ 4808 VOID CuCmd_RadioDebug_GetRxStatistics(THandle hCuCmd, ConParm_t parm[], U16 nParms) 4809 { 4810 #if 0 /*Temp: currently not supported*/ 4811 U32 i = 0; 4812 #endif 4813 4814 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4815 TTestCmd data; 4816 4817 os_memset(&data, 0, sizeof(TTestCmd)); 4818 data.testCmdId = TEST_CMD_RX_STAT_GET; 4819 4820 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 4821 { 4822 os_error_printf(CU_MSG_INFO2, (PS8)"Get RX Statistics has failed\n"); 4823 return; 4824 } 4825 /* print Statistics Got */ 4826 os_error_printf(CU_MSG_INFO2, (PS8)"\n"); 4827 os_error_printf(CU_MSG_INFO2, (PS8)"Received Valid Packet no.: %d(0x%x)\n", data.testCmd_u.Statistics.oRxPathStatistics.ReceivedValidPacketsNumber,data.testCmd_u.Statistics.oRxPathStatistics.ReceivedValidPacketsNumber); 4828 os_error_printf(CU_MSG_INFO2, (PS8)"Received FCS Error Packet no.: %d(0x%x)\n", data.testCmd_u.Statistics.oRxPathStatistics.ReceivedFcsErrorPacketsNumber,data.testCmd_u.Statistics.oRxPathStatistics.ReceivedFcsErrorPacketsNumber); 4829 os_error_printf(CU_MSG_INFO2, (PS8)"Received Address mismatched packet: %d(0x%x)\n", data.testCmd_u.Statistics.oRxPathStatistics.ReceivedPlcpErrorPacketsNumber,data.testCmd_u.Statistics.oRxPathStatistics.ReceivedPlcpErrorPacketsNumber); 4830 os_error_printf(CU_MSG_INFO2, (PS8)"Sequance Nomber Missing Count: %d(0x%x)\n", data.testCmd_u.Statistics.oRxPathStatistics.SeqNumMissCount,data.testCmd_u.Statistics.oRxPathStatistics.SeqNumMissCount); 4831 /* The RSSI and SNR are in octal units, the value divided by 8 for the print */ 4832 os_error_printf(CU_MSG_INFO2, (PS8)"Average SNR: %d(0x%x)\n", data.testCmd_u.Statistics.oRxPathStatistics.AverageSnr/8,data.testCmd_u.Statistics.oRxPathStatistics.AverageSnr/8); 4833 os_error_printf(CU_MSG_INFO2, (PS8)"Average RSSI: %d(0x%x)\n", (data.testCmd_u.Statistics.oRxPathStatistics.AverageRssi)/8,(data.testCmd_u.Statistics.oRxPathStatistics.AverageRssi)/8); 4834 os_error_printf(CU_MSG_INFO2, (PS8)"Base Packet ID: %d(0x%x)\n", data.testCmd_u.Statistics.oBasePacketId,data.testCmd_u.Statistics.oBasePacketId); 4835 os_error_printf(CU_MSG_INFO2, (PS8)"Number of Packets: %d(0x%x)\n", data.testCmd_u.Statistics.ioNumberOfPackets,data.testCmd_u.Statistics.ioNumberOfPackets); 4836 os_error_printf(CU_MSG_INFO2, (PS8)"Number of Missed Packets: %d(0x%x)\n", data.testCmd_u.Statistics.oNumberOfMissedPackets,data.testCmd_u.Statistics.oNumberOfMissedPackets); 4837 #if 0/*Temp: currently not supported*/ 4838 for ( i = 0 ; i < RX_STAT_PACKETS_PER_MESSAGE ; i++ ) 4839 { 4840 os_error_printf(CU_MSG_INFO2, (PS8)"RX Packet %d Statistics\n",i); 4841 os_error_printf(CU_MSG_INFO2, (PS8)"Length: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].Length,data.testCmd_u.Statistics.RxPacketStatistics[i].Length); 4842 os_error_printf(CU_MSG_INFO2, (PS8)"EVM: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].EVM,data.testCmd_u.Statistics.RxPacketStatistics[i].EVM); 4843 os_error_printf(CU_MSG_INFO2, (PS8)"RSSI: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].RSSI,data.testCmd_u.Statistics.RxPacketStatistics[i].RSSI); 4844 os_error_printf(CU_MSG_INFO2, (PS8)"Frequency Delta: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].FrequencyDelta,data.testCmd_u.Statistics.RxPacketStatistics[i].FrequencyDelta); 4845 os_error_printf(CU_MSG_INFO2, (PS8)"Flags: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].Flags,data.testCmd_u.Statistics.RxPacketStatistics[i].Flags); 4846 os_error_printf(CU_MSG_INFO2, (PS8)"Type: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].Type,data.testCmd_u.Statistics.RxPacketStatistics[i].Type); 4847 os_error_printf(CU_MSG_INFO2, (PS8)"Rate: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].Rate,data.testCmd_u.Statistics.RxPacketStatistics[i].Rate); 4848 os_error_printf(CU_MSG_INFO2, (PS8)"Noise: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].Noise,data.testCmd_u.Statistics.RxPacketStatistics[i].Noise); 4849 os_error_printf(CU_MSG_INFO2, (PS8)"AGC Gain: %d(0x%x)\n", data.testCmd_u.Statistics.RxPacketStatistics[i].AgcGain,data.testCmd_u.Statistics.RxPacketStatistics[i].AgcGain); 4850 } 4851 #endif 4852 } 4853 4854 4855 /*-----------*/ 4856 /* BIP Tests */ 4857 /*-----------*/ 4858 4859 4860 void FillMACAddressToNVS(THandle hCuCmd, FILE *nvsBinFile) 4861 { 4862 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 4863 TMacAddr Mac; 4864 U8 lengthToSet; 4865 U8 addressHigher; 4866 U8 addressLower; 4867 U8 valueToSet=0; 4868 4869 lengthToSet = 0x1; 4870 4871 4872 os_error_printf(CU_MSG_INFO2, (PS8)"Entering FillMACAddressToNVS\n"); 4873 /* param 0 in nvs*/ 4874 os_fwrite(&lengthToSet, sizeof(U8), 1, nvsBinFile); 4875 4876 /* register for MAC Address*/ 4877 addressHigher = 0x6D; 4878 addressLower = 0x54; 4879 4880 /* param 1 in nvs*/ 4881 os_fwrite(&addressHigher, sizeof(U8), 1, nvsBinFile); 4882 /* param 2 in nvs*/ 4883 os_fwrite(&addressLower, sizeof(U8), 1, nvsBinFile); 4884 4885 4886 /* read mac address */ 4887 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, CTRL_DATA_MAC_ADDRESS, Mac, sizeof(TMacAddr))) 4888 { 4889 os_error_printf(CU_MSG_INFO2, (PS8)"Unable to get Mac address, aborting\n"); 4890 return; 4891 } 4892 os_error_printf(CU_MSG_INFO2, (PS8)"Mac[0]=%02x\n", Mac[0]); 4893 os_error_printf(CU_MSG_INFO2, (PS8)"Mac[1]=%02x\n", Mac[1]); 4894 os_error_printf(CU_MSG_INFO2, (PS8)"Mac[2]=%02x\n", Mac[2]); 4895 os_error_printf(CU_MSG_INFO2, (PS8)"Mac[3]=%02x\n", Mac[3]); 4896 os_error_printf(CU_MSG_INFO2, (PS8)"Mac[4]=%02x\n", Mac[4]); 4897 os_error_printf(CU_MSG_INFO2, (PS8)"Mac[5]=%02x\n", Mac[5]); 4898 4899 /* write the lower MAC address starting from the LSB 4900 params 3-6 in NVS*/ 4901 os_fwrite(&Mac[5], sizeof(U8), 1, nvsBinFile); 4902 os_fwrite(&Mac[4], sizeof(U8), 1, nvsBinFile); 4903 os_fwrite(&Mac[3], sizeof(U8), 1, nvsBinFile); 4904 os_fwrite(&Mac[2], sizeof(U8), 1, nvsBinFile); 4905 4906 /* param 7 in NVS*/ 4907 os_fwrite(&lengthToSet, sizeof(U8), 1, nvsBinFile); 4908 4909 addressHigher = 0x71; 4910 addressLower = 0x54; 4911 4912 /* params 8-9 in NVS*/ 4913 os_fwrite(&addressHigher, sizeof(U8), 1, nvsBinFile); 4914 os_fwrite(&addressLower, sizeof(U8), 1, nvsBinFile); 4915 4916 4917 /* Write the higher MAC address starting from the LSB 4918 params 10-13 in NVS*/ 4919 os_fwrite(&Mac[1], sizeof(U8), 1, nvsBinFile); 4920 os_fwrite(&Mac[0], sizeof(U8), 1, nvsBinFile); 4921 4922 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 4923 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 4924 4925 os_error_printf(CU_MSG_INFO2, (PS8)"exiting FillMACAddressToNVS\n"); 4926 } 4927 4928 4929 /****************************************************************************/ 4930 /* Function: FillTXParameterToNVS */ 4931 /****************************************************************************/ 4932 /* Description: Fill TX parameters to the NVS */ 4933 /* Parameters: nvsBinFile - NVS bin file */ 4934 /* nvsPtr - NVS pointer */ 4935 /* Return Value: True - file created, False - otherwise */ 4936 /****************************************************************************/ 4937 void FillTXParameterToNVS(FILE *nvsBinFile, const TTestCmdP2GCal *nvsPtr) 4938 { 4939 TTestCmdP2GCal *ptgStruct = (TTestCmdP2GCal *)nvsPtr; 4940 U16 tlvLength; 4941 U16 index; 4942 U8 valueToSet; 4943 4944 4945 /* TX BiP type */ 4946 valueToSet = eNVS_RADIO_TX_PARAMETERS; 4947 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 4948 4949 /* TX Bip Length */ 4950 tlvLength = NVS_TX_PARAM_LENGTH; 4951 os_fwrite(&tlvLength, sizeof(U16), 1, nvsBinFile); 4952 4953 for (index = 0; index < NVS_TX_PARAM_LENGTH; index++) 4954 { 4955 valueToSet = ptgStruct->oNvsStruct.Buffer[index]; 4956 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 4957 } 4958 } 4959 4960 4961 /****************************************************************************/ 4962 /* Function: FillOldRXParameterToNVS */ 4963 /****************************************************************************/ 4964 /* Description: Fill old RX parameters to the NVS */ 4965 /* Parameters: nvsBinFile - NVS bin file */ 4966 /* buffer - buffer of uin8 values */ 4967 /* maxLengthOfBuffer - maximum length of all the buffer */ 4968 /* Return Value: True - file created, False - otherwise */ 4969 /****************************************************************************/ 4970 void FillOldRXParameterToNVS(FILE *nvsBinFile, const U8 *buffer) 4971 { 4972 U32 index; 4973 U32 paramStartIndex = NVS_PRE_PARAMETERS_LENGTH + NVS_RX_PARAM_INDEX; 4974 U32 paramEndIndex = paramStartIndex + NVS_RX_PARAM_LENGTH; 4975 U8 valueToSet; 4976 U16 tlvLength; 4977 4978 /* RX BiP type */ 4979 valueToSet = eNVS_RADIO_RX_PARAMETERS; 4980 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 4981 4982 /* RX Bip Length */ 4983 tlvLength = NVS_RX_PARAM_LENGTH; 4984 os_fwrite(&tlvLength, sizeof(U16), 1, nvsBinFile); 4985 4986 for (index = paramStartIndex; 4987 (index < paramEndIndex); 4988 index++) 4989 { 4990 valueToSet = buffer[index]; 4991 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 4992 } 4993 } 4994 4995 /****************************************************************************/ 4996 /* Function: FillRXParameterToNVS */ 4997 /****************************************************************************/ 4998 /* Description: Fill old TX parameters to the NVS */ 4999 /* Parameters: nvsBinFile - NVS bin file */ 5000 /* buffer - buffer of uin8 values */ 5001 /* maxLengthOfBuffer - maximum length of all the buffer */ 5002 /* Return Value: True - file created, False - otherwise */ 5003 /****************************************************************************/ 5004 void FillRXParameterToNVS(FILE *nvsBinFile, const RadioRxPltCal *nvsPtr) 5005 { 5006 RadioRxPltCal *ptgStruct = (RadioRxPltCal *)nvsPtr; 5007 U32 index; 5008 U8 valueToSet; 5009 U16 tlvLength; 5010 5011 /* RX BiP type */ 5012 valueToSet = eNVS_RADIO_RX_PARAMETERS; 5013 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5014 5015 /* RX Bip Length */ 5016 tlvLength = NVS_RX_PARAM_LENGTH; 5017 os_fwrite(&tlvLength, sizeof(U16), 1, nvsBinFile); 5018 5019 5020 for (index = 0; 5021 index < NVS_RX_PARAM_LENGTH; 5022 index++) 5023 { 5024 valueToSet = ptgStruct->oNvsStruct.Buffer[index]; 5025 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5026 } 5027 } 5028 5029 5030 /****************************************************************************/ 5031 /* Function: FillOldTXParameterToNVS */ 5032 /****************************************************************************/ 5033 /* Description: Fill old TX parameters to the NVS */ 5034 /* Parameters: nvsBinFile - NVS bin file */ 5035 /* buffer - buffer of uin8 values */ 5036 /* maxLengthOfBuffer - maximum length of all the buffer */ 5037 /* Return Value: True - file created, False - otherwise */ 5038 /****************************************************************************/ 5039 void FillOldTXParameterToNVS(FILE *nvsBinFile, const U8 *buffer) 5040 { 5041 U32 index ; 5042 U8 valueToSet; 5043 U16 tlvLength; 5044 U32 paramStartIndex = NVS_PRE_PARAMETERS_LENGTH + NVS_TX_PARAM_INDEX; 5045 U32 paramEndIndex = paramStartIndex + NVS_TX_PARAM_LENGTH; 5046 5047 /* TX BiP type */ 5048 valueToSet = eNVS_RADIO_TX_PARAMETERS; 5049 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5050 5051 /* TX Bip Length */ 5052 tlvLength = NVS_TX_PARAM_LENGTH; 5053 os_fwrite(&tlvLength, sizeof(U16), 1, nvsBinFile); 5054 5055 for (index = paramStartIndex; index < paramEndIndex; index++) 5056 { 5057 valueToSet = buffer[index]; 5058 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5059 } 5060 } 5061 5062 /****************************************************************************/ 5063 /* Function: FillDefaultTXParameterToNVS */ 5064 /****************************************************************************/ 5065 /* Description: Set 0 in all tX parameters */ 5066 /* Parameters: nvsBinFile - NVS bin file */ 5067 /* Return Value: True - file created, False - otherwise */ 5068 /****************************************************************************/ 5069 void FillDefaultTXParameterToNVS(FILE *nvsBinFile) 5070 { 5071 S8 typeValue = eNVS_RADIO_TX_PARAMETERS; 5072 U16 tlvLength = NVS_TX_PARAM_LENGTH; 5073 U8 valueToSet = 0; 5074 U32 txParamIndex; 5075 5076 /* TX type */ 5077 os_fwrite(&typeValue, sizeof(U8), 1, nvsBinFile); 5078 5079 /* TX length; */ 5080 os_fwrite(&tlvLength, sizeof(U16), 1, nvsBinFile); 5081 5082 for (txParamIndex = 0; txParamIndex < tlvLength; txParamIndex++) 5083 { 5084 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5085 } 5086 } 5087 5088 5089 5090 /****************************************************************************/ 5091 /* Function: FillDefaultRXParameterToNVS */ 5092 /****************************************************************************/ 5093 /* Description: Set 0 in all RX parameters */ 5094 /* Parameters: nvsBinFile - NVS bin file */ 5095 /* Return Value: True - file created, False - otherwise */ 5096 /****************************************************************************/ 5097 void FillDefaultRXParameterToNVS(FILE *nvsBinFile) 5098 { 5099 S8 typeValue = eNVS_RADIO_RX_PARAMETERS; 5100 U16 lengthValue = NVS_RX_PARAM_LENGTH; 5101 U8 valueToSet = 0; 5102 S8 rxParamIndex; 5103 5104 /* RX type */ 5105 os_fwrite(&typeValue, sizeof(U8), 1, nvsBinFile); 5106 5107 /* RX length; */ 5108 os_fwrite(&lengthValue, sizeof(U16), 1, nvsBinFile); 5109 5110 for (rxParamIndex = 0; rxParamIndex < lengthValue; rxParamIndex++) 5111 { 5112 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5113 } 5114 } 5115 5116 5117 /****************************************************************************/ 5118 /* Function: WriteEndNVSParam */ 5119 /****************************************************************************/ 5120 /* Description: Write end of NVS */ 5121 /* Parameters: nvsBinFile - NVS bin file */ 5122 /* Return Value: None */ 5123 /****************************************************************************/ 5124 void WriteEndNVSParam(FILE *nvsBinFile) 5125 { 5126 U16 lengthToSet; 5127 U8 valueToSet; 5128 5129 /* version type */ 5130 valueToSet = eTLV_LAST; 5131 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5132 5133 valueToSet = eTLV_LAST; 5134 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5135 5136 /* version length */ 5137 lengthToSet = 0; 5138 os_fwrite(&lengthToSet, sizeof(U16), 1, nvsBinFile); 5139 } 5140 5141 5142 /****************************************************************************/ 5143 /* Function: FillVersionToNVS */ 5144 /****************************************************************************/ 5145 /* Description: Fill version to the NVS */ 5146 /* Parameters: nvsBinFile - NVS bin file */ 5147 /* oldVersionValid - old verson parameter valide */ 5148 /* buffer - buffer of uin8 values */ 5149 /* maxLengthOfBuffer - maximum length of all the buffer */ 5150 /* Return Value: None */ 5151 /****************************************************************************/ 5152 /* 25.05.2008 Efil Function Created */ 5153 /****************************************************************************/ 5154 void FillVersionToNVS(FILE *nvsBinFile, 5155 S8 *versionStr, 5156 const TI_BOOL oldVersionValid, 5157 const U8 *buffer, 5158 const U32 maxLengthOfBuffer) 5159 { 5160 #define NUMBER_OF_DIGIT_VERISON 3 5161 U8 version[NUMBER_OF_DIGIT_VERISON]; 5162 U8 charToVersion = 0; 5163 U8 tempStr[MAX_NVS_VERSION_LENGTH]; 5164 U8 numberOfVersionDigit; 5165 U8 valueToSet; 5166 U16 lengthToSet; 5167 U32 index; 5168 U32 lengthOfStructStr; 5169 U32 startParamIndex; 5170 U32 endVersionParamIndex; 5171 U8 indexForDefaultVersion; 5172 5173 /* version type */ 5174 valueToSet = eNVS_VERSION; 5175 fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5176 5177 /* version length */ 5178 lengthToSet = NUMBER_OF_DIGIT_VERISON; 5179 os_fwrite(&lengthToSet, sizeof(U16), 1, nvsBinFile); 5180 5181 if (versionStr != NULL) 5182 { 5183 lengthOfStructStr = os_strlen(versionStr); 5184 5185 for (numberOfVersionDigit = 0, charToVersion = 0, index = 0; 5186 (index < MAX_NVS_VERSION_LENGTH) && (numberOfVersionDigit < NUMBER_OF_DIGIT_VERISON); charToVersion = 0, index++) 5187 { 5188 while ((versionStr[index] != '.') && (index < lengthOfStructStr)) 5189 { 5190 if ((versionStr[index] < '0') || (versionStr[index] > '9')) 5191 { 5192 index++; 5193 } 5194 else 5195 { 5196 tempStr[charToVersion++] = versionStr[index++]; 5197 } 5198 } 5199 5200 tempStr[charToVersion] = '\0'; 5201 5202 if (0 == os_strlen((PS8)tempStr)) 5203 { 5204 for (valueToSet = 0, indexForDefaultVersion = 0; indexForDefaultVersion < NUMBER_OF_DIGIT_VERISON - numberOfVersionDigit; indexForDefaultVersion++) 5205 { 5206 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5207 } 5208 5209 break; 5210 } 5211 5212 5213 version[numberOfVersionDigit] = (U8)os_atoi((PS8)tempStr); 5214 os_fwrite(&(version[numberOfVersionDigit]), sizeof(U8), 1, nvsBinFile); 5215 5216 numberOfVersionDigit++; 5217 } 5218 } 5219 else 5220 { 5221 if (oldVersionValid) 5222 { 5223 5224 startParamIndex = NVS_PRE_PARAMETERS_LENGTH + NVS_VERSION_PARAMETER_INDEX; 5225 endVersionParamIndex = startParamIndex + NUMBER_OF_DIGIT_VERISON; 5226 5227 if (maxLengthOfBuffer >= endVersionParamIndex) 5228 { 5229 for (index = startParamIndex; index < endVersionParamIndex; index++) 5230 { 5231 valueToSet = buffer[index]; 5232 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5233 } 5234 } 5235 else 5236 { 5237 valueToSet = 0; 5238 5239 for (index = startParamIndex; index < endVersionParamIndex; index++) 5240 { 5241 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5242 } 5243 5244 } 5245 } 5246 else 5247 { 5248 valueToSet = 0; 5249 5250 for (index = 0; index < NUMBER_OF_DIGIT_VERISON; index++) 5251 { 5252 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5253 } 5254 } 5255 } 5256 5257 5258 } 5259 5260 5261 5262 VOID build_nvs_file(THandle hCuCmd, TTestCmd data, S8 updatedProtocol) 5263 { 5264 #ifdef _WINDOWS 5265 PS8 nvs_file_name = (PS8)"/windows/nvs_map.bin"; 5266 #else 5267 PS8 nvs_file_name = (PS8)"./nvs_map.bin"; 5268 #endif /*_WINDOWS*/ 5269 FILE *nvsBinFile = NULL; 5270 S8 index; 5271 U8 valueToSet = 0; 5272 S8 nvsFileValid = TRUE; 5273 uint8 Buffer[MAX_TLV_LENGTH]; 5274 uint8 uTxTypeIndexValue; 5275 uint8 uRrxTypeIndexValue; 5276 5277 5278 os_memset (Buffer, 0, MAX_TLV_LENGTH); 5279 5280 if (NULL == (nvsBinFile = os_fopen (nvs_file_name, OS_FOPEN_READ_BINARY))) 5281 { 5282 nvsFileValid = FALSE; 5283 } 5284 else 5285 { 5286 os_fread(Buffer,1, MAX_TLV_LENGTH, nvsBinFile); 5287 os_fclose(nvsBinFile); 5288 5289 uTxTypeIndexValue = Buffer[NVS_PRE_PARAMETERS_LENGTH + NVS_TX_TYPE_INDEX]; 5290 uRrxTypeIndexValue = Buffer[NVS_PRE_PARAMETERS_LENGTH + NVS_RX_TYPE_INDEX]; 5291 5292 /* if the NVS includes just the MAC preamble (the firest 24B) don't use the Tx and RX values */ 5293 if ((uTxTypeIndexValue != eNVS_RADIO_TX_PARAMETERS) || (uRrxTypeIndexValue != eNVS_RADIO_RX_PARAMETERS)) 5294 { 5295 nvsFileValid = FALSE; 5296 } 5297 } 5298 5299 /* open NVS file */ 5300 if (NULL == (nvsBinFile = os_fopen (nvs_file_name, OS_FOPEN_WRITE_BINARY))) 5301 { 5302 os_error_printf(CU_MSG_INFO2, (PS8)"Open NVS file failed\n"); 5303 return; 5304 } 5305 5306 FillMACAddressToNVS(hCuCmd, nvsBinFile); 5307 5308 /* fill end burst transaction zeros*/ 5309 5310 for (index = 0; index < NVS_END_BURST_TRANSACTION_LENGTH; index++) 5311 { 5312 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5313 } 5314 5315 /* fill zeros to Align TLV start address*/ 5316 for (index = 0; index < NVS_ALING_TLV_START_ADDRESS_LENGTH; index++) 5317 { 5318 os_fwrite(&valueToSet, sizeof(U8), 1, nvsBinFile); 5319 } 5320 5321 /* Getting from TX BiP Command*/ 5322 if(NVS_FILE_TX_PARAMETERS_UPDATE == updatedProtocol) 5323 { 5324 /* Fill new TX BiP values*/ 5325 FillTXParameterToNVS(nvsBinFile, &data.testCmd_u.P2GCal); 5326 if (nvsFileValid) 5327 { 5328 /*set Parameters of RX from the previous file*/ 5329 FillOldRXParameterToNVS(nvsBinFile, 5330 Buffer); 5331 5332 } 5333 else 5334 { 5335 FillDefaultRXParameterToNVS(nvsBinFile); 5336 } 5337 5338 } 5339 else /* Fill new RX BiP values*/ 5340 { 5341 if (nvsFileValid) 5342 { 5343 /*set Parameters of TX from the previous file*/ 5344 FillOldTXParameterToNVS(nvsBinFile, 5345 Buffer); 5346 5347 } 5348 else 5349 { 5350 FillDefaultTXParameterToNVS(nvsBinFile); 5351 } 5352 5353 /* Fill new RX BiP values*/ 5354 FillRXParameterToNVS(nvsBinFile, &data.testCmd_u.RxPlt); 5355 5356 } 5357 5358 5359 /*Fill the NVS version to the NVS*/ 5360 FillVersionToNVS(nvsBinFile, 5361 data.testCmd_u.P2GCal.oNvsVersion, 5362 nvsFileValid, 5363 data.testCmd_u.P2GCal.oNvsStruct.Buffer, 5364 data.testCmd_u.P2GCal.oNvsStruct.Length); 5365 5366 /* End of NVS*/ 5367 WriteEndNVSParam(nvsBinFile); 5368 5369 5370 #if 0 5371 /* Save NVS Results in NVS file */ 5372 if (data.testCmd_u.P2GCal.oNvsStruct.Length != os_fwrite(data.testCmd_u.P2GCal.oNvsStruct.Buffer, sizeof(U8),data.testCmd_u.P2GCal.oNvsStruct.Length,nvs_file)) 5373 { 5374 os_error_printf(CU_MSG_INFO2, (PS8)"Writing to NVS file failed\n"); 5375 } 5376 #endif 5377 5378 /* close NVS File */ 5379 os_fclose(nvsBinFile); 5380 } 5381 5382 VOID CuCmd_BIP_BufferCalReferencePoint(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5383 { 5384 #define NUM_OF_PARAMETERS_REF_POINT 3 5385 5386 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5387 TTestCmd data; 5388 5389 if(nParms != NUM_OF_PARAMETERS_REF_POINT) 5390 { 5391 os_error_printf(CU_MSG_INFO2, (PS8)"Missing Param1: iReferencePointDetectorValue\n"); 5392 os_error_printf(CU_MSG_INFO2, (PS8)"Missing Param2: iReferencePointPower\n"); 5393 os_error_printf(CU_MSG_INFO2, (PS8)"Missing Param3: isubBand\n"); 5394 return; 5395 } 5396 else 5397 { 5398 os_memset(&data, 0, sizeof(TTestCmd)); 5399 data.testCmdId = TEST_CMD_UPDATE_PD_REFERENCE_POINT; 5400 /* data.testCmd_u.PdBufferCalReferencePoint.iReferencePointDetectorValue = 189; 5401 data.testCmd_u.PdBufferCalReferencePoint.iReferencePointPower = 12; 5402 data.testCmd_u.PdBufferCalReferencePoint.isubBand = 0; 1- BG 2-*/ 5403 5404 data.testCmd_u.PdBufferCalReferencePoint.iReferencePointDetectorValue = parm[0].value; 5405 data.testCmd_u.PdBufferCalReferencePoint.iReferencePointPower = parm[1].value; 5406 data.testCmd_u.PdBufferCalReferencePoint.isubBand = (U8)parm[2].value; 5407 5408 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 5409 { 5410 os_error_printf(CU_MSG_INFO2, (PS8)"BufferCalReferencePoint has failed\n"); 5411 return; 5412 } 5413 5414 os_error_printf(CU_MSG_INFO2, (PS8)"BufferCalReferencePoint was configured succesfully\n"); 5415 } 5416 return; 5417 } 5418 5419 5420 /* P2G Calibration */ 5421 VOID CuCmd_BIP_StartBIP(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5422 { 5423 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5424 TTestCmd data; 5425 U32 i; 5426 5427 os_memset(&data, 0, sizeof(TTestCmd)); 5428 5429 data.testCmdId = TEST_CMD_P2G_CAL; 5430 5431 data.testCmd_u.P2GCal.iSubBandMask = 0; 5432 for (i = 0; i < 8; i++) 5433 { 5434 data.testCmd_u.P2GCal.iSubBandMask |= (U8)parm[i].value << i; 5435 } 5436 5437 if (data.testCmd_u.P2GCal.iSubBandMask == 0) 5438 { 5439 os_error_printf(CU_MSG_INFO2, (PS8)"At least one sub-band should be enabled\n"); 5440 return; 5441 } 5442 5443 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 5444 { 5445 os_error_printf(CU_MSG_INFO2, (PS8)"Tx calibration start has failed\n"); 5446 return; 5447 } 5448 5449 if (TI_OK != data.testCmd_u.P2GCal.oRadioStatus) { 5450 os_error_printf(CU_MSG_INFO2, (PS8)"Tx calibration returned status: %d\n", data.testCmd_u.P2GCal.oRadioStatus); 5451 return; 5452 } 5453 5454 /* for (i=0;i<data.testCmd_u.P2GCal.oNvsStruct.Length;i++) { 5455 os_error_printf(CU_MSG_INFO2, (PS8)"nvs buffer[%d]=%x\n, ", i, data.testCmd_u.P2GCal.oNvsStruct.Buffer[i]); 5456 } */ 5457 5458 build_nvs_file(hCuCmd, data, NVS_FILE_TX_PARAMETERS_UPDATE); 5459 } 5460 5461 VOID CuCmd_BIP_EnterRxBIP(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5462 { 5463 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5464 TTestCmd data; 5465 5466 os_memset(&data, 0, sizeof(TTestCmd)); 5467 5468 data.testCmdId = TEST_CMD_RX_PLT_ENTER; 5469 5470 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 5471 { 5472 os_error_printf(CU_MSG_INFO2, (PS8)"Enter Rx calibration has failed\n"); 5473 return; 5474 } 5475 5476 5477 if (TI_OK != data.testCmd_u.RxPlt.oRadioStatus) { 5478 os_error_printf(CU_MSG_INFO2, (PS8)"Enter Rx calibration returned status: %d\n", data.testCmd_u.RxPlt.oRadioStatus); 5479 return; 5480 } 5481 5482 } 5483 5484 5485 VOID CuCmd_BIP_StartRxBIP(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5486 { 5487 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5488 TTestCmd data; 5489 5490 os_memset(&data, 0, sizeof(TTestCmd)); 5491 5492 data.testCmdId = TEST_CMD_RX_PLT_CAL; 5493 data.testCmd_u.RxPlt.iExternalSignalPowerLevel = (S32)parm[0].value; 5494 5495 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 5496 { 5497 os_error_printf(CU_MSG_INFO2, (PS8)"Rx calibration has failed\n"); 5498 return; 5499 } 5500 5501 if (TI_OK != data.testCmd_u.RxPlt.oRadioStatus) { 5502 os_error_printf(CU_MSG_INFO2, (PS8)"Rx calibration returned status: %d\n", data.testCmd_u.RxPlt.oRadioStatus); 5503 return; 5504 } 5505 5506 build_nvs_file(hCuCmd, data, NVS_FILE_RX_PARAMETERS_UPDATE); 5507 5508 } 5509 5510 VOID CuCmd_BIP_ExitRxBIP(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5511 { 5512 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5513 TTestCmd data; 5514 5515 os_memset(&data, 0, sizeof(TTestCmd)); 5516 5517 data.testCmdId = TEST_CMD_RX_PLT_EXIT; 5518 5519 if(OK != CuCommon_Radio_Test(pCuCmd->hCuCommon, &data)) 5520 { 5521 os_error_printf(CU_MSG_INFO2, (PS8)"Exit Rx calibration has failed\n"); 5522 return; 5523 } 5524 5525 5526 if (TI_OK != data.testCmd_u.RxPlt.oRadioStatus) { 5527 os_error_printf(CU_MSG_INFO2, (PS8)"Exit Rx calibration returned status: %d\n", data.testCmd_u.RxPlt.oRadioStatus); 5528 return; 5529 } 5530 5531 } 5532 5533 5534 5535 VOID CuCmd_SetPrivacyAuth(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5536 { 5537 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5538 U32 AuthMode; 5539 5540 if( nParms ) 5541 { 5542 os_error_printf(CU_MSG_INFO2, (PS8)"Setting privacy authentication to %ld\n", parm[0].value); 5543 AuthMode = parm[0].value; 5544 if (pCuCmd->hWpaCore == NULL) 5545 { 5546 /* we can only accept WEP or OPEN configurations */ 5547 if((AuthMode >= os802_11AuthModeOpen) && (AuthMode <= os802_11AuthModeAutoSwitch)) 5548 { 5549 if(OK != CuCommon_SetU32(pCuCmd->hCuCommon, RSN_EXT_AUTHENTICATION_MODE, AuthMode)) return; 5550 } 5551 else 5552 { 5553 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetPrivacyAuth - cannot set mode (%ld) when Suppl is not present\n", AuthMode); 5554 return; 5555 } 5556 } 5557 else 5558 { 5559 #ifndef NO_WPA_SUPPL 5560 if(OK != WpaCore_SetAuthMode(pCuCmd->hWpaCore, AuthMode)) return; 5561 #endif 5562 } 5563 } 5564 else 5565 { 5566 #ifdef WPA_ENTERPRISE 5567 static named_value_t auth_mode_type[] = { 5568 { os802_11AuthModeOpen, (PS8)"Open" }, 5569 { os802_11AuthModeShared, (PS8)"Shared" }, 5570 { os802_11AuthModeAutoSwitch, (PS8)"AutoSwitch"}, 5571 { os802_11AuthModeWPA, (PS8)"WPA" }, 5572 { os802_11AuthModeWPAPSK, (PS8)"WPAPSK" }, 5573 { os802_11AuthModeWPANone, (PS8)"WPANone" }, 5574 { os802_11AuthModeWPA2, (PS8)"WPA2" }, 5575 { os802_11AuthModeWPA2PSK, (PS8)"WPA2PSK" }, 5576 }; 5577 #else 5578 static named_value_t auth_mode_type[] = { 5579 { os802_11AuthModeOpen, (PS8)"Open" }, 5580 { os802_11AuthModeShared, (PS8)"Shared" }, 5581 { os802_11AuthModeWPAPSK, (PS8)"WPAPSK" }, 5582 { os802_11AuthModeWPA2PSK, (PS8)"WPA2PSK" }, 5583 }; 5584 #endif 5585 5586 if (pCuCmd->hWpaCore == NULL) 5587 { 5588 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_EXT_AUTHENTICATION_MODE, &AuthMode)) return; 5589 } 5590 else 5591 { 5592 #ifndef NO_WPA_SUPPL 5593 if(OK != WpaCore_GetAuthMode(pCuCmd->hWpaCore, &AuthMode)) return; 5594 #endif 5595 } 5596 5597 print_available_values(auth_mode_type); 5598 os_error_printf(CU_MSG_INFO2, (PS8)"AuthenticationMode=%d\n", AuthMode ); 5599 } 5600 } 5601 5602 VOID CuCmd_SetPrivacyEap(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5603 { 5604 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5605 OS_802_11_EAP_TYPES EapType; 5606 S32 i; 5607 named_value_t EapType_type[] = { 5608 { OS_EAP_TYPE_NONE, (PS8)"OS_EAP_TYPE_NONE" }, 5609 { OS_EAP_TYPE_MD5_CHALLENGE, (PS8)"OS_EAP_TYPE_MD5_CHALLENGE" }, 5610 { OS_EAP_TYPE_GENERIC_TOKEN_CARD, (PS8)"OS_EAP_TYPE_GENERIC_TOKEN_CARD" }, 5611 { OS_EAP_TYPE_TLS, (PS8)"OS_EAP_TYPE_TLS" }, 5612 { OS_EAP_TYPE_LEAP, (PS8)"OS_EAP_TYPE_LEAP" }, 5613 { OS_EAP_TYPE_TTLS, (PS8)"OS_EAP_TYPE_TTLS" }, 5614 { OS_EAP_TYPE_PEAP, (PS8)"OS_EAP_TYPE_PEAP" }, 5615 { OS_EAP_TYPE_MS_CHAP_V2, (PS8)"OS_EAP_TYPE_MS_CHAP_V2" }, 5616 { OS_EAP_TYPE_FAST, (PS8)"OS_EAP_TYPE_FAST" } 5617 }; 5618 5619 /* check if we have supplicant */ 5620 if (pCuCmd->hWpaCore == NULL) 5621 { 5622 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetPrivacyEap - cannot set EapType when Suppl is not present\n"); 5623 return; 5624 } 5625 5626 if( nParms ) 5627 { 5628 EapType = parm[0].value; 5629 /* check if the param is valid */ 5630 CU_CMD_FIND_NAME_ARRAY(i, EapType_type, EapType); 5631 if(i == SIZE_ARR(EapType_type)) 5632 { 5633 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetPrivacyEap, EapType %d is not defined!\n", EapType); 5634 return; 5635 } 5636 5637 #ifndef NO_WPA_SUPPL 5638 5639 if(OK != WpaCore_SetPrivacyEap(pCuCmd->hWpaCore, EapType)) 5640 os_error_printf(CU_MSG_INFO2, (PS8)"Error Setting EapType to %ld\n", EapType); 5641 else 5642 os_error_printf(CU_MSG_INFO2, (PS8)"Setting EapType to %ld\n", EapType); 5643 5644 #endif 5645 /* 5646 WEXT phase I 5647 TI_SetEAPType( g_id_adapter, (OS_802_11_EAP_TYPES) parm[0].value ); 5648 TI_SetEAPTypeDriver( g_id_adapter, (OS_802_11_EAP_TYPES) parm[0].value ); 5649 */ 5650 5651 } 5652 else 5653 { 5654 print_available_values(EapType_type); 5655 } 5656 } 5657 5658 5659 VOID CuCmd_SetPrivacyEncryption(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5660 { 5661 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5662 U32 EncryptionType; 5663 #ifndef NO_WPA_SUPPL 5664 OS_802_11_ENCRYPTION_TYPES EncryptionTypePairWise; 5665 OS_802_11_ENCRYPTION_TYPES EncryptionTypeGroup; 5666 #endif 5667 S32 i; 5668 5669 if( nParms ) 5670 { 5671 EncryptionType = parm[0].value; 5672 5673 /* check if the param is valid */ 5674 CU_CMD_FIND_NAME_ARRAY(i, encrypt_type, EncryptionType); 5675 if(i == SIZE_ARR(encrypt_type)) 5676 { 5677 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetPrivacyEncryption, EncryptionType %d is not defined!\n", EncryptionType); 5678 return; 5679 } 5680 5681 if (pCuCmd->hWpaCore == NULL) 5682 { 5683 if((EncryptionType == OS_ENCRYPTION_TYPE_NONE) || (EncryptionType == OS_ENCRYPTION_TYPE_WEP)) 5684 { 5685 if(OK != CuCommon_SetU32(pCuCmd->hCuCommon, RSN_ENCRYPTION_STATUS_PARAM, (U32)EncryptionType)) return; 5686 } 5687 else 5688 { 5689 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_SetPrivacyEncryption - can't set EncryptionType %s when not connected to supplicant",encrypt_type[i].name); 5690 return; 5691 } 5692 } 5693 else 5694 { 5695 #ifndef NO_WPA_SUPPL 5696 switch(EncryptionType) 5697 { 5698 case OS_ENCRYPTION_TYPE_NONE: 5699 EncryptionTypePairWise = OS_ENCRYPTION_TYPE_NONE; 5700 EncryptionTypeGroup = OS_ENCRYPTION_TYPE_NONE; 5701 break; 5702 case OS_ENCRYPTION_TYPE_WEP: 5703 EncryptionTypePairWise = OS_ENCRYPTION_TYPE_WEP; 5704 EncryptionTypeGroup = OS_ENCRYPTION_TYPE_WEP; 5705 break; 5706 case OS_ENCRYPTION_TYPE_TKIP: 5707 EncryptionTypePairWise = OS_ENCRYPTION_TYPE_TKIP; 5708 EncryptionTypeGroup = OS_ENCRYPTION_TYPE_TKIP; 5709 break; 5710 case OS_ENCRYPTION_TYPE_AES: 5711 EncryptionTypePairWise = OS_ENCRYPTION_TYPE_AES; 5712 EncryptionTypeGroup = OS_ENCRYPTION_TYPE_AES; 5713 break; 5714 } 5715 5716 if(OK != WpaCore_SetEncryptionPairWise(pCuCmd->hWpaCore, EncryptionTypePairWise)) return; 5717 if(OK != WpaCore_SetEncryptionGroup(pCuCmd->hWpaCore, EncryptionTypeGroup)) return; 5718 #endif 5719 5720 } 5721 5722 os_error_printf(CU_MSG_INFO2, (PS8)"Setting privacy encryption to %ld\n", encrypt_type[i]); 5723 } 5724 else 5725 { 5726 if (pCuCmd->hWpaCore == NULL) 5727 { 5728 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_ENCRYPTION_STATUS_PARAM, &EncryptionType)) return; 5729 5730 switch (EncryptionType) 5731 { 5732 case TWD_CIPHER_NONE: 5733 EncryptionType = OS_ENCRYPTION_TYPE_NONE; 5734 break; 5735 case TWD_CIPHER_WEP: 5736 case TWD_CIPHER_WEP104: 5737 EncryptionType = OS_ENCRYPTION_TYPE_WEP; 5738 break; 5739 case TWD_CIPHER_TKIP: 5740 EncryptionType = OS_ENCRYPTION_TYPE_TKIP; 5741 break; 5742 case TWD_CIPHER_AES_WRAP: 5743 case TWD_CIPHER_AES_CCMP: 5744 EncryptionType = OS_ENCRYPTION_TYPE_AES; 5745 break; 5746 default: 5747 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_SetPrivacyEncryption - unknown encryption type (%d)",EncryptionType); 5748 break; 5749 } 5750 } 5751 else 5752 { 5753 #ifndef NO_WPA_SUPPL 5754 if(OK != WpaCore_GetEncryptionPairWise(pCuCmd->hWpaCore, &EncryptionTypePairWise)) return; 5755 if(OK != WpaCore_GetEncryptionGroup(pCuCmd->hWpaCore, &EncryptionTypeGroup)) return; 5756 5757 if((EncryptionTypePairWise == OS_ENCRYPTION_TYPE_NONE) && (EncryptionTypeGroup == OS_ENCRYPTION_TYPE_NONE)) 5758 EncryptionType = OS_ENCRYPTION_TYPE_NONE; 5759 else if((EncryptionTypePairWise == OS_ENCRYPTION_TYPE_WEP) && (EncryptionTypeGroup == OS_ENCRYPTION_TYPE_WEP)) 5760 EncryptionType = OS_ENCRYPTION_TYPE_WEP; 5761 else if((EncryptionTypePairWise == OS_ENCRYPTION_TYPE_TKIP) && (EncryptionTypeGroup == OS_ENCRYPTION_TYPE_TKIP)) 5762 EncryptionType = OS_ENCRYPTION_TYPE_TKIP; 5763 else if((EncryptionTypePairWise == OS_ENCRYPTION_TYPE_AES) && (EncryptionTypeGroup == OS_ENCRYPTION_TYPE_AES)) 5764 EncryptionType = OS_ENCRYPTION_TYPE_AES; 5765 else 5766 { 5767 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_SetPrivacyEncryption - unknown encryption type (%d,%d)",EncryptionTypePairWise, EncryptionTypeGroup); 5768 return; 5769 } 5770 #endif 5771 } 5772 5773 print_available_values(encrypt_type); 5774 os_error_printf(CU_MSG_INFO2, (PS8)"Encryption = %d\n", EncryptionType); 5775 } 5776 } 5777 5778 VOID CuCmd_SetPrivacyKeyType(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5779 { 5780 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5781 OS_802_11_KEY_TYPES KeyType; 5782 S32 i; 5783 static named_value_t KeyType_type[] = { 5784 { OS_KEY_TYPE_STATIC, (PS8)"STATIC" }, 5785 { OS_KEY_TYPE_DYNAMIC, (PS8)"DYNAMIC"} 5786 }; 5787 5788 /* check if we have supplicant */ 5789 if (pCuCmd->hWpaCore == NULL) 5790 { 5791 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetPrivacyEncryptGroup - cannot set encryption Group when Suppl is not present\n"); 5792 return; 5793 } 5794 5795 if( nParms ) 5796 { 5797 KeyType = parm[0].value; 5798 /* check if the param is valid */ 5799 CU_CMD_FIND_NAME_ARRAY(i, KeyType_type, KeyType); 5800 if(i == SIZE_ARR(KeyType_type)) 5801 { 5802 os_error_printf(CU_MSG_INFO2, (PS8)"CuCmd_SetPrivacyKeyType - KeyType %d is not defined!\n", KeyType); 5803 return; 5804 } 5805 5806 os_error_printf(CU_MSG_INFO2, (PS8)"Setting KeyType to %ld\n", KeyType); 5807 5808 /* 5809 WEXT phase I 5810 TI_SetKeyType( g_id_adapter, (OS_802_11_KEY_TYPES)parm[0].value ); 5811 */ 5812 } 5813 else 5814 { 5815 print_available_values(KeyType_type); 5816 } 5817 } 5818 5819 VOID CuCmd_SetPrivacyMixedMode(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5820 { 5821 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5822 U32 MixedMode; 5823 5824 if( nParms ) 5825 { 5826 MixedMode = parm[0].value; 5827 os_error_printf(CU_MSG_INFO2, (PS8)"Setting MixedMode to %s\n", (MixedMode)?"True":"False"); 5828 5829 CuCommon_SetU32(pCuCmd->hCuCommon, TIWLN_802_11_MIXED_MODE_SET, MixedMode); 5830 } 5831 else 5832 { 5833 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, TIWLN_802_11_MIXED_MODE_GET, &MixedMode)) return; 5834 5835 os_error_printf(CU_MSG_INFO2, (PS8)"Mixed Mode: 0 - FALSE, 1 - TRUE\n"); 5836 os_error_printf(CU_MSG_INFO2, (PS8)"Mixed Mode =%s\n", (MixedMode)?"True":"False"); 5837 } 5838 } 5839 5840 VOID CuCmd_SetPrivacyAnyWpaMode(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5841 { 5842 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5843 #ifndef NO_WPA_SUPPL 5844 U32 anyWpaMode; 5845 5846 if( nParms ) 5847 { 5848 anyWpaMode = parm[0].value; 5849 os_error_printf(CU_MSG_INFO2, (PS8)"Setting anyWpaMode to %s\n", (anyWpaMode)?"True":"False"); 5850 5851 WpaCore_SetAnyWpaMode(pCuCmd->hWpaCore,(U8)anyWpaMode); 5852 } 5853 else 5854 { 5855 WpaCore_GetAnyWpaMode(pCuCmd->hWpaCore,(U8 *)&anyWpaMode); 5856 os_error_printf(CU_MSG_INFO2, (PS8)"Any WPA Mode: 0 - FALSE, 1 - TRUE\n"); 5857 os_error_printf(CU_MSG_INFO2, (PS8)"Any WPA =%s\n", (anyWpaMode)?"True":"False"); 5858 } 5859 #else 5860 os_error_printf(CU_MSG_INFO2, (PS8)"Any Wpa Mode support only in Linux supplicants\n"); 5861 #endif 5862 } 5863 5864 VOID CuCmd_SetPrivacyCredentials(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5865 { 5866 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5867 5868 if( nParms == 0 ) 5869 return; 5870 5871 if (pCuCmd->hWpaCore == NULL) 5872 { 5873 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetPrivacyPskPassPhrase - cannot set Credential password phrase when Suppl is not present\n"); 5874 return; 5875 } 5876 5877 #ifndef NO_WPA_SUPPL 5878 5879 if( nParms == 2 ) 5880 { 5881 WpaCore_SetCredentials(pCuCmd->hWpaCore,(PU8)(parm[0].value),(PU8)(parm[1].value)); 5882 } 5883 else if( nParms == 1 ) 5884 { 5885 WpaCore_SetCredentials(pCuCmd->hWpaCore,(PU8)(parm[0].value),NULL); 5886 } 5887 #endif 5888 } 5889 5890 VOID CuCmd_SetPrivacyPskPassPhrase(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5891 { 5892 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5893 U32 IsHexKey = FALSE; 5894 U8 buf[WPACORE_MAX_PSK_STRING_LENGTH]; 5895 PS8 pPassphrase; 5896 S32 len; 5897 5898 if( nParms == 0 ) 5899 return; 5900 5901 /* check if we have supplicant */ 5902 if (pCuCmd->hWpaCore == NULL) 5903 { 5904 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetPrivacyPskPassPhrase - cannot set PSK password phrase when Suppl is not present\n"); 5905 return; 5906 } 5907 5908 len = os_strlen((PS8)(parm[0].value)); 5909 pPassphrase = ((PS8)parm[0].value); 5910 os_memset(buf, 0, WPACORE_MAX_PSK_STRING_LENGTH); 5911 5912 5913 if( nParms == 2 ) 5914 { 5915 if( !os_strcmp( (PS8) parm[1].value, (PS8)"hex") ) 5916 IsHexKey = TRUE; 5917 else if(!os_strcmp( (PS8) parm[1].value, (PS8)"text")) 5918 IsHexKey = FALSE; 5919 } 5920 5921 if( IsHexKey ) 5922 { 5923 U8 val_l; 5924 U8 val_u; 5925 S32 i; 5926 5927 if( len != WPACORE_PSK_HEX_LENGTH ) 5928 { 5929 os_error_printf(CU_MSG_INFO2, (PS8)"The hexa PSKPassphrase must be at length of %d hexa digits \n",WPACORE_PSK_HEX_LENGTH); 5930 return; 5931 } 5932 5933 for( i=0; *pPassphrase; i++, pPassphrase++ ) 5934 { 5935 val_u = CuCmd_Char2Hex(*pPassphrase); 5936 if( val_u == ((U8)-1) ) return; 5937 val_l = CuCmd_Char2Hex(*(++pPassphrase)); 5938 if( val_l == ((U8)-1) ) return; 5939 buf[i] = ((val_u << 4) | val_l); 5940 } 5941 } 5942 else 5943 { 5944 if (len > WPACORE_MAX_PSK_STRING_LENGTH || len < WPACORE_MIN_PSK_STRING_LENGTH) 5945 { 5946 os_error_printf(CU_MSG_INFO2, (PS8)"The PSKPassphrase must be between %d to %d chars \n", WPACORE_MIN_PSK_STRING_LENGTH, WPACORE_MAX_PSK_STRING_LENGTH); 5947 return; 5948 } 5949 5950 os_memcpy((PVOID)buf, (PVOID)pPassphrase, len); 5951 } 5952 5953 os_error_printf(CU_MSG_INFO2, (PS8)"Setting PSKPassphrase to %s\n", (PS8) parm[0].value); 5954 #ifndef NO_WPA_SUPPL 5955 WpaCore_SetPskPassPhrase(pCuCmd->hWpaCore, buf); 5956 #endif 5957 5958 } 5959 5960 VOID CuCmd_SetPrivacyCertificate(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5961 { 5962 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5963 5964 if( nParms == 0 ) 5965 return; 5966 5967 if (pCuCmd->hWpaCore == NULL) 5968 { 5969 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_SetPrivacyPskPassPhrase - cannot set Certification when Suppl is not present\n"); 5970 return; 5971 } 5972 #ifndef NO_WPA_SUPPL 5973 WpaCore_SetCertificate(pCuCmd->hWpaCore,(PU8)(parm[0].value)); 5974 #endif 5975 5976 5977 } 5978 5979 VOID CuCmd_StopSuppl(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5980 { 5981 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5982 5983 /* check if we have supplicant */ 5984 if (pCuCmd->hWpaCore == NULL) 5985 { 5986 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_StopSuppl - cannot stop supplicant when Suppl is not present :-)\n"); 5987 return; 5988 } 5989 #ifndef NO_WPA_SUPPL 5990 WpaCore_StopSuppl(pCuCmd->hWpaCore); 5991 #endif 5992 } 5993 5994 VOID CuCmd_ChangeSupplDebugLevels(THandle hCuCmd, ConParm_t parm[], U16 nParms) 5995 { 5996 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 5997 5998 /* check if we have supplicant */ 5999 if (pCuCmd->hWpaCore == NULL) 6000 { 6001 os_error_printf(CU_MSG_ERROR, (PS8)"Error - CuCmd_DebugSuppl - cannot debug supplicant when Suppl is not present :-)\n"); 6002 return; 6003 } 6004 #ifndef NO_WPA_SUPPL 6005 WpaCore_ChangeSupplDebugLevels(pCuCmd->hWpaCore, parm[0].value, parm[1].value, parm[2].value); 6006 #endif 6007 } 6008 6009 VOID CuCmd_AddPrivacyKey(THandle hCuCmd, ConParm_t parm[], U16 nParms) 6010 { 6011 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 6012 PS8 buf; 6013 U32 key_id = 0; 6014 U32 def_flag = 0; 6015 U32 IsHexKey = TRUE; 6016 OS_802_11_WEP data; 6017 U8 val_l, val_u; 6018 S32 len; 6019 6020 buf = (PS8)parm[0].value; 6021 key_id = (U32)parm[1].value; 6022 if( parm[2].value ) def_flag = 0x80000000; 6023 os_memset(data.KeyMaterial,0,sizeof(data.KeyMaterial)); 6024 len = os_strlen((PS8)buf); 6025 6026 if(key_id > 3) 6027 { 6028 os_error_printf(CU_MSG_INFO2, (PS8)"the key index must be between 0 and 3\n"); 6029 return; 6030 } 6031 6032 if( nParms >= 4 ) 6033 { 6034 if( !os_strcmp( (PS8) parm[3].value, (PS8)"hex") ) 6035 IsHexKey = TRUE; 6036 else if( !os_strcmp( (PS8) parm[3].value, (PS8)"HEX") ) 6037 IsHexKey = TRUE; 6038 else if(!os_strcmp( (PS8) parm[3].value, (PS8)"text")) 6039 IsHexKey = FALSE; 6040 else if(!os_strcmp( (PS8) parm[3].value, (PS8)"TEXT")) 6041 IsHexKey = FALSE; 6042 } 6043 6044 if( IsHexKey ) 6045 { 6046 S32 i; 6047 6048 if( len % 2 ) 6049 { 6050 os_error_printf(CU_MSG_INFO2, (PS8)"The hexa key should be even length\n"); 6051 return; 6052 } 6053 if(len <= 10) /*10 is number of character for key length 40 bit*/ 6054 data.KeyLength = 5; 6055 else if(len <= 26) /*26 is number of character for key length 128 bit*/ 6056 data.KeyLength = 13; 6057 else if(len <= 58) /*58 is number of character for key length 256 bit*/ 6058 data.KeyLength = 29; 6059 else 6060 { 6061 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_AddPrivacyKey - key length not valid\n" ); 6062 return; 6063 } 6064 6065 for( i=0; *buf; i++, buf++ ) 6066 { 6067 val_u = CuCmd_Char2Hex(*buf); 6068 if(val_u == ((U8)-1)) return; 6069 val_l = CuCmd_Char2Hex(*(++buf)); 6070 if(val_l == ((U8)-1)) return; 6071 data.KeyMaterial[i] = ((val_u << 4) | val_l); 6072 } 6073 } 6074 else /* for ascii key */ 6075 { 6076 if(len <= 5) /*10 is number of character for key length 40 bit*/ 6077 data.KeyLength = 5; 6078 else if(len <= 13) /*26 is number of character for key length 128 bit*/ 6079 data.KeyLength = 13; 6080 else if(len <= 29) /*58 is number of character for key length 256 bit*/ 6081 data.KeyLength = 29; 6082 else 6083 { 6084 os_error_printf(CU_MSG_ERROR, (PS8)"ERROR - CuCmd_AddPrivacyKey - key length not valid\n" ); 6085 return; 6086 } 6087 os_memcpy((PVOID)data.KeyMaterial, (PVOID)buf, len); 6088 } 6089 6090 data.KeyIndex = def_flag | key_id; 6091 data.Length = sizeof(OS_802_11_WEP); 6092 6093 /* check if we have supplicant */ 6094 if (pCuCmd->hWpaCore == NULL) 6095 { 6096 CuCommon_AddKey(pCuCmd->hCuCommon, &data); 6097 } 6098 else 6099 { 6100 #ifndef NO_WPA_SUPPL 6101 WpaCore_AddKey(pCuCmd->hWpaCore, &data); 6102 #endif 6103 } 6104 } 6105 6106 VOID CuCmd_RemovePrivacyKey(THandle hCuCmd, ConParm_t parm[], U16 nParms) 6107 { 6108 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 6109 6110 /* check if we have supplicant */ 6111 CuCommon_RemoveKey(pCuCmd->hCuCommon, parm[0].value); 6112 } 6113 6114 VOID CuCmd_GetPrivacyDefaultKey(THandle hCuCmd, ConParm_t parm[], U16 nParms) 6115 { 6116 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 6117 U32 DefaultKeyId; 6118 6119 /* check if we have supplicant */ 6120 if (pCuCmd->hWpaCore == NULL) 6121 { 6122 if(OK != CuCommon_GetU32(pCuCmd->hCuCommon, RSN_DEFAULT_KEY_ID, &DefaultKeyId)) return; 6123 } 6124 else 6125 { 6126 #ifndef NO_WPA_SUPPL 6127 if(OK != WpaCore_GetDefaultKey(pCuCmd->hWpaCore, &DefaultKeyId)) return; 6128 #endif 6129 } 6130 6131 os_error_printf(CU_MSG_INFO2, (PS8)"WEP default key ID = %d\n", DefaultKeyId ); 6132 } 6133 6134 VOID CuCmd_EnableKeepAlive (THandle hCuCmd, ConParm_t parm[], U16 nParms) 6135 { 6136 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 6137 6138 if (OK != CuCommon_SetU32 (pCuCmd->hCuCommon, POWER_MGR_KEEP_ALIVE_ENA_DIS, 1)) 6139 { 6140 os_error_printf (CU_MSG_ERROR, (PS8)"Unable to enable keep-alive messages\n"); 6141 } 6142 } 6143 6144 VOID CuCmd_DisableKeepAlive (THandle hCuCmd, ConParm_t parm[], U16 nParms) 6145 { 6146 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 6147 6148 if (OK != CuCommon_SetU32 (pCuCmd->hCuCommon, POWER_MGR_KEEP_ALIVE_ENA_DIS, 0)) 6149 { 6150 os_error_printf (CU_MSG_ERROR, (PS8)"Unable to disable keep-alive messages\n"); 6151 } 6152 } 6153 6154 VOID CuCmd_AddKeepAliveMessage (THandle hCuCmd, ConParm_t parm[], U16 nParms) 6155 { 6156 CuCmd_t *pCuCmd = (CuCmd_t*)hCuCmd; 6157 TKeepAliveTemplate keepAliveParams; 6158 6159 if (4 != nParms) 6160 { 6161 os_error_printf (CU_MSG_ERROR, (PS8)"Number of params to add keep-alive message is %d\n", nParms); 6162 return; 6163 } 6164 6165 /* copy keep-alive params */ 6166 keepAliveParams.keepAliveParams.index = (U8)parm[ 0 ].value; 6167 keepAliveParams.keepAliveParams.interval = parm[ 1 ].value; 6168 keepAliveParams.keepAliveParams.trigType = parm[ 2 ].value; 6169 keepAliveParams.keepAliveParams.enaDisFlag = 1; /* set to enable */ 6170 keepAliveParams.msgBufferLength = os_strlen ((PS8)parm[ 3 ].value); 6171 if (0 == (keepAliveParams.msgBufferLength %2)) 6172 { 6173 keepAliveParams.msgBufferLength = keepAliveParams.msgBufferLength / 2; 6174 } 6175 else 6176 { 6177 keepAliveParams.msgBufferLength = (keepAliveParams.msgBufferLength / 2) + 1; 6178 } 6179 /* convert the string to hexadeciaml values, and copy it */ 6180 CuCmd_atox_string ((U8*)parm[ 3 ].value, &keepAliveParams.msgBuffer[ 0 ]); 6181 6182 if (TI_OK != CuCommon_SetBuffer(pCuCmd->hCuCommon, POWER_MGR_KEEP_ALIVE_ADD_REM, 6183 &(keepAliveParams), sizeof(TKeepAliveTemplate))) 6184 { 6185 os_error_printf (CU_MSG_ERROR, (PS8)"Unable to add keep-alive message\n"); 6186 } 6187 } 6188 6189 VOID CuCmd_RemoveKeepAliveMessage (THandle hCuCmd, ConParm_t parm[], U16 nParms) 6190 { 6191 CuCmd_t *pCuCmd = (CuCmd_t*)hCuCmd; 6192 TKeepAliveTemplate keepAliveParams; 6193 6194 if (1 != nParms) 6195 { 6196 os_error_printf (CU_MSG_ERROR, (PS8)"Number of params to remove keep-alive message is %d\n", nParms); 6197 return; 6198 } 6199 6200 /* copy keep-alive params */ 6201 keepAliveParams.keepAliveParams.index = (U8)parm[ 0 ].value; 6202 keepAliveParams.keepAliveParams.enaDisFlag = 0; /* set to disable */ 6203 keepAliveParams.keepAliveParams.interval = 1000; /* FW validate all parameters, so some reasonable values must be used */ 6204 keepAliveParams.keepAliveParams.trigType = KEEP_ALIVE_TRIG_TYPE_PERIOD_ONLY; 6205 6206 if (OK != CuCommon_SetBuffer (pCuCmd->hCuCommon, POWER_MGR_KEEP_ALIVE_ADD_REM, 6207 &(keepAliveParams), sizeof(TKeepAliveTemplate))) 6208 { 6209 os_error_printf (CU_MSG_ERROR, (PS8)"Unable to remove keep-alive message\n"); 6210 } 6211 } 6212 6213 VOID CuCmd_ShowKeepAlive (THandle hCuCmd, ConParm_t parm[], U16 nParms) 6214 { 6215 CuCmd_t *pCuCmd = (CuCmd_t*)hCuCmd; 6216 TKeepAliveConfig tConfig; 6217 U32 uIndex, uNameIndex; 6218 S8 msgBuffer[ KEEP_ALIVE_TEMPLATE_MAX_LENGTH * 2 ]; 6219 6220 if (OK != CuCommon_GetSetBuffer (pCuCmd->hCuCommon, POWER_MGR_KEEP_ALIVE_GET_CONFIG, 6221 &(tConfig), sizeof(TKeepAliveConfig))) 6222 { 6223 os_error_printf (CU_MSG_ERROR, (PS8)"Unable to read keep-alive configuration\n"); 6224 } 6225 6226 os_error_printf (CU_MSG_ERROR, (PS8)"Keep-Alive configuration:\n" 6227 "-------------------------\n"); 6228 if (TRUE == tConfig.enaDisFlag) 6229 { 6230 os_error_printf (CU_MSG_ERROR, (PS8)"Keep-Alive global flag set to enabled\n\n"); 6231 } 6232 else 6233 { 6234 os_error_printf (CU_MSG_ERROR, (PS8)"Keep-Alive global flag set to disabled\n\n"); 6235 } 6236 6237 os_error_printf (CU_MSG_ERROR, (PS8)"%-8s %-8s %-9s %-10s %s\n", (PS8)"Index", (PS8)"Enabled", (PS8)"Trig Type", (PS8)"Interval", (PS8)"Pattern"); 6238 os_error_printf (CU_MSG_ERROR, (PS8)"-----------------------------------------------\n"); 6239 for (uIndex = 0; uIndex < KEEP_ALIVE_MAX_USER_MESSAGES; uIndex++) 6240 { 6241 if (TRUE == tConfig.templates[ uIndex ].keepAliveParams.enaDisFlag) 6242 { 6243 CU_CMD_FIND_NAME_ARRAY (uNameIndex, tKeepAliveTriggerTypes, 6244 tConfig.templates[ uIndex ].keepAliveParams.trigType); 6245 CuCmd_xtoa_string (&(tConfig.templates[ uIndex ].msgBuffer[ 0 ]), 6246 tConfig.templates[ uIndex ].msgBufferLength, (U8*)&(msgBuffer[ 0 ])); 6247 os_error_printf (CU_MSG_ERROR, (PS8)"%-8d %-8d %-9s %-10d %s\n", uIndex, 6248 tConfig.templates[ uIndex ].keepAliveParams.enaDisFlag, 6249 tKeepAliveTriggerTypes[ uNameIndex ].name, 6250 tConfig.templates[ uIndex ].keepAliveParams.interval, 6251 &(msgBuffer[ 0 ])); 6252 } 6253 else 6254 { 6255 os_error_printf (CU_MSG_ERROR, (PS8)"%-8d %-8d %-9s %-10d %s\n", uIndex, 0, (PS8)"N/A", 0, (PS8)"N/A"); 6256 } 6257 } 6258 } 6259 6260 VOID CuCmd_ShowAbout(THandle hCuCmd, ConParm_t parm[], U16 nParms) 6261 { 6262 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 6263 S8 FwVesrion[FW_VERSION_LEN]; 6264 6265 if(OK != CuCommon_GetBuffer(pCuCmd->hCuCommon, SITE_MGR_FIRMWARE_VERSION_PARAM, 6266 FwVesrion, FW_VERSION_LEN)) return; 6267 6268 #ifdef XCC_MODULE_INCLUDED 6269 os_error_printf(CU_MSG_INFO2, (PS8)"Driver version: %s_XCC\n", 6270 SW_VERSION_STR); 6271 #else 6272 os_error_printf(CU_MSG_INFO2, (PS8)"Driver version: %s_NOCCX\n", 6273 SW_VERSION_STR); 6274 #endif/* XCC_MODULE_INCLUDED*/ 6275 os_error_printf(CU_MSG_INFO2, (PS8)"Firmware version: %s\n", 6276 FwVesrion); 6277 6278 } 6279 6280 VOID CuCmd_Quit(THandle hCuCmd, ConParm_t parm[], U16 nParms) 6281 { 6282 CuCmd_t* pCuCmd = (CuCmd_t*)hCuCmd; 6283 6284 Console_Stop(pCuCmd->hConsole); 6285 } 6286 6287 6288