Home | History | Annotate | Download | only in CLI
      1 /*******************************************************************************
      2 **+--------------------------------------------------------------------------+**
      3 **|                                                                          |**
      4 **| Copyright 1998-2008 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 #ifdef _WINDOWS
     22 #endif
     23 
     24 #include <stdio.h>
     25 #include <string.h>
     26 #include <stdlib.h>
     27 #include <ctype.h>
     28 
     29 #ifndef _WINDOWS
     30 	#include <errno.h>
     31 #include <stdio.h>
     32 #include <unistd.h>
     33 #include <termios.h>
     34 #include <sys/socket.h>
     35 #include <linux/if.h>
     36 #include <linux/wireless.h>
     37 
     38 	#include "tnetwCommon.h"
     39 #endif /* __LINUX__ */
     40 
     41 #include "g_tester.h"
     42 #include "wspVer.h"
     43 
     44 #include "paramOut.h"
     45 #include "console.h"
     46 #include "ticon.h"
     47 #include "cu_cmd.h"
     48 #include "linux_ioctl_common.h"
     49 #include "802_11Defs.h"
     50 
     51 #ifndef _T
     52 #define _T(a)    a
     53 #endif
     54 
     55 #ifndef _WINDOWS
     56 TI_HANDLE   g_id_adapter = 0;
     57 #endif
     58 
     59 #define MAX_SSID_LEN 32
     60 #define CLI_NUM_OF_TX_CLASFR_CON 4
     61 
     62 scan_Params_t appScanParams;
     63 scan_Policy_t scanPolicy;
     64 
     65 /*** Roaming Manager configuration parameters ***/
     66 roamingMngrConfigParams_t   roamingMngrConfigParams;
     67 
     68 static tiUINT32 events_mask = 0; // TRS:PGK
     69 
     70 #define NET_BASIC_MASK      0x80    /* defined in common/src/utils/utils.c */
     71 
     72 #define IS_BASIC_RATE(a)    ((a) & NET_BASIC_MASK)
     73 
     74 #define RATE_2_MBPS(a)    ((float)((a) & (NET_BASIC_MASK-1))/2)
     75 
     76 #define GET_NAME_BY_VALUE(arr, value)    get_name_by_value(arr, SIZE_ARR(arr), value)
     77 
     78 #define CHAN_FREQ_TABLE_SIZE        (sizeof(ChanFreq) / sizeof(struct CHAN_FREQ))
     79 
     80 #define RATE_TABLE_SIZE             (sizeof(rate2Str) / sizeof(named_value_t))
     81 
     82 #define ET_TABLE_SIZE               (sizeof(EtEvent2Str) / sizeof(named_value_t))
     83 
     84 /* EarlyTermination DISABLE mode - Should be same as in scan.h */
     85 #define SCAN_ET_COND_DISABLE 0
     86 
     87 #define MAX_PSK_STRING_LENGTH       63
     88 
     89 #define MIN_PSK_STRING_LENGTH       8
     90 
     91 #define PSK_HEXA_LENGTH       64
     92 
     93 #define PSK_BUFF_LEN 65
     94 
     95 static void get_bssid_list(ConParm_t parm[], U16 nParms, BOOL fullBssidList , OS_802_11_BSSID_EX *pBssid);
     96 
     97 static BOOL is_value_rate (tiUINT32 rate)
     98 {
     99 
    100    switch (rate)
    101    {
    102    case 1:
    103    case 2:
    104    case 5:
    105    case 6:
    106    case 9:
    107    case 11:
    108    case 12:
    109    case 18:
    110    case 22:
    111    case 24:
    112    case 36:
    113    case 48:
    114    case 54:
    115       return (TRUE);
    116    default:
    117       return (FALSE);
    118    }
    119 
    120 }
    121 static BOOL is_value_rate (tiUINT32 rate);
    122 struct CHAN_FREQ {
    123     UINT8       chan;
    124     UINT32      freq;
    125 } ChanFreq[] = {
    126     {1,2412000}, {2,2417000}, {3,2422000}, {4,2427000},
    127     {5,2432000}, {6,2437000}, {7,2442000}, {8,2447000},
    128     {9,2452000},
    129     {10,2457000}, {11,2462000}, {12,2467000}, {13,2472000},
    130     {14,2484000}, {36,5180000}, {40,5200000}, {44,5220000},
    131     {48,5240000}, {52,5260000}, {56,5280000}, {60,5300000},
    132     {64,5320000},
    133     {100,5500000}, {104,5520000}, {108,5540000}, {112,5560000},
    134     {116,5580000}, {120,5600000}, {124,5620000}, {128,5640000},
    135     {132,5660000}, {136,5680000}, {140,5700000}, {149,5745000},
    136     {153,5765000}, {157,5785000}, {161,5805000} };
    137 
    138 static named_value_t power_mode_val[] = {
    139         { OS_POWER_MODE_AUTO,        "AUTO" },
    140         { OS_POWER_MODE_ACTIVE,      "ACTIVE" },
    141         { OS_POWER_MODE_SHORT_DOZE,  "SHORT_DOZE" },
    142         { OS_POWER_MODE_LONG_DOZE,   "LONG_DOZE" }
    143 };
    144 
    145 static named_value_t power_level_val[] = {
    146         { OS_POWER_LEVEL_ELP,        "ELP" },
    147         { OS_POWER_LEVEL_PD,      "PD" },
    148         { OS_POWER_LEVEL_AWAKE,  "AWAKE" }
    149 };
    150 
    151 static named_value_t encrypt_type[] = {
    152         { OS_ENCRYPTION_TYPE_NONE,              "None" },
    153         { OS_ENCRYPTION_TYPE_WEP,               "WEP"  },
    154         { OS_ENCRYPTION_TYPE_TKIP,              "TKIP" },
    155         { OS_ENCRYPTION_TYPE_AES,               "AES" }
    156 };
    157 
    158 static named_value_t scanType2Str[] = {
    159         { SCAN_TYPE_NORMAL_PASSIVE,             "Passive Normal Scan"               },
    160         { SCAN_TYPE_NORMAL_ACTIVE,              "Active Normal Scan"                },
    161         { SCAN_TYPE_SPS,                        "Scheduled Passive Scan (SPS)"      },
    162         { SCAN_TYPE_TRIGGERED_PASSIVE,          "Passive Triggered Scan"            },
    163         { SCAN_TYPE_TRIGGERED_ACTIVE,           "Active Triggered Scan"             }
    164 };
    165 
    166 static named_value_t band2Str[] = {
    167         { RADIO_BAND_2_4_GHZ,                   "2.4 GHz"                        },
    168         { RADIO_BAND_5_0_GHZ,                   "5.0 GHz"                        },
    169         { RADIO_BAND_DUAL,                      "Both   "                        }
    170 };
    171 
    172 static named_value_t rate2Str[] = {
    173         { DRV_RATE_MASK_AUTO,                   "Auto    "                          },
    174         { DRV_RATE_MASK_1_BARKER,               "1 Mbps  "                          },
    175         { DRV_RATE_MASK_2_BARKER,               "2 Mbps  "                          },
    176         { DRV_RATE_MASK_5_5_CCK,                "5.5 Mbps"                          },
    177         { DRV_RATE_MASK_11_CCK,                 "11 Mbps "                          },
    178         { DRV_RATE_MASK_22_PBCC,                "22 Mbps "                          },
    179         { DRV_RATE_MASK_6_OFDM,                 "6 Mbps  "                          },
    180         { DRV_RATE_MASK_9_OFDM,                 "9 Mbps  "                          },
    181         { DRV_RATE_MASK_12_OFDM,                "12 Mbps "                          },
    182         { DRV_RATE_MASK_18_OFDM,                "18 Mbps "                          },
    183         { DRV_RATE_MASK_24_OFDM,                "24 Mbps "                          },
    184         { DRV_RATE_MASK_36_OFDM,                "36 Mbps "                          },
    185         { DRV_RATE_MASK_48_OFDM,                "48 Mbps "                          },
    186         { DRV_RATE_MASK_54_OFDM,                "54 Mbps "                          }
    187 };
    188 
    189 static named_value_t EtEvent2Str[] = {
    190         { SCAN_ET_COND_DISABLE,                      "ET disabled  "                     },
    191         { SCAN_ET_COND_BEACON,                       "ET on Beacon "                     },
    192         { SCAN_ET_COND_PROBE_RESP,                   "ET on Prb Rsp"                     },
    193         { SCAN_ET_COND_ANY_FRAME,                    "ET on both   "                     }
    194 };
    195 
    196 /* used in scan_display */
    197 static char* rate2StrFunc(UINT32 rate)
    198 {
    199     UINT32 i;
    200 
    201     for ( i = 0; i < RATE_TABLE_SIZE; i++ )
    202     {
    203         if ( rate2Str[ i ].value == rate )
    204             return rate2Str[ i ].name;
    205     }
    206     return rate2Str[ 0 ].name;
    207 }
    208 
    209 /* used in scan_display */
    210 static char* EtEvent2StrFunc( UINT32 ETCond )
    211 {
    212     int i;
    213 
    214     for ( i = 0; i < ET_TABLE_SIZE; i++ )
    215     {
    216         if ( EtEvent2Str[ i ].value == ETCond )
    217         {
    218             return EtEvent2Str[ i ].name;
    219         }
    220     }
    221 
    222     return EtEvent2Str[ 0 ].name;
    223 }
    224 
    225 /* used in get_bssid_list() */
    226 UINT8 Freq2Chan(UINT32 freq)
    227 {
    228     UINT32 i;
    229 
    230     for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
    231         if(ChanFreq[i].freq == freq) return ChanFreq[i].chan;
    232 
    233     return 0;
    234 }
    235 /* IPC events Callback */
    236 int cli_receive_ev(IPC_EV_DATA*    pData)
    237 {
    238     tiUINT8 *buf;
    239     OS_802_11_QOS_TSPEC_PARAMS *AddTsResult;
    240     OS_802_11_AUTHENTICATION_REQUEST *request;
    241 	OS_802_11_DISASSOCIATE_REASON_T	 *pDisAssoc;
    242     OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *CrossParams;
    243     OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS *TrafficIntensityThresholdParams;
    244 	btCoexStatus_t				*btCoexStatus;
    245 
    246 #if defined (_WINDOWS)
    247 #endif
    248     g_tester_receive_event((tiUINT8)((IPC_EVENT_PARAMS *)pData)->uEventType);
    249 #if defined (_WINDOWS)
    250 #endif
    251 
    252     switch(((IPC_EVENT_PARAMS *)pData)->uEventType)
    253     {
    254         case IPC_EVENT_ASSOCIATED:
    255             console_printf_terminal("CLI Event - Associated\n");
    256 // TRS:HLC
    257 /*
    258 #if defined (_WINDOWS)
    259 #endif
    260 */
    261 //TRS end
    262         break;
    263         case IPC_EVENT_DISASSOCIATED:
    264 			pDisAssoc = (OS_802_11_DISASSOCIATE_REASON_T*)pData->uBuffer;
    265 			switch(pDisAssoc->eDisAssocType)
    266 			{
    267 			case OS_DISASSOC_STATUS_UNSPECIFIED:
    268 				console_printf_terminal("CLI Event - Disassociated with unspecified reason (User/SG/Recovery)\n");
    269 				break;
    270 			case OS_DISASSOC_STATUS_AUTH_REJECT:
    271 				if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
    272 				{
    273 					console_printf_terminal("CLI Event - Disassociated due to no Auth response \n");
    274 				}
    275 				else
    276 				{
    277 					console_printf_terminal("CLI Event - Disassociated due to Auth response packet with reason = %d\n", pDisAssoc->uStatusCode);
    278 				}
    279 				break;
    280 			case OS_DISASSOC_STATUS_ASSOC_REJECT:
    281 				if (pDisAssoc->uStatusCode == STATUS_PACKET_REJ_TIMEOUT)
    282 				{
    283 					console_printf_terminal("CLI Event - Disassociated due to no Assoc response \n");
    284 				}
    285 				else
    286 				{
    287 					console_printf_terminal("CLI Event - Disassociated due to Assoc response packet with reason = %d\n", pDisAssoc->uStatusCode);
    288 				}
    289 			    break;
    290 			case OS_DISASSOC_STATUS_SECURITY_FAILURE:
    291 				console_printf_terminal("CLI Event - Disassociated due to RSN failure\n");
    292 			    break;
    293 			case OS_DISASSOC_STATUS_AP_DEAUTHENTICATE:
    294 				console_printf_terminal("CLI Event - Disassociated due to AP deAuthenticate packet with reason = %d\n", pDisAssoc->uStatusCode);
    295 				break;
    296 			case OS_DISASSOC_STATUS_AP_DISASSOCIATE:
    297 				console_printf_terminal("CLI Event - Disassociated due to AP disAssoc packet with reason = %d\n", pDisAssoc->uStatusCode);
    298 				break;
    299 			case OS_DISASSOC_STATUS_ROAMING_TRIGGER:
    300 				console_printf_terminal("CLI Event - Disassociated due to roaming trigger = %d\n", pDisAssoc->uStatusCode);
    301 				break;
    302 			default:
    303 				console_printf_terminal("CLI Event - Disassociated with unknown reason = %d\n", pDisAssoc->eDisAssocType);
    304 			    break;
    305 			}
    306         break;
    307         case IPC_EVENT_LINK_SPEED:
    308             console_printf_terminal("CLI Event - LinkSpeed\n");
    309         break;
    310         case IPC_EVENT_AUTH_SUCC:
    311             console_printf_terminal("CLI Event - Authentication Success\n");
    312         break;
    313         case IPC_EVENT_SCAN_COMPLETE:
    314             console_printf_terminal("CLI Event - Scan Complete\n");
    315         break;
    316         case IPC_EVENT_TIMEOUT:
    317             console_printf_terminal("CLI Event - Timeout\n");
    318         break;
    319         case IPC_EVENT_UNBOUND:
    320             console_printf_terminal("CLI Event - Unbound\n");
    321         break;
    322         case IPC_EVENT_BOUND:
    323             console_printf_terminal("CLI Event - Bound\n");
    324         break;
    325         case IPC_EVENT_EAPOL:
    326             console_printf_terminal("CLI Event - EAPOL\n");
    327         break;
    328         case IPC_EVENT_MEDIA_SPECIFIC:
    329             buf = pData->uBuffer;
    330             request = (OS_802_11_AUTHENTICATION_REQUEST *) (buf + sizeof(tiUINT32));
    331             if( request->Flags == OS_802_11_REQUEST_PAIRWISE_ERROR ||
    332                 request->Flags == OS_802_11_REQUEST_GROUP_ERROR)
    333             console_printf_terminal("CLI Event - Media_Specific\n");
    334         break;
    335         case IPC_EVENT_CCKM_START:
    336             console_printf_terminal("CLI Event - CCKM_Start\n");
    337         break;
    338 
    339         case IPC_EVENT_PREAUTH_EAPOL:
    340             console_printf_terminal("CLI Event - PreAuth EAPOL\n");
    341             break;
    342 
    343         case IPC_EVENT_LOW_SNR:
    344             console_printf_terminal("CLI Event - Low SNR\n");
    345             break;
    346 
    347         case IPC_EVENT_LOW_RSSI:
    348             console_printf_terminal("CLI Event - Low RSSI\n");
    349             break;
    350 
    351         case IPC_EVENT_EAP_AUTH_FAILURE:
    352             {
    353                 OS_802_11_EAP_TYPES eapType;
    354                 tiINT32             status;
    355                 authStatus_e        eAuthStatusReason;
    356 
    357 				/* Cast the value to be UINT16 16 bits since it is sent this way in the EXCMngr.c */
    358                 eAuthStatusReason = (authStatus_e)((*(pData->uBuffer)) & 0xFFFF);
    359 
    360                 status = TI_GetEAPType( g_id_adapter, &eapType );
    361 
    362                 if (eapType == OS_EAP_TYPE_LEAP)
    363                 {
    364                     console_printf_terminal("CLI Event - LEAP Authentication Failed \n");
    365                 }
    366                 else if (eapType == OS_EAP_TYPE_FAST)
    367                 {
    368                     console_printf_terminal("CLI Event - EAP-FAST Authentication Failed \n");
    369                 }
    370                 else if (eapType == OS_EAP_TYPE_TLS)
    371                 {
    372                     console_printf_terminal("CLI Event - EAP-TLS Authentication Failed \n");
    373                 }
    374 
    375                 switch ( eAuthStatusReason )
    376                 {
    377                 case RSN_AUTH_STATUS_INVALID_TYPE:
    378                     console_printf_terminal("The reason: Invalid Authentication Type \n");
    379                     break;
    380                 case RSN_AUTH_STATUS_TIMEOUT:
    381                     console_printf_terminal("The reason: Authentication Timeout \n");
    382                     break;
    383                 case RSN_AUTH_STATUS_CHALLENGE_FROM_AP_FAILED:
    384                 case RSN_AUTH_STATUS_CHALLENGE_TO_AP_FAILED:
    385                     console_printf_terminal("The reason: username or password incorrect \n");
    386                     break;
    387                 default:
    388                     console_printf_terminal("The reason: unknown = %d \n", eAuthStatusReason);
    389                     break;
    390                 }
    391 
    392             }
    393             break;
    394 
    395         case IPC_EVENT_TSPEC_STATUS:
    396            AddTsResult = (OS_802_11_QOS_TSPEC_PARAMS *)pData->uBuffer;
    397            console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_STATUS -- (userPriority = %d, ReasonCode = %d) \n",AddTsResult->uUserPriority,AddTsResult->uReasonCode);
    398            console_printf_terminal ("Tspec Parameters (as received through event handler):\n");
    399            console_printf_terminal ("-----------------------------------------------------\n");
    400            console_printf_terminal ("userPriority = %d\n",AddTsResult->uUserPriority);
    401            console_printf_terminal ("uNominalMSDUsize = %d\n",AddTsResult->uNominalMSDUsize);
    402            console_printf_terminal ("uMeanDataRate = %d\n",AddTsResult->uMeanDataRate);
    403            console_printf_terminal ("uMinimumPHYRate = %d\n",AddTsResult->uMinimumPHYRate);
    404            console_printf_terminal ("uSurplusBandwidthAllowance = %d\n",AddTsResult->uSurplusBandwidthAllowance);
    405            console_printf_terminal ("uAPSDFlag = %d\n",AddTsResult->uAPSDFlag);
    406            console_printf_terminal ("uMediumTime = %d\n\n",AddTsResult->uMediumTime);
    407            break;
    408         case IPC_EVENT_TSPEC_RATE_STATUS:
    409            CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
    410            console_printf_terminal("CLI Event - IPC_EVENT_TSPEC_RATE_STATUS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
    411            break;
    412         case IPC_EVENT_MEDIUM_TIME_CROSS:
    413            CrossParams = (OS_802_11_THRESHOLD_CROSS_INDICATION_PARAMS *)pData->uBuffer;
    414            console_printf_terminal("CLI Event - IPC_EVENT_MEDIUM_TIME_CROSS (AC = %d, HighLowFlag = %d, AboveOrBelow = %d)\n",CrossParams->uAC,CrossParams->uHighOrLowThresholdFlag,CrossParams->uAboveOrBelowFlag);
    415            break;
    416         case IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED:
    417            TrafficIntensityThresholdParams = (OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_CROSS_INDICATION_PARAMS*)pData->uBuffer;
    418            printf("CLI Event - IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED\n");
    419            printf("---------------------------------------------------------\n");
    420            printf("Threshold crossed: %s Threshold\n", ((TrafficIntensityThresholdParams->uHighOrLowThresholdFlag == HIGH_THRESHOLD_CROSS) ? "High" : "Low"));
    421            printf("Direction crossed: %s\n\n", ((TrafficIntensityThresholdParams->uAboveOrBelowFlag == CROSS_ABOVE) ? "Above" : "Below"));
    422            break;
    423 
    424         case IPC_EVENT_WPA2_PREAUTHENTICATION:
    425             {
    426                 ULONG *WPA2_PreAuth_Status;
    427 
    428                WPA2_PreAuth_Status = (ULONG *)pData->uBuffer;
    429                printf("CLI Event - IPC_EVENT_WPA2_PREAUTHENTICATION\n");
    430                printf("Status code = %lu\n",*WPA2_PreAuth_Status);
    431             }
    432            break;
    433 
    434         case IPC_EVENT_ROAMING_COMPLETE:
    435             printf("CLI Event - IPC_EVENT_ROAMING_COMPLETE \n");
    436         break;
    437 
    438 	case IPC_EVENT_BT_COEX_MODE:
    439 		btCoexStatus = (btCoexStatus_t*)pData->uBuffer;
    440 		if (btCoexStatus->state)
    441 		{
    442 			console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is ON, minTxRate = %d)\n",btCoexStatus->minTxRate);
    443 		}
    444 		else
    445 		{
    446 			console_printf_terminal("CLI Event - IPC_EVENT_BT_COEX_MODE (SG is OFF)\n");
    447 		}
    448 		break;
    449 
    450         default:
    451             console_printf_terminal("CLI Event - Unknown event\n");
    452         break;
    453     }
    454     return 0;
    455 
    456 
    457 }
    458 
    459 static char *print_rate(rate_e rate)
    460 {
    461     static char buf[20];
    462 
    463     if( rate == 0 )
    464         return "Auto (0)";
    465 
    466     sprintf(buf, "%.3g Mbps (%u%s)", RATE_2_MBPS(rate), rate,
    467         IS_BASIC_RATE(rate) ? " - basic" : "" );
    468     return buf;
    469 }
    470 
    471 static BOOL isJunkSSID(OS_802_11_SSID *ssid )
    472 {
    473     if ((ssid == NULL) || (ssid->SsidLength == 0))
    474     {
    475         return TRUE;
    476     }
    477 
    478     if (ssid->SsidLength > 2)
    479     {
    480         if ((ssid->Ssid[0] < MAX_SSID_LEN) &&
    481             (ssid->Ssid[1] < MAX_SSID_LEN) &&
    482             (ssid->Ssid[2] < MAX_SSID_LEN))
    483         {
    484             return TRUE;
    485         }
    486     }
    487 
    488     return FALSE;
    489 }
    490 
    491 static char *get_ssid_string(OS_802_11_SSID *ssid )
    492 {
    493     static char tmp_buf[MAX_SSID_LEN+1];
    494     if ((ssid == NULL) || (ssid->SsidLength == 0) || isJunkSSID(ssid))
    495         return "<empty>";
    496 
    497     if (ssid->SsidLength < SIZE_ARR(ssid->Ssid))
    498            ssid->Ssid[ssid->SsidLength] = 0;
    499     else if( ssid->SsidLength == MAX_SSID_LEN )
    500     {
    501         memcpy(tmp_buf, ssid->Ssid, MAX_SSID_LEN );
    502         tmp_buf[MAX_SSID_LEN] = 0;
    503         return tmp_buf;
    504     }
    505     else
    506     {
    507         console_printf_terminal("error: invalid ssid length (len = %u)\n", ssid->SsidLength );
    508         return "<error>";
    509     }
    510     return (char *) ssid->Ssid;
    511 }
    512 /*  return 0 on error
    513     or 'mac' if success
    514     'str' format: num.num.num.num.num.num (where 'num' is number from 0 to 255)
    515 */
    516 U8* str2MACAddr(char *str, U8 *mac)
    517 {
    518     const int mac_len = 6;
    519     int i;
    520     char *p = str;
    521 #ifndef _WINDOWS
    522     errno = 0;
    523 #endif
    524     console_printf_terminal("str2MAC():");
    525     for( i=0; i<mac_len; i++ )
    526     {
    527         mac[i] = (U8) strtoul(p, &p, 16);
    528 #ifndef _WINDOWS
    529         if( errno == ERANGE )
    530             return NULL;
    531 #endif
    532         console_printf_terminal("%2x.", mac[i] );
    533         p++;
    534 
    535     }
    536     console_printf_terminal("\n");
    537     return mac;
    538 }
    539 
    540 static char * print_mac_2_str(OS_802_11_MAC_ADDRESS mac)
    541 {
    542     static char buf[30];
    543 
    544     sprintf(buf, "%02x.%02x.%02x.%02x.%02x.%02x",
    545                 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
    546 
    547     return buf;
    548 }
    549 
    550 /* convert hex MAC addr in the form xx:xx:xx:xx:xx:xx to mac address */
    551 static void hexStr2MACAddr( char *hexStr, macAddress_t* mac )
    552 {
    553     size_t i;
    554     char *currHexStrPos = hexStr;
    555     UINT8 tempValue;
    556 
    557     /* convert hex string to lower */
    558     for ( i = 0; i < strlen(hexStr); i++ )
    559     {
    560         hexStr[ i ] = tolower( hexStr[ i ] );
    561     }
    562 
    563     /* convert to numbers */
    564     for ( i = 0; i < 6; i++ )
    565     {
    566         tempValue = 0;
    567         if ( *currHexStrPos >= 'a' )
    568             tempValue = *currHexStrPos - 'a' + 10;
    569         else
    570             tempValue = *currHexStrPos - '0';
    571         currHexStrPos++;
    572         tempValue <<= 4;
    573         if ( *currHexStrPos >= 'a' )
    574             tempValue += *currHexStrPos - 'a' + 10;
    575         else
    576             tempValue += *currHexStrPos - '0';
    577         currHexStrPos += 2;
    578         mac->addr[ i ] = tempValue;
    579     }
    580 }
    581 
    582 static void mac2HexStr( macAddress_t* mac, char* hexStr )
    583 {
    584     sprintf( hexStr, "%02x:%02x:%02x:%02x:%02x:%02x",
    585         mac->addr[0],mac->addr[1],mac->addr[2],mac->addr[3],mac->addr[4],mac->addr[5]);
    586 }
    587 
    588 char *get_name_by_value(named_value_t *arr, int arr_size, UINT32 value)
    589 {
    590     int i;
    591     for(i=0; i<arr_size; i++) {
    592         if( arr[i].value == value )
    593             return arr[i].name;
    594     }
    595     return "<unknow>";
    596 }
    597 
    598 void cmd_modify_supported_rates(ConParm_t parm[], U16 nParms)
    599 {
    600     rates_t data = { 0 };
    601     char debug_buf[256] = { 0 };
    602     int i;
    603 
    604     if( nParms == 0 )
    605     {
    606         if( !TI_GetSupportedRates(g_id_adapter, (tiUINT8*)&data, sizeof(data)) )
    607         {
    608             console_printf_terminal(" Rates: ");
    609             for( i=0; i<MAX_SUPPORTED_RATES && i < data.len; i++ )
    610             {
    611                 console_printf_terminal("%g Mbps(%u%s)%s", RATE_2_MBPS(data.ratesString[i]),
    612                     data.ratesString[i],
    613                     IS_BASIC_RATE(data.ratesString[i]) ? " - basic" : "",
    614                     (i < data.len-1) ? "," : "" );
    615             }
    616             console_printf_terminal("\n");
    617         }
    618     }
    619     else
    620     {
    621         char *end_p, *buf = (char *) parm[0].value;
    622         float val;
    623         console_printf_terminal("param: %s\n", buf );
    624 #ifndef _WINDOWS
    625         errno = 0;
    626 #endif
    627         for( i=0; *buf && i < MAX_SUPPORTED_RATES; i++ )
    628         {
    629             val = (float) strtod(buf, &end_p);
    630             if(
    631 #ifndef _WINDOWS
    632 			   errno ||
    633 #endif
    634 			   buf == end_p )
    635             {
    636                 console_printf_terminal("cmd_modify_supported_rates(): invalid value - %s\n", buf );
    637                 return;
    638             }
    639             if( val > ((1 << (sizeof(data.ratesString[i]) * 8))-1) )
    640             {
    641                 console_printf_terminal("cmd_modify_supported_rates(): out of range '%.*s'\n", end_p - buf, buf );
    642                 return;
    643             }
    644             data.ratesString[i] = (tiUINT8) (val);
    645 
    646             sprintf(&debug_buf[strlen(debug_buf)], "%g (%d) ", val, data.ratesString[i] );
    647 
    648             buf = end_p;
    649             while( *buf==' ' || *buf == ',' )   buf++;
    650 
    651         }
    652 
    653         if( *buf )
    654         {
    655             console_printf_terminal("too many parameters. Max=%d\n", MAX_SUPPORTED_RATES );
    656             return;
    657         }
    658 
    659         data.len = i;
    660         console_printf_terminal("**set rates (%d) :%s\n", data.len, debug_buf );
    661         TI_SetSupportedRates(g_id_adapter, (tiUINT8*) &data, sizeof(data));
    662     }
    663 }
    664 
    665 void cmd_show_status(ConParm_t parm[], U16 nParms)
    666 {
    667     tiINT32 res;
    668     OS_802_11_BSSID_EX BssIdInfo;
    669 
    670     tiUINT32 data;
    671     char buf[4096] = { 0 };
    672     OS_802_11_SSID ssid = { 0 };
    673     OS_802_11_MAC_ADDRESS bssid = { 0 };
    674 
    675     UNUSED(parm);
    676     UNUSED(nParms);
    677 
    678     buf[0] = 0;
    679 
    680     res = TI_WLAN_IsDriverRun(g_id_adapter, (tiBOOL *)&data);
    681     if( res )
    682         return ;
    683 
    684     sprintf(buf, "Status   : %s\n", res ? "<error>" : (data ? "running" : "stopped") );
    685 
    686     sprintf(&buf[strlen(buf)], "MAC      : ");
    687     if( !TI_GetCurrentAddress(g_id_adapter, &bssid ) )
    688         strcat(buf, print_mac_2_str(bssid) );
    689     else
    690         strcat(buf, "<error>");
    691 
    692     strcat(buf, "\nSSID     : ");
    693     if( !TI_GetCurrentSSID(g_id_adapter, &ssid) )
    694     {
    695         if (!isJunkSSID(&ssid))
    696         {
    697            strncat(buf, get_ssid_string(&ssid),ssid.SsidLength);
    698         }
    699         else
    700         {
    701            strcat(buf,"<empty>");
    702         }
    703     }
    704     else
    705         strcat(buf, "<error>" );
    706 
    707     sprintf(&buf[strlen(buf)], "\nBSSID    : ");
    708 
    709    TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
    710    strcat(buf, print_mac_2_str(BssIdInfo.MacAddress));
    711 
    712     strcat(buf, "\nChannel  : ");
    713     data = 0;
    714     if( !TI_GetCurrentChannel(g_id_adapter, &data ) )
    715     {
    716         sprintf(&buf[strlen(buf)], "%d", data );
    717     }
    718     else
    719         strcat(buf, "<error>");
    720 
    721     console_printf_terminal("==========================\n%s\n==========================\n\n", buf);
    722 }
    723 
    724 void cmd_connect(ConParm_t parm[], U16 nParms)
    725 {
    726     char buf[1] = { 0 };
    727     OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
    728 
    729     buf[0] = 0;
    730 
    731     switch (nParms) {
    732 
    733     case 0 :
    734         /*
    735          *  No SSID & No BSSID are set -
    736          *  Use Any SSID & Any BSSID.
    737          */
    738 
    739         TI_SetBSSID(g_id_adapter, &bssid );
    740         TI_SetSSID(g_id_adapter, (tiUINT8 *) buf);
    741         break;
    742 
    743     case 1:
    744         /*
    745          *  SSID set & BSSID insn't set  -
    746          *  Use CLI's SSID & Any BSSID.
    747          */
    748         TI_SetBSSID(g_id_adapter, &bssid );
    749         TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
    750         break;
    751 
    752     case 2:
    753         /*
    754          *  Both SSID & BSSID are set -
    755          *  Use CLI's SSID & BSSID.
    756          */
    757         if( !str2MACAddr((char *) parm[1].value, bssid) )
    758             return;
    759         TI_SetBSSID(g_id_adapter, &bssid);
    760         TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
    761         break;
    762 }
    763 }
    764 
    765 
    766 void cmd_disassociate(ConParm_t parm[], U16 nParms)
    767 {
    768     UNUSED(parm);
    769     UNUSED(nParms);
    770 
    771     TI_Disassociate(g_id_adapter);
    772 }
    773 
    774 void cmd_show_advanced_params(ConParm_t parm[], U16 nParms)
    775 {
    776     tiUINT32 mode_4x = 0, preamble = 0xfefefefe;
    777     OS_802_11_AUTHENTICATION_MODE auth;
    778     OS_802_11_ENCRYPTION_TYPES encrypt;
    779     tiUINT32    rts_tresh;
    780     tiUINT32    frag_tresh = 0xfefefefe;
    781     tiUINT8     tx_power = 0xfe;
    782     OS_802_11_POWER_PROFILE power_mode = 0;
    783 
    784     UNUSED(parm);
    785     UNUSED(nParms);
    786 
    787     TI_GetAuthenticationMode(g_id_adapter, &auth );
    788     TI_GetTxPowerDbm(g_id_adapter, (tiCHAR*) &tx_power);
    789     TI_GetFragmentThreshold( g_id_adapter, &frag_tresh);
    790     TI_GetRTSThreshold( g_id_adapter, &rts_tresh);
    791     TI_Get4XState( g_id_adapter, &mode_4x);
    792     TI_GetEncryptionType( g_id_adapter, &encrypt );
    793     TI_GetPowerMode(g_id_adapter, (OS_802_11_POWER_PROFILE*) &power_mode );
    794     console_printf_terminal("  Authentication : %u\n", auth );
    795     console_printf_terminal("      Power mode : %d\n", (tiUINT32) power_mode );
    796     console_printf_terminal("  Tx Power (Dbm/10 units) : %d\n", tx_power );
    797 
    798     console_printf_terminal("      Encryption : %u\n", encrypt );
    799     console_printf_terminal("        Preamble : <%s>\n", (preamble) ? "short" : "long");
    800 /*    console_printf_terminal("      Tx antenna : %u\n", tx_ant );*/
    801 /*    console_printf_terminal(  "      Rx antenna : %u\n", rx_ant );*/
    802 /*    console_printf_terminal(  "Ap Tx power level: n/a\n" );*/
    803 /*    console_printf_terminal(  "  Tx power value : %lu\n", tx_power_val );*/
    804 /*    console_printf_terminal(  "     MAC address : n/a\n" );*/
    805     console_printf_terminal(  "        4X state : %d\n", mode_4x );
    806 /*     console_printf_terminal(  "        B/G mode : n/a\n" );*/
    807 /*     console_printf_terminal(  "    Country code : n/a\n" );*/
    808 /*     console_printf_terminal(  "      IP address : n/a\n" );*/
    809 /*     console_printf_terminal(  "        Net mask : n/a\n" );*/
    810 /*     console_printf_terminal(  "         Gateway : n/a\n" );*/
    811     console_printf_terminal(  " Frag. threshold : %u\n", frag_tresh);
    812     console_printf_terminal(  "   RTS threshold : %u\n", rts_tresh );
    813 
    814     console_printf_terminal(  "Power mode: ");
    815     print_available_values(power_mode_val);
    816 
    817     console_printf_terminal(  "Encryption type: ");
    818     print_available_values(encrypt_type);
    819 }
    820 
    821 void cmd_show_statistics(ConParm_t parm[], U16 nParms)
    822 {
    823     TIWLN_STATISTICS statistics = { 0 } ;
    824 
    825     UNUSED(parm);
    826     UNUSED(nParms);
    827 
    828     console_printf_terminal(  "TI_GetStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
    829 
    830     if( TI_GetStatistics( g_id_adapter, &statistics ) )
    831     {
    832         console_printf_terminal ("Error in getting TI_GetStatistics!!\n");
    833         return;
    834     }
    835 
    836     console_printf_terminal("******************\n");
    837     console_printf_terminal("Driver Statistics:\n");
    838     console_printf_terminal("******************\n");
    839 
    840     console_printf_terminal("    dot11CurrentTxRate : %s\n", print_rate(statistics.dot11CurrentTxRate) );
    841     console_printf_terminal("   dot11CurrentChannel : %d\n", statistics.dot11CurrentChannel );
    842     console_printf_terminal("     currentMACAddress : %s\n", print_mac_2_str(statistics.currentMACAddress) );
    843     console_printf_terminal("      dot11DesiredSSID : %s\n", get_ssid_string(&statistics.dot11DesiredSSID) );
    844     console_printf_terminal("          dot11BSSType : %d\n", statistics.dot11BSSType );
    845     console_printf_terminal("    AuthenticationMode : %d\n", statistics.AuthenticationMode );
    846     console_printf_terminal("    bShortPreambleUsed : %d\n", statistics.bShortPreambleUsed );
    847     console_printf_terminal("          RTSThreshold : %d\n", statistics.RTSThreshold );
    848     console_printf_terminal("FragmentationThreshold : %d\n", statistics.FragmentationThreshold );
    849     console_printf_terminal(" bDefaultWEPKeyDefined : %d\n", statistics.bDefaultWEPKeyDefined );
    850     console_printf_terminal("             WEPStatus : %d\n", statistics.WEPStatus );
    851     console_printf_terminal("             TxAntenna : %d\n", statistics.TxAntenna );
    852     console_printf_terminal("             RxAntenna : %d\n", statistics.RxAntenna );
    853     console_printf_terminal("            TxPowerDbm : %d\n", statistics.TxPowerDbm );
    854     console_printf_terminal("             PowerMode : %d\n", statistics.PowerMode );
    855     console_printf_terminal("               RxLevel : %d\n", statistics.RxLevel );
    856 
    857     /**/
    858     /* status & AP info*/
    859     /**/
    860     console_printf_terminal("            dot11State : %d\n", statistics.dot11State );
    861 
    862     /**/
    863     /* network layer statistics*/
    864     /**/
    865     console_printf_terminal("                RecvOk : %d\n", statistics.tiCounters.RecvOk );
    866     console_printf_terminal("             RecvError : %d\n", statistics.tiCounters.RecvError );
    867     console_printf_terminal("     DirectedBytesRecv : %d\n", statistics.tiCounters.DirectedBytesRecv );
    868     console_printf_terminal("    DirectedFramesRecv : %d\n", statistics.tiCounters.DirectedFramesRecv );
    869     console_printf_terminal("    MulticastBytesRecv : %d\n", statistics.tiCounters.MulticastBytesRecv );
    870     console_printf_terminal("   MulticastFramesRecv : %d\n", statistics.tiCounters.MulticastFramesRecv );
    871     console_printf_terminal("    BroadcastBytesRecv : %d\n", statistics.tiCounters.BroadcastBytesRecv );
    872     console_printf_terminal("   BroadcastFramesRecv : %d\n", statistics.tiCounters.BroadcastFramesRecv );
    873     console_printf_terminal("             FcsErrors : %d\n", statistics.tiCounters.FcsErrors );
    874     console_printf_terminal("           BeaconsRecv : %d\n", statistics.tiCounters.BeaconsRecv );
    875     console_printf_terminal("          AssocRejects : %d\n", statistics.tiCounters.AssocRejects );
    876     console_printf_terminal("         AssocTimeouts : %d\n", statistics.tiCounters.AssocTimeouts );
    877     console_printf_terminal("           AuthRejects : %d\n", statistics.tiCounters.AuthRejects );
    878     console_printf_terminal("          AuthTimeouts : %d\n", statistics.tiCounters.AuthTimeouts );
    879 
    880     /**/
    881     /* other statistics*/
    882     /**/
    883     console_printf_terminal("        dwSecuritySuit : %d\n", statistics.dwSecuritySuit );
    884     console_printf_terminal("       dwSecurityState : %d\n", statistics.dwSecurityState );
    885     console_printf_terminal("  dwSecurityAuthStatus : %d\n", statistics.dwSecurityAuthStatus );
    886     console_printf_terminal("         dwFeatureSuit : %d\n", statistics.dwFeatureSuit );
    887 }
    888 
    889 void cmd_show_tx_statistics(ConParm_t parm[], U16 nParms)
    890 {
    891     TIWLN_TX_STATISTICS statistics;
    892     UINT32 TxQid;
    893     UINT32 AverageDelay;
    894     UINT32 AverageFWDelay;
    895     UINT32 AverageMacDelay;
    896     tiINT32 status;
    897 
    898     UNUSED(parm);
    899     UNUSED(nParms);
    900 
    901     console_printf_terminal("TI_GetTxStatistics(%s, data=%p, size=%d\n", (char*) g_id_adapter, &statistics, sizeof(statistics) );
    902 
    903     /* The first parameter indicates whether to clear the statistics on read: 0 - don't clear, 1 - clear */
    904     if ( 0 == nParms )
    905     {
    906         status = TI_GetTxStatistics( g_id_adapter, &statistics, 0 );
    907     }
    908     else
    909     {
    910         status = TI_GetTxStatistics( g_id_adapter, &statistics, parm[0].value );
    911     }
    912 
    913     if( status )
    914     {
    915         console_printf_terminal ("Error in getting TI_GetTxStatistics!!\n");
    916         return;
    917     }
    918 
    919     console_printf_terminal("*********************\n");
    920     console_printf_terminal("Tx Queues Statistics:\n");
    921     console_printf_terminal("*********************\n");
    922 
    923     for (TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
    924     {
    925         console_printf_terminal("\nTx Queue %d:\n", TxQid);
    926         console_printf_terminal("===========\n");
    927 
    928         console_printf_terminal("  Total Good Frames             : %d\n", statistics.txCounters[TxQid].XmitOk );
    929         console_printf_terminal("  Unicast Bytes                 : %d\n", statistics.txCounters[TxQid].DirectedBytesXmit );
    930         console_printf_terminal("  Unicast Frames                : %d\n", statistics.txCounters[TxQid].DirectedFramesXmit );
    931         console_printf_terminal("  Multicast Bytes               : %d\n", statistics.txCounters[TxQid].MulticastBytesXmit );
    932         console_printf_terminal("  Multicast Frames              : %d\n", statistics.txCounters[TxQid].MulticastFramesXmit );
    933         console_printf_terminal("  Broadcast Bytes               : %d\n", statistics.txCounters[TxQid].BroadcastBytesXmit );
    934         console_printf_terminal("  Broadcast Frames              : %d\n", statistics.txCounters[TxQid].BroadcastFramesXmit );
    935         console_printf_terminal("  Retry Failures                : %d\n", statistics.txCounters[TxQid].RetryFailCounter );
    936         console_printf_terminal("  Tx Timeout Failures           : %d\n", statistics.txCounters[TxQid].TxTimeoutCounter );
    937         console_printf_terminal("  No Link Failures              : %d\n", statistics.txCounters[TxQid].NoLinkCounter );
    938         console_printf_terminal("  Other Failures                : %d\n", statistics.txCounters[TxQid].OtherFailCounter );
    939         console_printf_terminal("  Max Consecutive Retry Failures : %d\n\n", statistics.txCounters[TxQid].MaxConsecutiveRetryFail );
    940 
    941         console_printf_terminal("  Retry histogram:\n");
    942         console_printf_terminal("  ----------------\n\n");
    943         console_printf_terminal("  Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 0, 1, 2, 3, 4, 5, 6, 7);
    944         console_printf_terminal("  packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
    945                                 statistics.txCounters[TxQid].RetryHistogram[ 0 ],
    946                                 statistics.txCounters[TxQid].RetryHistogram[ 1 ],
    947                                 statistics.txCounters[TxQid].RetryHistogram[ 2 ],
    948                                 statistics.txCounters[TxQid].RetryHistogram[ 3 ],
    949                                 statistics.txCounters[TxQid].RetryHistogram[ 4 ],
    950                                 statistics.txCounters[TxQid].RetryHistogram[ 5 ],
    951                                 statistics.txCounters[TxQid].RetryHistogram[ 6 ],
    952                                 statistics.txCounters[TxQid].RetryHistogram[ 7 ]);
    953         console_printf_terminal("  Retries: %8d %8d %8d %8d %8d %8d %8d %8d\n", 8, 9, 10, 11, 12, 13, 14, 15);
    954         console_printf_terminal("  packets: %8d %8d %8d %8d %8d %8d %8d %8d\n\n",
    955                                 statistics.txCounters[TxQid].RetryHistogram[ 8 ],
    956                                 statistics.txCounters[TxQid].RetryHistogram[ 9 ],
    957                                 statistics.txCounters[TxQid].RetryHistogram[ 10 ],
    958                                 statistics.txCounters[TxQid].RetryHistogram[ 11 ],
    959                                 statistics.txCounters[TxQid].RetryHistogram[ 12 ],
    960                                 statistics.txCounters[TxQid].RetryHistogram[ 13 ],
    961                                 statistics.txCounters[TxQid].RetryHistogram[ 14 ],
    962                                 statistics.txCounters[TxQid].RetryHistogram[ 15 ]);
    963 
    964         if (statistics.txCounters[TxQid].NumPackets)
    965         {
    966             AverageDelay = statistics.txCounters[TxQid].SumTotalDelayMs / statistics.txCounters[TxQid].NumPackets;
    967             AverageFWDelay = statistics.txCounters[TxQid].SumFWDelayUs / statistics.txCounters[TxQid].NumPackets;
    968             AverageMacDelay = statistics.txCounters[TxQid].SumMacDelayUs / statistics.txCounters[TxQid].NumPackets;
    969         }
    970         else
    971         {
    972             AverageDelay = 0;
    973             AverageFWDelay = 0;
    974             AverageMacDelay = 0;
    975         }
    976 
    977         console_printf_terminal("  Total Delay ms (average/sum) : %d / %d\n", AverageDelay, statistics.txCounters[TxQid].SumTotalDelayMs);
    978         console_printf_terminal("  FW Delay us (average/sum) : %d / %d\n", AverageFWDelay, statistics.txCounters[TxQid].SumFWDelayUs);
    979         console_printf_terminal("  MAC Delay us (average/sum)   : %d / %d\n\n", AverageMacDelay, statistics.txCounters[TxQid].SumMacDelayUs);
    980 
    981         console_printf_terminal("  Delay Ranges [msec]  : Num of packets\n");
    982         console_printf_terminal("  -------------------  : --------------\n");
    983         console_printf_terminal("        0   -    1     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_0_TO_1] );
    984         console_printf_terminal("        1   -   10     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_1_TO_10] );
    985         console_printf_terminal("       10   -   20     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_10_TO_20] );
    986         console_printf_terminal("       20   -   40     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_20_TO_40] );
    987         console_printf_terminal("       40   -   60     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_40_TO_60] );
    988         console_printf_terminal("       60   -   80     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_60_TO_80] );
    989         console_printf_terminal("       80   -  100     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_80_TO_100] );
    990         console_printf_terminal("      100   -  200     : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_100_TO_200] );
    991         console_printf_terminal("        Above 200      : %d\n", statistics.txCounters[TxQid].txDelayHistogram[TX_DELAY_RANGE_ABOVE_200] );
    992     }
    993 }
    994 
    995 void cmd_show_about(ConParm_t parm[], U16 nParms)
    996 {
    997     TIWLN_VERSION_EX data;
    998 
    999     UNUSED(parm);
   1000     UNUSED(nParms);
   1001 
   1002     console_printf_terminal("Utility version: %s (%u.%u.%u)\n", SW_VERSION_STR, SW_RELEASE_DAY,
   1003             SW_RELEASE_MONTH, SW_RELEASE_YEAR );
   1004     if( TI_GetDriverVersion(g_id_adapter, &data ) )
   1005         return ;
   1006 
   1007     console_printf_terminal("Driver version: %u.%u.%u.%u.%u\n", data.DrvVersion.major, data.DrvVersion.minor,
   1008             data.DrvVersion.bugfix, data.DrvVersion.subld, data.DrvVersion.build );
   1009     console_printf_terminal("Firmware version: %u.%u.%u.%u.%u\n", data.FWVersion.major, data.FWVersion.minor,
   1010             data.FWVersion.bugfix, data.FWVersion.subld, data.FWVersion.build );
   1011     console_printf_terminal("Eeprom Version: %u.%u.%u.%u.%u\n", data.HWVersion.major, data.HWVersion.minor,
   1012             data.HWVersion.bugfix, data.HWVersion.subld, data.HWVersion.build );
   1013     console_printf_terminal("Eeprom Version2: %u.%u.%u.%u.%u\n", data.NVVersion.major, data.NVVersion.minor,
   1014             data.NVVersion.bugfix, data.NVVersion.subld, data.HWVersion.build );
   1015 }
   1016 
   1017 void cmd_modify_ssid(ConParm_t parm[], U16 nParms)
   1018 {
   1019     OS_802_11_SSID ssid = { 0 };
   1020     OS_802_11_MAC_ADDRESS bssid = { 0xff,0xff,0xff,0xff,0xff,0xff };
   1021     char *ssid_str;
   1022 
   1023     if( nParms == 0 )
   1024     {
   1025         if(!TI_GetCurrentSSID(g_id_adapter, &ssid))
   1026             ssid_str = get_ssid_string(&ssid);
   1027         else
   1028             ssid_str = "<error>";
   1029         console_printf_terminal("SSID: %s\n",  ssid_str );
   1030     }
   1031     else{
   1032         /* Setting the new SSID, BRCS BSSID is set to clean pre-set BSSID */
   1033         TI_SetBSSID(g_id_adapter, &bssid );
   1034         TI_SetSSID(g_id_adapter, (tiUINT8 *) parm[0].value);
   1035 }
   1036 }
   1037 
   1038 void cmd_modify_channel(ConParm_t parm[], U16 nParms)
   1039 {
   1040     if( nParms == 0 )
   1041     {
   1042         tiUINT32 data1 = 0, data = 0;
   1043         if( !TI_GetDesiredChannel( g_id_adapter, &data1) )
   1044             console_printf_terminal("Channel=%d (desired: %d)\n", !TI_GetCurrentChannel(g_id_adapter, &data) ? data : -1, data1 );
   1045     }
   1046     else
   1047         TI_SetDesiredChannel( g_id_adapter, parm[0].value );
   1048 }
   1049 
   1050 void cmd_set_power_mode(ConParm_t parm[], U16 nParms)
   1051 {
   1052     OS_802_11_POWER_PROFILE mode = 0x12345678;
   1053     if( nParms )
   1054         TI_ConfigPowerManagement (g_id_adapter, parm[0].value );
   1055     else
   1056     {
   1057         if( !TI_GetPowerMode(g_id_adapter, &mode ) )
   1058         {
   1059             console_printf_terminal("Power mode: %d\n", mode );
   1060             print_available_values(power_mode_val);
   1061         }
   1062     }
   1063 }
   1064 
   1065 void cmd_set_PowerSave_PowerLevel(ConParm_t parm[], U16 nParms)
   1066 {
   1067     OS_802_11_POWER_LEVELS mode;
   1068     if( nParms )
   1069         TI_SetPowerLevelPS (g_id_adapter, parm[0].value );
   1070     else
   1071     {
   1072         if( !TI_GetPowerLevelPS(g_id_adapter, &mode ) )
   1073         {
   1074             console_printf_terminal("Power Level PowerSave: %d\n", mode );
   1075             print_available_values(power_level_val);
   1076         }
   1077     }
   1078 }
   1079 
   1080 void cmd_set_Default_PowerLevel(ConParm_t parm[], U16 nParms)
   1081 {
   1082     OS_802_11_POWER_LEVELS mode;
   1083     if( nParms )
   1084         TI_SetPowerLevelDefault (g_id_adapter, parm[0].value );
   1085     else
   1086     {
   1087         if( !TI_GetPowerLevelDefault(g_id_adapter, &mode ) )
   1088         {
   1089             console_printf_terminal("Default Power Level: %d\n", mode );
   1090             print_available_values(power_level_val);
   1091         }
   1092     }
   1093 }
   1094 
   1095 void cmd_set_DozeModeInAutoPowerLevel(ConParm_t parm[], U16 nParms)
   1096 {
   1097 	OS_802_11_POWER_PROFILE mode;
   1098     if( nParms )
   1099         TI_SetPowerLevelDozeMode (g_id_adapter, parm[0].value );
   1100     else
   1101     {
   1102 		/* set Short or Long Doze. no use of other parameters */
   1103         if( !TI_GetPowerLevelDozeMode(g_id_adapter,&mode ) )
   1104         {
   1105             console_printf_terminal("Doze Mode in Auto Power Level: SHORT_DOZE -  %d LONG_DOZE - %d\n",
   1106 				OS_POWER_MODE_SHORT_DOZE,OS_POWER_MODE_LONG_DOZE);
   1107         }
   1108     }
   1109 }
   1110 
   1111 
   1112 void cmd_Beacon_Filter_Set_Desired_State(ConParm_t parm[], U16 nParms)
   1113 {
   1114     /*there are two modes : feature ACTIVE & PASSIV ( or NOT ACTIVE )*/
   1115     if( nParms )
   1116     {
   1117         TI_SetBeaconFilterDesiredState(g_id_adapter, parm[0].value );
   1118     }
   1119     else
   1120     {
   1121         console_printf_terminal("Use : 0 =  INACTIVE , 1 = ACTIVE\n" ) ;
   1122 
   1123     }
   1124 }
   1125 
   1126 void cmd_Beacon_Filter_Get_Desired_State(ConParm_t parm[], U16 nParms)
   1127 {
   1128     UINT8 desState = FALSE ;
   1129 
   1130     TI_GetBeaconFilterDesiredState(g_id_adapter, &desState ) ;
   1131     console_printf_terminal("Desired State is %s\n", (desState == FALSE)?"FILTER INACTIVE":"FILTER ACTIVE" );
   1132 
   1133 
   1134 }
   1135 
   1136 
   1137 
   1138 /* scan commands (new from eSTAdk 5.0) */
   1139 
   1140 void init_scan_params(void)
   1141 {
   1142     int i,j;
   1143 
   1144     /* init application scan default params */
   1145     appScanParams.desiredSsid.len = 0;
   1146     appScanParams.scanType = SCAN_TYPE_NORMAL_ACTIVE;
   1147     appScanParams.band = RADIO_BAND_2_4_GHZ;
   1148     appScanParams.probeReqNumber = 3;
   1149     appScanParams.probeRequestRate = DRV_RATE_MASK_2_BARKER;
   1150     appScanParams.numOfChannels = 11;
   1151     for ( i = 0; i < 11; i++ )
   1152     {
   1153         for ( j = 0; j < 6; j++ )
   1154         {
   1155             appScanParams.channelEntry[ i ].normalChannelEntry.bssId.addr[ j ] = 0xff;
   1156         }
   1157         appScanParams.channelEntry[ i ].normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
   1158         appScanParams.channelEntry[ i ].normalChannelEntry.ETMaxNumOfAPframes = 0;
   1159         appScanParams.channelEntry[ i ].normalChannelEntry.maxChannelDwellTime = 60000;
   1160         appScanParams.channelEntry[ i ].normalChannelEntry.minChannelDwellTime = 30000;
   1161         appScanParams.channelEntry[ i ].normalChannelEntry.txPowerDbm = MAX_TX_POWER;
   1162         appScanParams.channelEntry[ i ].normalChannelEntry.channel = i + 1;
   1163     }
   1164 
   1165     /* init default scan policy */
   1166     scanPolicy.normalScanInterval = 10000;
   1167     scanPolicy.deterioratingScanInterval = 5000;
   1168     scanPolicy.maxTrackFailures = 3;
   1169     scanPolicy.BSSListSize = 4;
   1170     scanPolicy.BSSNumberToStartDiscovery = 1;
   1171     scanPolicy.numOfBands = 1;
   1172     scanPolicy.bandScanPolicy[ 0 ].band = RADIO_BAND_2_4_GHZ;
   1173     scanPolicy.bandScanPolicy[ 0 ].rxRSSIThreshold = -80;
   1174     scanPolicy.bandScanPolicy[ 0 ].numOfChannles = 11;
   1175     scanPolicy.bandScanPolicy[ 0 ].numOfChannlesForDiscovery = 3;
   1176     for ( i = 0; i < 11; i++ )
   1177     {
   1178         scanPolicy.bandScanPolicy[ 0 ].channelList[ i ] = i + 1;
   1179     }
   1180     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
   1181     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
   1182     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
   1183     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
   1184     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.minChannelDwellTime = 15000;
   1185     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_1_BARKER;
   1186     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
   1187     scanPolicy.bandScanPolicy[ 0 ].trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
   1188     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
   1189     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
   1190     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
   1191     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
   1192     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.minChannelDwellTime = 15000;
   1193     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_2_BARKER;
   1194     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
   1195     scanPolicy.bandScanPolicy[ 0 ].discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
   1196     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.scanType = SCAN_TYPE_NORMAL_ACTIVE;
   1197     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
   1198     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = 0;
   1199     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = 30000;
   1200     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.minChannelDwellTime = 15000;
   1201     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = DRV_RATE_MASK_5_5_CCK;
   1202     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = 3;
   1203     scanPolicy.bandScanPolicy[ 0 ].immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = MAX_TX_POWER;
   1204 }
   1205 
   1206 void cmd_Scan_Start(ConParm_t parm[], U16 nParms)
   1207 {
   1208     TI_StartScan( g_id_adapter, &appScanParams );
   1209     console_printf_terminal("Application scan started.\n");
   1210 }
   1211 
   1212 void cmd_Scan_Stop(ConParm_t parm[], U16 nParms)
   1213 {
   1214     TI_StopScan( g_id_adapter );
   1215     console_printf_terminal("Application scan stopped.\n");
   1216 }
   1217 
   1218 void cmd_Scan_app_global_config(ConParm_t parm[], U16 nParms)
   1219 {
   1220     if ( 0 == strcmp( "<empty>", (char*)parm[0].value) )
   1221     {
   1222         appScanParams.desiredSsid.len = 0;
   1223         appScanParams.desiredSsid.ssidString[ 0 ] = '\0';
   1224     }
   1225     else
   1226     {
   1227     appScanParams.desiredSsid.len = strlen((char*)parm[0].value);
   1228     memcpy( &(appScanParams.desiredSsid.ssidString), (char*)parm[0].value, appScanParams.desiredSsid.len );
   1229     }
   1230     appScanParams.scanType = parm[1].value;
   1231     appScanParams.band = parm[2].value;
   1232     appScanParams.probeReqNumber = (UINT8)parm[3].value;
   1233     appScanParams.probeRequestRate = parm[4].value;
   1234 #ifdef TI_DBG
   1235     appScanParams.Tid = (UINT8)parm[5].value;
   1236     appScanParams.numOfChannels  = (UINT8)parm[6].value;
   1237 #else
   1238     appScanParams.Tid = 0;
   1239     appScanParams.numOfChannels = (UINT8)parm[5].value;
   1240 #endif
   1241 }
   1242 
   1243 void cmd_Scan_app_channel_config(ConParm_t parm[], U16 nParms)
   1244 {
   1245     scan_normalChannelEntry_t* pChannelEntry =
   1246         &(appScanParams.channelEntry[ parm[0].value ].normalChannelEntry);
   1247 
   1248 	if (parm[2].value < parm[3].value)
   1249 	{
   1250 		console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
   1251 		return;
   1252 	}
   1253 
   1254     hexStr2MACAddr( (char*)parm[1].value, &(pChannelEntry->bssId) );
   1255     pChannelEntry->maxChannelDwellTime = parm[2].value;
   1256     pChannelEntry->minChannelDwellTime = parm[3].value;
   1257     pChannelEntry->earlyTerminationEvent = parm[4].value;
   1258     pChannelEntry->ETMaxNumOfAPframes = (UINT8)parm[5].value;
   1259     pChannelEntry->txPowerDbm = (UINT8)parm[6].value;
   1260     pChannelEntry->channel = (UINT8)parm[7].value;
   1261 }
   1262 
   1263 void cmd_Scan_app_clear(ConParm_t parm[], U16 nParms)
   1264 {
   1265     memset( &appScanParams, 0, sizeof(scan_Params_t) );
   1266     console_printf_terminal("Application scan parameters cleared.\n");
   1267 }
   1268 
   1269 void cmd_Scan_app_display(ConParm_t parm[], U16 nParms)
   1270 {
   1271     int i;
   1272     scan_normalChannelEntry_t* pNormalChannel;
   1273     char bssId[18];
   1274 
   1275     bssId[17] = '\0';
   1276     console_printf_terminal("Application Scan params:\n");
   1277     console_printf_terminal("SSID: %s, Type: %s\n", appScanParams.desiredSsid.ssidString, scanType2Str[ appScanParams.scanType ].name);
   1278     console_printf_terminal("Band: %s, Number of probe req:%d, probe req. rate:%s\n",
   1279           band2Str[ appScanParams.band ].name, appScanParams.probeReqNumber, rate2StrFunc( appScanParams.probeRequestRate ) );
   1280 #ifdef TI_DBG
   1281     console_printf_terminal("Tid :%d\n\n", appScanParams.Tid);
   1282 #else
   1283     console_printf_terminal("\n");
   1284 #endif
   1285     console_printf_terminal("Channel  BSS ID             Max time  Min time  ET event     ET frame num Power\n");
   1286     console_printf_terminal("-------------------------------------------------------------------------------\n");
   1287     for ( i = 0; i < appScanParams.numOfChannels; i++ )
   1288     {
   1289         pNormalChannel = &(appScanParams.channelEntry[ i ].normalChannelEntry);
   1290         mac2HexStr( &(pNormalChannel->bssId), bssId );
   1291         console_printf_terminal ("%2d       %s  %7d   %7d   %s%3d          %1d\n",
   1292                pNormalChannel->channel, bssId, pNormalChannel->maxChannelDwellTime,
   1293                pNormalChannel->minChannelDwellTime, EtEvent2StrFunc( pNormalChannel->earlyTerminationEvent ),
   1294                pNormalChannel->ETMaxNumOfAPframes, pNormalChannel->txPowerDbm);
   1295     }
   1296     console_printf_terminal("\n");
   1297 }
   1298 
   1299 void cmd_Scan_policy_global_config(ConParm_t parm[], U16 nParms)
   1300 {
   1301     scanPolicy.normalScanInterval =  parm[ 0 ].value;
   1302     scanPolicy.deterioratingScanInterval = parm[ 1 ].value;
   1303     scanPolicy.maxTrackFailures = (UINT8)(parm[ 2 ].value);
   1304     scanPolicy.BSSListSize = (UINT8)(parm[ 3 ].value);
   1305     scanPolicy.BSSNumberToStartDiscovery = (UINT8)(parm[ 4 ].value);
   1306     scanPolicy.numOfBands = (UINT8)(parm[ 5 ].value);
   1307 }
   1308 
   1309 void cmd_Scan_band_global_config(ConParm_t parm[], U16 nParms)
   1310 {
   1311     scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
   1312 
   1313     bandPolicy->band = parm[ 1 ].value;
   1314     bandPolicy->rxRSSIThreshold = (S8)(parm[ 2 ].value);
   1315     bandPolicy->numOfChannlesForDiscovery = (UINT8)(parm[ 3 ].value);
   1316     bandPolicy->numOfChannles = (UINT8)(parm[ 4 ].value);
   1317 }
   1318 
   1319 void cmd_Scan_band_channel_config(ConParm_t parm[], U16 nParms)
   1320 {
   1321     scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
   1322 
   1323     bandPolicy->channelList[ parm[ 1 ].value ] = (UINT8)(parm[ 2 ].value);
   1324 }
   1325 
   1326 void cmd_Scan_band_track_config(ConParm_t parm[], U16 nParms)
   1327 {
   1328     scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
   1329 
   1330 	if (parm[6].value < parm[7].value)
   1331 	{
   1332 		console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
   1333 		return;
   1334 	}
   1335 
   1336     bandPolicy->trackingMethod.scanType = parm[ 1 ].value;
   1337 
   1338     switch (bandPolicy->trackingMethod.scanType)
   1339     {
   1340     case SCAN_TYPE_NORMAL_ACTIVE:
   1341     case SCAN_TYPE_NORMAL_PASSIVE:
   1342         bandPolicy->trackingMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
   1343         bandPolicy->trackingMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
   1344         bandPolicy->trackingMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1345         bandPolicy->trackingMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1346         bandPolicy->trackingMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
   1347         bandPolicy->trackingMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
   1348         bandPolicy->trackingMethod.method.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
   1349         break;
   1350 
   1351     case SCAN_TYPE_TRIGGERED_ACTIVE:
   1352     case SCAN_TYPE_TRIGGERED_PASSIVE:
   1353 
   1354 		/* Check if valid TID */
   1355 		if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255))
   1356 		{
   1357 			console_printf_terminal ("ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value));
   1358 			parm[ 4 ].value = 255;
   1359 		}
   1360         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.triggeringTid = (UINT8)(parm[ 4 ].value);
   1361         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
   1362         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
   1363         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1364         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1365         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
   1366         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
   1367         bandPolicy->trackingMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
   1368         break;
   1369 
   1370     case SCAN_TYPE_SPS:
   1371         bandPolicy->trackingMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1372         bandPolicy->trackingMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1373         bandPolicy->trackingMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value;
   1374         break;
   1375 
   1376     default:
   1377         bandPolicy->trackingMethod.scanType = SCAN_TYPE_NO_SCAN;
   1378         break;
   1379     }
   1380 }
   1381 
   1382 void cmd_Scan_band_discover_config(ConParm_t parm[], U16 nParms)
   1383 {
   1384     scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
   1385 
   1386 	if (parm[6].value < parm[7].value)
   1387 	{
   1388 		console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
   1389 		return;
   1390 	}
   1391 
   1392     bandPolicy->discoveryMethod.scanType = parm[ 1 ].value;
   1393 
   1394     switch (bandPolicy->discoveryMethod.scanType)
   1395     {
   1396     case SCAN_TYPE_NORMAL_ACTIVE:
   1397     case SCAN_TYPE_NORMAL_PASSIVE:
   1398         bandPolicy->discoveryMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
   1399         bandPolicy->discoveryMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
   1400         bandPolicy->discoveryMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1401         bandPolicy->discoveryMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1402         bandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
   1403         bandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
   1404         bandPolicy->discoveryMethod.method.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
   1405         break;
   1406 
   1407     case SCAN_TYPE_TRIGGERED_ACTIVE:
   1408     case SCAN_TYPE_TRIGGERED_PASSIVE:
   1409 		/* Check if valid TID */
   1410 		if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255))
   1411 		{
   1412 			console_printf_terminal ("ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value));
   1413 			parm[ 4 ].value = 255;
   1414 		}
   1415         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.triggeringTid = (UINT8)(parm[ 4 ].value);
   1416         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
   1417         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
   1418         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1419         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1420         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
   1421         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
   1422         bandPolicy->discoveryMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
   1423         break;
   1424 
   1425     case SCAN_TYPE_SPS:
   1426         bandPolicy->discoveryMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1427         bandPolicy->discoveryMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1428         bandPolicy->discoveryMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value;
   1429         break;
   1430 
   1431     default:
   1432         bandPolicy->discoveryMethod.scanType = SCAN_TYPE_NO_SCAN;
   1433         break;
   1434     }
   1435 }
   1436 
   1437 void cmd_Scan_band_immed_config(ConParm_t parm[], U16 nParms)
   1438 {
   1439     scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ parm [ 0 ].value ]);
   1440 
   1441 	if (parm[6].value < parm[7].value)
   1442 	{
   1443 		console_printf_terminal ("Max Dwell Time must be larger than or equal to Min Dwell Time...\n");
   1444 		return;
   1445 	}
   1446 
   1447     bandPolicy->immediateScanMethod.scanType = parm[ 1 ].value;
   1448 
   1449     switch (bandPolicy->immediateScanMethod.scanType)
   1450     {
   1451     case SCAN_TYPE_NORMAL_ACTIVE:
   1452     case SCAN_TYPE_NORMAL_PASSIVE:
   1453         bandPolicy->immediateScanMethod.method.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
   1454         bandPolicy->immediateScanMethod.method.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
   1455         bandPolicy->immediateScanMethod.method.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1456         bandPolicy->immediateScanMethod.method.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1457         bandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
   1458         bandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
   1459         bandPolicy->immediateScanMethod.method.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
   1460         break;
   1461 
   1462     case SCAN_TYPE_TRIGGERED_ACTIVE:
   1463     case SCAN_TYPE_TRIGGERED_PASSIVE:
   1464 		/* Check if valid TID */
   1465 		if (((parm[ 4 ].value) > 7) && ((parm[ 4 ].value) != 255))
   1466 		{
   1467 			console_printf_terminal ("ERROR Tid (AC) should be 0..7 or 255 instead = %d (using default = 255)\n",(parm[ 4 ].value));
   1468 			parm[ 4 ].value = 255;
   1469 		}
   1470         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.triggeringTid = (UINT8)(parm[ 4 ].value);
   1471         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.maxChannelDwellTime = (parm[ 6 ].value);
   1472         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.minChannelDwellTime = (parm[ 7 ].value);
   1473         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1474         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1475         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.bitrate = parm[ 9 ].value;
   1476         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.numOfProbeReqs = (UINT8)(parm[ 8 ].value);
   1477         bandPolicy->immediateScanMethod.method.TidTriggerdMethodParams.basicMethodParams.probReqParams.txPowerDbm = (UINT8)(parm[ 10 ].value);
   1478         break;
   1479 
   1480     case SCAN_TYPE_SPS:
   1481         bandPolicy->immediateScanMethod.method.spsMethodParams.earlyTerminationEvent = parm[ 2 ].value;
   1482         bandPolicy->immediateScanMethod.method.spsMethodParams.ETMaxNumberOfApFrames = (UINT8)(parm[ 3 ].value);
   1483         bandPolicy->immediateScanMethod.method.spsMethodParams.scanDuration = parm[ 5 ].value;
   1484         break;
   1485 
   1486     default:
   1487         bandPolicy->immediateScanMethod.scanType = SCAN_TYPE_NO_SCAN;
   1488         break;
   1489     }
   1490 }
   1491 
   1492 void cmd_Scan_policy_display(ConParm_t parm[], U16 nParms)
   1493 {
   1494     int i;
   1495 
   1496     console_printf_terminal("Scan Policy:\n");
   1497     console_printf_terminal("Normal scan interval: %d, deteriorating scan interval: %d\n",
   1498           scanPolicy.normalScanInterval, scanPolicy.deterioratingScanInterval);
   1499     console_printf_terminal("Max track attempt failures: %d\n", scanPolicy.maxTrackFailures);
   1500     console_printf_terminal("BSS list size: %d, number of BSSes to start discovery: %d\n",
   1501           scanPolicy.BSSListSize, scanPolicy.BSSNumberToStartDiscovery);
   1502     console_printf_terminal("Number of configured bands: %d\n", scanPolicy.numOfBands);
   1503     for ( i = 0; i < scanPolicy.numOfBands; i++ )
   1504     {
   1505         cmd_Scan_print_band( i );
   1506     }
   1507 }
   1508 
   1509 void cmd_Scan_print_band( int i )
   1510 {
   1511     scan_bandPolicy_t* bandPolicy = &(scanPolicy.bandScanPolicy[ i ]);
   1512     int j;
   1513 
   1514     console_printf_terminal("\nBand: %s\n", band2Str[ bandPolicy->band ].name);
   1515     console_printf_terminal("RSSI Threshold: %d dBm\n", bandPolicy->rxRSSIThreshold);
   1516     console_printf_terminal("Number of channels for each discovery interval: %d\n", bandPolicy->numOfChannlesForDiscovery);
   1517     console_printf_terminal("\nTracking Method:\n");
   1518     cmd_Scan_print_method( &(bandPolicy->trackingMethod) );
   1519     console_printf_terminal("\nDiscovery Method:\n");
   1520     cmd_Scan_print_method( &(bandPolicy->discoveryMethod) );
   1521     console_printf_terminal("\nImmediate Scan Method:\n");
   1522     cmd_Scan_print_method( &(bandPolicy->immediateScanMethod) );
   1523     if ( bandPolicy->numOfChannles > 0 )
   1524     {
   1525         console_printf_terminal("\nChannel list: ");
   1526         for ( j = 0; j < bandPolicy->numOfChannles; j++ )
   1527         {
   1528             console_printf_terminal("%3d ", bandPolicy->channelList[ j ]);
   1529         }
   1530         console_printf_terminal("\n");
   1531     }
   1532     else
   1533         console_printf_terminal("\nNo channels defined.\n");
   1534 }
   1535 
   1536 void cmd_Scan_print_method( scan_Method_t* scanMethod )
   1537 {
   1538     console_printf_terminal("Scan type: %s\n", scanType2Str[ scanMethod->scanType ].name);
   1539     switch (scanMethod->scanType)
   1540     {
   1541     case SCAN_TYPE_NORMAL_ACTIVE:
   1542     case SCAN_TYPE_NORMAL_PASSIVE:
   1543         cmd_Scan_print_basic_method( &(scanMethod->method.basicMethodParams) );
   1544         break;
   1545 
   1546     case SCAN_TYPE_TRIGGERED_ACTIVE:
   1547     case SCAN_TYPE_TRIGGERED_PASSIVE:
   1548         cmd_Scan_print_triggered_method( &(scanMethod->method.TidTriggerdMethodParams) );
   1549         break;
   1550 
   1551     case SCAN_TYPE_SPS:
   1552         cmd_Scan_print_sps_method( &(scanMethod->method.spsMethodParams) );
   1553         break;
   1554 
   1555     case SCAN_TYPE_NO_SCAN:
   1556         break;
   1557     }
   1558 }
   1559 
   1560 void cmd_Scan_print_basic_method( scan_basicMethodParams_t* basicMethodParams )
   1561 {
   1562     console_printf_terminal("Max channel dwell time: %d, Min channel dwell time: %d\n",
   1563           basicMethodParams->maxChannelDwellTime, basicMethodParams->minChannelDwellTime);
   1564     console_printf_terminal("ET condition: %s, ET number of frames: %d\n",
   1565           EtEvent2StrFunc( basicMethodParams->earlyTerminationEvent ), basicMethodParams->ETMaxNumberOfApFrames);
   1566     console_printf_terminal("Probe request number: %d, probe request rate: %s, TX power (Dbm/10): %d\n",
   1567           basicMethodParams->probReqParams.numOfProbeReqs, rate2StrFunc( basicMethodParams->probReqParams.bitrate ),
   1568           basicMethodParams->probReqParams.txPowerDbm);
   1569 }
   1570 
   1571 void cmd_Scan_print_triggered_method( scan_TidTriggeredMethodParams_t* triggeredMethodParams )
   1572 {
   1573     console_printf_terminal("Triggering Tid: %d\n", triggeredMethodParams->triggeringTid);
   1574     cmd_Scan_print_basic_method( &(triggeredMethodParams->basicMethodParams) );
   1575 }
   1576 
   1577 void cmd_Scan_print_sps_method( scan_SPSMethodParams_t* spsMethodParams )
   1578 {
   1579     console_printf_terminal("ET condition: %s, ET number of frames: %d\n",
   1580           EtEvent2StrFunc( spsMethodParams->earlyTerminationEvent ), spsMethodParams->ETMaxNumberOfApFrames);
   1581     console_printf_terminal("Scan duration: %d\n", spsMethodParams->scanDuration);
   1582 }
   1583 
   1584 void cmd_Scan_policy_clear(ConParm_t parm[], U16 nParms)
   1585 {
   1586     memset( &scanPolicy, 0, sizeof(scan_Policy_t) );
   1587     console_printf_terminal("Scan policy cleared.\n");
   1588 }
   1589 
   1590 void cmd_Scan_policy_store(ConParm_t parm[], U16 nParms)
   1591 {
   1592     TI_SetScanPolicy( g_id_adapter, (UINT8*)&scanPolicy, sizeof(scan_Policy_t) );
   1593     console_printf_terminal("Scan policy stored.\n");
   1594 }
   1595 
   1596 void cmd_Scan_get_bss_list(ConParm_t parm[], U16 nParms)
   1597 {
   1598     bssList_t list;
   1599     int i;
   1600 
   1601     /* get list */
   1602     if ( (TI_RESULT_OK != TI_GetScanBssList( g_id_adapter, &list )) || (0 == list.numOfEntries) )
   1603     {
   1604         return;
   1605     }
   1606 
   1607     /* console_printf_terminal list */
   1608     console_printf_terminal("BSS List:\n");
   1609     console_printf_terminal("%-17s  %-7s  %-6s  %-4s  %-10s\n", "BSSID", "Band", "Channel", "RSSI", "Neighbor?");
   1610     console_printf_terminal("-----------------------------------------------------\n");
   1611     for  ( i = 0; i < list.numOfEntries; i++ )
   1612     {
   1613 
   1614         console_printf_terminal( "%s  %s  %-7d  %-4d  %s\n",
   1615                print_mac_2_str(list.BSSList[ i ].BSSID.addr), band2Str[ list.BSSList[ i ].band ].name,
   1616                list.BSSList[ i ].channel, list.BSSList[ i ].RSSI,
   1617                (TRUE == list.BSSList[ i ].bNeighborAP ? "Yes" : "No") );
   1618     }
   1619 }
   1620 
   1621 void cmd_set_dtag_to_ac_mapping_table(ConParm_t parm[], U16 nParms)
   1622 {
   1623     int				i;
   1624     acTrfcType_e	dtagToAcTable[MAX_NUM_OF_802_1d_TAGS];
   1625 
   1626     for (i=0; i<MAX_NUM_OF_802_1d_TAGS; i++)
   1627     {
   1628         dtagToAcTable[i] = (UINT32) parm[i].value;
   1629 	}
   1630 	console_printf_terminal("Input parameters =%d, %d, %d, %d, %d, %d, %d, %d\n",
   1631                     (UINT32) parm[0].value,
   1632                     (UINT32) parm[1].value,
   1633                     (UINT32) parm[2].value,
   1634                     (UINT32) parm[3].value,
   1635                     (UINT32) parm[4].value,
   1636                     (UINT32) parm[5].value,
   1637                     (UINT32) parm[6].value,
   1638                     (UINT32) parm[7].value);
   1639 
   1640 	if (TI_SetDTagToAcMappingTable(g_id_adapter, dtagToAcTable) == TI_RESULT_OK)
   1641 	{
   1642 	}
   1643 	else
   1644 	{
   1645 		console_printf_terminal ("Error: could not set tag_ToAcClsfrTable ...\n");
   1646 	}
   1647 }
   1648 
   1649 void cmd_set_vad(ConParm_t parm[], U16 nParms)
   1650 {
   1651 	txDataVadTimerParams_t  pVadTimer;
   1652 
   1653 	if (0 == nParms)	// GET operation
   1654 	{
   1655 		console_printf_terminal("Set VAD: \n");
   1656 		console_printf_terminal("    Parm 0 -- 1: ENABLE; 0: DISABLE\n");
   1657 		console_printf_terminal("    Parm 1 -- VAD timer duration in ms for enabling action\n");
   1658 		if (TI_GetVAD(g_id_adapter, &pVadTimer) == TI_RESULT_OK)
   1659 		{
   1660 
   1661 		    console_printf_terminal("Current param values: %d, %d\n",
   1662 				 pVadTimer.vadTimerEnabled, pVadTimer.vadTimerDuration);
   1663 		}
   1664 	}
   1665 	else
   1666 	{
   1667 		pVadTimer.vadTimerEnabled  = (UINT16) parm[0].value;
   1668 		pVadTimer.vadTimerDuration = (UINT16) parm[1].value;
   1669 
   1670 		if (pVadTimer.vadTimerEnabled)
   1671 		{
   1672 			console_printf_terminal("Enabling VAD timer (cycle = %d ms)\n", pVadTimer.vadTimerDuration);
   1673 		}
   1674 		else
   1675 		{
   1676 			console_printf_terminal("Disabling VAD timer\n");
   1677 		}
   1678 
   1679 		if (TI_SetVAD(g_id_adapter, &pVadTimer) == TI_RESULT_OK)
   1680 		{
   1681 			console_printf_terminal("Setting VAD is done\n");
   1682 		}
   1683 	}
   1684 }
   1685 
   1686 
   1687 void cmd_set_qos_params(ConParm_t parm[], U16 nParms)
   1688 {
   1689    OS_802_11_QOS_PARAMS pQosParams;
   1690 
   1691    pQosParams.acID=parm[0].value;
   1692    pQosParams.MaxLifeTime=parm[1].value;
   1693    pQosParams.VoiceDeliveryProtocol=0;
   1694    pQosParams.PSDeliveryProtocol=0;
   1695 
   1696    if (nParms == 7) /* If the user has input 7 parameters, it means he gave Voice+PS delivery protocol values */
   1697    {
   1698       pQosParams.VoiceDeliveryProtocol=parm[5].value;
   1699       pQosParams.PSDeliveryProtocol=parm[6].value;
   1700 
   1701       /* If this QOS config was done for a queue OTHER THAN VO, we will zero the DeliveryProtocolPsPoll parameter and notify the user */
   1702       if ((parm[0].value != 3) && (parm[5].value != 0))
   1703          {
   1704             pQosParams.VoiceDeliveryProtocol = 0;
   1705             console_printf_terminal("Since the acID is not VO, resetting VoiceDeliveryProtocol parameter to PS_NONE\n");
   1706          }
   1707       if ((pQosParams.VoiceDeliveryProtocol == 1) && (pQosParams.PSDeliveryProtocol == 1))
   1708       {
   1709             pQosParams.VoiceDeliveryProtocol = 1;
   1710             pQosParams.PSDeliveryProtocol = 0;
   1711             console_printf_terminal("Since the VoiceDeliveryProtocol is PS_POLL, resetting PSDeliveryProtocol to Legacy\n");
   1712       }
   1713    }
   1714 
   1715    if (TI_SetQosParameters(g_id_adapter, &pQosParams) == TI_RESULT_OK)
   1716    {
   1717       console_printf_terminal("Sent QOS params to driver...\n AC Number=%d \n MaxLifeTime=%d \n DeliveryProtocolPsPoll = %d\n PSDeliveryProtocol = %d\n",
   1718           pQosParams.acID,
   1719           pQosParams.MaxLifeTime,
   1720           pQosParams.VoiceDeliveryProtocol,
   1721           pQosParams.PSDeliveryProtocol);
   1722    }
   1723    else
   1724    {
   1725       console_printf_terminal ("Error: could not set QOS params...\n");
   1726    }
   1727 }
   1728 
   1729 void cmd_set_rxTimeOut_params(ConParm_t parm[], U16 nParms)
   1730 {
   1731     OS_802_11_QOS_RX_TIMEOUT_PARAMS rxTimeOut;
   1732 
   1733     rxTimeOut.psPoll = parm[0].value;
   1734     rxTimeOut.UPSD   = parm[1].value;
   1735 
   1736     if (nParms != 2)
   1737     {
   1738         console_printf_terminal("Please enter Rx Time Out:\n");
   1739         console_printf_terminal("Param 0 - psPoll (0 - 65000)\n");
   1740         console_printf_terminal("Param 1 - UPSD (1 - 65000)\n");
   1741     }
   1742     else
   1743     {
   1744        if (TI_SetQosRxTimeOut(g_id_adapter, &rxTimeOut) == TI_RESULT_OK)
   1745        {
   1746           console_printf_terminal("Sent QOS Rx TimeOut params to driver...\n PsPoll = %d\n UPSD = %d\n",
   1747               rxTimeOut.psPoll,
   1748               rxTimeOut.UPSD);
   1749        }
   1750        else
   1751        {
   1752           console_printf_terminal ("Error: could not set Rx TimeOut..\n");
   1753        }
   1754     }
   1755 }
   1756 
   1757 
   1758 void cmd_enable_rx_data_filters(ConParm_t parm[], U16 nParms)
   1759 {
   1760     console_printf_terminal("Enabling Rx data filtering...\n");
   1761     TI_EnableDisableRxDataFilters( g_id_adapter, TRUE );
   1762 }
   1763 
   1764 
   1765 void cmd_disable_rx_data_filters(ConParm_t parm[], U16 nParms)
   1766 {
   1767     console_printf_terminal("Disabling Rx data filtering...\n");
   1768     TI_EnableDisableRxDataFilters( g_id_adapter, FALSE );
   1769 }
   1770 
   1771 
   1772 void cmd_get_rx_data_filters_statistics(ConParm_t parm[], U16 nParms)
   1773 {
   1774     TIWLAN_DATA_FILTER_STATISTICS statistics;
   1775 
   1776 
   1777     console_printf_terminal("Rx data filtering statistics:\n");
   1778 
   1779     TI_GetRxDataFiltersStatistics( g_id_adapter, &statistics );
   1780 
   1781     console_printf_terminal("Unmatched packets: %u\n", statistics.UnmatchedPacketsCount);
   1782     console_printf_terminal("Packets matching filter #1: %u\n", statistics.MatchedPacketsCount[0]);
   1783     console_printf_terminal("Packets matching filter #2: %u\n", statistics.MatchedPacketsCount[1]);
   1784     console_printf_terminal("Packets matching filter #3: %u\n", statistics.MatchedPacketsCount[2]);
   1785     console_printf_terminal("Packets matching filter #4: %u\n", statistics.MatchedPacketsCount[3]);
   1786 }
   1787 
   1788 void cmd_show_power_consumption_stats(ConParm_t parm[])
   1789 {
   1790     PowerConsumptionTimeStat_t statistics;
   1791 
   1792 
   1793     TI_GetPowerConsumptionStatistics( g_id_adapter, &statistics );
   1794 
   1795     console_printf_terminal("\nPower Consumption Statistics:\n");
   1796     console_printf_terminal("-----------------------------\n");
   1797     console_printf_terminal("activeTimeCnt_H: %u\n", statistics.activeTimeCnt_Hi);
   1798     console_printf_terminal("activeTimeCnt_Low: %u\n", statistics.activeTimeCnt_Low);
   1799     console_printf_terminal("elpTimeCnt_Hi: %u\n", statistics.elpTimeCnt_Hi);
   1800     console_printf_terminal("elpTimeCnt_Low: %u\n", statistics.elpTimeCnt_Low);
   1801     console_printf_terminal("powerDownTimeCnt_Hi: %u\n", statistics.powerDownTimeCnt_Hi);
   1802     console_printf_terminal("powerDownTimeCnt_Low: %u\n", statistics.powerDownTimeCnt_Low);
   1803 
   1804 }
   1805 
   1806 
   1807 
   1808 static void parse_hex_string(char * pString, tiUINT8 * pBuffer, tiUINT8 * Length)
   1809 {
   1810     char ch;
   1811     int iter = 0;
   1812 
   1813     while ((ch = pString[iter]))
   1814     {
   1815         UINT8 val = ((ch >= '0' && ch <= '9') ? (ch - '0') :
   1816                      (ch >= 'A' && ch <= 'F') ? (0xA + ch - 'A') :
   1817                      (ch >= 'a' && ch <= 'f') ? (0xA + ch - 'a') : 0);
   1818 
   1819         /* even indexes go to the lower nibble, odd indexes push them to the */
   1820         /* higher nibble and then go themselves to the lower nibble. */
   1821         if (iter % 2)
   1822             pBuffer[iter / 2] = ((pBuffer[iter / 2] << (BIT_TO_BYTE_FACTOR / 2)) | val);
   1823         else
   1824             pBuffer[iter / 2] = val;
   1825 
   1826         ++iter;
   1827     }
   1828 
   1829     /* iter = 0 len = 0, iter = 1 len = 1, iter = 2 len = 1, and so on... */
   1830     *Length = (iter + 1) / 2;
   1831 }
   1832 
   1833 static void parse_binary_string(char * pString, tiUINT8 * pBuffer, tiUINT8 * Length)
   1834 {
   1835     char ch;
   1836     int iter = 0;
   1837 
   1838     while ((ch = pString[iter]))
   1839     {
   1840         UINT8 val = (ch == '1' ? 1 : 0);
   1841 
   1842         if (iter % BIT_TO_BYTE_FACTOR)
   1843             pBuffer[iter / BIT_TO_BYTE_FACTOR] |= (val << (iter % BIT_TO_BYTE_FACTOR));
   1844         else
   1845             pBuffer[iter / BIT_TO_BYTE_FACTOR] = val;
   1846 
   1847         ++iter;
   1848     }
   1849 
   1850     /* iter = 0 len = 0, iter = 1 len = 1, iter = 8 len = 1, and so on... */
   1851     *Length = (iter + BIT_TO_BYTE_FACTOR - 1) / BIT_TO_BYTE_FACTOR;
   1852 }
   1853 
   1854 void cmd_add_rx_data_filter(ConParm_t parm[], U16 nParms)
   1855 {
   1856     tiUINT32 resultCode;
   1857     TIWLAN_DATA_FILTER_REQUEST request;
   1858 
   1859     char * mask = (char *) parm[1].value;
   1860     char * pattern = (char *) parm[2].value;
   1861 
   1862 
   1863     request.Offset = (UINT8) parm[0].value;
   1864 
   1865     parse_binary_string(mask, request.Mask, &request.MaskLength);
   1866     parse_hex_string(pattern, request.Pattern, &request.PatternLength);
   1867 
   1868     resultCode = TI_AddRxDataFilter(g_id_adapter, &request);
   1869 
   1870 
   1871     console_printf_terminal(resultCode == RX_NO_AVAILABLE_FILTERS ? "Error: There are no available filter slots.\n" :
   1872                             resultCode == RX_FILTER_ALREADY_EXISTS ? "Error: Filter already exists.\n" :
   1873                             resultCode == NOK ? "Error: Could not add the filter.\n" :
   1874                             "Filter added.\n");
   1875 }
   1876 
   1877 void cmd_remove_rx_data_filter(ConParm_t parm[], U16 nParms)
   1878 {
   1879     tiUINT32 resultCode;
   1880     TIWLAN_DATA_FILTER_REQUEST request;
   1881 
   1882     char * mask = (char *) parm[1].value;
   1883     char * pattern = (char *) parm[2].value;
   1884 
   1885     request.Offset = (UINT8) parm[0].value;
   1886 
   1887     parse_binary_string(mask, request.Mask, &request.MaskLength);
   1888     parse_hex_string(pattern, request.Pattern, &request.PatternLength);
   1889 
   1890     resultCode = TI_RemoveRxDataFilter(g_id_adapter, &request);
   1891 
   1892     console_printf_terminal(resultCode == RX_FILTER_DOES_NOT_EXIST ? "Error: Filter was not found.\n" :
   1893                             resultCode == NOK ? "Error: Could not remove the filter, removal request must be identical to add request.\n" :
   1894                             "Filter removed.\n");
   1895 }
   1896 
   1897 void cmd_MaxRxLifetime_params(ConParm_t parm[], U16 nParms)
   1898 {
   1899     PLT_MIB_t Mib;
   1900     UINT32 Status;
   1901     memset(&Mib, 0, sizeof(Mib));
   1902     Mib.aMib = PLT_MIB_dot11MaxReceiveLifetime;
   1903 
   1904 	if (nParms != 1)
   1905 	{
   1906 	   console_printf_terminal("Max Rx lifetime: [0 - 4294967295(0xFFFFFFFF)]\n");
   1907 
   1908 	}
   1909 
   1910 	if (nParms == 0) /*Get MaxRxlifetime */
   1911     {
   1912         Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
   1913         if (OK == Status)
   1914   	       console_printf_terminal("MaxRxLifetime = %d\n", Mib.aData.MaxReceiveLifeTime);
   1915     }
   1916     else if (nParms == 1)
   1917     {
   1918         Mib.Length = sizeof(Mib.aData.MaxReceiveLifeTime);
   1919         Mib.aData.MaxReceiveLifeTime = parm[0].value;
   1920         if (OK != TI_PLT_WriteMIB(g_id_adapter, &Mib))
   1921             console_printf_terminal("TI_PLT_WriteMIB failed\n");
   1922     }
   1923 }
   1924 
   1925 
   1926 void cmd_add_tspec(ConParm_t parm[], U16 nParms)
   1927 {
   1928    OS_802_11_QOS_TSPEC_PARAMS pTspecParams;
   1929    tiUINT32 resultCode;
   1930 
   1931    pTspecParams.uUserPriority = parm[0].value;
   1932    pTspecParams.uNominalMSDUsize = parm[1].value;
   1933    pTspecParams.uMeanDataRate = parm[2].value;
   1934    pTspecParams.uMinimumPHYRate = parm[3].value * 1000 * 1000;
   1935    pTspecParams.uSurplusBandwidthAllowance = parm[4].value << 13;
   1936    pTspecParams.uAPSDFlag = parm[5].value;
   1937 
   1938    resultCode = TI_AddTspec (g_id_adapter,&pTspecParams);
   1939 
   1940    switch (resultCode)
   1941    {
   1942    case OK:
   1943       console_printf_terminal ("TSpec request sent to driver...\n uUserPriority = %d\n uNominalMSDUsize = %d\n uMeanDataRate = %d\n uMinimumPHYRate = %d\n uSurplusBandwidthAllowance = %d\n uAPSDFlag = %d\n",
   1944                parm[0].value,
   1945                parm[1].value,
   1946                parm[2].value,
   1947                parm[3].value,
   1948                parm[4].value,
   1949                parm[5].value);
   1950       break;
   1951    case TRAFIC_ADM_PENDING:
   1952       console_printf_terminal ("Driver is still waiting for a response of previous request...\n");
   1953       break;
   1954    case AC_ALREADY_IN_USE:
   1955       console_printf_terminal ("Other user priority from the same AC has already used a TSPEC...\n");
   1956       break;
   1957    case NOT_CONNECTED:
   1958       console_printf_terminal ("Not connected to an AP...\n");
   1959       break;
   1960    case NO_QOS_AP:
   1961       console_printf_terminal ("AP does not support QOS...\n");
   1962       break;
   1963    case NOK:
   1964       console_printf_terminal ("Invalid parameter...\n");
   1965       break;
   1966    default:
   1967       console_printf_terminal ("Unknown return value...\n");
   1968       break;
   1969    }
   1970 
   1971    return;
   1972 }
   1973 
   1974 void cmd_get_tspec_params(ConParm_t parm[], U16 nParms)
   1975 {
   1976    OS_802_11_QOS_TSPEC_PARAMS pTspecParams;
   1977    tiUINT32 resultCode;
   1978 
   1979    pTspecParams.uUserPriority = parm[0].value;
   1980 
   1981    resultCode = TI_GetTspecParameters(g_id_adapter, &pTspecParams);
   1982 
   1983    switch (resultCode)
   1984    {
   1985    case OK:
   1986       console_printf_terminal ("TSpec parameters retrieved:\nuUserPriority = %d\nuNominalMSDUsize = %d\nuMeanDataRate = %d\nuMinimumPHYRate = %d\nuSurplusBandwidthAllowance = %d\nuUAPSD_Flag = %d\nuMediumTime = %d\n",
   1987                pTspecParams.uUserPriority,
   1988                pTspecParams.uNominalMSDUsize,
   1989                pTspecParams.uMeanDataRate,
   1990                pTspecParams.uMinimumPHYRate,
   1991                pTspecParams.uSurplusBandwidthAllowance,
   1992                pTspecParams.uAPSDFlag,
   1993                pTspecParams.uMediumTime);
   1994       break;
   1995    case USER_PRIORITY_NOT_ADMITTED:
   1996       console_printf_terminal ("User Priority is not admitted...\n");
   1997       break;
   1998    case NOT_CONNECTED:
   1999       console_printf_terminal ("Not connected to an AP...\n");
   2000       break;
   2001    case NO_QOS_AP:
   2002       console_printf_terminal ("AP does not support QOS...\n");
   2003       break;
   2004    case NOK:
   2005       console_printf_terminal ("Invalid parameter...\n");
   2006       break;
   2007    default:
   2008       console_printf_terminal ("Unknown return value...\n");
   2009       break;
   2010    }
   2011 
   2012    return;
   2013 }
   2014 
   2015 void cmd_delete_tspec(ConParm_t parm[], U16 nParms)
   2016 {
   2017    OS_802_11_QOS_DELETE_TSPEC_PARAMS pDelTspecParams;
   2018    tiUINT32 resultCode;
   2019 
   2020    pDelTspecParams.uUserPriority = parm[0].value;
   2021    pDelTspecParams.uReasonCode = parm[1].value;
   2022 
   2023    resultCode = TI_DeleteTspec(g_id_adapter, &pDelTspecParams);
   2024 
   2025    switch (resultCode)
   2026    {
   2027    case OK:
   2028       console_printf_terminal ("TSPEC Delete request sent to driver...\n uUserPriority = %d\n uReasonCode = %d\n",
   2029                pDelTspecParams.uUserPriority,
   2030                pDelTspecParams.uReasonCode);
   2031       break;
   2032    case NOT_CONNECTED:
   2033       console_printf_terminal ("Not connected to an AP...\n");
   2034       break;
   2035    case NO_QOS_AP:
   2036       console_printf_terminal ("AP does not support QOS...\n");
   2037       break;
   2038    case NOK:
   2039       console_printf_terminal ("Invalid parameter...\n");
   2040       break;
   2041    default:
   2042       console_printf_terminal ("Unknown return value...\n");
   2043       break;
   2044    }
   2045 
   2046 }
   2047 
   2048 void cmd_get_ap_qos_params(ConParm_t parm[], U16 nParms)
   2049 {
   2050    OS_802_11_AC_QOS_PARAMS pACQosParams;
   2051    int i = 0;
   2052    tiUINT32 resultCode;
   2053 
   2054    pACQosParams.uAC = i;
   2055    /* Read AC 0 parameters - just to check if connected to QOS AP etc */
   2056    resultCode = TI_GetAPQosParameters(g_id_adapter, &pACQosParams);
   2057 
   2058    switch (resultCode)
   2059    {
   2060    case OK:
   2061    console_printf_terminal ("AP QOS Parameters:\n");
   2062          console_printf_terminal ("+----+-------------+----------+-----------+-----------+-----------+\n");
   2063          console_printf_terminal ("| AC | AdmCtrlFlag |   AIFS   |   CwMin   |   CwMax   | TXOPLimit |\n");
   2064          console_printf_terminal ("+----+-------------+----------+-----------+-----------+-----------+\n");
   2065 
   2066 
   2067    for (i=0; i<4; i++)
   2068       {
   2069          pACQosParams.uAC = i;
   2070          resultCode = TI_GetAPQosParameters(g_id_adapter, &pACQosParams);
   2071 
   2072                console_printf_terminal ("| %2d | %11d | %8d | %9d | %9d | %9d |\n",i,
   2073                pACQosParams.uAssocAdmissionCtrlFlag,
   2074                pACQosParams.uAIFS,
   2075                pACQosParams.uCwMin,
   2076                pACQosParams.uCwMax,
   2077                pACQosParams.uTXOPLimit);
   2078       }
   2079 
   2080          console_printf_terminal ("+----+-------------+----------+-----------+-----------+-----------+\n");
   2081       break;
   2082    case NOT_CONNECTED:
   2083       console_printf_terminal ("Not connected to an AP...\n");
   2084       break;
   2085    case NO_QOS_AP:
   2086       console_printf_terminal ("AP does not support QOS...\n");
   2087       break;
   2088    case NOK:
   2089       console_printf_terminal ("Invalid parameter...\n");
   2090       break;
   2091    default:
   2092       console_printf_terminal ("Unknown return value...\n");
   2093       break;
   2094    }
   2095 
   2096 }
   2097 
   2098 void cmd_get_ap_qos_capabilities(ConParm_t parm[], U16 nParms)
   2099 {
   2100    OS_802_11_AP_QOS_CAPABILITIES_PARAMS pAPQosCapabiltiesParams;
   2101    tiUINT32 resultCode;
   2102 
   2103    resultCode = TI_GetAPQosCapabilitesParameters(g_id_adapter, &pAPQosCapabiltiesParams);
   2104 
   2105    switch (resultCode)
   2106    {
   2107    case TI_RESULT_OK:
   2108       console_printf_terminal ("AP Qos Capabilities:\n QOSFlag = %d\n APSDFlag = %d\n",pAPQosCapabiltiesParams.uQOSFlag,pAPQosCapabiltiesParams.uAPSDFlag);
   2109       break;
   2110    case NOT_CONNECTED:
   2111       console_printf_terminal ("Not connected to an AP...\n");
   2112       break;
   2113    case NO_QOS_AP:
   2114       console_printf_terminal ("AP does not support QOS...\n");
   2115       break;
   2116    default:
   2117       console_printf_terminal ("Unknown return value...\n");
   2118       break;
   2119    }
   2120 
   2121    return;
   2122 }
   2123 
   2124 void cmd_get_ac_status(ConParm_t parm[], U16 nParms)
   2125 {
   2126    OS_802_11_AC_UPSD_STATUS_PARAMS pAcStatusParams;
   2127    tiUINT32 resultCode;
   2128 
   2129    pAcStatusParams.uAC = parm[0].value;
   2130 
   2131    resultCode = TI_GetCurrentACStatus(g_id_adapter, &pAcStatusParams);
   2132 
   2133    switch (resultCode)
   2134    {
   2135    case TI_RESULT_OK:
   2136       console_printf_terminal ("AC %d Status:\nCurrentUAPSDStatus = %d (0=PS_POLL,1=UPSD,2=PS_NONE)\nCurrentAdmissionStatus = %d(0=NOT_ADMITED,1=WAIT,2=ADMITED)\n",
   2137                pAcStatusParams.uAC,
   2138                pAcStatusParams.uCurrentUAPSDStatus,
   2139                pAcStatusParams.pCurrentAdmissionStatus);
   2140       break;
   2141    case NOT_CONNECTED:
   2142       console_printf_terminal ("Not connected to an AP...\n");
   2143       break;
   2144    case NO_QOS_AP:
   2145       console_printf_terminal ("AP does not support QOS...\n");
   2146       break;
   2147    case NOK:
   2148       console_printf_terminal ("Invalid parameters...\n");
   2149       break;
   2150    default:
   2151       console_printf_terminal ("Unknown return value...\n");
   2152       break;
   2153    }
   2154 
   2155 }
   2156 
   2157 void cmd_get_desired_ps_mode(ConParm_t parm[], U16 nParms)
   2158 {
   2159    OS_802_11_QOS_DESIRED_PS_MODE pDesiredPsMode;
   2160    tiUINT32 resultCode;
   2161 
   2162    resultCode = TI_GetDesiredPsMode(g_id_adapter, &pDesiredPsMode);
   2163 
   2164    switch (resultCode)
   2165    {
   2166    case TI_RESULT_OK:
   2167       console_printf_terminal ("\n\
   2168 Desired PS Mode (0=PS_POLL, 1=UPSD, 2=PS_NONE):\n\
   2169 ===============================================\n\
   2170 General Desired Ps Mode  =  %d\n\
   2171  BE_AC  Desired Ps Mode  =  %d\n\
   2172  BK_AC  Desired Ps Mode  =  %d\n\
   2173  VI_AC  Desired Ps Mode  =  %d\n\
   2174  VO_AC  Desired Ps Mode  =  %d\n",
   2175               pDesiredPsMode.uDesiredPsMode,
   2176               pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_BE],
   2177               pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_BK],
   2178               pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_VI],
   2179               pDesiredPsMode.uDesiredWmeAcPsMode[QOS_AC_VO]);
   2180 
   2181       break;
   2182    case NOK:
   2183       console_printf_terminal ("Invalid parameters...\n");
   2184       break;
   2185    default:
   2186       console_printf_terminal ("Unknown return value...\n");
   2187       break;
   2188    }
   2189 }
   2190 
   2191 
   2192 
   2193 void cmd_medium_usage_threshold(ConParm_t parm[], U16 nParms)
   2194 {
   2195    OS_802_11_THRESHOLD_CROSS_PARAMS pThresholdCrossParams;
   2196    tiUINT32 resultCode;
   2197 
   2198    if (nParms == 3) /* If user supplied 3 parameters - this is a SET operation */
   2199    {
   2200        pThresholdCrossParams.uAC = parm[0].value;
   2201        pThresholdCrossParams.uHighThreshold = parm[1].value;
   2202        pThresholdCrossParams.uLowThreshold = parm[2].value;
   2203 
   2204       if (pThresholdCrossParams.uLowThreshold > pThresholdCrossParams.uHighThreshold)
   2205       {
   2206          console_printf_terminal ("Low threshold cannot be higher than the High threshold...Aborting...\n");
   2207       }
   2208       else
   2209       {
   2210            resultCode = TI_SetMediumUsageThreshold(g_id_adapter, &pThresholdCrossParams);
   2211            if (resultCode == TI_RESULT_OK)
   2212            {
   2213                console_printf_terminal ("Medium usage threshold for AC %d has been set to:\n LowThreshold = %d\n HighThreshold = %d\n",
   2214                pThresholdCrossParams.uAC,
   2215                pThresholdCrossParams.uLowThreshold,
   2216                pThresholdCrossParams.uHighThreshold);
   2217            }
   2218            else
   2219            {
   2220                console_printf_terminal ("Error...\n");
   2221            }
   2222       }
   2223 
   2224    }
   2225    else if (nParms == 1) /* Only 1 parameter means a GET operation */
   2226    {
   2227       pThresholdCrossParams.uAC = parm[0].value;
   2228       pThresholdCrossParams.uLowThreshold = 0;
   2229       pThresholdCrossParams.uHighThreshold = 0;
   2230 
   2231       resultCode = TI_GetMediumUsageThreshold(g_id_adapter, &pThresholdCrossParams);
   2232 
   2233       console_printf_terminal ("Medium usage threshold for AC %d:\n LowThreshold = %d\n HighThreshold = %d\n",
   2234           pThresholdCrossParams.uAC,
   2235           pThresholdCrossParams.uLowThreshold,
   2236           pThresholdCrossParams.uHighThreshold);
   2237    }
   2238 
   2239 }
   2240 
   2241 void cmd_phy_rate_threshold(ConParm_t parm[], U16 nParms)
   2242 {
   2243    OS_802_11_THRESHOLD_CROSS_PARAMS pThresholdCrossParams;
   2244    tiUINT32 resultCode;
   2245 
   2246    if (nParms == 3) /* If user supplied 3 parameters - this is a SET operation */
   2247    {
   2248        if ((is_value_rate(parm[1].value) == FALSE) || (is_value_rate(parm[2].value) == FALSE))
   2249        {
   2250           console_printf_terminal ("Invalid rate - PHY rate valid values are: 1,2,5,6,9,11,12,18,24,36,48,54\n");
   2251           return;
   2252        }
   2253 
   2254        pThresholdCrossParams.uAC = parm[0].value;
   2255        pThresholdCrossParams.uHighThreshold = parm[1].value;
   2256        pThresholdCrossParams.uLowThreshold = parm[2].value;
   2257 
   2258        if (pThresholdCrossParams.uLowThreshold > pThresholdCrossParams.uHighThreshold)
   2259        {
   2260           console_printf_terminal ("Low threshold cannot be higher than the High threshold...Aborting...\n");
   2261        }
   2262        else
   2263        {
   2264 
   2265            resultCode = TI_SetPhyRateThreshold(g_id_adapter, &pThresholdCrossParams);
   2266 
   2267            if (resultCode == TI_RESULT_OK)
   2268            {
   2269               console_printf_terminal ("PHY rate threshold for AC %d has been set to:\n LowThreshold = %d\n HighThreshold = %d\n",
   2270                        pThresholdCrossParams.uAC,
   2271                        pThresholdCrossParams.uLowThreshold,
   2272                        pThresholdCrossParams.uHighThreshold);
   2273            }
   2274            else
   2275            {
   2276               console_printf_terminal ("Error...\n");
   2277            }
   2278        }
   2279    }
   2280    else if (nParms == 1)
   2281    {
   2282       pThresholdCrossParams.uAC = parm[0].value;
   2283       pThresholdCrossParams.uLowThreshold = 0;
   2284       pThresholdCrossParams.uHighThreshold = 0;
   2285 
   2286       resultCode = TI_GetPhyRateThreshold(g_id_adapter, &pThresholdCrossParams);
   2287 
   2288       console_printf_terminal ("PHY rate threshold for AC %d:\n",pThresholdCrossParams.uAC);
   2289       console_printf_terminal ("LowThreshold = %s\n",print_rate((rate_e) pThresholdCrossParams.uLowThreshold));
   2290       console_printf_terminal ("HighThreshold = %s\n",print_rate((rate_e) pThresholdCrossParams.uHighThreshold));
   2291    }
   2292 
   2293 }
   2294 
   2295 void cmd_traffic_intensity_threshold(ConParm_t parm[], U16 nParms)
   2296 {
   2297    OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS pTrafficIntensityThresholds;
   2298    tiUINT32 resultCode;
   2299 
   2300    if (nParms == 3)
   2301    {
   2302       pTrafficIntensityThresholds.uHighThreshold = parm[0].value;
   2303       pTrafficIntensityThresholds.uLowThreshold = parm[1].value;
   2304       pTrafficIntensityThresholds.TestInterval = parm[2].value;
   2305 
   2306       if (pTrafficIntensityThresholds.uLowThreshold >= pTrafficIntensityThresholds.uHighThreshold)
   2307       {
   2308          console_printf_terminal ("Error: low threshold equal or greater than the high threshold...aborting...\n");
   2309       }
   2310 
   2311       resultCode = TI_SetTrafficIntensityThresholds (g_id_adapter, &pTrafficIntensityThresholds);
   2312 
   2313       if (resultCode == TI_RESULT_OK)
   2314       {
   2315          console_printf_terminal ("Successfully set traffic intensity thresholds...\n");
   2316 
   2317       }
   2318       else
   2319       {
   2320          console_printf_terminal ("Error: result code = %d\n",resultCode);
   2321       }
   2322    }
   2323    else if (nParms == 0)
   2324    {
   2325       resultCode = TI_GetTrafficIntensityThresholds (g_id_adapter, &pTrafficIntensityThresholds);
   2326 
   2327       if (resultCode == TI_RESULT_OK)
   2328       {
   2329          console_printf_terminal ("Traffic intensity thresholds :\n HighThreshold = %d\n LowThreshold = %d\n TestInterval = %d\n",
   2330                   pTrafficIntensityThresholds.uHighThreshold,
   2331                   pTrafficIntensityThresholds.uLowThreshold,
   2332                   pTrafficIntensityThresholds.TestInterval);
   2333       }
   2334       else
   2335       {
   2336          console_printf_terminal ("Error: result code = %d\n",resultCode);
   2337       }
   2338 
   2339    }
   2340 
   2341 }
   2342 
   2343 void cmd_enable_traffic_events(ConParm_t parm[], U16 nParms)
   2344 {
   2345    TI_ToggleTrafficIntensityEvents (g_id_adapter, (tiUINT32)TRUE);
   2346    console_printf_terminal ("Traffic intensity thresholds enabled...\n");
   2347 }
   2348 
   2349 void cmd_disable_traffic_events(ConParm_t parm[], U16 nParms)
   2350 {
   2351    TI_ToggleTrafficIntensityEvents (g_id_adapter, (tiUINT32)FALSE);
   2352    console_printf_terminal ("Traffic intensity thresholds disabled...\n");
   2353 }
   2354 
   2355 void cmd_config_tx_classifier(ConParm_t parm[], U16 nParms)
   2356 {
   2357     NWIF_CLSFR_ENTRY inParamsBuff[CLI_NUM_OF_TX_CLASFR_CON];
   2358 
   2359     UINT32 inParamsBuffLen = 0;
   2360     UINT8 i,ic,iv=0;
   2361 
   2362     for( ic=0,iv=0; ic<CLI_NUM_OF_TX_CLASFR_CON; ic++)
   2363     {
   2364         inParamsBuff[ic].port = (UINT16 )parm[iv].value;
   2365         iv++;
   2366         inParamsBuff[ic].pri = (UINT16 )parm[iv].value;
   2367         iv++;
   2368         inParamsBuff[ic].ip = 0;
   2369 
   2370 
   2371         inParamsBuffLen += sizeof(NWIF_CLSFR_ENTRY);
   2372 
   2373     }
   2374     for( i=0; i<4; i++,iv++)
   2375     {
   2376         for(ic=0;ic<CLI_NUM_OF_TX_CLASFR_CON;ic++)
   2377         {
   2378             inParamsBuff[ic].ip |= parm[iv].value << i * 8;
   2379         }
   2380     }
   2381 }
   2382 
   2383 void cmd_remove_clsfr_entry (ConParm_t parm[], U16 uParms)
   2384 {
   2385     clsfr_tableEntry_t newUserTableEntry;
   2386     int i;
   2387     clsfrTypeAndSupport ClsfrType;
   2388     tiINT32 res;
   2389 
   2390     TI_GetClsfrType(g_id_adapter, &ClsfrType );
   2391 
   2392     /* Possibly needs to be removed if we want to keep this routine working for old classifier as well */
   2393     if (ClsfrType.oldVersionSupport == TRUE)
   2394     {
   2395       console_printf_terminal ("Old classifier support detected...Remove action disabled (use old classifier config)\n");
   2396       return;
   2397     }
   2398 
   2399     if (uParms >=2)
   2400         newUserTableEntry.DTag = (tiUINT8) parm[1].value;
   2401 
   2402     switch(parm[0].value)
   2403     {
   2404         case D_TAG_CLSFR:
   2405             console_printf_terminal("Cannot remove D_TAG classifier entry!\n");
   2406             return;
   2407         break;
   2408         case DSCP_CLSFR:
   2409             if (uParms != 3)
   2410             {
   2411                 console_printf_terminal("DSCP_CLSFR Entry type, wrong number of parameters(too many?)\n");
   2412                 return;
   2413             }
   2414             newUserTableEntry.Dscp.CodePoint = (tiUINT8) parm[2].value;
   2415             console_printf_terminal ("Removing DSCP_CLSFR classifier entry\nD-Tag = %d\nCodePoint = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.CodePoint);
   2416         break;
   2417         case PORT_CLSFR:
   2418             if (uParms != 3)
   2419             {
   2420                 console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters(too many?)\n");
   2421                 return;
   2422             }
   2423             newUserTableEntry.Dscp.DstPortNum = (tiUINT16) parm[2].value;
   2424             console_printf_terminal ("Removing PORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.DstPortNum);
   2425         break;
   2426         case IPPORT_CLSFR:
   2427             if (uParms != 7)
   2428             {
   2429                 console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters\n");
   2430                 return;
   2431             }
   2432             newUserTableEntry.Dscp.DstIPPort.DstPortNum = (tiUINT16) parm[2].value;
   2433             newUserTableEntry.Dscp.DstIPPort.DstIPAddress = 0;
   2434             for(i=0; i<4; i++)
   2435                 {
   2436                     newUserTableEntry.Dscp.DstIPPort.DstIPAddress |= parm[i+3].value << i * 8;
   2437                 }
   2438             console_printf_terminal ("Removing IPPORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\nIP = %3d.%d.%d.%d\n",
   2439                     newUserTableEntry.DTag,
   2440                     newUserTableEntry.Dscp.DstIPPort.DstPortNum,
   2441                     (int)parm[3].value,(int)parm[4].value,(int)parm[5].value,(int)parm[6].value);
   2442             break;
   2443         default:
   2444             console_printf_terminal("Unknown Classifier Type - Command aborted!\n");
   2445             return;
   2446         break;
   2447     }
   2448 
   2449     res = TI_RemoveClassifierEntry(g_id_adapter, &newUserTableEntry);
   2450     if (res)
   2451     {
   2452        console_printf_terminal ("Failed to remove classifier entry...return code = %d\n",res);
   2453     }
   2454 
   2455 }
   2456 
   2457 void cmd_insert_clsfr_entry (ConParm_t parm[], U16 uParms)
   2458 {
   2459     clsfr_tableEntry_t newUserTableEntry;
   2460     int i;
   2461     clsfrTypeAndSupport ClsfrType;
   2462     tiINT32 res;
   2463 
   2464     TI_GetClsfrType(g_id_adapter, &ClsfrType );
   2465 
   2466     if (ClsfrType.oldVersionSupport == TRUE)
   2467     {
   2468       console_printf_terminal ("Old classifier support detected...Insert action disabled (use old classifier config)\n");
   2469       return;
   2470     }
   2471 
   2472     if (uParms >=2)
   2473         newUserTableEntry.DTag = (UINT8) parm[1].value;
   2474 
   2475     switch(parm[0].value)
   2476     {
   2477         case D_TAG_CLSFR:
   2478             console_printf_terminal("Cannot insert D_TAG classifier entry!\n");
   2479             return;
   2480         break;
   2481         case DSCP_CLSFR:
   2482             if (uParms != 3)
   2483             {
   2484                 console_printf_terminal("DSCP_CLSFR Entry type, wrong number of parameters(too many?)\n");
   2485                 return;
   2486             }
   2487             newUserTableEntry.Dscp.CodePoint = (UINT8) parm[2].value;
   2488             console_printf_terminal ("Inserting new DSCP_CLSFR classifier entry\nD-Tag = %d\nCodePoint = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.CodePoint);
   2489         break;
   2490         case PORT_CLSFR:
   2491             if (uParms != 3)
   2492             {
   2493                 console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters(too many?)\n");
   2494                 return;
   2495             }
   2496             newUserTableEntry.Dscp.DstPortNum = (UINT16) parm[2].value;
   2497             console_printf_terminal ("Inserting new PORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\n",newUserTableEntry.DTag,newUserTableEntry.Dscp.DstPortNum);
   2498         break;
   2499         case IPPORT_CLSFR:
   2500             if (uParms != 7)
   2501             {
   2502                 console_printf_terminal("PORT_CLSFR Entry type, wrong number of parameters\n");
   2503                 return;
   2504             }
   2505             newUserTableEntry.Dscp.DstIPPort.DstPortNum = (UINT16) parm[2].value;
   2506             newUserTableEntry.Dscp.DstIPPort.DstIPAddress = 0;
   2507             for(i=0; i<4; i++)
   2508                 {
   2509                     newUserTableEntry.Dscp.DstIPPort.DstIPAddress |= parm[i+3].value << i * 8;
   2510                 }
   2511             console_printf_terminal ("Inserting new IPPORT_CLSFR classifier entry\nD-Tag = %d\nPort = %d\nIP = %3d.%d.%d.%d\n",
   2512                     newUserTableEntry.DTag,
   2513                     newUserTableEntry.Dscp.DstIPPort.DstPortNum,
   2514                     (int)parm[3].value,(int)parm[4].value,(int)parm[5].value,(int)parm[6].value);
   2515             break;
   2516         default:
   2517             console_printf_terminal("Unknown Classifier Type - Command aborted!\n");
   2518             return;
   2519         break;
   2520     }
   2521 
   2522     res = TI_ConfigTxClassifier(g_id_adapter, sizeof(clsfr_tableEntry_t), (UINT8 *)&newUserTableEntry);
   2523     if (res)
   2524     {
   2525        console_printf_terminal ("Failed to insert new classifier entry...return code = %d\n",res);
   2526     }
   2527 
   2528 }
   2529 
   2530 void cmd_poll_ap_packets(ConParm_t parm[], U16 nParms)
   2531 {
   2532    if (nParms == 0)
   2533    {
   2534    TI_PollApPackets (g_id_adapter);
   2535    console_printf_terminal ("Poll AP packets cmd sent to driver...\n");
   2536 }
   2537    else if (nParms == 1)
   2538    {
   2539       TI_PollApPacketsFromAC (g_id_adapter,parm[0].value);
   2540       console_printf_terminal ("Poll AP packets (From AC %d) cmd sent to driver...\n",(int)parm[0].value);
   2541    }
   2542 
   2543 }
   2544 
   2545 void cmd_modify_rate(ConParm_t parm[], U16 nParms)
   2546 {
   2547     tiUINT32 data = 0, data1 = 0;
   2548 
   2549     if( !TI_GetDesiredRate(g_id_adapter, &data1 ) )
   2550     {
   2551         TI_GetCurrentRate(g_id_adapter, &data );
   2552 
   2553         console_printf_terminal("Rate: %s", print_rate(data));
   2554         console_printf_terminal(", desired rate: %s\n", print_rate(data1));
   2555     }
   2556 }
   2557 
   2558 
   2559 #if 0    /* not in use*/
   2560 void cmd_net_current_regdomain(ConParm_t parm[], U16 nParms)
   2561 {
   2562     UNUSED(nParms);
   2563     UNUSED(parm);
   2564 
   2565     console_printf_terminal("not implemented...\n");
   2566 }
   2567 
   2568  static named_value_t network_type_name[] = {
   2569      { os802_11FH,                     "FH" } ,
   2570      { os802_11DS,                     "DS" } ,
   2571      { os802_11OFDM5,                  "OFDM5" } ,
   2572      { os802_11OFDM24,                 "OFDM24" } ,
   2573      { os802_11OFDM24_AND_5,           "OFDM24_AND_5" } ,
   2574      { os802_11NetworkTypeMax,         "NetworkTypeMax" }
   2575  };
   2576 
   2577 void cmd_net_network_in_use(ConParm_t parm[], U16 nParms)
   2578 {
   2579     OS_802_11_NETWORK_TYPE data;
   2580     if( !nParms )
   2581     {
   2582         if( !TI_GetNetworkTypeInUse(g_id_adapter, &data ) )
   2583         {
   2584             print_available_values(network_type_name);
   2585 
   2586              console_printf_terminal("Cur.network: %d\n", data );
   2587         }
   2588     }
   2589     else
   2590         TI_SetNetworkTypeInUse(g_id_adapter, parm[0].value );
   2591 }
   2592 #endif /* if 0*/
   2593 
   2594 void cmd_show_tx_power_level_table(ConParm_t parm[], U16 nParms)
   2595 {
   2596     TIWLAN_POWER_LEVEL_TABLE powerTable;
   2597 	int i;
   2598 
   2599     if( !TI_GetTxPowerLevel(g_id_adapter, (tiCHAR*)&powerTable) )
   2600 	{
   2601         console_printf_terminal("Power level table (Dbm/10)\n");
   2602 		for ( i = 0 ; i < TI_NUM_OF_SUB_BANDS ; i++)
   2603 		{
   2604 			console_printf_terminal("sub-band %i: %d %d %d %d\n", i,
   2605 			powerTable.uTxPower[i][0],
   2606 			powerTable.uTxPower[i][1],
   2607 			powerTable.uTxPower[i][2],
   2608 			powerTable.uTxPower[i][3]);
   2609 		}
   2610 	}
   2611     else
   2612 	{
   2613         console_printf_terminal("Tx Power level table ERROR !!!\n");
   2614 	}
   2615 }
   2616 void cmd_tx_power_dbm(ConParm_t parm[], U16 nParms)
   2617 {
   2618     tiCHAR dummyData = 0;
   2619 
   2620 	if (nParms == 0)
   2621 	{
   2622 		if( !TI_GetTxPowerDbm(g_id_adapter, &dummyData))
   2623 		{
   2624 			console_printf_terminal("Tx Power (Dbm/10) = %d\n", dummyData);
   2625 		}
   2626 	}
   2627     else
   2628     {
   2629         if (parm[0].value > MAX_TX_POWER)
   2630         {
   2631             console_printf_terminal("Hey !!! You should use values between %d and %d\n", MIN_TX_POWER, MAX_TX_POWER);
   2632             return;
   2633         }
   2634         /* use U8 cast to fix compile warning */
   2635         if(! TI_SetTxPowerDbm(g_id_adapter, (U8)parm[0].value) )
   2636         {
   2637             console_printf_terminal("Set Tx Power in DBM/10 = %d\n", parm[0].value);
   2638         }
   2639     }
   2640 }
   2641 
   2642 
   2643 void cmd_enableDisable_802_11d(ConParm_t parm[], U16 nParms)
   2644 {
   2645     UINT8 data = 0;
   2646     tiINT32 result;
   2647 
   2648     result = TI_Get_802_11d(g_id_adapter, &data );
   2649     if ( nParms == 0 )
   2650     {
   2651         if( result ==  TI_RESULT_OK)
   2652         {
   2653             console_printf_terminal("802_11d status=%d\n", data );
   2654         }
   2655     }
   2656     else
   2657     {
   2658         result = TI_EnableDisable_802_11d(g_id_adapter, (UINT8) parm[0].value);
   2659         if ((result != TI_RESULT_OK) && (!parm[0].value))
   2660         {
   2661             result = TI_Get_802_11h(g_id_adapter, &data );
   2662             if (data)
   2663             {
   2664                 console_printf_terminal("802_11d cannot be disabled while 802_11h is enabled!!\n" );
   2665             }
   2666         }
   2667         else
   2668         {
   2669             console_printf_terminal("802_11d status is updated to =%d\n", parm[0].value );
   2670         }
   2671 
   2672     }
   2673 
   2674 
   2675 }
   2676 
   2677 void cmd_enableDisable_802_11h(ConParm_t parm[], U16 nParms)
   2678 {
   2679     UINT8 data = 0;
   2680     tiINT32 result;
   2681 
   2682     result = TI_Get_802_11h(g_id_adapter, &data );
   2683     if( nParms == 0 )
   2684     {
   2685         if( result ==  TI_RESULT_OK)
   2686         {
   2687             console_printf_terminal("802_11h status=%d\n", data );
   2688         }
   2689     }
   2690     else
   2691     {
   2692         TI_EnableDisable_802_11h(g_id_adapter, (UINT8) parm[0].value);
   2693         if (parm[0].value)
   2694         {
   2695             console_printf_terminal("802_11h enables automatically 802_11d!!\n" );
   2696         }
   2697 
   2698         console_printf_terminal("802_11h status is updated to =%d\n", parm[0].value );
   2699 
   2700     }
   2701 
   2702 
   2703 }
   2704 
   2705 void cmd_d_Country_2_4Ie(ConParm_t parm[], U16 nParms)
   2706 {
   2707     tiINT32 result;
   2708 
   2709     if( nParms == 0 )
   2710     {
   2711         UINT8   countryString[COUNTRY_STRING_LEN+1];
   2712         result = TI_Get_countryIeFor2_4_Ghz(g_id_adapter, (UINT8**)&countryString );
   2713         if( result ==  TI_RESULT_OK)
   2714         {
   2715             countryString[COUNTRY_STRING_LEN] = '\0';
   2716             if (countryString[0] == '\0')
   2717             {
   2718                 console_printf_terminal("802_11d Country for 2.4 GHz is not found\n");
   2719             }
   2720             else
   2721             {
   2722                 console_printf_terminal("802_11d Country for 2.4 GHz is %s \n", countryString );
   2723             }
   2724 
   2725         }
   2726     }
   2727     else
   2728     {
   2729         country_t countryWorld;
   2730 
   2731         countryWorld.elementId = COUNTRY_IE_ID;
   2732         countryWorld.len = 6;
   2733         memcpy( countryWorld.countryIE.CountryString,"GB ", 3);
   2734         countryWorld.countryIE.tripletChannels[0].firstChannelNumber = 1;
   2735         countryWorld.countryIE.tripletChannels[0].maxTxPowerLevel = 23;
   2736         countryWorld.countryIE.tripletChannels[0].numberOfChannels = 11;
   2737         console_printf_terminal("802_11d Start Setting GB Country for 2.4 GHz \n");
   2738 
   2739         result = TI_Set_countryIeFor2_4_Ghz(g_id_adapter, countryWorld);
   2740 
   2741         console_printf_terminal("802_11d Setting GB Country for 2.4 GHz, result=%d\n", result);
   2742 
   2743     }
   2744 
   2745 
   2746 }
   2747 
   2748 void cmd_d_Country_5Ie(ConParm_t parm[], U16 nParms)
   2749 {
   2750     tiINT32 result;
   2751 
   2752     if( nParms == 0 )
   2753     {
   2754         UINT8   countryString[COUNTRY_STRING_LEN+1];
   2755         result = TI_Get_countryIeFor5_Ghz(g_id_adapter, (UINT8**)&countryString );
   2756         if( result ==  TI_RESULT_OK)
   2757         {
   2758             countryString[COUNTRY_STRING_LEN] = '\0';
   2759             if (countryString[0] == '\0')
   2760             {
   2761                 console_printf_terminal("802_11d Country for 5 GHz is not found\n");
   2762             }
   2763             else
   2764             {
   2765                 console_printf_terminal("802_11d Country for 5 GHz is %s\n", countryString );
   2766             }
   2767         }
   2768     }
   2769     else
   2770     {
   2771         country_t countryWorld;
   2772 
   2773         countryWorld.elementId = COUNTRY_IE_ID;
   2774         countryWorld.len = 6;
   2775         memcpy( countryWorld.countryIE.CountryString,"US ", 3);
   2776         countryWorld.countryIE.tripletChannels[0].firstChannelNumber = 36;
   2777         countryWorld.countryIE.tripletChannels[0].maxTxPowerLevel = 16;
   2778         countryWorld.countryIE.tripletChannels[0].numberOfChannels = 8;
   2779         result = TI_Set_countryIeFor5_Ghz(g_id_adapter, countryWorld);
   2780 
   2781         console_printf_terminal("802_11d Setting US Country for 5 GHz, result=%d\n", result);
   2782 
   2783     }
   2784 
   2785 }
   2786 
   2787 void cmd_DFS_range(ConParm_t parm[], U16 nParms)
   2788 {
   2789     tiINT32 result;
   2790     DFS_ChannelRange_t DFS_ChannelRange;
   2791 
   2792     if( nParms == 0 )
   2793     {
   2794 
   2795         result = TI_Get_minMaxDfsChannels(g_id_adapter, &DFS_ChannelRange );
   2796         if( result ==  TI_RESULT_OK)
   2797         {
   2798             console_printf_terminal("DFS min channel is %d, DFS max channel is %d\n",
   2799                                     DFS_ChannelRange.minDFS_channelNum, DFS_ChannelRange.maxDFS_channelNum);
   2800         }
   2801     }
   2802     else
   2803     {
   2804         DFS_ChannelRange.minDFS_channelNum = (UINT16) parm[0].value;
   2805         DFS_ChannelRange.maxDFS_channelNum = (UINT16) parm[1].value;
   2806 
   2807         console_printf_terminal("Given params: min channel %d, DFS max channel %d\n",
   2808                                 parm[0].value, parm[1].value);
   2809 
   2810         result = TI_Set_minMaxDfsChannels(g_id_adapter, DFS_ChannelRange);
   2811         if (result ==  TI_RESULT_OK)
   2812         {
   2813             console_printf_terminal("Setting DFS min channel %d, DFS max channel %d\n",
   2814                                     DFS_ChannelRange.minDFS_channelNum, DFS_ChannelRange.maxDFS_channelNum);
   2815         }
   2816         else
   2817         {
   2818             console_printf_terminal("Setting DFS min channel %d, DFS max channel %d - FAILED !!\n",
   2819                                     DFS_ChannelRange.minDFS_channelNum, DFS_ChannelRange.maxDFS_channelNum);
   2820         }
   2821     }
   2822 
   2823 }
   2824 
   2825 #if 0
   2826 void cmd_modify_tx_power_value(ConParm_t parm[], U16 nParms)
   2827 {
   2828     if( nParms == 0 )
   2829     {
   2830         tiUINT32 data = 1234;
   2831         if( !TI_GetTxPowerValue(g_id_adapter, &data) )
   2832             console_printf_terminal(  "Tx Power val = %ld\n", data);
   2833     }
   2834     else
   2835         TI_SetTxPowerValue(g_id_adapter, parm[0].value);
   2836 }
   2837 #endif
   2838 
   2839 void cmd_show_regdomain_table(ConParm_t parm[], U16 nParms)
   2840 {
   2841     UNUSED(nParms);
   2842     UNUSED(parm);
   2843     console_printf_terminal(  "not implemented ....\n");
   2844 }
   2845 
   2846 void cmd_modify_4x_state(ConParm_t parm[], U16 nParms)
   2847 {
   2848     if( nParms == 0 )
   2849     {
   2850         tiBOOL data = FALSE;
   2851         if( !TI_Get4XState(g_id_adapter, &data ) )
   2852             console_printf_terminal("4x state=%s\n", data ? "True" : "False" );
   2853     }
   2854     else    /* param <read-only!!> */
   2855         TI_Set4XState(g_id_adapter, (BOOL) parm[0].value);
   2856 }
   2857 
   2858 static named_value_t BSS_type[] =
   2859 {
   2860     { os802_11IBSS,                  "AD-Hoc" },
   2861     { os802_11Infrastructure,        "Infr." },
   2862     { os802_11AutoUnknown,           "Auto" },
   2863 /*    { os802_11HighSpeedIBSS,         "HighSpeedIBSS" },*/
   2864 /*    { os802_11InfrastructureMax,     "Max" }*/
   2865 };
   2866 
   2867 void cmd_modify_bss_type(ConParm_t parm[], U16 nParms)
   2868 {
   2869     OS_802_11_NETWORK_MODE data = 0;     //TRS:MEB use correct datatype to avoid compiler warning
   2870     if( nParms == 0 )
   2871     {
   2872         if( !TI_GetBSSType(g_id_adapter, &data ) )
   2873         {
   2874             print_available_values(BSS_type);
   2875 
   2876             console_printf_terminal("Current mode=%d\n", data );
   2877         }
   2878     }
   2879     else    /* param <read-only!!> */
   2880         TI_SetBSSType(g_id_adapter, (BOOL) parm[0].value);
   2881 }
   2882 
   2883 void cmd_get_driver_state(ConParm_t parm[], U16 nParms)
   2884 {
   2885    static char stateDesc[6][100] =
   2886 {
   2887     "DRIVER_STATE_IDLE",
   2888     "DRIVER_STATE_SCANNING",
   2889     "DRIVER_STATE_SELECTING",
   2890     "DRIVER_STATE_CONNECTING",
   2891     "DRIVER_STATE_CONNECTED",
   2892     "DRIVER_STATE_DISCONNECTED",
   2893 };
   2894    driverState_e myState;
   2895 
   2896    TI_GetDriverState (g_id_adapter, &myState);
   2897    console_printf_terminal("Driver state is %s\n", stateDesc[(UINT8)myState]);
   2898 }
   2899 
   2900 void cmd_modify_ext_rates_ie(ConParm_t parm[], U16 nParms)
   2901 {
   2902     static named_value_t ExtRatesIE[] =
   2903     {
   2904         { DRAFT_5_AND_EARLIER,  "5_AND_EARLIER" },
   2905         { DRAFT_6_AND_LATER,    "6_AND_LATER" }
   2906     };
   2907     if( nParms == 0 )
   2908     {
   2909         tiUINT32 data = 1122;
   2910         if( !TI_GetExtRatesIE(g_id_adapter, &data ) )
   2911         {
   2912             print_available_values(ExtRatesIE);
   2913             console_printf_terminal("ExtRatesIE=%u\n", data  );
   2914         }
   2915     }
   2916     else
   2917         TI_SetExtRatesIE(g_id_adapter, (tiUINT32) parm[0].value);
   2918 }
   2919 
   2920 
   2921 /*will return RSSI*/
   2922 void cmd_get_rsii_level(ConParm_t parm[], U16 nParms)
   2923 {
   2924    tiINT32 rssi ;
   2925    TI_GetRSSI(g_id_adapter, &rssi);
   2926    console_printf_terminal("\n Current RSSI : %d\n" ,rssi)  ; // TRS:WDK - add return
   2927 }
   2928 
   2929 
   2930 /*will return SNR ratio*/
   2931 void cmd_get_snr_ratio(ConParm_t parm[], U16 nParms)
   2932 {
   2933    tiUINT32 snr ;
   2934    TI_GetSNR(g_id_adapter, &snr);
   2935    console_printf_terminal("\n Current SNR ratio : %d\n" ,snr)  ;  // TRS:WDK - add return
   2936 }
   2937 
   2938 void cmd_modify_frag_threshold(ConParm_t parm[], U16 nParms)
   2939 {
   2940     if( nParms == 0 )
   2941     {
   2942         tiUINT32 data = 0xfefefefe;
   2943         if( !TI_GetFragmentThreshold(g_id_adapter, &data ) )
   2944             console_printf_terminal("Frag. threshold=%d\n", data );
   2945     }
   2946     else
   2947         TI_SetFragmentThreshold(g_id_adapter, parm[0].value);
   2948 }
   2949 
   2950 void cmd_modify_short_slot(ConParm_t parm[], U16 nParms)
   2951 {
   2952     if( nParms == 0 )
   2953     {
   2954         tiUINT32 data = 0xfefefefe;
   2955         if( !TI_GetShortSlot(g_id_adapter, &data ) )
   2956             console_printf_terminal("Short slot=%d\n", data );
   2957     }
   2958     else
   2959         TI_SetShortSlot(g_id_adapter, parm[0].value);
   2960 }
   2961 
   2962 void cmd_modify_rts_threshold(ConParm_t parm[], U16 nParms)
   2963 {
   2964     if( nParms == 0 )
   2965     {
   2966         tiUINT32 data = 0xfefefefe;
   2967         if( !TI_GetRTSThreshold( g_id_adapter, &data) )
   2968             console_printf_terminal("RTSThreshold=%d\n", data );
   2969     }
   2970     else
   2971         TI_SetRTSThreshold(g_id_adapter, parm[0].value);
   2972 }
   2973 
   2974 void cmd_modify_preamble(ConParm_t parm[], U16 nParms)
   2975 {
   2976     if( nParms == 0 )
   2977     {
   2978         tiUINT32 data = 0xfefefefe;
   2979         if( !TI_GetShortPreamble( g_id_adapter, &data) )
   2980             console_printf_terminal("ShortPreamble=%d\n", data );
   2981     }
   2982     else
   2983         TI_SetShortPreamble(g_id_adapter, parm[0].value);
   2984 }
   2985 
   2986 void cmd_modify_antenna_diversity(ConParm_t parm[], U16 nParms)
   2987 {
   2988     TIWLAN_ANT_DIVERSITY antennaDiversityOptions;
   2989 
   2990     antennaDiversityOptions.enableRxDiversity = (UINT8)parm[0].value;
   2991     antennaDiversityOptions.rxSelectedAntenna = (UINT8)parm[1].value;
   2992     antennaDiversityOptions.enableTxDiversity = (UINT8)parm[2].value;
   2993     antennaDiversityOptions.txSelectedAntenna = (UINT8)parm[3].value;
   2994     antennaDiversityOptions.rxTxSharedAnts = (UINT8)parm[4].value;
   2995     TI_SetAntennaDiversityParams(g_id_adapter, &antennaDiversityOptions);
   2996     console_printf_terminal("Antenna diversity parameters sent.\n");
   2997 }
   2998 
   2999 void cmd_modify_short_retry(ConParm_t parm[], U16 nParms)
   3000 {
   3001     if( nParms == 0 )
   3002     {
   3003         tiUINT32 data = 0xfefefefe;
   3004         if( !TI_GetShortRetry( g_id_adapter, &data) )
   3005             console_printf_terminal("ShortRetry=%d\n", data );
   3006     }
   3007     else
   3008         TI_SetShortRetry(g_id_adapter, parm[0].value);
   3009 }
   3010 
   3011 void cmd_modify_long_retry(ConParm_t parm[], U16 nParms)
   3012 {
   3013     if( nParms == 0 )
   3014     {
   3015         tiUINT32 data = 0xfefefefe;
   3016         if( !TI_GetLongRetry( g_id_adapter, &data) )
   3017             console_printf_terminal("LongRetry=%d\n", data );
   3018     }
   3019     else
   3020         TI_SetLongRetry(g_id_adapter, parm[0].value);
   3021 }
   3022 
   3023 void cmd_start_driver(ConParm_t parm[], U16 nParms)
   3024 {
   3025     TI_Start( g_id_adapter );
   3026 }
   3027 
   3028 void cmd_stop_driver(ConParm_t parm[], U16 nParms)
   3029 {
   3030     UNUSED(nParms);
   3031     UNUSED(parm);
   3032     TI_Stop(g_id_adapter);
   3033 }
   3034 static TI_HANDLE eventRegistered[IPC_EVENT_MAX];
   3035 
   3036 static named_value_t event_type[] = {
   3037     { IPC_EVENT_ASSOCIATED,             "Associated" },
   3038     { IPC_EVENT_DISASSOCIATED,          "Disassociated"  },
   3039     { IPC_EVENT_LINK_SPEED,             "LinkSpeed" },
   3040     { IPC_EVENT_AUTH_SUCC,              "Authentication Success" },
   3041     { IPC_EVENT_SCAN_COMPLETE,          "ScanComplete" },
   3042     { IPC_EVENT_TIMEOUT,                "Timeout" },
   3043     { IPC_EVENT_CCKM_START,             "CCKM_Start" },
   3044     { IPC_EVENT_MEDIA_SPECIFIC,         "Media_Specific" },
   3045     { IPC_EVENT_EAPOL,                  "EAPOL" },
   3046     { IPC_EVENT_BOUND,                  "Bound" },
   3047     { IPC_EVENT_UNBOUND,                "Unbound" },
   3048     { IPC_EVENT_PREAUTH_EAPOL,          "PreAuth EAPOL"},
   3049 /*  { IPC_EVENT_PER,                    "PER" },*/
   3050     { IPC_EVENT_LOW_SNR,               "Low SNR" },
   3051     { IPC_EVENT_LOW_RSSI,               "Low RSSI" },
   3052     { IPC_EVENT_TSPEC_STATUS,           "IPC_EVENT_TSPEC_STATUS" },
   3053     { IPC_EVENT_TSPEC_RATE_STATUS,      "IPC_EVENT_TSPEC_RATE_STATUS" },
   3054     { IPC_EVENT_MEDIUM_TIME_CROSS,      "IPC_EVENT_MEDIUM_TIME_CROSS" },
   3055     { IPC_EVENT_ROAMING_COMPLETE,       "ROAMING_COMPLETE"},
   3056     { IPC_EVENT_EAP_AUTH_FAILURE,       "EAP-FAST/LEAP Auth Failed"},
   3057     { IPC_EVENT_WPA2_PREAUTHENTICATION, "IPC_EVENT_WPA2_PREAUTHENTICATION" },
   3058     { IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED, "IPC_EVENT_TRAFFIC_INTENSITY_THRESHOLD_CROSSED" },
   3059     { IPC_EVENT_BT_COEX_MODE, 	"IPC_EVENT_BT_COEX_MODE" },
   3060 
   3061 };
   3062 
   3063 
   3064 void cmd_events_register(ConParm_t parm[], U16 nParms)
   3065 {
   3066     tiUINT32 event;
   3067     IPC_EVENT_PARAMS pEvent;
   3068 
   3069    if( nParms )
   3070    {
   3071         event = (tiUINT32)parm[0].value;
   3072 
   3073         if (events_mask & (1 << event))
   3074         {
   3075 #ifndef _WINDOWS
   3076             console_printf_terminal("cmd_events_register, event is already enabled! (%d)\n", events_mask);
   3077 #endif
   3078         }
   3079         else
   3080    {
   3081         pEvent.uEventType       = (tiUINT32)parm[0].value;
   3082         pEvent.uDeliveryType      = DELIVERY_PUSH;
   3083         pEvent.pfEventCallback = cli_receive_ev;
   3084 #ifdef _WINDOWS
   3085 #endif
   3086         if( !TI_RegisterEvent(g_id_adapter, &pEvent) )
   3087             {
   3088             eventRegistered[pEvent.uEventType] = pEvent.uEventID;
   3089 
   3090                 events_mask |= (1 << event);
   3091 #ifdef _WINDOWS
   3092 #endif
   3093             }
   3094         }
   3095         }
   3096     else
   3097         {
   3098 #ifdef _WINDOWS
   3099 #else
   3100 		print_available_values(event_type);
   3101 #endif
   3102     }
   3103 
   3104         }
   3105 void cmd_events_unregister(ConParm_t parm[], U16 nParms)
   3106 {
   3107     tiUINT32 event;
   3108     IPC_EVENT_PARAMS pEvent;
   3109 
   3110    if( nParms )
   3111    {
   3112         event = (tiUINT32)parm[0].value;
   3113 #ifdef _WINDOWS
   3114 #else
   3115         pEvent.uEventType = event;
   3116         pEvent.uEventID = eventRegistered[pEvent.uEventType];
   3117         TI_UnRegisterEvent(g_id_adapter, &pEvent);
   3118 
   3119         events_mask &= ~(1 << event);
   3120 #endif
   3121     }
   3122     else
   3123     {
   3124 #ifdef _WINDOWS
   3125 #else
   3126         print_available_values(event_type);
   3127 #endif
   3128     }
   3129 }
   3130 
   3131 void cmd_get_selected_bssid_info(ConParm_t parm[], U16 nParms)
   3132 {
   3133    OS_802_11_BSSID_EX myInfo;
   3134    TI_GetSelectedBSSIDInfo(g_id_adapter, &myInfo);
   3135 
   3136    console_printf_terminal("Selected BSSID Info:\n");
   3137    console_printf_terminal("--------------------\n");
   3138    console_printf_terminal("SSID: %s\n", get_ssid_string(&myInfo.Ssid));
   3139    console_printf_terminal("BSSID: %02x.%02x.%02x.%02x.%02x.%02x\n",
   3140           myInfo.MacAddress[0], myInfo.MacAddress[1], myInfo.MacAddress[2], myInfo.MacAddress[3], myInfo.MacAddress[4], myInfo.MacAddress[5] );
   3141 }
   3142 
   3143 int parseBssidIe(OS_802_11_BSSID_EX * bssid)
   3144 {
   3145     OS_802_11_VARIABLE_IEs *pData;
   3146     dot11_WME_PARAM_t *  qosParams;
   3147 
   3148     int length;
   3149     int retval = 0;
   3150     /* console_printf_terminal("parseBssidIe,IElength=%d \n",bssid->IELength);*/
   3151     for (
   3152             length =sizeof(OS_802_11_FIXED_IEs) , pData = (OS_802_11_VARIABLE_IEs*) ((char*)bssid->IEs + sizeof(OS_802_11_FIXED_IEs));
   3153             length < (int)(bssid->IELength-3);
   3154             length += (pData->Length +2),pData =  (OS_802_11_VARIABLE_IEs*)((char*)bssid->IEs  + length)
   3155         )
   3156     {
   3157         /* console_printf_terminal("ElementID=%d pData=%x length=%d length1=%d\n",pData->ElementID,pData,pData->Length,length);*/
   3158         if (pData->ElementID == DOT11_WME_ELE_ID)
   3159         {
   3160             qosParams = (dot11_WME_PARAM_t *)pData;
   3161             /* console_printf_terminal("OUIType=%x OUI =%x %x %x \n",qosParams->OUIType,qosParams->OUI[0],qosParams->OUI[1],qosParams->OUI[2]);*/
   3162             if (qosParams->OUIType == dot11_WME_OUI_TYPE)
   3163             {
   3164                 retval |= dot11_WME_OUI_TYPE;
   3165             }
   3166 
   3167 
   3168         }
   3169     }
   3170 
   3171 
   3172     return retval;
   3173 }
   3174 
   3175 void cmd_bssid_list(ConParm_t parm[], U16 nParms)
   3176 {
   3177 
   3178     OS_802_11_BSSID_EX BssIdInfo;
   3179     TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
   3180     get_bssid_list(parm, nParms, FALSE , &BssIdInfo );
   3181 }
   3182 
   3183 void cmd_Full_bssid_list(ConParm_t parm[], U16 nParms)
   3184 {
   3185     OS_802_11_BSSID_EX BssIdInfo;
   3186     TI_GetSelectedBSSIDInfo(g_id_adapter, &BssIdInfo);
   3187     get_bssid_list(parm, nParms, TRUE , &BssIdInfo);
   3188 }
   3189 
   3190 /*When beacon filter is activated, the current RSSI of the connection with the AP will be displayed despite no beacons are
   3191  *passed up to the driver*/
   3192 static void get_bssid_list(ConParm_t parm[], U16 nParms, BOOL fullBssidList , OS_802_11_BSSID_EX *pBssid)
   3193 {
   3194     OS_802_11_BSSID_LIST_EX *list;/* = (OS_802_11_BSSID_LIST_EX *) data; */
   3195     OS_802_11_BSSID_EX *bssid;
   3196     tiUINT32 number_items, index;
   3197     char buffer[8] ;
   3198     int Qos = 0;
   3199 	BOOL isConnectedAp = FALSE ;   //TRS:MEB move this line earlier to avoid compile error
   3200     buffer[0] ='\0';
   3201 
   3202     UNUSED(nParms);
   3203     UNUSED(parm);
   3204 
   3205     if (fullBssidList)
   3206     {
   3207         if( TI_GetFullBSSIDList(g_id_adapter, &list) || !list )
   3208             return ;
   3209     }
   3210     else
   3211     {
   3212     if( TI_GetBSSIDList(g_id_adapter, &list) || !list )
   3213         return ;
   3214     }
   3215 
   3216 
   3217     bssid = &list->Bssid[0];
   3218     number_items = list->NumberOfItems;
   3219 
   3220     console_printf_terminal("BssId List: Num=%u\n", number_items );
   3221 
   3222     if( number_items )
   3223     {
   3224         console_printf_terminal("%17s %7s %4s %5s %7s  %10s %s\n", "MAC", "Privacy", "Rssi", "Infra", "Channel","Qos   ", "SSID");
   3225         while (number_items)
   3226         {
   3227             Qos = parseBssidIe(bssid);
   3228 
   3229 /*          console_printf_terminal("Qos=%d\n",Qos);*/
   3230             if (Qos & dot11_WME_OUI_TYPE)
   3231             {
   3232                 strcpy(buffer, "WME ");
   3233             }
   3234 
   3235             if (Qos == 0)
   3236             {
   3237                 strcpy(buffer, "NONE ");
   3238             }
   3239 
   3240             if (( 0 == memcmp(pBssid->MacAddress ,bssid->MacAddress,sizeof(OS_802_11_MAC_ADDRESS)) ) &&
   3241 				(pBssid->NetworkTypeInUse == bssid->NetworkTypeInUse))
   3242             {
   3243                 /*bssid->Rssi = staRssi ;*/
   3244                 isConnectedAp = TRUE ;
   3245             }
   3246             else
   3247             {
   3248                 isConnectedAp = FALSE ;
   3249             }
   3250 
   3251             console_printf_terminal("%s %s %7u %4d %5d %7d %10s %s\n",
   3252                     ( TRUE == isConnectedAp)?"*":" " ,
   3253                     print_mac_2_str(bssid->MacAddress),
   3254                     bssid->Privacy, bssid->Rssi,
   3255                     bssid->InfrastructureMode, Freq2Chan(bssid->Configuration.Union.channel),
   3256                     buffer,
   3257                     get_ssid_string(&bssid->Ssid) );
   3258 
   3259             if (fullBssidList)
   3260             {
   3261                 console_printf_terminal("   TSF 0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x\n",
   3262                       bssid->IEs[0], bssid->IEs[1], bssid->IEs[2], bssid->IEs[3],
   3263                       bssid->IEs[4], bssid->IEs[5], bssid->IEs[6], bssid->IEs[7]);
   3264                 console_printf_terminal("   BeaconInterval 0x%02x%02x\n",  bssid->IEs[9], bssid->IEs[8]);
   3265                 console_printf_terminal("   Capabilities   0x%02x%02x\n",  bssid->IEs[10], bssid->IEs[11]);
   3266                 console_printf_terminal("   Variable IEs:\n");
   3267                 for (index=12; index<bssid->IELength; index++)
   3268                 {
   3269                     if ((index-12)%8 == 0)
   3270                     {
   3271                         console_printf_terminal("\n   ");
   3272                     }
   3273                     console_printf_terminal("0x%02x ",bssid->IEs[index]);
   3274 
   3275                 }
   3276                 console_printf_terminal("\n");
   3277             }
   3278             bssid = (OS_802_11_BSSID_EX *) (((char *) bssid) + bssid->Length);
   3279             number_items--;
   3280         }
   3281         console_printf_terminal("Infra.mode:");
   3282         print_available_values(BSS_type);
   3283     }
   3284 
   3285     free(list);
   3286 }
   3287 
   3288 #ifdef _WINDOWS
   3289 #else
   3290 PACKED_STRUCT( OS_802_11_BSSID_EX_TEMP,
   3291 	tiUINT32                  Length;
   3292 	OS_802_11_MAC_ADDRESS     MacAddress;
   3293     PACKED_UNION(Union,
   3294         tiUINT8  Reserved[2];
   3295         tiUINT16 Capabilities;
   3296     );
   3297 	OS_802_11_SSID            Ssid;
   3298 	tiUINT32                  Privacy;
   3299 	OS_802_11_RSSI            Rssi;
   3300 	OS_802_11_NETWORK_TYPE    NetworkTypeInUse;
   3301 	OS_802_11_CONFIGURATION   Configuration;
   3302 	OS_802_11_NETWORK_MODE    InfrastructureMode;
   3303 	OS_802_11_RATES_EX        SupportedRates;
   3304 	tiUINT32                  IELength;
   3305 	tiUINT8                   IEs[MAX_BEACON_BODY_LENGTH+sizeof(OS_802_11_FIXED_IEs)];
   3306 );
   3307 #endif
   3308 
   3309 
   3310 void cmd_FullPrimaryBbssid(ConParm_t parm[], U16 nParms)
   3311 {
   3312     OS_802_11_BSSID_EX_TEMP bssid;
   3313     OS_802_11_BSSID_EX_TEMP *pBssid = &bssid;
   3314     UINT32  index;
   3315     char buffer[8] ;
   3316     int Qos = 0;
   3317     buffer[0] ='\0';
   3318 
   3319     UNUSED(nParms);
   3320     UNUSED(parm);
   3321 
   3322     memset(pBssid, 0, sizeof(OS_802_11_BSSID_EX));
   3323     pBssid->Length = sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) + MAX_BEACON_BODY_LENGTH;
   3324     if( TI_GetPrimaryBSSIDInfo(g_id_adapter, (OS_802_11_BSSID_EX*)pBssid))
   3325             return ;
   3326 
   3327     console_printf_terminal("Primary BssId: Length = %d, IELength=%d \n" , pBssid->Length, pBssid->IELength);
   3328 
   3329     if (pBssid->Length > sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) + MAX_BEACON_BODY_LENGTH)
   3330     {
   3331         console_printf_terminal("Error - Length = %d is too long!!\n", pBssid->Length);
   3332         return;
   3333     }
   3334     if (pBssid->Length < pBssid->IELength)
   3335     {
   3336         console_printf_terminal("Error - IELength = %d is too long!!\n", pBssid->IELength);
   3337         pBssid->IELength = 50;
   3338         print_mac_2_str(pBssid->MacAddress),
   3339 
   3340         console_printf_terminal("SSID len=%d\n", pBssid->Ssid.SsidLength);
   3341 
   3342         return;
   3343     }
   3344     console_printf_terminal("%17s %7s %4s %5s %7s  %10s %s\n", "MAC", "Privacy", "Rssi", "Infra", "Channel","Qos   ", "SSID");
   3345     Qos = parseBssidIe((OS_802_11_BSSID_EX*)pBssid);
   3346 
   3347     if (Qos & dot11_WME_OUI_TYPE)
   3348     {
   3349         strcpy(buffer, "WME ");
   3350     }
   3351 
   3352     if (Qos == 0)
   3353     {
   3354         strcpy(buffer, "NONE ");
   3355     }
   3356 
   3357     console_printf_terminal("%s %7u %4d %5d %7d %10s %s\n",
   3358             print_mac_2_str(pBssid->MacAddress),
   3359             pBssid->Privacy, pBssid->Rssi,
   3360             pBssid->InfrastructureMode, Freq2Chan(pBssid->Configuration.Union.channel),
   3361             buffer,
   3362             get_ssid_string(&pBssid->Ssid) );
   3363 
   3364     {
   3365         console_printf_terminal("   TSF 0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x-0x%02x\n",
   3366               pBssid->IEs[0], pBssid->IEs[1], pBssid->IEs[2], pBssid->IEs[3],
   3367               pBssid->IEs[4], pBssid->IEs[5], pBssid->IEs[6], pBssid->IEs[7]);
   3368         console_printf_terminal("   BeaconInterval 0x%02x%02x\n",  pBssid->IEs[9], pBssid->IEs[8]);
   3369         console_printf_terminal("   Capabilities   0x%02x%02x\n",  pBssid->IEs[10], pBssid->IEs[11]);
   3370         console_printf_terminal("   Variable IEs:\n");
   3371         for (index=12; index<pBssid->IELength; index++)
   3372         {
   3373             if ((index-12)%8 == 0)
   3374             {
   3375                 console_printf_terminal("\n   ");
   3376             }
   3377             console_printf_terminal("0x%02x ",pBssid->IEs[index]);
   3378 
   3379         }
   3380         console_printf_terminal("\n");
   3381     }
   3382     console_printf_terminal("\nInfra.mode:");
   3383     print_available_values(BSS_type);
   3384 }
   3385 
   3386 void cmd_file_load(ConParm_t parm[], U16 nParms)
   3387 {
   3388     consoleRunScript((char *) parm[0].value);
   3389 }
   3390 
   3391 #ifdef TI_DBG
   3392 
   3393 struct report_bit_desc_t
   3394 {
   3395     int index;
   3396     char *desc;
   3397 };
   3398 
   3399 struct report_bit_desc_t report[] =
   3400 {
   3401 
   3402     /* Set 0 */
   3403     { CONFIG_MGR_MODULE_LOG,        "CONFIG_MGR" },
   3404     { SME_SM_MODULE_LOG,            "SME_SM" },
   3405     { SITE_MGR_MODULE_LOG,          "SITE_MGR" },
   3406     { CONN_MODULE_LOG,              "CONN" },
   3407     { MLME_SM_MODULE_LOG,           "MLMEE" },
   3408     { AUTH_MODULE_LOG,              "AUTH" },
   3409     { ASSOC_MODULE_LOG,             "ASSOC" },
   3410     { RX_DATA_MODULE_LOG,           "RX_DATA" },
   3411     { TX_DATA_MODULE_LOG,           "TX_DATA" },
   3412     { CTRL_DATA_MODULE_LOG,         "CTRL_DATA" },
   3413     { RSN_MODULE_LOG,               "RSN" },
   3414     { HAL_RX_MODULE_LOG,            "HAL_RX" },
   3415     { HAL_TX_MODULE_LOG,            "HAL_TX" },
   3416     { HAL_CTRL_MODULE_LOG,          "HAL_CTRL" },
   3417     { HAL_SECURITY_MODULE_LOG,      "HAL_SECUR" },
   3418     { MEM_MGR_MODULE_LOG,           "MEM_MGR" },
   3419     { REPORT_MODULE_LOG,            "REPORT" },
   3420     { SITE_UPDATE_MODULE_LOG,       "SITE_UPDATE" },
   3421     { REGULATORY_DOMAIN_MODULE_LOG, "REG_DOMAIN" },
   3422     { MEASUREMENT_MNGR_MODULE_LOG,  "MEASUREMENT_MNGR" },
   3423     { MEASUREMENT_SRV_MODULE_LOG,   "MEASUREMENT_SRV" },
   3424     { SOFT_GEMINI_MODULE_LOG,       "SOFT_GEMINI" },
   3425     { SC_MODULE_LOG,                "SC (Switch Channel)" },
   3426     { EXC_MANAGER_MODULE_LOG,       "EXC_MANAGER" },
   3427     { ROAMING_MANAGER_MODULE_LOG,   "ROAMING_MANAGER" },
   3428     { QOS_MANAGER_MODULE_LOG,       "QOS_MANAGER" },
   3429     { TRAFFIC_ADM_CTRL_MODULE_LOG,  "TRAFFIC_ADM_CTRL" },
   3430     { POWER_MANAGER_MODULE_LOG,     "POWER_MANAGER" },
   3431     { POWER_CONTROL_MODULE_LOG,     "POWER_CONTROL" },
   3432     { POWER_SERVER_MODULE_LOG,      "POWER_SERVER" },
   3433     { ELP_MODULE_LOG,               "ELP" },
   3434     { SCR_MODULE_LOG,               "SCR" },
   3435     { SCAN_SRV_MODULE_LOG,          "SCAN_SRV" },
   3436     { SCAN_CNCN_MODULE_LOG,         "SCAN_CNCN" },
   3437     { SCAN_MNGR_MODULE_LOG,         "SCAN_MNGR" },
   3438     { GWSI_ADAPT_MODULE_LOG,        "GWSI_ADAPT" },
   3439     { GWSI_ADAPT_CB_MODULE_LOG,     "GWSI_ADAPT_CB" },
   3440     { CORE_ADAPT_MODULE_LOG,        "CORE_ADAPT" },
   3441     { TX_HW_QUEUE_MODULE_LOG,       "TX HW QUEUE" },
   3442     { TX_CTRL_BLK_MODULE_LOG,       "TX CTRL BLK" },
   3443     { TX_RESULT_MODULE_LOG,         "TX RESULT" },
   3444     { TNETW_IF_MODULE_LOG,          "TNETW IF" },
   3445     { TNETW_ARBITER_MODULE_LOG,     "TNETW ARBITER" },
   3446     { CURR_BSS_MODULE_LOG,          "CURR_BSS" },
   3447     { FW_EVENT_MODULE_LOG,          "FW_EVENT" },
   3448     { CMD_MBOX_MODULE_LOG,          "CMD_MBOX" },
   3449 	{ CMDQUEUE_MODULE_LOG,          "CMD_QUEUE" },
   3450     { EVENT_MBOX_MODULE_LOG,        "EVENT_MBOX"},
   3451     { TNETW_DRV_MODULE_LOG,         "TNETW DRV" },
   3452 	{ TNETW_XFER_MODULE_LOG,        "TX XFER" },
   3453     { RECOVERY_MGR_MODULE_LOG,      "RECOVERY MGR" },
   3454     { RECOVERY_CTRL_MODULE_LOG,     "RECOVERY CTRL" },
   3455     { HW_INIT_MODULE_LOG,           "HW INIT" }
   3456 
   3457 };
   3458 
   3459 
   3460 struct rep_severity_level_t {
   3461     U8 level;
   3462     char *desc;
   3463 };
   3464 
   3465 static struct rep_severity_level_t report_severity_level[] = {
   3466     { 0,                          "----"           },
   3467     { WLAN_SEVERITY_INIT,         "INIT",          },
   3468     { WLAN_SEVERITY_INFORMATION,  "INFORMATION",   },
   3469     { WLAN_SEVERITY_WARNING,      "WARNING",       },
   3470     { WLAN_SEVERITY_ERROR,        "ERROR",         },
   3471     { WLAN_SEVERITY_FATAL_ERROR,  "FATAL_ERROR",   },
   3472     { WLAN_SEVERITY_SM,           "SM",            },
   3473     { WLAN_SEVERITY_CONSOLE,      "CONSOLE",       },
   3474     { WLAN_SEVERITY_DEBUG_RX,     "DEBUG RX",      },
   3475     { WLAN_SEVERITY_DEBUG_TX,     "DEBUG TX",      },
   3476     { WLAN_SEVERITY_DEBUG_CONTROL,"DEBUG CONTROL", },
   3477     { WLAN_SEVERITY_GWSI_RECORDING,"GWSI RECORDING"}
   3478 };
   3479 
   3480 static void print_report_module_desc(void)
   3481 {
   3482     int i;
   3483     tiUINT8 module_table[WLAN_MAX_LOG_MODULES];
   3484 
   3485     if (!TI_GetReportModule(g_id_adapter, module_table))
   3486     {
   3487         console_printf_terminal("-------------------------------\n");
   3488         console_printf_terminal("%.5s\tState\t %s\n", "Index", "Desc");
   3489 
   3490         for( i = 0; i < SIZE_ARR(report); i++)
   3491         {
   3492             /* Check if there is string content (the first character is not ZERO) */
   3493             if( report[i].desc[0] )
   3494             {
   3495                 console_printf_terminal("%3d\t%c\t%s\n", report[i].index, (module_table[i] == '1') ? '+' : ' ', report[i].desc );
   3496             }
   3497         }
   3498     }
   3499     else
   3500     {
   3501         console_printf_terminal("Error reading the report table form the driver\n");
   3502     }
   3503 }
   3504 
   3505 void cmd_report_add(ConParm_t parm[], U16 nParms)
   3506 {
   3507     tiUINT8 module_table[WLAN_MAX_LOG_MODULES];
   3508 
   3509     if( nParms != 1)
   3510     {
   3511         print_report_module_desc();
   3512         console_printf_terminal( "* Use '%d' (max index) to set all table.\n", WLAN_MAX_LOG_MODULES);
   3513     }
   3514     else if(!TI_GetReportModule(g_id_adapter, module_table))
   3515     {
   3516         if (parm[0].value == WLAN_MAX_LOG_MODULES)
   3517         {
   3518             memset(module_table, '1', sizeof(module_table));
   3519         }
   3520         else if(parm[0].value < WLAN_MAX_LOG_MODULES)
   3521         {
   3522             module_table[parm[0].value] = '1';
   3523         }
   3524         TI_SetReportModule(g_id_adapter, module_table);
   3525     }
   3526 }
   3527 
   3528 void cmd_report_clear(ConParm_t parm[], U16 nParms)
   3529 {
   3530     tiUINT8 module_table[WLAN_MAX_LOG_MODULES + 1];
   3531 
   3532     if( nParms != 1)
   3533     {
   3534         print_report_module_desc();
   3535         console_printf_terminal( "* Use '%d' (max index) to clear all table.\n", WLAN_MAX_LOG_MODULES);
   3536     }
   3537     else if(!TI_GetReportModule(g_id_adapter, module_table))
   3538     {
   3539         if (parm[0].value == WLAN_MAX_LOG_MODULES)
   3540         {
   3541             memset(module_table, '0', WLAN_MAX_LOG_MODULES);
   3542         }
   3543         else if (parm[0].value < WLAN_MAX_LOG_MODULES)
   3544         {
   3545             module_table[parm[0].value] = '0';
   3546         }
   3547         TI_SetReportModule(g_id_adapter, module_table);
   3548     }
   3549 }
   3550 
   3551 void cmd_report_set(ConParm_t parm[], U16 nParms)
   3552 {
   3553     U8 *ModuleTable = (U8 *)parm[0].value;
   3554 
   3555     if( nParms != 1)
   3556     {
   3557         print_report_module_desc();
   3558     }
   3559     else
   3560     {
   3561 #ifdef _WINDOWS
   3562 #endif /* _WINDOWS */
   3563 
   3564         TI_SetReportModule(g_id_adapter, ModuleTable);
   3565     }
   3566 }
   3567 
   3568 void cmd_hw_register(ConParm_t parm[], U16 nParms)
   3569 {
   3570     tiUINT32 data;
   3571 
   3572 #ifndef _WINDOWS
   3573         usleep(10 * 1000);
   3574 #elif defined (_WINDOWS)
   3575 #endif
   3576 
   3577     if( nParms == 1 )
   3578     {
   3579         if( !TI_hwReadRegister(g_id_adapter, parm[0].value, &data ) )
   3580         {
   3581 #ifdef _WINDOWS
   3582 #endif
   3583         }
   3584     }
   3585     else
   3586     {
   3587         TI_hwWriteRegister(g_id_adapter, parm[0].value, parm[1].value );
   3588     }
   3589 }
   3590 
   3591 void cmd_debug_driver_print(ConParm_t parm[], U16 nParms)
   3592     {
   3593         tiUINT32 func_id = ( nParms > 0 ) ? parm[0].value : 0;
   3594         tiUINT32 opt_param = ( nParms > 1 ) ? parm[1].value : 0;
   3595         tiUINT32 buf[2] = { func_id, opt_param };
   3596 
   3597         console_printf_terminal("DRV_PRINT: FUNC:%u, PARAM:%u\n", func_id, opt_param);
   3598         TI_DisplayStats(g_id_adapter, (tiUINT8 *) buf, sizeof(buf) );
   3599         /* tiwlan_driver_debug_print( g_drv_name, func_id, opt_param ); */
   3600 }
   3601 
   3602 void cmd_debug_buffer_put(ConParm_t parm[], U16 nParms)
   3603     {
   3604         tiUINT32 func_id = ( nParms > 0 ) ? parm[0].value : 0;
   3605         tiUINT32 opt_param = ( nParms > 1 ) ? parm[1].value : 0;
   3606         tiUINT8 buf[260];  /* no more then 256 + func id */
   3607 
   3608         if (opt_param == 0)
   3609             return;
   3610         *(tiUINT32*) buf = func_id;
   3611         memcpy (buf + sizeof(func_id),(char *)opt_param,strlen((char *)opt_param));
   3612 
   3613         console_printf_terminal("cmd_debug_buffer_put: FUNC:%u, PARAM:%u\n", func_id, opt_param);
   3614         TI_DisplayStats(g_id_adapter, (tiUINT8 *) buf, strlen((char *)opt_param) +  sizeof(func_id));
   3615         /* tiwlan_driver_debug_print( g_drv_name, func_id, opt_param ); */
   3616 }
   3617 
   3618 static void print_severity_table(tiUINT8 *pTable)
   3619 {
   3620     int i;
   3621 
   3622     console_printf_terminal("Severity:\n");
   3623     console_printf_terminal("-------------------------------\n");
   3624     console_printf_terminal("%14s\tState\t%s\n", "Severity level", "Desc");
   3625 
   3626     for( i=1; i<SIZE_ARR(report_severity_level); i++ )
   3627     {
   3628         console_printf_terminal("%d\t%c\t%s\n", report_severity_level[i].level, (pTable[i] == '1') ? '+' : ' ',report_severity_level[i].desc );
   3629     }
   3630 
   3631     console_printf_terminal( "* Use '0' to clear all table.\n");
   3632     console_printf_terminal( "* Use '%d' (max index) to set all table.\n", SIZE_ARR(report_severity_level));
   3633 }
   3634 
   3635 void cmd_report_severity_table(ConParm_t parm[], U16 nParms)
   3636 {
   3637     U8 *pSeverityTable = (U8 *)parm[0].value;
   3638     tiUINT8 SeverityTable[WLAN_MAX_SEVERITIES];
   3639 #ifdef _WINDOWS
   3640 #endif /* _WINDOWS */
   3641     if( nParms != 1)
   3642     {
   3643         if (!TI_GetReportSeverity( g_id_adapter, &SeverityTable[0]))
   3644         {
   3645             print_severity_table(SeverityTable);
   3646         }
   3647     }
   3648     else
   3649     {
   3650         TI_SetReportSeverity(g_id_adapter, pSeverityTable);
   3651     }
   3652 }
   3653 
   3654 void cmd_report_severity_level(ConParm_t parm[], U16 nParms)
   3655 {
   3656     tiUINT8 SeverityTable[WLAN_MAX_SEVERITIES];
   3657 
   3658     /* Get the current report severity */
   3659     if (!TI_GetReportSeverity( g_id_adapter, &SeverityTable[0]))
   3660     {
   3661         if(nParms == 0)
   3662         {
   3663             /* Parameters error - print the current table values */
   3664             print_severity_table(SeverityTable);
   3665         }
   3666         else
   3667         {
   3668             if (parm[0].value == 0)
   3669             {
   3670                 /* Disable all severity levels */
   3671 
   3672                 memset(SeverityTable, (int)('0'), sizeof(SeverityTable));
   3673 
   3674                 TI_SetReportSeverity(g_id_adapter, SeverityTable);
   3675             }
   3676             else if (parm[0].value == SIZE_ARR(report_severity_level))
   3677             {
   3678                 /* Enable all severity levels */
   3679 
   3680                 memset(SeverityTable, (int)('1'), sizeof(SeverityTable));
   3681 
   3682                 TI_SetReportSeverity(g_id_adapter, SeverityTable);
   3683             }
   3684             else if (parm[0].value < SIZE_ARR(report_severity_level))
   3685             {
   3686                 console_printf_terminal("Toggle severity level %#lx\n", parm[0].value);
   3687 
   3688                 if (SeverityTable[parm[0].value] == '1')
   3689                 {
   3690                     /* The level is enabled - Disable it */
   3691                     SeverityTable[parm[0].value] = '0';
   3692                 }
   3693                 else
   3694                 {
   3695                     /* The bit is disabled - Enable it */
   3696                     SeverityTable[parm[0].value] = '1';
   3697                 }
   3698 
   3699                 TI_SetReportSeverity(g_id_adapter, SeverityTable);
   3700             }
   3701             else
   3702             {
   3703                 console_printf_terminal("invalid level value: %#lx\n", parm[0].value );
   3704             }
   3705         }
   3706     }
   3707     else
   3708     {
   3709         console_printf_terminal("Error retriving the severity table from the driver\n");
   3710     }
   3711 }
   3712 
   3713 
   3714 #ifdef DRIVER_PROFILING
   3715 
   3716 void cmd_profile_report(ConParm_t parm[], U16 nParms)
   3717 {
   3718     TI_ProfileReport( g_id_adapter );
   3719 }
   3720 
   3721 
   3722 void cmd_profile_cpu_estimator_command(ConParm_t parm[], U16 nParms)
   3723 {
   3724     /* reset or stop command */
   3725     if (nParms == 1) {
   3726         //printf("cpu_profile_cpu_estimator: param[0] = %d\n", (tiUINT8)parm[0].value);
   3727         TI_CpuEstimatorCommand(g_id_adapter, (tiUINT8)parm[0].value, 0);
   3728     }
   3729     else /* start command */
   3730     {
   3731         //printf("cpu_profile_cpu_estimator: param[0] = %d, param[1] = %d\n",(tiUINT8)parm[0].value,(tiUINT32)parm[1].value);
   3732         TI_CpuEstimatorCommand(g_id_adapter, (tiUINT8)parm[0].value,(tiUINT32)parm[1].value);
   3733     }
   3734 }
   3735 
   3736 #endif
   3737 
   3738 void cmd_report_os_dbg_state(ConParm_t parm[], U16 nParms)
   3739 {
   3740     UINT32 dwOsDbgState;
   3741 
   3742     if(nParms == 0) {
   3743         if (TI_GetOsDbgState( g_id_adapter, &dwOsDbgState) == TI_RESULT_OK) {
   3744             console_printf_terminal("OsDbgState %d (0x%08X)\n", dwOsDbgState, dwOsDbgState);
   3745         }
   3746         else {
   3747             console_printf_terminal("Error retriving the OsDbgState from the driver\n");
   3748         }
   3749     }
   3750     else {
   3751         TI_SetOsDbgState(g_id_adapter, parm[0].value);
   3752     }
   3753 }
   3754 
   3755 #endif /* define TI_DBG */
   3756 
   3757 void cmd_privacy_auth(ConParm_t parm[], U16 nParms)
   3758 {
   3759     if( nParms )
   3760     {
   3761         TI_SetAuthenticationMode( g_id_adapter, (tiUINT32)parm[0].value );
   3762         /*console_printf_terminal("CLI-AuthenticationMode: - %x",(tiUINT32)parm[0].value);*/
   3763     }
   3764     else
   3765     {
   3766         static named_value_t auth_mode_type[] = {
   3767             { os802_11AuthModeOpen,             "Open"      },
   3768             { os802_11AuthModeShared,           "Shared"    },
   3769             { os802_11AuthModeAutoSwitch,       "AutoSwitch"},
   3770             { os802_11AuthModeWPA,              "WPA"       },
   3771             { os802_11AuthModeWPAPSK,           "WPAPSK"    },
   3772             { os802_11AuthModeWPANone,          "WPANone"   },
   3773             { os802_11AuthModeWPA2,             "WPA2"      },
   3774             { os802_11AuthModeWPA2PSK,          "WPA2PSK"   },
   3775 
   3776             /*{ os802_11AuthModeMax,              "Max"       }*/
   3777         };
   3778         OS_802_11_AUTHENTICATION_MODE data;
   3779 
   3780         if( !TI_GetAuthenticationMode( g_id_adapter, &data ) )
   3781         {
   3782             print_available_values(auth_mode_type);
   3783             console_printf_terminal("AuthenticationMode=%d\n", data );
   3784         }
   3785     }
   3786 }
   3787 
   3788 void cmd_privacy_eap(ConParm_t parm[], U16 nParms)
   3789 {
   3790     if( nParms )
   3791     {
   3792         TI_SetEAPType( g_id_adapter, (OS_802_11_EAP_TYPES) parm[0].value );
   3793         TI_SetEAPTypeDriver( g_id_adapter, (OS_802_11_EAP_TYPES) parm[0].value );
   3794     }
   3795     else
   3796     {
   3797         static named_value_t eap_type[] = {
   3798             { OS_EAP_TYPE_GENERIC_TOKEN_CARD,   "TOKEN" },
   3799             { OS_EAP_TYPE_TLS,                  "TLS"   },
   3800             INCLUDE_EXC_TYPE_NAMES
   3801             { OS_EAP_TYPE_TTLS,                 "TTLS"  },
   3802             { OS_EAP_TYPE_PEAP,                 "PEAP"  },
   3803             {OS_EAP_TYPE_MS_CHAP_V2,            "CHAP"  }
   3804         };
   3805 /*temp_closed
   3806         OS_802_11_EAP_TYPES data;
   3807 
   3808         if( !TI_GetEAPType( g_id_adapter, &data ) )
   3809         {
   3810             print_available_values(eap_type);
   3811             console_printf_terminal("EAP Type = %d\n", data );
   3812         }
   3813 */
   3814     print_available_values(eap_type);
   3815     }
   3816 
   3817 }
   3818 
   3819 
   3820 void cmd_privacy_encrypt(ConParm_t parm[], U16 nParms)
   3821 {
   3822    OS_802_11_ENCRYPTION_TYPES data;
   3823    if( nParms )
   3824     {
   3825         TI_SetEncryptionType( g_id_adapter, (OS_802_11_ENCRYPTION_TYPES) parm[0].value );
   3826     }
   3827     else
   3828     {
   3829         print_available_values(encrypt_type);
   3830         console_printf_terminal("Encryption=%d\n", !TI_GetEncryptionType( g_id_adapter, &data ) ? data : -1 );
   3831     }
   3832 
   3833 }
   3834 void cmd_privacy_credent(ConParm_t parm[], U16 nParms)
   3835 {
   3836 
   3837     if( nParms == 2 )
   3838     {
   3839         TI_SetCredentials(g_id_adapter,(tiCHAR *) parm[0].value, (tiCHAR *) parm[1].value);
   3840     }
   3841     else if( nParms == 1 )
   3842         TI_SetCredentials(g_id_adapter,(tiCHAR *) parm[0].value, NULL);
   3843     else
   3844         return;
   3845 
   3846 }
   3847 
   3848 void cmd_privacy_PSKPassphrase(ConParm_t parm[], U16 nParms)
   3849 {
   3850     char buf[PSK_BUFF_LEN], *pPassphrase;
   3851     unsigned int len, is_hex_key = 0;
   3852 
   3853 
   3854 	if( nParms == 0 )
   3855         return;
   3856 
   3857 	len = strlen((char*)(parm[0].value));
   3858 
   3859 	pPassphrase = (char*)(parm[0].value);
   3860 
   3861 	memset(buf,0,PSK_BUFF_LEN);
   3862 
   3863     if( nParms >= 2 )
   3864     {
   3865 #ifdef _WINDOWS
   3866 #else
   3867         if( !stricmp((char *) parm[1].value, "hex") )
   3868             is_hex_key = 1;
   3869         else if(!stricmp((char *) parm[1].value, "text"))
   3870             is_hex_key = 0;
   3871 #endif
   3872     }
   3873 
   3874     if( is_hex_key )
   3875     {
   3876 		if( len != PSK_HEXA_LENGTH )
   3877         {
   3878             console_printf_terminal("The hexa PSKPassphrase must be at length of %d hexa digits \n",PSK_HEXA_LENGTH);
   3879             return ;
   3880         }
   3881     }
   3882 	else
   3883 	{
   3884 		if (len > MAX_PSK_STRING_LENGTH || len < MIN_PSK_STRING_LENGTH)
   3885 		{
   3886             console_printf_terminal("The PSKPassphrase must be between %d to  %d chars \n", MIN_PSK_STRING_LENGTH, MAX_PSK_STRING_LENGTH);
   3887             return ;
   3888         }
   3889 	}
   3890 
   3891 	memcpy(buf, (char*)(parm[0].value), len);
   3892 
   3893 	/*TI_SetPSKPassPhrase*/
   3894 	TI_SetPSK(g_id_adapter, (tiCHAR *)buf);
   3895 }
   3896 
   3897 void cmd_privacy_certificate(ConParm_t parm[], U16 nParms)
   3898 {
   3899 #ifdef _WINDOWS // TRS:HLC
   3900 #else
   3901     console_printf_terminal("Set sertificate file : %s\n", (char*)parm[0].value);
   3902     if(nParms == 1 )
   3903         TI_SetCertificateParameters(g_id_adapter, (void*)parm[0].value, 0);
   3904     else if(nParms == 2 )
   3905         TI_SetCertificateParameters(g_id_adapter, (void*)parm[0].value,
   3906                                                    (unsigned int)parm[1].value);
   3907     else return;
   3908 #endif
   3909 //TRS end
   3910 }
   3911 
   3912 void cmd_privacy_wpa_options(ConParm_t parm[], U16 nParms)
   3913 {
   3914     if( nParms )
   3915     {
   3916         TI_SetWpaOptions(g_id_adapter, parm[0].value );
   3917     }
   3918     else
   3919     {
   3920         tiUINT32 data;
   3921         static named_value_t wpa_options[] = {
   3922             { OS_802_11_OPTION_ENABLE_PROMOTE_MODE,   "PROMOTE_MODE" },
   3923             { OS_802_11_OPTION_ENABLE_PROMOTE_CIPHER, "PROMOTE_CIPHER"   },
   3924             { OS_802_11_OPTION_ENABLE_ALL,            "All" }
   3925         };
   3926 
   3927         print_available_values(wpa_options);
   3928         if( !TI_GetWpaOptions(g_id_adapter, &data ) )
   3929             console_printf_terminal("WPA option=%d\n", data );
   3930     }
   3931 }
   3932 
   3933 void cmd_privacy_getdefaultkey(ConParm_t parm[], U16 nParms)
   3934 {
   3935     tiUINT32 DefaultKeyId;
   3936     if (OK == TI_GetDefaultWepKey(g_id_adapter, &DefaultKeyId))
   3937         console_printf_terminal("WEP default key ID = %d\n", DefaultKeyId );
   3938 
   3939 }
   3940 unsigned int char_2_hexa( char c )
   3941 {
   3942     if( c >= '0' && c <= '9' )
   3943         return c - '0';
   3944     else if( tolower(c) >= 'a' && tolower(c) <= 'f' )
   3945         return tolower(c) - 'a' + 0x0a;
   3946     console_printf_terminal("invalid symbol '%c'\n", c );
   3947     return (unsigned int) -1;
   3948 }
   3949 
   3950 void cmd_privacy_addkey(ConParm_t parm[], U16 nParms)
   3951 {
   3952     OS_802_11_WEP data;
   3953     char *buf;
   3954     unsigned int i, len, is_hex_key = 1;
   3955     U32 val, val_l;
   3956     unsigned int key_id = 0;
   3957     unsigned int def_flag = 0;
   3958 
   3959     buf = (char *) parm[0].value;
   3960 
   3961     key_id = (unsigned int)parm[1].value;
   3962 
   3963     if( parm[2].value )
   3964         def_flag = 0x80000000;
   3965 
   3966     if( nParms >= 4 )
   3967     {
   3968 #ifdef _WINDOWS
   3969 #else
   3970         if( !stricmp((char *) parm[3].value, "hex") )
   3971             is_hex_key = 1;
   3972         else if(!stricmp((char *) parm[3].value, "text"))
   3973             is_hex_key = 0;
   3974 #endif
   3975     }
   3976 
   3977     memset(data.KeyMaterial,0,sizeof(data.KeyMaterial));
   3978 
   3979     len = strlen(buf);
   3980 
   3981     if( is_hex_key )
   3982     {
   3983         if( len % 2 )
   3984         {
   3985             console_printf_terminal("The hexa key should be even length\n");
   3986             return ;
   3987         }
   3988         if(len <= 10) /*10 is number of character for key length 40 bit*/
   3989             data.KeyLength = 5;
   3990         else if(len <= 26) /*26 is number of character for key length 128 bit*/
   3991             data.KeyLength = 13;
   3992         else if(len <= 58) /*58 is number of character for key length 256 bit*/
   3993             data.KeyLength = 29;
   3994         else {
   3995                 console_printf_terminal("**Error key length\n" );
   3996                 return;
   3997         }
   3998 
   3999         for( i=0; *buf && i < data.KeyLength; i++ )
   4000         {
   4001                 val = char_2_hexa(*buf);
   4002                 if( val == (U32) -1 )
   4003                     return;
   4004 
   4005                 val_l = char_2_hexa(*(++buf));
   4006                 if( val_l == (U32) -1 )
   4007                     return;
   4008 
   4009                 data.KeyMaterial[i] = (tiUINT8)((val << 4) | val_l);
   4010                 buf++;
   4011         }
   4012     }
   4013     else        /* for ascii key */
   4014     {
   4015         if(len <= 5) /*10 is number of character for key length 40 bit*/
   4016             data.KeyLength = 5;
   4017         else if(len <= 13) /*26 is number of character for key length 128 bit*/
   4018             data.KeyLength = 13;
   4019         else if(len <= 29) /*58 is number of character for key length 256 bit*/
   4020             data.KeyLength = 29;
   4021         else {
   4022                 console_printf_terminal("**Error key length\n" );
   4023                 return;
   4024         }
   4025         memcpy(data.KeyMaterial, buf, len );
   4026     }
   4027 
   4028     data.KeyIndex = def_flag | key_id;
   4029     data.Length = sizeof(OS_802_11_WEP);
   4030 
   4031 #ifdef DEBUG_MESSAGES
   4032     console_printf_terminal("cmd_privacy_addkey len = %d, type: %s\nkey:", data.KeyLength, is_hex_key ? "hex" : "text");
   4033     for(i=0; i<SIZE_ARR(data.KeyMaterial); i++ )
   4034         console_printf_terminal("%02x", (U32) data.KeyMaterial[i]);
   4035     console_printf_terminal("\n");
   4036 #endif /*DEBUG_MESSAGES */
   4037     TI_AddWEPKey(g_id_adapter, &data);
   4038 }
   4039 
   4040 
   4041 void cmd_privacy_removekey(ConParm_t parm[], U16 nParms)
   4042 {
   4043     TI_RemoveWEPKey(g_id_adapter, (U32) parm[0].value );
   4044 }
   4045 
   4046 void cmd_privacy_key_type(ConParm_t parm[], U16 nParms)
   4047 {
   4048 
   4049    if( nParms )
   4050         {
   4051         TI_SetKeyType( g_id_adapter, (OS_802_11_KEY_TYPES)parm[0].value );
   4052         console_printf_terminal("CLI-: KeyType - %x\n",(tiUINT32)parm[0].value);
   4053         }
   4054     else
   4055     {
   4056         static named_value_t key_type[] = {
   4057             { OS_KEY_TYPE_STATIC,             "STATIC" },
   4058             { OS_KEY_TYPE_DYNAMIC,            "DYNAMIC"}
   4059         };
   4060 
   4061         print_available_values(key_type);
   4062     }
   4063 
   4064 }
   4065 void cmd_privacy_mixed_mode(ConParm_t parm[], U16 nParms)
   4066 {
   4067     tiBOOL data;
   4068 
   4069     if( nParms == 0 )
   4070     {
   4071        console_printf_terminal("Mixed Mode: 0 - FALSE, 1 - TRUE\n");
   4072        data = FALSE;
   4073        if( !TI_GetMixedMode(g_id_adapter, &data ) );
   4074             console_printf_terminal("Mixed Mode =%s\n", data ? "True" : "False" );
   4075 
   4076     }
   4077     else    /* param <read-only!!> */
   4078         TI_SetMixedMode(g_id_adapter, (BOOL) parm[0].value);
   4079 }
   4080 
   4081 
   4082 /************** Roaming Manager functions  ******************/
   4083 void cmd_Roaming_enable(ConParm_t parm[], U16 nParms)
   4084 {
   4085     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4086     roamingMngrConfigParams.roamingMngrConfig.enableDisable = ROAMING_ENABLED;
   4087     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4088     console_printf_terminal("Roaming is enabled \n");
   4089 }
   4090 
   4091 
   4092 void cmd_Roaming_disable(ConParm_t parm[], U16 nParms)
   4093 {
   4094     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4095     roamingMngrConfigParams.roamingMngrConfig.enableDisable = ROAMING_DISABLED;
   4096     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4097     console_printf_terminal("Roaming is disabled \n");
   4098 }
   4099 void cmd_Roaming_lowPassFilter(ConParm_t parm[], U16 nParms)
   4100 {
   4101     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4102     if( nParms != 0 )
   4103     {
   4104         roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt = (UINT16) parm[0].value;
   4105     }
   4106     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4107     console_printf_terminal("Time in sec to wait before low quality Roaming Triggers, \n lowPassFilterRoamingAttempt = %d sec\n",
   4108            roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt);
   4109 }
   4110 
   4111 void cmd_Roaming_qualityIndicator(ConParm_t parm[], U16 nParms)
   4112 {
   4113     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4114     if( nParms != 0 )
   4115     {
   4116         roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold = (S8) parm[0].value;
   4117     }
   4118     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4119     console_printf_terminal("Quality indicator (RSSI) to be used when comparing AP List matching quality, \n apQualityThreshold = %d \n",
   4120            (roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold));
   4121 }
   4122 
   4123 
   4124 void cmd_Roaming_dataRetryThreshold(ConParm_t parm[], U16 nParms)
   4125 {
   4126     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4127     if( nParms != 0 )
   4128     {
   4129         roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold = (UINT8) parm[0].value;
   4130 
   4131     }
   4132     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4133     console_printf_terminal("dataRetryThreshold = %d \n",
   4134            roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold);
   4135 
   4136 }
   4137 void cmd_Roaming_numExpectedTbttForBSSLoss(ConParm_t parm[], U16 nParms)
   4138 {
   4139     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4140     if( nParms != 0 )
   4141     {
   4142         roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss =  (UINT8) parm[0].value;
   4143 
   4144     }
   4145     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4146     console_printf_terminal("Number of expected TBTTs for BSS Loss event, \n numExpectedTbttForBSSLoss = %d \n",
   4147            roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss);
   4148 
   4149 }
   4150 void cmd_Roaming_txRateThreshold(ConParm_t parm[], U16 nParms)
   4151 {
   4152     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4153     if( nParms != 0 )
   4154     {
   4155         roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold =  (UINT8) parm[0].value;
   4156 
   4157     }
   4158     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4159     console_printf_terminal("txRateThreshold = %d \n",
   4160            roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold);
   4161 
   4162 }
   4163 void cmd_Roaming_lowRssiThreshold(ConParm_t parm[], U16 nParms)
   4164 {
   4165     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4166     if( nParms != 0 )
   4167     {
   4168         roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold =  (S8) parm[0].value;
   4169 
   4170     }
   4171     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4172     console_printf_terminal("lowRssiThreshold = %d \n",
   4173            (roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold));
   4174 
   4175 }
   4176 void cmd_Roaming_lowSnrThreshold(ConParm_t parm[], U16 nParms)
   4177 {
   4178     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4179     if( nParms != 0 )
   4180     {
   4181         roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold =  (S8)parm[0].value;
   4182 
   4183     }
   4184     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4185     console_printf_terminal("lowSnrThreshold = %d \n", roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold);
   4186 }
   4187 void cmd_Roaming_lowQualityForBackgroungScanCondition(ConParm_t parm[], U16 nParms)
   4188 {
   4189     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4190     if( nParms != 0 )
   4191     {
   4192         roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition = (S8) parm[0].value;
   4193 
   4194     }
   4195     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4196     console_printf_terminal("Indicator used to increase the background scan period when quality is low, \n lowQualityForBackgroungScanCondition = %d \n",
   4197            (roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition));
   4198 
   4199 }
   4200 void cmd_Roaming_normalQualityForBackgroungScanCondition(ConParm_t parm[], U16 nParms)
   4201 {
   4202     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4203     if( nParms != 0 )
   4204     {
   4205         roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition = (S8) parm[0].value;
   4206 
   4207     }
   4208     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4209     console_printf_terminal("Indicator used to reduce the background scan period when quality is normal, \n normalQualityForBackgroungScanCondition = %d \n",
   4210            (roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition));
   4211 
   4212 }
   4213 
   4214 void cmd_Roaming_rssiFilterWeight(ConParm_t parm[], U16 nParms)
   4215 {
   4216     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4217     if( nParms != 0 )
   4218     {
   4219         roamingMngrConfigParams.roamingMngrThresholdsConfig.rssiFilterWeight =  (UINT8) parm[0].value;
   4220 
   4221     }
   4222     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4223     console_printf_terminal("Rssi Filter Weight = %d \n",
   4224            (roamingMngrConfigParams.roamingMngrThresholdsConfig.rssiFilterWeight));
   4225 }
   4226 
   4227 void cmd_Roaming_snrFilterWeight(ConParm_t parm[], U16 nParms)
   4228 {
   4229     TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4230     if( nParms != 0 )
   4231     {
   4232         roamingMngrConfigParams.roamingMngrThresholdsConfig.snrFilterWeight =  (UINT8) parm[0].value;
   4233 
   4234     }
   4235     TI_SetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4236     console_printf_terminal("Snr FIlter Weight = %d \n",
   4237            (roamingMngrConfigParams.roamingMngrThresholdsConfig.snrFilterWeight));
   4238 }
   4239 
   4240 void cmd_Roaming_getConfParams(ConParm_t parm[], U16 nParms)
   4241 {
   4242    TI_GetRoamingConfiguration (g_id_adapter, (UINT8*)&roamingMngrConfigParams, sizeof(roamingMngrConfigParams_t));
   4243 
   4244    console_printf_terminal("Roaming is: %s \n", roamingMngrConfigParams.roamingMngrConfig.enableDisable ? "Enabled" : "Disabled");
   4245    console_printf_terminal("lowPassFilterRoamingAttempt = %d sec, apQualityThreshold = %d\n",
   4246           roamingMngrConfigParams.roamingMngrConfig.lowPassFilterRoamingAttempt,
   4247 		  roamingMngrConfigParams.roamingMngrConfig.apQualityThreshold);
   4248    console_printf_terminal("Roaming Triggers' thresholds are: \n");
   4249    console_printf_terminal("dataRetryThreshold = %d, lowQualityForBackgroungScanCondition = %d, \
   4250 lowRssiThreshold = %d, lowSnrThreshold = %d, normalQualityForBackgroungScanCondition = %d, \
   4251 numExpectedTbttForBSSLoss = %d, txRateThreshold = %d \n",
   4252           roamingMngrConfigParams.roamingMngrThresholdsConfig.dataRetryThreshold,
   4253 		  roamingMngrConfigParams.roamingMngrThresholdsConfig.lowQualityForBackgroungScanCondition,
   4254 		  roamingMngrConfigParams.roamingMngrThresholdsConfig.lowRssiThreshold,
   4255           roamingMngrConfigParams.roamingMngrThresholdsConfig.lowSnrThreshold,
   4256 		  roamingMngrConfigParams.roamingMngrThresholdsConfig.normalQualityForBackgroungScanCondition,
   4257           roamingMngrConfigParams.roamingMngrThresholdsConfig.numExpectedTbttForBSSLoss,
   4258           roamingMngrConfigParams.roamingMngrThresholdsConfig.txRateThreshold);
   4259    console_printf_terminal("RSSI / SNR filter weights are: \n");
   4260    console_printf_terminal("RSSI filter weight = %d, SNR filter weight = %d\n ",
   4261    		roamingMngrConfigParams.roamingMngrThresholdsConfig.rssiFilterWeight,
   4262    		roamingMngrConfigParams.roamingMngrThresholdsConfig.snrFilterWeight);
   4263 }
   4264 
   4265 
   4266 void cmd_bt_coe_enable(ConParm_t parm[], U16 nParms)
   4267 {
   4268     if( nParms == 0 )
   4269     {
   4270         console_printf_terminal("Please enter enable value:\n");
   4271         console_printf_terminal("0 - Enable\n");
   4272         console_printf_terminal("1 - Disable\n");
   4273         console_printf_terminal("2 - Auto\n");
   4274     }
   4275     else
   4276     {
   4277         TI_SetBtCoeEnable(g_id_adapter, parm[0].value);
   4278     }
   4279 }
   4280 
   4281 
   4282 void cmd_bt_coe_rate(ConParm_t parm[], U16 nParms)
   4283 {
   4284     U8 Values[NUM_OF_RATES_IN_SG];
   4285     U8 Index;
   4286     if( nParms != NUM_OF_RATES_IN_SG )
   4287     {
   4288  		console_printf_terminal("0 - 1Mbps (not recommended)\n");
   4289 		console_printf_terminal("1 - 2Mbps (not recommended)\n");
   4290 		console_printf_terminal("2 - 5.5Mbps\n");
   4291 		console_printf_terminal("3 - 6Mbps\n");
   4292 		console_printf_terminal("4 - 9Mbps\n");
   4293 		console_printf_terminal("5 - 11Mbps\n");
   4294 		console_printf_terminal("6 - 12Mbps\n");
   4295 		console_printf_terminal("7 - 18Mbps\n");
   4296 		console_printf_terminal("8 - 22Mbps (not in use)\n");
   4297 		console_printf_terminal("9 - 24Mbps\n");
   4298 		console_printf_terminal("10 - 36Mbps\n");
   4299 		console_printf_terminal("11 - 48Mbps\n");
   4300 		console_printf_terminal("12 - 54Mbps\n");
   4301     }
   4302     else
   4303     {
   4304         for (Index = 0; Index < NUM_OF_RATES_IN_SG; Index++ )
   4305         {
   4306 			Values[Index] = (U8)parm[Index].value;  //TRS:MEB use cast to fix compile warning
   4307         }
   4308         TI_SetBtCoeRate(g_id_adapter, Values);
   4309     }
   4310 }
   4311 
   4312 
   4313 void cmd_bt_coe_config(ConParm_t parm[], U16 nParms)
   4314 {
   4315     U32 Values[NUM_OF_CONFIG_PARAMS_IN_SG];
   4316     U8 Index = 0;
   4317 
   4318     if( nParms != NUM_OF_CONFIG_PARAMS_IN_SG )
   4319     {
   4320         console_printf_terminal("Please enter valid config values:\n");
   4321 
   4322 		console_printf_terminal("Param %d - wlanRxMinRateToRespectBtHp (0 - all,2,5,6,9,11,12,18,22,24,36,48,54)  \n",Index++);
   4323         console_printf_terminal("Param %d - btHpMaxTime (100 - 15000)\n",Index++);
   4324         console_printf_terminal("Param %d - wlanHpMaxTime (100 - 15000)\n",Index++);
   4325         console_printf_terminal("Param %d - senseDisableTimer (100 - 15000)\n",Index++);
   4326         console_printf_terminal("Param %d - protectiveRxTimeBeforeBtHp (10 - 2300)\n",Index++);
   4327         console_printf_terminal("Param %d - protectiveTxTimeBeforeBtHp (10 - 2300)\n",Index++);
   4328         console_printf_terminal("Param %d - protectiveRxTimeBeforeBtHpFastAp (10 - 20000)\n",Index++);
   4329         console_printf_terminal("Param %d - protectiveTxTimeBeforeBtHpFastAp (10 - 20000)\n",Index++);
   4330         console_printf_terminal("Param %d - protectiveWlanCycleTimeForFastAp (2000 - 65535)\n",Index++);
   4331         console_printf_terminal("Param %d - btAntiStarvationPeriod (0 - 15000) \n",Index++);
   4332         console_printf_terminal("Param %d - timeoutNextBtLpPacket (400 - 10000)\n",Index++);
   4333 		console_printf_terminal("Param %d - wakeUpTimeBeforeBeacon   (0 - 20000)  \n",Index++);
   4334 		console_printf_terminal("Param %d - hpdmMaxGuardTime   (0 - 50000)  \n",Index++);
   4335 		console_printf_terminal("Param %d - timeoutNextWlanPacket   (100 - 50000)  \n",Index++);
   4336         console_printf_terminal("Param %d - sgAntennaType (0 - Single | 1 - Dual | 2 - Single+ )\n",Index++);
   4337         console_printf_terminal("Param %d - signalingType (0 - Legacy | 1 - Palau | 2 - Other)\n",Index++);
   4338         console_printf_terminal("Param %d - afhLeverageOn (0 - OFF | 1 - GPIO  | 2 - ON)\n",Index++);
   4339         console_printf_terminal("Param %d - numberQuietCycle (0 - 10)\n",Index++);
   4340         console_printf_terminal("Param %d - maxNumCts (0 - 10)\n",Index++);
   4341         console_printf_terminal("Param %d - numberOfWlanPackets (1 - 10)\n",Index++);
   4342         console_printf_terminal("Param %d - numberOfBtPackets (2 - 10)\n",Index++);
   4343         console_printf_terminal("Param %d - numberOfMissedRxForAvalancheTrigger (1 - 255)\n",Index++);
   4344         console_printf_terminal("Param %d - wlanElpHpSupport (0 - 1)\n",Index++);
   4345         console_printf_terminal("Param %d - btAntiStarvationNumberOfCyclesWithinThePeriod (0 - 15)  \n",Index++);
   4346         console_printf_terminal("Param %d - ackModeDuringBtLpInDualAnt (0 - 1)  \n",Index++);
   4347         console_printf_terminal("Param %d - allowPaSdToggleDuringBtActivityEnable (0 - 1)  \n",Index++);
   4348 		console_printf_terminal("Param %d - sgAutoModeNoCts   (0 - 1)  \n",Index++);
   4349 		console_printf_terminal("Param %d - numOfBtHpRespectedReq   (0 - 20)  \n",Index++);
   4350    }
   4351    else
   4352     {
   4353         for (Index = 0; Index < NUM_OF_CONFIG_PARAMS_IN_SG; Index++ )
   4354         {
   4355             Values[Index] = parm[Index].value;
   4356         }
   4357 
   4358 		if ( ( (is_value_rate(Values[0])) && (Values[0] != 1) ) || (Values[0] == 0) )
   4359 		{
   4360 			TI_SetBtCoeConfig(g_id_adapter, (tiUINT32 *)Values);
   4361 		}
   4362 		else
   4363 		{
   4364 			console_printf_terminal("Error: Param 26 - wlanRxMinRateToRespectBtHp (0 - all,2,5,6,9,11,12,18,22,24,36,48,54)  \n");
   4365 		}
   4366     }
   4367 }
   4368 
   4369 
   4370 void cmd_bt_coe_get_status(ConParm_t parm[], U16 nParms)
   4371 {
   4372     U32 Values[NUM_OF_STATUS_PARAMS_IN_SG];
   4373     /* The print is done inside the module */
   4374     console_printf_terminal("Done by driver - ");
   4375     if( TI_SetBtCoeGetStatus(g_id_adapter,(tiUINT32 *) Values) == OK ) {
   4376         console_printf_terminal("Ok\n");
   4377 /*      console_printf_terminal("BT Coxistence status: \n\n");
   4378         console_printf_terminal("Enable: %d\n", Values[0]);
   4379         console_printf_terminal("Rate: %d\n", Values[1]);
   4380         console_printf_terminal("BtSignaling: %d\n", Values[2]);
   4381         console_printf_terminal("BtHPMaxTime: %d\n", Values[3]);
   4382         console_printf_terminal("WlanHPMaxTime: %d\n", Values[4]);
   4383         console_printf_terminal("WlanEOSMaxPacket: %d\n", Values[5]);
   4384         console_printf_terminal("WlanEOSMaxPacketTimeOut: %d\n", Values[6]);
   4385         console_printf_terminal("BtPTAMaxPacket: %d\n", Values[7]);
   4386         console_printf_terminal("BtPTAMaxPacketTimeOut: %d\n", Values[8]);
   4387         console_printf_terminal("WlanSlowAPSocial: %d\n", Values[9]);
   4388         console_printf_terminal("WlanSlowAPMaxCTS: %d\n", Values[10]);
   4389         console_printf_terminal("WlanSlowAPMaxTimeToCTS: %d\n", Values[11]);
   4390         console_printf_terminal("T8_temporary: %d\n", Values[12]);
   4391         console_printf_terminal("BTtoWLANSwitchTime: %d\n", Values[13]); */
   4392     }
   4393     else
   4394     {
   4395         console_printf_terminal("Fail\n");
   4396 /*      console_printf_terminal("Error reading status!\n"); */
   4397     }
   4398 }
   4399 
   4400 
   4401 void cmd_PLT_RxPerStart(ConParm_t parm[], U16 nParms)
   4402 {
   4403 	UINT32 Status = TI_PLT_RxPerStart(g_id_adapter);
   4404 	if (Status == OK)
   4405 		console_printf_terminal("Plt RX counters started\n");
   4406 	else
   4407 		console_printf_terminal("Plt RX counters start failed\n");
   4408 }
   4409 
   4410 void cmd_PLT_RxPerStop(ConParm_t parm[], U16 nParms)
   4411 {
   4412 	UINT32 Status = TI_PLT_RxPerStop(g_id_adapter);
   4413 	if (Status == OK)
   4414 		console_printf_terminal("Plt RX counters stoped\n");
   4415 	else
   4416 		console_printf_terminal("Plt RX counters stop failed\n");
   4417 }
   4418 
   4419 void cmd_PLT_RxPerClear(ConParm_t parm[], U16 nParms)
   4420 {
   4421 	UINT32 Status = TI_PLT_RxPerClear(g_id_adapter);
   4422 	if (Status == OK)
   4423 		console_printf_terminal("Plt RX counters cleard\n");
   4424 	else
   4425 		console_printf_terminal("Plt RX counters clear failed\n");
   4426 }
   4427 
   4428 void cmd_PLT_RxPerGet(ConParm_t parm[], U16 nParms)
   4429 {
   4430 	PltRxPer_t PltRxPer;
   4431 	UINT32 Status = TI_PLT_RxPerGetResults(g_id_adapter, &PltRxPer);
   4432 
   4433 	if (Status == OK)
   4434 	{
   4435 		console_printf_terminal("FCSErrorCount = %d\n", PltRxPer.FCSErrorCount);
   4436 		console_printf_terminal("PLCPErrorCount  = %d\n", PltRxPer.PLCPErrorCount);
   4437         console_printf_terminal("SeqNumMissCount = %d\n", PltRxPer.SeqNumMissCount);
   4438 		console_printf_terminal("TotalFrameCount = %d\n", PltRxPer.TotalFrameCount);
   4439 	}
   4440 	else
   4441 		console_printf_terminal("Plt RX counters Get results failed\n");
   4442 }
   4443 
   4444 void cmd_PLT_RegisterRead(ConParm_t parm[], U16 nParms)
   4445 {
   4446     tiUINT32 RegAddress;
   4447     tiUINT32 RegValue;
   4448     tiUINT32 Status;
   4449     char* pTmp;
   4450 
   4451     /* Converting hex string to tiUINT32*/
   4452     pTmp = (char*)parm[0].value;
   4453     sscanf(pTmp , "%x", &RegAddress);
   4454 
   4455     /*Call the API function */
   4456     Status = TI_PLT_ReadRegister(g_id_adapter, RegAddress, &RegValue);
   4457     if( Status == OK )
   4458         console_printf_terminal("Reg. %#lx = %#x (%d)\n", RegAddress, RegValue, RegValue );
   4459 }
   4460 
   4461 void cmd_PLT_RegisterWrite(ConParm_t parm[], U16 nParms)
   4462 {
   4463     tiUINT32 RegAddress;
   4464     tiUINT32 RegValue = 0;
   4465     tiUINT32 Status;
   4466     char* pTmp;
   4467 
   4468     /* Converting hex string to tiUINT32*/
   4469     printf("cmd_PLT_RegisterWrite\n");
   4470     pTmp = (char*)parm[0].value;
   4471     sscanf(pTmp, "%x", &RegAddress);
   4472     pTmp = (char*)parm[1].value;
   4473     sscanf(pTmp , "%x", &RegValue);
   4474     printf("cmd_PLT_RegisterWrite %x %x\n", RegAddress, RegValue);
   4475 
   4476     /*Call the API function */
   4477     Status = TI_PLT_WriteRegister(g_id_adapter, RegAddress, RegValue );
   4478     if (Status == OK)
   4479         console_printf_terminal("Plt register 0x%x is set to 0x%x OK.\n", RegAddress, RegValue);
   4480     else
   4481         console_printf_terminal("Plt register 0x%x is set to 0x%x NOK.\n", RegAddress, RegValue);
   4482 
   4483 }
   4484 
   4485 
   4486 void cmd_PLT_TxContinues(ConParm_t parm[], U16 nParms)
   4487 {
   4488    UINT32 Status;
   4489    PltTxContinues_t PltTxContinues;
   4490    if ((nParms == 0) || (nParms > 10))
   4491    {
   4492       console_printf_terminal("\n");
   4493 	  console_printf_terminal("Param 0 - Band (0 - 2.4Ghz(B/G), 1 - 5Ghz(A), 2 - Japan(4.9Ghz))\n");
   4494 	  console_printf_terminal("Param 1 - Channel: (1..14(2.4Ghz), 1..180(5Ghz)) \n");
   4495 	  console_printf_terminal("Param 2 - Rate: \n");
   4496       console_printf_terminal("                1  - 1Mbps\n");
   4497       console_printf_terminal("                2  - 2Mbps\n");
   4498       console_printf_terminal("                3  - 5.5Mbps\n");
   4499       console_printf_terminal("                4  - 11Mbps\n");
   4500       console_printf_terminal("                6  - 6Mbps\n");
   4501       console_printf_terminal("                7  - 9Mbps\n");
   4502       console_printf_terminal("                8  - 12Mbps\n");
   4503       console_printf_terminal("                9  - 18Mbps\n");
   4504       console_printf_terminal("                10 - 24Mbps\n");
   4505       console_printf_terminal("                11 - 36Mbps\n");
   4506       console_printf_terminal("                12 - 48Mbps\n");
   4507       console_printf_terminal("                13 - 54Mbps \n");
   4508 	  console_printf_terminal("Param 3 - preamble (0-long, 1-short)\n");
   4509 	  console_printf_terminal("Param 4 - Delay between packets (uSec)\n");
   4510       console_printf_terminal("Param 5 - Number of TX frames (0 - endless)\n");
   4511       console_printf_terminal("Param 6 - Test mode (5-Random data, 9-ZOZO(0,1,0,1,...))\n");
   4512       console_printf_terminal("Param 7 - Sequance number mode(0 - fixed, 1 - incremented)\n");
   4513       console_printf_terminal("Param 8 - packet Data legth [bytes] (0 - 2284)\n");
   4514       console_printf_terminal("Param 9 - peer mac address: [xx:xx:xx:xx:xx:xx]\n");
   4515 
   4516    }
   4517    else
   4518    {
   4519 	   PltTxContinues.band 	            = (UINT8) parm[0].value;
   4520 	   PltTxContinues.chID   	        = parm[1].value;
   4521 	   PltTxContinues.rate   	        = parm[2].value;
   4522 	   PltTxContinues.preamble	        = (UINT8) parm[3].value;
   4523 	   PltTxContinues.InterPacketDelay  = parm[4].value;
   4524        PltTxContinues.NumOfFrames       = parm[5].value;
   4525 	   PltTxContinues.mode              = (UINT8) parm[6].value;
   4526        PltTxContinues.aSeqNumMode       = parm[7].value;
   4527        PltTxContinues.aPacketLength     = parm[8].value;
   4528        hexStr2MACAddr( (char*)parm[9].value, &(PltTxContinues.aPeerMacAddr) );
   4529 
   4530 
   4531 	   Status = TI_PLT_TxContiues(g_id_adapter, &PltTxContinues);
   4532 		if (Status == OK)
   4533 			console_printf_terminal("OK\n");
   4534 		else
   4535 			console_printf_terminal("NOK\n");
   4536 
   4537    }
   4538 }
   4539 
   4540 void cmd_PLT_TxCW(ConParm_t parm[], U16 nParms)
   4541 {
   4542    UINT32 Status;
   4543    TestCmdChannelBand_t PltTxCW;
   4544 
   4545    if ((nParms == 0) || (nParms > 2))
   4546    {
   4547 	  console_printf_terminal("Param 0 - Band (0 - 2.4Ghz(B/G), 1 - 5Ghz(A), 2 - Japan(4.9Ghz))\n");
   4548 	  console_printf_terminal("Param 1 - Channel(1..14(2.4Ghz), 1..180(5Ghz))\n");
   4549    }
   4550    else
   4551    {
   4552 	   PltTxCW.band 	= (RadioBand_e) parm[0].value;
   4553 	   PltTxCW.channel 	= (Channel_e) parm[1].value;
   4554 
   4555 	   Status = TI_PLT_TxCW(g_id_adapter, &PltTxCW);
   4556 		if (Status == OK)
   4557 			console_printf_terminal("OK\n");
   4558 		else
   4559 			console_printf_terminal("NOK\n");
   4560 
   4561    }
   4562 }
   4563 
   4564 void cmd_PLT_TxStop(ConParm_t parm[], U16 nParms)
   4565 {
   4566 	UINT32 Status = TI_PLT_TxStop(g_id_adapter);
   4567 	if (Status == OK)
   4568 		console_printf_terminal("OK\n");
   4569 	else
   4570 		console_printf_terminal("NOK\n");
   4571 }
   4572 
   4573 void cmd_PLT_MIB_CounterTable(ConParm_t parm[], U16 nParms)
   4574 {
   4575     PLT_MIB_t Mib;
   4576     UINT32 Status;
   4577     memset(&Mib, 0, sizeof(Mib));
   4578     Mib.aMib = PLT_MIB_countersTable;
   4579 
   4580     Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
   4581     if (Status == OK)
   4582     {
   4583        console_printf_terminal("FCS error count= %d \nPLCP  error count = %d\n",
   4584 							   Mib.aData.CounterTable.FCSErrorCount,
   4585 							   Mib.aData.CounterTable.PLCPErrorCount);
   4586     }
   4587     else
   4588     {
   4589 		console_printf_terminal("NOK\n");
   4590     }
   4591 }
   4592 
   4593 void cmd_PLT_MIB_StationID(ConParm_t parm[], U16 nParms)
   4594 {
   4595     PLT_MIB_t Mib;
   4596     UINT32 Status;
   4597     memset(&Mib, 0, sizeof(Mib));
   4598     Mib.aMib = PLT_MIB_dot11StationId;
   4599 
   4600     Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
   4601     if (Status == OK)
   4602     {
   4603        console_printf_terminal("MIB_StationID = %02x:%02x:%02x:%02x:%02x:%02x\n",
   4604                                 Mib.aData.StationId.addr[5],
   4605                                 Mib.aData.StationId.addr[4],
   4606                                 Mib.aData.StationId.addr[3],
   4607                                 Mib.aData.StationId.addr[2],
   4608                                 Mib.aData.StationId.addr[1],
   4609                                 Mib.aData.StationId.addr[0]);
   4610     }
   4611     else
   4612     {
   4613 		console_printf_terminal("NOK\n");
   4614     }
   4615 
   4616 
   4617 }
   4618 
   4619 
   4620 void cmd_modify_ctsToSelf(ConParm_t parm[], U16 nParms)
   4621 {
   4622     PLT_MIB_t Mib;
   4623     UINT32 Status;
   4624     memset(&Mib, 0, sizeof(Mib));
   4625     Mib.aMib = PLT_MIB_ctsToSelf;
   4626 
   4627 	if (nParms != 1)
   4628 	{
   4629 	   console_printf_terminal("CTS to self: [0 - Disable, 1 - Enable]\n");
   4630 	}
   4631 
   4632 	if (nParms == 0) /*Get ctsToSelf */
   4633     {
   4634         Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
   4635         if (OK == Status)
   4636             console_printf_terminal("ctsToSelf = %s (%d)\n",
   4637             Mib.aData.CTSToSelfEnable?"Enable":"Disable",
   4638             Mib.aData.CTSToSelfEnable);
   4639     }
   4640     else if (nParms == 1)
   4641     {
   4642         Mib.Length = sizeof(Mib.aData.CTSToSelfEnable);
   4643         Mib.aData.CTSToSelfEnable = parm[0].value;
   4644         if (OK != TI_PLT_WriteMIB(g_id_adapter, &Mib))
   4645             console_printf_terminal("TI_PLT_WriteMIB failed\n");
   4646     }
   4647 }
   4648 
   4649 void cmd_get_arpIpTable(ConParm_t parm[], U16 nParms)
   4650 {
   4651     PLT_MIB_t Mib;
   4652     UINT32 Status;
   4653     memset(&Mib, 0, sizeof(Mib));
   4654     Mib.aMib = PLT_MIB_arpIpAddressesTable;
   4655     Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
   4656     if (OK == Status)
   4657     {
   4658        int FilteringEnable = Mib.aData.ArpIpAddressesTable.FilteringEnable;
   4659        console_printf_terminal("ARP IP Table:\n");
   4660        console_printf_terminal("FilteringEnable: %s (%d)\n",
   4661            FilteringEnable?"Enable":"Disable",
   4662            FilteringEnable);
   4663        console_printf_terminal("ArpIpAddress: %d.%d.%d.%d\n",
   4664            Mib.aData.ArpIpAddressesTable.addr[0],
   4665            Mib.aData.ArpIpAddressesTable.addr[1],
   4666            Mib.aData.ArpIpAddressesTable.addr[2],
   4667            Mib.aData.ArpIpAddressesTable.addr[3]
   4668            );
   4669     }
   4670 }
   4671 
   4672 void cmd_get_GroupAddressTable(ConParm_t parm[], U16 nParms)
   4673 {
   4674     PLT_MIB_t Mib;
   4675     UINT32 Status;
   4676     memset(&Mib, 0, sizeof(Mib));
   4677     Mib.aMib = PLT_MIB_dot11GroupAddressesTable;
   4678     Status = TI_PLT_ReadMIB(g_id_adapter, &Mib);
   4679     if (OK == Status)
   4680     {
   4681        int FilteringEnable = Mib.aData.GroupAddressTable.bFilteringEnable;
   4682        int i;
   4683 
   4684        console_printf_terminal("Group addresses Table:\n");
   4685        console_printf_terminal("FilteringEnable: %s (%d)\n",
   4686            FilteringEnable?"Enable":"Disable",
   4687            FilteringEnable);
   4688        console_printf_terminal("nNumberOfAddresses: %d\n", Mib.aData.GroupAddressTable.nNumberOfAddresses);
   4689        console_printf_terminal("Group addresses: \n");
   4690 
   4691        for (i=0; i<Mib.aData.GroupAddressTable.nNumberOfAddresses; i++)
   4692        console_printf_terminal("%x:%x:%x:%x:%x:%x\n",
   4693            Mib.aData.GroupAddressTable.GroupTable[i].addr[0],
   4694            Mib.aData.GroupAddressTable.GroupTable[i].addr[1],
   4695            Mib.aData.GroupAddressTable.GroupTable[i].addr[2],
   4696            Mib.aData.GroupAddressTable.GroupTable[i].addr[3],
   4697            Mib.aData.GroupAddressTable.GroupTable[i].addr[4],
   4698            Mib.aData.GroupAddressTable.GroupTable[i].addr[5]
   4699            );
   4700     }
   4701 }
   4702 
   4703 void cmd_PLT_TxCalGainGet(ConParm_t parm[], U16 nParms)
   4704 {
   4705    UINT32 Status;
   4706    PltGainGet_t PLTGainGet;
   4707 
   4708    Status = TI_PLT_TxCalGainGet(g_id_adapter, &PLTGainGet);
   4709    if (Status == OK)
   4710    {
   4711        console_printf_terminal("\n");
   4712        console_printf_terminal("TxGain: %d(0x%x)\n", PLTGainGet.TxGain, PLTGainGet.TxGain);
   4713        console_printf_terminal("TxUpperBound: %d(0x%x)\n", PLTGainGet.TxUpperBound, PLTGainGet.TxUpperBound);
   4714        console_printf_terminal("TxLowerBound: %d(0x%x)\n", PLTGainGet.TxLowerBound, PLTGainGet.TxLowerBound);
   4715    }
   4716    else
   4717        console_printf_terminal("NOK\n");
   4718 }
   4719 
   4720 
   4721 void cmd_PLT_TxCalGainAdjust(ConParm_t parm[], U16 nParms)
   4722 {
   4723    UINT32 Status;
   4724    UINT32 GainChange;
   4725    OS_802_11_POWER_LEVELS mode;
   4726 
   4727 
   4728    if ((nParms == 0) || (nParms > 1))
   4729    {
   4730 	   console_printf_terminal("\n");
   4731        console_printf_terminal("Param 0 - Gain change (db)\n");
   4732    }
   4733    else
   4734    {
   4735        GainChange = parm[0].value;
   4736 
   4737         /* Check Power mode (works only in "awake" mode !!!) */
   4738         TI_GetPowerLevelDefault(g_id_adapter, &mode );
   4739         if(mode == OS_POWER_LEVEL_AWAKE)
   4740         {
   4741 	   Status = TI_PLT_TxCalGainAdjust(g_id_adapter, GainChange);
   4742 		    if (Status == OK)
   4743 			    console_printf_terminal("OK\n");
   4744 		    else
   4745 			    console_printf_terminal("NOK\n");
   4746         }
   4747         else
   4748         {
   4749 	        console_printf_terminal("Gain Adjust was not performed becouse Default power-mode is not AWAKE\n");
   4750 	        console_printf_terminal("Please change defaultPowerLevel parametr in tiwlan.ini file first\n");
   4751         }
   4752    }
   4753 }
   4754 
   4755 void cmd_PLT_TxCalStart(ConParm_t parm[], U16 nParms)
   4756 {
   4757        UINT32 Status;
   4758 	   PltTxCalibrationRequest_t tTxStart;
   4759 
   4760 	   if (nParms != 1)
   4761 	   {
   4762 		   console_printf_terminal("\nParam 0 - Tx Power [0-255]\n");
   4763 	   }
   4764 	   else
   4765 	   {
   4766         /* use U8 cast to fix compile warning */
   4767 		   tTxStart.refTxPower = (U8)parm[0].value;
   4768 		   Status = TI_PLT_TxCalStart(g_id_adapter,&tTxStart);
   4769 		   if (Status == OK)
   4770 			   console_printf_terminal("OK\n");
   4771 		   else
   4772 			   console_printf_terminal("NOK\n");
   4773 	   }
   4774 }
   4775 
   4776 void cmd_PLT_TxCalStop(ConParm_t parm[], U16 nParms)
   4777 {
   4778        UINT32 Status;
   4779 
   4780 	   Status = TI_PLT_TxCalStop(g_id_adapter);
   4781        if (Status == OK)
   4782            console_printf_terminal("OK\n");
   4783        else
   4784            console_printf_terminal("NOK\n");
   4785 }
   4786 
   4787 void cmd_PLT_RxTxCalNVSUpdateBuffer(ConParm_t parm[], U16 nParms)
   4788 {
   4789    UINT32 Status;
   4790    PltNvsResultsBuffer_t PltNvsResultsBuffer;
   4791    int i;
   4792 
   4793    memset(&PltNvsResultsBuffer, 0, sizeof(PltNvsResultsBuffer));
   4794    Status = TI_PLT_RxTxCalNVSUpdateBuffer(g_id_adapter, &PltNvsResultsBuffer);
   4795    if (Status == OK)
   4796    {
   4797        console_printf_terminal("NVSUpdateBuffer -  number of tables:%d\n", PltNvsResultsBuffer.numOfTables);
   4798        console_printf_terminal("# \t Offset\t Size\t Data\n");
   4799        console_printf_terminal("###################################################################\n");
   4800        for (i=0; (i<PltNvsResultsBuffer.numOfTables) && (i<NVS_RESULTS_MAX_NUM_OF_TABLES); i++)
   4801        {
   4802         int j;
   4803         console_printf_terminal("#%d\t %p\t %.4d\t ",
   4804                                 i,
   4805                                 PltNvsResultsBuffer.tables[i].offset,
   4806                                 PltNvsResultsBuffer.tables[i].size);
   4807         for (j=0; (j<PltNvsResultsBuffer.tables[i].size) && (j<NVS_RESULTS_MAX_UPDATE_TABLE_SIZE); j++)
   4808         {
   4809             console_printf_terminal("%.2x ", PltNvsResultsBuffer.tables[i].data[j]);
   4810         }
   4811         console_printf_terminal("\n");
   4812        }
   4813    }
   4814    else
   4815        console_printf_terminal("NOK\n");
   4816 }
   4817 
   4818 void cmd_PLT_RxCal(ConParm_t parm[], U16 nParms)
   4819 {
   4820    UINT32 Status;
   4821    PltRxCalibrationRequest_t PltRxCalibrationRequest;
   4822    OS_802_11_POWER_LEVELS mode;
   4823 
   4824    if ((nParms == 0) || (nParms > 5))
   4825    {
   4826       console_printf_terminal("\n");
   4827 	  console_printf_terminal("Param 0 - Expected Rssi (db)\n");
   4828 	  console_printf_terminal("Param 1 - Channel\n");
   4829 	  console_printf_terminal("Param 2 - Band (0 - 2.4Ghz(B/G), 1 - 5Ghz(A), 2 - Japan(4.9Ghz)\n");
   4830       console_printf_terminal("Param 3 - Interval between samples(uSec) [100]\n");
   4831       console_printf_terminal("Param 4 - Number of samples [1000]\n");
   4832    }
   4833    else
   4834    {
   4835 	   PltRxCalibrationRequest.expectedRssi	= parm[0].value;
   4836 	   PltRxCalibrationRequest.channel = (UINT8)parm[1].value;
   4837 	   PltRxCalibrationRequest.band = (UINT8)parm[2].value;
   4838        PltRxCalibrationRequest.intervalBetweenSamplesUsec = parm[3].value;
   4839        PltRxCalibrationRequest.numOfSamples = (UINT16)parm[4].value;
   4840 
   4841         /* Check Power mode (works only in "awake" mode !!!) */
   4842         TI_GetPowerLevelDefault(g_id_adapter, &mode );
   4843         if(mode == OS_POWER_LEVEL_AWAKE)
   4844         {
   4845 	        Status = TI_PLT_RxCal(g_id_adapter, &PltRxCalibrationRequest);
   4846 	        if (Status == OK)
   4847 		        console_printf_terminal("OK\n");
   4848 	        else
   4849 		        console_printf_terminal("NOK\n");
   4850         }
   4851         else
   4852         {
   4853 	        console_printf_terminal("Rx calibration was not performed becouse Default power-mode is not AWAKE\n");
   4854 	        console_printf_terminal("Please change defaultPowerLevel parametr in tiwlan.ini file first\n");
   4855         }
   4856    }
   4857 }
   4858 
   4859 void cmd_PLT_RadioTune(ConParm_t parm[], U16 nParms)
   4860 {
   4861    UINT32 Status;
   4862    TestCmdChannelBand_t ChannelBand;
   4863    OS_802_11_POWER_LEVELS mode;
   4864 
   4865 
   4866    if ((nParms == 0) || (nParms > 2))
   4867    {
   4868 	  console_printf_terminal("Param 0 - Band (0-2.4Ghz, 1-5Ghz, 2-4.9Ghz)\n");
   4869 	  console_printf_terminal("Param 1 - Channel\n");
   4870    }
   4871    else
   4872    {
   4873 	   ChannelBand.band 	= (RadioBand_e) parm[0].value;
   4874 	   ChannelBand.channel 	= (Channel_e) parm[1].value;
   4875 
   4876 	    /* Check Power mode (works only in "awake" mode !!!) */
   4877         TI_GetPowerLevelDefault(g_id_adapter, &mode );
   4878 		if(mode == OS_POWER_LEVEL_AWAKE)
   4879 		{
   4880 			Status = TI_PLT_RadioTune(g_id_adapter, &ChannelBand);
   4881 			if (Status == OK)
   4882 				console_printf_terminal("OK\n");
   4883 			else
   4884 				console_printf_terminal("NOK\n");
   4885 		}
   4886 		else
   4887 		{
   4888 			console_printf_terminal("Radio tune was not performed becouse Default power-mode is not AWAKE\n");
   4889 			console_printf_terminal("Please change defaultPowerLevel parametr in tiwlan.ini file first\n");
   4890 		}
   4891 	}
   4892 }
   4893 
   4894 
   4895 #ifdef _WINDOWS
   4896 #endif /* ifdef _WINDOWS */
   4897