Home | History | Annotate | Download | only in Test
      1 /*
      2  * scrDbg.c
      3  *
      4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  *
     11  *  * Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  *  * Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in
     15  *    the documentation and/or other materials provided with the
     16  *    distribution.
     17  *  * Neither the name Texas Instruments nor the names of its
     18  *    contributors may be used to endorse or promote products derived
     19  *    from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /** \file  scrDbg.c
     35  *  \brief This file include the SCR debug module implementation
     36  *
     37  *  \see   scrDbg.h, scrApi.h
     38  */
     39 
     40 
     41 #include "tidef.h"
     42 #include "scrDbg.h"
     43 #include "osApi.h"
     44 #include "report.h"
     45 
     46 #define MAX_DESC_LENGTH     50
     47 
     48 char clientDesc[ SCR_CID_NO_CLIENT + 1 ][ MAX_DESC_LENGTH ] =
     49 {
     50     "SCR_CID_APP_SCAN",
     51     "SCR_CID_DRIVER_FG_SCAN",
     52     "SCR_CID_CONT_SCAN",
     53     "SCR_CID_XCC_MEASURE",
     54     "SCR_CID_BASIC_MEASURE",
     55     "SCR_CID_CONNECT",
     56     "SCR_CID_IMMED_SCAN",
     57     "SCR_CID_SWITCH_CHAN",
     58     "SCR_CID_NUM_OF_CLIENTS",
     59     "SCR_CID_NO_CLIENT"
     60 };
     61 
     62 char requestStatusDesc[ 4 ][ MAX_DESC_LENGTH ] =
     63 {
     64     "SCR_CRS_RUN",
     65     "SCR_CRS_PEND",
     66     "SCR_CRS_ABORT",
     67     "SCR_CRS_FW_RESET"
     68 };
     69 
     70 char pendReasonDesc[ SCR_PR_NONE + 1 ][ MAX_DESC_LENGTH ] =
     71 {
     72     "SCR_PR_OTHER_CLIENT_ABORTING",
     73     "SCR_PR_OTHER_CLIENT_RUNNING",
     74     "SCR_PR_DIFFERENT_GROUP_RUNNING",
     75     "SCR_PR_NONE"
     76 };
     77 
     78 char groupDesc[ SCR_GID_NUM_OF_GROUPS ][ MAX_DESC_LENGTH ] =
     79 {
     80     "SCR_GID_IDLE",
     81     "SCR_GID_DRV_SCAN",
     82     "SCR_GID_APP_SCAN",
     83     "SCR_GID_CONNECT",
     84     "SCR_GID_CONNECTED",
     85     "SCR_GID_ROAMING"
     86 };
     87 
     88 char stateDesc[ SCR_CS_ABORTING + 1 ][ MAX_DESC_LENGTH ] =
     89 {
     90     "SCR_CS_IDLE",
     91     "SCR_CS_PENDING",
     92     "SCR_CS_RUNNING",
     93     "SCR_CS_ABORTING"
     94 };
     95 
     96 char modeDesc[ SCR_MID_NUM_OF_MODES][ MAX_DESC_LENGTH ] =
     97 {
     98     "SCR_MID_NORMAL",
     99     "SCR_MID_SG",
    100 };
    101 
    102 char resourceDesc[ SCR_RESOURCE_NUM_OF_RESOURCES ][ MAX_DESC_LENGTH ]=
    103 {
    104     "SCR_RESOURCE_SERVING_CHANNEL",
    105     "SCR_RESOURCE_PERIODIC_SCAN"
    106 };
    107 
    108 /**
    109  * \\n
    110  * \date 01-May-2005\n
    111  * \brief Main SCR debug function
    112  *
    113  * Function Scope \e Public.\n
    114  * \param hScr - handle to the SCR object.\n
    115  * \param funcType - the specific debug function.\n
    116  * \param pParam - parameters for the debug function.\n
    117  */
    118 void scrDebugFunction( TI_HANDLE hScr, TI_UINT32 funcType, void *pParam )
    119 {
    120     switch (funcType)
    121     {
    122     case DBG_SCR_PRINT_HELP:
    123         printScrDbgFunctions();
    124         break;
    125 
    126     case DBG_SCR_CLIENT_REQUEST_SERVING_CHANNEL:
    127         requestAsClient( hScr, *((EScrClientId*)pParam), SCR_RESOURCE_SERVING_CHANNEL );
    128         break;
    129 
    130     case DBG_SCR_CLIENT_RELEASE_SERVING_CHANNEL:
    131         releaseAsClient( hScr, *((EScrClientId*)pParam), SCR_RESOURCE_SERVING_CHANNEL );
    132         break;
    133 
    134     case DBG_SCR_CLIENT_REQUEST_PERIODIC_SCAN:
    135         requestAsClient( hScr, *((EScrClientId*)pParam), SCR_RESOURCE_PERIODIC_SCAN );
    136         break;
    137 
    138     case DBG_SCR_CLIENT_RELEASE_PERIODIC_SCAN:
    139         releaseAsClient( hScr, *((EScrClientId*)pParam), SCR_RESOURCE_PERIODIC_SCAN );
    140         break;
    141 
    142     case DBG_SCR_SET_GROUP:
    143         changeGroup( hScr, *((EScrGroupId*)pParam) );
    144         break;
    145 
    146     case DBG_SCR_PRINT_OBJECT:
    147         printSCRObject( hScr );
    148         break;
    149 
    150     case DBG_SCR_SET_MODE:
    151         changeMode(hScr, *((EScrModeId*)pParam));
    152         break;
    153 
    154     default:
    155         WLAN_OS_REPORT(("Invalid function type in SCR debug function: %d\n", funcType));
    156         break;
    157     }
    158 }
    159 
    160 /**
    161  * \\n
    162  * \date 01-May-2005\n
    163  * \brief Prints SCR debug menu
    164  *
    165  * Function Scope \e Public.\n
    166  */
    167 void printScrDbgFunctions(void)
    168 {
    169     WLAN_OS_REPORT(("   SCR Debug Functions   \n"));
    170     WLAN_OS_REPORT(("-------------------------\n"));
    171     WLAN_OS_REPORT(("1700 - Print the SCR Debug Help\n"));
    172     WLAN_OS_REPORT(("1701 <client> - Request SCR as one shot scan (set client 0-7).\n"));
    173     WLAN_OS_REPORT(("1702 <client> - Release SCR as one shot scan (set client 0-7).\n"));
    174     WLAN_OS_REPORT(("1703 <client> - Request SCR as periodic scan (set client 0-7).\n"));
    175     WLAN_OS_REPORT(("1704 <client> - Release SCR as periodic scan (set client 0-7).\n"));
    176     WLAN_OS_REPORT(("1705 - Change SCR group\n"));
    177     WLAN_OS_REPORT(("1706 - Print SCR object\n"));
    178     WLAN_OS_REPORT(("1707 - Change SCR mode\n"));
    179 }
    180 
    181 /**
    182  * \\n
    183  * \date 29-March-2005\n
    184  * \brief Request the SCR with a given client ID.\n
    185  *
    186  * Function Scope \e Public.\n
    187  * \param hScr - handle to the SCR object.\n
    188  * \param client - the client to request as.\n\
    189  * \param eResource - the requested resource.\n
    190  */
    191 void requestAsClient( TI_HANDLE hScr, EScrClientId client, EScrResourceId eResource )
    192 {
    193     EScePendReason pendReason;
    194     EScrClientRequestStatus requestStatus;
    195 
    196     requestStatus = scr_clientRequest( hScr, client, eResource, &pendReason );
    197     WLAN_OS_REPORT(("Resource %s was requested as client %s, result %s, pend reason %s\n",
    198                     resourceDesc[ eResource ], clientDesc[ client ], requestStatusDesc[ requestStatus ],
    199                     pendReasonDesc[ pendReason ]));
    200 }
    201 
    202 /**
    203  * \\n
    204  * \date 01-May-2005\n
    205  * \brief Stops continuous scan process.\n
    206  *
    207  * Function Scope \e Public.\n
    208  * \param hScr - handle to the SCR object.\n
    209  * \param client - the client to release as.\n
    210  * \param eResource - the released resource.\n
    211  */
    212 void releaseAsClient( TI_HANDLE hScr, EScrClientId client, EScrResourceId eResource )
    213 {
    214     scr_clientComplete( hScr, client, eResource );
    215     WLAN_OS_REPORT(("Resource %s was released as client %s\n",
    216                     resourceDesc[ eResource ], clientDesc[ client ]));
    217 }
    218 
    219 /**
    220  * \\n
    221  * \date 01-May-2005\n
    222  * \brief Change the SCR group.\n
    223  *
    224  * Function Scope \e Public.\n
    225  * \param hScr - handle to the SCR object.\n
    226  * \param group - the group to change to.\n
    227  */
    228 void changeGroup( TI_HANDLE hScr, EScrGroupId group )
    229 {
    230     scr_setGroup( hScr, group );
    231     WLAN_OS_REPORT(("SCR group was changed to %s\n",
    232                     groupDesc[ group ]));
    233 }
    234 
    235 /**
    236  * \\n
    237  * \date 23-Nov-2005\n
    238  * \brief Change the SCR mode.\n
    239  *
    240  * Function Scope \e Public.\n
    241  * \param hScr - handle to the SCR object.\n
    242  * \param mode - the mode to change to.\n
    243  */
    244 void changeMode( TI_HANDLE hScr, EScrModeId mode )
    245 {
    246     scr_setMode( hScr, mode );
    247     WLAN_OS_REPORT(("SCR mode was changed to %s\n",
    248                     modeDesc[ mode ]));
    249 }
    250 /**
    251  * \\n
    252  * \date 15-June-2005\n
    253  * \brief Prints the SCR object.\n
    254  *
    255  * Function Scope \e Public.\n
    256  * \param hScr - handle to the SCR object.\n
    257  */
    258 void printSCRObject( TI_HANDLE hScr )
    259 {
    260 #ifdef REPORT_LOG
    261     TScr* pScr = (TScr*)hScr;
    262     int i;
    263 
    264     WLAN_OS_REPORT( ("SCR current group:%s, mode: %s, serving channel owner:%s, periodic scan owner: %s "
    265                      "within request:%s\n",
    266                      groupDesc[ pScr->currentGroup ],modeDesc[ pScr->currentMode ],
    267                      clientDesc[ pScr->runningClient[ SCR_RESOURCE_SERVING_CHANNEL ] ],
    268                      clientDesc[ pScr->runningClient[ SCR_RESOURCE_PERIODIC_SCAN ] ],
    269                      (TI_TRUE == pScr->statusNotficationPending ? "Yes" : "No" )) );
    270 
    271     WLAN_OS_REPORT( ("%-22s %-15s %-15s %-15s %-15s\n", "Client", "State (SC)", "State (PS)", "Pend Reason (SC)", "Pend Reason (PS)") );
    272     WLAN_OS_REPORT( ("----------------------------------------------------------------------\n"));
    273     for ( i = 0; i < SCR_CID_NUM_OF_CLIENTS; i++ )
    274     {
    275         WLAN_OS_REPORT( ("%-22s %-15s %-15s %-15s %-15s \n",
    276                          clientDesc[ i ], stateDesc[ pScr->clientArray[ i ].state[ SCR_RESOURCE_SERVING_CHANNEL ] ],
    277                          stateDesc[ pScr->clientArray[ i ].state[ SCR_RESOURCE_PERIODIC_SCAN ] ],
    278                          pendReasonDesc[ pScr->clientArray[ i ].currentPendingReason[ SCR_RESOURCE_SERVING_CHANNEL ] ],
    279                          pendReasonDesc[ pScr->clientArray[ i ].currentPendingReason[ SCR_RESOURCE_PERIODIC_SCAN ] ]) );
    280     }
    281 #endif
    282 }
    283