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

counter.c (89040B)


      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  */
      8 
      9 #include <shared/bsl.h>
     10 #include <sal/core/libc.h>
     11 #include <soc/debug.h>
     12 #include <soc/util.h>
     13 #include <soc/mem.h>
     14 
     15 #include <soc/tomahawk.h>
     16 #include <soc/tomahawk3.h>
     17 
     18 
     19 #ifdef BCM_TOMAHAWK3_SUPPORT
     20 
     21 /* TH3 MMU queue number are different for each pipe */
     22 int th3_num_queues_pipe[] = {276, 240, 228, 228, 228, 240, 240, 240};
     23 
     24 static soc_reg_t th3_obm_drop_pkt_regs[][4] = {
     25     {IDB_OBM0_LOSSY_LO_PKT_DROP_COUNTr, IDB_OBM0_LOSSY_HI_PKT_DROP_COUNTr,
     26      IDB_OBM0_LOSSLESS0_PKT_DROP_COUNTr, IDB_OBM0_LOSSLESS1_PKT_DROP_COUNTr
     27     },
     28     {IDB_OBM1_LOSSY_LO_PKT_DROP_COUNTr, IDB_OBM1_LOSSY_HI_PKT_DROP_COUNTr,
     29      IDB_OBM1_LOSSLESS0_PKT_DROP_COUNTr, IDB_OBM1_LOSSLESS1_PKT_DROP_COUNTr
     30     },
     31     {IDB_OBM2_LOSSY_LO_PKT_DROP_COUNTr, IDB_OBM2_LOSSY_HI_PKT_DROP_COUNTr,
     32      IDB_OBM2_LOSSLESS0_PKT_DROP_COUNTr, IDB_OBM2_LOSSLESS1_PKT_DROP_COUNTr
     33     },
     34     {IDB_OBM3_LOSSY_LO_PKT_DROP_COUNTr, IDB_OBM3_LOSSY_HI_PKT_DROP_COUNTr,
     35      IDB_OBM3_LOSSLESS0_PKT_DROP_COUNTr, IDB_OBM3_LOSSLESS1_PKT_DROP_COUNTr
     36     },
     37     {IDB_OBM4_LOSSY_LO_PKT_DROP_COUNTr, IDB_OBM4_LOSSY_HI_PKT_DROP_COUNTr,
     38      IDB_OBM4_LOSSLESS0_PKT_DROP_COUNTr, IDB_OBM4_LOSSLESS1_PKT_DROP_COUNTr
     39     }
     40 };
     41 
     42 static soc_reg_t th3_obm_drop_byte_regs[][4] = {
     43     {IDB_OBM0_LOSSY_LO_BYTE_DROP_COUNTr, IDB_OBM0_LOSSY_HI_BYTE_DROP_COUNTr,
     44      IDB_OBM0_LOSSLESS0_BYTE_DROP_COUNTr, IDB_OBM0_LOSSLESS1_BYTE_DROP_COUNTr
     45     },
     46     {IDB_OBM1_LOSSY_LO_BYTE_DROP_COUNTr, IDB_OBM1_LOSSY_HI_BYTE_DROP_COUNTr,
     47      IDB_OBM1_LOSSLESS0_BYTE_DROP_COUNTr, IDB_OBM1_LOSSLESS1_BYTE_DROP_COUNTr
     48     },
     49     {IDB_OBM2_LOSSY_LO_BYTE_DROP_COUNTr, IDB_OBM2_LOSSY_HI_BYTE_DROP_COUNTr,
     50      IDB_OBM2_LOSSLESS0_BYTE_DROP_COUNTr, IDB_OBM2_LOSSLESS1_BYTE_DROP_COUNTr
     51     },
     52     {IDB_OBM3_LOSSY_LO_BYTE_DROP_COUNTr, IDB_OBM3_LOSSY_HI_BYTE_DROP_COUNTr,
     53      IDB_OBM3_LOSSLESS0_BYTE_DROP_COUNTr, IDB_OBM3_LOSSLESS1_BYTE_DROP_COUNTr
     54     }
     55 };
     56 
     57 static soc_reg_t th3_obm_fc_event_regs[] = {
     58     IDB_OBM0_FLOW_CONTROL_EVENT_COUNTr,
     59     IDB_OBM1_FLOW_CONTROL_EVENT_COUNTr,
     60     IDB_OBM2_FLOW_CONTROL_EVENT_COUNTr,
     61     IDB_OBM3_FLOW_CONTROL_EVENT_COUNTr
     62 };
     63 
     64 int soc_counter_tomahawk3_obm_drop_to_phy_port(int unit, int pipe, soc_reg_t reg, int obm_port) {
     65     int i, j, phy_port = -1;
     66 
     67     for(i = 0; i < _TH3_PBLKS_PER_PIPE; i++) {
     68         for(j = 0; j < 4; j++) {
     69             if (reg == SOC_REG_UNIQUE_ACC(unit, th3_obm_drop_pkt_regs[i][j])[pipe] ||
     70                 reg == SOC_REG_UNIQUE_ACC(unit, th3_obm_drop_byte_regs[i][j])[pipe] ||
     71                 reg == SOC_REG_UNIQUE_ACC(unit, th3_obm_fc_event_regs[i])[pipe]) {
     72                 phy_port = (pipe * _TH3_PORTS_PER_PBLK * _TH3_PBLKS_PER_PIPE) +
     73                            (i * _TH3_PORTS_PER_PBLK) + obm_port + 1;
     74                 return phy_port;
     75             }
     76         }
     77     }
     78 
     79     return phy_port;
     80 }
     81 
     82 STATIC int
     83 soc_counter_th3_extra_ctrs_init(int unit, soc_reg_t id,
     84                                 soc_counter_non_dma_t *non_dma_parent,
     85                                 soc_counter_non_dma_t *non_dma_extra,
     86                                 uint32 extra_ctr_ct,
     87                                 int *total_entries)
     88 {
     89     soc_mem_t base_mem = INVALIDm;
     90     int rv = SOC_E_NONE, i, pipe, count = 0;
     91     int parent_base_index = 0, num_entries = 0;
     92     int entry_words = 0, dma_offset = 0;
     93     int entries_per_pipe[_TH3_PIPES_PER_DEV];
     94     uint8 itm_mem = FALSE;
     95     soc_info_t *si = &SOC_INFO(unit);
     96 
     97     /* DO SANITY CHECK FOR INPUT PARAMs */
     98     if (!(non_dma_parent->flags & _SOC_COUNTER_NON_DMA_SUBSET_PARENT)) {
     99         /* Only for Extra counters */
    100         rv = SOC_E_PARAM;
    101         goto _err_soc_counter_th3_extra_ctrs_init;
    102     }
    103 
    104     if(si == NULL) {
    105         rv = SOC_E_UNIT;
    106         goto _err_soc_counter_th3_extra_ctrs_init;
    107     }
    108 
    109     parent_base_index = non_dma_parent->base_index;
    110     *total_entries = 0;
    111 
    112     switch (id) {
    113         case SOC_COUNTER_NON_DMA_COSQ_DROP_PKT:
    114         case SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE:
    115         case SOC_COUNTER_NON_DMA_COSQ_DROP_WRED_PKT:
    116         case SOC_COUNTER_NON_DMA_COSQ_DROP_PKT_UC:
    117         case SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE_UC:
    118         case SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW:
    119         case SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED:
    120         case SOC_COUNTER_NON_DMA_PORT_WRED_PKT_YELLOW:
    121         case SOC_COUNTER_NON_DMA_PORT_WRED_PKT_RED:
    122         case SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW_UC:
    123         case SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED_UC:
    124         case SOC_COUNTER_NON_DMA_QUEUE_CURRENT:
    125         case SOC_COUNTER_NON_DMA_UC_QUEUE_CURRENT:
    126             itm_mem = TRUE;
    127 
    128             base_mem = SOC_MEM_UNIQUE_ACC_ITM(unit, non_dma_parent->mem, 0);
    129             if(base_mem == INVALIDm) {
    130                 rv = SOC_E_INTERNAL;
    131                 goto _err_soc_counter_th3_extra_ctrs_init;
    132             }
    133             entry_words = soc_mem_entry_words(unit, base_mem);
    134             count = extra_ctr_ct;
    135             break;
    136         default:
    137             rv = SOC_E_INTERNAL;
    138             goto _err_soc_counter_th3_extra_ctrs_init;
    139     }
    140 
    141     switch(id) {
    142         case SOC_COUNTER_NON_DMA_COSQ_DROP_PKT:
    143         case SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE:
    144         case SOC_COUNTER_NON_DMA_COSQ_DROP_WRED_PKT:
    145         case SOC_COUNTER_NON_DMA_COSQ_DROP_PKT_UC:
    146         case SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE_UC:
    147         case SOC_COUNTER_NON_DMA_QUEUE_CURRENT:
    148         case SOC_COUNTER_NON_DMA_UC_QUEUE_CURRENT:
    149             for(i = 0; i < _TH3_PIPES_PER_DEV; i++) {
    150                 entries_per_pipe[i] = th3_num_queues_pipe[i];
    151             }
    152             break;
    153         default:
    154             for(i = 0; i < _TH3_PIPES_PER_DEV; i++) {
    155                 entries_per_pipe[i] =
    156                     soc_mem_index_count(unit, base_mem) / _TH3_PIPES_PER_DEV;
    157             }
    158             break;
    159     }
    160 
    161     if (extra_ctr_ct > count) {
    162         rv = SOC_E_INTERNAL;
    163         goto _err_soc_counter_th3_extra_ctrs_init;
    164     }
    165 
    166     for (i = 0; i < count; i++) {
    167         if (itm_mem == TRUE) {
    168             /* Inherit few info from the Parent */
    169             non_dma_extra->flags = (non_dma_parent->flags &
    170                                     ~_SOC_COUNTER_NON_DMA_SUBSET_PARENT) |
    171                                     _SOC_COUNTER_NON_DMA_SUBSET_CHILD;
    172 
    173             non_dma_extra->cname = non_dma_parent->cname;
    174             non_dma_extra->field = non_dma_parent->field;
    175             non_dma_extra->reg = non_dma_parent->reg;
    176             non_dma_extra->entries_per_port = non_dma_parent->entries_per_port;
    177             non_dma_extra->id = non_dma_parent->id;
    178 
    179             /* Set Child attributes */
    180             non_dma_extra->base_index = parent_base_index + *total_entries;
    181 
    182             num_entries = 0;
    183             non_dma_extra->num_valid_pipe = 0;
    184             /* This for block initialize dma config that can be used in EM 
    185                half-chip setup by DMA a table per pipe. */
    186             for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    187                 if(!SOC_PBMP_IS_NULL(PBMP_PIPE(unit, pipe)) &&
    188                    (si->itm_map & (1 << i))) {
    189                     non_dma_extra->dma_mem[pipe] =
    190                         SOC_MEM_UNIQUE_ACC_ITM(unit, non_dma_parent->mem, i);
    191                     non_dma_extra->num_valid_pipe++;
    192                 } else {
    193                     non_dma_extra->dma_mem[pipe] = INVALIDm;
    194                 }
    195                 non_dma_extra->dma_index_min[pipe] = num_entries;
    196                 non_dma_extra->dma_index_max[pipe] = num_entries + entries_per_pipe[pipe] - 1;
    197                 non_dma_extra->dma_num_entries[pipe] = entries_per_pipe[pipe];
    198                 non_dma_extra->dma_buf[pipe] = non_dma_parent->dma_buf[0] +
    199                                                dma_offset +
    200                                                (num_entries * entry_words);
    201                 num_entries += entries_per_pipe[pipe];
    202             }
    203 
    204             /* When th3_em_halfchip is not set (the normal case), we can DMA the 
    205                whole table at once for performance  */
    206             if(soc_property_get(unit, "th3_em_halfchip", 0) == 0) {
    207                 non_dma_extra->dma_index_max[0] = num_entries - 1;
    208                 for (pipe = 1; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    209                     non_dma_extra->dma_mem[pipe] = INVALIDm;
    210                 }
    211             }
    212             *total_entries += num_entries;
    213             dma_offset += (num_entries * entry_words);
    214             non_dma_extra->mem = non_dma_parent->mem;
    215             non_dma_extra->num_entries = num_entries;
    216 
    217             non_dma_extra++;
    218             /* coverity[check_after_deref] */
    219             if (!non_dma_extra) {
    220                 /* ERR: Cannot be NULL, until 'i reaches 'count' */
    221                 /* This condition may not hit but intentional for defensive check */
    222                 /* coverity[dead_error_begin] */
    223                 rv = SOC_E_INTERNAL;
    224                 goto _err_soc_counter_th3_extra_ctrs_init;
    225             }
    226         }
    227 
    228     }
    229     return SOC_E_NONE;
    230 
    231 _err_soc_counter_th3_extra_ctrs_init:
    232     LOG_WARN(BSL_LS_SOC_COUNTER,
    233         (BSL_META_U(unit, "ERR: Extra ctrs Init FAILED for id %d\n"),
    234                     id - SOC_COUNTER_NON_DMA_START));
    235     return rv;
    236 }
    237 
    238 /* Function to initialize sFlow extra counters */
    239 STATIC int
    240 soc_counter_th3_extra_sflow_ctrs_init(int unit,
    241                                soc_counter_non_dma_t *non_dma_parent,
    242                                soc_counter_non_dma_t *non_dma_extra,
    243                                uint32 extra_ctr_ct,
    244                                int *total_entries)
    245 {
    246     int i, parent_base_index = 0;
    247     int base_mem_ct = 0;
    248     int do_dma = 1;
    249     int pipe, ind_min, pipe_rows, entry_words;
    250     uint32 *dma_buf;
    251 
    252     soc_field_t sflow_counter_fields[] = {
    253         SAMPLE_POOLf,
    254         SAMPLE_POOL_SNAPSHOTf,
    255         SAMPLE_COUNTf
    256     };
    257 
    258     /* Do sanity check for input params */
    259     if (!(non_dma_parent->flags & _SOC_COUNTER_NON_DMA_SUBSET_PARENT)) {
    260         /* Only for Extra counters */
    261         return SOC_E_PARAM;
    262     }
    263 
    264     parent_base_index = non_dma_parent->base_index;
    265     *total_entries = 0;
    266 
    267     for (i = 0; i < extra_ctr_ct; i++) {
    268         /* Set Child attributes. Inherit few info from the Parent */
    269         non_dma_extra->mem = non_dma_parent->mem;
    270         non_dma_extra->base_index = parent_base_index + *total_entries;
    271         base_mem_ct = soc_mem_index_count(unit, non_dma_extra->mem);
    272         non_dma_extra->num_entries = base_mem_ct;
    273         dma_buf = non_dma_parent->dma_buf[0];
    274 
    275         non_dma_extra->flags = (non_dma_parent->flags &
    276                                 ~_SOC_COUNTER_NON_DMA_SUBSET_PARENT) |
    277                                 _SOC_COUNTER_NON_DMA_SUBSET_CHILD;
    278 
    279         /* DMA should be done only once to get sFlow data table */
    280         if (do_dma != 1) {
    281             non_dma_extra->flags = (non_dma_extra->flags &
    282                                     ~_SOC_COUNTER_NON_DMA_DO_DMA);
    283         }
    284 
    285         non_dma_extra->cname = sal_alloc(sal_strlen(non_dma_parent->cname) + 9,
    286                                          "Extra ctrs cname");
    287 
    288         if (non_dma_extra->cname == NULL) {
    289             return SOC_E_MEMORY;
    290         }
    291 
    292         sal_sprintf(non_dma_extra->cname, "*%s_CNTR%d",
    293                     non_dma_parent->cname, i);
    294 
    295         non_dma_extra->field = sflow_counter_fields[i];
    296         non_dma_extra->reg = non_dma_parent->reg;
    297 
    298         ind_min = 0;
    299         pipe_rows = (soc_mem_index_max(unit,non_dma_parent->mem) + 1) 
    300                     / _TH3_PIPES_PER_DEV;
    301         entry_words = soc_mem_entry_words(unit, non_dma_parent->mem);
    302         for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    303             if(SOC_PBMP_IS_NULL(PBMP_PIPE(unit, pipe))) {
    304                 non_dma_extra->dma_mem[pipe] = INVALIDm;
    305             } else {
    306                 non_dma_extra->dma_mem[pipe] = non_dma_parent->mem;
    307                 non_dma_extra->dma_index_min[pipe] = ind_min;
    308                 non_dma_extra->dma_index_max[pipe] = ind_min + pipe_rows - 1;
    309                 non_dma_extra->dma_num_entries[pipe] = pipe_rows;
    310                 non_dma_extra->dma_buf[pipe] = dma_buf;
    311             }
    312             *total_entries += pipe_rows;
    313             ind_min += pipe_rows;
    314             dma_buf += entry_words * pipe_rows;
    315         }
    316 
    317         /* Allocation of Child Control blocks.
    318          * [0],..<even indices> - PKT_CTR non_dma ctrl block
    319          * [1],..<odd indices> - BYTE_CTR non_dma ctrl block
    320          * Hence in below code, jump by 2, so all similar control blocks are
    321          * initilized at the same time.
    322          */
    323         non_dma_extra += 2;
    324 
    325         do_dma = 0;
    326 
    327         /* coverity[check_after_deref] */
    328         if (!non_dma_extra) {
    329             /* ERR: Cannot be NULL, until 'i reaches 'extra_ctr_ct' */
    330             /* This condition may not hit but intentional for defensive check */
    331             /* coverity[dead_error_line] */
    332             return SOC_E_INTERNAL;
    333         }
    334     }
    335 
    336     return SOC_E_NONE;
    337 }
    338 
    339 int
    340 soc_counter_tomahawk3_non_dma_init(int unit, int nports,
    341                                   int non_dma_start_index,
    342                                   int *non_dma_entries)
    343 {
    344     soc_control_t *soc;
    345     soc_counter_non_dma_t *non_dma0, *non_dma1, *non_dma2, *temp;
    346     soc_mem_t child_mem = INVALIDm;
    347     uint32 *buf;
    348     int pipe, num_entries, alloc_size, entry_words, num_extra_ctr_entries;
    349     int pool_count = 0, rv;
    350     soc_counter_control_t *soc_ctr_ctrl = SOC_CTR_CTRL(unit);
    351 
    352     if (soc_ctr_ctrl == NULL) {
    353         return SOC_E_INIT;
    354     }
    355 
    356     soc = SOC_CONTROL(unit);
    357     *non_dma_entries = 0;
    358 
    359     /* Registration of Chip specific functions to the Global Counter 
    360      * control structure.
    361      */
    362     soc_ctr_ctrl->get_child_dma = soc_counter_tomahawk_get_child_dma;
    363     soc_ctr_ctrl->dma_config_update = soc_counter_tomahawk_dma_flags_update;
    364     soc_ctr_ctrl->port_obm_info_get = soc_tomahawk_port_obm_info_get;
    365 
    366     /* ING_FLEX_CTR_COUNTER_TABLE_0 is the largest table to be DMA'ed */
    367     num_entries = soc_mem_index_count(unit, ING_FLEX_CTR_COUNTER_TABLE_0m);
    368     entry_words = soc_mem_entry_words(unit, ING_FLEX_CTR_COUNTER_TABLE_0m);
    369     alloc_size = _TH3_PIPES_PER_DEV * num_entries * sizeof(uint32) * entry_words;
    370 
    371     buf = soc_cm_salloc(unit, alloc_size, "non_dma_counter_range_read_buffer");
    372     if (buf == NULL) {
    373         return SOC_E_MEMORY;
    374     }
    375     sal_memset(buf, 0, alloc_size);
    376 
    377     /* SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_PKT */
    378     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_PKT -
    379                                      SOC_COUNTER_NON_DMA_START];
    380     non_dma0->id = SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_PKT;
    381     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
    382                       _SOC_COUNTER_NON_DMA_DO_DMA |
    383                       _SOC_COUNTER_NON_DMA_ALLOC |
    384                       _SOC_COUNTER_NON_DMA_CTR_EVICT;
    385     non_dma0->dma_rate_profile |= _SOC_COUNTER_DMA_RATE_PROFILE_ALL;
    386 
    387     non_dma0->pbmp = PBMP_ALL(unit);
    388     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
    389     non_dma0->entries_per_port = 48; /* cpu port has max number of queues */
    390     non_dma0->mem = EGR_PERQ_XMT_COUNTERSm;
    391     non_dma0->reg = INVALIDr;
    392     non_dma0->field = PACKET_COUNTERf;
    393     non_dma0->cname = "MC_PERQ_PKT";
    394     num_entries = soc_mem_index_count(unit, EGR_PERQ_XMT_COUNTERSm);
    395     entry_words = soc_mem_entry_words(unit, EGR_PERQ_XMT_COUNTERSm);
    396     non_dma0->num_entries = num_entries * _TH3_PIPES_PER_DEV;
    397 
    398     for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    399         non_dma0->dma_mem[pipe] =
    400             SOC_MEM_UNIQUE_ACC(unit, non_dma0->mem)[pipe];
    401         non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
    402         non_dma0->dma_index_max[pipe] =
    403             soc_mem_index_max(unit, non_dma0->dma_mem[pipe]);
    404         non_dma0->dma_num_entries[pipe] = num_entries;
    405     }
    406     *non_dma_entries += non_dma0->num_entries;
    407 
    408     /* SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_BYTE */
    409     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_BYTE -
    410                                      SOC_COUNTER_NON_DMA_START];
    411     *non_dma1 = *non_dma0;
    412     non_dma1->id = SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_BYTE;
    413     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID;
    414     non_dma1->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
    415     non_dma0->dma_rate_profile |= _SOC_COUNTER_DMA_RATE_PROFILE0;
    416 
    417     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
    418     non_dma1->field = BYTE_COUNTERf;
    419     non_dma1->cname = "MC_PERQ_BYTE";
    420     *non_dma_entries += non_dma1->num_entries;
    421 
    422 
    423     /* SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_PKT_UC */
    424     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_PKT_UC -
    425                                      SOC_COUNTER_NON_DMA_START];
    426     *non_dma2 = *non_dma0;
    427     non_dma2->id = SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_PKT_UC;
    428     non_dma2->flags = _SOC_COUNTER_NON_DMA_VALID;
    429     non_dma2->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
    430     non_dma2->dma_rate_profile |= _SOC_COUNTER_DMA_RATE_PROFILE0;
    431 
    432     non_dma2->pbmp = PBMP_PORT_ALL(unit);
    433     non_dma2->num_entries = 0;
    434     non_dma2->cname = "UC_PERQ_PKT";
    435 
    436     /* SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_BYTE_UC */
    437     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_BYTE_UC -
    438                                      SOC_COUNTER_NON_DMA_START];
    439     *non_dma2 = *non_dma1;
    440     non_dma2->id = SOC_COUNTER_NON_DMA_EGR_PERQ_XMT_BYTE_UC;
    441     non_dma2->flags = _SOC_COUNTER_NON_DMA_VALID;
    442     non_dma2->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
    443     non_dma2->dma_rate_profile |= _SOC_COUNTER_DMA_RATE_PROFILE0;
    444 
    445     non_dma2->pbmp = PBMP_PORT_ALL(unit);
    446     non_dma2->num_entries = 0;
    447     non_dma2->cname = "UC_PERQ_BYTE";
    448 
    449     /* SOC_COUNTER_NON_DMA_COSQ_DROP_PKT */
    450     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_COSQ_DROP_PKT -
    451                                      SOC_COUNTER_NON_DMA_START];
    452     non_dma0->id = SOC_COUNTER_NON_DMA_COSQ_DROP_PKT;
    453     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
    454                       _SOC_COUNTER_NON_DMA_DO_DMA |
    455                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
    456     non_dma0->pbmp = PBMP_ALL(unit);
    457     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
    458     non_dma0->entries_per_port = 48; /* 48 for cpu port */
    459     non_dma0->mem = MMU_THDO_QUEUE_DROP_COUNTm;
    460     non_dma0->reg = INVALIDr;
    461     non_dma0->field = Q_PACKET_TOTAL_DROPf;
    462     non_dma0->cname = "PERQ_DROP_PKT";
    463 
    464     child_mem = SOC_MEM_UNIQUE_ACC_ITM(unit, non_dma0->mem, 0);
    465     entry_words = soc_mem_entry_words(unit, child_mem );
    466     non_dma0->num_entries = soc_mem_index_count(unit, child_mem) * NUM_ITM(unit);
    467     non_dma0->dma_buf[0] = buf;
    468     non_dma0->extra_ctr_ct = NUM_ITM(unit);
    469     /* Incl. extra_ctr for: PERQ_DROP_PKT,
    470                             PERQ_DROP_PKT_UC,
    471                             PERQ_DROP_BYTE,
    472                             PERQ_DROP_BYTE_UC,
    473                             PERQ_DROP_WRED_PKT
    474        5x alloc size*/
    475     non_dma0->extra_ctr_fld_ct = 5;
    476     alloc_size = (non_dma0->extra_ctr_ct * 5) * sizeof(soc_counter_non_dma_t);
    477     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_perq_drop");
    478 
    479     if (non_dma0->extra_ctrs == NULL) {
    480         non_dma0->extra_ctr_ct = 0;
    481         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    482         return SOC_E_MEMORY;
    483     } else {
    484         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
    485         soc_counter_th3_extra_ctrs_init(unit,
    486                                         SOC_COUNTER_NON_DMA_COSQ_DROP_PKT,
    487                                         non_dma0,
    488                                         non_dma0->extra_ctrs,
    489                                         non_dma0->extra_ctr_ct,
    490                                         &num_extra_ctr_entries);
    491         non_dma0->num_entries = num_extra_ctr_entries;
    492         *non_dma_entries += non_dma0->num_entries;
    493     }
    494 
    495     /* SOC_COUNTER_NON_DMA_COSQ_DROP_PKT_UC */
    496     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_COSQ_DROP_PKT_UC -
    497                                      SOC_COUNTER_NON_DMA_START];
    498     *non_dma1 = *non_dma0;
    499     non_dma1->id = SOC_COUNTER_NON_DMA_COSQ_DROP_PKT_UC;
    500     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
    501                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
    502     non_dma1->extra_ctrs = non_dma0->extra_ctrs + non_dma0->extra_ctr_ct;
    503     non_dma1->cname = "PERQ_DROP_PKT_UC";
    504     if (non_dma0->extra_ctrs == NULL) {
    505         non_dma1->extra_ctr_ct = 0;
    506         non_dma1->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    507         return SOC_E_MEMORY;
    508     } else {
    509         soc_counter_th3_extra_ctrs_init(unit,
    510                                         SOC_COUNTER_NON_DMA_COSQ_DROP_PKT_UC,
    511                                         non_dma1,
    512                                         non_dma1->extra_ctrs,
    513                                         non_dma1->extra_ctr_ct,
    514                                         &num_extra_ctr_entries);
    515         non_dma1->num_entries = num_extra_ctr_entries;
    516     }
    517 
    518     /* SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE */
    519     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE -
    520                                      SOC_COUNTER_NON_DMA_START];
    521     *non_dma2 = *non_dma1;
    522     non_dma2->id = SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE;
    523     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    524     non_dma2->field = Q_BYTE_TOTAL_DROPf;
    525     non_dma2->cname = "PERQ_DROP_BYTE";
    526     non_dma2->extra_ctrs = non_dma1->extra_ctrs + non_dma1->extra_ctr_ct;
    527     if (non_dma0->extra_ctrs == NULL) {
    528         non_dma2->extra_ctr_ct = 0;
    529         non_dma2->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    530         return SOC_E_MEMORY;
    531     } else {
    532         soc_counter_th3_extra_ctrs_init(unit,
    533                                         SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE,
    534                                         non_dma2,
    535                                         non_dma2->extra_ctrs,
    536                                         non_dma2->extra_ctr_ct,
    537                                         &num_extra_ctr_entries);
    538         non_dma2->num_entries = num_extra_ctr_entries;
    539         *non_dma_entries += non_dma2->num_entries;
    540     }
    541 
    542     /* SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE_UC */
    543     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE_UC -
    544                                      SOC_COUNTER_NON_DMA_START];
    545     *non_dma1 = *non_dma2;
    546     non_dma1->id = SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE_UC;
    547     non_dma1->cname = "PERQ_DROP_BYTE_UC";
    548     non_dma1->extra_ctrs = non_dma2->extra_ctrs + non_dma2->extra_ctr_ct;
    549     if (non_dma0->extra_ctrs == NULL) {
    550         non_dma1->extra_ctr_ct = 0;
    551         non_dma1->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    552         return SOC_E_MEMORY;
    553     } else {
    554         soc_counter_th3_extra_ctrs_init(unit,
    555                                         SOC_COUNTER_NON_DMA_COSQ_DROP_BYTE_UC,
    556                                         non_dma1,
    557                                         non_dma1->extra_ctrs,
    558                                         non_dma1->extra_ctr_ct,
    559                                         &num_extra_ctr_entries);
    560         non_dma1->num_entries = num_extra_ctr_entries;
    561     }
    562 
    563     /* SOC_COUNTER_NON_DMA_COSQ_DROP_WRED_PKT */
    564     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_COSQ_DROP_WRED_PKT -
    565                                      SOC_COUNTER_NON_DMA_START];
    566     *non_dma2 = *non_dma0;
    567     non_dma2->id = SOC_COUNTER_NON_DMA_COSQ_DROP_WRED_PKT;
    568     non_dma2->flags = _SOC_COUNTER_NON_DMA_VALID |
    569                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
    570     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    571     non_dma2->field = Q_WRED_PACKET_TOTAL_DROPf;
    572     non_dma2->cname = "PERQ_DROP_WRED_PKT";
    573     non_dma2->extra_ctrs = non_dma1->extra_ctrs + non_dma1->extra_ctr_ct;
    574     if (non_dma0->extra_ctrs) {
    575         soc_counter_th3_extra_ctrs_init(unit,
    576                                         SOC_COUNTER_NON_DMA_COSQ_DROP_WRED_PKT,
    577                                         non_dma2,
    578                                         non_dma2->extra_ctrs,
    579                                         non_dma2->extra_ctr_ct,
    580                                         &num_extra_ctr_entries);
    581         non_dma2->num_entries = num_extra_ctr_entries;
    582         *non_dma_entries += non_dma2->num_entries;
    583     }
    584 
    585     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW */
    586     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW -
    587                                      SOC_COUNTER_NON_DMA_START];
    588     non_dma0->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW;
    589     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
    590                       _SOC_COUNTER_NON_DMA_DO_DMA |
    591                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
    592     non_dma0->pbmp = PBMP_ALL(unit);
    593     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
    594     non_dma0->entries_per_port = 1;
    595     non_dma0->mem = MMU_THDO_PORT_DROP_COUNT_MCm;
    596     non_dma0->reg = INVALIDr;
    597     non_dma0->field = PORT_PACKET_YELLOW_DROPf;
    598     non_dma0->cname = "DROP_PKT_YEL";
    599 
    600     child_mem = SOC_MEM_UNIQUE_ACC_ITM(unit, non_dma0->mem, 0);
    601     num_entries = soc_mem_index_count(unit, child_mem) / _TH3_PIPES_PER_DEV;
    602     entry_words = soc_mem_entry_words(unit, non_dma0->mem);
    603 
    604     for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    605         non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
    606     }
    607 
    608     non_dma0->extra_ctr_ct = NUM_ITM(unit);
    609     /* Incl. buffer for: PORT_PACKET_RED_DROP,
    610                          PORT_PACKET_YELLOW_DROP,
    611        2x alloc size */
    612     non_dma0->extra_ctr_fld_ct = 2;
    613     alloc_size = (non_dma0->extra_ctr_ct * 2) * sizeof(soc_counter_non_dma_t);
    614     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_color_drop_pkt_mc");
    615 
    616     /*
    617      * Below represents how Extra cntrs are arranged
    618      * for Per Port Color Drop Counters. (2 x ITM in TH3)
    619      *
    620      *   [0]     [2]
    621      *  ------  ------
    622      * |      ||      |
    623      * | YEL  || RED  |
    624      * | [0]  || [0]  |
    625      *  ------  ------
    626      * |      ||      |
    627      * | YEL  || RED  |
    628      * | [1]  || [1]  |
    629      *  ------  ------
    630      *   [1]     [3]
    631      */
    632     if (non_dma0->extra_ctrs == NULL) {
    633         non_dma0->extra_ctr_ct = 0;
    634         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    635         return SOC_E_MEMORY;
    636     } else {
    637         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
    638         soc_counter_th3_extra_ctrs_init(unit,
    639                                         SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW,
    640                                         non_dma0,
    641                                         non_dma0->extra_ctrs,
    642                                         non_dma0->extra_ctr_ct,
    643                                         &num_extra_ctr_entries);
    644         non_dma0->num_entries = num_extra_ctr_entries;
    645     }
    646     *non_dma_entries += non_dma0->num_entries;
    647 
    648     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED */
    649     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED -
    650                                      SOC_COUNTER_NON_DMA_START];
    651     *non_dma1 = *non_dma0;
    652     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED;
    653     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
    654                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
    655     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
    656     non_dma1->field = PORT_PACKET_RED_DROPf;
    657     non_dma1->cname = "DROP_PKT_RED";
    658 
    659     non_dma1->extra_ctrs = non_dma0->extra_ctrs + non_dma0->extra_ctr_ct;
    660     if (non_dma0->extra_ctrs) {
    661         soc_counter_th3_extra_ctrs_init(unit,
    662                                         SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED,
    663                                         non_dma1,
    664                                         non_dma1->extra_ctrs,
    665                                         non_dma1->extra_ctr_ct,
    666                                         &num_extra_ctr_entries);
    667         non_dma1->num_entries = num_extra_ctr_entries;
    668         *non_dma_entries += non_dma1->num_entries;
    669     }
    670 
    671     /* SOC_COUNTER_NON_DMA_PORT_WRED_PKT_YELLOW */
    672     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_WRED_PKT_YELLOW -
    673                                      SOC_COUNTER_NON_DMA_START];
    674     non_dma0->id = SOC_COUNTER_NON_DMA_PORT_WRED_PKT_YELLOW;
    675     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
    676                       _SOC_COUNTER_NON_DMA_DO_DMA |
    677                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
    678     non_dma0->pbmp = PBMP_ALL(unit);
    679     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
    680     non_dma0->entries_per_port = 1;
    681     non_dma0->mem = MMU_THDO_PORT_DROP_COUNT_UCm;
    682     non_dma0->reg = INVALIDr;
    683     non_dma0->field = PORT_WRED_PACKET_YELLOW_DROPf;
    684     non_dma0->cname = "WRED_PKT_YEL";
    685 
    686     child_mem = SOC_MEM_UNIQUE_ACC_ITM(unit, non_dma0->mem, 0);
    687     num_entries = soc_mem_index_count(unit, child_mem) /_TH3_PIPES_PER_DEV;
    688     entry_words = soc_mem_entry_words(unit, non_dma0->mem);
    689 
    690     for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    691         non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
    692     }
    693 
    694     non_dma0->extra_ctr_ct = NUM_ITM(unit);
    695     /* Incl. buffer for: PORT_WRED_PACKET_YELLOW_DROP,
    696                          PORT_WRED_PACKET_RED_DROP,
    697                          PORT_PACKET_YELLOW_DROP,
    698                          PORT_PACKET_RED_DROP
    699        4x alloc size */
    700     non_dma0->extra_ctr_fld_ct = 4;
    701     alloc_size = (non_dma0->extra_ctr_ct * 4) * sizeof(soc_counter_non_dma_t);
    702     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_color_drop_pkt_uc");
    703     /*
    704      * Below represents how Extra cntrs are arranged
    705      * for Per Port Color Drop Counters. (2 x ITM in TH3)
    706      *
    707      *   [0]        [2]       [4]   [6]
    708      *  ---------  --------- ----- -----
    709      * |         ||         |     |     |
    710      * | WRED_YEL|| WRED_RED| YEL | RED |
    711      * | [0]     || [0]     | [0] | [0] |
    712      *  ---------  --------- ----- -----
    713      * |         ||         |     |     |
    714      * | WRED_YEL|| WRED_RED| YEL | RED |
    715      * | [1]     || [1]     | [1] | [1] |
    716      *  ---------  --------- ----- -----
    717      *   [1]        [3]       [5]   [7]
    718      */
    719     if (non_dma0->extra_ctrs == NULL) {
    720         non_dma0->extra_ctr_ct = 0;
    721         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    722         return SOC_E_MEMORY;
    723     } else {
    724         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
    725         soc_counter_th3_extra_ctrs_init(unit,
    726                                         SOC_COUNTER_NON_DMA_PORT_WRED_PKT_YELLOW,
    727                                         non_dma0,
    728                                         non_dma0->extra_ctrs,
    729                                         non_dma0->extra_ctr_ct,
    730                                         &num_extra_ctr_entries);
    731         non_dma0->num_entries = num_extra_ctr_entries;
    732     }
    733     *non_dma_entries += non_dma0->num_entries;
    734 
    735 
    736     /* SOC_COUNTER_NON_DMA_PORT_WRED_PKT_RED */
    737     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_WRED_PKT_RED -
    738                                      SOC_COUNTER_NON_DMA_START];
    739     *non_dma1 = *non_dma0;
    740     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_WRED_PKT_RED;
    741     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
    742                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
    743     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
    744     non_dma1->field = PORT_WRED_PACKET_RED_DROPf;
    745     non_dma1->cname = "WRED_PKT_RED";
    746     non_dma1->extra_ctrs = non_dma0->extra_ctrs + non_dma0->extra_ctr_ct;
    747     if (non_dma0->extra_ctrs) {
    748         soc_counter_th3_extra_ctrs_init(unit,
    749                                         SOC_COUNTER_NON_DMA_PORT_WRED_PKT_RED,
    750                                         non_dma1,
    751                                         non_dma1->extra_ctrs,
    752                                         non_dma1->extra_ctr_ct,
    753                                         &num_extra_ctr_entries);
    754         non_dma1->num_entries = num_extra_ctr_entries;
    755         *non_dma_entries += non_dma1->num_entries;
    756     }
    757 
    758     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW_UC */
    759     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW_UC -
    760                                      SOC_COUNTER_NON_DMA_START];
    761     *non_dma2 = *non_dma1;
    762     non_dma2->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW_UC;
    763     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    764     non_dma2->field = PORT_PACKET_YELLOW_DROPf;
    765     non_dma2->cname = "DROP_PKT_YEL_UC";
    766     non_dma2->extra_ctrs = non_dma1->extra_ctrs + non_dma1->extra_ctr_ct;
    767     if (non_dma0->extra_ctrs) {
    768         soc_counter_th3_extra_ctrs_init(unit,
    769                                         SOC_COUNTER_NON_DMA_PORT_DROP_PKT_YELLOW_UC,
    770                                         non_dma2,
    771                                         non_dma2->extra_ctrs,
    772                                         non_dma2->extra_ctr_ct,
    773                                         &num_extra_ctr_entries);
    774         non_dma2->num_entries = num_extra_ctr_entries;
    775         *non_dma_entries += non_dma2->num_entries;
    776     }
    777 
    778     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED_UC */
    779     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED_UC -
    780                                      SOC_COUNTER_NON_DMA_START];
    781     *non_dma1 = *non_dma2;
    782     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED_UC;
    783     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
    784     non_dma1->field = PORT_PACKET_RED_DROPf;
    785     non_dma1->cname = "DROP_PKT_RED_UC";
    786     non_dma1->extra_ctrs = non_dma2->extra_ctrs + non_dma2->extra_ctr_ct;
    787     if (non_dma0->extra_ctrs) {
    788         soc_counter_th3_extra_ctrs_init(unit,
    789                                         SOC_COUNTER_NON_DMA_PORT_DROP_PKT_RED_UC,
    790                                         non_dma1,
    791                                         non_dma1->extra_ctrs,
    792                                         non_dma1->extra_ctr_ct,
    793                                         &num_extra_ctr_entries);
    794         non_dma1->num_entries = num_extra_ctr_entries;
    795         *non_dma_entries += non_dma1->num_entries;
    796     }
    797 
    798     /* SOC_COUNTER_NON_DMA_QUEUE_CURRENT */
    799     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_QUEUE_CURRENT -
    800                                      SOC_COUNTER_NON_DMA_START];
    801     non_dma0->id = SOC_COUNTER_NON_DMA_QUEUE_CURRENT;
    802     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
    803                       _SOC_COUNTER_NON_DMA_DO_DMA |
    804                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT |
    805                       _SOC_COUNTER_NON_DMA_CURRENT;
    806     non_dma0->pbmp = PBMP_ALL(unit);
    807     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
    808     non_dma0->entries_per_port = 48; /* 48 for cpu port */
    809     non_dma0->mem = MMU_THDO_COUNTER_QUEUEm;
    810     non_dma0->reg = INVALIDr;
    811     non_dma0->field = SHARED_COUNTf;
    812     non_dma0->cname = "QUEUE_CUR";
    813 
    814     child_mem = SOC_MEM_UNIQUE_ACC_ITM(unit, non_dma0->mem, 0);
    815     num_entries = soc_mem_index_count(unit, child_mem) / _TH3_PIPES_PER_DEV;
    816     entry_words = soc_mem_entry_words(unit, child_mem );
    817     non_dma0->num_entries = _TH3_PIPES_PER_DEV * num_entries * NUM_ITM(unit);
    818     non_dma0->dma_buf[0] = buf;
    819 
    820     non_dma0->extra_ctr_ct = NUM_ITM(unit);
    821     /* Incl. buffer for:
    822        1x alloc size
    823        extend when we want to include TOTALCOUNT and MIN_COUNT*/
    824     non_dma0->extra_ctr_fld_ct = 2;
    825     alloc_size = (non_dma0->extra_ctr_ct * 2) * sizeof(soc_counter_non_dma_t);
    826     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_queue");
    827 
    828     if (non_dma0->extra_ctrs == NULL) {
    829         non_dma0->extra_ctr_ct = 0;
    830         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    831         return SOC_E_MEMORY;
    832     } else {
    833         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
    834         soc_counter_th3_extra_ctrs_init(unit,
    835                                         SOC_COUNTER_NON_DMA_QUEUE_CURRENT,
    836                                         non_dma0,
    837                                         non_dma0->extra_ctrs,
    838                                         non_dma0->extra_ctr_ct,
    839                                         &num_extra_ctr_entries);
    840         non_dma0->num_entries = num_extra_ctr_entries;
    841     }
    842     *non_dma_entries += non_dma0->num_entries;
    843 
    844     /* SOC_COUNTER_NON_DMA_UC_QUEUE_CURRENT */
    845     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_UC_QUEUE_CURRENT -
    846                                      SOC_COUNTER_NON_DMA_START];
    847     *non_dma1 = *non_dma0;
    848     non_dma1->id = SOC_COUNTER_NON_DMA_UC_QUEUE_CURRENT;
    849     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
    850                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT |
    851                       _SOC_COUNTER_NON_DMA_CURRENT;
    852     non_dma1->cname = "UC_QUEUE_CUR";
    853     non_dma1->extra_ctrs = non_dma0->extra_ctrs + non_dma0->extra_ctr_ct;
    854     if (non_dma1->extra_ctrs == NULL) {
    855         non_dma1->extra_ctr_ct = 0;
    856         non_dma1->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    857         return SOC_E_MEMORY;
    858     } else {
    859         soc_counter_th3_extra_ctrs_init(unit,
    860                                         SOC_COUNTER_NON_DMA_UC_QUEUE_CURRENT,
    861                                         non_dma1,
    862                                         non_dma1->extra_ctrs,
    863                                         non_dma1->extra_ctr_ct,
    864                                         &num_extra_ctr_entries);
    865         non_dma1->num_entries = num_extra_ctr_entries;
    866     }
    867 
    868     /* SOC_COUNTER_NON_DMA_PG0_MIN_CURRENT */
    869     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG0_MIN_CURRENT -
    870                                      SOC_COUNTER_NON_DMA_START];
    871     non_dma0->id = SOC_COUNTER_NON_DMA_PG0_MIN_CURRENT;
    872     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
    873                       _SOC_COUNTER_NON_DMA_DO_DMA |
    874                       _SOC_COUNTER_NON_DMA_CURRENT;
    875     non_dma0->pbmp = PBMP_ALL(unit);
    876     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
    877     non_dma0->entries_per_port = 1;
    878     non_dma0->mem = MMU_THDI_PORT_PG_MIN_COUNTERm;
    879     non_dma0->reg = INVALIDr;
    880     non_dma0->field = PG0_MIN_COUNTf;
    881     non_dma0->cname = "PG0_MIN_CUR";
    882 
    883     child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, 0);
    884     if (child_mem != INVALIDm) {
    885         num_entries = soc_mem_index_count(unit, child_mem);
    886         entry_words = soc_mem_entry_words(unit, child_mem);
    887         non_dma0->num_entries = _TH3_PIPES_PER_DEV * num_entries;
    888 
    889         for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    890             child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, pipe);
    891             non_dma0->dma_mem[pipe] = child_mem;
    892             non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
    893             non_dma0->dma_index_max[pipe] =
    894                 soc_mem_index_max(unit, child_mem);
    895             non_dma0->dma_index_min[pipe] =
    896                 soc_mem_index_min(unit, child_mem);
    897             non_dma0->dma_num_entries[pipe] = num_entries;
    898         }
    899         *non_dma_entries += non_dma0->num_entries;
    900     } else {
    901         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
    902     }
    903 
    904     /* SOC_COUNTER_NON_DMA_PG1_MIN_CURRENT */
    905     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG1_MIN_CURRENT -
    906                                      SOC_COUNTER_NON_DMA_START];
    907     *non_dma1 = *non_dma0;
    908     non_dma1->id = SOC_COUNTER_NON_DMA_PG1_MIN_CURRENT;
    909     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
    910                       _SOC_COUNTER_NON_DMA_CURRENT;
    911     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
    912     non_dma1->field = PG1_MIN_COUNTf;
    913     non_dma1->cname = "PG1_MIN_CUR";
    914     *non_dma_entries += non_dma1->num_entries;
    915 
    916     /* SOC_COUNTER_NON_DMA_PG2_MIN_CURRENT */
    917     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG2_MIN_CURRENT -
    918                                      SOC_COUNTER_NON_DMA_START];
    919     *non_dma2 = *non_dma1;
    920     non_dma2->id = SOC_COUNTER_NON_DMA_PG2_MIN_CURRENT;
    921     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    922     non_dma2->field = PG2_MIN_COUNTf;
    923     non_dma2->cname = "PG2_MIN_CUR";
    924     *non_dma_entries += non_dma2->num_entries;
    925 
    926     /* SOC_COUNTER_NON_DMA_PG3_MIN_CURRENT */
    927     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG3_MIN_CURRENT -
    928                                      SOC_COUNTER_NON_DMA_START];
    929     *non_dma2 = *non_dma1;
    930     non_dma2->id = SOC_COUNTER_NON_DMA_PG3_MIN_CURRENT;
    931     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    932     non_dma2->field = PG3_MIN_COUNTf;
    933     non_dma2->cname = "PG3_MIN_CUR";
    934     *non_dma_entries += non_dma2->num_entries;
    935 
    936     /* SOC_COUNTER_NON_DMA_PG4_MIN_CURRENT */
    937     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG4_MIN_CURRENT -
    938                                      SOC_COUNTER_NON_DMA_START];
    939     *non_dma2 = *non_dma1;
    940     non_dma2->id = SOC_COUNTER_NON_DMA_PG4_MIN_CURRENT;
    941     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    942     non_dma2->field = PG4_MIN_COUNTf;
    943     non_dma2->cname = "PG4_MIN_CUR";
    944     *non_dma_entries += non_dma2->num_entries;
    945 
    946     /* SOC_COUNTER_NON_DMA_PG5_MIN_CURRENT */
    947     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG5_MIN_CURRENT -
    948                                      SOC_COUNTER_NON_DMA_START];
    949     *non_dma2 = *non_dma1;
    950     non_dma2->id = SOC_COUNTER_NON_DMA_PG5_MIN_CURRENT;
    951     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    952     non_dma2->field = PG5_MIN_COUNTf;
    953     non_dma2->cname = "PG5_MIN_CUR";
    954     *non_dma_entries += non_dma2->num_entries;
    955 
    956     /* SOC_COUNTER_NON_DMA_PG6_MIN_CURRENT */
    957     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG6_MIN_CURRENT -
    958                                      SOC_COUNTER_NON_DMA_START];
    959     *non_dma2 = *non_dma1;
    960     non_dma2->id = SOC_COUNTER_NON_DMA_PG6_MIN_CURRENT;
    961     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    962     non_dma2->field = PG6_MIN_COUNTf;
    963     non_dma2->cname = "PG6_MIN_CUR";
    964     *non_dma_entries += non_dma2->num_entries;
    965 
    966     /* SOC_COUNTER_NON_DMA_PG7_MIN_CURRENT */
    967     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG7_MIN_CURRENT -
    968                                      SOC_COUNTER_NON_DMA_START];
    969     *non_dma2 = *non_dma1;
    970     non_dma2->id = SOC_COUNTER_NON_DMA_PG7_MIN_CURRENT;
    971     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
    972     non_dma2->field = PG7_MIN_COUNTf;
    973     non_dma2->cname = "PG7_MIN_CUR";
    974     *non_dma_entries += non_dma2->num_entries;
    975 
    976     /* SOC_COUNTER_NON_DMA_PG0_SHARED_CURRENT */
    977     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG0_SHARED_CURRENT -
    978                                      SOC_COUNTER_NON_DMA_START];
    979     non_dma0->id = SOC_COUNTER_NON_DMA_PG0_SHARED_CURRENT;
    980     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
    981                       _SOC_COUNTER_NON_DMA_DO_DMA |
    982                       _SOC_COUNTER_NON_DMA_CURRENT;
    983     non_dma0->pbmp = PBMP_ALL(unit);
    984     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
    985     non_dma0->entries_per_port = 1;
    986     non_dma0->mem = MMU_THDI_PORT_PG_SHARED_COUNTERm;
    987     non_dma0->reg = INVALIDr;
    988     non_dma0->field = PG0_SHARED_COUNTf;
    989     non_dma0->cname = "PG0_SHARED_CUR";
    990 
    991     child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, 0);
    992     if (child_mem != INVALIDm) {
    993         num_entries = soc_mem_index_count(unit, child_mem);
    994         entry_words = soc_mem_entry_words(unit, child_mem);
    995         non_dma0->num_entries = _TH3_PIPES_PER_DEV * num_entries;
    996 
    997         for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
    998             child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, pipe);
    999             non_dma0->dma_mem[pipe] = child_mem;
   1000             non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
   1001             non_dma0->dma_index_max[pipe] =
   1002                 soc_mem_index_max(unit, child_mem);
   1003             non_dma0->dma_index_min[pipe] =
   1004                 soc_mem_index_min(unit, child_mem);
   1005             non_dma0->dma_num_entries[pipe] = num_entries;
   1006         }
   1007         *non_dma_entries += non_dma0->num_entries;
   1008     } else {
   1009         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1010     }
   1011 
   1012     /* SOC_COUNTER_NON_DMA_PG1_SHARED_CURRENT */
   1013     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG1_SHARED_CURRENT -
   1014                                      SOC_COUNTER_NON_DMA_START];
   1015     *non_dma1 = *non_dma0;
   1016     non_dma1->id = SOC_COUNTER_NON_DMA_PG1_SHARED_CURRENT;
   1017     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
   1018                       _SOC_COUNTER_NON_DMA_CURRENT;
   1019     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1020     non_dma1->field = PG1_SHARED_COUNTf;
   1021     non_dma1->cname = "PG1_SHARED_CUR";
   1022     *non_dma_entries += non_dma1->num_entries;
   1023 
   1024     /* SOC_COUNTER_NON_DMA_PG2_SHARED_CURRENT */
   1025     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG2_SHARED_CURRENT -
   1026                                      SOC_COUNTER_NON_DMA_START];
   1027     *non_dma2 = *non_dma1;
   1028     non_dma2->id = SOC_COUNTER_NON_DMA_PG2_SHARED_CURRENT;
   1029     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1030     non_dma2->field = PG2_SHARED_COUNTf;
   1031     non_dma2->cname = "PG2_SHARED_CUR";
   1032     *non_dma_entries += non_dma2->num_entries;
   1033 
   1034     /* SOC_COUNTER_NON_DMA_PG3_SHARED_CURRENT */
   1035     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG3_SHARED_CURRENT -
   1036                                      SOC_COUNTER_NON_DMA_START];
   1037     *non_dma2 = *non_dma1;
   1038     non_dma2->id = SOC_COUNTER_NON_DMA_PG3_SHARED_CURRENT;
   1039     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1040     non_dma2->field = PG3_SHARED_COUNTf;
   1041     non_dma2->cname = "PG3_SHARED_CUR";
   1042     *non_dma_entries += non_dma2->num_entries;
   1043 
   1044     /* SOC_COUNTER_NON_DMA_PG4_SHARED_CURRENT */
   1045     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG4_SHARED_CURRENT -
   1046                                      SOC_COUNTER_NON_DMA_START];
   1047     *non_dma2 = *non_dma1;
   1048     non_dma2->id = SOC_COUNTER_NON_DMA_PG4_SHARED_CURRENT;
   1049     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1050     non_dma2->field = PG4_SHARED_COUNTf;
   1051     non_dma2->cname = "PG4_SHARED_CUR";
   1052     *non_dma_entries += non_dma2->num_entries;
   1053 
   1054     /* SOC_COUNTER_NON_DMA_PG5_SHARED_CURRENT */
   1055     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG5_SHARED_CURRENT -
   1056                                      SOC_COUNTER_NON_DMA_START];
   1057     *non_dma2 = *non_dma1;
   1058     non_dma2->id = SOC_COUNTER_NON_DMA_PG5_SHARED_CURRENT;
   1059     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1060     non_dma2->field = PG5_SHARED_COUNTf;
   1061     non_dma2->cname = "PG5_SHARED_CUR";
   1062     *non_dma_entries += non_dma2->num_entries;
   1063 
   1064     /* SOC_COUNTER_NON_DMA_PG6_SHARED_CURRENT */
   1065     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG6_SHARED_CURRENT -
   1066                                      SOC_COUNTER_NON_DMA_START];
   1067     *non_dma2 = *non_dma1;
   1068     non_dma2->id = SOC_COUNTER_NON_DMA_PG6_SHARED_CURRENT;
   1069     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1070     non_dma2->field = PG6_SHARED_COUNTf;
   1071     non_dma2->cname = "PG6_SHARED_CUR";
   1072     *non_dma_entries += non_dma2->num_entries;
   1073 
   1074     /* SOC_COUNTER_NON_DMA_PG7_SHARED_CURRENT */
   1075     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG7_SHARED_CURRENT -
   1076                                      SOC_COUNTER_NON_DMA_START];
   1077     *non_dma2 = *non_dma1;
   1078     non_dma2->id = SOC_COUNTER_NON_DMA_PG7_SHARED_CURRENT;
   1079     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1080     non_dma2->field = PG7_SHARED_COUNTf;
   1081     non_dma2->cname = "PG7_SHARED_CUR";
   1082     *non_dma_entries += non_dma2->num_entries;
   1083 
   1084     /* SOC_COUNTER_NON_DMA_PG0_HDRM_CURRENT */
   1085     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG0_HDRM_CURRENT -
   1086                                      SOC_COUNTER_NON_DMA_START];
   1087     non_dma0->id = SOC_COUNTER_NON_DMA_PG0_HDRM_CURRENT;
   1088     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1089                       _SOC_COUNTER_NON_DMA_DO_DMA |
   1090                       _SOC_COUNTER_NON_DMA_CURRENT;
   1091     non_dma0->pbmp = PBMP_ALL(unit);
   1092     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1093     non_dma0->entries_per_port = 1;
   1094     non_dma0->mem = MMU_THDI_PORT_PG_HDRM_COUNTERm;
   1095     non_dma0->reg = INVALIDr;
   1096     non_dma0->field = PG0_HDRM_COUNTf;
   1097     non_dma0->cname = "PG0_HDRM_CUR";
   1098 
   1099     child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, 0);
   1100     if (child_mem != INVALIDm) {
   1101         num_entries = soc_mem_index_count(unit, child_mem);
   1102         entry_words = soc_mem_entry_words(unit, child_mem);
   1103         non_dma0->num_entries = _TH3_PIPES_PER_DEV * num_entries;
   1104 
   1105         for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
   1106             child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, pipe);
   1107             non_dma0->dma_mem[pipe] = child_mem;
   1108             non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
   1109             non_dma0->dma_index_max[pipe] =
   1110                 soc_mem_index_max(unit, child_mem);
   1111             non_dma0->dma_index_min[pipe] =
   1112                 soc_mem_index_min(unit, child_mem);
   1113             non_dma0->dma_num_entries[pipe] = num_entries;
   1114         }
   1115         *non_dma_entries += non_dma0->num_entries;
   1116     } else {
   1117         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1118     }
   1119 
   1120     /* SOC_COUNTER_NON_DMA_PG1_HDRM_CURRENT */
   1121     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG1_HDRM_CURRENT -
   1122                                      SOC_COUNTER_NON_DMA_START];
   1123     *non_dma1 = *non_dma0;
   1124     non_dma1->id = SOC_COUNTER_NON_DMA_PG1_HDRM_CURRENT;
   1125     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
   1126                       _SOC_COUNTER_NON_DMA_CURRENT;
   1127     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1128     non_dma1->field = PG1_HDRM_COUNTf;
   1129     non_dma1->cname = "PG1_HDRM_CUR";
   1130     *non_dma_entries += non_dma1->num_entries;
   1131 
   1132     /* SOC_COUNTER_NON_DMA_PG2_HDRM_CURRENT */
   1133     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG2_HDRM_CURRENT -
   1134                                      SOC_COUNTER_NON_DMA_START];
   1135     *non_dma2 = *non_dma1;
   1136     non_dma2->id = SOC_COUNTER_NON_DMA_PG2_HDRM_CURRENT;
   1137     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1138     non_dma2->field = PG2_HDRM_COUNTf;
   1139     non_dma2->cname = "PG2_HDRM_CUR";
   1140     *non_dma_entries += non_dma2->num_entries;
   1141 
   1142     /* SOC_COUNTER_NON_DMA_PG3_HDRM_CURRENT */
   1143     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG3_HDRM_CURRENT -
   1144                                      SOC_COUNTER_NON_DMA_START];
   1145     *non_dma2 = *non_dma1;
   1146     non_dma2->id = SOC_COUNTER_NON_DMA_PG3_HDRM_CURRENT;
   1147     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1148     non_dma2->field = PG3_HDRM_COUNTf;
   1149     non_dma2->cname = "PG3_HDRM_CUR";
   1150     *non_dma_entries += non_dma2->num_entries;
   1151 
   1152     /* SOC_COUNTER_NON_DMA_PG4_HDRM_CURRENT */
   1153     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG4_HDRM_CURRENT -
   1154                                      SOC_COUNTER_NON_DMA_START];
   1155     *non_dma2 = *non_dma1;
   1156     non_dma2->id = SOC_COUNTER_NON_DMA_PG4_HDRM_CURRENT;
   1157     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1158     non_dma2->field = PG4_HDRM_COUNTf;
   1159     non_dma2->cname = "PG4_HDRM_CUR";
   1160     *non_dma_entries += non_dma2->num_entries;
   1161 
   1162     /* SOC_COUNTER_NON_DMA_PG5_HDRM_CURRENT */
   1163     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG5_HDRM_CURRENT -
   1164                                      SOC_COUNTER_NON_DMA_START];
   1165     *non_dma2 = *non_dma1;
   1166     non_dma2->id = SOC_COUNTER_NON_DMA_PG5_HDRM_CURRENT;
   1167     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1168     non_dma2->field = PG5_HDRM_COUNTf;
   1169     non_dma2->cname = "PG5_HDRM_CUR";
   1170     *non_dma_entries += non_dma2->num_entries;
   1171 
   1172     /* SOC_COUNTER_NON_DMA_PG6_HDRM_CURRENT */
   1173     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG6_HDRM_CURRENT -
   1174                                      SOC_COUNTER_NON_DMA_START];
   1175     *non_dma2 = *non_dma1;
   1176     non_dma2->id = SOC_COUNTER_NON_DMA_PG6_HDRM_CURRENT;
   1177     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1178     non_dma2->field = PG6_HDRM_COUNTf;
   1179     non_dma2->cname = "PG6_HDRM_CUR";
   1180     *non_dma_entries += non_dma2->num_entries;
   1181 
   1182     /* SOC_COUNTER_NON_DMA_PG7_HDRM_CURRENT */
   1183     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PG7_HDRM_CURRENT -
   1184                                      SOC_COUNTER_NON_DMA_START];
   1185     *non_dma2 = *non_dma1;
   1186     non_dma2->id = SOC_COUNTER_NON_DMA_PG7_HDRM_CURRENT;
   1187     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1188     non_dma2->field = PG7_HDRM_COUNTf;
   1189     non_dma2->cname = "PG7_HDRM_CUR";
   1190     *non_dma_entries += non_dma2->num_entries;
   1191 
   1192     /* SOC_COUNTER_NON_DMA_SP0_CURRENT */
   1193     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_SP0_CURRENT -
   1194                                      SOC_COUNTER_NON_DMA_START];
   1195     non_dma0->id = SOC_COUNTER_NON_DMA_SP0_CURRENT;
   1196     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1197                       _SOC_COUNTER_NON_DMA_DO_DMA |
   1198                       _SOC_COUNTER_NON_DMA_CURRENT;
   1199     non_dma0->pbmp = PBMP_ALL(unit);
   1200     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1201     non_dma0->entries_per_port = 1;
   1202     non_dma0->mem = MMU_THDI_PORTSP_COUNTERm;
   1203     non_dma0->reg = INVALIDr;
   1204     non_dma0->field = PORTSP0_SHARED_COUNTf;
   1205     non_dma0->cname = "SP0_CUR";
   1206 
   1207     child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, 0);
   1208     if (child_mem != INVALIDm) {
   1209         num_entries = soc_mem_index_count(unit, child_mem);
   1210         entry_words = soc_mem_entry_words(unit, child_mem);
   1211         non_dma0->num_entries = _TH3_PIPES_PER_DEV * num_entries;
   1212 
   1213         for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
   1214             child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, pipe);
   1215             non_dma0->dma_mem[pipe] = child_mem;
   1216             non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
   1217             non_dma0->dma_index_max[pipe] =
   1218                 soc_mem_index_max(unit, child_mem);
   1219             non_dma0->dma_index_min[pipe] =
   1220                 soc_mem_index_min(unit, child_mem);
   1221             non_dma0->dma_num_entries[pipe] = num_entries;
   1222         }
   1223         *non_dma_entries += non_dma0->num_entries;
   1224     } else {
   1225         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1226     }
   1227 
   1228     /* SOC_COUNTER_NON_DMA_SP1_CURRENT */
   1229     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_SP1_CURRENT -
   1230                                      SOC_COUNTER_NON_DMA_START];
   1231     *non_dma1 = *non_dma0;
   1232     non_dma1->id = SOC_COUNTER_NON_DMA_SP1_CURRENT;
   1233     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
   1234                       _SOC_COUNTER_NON_DMA_CURRENT;
   1235     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1236     non_dma1->field = PORTSP1_SHARED_COUNTf;
   1237     non_dma1->cname = "SP1_CUR";
   1238     *non_dma_entries += non_dma1->num_entries;
   1239 
   1240     /* SOC_COUNTER_NON_DMA_SP2_CURRENT  */
   1241     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_SP2_CURRENT  -
   1242                                      SOC_COUNTER_NON_DMA_START];
   1243     *non_dma2 = *non_dma1;
   1244     non_dma2->id = SOC_COUNTER_NON_DMA_SP2_CURRENT;
   1245     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1246     non_dma2->field = PORTSP2_SHARED_COUNTf;
   1247     non_dma2->cname = "SP2_CUR";
   1248     *non_dma_entries += non_dma2->num_entries;
   1249 
   1250     /* SOC_COUNTER_NON_DMA_SP3_CURRENT  */
   1251     non_dma2 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_SP3_CURRENT  -
   1252                                      SOC_COUNTER_NON_DMA_START];
   1253     *non_dma2 = *non_dma1;
   1254     non_dma2->id = SOC_COUNTER_NON_DMA_SP3_CURRENT;
   1255     non_dma2->base_index = non_dma_start_index + *non_dma_entries;
   1256     non_dma2->field = PORTSP3_SHARED_COUNTf;
   1257     non_dma2->cname = "SP3_CUR";
   1258     *non_dma_entries += non_dma2->num_entries;
   1259 
   1260     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_ING */
   1261     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_ING -
   1262                                      SOC_COUNTER_NON_DMA_START];
   1263     non_dma0->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_ING;
   1264     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1265                       _SOC_COUNTER_NON_DMA_DO_DMA;
   1266     non_dma0->pbmp = PBMP_ALL(unit);
   1267     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1268     non_dma0->entries_per_port = 1; /* 48 for cpu port */
   1269     non_dma0->mem = MMU_THDO_SRC_PORT_DROP_COUNTm;
   1270     non_dma0->reg = INVALIDr;
   1271     non_dma0->field = SRC_PORT_PACKET_TOTAL_DROPf;
   1272     non_dma0->cname = "DROP_PKT_ING";
   1273 
   1274     child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, 0);
   1275     if (child_mem != INVALIDm) {
   1276         num_entries = soc_mem_index_count(unit, child_mem);
   1277         entry_words = soc_mem_entry_words(unit, child_mem);
   1278         non_dma0->num_entries = _TH3_PIPES_PER_DEV * num_entries;
   1279 
   1280         for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
   1281             child_mem = SOC_MEM_UNIQUE_ACC_PIPE(unit, non_dma0->mem, pipe);
   1282             non_dma0->dma_mem[pipe] = child_mem;
   1283             non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
   1284             non_dma0->dma_index_max[pipe] =
   1285                 soc_mem_index_max(unit, child_mem);
   1286             non_dma0->dma_index_min[pipe] =
   1287                 soc_mem_index_min(unit, child_mem);
   1288             non_dma0->dma_num_entries[pipe] = num_entries;
   1289         }
   1290         *non_dma_entries += non_dma0->num_entries;
   1291     } else {
   1292         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1293     }
   1294 
   1295     /* SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT */
   1296     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT -
   1297                                      SOC_COUNTER_NON_DMA_START];
   1298     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1299                       _SOC_COUNTER_NON_DMA_DO_DMA;
   1300     non_dma0->id = SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT;
   1301     SOC_PBMP_CLEAR(non_dma0->pbmp);
   1302     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1303     non_dma0->pbmp = PBMP_ALL(unit);
   1304     non_dma0->entries_per_port = 0;
   1305     non_dma0->mem = INVALIDm;
   1306     non_dma0->reg = MMU_THDR_QE_DROP_COUNT_PKT_PRIQr;
   1307     non_dma0->field = PKT_COUNTf;
   1308     non_dma0->num_entries = SOC_REG_NUMELS(unit, non_dma0->reg) * NUM_ITM(unit);
   1309     non_dma0->cname = "PRIQ_DROP_PKT";
   1310     non_dma0->dma_buf[0] = buf;
   1311     *non_dma_entries += non_dma0->num_entries;
   1312 
   1313     /* SOC_COUNTER_NON_DMA_PRIQ_DROP_BYTE */
   1314     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PRIQ_DROP_BYTE -
   1315                                      SOC_COUNTER_NON_DMA_START];
   1316     *non_dma1 = *non_dma0;
   1317     non_dma1->id = SOC_COUNTER_NON_DMA_PRIQ_DROP_BYTE;
   1318     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1319     non_dma1->reg = MMU_THDR_QE_DROP_COUNT_BYTE_PRIQr;
   1320     non_dma1->field = BYTE_COUNTf;
   1321     non_dma1->num_entries = SOC_REG_NUMELS(unit, non_dma1->reg) * NUM_ITM(unit);
   1322     non_dma1->cname = "PRIQ_DROP_BYTE";
   1323     *non_dma_entries += non_dma1->num_entries;
   1324 
   1325     /* SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT_YELLOW */
   1326     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT_YELLOW -
   1327                                      SOC_COUNTER_NON_DMA_START];
   1328     *non_dma1 = *non_dma0;
   1329     non_dma1->id = SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT_YELLOW;
   1330     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1331     non_dma1->reg = MMU_THDR_QE_DROP_COUNT_YELLOW_PKT_PRIQr;
   1332     non_dma1->field = PKT_COUNTf;
   1333     non_dma1->num_entries = SOC_REG_NUMELS(unit, non_dma1->reg) * NUM_ITM(unit);
   1334     non_dma1->cname = "PRIQ_DROP_PKT_YEL";
   1335     *non_dma_entries += non_dma1->num_entries;
   1336 
   1337     /* SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT_RED */
   1338     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT_RED -
   1339                                      SOC_COUNTER_NON_DMA_START];
   1340     *non_dma1 = *non_dma0;
   1341     non_dma1->id = SOC_COUNTER_NON_DMA_PRIQ_DROP_PKT_RED;
   1342     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1343     non_dma1->reg = MMU_THDR_QE_DROP_COUNT_RED_PKT_PRIQr;
   1344     non_dma1->field = PKT_COUNTf;
   1345     non_dma1->num_entries = SOC_REG_NUMELS(unit, non_dma1->reg) * NUM_ITM(unit);
   1346     non_dma1->cname = "PRIQ_DROP_PKT_RED";
   1347     *non_dma_entries += non_dma1->num_entries;
   1348 
   1349     /* SOC_COUNTER_NON_DMA_HDRM_POOL_DROP_PKT */
   1350     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_HDRM_POOL_DROP_PKT -
   1351                                      SOC_COUNTER_NON_DMA_START];
   1352     *non_dma1 = *non_dma0;
   1353     non_dma1->id = SOC_COUNTER_NON_DMA_HDRM_POOL_DROP_PKT;
   1354     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1355     non_dma1->reg = MMU_THDI_POOL_DROP_COUNT_HPr;
   1356     non_dma1->field = PACKET_DROP_COUNTf;
   1357     non_dma1->num_entries = SOC_REG_NUMELS(unit, non_dma1->reg) * NUM_ITM(unit);
   1358     non_dma1->cname = "HDRM_POOL_DROP_PKT";
   1359     *non_dma_entries += non_dma1->num_entries;
   1360 
   1361     /* SOC_COUNTER_NON_DMA_ING_FLEX_PKT */
   1362     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_ING_FLEX_PKT -
   1363                                      SOC_COUNTER_NON_DMA_START];
   1364     non_dma0->id = SOC_COUNTER_NON_DMA_ING_FLEX_PKT;
   1365     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1366                       _SOC_COUNTER_NON_DMA_DO_DMA |
   1367                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1368     non_dma0->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
   1369     non_dma0->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1370     SOC_PBMP_CLEAR(non_dma0->pbmp);
   1371     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1372     non_dma0->entries_per_port = 0;
   1373     pool_count = 20;
   1374     non_dma0->num_entries =
   1375         pool_count * _TH3_PIPES_PER_DEV *
   1376                         soc_mem_index_count(unit, ING_FLEX_CTR_COUNTER_TABLE_0m);
   1377     non_dma0->mem = ING_FLEX_CTR_COUNTER_TABLE_0m;
   1378     non_dma0->reg = INVALIDr;
   1379     non_dma0->field = PACKET_COUNTERf;
   1380     non_dma0->cname = "ING_FLEX_PKT";
   1381 
   1382     num_entries = soc_mem_index_count(unit, ING_FLEX_CTR_COUNTER_TABLE_0m);
   1383     entry_words = soc_mem_entry_words(unit, ING_FLEX_CTR_COUNTER_TABLE_0m);
   1384     for (pipe = 0; pipe <_TH3_PIPES_PER_DEV; pipe++) {
   1385         non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
   1386     }
   1387     non_dma0->extra_ctr_ct = pool_count;
   1388     /* Incl. buffer for BYTE_CTR. 2x alloc size*/
   1389     alloc_size = (non_dma0->extra_ctr_ct << 1) * sizeof(soc_counter_non_dma_t);
   1390     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_ing_flex");
   1391 
   1392     if (non_dma0->extra_ctrs == NULL) {
   1393         non_dma0->extra_ctr_ct = 0;
   1394         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1395         return SOC_E_MEMORY;
   1396     } else {
   1397         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
   1398         rv = soc_counter_th_extra_ctrs_init(unit, SOC_COUNTER_NON_DMA_ING_FLEX_PKT,
   1399                                             non_dma0,
   1400                                             non_dma0->extra_ctrs,
   1401                                             non_dma0->extra_ctr_ct,
   1402                                             &num_extra_ctr_entries);
   1403         if (rv != SOC_E_NONE) {
   1404             LOG_WARN(BSL_LS_SOC_COUNTER,
   1405                 (BSL_META_U(unit, "ERR: Extra ctrs Init FAILED for id %d\n"),
   1406                             SOC_COUNTER_NON_DMA_ING_FLEX_PKT -
   1407                             SOC_COUNTER_NON_DMA_START));
   1408         }
   1409         non_dma0->num_entries = num_extra_ctr_entries;
   1410     }
   1411     *non_dma_entries += non_dma0->num_entries;
   1412 
   1413     /* SOC_COUNTER_NON_DMA_ING_FLEX_BYTE */
   1414     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_ING_FLEX_BYTE -
   1415                                      SOC_COUNTER_NON_DMA_START];
   1416     *non_dma1 = *non_dma0;
   1417     non_dma1->id = SOC_COUNTER_NON_DMA_ING_FLEX_BYTE;
   1418     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
   1419                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1420     non_dma1->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
   1421     non_dma1->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1422     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1423     non_dma1->field = BYTE_COUNTERf;
   1424     non_dma1->cname = "ING_FLEX_BYTE";
   1425     non_dma1->extra_ctr_ct = pool_count; /* Taken care by PKT_CTR */
   1426     non_dma1->extra_ctrs = non_dma0->extra_ctrs + 1;
   1427     if (non_dma0->extra_ctrs)
   1428     {
   1429         rv = soc_counter_th_extra_ctrs_init(unit,
   1430                                             SOC_COUNTER_NON_DMA_ING_FLEX_BYTE,
   1431                                             non_dma1,
   1432                                             non_dma1->extra_ctrs,
   1433                                             non_dma1->extra_ctr_ct,
   1434                                             &num_extra_ctr_entries);
   1435         if (rv != SOC_E_NONE) {
   1436             LOG_WARN(BSL_LS_SOC_COUNTER,
   1437                 (BSL_META_U(unit, "ERR: Extra ctrs Init FAILED for id %d\n"),
   1438                             SOC_COUNTER_NON_DMA_ING_FLEX_BYTE -
   1439                             SOC_COUNTER_NON_DMA_START));
   1440         }
   1441     }
   1442     non_dma1->flags = _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1443     non_dma1->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1444     *non_dma_entries += non_dma1->num_entries;
   1445 
   1446     /* SOC_COUNTER_NON_DMA_EGR_FLEX_PKT */
   1447     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EGR_FLEX_PKT -
   1448                                      SOC_COUNTER_NON_DMA_START];
   1449     non_dma0->id = SOC_COUNTER_NON_DMA_EGR_FLEX_PKT;
   1450     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1451                       _SOC_COUNTER_NON_DMA_DO_DMA |
   1452                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1453     non_dma0->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
   1454     non_dma0->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1455     SOC_PBMP_CLEAR(non_dma0->pbmp);
   1456     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1457     pool_count = 4;
   1458     non_dma0->entries_per_port = 0;
   1459     non_dma0->num_entries =
   1460         pool_count * _TH3_PIPES_PER_DEV *
   1461             soc_mem_index_count(unit, EGR_FLEX_CTR_COUNTER_TABLE_0m);
   1462     non_dma0->mem = EGR_FLEX_CTR_COUNTER_TABLE_0m;
   1463     non_dma0->reg = INVALIDr;
   1464     non_dma0->field = PACKET_COUNTERf;
   1465     non_dma0->cname = "EGR_FLEX_PKT";
   1466 
   1467     num_entries = soc_mem_index_count(unit, EGR_FLEX_CTR_COUNTER_TABLE_0m);
   1468     entry_words = soc_mem_entry_words(unit, EGR_FLEX_CTR_COUNTER_TABLE_0m);
   1469     for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
   1470         non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
   1471     }
   1472     non_dma0->extra_ctr_ct = pool_count;
   1473     /* Incl. buffer for BYTE_CTR. 2x alloc size*/
   1474     alloc_size = (non_dma0->extra_ctr_ct << 1) * sizeof(soc_counter_non_dma_t);
   1475     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_ing_flex");
   1476     if (non_dma0->extra_ctrs == NULL) {
   1477         non_dma0->extra_ctr_ct = 0;
   1478         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1479         return SOC_E_MEMORY;
   1480     } else {
   1481         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
   1482         rv = soc_counter_th_extra_ctrs_init(unit, SOC_COUNTER_NON_DMA_EGR_FLEX_PKT,
   1483                                             non_dma0,
   1484                                             non_dma0->extra_ctrs,
   1485                                             non_dma0->extra_ctr_ct,
   1486                                             &num_extra_ctr_entries);
   1487         if (rv != SOC_E_NONE) {
   1488             LOG_WARN(BSL_LS_SOC_COUNTER,
   1489                 (BSL_META_U(unit, "ERR: Extra ctrs Init FAILED for id %d\n"),
   1490                             SOC_COUNTER_NON_DMA_EGR_FLEX_PKT -
   1491                             SOC_COUNTER_NON_DMA_START));
   1492         }
   1493         non_dma0->num_entries = num_extra_ctr_entries;
   1494     }
   1495     *non_dma_entries += non_dma0->num_entries;
   1496 
   1497     /* SOC_COUNTER_NON_DMA_EGR_FLEX_BYTE */
   1498     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EGR_FLEX_BYTE -
   1499                                      SOC_COUNTER_NON_DMA_START];
   1500     *non_dma1 = *non_dma0;
   1501     non_dma1->id = SOC_COUNTER_NON_DMA_EGR_FLEX_BYTE;
   1502     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID |
   1503                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1504     non_dma1->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
   1505     non_dma1->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1506     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1507     non_dma1->field = BYTE_COUNTERf;
   1508     non_dma1->cname = "EGR_FLEX_BYTE";
   1509     non_dma1->extra_ctr_ct = pool_count; /* Taken care by PKT_CTR */
   1510     non_dma1->extra_ctrs = non_dma0->extra_ctrs + 1;
   1511     if (non_dma0->extra_ctrs)
   1512     {
   1513         rv = soc_counter_th_extra_ctrs_init(unit,
   1514                                             SOC_COUNTER_NON_DMA_EGR_FLEX_BYTE,
   1515                                             non_dma1,
   1516                                             non_dma1->extra_ctrs,
   1517                                             non_dma1->extra_ctr_ct,
   1518                                             &num_extra_ctr_entries);
   1519         if (rv != SOC_E_NONE) {
   1520             LOG_WARN(BSL_LS_SOC_COUNTER,
   1521                 (BSL_META_U(unit, "ERR: Extra ctrs Init FAILED for id %d\n"),
   1522                             SOC_COUNTER_NON_DMA_EGR_FLEX_BYTE -
   1523                             SOC_COUNTER_NON_DMA_START));
   1524         }
   1525     }
   1526     non_dma1->flags = _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1527     non_dma1->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1528     *non_dma_entries += non_dma1->num_entries;
   1529 
   1530     /* SOC_COUNTER_NON_DMA_EFP_PKT */
   1531     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EFP_PKT -
   1532                                      SOC_COUNTER_NON_DMA_START];
   1533     non_dma0->id = SOC_COUNTER_NON_DMA_EFP_PKT;
   1534     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1535                       _SOC_COUNTER_NON_DMA_DO_DMA;
   1536     non_dma0->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
   1537     non_dma0->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1538     SOC_PBMP_CLEAR(non_dma0->pbmp);
   1539     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1540     non_dma0->entries_per_port = 0;
   1541     non_dma0->num_entries =
   1542         _TH3_PIPES_PER_DEV * soc_mem_index_count(unit, EFP_COUNTER_TABLEm);
   1543     non_dma0->mem = EFP_COUNTER_TABLEm;
   1544     non_dma0->reg = INVALIDr;
   1545     non_dma0->field = PACKET_COUNTERf;
   1546     non_dma0->cname = "EFP_PKT";
   1547 
   1548     num_entries = soc_mem_index_count(unit, EFP_COUNTER_TABLEm);
   1549     entry_words = soc_mem_entry_words(unit, EFP_COUNTER_TABLEm);
   1550     for (pipe = 0; pipe < _TH3_PIPES_PER_DEV; pipe++) {
   1551         non_dma0->dma_mem[pipe] =
   1552             SOC_MEM_UNIQUE_ACC(unit, non_dma0->mem)[pipe];
   1553         non_dma0->dma_buf[pipe] = &buf[num_entries * entry_words * pipe];
   1554         non_dma0->dma_index_max[pipe] =
   1555             soc_mem_index_max(unit, non_dma0->dma_mem[pipe]);
   1556         non_dma0->dma_num_entries[pipe] =
   1557             soc_mem_index_count(unit, non_dma0->dma_mem[0]);
   1558     }
   1559     *non_dma_entries += non_dma0->num_entries;
   1560 
   1561     /* SOC_COUNTER_NON_DMA_EFP_BYTE */
   1562     non_dma1 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_EFP_BYTE -
   1563                                      SOC_COUNTER_NON_DMA_START];
   1564     *non_dma1 = *non_dma0;
   1565     non_dma1->id = SOC_COUNTER_NON_DMA_EFP_BYTE;
   1566     non_dma1->flags = _SOC_COUNTER_NON_DMA_VALID;
   1567     non_dma1->flags |= _SOC_COUNTER_NON_DMA_CTR_EVICT;
   1568     non_dma1->flags |= _SOC_COUNTER_NON_DMA_NO_SHOW_C;
   1569 
   1570     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1571     non_dma1->field = BYTE_COUNTERf;
   1572     non_dma1->cname = "EFP_BYTE";
   1573     *non_dma_entries += non_dma1->num_entries;
   1574 
   1575     /* cSOC_COUNTER_NON_DMA_SFLOW_ING_PKT */
   1576     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_SFLOW_ING_PKT -
   1577                                      SOC_COUNTER_NON_DMA_START];
   1578     non_dma0->id = SOC_COUNTER_NON_DMA_SFLOW_ING_PKT;
   1579     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID | _SOC_COUNTER_NON_DMA_DO_DMA
   1580                       | _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1581     non_dma0->pbmp = PBMP_PORT_ALL(unit);
   1582     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1583     non_dma0->entries_per_port = 1;
   1584     non_dma0->mem = SFLOW_ING_DATA_SOURCEm;
   1585 
   1586     num_entries = soc_mem_index_count(unit, SFLOW_ING_DATA_SOURCEm);
   1587     entry_words = soc_mem_entry_words(unit, non_dma0->mem);
   1588     non_dma0->num_entries = SOC_SFLOW_CTR_TYPE_COUNT * num_entries;
   1589     non_dma0->reg = INVALIDr;
   1590     non_dma0->cname = "SFLOW_ING_PKT";
   1591     non_dma0->field = SAMPLE_POOLf;
   1592     non_dma0->dma_buf[0] = &buf[0];
   1593     non_dma0->extra_ctr_ct = SOC_SFLOW_CTR_TYPE_COUNT;
   1594     /* Buffer allocated for 2x alloc size. Though 2nd half is NOT used.
   1595      * This memory supports BYTE Count, but not implemented yet. So space
   1596      * reserved.
   1597      */
   1598     alloc_size = (non_dma0->extra_ctr_ct << 1) * sizeof(soc_counter_non_dma_t);
   1599     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_sflow_ing");
   1600 
   1601     /*
   1602      * Below represents how Extra cntrs are arranged
   1603      * for sFlow counters.
   1604      *
   1605      *       --------------------------
   1606      * [0]  |      SAMPLE_POOL [0]     |
   1607      *       --------------------------
   1608      * [1]  |           N/A [0]        |
   1609      *       --------------------------
   1610      * [2]  | SAMPLE_POOL_SNAPSHOT [0] |
   1611      *       --------------------------
   1612      * [3]  |           N/A [0]        |
   1613      *       --------------------------
   1614      * [4]  |      SAMPLE_COUNT [0]    |
   1615      *       --------------------------
   1616      * [5]  |           N/A [0]        |
   1617      *       --------------------------
   1618  */
   1619     if (non_dma0->extra_ctrs == NULL) {
   1620         non_dma0->extra_ctr_ct = 0;
   1621         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1622         return SOC_E_MEMORY;
   1623     } else {
   1624         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
   1625         rv = soc_counter_th3_extra_sflow_ctrs_init(unit,
   1626                                             non_dma0,
   1627                                             non_dma0->extra_ctrs,
   1628                                             non_dma0->extra_ctr_ct,
   1629                                             &num_extra_ctr_entries);
   1630         if (rv != SOC_E_NONE) {
   1631             LOG_WARN(BSL_LS_SOC_COUNTER,
   1632                 (BSL_META_U(unit, "ERR: Extra ctrs Init FAILED for id %d\n"),
   1633                             SOC_COUNTER_NON_DMA_SFLOW_ING_PKT  -
   1634                             SOC_COUNTER_NON_DMA_START));
   1635         }
   1636         non_dma0->num_entries = num_extra_ctr_entries;
   1637     }
   1638     *non_dma_entries += non_dma0->num_entries;
   1639 
   1640     /* SOC_COUNTER_NON_DMA_SFLOW_FLEX_PKT */
   1641     non_dma0 = &soc->counter_non_dma[SOC_COUNTER_NON_DMA_SFLOW_FLEX_PKT -
   1642                                      SOC_COUNTER_NON_DMA_START];
   1643     non_dma0->id = SOC_COUNTER_NON_DMA_SFLOW_FLEX_PKT;
   1644     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID | _SOC_COUNTER_NON_DMA_DO_DMA
   1645                       | _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1646     non_dma0->pbmp = PBMP_PORT_ALL(unit);
   1647     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1648     non_dma0->entries_per_port = 1;
   1649     non_dma0->mem = SFLOW_ING_FLEX_DATA_SOURCEm;
   1650 
   1651     num_entries = soc_mem_index_count(unit, SFLOW_ING_FLEX_DATA_SOURCEm);
   1652     entry_words = soc_mem_entry_words(unit, non_dma0->mem);
   1653     non_dma0->num_entries = SOC_SFLOW_CTR_TYPE_COUNT * num_entries;
   1654     non_dma0->reg = INVALIDr;
   1655     non_dma0->cname = "SFLOW_FLEX_PKT";
   1656     non_dma0->field = SAMPLE_POOLf;
   1657     non_dma0->dma_buf[0] = &buf[0];
   1658     non_dma0->extra_ctr_ct = SOC_SFLOW_CTR_TYPE_COUNT;
   1659 
   1660     /* Buffer allocated for 2x alloc size. Though 2nd half is NOT used.
   1661      * This memory supports BYTE Count, but not implemented yet. So space
   1662      * reserved.
   1663      */
   1664     alloc_size = (non_dma0->extra_ctr_ct << 1) * sizeof(soc_counter_non_dma_t);
   1665     non_dma0->extra_ctrs = sal_alloc(alloc_size, "non_dma_ctrs_sflow_flex");
   1666     if (non_dma0->extra_ctrs == NULL) {
   1667         non_dma0->extra_ctr_ct = 0;
   1668         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1669         return SOC_E_MEMORY;
   1670     } else {
   1671         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
   1672         rv = soc_counter_th3_extra_sflow_ctrs_init(unit,
   1673                                             non_dma0,
   1674                                             non_dma0->extra_ctrs,
   1675                                             non_dma0->extra_ctr_ct,
   1676                                             &num_extra_ctr_entries);
   1677         if (rv != SOC_E_NONE) {
   1678             LOG_WARN(BSL_LS_SOC_COUNTER,
   1679                 (BSL_META_U(unit, "ERR: Extra ctrs Init FAILED for id %d\n"),
   1680                             SOC_COUNTER_NON_DMA_SFLOW_FLEX_PKT -
   1681                             SOC_COUNTER_NON_DMA_START));
   1682         }
   1683         non_dma0->num_entries = num_extra_ctr_entries;
   1684     }
   1685     *non_dma_entries += non_dma0->num_entries;
   1686 
   1687     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSY_LO */
   1688     non_dma0 =
   1689         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSY_LO -
   1690                               SOC_COUNTER_NON_DMA_START];
   1691     non_dma0->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSY_LO;
   1692     non_dma0->base_index = non_dma_start_index + *non_dma_entries;
   1693     non_dma0->reg = IDB_OBM0_LOSSY_LO_PKT_DROP_COUNTr;
   1694     non_dma0->cname = "OBM_LOSSY_LO_DRP_PKT";
   1695     non_dma0->flags = _SOC_COUNTER_NON_DMA_VALID |
   1696                       _SOC_COUNTER_NON_DMA_OBM |
   1697                       _SOC_COUNTER_NON_DMA_SUBSET_PARENT;
   1698     non_dma0->pbmp = PBMP_PORT_ALL(unit);
   1699     non_dma0->entries_per_port = _TH3_PORTS_PER_PBLK;
   1700     non_dma0->num_entries = _TH3_PORTS_PER_PBLK * NUM_PIPE(unit);
   1701     non_dma0->mem = INVALIDm;
   1702     non_dma0->field = COUNTERf;
   1703     non_dma0->dma_buf[0] = buf;
   1704 
   1705     /*
   1706      * Below represents how Extra cntrs are arranged
   1707      * for OBM 0-3 Drop Counters.
   1708      * n = NUM_OBMs (4)
   1709      *
   1710      *   [0]     [2]        [2n-2]
   1711      *  ------  ------     ------
   1712      * |      ||      |...|      |
   1713      * | PKT  || PKT  |...| PKT  |
   1714      * | [0]  || [1]  |...| [n-1]|
   1715      *  ------  ------ ... ------
   1716      * |      ||      |...|      |
   1717      * | BYTE || BYTE |...| BYTE |
   1718      * | [0]  || [1]  |...| [n-1]|
   1719      *  ------  ------     ------
   1720      *   [1]     [3]        [2n-1]
   1721      */
   1722     non_dma0->extra_ctr_ct = _TH3_PBLKS_PER_PIPE;
   1723     alloc_size = (non_dma0->extra_ctr_ct << 1) * sizeof(soc_counter_non_dma_t);
   1724     temp = non_dma0->extra_ctrs = sal_alloc(alloc_size,
   1725                                             "non_dma_ctrs_obm_lossy_lo");
   1726 
   1727     if (non_dma0->extra_ctrs == NULL) {
   1728         non_dma0->extra_ctr_ct = 0;
   1729         non_dma0->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1730         return SOC_E_MEMORY;
   1731     } else {
   1732         sal_memset(non_dma0->extra_ctrs, 0, alloc_size);
   1733         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1734                                                 non_dma0,
   1735                                                 non_dma0->extra_ctrs,
   1736                                                 non_dma0->extra_ctr_ct,
   1737                                                 &num_extra_ctr_entries);
   1738         if (rv != SOC_E_NONE) {
   1739             LOG_CLI((BSL_META_U(unit,
   1740                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1741                         non_dma0->id - SOC_COUNTER_NON_DMA_START));
   1742         }
   1743         non_dma0->num_entries = num_extra_ctr_entries;
   1744     }
   1745     *non_dma_entries += non_dma0->num_entries;
   1746 
   1747     /* SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSY_LO */
   1748     non_dma1 =
   1749         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSY_LO -
   1750                               SOC_COUNTER_NON_DMA_START];
   1751     *non_dma1 = *non_dma0;
   1752     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSY_LO;
   1753     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1754     non_dma1->reg = IDB_OBM0_LOSSY_LO_BYTE_DROP_COUNTr;
   1755     non_dma1->field = COUNTERf;
   1756     non_dma1->cname = "OBM_LOSSY_LO_DRP_BYTE";
   1757 
   1758     non_dma1->extra_ctrs = temp + 1;
   1759     if (non_dma1->extra_ctrs) {
   1760         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1761                                                 non_dma1,
   1762                                                 non_dma1->extra_ctrs,
   1763                                                 non_dma1->extra_ctr_ct,
   1764                                                 &num_extra_ctr_entries);
   1765         if (rv != SOC_E_NONE) {
   1766             LOG_CLI((BSL_META_U(unit,
   1767                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1768                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1769         }
   1770     }
   1771     *non_dma_entries += non_dma1->num_entries;
   1772 
   1773     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSY_HI */
   1774     non_dma1 =
   1775         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSY_HI -
   1776                               SOC_COUNTER_NON_DMA_START];
   1777     *non_dma1 = *non_dma0;
   1778     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSY_HI;
   1779     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1780     non_dma1->reg = IDB_OBM0_LOSSY_HI_PKT_DROP_COUNTr;
   1781     non_dma1->cname = "OBM_LOSSY_HI_DRP_PKT";
   1782 
   1783     temp = non_dma1->extra_ctrs = sal_alloc(alloc_size,
   1784                                             "non_dma_ctrs_obm_lossy_hi");
   1785 
   1786     if (non_dma1->extra_ctrs == NULL) {
   1787         non_dma1->extra_ctr_ct = 0;
   1788         non_dma1->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1789         return SOC_E_MEMORY;
   1790     } else {
   1791         sal_memset(non_dma1->extra_ctrs, 0, alloc_size);
   1792         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1793                                                 non_dma1,
   1794                                                 non_dma1->extra_ctrs,
   1795                                                 non_dma1->extra_ctr_ct,
   1796                                                 &num_extra_ctr_entries);
   1797         if (rv != SOC_E_NONE) {
   1798             LOG_CLI((BSL_META_U(unit,
   1799                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1800                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1801         }
   1802         non_dma1->num_entries = num_extra_ctr_entries;
   1803     }
   1804     *non_dma_entries += non_dma1->num_entries;
   1805 
   1806 
   1807     /* SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSY_HI */
   1808     non_dma1 =
   1809         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSY_HI -
   1810                               SOC_COUNTER_NON_DMA_START];
   1811     *non_dma1 = *non_dma0;
   1812     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSY_HI;
   1813     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1814     non_dma1->reg = IDB_OBM0_LOSSY_HI_BYTE_DROP_COUNTr;
   1815     non_dma1->field = COUNTERf;
   1816     non_dma1->cname = "OBM_LOSSY_HI_DRP_BYTE";
   1817 
   1818     /* Memory for extra ctrs for BYTE_CTRS are done along with PACKET_CTR */
   1819     non_dma1->extra_ctrs = temp + 1;
   1820     if (non_dma1->extra_ctrs) {
   1821         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1822                                                 non_dma1,
   1823                                                 non_dma1->extra_ctrs,
   1824                                                 non_dma1->extra_ctr_ct,
   1825                                             &num_extra_ctr_entries);
   1826         if (rv != SOC_E_NONE) {
   1827             LOG_CLI((BSL_META_U(unit,
   1828                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1829                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1830         }
   1831     }
   1832     *non_dma_entries += non_dma1->num_entries;
   1833 
   1834 
   1835     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSLESS0 */
   1836     non_dma1 =
   1837         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSLESS0 -
   1838                               SOC_COUNTER_NON_DMA_START];
   1839     *non_dma1 = *non_dma0;
   1840     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSLESS0;
   1841     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1842     non_dma1->reg = IDB_OBM0_LOSSLESS0_PKT_DROP_COUNTr;
   1843     non_dma1->cname = "OBM_LOSSLESS0_DRP_PKT";
   1844 
   1845     temp = non_dma1->extra_ctrs = sal_alloc(alloc_size,
   1846                                             "non_dma_ctrs_obm_lossless0");
   1847 
   1848     if (non_dma1->extra_ctrs == NULL) {
   1849         non_dma1->extra_ctr_ct = 0;
   1850         non_dma1->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1851         return SOC_E_MEMORY;
   1852     } else {
   1853         sal_memset(non_dma1->extra_ctrs, 0, alloc_size);
   1854         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1855                                                 non_dma1,
   1856                                                 non_dma1->extra_ctrs,
   1857                                                 non_dma1->extra_ctr_ct,
   1858                                                 &num_extra_ctr_entries);
   1859         if (rv != SOC_E_NONE) {
   1860             LOG_CLI((BSL_META_U(unit,
   1861                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1862                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1863         }
   1864         non_dma1->num_entries = num_extra_ctr_entries;
   1865     }
   1866     *non_dma_entries += non_dma1->num_entries;
   1867 
   1868     /* SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSLESS0 */
   1869     non_dma1 =
   1870         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSLESS0 -
   1871                               SOC_COUNTER_NON_DMA_START];
   1872     *non_dma1 = *non_dma0;
   1873     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSLESS0;
   1874     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1875     non_dma1->reg = IDB_OBM0_LOSSLESS0_BYTE_DROP_COUNTr;
   1876     non_dma1->field = COUNTERf;
   1877     non_dma1->cname = "OBM_LOSSLESS0_DRP_BYTE";
   1878 
   1879     /* Memory for extra ctrs for BYTE_CTRS are done along with PACKET_CTR */
   1880     non_dma1->extra_ctrs = temp + 1;
   1881     if (non_dma1->extra_ctrs) {
   1882         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1883                                                 non_dma1,
   1884                                                 non_dma1->extra_ctrs,
   1885                                                 non_dma1->extra_ctr_ct,
   1886                                                 &num_extra_ctr_entries);
   1887         if (rv != SOC_E_NONE) {
   1888             LOG_CLI((BSL_META_U(unit,
   1889                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1890                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1891         }
   1892     }
   1893     *non_dma_entries += non_dma1->num_entries;
   1894 
   1895     /* SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSLESS1 */
   1896     non_dma1 =
   1897         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSLESS1 -
   1898                               SOC_COUNTER_NON_DMA_START];
   1899     *non_dma1 = *non_dma0;
   1900     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_PKT_OBM_LOSSLESS1;
   1901     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1902     non_dma1->reg = IDB_OBM0_LOSSLESS1_PKT_DROP_COUNTr;
   1903     non_dma1->cname = "OBM_LOSSLESS1_DRP_PKT";
   1904 
   1905     temp = non_dma1->extra_ctrs = sal_alloc(alloc_size,
   1906                                             "non_dma_ctrs_obm_lossless1");
   1907 
   1908     if (non_dma1->extra_ctrs == NULL) {
   1909         non_dma1->extra_ctr_ct = 0;
   1910         non_dma1->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1911         return SOC_E_MEMORY;
   1912     } else {
   1913         sal_memset(non_dma1->extra_ctrs, 0, alloc_size);
   1914         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1915                                                 non_dma1,
   1916                                                 non_dma1->extra_ctrs,
   1917                                                 non_dma1->extra_ctr_ct,
   1918                                                 &num_extra_ctr_entries);
   1919         if (rv != SOC_E_NONE) {
   1920             LOG_CLI((BSL_META_U(unit,
   1921                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1922                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1923         }
   1924         non_dma1->num_entries = num_extra_ctr_entries;
   1925     }
   1926     *non_dma_entries += non_dma1->num_entries;
   1927 
   1928     /* SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSLESS1 */
   1929     non_dma1 =
   1930         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSLESS1 -
   1931                               SOC_COUNTER_NON_DMA_START];
   1932     *non_dma1 = *non_dma0;
   1933     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_DROP_BYTE_OBM_LOSSLESS1;
   1934     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1935     non_dma1->reg = IDB_OBM0_LOSSLESS1_BYTE_DROP_COUNTr;
   1936     non_dma1->field = COUNTERf;
   1937     non_dma1->cname = "OBM_LOSSLESS1_DRP_BYTE";
   1938 
   1939     non_dma1->extra_ctrs = temp + 1;
   1940     if (non_dma1->extra_ctrs) {
   1941         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1942                                                 non_dma1,
   1943                                                 non_dma1->extra_ctrs,
   1944                                                 non_dma1->extra_ctr_ct,
   1945                                                 &num_extra_ctr_entries);
   1946         if (rv != SOC_E_NONE) {
   1947             LOG_CLI((BSL_META_U(unit,
   1948                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1949                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1950         }
   1951     }
   1952     *non_dma_entries += non_dma1->num_entries;
   1953 
   1954     /* SOC_COUNTER_NON_DMA_PORT_OBM_FC_EVENTS */
   1955     non_dma1 =
   1956         &soc->counter_non_dma[SOC_COUNTER_NON_DMA_PORT_OBM_FC_EVENTS -
   1957                               SOC_COUNTER_NON_DMA_START];
   1958     *non_dma1 = *non_dma0;
   1959     non_dma1->id = SOC_COUNTER_NON_DMA_PORT_OBM_FC_EVENTS;
   1960     non_dma1->base_index = non_dma_start_index + *non_dma_entries;
   1961     non_dma1->reg = IDB_OBM0_FLOW_CONTROL_EVENT_COUNTr;
   1962     non_dma1->field = COUNTERf;
   1963     non_dma1->cname = "OBM_FC_EVENTS";
   1964 
   1965     temp = non_dma1->extra_ctrs = sal_alloc(alloc_size,
   1966                                             "non_dma_ctrs_obm_fc");
   1967 
   1968     if (non_dma1->extra_ctrs == NULL) {
   1969         non_dma1->extra_ctr_ct = 0;
   1970         non_dma1->flags &= ~_SOC_COUNTER_NON_DMA_VALID;
   1971         return SOC_E_MEMORY;
   1972     } else {
   1973         sal_memset(non_dma1->extra_ctrs, 0, alloc_size);
   1974         rv = soc_counter_th_extra_obm_ctrs_init(unit,
   1975                                                 non_dma1,
   1976                                                 non_dma1->extra_ctrs,
   1977                                                 non_dma1->extra_ctr_ct,
   1978                                                 &num_extra_ctr_entries);
   1979         if (rv != SOC_E_NONE) {
   1980             LOG_CLI((BSL_META_U(unit,
   1981                                 "ERR: Extra ctrs Init FAILED for id %d\n"),
   1982                      non_dma1->id - SOC_COUNTER_NON_DMA_START));
   1983         }
   1984         non_dma1->num_entries = num_extra_ctr_entries;
   1985     }
   1986     *non_dma_entries += non_dma1->num_entries;
   1987 
   1988 
   1989     /* eviction table init */
   1990     SOC_IF_ERROR_RETURN(soc_counter_tomahawk_eviction_init(unit));
   1991 
   1992     soc_counter_tomahawk_ctr_dma_post_init(unit);
   1993 
   1994     return SOC_E_NONE;
   1995 }
   1996 
   1997 #endif /* BCM_TOMAHAWK3_SUPPORT */