openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

cmdlist.c (49437B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * socdiag command list
      8  */
      9 
     10 #include <appl/diag/system.h>
     11 #include <shared/bsl.h>
     12 #include <sal/appl/sal.h>
     13 /*
     14  * The following are always turned off in portability mode
     15  */
     16 #ifdef NO_SAL_APPL
     17 
     18 #undef INCLUDE_I2C
     19 
     20 #endif /* NO_SAL_APPL */
     21 
     22 
     23 #if defined(MOUSSE) || defined(BMW) || defined(IDTRP334) || defined(GTO) || \
     24     defined(MBZ) || defined(IDT438) || defined(NSX) ||  \
     25     defined(KEYSTONE)
     26 #endif
     27 
     28 #if defined(INCLUDE_BCMX_DIAG)
     29 #include "bcmx/bcmx.h"
     30 #endif
     31 
     32 #if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)
     33 #include <appl/diag/dcmn/cmdlist.h>
     34 #endif
     35 
     36 #if defined(BCM_DNX_SUPPORT)
     37 #include <appl/diag/dnx/diag_dnx_cmdlist.h>
     38 #endif
     39 
     40 #if defined(BCM_DNXF_SUPPORT)
     41 #include <appl/diag/dnxf/diag_dnxf_cmdlist.h>
     42 #endif
     43 
     44 #if defined(BCM_SAND_SUPPORT) && (defined(__DUNE_GTO_BCM_CPU__) || defined(__DUNE_WRX_BCM_CPU__) || defined(__DUNE_SLK_BCM_CPU__))
     45 #include <appl/diag/sand/diag_sand_access.h>
     46 #endif
     47 
     48 
     49 #include <appl/diag/diag.h>
     50 #include <appl/diag/cmdlist.h>
     51 
     52 cmd_t *cur_cmd_list[SOC_MAX_NUM_DEVICES];
     53 int cur_cmd_cnt[SOC_MAX_NUM_DEVICES];
     54 int cur_mode[SOC_MAX_NUM_DEVICES];
     55 
     56 cmd_t * dyn_cmd_list[SOC_MAX_NUM_DEVICES];
     57 int     dyn_cmd_cnt[SOC_MAX_NUM_DEVICES];
     58 
     59 #if defined(BCM_ESW_SUPPORT)
     60 static cmd_result_t (*_bcm_trunk_ref)(int unit, args_t *a) = _bcm_diag_trunk_show;
     61 #endif
     62 
     63 #if defined(INCLUDE_LIB_CPUDB) && defined(INCLUDE_LIB_CPUTRANS) && \
     64     defined(INCLUDE_LIB_DISCOVER) && defined(INCLUDE_LIB_STKTASK)
     65 #define TKS_SUPPORT
     66 #endif
     67 
     68 /* This is the list of commands that can be executed independent of mode */
     69 cmd_t bcm_cmd_common[] = {
     70     {"?",               sh_help_short,          sh_help_short_usage,
     71      "Display list of commands"},
     72     {"??",              sh_help,                sh_help_usage,
     73      "@help" },
     74 #if defined(INCLUDE_LIB_AEDEV)
     75     {"AEDev",  cmd_aedev, cmd_aedev_usage, "AE Development Environment Utility."},
     76     {"SWDev",  cmd_swdev, cmd_swdev_usage, "SW Development Environment Utility."},
     77 #endif
     78 #if defined(INCLUDE_APIMODE)
     79     {"API",       cmd_api,      cmd_api_usage,
     80      "Control API command mode parsing."},
     81 #endif
     82     {"ASSert",       cmd_assert,      cmd_assert_usage,
     83      "Assert"},
     84 #if defined(BCM_ASYNC_SUPPORT)
     85     {"ASYNC",       cmd_async,      cmd_async_usage,
     86      "Control BCM API Async daemon."},
     87 #endif
     88     {"Attach",          sh_attach,              sh_attach_usage,
     89      "Attach SOC device(s)" },
     90     {"BackGround",      sh_bg,                 sh_bg_usage,
     91      "Execute a command in the background."},
     92 #if defined(INCLUDE_BCMX_DIAG)
     93     {"BCM",             cmd_mode_bcm,            shell_bcm_usage,
     94      "Set shell mode to BCM."},
     95     {"BCMX",            cmd_mode_bcmx,           shell_bcmx_usage,
     96      "Set shell mode to BCMX."},
     97 #endif
     98 #if defined(INCLUDE_BOARD)
     99     {"Board",           board_cmd,              board_cmd_usage,
    100      "New Board support."},
    101 #endif
    102 #if defined(BROADCOM_DEBUG)
    103     {"break",           sh_break,          sh_break_usage,        "place to hang a breakpoint" },
    104 #endif
    105 #if defined(BCM_CMICM_SUPPORT)
    106     {"BroadSync",       cmd_broadsync,          cmd_broadsync_usage,     "Manage Time API BroadSync endpoints"},
    107 #endif
    108 #if defined(INCLUDE_GDPLL)
    109     {"GDPLL",       cmd_gdpll,          cmd_gdpll_usage,     "GDPLL Channel Management"},
    110 #endif
    111     {"CASE",            sh_case,                sh_case_usage,
    112      "Execute command based on string match"},
    113 #ifndef NO_SAL_APPL
    114 #ifndef NO_UNIX_ACCESS
    115     {"CD",              sh_cd,                  sh_cd_usage,
    116      "Change current working directory"},
    117 #endif
    118 #if defined(INCLUDE_LIB_CINT)
    119     {"cint",            cmd_cint,                cmd_cint_usage,
    120      "Enter the C interpreter",
    121     },
    122 #endif
    123 #endif
    124 #if defined(BCM_API_VERBOSE_LOGGING)
    125     {"CintApiLogging",   cint_logger_cmd,  cint_logger_usage,
    126      "Configure the CINT API Logger functionality"},
    127 #endif
    128     {"ClearScreen",         sh_clear_screen,             sh_clear_screen_usage,
    129      "Clear terminal output"},
    130 #ifndef NO_SAL_APPL
    131     {"CONFig",          sh_config,              sh_config_usage,
    132      "Configure Management interface"},
    133     {"CONSole",         sh_console,             sh_console_usage,
    134      "Control console options"},
    135 #ifndef NO_UNIX_ACCESS
    136     {"CoPy",            sh_copy,                sh_copy_usage,
    137      "Copy a file"},
    138 #endif
    139 #endif /* NO_SAL_APPL */
    140 #if defined(BCM_SAND_SUPPORT) && (defined(__DUNE_GTO_BCM_CPU__) || defined(__DUNE_WRX_BCM_CPU__) || defined(__DUNE_SLK_BCM_CPU__))
    141     {"cpu_i2c", cmd_sand_cpu_i2c, cmd_sand_cpu_i2c_usage, "Read/Write I2C via cpu"},
    142     {"cpu_regs", cmd_sand_cpu_regs, cmd_sand_cpu_regs_usage, "Read/Write function to cpu regs"},
    143 #endif
    144 #if defined(TKS_SUPPORT)
    145     {"CPUDB",           ct_cpudb,               ct_cpudb_usage,
    146      "Update the CPU database"},
    147     {"CTEcho",          ct_echo,                ct_echo_usage,
    148      "Send an echo request using CPUTRANS"},
    149     {"CTInstall",       ct_install,             ct_install_usage,
    150      "Set up transport pointers in CPU transports"},
    151     {"CTSetup",         ct_setup,               ct_setup_usage,
    152      "Modify the CPUTRANS setup"},
    153 #endif
    154 #ifndef NO_SAL_APPL
    155     {"DATE",            sh_date,                sh_date_usage,
    156      "Set or display current date"},
    157 #endif
    158 #if defined(TKS_SUPPORT)
    159     {"DBDump",          cmd_st_db_dump,         cmd_st_db_dump_usage,
    160      "Dump the current StackTask CPUDB"},
    161     {"DBParse",         cmd_cpudb_parse,        cmd_cpudb_parse_usage,
    162      "Parse a line of CPUDB dumped code"},
    163 #endif
    164     {"DeBug",           sh_debug,               sh_debug_usage,
    165      "Enable/Disable debug output"},
    166     {"DELAY",           sh_delay,               sh_delay_usage,
    167      "Put CLI task in a busy-wait loop for some amount of time"},
    168 #if defined(BCM_XGS_SUPPORT)
    169     {"DEVice",          cmd_device,             cmd_device_usage,
    170      "Device add/remove"},
    171 #endif /* BCM_XGS_SUPPORT */
    172 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    173     {"DIR",             sh_ls,                  sh_ls_usage,
    174      "@ls" },
    175 #endif
    176     {"DISPatch",    cmd_dispatch,       cmd_dispatch_usage,
    177      "BCM Dispatch control."},
    178      {"Echo",            sh_echo,               sh_echo_usage,
    179      "Echo command line"},
    180 #ifndef NO_UNIX_ACCESS
    181     {"EXIT",            sh_exit,                sh_exit_usage,
    182      "Exit the current shell (and possibly reset)" },
    183 #endif
    184     {"EXPR",            sh_expr,                sh_expr_usage,
    185      "Evaluate infix expression" },
    186 #ifndef NO_SAL_APPL
    187     {"FLASHINIT",       sh_flashinit,           sh_flashinit_usage,
    188      "Initialize on board flash as a file system"},
    189     {"FLASHSYNC",       sh_flashsync,           sh_flashsync_usage,
    190      "Sync up on board flash with file system"},
    191 #endif
    192     {"FOR",             sh_for,                 sh_for_usage,
    193      "Execute a series of commands in a loop"},
    194     {"Help",            sh_help,                sh_help_usage,
    195      "Print this list OR usage for a specific command" },
    196     {"HISTory",         sh_history,             sh_history_usage,
    197      "List command history"},
    198 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    199 #endif
    200     {"IF",              sh_if,                  sh_if_usage,
    201      "Conditionally execute commands"},
    202 #ifndef NO_SAL_APPL
    203 #ifndef SAL_CONFIG_FILE_DISABLE
    204 #ifndef NO_FILEIO
    205      {"IMPORT",         sh_import,              sh_import_usage,
    206       "Load commands from a file"},
    207 #endif
    208 #endif
    209 #endif
    210 #ifdef BCM_IPROC_SUPPORT
    211     {"IPROCRead",       iprocread_cmd,          iprocread_usage,
    212      "Read from IPROC Area"},
    213     {"IPROCWrite",      iprocwrite_cmd,         iprocwrite_usage,
    214      "Write to IPROC Area"},
    215 #endif
    216     {"JOBS",            sh_jobs,                sh_jobs_usage,
    217      "List current background jobs"},
    218     {"KILL",            sh_kill,                sh_kill_usage,
    219      "Terminate a background job"},
    220 /*
    221  * Change 'LED' clause: This was for BCM_PETRA_SUPPORT (Arad and Jericho
    222  * family)and was changed to BCM_SAND_SUPPORT (Jericho-2 family, DNX) to
    223  * enable using a similar configuration file (For DNX: dnx.doc)
    224  * In the future, this may be changed as per actual DNX board details.
    225  */
    226 #if defined(BCM_ESW_SUPPORT) || defined(BCM_SAND_SUPPORT)
    227     {"LED",             ledproc_cmd,            ledproc_usage,
    228      "Control/Load LED processor"},
    229 #endif
    230     {"LOCal",           var_local,              var_local_usage,
    231      "Create/Delete a variable in the local scope"},
    232 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    233     {"LOG",             sh_log,                 sh_log_usage,
    234      "Enable/Disable logging and set log file"},
    235 #endif
    236     {"LOOP",            sh_loop,                sh_loop_usage,
    237      "Execute a series of commands in a loop"},
    238 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    239     {"LS",              sh_ls,                  sh_ls_usage,
    240      "List current directory"},
    241 #endif
    242 #ifdef BCM_CMICX_SUPPORT
    243     {"M0",             m0_cmd,                m0_usage,          "M0 commands for led/linkscan fw"},
    244 #endif
    245 #ifdef INCLUDE_MACSEC
    246     {"MacSec",           sh_macsec,               sh_macsec_usage,
    247      "Set/Get MACSEC register/table and call MACSEC APIs"},
    248 #endif /* INCLUDE_MACSEC */
    249 #ifdef BCM_CMICM_SUPPORT
    250     {"MCSCmd",          mcscmd_cmd,             mcscmd_usage,           "Execute cmd on uC"},
    251     {"MCSDump",         mcsdump_cmd,            mcsdump_usage,          "Create MCS dumpfile"},
    252     {"MCSLoad",         mcsload_cmd,            mcsload_usage,          "Load hexfile to MCS memory"},
    253     {"MCSMsg",          mcsmsg_cmd,             mcsmsg_usage,           "Start/stop messaging with MCs"},
    254     {"MCSStatus",       mcsstatus_cmd,          mcsstatus_usage,        "Show MCS fault status"},
    255     {"MCSTimeStamp",    mcstimestamp_cmd,       mcstimestamp_usage,     "Print MCS timestamp data"},
    256 #endif
    257 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    258     {"MKDIR",           sh_mkdir,               sh_mkdir_usage,
    259      "Make a directory"},
    260 #endif
    261 #if defined(INCLUDE_BCMX_DIAG)
    262     {"MODE",            cmd_mode,               shell_mode_usage,
    263      "Set shell mode" },
    264 #endif
    265 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    266     {"MORe",            sh_more,                sh_more_usage,
    267      "Copy a file to the console"},
    268     {"MoVe",            sh_rename,              sh_rename_usage,
    269      "Rename a file on a file system"},
    270 #ifdef INCLUDE_NFS
    271     {"NFS",             cmd_nfs,                cmd_nfs_usage,
    272      "NFS Control"},
    273 #endif
    274 #endif /* !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS) */
    275     {"NOEcho",          sh_noecho,              sh_noecho_usage,
    276      "Ignore command line"},
    277 #ifndef NO_SAL_APPL
    278     {"Pause",           sh_pause,               sh_pause_usage,
    279      "Pause command processing and wait for input"},
    280 #endif
    281 #if defined(BCM_DNX_SUPPORT) || defined(BCM_DNXF_SUPPORT) || (defined(BCM_ESW_SUPPORT) && defined(PCIEG3_DIAG_SUPPORT))
    282     {"PCIEPHY",         cmd_pciephy,            pciephy_usage,
    283      "PCIe PHY speicific utilities"},
    284 #endif
    285 #ifndef NO_SAL_APPL
    286 #endif
    287 #ifdef INCLUDE_LIB_PIONEER_HOST
    288     {"PIOneer",         cmd_pioneer,            cmd_pioneer_usage,
    289      "Run a pioneer host command"},
    290 #endif
    291 #ifdef PORTMOD_DIAG
    292     {"PortMod",          cmd_portmod_diag,      portmod_diag_usage,    "Portmod Diagnostics"},
    293 #endif
    294     {"PRINTENV",        var_display,            var_display_usage,
    295      "Display current variable list"},
    296     {"PROBE",           sh_probe,               sh_probe_usage,
    297      "Probe for available SOC units"},
    298 #ifdef BCM_BPROF_STATS
    299     {"PROF",             sh_prof,              sh_prof_usage,           "Profile statistics info "},
    300 #endif
    301 #ifdef BCM_CMICM_SUPPORT
    302     {"PSCAN",           pscan_cmd,              pscan_usage,
    303      "Control uKernel port scanning."},
    304 #endif
    305 #ifdef INCLUDE_PTP
    306     {"PTP",             cmd_ptp,                cmd_ptp_usage,           "PTP stack configuration"},
    307 #endif
    308 #if defined(SOC_UKERNEL_DEBUG)
    309 #if defined(BCM_CMICM_SUPPORT) || defined(BCM_IPROC_SUPPORT)
    310     {"UCDBG",           cmd_cmic_ucdebug,       cmd_cmic_ucdebug_usage,  "Ukernel Debug"},
    311 #endif
    312 #endif
    313 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    314     {"PWD",             sh_pwd,                 sh_pwd_usage,
    315      "Print platform dependent working directory"},
    316 #endif
    317 #ifndef NO_UNIX_ACCESS
    318     {"QUIT",            sh_exit,                sh_exit_usage,
    319      "@exit"},
    320 #endif
    321 #ifndef NO_SAL_APPL
    322     {"RCCache",         sh_rccache,             sh_rccache_usage,
    323      "Save contents of an rc file in memory"},
    324     {"RCLoad",          sh_rcload,              sh_rcload_usage,
    325      "Load commands from a file"},
    326 #ifndef NO_UNIX_ACCESS
    327     {"REBOOT",          sh_reboot,              sh_reboot_usage,
    328      "Reboot the processor"},
    329     {"REName",          sh_rename,              sh_rename_usage,
    330      "@move" },
    331     {"RESET",           sh_reboot,              sh_reboot_usage,
    332      "@reboot"},
    333     {"RM",              sh_remove,              sh_remove_usage,
    334      "Remove a file from a file system"},
    335     {"RMDIR",           sh_rmdir,               sh_rmdir_usage,
    336      "Remove a directory"},
    337 #endif
    338 #endif  /* NO_SAL_APPL */
    339 
    340 #if defined(BCM_RPC_SUPPORT)
    341     {"RPC",     cmd_rpc,        cmd_rpc_usage,
    342      "Control BCM API RPC daemon."},
    343 #endif
    344 #ifdef BROADCOM_DEBUG
    345 #ifdef INCLUDE_BCM_SAL_PROFILE
    346     {"SalProfile",      cmd_sal_profile,        cmd_sal_profile_usage,
    347      "Displays current SAL resource usage"},
    348 #endif /* INCLUDE_BCM_SAL_PROFILE */
    349 #endif /* BROADCOM_DEBUG */
    350 #ifdef BCM_SAT_SUPPORT
    351     {"SAT",             cmd_sat,                cmd_sat_usage,
    352      "Service activation test"},
    353 #endif /* BCM_SAT_SUPPORT */
    354 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    355     {"SAVE",            sh_write,               sh_write_usage,
    356      "Write data to a file"},
    357 #endif
    358     {"SET",             sh_set,                 sh_set_usage,
    359      "Set various configuration options"},
    360     {"SETENV",          var_export,             var_export_usage,
    361      "Create/Delete a variable in the global scope" },
    362 
    363 #if !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS)
    364     {"SHell",           sh_shell,               sh_shell_usage,
    365      "Invoke a system dependent shell"},
    366 #endif /* !defined(NO_SAL_APPL) && !defined(NO_UNIX_ACCESS) */
    367 
    368     {"SLeep",           sh_sleep,               sh_sleep_usage,
    369      "Suspend the CLI task for specified amount of time"},
    370 #ifndef NO_SAL_APPL
    371 #ifdef INCLUDE_TCL
    372     {"TCL",             cmd_tcl,                tcl_usage,
    373      "Run a TCL shell or TCL script"},
    374 #endif
    375 #endif
    376 #ifdef INCLUDE_PTP
    377     {"TDPLL",           cmd_tdpll,              cmd_tdpll_usage,
    378      "T-DPLL configuration and management"},
    379 #endif
    380     {"TIME",            sh_time,                sh_time_usage,
    381      "Time the execution of one or more commands"},
    382 #ifdef BSL_TRACE_INCLUDE
    383     {"TRaCe",           sh_trace,               sh_trace_usage,
    384      "Control console options"},
    385 #endif
    386     {"Version",         sh_version,             sh_version_usage,
    387      "Print version and build information"},
    388 };
    389 
    390 int bcm_cmd_common_cnt = COUNTOF(bcm_cmd_common);
    391 
    392 #if defined(BCM_ESW_SUPPORT)
    393 /* This is the list of commands that can be executed only in ESW mode */
    394 static cmd_t bcm_esw_cmd_list[] = {
    395 /*                                                                                                                      */
    396 /*    Command   |       Function            |   Usage String      |     Description (Short help)                        */
    397 /*  ------------+---------------------------+---------------------+---------------------------------------------------- */
    398 #ifdef INCLUDE_I2C
    399     {"ADC",             cmd_adc,                cmd_adc_usage,          "Show MAX127 A/D Conversions" },
    400 #endif
    401     {"AGE",             cmd_esw_age,            cmd_age_esw_usage,           "Set ESW hardware age timer" },
    402 #if defined(ALPM_ENABLE)
    403 #if defined(BCM_TRIDENT3_SUPPORT) || defined(BCM_TOMAHAWK3_SUPPORT)
    404     {"ALPM",            cmd_esw_alpm,           cmd_esw_alpm_usage,     "ALPM trouble shooting" },
    405 #endif
    406 #endif
    407 #if defined(BCM_TOMAHAWK_SUPPORT)
    408     {"ASF",             if_esw_asf,             if_esw_asf_usage,       "ASF (cut-through) Mode" },
    409 #endif
    410     {"Attach",          sh_attach,              sh_attach_usage,        "Attach SOC device(s)" },
    411     {"Auth",            cmd_esw_auth,           auth_esw_cmd_usage,     "Port-based network access control"},
    412 #ifdef INCLUDE_AVS
    413     {"AVS",             cmd_avs,                cmd_avs_usage,          "AVS (Adaptive Voltage Scaling)" },
    414 #endif
    415 #ifdef INCLUDE_I2C
    416     {"BaseBoard",       cmd_bb,                 cmd_bb_usage,           "Configure baseboard system parameters."},
    417 #endif
    418 #ifdef BCM_KATANA_SUPPORT
    419 #if defined(INCLUDE_L3)
    420 #if defined(INCLUDE_BFD)
    421     {"BFD",             cmd_esw_bfd,            cmd_esw_bfd_usage,     "Manage BFD endpoints"},
    422 #endif
    423 #endif
    424 #endif
    425     {"BIST",            cmd_bist,               bist_usage,             "Run on-chip memory built-in self tests"},
    426     {"BKPmon",          dbg_bkpmon,             bkpmon_usage,           ".Monitor incoming BKP Discard Messages" },
    427     {"BPDU",            if_esw_bpdu,            if_esw_bpdu_usage,          "Manage BPDU addresses" },
    428     {"BTiMeout",        cmd_btimeout,           btimeout_usage,         "Set BIST operation timeout in microseconds" },
    429 #if defined(BCM_TRIDENT_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT)
    430     {"BUFfer",          cmd_buffer,             cmd_buffer_usage,       "MMU config" },
    431 #endif /* BCM_TRIDENT_SUPPORT || BCM_TRIUMPH3_SUPPORT */
    432     {"CABLEdiag",       cmd_esw_cablediag,      cmd_esw_cablediag_usage,"Run Cable Diagnotics" },
    433     {"CACHE",           mem_esw_cache,          mem_esw_cache_usage,    "Turn on/off software caching of tables" },
    434 #if defined(CANCUN_SUPPORT)
    435 #ifndef NO_SAL_APPL
    436     {"CanCun",          cmd_cancun,             cmd_cancun_usage,       "Cancun file and status operations"},
    437 #endif /* NO_SAL_APPL */
    438 #endif /* CANCUN_SUPPORT */
    439     {"CFAPINIT",        mem_cfapinit,           cfapinit_usage,         ".Init MMU cell free address table" },
    440 #if defined(MBZ)
    441     {"CFMFailover",     if_cfm_failover,        if_cfm_failover_usage,  "Activate CFM failover" },
    442 #endif
    443     {"CHecK",           cmd_check,              check_usage,            "Check a sorted memory table" },
    444     {"CLEAR",           cmd_esw_clear,          cmd_esw_clear_usage,    "Clear a memory table or counters" },
    445 #ifdef INCLUDE_I2C
    446     {"CLOCKS",          cmd_clk,                cmd_clk_usage,          "Set core clock frequency." },
    447 #endif
    448     {"COLOR",           cmd_color,              cmd_color_usage,        "Manage packet color"},
    449     {"COMBO",           if_esw_combo,           if_esw_combo_usage,     "Control combination copper/fiber ports"},
    450     {"COS",             cmd_esw_cos,            cmd_esw_cos_usage,      "Manage classes of service"},
    451     {"CounTeR",         cmd_esw_counter,        cmd_esw_counter_usage,  "Enable/disable counter collection"},
    452     {"CustomSTAT",         cmd_esw_custom_stat,        cmd_esw_custom_stat_usage,  "Enable/disable counter collection"},
    453 #ifdef INCLUDE_I2C
    454     {"DAC",             cmd_dac,                cmd_dac_usage,          "Set DAC register"},
    455 #endif
    456 #ifdef BCM_DDR3_SUPPORT
    457     {"DDRMemRead",      cmd_ddr_mem_read,       cmd_ddr_mem_read_usage,  "Indirect reads to DDR"},
    458     {"DDRMemWrite",     cmd_ddr_mem_write,      cmd_ddr_mem_write_usage, "Indirect writes to DDR"},
    459     {"DDRPhyRead",      cmd_ddr_phy_read,       cmd_ddr_phy_read_usage,  "Read DDR40 phy registers"},
    460     {"DDRPhyTune",      cmd_ddr_phy_tune,       cmd_ddr_phy_tune_usage,  "Tune DDR40 phy registers"},
    461     {"DDRPhyWrite",     cmd_ddr_phy_write,      cmd_ddr_phy_write_usage, "Write DDR40 phy registers"},
    462 #endif
    463     {"DELete",          mem_delete,             delete_usage,           "Delete entry by key from a sorted table" },
    464     {"DETach",          sh_detach,              sh_detach_usage,        "Detach SOC device(s)" },
    465     {"DMA",             cmd_esw_dma,            cmd_esw_dma_usage,      "DMA Facilities Interface" },
    466     {"DmaRomTest",      cmd_drt,                cmd_drt_usage,          "Simple test of the SOC DMA ROM API" },
    467     {"DMIRror",         if_dmirror,             if_dmirror_usage,       "Manage directed port mirroring"},
    468 #ifdef BCM_CMICM_SUPPORT
    469     {"DPLL",            dpll_cmd,               dpll_usage,             "DPLL operations on SPI bus"},
    470 #endif
    471     {"DSCP",            if_esw_dscp,            if_esw_dscp_usage,      "Map Diffserv Code Points" },
    472     {"DTAG",            if_esw_dtag,            if_esw_dtag_usage,      "Double Tagging" },
    473     {"Dump",            cmd_esw_dump,           cmd_esw_dump_usage,     "Dump an address space or registers" },
    474     {"EditReg",         cmd_esw_reg_edit,       cmd_esw_reg_edit_usage, "Edit each field of SOC internal register"},
    475     {"EGRess",          if_egress,              if_egress_usage,        "Manage source-based egress enabling"},
    476     {"EthernetAV",      cmd_esw_eav,            cmd_esw_eav_usage,      "Set/Display the Ethernet AV characteristics"},
    477 
    478 #ifdef INCLUDE_EXAMPLES
    479     {"EXample",         cmd_example_exec,                cmd_example_exec_usage,   "Execute example codes "},
    480 #endif
    481 
    482 #ifdef BCM_TRIUMPH_SUPPORT
    483 #ifndef NO_MEMTUNE
    484     {"EXTernalTuning",  cmd_extt,               cmd_extt_usage,         "External memory automatic tuning" },
    485     {"EXTernalTuning2", cmd_extt2,              cmd_extt2_usage,    "External memory automatic tuning 2" },
    486     {"EXTernalTuningSum",  cmd_extts,       cmd_extts_usage,        "External memory automatic tuning (summary)" },
    487 #endif /* NO_MEMTUNE */
    488 #endif /* BCM_TRIUMPH_SUPPORT */
    489 #ifdef INCLUDE_FCMAP
    490     {"FCOE",             if_esw_fcoe,             if_esw_fcoe_usage, "FCoE NPV Service (Debug Only)"},
    491 #endif
    492 
    493 #ifdef BCM_FIELD_SUPPORT
    494     {"FieldProcessor",  if_esw_field_proc,       if_esw_field_proc_usage,"Manage Field Processor"},
    495 #endif /* BCM_FIELD_SUPPORT */
    496 #ifdef BCM_XGS5_SWITCH_PORT_SUPPORT
    497 #ifdef BCM_TOMAHAWK3_SUPPORT
    498     {"FLEXport",        cmd_if_flexport,        cmd_if_flexport_usage_th3,  "Flexport"},
    499 #elif defined(BCM_TRIDENT3_SUPPORT)
    500     {"FLEXport",        cmd_if_flexport,        cmd_if_flexport_usage_td3,  "Flexport"},
    501 #else
    502     {"FLEXport",        cmd_if_flexport,        cmd_if_flexport_usage,  "Flexport"},
    503 #endif
    504 #endif /* BCM_XGS5_SWITCH_PORT_SUPPORT */
    505 #if defined(CANCUN_SUPPORT)
    506 #ifndef NO_SAL_APPL
    507     {"FlowDb",          cmd_flow_db,            cmd_flow_db_usage,      "Flow Database for flexible tables"},
    508 #endif /* NO_SAL_APPL */
    509 #endif /* CANCUN_SUPPORT */
    510     {"FlowTracker",     cmd_ft,                 cmd_ft_usage,           "Flowtracker commands"},
    511 #ifdef BCM_FLOWTRACKER_EXPORT_FIFO_SUPPORT
    512     {"FlowTrackerMON",        cmd_ftmon,        cmd_ftmon_usage,  "FlowtracketMon"},
    513     {"FlowTrackerRemoteMON",  cmd_ft_rmon_command,    cmd_ft_rmon_usage, "Monitor ports for packets"},
    514 #endif /*  BCM_FLOWTRACKER_EXPORT_FIFO_SUPPORT */
    515     {"Getreg",          cmd_esw_reg_get,        cmd_esw_reg_get_usage,  "Get register" },
    516 #ifdef BCM_KATANA_SUPPORT
    517     {"GlobalMeter",     cmd_esw_policer_global_meter, cmd_esw_policer_global_meter_usage,  "Global meter - policer commands"},
    518 #endif
    519     {"GPORT",           if_esw_gport,           if_esw_gport_usage,     "Get a GPORT id" },
    520 #ifdef BCM_XGS_SUPPORT
    521     {"H2HIGIG",         if_h2higig,             if_h2higig_usage,       "Convert hex words to higig info" },
    522 #ifdef BCM_HIGIG2_SUPPORT
    523     {"H2HIGIG2",        if_h2higig2,            if_h2higig2_usage,      "Convert hex words to higig2 info" },
    524 #endif
    525 #endif
    526 #ifdef BCM_XGS_SWITCH_SUPPORT
    527     {"HASH",            cmd_hash,               hash_usage,             "Get or set hardware hash modes" },
    528 #endif
    529 #if defined(BCM_TRIDENT_SUPPORT) || defined(BCM_ENDURO_SUPPORT) || \
    530     defined(BCM_GREYHOUND2_SUPPORT)
    531     {"HashDestination", cmd_hash_destination,   hash_destination_usage, "Display Hash Destination" },
    532 #endif
    533 #ifdef INCLUDE_I2C
    534     {"HClksel",         cmd_hclksel,           cmd_hclksel_usage,       "Set I2C HClk (MUX for clock-chip-selects)" },
    535 #endif
    536     {"HeaderMode",      cmd_hdr_mode,           cmd_hdr_mode_usage,     "Get or set packet tx header mode" },
    537 #if defined(BCM_TRIDENT2_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT)
    538     {"HSP",             cmd_hsp,                cmd_hsp_usage,          "MMU HSP hierarchy" },
    539 #endif /* BCM_TRIDENT2_SUPPORT */
    540 #ifdef INCLUDE_I2C
    541     {"I2C",             cmd_i2c,                cmd_i2c_usage,          "Inter-Integrated Circuit (I2C) Bus commands"},
    542 #endif
    543 #ifdef BCM_HERCULES_SUPPORT
    544     {"IBDump",          if_ibdump,              if_ibdump_usage,        "Display packets pending in the Ingress Buffer" },
    545 #endif
    546 #ifdef BCM_TRIUMPH3_SUPPORT
    547     {"IbodSync",        cmd_ibod_sync,          ibod_sync_usage,        "Enable/Disable IBOD sync process" },
    548 #endif /* BCM_TRIUHMPH3_SUPPORT */
    549     {"INIT",            sh_init,                sh_init_usage,          "Initialize SOC and S/W"},
    550     {"Insert",          mem_insert,             insert_usage,           "Insert into a sorted table" },
    551     {"INTR",            cmd_intr,               cmd_intr_usage,         "Enable, disable, show interrupts" },
    552     {"IPFIX",           cmd_ipfix,              cmd_ipfix_usage,        "IPFIX"},
    553     {"IPG",             if_esw_ipg,             if_esw_ipg_usage,       "Set default IPG values for ports" },
    554 #ifdef INCLUDE_L3
    555 #if defined(BCM_XGS_SWITCH_SUPPORT)
    556     {"IPMC",            if_ipmc,                if_ipmc_usage,          "Manage IPMC (IP Multicast) addresses"},
    557 #endif /* BCM_XGS_SWITCH_SUPPORT */
    558 #endif /* INCLUDE_L3 */
    559 #ifdef INCLUDE_KNET
    560     {"KNETctrl",        cmd_knet_ctrl,          cmd_knet_ctrl_usage,    "Manage kernel network functions"},
    561 #endif
    562     {"L2",              if_esw_l2,              if_esw_l2_usage,         "Manage L2 (MAC) addresses"},
    563 #ifdef BCM_TOMAHAWK3_SUPPORT
    564     {"L2LEARN",          cmd_l2learn,           l2learn_usage,          "Control Learn Thread Execution" },
    565 #endif
    566 #ifdef BCM_XGS_SWITCH_SUPPORT
    567     {"L2MODE",          cmd_l2mode,             l2mode_usage,           "Change ARL handling mode" },
    568 #endif
    569 #ifdef INCLUDE_L3
    570     {"L3",              if_l3,                  if_l3_usage,            "Manage L3 (IP) addresses"},
    571 #endif
    572 #if defined(BCM_TOMAHAWK_SUPPORT)
    573     {"LATency",			if_esw_latency,			if_esw_latency_usage,	"Switch Latency Bypass Diagnostics"},
    574 #endif
    575 #ifdef INCLUDE_I2C
    576     {"LCDMSG",          cmd_lcdmsg,             cmd_lcdmsg_usage,       "Print message on Matrix Orbital LCD display (via I2C)"},
    577 #endif
    578     {"LINKscan",        if_esw_linkscan,        if_esw_linkscan_usage,  "Configure/Display link scanning" },
    579     {"LISTmem",         cmd_esw_mem_list,       cmd_esw_mem_list_usage, "List the entry format for a given table" },
    580     {"Listreg",         cmd_esw_reg_list,       cmd_esw_reg_list_usage,  "List register fields"},
    581 #ifdef BCM_HERCULES_SUPPORT
    582     {"LLAINIT",         mem_llainit,            llainit_usage,          ".Init MMU LLA pointers" },
    583 #endif
    584 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_KATANA_SUPPORT)
    585     {"LLS",             cmd_lls,                cmd_lls_usage,          "MMU LLS hierarchy" },
    586 #endif /* (BCM_TRIUMPH3_SUPPORT | BCM_KATANA_SUPPORT) */
    587     {"LOOKup",          mem_lookup,             lookup_usage,           "Look up a table entry"},
    588     {"MCAST",           if_esw_mcast,           if_esw_mcast_usage,     "Manage multicast table"},
    589     {"MemFirst",        mem_first,              memfirst_usage,          "Displays first valid memory" },
    590     {"MemNext",         mem_next,               memnext_usage,          "Displays next valid memory" },
    591 #ifdef INCLUDE_MEM_SCAN
    592     {"MemSCAN",         mem_scan,               memscan_usage,          "Turn on/off software memory error scanning" },
    593 #endif
    594     {"MemWatch",        mem_watch,              memwatch_usage,          "Turn on/off memory snooping" },
    595 #if defined(INCLUDE_L3) && defined(BCM_TRIUMPH2_SUPPORT)
    596     {"MIM",             if_tr2_mim,             if_tr2_mim_usage,
    597 "Manage XGS4 Mac-in-MAC"},
    598 #endif
    599     {"MIRror",          if_esw_mirror,          if_esw_mirror_usage,     "Manage port mirroring"},
    600 #ifdef BCM_HERCULES_SUPPORT
    601     {"MmuConFiG",       if_mmu_cfg,             if_mmu_cfg_usage,       "Configure MMU mode" },
    602 #endif
    603     {"MmuDeBuG",        mem_mmudebug,           mmudebug_usage,         ".Place SOC MMU in debug mode" },
    604     {"MODify",          cmd_esw_mem_modify,     cmd_esw_mem_modify_usage,"Modify table entry by field names" },
    605 #ifdef BCM_XGS_SUPPORT
    606     {"ModMap",          cmd_modmap,             modmap_cmd_usage,       "MODID Remapping" },
    607 #endif
    608     {"Modreg",          cmd_esw_reg_mod,        cmd_esw_reg_mod_usage,  "Read/modify/write register"},
    609 #if defined(INCLUDE_L3) && defined(BCM_TRIUMPH_SUPPORT)
    610     {"MPLS",            if_tr_mpls,             if_tr_mpls_usage,
    611 "Manage XGS4 MPLS"},
    612 #endif
    613 #ifdef BCM_CMICM_SUPPORT
    614     {"MSPI",            mspi_cmd,               mspi_usage,             "MasterSPI Read / Write"},
    615 #endif
    616     {"MTiMeout",        cmd_mtimeout,           mtimeout_usage,         "Set MIIM operation timeout in usec" },
    617     {"MultiCast",       cmd_multicast,          cmd_multicast_usage,    "Manage multicast operation" },
    618 #ifdef INCLUDE_I2C
    619     {"MUXsel",          cmd_muxsel,             cmd_muxsel_usage,       "Set I2C LPT state (MUX for clock-chip-selects)" },
    620 #endif
    621 #ifdef INCLUDE_I2C
    622     {"NVram",           cmd_nvram,              cmd_nvram_usage,        "Manipulate Nonvolatile memory"},
    623 #endif
    624     {"OAM",             cmd_esw_oam,            cmd_esw_oam_usage,     "Manage OAM groups and endpoints"},
    625     {"PacketWatcher",   pw_command,             pw_usage,               "Monitor ports for packets"},
    626 #if defined(MOUSSE) || defined(BMW) || defined(GTO)
    627     {"PANIC",           cmd_panic,              panic_usage,            "Set system panic mode"},
    628 #endif
    629     {"PBMP",            cmd_esw_pbmp,           cmd_esw_pbmp_usage,     "Convert port bitmap string to hex"},
    630 #ifdef INCLUDE_I2C
    631     {"PCIE",           cmd_pcie,              cmd_pcie_usage,        "R/W PCIE core registers"},
    632 #endif
    633 #ifdef PE_SDK
    634     {"PEAPP",           cmd_peapp,              cmd_peapp_usage,        "Port Extender Lib Commands"},
    635 #endif /* PE_SDK */
    636 #ifdef PE_MODE_CMD
    637     {"PEMODE",          cmd_pemode,             cmd_pemode_usage,       "Port Extender Mode"},
    638 #endif /* PE_MODE_CMD */
    639     {"PHY",             if_esw_phy,             if_esw_phy_usage,       "Set/Display phy characteristics"},
    640 #ifdef INCLUDE_I2C
    641 #ifdef SHADOW_SVK
    642     {"PIO",             cmd_pio,                cmd_pio_usage,          "Set/Display parallel port."},
    643 #endif
    644     {"POE",             cmd_poe,                cmd_poe_usage,          "Configure PowerOverEthernet controllers."},
    645     {"POESel",          cmd_poesel,             cmd_poesel_usage,       "Set I2C POE (MUX for poe-chip-selects)" },
    646 #endif
    647     {"POP",             mem_pop,                pop_usage,              "Pop an entry from a FIFO" },
    648     {"PORT",            if_esw_port,            if_esw_port_usage,      "Set/Display port characteristics"},
    649 #ifdef BCM_KATANA_SUPPORT
    650     {"PortPolicer",     if_esw_port_policer,    if_esw_port_policer_usage, "Display port policer status in table"},
    651 #endif
    652     {"PortRate",        if_esw_port_rate,       if_esw_port_rate_usage, "Set/Display port rate metering characteristics"},
    653     {"PortSampRate",    if_port_samp_rate,      if_port_samp_rate_usage,"Set/Display sflow port sampling rate"},
    654     {"PortStat",        if_esw_port_stat,       if_esw_port_stat_usage, "Display port status in table"},
    655 #ifdef INCLUDE_I2C
    656 #ifdef BCM_ESW_SUPPORT
    657     {"PPDclk",          cmd_ppdclk,             cmd_ppdclk_usage,       "Show PPD clock delay" },
    658 #endif
    659 #endif
    660     {"PROBE",           sh_probe,               sh_probe_usage,         "Probe for available SOC units"},
    661     {"PUSH",            mem_push,               push_usage,             "Push an entry onto a FIFO" },
    662     {"PUTREG",          cmd_esw_reg_set,        cmd_esw_reg_set_usage,  "@setreg" },
    663     {"PVlan",           if_esw_pvlan,           if_esw_pvlan_usage,     "Port VLAN settings" },
    664     {"RATE",            cmd_esw_rate,           cmd_esw_rate_usage,     "Manage packet rate controls"},
    665     {"RateBw",          cmd_bw_rate,            cmd_bw_rate_usage,      "Set/Display port bandwidth rate metering characteristics"},
    666     {"RegCMp",          reg_cmp,                regcmp_usage,           "Test a register value"},
    667 #ifdef INCLUDE_REGEX
    668     {"REgex",        cmd_regex,           cmd_regex_usage,     "Regex command" },
    669 #endif
    670     {"RegWatch",        reg_watch,              regwatch_usage,          "Turn on/off register snooping" },
    671     {"REMove",          mem_remove,             remove_usage,           "Delete entry by index from a sorted table" },
    672     {"ResTest",     cmd_sh_restest,         cmd_sh_restest_usage,   "Tests for resource manager"},
    673     {"RX",              cmd_rx,                 cmd_rx_usage,           ".Receive some number of packets"},
    674     {"RXCfg",           cmd_esw_rx_cfg,         cmd_esw_rx_cfg_usage,   "Configure RX settings"},
    675     {"RXInit",          cmd_esw_rx_init,        cmd_esw_rx_init_usage,  "Call bcm_rx_init"},
    676     {"RXMon",           cmd_esw_rx_mon,         cmd_esw_rx_mon_usage,   "Register an RX handler to dump received packets"},
    677 #if defined(INCLUDE_SIM8051)
    678     {"S51",             sim8051_ent,            sim8051_usage,          "Enter 8051 simulator" },
    679 #endif
    680     {"SCHan",           cmd_schan,              schan_usage,            "Send raw S-Channel message, get response" },
    681     {"SEArch",          mem_search,             search_usage,           "Search a table for a byte pattern" },
    682 #if defined(SER_TR_TEST_SUPPORT)
    683     {"SER",  cmd_esw_ser,   cmd_esw_ser_usage,     "Performs operations related to Soft Error Recovery"},
    684 #endif /*defined(SER_TR_TEST_SUPPORT)*/
    685     {"Setreg",          cmd_esw_reg_set,        cmd_esw_reg_set_usage,  "Set register" },
    686     {"SHOW",            cmd_esw_show,           cmd_esw_show_usage,     "Show information on a subsystem" },
    687 #ifdef PLISIM
    688     {"SHUTDOWN",        cmd_shutd,              NULL,                   "Tell plisim to shutdown" },
    689 #endif
    690     {"SOC",             cmd_esw_soc,            cmd_esw_soc_usage,      "Print internal Driver control information"},
    691     {"SOCRES",          cmd_socres,             socres_usage,           ".SOC reset (SCP channel)" },
    692 #ifdef BCM_TRIUMPH_SUPPORT
    693     {"SRAM",            cmd_sram,               cmd_sram_usage,         "External DDR2_SRAM test control" },
    694 #endif
    695 #ifdef BCM_SRAM_SCAN_SUPPORT
    696     {"SramSCAN",        sram_scan,              sramscan_usage,         "Turn on/off software SRAM error scanning" },
    697 #endif
    698     {"STACKMode",       cmd_stk_mode,           cmd_stk_mode_usage,     "Set/get the stack mode"},
    699     {"StackPortGet",    cmd_stk_port_get,       cmd_stk_port_get_usage,  "Get stacking characteristics of a port"},
    700     {"StackPortSet",    cmd_stk_port_set,       cmd_stk_port_set_usage,  "Set stacking characteristics of a port"},
    701 #ifdef PLISIM
    702     {"StartSim",        cmd_simstart,           NULL,                   "Tell plisim to activate" },
    703 #endif
    704     {"STG",             if_esw_stg,             if_esw_stg_usage,       "Manage spanning tree groups" },
    705     {"STiMeout",        cmd_stimeout,           stimeout_usage,         "Set S-Channel timeout in microseconds" },
    706     {"STKMode",         cmd_stkmode,            cmd_stkmode_usage,       "Hardware Stacking Mode Control"},
    707 #if defined(TKS_SUPPORT)
    708     {"StkTask",         tks_stk_task,           tks_stk_task_usage,      "Stack task control" },
    709 #endif
    710 #ifdef SW_AUTONEG_SUPPORT    
    711     {"SW_AN", if_esw_swAutoneg, if_esw_swAutoneg_usage, "Enable/Disable SW AN Thread"},
    712 #endif    
    713     {"SwitchControl",   cmd_switch_control,     cmd_switch_control_usage, "General switch control"},
    714 #ifdef INCLUDE_I2C
    715 #ifdef BCM_ESW_SUPPORT
    716     {"SYnth",           cmd_synth,              cmd_synth_usage,        "Show synthesizer frequency" },
    717 #endif
    718 #endif
    719 #ifdef INCLUDE_TEST
    720     {"SystemSnake",     cmd_ss,                 cmd_ss_usage,           "Cycle packets through selected system"},
    721 #endif
    722 #ifdef BCM_TRIUMPH_SUPPORT
    723      {"TCAM",           cmd_tcam,               cmd_tcam_usage,           "TCAM control" },
    724 #endif
    725 #if defined(BCM_ESW_SUPPORT)
    726     {"TeCHSupport",     command_techsupport,    command_techsupport_usage,  "Collects information required to "
    727                                                                             "debug a given feature or subfeature" },
    728 #endif
    729 #ifdef INCLUDE_I2C
    730     {"TEMPerature",     cmd_temperature,        cmd_temperature_usage,  "Show environmental conditions"},
    731 #endif
    732 #ifdef INCLUDE_TEST
    733     {"TestClear",       test_clear,             test_clear_usage,       "Clear run statisistics for a test"},
    734     {"TestList",        test_print_list,        test_list_usage,        "List loaded tests and status"},
    735     {"TestMode",        test_mode,              test_mode_usage,        "Set global test run modes"},
    736     {"TestParameters",  test_parameters,        test_parameters_usage,  "Set test Parameters"},
    737     {"TestRun",         test_run,               test_run_usage,         "Run a specific or selected tests"},
    738     {"TestSelect",      test_select,            test_select_usage,      "Select tests for running"},
    739 #endif
    740 #if defined(BCM_TOMAHAWK3_SUPPORT)
    741     {"TMCheck",          cmd_check_tm_settings,  cmd_check_tm_usage,       "TM config check" },
    742     {"TMDumpMem",        cmd_tm_dump_mem,        cmd_tm_dump_mem_usage,        "TM dump memories" },
    743     {"TMShow",           cmd_tm_show_hw_config,  cmd_tm_show_usage,        "TM config show"},
    744 #endif /* BCM_TOMAHAWK3_SUPPORT */
    745 #ifdef INCLUDE_PTP
    746 #ifdef PTP_KEYSTONE_STACK
    747     {"TOPLoad",         cmd_topload,            cmd_topload_usage,      "Load hexfile to ToP memory for PTP"},
    748     {"TOPInfo",         cmd_topinfo,            cmd_topinfo_usage,      "Print information about ToP Firmware"},
    749 #endif
    750 #endif
    751     {"TRUNK",           if_esw_trunk,           if_esw_trunk_usage,     "Manage port aggregation"},
    752 #ifdef BCM_HERCULES15_SUPPORT
    753     {"TrunkPool",       cmd_trunkpool,          trunkpool_cmd_usage,    "Trunk pool table configuration"},
    754 #endif
    755     {"TX",              cmd_esw_tx,             cmd_esw_tx_usage,       "Transmit one or more packets"},
    756     {"TXBeacon",        cmd_esw_txbeacon,       cmd_esw_txbeacon_usage, "txbeacon tests"},
    757     {"TXCount",         cmd_esw_tx_count,       cmd_esw_tx_count_usage, "Print current TX statistics"},
    758 #ifdef PLISIM
    759     {"TXEN",            cmd_txen,               NULL,                   "Enable packet transmission" },
    760 #endif
    761     {"TXSTArt",         cmd_esw_tx_start,       cmd_esw_tx_usage,       "Transmit one or more packets in background"},
    762     {"TXSTOp",          cmd_esw_tx_stop,        cmd_esw_tx_stop_usage,  "Terminate a previous \"txstart\" command"},
    763     {"VLAN",            if_esw_vlan,            if_esw_vlan_usage,      "Manage virtual LANs"},
    764     {"WARMBOOT",        sh_warmboot,            sh_warmboot_usage,      "Optionally boot warm"},
    765 #if defined(INCLUDE_L3) && defined(BCM_TRIUMPH2_SUPPORT)
    766     {"WLAN",            if_tr2_wlan,            if_tr2_wlan_usage,
    767 "Manage XGS4 WLAN"},
    768 #endif
    769     {"Write",           cmd_esw_mem_write,      cmd_esw_mem_write_usage, "Write entry(s) into a table" },
    770 #ifdef BCM_XGS3_SWITCH_SUPPORT
    771     {"XAUI",            cmd_xaui,                cmd_xaui_usage,         "Run XAUI BERT on specified port pair" },
    772 #endif
    773 #ifdef INCLUDE_I2C
    774     {"XClocks",         cmd_xclk,               cmd_xclk_usage,         "Configure clocks for PCI, SDRAM, Core clock"},
    775 #endif
    776 #ifdef INCLUDE_I2C
    777     {"XPoe",            cmd_xpoe,               cmd_xpoe_usage,         "Communication with PD63000 PowerOverEthernet MCU."},
    778 #endif
    779 #ifdef BCM_HERCULES_SUPPORT
    780     {"XQDump",          if_xqdump,              if_xqdump_usage,        "Display packets pending in the XQ" },
    781     {"XQErr",           if_xqerr,               if_xqerr_usage,         "Inject bit errors into packets pending in XQ" },
    782 #endif
    783 #ifdef BCM_EASY_RELOAD_SUPPORT
    784     {"XXReload",        cmd_xxreload,           cmd_xxreload_usage,     "\"Easy\" Reload control" },
    785 #endif
    786 };
    787 
    788 int bcm_esw_cmd_cnt = COUNTOF(bcm_esw_cmd_list);
    789 #endif
    790 
    791 void
    792 cmdlist_init(void)
    793 {
    794     int         i;
    795     int         unit;
    796 
    797 #if defined(BCM_ESW_SUPPORT)
    798     for (i = 1; i < bcm_esw_cmd_cnt; i++) {
    799         if (sal_strcasecmp(bcm_esw_cmd_list[i].c_cmd,
    800         bcm_esw_cmd_list[i - 1].c_cmd) <= 0) {
    801             cli_out("WARNING: bcm esw command %s not alphabetized\n",
    802                     bcm_esw_cmd_list[i].c_cmd);
    803         }
    804     }
    805 #endif
    806 
    807     for (i = 1; i < bcm_cmd_common_cnt; i++) {
    808         if (sal_strcasecmp(bcm_cmd_common[i].c_cmd,
    809                        bcm_cmd_common[i - 1].c_cmd) <= 0) {
    810             cli_out("WARNING: bcm common command %s not alphabetized\n",
    811                     bcm_cmd_common[i].c_cmd);
    812         }
    813     }
    814 
    815 
    816 
    817 #if defined(INCLUDE_BCMX_DIAG)
    818     for (i = 1; i < bcmx_cmd_cnt; i++) {
    819         if (sal_strcasecmp(bcmx_cmd_list[i].c_cmd,
    820                bcmx_cmd_list[i - 1].c_cmd) <= 0) {
    821             cli_out("WARNING: bcmx command %s not alphabetized\n",
    822                     bcmx_cmd_list[i].c_cmd);
    823         }
    824     }
    825 #endif
    826 
    827 #if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)
    828     for (i = 1; i < bcm_dpp_cmd_cnt; i++) {
    829         if (sal_strcasecmp(bcm_dpp_cmd_list[i].c_cmd,
    830         bcm_dpp_cmd_list[i - 1].c_cmd) <= 0) {
    831             cli_out("WARNING: bcm dpp command %s not alphabetized\n",
    832                     bcm_dpp_cmd_list[i].c_cmd);
    833         }
    834     }
    835 #endif
    836 
    837 #if defined(BCM_DNX_SUPPORT)
    838     for (i = 1; i < bcm_dnx_cmd_cnt; i++) {
    839         if (sal_strcasecmp(bcm_dnx_cmd_list[i].c_cmd,
    840         bcm_dnx_cmd_list[i - 1].c_cmd) <= 0) {
    841             cli_out("WARNING: bcm dnx command %s not alphabetized\n",
    842                     bcm_dnx_cmd_list[i].c_cmd);
    843         }
    844     }
    845 #endif
    846 
    847 #if defined(BCM_DNXF_SUPPORT)
    848     for (i = 1; i < bcm_dnxf_cmd_cnt; i++) {
    849         if (sal_strcasecmp(bcm_dnxf_cmd_list[i].c_cmd,
    850         bcm_dnxf_cmd_list[i - 1].c_cmd) <= 0) {
    851             cli_out("WARNING: bcm dnxf command %s not alphabetized\n",
    852                     bcm_dnxf_cmd_list[i].c_cmd);
    853         }
    854     }
    855 #endif
    856     for(i = 0; i < SOC_MAX_NUM_DEVICES; i++) {
    857         cur_cmd_list[i] = NULL;
    858         cur_cmd_cnt[i] = 0;
    859         cur_mode[i] = ILLEGAL_CMD_MODE;
    860         dyn_cmd_list[i] = NULL;
    861         dyn_cmd_cnt[i] = 0;
    862     }
    863 
    864     for (i = 0; i < soc_ndev; i++) {
    865         unit = SOC_NDEV_IDX2DEV(i);
    866         if(!soc_attached(unit)) {
    867             command_mode_set(unit, ESW_CMD_MODE);
    868         }
    869 #if defined(BCM_DNX_SUPPORT)
    870         else if(SOC_IS_DNX(unit) ) {
    871             command_mode_set(unit, DNX_CMD_MODE);
    872             /** initialize DNX specific dynamic shell commands */
    873             if(diag_sand_error_get(cmd_dnx_sh_init(unit)) != CMD_OK)
    874             {
    875                 cli_out("Error: Problem while initiating DNX Dynamic commands\n");
    876             }
    877         }
    878 #endif /* BCM_DNX_SUPPORT */
    879 
    880 #if defined(BCM_DNXF_SUPPORT)
    881         if(SOC_IS_DNXF(unit) ) {
    882             command_mode_set(unit, DNXF_CMD_MODE);
    883             /** initialize DNXF specific dynamic shell commands */
    884             if(diag_sand_error_get(cmd_dnxf_sh_init(unit)) != CMD_OK)
    885             {
    886                 cli_out("Error: Problem while initiating DNX Dynamic commands\n");
    887             }
    888         }
    889 #endif /* BCM_DNXF_SUPPORT */
    890 
    891 #if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)
    892         if(SOC_IS_DPP(unit) || SOC_IS_DFE(unit)) {
    893             command_mode_set(unit, DPP_CMD_MODE);
    894         }
    895 #endif /* BCM_PETRA_SUPPORT || BCM_DFE_SUPPORT */
    896 
    897 #if defined(BCM_ESW_SUPPORT)
    898         if(SOC_IS_ESW(unit)) {
    899             command_mode_set(unit, ESW_CMD_MODE);
    900         }
    901 #endif /* BCM_ESW_SUPPORT */
    902     }
    903 
    904 #if defined(BCM_ESW_SUPPORT)
    905     _bcm_trunk_ref = NULL;
    906 #endif
    907 }
    908 
    909 /*
    910  * Add a dynamic command to the shell
    911  */
    912 int
    913 cmdlist_add(int unit, cmd_t* cmd)
    914 {
    915 
    916     if((unit < 0) || (unit >= SOC_MAX_NUM_DEVICES)) {
    917         return CMD_FAIL;
    918     }
    919     /*
    920      * Allow the dynamic command list to be cleared by passing NULL
    921      */
    922     if(cmd == NULL) {
    923         dyn_cmd_cnt[unit] = 0;
    924         return CMD_OK;
    925     }
    926 
    927     /*
    928      * Allow the dynamic command memory to be allocated when needed.
    929      * Also allows it to be called prior to diag_shell invocation if necessary.
    930      */
    931 
    932     if(dyn_cmd_list[unit] == NULL) {
    933         dyn_cmd_list[unit] = sal_alloc(sizeof(cmd_t)*BCM_SHELL_MAX_DYNAMIC_CMDS, "DYN CMD LIST");
    934         if(dyn_cmd_list[unit] == NULL) {
    935             return CMD_FAIL;
    936         }
    937         else {
    938             dyn_cmd_cnt[unit] = 0;
    939         }
    940     }
    941 
    942     /*
    943      * Attempt to add the command
    944      */
    945     if(dyn_cmd_cnt[unit] >= BCM_SHELL_MAX_DYNAMIC_CMDS) {
    946         /* Full */
    947         return CMD_FAIL;
    948     }
    949     else {
    950         dyn_cmd_list[unit][dyn_cmd_cnt[unit]] = *cmd;
    951         dyn_cmd_cnt[unit]++;
    952         return CMD_OK;
    953     }
    954 }
    955 
    956 int
    957 cmdlist_remove(int unit, cmd_t* cmd)
    958 {
    959     cmd_t* p;
    960     int i;
    961 
    962     if((unit < 0) || (unit >= SOC_MAX_NUM_DEVICES)) {
    963         return CMD_FAIL;
    964     }
    965     /*
    966      * Find this command in the array
    967      */
    968     for(i = 0, p = dyn_cmd_list[unit]; i < dyn_cmd_cnt[unit]; i++, p++) {
    969         if((p->c_f == cmd->c_f) && !sal_strcasecmp(p->c_cmd, cmd->c_cmd)) {
    970 
    971             /*
    972              * This command should be removed.
    973              */
    974             if(i == dyn_cmd_cnt[unit] - 1) {
    975                 /* This command is the last entry */
    976                 dyn_cmd_cnt[unit]--;
    977             }
    978             else {
    979                 /* Swap the last command into this slot */
    980                 dyn_cmd_list[unit][i] = dyn_cmd_list[unit][dyn_cmd_cnt[unit]-1];
    981                 dyn_cmd_cnt[unit]--;
    982             }
    983             if(dyn_cmd_cnt[unit] == 0)
    984             {
    985                 sal_free(dyn_cmd_list[unit]);
    986                 dyn_cmd_list[unit] = NULL;
    987             }
    988             return CMD_OK;
    989         }
    990     }
    991 
    992     /* Not found in the list */
    993     return CMD_NFND;
    994 }
    995 
    996 
    997 void
    998 command_mode_set(int unit, int mode)
    999 {
   1000     if((unit < 0) || (unit >= SOC_MAX_NUM_DEVICES)) {
   1001         cli_out("WARNING: unit:%d in command_mode_set is out of range\n", unit);
   1002         return;
   1003     }
   1004 
   1005     if (mode == cur_mode[unit]) {
   1006         return;
   1007     }
   1008 
   1009     switch (mode) {
   1010 #if defined(INCLUDE_BCMX_DIAG)
   1011     case BCMX_CMD_MODE:
   1012         cur_cmd_list[unit] = bcmx_cmd_list;
   1013         cur_cmd_cnt[unit] = bcmx_cmd_cnt;
   1014         break;
   1015 #endif
   1016 
   1017 #if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)
   1018     case DPP_CMD_MODE:
   1019         cur_cmd_list[unit] = bcm_dpp_cmd_list;
   1020         cur_cmd_cnt[unit] = bcm_dpp_cmd_cnt;
   1021         break;
   1022 #endif
   1023 
   1024 #if defined(BCM_DNX_SUPPORT)
   1025     case DNX_CMD_MODE:
   1026         cur_cmd_list[unit] = bcm_dnx_cmd_list;
   1027         cur_cmd_cnt[unit] = bcm_dnx_cmd_cnt;
   1028         break;
   1029 #endif
   1030 
   1031 #if defined(BCM_DNXF_SUPPORT)
   1032     case DNXF_CMD_MODE:
   1033         cur_cmd_list[unit] = bcm_dnxf_cmd_list;
   1034         cur_cmd_cnt[unit] = bcm_dnxf_cmd_cnt;
   1035         break;
   1036 #endif
   1037 
   1038 #if defined(BCM_ESW_SUPPORT)
   1039     case ESW_CMD_MODE:
   1040     default:   /* BCM is default command mode */
   1041         cur_cmd_list[unit] = bcm_esw_cmd_list;
   1042         cur_cmd_cnt[unit] = bcm_esw_cmd_cnt;
   1043         break;
   1044 #endif
   1045     }
   1046     cur_mode[unit] = mode;
   1047 }
   1048 
   1049 int
   1050 command_mode_get(int unit)
   1051 {
   1052     if((unit < 0) || (unit >= SOC_MAX_NUM_DEVICES)) {
   1053         cli_out("WARNING: unit:%d in command_mode_get is out of range\n", unit);
   1054         return ILLEGAL_CMD_MODE;
   1055     }
   1056 
   1057     return cur_mode[unit];
   1058 }
   1059 
   1060 /*
   1061  * Function:
   1062  *     subcommand_execute
   1063  * Purpose:
   1064  *     Parse subcommand and execute function defined in given command list
   1065  *     table.
   1066  *
   1067  *     This function provides an alternate way of parsing subcommands using
   1068  *     currently defined parse functions and typedefs.  It is not limited
   1069  *     to parsing subcommands of a command, it can be called from a subcommand
   1070  *     as long as the correct table is given.
   1071  *
   1072  * Params:
   1073  *     unit     - Unit number (passed-in to the initial command function)
   1074  *     args     - Pointer to the argument structure
   1075  *                Current argument MUST point to the subcommand to be parsed
   1076  *     cmd_list - Table of subcommands for a given command
   1077  *     cmd_cnt  - Number of subcommands in table
   1078  */
   1079 cmd_result_t
   1080 subcommand_execute(int unit, args_t *args, cmd_t *cmd_list, int cmd_cnt)
   1081 {
   1082     char            *initial_cmd = ARG_CMD(args);
   1083     char            *key;
   1084     cmd_t           *cmd;
   1085     char            *param;
   1086     cmd_result_t    rv = CMD_OK;
   1087 
   1088     if ((key = ARG_GET(args)) == NULL) {
   1089         sal_printf("%s:  Subcommand required\n", initial_cmd);
   1090         return CMD_USAGE;
   1091     }
   1092 
   1093     cmd = (cmd_t *) parse_lookup(key, cmd_list, sizeof(cmd_t), cmd_cnt);
   1094 
   1095     if (cmd == NULL)
   1096     {
   1097         sal_printf("%s: Unknown subcommand %s\n", initial_cmd, key);
   1098         return CMD_USAGE;
   1099     }
   1100 
   1101     /* If next param is "?", just display help for command */
   1102     param = ARG_CUR(args);
   1103     if (param != NULL) {
   1104         if (sal_strcmp(param, "?") == 0)
   1105         {
   1106             ARG_GET(args);    /* Consume "?" */
   1107             if ((cmd->c_usage != NULL) &&
   1108                 (soc_property_get(unit, spn_HELP_CLI_ENABLE, 1))) {
   1109                 sal_printf("Usage:  %s\n", cmd->c_usage);
   1110             }
   1111             if ((cmd->c_help != NULL) &&
   1112                 soc_property_get(unit, spn_HELP_CLI_ENABLE, 1)) {
   1113                 sal_printf("Help :  %s\n", cmd->c_help);
   1114             }
   1115             return rv;
   1116         }
   1117     }
   1118 
   1119     rv = cmd->c_f(unit, args);
   1120 
   1121     return rv;
   1122 }