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

tm_checks.c (9767B)


      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:        traffic_manager.c
      8  * Purpose:     Tomahawk3 IDB, EDB and MMU routines
      9  * Requires:
     10  */
     11 
     12 #include <shared/bsl.h>
     13 
     14 #include <soc/drv.h>
     15 #include <soc/mem.h>
     16 #include <soc/debug.h>
     17 #include <soc/hash.h>
     18 
     19 #if defined(BCM_TOMAHAWK3_SUPPORT)
     20 
     21 #include <soc/tomahawk3.h>
     22 #include <appl/diag/system.h>
     23 #include <appl/diag/parse.h>
     24 #include <shared/bsl.h>
     25 
     26 void
     27 soc_th3_check_soc_info_dev_port_idb_port_map (int unit)
     28 {
     29     int dev_port, pipe, local_dev_port;
     30     int idb_port, exp_idb_port;
     31     soc_info_t *si = &SOC_INFO(unit);
     32 
     33     PBMP_PORT_ITER(unit, dev_port) {
     34         if(!IS_MANAGEMENT_PORT(unit, dev_port)) {
     35             idb_port = si->port_l2i_mapping[dev_port];
     36             pipe = si->port_pipe[dev_port];
     37             local_dev_port = dev_port % SOC_TH3_MAX_DEV_PORTS_PER_PIPE;
     38             if (pipe == 0) {
     39                 exp_idb_port = local_dev_port - 1;
     40             } else {
     41                 exp_idb_port = local_dev_port;
     42             }
     43             if (exp_idb_port != idb_port) {
     44                 LOG_CLI((BSL_META_U(unit,
     45                     "ERROR: device port to idb port mapping in SOC infor wrong"
     46                     "for port:%d, exp value:%d actual value:%u\n"),
     47                     dev_port, exp_idb_port, idb_port ));
     48             }
     49         }
     50     }
     51 }
     52 
     53 void
     54 soc_th3_check_idb_portmap(int unit)
     55 {
     56     int dev_port, local_dev_port;
     57     int phy_port;
     58     int idb_port, pipe;
     59     soc_info_t *si = &SOC_INFO(unit);
     60     soc_mem_t mem_list[] = {ING_IDB_TO_DEVICE_PORT_MAPm,
     61                             ING_PHY_TO_IDB_PORT_MAPm};
     62     soc_mem_t mem;
     63     int mem_index, num_mems, index;
     64     soc_field_t field = INVALIDf;
     65     uint32 value = 0, exp_value;
     66     uint32 read_entry[SOC_MAX_MEM_WORDS];
     67     char *mem_name;
     68     int pm, subport, idb_phy_index;
     69 
     70     PBMP_PORT_ITER(unit, dev_port) {
     71         if(!IS_MANAGEMENT_PORT(unit, dev_port)) {
     72             idb_port = si->port_l2i_mapping[dev_port];
     73             phy_port = si->port_l2p_mapping[dev_port];
     74             local_dev_port = dev_port % SOC_TH3_MAX_DEV_PORTS_PER_PIPE;
     75             pipe = si->port_pipe[dev_port];
     76             pm = ((phy_port - 1) & 0x1f) / _TH3_PORTS_PER_PBLK;
     77             subport = ((phy_port - 1) & 0x1f) % _TH3_PORTS_PER_PBLK;
     78             idb_phy_index = pm * _TH3_PORTS_PER_PBLK + subport;
     79 
     80             num_mems = sizeof(mem_list) / sizeof(soc_mem_t);
     81             for (mem_index = 0;mem_index < num_mems; mem_index++) {
     82                 mem = mem_list[mem_index];
     83                 switch(mem) {
     84                     case ING_IDB_TO_DEVICE_PORT_MAPm:
     85                         field = DEVICE_PORTf;
     86                         index = idb_port;
     87                         exp_value = local_dev_port;
     88                         mem_name = "ING_IDB_TO_DEVICE_PORT_MAP";
     89                         break;
     90                     case ING_PHY_TO_IDB_PORT_MAPm:
     91                         field = IDB_PORTf;
     92                         index = idb_phy_index;
     93                         exp_value = idb_port;
     94                         mem_name = "ING_PHY_TO_IDB_PORT_MAP";
     95                         break;
     96                     default:
     97                         field = INVALIDf;
     98                         index = -1;
     99                         exp_value = -1;
    100                         mem_name = "INVALID";
    101                         break;
    102                 }
    103                 mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, mem_list[mem_index], pipe);
    104                 /* coverity[checked_return:FALSE]*/
    105                 soc_mem_read(unit, mem, MEM_BLOCK_ANY, index, read_entry);
    106                 /* coverity[checked_return:FALSE]*/
    107                 value = soc_mem_field32_get(unit, mem, read_entry, field);
    108                 if(exp_value != value) {
    109                     LOG_CLI((BSL_META_U(unit,
    110                         "ERROR: memory:%s port:%d exp value:%d actual value:%u\n"),
    111                                mem_name, dev_port, exp_value, value));
    112                     soc_th3_check_soc_info_dev_port_idb_port_map(unit);
    113                 }
    114             }
    115         }
    116     }
    117 }
    118 
    119 void
    120 soc_th3_check_mmu_portmap(int unit)
    121 {
    122     int dev_port;
    123     int phy_port, local_phy_port;
    124     int chip_port_num, pipe;
    125     int mmu_port;
    126     soc_info_t *si = &SOC_INFO(unit);
    127     soc_mem_t mem_list[] = {MMU_THDO_DEVICE_PORT_MAPm,
    128                             MMU_RQE_DEVICE_TO_MMU_PORT_MAPPINGm};
    129     soc_reg_t reg_list[]={MMU_CRB_DEVICE_PORT_TO_MMU_PORT_MAPPINGr,
    130                           MMU_INTFO_MMU_PORT_TO_PHY_PORT_MAPPINGr,
    131                           MMU_EBPTS_MMU_PORT_TO_PHY_PORT_MAPPINGr,
    132                           MMU_INTFI_MMU_PORT_TO_PHY_PORT_MAPPINGr,
    133                           MMU_EBCFP_MMU_PORT_TO_DEVICE_PORT_MAPPINGr};
    134     soc_mem_t mem;
    135     soc_reg_t reg;
    136     int mem_index, num_mems, index;
    137     int reg_index, num_regs;
    138     soc_field_t field=INVALIDf;
    139     uint32 value = 0, exp_value;
    140     uint32 read_entry[SOC_MAX_MEM_WORDS];
    141     char *mem_name;
    142     uint32 rval=0;
    143 
    144     PBMP_PORT_ITER(unit, dev_port) {
    145         if(!IS_MANAGEMENT_PORT(unit, dev_port)) {
    146             phy_port = si->port_l2p_mapping[dev_port];
    147             mmu_port = si->port_p2m_mapping[phy_port];
    148             chip_port_num = SOC_TH3_MMU_CHIP_PORT(unit, dev_port);
    149             pipe = si->port_pipe[dev_port];
    150             if (pipe) {
    151                 local_phy_port = (phy_port - 1) % SOC_TH3_MMU_PORT_STRIDE;
    152             } else {
    153                 local_phy_port = (phy_port) % SOC_TH3_MMU_PORT_STRIDE;
    154             }
    155 
    156             num_mems = sizeof(mem_list) / sizeof(soc_mem_t);
    157             for (mem_index = 0;mem_index < num_mems; mem_index++) {
    158                 mem = mem_list[mem_index];
    159                 switch(mem) {
    160                     case MMU_THDO_DEVICE_PORT_MAPm:
    161                         field = DEVICE_PORTf;
    162                         index = chip_port_num;
    163                         exp_value = dev_port;
    164                         mem_name = "MMU_THDO_DEVICE_PORT_MAP";
    165                         break;
    166                     case MMU_RQE_DEVICE_TO_MMU_PORT_MAPPINGm:
    167                         field = MMU_PORTf;
    168                         index = dev_port;
    169                         exp_value = mmu_port;
    170                         mem_name = "MMU_RQE_DEVICE_TO_MMU_PORT_MAPPING";
    171                         break;
    172                     default:
    173                         field = INVALIDf;
    174                         index = -1;
    175                         exp_value = -1;
    176                         mem_name = "INVALID";
    177                         break;
    178                 }
    179                 /* coverity[checked_return:FALSE]*/
    180                 soc_mem_read(unit, mem, MEM_BLOCK_ANY, index, read_entry);
    181                 /* coverity[checked_return:FALSE]*/
    182                 value = soc_mem_field32_get(unit, mem, read_entry, field);
    183                 if(exp_value != value) {
    184                     LOG_CLI((BSL_META_U(unit,
    185                         "ERROR: memory:%s port:%d exp value:%d actual value:%u\n"),
    186                                mem_name, dev_port, exp_value, value));
    187                     soc_th3_check_soc_info_dev_port_idb_port_map(unit);
    188                 }
    189             }
    190 
    191             num_regs = sizeof(reg_list) / sizeof(soc_reg_t);
    192             for (reg_index = 0;reg_index < num_regs; reg_index++) {
    193                 reg = reg_list[reg_index];
    194                 switch(reg) {
    195                     case MMU_CRB_DEVICE_PORT_TO_MMU_PORT_MAPPINGr:
    196                         field = MMU_PORTf;
    197                         index = dev_port;
    198                         exp_value = mmu_port;
    199                         mem_name = "MMU_CRB_DEVICE_PORT_TO_MMU_PORT_MAPPING";
    200                         break;
    201                     case MMU_INTFO_MMU_PORT_TO_PHY_PORT_MAPPINGr:
    202                         field = PHY_PORT_NUMf;
    203                         index = dev_port;
    204                         exp_value = phy_port;
    205                         mem_name = "MMU_INTFO_MMU_PORT_TO_PHY_PORT_MAPPING";
    206                         break;
    207                     case MMU_INTFI_MMU_PORT_TO_PHY_PORT_MAPPINGr:
    208                         field = PHY_PORT_NUMf;
    209                         index = dev_port;
    210                         exp_value = local_phy_port;
    211                         mem_name = "MMU_INTFI_MMU_PORT_TO_PHY_PORT_MAPPING";
    212                         break;
    213                     case MMU_EBPTS_MMU_PORT_TO_PHY_PORT_MAPPINGr:
    214                         field = PHY_PORT_NUMf;
    215                         index = dev_port;
    216                         exp_value = local_phy_port;
    217                         mem_name = "MMU_EBPTS_MMU_PORT_TO_PHY_PORT_MAPPING";
    218                         break;
    219                     case MMU_EBCFP_MMU_PORT_TO_DEVICE_PORT_MAPPINGr:
    220                         field = DEVICE_PORTf;
    221                         index = dev_port;
    222                         exp_value = dev_port;
    223                         mem_name = "MMU_EBCFP_MMU_PORT_TO_DEVICE_PORT_MAPPING";
    224                         break;
    225                     default:
    226                         field = INVALIDf;
    227                         index = -1;
    228                         exp_value = -1;
    229                         mem_name = "INVALID";
    230                         break;
    231                 }
    232                 soc_reg32_get(unit, reg, index, 0, &rval);
    233                 value = soc_reg_field_get(unit, reg, rval, field);
    234                 if(exp_value != value) {
    235                     LOG_CLI((BSL_META_U(unit,
    236                         "ERROR: register:%s port:%d exp value:%d actual value:%u\n"),
    237                                mem_name, dev_port, exp_value, value));
    238                     soc_th3_check_soc_info_dev_port_idb_port_map(unit);
    239                 }
    240             }
    241         }
    242     }
    243 }
    244 
    245 #endif /* BCM_TOMAHAWK3_SUPPORT */