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