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

fabric.c (2516B)


      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  * Fabric and Higig related CLI commands
      8  */
      9 
     10 #include <appl/diag/system.h>
     11 #include <appl/diag/parse.h>
     12 #include <appl/diag/dport.h>
     13 #include <shared/bsl.h>
     14 #include <bcm/error.h>
     15 #include <bcm/stack.h>
     16 #include <bcm/debug.h>
     17 
     18 #ifdef BCM_XGS_SUPPORT
     19 #include <soc/higig.h>
     20 #endif
     21 
     22 #ifdef	BCM_XGS_SUPPORT
     23 #define PACK_LONG(buf, val) \
     24     do {                                               \
     25         uint32 v2;                                     \
     26         v2 = bcm_htonl(val);                           \
     27         sal_memcpy(buf, &v2, sizeof(uint32));          \
     28     } while (0)
     29 
     30 char if_h2higig_usage[] =
     31     "H2Higig [<word0> <word1> <word2>]:  Convert hex to higig info\n";
     32 
     33 cmd_result_t
     34 if_h2higig(int unit, args_t *args)
     35 {
     36     uint32 val;
     37     char *arg;
     38     soc_higig_hdr_t hghdr;
     39     int i;
     40 
     41     sal_memset(&hghdr, 0, sizeof(soc_higig_hdr_t));
     42     for (i = 0; i < 3; i++) {
     43         if ((arg = ARG_GET(args)) == NULL) {
     44             break;
     45         }
     46 
     47         val = sal_strtoul(arg, NULL, 0);
     48         PACK_LONG(&hghdr.overlay0.bytes[i * 4], val);
     49     }
     50 
     51     soc_higig_dump(unit, "", &hghdr);
     52 
     53     return CMD_OK;
     54 }
     55 
     56 #ifdef BCM_HIGIG2_SUPPORT
     57 
     58 char if_h2higig2_usage[] =
     59     "H2Higig2 [<word0> <word1> <word2> <word3> [<word4>]]:  Convert hex to higig2 info\n";
     60 
     61 cmd_result_t
     62 if_h2higig2(int unit, args_t *args)
     63 {
     64     uint32 val;
     65     char *arg;
     66     soc_higig2_hdr_t hghdr;
     67     int i;
     68 
     69     sal_memset(&hghdr, 0, sizeof(soc_higig2_hdr_t));
     70     for (i = 0; i < 4; i++) {
     71         if ((arg = ARG_GET(args)) == NULL) {
     72             break;
     73         }
     74 
     75         val = sal_strtoul(arg, NULL, 0);
     76         PACK_LONG(&hghdr.overlay0.bytes[i * 4], val);
     77     }
     78 
     79     soc_higig2_dump(unit, "", &hghdr);
     80 
     81     /* Decode extension header if present */
     82     if ((arg = ARG_GET(args)) != NULL) {
     83         int eh_type;
     84         val = sal_strtoul(arg, NULL, 0);
     85         eh_type = val >> 28;
     86         cli_out("0x%08x <EHT=%d", val, eh_type);
     87         if (eh_type == 0) {
     88             cli_out(" TM=%d", (val >> 24) & 0x1);
     89             cli_out(" SEG_SEL=%d", (val >> 21) & 0x7);
     90             cli_out(" TAG_TYPE=%d", (val >> 19) & 0x3);
     91             cli_out(" QTAG=0x%04x", val & 0xffff);
     92         }
     93         cli_out(">\n");
     94     }
     95 
     96     return CMD_OK;
     97 }
     98 #endif /* BCM_HIGIG2_SUPPORT */
     99 
    100 #endif	/* BCM_XGS_SUPPORT */
    101 
    102 int _bcm_diag_fabric_not_empty;