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

pscan.c (2766B)


      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  * File: 	mcs.c
      8  * Purpose: 	Micro Controller Subsystem Support
      9  */
     10 
     11 #include <assert.h>
     12 #include <sal/core/libc.h>
     13 #include <bcm/error.h>
     14 #include <soc/pscan.h>
     15 #include <soc/types.h>
     16 #include <soc/dma.h>
     17 #include <appl/diag/shell.h>
     18 #include <appl/diag/system.h>
     19 
     20 #if defined(BCM_CMICM_SUPPORT)
     21 
     22 #include <soc/uc_msg.h>
     23 
     24 char pscan_usage[] =
     25     "Parameters: \n\t"
     26     "Control the pscan on the Uc.\n\t"
     27     "init\n\t"
     28     "delay <usec>\n\t"
     29     "enable <port>\n\t"
     30     "disable <port>\n\t"
     31     "config <port> <flags>\n"
     32     "update\n\t"
     33     ;
     34 
     35 cmd_result_t
     36 pscan_cmd(int unit, args_t *a)
     37 /*
     38  * Function: 	pscan_cmd
     39  * Purpose:	Control uKernel pscan interface
     40  * Parameters:	unit - unit
     41  *		a - args
     42  * Returns:	CMD_OK/CMD_FAIL/CMD_USAGE
     43  */
     44 {
     45     cmd_result_t rv = CMD_OK;
     46     char *c;
     47     int count, delay, port, flags;
     48 
     49 #ifndef NO_CTRL_C
     50     jmp_buf ctrl_c;
     51 #endif    
     52 
     53     if (!sh_check_attached("pscan", unit)) {
     54         return(CMD_FAIL);
     55     }
     56 
     57     if (!soc_feature(unit, soc_feature_uc)) {
     58         return (CMD_FAIL);
     59     } 
     60 
     61     if (ARG_CNT(a) < 1) {
     62         return(CMD_USAGE);
     63     }
     64 
     65     /* check for simulation*/
     66     if (SAL_BOOT_BCMSIM) {
     67         return(rv);
     68     }
     69 
     70 #ifndef NO_CTRL_C    
     71     if (!setjmp(ctrl_c)) {
     72         sh_push_ctrl_c(&ctrl_c);
     73 #endif
     74         c = ARG_GET(a);
     75         count = ARG_CNT(a);
     76         if ((count == 0) && !sal_strcmp(c, "init")) {
     77             rv = soc_pscan_init(unit);
     78         }
     79         else if ((count == 2) && !sal_strcmp(c, "config")) {
     80             c = ARG_GET(a);
     81             port = parse_integer(c);
     82             c = ARG_GET(a);
     83             flags = parse_integer(c);
     84             rv = soc_pscan_port_config(unit, port, flags);
     85         }
     86         else if ((count == 1) && !sal_strcmp(c, "delay")) {
     87             c = ARG_GET(a);
     88             delay = parse_integer(c);
     89             rv = soc_pscan_delay(unit, delay);
     90         }
     91         else if ((count == 1) && !sal_strcmp(c, "disable")) {
     92             c = ARG_GET(a);
     93             port = parse_integer(c);
     94             rv = soc_pscan_port_enable(unit, port, 0);
     95         }
     96         else if ((count == 1) && !sal_strcmp(c, "enable")) {
     97             c = ARG_GET(a);
     98             port = parse_integer(c);
     99             rv = soc_pscan_port_enable(unit, port, 1);
    100         }
    101         else if ((count == 0) && !sal_strcmp(c, "update")) {
    102             rv = soc_pscan_update(unit);
    103         }
    104         else {
    105             rv = CMD_USAGE;
    106         }
    107 #ifndef NO_CTRL_C    
    108     } else {
    109         rv = CMD_INTR;
    110     }
    111 
    112     sh_pop_ctrl_c();
    113 #endif    
    114 
    115     return(rv);
    116 }
    117 
    118 #endif /* CMICM support */
    119