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

field_int.h (220516B)


      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-2020 Broadcom Inc. All rights reserved.
      6  *
      7  * Module: Field Processor APIs
      8  *
      9  * Purpose:
     10  *     'Field Processor' (FP) API for Dune Packet Processor devices
     11  */
     12 #ifndef _DPP_FIELD_INT_H_
     13 #define _DPP_FIELD_INT_H_
     14 
     15 /*
     16  *  This file contains private declarations (private to the field API
     17  *  implementations) that have been moved to here because the module has
     18  *  been split across a few files in order to certain features.
     19  *
     20  *  IT SHOULD NOT BE INCLUDED FROM MODULES OUTSIDE OF FIELD.
     21  */
     22 #include <bcm/stg.h>
     23 #include <bcm/field.h>
     24 #include <shared/idxres_fl.h>
     25 #include <shared/shr_resmgr.h>
     26 #include <bcm_int/dpp/field.h>
     27 #include <soc/dpp/PPD/ppd_api_fp.h>
     28 #include <soc/dpp/PPD/ppd_api_port.h>
     29 #include <soc/dpp/PPD/ppd_api_trap_mgmt.h>
     30 #include <soc/dpp/ARAD/ARAD_PP/arad_pp_dbal.h>
     31 #include <soc/dpp/SAND/Utils/sand_occupation_bitmap.h>
     32 #include <soc/dpp/ARAD/arad_kbp.h>
     33 
     34 /*
     35  * SW_STATE Access
     36  */
     37 #define FIELD_ACCESS  sw_state_access[unit].dpp.bcm.field
     38 
     39 /*
     40  *  Right now, warm boot support for field APIs on DPP devices is a work in
     41  *  progress.  Basically, it is unfinished (backing store space is allocated,
     42  *  writes to backing store are performed, but recovery is not in place).  For
     43  *  testing purposes, it has been included in the branches for builds and
     44  *  validation, to ensure that it does not cause undesirable effects as the
     45  *  work progresses.
     46  *
     47  *  However, since it is unfinished, it merely consumes resources and provides
     48  *  no particular benefit in the field.  It should therefore remain disabled,
     49  *  so _BCM_DPP_FIELD_WARM_BOOT_SUPPORT should be set to FALSE.
     50  */
     51 #define _BCM_DPP_FIELD_WARM_BOOT_SUPPORT TRUE
     52 
     53 /******************************************************************************
     54  *
     55  *  Exports to submodules (see field module for code comments)
     56  */
     57 
     58 /*
     59  *  _DPP_PETRA_FIELD_PAGE_WIDTH specifies how wide the console should be for
     60  *  certain debugging functions that tend to generate lists (so they can be
     61  *  formatted to make better use of the available console space).  Don't make
     62  *  it more than 16384; use zero if you want no line joining (each element will
     63  *  be on its own line).
     64  */
     65 #define _BCM_DPP_FIELD_PAGE_WIDTH              79
     66 
     67 /*
     68  *  Controls whether certain (perhaps excessively) verbose messages will be
     69  *  emitted by the diagnostics.  These messages are the FIELD_EVERB messages,
     70  *  which will be emitted at VVERB level if enabled.
     71  */
     72 #define _BCM_DPP_FIELD_EXCESS_VERBOSITY      TRUE
     73 
     74 /*
     75  *  Control whether symbolic flags are included in the dumps.  They're ugly,
     76  *  do not flow properly on the display, but they might be helpful if you
     77  *  don't want to look up the meaning of the bits in the flags fields.
     78  */
     79 #define _BCM_DPP_FIELD_DUMP_SYM_FLAGS        TRUE
     80 
     81 /*
     82  *  Control whether underlying PPD state is included in the unit dump.  This is
     83  *  potentially helpful diagnostics, but maybe confusing?
     84  */
     85 #define _BCM_DPP_FIELD_DUMP_INCLUDE_PPD      TRUE
     86 
     87 /*
     88  *  Dump PPD layer state intermixed with BCM layer state.  This state is taken
     89  *  from the cached values.
     90  */
     91 #define _BCM_DPP_FIELD_DUMP_INTERMIX_PPD     TRUE
     92 
     93 /*
     94  *  Verify PPD layer state when dumping BCM layer state.  This reads back the
     95  *  PPD layer state and compares it to the BCM layer state.  It displays the
     96  *  mismatches if there are any.
     97  *
     98  *  _BCM_DPP_FIELD_DUMP_VERIFY_PPD does not provide particularly useful
     99  *  diagnostics if _BCM_DPP_FIELD_DUMP_INTERMIX_PPD is FALSE, but you can guess
    100  *  by looking up the hardware entry ID later in the PPD layer dump, assuming
    101  *  you have _BCM_DPP_FIELD_DUMP_INCLUDE_PPD set to TRUE.  If both are FALSE,
    102  *  you get a message/error but nothing more.
    103  */
    104 #define _BCM_DPP_FIELD_DUMP_VERIFY_PPD       TRUE
    105 
    106 /*
    107  *  If _BCM_DPP_FIELD_DUMP_VERIFY_PPD is TRUE, setting
    108  *  _BCM_DPP_FIELD_DUMP_VERIFY_ERROR to TRUE will cause the dump functions to
    109  *  return an error (BCM_E_INTERNAL) if there is a mismatch.
    110  *
    111  *  This has no effect if _BCM_DPP_FIELD_DUMP_VERIFY_PPD is FALSE.
    112  */
    113 
    114 #define _BCM_DPP_FIELD_DUMP_VERIFY_ERROR     FALSE
    115 
    116 /*
    117  *  If _BCM_DPP_FIELD_GET_VERIFY_PPD is TRUE, an entry get operation will read
    118  *  the entry from PPD and verify that its values are consistent with the
    119  *  expected values.
    120  *
    121  *  If _BCM_DPP_FIELD_GET_VERIFY_PPD is FALSE, a get operation will only
    122  *  read the cached state and use that (the original behavior).
    123  *
    124  *  This functionality only applies to explicit gets; it does not apply to
    125  *  implied gets (such as setting subset qualifiers) or if a get is not
    126  *  performed (adding a qualifier or action).
    127  *
    128  *  This will reduce performance, since it must read the hardware via PPD layer
    129  *  even when it is accessing something that can be cached.  If an error occurs
    130  *  retrieving the entry from the PPD layer, that error will be returned,
    131  *  instead of using the cached value.
    132  */
    133 #define _BCM_DPP_FIELD_GET_VERIFY_PPD        TRUE
    134 
    135 /*
    136  *  If _BCM_DPP_FIELD_GET_USE_PPD is TRUE, an entry get operation will read the
    137  *  entry from PPD and use the values so retrieved, where possible.
    138  *
    139  *  If _BCM_DPP_FIELD_GET_USE_PPD is FALSE, a get operation will use the cached
    140  *  state to fill in the value to be retrieved.
    141  *
    142  *  Note this only applies where the BCM layer values can be reasonably derived
    143  *  from the PPD layer values.  For example, qualifiers can be extracted thus,
    144  *  but TCAM actions do not map cleanly in both directions, so they will always
    145  *  use the cached values instead.
    146  *
    147  *  This will reduce performance, since it must read the hardware via PPD layer
    148  *  even when it is accessing something that can be cached.  If an error occurs
    149  *  retrieving the entry from the PPD layer, that error will be returned,
    150  *  instead of using the cached value.
    151  */
    152 
    153 #define _BCM_DPP_FIELD_GET_USE_PPD           TRUE
    154 
    155 /*
    156  *  If _BCM_DPP_FIELD_GET_VERIFY_PPD is TRUE, setting
    157  *  _BCM_DPP_FIELD_GET_VERIFY_RETURN_ERROR to TRUE will set the get functions
    158  *  so they return _BCM_DPP_FIELD_GET_VERIFY_ERROR should there be a mismatch
    159  *  between the PPD state and the expected PPD state during a get operation.
    160  *
    161  *  Even if this is FALSE, if _BCM_DPP_FIELD_GET_VERIFY_PPD is TRUE, at least a
    162  *  diagnostic messages will be emitted should there be a mismatch (but
    163  *  diagnostic messages will have to be enabled for it to be shown).
    164  */
    165 
    166 #define _BCM_DPP_FIELD_GET_VERIFY_RETURN_ERROR FALSE
    167 
    168 /*
    169  *  If _BCM_DPP_FIELD_GET_VERIFY_PPD is TRUE, and
    170  *  _BCM_DPP_FIELD_GET_VERIFY_RETURN_ERROR is TRUE, then
    171  *  _BCM_DPP_FIELD_GET_VERIFY_ERROR selects the error code that will be
    172  *  returned on mismatch.
    173  *
    174  *  This has no effect if _BCM_DPP_FIELD_GET_VERIFY_PPD is FALSE, or if
    175  *  _BCM_DPP_FIELD_GET_VERIFY_RETURN_ERROR is FALSE.
    176  *
    177  *  This will not override any other error that occurs.
    178  */
    179 #define _BCM_DPP_FIELD_GET_VERIFY_ERROR      BCM_E_FAIL
    180 
    181 /*
    182  *  Control whether resource map is included in the unit dump.  Should normally
    183  *  be FALSE because it does not honor the prefix argument, but can be useful
    184  *  for some sorts of debugging.
    185  */
    186 #define _BCM_DPP_UNIT_DUMP_INCLUDE_RES_DUMP  TRUE
    187 
    188 /*
    189  *  _BCM_DPP_ALLOW_IMPLIED_ACTION_REPLACE controls whether adding the same
    190  *  action more than once is allowed.  Since Soc_petra only supports one set of
    191  *  values for an action, this would imply a replacement of the old action's
    192  *  parameters with the new action's parameters.  If this is TRUE, and both
    193  *  actions are the same enumeration from bcm_field_ation_t, the parameter
    194  *  values from the new action will replace those from the old action.  If this
    195  *  is FALSE, adding the same enumeration from bcm_field_action_t more than
    196  *  once (without removing the older one) is BCM_E_EXISTS.
    197  */
    198 #define _BCM_DPP_ALLOW_IMPLIED_ACTION_REPLACE TRUE
    199 
    200 /*
    201  *  Control whether the direct extraction code will permit compound actions to
    202  *  be used (but even if enabled, will only use the first action).  Some BCM
    203  *  actions involve more than one action; on TCAM, this is easy to emulate, but
    204  *  for direct extraction, only the first hardware action will be used, and the
    205  *  application must explicitly set up both.
    206  */
    207 #define _BCM_DPP_ALLOW_DIR_EXT_COMPOUND_ACTIONS TRUE
    208 
    209 /*
    210  *  Bias value for IDs of each type of entry.  TCAM entries start with zero;
    211  *  direct extraction entries start with this value; as other entry types get
    212  *  included, their IDs will start with some counting integer times this.
    213  *
    214  *  This is used instead of simply tacking the block into a contiguous number
    215  *  space so that WITH_ID calls can possibly work across different devices.
    216  * 
    217  *  Extend this number to the maximum number of entries in TCAM (internal
    218  *  or external)
    219  */
    220 #define _BCM_DPP_FIELD_ENTRY_TYPE_BIAS(unit)  \
    221     SOC_SAND_MAX(SOC_TMC_TCAM_NL_88650_MAX_NOF_ENTRIES, SOC_DPP_DEFS_MAX_NOF_ENTRY_IDS)
    222 
    223 /*
    224  *  An earlier version of this file exposed the Dune PPD bit numbering at the
    225  *  BCM layer for programmable fields, but that numbering is inconsistent with
    226  *  the standard used in the BCM APIs.  In order to avoid breaking existing
    227  *  applications, this switch controls whether to use the Dune bit numbering
    228  *  for programmable fields (TRUE) or the BCM numbering (FALSE).  It only
    229  *  affects the 'starting bit' number for programmable fields; it does not
    230  *  affect the order of bits within other arguments.
    231  *
    232  *  Dune ordering calls the Most Significant Bit of a byte bit zero, while BCM
    233  *  ordering calls the Most Significant Bit of a byte bit seven.  The binary
    234  *  values of each bit in Dune notation is thus 2^(7-bit_number) while in the
    235  *  BCM notation it is 2^(bit_number), thus:
    236  *
    237  *  Bit value     = 128  64  32  16   8   4   2   1
    238  *  Dune bit num  =   0   1   2   3   4   5   6   7
    239  *  BCM bit num   =   7   6   5   4   3   2   1   0
    240  *
    241  *  The BCM numbering is consistent with Ethernet bit numbering, while the Dune
    242  *  bit numbering seems more visually consistent across bytes:
    243  *
    244  *  Byte         ----------- 0 ----------  ----------- 1 ----------
    245  *  Bit values   128 64 32 16  8  4  2  1  128 64 32 16  8  4  2  1
    246  *  Dune bits      0  1  2  3  4  5  6  7    8  9 10 11 12 13 14 15
    247  *  BCM bits       7  6  5  4  3  2  1  0   15 14 13 12 11 10  9  8
    248  *
    249  *  The result of this is, for example, to get the lower nibble of byte 1 in
    250  *  Dune bit numbering mode requires the programmable field to start at bit 12
    251  *  and run for four bits; to get the same nibble in BCM bit numbering mode
    252  *  requires the field to start at bit 11 and run for four bits.  It's more
    253  *  confusing when spanning bytes.  To get the lower nibble of byte 0 and the
    254  *  upper nibble of byte 1, Dune mode would start at bit 4 and run for eight
    255  *  bits (so including bits 4,5,6,7,8,9,10,11), while BCM mode would start at
    256  *  bit 3 and run for eight bits (so including bits 3,2,1,0,15,14,13,12).  The
    257  *  numbering continues in these manners for further bytes, so byte 3 is bits
    258  *  16..23 or 23..16, byte 4 is bits 24..31 or 31..24, and so on.
    259  *
    260  *  Note that these programmable fields start at the most significant bit of
    261  *  the field in these APIs, no matter this setting.
    262  *
    263  *  Programmable fields specified in byte mode (where applicable) are not
    264  *  affected by this setting: a byte starts with its most significant bit.
    265  *
    266  *  Note that in both cases, bytes are numbered in network order, and in both
    267  *  cases the actual bit values does not change (so the value of a byte is the
    268  *  same no matter the bit order selected).
    269  */
    270 #define _BCM_DPP_FIELD_BIT_NUMBER_AS_DUNE FALSE
    271 
    272 /*
    273  *  I can't think of why you'd want to turn off certain displays, but there
    274  *  is a way to do so here...
    275  */
    276 #define BCM_DPP_FIELD_PRINT 1
    277 
    278 #if defined(BROADCOM_DEBUG) && BCM_DPP_FIELD_PRINT
    279 #include <shared/bsl.h>
    280 #define FIELD_PRINT(stuff) bsl_printf stuff
    281 #else
    282 #define FIELD_PRINT(stuff)
    283 #endif
    284 
    285 
    286 #if (32 != _SHR_PBMP_WORD_WIDTH)
    287 #error PBMP formats are not correct for current PBMP word size
    288 #endif /* (32 != _SHR_PBMP_WORD_WIDTH) */
    289 #if (_SHR_PBMP_WORD_MAX > 1)
    290 #if (_SHR_PBMP_WORD_MAX > 2)
    291 #if (_SHR_PBMP_WORD_MAX > 3)
    292 #if (_SHR_PBMP_WORD_MAX > 4)
    293 #if (_SHR_PBMP_WORD_MAX > 5)
    294 #if (_SHR_PBMP_WORD_MAX > 6)
    295 #if (_SHR_PBMP_WORD_MAX > 7)
    296 #define FIELD_PBMP_FORMAT "%08X %08X %08X %08X %08X %08X %08X %08X"
    297 #define FIELD_PBMP_SHOW(pbmp) \
    298                              _SHR_PBMP_WORD_GET(pbmp,7), \
    299                              _SHR_PBMP_WORD_GET(pbmp,6), \
    300                              _SHR_PBMP_WORD_GET(pbmp,5), \
    301                              _SHR_PBMP_WORD_GET(pbmp,4), \
    302                              _SHR_PBMP_WORD_GET(pbmp,3), \
    303                              _SHR_PBMP_WORD_GET(pbmp,2), \
    304                              _SHR_PBMP_WORD_GET(pbmp,1), \
    305                              _SHR_PBMP_WORD_GET(pbmp,0)
    306 #else /* (_SHR_PBMP_WORD_MAX > 7) */
    307 #define FIELD_PBMP_FORMAT "%08X %08X %08X %08X %08X %08X %08X"
    308 #define FIELD_PBMP_SHOW(pbmp) \
    309                              _SHR_PBMP_WORD_GET(pbmp,6), \
    310                              _SHR_PBMP_WORD_GET(pbmp,5), \
    311                              _SHR_PBMP_WORD_GET(pbmp,4), \
    312                              _SHR_PBMP_WORD_GET(pbmp,3), \
    313                              _SHR_PBMP_WORD_GET(pbmp,2), \
    314                              _SHR_PBMP_WORD_GET(pbmp,1), \
    315                              _SHR_PBMP_WORD_GET(pbmp,0)
    316 #endif /* (_SHR_PBMP_WORD_MAX > 7) */
    317 #else /* (_SHR_PBMP_WORD_MAX > 6) */
    318 #define FIELD_PBMP_FORMAT "%08X %08X %08X %08X %08X %08X"
    319 #define FIELD_PBMP_SHOW(pbmp) \
    320                              _SHR_PBMP_WORD_GET(pbmp,5), \
    321                              _SHR_PBMP_WORD_GET(pbmp,4), \
    322                              _SHR_PBMP_WORD_GET(pbmp,3), \
    323                              _SHR_PBMP_WORD_GET(pbmp,2), \
    324                              _SHR_PBMP_WORD_GET(pbmp,1), \
    325                              _SHR_PBMP_WORD_GET(pbmp,0)
    326 #endif /* (_SHR_PBMP_WORD_MAX > 6) */
    327 #else /* (_SHR_PBMP_WORD_MAX > 5) */
    328 #define FIELD_PBMP_FORMAT "%08X %08X %08X %08X %08X"
    329 #define FIELD_PBMP_SHOW(pbmp) \
    330                              _SHR_PBMP_WORD_GET(pbmp,4), \
    331                              _SHR_PBMP_WORD_GET(pbmp,3), \
    332                              _SHR_PBMP_WORD_GET(pbmp,2), \
    333                              _SHR_PBMP_WORD_GET(pbmp,1), \
    334                              _SHR_PBMP_WORD_GET(pbmp,0)
    335 #endif /* (_SHR_PBMP_WORD_MAX > 5) */
    336 #else /* (_SHR_PBMP_WORD_MAX > 4) */
    337 #define FIELD_PBMP_FORMAT "%08X %08X %08X %08X"
    338 #define FIELD_PBMP_SHOW(pbmp) \
    339                              _SHR_PBMP_WORD_GET(pbmp,3), \
    340                              _SHR_PBMP_WORD_GET(pbmp,2), \
    341                              _SHR_PBMP_WORD_GET(pbmp,1), \
    342                              _SHR_PBMP_WORD_GET(pbmp,0)
    343 #endif /* (_SHR_PBMP_WORD_MAX > 4) */
    344 #else /* (_SHR_PBMP_WORD_MAX > 3) */
    345 #define FIELD_PBMP_FORMAT "%08X %08X %08X"
    346 #define FIELD_PBMP_SHOW(pbmp) \
    347                              _SHR_PBMP_WORD_GET(pbmp,2), \
    348                              _SHR_PBMP_WORD_GET(pbmp,1), \
    349                              _SHR_PBMP_WORD_GET(pbmp,0)
    350 #endif /* (_SHR_PBMP_WORD_MAX > 3) */
    351 #else /* (_SHR_PBMP_WORD_MAX > 2) */
    352 #define FIELD_PBMP_FORMAT "%08X %08X"
    353 #define FIELD_PBMP_SHOW(pbmp) \
    354                              _SHR_PBMP_WORD_GET(pbmp,1), \
    355                              _SHR_PBMP_WORD_GET(pbmp,0)
    356 #endif /* (_SHR_PBMP_WORD_MAX > 2) */
    357 #else /* (_SHR_PBMP_WORD_MAX > 1) */
    358 #define FIELD_PBMP_FORMAT "%08X"
    359 #define FIELD_PBMP_SHOW(pbmp) \
    360                              _SHR_PBMP_WORD_GET(pbmp,0)
    361 #endif /* (_SHR_PBMP_WORD_MAX > 1) */
    362 
    363 #define FIELD_MACA_FORMAT "%02X:%02X:%02X:%02X:%02X:%02X"
    364 #define FIELD_MACA_SHOW(maca) \
    365                              (maca)[0], \
    366                              (maca)[1], \
    367                              (maca)[2], \
    368                              (maca)[3], \
    369                              (maca)[4], \
    370                              (maca)[5]
    371 
    372 
    373 #define FIELD_IPV6A_FORMAT \
    374     "%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X:%02X%02X"
    375 #define FIELD_IPV6A_SHOW(ipv6a) \
    376                   (ipv6a)[0], (ipv6a)[1], \
    377                   (ipv6a)[2], (ipv6a)[3], \
    378                   (ipv6a)[4], (ipv6a)[5], \
    379                   (ipv6a)[6], (ipv6a)[7], \
    380                   (ipv6a)[8], (ipv6a)[9], \
    381                   (ipv6a)[10], (ipv6a)[11], \
    382                   (ipv6a)[12], (ipv6a)[13], \
    383                   (ipv6a)[14], (ipv6a)[15]
    384 
    385 /*
    386  *  Limits...
    387  *
    388  *  _BCM_PETRA_FIELD_PREDEF_KEYS = 'predefined' keys count.  Note this is not
    389  *  the number of predefined keys supported by the device, but the largest
    390  *  number of them supported at BCM layer.
    391  *
    392  *  _BCM_PETRA_FIELD_PRESEL_LIMIT = preselector count
    393  *
    394  *  _BCM_PETRA_FIELD_DQ_LIMIT(_u) = data qualifier count
    395  *
    396  *
    397  *  _BCM_DPP_FIELD_MAX_GROUP_TYPES = maximum number of group types (such as L2,
    398  *  IPv4, IPv6, MPLS)
    399  *
    400  *  _BCM_DPP_FIELD_ACTION_CHAIN_MAX = maximum number of PPD actions that can be
    401  *  used to represent a single BCM layer action.  Specifically, code may need
    402  *  this changed if there are new actions at BCM layer that require more PPD
    403  *  layer actions to implement.
    404  *
    405  *  _BCM_PETRA_FIELD_QUAL_CHAIN_MAX = maximum number of PPD qualifiers that can
    406  *  be used to represent a single BCM layer qualifier.  Specifically, code may
    407  *  need this changed if there are new actions at BCM layer that require more
    408  *  PPD layer actions to implement.
    409  */
    410 #define _BCM_PETRA_FIELD_GROUP_LIMIT(_u) SOC_PPC_FP_NOF_DBS
    411 #define _BCM_PETRA_FIELD_PREDEF_KEYS 3
    412 #define _BCM_PETRA_FIELD_PRESEL_LIMIT(_u) 5
    413 #ifdef BCM_ARAD_SUPPORT
    414 /* support Arad and Soc_petraB */
    415 #if (64 > BCM_FIELD_USER_NUM_UDFS)
    416 #error "BCM_FIELD_USER_NUM_UDFS is too low (must be >= 16)"
    417 #endif /* (10 > BCM_FIELD_USER_NUM_UDFS) */
    418 #define _BCM_PETRA_FIELD_DQ_LIMIT(_u) \
    419     (SOC_PPC_FP_QUAL_HDR_USER_DEF_LAST - SOC_PPC_FP_QUAL_HDR_USER_DEF_0 + 1)
    420 #else
    421 /* support only Soc_petraB */
    422 #if (10 > BCM_FIELD_USER_NUM_UDFS)
    423 #error "BCM_FIELD_USER_NUM_UDFS is too low (must be >= 10)"
    424 #endif /* (10 > BCM_FIELD_USER_NUM_UDFS) */
    425 #define _BCM_PETRA_FIELD_DQ_LIMIT(_u) 0
    426 #endif
    427 #define _BCM_DPP_FIELD_MAX_GROUP_TYPES 4
    428 #define _BCM_DPP_FIELD_ACTION_CHAIN_MAX 2
    429 #define _BCM_DPP_FIELD_QUAL_CHAIN_MAX 2
    430 
    431 /*
    432  *  Error checking -- just to be sure about things
    433  */
    434 #if (31 < _BCM_DPP_FIELD_MAX_GROUP_TYPES)
    435 #error "_BCM_DPP_FIELD_MAX_GROUP_TYPES must be < 32"
    436 #endif /* (31 < _BCM_DPP_FIELD_MAX_GROUP_TYPES) */
    437 
    438 /* maximum number of sub-ranges in a single range */
    439 #define _BCM_DPP_FIELD_RANGE_CHAIN_MAX 2
    440 
    441 /*
    442  *  Send stuff here to drop it
    443  */
    444 #define _BCM_DPP_FIELD_DROP_DEST(unit) (SOC_DPP_CONFIG((unit))->pp.drop_dest)
    445 
    446 /*
    447  *  Indices.  These are declared here rather than using ints because ints can
    448  *  be pretty large when used the way we want to use them, particularly if
    449  *  certain limits are better expressed with more specific size items.
    450  *
    451  *  We can never *quite* fill the type because we use the maximum possible
    452  *  value for the type to indicate NULL (since zero is valid).  Basically this
    453  *  means that if using a byte index, there can be only 255 (0..254) valid
    454  *  values with 255 reserved as an internal NULL value.
    455  */
    456 typedef uint8 _bcm_dpp_field_grp_idx_t;
    457 typedef uint32 _bcm_dpp_field_ent_idx_t;
    458 typedef uint32 _bcm_dpp_field_presel_idx_t;
    459 typedef uint32 _bcm_dpp_field_dq_idx_t;
    460 typedef uint8 _bcm_dpp_field_stage_idx_t;
    461 typedef uint8 _bcm_dpp_field_type_idx_t;
    462 typedef uint8 _bcm_dpp_field_chain_idx_t;
    463 typedef uint8 _bcm_dpp_field_map_idx_t;
    464 typedef uint8 _bcm_dpp_field_range_idx_t;
    465 typedef uint8 _bcm_dpp_field_program_idx_t;
    466 #define _BCM_DPP_FIELD_GROUP_IDX_FORMAT "%8d"
    467 #define _BCM_DPP_FIELD_ENTRY_IDX_FORMAT "%8d"
    468 #define _BCM_DPP_FIELD_STAGE_IDX_FORMAT "%8d"
    469 
    470 /*
    471  *  L4 port range definitions
    472  */
    473 
    474 #define _BCM_DPP_NOF_L4_PORT_RANGES  (24)
    475 
    476 /*
    477  *  Packet length range definitions
    478  */
    479 
    480 #define _BCM_DPP_NOF_PKT_LEN_RANGES (3)
    481 
    482 /*
    483  * Number of local-ports per Device
    484  */
    485 #define _BCM_DPP_NOF_LOCAL_PORTS(unit) (SOC_DPP_DEFS_GET(unit,nof_local_ports))
    486 
    487 #define _BCM_DPP_NOF_PORTS_PER_CORE(unit) (SOC_TMC_NOF_FAP_PORTS_PER_CORE)
    488 
    489 /*
    490  *  Data field definitions
    491  */
    492 
    493 #ifdef BCM_ARAD_SUPPORT
    494 #define _BCM_DPP_NOF_FIELD_DATAS  256 /* hard-coded, since doesn't compile in kernel mode
    495                                         (SOC_PPC_FP_QUAL_HDR_USER_DEF_LAST - SOC_PPC_FP_QUAL_HDR_USER_DEF_0 + 1) */
    496 #else
    497 #define _BCM_DPP_NOF_FIELD_DATAS  (10)
    498 #endif /* def BCM_ARAD_SUPPORT */
    499 typedef SHR_BITDCL _bcm_dpp_field_datafield_bits[_SHR_BITDCLSIZE(_BCM_DPP_NOF_FIELD_DATAS)];
    500 
    501 #ifdef BCM_ARAD_SUPPORT
    502 /* support Arad and Soc_petraB */
    503 #if (_BCM_DPP_NOF_FIELD_DATAS > BCM_FIELD_USER_NUM_UDFS)
    504 #error "BCM_FIELD_USER_NUM_UDFS is too low (must be >= 16)"
    505 #endif /* (10 > BCM_FIELD_USER_NUM_UDFS) */
    506 #define _BCM_PETRA_FIELD_DQ_LIMIT(_u) \
    507     (SOC_PPC_FP_QUAL_HDR_USER_DEF_LAST - SOC_PPC_FP_QUAL_HDR_USER_DEF_0 + 1)
    508 #else
    509 /* support only Soc_petraB */
    510 #if (10 > BCM_FIELD_USER_NUM_UDFS)
    511 #error "BCM_FIELD_USER_NUM_UDFS is too low (must be >= 10)"
    512 #endif /* (10 > BCM_FIELD_USER_NUM_UDFS) */
    513 #define _BCM_PETRA_FIELD_DQ_LIMIT(_u) (0)
    514 #endif
    515 
    516 /*
    517  *  Preselector definitions
    518  */
    519 #ifdef BCM_ARAD_SUPPORT
    520 #define _BCM_DPP_NOF_FIELD_PRESELECTORS SOC_PPC_FP_NOF_PFGS_ARAD
    521 #else /* def BCM_ARAD_SUPPORT */
    522 #define _BCM_DPP_NOF_FIELD_PRESELECTORS     (5)
    523 #endif /* def BCM_ARAD_SUPPORT */
    524 
    525 #define _BCM_DPP_PRESEL_NOF_PORT_PROFILES   (8) /* 8 profiles for both InPort, OutPort and AppType */
    526 
    527 #define _BCM_DPP_PRESEL_ID_INVALID          (-1)
    528 
    529 /*
    530  *  Mapping BCM layer qualifier and action sets to PPD layer.
    531  */
    532 typedef SHR_BITDCL _bcm_dpp_field_qual_set_t[_SHR_BITDCLSIZE(SOC_PPC_NOF_FP_QUAL_TYPES)];
    533 typedef SHR_BITDCL _bcm_dpp_field_action_set_t[_SHR_BITDCLSIZE(SOC_PPC_NOF_FP_ACTION_TYPES)];
    534 /*typedef struct _bcm_dpp_field_qual_set_s {
    535     SHR_BITDCL w[_SHR_BITDCLSIZE(SOC_PPC_NOF_FP_QUAL_TYPES)]; 
    536 } _bcm_dpp_field_qual_set_t;
    537 
    538 typedef struct _bcm_dpp_field_action_set_s {
    539     SHR_BITDCL w[_SHR_BITDCLSIZE(SOC_PPC_NOF_FP_ACTION_TYPES)]; 
    540 } _bcm_dpp_field_action_set_t;*/
    541 
    542 
    543 #define _BCM_DPP_FIELD_DEV_INFO(unit)       _bcm_arad_field_device_info
    544 
    545 #define _BCM_DPP_FIELD_STAGE_DEV_INFO(unit, _stage) \
    546        ((_BCM_DPP_FIELD_DEV_INFO(unit)).stage[_stage])
    547 
    548 /*
    549  *  This describes the entry type that will be used for each mode.
    550  *
    551  *  Note that when automatically choosing the group mode (for
    552  *  bcmFieldGroupModeAuto), only those modes using TCAM type entries will be
    553  *  considered.
    554  *
    555  *  TCAM almost certainly must come first, and be equal to zero.
    556  */
    557 typedef enum _bcm_dpp_field_entry_type_e {
    558     _bcmDppFieldEntryTypeInternalTcam = 0,          /* Standard internal TCAM based entry */
    559     _bcmDppFieldEntryTypeDirLookup = _bcmDppFieldEntryTypeInternalTcam, /* Direct Lookup entry */
    560     _bcmDppFieldEntryTypeDirExt,            /* Direct Extraction entry */
    561     _bcmDppFieldEntryTypeExternalTcam,          /* External TCAM based entry */
    562     _bcmDppFieldEntryTypeCount              /* not a valid type; must be last */
    563 } _bcm_dpp_field_entry_type_t;
    564 
    565 #define _BCM_DPP_FIELD_ENTRY_TYPE_STRINGS \
    566     { \
    567         "TCAM", \
    568         "DirExt" \
    569     }
    570 
    571 #define _BCM_DPP_FIELD_ENT_BIAS(unit, _x) \
    572      (_BCM_DPP_FIELD_ENTRY_TYPE_BIAS(unit) * (_bcmDppFieldEntryType ## _x))
    573 
    574 /* Internal / External TCAM macros */
    575 #define _BCM_DPP_FIELD_ENT_TYPE_IS_INTTCAM(_entryType) \
    576      ((_entryType == _bcmDppFieldEntryTypeInternalTcam)? TRUE: FALSE)
    577 #define _BCM_DPP_FIELD_ENT_TYPE_IS_EXTTCAM(_entryType) \
    578      ((_entryType == _bcmDppFieldEntryTypeExternalTcam)? TRUE: FALSE)
    579 #define _BCM_DPP_FIELD_ENT_TYPE_IS_TCAM(_entryType) \
    580      ((_BCM_DPP_FIELD_ENT_TYPE_IS_INTTCAM(_entryType) || _BCM_DPP_FIELD_ENT_TYPE_IS_EXTTCAM(_entryType))? TRUE: FALSE)
    581 
    582 /* Set/Get External TCAM qualifiers in sw_state. Some devices like Arad, Arad+ and QUX do not have enough memory for storing the entries in the sw_state. */
    583 #define _BCM_DPP_EXT_TCAM_ENTRIES_IN_SW_STATE 0
    584 
    585 int _BCM_DPP_FIELD_ENT_IS_INTTCAM(int unit, int _entry);
    586 int _BCM_DPP_FIELD_ENT_IS_EXTTCAM(int unit, int _entry);
    587 int _BCM_DPP_FIELD_ENT_IS_DIR_EXT(int unit, int _entry);
    588 
    589 #define _BCM_DPP_FIELD_ENT_IS_TCAM(unit, _entry) \
    590      ((_BCM_DPP_FIELD_ENT_IS_INTTCAM(unit, _entry) || _BCM_DPP_FIELD_ENT_IS_EXTTCAM(unit, _entry))? TRUE: FALSE)
    591 
    592 #define _BCM_DPP_FIELD_INTTCAM_LOCAL_ID(unit, _entry) (_entry - _BCM_DPP_FIELD_ENT_BIAS(unit, InternalTcam))
    593 #define _BCM_DPP_FIELD_EXTTCAM_LOCAL_ID(unit, _entry) (_entry - _BCM_DPP_FIELD_ENT_BIAS(unit, ExternalTcam))
    594 #define _BCM_DPP_FIELD_TCAM_LOCAL_ID(unit, _entry) (_BCM_DPP_FIELD_ENT_IS_INTTCAM(unit, _entry)? \
    595     _BCM_DPP_FIELD_INTTCAM_LOCAL_ID(unit, _entry): _BCM_DPP_FIELD_EXTTCAM_LOCAL_ID(unit, _entry))
    596 
    597 #define _BCM_DPP_FIELD_INTTCAM_GLOBAL_ID(unit, _entry) (_entry + _BCM_DPP_FIELD_ENT_BIAS(unit, InternalTcam))
    598 #define _BCM_DPP_FIELD_EXTTCAM_GLOBAL_ID(unit, _entry) (_entry + _BCM_DPP_FIELD_ENT_BIAS(unit, ExternalTcam))
    599 #define _BCM_DPP_FIELD_TCAM_GLOBAL_ID(unit, _entry, isExternalTcam) ((!isExternalTcam)? \
    600     _BCM_DPP_FIELD_INTTCAM_GLOBAL_ID(unit, _entry): _BCM_DPP_FIELD_EXTTCAM_GLOBAL_ID(unit, _entry))
    601 
    602 #define _BCM_DPP_FIELD_TCAM_ENTRY_LIMIT(_entryType) \
    603     ((_entryType == _bcmDppFieldEntryTypeInternalTcam)? FIELD_ACCESS.entryTcLimit.get(unit, &tcam_entry_limit) : FIELD_ACCESS.entryExtTcLimit.get(unit, &tcam_entry_limit))
    604 #define _BCM_DPP_FIELD_TCAM_ENTRY_TC_FREE(_entryType) \
    605     ((_entryType == _bcmDppFieldEntryTypeInternalTcam)? FIELD_ACCESS.entryIntTcFree.get(unit, &next) : FIELD_ACCESS.entryExtTcFree.get(unit, &next));
    606 
    607 #define _BCM_DPP_FIELD_TCAM_ENTRY_TC_COUNT_OPERATION(_entryType, _operation){ \
    608     if  (_entryType == _bcmDppFieldEntryTypeInternalTcam){\
    609           {FIELD_ACCESS.entryIntTcCount.get(unit, &entryIntTcCount);} \
    610           {entryIntTcCount _operation} \
    611           {FIELD_ACCESS.entryIntTcCount.set(unit, entryIntTcCount);}}\
    612     else {{FIELD_ACCESS.entryExtTcCount.get(unit, &entryExtTcCount);} \
    613           {entryExtTcCount _operation} \
    614           {FIELD_ACCESS.entryExtTcCount.set(unit, entryExtTcCount);}}}
    615 
    616 
    617 
    618 
    619 #define _BCM_DPP_FIELD_TCAM_ENTRY_TC_FREE_OPERATION(_entryType, _operation){ \
    620         if ((_entryType == _bcmDppFieldEntryTypeInternalTcam)){\
    621               {FIELD_ACCESS.entryIntTcFree.get(unit, &entryIntTcFree);} \
    622               {entryIntTcFree _operation} \
    623               {FIELD_ACCESS.entryIntTcFree.set(unit, entryIntTcFree);}}\
    624         else {{FIELD_ACCESS.entryExtTcFree.get(unit, &entryExtTcFree);} \
    625               {entryExtTcFree _operation} \
    626               {FIELD_ACCESS.entryExtTcFree.set(unit, entryExtTcFree);}}}
    627 /*
    628  * Depending on '_qual_ndx', get the element
    629  *   entryQual[qual_ndx].qualData
    630  * using
    631  *   FIELD_ACCESS_ENTRYTC.entryCmn.entryQual.qualData.get
    632  *   FIELD_ACCESS_EXTTCAMINFO.entryQual.qualData.get
    633  * See:
    634  *   _BCM_DPP_FIELD_TCAM_ENTRY_QUALS
    635  */
    636 #define _BCM_DPP_FIELD_TCAM_ENTRY_QUALS_QUALDATA_GET(unit,isExternalTcam, _entry, _qual_ndx, qualData) \
    637     { \
    638         if (!isExternalTcam) \
    639         { \
    640             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.entryCmn.entryQual.qualData.get(unit,_entry,_qual_ndx,&qualData)) ; \
    641         } \
    642         else \
    643         { \
    644             uint32 ext_info_idx ; \
    645             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    646             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.entryQual.qualData.get(unit,ext_info_idx,_qual_ndx,&qualData)) ; \
    647         } \
    648     }
    649 /*
    650  * Depending on '_qual_ndx', get the element
    651  *   entryQual[qual_ndx]
    652  * using
    653  *   FIELD_ACCESS_ENTRYTC.entryCmn.entryQual.get
    654  *   FIELD_ACCESS_EXTTCAMINFO.entryQual.get
    655  * See:
    656  *   _BCM_DPP_FIELD_TCAM_ENTRY_QUALS
    657  */
    658 #define _BCM_DPP_FIELD_TCAM_ENTRY_QUALS_GET(unit,isExternalTcam, _entry, _qual_ndx, qual) \
    659     { \
    660         if (!isExternalTcam) \
    661         { \
    662             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.entryCmn.entryQual.get(unit,_entry,_qual_ndx,&qual)) ; \
    663         } \
    664         else \
    665         { \
    666             uint32 ext_info_idx ; \
    667             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    668             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.entryQual.get(unit,ext_info_idx,_qual_ndx,&qual)) ; \
    669         } \
    670     }
    671 /*
    672  * Depending on '_qual_ndx', set the element
    673  *   entryQual[qual_ndx]
    674  * using
    675  *   FIELD_ACCESS_ENTRYTC.entryCmn.entryQual.set
    676  *   FIELD_ACCESS_EXTTCAMINFO.entryQual.set
    677  * See:
    678  *   _BCM_DPP_FIELD_TCAM_ENTRY_QUALS
    679  */
    680 #define _BCM_DPP_FIELD_TCAM_ENTRY_QUALS_SET(unit,isExternalTcam, _entry, _qual_ndx, qual) \
    681     { \
    682         if (!isExternalTcam) \
    683         { \
    684             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.entryCmn.entryQual.set(unit,_entry,_qual_ndx,&qual)) ; \
    685         } \
    686         else \
    687         { \
    688             uint32 ext_info_idx ; \
    689             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    690             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.entryQual.set(unit,ext_info_idx,_qual_ndx,&qual)) ; \
    691         } \
    692     }
    693 
    694 
    695 
    696 #define _BCM_DPP_FIELD_TCAM_ENTRY_QUALS(isExternalTcam, _entry) \
    697     ((!isExternalTcam)? \
    698     unitData->entryTc[_entry].entryCmn.entryQual: \
    699     unitData->extTcamInfo[unitData->entryExtTc[_entry].ext_info_idx].entryQual)
    700 
    701 
    702 /*
    703  * Depending on '_index' and '_entry', get the element
    704  *   tcActP[_index].hwType
    705  * using
    706  *   FIELD_ACCESS_ENTRYTC.tcActP.hwType.get
    707  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.hwType.get
    708  * See:
    709  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    710  */
    711 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_HWTYPE_GET(unit,isExternalTcam, _entry, _index, _hwType) \
    712     { \
    713         if (!isExternalTcam) \
    714         { \
    715             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.hwType.get(unit,_entry,_index,&_hwType)) ; \
    716         } \
    717         else \
    718         { \
    719             uint32 ext_info_idx ; \
    720             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    721             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.hwType.get(unit,ext_info_idx,_index,&_hwType)) ; \
    722         } \
    723     }
    724 /*
    725  * Depending on '_index' and '_entry', set the element
    726  *   tcActP[_index].hwType
    727  * using
    728  *   FIELD_ACCESS_ENTRYTC.tcActP.hwType.set
    729  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.hwType.set
    730  * See:
    731  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    732  */
    733 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_HWTYPE_SET(unit,isExternalTcam, _entry, _index, _hwType) \
    734     { \
    735         if (!isExternalTcam) \
    736         { \
    737             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.hwType.set(unit,_entry,_index,_hwType)) ; \
    738         } \
    739         else \
    740         { \
    741             uint32 ext_info_idx ; \
    742             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    743             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.hwType.set(unit,ext_info_idx,_index,_hwType)) ; \
    744         } \
    745     }
    746 
    747 /*
    748  * Depending on '_index' and '_entry', get the element
    749  *   tcActP[_index].hwParam
    750  * using
    751  *   FIELD_ACCESS_ENTRYTC.tcActP.hwParam.get
    752  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.hwParam.get
    753  * See:
    754  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    755  */
    756 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_HWPARAM_GET(unit,isExternalTcam, _entry, _index, _hwParam) \
    757     { \
    758         if (!isExternalTcam) \
    759         { \
    760             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.hwParam.get(unit,_entry,_index,&_hwParam)) ; \
    761         } \
    762         else \
    763         { \
    764             uint32 ext_info_idx ; \
    765             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    766             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.hwParam.get(unit,ext_info_idx,_index,&_hwParam)) ; \
    767         } \
    768     }
    769 /*
    770  * Depending on '_index' and '_entry', set the element
    771  *   tcActP[_index].hwParam
    772  * using
    773  *   FIELD_ACCESS_ENTRYTC.tcActP.hwParam.set
    774  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.hwParam.set
    775  * See:
    776  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    777  */
    778 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_HWPARAM_SET(unit,isExternalTcam, _entry, _index, _hwParam) \
    779     { \
    780         if (!isExternalTcam) \
    781         { \
    782             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.hwParam.set(unit,_entry,_index,_hwParam)) ; \
    783         } \
    784         else \
    785         { \
    786             uint32 ext_info_idx ; \
    787             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    788             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.hwParam.set(unit,ext_info_idx,_index,_hwParam)) ; \
    789         } \
    790     }
    791 /*
    792  * Depending on '_index' and '_entry', get the element
    793  *   tcActP[_index].hwFlags
    794  * using
    795  *   FIELD_ACCESS_ENTRYTC.tcActP.hwFlags.get
    796  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.hwFlags.get
    797  * See:
    798  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    799  */
    800 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_HWFLAGS_GET(unit,isExternalTcam, _entry, _index, _hwFlags) \
    801     { \
    802         if (!isExternalTcam) \
    803         { \
    804             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.hwFlags.get(unit,_entry,_index,&_hwFlags)) ; \
    805         } \
    806         else \
    807         { \
    808             uint32 ext_info_idx ; \
    809             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    810             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.hwFlags.get(unit,ext_info_idx,_index,&_hwFlags)) ; \
    811         } \
    812     }
    813 /*
    814  * Depending on '_index' and '_entry', set the element
    815  *   tcActP[_index].hwFlags
    816  * using
    817  *   FIELD_ACCESS_ENTRYTC.tcActP.hwFlags.set
    818  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.hwFlags.set
    819  * See:
    820  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    821  */
    822 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_HWFLAGS_SET(unit,isExternalTcam, _entry, _index, _hwFlags) \
    823     { \
    824         if (!isExternalTcam) \
    825         { \
    826             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.hwFlags.set(unit,_entry,_index,_hwFlags)) ; \
    827         } \
    828         else \
    829         { \
    830             uint32 ext_info_idx ; \
    831             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    832             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.hwFlags.set(unit,ext_info_idx,_index,_hwFlags)) ; \
    833         } \
    834     }
    835 
    836 /*
    837  * Depending on '_index' and '_entry', get the element
    838  *   tcActP[_index]
    839  * using
    840  *   FIELD_ACCESS_ENTRYTC.tcActP.get
    841  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.get
    842  * See:
    843  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    844  */
    845 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_GET(unit,isExternalTcam, _entry, _index, _tcActP) \
    846     { \
    847         if (!isExternalTcam) \
    848         { \
    849             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.get(unit,_entry,_index,&_tcActP)) ; \
    850         } \
    851         else \
    852         { \
    853             uint32 ext_info_idx ; \
    854             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    855             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.get(unit,ext_info_idx,_index,&_tcActP)) ; \
    856         } \
    857     }
    858 /*
    859  * Depending on '_index' and '_entry', set the element
    860  *   tcActP[_index]
    861  * using
    862  *   FIELD_ACCESS_ENTRYTC.tcActP.set
    863  *   FIELD_ACCESS_EXTTCAMINFO.tcActP.set
    864  * See:
    865  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTP
    866  */
    867 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP_SET(unit,isExternalTcam, _entry, _index, _tcActP) \
    868     { \
    869         if (!isExternalTcam) \
    870         { \
    871             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActP.set(unit,_entry,_index,&_tcActP)) ; \
    872         } \
    873         else \
    874         { \
    875             uint32 ext_info_idx ; \
    876             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    877             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActP.set(unit,ext_info_idx,_index,&_tcActP)) ; \
    878         } \
    879     }
    880 
    881 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTP(isExternalTcam, _entry) \
    882     ((!isExternalTcam)? \
    883     unitData->entryTc[_entry].tcActP: \
    884     unitData->extTcamInfo[unitData->entryExtTc[_entry].ext_info_idx].tcActP)
    885 
    886 /*
    887  * Depending on '_index' and '_entry', get the element
    888  *   tcActP[_index]
    889  * using
    890  *   FIELD_ACCESS_ENTRYTC.tcActB.get
    891  *   FIELD_ACCESS_EXTTCAMINFO.tcActB.get
    892  * See:
    893  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTB
    894  */
    895 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTB_GET(unit,isExternalTcam, _entry, _index, _tcActB) \
    896     { \
    897         if (!isExternalTcam) \
    898         { \
    899             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActB.get(unit,_entry,_index,&_tcActB)) ; \
    900         } \
    901         else \
    902         { \
    903             uint32 ext_info_idx ; \
    904             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    905             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActB.get(unit,ext_info_idx,_index,&_tcActB)) ; \
    906         } \
    907     }
    908 /*
    909  * Depending on '_index' and '_entry', set the element
    910  *   tcActB[_index]
    911  * using
    912  *   FIELD_ACCESS_ENTRYTC.tcActB.set
    913  *   FIELD_ACCESS_EXTTCAMINFO.tcActB.set
    914  * See:
    915  *   _BCM_DPP_FIELD_TCAM_ENTRY_ACTB
    916  */
    917 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTB_SET(unit,isExternalTcam, _entry, _index, _tcActB) \
    918     { \
    919         if (!isExternalTcam) \
    920         { \
    921             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.tcActB.set(unit,_entry,_index,&_tcActB)) ; \
    922         } \
    923         else \
    924         { \
    925             uint32 ext_info_idx ; \
    926             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    927             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.tcActB.set(unit,ext_info_idx,_index,&_tcActB)) ; \
    928         } \
    929     }
    930 
    931 
    932 #define _BCM_DPP_FIELD_TCAM_ENTRY_ACTB(isExternalTcam, _entry) \
    933     ((!isExternalTcam)? \
    934     unitData->entryTc[_entry].tcActB: \
    935     unitData->extTcamInfo[unitData->entryExtTc[_entry].ext_info_idx].tcActB)
    936 
    937 #define _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY_PTR(isExternalTcam, _entry) \
    938     ((!isExternalTcam) ? \
    939     (&(unitData->entryTc[_entry].entryCmn.entryPriority)): \
    940     (&(unitData->extTcamInfo[unitData->entryExtTc[_entry].ext_info_idx].entryPriority)))
    941 
    942 /*
    943  * Depending on '_entry', get the element
    944  *   entryCmn.entryPriority
    945  * using
    946  *   FIELD_ACCESS_ENTRYTC.entryCmn.entryPriority.get
    947  *   FIELD_ACCESS_EXTTCAMINFO.entryCmn.entryPriority.get
    948  * See:
    949  *   _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY
    950  */
    951 #define _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY_GET(unit,isExternalTcam, _entry, _entryPriority) \
    952     { \
    953         if (!isExternalTcam) \
    954         { \
    955             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.entryCmn.entryPriority.get(unit,_entry,&_entryPriority)) ; \
    956         } \
    957         else \
    958         { \
    959             uint32 ext_info_idx ; \
    960             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    961             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.entryPriority.get(unit,ext_info_idx,&_entryPriority)) ; \
    962         } \
    963     }
    964 /*
    965  * Depending on '_entry', set the element
    966  *   entryCmn.entryPriority
    967  * using
    968  *   FIELD_ACCESS_ENTRYTC.entryCmn.entryPriority.get
    969  *   FIELD_ACCESS_EXTTCAMINFO.entryCmn.entryPriority.get
    970  * See:
    971  *   _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY
    972  */
    973 #define _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY_SET(unit,isExternalTcam, _entry, _entryPriority) \
    974     { \
    975         if (!isExternalTcam) \
    976         { \
    977             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.entryCmn.entryPriority.set(unit,_entry,_entryPriority)) ; \
    978         } \
    979         else \
    980         { \
    981             uint32 ext_info_idx ; \
    982             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
    983             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.entryPriority.set(unit,ext_info_idx,_entryPriority)) ; \
    984         } \
    985     }
    986 
    987 
    988 #define _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY(isExternalTcam, _entry) \
    989     ((!isExternalTcam) ? \
    990     (unitData->entryTc[_entry].entryCmn.entryPriority): \
    991     (unitData->extTcamInfo[unitData->entryExtTc[_entry].ext_info_idx].entryPriority))
    992 
    993 
    994 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_PRIORITY_PTR(isExternalTcam, _entry) \
    995     ((!isExternalTcam) ? \
    996     (&(unitData->entryTc[_entry].entryCmn.hwPriority)): \
    997     (&(unitData->extTcamInfo[unitData->entryExtTc[_entry].ext_info_idx].hwPriority)))
    998 
    999 /*
   1000  * Depending on '_entry', get the element
   1001  *   entryCmn.hwPriority
   1002  * using
   1003  *   FIELD_ACCESS_ENTRYTC.entryCmn.hwPriority.get
   1004  *   FIELD_ACCESS_EXTTCAMINFO.entryCmn.hwPriority.get
   1005  * See:
   1006  *   _BCM_DPP_FIELD_TCAM_ENTRY_HW_PRIORITY
   1007  */
   1008 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_PRIORITY_GET(unit,isExternalTcam, _entry, _hwPriority) \
   1009     { \
   1010         if (!isExternalTcam) \
   1011         { \
   1012             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.entryCmn.hwPriority.get(unit,_entry,&_hwPriority)) ; \
   1013         } \
   1014         else \
   1015         { \
   1016             uint32 ext_info_idx ; \
   1017             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
   1018             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.hwPriority.get(unit,ext_info_idx,&_hwPriority)) ; \
   1019         } \
   1020     }
   1021 /*
   1022  * Depending on '_entry', set the element
   1023  *   entryCmn.hwPriority
   1024  * using
   1025  *   FIELD_ACCESS_ENTRYTC.entryCmn.hwPriority.get
   1026  *   FIELD_ACCESS_EXTTCAMINFO.entryCmn.hwPriority.get
   1027  * See:
   1028  *   _BCM_DPP_FIELD_TCAM_ENTRY_HW_PRIORITY
   1029  */
   1030 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_PRIORITY_SET(unit,isExternalTcam, _entry, _hwPriority) \
   1031     { \
   1032         if (!isExternalTcam) \
   1033         { \
   1034             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYTC.entryCmn.hwPriority.set(unit,_entry,_hwPriority)) ; \
   1035         } \
   1036         else \
   1037         { \
   1038             uint32 ext_info_idx ; \
   1039             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_ENTRYEXTTC.ext_info_idx.get(unit,_entry,&ext_info_idx)) ; \
   1040             BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_EXTTCAMINFO.hwPriority.set(unit,ext_info_idx,_hwPriority)) ; \
   1041         } \
   1042     }
   1043 
   1044 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_PRIORITY(isExternalTcam, _entry) \
   1045     ((!isExternalTcam) ? \
   1046     (unitData->entryTc[_entry].entryCmn.hwPriority): \
   1047     (unitData->extTcamInfo[unitData->entryExtTc[_entry].ext_info_idx].hwPriority))
   1048 
   1049 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_HANDLE_PTR(isExternalTcam, _entry) \
   1050     ((!isExternalTcam) ? (&(unitData->entryTc[_entry].entryCmn.hwHandle)) : (&(unitData->entryExtTc[_entry].entryCmn.hwHandle)))
   1051 
   1052 
   1053 
   1054 /*
   1055  * Depending on '_entry', get the element
   1056  *   entryCmn.hwHandle
   1057  * using
   1058  *   FIELD_ACCESS_ENTRYTC.entryCmn.hwHandle.get
   1059  *   FIELD_ACCESS_EXTTCAMINFO.entryCmn.hwHandle.get
   1060  * See:
   1061  *   _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY
   1062  */
   1063 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_HANDLE_GET(unit,isExternalTcam, _entry, _hwHandle) \
   1064     ((!isExternalTcam) ? \
   1065         FIELD_ACCESS_ENTRYTC.entryCmn.hwHandle.get(unit,_entry,&_hwHandle) : \
   1066         FIELD_ACCESS_ENTRYEXTTC.entryCmn.hwHandle.get(unit,_entry,&_hwHandle)) ;
   1067 
   1068 /*
   1069  * Depending on '_entry', set the element
   1070  *   entryCmn.hwHandle
   1071  * using
   1072  *   FIELD_ACCESS_ENTRYTC.entryCmn.hwHandle.set
   1073  *   FIELD_ACCESS_EXTTCAMINFO.entryCmn.hwHandle.set
   1074  * See:
   1075  *   _BCM_DPP_FIELD_TCAM_ENTRY_PRIORITY
   1076  */
   1077 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_HANDLE_SET(unit,isExternalTcam, _entry, _hwHandle) \
   1078     ((!isExternalTcam) ? \
   1079         FIELD_ACCESS_ENTRYTC.entryCmn.hwHandle.set(unit,_entry,_hwHandle) : \
   1080         FIELD_ACCESS_ENTRYEXTTC.entryCmn.hwHandle.set(unit,_entry,_hwHandle)) 
   1081 
   1082 
   1083 #define _BCM_DPP_FIELD_TCAM_ENTRY_HW_HANDLE(isExternalTcam, _entry) \
   1084     ((!isExternalTcam) ? (unitData->entryTc[_entry].entryCmn.hwHandle) : (unitData->entryExtTc[_entry].entryCmn.hwHandle))
   1085 
   1086 #define _BCM_DPP_FIELD_TCAM_ENTRY_NEXT_PTR(isExternalTcam, _entry) \
   1087     ((!isExternalTcam) ? (&(unitData->entryTc[_entry].entryCmn.entryNext)) : (&(unitData->entryExtTc[_entry].entryCmn.entryNext)))
   1088 
   1089 
   1090 /*
   1091  * get/set 'entryNext' element from Tc/extTc depending on 'isExternalTcam'
   1092  * See _BCM_DPP_FIELD_TCAM_ENTRY_NEXT
   1093  */ 
   1094 #define _BCM_DPP_FIELD_TCAM_ENTRY_NEXT_GET(unit,isExternalTcam, _entry, _entryNext) \
   1095     ((!isExternalTcam) ? \
   1096       FIELD_ACCESS_ENTRYTC.entryCmn.entryNext.get(unit,_entry,&_entryNext) : \
   1097       FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryNext.get(unit,_entry,&_entryNext))
   1098 
   1099 #define _BCM_DPP_FIELD_TCAM_ENTRY_NEXT_SET(unit,isExternalTcam, _entry, _entryNext) \
   1100     ((!isExternalTcam) ? \
   1101       FIELD_ACCESS_ENTRYTC.entryCmn.entryNext.set(unit,_entry,_entryNext) : \
   1102       FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryNext.set(unit,_entry,_entryNext))
   1103 
   1104 
   1105 
   1106 #define _BCM_DPP_FIELD_TCAM_ENTRY_NEXT(isExternalTcam, _entry) \
   1107     ((!isExternalTcam) ? (unitData->entryTc[_entry].entryCmn.entryNext) : (unitData->entryExtTc[_entry].entryCmn.entryNext))
   1108 
   1109 #define _BCM_DPP_FIELD_TCAM_ENTRY_PREV_PTR(isExternalTcam, _entry) \
   1110     ((!isExternalTcam) ? (&(unitData->entryTc[_entry].entryCmn.entryPrev)) : (&(unitData->entryExtTc[_entry].entryCmn.entryPrev)))
   1111 
   1112 
   1113 /*
   1114  * get/set 'entryPrev' element from Tc/extTc depending on 'isExternalTcam'
   1115  * See _BCM_DPP_FIELD_TCAM_ENTRY_PREV
   1116  */ 
   1117 #define _BCM_DPP_FIELD_TCAM_ENTRY_PREV_GET(unit,isExternalTcam, _entry, _entryPrev) \
   1118     ((!isExternalTcam) ? \
   1119       FIELD_ACCESS_ENTRYTC.entryCmn.entryPrev.get(unit,_entry,&_entryPrev) : \
   1120       FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryPrev.get(unit,_entry,&_entryPrev))
   1121 
   1122 #define _BCM_DPP_FIELD_TCAM_ENTRY_PREV_SET(unit,isExternalTcam, _entry, _entryPrev) \
   1123     ((!isExternalTcam) ? \
   1124       FIELD_ACCESS_ENTRYTC.entryCmn.entryPrev.set(unit,_entry,_entryPrev) : \
   1125       FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryPrev.set(unit,_entry,_entryPrev))
   1126 
   1127 
   1128 #define _BCM_DPP_FIELD_TCAM_ENTRY_PREV(isExternalTcam, _entry) \
   1129     ((!isExternalTcam) ? (unitData->entryTc[_entry].entryCmn.entryPrev) : (unitData->entryExtTc[_entry].entryCmn.entryPrev))
   1130 /*
   1131  * get/set 'flags' element from Tc/extTc depending on 'isExternalTcam'
   1132  * See _BCM_DPP_FIELD_TCAM_ENTRY_FLAGS
   1133  */ 
   1134 #define _BCM_DPP_FIELD_TCAM_ENTRY_FLAGS_GET(unit,isExternalTcam, _entry, _flags) \
   1135     ((!isExternalTcam) ? \
   1136       FIELD_ACCESS_ENTRYTC.entryCmn.entryFlags.get(unit,_entry,&_flags) : \
   1137       FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryFlags.get(unit,_entry,&_flags))
   1138 
   1139 #define _BCM_DPP_FIELD_TCAM_ENTRY_FLAGS_SET(unit,isExternalTcam, _entry, _flags) \
   1140     ((!isExternalTcam) ? \
   1141       FIELD_ACCESS_ENTRYTC.entryCmn.entryFlags.set(unit,_entry,_flags) : \
   1142       FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryFlags.set(unit,_entry,_flags))
   1143 
   1144 
   1145 #define _BCM_DPP_FIELD_TCAM_ENTRY_FLAGS_PTR(isExternalTcam, _entry) \
   1146     ((!isExternalTcam) ? (&(unitData->entryTc[_entry].entryCmn.entryFlags)) : (&(unitData->entryExtTc[_entry].entryCmn.entryFlags)))
   1147 
   1148 #define _BCM_DPP_FIELD_TCAM_ENTRY_FLAGS(isExternalTcam, _entry) \
   1149     ((!isExternalTcam) ? (unitData->entryTc[_entry].entryCmn.entryFlags) : (unitData->entryExtTc[_entry].entryCmn.entryFlags))
   1150 
   1151 #define _BCM_DPP_FIELD_TCAM_ENTRY_GROUP_PTR(isExternalTcam, _entry) \
   1152     ((!isExternalTcam) ? (&(unitData->entryTc[_entry].entryCmn.entryGroup)) : (&(unitData->entryExtTc[_entry].entryCmn.entryGroup)))
   1153 
   1154 /*
   1155  * get/set 'entryGroup' element from Tc/extTc depending on 'isExternalTcam'
   1156  * See _BCM_DPP_FIELD_TCAM_ENTRY_GROUP
   1157  */ 
   1158 #define _BCM_DPP_FIELD_TCAM_ENTRY_GROUP_GET(unit,isExternalTcam, _entry, _entryGroup) \
   1159     ((!isExternalTcam) ? \
   1160       (FIELD_ACCESS_ENTRYTC.entryCmn.entryGroup.get(unit,_entry,&_entryGroup)) : \
   1161       (FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryGroup.get(unit,_entry,&_entryGroup)))
   1162 
   1163 #define _BCM_DPP_FIELD_TCAM_ENTRY_GROUP_SET(unit,isExternalTcam, _entry, _entryGroup) \
   1164     ((!isExternalTcam) ? \
   1165       (FIELD_ACCESS_ENTRYTC.entryCmn.entryGroup.set(unit,_entry,_entryGroup)) : \
   1166       (FIELD_ACCESS_ENTRYEXTTC.entryCmn.entryGroup.set(unit,_entry,_entryGroup)))
   1167 
   1168 #define _BCM_DPP_FIELD_TCAM_ENTRY_GROUP(isExternalTcam, _entry) \
   1169     ((!isExternalTcam) ? (unitData->entryTc[_entry].entryCmn.entryGroup) : (unitData->entryExtTc[_entry].entryCmn.entryGroup))
   1170 
   1171 #define _BCM_DPP_FIELD_TCAM_ENTRY(isExternalTcam, _entry) \
   1172     ((!isExternalTcam) ? ((void*)&(unitData->entryTc[_entry])) : ((void*)&(unitData->entryExtTc[_entry])))
   1173 
   1174 #define _BCM_DPP_FIELD_TCAM_ENTRY_SIZE(isExternalTcam) \
   1175     ((!isExternalTcam) ? (sizeof(_bcm_dpp_field_entry_t)) : (sizeof(_bcm_dpp_field_entry_ext_t)))
   1176 
   1177 /*
   1178  *  This describes the profile type when handling bitmap HW profiles:
   1179  *  - in/out-port profiles, - FLP program processing profile
   1180  */
   1181 typedef enum _bcm_dpp_field_profile_type_e {
   1182     _bcmDppFieldProfileTypeInPort = 0,        /* In-Port profile  - mapped to InPort qualifier */
   1183     _bcmDppFieldProfileTypeOutPort,           /* Out-Port profile  - mapped to OutPort qualifier */
   1184     _bcmDppFieldProfileTypeFlpProgramProfile, /* FLP program processing profile - mapped to AppType qualifier */
   1185     _bcmDppFieldProfileTypeInterfaceInPort,
   1186     _bcmDppFieldProfileTypeCount              /* not a valid type; must be last */
   1187 } _bcm_dpp_field_profile_type_t;
   1188 #ifdef BROADCOM_DEBUG
   1189 #endif /* def BROADCOM_DEBUG */
   1190 /*
   1191  * Definitions related to the following APIs:
   1192  *   bcm_petra_field_action_width_get
   1193  *   bcm_petra_field_action_width_set
   1194  */
   1195 /* { */
   1196 /*
   1197  * Number of elements (second index) attached to each action on the tables:
   1198  *
   1199  *   *_pmf_fem_action_type_encoding_runtime[][<second index>]
   1200  *   *_pmf_fem_action_type_encoding[][<second index>]
   1201  * See, for example: Jericho_pmf_fem_action_type_encoding
   1202  */
   1203 #define NUM_ACTION_ELEMENTS                  3
   1204 /*
   1205  * Index, on 'second index', at which the 'width' of each action is stored.
   1206  * 'width' is the number of bits assigned to 'action'.
   1207  * See NUM_ACTION_ELEMENTS above.
   1208  */
   1209 #define INDEX_OF_ACTION_WIDTH                2
   1210 /*
   1211  * Index, on 'second index', at which the 'action id' of each action is stored.
   1212  * Type of this element is, effectively, SOC_PPC_FP_ACTION_TYPE.
   1213  * See NUM_ACTION_ELEMENTS above.
   1214  */
   1215 #define INDEX_OF_ACTION                      0
   1216 /*
   1217  * Index, on 'second index', at which the 'HW id' of each action is stored.
   1218  * This is the hardware identifier of the action.
   1219  * See NUM_ACTION_ELEMENTS above.
   1220  */
   1221 #define INDEX_OF_HW_ID                       1
   1222 /* } */
   1223 /*
   1224  *  There are now multiple flags per qualifier instead of just whether that
   1225  *  qualifier is used for reverse lookup (translation from PPD qualifier into
   1226  *  BCM qualifier).  These are used in the flags field of the qualifier table.
   1227  *  These flags are ORed together if more than one is applicable, but note that
   1228  *  some of them can't be combined (they are noted so in their description).
   1229  *
   1230  *  Because TRUE/FALSE was used before in this field, and most people (probably
   1231  *  most compilers as well) set basic boolean TRUE as 1, we do not use bit 0
   1232  *  for this set of flags.  This allows the startup code to be sure new
   1233  *  qualifiers use this as a flags field instead of as a simple boolean.
   1234  *
   1235  *  NOTE: this is a 32b signed number, and we don't want bit 0 set to avoid
   1236  *  being equal to TRUE.  Basically, this means it should be limited to 30
   1237  *  useful bits, to avoid compiler quirks around bit 31, and to avoid ever
   1238  *  being equal to either of the common values of TRUE (1 and ~0).
   1239  *
   1240  *  _BCM_DPP_QUAL_REVERSE_LOOKUP indicates the qualifier will be used for
   1241  *  reverse lookup (given a PPD layer qualifier, we will use the last BCM
   1242  *  qualifier in the qualifiers table as the mapping).
   1243  *
   1244  *  _BCM_DPP_QUAL_RANGE_BITMAP indicates the qualifier is a range qualifier
   1245  *  implemented as a bitmap, and so more than one of the same range comparison
   1246  *  type can be active on a single entry and the INVERT feature is offered.  It
   1247  *  can not be combined with _BCM_DPP_QUAL_RANGE_INDEX.
   1248  *
   1249  *  _BCM_DPP_QUAL_RANGE_INDEX indicates the qualifier is a range qualifier
   1250  *  implemented as a selector, so only one range per comparison type can be
   1251  *  active on a single entry, and the INVERT feature is not offered.  It can
   1252  *  not be combined with _BCM_DPP_QUAL_RANGE_BITMAP.
   1253  *
   1254  *  _BCM_DPP_QUAL_FLAGS_RNG_VALID_BITS is merely the set of bits that indicate
   1255  *  some format or other of range.
   1256  *
   1257  *  _BCM_DPP_QUAL_FLAGS_ALL_VALID_BITS is merely the set of valid bits.  It
   1258  *  must exactly cover the existing flags.
   1259  */
   1260 #define _BCM_DPP_QUAL_REVERSE_LOOKUP        0x00000002
   1261 #define _BCM_DPP_QUAL_RANGE_BITMAP          0x00000004
   1262 #define _BCM_DPP_QUAL_RANGE_INDEX           0x00000008
   1263 #define _BCM_DPP_QUAL_FLAGS_RNG_VALID_BITS  0x0000000C
   1264 #define _BCM_DPP_QUAL_FLAGS_ALL_VALID_BITS  0x0000000E
   1265 
   1266 /*
   1267  *  The range support is designed with the assumption that ranges are only
   1268  *  applicable to a single stage.
   1269  *
   1270  *  Certain details about a range qualifier are here, but most of these have to
   1271  *  do with how that range qualifier will be exposed.  The format (bitmap or
   1272  *  index) for a given range qualifier is specified in the qualifier table.
   1273  *
   1274  *  The last entry in the table of these must be bcmFieldQualifyCount.
   1275  */
   1276 #define _BCM_DPP_RANGE_MAX_COUNT 64
   1277 typedef struct _bcm_dpp_field_device_range_info_s {
   1278     bcm_field_qualify_t qualifier;          /* qualifier for this range type */
   1279     uint32 rangeFlags;                      /* flags in range definition */
   1280     bcm_field_range_t rangeBase;            /* base ID */
   1281     _bcm_dpp_field_range_idx_t count;       /* number of this range type */
   1282 } _bcm_dpp_field_device_range_info_t;
   1283 
   1284 /*
   1285  *  This describes the number of bits/trits that can be included in a group
   1286  *  mode in a particular stage.  The hardware description employs an array of
   1287  *  these, with the last one (as an end indicator) specifying stage 0, bits 0,
   1288  *  and mode bcmFieldGroupModeCount.
   1289  *
   1290  *  Do not include elements in the array for modes that are not supported on
   1291  *  a given stage, and do not include elements in the array for stages that are
   1292  *  not supported, even if you set the number of bits to zero.
   1293  *
   1294  *  It is obligatory to include at least one mode per stage, plus
   1295  *  bcmFieldGroupModeAuto per stage (with the largest number of bits supported
   1296  *  in any mode for that particular stage).
   1297  *
   1298  *  stage is the stage index.
   1299  *
   1300  *  mode is the bcm_field_group_mode being described for the stage.
   1301  *
   1302  *  length is the number of bits that stage supports in the specified mode.
   1303  *
   1304  *  entryCount is the number of 'single' hardware entries taken by an entry in
   1305  *  a group of this width.
   1306  *
   1307  *  An array of these is built to define the supported group modes and their
   1308  *  respective trit limits
   1309  */
   1310 typedef struct _bcm_dpp_field_device_group_mode_bits_s {
   1311     _bcm_dpp_field_stage_idx_t stage;           /* stage index */
   1312     bcm_field_group_mode_t mode;                /* group mode */
   1313     unsigned int length;                        /* number of bits */
   1314     unsigned int qualLength;                    /* qualifiable num of bits */
   1315     unsigned int entryCount;                    /* number of entries */
   1316     _bcm_dpp_field_entry_type_t entryType;      /* type of entry */
   1317     SOC_PPC_FP_DATABASE_TYPE hwType;            /* hardware database type */
   1318 } _bcm_dpp_field_device_group_mode_bits_t;
   1319 
   1320 /*
   1321  *  This describes limits and sharing properties for a stage.  They are defined
   1322  *  in an array.  Exactly one must be included for each stage as configured in
   1323  *  the hardware description.
   1324  *
   1325  *  name is the name for the stage.
   1326  *
   1327  *  hwStageId is the hardware stage ID for this stage.
   1328  *
   1329  *  flags is the flags that apply to this stage (bitmap).
   1330  *
   1331  *    _BCM_DPP_FIELD_DEV_STAGE_FLAG_IMPLIED_ACTION indicates the stage action
   1332  *    set is small enough that it entirely fits in the resolution buffers, or
   1333  *    that the stage has a fixed action set.  If set, a group created in the
   1334  *    stage will assume a default action set.
   1335  *
   1336  *    _BCM_DPP_FIELD_DEV_STAGE_FLAG_ALLOW_CASCADE indicates the stage allows
   1337  *    cascaded groups.  If set, the cascaded group feature can be configured by
   1338  *    the normal procedure; if clear, cascaded groups are not supported by any
   1339  *    explicit mechanism (groups created by any implied mechanism will be
   1340  *    considered parallel; explicit creation will result in an error).
   1341  *
   1342  *    _BCM_DPP_FIELD_DEV_STAGE_FLAG_ALLOW_TYPE_MERGE indicates the stage allows
   1343  *    a group to be of more than one 'type' (without it, a group can only
   1344  *    include qualifiers from one of L2, IPv4, IPv6, MPLS, but with it, a group
   1345  *    can include qualifiers from combinations of these types, with the
   1346  *    exception that it can not include both IPv4 and IPv6).
   1347  *
   1348  *    _BCM_DPP_FIELD_DEV_STAGE_USES_PRESELECTORS indicates the stage uses
   1349  *    preselectors (if not set, the stage neither uses nor supports them).
   1350  *
   1351  *  maxGroups is the maximum number of groups in the stage.
   1352  *
   1353  *  maxEntriesInternalTcam is the maximum number of internal TCAM entries in the stage.
   1354  *
   1355  *  maxEntriesExternalTcam is the maximum number of external TCAM entries in the stage.
   1356  *
   1357  *  maxEntriesDe is the maximum number of direct extraction entries.
   1358  *
   1359  *  maxProgQuals is the maximum number of programmable qualifiers.
   1360  *
   1361  *  entryMaxQuals is the maximum number of qualifiers for a TCAM entry and the
   1362  *  maximum number of qualifiers in a group's qualifier set.
   1363  *
   1364  *  entryMaxActs is the maximum number of actions for an entry and the maximum
   1365  *  number of actions in a group's action set.
   1366  *
   1367  *  entryDeMaxQuals is the maximum number of qualifiers on a direct extraction
   1368  *  entry (that will be used to qualify the entry; it can still use all of the
   1369  *  qualifier(s) from the group's qualifier set for extractions).
   1370  *
   1371  *  impliedActionSet is TRUE if the stage allows action set to be implied (will
   1372  *  be assumed in this case to be all actions permitted to a group according to
   1373  *  the stage and type).  If impliedActionSet is TRUE, a group will not require
   1374  *  an action set to be configured, but if one is configured, it will be
   1375  *  honored.  If impliedActionSet is FALSE, a group must have an action set
   1376  *  explicitly configured before it can be used.
   1377  *
   1378  *  If this stage does not share hardware group ID space with a previously
   1379  *  defined stage, sharesGroups is -1.  If this stage shares hardware group Id
   1380  *  space with a previously defined stage, sharedGroups is the index of the
   1381  *  most recently defined such stage.
   1382  *
   1383  *  If this stage does not share hardware TCAM entry ID space with a previously
   1384  *  defined stage, sharesEntriesTc is -1.  If this stage shares hardware TCAM
   1385  *  entry ID space with a previously defined stage, sharedEntriesTc is the
   1386  *  index of the most recently defined such stage.
   1387  *
   1388  *  If this stage does not share hardware direct extraction entry ID space with
   1389  *  a previously defined stage, sharesEntriesDe is -1.  If this stage shares
   1390  *  hardware direct extraction entry ID space with a previously defined stage,
   1391  *  sharedEntriesDe is the index of the most recently defined such stage.
   1392  */
   1393 #define _BCM_DPP_FIELD_DEV_STAGE_FLAG_IMPLIED_ACTION   0x00000001
   1394 #define _BCM_DPP_FIELD_DEV_STAGE_FLAG_ALLOW_CASCADE    0x00000002
   1395 #define _BCM_DPP_FIELD_DEV_STAGE_FLAG_ALLOW_TYPE_MERGE 0x00000004
   1396 #define _BCM_DPP_FIELD_DEV_STAGE_USES_PRESELECTORS     0x00000008
   1397 typedef struct _bcm_dpp_field_device_stage_info_s {
   1398     char *stageName;                            /* stage name */
   1399     bcm_field_stage_t bcmStage;                 /* BCM layer stage ID */
   1400     SOC_PPC_FP_DATABASE_STAGE hwStageId;        /* hardware stage ID */
   1401     uint32 stageFlags;                          /* stage flags */
   1402     unsigned int maxGroups;                     /* max groups */
   1403     uint32 maxEntriesInternalTcam;                        /* max internal TCAM entries */
   1404     uint32 maxEntriesExternalTcam;                        /* max external TCAM entries */
   1405     unsigned int maxEntriesDe;                  /* max dir ext entries */
   1406     unsigned int maxProgQuals;                  /* max programmable quals */
   1407     unsigned int entryMaxQuals;                 /* max quals per entry */
   1408     unsigned int entryMaxActs;                  /* max actions per entry */
   1409     unsigned int entryDeMaxQuals;               /* max qualifiers for dir ext */
   1410     int sharesGroups;                           /* HW grp spc sharing */
   1411     int sharesEntriesTc;                        /* HW ent spc sharing */
   1412     int sharesEntriesDe;                        /* HW dir ext ent spc sharing */
   1413 } _bcm_dpp_field_device_stage_info_t;
   1414 
   1415 /*
   1416  *  This describes how a cell in a layer maps to the stage and type.  In each
   1417  *  of the BCM qualifier and action descriptors, there is a set of PPD values.
   1418  *  This set of values consists of one qualifier/action for each possible
   1419  *  element of the longest supported chain, for each of the elements in the
   1420  *  array made of these mapping descriptions.  Each chain set corresponds to
   1421  *  the description at the same offset in the table made from these mapping
   1422  *  descriptors.
   1423  *
   1424  *  stage is the stage index.
   1425  *
   1426  *  type is the group type index.  If the flags value does not include
   1427  *  _BCM_DPP_FIELD_GROUP_PRESEL, this must be a valid type number.  If the
   1428  *  flags value does include _BCM_DPP_FIELD_GROUP_PRESEL, it will be ignored,
   1429  *  and the type thus defined will be used for that stage's preselectors.
   1430  *
   1431  *  predefKey is the predefined key for this group type in this stage, or
   1432  *  SOC_PPC_NOF_FP_PREDEFINED_ACL_KEYS if there is no predefined key.
   1433  *
   1434  *  flags indicates which of the group flags should be set out of the set of
   1435  *  flags that indicate the group stage and mode.
   1436  *
   1437  *  These must be filled in the same order as the cells are filled in within a
   1438  *  layer of the qualifier mapping table.
   1439  */
   1440 #define _BCM_DPP_FIELD_STAGE_INDEX_INGRESS      0
   1441 #define _BCM_DPP_FIELD_STAGE_INDEX_EGRESS       1
   1442 #define _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL 2
   1443 #define _BCM_DPP_FIELD_STAGE_INDEX_ING_SLB      3
   1444 
   1445 typedef struct _bcm_dpp_field_device_st_mapping_s {
   1446     _bcm_dpp_field_stage_idx_t stmStage;        /* stage index */
   1447     _bcm_dpp_field_type_idx_t stmType;          /* type index */
   1448     SOC_PPC_FP_PREDEFINED_ACL_KEY predefKey;    /* predefined key */
   1449     uint32 stmFlags;                            /* group type flags */
   1450 } _bcm_dpp_field_device_st_mapping_t;
   1451 
   1452 /*
   1453  *  This describes a device (gives certain criteria about the device) and
   1454  *  provides a pointer to the description tables for the device.
   1455  *
   1456  *  stages indicates how many field stages are supported on this device.
   1457  *
   1458  *  types indicates how many group types (not group modes -- a group type is
   1459  *  something like IPv4, L2, MPLS, &c) are supported each stage on the device.
   1460  *
   1461  *  qualChain indicates the longest chain of qualifiers at PPD layer that
   1462  *  correspond to a single BCM layer qualifier.  In most cases, such qualifiers
   1463  *  will generally require special code when adding support for them, since
   1464  *  they will tend to be long and the code only internally supports qualifiers
   1465  *  of up to 64b.
   1466  *
   1467  *  mappings indicates how many mappings are defined by the table built
   1468  *  _bcm_dpp_field_qual_mapping_t, above.
   1469  *
   1470  *  stage points to the table of stage descriptors.
   1471  *
   1472  *  qMapInfo points to the _bcm_dpp_field_qual_mapping_t array that defines how
   1473  *  the mapping is done between qualifier chains and group types within each of
   1474  *  the supported stages.
   1475  *
   1476  *  modeBits points to the table that specifies which group modes are supported
   1477  *  in each stage and how many bits are represented by each mode.
   1478  *
   1479  *  qualMap points to the table that describes each of the supported BCM
   1480  *  qualifiers and how they map to PPD qualifiers for each type of group in
   1481  *  each stage of the device.
   1482  *
   1483  *  typeNames points to an array of strings that give a name to each of the
   1484  *  supported group types.
   1485  */
   1486 typedef struct _bcm_dpp_field_device_info_s {
   1487     _bcm_dpp_field_stage_idx_t stages;                 /* number of stages */
   1488     _bcm_dpp_field_type_idx_t types;                   /* number of types */
   1489     _bcm_dpp_field_map_idx_t mappings;                 /* number of mappings */
   1490     _bcm_dpp_field_chain_idx_t qualChain;              /* max qual chain */
   1491     _bcm_dpp_field_chain_idx_t actChain;               /* max action chain */
   1492     _bcm_dpp_field_presel_idx_t presels;               /* number of presels */
   1493     uint32 cascadeKeyLimit;                            /* cascade key max len */
   1494     _bcm_dpp_field_device_stage_info_t *stage;         /* stage information */
   1495     const _bcm_dpp_field_device_st_mapping_t *stMapInfo; /* qual map defs */
   1496     const _bcm_dpp_field_device_group_mode_bits_t *modeBits; /* mode max lens */
   1497     const _bcm_dpp_field_device_range_info_t *ranges;  /* range type table */
   1498     int32 *qualMap;                                    /* qual map table */
   1499     int32 *actMap;                                     /* action map table */
   1500     const char* const* typeNames;                      /* group types */
   1501 } _bcm_dpp_field_device_info_t;
   1502 
   1503 /*
   1504  *  Information needed for a group
   1505  *
   1506  *  _BCM_DPP_FIELD_GROUP_IN_USE - group is in use
   1507  *  _BCM_DPP_FIELD_GROUP_IN_HW - group is in hardware (as database)
   1508  *  _BCM_DPP_FIELD_GROUP_PHASE - priority phase of copy in hardware
   1509  *  _BCM_DPP_FIELD_GROUP_WITH_CE_ID - group has ce_id list which set explicit ce
   1510  *  _BCM_DPP_FIELD_GROUP_CHG_ENT - group has changed entries
   1511  *  _BCM_DPP_FIELD_GROUP_ADD_ENT - group has added/reordered entries
   1512  *  _BCM_DPP_FIELD_GROUP_INGRESS - group is ingress stage
   1513  *  _BCM_DPP_FIELD_GROUP_INGRESS - group is egress stage
   1514  *  _BCM_DPP_FIELD_GROUP_AUTO_SZ - group created with 'auto' mode
   1515  *  _BCM_DPP_FIELD_GROUP_L2 - group has L2 qualifiers
   1516  *  _BCM_DPP_FIELD_GROUP_IPV4 - group has IPv4 qualifiers
   1517  *  _BCM_DPP_FIELD_GROUP_IPV6 - group has IPv6 qualifiers
   1518  *  _BCM_DPP_FIELD_GROUP_MPLS - group has MPLS qualifiers
   1519  *  _BCM_DPP_FIELD_GROUP_PRESEL - group has presel set explicitly specified
   1520  *  _BCM_DPP_FIELD_GROUP_CASCADE - group uses cascading features
   1521  *  _BCM_DPP_FIELD_GROUP_TINFO - flags that can change with set
   1522  *
   1523  *  Note CHG_ENT is a 'lazy' bit in that it sticks on whenever an entry in a
   1524  *  group changes for any reason, and is only cleared when committing the
   1525  *  entire group (at this time).  It should not be taken as a 'reliable' state.
   1526  *
   1527  *  BCM considers IPv4 and IPv6 header elements to be the same things (for
   1528  *  example, bcmFieldQualifyIpProtocol == bcmFieldQualifyIp6NextHeader).  PPD
   1529  *  uses different identifiers.  This means that a group must not have both
   1530  *  IPv4 and IPv6 qualifiers.  While this leaves it possible to overlap one of
   1531  *  the IPs with MPLS and L2, it requires the application make additional
   1532  *  checks in the L2 qualifiers (such as EtherType) to ensure accuracy of the
   1533  *  comparison at higher layers.
   1534  */
   1535 #define _BCM_DPP_FIELD_GROUP_IN_USE                 0x00000001
   1536 #define _BCM_DPP_FIELD_GROUP_IN_HW                  0x00000002
   1537 #define _BCM_DPP_FIELD_GROUP_PHASE                  0x00000004
   1538 #define _BCM_DPP_FIELD_GROUP_CHG_ENT                0x00000010
   1539 #define _BCM_DPP_FIELD_GROUP_ADD_ENT                0x00000020
   1540 #define _BCM_DPP_FIELD_GROUP_INGRESS                0x00000040
   1541 #define _BCM_DPP_FIELD_GROUP_EGRESS                 0x00000080
   1542 #define _BCM_DPP_FIELD_GROUP_AUTO_SZ                0x00000100
   1543 #define _BCM_DPP_FIELD_GROUP_L2                     0x00000200
   1544 #define _BCM_DPP_FIELD_GROUP_IPV4                   0x00000400
   1545 #define _BCM_DPP_FIELD_GROUP_IPV6                   0x00000800
   1546 #define _BCM_DPP_FIELD_GROUP_MPLS                   0x00001000
   1547 #define _BCM_DPP_FIELD_GROUP_PRESEL                 0x00002000
   1548 #define _BCM_DPP_FIELD_GROUP_CASCADE                0x00004000
   1549 #define _BCM_DPP_FIELD_GROUP_SMALL                  0x00008000
   1550 #define _BCM_DPP_FIELD_GROUP_LOOSE                  0x00010000 /* insertion priority order canceled */
   1551 #define _BCM_DPP_FIELD_GROUP_WITH_PRESEL            0x00020000 /* install group in HW only once after presel creation */
   1552 #define _BCM_DPP_FIELD_GROUP_SPARSE_PRIO            0x00040000 /* field groups with few priorities */
   1553 #define _BCM_DPP_FIELD_GROUP_IS_EQUAL_LSB           0x00080000 /* first DB for compare */
   1554 #define _BCM_DPP_FIELD_GROUP_IS_EQUAL_MSB           0x00100000 /* second DB for compare */
   1555 #define _BCM_DPP_FIELD_GROUP_WITH_HEADER_SELECTION  0x00200000 /* field groups with header index selection*/
   1556 #define _BCM_DPP_FIELD_GROUP_USE_DBAL               0x00400000 /* mapped SOC_PPC_FP_DATABASE_INFO_FLAGS_USE_DBAL */
   1557 #define _BCM_DPP_FIELD_GROUP_EXTENDED_DATABASES     0x00800000 
   1558 #define _BCM_DPP_FIELD_GROUP_STAGE_VT_EXTENDED      0x01000000 
   1559 #define _BCM_DPP_FIELD_GROUP_HANDLE_ENTRIES_BY_KEY  0x02000000 /* SOC_PPC_FP_DATABASE_INFO_FLAGS_HANDLE_ENTRY_BY_KEY */
   1560 #define _BCM_DPP_FIELD_GROUP_SINGLE_BANK            0x08000000
   1561 #define _BCM_DPP_FIELD_GROUP_TINFO                  0x00001EC5
   1562 #define _BCM_DPP_FIELD_GROUP_LARGE                  0x10000000 /* allocate FES for direct extraction */
   1563 #define _BCM_DPP_FIELD_GROUP_VT_CLASSIFICATION      0x20000000
   1564 #define _BCM_DPP_FIELD_GROUP_WITH_CYCLE             0x40000000 /* cycle value */
   1565 #define _BCM_DPP_FIELD_GROUP_WITH_PROGRAM_ID        0x80000000 /*create field group with program ID*/
   1566 #define _BCM_DPP_FIELD_GROUP_WITH_CE_ID             0x00000008 /*create field group with ce ID*/
   1567 
   1568 #define _BCM_DPP_FIELD_GROUP_ENTRY_BY_KEY_EMPTY     -1
   1569 
   1570 typedef enum _bcm_field_vt_classification_table_type_e {
   1571     _BCM_DPP_VT_CLASS_IPV4_MATCH = 0,
   1572     _BCM_DPP_VT_CLASS_EFP,
   1573     _BCM_DPP_VT_CLASS_VRRP,
   1574     _BCM_DPP_VT_QINQ_COMPRESSED_OUTER,
   1575     _BCM_DPP_VT_QINQ_COMPRESSED_INNER,
   1576     _BCM_DPP_VT_QINANY_OUTER,
   1577     _BCM_DPP_VT_QINANY_INNER,
   1578     _BCM_DPP_VT_QINANY_PCP_OUTER,
   1579     _BCM_DPP_VT_QINANY_PCP_INNER,
   1580     _BCM_DPP_VT_DOT1Q_OUTER,
   1581     _BCM_DPP_VT_DOT1Q_INNER,
   1582     _BCM_DPP_VT_DOT1Q_COMPRESSED_OUTER,
   1583     _BCM_DPP_VT_DOT1Q_COMPRESSED_INNER,
   1584     _BCM_DPP_VT_DOT1Q_COMPRESSED_PCP_OUTER,
   1585     _BCM_DPP_VT_DOT1Q_COMPRESSED_PCP_INNER,
   1586     _BCM_DPP_VT_UNTAGGED,
   1587     _BCM_DPP_VT_TST2,
   1588     _BCM_DPP_VT_TEST2,
   1589     _BCM_DPP_VT_PORT_DA,
   1590     _BCM_DPP_VT_CLASS_COUNT /* always last, not a valid value */
   1591 } _bcm_field_vt_classification_table_type_t;
   1592 
   1593 typedef enum _bcm_field_flp_classification_table_type_e {
   1594     _BCM_DPP_FLP_CLASS_IPV4_MPLS_EXTENDED = 0,
   1595     _BCM_DPP_FLP_CLASS_IPV6_EXTENDED,
   1596     _BCM_DPP_FLP_CLASS_P2P_EXTENDED,
   1597     _BCM_DPP_FLP_CLASS_IPV4_MC_FLEXIBLE,
   1598 	_BCM_DPP_FLP_CLASS_INRIF_MAPPING,
   1599     _BCM_DPP_FLP_CLASS_IVL_LEARN,                   /* IVL database access by {MAC;VSI;IVEC.VID} */
   1600     _BCM_DPP_FLP_CLASS_IVL_INNER_LEARN,             /* IVL database access by {MAC;VSI;Inner-Most.VID} */
   1601     _BCM_DPP_FLP_CLASS_IVL_FWD_OUTER_LEARN,         /* IVL database access by {MAC;VSI;FWD-Outer.VID} */
   1602 
   1603     _BCM_DPP_FLP_CLASS_COUNT /* always last, not a valid value */
   1604 } _bcm_field_flp_classification_table_type_t;
   1605 
   1606 typedef struct _bcm_dpp_field_group_s {
   1607     /* derivable from config or hardware */
   1608     bcm_field_qset_t qset;                      /* qualifiers for this group */
   1609     bcm_field_aset_t aset;                      /* actions for this group */
   1610     bcm_field_presel_set_t preselSet;           /* preselector set */
   1611     bcm_field_presel_set_t preselHw;            /* preselector set in hw */
   1612     /*_bcm_dpp_field_qual_set_t pqset;  */
   1613     SHR_BITDCL pqset[_SHR_BITDCLSIZE(SOC_PPC_NOF_FP_QUAL_TYPES)];         /* DPP qualifiers */
   1614     /*_bcm_dpp_field_action_set_t paset;  */        
   1615     SHR_BITDCL paset[_SHR_BITDCLSIZE(SOC_PPC_NOF_FP_ACTION_TYPES)];    /* DPP actions */
   1616     uint32 groupTypes;                          /* this group's types, Bitmap of which types supprted: L2/IPv4/IPv6/MPLS */
   1617     _bcm_dpp_field_ent_idx_t entryHead;         /* first entry in group */
   1618     _bcm_dpp_field_ent_idx_t entryTail;         /* last entry in group */
   1619     _bcm_dpp_field_ent_idx_t entryCount;        /* number of entries */
   1620     _bcm_dpp_field_grp_idx_t groupNext;         /* next group */
   1621     _bcm_dpp_field_grp_idx_t groupPrev;         /* previous group */
   1622     _bcm_dpp_field_grp_idx_t cascadePair;       /* other in cascade pair */
   1623     int priority;                               /* group priority */
   1624     int maxEntryPriorities;                     /* max entry priorities in group, constant value
   1625                                                                                     (entry priority where the enrty will be located in the TCAM bank)*/
   1626     /* kept in backing store to make it easier */
   1627     _bcm_dpp_field_stage_idx_t stage;           /* this group's stage */
   1628     SOC_PPC_FP_PREDEFINED_ACL_KEY predefKey;    /* predefined key (if used)*/
   1629     /* needs to be kept in backing store */
   1630     uint32 groupFlags;                          /* group flags _BCM_DPP_FIELD_GROUP*/
   1631     bcm_field_group_mode_t grpMode;             /* group mode, DE/DT/TCAM... */
   1632     bcm_field_aset_t oaset;                     /* original (caller's) aset */
   1633     /* 
   1634         * vlan translation classification Id 
   1635         * Relevant only in case of Vlan translation stage. 
   1636         */
   1637     uint32          internal_table_id;          
   1638     uint32          handle_by_key_entry_id;     /* a unique entry for groups that handles entry by key */
   1639     SOC_DPP_DBAL_PHYSICAL_DB_TYPES    physicalDB;     /* the type of the physical database to use for VTT FLP stages*/
   1640     
   1641     bcm_field_group_cycle_t groupCycle;         /* cycle value */
   1642     uint32 pgm_bmp;                     /* Bitmap of program-ids which the
   1643                                            current field group will be pointing
   1644                                            to. */
   1645     uint32          share_id;                   /* share ID, groups with same share ID may share TCAM banks */ 
   1646     uint32          num_entry_in_keep_location; /* number of entry in keep location mode */
   1647 } _bcm_dpp_field_group_t;
   1648 
   1649 typedef struct _bcm_dpp_field_group_presel_info_s {
   1650     int nof_presel_info;
   1651     bcm_field_group_presel_info_t presel_info[BCM_FIELD_NOF_PRESEL_PER_FG];
   1652 } _bcm_dpp_field_group_presel_info_t;
   1653 
   1654 /*
   1655  *  Describe a single qualifier
   1656  *
   1657  *  PPD layer says qualifier >= SOC_PPC_NOF_FP_QUAL_TYPES is invalid, but it
   1658  *  also curiously provides SOC_PPC_FP_QUAL_IRPP_INVALID as an alternative
   1659  *  invalid value, so check both, since (per the example of actions, see
   1660  *  below), it is likely that somewhere the PPD will provide the value of
   1661  *  SOC_PPC_FP_QUAL_IRPP_INVALID instead of SOC_PPC_NOF_FP_QUAL_TYPES.
   1662  */
   1663 #define _BCM_DPP_FIELD_PPD_QUAL_VALID(_qual) \
   1664      ((SOC_PPC_FP_QUAL_IRPP_INVALID != (_qual)) && \
   1665        (BCM_FIELD_ENTRY_INVALID != (_qual)) && \
   1666       (SOC_PPC_NOF_FP_QUAL_TYPES > (_qual)))
   1667 typedef struct _bcm_dpp_field_qual_s {
   1668     /* can be retrieved from hardware or derived thence */
   1669     bcm_field_qualify_t qualType;               /* BCM qualifier type */
   1670     SOC_PPC_FP_QUAL_TYPE hwType;                /* hardware qualifier type */
   1671     uint64 qualData;                            /* qualifier data (hardware) */
   1672     uint64 qualMask;                            /* qualifier mask (hardware) */
   1673 } _bcm_dpp_field_qual_t;
   1674 
   1675 /* Keeps the original input values to the BCM qualifier set API */
   1676 typedef struct _bcm_dpp_field_b_qual_s {
   1677     /* must be kept in backing store */
   1678     bcm_field_qualify_t qualType;               /* BCM qualifier type */
   1679     uint32 bcmParam0;                           /* qualifier data (sw) */
   1680     uint32 bcmMask0;                            /* qualifier mask (sw) */
   1681     uint32 bcmParam1;                           /* qualifier data (sw) */
   1682     uint32 bcmMask1;                            /* qualifier mask (sw) */
   1683 } _bcm_dpp_field_b_qual_t;
   1684 
   1685 /*
   1686  *  Describe a single TCAM action (BCM view)
   1687  */
   1688 typedef struct _bcm_dpp_field_tc_b_act_s {
   1689     /* must be kept in backing store */
   1690     bcm_field_action_t bcmType;                 /* BCM action type */
   1691     uint32 bcmParam0;                           /* action param0 */
   1692     uint32 bcmParam1;                           /* action param1 */
   1693     uint32 bcmParam2;                           /* action param2 */
   1694     uint32 bcmParam3;                           /* action param3 */
   1695 } _bcm_dpp_field_tc_b_act_t;
   1696 /*
   1697  *  Describe a single TCAM action (PPD view)
   1698  *
   1699  *  The special flags can vary by hwType.  Most hwType values will not use it,
   1700  *  but some will.  For example, SOC_PPC_FP_ACTION_TYPE_EGR_TRAP will use flags
   1701  *  to indicate which value of SOC_PPC_TRAP_ACTION_PROFILE_OVERWRITE* is
   1702  *  intended.
   1703  *
   1704  *  PPD layer says action type >= SOC_PPC_NOF_FP_ACTION_TYPES is invalid, but
   1705  *  it also curiously provides SOC_PPC_FP_ACTION_TYPE_INVALID to indicate
   1706  *  invalid action type.  The PPD code usually seems to set
   1707  *  SOC_PPC_FP_ACTION_TYPE_INVALID as the invalid type on reading, but the
   1708  *  other is also possible.  We will set SOC_PPC_FP_ACTION_TYPE_INVALID on
   1709  *  writing as well, but still need to check the other mode when reading.
   1710  */
   1711 #define _BCM_DPP_FIELD_PPD_ACTION_VALID(_action) \
   1712      ((SOC_PPC_FP_ACTION_TYPE_INVALID != (_action)) && \
   1713       (BCM_FIELD_ENTRY_INVALID != (_action)) && \
   1714       (SOC_PPC_NOF_FP_ACTION_TYPES > (_action)))
   1715 typedef struct _bcm_dpp_field_tc_p_act_s {
   1716     /* can be retrieved from hardware */
   1717     SOC_PPC_FP_ACTION_TYPE hwType;              /* hardware action type */
   1718     uint32 hwParam;                             /* hardware action parameter */
   1719     uint32 hwFlags;                             /* special flags for action */
   1720 } _bcm_dpp_field_tc_p_act_t;
   1721 
   1722 /*
   1723  *  Describe a single Direct Extraction action
   1724  */
   1725 typedef struct _bcm_dpp_field_de_act_s {
   1726     /* can be retrieved from hardware */
   1727     SOC_PPC_FP_DIR_EXTR_ACTION_VAL  hwParam;     /* hardware parameters */
   1728     /* must be kept in backing store */
   1729     bcm_field_action_t bcmType;                 /* BCM action type */
   1730 } _bcm_dpp_field_de_act_t;
   1731 
   1732 
   1733 /* those defines are used for direct mapping to the table id in the external TCAM.
   1734 	in all other cases the table ID should be taken from the DBAL include file */
   1735 #define _BCM_DPP_INTERNAL_TABLE_ID_EXTENDED_IPV4_MPLS           13 /*ARAD_KBP_FRWRD_TBL_ID_LSR_IP_SHARED*/       
   1736 #define _BCM_DPP_INTERNAL_TABLE_ID_EXTENDED_IPV6                16 /*ARAD_KBP_FRWRD_TBL_ID_EXTENDED_IPV6*/       
   1737 #define _BCM_DPP_INTERNAL_TABLE_ID_EXTENDED_P2P                 17 /*ARAD_KBP_FRWRD_TBL_ID_EXTENDED_P2P*/
   1738 #define _BCM_DPP_INTERNAL_TABLE_ID_EXTENDED_IPV4_MC             2  /*ARAD_KBP_FRWRD_TBL_ID_IPV4_MC */       
   1739 #define _BCM_DPP_INTERNAL_TABLE_ID_INRIF_MAPPING                18 /*ARAD_KBP_FRWRD_TBL_ID_INRIF_MAPPING*/
   1740 
   1741 /*
   1742  *  Information needed for an entry
   1743  *
   1744  *  _BCM_DPP_FIELD_ENTRY_IN_USE - entry is in use
   1745  *  _BCM_DPP_FIELD_ENTRY_IN_HW - entry is in hardware
   1746  *  _BCM_DPP_FIELD_ENTRY_WANT_HW - entry wants to be in hardware
   1747  *  _BCM_DPP_FIELD_ENTRY_UPDATE - specifies which entries to update
   1748  *  _BCM_DPP_FIELD_ENTRY_CHANGED - entry has been changed
   1749  *  _BCM_DPP_FIELD_ENTRY_NEW - entry is new (HW priority not valid)
   1750  *  _BCM_DPP_FIELD_ENTRY_STATS - entry has associated statistics
   1751  *  _BCM_DPP_FIELD_ENTRY_EGR_PRO - entry uses egress action profile
   1752  *  _BCM_DPP_FIELD_ENTRY_ACE_PRO - entry uses an ACE profile
   1753  *
   1754  *  _BCM_DPP_FIELD_ENTRY_UPDATE_REPLACE - (ARAD-only flag) entry was updated but not installed yet
   1755  *  _BCM_DPP_FIELD_ENTRY_IN_HW_VALID - (ARAD-only flag) entry is in HW and it's valid
   1756  *  _BCM_DPP_FIELD_ENTRY_WANT_DESTROY - (ARAD-only flag) entry needs to be removed from HW
   1757  */
   1758 #define _BCM_DPP_FIELD_ENTRY_IN_USE  0x00000001
   1759 #define _BCM_DPP_FIELD_ENTRY_IN_HW   0x00000002
   1760 #define _BCM_DPP_FIELD_ENTRY_WANT_HW 0x00000004
   1761 #define _BCM_DPP_FIELD_ENTRY_UPDATE  0x00000008
   1762 #define _BCM_DPP_FIELD_ENTRY_CHANGED 0x00000010
   1763 #define _BCM_DPP_FIELD_ENTRY_NEW     0x00000020
   1764 #define _BCM_DPP_FIELD_ENTRY_STATS   0x00000100
   1765 #define _BCM_DPP_FIELD_ENTRY_EGR_PRO 0x00000200
   1766 #define _BCM_DPP_FIELD_ENTRY_ACE_PRO 0x00000400
   1767 #define _BCM_DPP_FIELD_ENTRY_KEEP_LOCATION 0x00000800
   1768 
   1769 
   1770 #define _BCM_DPP_FIELD_GROUP_INSTALL    0x00010000
   1771 /*
   1772  * 1. The priority of the entries in the HW is in increasing order,
   1773  *    so that an entry with priority 0 is with the highest priority;
   1774  *    as opposed to BCM priority which is in decreasing order.
   1775  * 2. Also, the priority as defined in PPD is 16 bits, whereas here
   1776  *    it is 32 bit, hence the translation. Setting an entry with
   1777  *    priority in the range (0xffff + 1, BCM_FIELD_ENTRY_PRIO_HIGHEST - 1)
   1778  *    will fail.
   1779  */
   1780 #define BCM_FIELD_ENTRY_PRIO_HIGHEST_EXT_TCAM (0x3fffff) /* Highest possible entry
   1781                                                             priority in a group which is in external TCAM. */
   1782 
   1783 #define BCM_FIELD_ENTRY_HIGHEST_PRIORITY(isExternalTcam)    \
   1784 ((isExternalTcam) ? BCM_FIELD_ENTRY_PRIO_HIGHEST_EXT_TCAM : BCM_FIELD_ENTRY_PRIO_HIGHEST)
   1785 
   1786 #define BCM_FIELD_ENTRY_BCM_PRIO_TO_DPP_PRIO(isExternalTcam, prio)  \
   1787 ((BCM_FIELD_ENTRY_HIGHEST_PRIORITY(isExternalTcam)) - (prio))
   1788 
   1789 /*
   1790  *  Normally, a BCM layer action maps to a single PPD layer action, but there
   1791  *  are cases where a single BCM layer action maps to more than one PPD layer
   1792  *  action, or more than one BCM layer action maps to one PPD layer action.
   1793  *
   1794  *  _BCM_DPP_NOF_BCM_ACTIONS_PER_DB_MAX should be set considering whether the
   1795  *  BCM or PPD actions tend to be more plentiful.
   1796  *
   1797  *  This only applies to TCAM actions; at this point, other action types are
   1798  *  limited exactly by the support at PPD layer.
   1799  */
   1800 #define _BCM_DPP_NOF_BCM_ACTIONS_PER_DB_MAX SOC_PPC_FP_NOF_ACTIONS_PER_DB_MAX
   1801 /*
   1802  * Number of qualifiers for which SW state parameters keep is implemented.
   1803  * Set APIs update entryBcmQual descriptor.
   1804  * Get APIs rely on it to derive the original parameters.
   1805  * Currently implemented: bcmFieldQualifySrcPort, bcmFieldQualifyDstPort.
   1806  */
   1807 #define _BCM_DPP_NOF_BCM_QUALIFIERS_PER_ENTRY_TO_KEEP 3
   1808 /* Macro to check whether the provided qualifier was implemented for keeping */
   1809 #define _BCM_DPP_QUALIFIER_IS_KEPT_IN_SW_STATE(bcmQual) \
   1810 ((bcmQual == bcmFieldQualifySrcPort || bcmQual == bcmFieldQualifyDstPort || bcmQual == bcmFieldQualifyPacketRes) ? 1 : 0)
   1811 /*
   1812  *  Describe the common elements of entries
   1813  */
   1814 typedef struct _bcm_dpp_field_entry_common_s {
   1815     /* derivable from config or hardware */
   1816     _bcm_dpp_field_ent_idx_t entryNext;         /* next entry */
   1817     _bcm_dpp_field_ent_idx_t entryPrev;         /* previous entry */
   1818     _bcm_dpp_field_grp_idx_t entryGroup;        /* this entry's group */
   1819     uint32 hwPriority;                          /* entry priority in hardware */
   1820     _bcm_dpp_field_qual_t entryQual[SOC_PPC_FP_NOF_QUALS_PER_DB_MAX]; /* qualifiers */
   1821     /* needs to be kept in backing store */
   1822     uint32 entryFlags;                          /* entry flags */
   1823     int entryPriority;                          /* entry priority */
   1824     uint32 hwHandle;                            /* entry handle in hardware */
   1825     _bcm_dpp_field_b_qual_t entryBcmQual[_BCM_DPP_NOF_BCM_QUALIFIERS_PER_ENTRY_TO_KEEP]; /* BCM qualifiers if kept*/
   1826     /* partially derivable from hardware, part in backing store */
   1827 } _bcm_dpp_field_entry_common_t;
   1828 
   1829 /*
   1830  *  Describe a TCAM entry
   1831  */
   1832 typedef struct _bcm_dpp_field_entry_s {
   1833     /* derivable from config or hardware */
   1834     _bcm_dpp_field_entry_common_t entryCmn;     /* common data for all types */
   1835     _bcm_dpp_field_tc_p_act_t tcActP[SOC_PPC_FP_NOF_ACTIONS_PER_DB_MAX];
   1836     uint32 egrTrapProfile;                      /* hw egr trap profile */
   1837     /* must be kept in backing store */
   1838     _bcm_dpp_field_tc_b_act_t tcActB[_BCM_DPP_NOF_BCM_ACTIONS_PER_DB_MAX];
   1839     uint32 large_direct_lookup_key;             /* Large direct lookup key */
   1840     uint32 large_direct_lookup_mask;            /* Large direct lookup mask */
   1841 } _bcm_dpp_field_entry_t;
   1842 
   1843 /*
   1844  *  Describe an external TCAM info entry
   1845  */
   1846 typedef struct _bcm_dpp_field_entry_ext_info_s {
   1847     _bcm_dpp_field_qual_t entryQual[SOC_PPC_FP_NOF_QUALS_PER_DB_MAX]; /* qualifiers */
   1848     _bcm_dpp_field_tc_p_act_t tcActP[SOC_PPC_FP_NOF_ACTIONS_PER_DB_MAX]; /* ppd actions */
   1849     _bcm_dpp_field_tc_b_act_t tcActB[_BCM_DPP_NOF_BCM_ACTIONS_PER_DB_MAX]; /* bcm actions */
   1850     uint32 hwPriority; /* entry priority in hardware */
   1851     int entryPriority; /* entry priority */
   1852 } _bcm_dpp_field_entry_ext_info_t;
   1853 
   1854 /*
   1855  *  Describe the common elements of external TCAM entries
   1856  */
   1857 typedef struct _bcm_dpp_field_entry_common_ext_s {
   1858     /* derivable from config or hardware */
   1859     _bcm_dpp_field_ent_idx_t entryNext;      /* next entry */
   1860     _bcm_dpp_field_ent_idx_t entryPrev;      /* previous entry */
   1861     _bcm_dpp_field_grp_idx_t entryGroup;     /* this entry's group */
   1862     uint32 entryFlags;                       /* entry flags */
   1863     uint32 hwHandle;                         /* entry handle in hardware */
   1864 #if _BCM_DPP_EXT_TCAM_ENTRIES_IN_SW_STATE
   1865     _bcm_dpp_field_b_qual_t entryBcmQual[_BCM_DPP_NOF_BCM_QUALIFIERS_PER_ENTRY_TO_KEEP]; /* BCM qualifiers if kept*/
   1866 #endif
   1867 } _bcm_dpp_field_entry_common_ext_t;
   1868 
   1869 /*
   1870  *  Describe an external TCAM entry
   1871  */
   1872 typedef struct _bcm_dpp_field_entry_ext_s {
   1873     _bcm_dpp_field_entry_common_ext_t entryCmn;/* common data */
   1874     uint32 ext_info_idx; 	/* index to external info array */
   1875 } _bcm_dpp_field_entry_ext_t;
   1876 
   1877 /*
   1878  *  Describe a Direct Extraction entry
   1879  */
   1880 typedef struct _bcm_dpp_field_entry_dir_ext_s {
   1881     _bcm_dpp_field_entry_common_t entryCmn;     /* common data for all types */
   1882     _bcm_dpp_field_de_act_t deAct[SOC_PPC_FP_NOF_ACTIONS_PER_DB_MAX]; /* actions */
   1883 } _bcm_dpp_field_entry_dir_ext_t;
   1884 
   1885 /*
   1886  *  Stage specific information
   1887  *
   1888  *  The extra qsetType is for preselectors; similar for the extra offset.
   1889  */
   1890 #define _BCM_DPP_FIELD_RESOURCES_PER_STAGE 3
   1891 typedef struct _bcm_dpp_field_stage_s {
   1892     /* derivable from config or hardware */
   1893     bcm_field_qset_t stgQset;                   /* stage qualifiers */
   1894     bcm_field_qset_t qsetType[_BCM_DPP_FIELD_MAX_GROUP_TYPES + 1];/* type qset */
   1895     SHR_BITDCL ppqset[_SHR_BITDCLSIZE(SOC_PPC_NOF_FP_QUAL_TYPES)];           /* presel PPD qual set */
   1896     bcm_field_aset_t stgAset;                   /* stage actions */
   1897     PARSER_HINT_PTR _bcm_dpp_field_device_group_mode_bits_t *modeBits[bcmFieldGroupModeCount];
   1898                                                 /* stage mode information */
   1899     unsigned int ltOffset[_BCM_DPP_FIELD_MAX_GROUP_TYPES + 1];/* lkup tbl ofs */
   1900     _bcm_dpp_field_stage_idx_t groupSh1;        /* first in group share set */
   1901     _bcm_dpp_field_stage_idx_t entryTcSh1;      /* first in TC ent share set */
   1902     _bcm_dpp_field_stage_idx_t entryDeSh1;      /* first in DE ent share set */
   1903     uint32 hwGroupLimit;                        /* hardware group ID limit */
   1904     uint32 hwEntryLimit;                        /* hardware entry ID limit */
   1905     uint32 hwEntryDeLimit;                      /* HW dir ext entry ID limit */
   1906     _bcm_dpp_field_grp_idx_t groupHead;         /* first group this stage */
   1907     _bcm_dpp_field_grp_idx_t groupTail;         /* last group this stage */
   1908     _bcm_dpp_field_grp_idx_t groupCount;        /* active groups this stage */
   1909     _bcm_dpp_field_ent_idx_t entryCount;        /* active entries this stage */
   1910     _bcm_dpp_field_ent_idx_t entryElems;        /* active HW entry elements */
   1911     _bcm_dpp_field_ent_idx_t entryDeCount;      /* active dir ext entries */
   1912     _bcm_dpp_field_ent_idx_t entryDeElems;      /* active dir ext HW elems */
   1913     /* must be kept in backing store  */
   1914     bcm_field_presel_set_t pfgsEther;           /* PFG set for ethernet */
   1915     bcm_field_presel_set_t pfgsIPv4;            /* PFG set for IPv4 */
   1916     bcm_field_presel_set_t pfgsIPv6;            /* PFG set for IPv6 */
   1917     bcm_field_presel_set_t pfgsMPLS;            /* PFG set for MPLS */
   1918 } _bcm_dpp_field_stage_t;
   1919 
   1920 /*
   1921  *  Unit-specific information
   1922  *
   1923  *  Note the actual memory for 'group' and 'entry' will be allocated
   1924  *  immediately after the memory for this struct, and it will be allocated in
   1925  *  the same heap cell.
   1926  *
   1927  *  _BCM_DPP_FIELD_UNIT_WB_RESTORE_FAIL is set when restoring from the backing
   1928  *  store and the data therein are inconsistent with either the hardware state
   1929  *  or internally.  Note that inconsistencies are only verified for active
   1930  *  elements, so if the backing store covers things not supported by the new
   1931  *  code, it is only an error here if those things are in use; also, if the
   1932  *  backing store does not cover a certain resource, it will be assumed to be
   1933  *  entirely unused (and not treated as an inconsistency).
   1934  *
   1935  *  _BCM_DPP_FIELD_UNIT_WB_VERSION_FAIL is set whenever the backing store
   1936  *  version is not recognized by some component of the module. This should
   1937  *  never happen and it indicates some component was missed when an update to
   1938  *  the backing store version was made.
   1939  *
   1940  *  _BCM_DPP_FIELD_UNIT_WB_FORMAT_FAIL is set whenever there is a dynamically
   1941  *  sized object that has parts which will not fit in the backing store.  This
   1942  *  should only happen when writing to backing store using an older format.
   1943  *
   1944  *  _BCM_DPP_FIELD_UNIT_WB_COMMIT_FAIL is set whenever there is a failure to
   1945  *  update the backing store.  It indicates the backing store is not in sync
   1946  *  with the hardware state.  For now, the only way to clear this is to reinit
   1947  *  the field APIs or to have a full state sync complete successfully.
   1948  */
   1949 
   1950 
   1951 typedef struct _bcm_dpp_field_info_OLD_s {
   1952     /* derivable from config or hardware */
   1953     int unit;                                   /* unit ID */
   1954     uint32 unitHandle;                          /* PPD device ID */
   1955     const _bcm_dpp_field_device_info_t *devInfo;/* pointer to device info */
   1956 } bcm_dpp_field_info_OLD_t;
   1957 extern bcm_dpp_field_info_OLD_t *_bcm_dpp_field_unit_info[BCM_MAX_NUM_UNITS];
   1958 
   1959 #define BCM_FIELD_GROUP_CONFIG_MAX_ID_COUNT 128
   1960 
   1961 typedef struct _bcm_dpp_field_info_s {
   1962     unsigned int                rangeQualTypes;    /* range qualifier types */
   1963 
   1964         /*
   1965          * Qualifier mappings. Array of bcmFieldQualifyCount entries. Each is an index
   1966          * into selected constant array: bcm_dpp_field_info_t.devInfo->->qualMap[]
   1967          * Note that, currently, temporarily, this is:
   1968          * bcm_dpp_field_info_OLD_t.devInfo->->qualMap[]
   1969          * Note:
   1970          * The whole structure, containing 'bcm_dpp_field_info_t' for 'unit' is pointed
   1971          * by _bcm_dpp_field_unit_info[unit]
   1972          */
   1973     PARSER_HINT_ARR  int32 *qualMaps ;
   1974 	/*
   1975          * Action mappings. Array of bcmFieldActionCount entries. Each is an index
   1976          * into selected constant array: bcm_dpp_field_info_t.devInfo->->actMap[]
   1977          * Note that, currently, temporarily, this is:
   1978          * bcm_dpp_field_info_OLD_t.devInfo->->actMap[]
   1979          * Note:
   1980          * The whole structure, containing 'bcm_dpp_field_info_t' for 'unit' is pointed
   1981          * by _bcm_dpp_field_unit_info[unit]
   1982          */
   1983     PARSER_HINT_ARR  int32 *actMaps ;
   1984     bcm_field_qualify_t         ppdQual[SOC_PPC_NOF_FP_QUAL_TYPES];/* PPD -> BCM qual map */
   1985     unsigned int                qualMapCount;      /* qualifier map table size */
   1986     unsigned int                actMapCount;       /* action map table size */
   1987     _bcm_dpp_field_presel_idx_t preselLimit;       /* max preselectors */
   1988         /*
   1989          * unitQset,unitAset -- Structures containing a few arrays of bits.
   1990          * Note:
   1991          * The whole structure, containing 'bcm_dpp_field_info_t' for 'unit' is pointed
   1992          * by _bcm_dpp_field_unit_info[unit]
   1993          */
   1994     bcm_field_qset_t            unitQset;          /* supported qualifiers */
   1995     bcm_field_aset_t            unitAset;          /* supported actions */
   1996     uint8                       cascadedKeyLen;    /* cascaded key length */
   1997     _bcm_dpp_field_ent_idx_t    entryDeCount;      /* active dir ext entries */
   1998     _bcm_dpp_field_ent_idx_t    entryUninstalledTcCount; /* configured but not installed TCAM entries */
   1999     _bcm_dpp_field_grp_idx_t    groupCount;        /* active groups */
   2000     _bcm_dpp_field_grp_idx_t    groupFree;         /* first free group */
   2001     _bcm_dpp_field_grp_idx_t    groupCascaded;     /* groups using cascading */
   2002     _bcm_dpp_field_ent_idx_t    entryIntTcCount;   /* active internal TCAM entries */
   2003     _bcm_dpp_field_ent_idx_t    entryExtTcCount;   /* active external TCAM entries */
   2004     _bcm_dpp_field_ent_idx_t    entryIntTcFree;    /* first free internal TCAM entry */
   2005     _bcm_dpp_field_ent_idx_t    entryExtTcFree;    /* first free external TCAM entry */
   2006     _bcm_dpp_field_ent_idx_t    entryDeFree;       /* first free dir ext entry */
   2007 
   2008     _bcm_dpp_field_ent_idx_t    entryTcLimit;      /* max internal TCAM entries */
   2009     _bcm_dpp_field_ent_idx_t    entryExtTcLimit;   /* max external TCAM entries */
   2010     _bcm_dpp_field_grp_idx_t    groupLimit;        /* max groups */
   2011     _bcm_dpp_field_ent_idx_t    entryDeLimit;      /* max dir ext entries */
   2012     _bcm_dpp_field_dq_idx_t     dqLimit;           /* max data qualifier */
   2013 
   2014     SHR_BITDCL dataFieldInUse[_SHR_BITDCLSIZE(_BCM_DPP_NOF_FIELD_DATAS)]; /* programmable fields in use */
   2015     SHR_BITDCL dataFieldOfsBit[_SHR_BITDCLSIZE(_BCM_DPP_NOF_FIELD_DATAS)]; /* offset is bit resolution */
   2016     SHR_BITDCL dataFieldLenBit[_SHR_BITDCLSIZE(_BCM_DPP_NOF_FIELD_DATAS)]; /* length is bit resolution */
   2017     SHR_BITDCL dataFieldDnxOrderBit[_SHR_BITDCLSIZE(_BCM_DPP_NOF_FIELD_DATAS)]; /* Dnx order is bit resolution */
   2018     unsigned int dataFieldRefs[_BCM_DPP_NOF_FIELD_DATAS]; /* reference cnt */
   2019         /*
   2020          * rangeInUse --
   2021          *   Array of pointers (not more than 'bcmFieldQualifyCount' elements)
   2022          *   each pointing to an array of _BCM_DPP_RANGE_MAX_COUNT bits {In
   2023          *   longs: SHR_BITALLOCSIZE(_BCM_DPP_RANGE_MAX_COUNT)}
   2024          *   Esentially, this is a two dimensional array of bits.
   2025          * Note:
   2026          * The whole structure, containing 'bcm_dpp_field_info_t' for 'unit' is pointed
   2027          * by _bcm_dpp_field_unit_info[unit]
   2028          */
   2029     SOC_SAND_OCC_BM_PTR extTcamBmp;        /* pointer to occupation bitmap for external TCAM info table */
   2030     PARSER_HINT_PTR_PTR  SHR_BITDCL **rangeInUse;               /* range in-use information */
   2031     bcm_field_presel_set_t preselInUse;                         /* preselectors in use */
   2032     unsigned int preselRefs[_BCM_DPP_NOF_FIELD_PRESELECTORS];   /* ref count */
   2033     unsigned int preselProfileRefs[_bcmDppFieldProfileTypeCount][_BCM_DPP_PRESEL_NOF_PORT_PROFILES]; /* ref count */
   2034     PARSER_HINT_ARR _bcm_dpp_field_stage_t *stageD;             /* pointer to stage data */
   2035     PARSER_HINT_PTR_SET PARSER_HINT_ARR _bcm_dpp_field_group_t *groupD;
   2036     PARSER_HINT_ARR _bcm_dpp_field_group_presel_info_t *groupHwInfo;
   2037     PARSER_HINT_ARR _bcm_dpp_field_entry_dir_ext_t *entryDe;
   2038     PARSER_HINT_ARR _bcm_dpp_field_entry_t *entryTc;              /* pointer to internal entry table */
   2039     PARSER_HINT_ARR _bcm_dpp_field_entry_ext_t *entryExtTc;       /* pointer to external entry table */
   2040     PARSER_HINT_ARR _bcm_dpp_field_entry_ext_info_t *extTcamInfo; /* pointer to external TCAM info table */
   2041     /*
   2042      * Number of meaningful elements (first index) on Arad_pmf_fem_action_type_encoding_runtime[]
   2043      */
   2044     uint32 num_arad_pmf_fem_action_type_encoding_runtime ;
   2045     uint32 Arad_pmf_fem_action_type_encoding_runtime[SOC_PPC_NOF_FP_ACTION_TYPES][NUM_ACTION_ELEMENTS] ;
   2046     /*
   2047      * Number of meaningful elements (first index) on Arad_plus_pmf_fem_action_type_encoding_runtime[]
   2048      */
   2049     uint32 num_arad_plus_pmf_fem_action_type_encoding_runtime ;
   2050     uint32 Arad_plus_pmf_fem_action_type_encoding_runtime[SOC_PPC_NOF_FP_ACTION_TYPES][NUM_ACTION_ELEMENTS] ;
   2051     /*
   2052      * Number of meaningful elements (first index) on Jericho_pmf_fem_action_type_encoding_runtime[]
   2053      */
   2054     uint32 num_jericho_pmf_fem_action_type_encoding_runtime ;
   2055     uint32 Jericho_pmf_fem_action_type_encoding_runtime[SOC_PPC_NOF_FP_ACTION_TYPES][NUM_ACTION_ELEMENTS] ;
   2056     /*
   2057      * Number of meaningful elements (first index) on Qax_pmf_fem_action_type_encoding_runtime[]
   2058      */
   2059     uint32 num_qax_pmf_fem_action_type_encoding_runtime ;
   2060     uint32 Qax_pmf_fem_action_type_encoding_runtime[SOC_PPC_NOF_FP_ACTION_TYPES][NUM_ACTION_ELEMENTS] ;
   2061 
   2062     uint8 groupConfigNames[BCM_FIELD_GROUP_CONFIG_MAX_ID_COUNT][BCM_FIELD_MAX_NAME_LEN];    /* Mapping between group config id & name*/
   2063     uint8 dataQualifierNames[bcmFieldQualifyCount][BCM_FIELD_MAX_NAME_LEN];                 /* Mapping between data qualifier id & name*/
   2064     uint8 preselConfigNames[BCM_FIELD_GROUP_CONFIG_MAX_ID_COUNT][BCM_FIELD_MAX_NAME_LEN];   /* Mapping between presel config id & name*/
   2065 
   2066     uint32 keyGenVar;         /* Key Gen Var */
   2067     uint32 kaps_large_db_bits;
   2068 } bcm_dpp_field_info_t ;
   2069 
   2070 /* --------------------- Definitions related to entryTc/entryExtTc/extTcamInfo ------ */
   2071 /* { */
   2072 #define FIELD_ACCESS_ENTRYTC      FIELD_ACCESS.entryTc
   2073 #define FIELD_ACCESS_ENTRYEXTTC   FIELD_ACCESS.entryExtTc
   2074 #define FIELD_ACCESS_EXTTCAMINFO  FIELD_ACCESS.extTcamInfo
   2075 /* } */
   2076 /* ---------------------------------------------------------------------------------- */
   2077 
   2078 /* --------------------- Definitions related to 'runtime' arrays ------ */
   2079 /* { */
   2080 #define FIELD_ACCESS_ARAD_NUM_ACTION_RUNTIME      FIELD_ACCESS.num_arad_pmf_fem_action_type_encoding_runtime
   2081 #define FIELD_ACCESS_ARAD_PLUS_NUM_ACTION_RUNTIME FIELD_ACCESS.num_arad_plus_pmf_fem_action_type_encoding_runtime
   2082 #define FIELD_ACCESS_JERICHO_NUM_ACTION_RUNTIME   FIELD_ACCESS.num_jericho_pmf_fem_action_type_encoding_runtime
   2083 #define FIELD_ACCESS_QAX_NUM_ACTION_RUNTIME       FIELD_ACCESS.num_qax_pmf_fem_action_type_encoding_runtime
   2084 #define FIELD_ACCESS_ARAD_ACTION_RUNTIME          FIELD_ACCESS.Arad_pmf_fem_action_type_encoding_runtime
   2085 #define FIELD_ACCESS_ARAD_PLUS_ACTION_RUNTIME     FIELD_ACCESS.Arad_plus_pmf_fem_action_type_encoding_runtime
   2086 #define FIELD_ACCESS_JERICHO_ACTION_RUNTIME       FIELD_ACCESS.Jericho_pmf_fem_action_type_encoding_runtime
   2087 #define FIELD_ACCESS_QAX_ACTION_RUNTIME           FIELD_ACCESS.Qax_pmf_fem_action_type_encoding_runtime
   2088 /* } */
   2089 /* ---------------------------------------------------------------------------------- */
   2090 
   2091 /* --------------------- Definitions related to preselInUse/preselRefs/preselProfileRefs ------ */
   2092 /* { */
   2093 #define FIELD_ACCESS_PRESELPROFILEREFS   FIELD_ACCESS.preselProfileRefs
   2094 #define FIELD_ACCESS_PRESELREFS          FIELD_ACCESS.preselRefs
   2095 #define FIELD_ACCESS_PRESELINUSE         FIELD_ACCESS.preselInUse
   2096 #define FIELD_ACCESS_PRESELINUSE_W       FIELD_ACCESS_PRESELINUSE.w
   2097 /* } */
   2098 /* --------------------------------------------------------------------------------------------- */
   2099 
   2100 /* --------------------- Definitions related to rangeInUse ------------------ */
   2101 /* { */
   2102 #define FIELD_ACCESS_RANGEINUSE         FIELD_ACCESS.rangeInUse
   2103 /*
   2104  * This macro is added, temporarily, to allow compilation of wb_db_field.c ;
   2105  * Remove in final version (together with the whole file)
   2106  */
   2107 #define GET_ADDROF_RANGEINUSE(_unit,_ptr_index,_bitmap_index) \
   2108   &(sw_state[_unit]->dpp.bcm.field->rangeInUse[_ptr_index][_bitmap_index])
   2109 /* } */
   2110 /* ------------------------------------------------------------------------------------ */
   2111 
   2112 /* --------------------- Definitions related to unitQset ------------------ */
   2113 /* { */
   2114 #define FIELD_ACCESS_UNITQSET         FIELD_ACCESS.unitQset
   2115 #define FIELD_ACCESS_UNITQSET_W       FIELD_ACCESS_UNITQSET.w
   2116 #define FIELD_ACCESS_UNITQSET_UDFMAP  FIELD_ACCESS_UNITQSET.udf_map
   2117 /* } */
   2118 /* ------------------------------------------------------------------------------------ */
   2119 
   2120 /* --------------------- Definitions related to unitAset ------------------ */
   2121 /* { */
   2122 #define FIELD_ACCESS_UNITASET         FIELD_ACCESS.unitAset
   2123 #define FIELD_ACCESS_UNITASET_W       FIELD_ACCESS_UNITASET.w
   2124 /* } */
   2125 /* ------------------------------------------------------------------------------------ */
   2126 
   2127 /* --------------------- Definitions related to actMaps ------------------ */
   2128 /* { */
   2129 #define FIELD_ACCESS_ACTMAPS  FIELD_ACCESS.actMaps
   2130 /*
   2131  * Verify specified unit has a legal value. If not, software goes to
   2132  * exit with error code.
   2133  * 
   2134  * Notes:
   2135  *   'exit' is assumed to be defined in the caller's scope.
   2136  */
   2137 #define SOC_SAND_ACTMAPS_VERIFY_UNIT_IS_LEGAL(unit, _err1) \
   2138   if (((int)unit < 0) || ((int)unit >= SOC_MAX_NUM_DEVICES)) \
   2139   { \
   2140     /* \
   2141      * If this is an illegal unit identifier, quit \
   2142      * with error. \
   2143      */ \
   2144     SOC_SAND_SET_ERROR_CODE(SOC_SAND_MAX_NUM_DEVICES_OUT_OF_RANGE_ERR, _err1, exit); \
   2145   }
   2146 /*
   2147  * Convert input ACTMAPS handle to index in '_bcm_dpp_field_unit_info[unit]->devInfo->actMap' array.
   2148  * Convert input index in actMap array to ACTMAPS handle.
   2149  * Indices go from 0 -> (bcmFieldActionCount - 1)
   2150  * Handles go from 1 -> bcmFieldActionCount
   2151  */
   2152 #define SOC_SAND_ACTMAPS_CONVERT_HANDLE_TO_ACTMAPS_INDEX(_actMap_index,_handle) (_actMap_index = _handle - 1)
   2153 #define SOC_SAND_ACTMAPS_CONVERT_ACTMAPS_INDEX_TO_HANDLE(_handle,_actMap_index) (_handle = _actMap_index + 1)
   2154 /*
   2155  * Convert input ACTMAPS handle to address of element in '_bcm_dpp_field_unit_info[unit]->devInfo->actMap'
   2156  * array (of int32). '_element', then, is of type 'ptr to int32'.
   2157  * Convert input index in actMap array to ACTMAPS handle.
   2158  * Handles go from 1 -> bcmFieldActionCount
   2159  */
   2160 #define SOC_SAND_ACTMAPS_CONVERT_HANDLE_TO_ELEMENT(_unit,_handle,_element) \
   2161   { \
   2162     uint32 actMap_index ; \
   2163     SOC_SAND_ACTMAPS_CONVERT_HANDLE_TO_ACTMAPS_INDEX(actMap_index,_handle) ; \
   2164     _element = &(_bcm_dpp_field_unit_info[_unit]->devInfo->actMap[actMap_index]) ; \
   2165   }
   2166 /* } */
   2167 /* ------------------------------------------------------------------------------------ */
   2168 
   2169 /* --------------------- Definitions related to qualMaps ------------------ */
   2170 /* { */
   2171 #define FIELD_ACCESS_QUALMAPS  FIELD_ACCESS.qualMaps
   2172 /*
   2173  * Verify specified unit has a legal value. If not, software goes to
   2174  * exit with error code.
   2175  * 
   2176  * Notes:
   2177  *   'exit' is assumed to be defined in the caller's scope.
   2178  */
   2179 #define SOC_SAND_QUALMAPS_VERIFY_UNIT_IS_LEGAL(unit, _err1) \
   2180   if (((int)unit < 0) || ((int)unit >= SOC_MAX_NUM_DEVICES)) \
   2181   { \
   2182     /* \
   2183      * If this is an illegal unit identifier, quit \
   2184      * with error. \
   2185      */ \
   2186     SOC_SAND_SET_ERROR_CODE(SOC_SAND_MAX_NUM_DEVICES_OUT_OF_RANGE_ERR, _err1, exit); \
   2187   }
   2188 /*
   2189  * Convert input QUALMAPS handle to index in '_bcm_dpp_field_unit_info[unit]->devInfo->qualMap' array.
   2190  * Convert input index in qualMap array to QUALMAPS handle.
   2191  * Indices go from 0 -> (bcmFieldQualifyCount - 1)
   2192  * Handles go from 1 -> bcmFieldQualifyCount
   2193  */
   2194 #define SOC_SAND_QUALMAPS_CONVERT_HANDLE_TO_QUALMAPS_INDEX(_qualMap_index,_handle) (_qualMap_index = _handle - 1)
   2195 #define SOC_SAND_QUALMAPS_CONVERT_QUALMAPS_INDEX_TO_HANDLE(_handle,_qualMap_index) (_handle = _qualMap_index + 1)
   2196 /*
   2197  * Convert input QUALMAPS handle to address of element in '_bcm_dpp_field_unit_info[unit]->devInfo->qualMap'
   2198  * array (of int32). '_element', then, is of type 'ptr to int32'.
   2199  * Convert input index in qualMap array to QUALMAPS handle.
   2200  * Handles go from 1 -> bcmFieldQualifyCount
   2201  */
   2202 #define SOC_SAND_QUALMAPS_CONVERT_HANDLE_TO_ELEMENT(_unit,_handle,_element) \
   2203   { \
   2204     uint32 qualMap_index ; \
   2205     SOC_SAND_QUALMAPS_CONVERT_HANDLE_TO_QUALMAPS_INDEX(qualMap_index,_handle) ; \
   2206     _element = &(_bcm_dpp_field_unit_info[_unit]->devInfo->qualMap[qualMap_index]) ; \
   2207   }
   2208 /* } */
   2209 /* ------------------------------------------------------------------------------------ */
   2210 
   2211 #define _BCM_DPP_FIELD_QUALMAP_OFFSET_QUAL 0
   2212 #define _BCM_DPP_FIELD_QUALMAP_OFFSET_LENGTH 1
   2213 #define _BCM_DPP_FIELD_QUALMAP_OFFSET_SHIFT 2
   2214 #define _BCM_DPP_FIELD_QUALMAP_OFFSET_FLAGS 3
   2215 #define _BCM_DPP_FIELD_QUALMAP_OFFSET_MAPS 4
   2216 #define _BCM_DPP_FIELD_ACTMAP_OFFSET_ACT 0
   2217 #define _BCM_DPP_FIELD_ACTMAP_OFFSET_MAPS 1
   2218 
   2219 #ifdef BCM_ARAD_SUPPORT
   2220 /*-----------------------------------------------------------------------------
   2221  *
   2222  *  The struct definition below is used in _bcm_arad_field_qual_info deceleration
   2223  *  table in field_hwconfig.c. Please refer to comments of the table's deceleration
   2224  *  for further explanations and clarifications.
   2225  */
   2226 typedef struct _bcm_arad_field_device_qual_info_layer_s {
   2227     int32 bcmQual;            /* BCM layer qualifier to define */
   2228     int32 bits;               /* number of bits at BCM layer */
   2229     int32 lshift;             /* left shift BCM LSb to align to PPD LSb */
   2230     int32 flags;              /* see _BCM_DPP_QUAL_* in dpp/field_int.h */
   2231     /* remaining elements are all according to the configuration */
   2232     /* the number of chain members per map is in the device descriptor */
   2233     /* the number of maps is in the device descriptor */
   2234     /* how the maps align to stages,types is in the mappings descriptor */
   2235     /* i_ for ingress PMF, f_ for ingress FLP, e_ for egress PMF, s_ for SLB */
   2236 
   2237     /* INGRESS stage */
   2238     int32 i_l2_a;
   2239     int32 i_l2_b;   /* chain 0,1 of L2 */
   2240     int32 i_ipv4_a;
   2241     int32 i_ipv4_b; /* chain 0,1 of IPV4 */
   2242     int32 i_ipv6_a;
   2243     int32 i_ipv6_b; /* chain 0,1 of IPV6 */
   2244     int32 i_mpls_a;
   2245     int32 i_mpls_b; /* chain 0,1 of MPLS */
   2246     int32 i_psel_a;
   2247     int32 i_psel_b; /* chain 0,1 of PRESEL */
   2248 
   2249     /* FLP stage */
   2250     int32 f_l2_a;
   2251     int32 f_l2_b;   /* chain 0,1 of L2 */
   2252     int32 f_ipv4_a;
   2253     int32 f_ipv4_b; /* chain 0,1 of IPV4 */
   2254     int32 f_ipv6_a;
   2255     int32 f_ipv6_b; /* chain 0,1 of IPV6 */
   2256     int32 f_mpls_a;
   2257     int32 f_mpls_b; /* chain 0,1 of MPLS */
   2258     int32 f_psel_a;
   2259     int32 f_psel_b; /* chain 0,1 of PRESEL */
   2260 
   2261     /* SLB stage */
   2262     int32 s_l2_a;
   2263     int32 s_l2_b;   /* chain 0,1 of L2 */
   2264     int32 s_ipv4_a;
   2265     int32 s_ipv4_b; /* chain 0,1 of IPV4 */
   2266     int32 s_ipv6_a;
   2267     int32 s_ipv6_b; /* chain 0,1 of IPV6 */
   2268     int32 s_mpls_a;
   2269     int32 s_mpls_b; /* chain 0,1 of MPLS */
   2270     int32 s_psel_a;
   2271     int32 s_psel_b; /* chain 0,1 of PRESEL */
   2272 
   2273     /* EGRESS stage */
   2274     int32 e_l2_a;
   2275     int32 e_l2_b;   /* chain 0,1 of L2 */
   2276     int32 e_ipv4_a;
   2277     int32 e_ipv4_b; /* chain 0,1 of IPV4 */
   2278     int32 e_ipv6_a;
   2279     int32 e_ipv6_b; /* chain 0,1 of IPV6 */
   2280     int32 e_mpls_a;
   2281     int32 e_mpls_b; /* chain 0,1 of MPLS  */
   2282     int32 e_psel_a;
   2283     int32 e_psel_b; /* chain 0,1 of PRESEL */
   2284 } _bcm_arad_field_device_qual_info_layer_t;
   2285 
   2286 
   2287 extern _bcm_arad_field_device_qual_info_layer_t _bcm_arad_field_qual_info[];
   2288 
   2289 /*
   2290  *  Like the qualifier mapping table, the action mapping table lists each of
   2291  *  the supported BCM layer actions and their implied PPD layer actions.  It is
   2292  *  laid out in a similar way, except that it does not include bit information,
   2293  *  and since the actions are common to all types in a stage, there is only one
   2294  *  row per stage rather than one row per mapping type.
   2295  *
   2296  *  Unlike the qualifier mapping table, which is considered absolute by the
   2297  *  code, both in terms of bit width of qualifiers and bit locations, and in
   2298  *  terms of the qualifier mappings, the action table is merely a hint.  It
   2299  *  tells the code, for example, what PPD actions to include when a BCM action
   2300  *  is included in a group's action set, but it does not force this action to
   2301  *  be the one used.  This key difference is because in some cases, actions can
   2302  *  have GPORT arguments and these GPORTs can imply different actions than the
   2303  *  staged one (redirect to TRAP GPORT, for example, requires PPD layer action
   2304  *  TRAP instead of REDIRECT).
   2305  *
   2306  *  Also, the bits are not included because the arguments are most often
   2307  *  mapped, rather than occasionally mapped as the qualifers are.
   2308  *
   2309  *  THE STRUCT BELOW HAS NO EFFECT WHATSOEVER ON WHAT THE ACTION TABLE PARSER
   2310  *  EXPECTS TO FIND; IT IS HERE ONLY FOR CONVENIENCE.
   2311  *
   2312  *  If you want to change the number of stage/type mappings, you need to adjust
   2313  *  the appropriate _bcm_dpp_field_device_st_mapping_t table, and adjust the
   2314  *  mappings field in the appropriate _bcm_dpp_field_device_info_t as well as
   2315  *  adjusting this structure so it provides the correct number of spaces.  You
   2316  *  must also adjust the qualifier table (above) so it has the correct number
   2317  *  of mappings for each of the actions.
   2318  *
   2319  *  If you change the maximum action chain length, you must adjust the actChain
   2320  *  value in the appropriate _bcm_dpp_field_device_info_t, as well as adjusting
   2321  *  every chain here and corresponding adjustments to every chain for every
   2322  *  qualifier in this table.
   2323  *
   2324  *  The struct definition below is used in _bcm_arad_field_action_info Arad mapping deceleration
   2325  *  table in field_hwconfig.c. Please refer to comments of the table's deceleration
   2326  *  for further explanations and clarifications.
   2327  */
   2328 typedef struct _bcm_arad_field_device_action_info_layer_s {
   2329     int32 bcmAction;          /* BCM layer action to define */
   2330     /* remaining elements are all according to the configuration */
   2331     /* the number of chain members per map is in the device descriptor */
   2332     /* the number of maps is in the device descriptor */
   2333     /* how the maps align to stages,types is in the mappings descriptor */
   2334     int32 ingress_a;
   2335     int32 ingress_b; /* chain 0,1 of stage 0 */
   2336     int32 egress_a;
   2337     int32 egress_b;   /* chain 0,1 of stage 1 */
   2338     int32 ing_flp_a;
   2339     int32 ing_flp_b;   /* chain 0,1 of stage 2 */
   2340     int32 ing_slb_a;
   2341     int32 ing_slb_b;   /* chain 0,1 of stage 3 */
   2342 } _bcm_arad_field_device_action_info_layer_t;
   2343 
   2344 typedef struct _bcm_jericho_added_action_s {
   2345       /*
   2346        * BCM layer action to define
   2347        */
   2348     bcm_field_action_t bcmAction ;
   2349       /* 'added_actions' is a dual index array. One dimention is the 'stage' and
   2350        * the other is the added action.
   2351        * This is, effecctively, a way to extend the length of the chain
   2352        * (See _bcm_arad_field_device_action_info_layer_t) above the hard value
   2353        * of '2' (selectively, on some entries of _bcm_arad_field_action_info).
   2354        * This option is only available for Jericho.
   2355        * Note that, at runtime, in bcm_petra_field_init(), it is verified that
   2356        *   The number of entries on the first index of 'added_actions' is the
   2357        *   same as 'num_stages' on _bcm_jericho_field_added_actions
   2358        *   The number of entries on the first index of 'added_actions'
   2359        *   is the same as 'num_added_actions' on _bcm_jericho_field_added_actions.
   2360        *
   2361        * See _bcm_dpp_field_actions_to_ppd
   2362        */
   2363     SOC_PPC_FP_ACTION_TYPE added_actions[SOC_PPC_NOF_FP_DATABASE_STAGES_ARAD][3] ;
   2364 } _bcm_jericho_field_action_t ;
   2365 
   2366 typedef struct _bcm_jericho_field_added_actions_s {
   2367       /*
   2368        * Number of stages in the 'added_actions' array below.
   2369        */
   2370     SOC_PPC_FP_DATABASE_STAGE num_stages ;
   2371       /*
   2372        * Number of stages in the 'added_actions' array below.
   2373        */
   2374     uint32 num_added_actions ;
   2375       /* 'added_actions_p' is an array whose size id set, at runtime.
   2376        *
   2377        * See _bcm_jericho_field_added_actions and added_action_arr
   2378        */
   2379     _bcm_jericho_field_action_t *added_actions_p ;
   2380 } _bcm_jericho_field_added_actions_t ;
   2381 
   2382 
   2383 extern _bcm_arad_field_device_action_info_layer_t _bcm_arad_field_action_info[];
   2384 extern _bcm_jericho_field_added_actions_t _bcm_jericho_field_added_actions ;
   2385 extern _bcm_jericho_field_action_t _bcm_jericho_field_added_action_arr[] ;
   2386 
   2387 #endif /* def BCM_ARAD_SUPPORT*/
   2388 
   2389 /*
   2390  *  Hardware descriptors
   2391  */
   2392 #ifdef BCM_ARAD_SUPPORT
   2393 extern _bcm_dpp_field_device_info_t _bcm_arad_field_device_info;
   2394 int _bcm_arad_field_get_num_stages(void) ;
   2395 #endif /* def BCM_ARAD_SUPPORT*/
   2396 
   2397 /*
   2398  *  These locals are needed in all of the functions; just type it once.
   2399  */
   2400 #define _DPP_FIELD_COMMON_LOCALS \
   2401     bcm_dpp_field_info_OLD_t *unitData = NULL;          /* unit information */ \
   2402     int                     result = BCM_E_NONE /* working result */
   2403 
   2404 /*
   2405  *  Initial checks for beginning of exposed (BCM layer) functions
   2406  */
   2407 #define _DPP_FIELD_UNIT_CHECK(_unit, _unitData) \
   2408     if ((0 > _unit) || (BCM_MAX_NUM_UNITS <= (_unit))) { \
   2409         BCMDNX_ERR_EXIT_MSG(BCM_E_UNIT, (_BSL_BCM_MSG("invalid unit"))); \
   2410     } \
   2411     (_unitData) = _bcm_dpp_field_unit_info[_unit]; \
   2412     if (!(_unitData)) { \
   2413         BCMDNX_ERR_EXIT_MSG(BCM_E_INIT, (_BSL_BCM_MSG("Uninitialized"))); \
   2414     }
   2415 #define _DPP_FIELD_SET_UNIT_LOCK(_unitData,val) \
   2416     sw_state_sync_db[(_unitData)->unit].dpp.unitLock=val
   2417 #define _DPP_FIELD_GET_UNIT_LOCK(_unitData) \
   2418     sw_state_sync_db[(_unitData)->unit].dpp.unitLock
   2419 #define _DPP_FIELD_UNIT_LOCK(_unitData) \
   2420     if (sal_mutex_take(sw_state_sync_db[(_unitData)->unit].dpp.unitLock, sal_mutex_FOREVER)) { \
   2421         BCMDNX_ERR_EXIT_MSG(BCM_E_INTERNAL, (_BSL_BCM_MSG("unable to take lock"))); \
   2422     }
   2423 #define _DPP_FIELD_UNIT_UNLOCK(_unitData) \
   2424     if (sal_mutex_give(sw_state_sync_db[(_unitData)->unit].dpp.unitLock)) { \
   2425         BCMDNX_ERR_EXIT_MSG(BCM_E_INTERNAL, (_BSL_BCM_MSG("unable to release lock"))); \
   2426     }
   2427 #define DPP_FIELD_UNIT_VALID_CHECK \
   2428     if (!((unit) >= 0 && ((unit) < (BCM_MAX_NUM_UNITS)))) { \
   2429         BCMDNX_ERR_EXIT_MSG(BCM_E_UNIT, (_BSL_BCM_MSG("invalid unit"))); \
   2430     }
   2431 
   2432 #if _BCM_DPP_FIELD_BIT_NUMBER_AS_DUNE
   2433 #define _BCM_DPP_BIT_NUMBER(_bitnum) (_bitnum)
   2434 #else /* _BCM_DPP_FIELD_BIT_NUMBER_AS_DUNE */
   2435 #define _BCM_DPP_BIT_NUM_BIT_PART(_bitnum) ((_bitnum) & 0x7)
   2436 #define _BCM_DPP_BIT_NUM_BYTE_PART(_bitnum) ((_bitnum) & (~(0x7)))
   2437 #define _BCM_DPP_BIT_NUMBER(_bitnum) \
   2438     (_BCM_DPP_BIT_NUM_BYTE_PART(_bitnum) | \
   2439      (7 - _BCM_DPP_BIT_NUM_BIT_PART(_bitnum)))
   2440 #endif /* _BCM_DPP_FIELD_BIT_NUMBER_AS_DUNE */
   2441 
   2442 typedef uint32  _bcm_dpp_core_ports_bitmap_t[SOC_TMC_NOF_FAP_PORTS_PER_CORE];
   2443 
   2444 int
   2445 bcm_dpp_field_get_dev_info(int unit, const _bcm_dpp_field_device_info_t **devInfo);
   2446 /*
   2447  *   Function
   2448  *      _bcm_dpp_field_entry_common_pointer
   2449  *   Purpose
   2450  *      Get pointer to an entry's common information
   2451  *   Parameters
   2452  *      (in) unitData = pointer to unit information
   2453  *      (in) entry = entry ID
   2454  *      (out) entryType = where to put entry type
   2455  *      (out) entryType = where to put entry handle (enabling
   2456  *                        access into data base depending on entry type)
   2457  *   Returns
   2458  *      int (implied cast from bcm_error_t)
   2459  *                    BCM_E_NONE if successful
   2460  *                    BCM_E_* appropriately otherwise
   2461  *   Notes
   2462  *      The common information is the part of the entry descriptor that is
   2463  *      common to all entry types, _bcm_dpp_field_entry_common_t.
   2464  */
   2465 extern int
   2466 _bcm_dpp_field_entry_common_pointer(bcm_dpp_field_info_OLD_t *unitData,
   2467                                     bcm_field_entry_t entry,
   2468                                     _bcm_dpp_field_entry_type_t *entryType,
   2469                                     int32 *entryCommonHandle) ;
   2470 
   2471 extern int
   2472 _bcm_dpp_field_qualify_fwd_decision_to_hw_destination_convert(int unit,
   2473                                                               SOC_PPC_FRWRD_DECISION_INFO   *fwdDecision,
   2474                                                               uint8 is_for_destination,
   2475                                                               uint8 is_for_action,
   2476                                                               uint64 *edata_dest,
   2477                                                               uint64 *emask_dest);
   2478 
   2479 extern int
   2480 _bcm_dpp_field_entry_qualify_uint32_get(int unit,
   2481                                         bcm_field_entry_t entry,
   2482                                         bcm_field_qualify_t type,
   2483                                         uint32 *data,
   2484                                         uint32 *mask);
   2485 
   2486 /*
   2487  *  Function
   2488  *     _bcm_dpp_field_group_hardware_install
   2489  *  Purpose
   2490  *     Insert a Soc_petra PPD group based upon the BCM field group information
   2491  *  Parameters
   2492  *     (in) unitData = unit information
   2493  *     (in) group = group ID
   2494  *     (in) newGroupData = proposed group data for creation of hardware DB
   2495  *  Returns
   2496  *     int (implied cast from bcm_error_t)
   2497  *        BCM_E_NONE if successful
   2498  *        BCM_E_* appropriately if not
   2499  *  Notes
   2500  *     Assumes group validity checks (such as qualifier width and action count)
   2501  *     have already been performed.
   2502  *
   2503  *     Will only work if group exists and both qset and aset have at least one
   2504  *     nonzero bit in them (at least one qualifier and one action).
   2505  *
   2506  *     Will not work if the group has entries.
   2507  *
   2508  *     Will destroy and recreate the hardware group if it already exists.
   2509  */
   2510 extern int
   2511 _bcm_dpp_field_group_hardware_install(bcm_dpp_field_info_OLD_t *unitData,
   2512                                       _bcm_dpp_field_grp_idx_t group,
   2513                                       _bcm_dpp_field_group_t *newGroupData);
   2514 
   2515 /*
   2516  *  Function
   2517  *    _bcm_dpp_field_entry_exists
   2518  *  Purpose
   2519  *    Make sure an entry exists before doing something to/with it
   2520  *  Arguments
   2521  *    (in) unitData = unit information
   2522  *    (in) entry = entry ID
   2523  *  Returns
   2524  *    bcm_error_t cast as int
   2525  *      BCM_E_NONE if entry exists
   2526  *      BCM_E_NOT_FOUND if entry does not exist or bad entry ID
   2527  *      BCM_E_* otherwise as appropriate
   2528  */
   2529 extern int
   2530 _bcm_dpp_field_entry_exists(bcm_dpp_field_info_OLD_t *unitData,
   2531                             bcm_field_entry_t entry);
   2532 
   2533 /*
   2534  *  Function
   2535  *    _bcm_dpp_field_entry_qualifier_get_single
   2536  *  Purpose
   2537  *    Get a single qualifier on an entry
   2538  *  Arguments
   2539  *    (in) unitData = unit information
   2540  *    (in) entry = entry ID
   2541  *    (in) hwType = PPD layer qualifier to add to the entry
   2542  *    (out) data = where to put data value
   2543  *    (out) mask = where to put mask value
   2544  *  Returns
   2545  *    bcm_error_t cast as int
   2546  *      BCM_E_NONE if success
   2547  *      BCM_E_* otherwise as appropriate
   2548  *  Notes
   2549  *    Caller must already hold the unit lock.
   2550  *
   2551  *    Assumes entry exists in a group.
   2552  *
   2553  *    Caller can choose what bits are desired after return.
   2554  */
   2555 extern int
   2556 _bcm_dpp_field_entry_qualifier_get_single(bcm_dpp_field_info_OLD_t *unitData,
   2557                                           bcm_field_entry_t entry,
   2558                                           SOC_PPC_FP_QUAL_TYPE hwType,
   2559                                           uint64 *data,
   2560                                           uint64 *mask);
   2561 
   2562 /*
   2563  *  Function
   2564  *     _bcm_dpp_field_entry_qualifier_get
   2565  *  Purpose
   2566  *     Get a qualifier from an entry
   2567  *  Parameters
   2568  *     (in) unitData = unit information
   2569  *     (in) entry = entry ID
   2570  *     (in) qual = BCM qualifier type
   2571  *     (in) count = number of elements in qualifier data/mask arrays
   2572  *     (out) data = where to put qualifier data
   2573  *     (out) mask = where to put qualifier mask
   2574  *  Returns
   2575  *     int (implied cast from bcm_error_t)
   2576  *        BCM_E_NONE if successful
   2577  *        BCM_E_* appropriately if not
   2578  *  Notes
   2579  *     Caller must already hold the unit lock.
   2580  *
   2581  *     Considers it BCM_E_CONFIG to manipulate qualifiers that are not in the
   2582  *     QSET for the entry's group.
   2583  *
   2584  *     Performs similar shifting and concatenation to the set function,
   2585  *     shifting the first PPD qualifier right so its appropriate bit aligns to
   2586  *     the LSb of the BCM qualifier, and then concatenating further PPD
   2587  *     qualifiers to the left until it has fully build any complex qualifier.
   2588  *
   2589  *     If the array is not large enough, any more significant bits (leftward)
   2590  *     that do not fit in the provided array will not be returned.  This will
   2591  *     not change the actual value stored, but may omit bits from the read.  It
   2592  *     does not return an error for this condition, but it does emit a warning.
   2593  *     It will also emit a warning if there are too many buffer elements.
   2594  *
   2595  *     The array is little-endian with 64b grains: least significant octbyte is
   2596  *     array[0], then next more significant is array[1], and so on.  Within
   2597  *     array elements, the data are in machine-native order.
   2598  *
   2599  *     Will overwrite caller provided buffer, possibly only partially, even in
   2600  *     certain error situations.
   2601  */
   2602 extern int
   2603 _bcm_dpp_field_entry_qualifier_get(bcm_dpp_field_info_OLD_t *unitData,
   2604                                    bcm_field_entry_t entry,
   2605                                    bcm_field_qualify_t type,
   2606                                    int count,
   2607                                    uint64 *data,
   2608                                    uint64 *mask);
   2609 
   2610 /*
   2611  *   Function
   2612  *      _bcm_dpp_proc_cntr_from_stat
   2613  *   Purpose
   2614  *      decode stat id into proc and ctr
   2615  *   Parameters
   2616  *      (in) int            unit = the unit
   2617  *      (in)int             stat
   2618  *      (out) unsigned int   proc = the processor
   2619  *      (out) unsigned int   cntr = the cntr index
   2620  *   Returns
   2621  *      int (implied cast from bcm_error_t)
   2622  *                    BCM_E_NONE if successful
   2623  *                    BCM_E_* appropriately otherwise
   2624  */
   2625 extern int
   2626 _bcm_dpp_proc_cntr_from_stat(int unit,
   2627                              int stat,
   2628                              unsigned int *proc,
   2629                              unsigned int *cntr);
   2630 
   2631 
   2632 /******************************************************************************
   2633  *
   2634  *  Exports from submodules (see submodules for code comments)
   2635  */
   2636 
   2637 /* -- field_utils.c -- */
   2638 
   2639 /*
   2640  *   Function
   2641  *      _bcm_dpp_ppd_qual_bits
   2642  *   Purpose
   2643  *      Figure out how many bits in a PPD layer qualifier
   2644  *   Parameters
   2645  *      (in) unitData = unit information
   2646  *      (in) stage = stage for the group
   2647  *      (in) ppdQual = PPD layer qualifier
   2648  *      (out) exposed = API exposed bits
   2649  *      (out) hardwareBestCase = bits taken by the qualifier in hardware in the best case
   2650  *      (out) hardwareWorstCase = bits taken by the qualifier in hardware in the worst case
   2651  *   Returns
   2652  *      int (implied cast from bcm_error_t)
   2653  *                    BCM_E_NONE if valid
   2654  *                    BCM_E_* appropriately otherwise
   2655  *   Notes
   2656  */
   2657 extern int
   2658 _bcm_dpp_ppd_qual_bits(int  unit,
   2659                        _bcm_dpp_field_stage_idx_t stage,
   2660                        SOC_PPC_FP_QUAL_TYPE ppdQual,
   2661                        unsigned int *exposed,
   2662                        unsigned int *hardwareBestCase,
   2663                        unsigned int *hardwareWorstCase);
   2664 
   2665 /*
   2666  *   Function
   2667  *      _bcm_dpp_ppd_action_bits
   2668  *   Purpose
   2669  *      Figure out how many bits in a PPD layer action
   2670  *   Parameters
   2671  *      (in) unitData = unit information
   2672  *      (in) stage = stage for the action
   2673  *      (in) ppdAct = PPD layer action
   2674  *      (out) bits = action bits
   2675  *   Returns
   2676  *      int (implied cast from bcm_error_t)
   2677  *                    BCM_E_NONE if valid
   2678  *                    BCM_E_* appropriately otherwise
   2679  *   Notes
   2680  */
   2681 extern int
   2682 _bcm_dpp_ppd_action_bits(int unit,
   2683                          _bcm_dpp_field_stage_idx_t stage,
   2684                          SOC_PPC_FP_ACTION_TYPE ppdAct,
   2685                          unsigned int *bits);
   2686 
   2687 #ifdef BROADCOM_DEBUG
   2688 /*
   2689  *  Function
   2690  *    _bcm_dpp_field_qset_dump
   2691  *  Purpose
   2692  *    Dump qualifier list from a qset
   2693  *  Parameters
   2694  *    (in) bcm_field_qset_t qset = the qset to dump
   2695  *    (in) char *prefix = line prefix
   2696  *  Returns
   2697  *    nothing
   2698  *  Notes
   2699  *    No error checking or locking is done here.
   2700  */
   2701 void
   2702 _bcm_dpp_field_qset_dump(const bcm_field_qset_t qset,
   2703                          const char *prefix);
   2704 /*
   2705  *  Function
   2706  *    _bcm_dpp_field_aset_dump
   2707  *  Purpose
   2708  *    Dump action list from an aset
   2709  *  Parameters
   2710  *    (in) bcm_field_aset_t aset = the aset to dump
   2711  *    (in) char *prefix = line prefix
   2712  *  Returns
   2713  *    nothing
   2714  *  Notes
   2715  *    No error checking or locking is done here.
   2716  */
   2717 void
   2718 _bcm_dpp_field_aset_dump(const bcm_field_aset_t *aset,
   2719                          const char *prefix);
   2720 /*
   2721  *  Function
   2722  *    _bcm_dpp_field_hfset_dump
   2723  *  Purpose
   2724  *    Dump action list from an header format set
   2725  *  Parameters
   2726  *    (in) bcm_field_header_format_set_t hfset = the hfset to dump
   2727  *    (in) char *prefix = line prefix
   2728  *  Returns
   2729  *    nothing
   2730  *  Notes
   2731  *    No error checking or locking is done here.
   2732  */
   2733 extern void
   2734 _bcm_dpp_field_hfset_dump(const bcm_field_header_format_set_t hfset,
   2735                           const char *prefix);
   2736 #endif /* def BROADCOM_DEBUG */
   2737 
   2738 
   2739 /* Conversion from PPD Trap id to HW trap id */
   2740 extern int
   2741 _bcm_dpp_field_trap_ppd_to_hw(int unit,
   2742                               int trap_id,
   2743                               uint32 *hwTrapCode);
   2744 
   2745 /* Conversion from PPD Trap id from HW trap id */
   2746 extern int
   2747 _bcm_dpp_field_trap_ppd_from_hw(int unit,
   2748                                 uint32 hwTrapCode,
   2749                                 SOC_PPC_TRAP_CODE *ppdTrapCode);
   2750 
   2751 /* Convert from gport of type LIF to global LIF-Id */
   2752 extern int
   2753 _bcm_dpp_field_gport_to_global_lif_convert(int unit,
   2754                                            bcm_gport_t  lif_gport,
   2755                                            uint8        is_global_inlif,
   2756                                            uint32      *global_lif);
   2757 
   2758 /* Convert from gport of type LIF to local LIF-Id */
   2759 extern int
   2760 _bcm_dpp_field_gport_to_local_lif_convert(int unit,
   2761                                           bcm_gport_t  lif_gport,
   2762                                           uint8        is_local_inlif,
   2763                                           uint32       *local_lif);
   2764 
   2765 /*
   2766  *  Function
   2767  *    _bcm_dpp_field_HeaderFormatExtension_bcm_to_ppd
   2768  *  Purpose
   2769  *    Translate BCM HeaderFormatExtension (PLC - Parser Leaf Context) to correspondig low level (PPD) value.
   2770  *  Parameters
   2771  *    (in) header_format_extension = BCM-level header format extension (PLC)
   2772  *    (out) pfc_sw_p       = PPD level sw value which is the equivalent of 'header_format_extension'
   2773  *  Returns
   2774  *    bcm_error_t (cast as int)
   2775  *      BCM_E_NONE for success
   2776  *      BCM_E_* otherwise as appropriate
   2777  */
   2778 int
   2779 _bcm_dpp_field_HeaderFormatExtension_bcm_to_ppd(bcm_field_header_format_extension_t header_format_extension,
   2780                                        DPP_PLC_E *plc_sw_p);
   2781 
   2782 /*
   2783  *  Function
   2784  *    _bcm_dpp_field_HeaderFormatExtension_ppd_to_bcm
   2785  *  Purpose
   2786  *    Translate PPD-level PLC (DPP_PLC_E) to BCM-level HeaderFormatExtension
   2787  *  Parameters
   2788  *    (in) plc_sw = PPD-level header format extension (PLC)
   2789  *    (out) header_format_extension_p = BCM-level header format extension
   2790  *  Returns
   2791  *    bcm_error_t (cast as int)
   2792  *      BCM_E_NONE for success
   2793  *      BCM_E_* otherwise as appropriate
   2794  */
   2795 int
   2796 _bcm_dpp_field_HeaderFormatExtension_ppd_to_bcm(DPP_PLC_E plc_sw,
   2797                                        bcm_field_header_format_extension_t *header_format_extension_p);
   2798 
   2799 /*
   2800  *  Function
   2801  *    _bcm_dpp_field_HeaderFormat_bcm_to_ppd
   2802  *  Purpose
   2803  *    Translate BCM HeaderFormat to correspondig PFC HW parameters (value and mask).
   2804  *    When these values are loaded into HW, BCM HeaderFormat is implemented.
   2805  *  Parameters
   2806  *    (in) header_format = BCM header format
   2807  *    (out) pfc_sw_p       = PPD level sw value which is the equivalent of 'header_format'
   2808  *    (out) pfc_pmf_p      = PFC (headerFormat) value to load into HW to implement 'header_format'
   2809  *    (out) pfc_pmf_mask_p = PFC (headerFormat) mask to load into HW to implement 'header_format'
   2810  *  Returns
   2811  *    bcm_error_t (cast as int)
   2812  *      BCM_E_NONE for success
   2813  *      BCM_E_* otherwise as appropriate
   2814  */
   2815 extern int
   2816 _bcm_dpp_field_HeaderFormat_bcm_to_ppd(int unit,
   2817                                        bcm_field_header_format_t header_format,
   2818                                        DPP_PFC_E *pfc_sw_p,
   2819                                        uint32 *pfc_pmf_p,
   2820                                        uint32 *pfc_pmf_mask_p);
   2821 
   2822 /*
   2823  *  Function
   2824  *    _bcm_dpp_field_HeaderFormat_ppd_to_bcm
   2825  *  Purpose
   2826  *    Translate PPD PKT_HDR_STK_TYPE to BCM HeaderFormat
   2827  *  Parameters
   2828  *    (in) hdr_stk_type = PPD header stack type
   2829  *    (out) header_format = BCM header format
   2830  *  Returns
   2831  *    bcm_error_t (cast as int)
   2832  *      BCM_E_NONE for success
   2833  *      BCM_E_* otherwise as appropriate
   2834  */
   2835 extern int
   2836 _bcm_dpp_field_HeaderFormat_ppd_to_bcm(int unit,
   2837                                        uint32 pfc_pmf,
   2838                                        uint32 pfc_pmf_mask,
   2839                                        bcm_field_header_format_t *header_format);
   2840 
   2841 /*
   2842  *  Function
   2843  *    _bcm_dpp_field_color_bcm_to_ppd
   2844  *  Purpose
   2845  *    Translate a BCM frame color to PPD frame color
   2846  *  Arguments
   2847  *    (in) bcmCol = BCM frame color
   2848  *    (out) ppdCol = where to put the PPD color
   2849  *  Returns
   2850  *      int (implied cast from bcm_error_t)
   2851  *                    BCM_E_NONE if successful
   2852  *                    BCM_E_* appropriately otherwise
   2853  */
   2854 extern int
   2855 _bcm_dpp_field_color_bcm_to_ppd(int bcmCol,
   2856                                 uint32 *ppdCol);
   2857 
   2858 /*
   2859  *  Function
   2860  *    _bcm_dpp_field_color_bcm_to_ppd
   2861  *  Purpose
   2862  *    Translate a PPD frame color to BCM frame color
   2863  *  Arguments
   2864  *    (in) ppdCol = PPD frame color
   2865  *    (out) bcmCol = where to put the BCM color
   2866  *  Returns
   2867  *      int (implied cast from bcm_error_t)
   2868  *                    BCM_E_NONE if successful
   2869  *                    BCM_E_* appropriately otherwise
   2870  */
   2871 extern int
   2872 _bcm_dpp_field_color_ppd_to_bcm(uint32 ppdCol,
   2873                                 int *bcmCol);
   2874 
   2875 extern int
   2876 _bcm_dpp_field_arp_opcode_bcm_to_ppd(bcm_field_ArpOpcode_t bcmArpOpcode,
   2877                                 uint32 *ppdArpOpcode);
   2878 extern int
   2879 _bcm_dpp_field_arp_opcode_ppd_to_bcm(bcm_field_ArpOpcode_t ppdArpOpcode,
   2880                                 bcm_field_ArpOpcode_t *bcmArpOpcode);
   2881 
   2882 /*
   2883  *  Function
   2884  *    _bcm_dpp_field_stp_state_bcm_to_ppd
   2885  *  Purpose
   2886  *    Translate a BCM STP state to PPD STP state
   2887  *  Arguments
   2888  *    (in) bcmStp = BCM STP state
   2889  *    (out) ppdStp = where to put the PPD STP state
   2890  *  Returns
   2891  *      int (implied cast from bcm_error_t)
   2892  *                    BCM_E_NONE if successful
   2893  *                    BCM_E_* appropriately otherwise
   2894  */
   2895 extern int
   2896 _bcm_dpp_field_stp_state_bcm_to_ppd(bcm_stg_stp_t bcmStp,
   2897                                     SOC_PPC_PORT_STP_STATE_FLD_VAL *ppdStp);
   2898 
   2899 /*
   2900  *  Function
   2901  *    _bcm_dpp_field_stp_state_ppd_to_bcm
   2902  *  Purpose
   2903  *    Translate a BCM STP state from PPD STP state
   2904  *  Arguments
   2905  *    (in) ppdStp = PPD STP state
   2906  *    (out) bcmStp = where to put the BCM STP state
   2907  *  Returns
   2908  *      int (implied cast from bcm_error_t)
   2909  *                    BCM_E_NONE if successful
   2910  *                    BCM_E_* appropriately otherwise
   2911  */
   2912 extern int
   2913 _bcm_dpp_field_stp_state_ppd_to_bcm(SOC_PPC_PORT_STP_STATE_FLD_VAL ppdStp,
   2914                                     bcm_stg_stp_t *bcmStp);
   2915 
   2916 /*
   2917  *  Function
   2918  *    _bcm_dpp_field_ip_type_bcm_to_ppd
   2919  *  Purpose
   2920  *    Translate a BCM IP Type to PPD IP Type
   2921  *  Arguments
   2922  *    (in) bcmIpType = BCM IP Type
   2923  *    (out) ppdIpType = where to put the PPD IP Type
   2924  *  Returns
   2925  *      int (implied cast from bcm_error_t)
   2926  *                    BCM_E_NONE if successful
   2927  *                    BCM_E_* appropriately otherwise
   2928  */
   2929 extern int
   2930 _bcm_dpp_field_ip_type_bcm_to_ppd(bcm_field_IpType_t bcmIpType,
   2931                                   uint8 is_egress,
   2932                                     SOC_PPC_FP_PARSED_ETHERTYPE *ppdIpType);
   2933 
   2934 extern int
   2935 _bcm_dpp_field_ip_type_ppd_to_bcm(SOC_PPC_FP_PARSED_ETHERTYPE ppdIpType,
   2936                                   uint8 is_egress,
   2937                                     bcm_field_IpType_t *bcmIpType);
   2938 
   2939 extern int
   2940 _bcm_dpp_field_ip_next_protocol_bcm_to_ppd(bcm_field_IpProtocolCommon_t bcmIpNextProtocol,
   2941                                     SOC_PPC_FP_PARSED_IP_NEXT_PROTOCOL *ppdIpNextProtocol, uint64 *emask);
   2942 
   2943 extern int
   2944 _bcm_dpp_field_ip_next_protocol_ppd_to_bcm(SOC_PPC_FP_PARSED_IP_NEXT_PROTOCOL ppdIpNextProtocol,
   2945                                     bcm_field_IpProtocolCommon_t *bcmIpNextProtocol, int32 emask);
   2946 
   2947 extern int
   2948 _bcm_dpp_field_termination_type_bcm_to_ppd(bcm_field_TunnelType_t bcmTerminationType,
   2949                                            SOC_PPC_PKT_TERM_TYPE *ppdTerminationType);
   2950 
   2951 extern int
   2952 _bcm_dpp_field_termination_type_ppd_to_bcm(SOC_PPC_PKT_TERM_TYPE ppdTerminationType,
   2953                                            bcm_field_TunnelType_t *bcmTerminationType);
   2954 
   2955 extern int
   2956 _bcm_dpp_field_l2_eth_format_ppd_to_bcm(SOC_PPC_FP_ETH_ENCAPSULATION ppdL2Format,
   2957                                         bcm_field_L2Format_t *bcmL2Format);
   2958 
   2959 extern int
   2960 _bcm_dpp_field_l2_eth_format_bcm_to_ppd(bcm_field_L2Format_t bcmL2Format,
   2961                                     SOC_PPC_FP_ETH_ENCAPSULATION *ppdL2Format);
   2962 
   2963 extern int
   2964 _bcm_dpp_field_forwarding_type_ppd_to_bcm(int unit,
   2965                                           SOC_TMC_PKT_FRWRD_TYPE ppdForwardingType,
   2966                                           uint32 ppdMask,
   2967                                           bcm_field_ForwardingType_t *bcmForwardingType);
   2968 
   2969 extern int
   2970 _bcm_dpp_field_forwarding_type_bcm_to_ppd(bcm_field_ForwardingType_t bcmForwardingType,
   2971                                           SOC_TMC_PKT_FRWRD_TYPE *ppdForwardingType,
   2972                                           uint32 *ppdMask);
   2973 
   2974 extern int
   2975 _bcm_dpp_field_app_type_bcm_to_ppd(int unit,
   2976                                    bcm_field_AppType_t bcmAppType,
   2977                                    uint32 *ppd_flp_program);
   2978 extern int
   2979 _bcm_dpp_field_app_type_ppd_to_bcm(int unit,
   2980                                           uint32 ppd_flp_program,
   2981                                           bcm_field_AppType_t *bcmAppType);
   2982 
   2983 extern int
   2984 _bcm_dpp_field_offset_ext_ppd_to_bcm(uint32 ppdOffsetExtData, uint32 ppdOffsetExtMask,
   2985                                           bcm_field_ForwardingType_t *bcmForwardingType);
   2986 
   2987 extern int
   2988 _bcm_dpp_field_offset_ext_bcm_to_ppd(bcm_field_ForwardingType_t bcmForwardingType,
   2989                                         uint32 *ppdOffsetExtData, uint32 *ppdOffsetExtMask);
   2990 
   2991 extern int
   2992 _bcm_dpp_field_vlan_format_bcm_to_ppd(uint8 bcmVlanFormatBitmap,
   2993                                       SOC_SAND_PP_ETHERNET_FRAME_VLAN_FORMAT *ppdVlanFormat);
   2994 
   2995 extern int
   2996 _bcm_dpp_field_vlan_format_ppd_to_bcm(SOC_SAND_PP_ETHERNET_FRAME_VLAN_FORMAT ppdVlanFormat,
   2997                                           uint8 *bcmVlanFormatBitmap);
   2998 
   2999 extern int
   3000 _bcm_dpp_field_base_header_bcm_to_ppd(bcm_field_data_offset_base_t bcm_base_header,
   3001                                       uint32 *ppd_base_header);
   3002 
   3003 extern int
   3004 _bcm_dpp_field_base_header_ppd_to_bcm(uint32 ppd_base_header,
   3005                                       bcm_field_data_offset_base_t *bcm_base_header);
   3006 
   3007 /*
   3008  *  Function
   3009  *    _bcm_dpp_field_ip_frag_bcm_to_ppd
   3010  *  Purpose
   3011  *    Translate a BCM IP Frag to PPD IP Frag
   3012  *  Arguments
   3013  *    (in) bcmFragInfo = BCM IP Frag
   3014  *    (out) ppdIpFragmented = if fragmented or not
   3015  *  Returns
   3016  *      int (implied cast from bcm_error_t)
   3017  *                    BCM_E_NONE if successful
   3018  *                    BCM_E_* appropriately otherwise
   3019  */
   3020 extern int
   3021 _bcm_dpp_field_ip_frag_bcm_to_ppd(int unit, bcm_field_IpFrag_t bcmFragInfo,
   3022                                     uint8 *ppdIpFragmented);
   3023 
   3024 /*
   3025  *  Function
   3026  *    _bcm_dpp_field_ip_frag_ppd_to_bcm
   3027  *  Purpose
   3028  *    Translate a BCM IP Frag from PPD IP Frag
   3029  *  Arguments
   3030  *    (in) ppdIpFragmented = if fragmented or not
   3031  *    (out) bcmFragInfo = BCM IP Frag
   3032  *  Returns
   3033  *      int (implied cast from bcm_error_t)
   3034  *                    BCM_E_NONE if successful
   3035  *                    BCM_E_* appropriately otherwise
   3036  */
   3037 extern int
   3038 _bcm_dpp_field_ip_frag_ppd_to_bcm(int unit, uint8 ppdIpFragmented,
   3039                                     bcm_field_IpFrag_t *bcmFragInfo);
   3040 
   3041 /* Convert from Gport to PP-port and TM-Port */
   3042 extern int
   3043 _bcm_dpp_field_gport_to_pp_port_tm_port_convert(int unit,
   3044                                                 bcm_port_t data,
   3045                                                 uint32 *pp_port,
   3046                                                 uint32 *tm_port,
   3047                                                 int *core);
   3048 int
   3049 _bcm_dpp_field_group_id_to_name(int unit, 
   3050                                     _bcm_dpp_field_grp_idx_t group,
   3051                                     char *group_name, 
   3052                                     int max_length);
   3053 
   3054 int
   3055 _bcm_dpp_field_group_hw_handle_to_name(int unit, 
   3056                                     uint32 hw_handle,
   3057                                     char *group_name, 
   3058                                     int max_length);
   3059 
   3060 int
   3061 _bcm_dpp_field_dump_single_qual_name(int unit,
   3062                                      int qual_id,
   3063                                      char *qual_name,
   3064                                      int max_length);
   3065 int
   3066 _bcm_dpp_field_dump_single_presel_name(int unit,
   3067                                        bcm_field_presel_t presel_id,
   3068                                        char *presel_name,
   3069                                        int max_length);
   3070 
   3071 #ifdef BROADCOM_DEBUG
   3072 /*
   3073  *   Function
   3074  *      _bcm_dpp_field_entry_qual_dump
   3075  *   Purpose
   3076  *      Dump the state of a single qualifier for a field entry
   3077  *   Parameters
   3078  *      (in) unitData = unit information
   3079  *      (in) stage = stage where entry exists
   3080  *      (in) qualData = pointer to the qualifier data for the entry
   3081  *      (in) qualHwData = pointer to the hardware qualifier data for the entry
   3082  *      (in) index = which qualifier to dump
   3083  *      (in) dumpRanges = TRUE if L4 port range qualifier is to be dumped
   3084  *      (in) prefix = string to prefix to each line
   3085  *   Returns
   3086  *      int (implied cast from bcm_error_t)
   3087  *                    BCM_E_NONE if successful
   3088  *                    BCM_E_* appropriately otherwise
   3089  *   Notes
   3090  */
   3091 int
   3092 _bcm_dpp_field_entry_qual_dump(bcm_dpp_field_info_OLD_t *unitData,
   3093                                _bcm_dpp_field_stage_idx_t stage,
   3094                                const _bcm_dpp_field_qual_t *qualData,
   3095 #if _BCM_DPP_FIELD_DUMP_VERIFY_PPD
   3096                                const SOC_PPC_FP_QUAL_VAL *qualHwData,
   3097 #endif
   3098                                unsigned int index,
   3099                                int dumpRanges,
   3100                                const char *prefix);
   3101 #endif /* def BROADCOM_DEBUG */
   3102 
   3103 #ifdef BROADCOM_DEBUG
   3104 /*
   3105  *   Function
   3106  *      _bcm_dpp_field_group_dump
   3107  *   Purpose
   3108  *      Dump the state of a specific field group
   3109  *   Parameters
   3110  *      (in) unitData = unit information
   3111  *      (in) group = group to be dumped
   3112  *      (in) prefix = string to prefix to each line
   3113  *      (in) entries = TRUE to include entries, FALSE to exclude entries
   3114  *   Returns
   3115  *      int (implied cast from bcm_error_t)
   3116  *                    BCM_E_NONE if successful
   3117  *                    BCM_E_* appropriately otherwise
   3118  *   Notes
   3119  */
   3120 extern int
   3121 _bcm_dpp_field_group_dump(bcm_dpp_field_info_OLD_t *unitData,
   3122                           _bcm_dpp_field_grp_idx_t group,
   3123                           const char *prefix,
   3124                           int entries);
   3125 #endif /* def BROADCOM_DEBUG */
   3126 
   3127 #ifdef BROADCOM_DEBUG
   3128 /*
   3129  *   Function
   3130  *      _bcm_dpp_field_unit_dump
   3131  *   Purpose
   3132  *      Dump the state of the unit
   3133  *   Parameters
   3134  *      (in) unitData = unit information
   3135  *      (in) prefix = string to prefix to each line
   3136  *      (in) stages = TRUE to include stages, FALSE to exclude stages
   3137  *      (in) groups = TRUE to include groups, FALSE to exclude groups
   3138  *      (in) entries = TRUE to include entries, FALSE to exclude entries
   3139  *   Returns
   3140  *      int (implied cast from bcm_error_t)
   3141  *                    BCM_E_NONE if successful
   3142  *                    BCM_E_* appropriately otherwise
   3143  *   Notes
   3144  *      If groups is FALSE, the value of entries does not matter: entries will
   3145  *      not be displayed if groups are not displayed.
   3146  *
   3147  *      If stages is FALSE, the values of groups and entries do not matter;
   3148  *      neither groups nor entries will be displayed if stages are not
   3149  *      displayed.
   3150  */
   3151 extern int
   3152 _bcm_dpp_field_unit_dump(bcm_dpp_field_info_OLD_t *unitData,
   3153                          const char *prefix,
   3154                          int stages,
   3155                          int groups,
   3156                          int entries);
   3157 #endif /* def BROADCOM_DEBUG */
   3158 
   3159 /*
   3160  *   Function
   3161  *      _bcm_dpp_compare_entry_priority
   3162  *   Purpose
   3163  *      Compare two entry priorities.  This returns -1 if the first is less
   3164  *      than the second, 0 if the first is equal to the second (or if either
   3165  *      priority is not valid), 1 if the first is greater than the second.
   3166  *   Parameters
   3167  *      (in) int pri1 = first priority to compare
   3168  *      (in) int pri2 = second priority to compare
   3169  *   Returns
   3170  *      signed int = 0 if priorities are equal
   3171  *                   >0 if pri1 is higher priority than pri2
   3172  *                   <0 if pri1 is lower priority than pri2
   3173  *   Notes
   3174  *      Valid priorities are: 0..MAXINT.
   3175  *
   3176  *      The actual mapping of the priorities is (from highest priority to
   3177  *      lowest priority): MAXINT down to 0.
   3178  *
   3179  *      If a priority is invalid and the other is valid, the valid one is
   3180  *      considered greater; if they're both invalid, they're considered equal.
   3181  *
   3182  *      Unhappily, this gets called a lot and it involves a lot of branches and
   3183  *      obligatorily sequential decisions as written. It'd be better if this
   3184  *      could be written in assembly, using inline, or made somehow otherwise
   3185  *      more optimal; maybe later?  It does early returns and boolean
   3186  *      short-circuiting where reasonable; this should help some.
   3187  */
   3188 extern signed int
   3189 _bcm_dpp_compare_entry_priority(int pri1,
   3190                                 int pri2);
   3191 
   3192 /*
   3193  *   Function
   3194  *      _bcm_dpp_field_qset_subset
   3195  *   Purpose
   3196  *      Check whether qset2 is a subset of qset1.
   3197  *   Parameters
   3198  *      (in) bcm_field_qset_t qset1 = qualifier set 1
   3199  *      (in) bcm_field_qset_t qset2 = qualifier set 2
   3200  *   Returns
   3201  *      int (implied cast from bcm_error_t)
   3202  *                    BCM_E_NONE if qset2 is subset of qset1
   3203  *                    BCM_E_FAIL if qset2 is not subset of qset1
   3204  *   Notes
   3205  *      This checks whether qset2 is a subset, either proper and improper, of
   3206  *      qset1, and returns BCM_E_NONE if qset2 is a subset of qset1, but
   3207  *      returns BCM_E_FAIL if qset2 is not a subset of qset1.  Other errors may
   3208  *      be returned under appropriate conditions.
   3209  */
   3210 extern int
   3211 _bcm_dpp_field_qset_subset(bcm_field_qset_t qset1,
   3212                            bcm_field_qset_t qset2);
   3213 
   3214 /*
   3215  *   Function
   3216  *      _bcm_dpp_field_qset_union
   3217  *   Purpose
   3218  *      Build union of two QSETs
   3219  *   Parameters
   3220  *      (in) qset0 = qualifier set 0
   3221  *      (in) qset1 = qualifier set 1
   3222  *      (out) qset2 = where to put union of qset0 and qset1
   3223  *   Returns
   3224  *      (none)
   3225  *   Notes
   3226  */
   3227 extern void
   3228 _bcm_dpp_field_qset_union(const bcm_field_qset_t *qset0,
   3229                           const bcm_field_qset_t *qset1,
   3230                           bcm_field_qset_t *qset2);
   3231 
   3232 /*
   3233  *   Function
   3234  *     _bcm_dpp_field_qset_subset_count
   3235  *   Purpose
   3236  *     Determine the number of qualifiers in each of two qsets, and in the
   3237  *     intersection of those two qsets
   3238  *   Parameters
   3239  *     (in) bcm_field_qset_t qset0 = base qset (proposed subset)
   3240  *     (in) bcm_field_qset_t qset1 = one of the qsets to check
   3241  *     (out) unsigned int *qual0 = where to put qset0 qualifier count
   3242  *     (out) unsigned int *qual1 = where to put qset1 qualifier count
   3243  *     (out) unsigned int *qual2 = where to put intersection qualifier count
   3244  *   Returns
   3245  *      (none)
   3246  *   Notes
   3247  */
   3248 extern void
   3249 _bcm_dpp_field_qset_subset_count(const bcm_field_qset_t *qset0,
   3250                                  const bcm_field_qset_t *qset1,
   3251                                  unsigned int *qual0,
   3252                                  unsigned int *qual1,
   3253                                  unsigned int *qualBoth);
   3254 
   3255 /*
   3256  *   Function
   3257  *      _bcm_dpp_field_aset_subset
   3258  *   Purpose
   3259  *      Check whether aset2 is a subset of aset1.
   3260  *   Parameters
   3261  *      (in) bcm_field_qset_t aset1 = action set 1
   3262  *      (in) bcm_field_qset_t aset2 = action set 2
   3263  *   Returns
   3264  *      int (implied cast from bcm_error_t)
   3265  *                    BCM_E_NONE if aset2 is subset of aset1
   3266  *                    BCM_E_FAIL if aset2 is not subset of aset1
   3267  *   Notes
   3268  *      This checks whether aset2 is a subset, either proper and improper, of
   3269  *      aset1, and returns BCM_E_NONE if aset2 is a subset of aset1, but
   3270  *      returns BCM_E_FAIL if aset2 is not a subset of aset1.  Other errors may
   3271  *      be returned under appropriate conditions.
   3272  */
   3273 extern int
   3274 _bcm_dpp_field_aset_subset(bcm_field_aset_t *aset1,
   3275                            bcm_field_aset_t *aset2);
   3276 
   3277 /*
   3278  *   Function
   3279  *      _bcm_dpp_field_aset_union
   3280  *   Purpose
   3281  *      Build union of two ASETs
   3282  *   Parameters
   3283  *      (in) aset0 = action set 0
   3284  *      (in) aset1 = action set 1
   3285  *      (out) aset2 = where to put union of aset0 and aset1
   3286  *   Returns
   3287  *      (none)
   3288  *   Notes
   3289  */
   3290 extern void
   3291 _bcm_dpp_field_aset_union(bcm_field_aset_t *aset0,
   3292                           bcm_field_aset_t *aset1,
   3293                           bcm_field_aset_t *aset2);
   3294 
   3295 /*
   3296  *   Function
   3297  *      _bcm_dpp_ppd_act_from_bcm_act
   3298  *   Purpose
   3299  *      Translate a BCM layer action to a PPD layer action
   3300  *   Parameters
   3301  *      (in) unitData = unit information
   3302  *      (in) stage = stage for the group
   3303  *      (in) bcmAct = BCM layer action
   3304  *      (out) ppdAct = where to put PPD layer action
   3305  *   Returns
   3306  *      int (implied cast from bcm_error_t)
   3307  *                    BCM_E_NONE if success
   3308  *                    BCM_E_CONFIG if not supported for the group config
   3309  *                    BCM_E_FAIL if mapping is special
   3310  *                    BCM_E_* appropriately otherwise
   3311  *   Notes
   3312  *      Does not require lock to be held.
   3313  *
   3314  *      It could be done with a (very) large table instead.
   3315  *
   3316  *      Some qualifiers are supported in some places but not others.
   3317  *
   3318  *      Does not deal with qualifiers used only as group flags.
   3319  *
   3320  *      Would look simpler and run faster as a table, except that the table has
   3321  *      at least three dimensions and is quite sparse, so is probably more
   3322  *      efficient in terms of overall size to have it in this form (not to
   3323  *      mention the trouble of initializing such a table).
   3324  */
   3325 extern int
   3326 _bcm_dpp_ppd_act_from_bcm_act(bcm_dpp_field_info_OLD_t *unitData,
   3327                               _bcm_dpp_field_stage_idx_t stage,
   3328                               bcm_field_action_t bcmAct,
   3329                               SOC_PPC_FP_ACTION_TYPE **ppdAct);
   3330 
   3331 /*
   3332  *   Function
   3333  *      _bcm_dpp_ppd_qual_from_bcm_qual
   3334  *   Purpose
   3335  *      Translate a BCM layer qualifier to a PPD layer qualifier
   3336  *   Parameters
   3337  *      (in) unitData = unit information
   3338  *      (in) stage = stage for the group
   3339  *      (in) types = bitmap of types to check for this qualifier
   3340  *      (in) bcmQual = BCM layer qualifier
   3341  *      (out) ppdQual = where to put PPD layer qualifier
   3342  *   Returns
   3343  *      int (implied cast from bcm_error_t)
   3344  *                    BCM_E_NONE if success
   3345  *                    BCM_E_CONFIG if not supported for the group config
   3346  *                    BCM_E_FAIL if mapping is special
   3347  *                    BCM_E_* appropriately otherwise
   3348  *   Notes
   3349  *      Does not require lock to be held.
   3350  *
   3351  *      It could be done with a (very) large table instead.
   3352  *
   3353  *      Some qualifiers are supported in some places but not others.
   3354  *
   3355  *      Does not deal with qualifiers used only as group flags.
   3356  *
   3357  *      Would look simpler and run faster as a table, except that the table has
   3358  *      at least three dimensions and is quite sparse, so is probably more
   3359  *      efficient in terms of overall size to have it in this form (not to
   3360  *      mention the trouble of initializing such a table).
   3361  *
   3362  *      Picks the first of the allowed types that includes the qualifier and
   3363  *      uses that mapping.  To just allow one type, only set one bit.
   3364  */
   3365 extern int
   3366 _bcm_dpp_ppd_qual_from_bcm_qual(bcm_dpp_field_info_OLD_t *unitData,
   3367                                 _bcm_dpp_field_stage_idx_t stage,
   3368                                 uint32 types,
   3369                                 bcm_field_qualify_t bcmQual,
   3370                                 SOC_PPC_FP_QUAL_TYPE **ppdQual);
   3371 
   3372 /*
   3373  *   Function
   3374  *      _bcm_dpp_ppd_stage_from_bcm_stage
   3375  *   Purpose
   3376  *      Translate a BCM layer stage to a PPD layer stage
   3377  *   Parameters
   3378  *      (in) unitData = unit information
   3379  *      (in) bcmStage = BCM layer stage
   3380  *      (out) hwStageId = where to put PPD layer stage
   3381  *   Returns
   3382  *      int (implied cast from bcm_error_t)
   3383  *                    BCM_E_NONE if success
   3384  *                    BCM_E_PARAM if BCM stage is not supported
   3385  *                    BCM_E_* appropriately otherwise
   3386  *   Notes
   3387  *      Does not require lock to be held.
   3388  */
   3389 extern int
   3390 _bcm_dpp_ppd_stage_from_bcm_stage(bcm_dpp_field_info_OLD_t *unitData,
   3391                                   bcm_field_stage_t bcmStage,
   3392                                   SOC_PPC_FP_DATABASE_STAGE *hwStageId);
   3393 
   3394 /*
   3395  *   Function
   3396  *      _bcm_dpp_bcm_stage_from_ppd_stage
   3397  *   Purpose
   3398  *      Translate a PPD layer layer stage to a BCM stage
   3399  *   Parameters
   3400  *      (in) unitData = unit information
   3401  *      (in) hwStageId = PPD layer stage
   3402  *      (out) bcmStage = where to put BCM layer stage
   3403  *   Returns
   3404  *      int (implied cast from bcm_error_t)
   3405  *                    BCM_E_NONE if success
   3406  *                    BCM_E_PARAM if PPD stage is not supported
   3407  *                    BCM_E_* appropriately otherwise
   3408  *   Notes
   3409  *      Does not require lock to be held.
   3410  */
   3411 extern int
   3412 _bcm_dpp_bcm_stage_from_ppd_stage(bcm_dpp_field_info_OLD_t *unitData,
   3413                                   SOC_PPC_FP_DATABASE_STAGE hwStageId,
   3414                                   bcm_field_stage_t *bcmStage);
   3415 
   3416 /*
   3417  *  Function
   3418  *     _bcm_dpp_field_group_priority_recalc
   3419  *  Purpose
   3420  *     Recompute hardware priorities for entries in a group after the
   3421  *     addition of a new entry, the destruction of an old entry, or any change
   3422  *     in priority of entries (which would imply the entries are rearranged).
   3423  *  Parameters
   3424  *    (in) unitData = unit information
   3425  *    (in) group = group ID
   3426  *  Returns
   3427  *     nothing
   3428  *  Notes
   3429  *     Assumes group and entry validity checking has been performed.
   3430  *
   3431  *     Will change hardware priority of all entries in a group, marking them
   3432  *     all as changed.
   3433  *
   3434  *     Will not make any changes to hardware.
   3435  *
   3436  *     Assumes priority at PPD layer is only required to be unique per group,
   3437  *     rather than across the entire system.
   3438  *
   3439  *     Assumes priority range of 0..16K-1 for TCAM groups.
   3440  *     Assumes priority range of 0..7 for direct extraction groups.
   3441  */
   3442 extern void
   3443 _bcm_dpp_field_group_priority_recalc(bcm_dpp_field_info_OLD_t *unitData,
   3444                                      _bcm_dpp_field_grp_idx_t group);
   3445 
   3446 /*
   3447  *   Function
   3448  *      _bcm_dpp_field_stage_type_qset_aset_get
   3449  *   Purpose
   3450  *      Get the qualifier set and action set supported by a particular
   3451  *      type of group within a specified stage
   3452  *   Parameters
   3453  *      (in) int unit = the unit number
   3454  *      (in) _bcm_dpp_field_stage_idx_t stage = which stage
   3455  *      (in) _bcm_dpp_field_type_idx_t type = which type
   3456  *      (out) bcm_field_qset_t *qset = where to put the qualifier set
   3457  *      (out) bcm_field_aset_t *aset = where to put the action set
   3458  *   Returns
   3459  *      int (implied cast from bcm_error_t)
   3460  *                    BCM_E_NONE if successful
   3461  *                    BCM_E_* appropriately if not
   3462  *   Notes
   3463  *      Not for use internally; expected to be used by functions outside of the
   3464  *      field API implementation to access specifics of what is supported for a
   3465  *      particular stage and type.
   3466  */
   3467 extern int
   3468 _bcm_dpp_field_stage_type_qset_aset_get(int unit,
   3469                                         _bcm_dpp_field_stage_idx_t stage,
   3470                                         _bcm_dpp_field_type_idx_t type,
   3471                                         bcm_field_qset_t *qset,
   3472                                         bcm_field_aset_t *aset);
   3473 
   3474 /*
   3475  *  Function
   3476  *    _bcm_dpp_field_group_qset_recover
   3477  *  Purpose
   3478  *    Build the BCM layer QSET from the PPD layer QSET
   3479  *  Arguments
   3480  *    IN unitData = pointer to the unit information
   3481  *    IN stage = stage number
   3482  *    IN types = group types bitmap
   3483  *    IN ppdQset = pointer to PPD qualifier set
   3484  *    OUT bcmQset = pointer to BCM qualifier set
   3485  *  Results
   3486  *    bcm_error_t (cast as int)
   3487  *      BCM_E_NONE if successful
   3488  *      BCM_E_* otherwise as appropriate
   3489  *  Notes
   3490  *    ppdQset should be const but the compiler gripes
   3491  */
   3492 extern int
   3493 _bcm_dpp_field_group_qset_recover(bcm_dpp_field_info_OLD_t *unitData,
   3494                                   _bcm_dpp_field_stage_idx_t stage,
   3495                                   uint32 types,
   3496                                   _bcm_dpp_field_qual_set_t *ppdQset,
   3497                                   bcm_field_qset_t *bcmQset);
   3498 
   3499 /*
   3500  *  Function
   3501  *    _bcm_dpp_field_group_aset_recover
   3502  *  Purpose
   3503  *    Build the BCM layer ASET from the PPD layer ASET
   3504  *  Arguments
   3505  *    IN unitData = pointer to the unit information
   3506  *    IN stage = stage number
   3507  *    IN ppdAset = pointer to PPD action set
   3508  *    OUT bcmAset = pointer to BCM action set
   3509  *  Results
   3510  *    bcm_error_t (cast as int)
   3511  *      BCM_E_NONE if successful
   3512  *      BCM_E_* otherwise as appropriate
   3513  *  Notes
   3514  *    ppdAset should be const but the compiler gripes
   3515  */
   3516 extern int
   3517 _bcm_dpp_field_group_aset_recover(bcm_dpp_field_info_OLD_t *unitData,
   3518                                   _bcm_dpp_field_stage_idx_t stage,
   3519                                   _bcm_dpp_field_action_set_t *ppdAset,
   3520                                   bcm_field_aset_t *bcmAset);
   3521 
   3522 /*
   3523  *  Function
   3524  *    _bcm_dpp_field_qualifier_set_single
   3525  *  Purpose
   3526  *    Set a single qualifier on an entry
   3527  *  Arguments
   3528  *    (in) unitData = unit information
   3529  *    (in) entry = entry ID
   3530  *    (in) hwType = PPD layer qualifier to add to the entry
   3531  *    (in) data = data value for qualifier
   3532  *    (in) mask = mask bits for qualifier
   3533  *    (in) valid = valid bits for qualifier
   3534  *  Returns
   3535  *    bcm_error_t cast as int
   3536  *      BCM_E_NONE if success
   3537  *      BCM_E_* otherwise as appropriate
   3538  *  Notes
   3539  *    Caller must already hold the unit lock.
   3540  *
   3541  *    Considers it BCM_E_CONFIG to manipulate qualifiers that are not in the
   3542  *    QSET for the entry's group.
   3543  *
   3544  *    Warns if data or mask bits are outside of valid bits, or if data bits are
   3545  *    outside of mask bits.  The data and mask are the values for the PPD
   3546  *    layer, and are therefore not shifted or concatenated or sliced here.
   3547  *
   3548  *    Sets the BCM layer qualifier according to the reverse mapping.
   3549  *
   3550  *    Removes a qualifier from the list if its mask is all zeroes.  When a BCM
   3551  *    qualifier is a proper subset of a PPD qualifier, it only affects those
   3552  *    bits in the PPD qualifier, so if there are other valid bits at PPD, the
   3553  *    qualifier will remain.
   3554  *
   3555  *    Assumes entry exists in a group.
   3556  */
   3557 extern int
   3558 _bcm_dpp_field_qualifier_set_single(bcm_dpp_field_info_OLD_t *unitData,
   3559                                     bcm_field_entry_t entry,
   3560                                     SOC_PPC_FP_QUAL_TYPE hwType,
   3561                                     const uint64 data,
   3562                                     const uint64 mask,
   3563                                     const uint64 valid);
   3564 
   3565 /*
   3566  *  Function
   3567  *     _bcm_dpp_field_qualifier_set
   3568  *  Purpose
   3569  *     Set a qualifier to an entry
   3570  *  Parameters
   3571  *     (in) unitData = unit information
   3572  *     (in) entry = entry ID
   3573  *     (in) bcmQual = BCM qualifier type
   3574  *     (in) count = number of elements in qualifier data/mask arrays
   3575  *     (in) data = pointer to array of qualifier data
   3576  *     (in) mask = pointer to array of qualifier mask
   3577  *  Returns
   3578  *     int (implied cast from bcm_error_t)
   3579  *        BCM_E_NONE if successful
   3580  *        BCM_E_* appropriately if not
   3581  *  Notes
   3582  *     If the qualifier mask and data are zero, and the qualifier exists, will
   3583  *     remove the qualifier from the entry.
   3584  *
   3585  *     If the qualifier mask or data is nonzero, and the qualifier exists, this
   3586  *     will update the mask and data values for the qualifier.  If the
   3587  *     qualifier mask is nonzero and the qualifier does not exist, this will
   3588  *     add the qualifier.
   3589  *
   3590  *     Does not return error at bits being set in data that are not set in
   3591  *     mask, but it does emit a warning.  It does return BCM_E_PARAM at bits
   3592  *     being in mask or data that are not valid for the qualifier.
   3593  *
   3594  *     Considers it BCM_E_CONFIG to manipulate qualifiers that are not in the
   3595  *     QSET for the entry's group (or not supported for Preselectors in the
   3596  *     preselector's stage).
   3597  *
   3598  *     Marks the entry as changed, and the entry's group as containing changed
   3599  *     entry/entries as appropriate.
   3600  *
   3601  *     Preselectors will be read/replaced during the process and so must not
   3602  *     have any references.
   3603  *
   3604  *     Caller must already hold the unit lock.
   3605  *
   3606  *     This manipulates BCM layer qualifiers, so will shift left if needed
   3607  *     (padding with zeroes) to align BCM LSb to appropriate bit of PPD, plus
   3608  *     it supports complex BCM qualifiers (those made of more than one PPD
   3609  *     qualifier)  by slicing the bits into appropriate parts for use as PPD
   3610  *     layer qualifiers.
   3611  *
   3612  *     Bits added to the LSb end to move a qualifier left before applying it
   3613  *     are not considered significant, but all bits from the least significant
   3614  *     bit of the argument and going leftward are significant, even if they are
   3615  *     not included (so if setting a qualifier that requires array of two and
   3616  *     only one is provided, it is as if providing data=0 and mask=0 for the
   3617  *     missing upper element of the array).
   3618  *
   3619  *     The array is little-endian with 64b grains: least significant octbyte is
   3620  *     array[0], then next more significant is array[1], and so on.  Within
   3621  *     array elements, the data are in machine-native order.
   3622  *
   3623  *     Should be called by _bcm_dpp_field_entry_qualifier_general_set_int, or
   3624  *     something below it.
   3625  */
   3626 extern int
   3627 _bcm_dpp_field_qualifier_set(bcm_dpp_field_info_OLD_t *unitData,
   3628                              bcm_field_entry_t entry,
   3629                              bcm_field_qualify_t bcmQual,
   3630                              int count,
   3631                              const uint64 *data,
   3632                              const uint64 *mask);
   3633 
   3634 /*
   3635  *  Function
   3636  *     _bcm_dpp_field_entry_qualifier_general_set_int
   3637  *  Purpose
   3638  *     Set a qualifier for an entry
   3639  *  Parameters
   3640  *     (in) unitData = the unit information
   3641  *     (in) entry = the entry ID
   3642  *     (in) bcmQual = the qualifier type
   3643  *     (in) count = number of octbytes of data/mask
   3644  *     (in) data = pointer to the data values
   3645  *     (in) mask = pointer to the mask value
   3646  *  Returns
   3647  *     int (implied cast from bcm_error_t)
   3648  *       BCM_E_NONE if successful
   3649  *       BCM_E_* appropriately if not
   3650  *  Notes
   3651  *     Meant to be called with the lock held
   3652  *
   3653  *     Must be called with a valid qualifier type (okay even if it is not a
   3654  *     supported one, as long as it is valid).
   3655  *
   3656  *     Only checks entries for validity.  Other objects (currently only
   3657  *     preselectors) are checked by their own setup code.
   3658  */
   3659 extern int
   3660 _bcm_dpp_field_entry_qualifier_general_set_int(bcm_dpp_field_info_OLD_t *unitData,
   3661                                                bcm_field_entry_t entry,
   3662                                                bcm_field_qualify_t bcmQual,
   3663                                                int count,
   3664                                                const uint64 *data,
   3665                                                const uint64 *mask);
   3666 
   3667 /*
   3668  *  Function
   3669  *    _bcm_dpp_field_qualifier_get_single
   3670  *  Purpose
   3671  *    Get a single qualifier on an entry
   3672  *  Arguments
   3673  *    (in) unitData = unit information
   3674  *    (in) entry = entry ID
   3675  *    (in) hwType = PPD layer qualifier to add to the entry
   3676  *    (out) data = where to put data value
   3677  *    (out) mask = where to put mask value
   3678  *  Returns
   3679  *    bcm_error_t cast as int
   3680  *      BCM_E_NONE if success
   3681  *      BCM_E_* otherwise as appropriate
   3682  *  Notes
   3683  *    Caller must already hold the unit lock.
   3684  *
   3685  *    Assumes entry exists in a group.
   3686  *
   3687  *    Caller can choose what bits are desired after return.
   3688  */
   3689 extern int
   3690 _bcm_dpp_field_qualifier_get_single(bcm_dpp_field_info_OLD_t *unitData,
   3691                                     bcm_field_entry_t entry,
   3692                                     SOC_PPC_FP_QUAL_TYPE hwType,
   3693                                     uint64 *data,
   3694                                     uint64 *mask);
   3695 
   3696 /*
   3697  *  Function
   3698  *     _bcm_dpp_field_entry_qualifier_get
   3699  *  Purpose
   3700  *     Get a qualifier from an entry
   3701  *  Parameters
   3702  *     (in) unitData = unit information
   3703  *     (in) entry = entry ID
   3704  *     (in) bcmQual = BCM qualifier type
   3705  *     (in) count = number of elements in qualifier data/mask arrays
   3706  *     (out) data = where to put qualifier data
   3707  *     (out) mask = where to put qualifier mask
   3708  *  Returns
   3709  *     int (implied cast from bcm_error_t)
   3710  *        BCM_E_NONE if successful
   3711  *        BCM_E_* appropriately if not
   3712  *  Notes
   3713  *     Caller must already hold the unit lock.
   3714  *
   3715  *     Considers it BCM_E_CONFIG to manipulate qualifiers that are not in the
   3716  *     QSET for the entry's group.
   3717  *
   3718  *     Performs similar shifting and concatenation to the set function,
   3719  *     shifting the first PPD qualifier right so its appropriate bit aligns to
   3720  *     the LSb of the BCM qualifier, and then concatenating further PPD
   3721  *     qualifiers to the left until it has fully build any complex qualifier.
   3722  *
   3723  *     If the array is not large enough, any more significant bits (leftward)
   3724  *     that do not fit in the provided array will not be returned.  This will
   3725  *     not change the actual value stored, but may omit bits from the read.  It
   3726  *     does not return an error for this condition, but it does emit a warning.
   3727  *     It will also emit a warning if there are too many buffer elements.
   3728  *
   3729  *     The array is little-endian with 64b grains: least significant octbyte is
   3730  *     array[0], then next more significant is array[1], and so on.  Within
   3731  *     array elements, the data are in machine-native order.
   3732  *
   3733  *     Will overwrite caller provided buffer, possibly only partially, even in
   3734  *     certain error situations.
   3735  *
   3736  *     Should be called by _bcm_dpp_field_entry_qualifier_general_get_int, or
   3737  *     something below it.
   3738  */
   3739 extern int
   3740 _bcm_dpp_field_qualifier_get(bcm_dpp_field_info_OLD_t *unitData,
   3741                              bcm_field_entry_t entry,
   3742                              bcm_field_qualify_t bcmQual,
   3743                              int count,
   3744                              uint64 *data,
   3745                              uint64 *mask);
   3746 
   3747 /*
   3748  *  Function
   3749  *     _bcm_dpp_field_entry_qualifier_general_get_int
   3750  *  Purpose
   3751  *     Get a qualifier for an entry
   3752  *  Parameters
   3753  *     (in) unitData = the unit information
   3754  *     (in) entry = the entry ID
   3755  *     (in) bcmQual = the qualifier type
   3756  *     (in) count = number of octbytes of data/mask
   3757  *     (out) data = pointer to the data values
   3758  *     (out) mask = pointer to the mask value
   3759  *  Returns
   3760  *     int (implied cast from bcm_error_t)
   3761  *       BCM_E_NONE if successful
   3762  *       BCM_E_* appropriately if not
   3763  *  Notes
   3764  *     Meant to be called with the lock held
   3765  *
   3766  *     Must be called with a valid qualifier type (okay even if it is not a
   3767  *     supported one, as long as it is valid).
   3768  *
   3769  *     Only checks entries for validity.  Other objects (currently only
   3770  *     preselectors) are checked by their own setup code.
   3771  */
   3772 extern int
   3773 _bcm_dpp_field_entry_qualifier_general_get_int(bcm_dpp_field_info_OLD_t *unitData,
   3774                                                bcm_field_entry_t entry,
   3775                                                bcm_field_qualify_t bcmQual,
   3776                                                unsigned int count,
   3777                                                uint64 *data,
   3778                                                uint64 *mask);
   3779 
   3780 /* -- field_presel.c -- */
   3781 
   3782 typedef enum _bcm_dpp_field_implied_presel_e {
   3783     _BCM_DPP_IMPLIED_PRESEL_L2 = 0,
   3784     _BCM_DPP_IMPLIED_PRESEL_IPV4,
   3785     _BCM_DPP_IMPLIED_PRESEL_IPV6,
   3786     _BCM_DPP_IMPLIED_PRESEL_MPLS,
   3787     _BCM_DPP_IMPLIED_PRESEL_COUNT /* always last; not a valid value */
   3788 } _bcm_dpp_field_implied_presel_t;
   3789 
   3790 typedef enum _bcm_dpp_field_presel_alloc_flags_e {
   3791     _BCM_DPP_PRESEL_ALLOC_WITH_ID = 0x00000001,
   3792     _BCM_DPP_PRESEL_ALLOC_DOWN = 0x00000002,
   3793     _BCM_DPP_PRESEL_ALLOC_WITH_STAGE = 0x00000004,
   3794     _BCM_DPP_PRESEL_ALLOC_SECOND_PASS = 0x00000008,
   3795     _BCM_DPP_PRESEL_ALLOC_WITH_PROGRAM = 0x00000010 /*create preselector with program ID*/
   3796 } _bcm_dpp_field_presel_alloc_flags_t;
   3797 
   3798 #define _BCM_DPP_FIELD_ENTRY_IS_LARGE_DIRECT_LOOKUP(_e) ((_e & BCM_FIELD_ENTRY_LARGE_DIRECT_LOOKUP) ? TRUE : FALSE)
   3799 #define _BCM_DPP_FIELD_ENTRY_IS_ENTRY(_e) ((0 == (_e & BCM_FIELD_QUALIFY_PRESEL))?TRUE:FALSE)
   3800 #define _BCM_DPP_FIELD_ENTRY_IS_PRESEL(_e) ((_e & BCM_FIELD_QUALIFY_PRESEL)?TRUE:FALSE)
   3801 #define _BCM_DPP_FIELD_ENTRY_IS_PRESEL_STAGGERED(_e) ((_e & 0x01000000)?TRUE:FALSE)
   3802 #define _BCM_DPP_FIELD_PRESEL_FROM_ENTRY(_e) (_e & 0x00FFFFFF)
   3803 #define _BCM_DPP_FIELD_PRESEL_ID_FROM_ENTRY(_e) (_e & 0x00000FFF)
   3804 #define _BCM_DPP_FIELD_ENTRY_IS_PRESEL_ADVANCED_MODE(_e) ((_e & 0x80000000)?TRUE:FALSE)
   3805 #define _BCM_DPP_FIELD_PRESEL_STAGE_FROM_ENTRY(_e) ( (_e & 0x8000) ? bcmFieldStageExternal : \
   3806                                                    ( (_e & 0x4000) ? bcmFieldStageHash : \
   3807                                                    ( (_e & 0x2000) ? bcmFieldStageEgress : \
   3808                                                                      bcmFieldStageIngress ) ) )
   3809 
   3810 #define _BCM_DPP_FIELD_PRESEL_FLAG_FROM_STAGE(_e) ( (_e == bcmFieldStageHash)     ? BCM_FIELD_QUALIFY_PRESEL_ADVANCED_MODE_STAGE_HASH : \
   3811                                                   ( (_e == bcmFieldStageExternal) ? BCM_FIELD_QUALIFY_PRESEL_ADVANCED_MODE_STAGE_EXTERNAL : \
   3812                                                   ( (_e == bcmFieldStageEgress)   ? BCM_FIELD_QUALIFY_PRESEL_ADVANCED_MODE_STAGE_EGRESS : \
   3813                                                                                     BCM_FIELD_QUALIFY_PRESEL_ADVANCED_MODE_STAGE_INGRESS ) ) )
   3814 
   3815 /*
   3816  *   Function
   3817  *      _bcm_dpp_field_presel_init
   3818  *   Purpose
   3819  *      Init the state of the unit's preselectors
   3820  *   Parameters
   3821  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   3822  *   Returns
   3823  *      int (implied cast from bcm_error_t)
   3824  *                    BCM_E_NONE if successful
   3825  *                    BCM_E_* appropriately otherwise
   3826  *   Notes
   3827  *      Assumes PPD sets up PFG 4 on Soc_petraB.
   3828  */
   3829 extern int
   3830 _bcm_dpp_field_presel_init(bcm_dpp_field_info_OLD_t *unitData);
   3831 
   3832 /*
   3833  *   Function
   3834  *      _bcm_dpp_field_presel_reset
   3835  *   Purpose
   3836  *      Reset the state of the unit's preselectors, at the PPD layer
   3837  *   Parameters
   3838  *      (in) int unit = the unit number to reset
   3839  *   Returns
   3840  *      int (implied cast from bcm_error_t)
   3841  *                    BCM_E_NONE if successful
   3842  *                    BCM_E_* appropriately otherwise
   3843  *   Notes
   3844  *      This scans the PPD layer and frees resources.  It should not be used
   3845  *      for detach, but must be used for cold init.
   3846  *
   3847  *      Assumes PPD owns PFG 4 on Soc_petraB.
   3848  *
   3849  *      Only returns last error if more than one occurs.
   3850  */
   3851 extern int
   3852 _bcm_dpp_field_presel_reset(int unit);
   3853 
   3854 /*
   3855  *   Function
   3856  *      _bcm_dpp_field_presel_info_get
   3857  *   Purpose
   3858  *      Get information for a single preselector from PPD
   3859  *   Parameters
   3860  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   3861  *      (in) _bcm_dpp_field_presel_idx_t presel = which preselector to read
   3862  *      (in) unsigned int qualLimit = max number of qualifiers
   3863  *      (out) _bcm_dpp_field_stage_idx_t *stage = where to put stage index
   3864  *      (out) _bcm_dpp_field_qual_t *bcmQuals = where to put BCM qualifiers
   3865  *   Returns
   3866  *      int (implied cast from bcm_error_t)
   3867  *                    BCM_E_NONE if successful
   3868  *                    BCM_E_* appropriately otherwise
   3869  *   Notes
   3870  *     Out arguments which are NULL will simply not be filled in.
   3871  */
   3872 extern int
   3873 _bcm_dpp_field_presel_info_get(bcm_dpp_field_info_OLD_t *unitData,
   3874                                _bcm_dpp_field_presel_idx_t presel,
   3875                                unsigned int qualLimit,
   3876                                uint32 flags,
   3877                                _bcm_dpp_field_stage_idx_t *stage,
   3878                                _bcm_dpp_field_qual_t *bcmQuals);
   3879 
   3880 /*
   3881  *   Function
   3882  *      _bcm_dpp_field_presel_info_set
   3883  *   Purpose
   3884  *      Set information for a single preselector
   3885  *   Parameters
   3886  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   3887  *      (in) _bcm_dpp_field_presel_idx_t presel = which preselector to write
   3888  *      (in) unsigned int qualLimit = max number of qualifiers
   3889  *      (in) _bcm_dpp_field_stage_idx_t stage = stage index
   3890  *      (in) _bcm_dpp_field_qual_t *bcmQuals = where to get BCM qualifiers
   3891  *      (in) _bcm_dpp_field_program_idx_t program_id = the program that the preselctor will point to
   3892  *   Returns
   3893  *      int (implied cast from bcm_error_t)
   3894  *                    BCM_E_NONE if successful
   3895  *                    BCM_E_* appropriately otherwise
   3896  *   Notes
   3897  *     Due to a requirement that the PFG be overwritten with a blank one
   3898  *     ('destroyed') before we can update it (so no direct overwrite), there is
   3899  *     the possibility that a single error in a series of updating a presel
   3900  *     will result in it not having the desired qualifiers.  Unhappily, there
   3901  *     seems to be no easy solution to this since we are not caching them.
   3902  */
   3903 extern int
   3904 _bcm_dpp_field_presel_info_set(bcm_dpp_field_info_OLD_t *unitData,
   3905                                _bcm_dpp_field_presel_idx_t presel,
   3906                                unsigned int qualLimit,
   3907                                uint32 flags,
   3908                                _bcm_dpp_field_stage_idx_t stage,
   3909                                const _bcm_dpp_field_qual_t *bcmQuals,
   3910                                _bcm_dpp_field_program_idx_t program_id);
   3911 
   3912 void _bcm_dpp_clear_core_ports(int                  nof_cores,
   3913                                _bcm_dpp_core_ports_bitmap_t *core_port_bitmap);
   3914 
   3915 #ifdef BROADCOM_DEBUG
   3916 /*
   3917  *   Function
   3918  *      _bcm_dpp_field_presel_dump
   3919  *   Purpose
   3920  *      Dump state of all preselectors
   3921  *   Parameters
   3922  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   3923  *      (in) char *prefix = prefix for each line of the dump
   3924  *   Returns
   3925  *      int (implied cast from bcm_error_t)
   3926  *                    BCM_E_NONE if successful
   3927  *                    BCM_E_* appropriately otherwise
   3928  */
   3929 extern int
   3930 _bcm_dpp_field_presel_dump(bcm_dpp_field_info_OLD_t *unitData,
   3931                            const char *prefix);
   3932 #endif /* def BROADCOM_DEBUG */
   3933 
   3934 #ifdef BCM_PETRA_SUPPORT
   3935 /*
   3936  *   Function
   3937  *      _bcm_dpp_field_presel_implied_setup
   3938  *   Purpose
   3939  *      Set up prequalifiers for a group that uses implied preselectors
   3940  *   Parameters
   3941  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   3942  *      (in/out) _bcm_dpp_petra_field_group_t *groupData = ptr to group data
   3943  *   Returns
   3944  *      int (implied cast from bcm_error_t)
   3945  *                    BCM_E_NONE if successful
   3946  *                    BCM_E_* appropriately otherwise
   3947  *   Notes
   3948  *      Assumes group is valid and exists.
   3949  */
   3950 extern int
   3951 _bcm_dpp_field_presel_implied_setup(bcm_dpp_field_info_OLD_t *unitData,
   3952                                     _bcm_dpp_field_group_t *groupData);
   3953 #endif /* def BCM_PETRA_SUPPORT */
   3954 
   3955 #ifdef BCM_PETRA_SUPPORT
   3956 /*
   3957  *   Function
   3958  *      _bcm_dpp_field_presel_implied_teardown
   3959  *   Purpose
   3960  *      Tear down prequalifiers for a group that uses implied preselectors
   3961  *   Parameters
   3962  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   3963  *      (in) _bcm_dpp_field_group_t *groupData = pointer to group data
   3964  *   Returns
   3965  *      int (implied cast from bcm_error_t)
   3966  *                    BCM_E_NONE if successful
   3967  *                    BCM_E_* appropriately otherwise
   3968  *   Notes
   3969  *      Assumes group is valid but has been removed from hardware, as in
   3970  *      preparation for deletion of the group.
   3971  */
   3972 extern int
   3973 _bcm_dpp_field_presel_implied_teardown(bcm_dpp_field_info_OLD_t *unitData,
   3974                                        _bcm_dpp_field_group_t *groupData);
   3975 #endif /* def BCM_PETRA_SUPPORT */
   3976 
   3977 /*
   3978  *   Function
   3979  *      _bcm_dpp_field_presel_qualify
   3980  *   Purpose
   3981  *      Apply a qualifier to a preselector
   3982  *   Parameters
   3983  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   3984  *      (in) bcm_field_presel_t presel = presel to be manipulated
   3985  *      (in) bcm_field_qualify_t qualifier = qualifier to adjust
   3986  *      (in) unsigned int count = number of octbytes of data/mask
   3987  *      (in) uint64 *data = pointer to qualifier data
   3988  *      (in) uint64 *mask = pointer to qualifier mask
   3989  *   Returns
   3990  *      int (implied cast from bcm_error_t)
   3991  *                    BCM_E_NONE if successful
   3992  *                    BCM_E_* appropriately otherwise
   3993  *   Notes
   3994  *     There are some 'special' qualifiers used by preselectors on Arad (such
   3995  *     as the bcmFieldQualifyStage qualifier) and on PetraB all qualifiers must
   3996  *     be explicitly mapped to special purpose elements in the PPD descriptor,
   3997  *     so this function is used as an intermediary to give the preselector code
   3998  *     a chance to do something 'special' with any given qualifier.  If a
   3999  *     qualifier is not 'special', then it passes the responsibility back to the
   4000  *     common qualifier code, which updates the preselector's qualifiers.
   4001  */
   4002 extern int
   4003 _bcm_dpp_field_presel_qualify(bcm_dpp_field_info_OLD_t *unitData,
   4004                               bcm_field_presel_t presel,
   4005                               bcm_field_stage_t  stage, 
   4006                               uint32 flags,
   4007                               bcm_field_qualify_t qualifier,
   4008                               unsigned int count,
   4009                               const uint64 *data,
   4010                               const uint64 *mask);
   4011 
   4012 /*
   4013  *   Function
   4014  *      _bcm_dpp_field_presel_qualify_get
   4015  *   Purpose
   4016  *      Get a qualifier from a preselector
   4017  *   Parameters
   4018  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4019  *      (in) bcm_field_presel_t presel = presel to be manipulated
   4020  *      (in) bcm_field_qualify_t qualifier = qualifier to get
   4021  *      (in) unsigned int count = number of octbytes of data/mask space
   4022  *      (out) uint64 *data = pointer to qualifier data
   4023  *      (out) uint64 *mask = pointer to qualifier mask
   4024  *   Returns
   4025  *      int (implied cast from bcm_error_t)
   4026  *                    BCM_E_NONE if successful
   4027  *                    BCM_E_* appropriately otherwise
   4028  */
   4029 extern int
   4030 _bcm_dpp_field_presel_qualify_get(bcm_dpp_field_info_OLD_t *unitData,
   4031                                   bcm_field_presel_t presel,
   4032                                   bcm_field_stage_t  stage,
   4033                                   uint32 flags,
   4034                                   bcm_field_qualify_t qualifier,
   4035                                   unsigned int count,
   4036                                   uint64 *data,
   4037                                   uint64 *mask);
   4038 
   4039 /*
   4040  *   Function
   4041  *      _bcm_dpp_field_group_presel_set
   4042  *   Purpose
   4043  *      Set preselector set for a group
   4044  *   Parameters
   4045  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4046  *      (in) _bcm_dpp_field_grp_idx_t group = group to update
   4047  *      (in) bcm_field_presel_set_t *presel_set = pointer to preselector set
   4048  *      (in) pgm_bmp =  Bitmap of program-ids which the current field group will be pointing to
   4049  *   Returns
   4050  *      int (implied cast from bcm_error_t)
   4051  *                    BCM_E_NONE if successful
   4052  *                    BCM_E_* appropriately otherwise
   4053  */
   4054 extern int
   4055 _bcm_dpp_field_group_presel_set(bcm_dpp_field_info_OLD_t *unitData,
   4056                                 _bcm_dpp_field_grp_idx_t group,
   4057                                 bcm_field_presel_set_t *presel_set,
   4058                                  uint32 pgm_bmp);
   4059 
   4060 /*
   4061  *  Function
   4062  *    _bcm_dpp_field_presel_port_profile_set
   4063  *  Purpose
   4064  *    Allocate a program selection profile for set of ports
   4065  *  Arguments
   4066  *    (in) unit - the unit ID
   4067  *    (in) profile_type - profile type according to _bcm_dpp_field_profile_type_t
   4068  *    (in) port_bitmap - set of ports to configure
   4069  *    (out) profile = the profile allocated
   4070  *  Returns
   4071  *      int (implied cast from bcm_error_t)
   4072  *                    BCM_E_NONE if successful
   4073  *                    BCM_E_* appropriately otherwise
   4074  */
   4075 extern int
   4076 _bcm_dpp_field_presel_port_profile_set(int unit,
   4077                                        _bcm_dpp_field_profile_type_t profile_type,
   4078                                        int    nof_cores,
   4079                                        _bcm_dpp_core_ports_bitmap_t *core_port_bitmap, 
   4080                                        uint64 *profile);
   4081 
   4082 /*
   4083  *  Function
   4084  *    _bcm_dpp_field_presel_port_profile_get
   4085  *  Purpose
   4086  *    Get the port-set relating to a presel profile
   4087  *  Arguments
   4088  *    (in) unit - the unit ID
   4089  *    (in) profile_type - profile type according to _bcm_dpp_field_profile_type_t
   4090  *    (in) profile - the profile ID
   4091  *    (out) port_bitmap - the set of ports
   4092  *  Returns
   4093  *      int (implied cast from bcm_error_t)
   4094  *                    BCM_E_NONE if successful
   4095  *                    BCM_E_* appropriately otherwise
   4096  */
   4097 extern int
   4098 _bcm_dpp_field_presel_port_profile_get(int unit,
   4099                                        _bcm_dpp_field_profile_type_t profile_type,
   4100                                        uint32 profile,
   4101                                        int    *nof_core,
   4102                                        _bcm_dpp_core_ports_bitmap_t *core_port_bitmap);
   4103 
   4104 /*
   4105  *  Function
   4106  *    _bcm_dpp_field_presel_port_profile_clear
   4107  *  Purpose
   4108  *    Remove a presel profile from ports if configured
   4109  *  Arguments
   4110  *    (in) unitData - pointer to unit data
   4111  *    (in) entry - the presel entry
   4112  *  Returns
   4113  *      int (implied cast from bcm_error_t)
   4114  *                    BCM_E_NONE if successful
   4115  *                    BCM_E_* appropriately otherwise
   4116  *   Notes
   4117  *      In case the profile is used by another presel, only
   4118  *      decrease reference counter, otherwise remove completely.
   4119  */
   4120 extern int
   4121 _bcm_dpp_field_presel_port_profile_clear_type(bcm_dpp_field_info_OLD_t *unitData,
   4122                                               _bcm_dpp_field_profile_type_t profile_type,
   4123                                               bcm_field_entry_t entry);
   4124 
   4125 extern int
   4126 _bcm_dpp_field_presel_port_profile_clear_all(bcm_dpp_field_info_OLD_t *unitData,
   4127                                              bcm_field_entry_t entry);
   4128 
   4129 extern int
   4130 _bcm_dpp_field_presel_port_entry_profile_get(bcm_dpp_field_info_OLD_t *unitData,
   4131                                              _bcm_dpp_field_profile_type_t profile_type,
   4132                                              bcm_field_entry_t entry,
   4133                                              uint64 *profile);
   4134 
   4135 extern int
   4136 _bcm_dpp_field_presel_install(bcm_dpp_field_info_OLD_t *unitData,
   4137                                _bcm_dpp_field_presel_idx_t presel,
   4138                               uint8 is_second_pass);
   4139 
   4140 extern int
   4141 _bcm_dpp_field_presel_destroy(bcm_dpp_field_info_OLD_t *unitData,
   4142                                _bcm_dpp_field_presel_idx_t presel,
   4143                               uint8 is_second_pass);
   4144 
   4145 extern int
   4146 _bcm_dpp_field_presel_to_bitmap(int unit,
   4147                                 bcm_field_presel_t presel_id,
   4148                                 bcm_field_stage_t  stage,
   4149                                 uint8 is_second_pass,
   4150                                 bcm_field_presel_t *presel_bitmap_id,
   4151                                 _bcm_dpp_field_stage_idx_t *stage_id);
   4152 
   4153 extern int
   4154 _bcm_dpp_field_presel_index_to_pfg(int unit,
   4155                              bcm_field_presel_t presel_id,
   4156                              bcm_field_stage_t *stage,
   4157                              int *pfg_ndx);
   4158 
   4159 /* -- field_dataqual.c -- */
   4160 
   4161 /*
   4162  *   Function
   4163  *      _bcm_petra_field_data_qualifier_init
   4164  *   Purpose
   4165  *      Init the state of the unit's data qualifiers
   4166  *   Parameters
   4167  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4168  *   Returns
   4169  *      int (implied cast from bcm_error_t)
   4170  *                    BCM_E_NONE if successful
   4171  *                    BCM_E_* appropriately otherwise
   4172  *   Notes
   4173  */
   4174 extern int
   4175 _bcm_petra_field_data_qualifier_init(bcm_dpp_field_info_OLD_t *unitData);
   4176 
   4177 /*
   4178  *   Function
   4179  *      _bcm_petra_field_data_qualifier_reset
   4180  *   Purpose
   4181  *      Reset the state of the unit's data qualifiers, at the PPD layer
   4182  *   Parameters
   4183  *      (in) int unit = the unit number to reset
   4184  *   Returns
   4185  *      int (implied cast from bcm_error_t)
   4186  *                    BCM_E_NONE if successful
   4187  *                    BCM_E_* appropriately otherwise
   4188  *   Notes
   4189  *      This scans the PPD layer and frees resources.  It should not be used
   4190  *      for detach, but must be used for cold init.
   4191  *
   4192  *      Assumes PPD owns PFG 4 on Soc_petraB.
   4193  *
   4194  *      Only returns last error if more than one occurs.
   4195  */
   4196 extern int
   4197 _bcm_petra_field_data_qualifier_reset(int unit);
   4198 
   4199 #ifdef BROADCOM_DEBUG
   4200 /*
   4201  *   Function
   4202  *      _bcm_petra_field_data_qualifier_dump
   4203  *   Purpose
   4204  *      Dump state of all data qualifiers
   4205  *   Parameters
   4206  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4207  *      (in) char *prefix = prefix for each line of the dump
   4208  *   Returns
   4209  *      int (implied cast from bcm_error_t)
   4210  *                    BCM_E_NONE if successful
   4211  *                    BCM_E_* appropriately otherwise
   4212  */
   4213 extern int
   4214 _bcm_petra_field_data_qualifier_dump(bcm_dpp_field_info_OLD_t *unitData,
   4215                                      const char *prefix);
   4216 #endif /* def BROADCOM_DEBUG */
   4217 
   4218 /*
   4219  *  Function
   4220  *    _bcm_petra_field_map_ppd_udf_to_bcm
   4221  *  Purpose
   4222  *    Map a PPD layer user-defined qualifier to BCM used-defined index
   4223  *  Parameters
   4224  *    (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4225  *    (in) SOC_PPC_FP_QUAL_TYPE hwType = PPD layer qualifier type
   4226  *    (out) unsigned int *bcmIndex = where to put BCM layer index
   4227  */
   4228 extern int
   4229 _bcm_petra_field_map_ppd_udf_to_bcm(bcm_dpp_field_info_OLD_t *unitData,
   4230                                     SOC_PPC_FP_QUAL_TYPE hwType,
   4231                                     unsigned int *bcmIndex);
   4232 
   4233 /*
   4234  *  Function
   4235  *    _bcm_petra_field_map_bcm_udf_to_ppd
   4236  *  Purpose
   4237  *    Map a BCM layer used-defined index to PPD user-defined qualifier
   4238  *  Parameters
   4239  *    (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4240  *    (in) SOC_PPC_FP_QUAL_TYPE hwType = PPD layer qualifier type
   4241  *    (out) unsigned int *bcmIndex = where to put BCM layer index
   4242  */
   4243 extern int
   4244 _bcm_petra_field_map_bcm_udf_to_ppd(bcm_dpp_field_info_OLD_t *unitData,
   4245                                     unsigned int bcmIndex,
   4246                                     SOC_PPC_FP_QUAL_TYPE *hwType);
   4247 
   4248 /*
   4249  *  Function
   4250  *    _bcm_petra_field_data_qualifier_bits_get
   4251  *  Purpose
   4252  *    Get number of bits represented by a data qualifier
   4253  *  Parameters
   4254  *    (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4255  *    (in) SOC_PPC_FP_QUAL_TYPE hwType = PPD layer qualifier type
   4256  *    (out) unsigned int *bcmIndex = where to put BCM layer index
   4257  */
   4258 extern int
   4259 _bcm_petra_field_data_qualifier_bits_get(bcm_dpp_field_info_OLD_t *unitData,
   4260                                          SOC_PPC_FP_QUAL_TYPE hwType,
   4261                                          unsigned int *bits);
   4262 
   4263 
   4264 /* -- field_range.c -- */
   4265 
   4266 /*
   4267  *   Function
   4268  *      _bcm_dpp_field_range_init
   4269  *   Purpose
   4270  *      Init the state of the unit's ranges
   4271  *   Parameters
   4272  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4273  *   Returns
   4274  *      int (implied cast from bcm_error_t)
   4275  *                    BCM_E_NONE if successful
   4276  *                    BCM_E_* appropriately otherwise
   4277  *   Notes
   4278  */
   4279 extern int
   4280 _bcm_dpp_field_range_init(bcm_dpp_field_info_OLD_t *unitData);
   4281 
   4282 /*
   4283  *   Function
   4284  *      _bcm_dpp_field_range_reset
   4285  *   Purpose
   4286  *      Reset the state of the unit's ranges, at the PPD layer
   4287  *   Parameters
   4288  *      (in) int unit = the unit number to reset
   4289  *      (in) uint32 handle = the hardware handle for the unit
   4290  *      (in) _bcm_dpp_Field_device_info_t *devInfo = pointer to unit dev info
   4291  *   Returns
   4292  *      int (implied cast from bcm_error_t)
   4293  *                    BCM_E_NONE if successful
   4294  *                    BCM_E_* appropriately otherwise
   4295  *   Notes
   4296  *      This scans the PPD layer and frees resources.  It should not be used
   4297  *      for detach, but must be used for cold init.
   4298  *
   4299  *      Assumes PPD owns PFG 4 on Soc_petraB.
   4300  *
   4301  *      Only returns last error if more than one occurs.
   4302  */
   4303 extern int
   4304 _bcm_dpp_field_range_reset(int unit,
   4305                            uint32 handle,
   4306                            const _bcm_dpp_field_device_info_t *devInfo);
   4307 
   4308 /*
   4309  *   Function
   4310  *      _bcm_dpp_field_range_get
   4311  *   Purpose
   4312  *      Get parameters for a range
   4313  *   Parameters
   4314  *      (in) unitData = unit information
   4315  *      (in) bcm_field_range_t range = range ID to get
   4316  *      (out) uint32 flags = flags for the range
   4317  *      (out) uint32 *min = pointer to min port for the range
   4318  *      (out) uint32 *max = pointer to max port for the range
   4319  *   Returns
   4320  *      int (implied cast from bcm_error_t)
   4321  *                    BCM_E_NONE if valid
   4322  *                    BCM_E_NOT_FOUND if not valid
   4323  *                    BCM_E_* appropriately otherwise
   4324  *   Notes
   4325  */
   4326 int
   4327 _bcm_dpp_field_range_get(bcm_dpp_field_info_OLD_t  *unitData,
   4328                          bcm_field_range_t range,
   4329                          int maxCount,
   4330                          uint32 *flags,
   4331                          uint32 *min,
   4332                          uint32 *max,
   4333                          int *actualCount);
   4334 
   4335 #ifdef BROADCOM_DEBUG
   4336 /*
   4337  *   Function
   4338  *      _bcm_dpp_field_range_dump
   4339  *   Purpose
   4340  *      Dump state of all ranges on the unit
   4341  *   Parameters
   4342  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4343  *      (in) char *prefix = prefix for each line of the dump
   4344  *   Returns
   4345  *      int (implied cast from bcm_error_t)
   4346  *                    BCM_E_NONE if successful
   4347  *                    BCM_E_* appropriately otherwise
   4348  */
   4349 extern int
   4350 _bcm_dpp_field_range_dump(bcm_dpp_field_info_OLD_t *unitData,
   4351                             const char *prefix);
   4352 #endif /* def BROADCOM_DEBUG */
   4353 
   4354 #ifdef BROADCOM_DEBUG
   4355 /*
   4356  *   Function
   4357  *      _bcm_dpp_field_entry_range_dump
   4358  *   Purpose
   4359  *      Dump all ranges associated with an entry
   4360  *   Parameters
   4361  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4362  *      (in) _bcm_dpp_field_qual_t *qualArray = qualifier array from entry
   4363  *      (in) SOC_PPC_FP_QUAL_VAL *qualHwData = qualifier array from hardware
   4364  *      (in) char prefix = prefix for each line of the dump
   4365  *   Returns
   4366  *      int (implied cast from bcm_error_t)
   4367  *                    BCM_E_NONE if successful
   4368  *                    BCM_E_* appropriately otherwise
   4369  *   Notes
   4370  *     Adds four spaces to the prefix (to format for entry dump)
   4371  */
   4372 int
   4373 _bcm_dpp_field_entry_range_dump(bcm_dpp_field_info_OLD_t  *unitData,
   4374                                  const _bcm_dpp_field_qual_t *qualArray,
   4375 #if _BCM_DPP_FIELD_DUMP_VERIFY_PPD
   4376                                 const SOC_PPC_FP_QUAL_VAL *qualHwData,
   4377 #endif
   4378                                 const char *prefix);
   4379 #endif /* def BROADCOM_DEBUG */
   4380 
   4381 
   4382 /* -- field_dir_ext.c -- */
   4383 
   4384 #ifdef BROADCOM_DEBUG
   4385 /*
   4386  *   Function
   4387  *      _bcm_dpp_field_dir_ext_entry_dump
   4388  *   Purpose
   4389  *      Dump an entry in a direct extraction group
   4390  *   Parameters
   4391  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4392  *      (in) _bcm_dpp_field_ent_idx_t entry = direct extraction entry to dump
   4393  *      (in) char prefix = prefix for each line of the dump
   4394  *   Returns
   4395  *      int (implied cast from bcm_error_t)
   4396  *                    BCM_E_NONE if successful
   4397  *                    BCM_E_* appropriately otherwise
   4398  *   Notes
   4399  */
   4400 extern int
   4401 _bcm_dpp_field_dir_ext_entry_dump(bcm_dpp_field_info_OLD_t *unitData,
   4402                                   _bcm_dpp_field_ent_idx_t entry,
   4403                                   const char *prefix);
   4404 #endif /* def BROADCOM_DEBUG */
   4405 
   4406 /*
   4407  *  Function
   4408  *     _bcm_dpp_field_dir_ext_entry_clear
   4409  *  Purpose
   4410  *     Clear everything about a direct extraction entry but next,prev linkx.
   4411  *  Parameters
   4412  *     (in) unitData = the unit information
   4413  *     (in) entry = entry ID
   4414  *  Returns
   4415  *     nothing
   4416  *  Notes
   4417  *     This is only called when allocating entries, so it does not adjust the
   4418  *     entry's group's flags (and the entry's flags are cleared).  This also
   4419  *     does not clean up the entry, on the assumption it was not used before
   4420  *     and so the resources it might appear to claim would be bogus.
   4421  */
   4422 extern void
   4423 _bcm_dpp_field_dir_ext_entry_clear(bcm_dpp_field_info_OLD_t *unitData,
   4424                                    _bcm_dpp_field_ent_idx_t entry);
   4425 
   4426 /*
   4427  *  Function
   4428  *     _bcm_dpp_field_dir_ext_entry_action_clear
   4429  *  Purpose
   4430  *     Remove an action from an entry
   4431  *  Parameters
   4432  *     (in) unitData = unit information
   4433  *     (in) entry = entry ID
   4434  *     (in) action = BCM action type
   4435  *  Returns
   4436  *     int (implied cast from bcm_error_t)
   4437  *        BCM_E_NONE if successful
   4438  *        BCM_E_* appropriately if not
   4439  *  Notes
   4440  *     Assumes the arguments are all valid.
   4441  *
   4442  *     Considers it BCM_E_CONFIG to manipulate actions that are not in the
   4443  *     ASET for the entry's group.
   4444  *
   4445  *     Marks the entry as changed, and the entry's group as containing changed
   4446  *     entry/entries.
   4447  *
   4448  *     Since it is possible that a single action at the BCM layer will require
   4449  *     multiple actions at PPD, this will clear all actions of an entry that
   4450  *     have the specified type (note that in this case the hardware types of
   4451  *     the different actions will be different).
   4452  */
   4453 extern int
   4454 _bcm_dpp_field_dir_ext_entry_action_clear(bcm_dpp_field_info_OLD_t *unitData,
   4455                                           _bcm_dpp_field_ent_idx_t entry,
   4456                                           bcm_field_action_t type);
   4457 
   4458 /*
   4459  *  Function
   4460  *     _bcm_dpp_field_dir_ext_entry_clear_acts
   4461  *  Purpose
   4462  *     Clear explicit actions from an entry.
   4463  *  Parameters
   4464  *     (in) unitData = the unit information
   4465  *     (in) entry = entry ID
   4466  *  Returns
   4467  *     nothing
   4468  *  Notes
   4469  */
   4470 extern int
   4471 _bcm_dpp_field_dir_ext_entry_clear_acts(bcm_dpp_field_info_OLD_t *unitData,
   4472                                         _bcm_dpp_field_ent_idx_t entry);
   4473 
   4474 /*
   4475  *   Function
   4476  *      _bcm_dpp_field_dir_ext_entry_alloc
   4477  *   Purpose
   4478  *      Allocate a direct extraction entry
   4479  *   Parameters
   4480  *      (in) bcm_dpp_field_info_OLD_t *unitData = pointer to unit data
   4481  *      (in) int withId = TRUE if caller provides the ID
   4482  *      (in/out) _bcm_dpp_field_ent_idx_t *entry = where to put/get the entry
   4483  *   Returns
   4484  *      int (implied cast from bcm_error_t)
   4485  *                    BCM_E_NONE if successful
   4486  *                    BCM_E_* appropriately otherwise
   4487  *   Notes
   4488  */
   4489 extern int
   4490 _bcm_dpp_field_dir_ext_entry_alloc(bcm_dpp_field_info_OLD_t *unitData,
   4491                                    _bcm_dpp_field_grp_idx_t group,
   4492                                    int withId,
   4493                                    _bcm_dpp_field_ent_idx_t *entry);
   4494 
   4495 /*
   4496  *  Function
   4497  *     _bcm_dpp_field_dir_ext_entry_add_to_group
   4498  *  Purpose
   4499  *     Insert an entry into a group.
   4500  *  Parameters
   4501  *     (in) unitData = the unit information
   4502  *     (in) group = group ID
   4503  *     (in) entry = entry ID
   4504  *  Returns
   4505  *     int (implied cast from bcm_error_t)
   4506  *        BCM_E_NONE if successful
   4507  *        BCM_E_* appropriately if not
   4508  *  Notes
   4509  *     If the entry is already in a group, it will remove the entry from that
   4510  *     group and insert it into the specified group, according to the BCM
   4511  *     priority rules.  If the entry is in hardware, this will remove the entry
   4512  *     from hardware.
   4513  *
   4514  *     Marks the entry as new/moved, changed, and in use.
   4515  *
   4516  *     Marks the entry's new group as containing net/moved entry/entries and
   4517  *     changed entry/entries.
   4518  */
   4519 extern int
   4520 _bcm_dpp_field_dir_ext_entry_add_to_group(bcm_dpp_field_info_OLD_t *unitData,
   4521                                           _bcm_dpp_field_grp_idx_t group,
   4522                                           _bcm_dpp_field_ent_idx_t entry);
   4523 
   4524 /*
   4525  *  Function
   4526  *     _bcm_dpp_field_dir_ext_entry_remove
   4527  *  Purpose
   4528  *     Remove an entry (if needed) from the hardware
   4529  *  Parameters
   4530  *     (in) unitData = unit information
   4531  *     (in) entry = entry number
   4532  *  Returns
   4533  *     int (implied cast from bcm_error_t)
   4534  *        BCM_E_NONE if successful
   4535  *        BCM_E_* appropriately if not
   4536  *  Notes
   4537  *     Considers NOP (remove a non-installed entry) as success, but considers
   4538  *     trying to remove an unused entry an error.
   4539  */
   4540 extern int
   4541 _bcm_dpp_field_dir_ext_entry_remove(bcm_dpp_field_info_OLD_t *unitData,
   4542                                     _bcm_dpp_field_ent_idx_t entry);
   4543 
   4544 /*
   4545  *  Function
   4546  *     _bcm_dpp_field_dir_ext_entry_destroy
   4547  *  Purpose
   4548  *     Destroy an entry, after (if needed) removal from hardware
   4549  *  Parameters
   4550  *     (in) unitData = unit information
   4551  *     (in) entry = entry number
   4552  *  Returns
   4553  *     int (implied cast from bcm_error_t)
   4554  *        BCM_E_NONE if successful
   4555  *        BCM_E_* appropriately if not
   4556  *  Notes
   4557  */
   4558 extern int
   4559 _bcm_dpp_field_dir_ext_entry_destroy(bcm_dpp_field_info_OLD_t *unitData,
   4560                                      _bcm_dpp_field_ent_idx_t entry);
   4561 
   4562 /*
   4563  *   Function
   4564  *      _bcm_dpp_field_dir_ext_group_hw_refresh
   4565  *   Purpose
   4566  *      Recommit (or initially commit) entries of a direct extraction group to
   4567  *      hardware
   4568  *   Parameters
   4569  *      (in) int unit = the unit number
   4570  *      (in) bcm_field_group_t group = which group ID to use
   4571  *      (in) cond = TRUE for conditional update, FALSE otherwise
   4572  *   Returns
   4573  *      int (implied cast from bcm_error_t)
   4574  *                    BCM_E_NONE if successful
   4575  *                    BCM_E_* appropriately if not
   4576  *   Notes
   4577  *      Assumes group and entry validity checking has been performed.
   4578  *
   4579  *      This inserts or updates all of the group's entries that WANT_HW to
   4580  *      hardware, and removes any IN_HW that don't WANT_HW.  It is used by
   4581  *      the group install/remove functionality, but it is also invoked for
   4582  *      cases where a single entry is installed but that entry does not have
   4583  *      an assigned hardware priority (so the priorities need to be redone).
   4584  *
   4585  *      This behavior implies a peculiar result when dealing with uncommitted
   4586  *      entries: If inserting even a single 'new' or 'moved' entry, any
   4587  *      uncommitted changes to any other entries in the same group that WANT_HW
   4588  *      will be committed.  This could only be avoided by significant
   4589  *      additional complexity, since either we have to track two states
   4590  *      (committed and not) for each entry, or we have to make the priority
   4591  *      allocation mechanism a lot more complex and capable of being split into
   4592  *      many segments instead of the current implementation's two segments.
   4593  *
   4594  *      Note that it is not obligatory to call this when removing an entry
   4595  *      since the removal of entries does not oblige priority recalculation,
   4596  *      and thence does not require the subsequent refresh.
   4597  *
   4598  *      This function does not change the WANT_HW state of any entries.
   4599  *
   4600  *      Expects to be called with the lock already held and arguments checked.
   4601  *
   4602  *      Conditional install is a special condition that is used when adding a
   4603  *      single entry (or set in theory) whose priority was not assigned or was
   4604  *      stale.  All of the existing entries need to be updated as well but only
   4605  *      the ones marked UPDATE will be transitioned from IN_HW to not, or not
   4606  *      to IN_HW, and all of the entries already IN_HW will be copied from
   4607  *      hardware state instead of having their current software state used.
   4608  *      This is to preserve the API semantic that bcm_field_entry_(re)install
   4609  *      only affects the single specified entry, but it makes the routine of
   4610  *      create, config, commit something approaching an O(n^3) operation; it is
   4611  *      far better to use the create all, config all, commit group sequence.
   4612  */
   4613 extern int
   4614 _bcm_dpp_field_dir_ext_group_hw_refresh(bcm_dpp_field_info_OLD_t *unitData,
   4615                                         bcm_field_group_t group,
   4616                                         int cond);
   4617 
   4618 /*
   4619  *   Function
   4620  *      _bcm_dpp_field_dir_ext_entry_install
   4621  *   Purpose
   4622  *      Write an entry to the hardware, either 'install' or 'reinstall'
   4623  *   Parameters
   4624  *      (in) unitData = unit information
   4625  *      (in) _bcm_dpp_field_ent_idx_t entry = the entry ID to destroy
   4626  *   Returns
   4627  *      int (implied cast from bcm_error_t)
   4628  *                    BCM_E_NONE if successful
   4629  *                    BCM_E_* appropriately if not
   4630  *   Notes
   4631  *      Meant to be called without the lock being held
   4632  *
   4633  *      Curiously, it is not an error to 'install' an entry that is already in
   4634  *      hardware, nor is it an error to 'reinstall' an entry that is not
   4635  *      already in hardware.  Seems these functions are redundant.
   4636  *
   4637  *      This does NOT remove the entry.
   4638  */
   4639 extern int
   4640 _bcm_dpp_field_dir_ext_entry_install(bcm_dpp_field_info_OLD_t *unitData,
   4641                                      _bcm_dpp_field_ent_idx_t entry);
   4642 
   4643 /*
   4644  *  Function
   4645  *     _bcm_dpp_field_dir_ext_entry_copy_id
   4646  *  Purpose
   4647  *     Copy one field entry to another
   4648  *  Parameters
   4649  *     (in) unitData = the unit information
   4650  *     (in) dest = destination entry ID
   4651  *     (in) source = source entry ID
   4652  *  Returns
   4653  *     nothing
   4654  *  Notes
   4655  *     New entry has copy of stats settings, and the new entry will be in the
   4656  *     stats chain with the old entry if the old entry had a statistics set
   4657  *     associated.
   4658  *
   4659  *     Assumes dest entry is not in use, and source entry is in use.
   4660  *
   4661  *     Dest must be in same group as source.
   4662  */
   4663 extern void
   4664 _bcm_dpp_field_dir_ext_entry_copy_id(bcm_dpp_field_info_OLD_t *unitData,
   4665                                      _bcm_dpp_field_ent_idx_t dest,
   4666                                      _bcm_dpp_field_ent_idx_t source);
   4667 
   4668 void
   4669    _bcm_dpp_field_ext_info_entry_clear(int unit, int32 extTcamInfoIndex) ;
   4670 #if _BCM_DPP_FIELD_GET_VERIFY_PPD || _BCM_DPP_FIELD_GET_USE_PPD
   4671 /*
   4672  *  Function
   4673  *    _bcm_dpp_field_dir_ext_hardware_entry_check
   4674  *  Purpose
   4675  *    Get a direct extraction entry from the PPD layer, verifying (according to
   4676  *    settings) that it is consistent with the expected BCM layer values.
   4677  *  Parameters
   4678  *    (in) unitData = the unit information
   4679  *    (in) entry = the entry ID
   4680  *    (out) entInfoDe = where to put the hardware entry description
   4681  *  Returns
   4682  *     int (implied cast from bcm_error_t)
   4683  *        BCM_E_NONE if successful
   4684  *        BCM_E_* appropriately if not
   4685  *  Notes
   4686  *    Might return an error for mismatch or just display a warning, according
   4687  *    to configuration.
   4688  *
   4689  *    Is also used to retrieve the entry in preparation for using the PPD layer
   4690  *    values for a 'get' operation.
   4691  */
   4692 int
   4693 _bcm_dpp_field_dir_ext_hardware_entry_check(bcm_dpp_field_info_OLD_t *unitData,
   4694                                             bcm_field_entry_t entry,
   4695                                             SOC_PPC_FP_DIR_EXTR_ENTRY_INFO *entInfoDe);
   4696 #endif /* _BCM_DPP_FIELD_GET_VERIFY_PPD || _BCM_DPP_FIELD_GET_USE_PPD */
   4697 
   4698 
   4699 /* -- field_tcam.c -- */
   4700 
   4701 #ifdef BROADCOM_DEBUG
   4702 /*
   4703  *   Function
   4704  *      _bcm_dpp_field_tcam_entry_dump
   4705  *   Purpose
   4706  *      Dump the state of a specific field entry (TCAM based)
   4707  *   Parameters
   4708  *      (in) unitData = unit information
   4709  *      (in) entry = entry to be dumped
   4710  *      (in) prefix = string to prefix to each line
   4711  *   Returns
   4712  *      int (implied cast from bcm_error_t)
   4713  *                    BCM_E_NONE if successful
   4714  *                    BCM_E_* appropriately otherwise
   4715  *   Notes
   4716  */
   4717 extern int
   4718 _bcm_dpp_field_tcam_entry_dump(bcm_dpp_field_info_OLD_t *unitData,
   4719                                uint8 isExternalTcam,
   4720                                _bcm_dpp_field_ent_idx_t entry,
   4721                                const char *prefix);
   4722 #endif /* def BROADCOM_DEBUG */
   4723 /*
   4724  *   Function
   4725  *     _bcm_dpp_field_ace_entry_add
   4726  *   Purpose
   4727  *     Load ACE tables as per input parameters. Tables are:
   4728  *       EPNI_ACE_TO_OUT_PP_PORT
   4729  *       EPNI_ACE_TABLE
   4730  *       EPNI_ACE_TO_OUT_LIF
   4731  *       (EPNI_ACE_TO_FHEI is, currently, not handled)
   4732  *     Note that this procedure does write into HW.
   4733  *   Parameters
   4734  *      (in)  int unit = the unit number
   4735  *      (in)  _bcm_dpp_field_tc_b_act_t *propActs =
   4736  *              A Pointer to a structure of type _bcm_dpp_field_tc_b_act_t.
   4737  *              Currenly, only one 'bcmType' is allowed and it
   4738  *              must be 'bcmFieldActionStat'.
   4739  *              The 'parameters' are as follows:
   4740  *                bcmParam0 =
   4741  *                  Statistic-Report Counter format as in Jericho.
   4742  *                  It contains both ACE pointer (in the LS 17 bits) and
   4743  *                  'prge' in the following 10 bits. Must be a valid value.
   4744  *                  See _SHR_FIELD_CTR_PROC_SHIFT_GET, _SHR_FIELD_CTR_PROC_SHIFT
   4745  *                bcmParam1 =
   4746  *                  Gport representing TM-Port and PP-Port.
   4747  *                  Must be a valid value.
   4748  *                bcmParam2 =
   4749  *                  If valid (not BCM_ILLEGAL_ACTION_PARAMETER) then this is the outlif
   4750  *                  id to use to replace existing outlif id.
   4751  *      (in)  core_id = core to perform action
   4752  *      (in)  unsigned int ppdIndex =
   4753  *              The index to start writing into 'hwAct'. See below.
   4754  *              This procedure will start loading at hwAct[ppdIndex], then.
   4755  *      (out) _bcm_dpp_field_tc_p_act_t *hwAct =
   4756  *              A pointer to an array of structures of type _bcm_dpp_field_tc_p_act_t.
   4757  *              Each structure contains internal info that is used for the configuration of
   4758  *              the HW. Caller is responsible for available space.
   4759  *              his array is loaded by this procedure starting from index 'ppdIndex'
   4760  *      (out) unsigned int *actCount_p =
   4761  *              Pointer to unsigned int. This procedure loads pointed memory by the number
   4762  *              of information elements loaded into hwAct[]
   4763  *   Returns
   4764  *     int (implied cast from bcm_error_t)
   4765  *                    BCM_E_NONE if successful
   4766  *                    BCM_E_* appropriately if not
   4767  *   Notes
   4768  *     Updates ACE HW tables:
   4769  *       EPNI_ACE_TO_OUT_PP_PORT
   4770  *       EPNI_ACE_TABLE
   4771  *       EPNI_ACE_TO_OUT_LIF
   4772  *       (EPNI_ACE_TO_FHEI is, currently, not handled)
   4773  *
   4774  *   This procedure is for JERICHO/JERICHO_PLUS only!
   4775  *   Caller is assumed to have verified that before calling this procedure.
   4776  */
   4777 int
   4778 _bcm_dpp_field_ace_entry_add(
   4779     int unit,
   4780     _bcm_dpp_field_tc_b_act_t *propActs,
   4781     int core_id,
   4782     unsigned int ppdIndex,
   4783     _bcm_dpp_field_tc_p_act_t *hwAct,
   4784     unsigned int *actCount_p);
   4785 /*
   4786  *   Function
   4787  *      _bcm_dpp_field_tcam_entry_install
   4788  *   Purpose
   4789  *      Write an entry to the hardware, either 'install' or 'reinstall'
   4790  *   Parameters
   4791  *      (in) unitData = unit information
   4792  *      (in) _bcm_dpp_field_ent_idx_t entry = the entry ID to destroy
   4793  *      (out)_bcm_dpp_field_ent_idx_t new_entry = large direct lookup entry ID
   4794  *   Returns
   4795  *      int (implied cast from bcm_error_t)
   4796  *                    BCM_E_NONE if successful
   4797  *                    BCM_E_* appropriately if not
   4798  *   Notes
   4799  *      Meant to be called without the lock being held
   4800  *
   4801  *      Curiously, it is not an error to 'install' an entry that is already in
   4802  *      hardware, nor is it an error to 'reinstall' an entry that is not
   4803  *      already in hardware.  Seems these functions are redundant.
   4804  *
   4805  *      This does NOT remove the entry.
   4806  */
   4807 extern int
   4808 _bcm_dpp_field_tcam_entry_install(bcm_dpp_field_info_OLD_t *unitData,
   4809                                   uint8 isExternalTcam,
   4810                                   _bcm_dpp_field_ent_idx_t entry,
   4811                                   bcm_field_entry_t *new_entry);
   4812 
   4813 /*
   4814  *  Function
   4815  *     _bcm_dpp_field_tcam_entry_remove
   4816  *  Purpose
   4817  *     Remove an entry (if needed) from the hardware
   4818  *  Parameters
   4819  *     (in) unitData = unit information
   4820  *     (in) is_kaps_sw_remove = Remove large direct lookup software entry
   4821  *     (in) entry = entry number
   4822  *  Returns
   4823  *     int (implied cast from bcm_error_t)
   4824  *        BCM_E_NONE if successful
   4825  *        BCM_E_* appropriately if not
   4826  *  Notes
   4827  *     Considers NOP (remove a non-installed entry) as success, but considers
   4828  *     trying to remove an unused entry an error.
   4829  */
   4830 extern int
   4831 _bcm_dpp_field_tcam_entry_remove(bcm_dpp_field_info_OLD_t *unitData,
   4832                                  uint8 is_kaps_sw_remove,
   4833                                  bcm_field_entry_t entry);
   4834 
   4835 /*
   4836  *   Function
   4837  *      _bcm_dpp_field_tcam_group_hw_refresh
   4838  *   Purpose
   4839  *      Recommit (or initially commit) entries of a TCAM group to hardware
   4840  *   Parameters
   4841  *      (in) int unit = the unit number
   4842  *      (in) bcm_field_group_t group = which group ID to use
   4843  *      (in) cond = TRUE for conditional update, FALSE otherwise
   4844  *   Returns
   4845  *      int (implied cast from bcm_error_t)
   4846  *                    BCM_E_NONE if successful
   4847  *                    BCM_E_* appropriately if not
   4848  *   Notes
   4849  *      Assumes group and entry validity checking has been performed.
   4850  *
   4851  *      This inserts or updates all of the group's entries that WANT_HW to
   4852  *      hardware, and removes any IN_HW that don't WANT_HW.  It is used by
   4853  *      the group install/remove functionality, but it is also invoked for
   4854  *      cases where a single entry is installed but that entry does not have
   4855  *      an assigned hardware priority (so the priorities need to be redone).
   4856  *
   4857  *      This behavior implies a peculiar result when dealing with uncommitted
   4858  *      entries: If inserting even a single 'new' or 'moved' entry, any
   4859  *      uncommitted changes to any other entries in the same group that WANT_HW
   4860  *      will be committed.  This could only be avoided by significant
   4861  *      additional complexity, since either we have to track two states
   4862  *      (committed and not) for each entry, or we have to make the priority
   4863  *      allocation mechanism a lot more complex and capable of being split into
   4864  *      many segments instead of the current implementation's two segments.
   4865  *
   4866  *      Note that it is not obligatory to call this when removing an entry
   4867  *      since the removal of entries does not oblige priority recalculation,
   4868  *      and thence does not require the subsequent refresh.
   4869  *
   4870  *      This function does not change the WANT_HW state of any entries.
   4871  *
   4872  *      Expects to be called with the lock already held and arguments checked.
   4873  *
   4874  *      Conditional install is a special condition that is used when adding a
   4875  *      single entry (or set in theory) whose priority was not assigned or was
   4876  *      stale.  All of the existing entries need to be updated as well but only
   4877  *      the ones marked UPDATE will be transitioned from IN_HW to not, or not
   4878  *      to IN_HW, and all of the entries already IN_HW will be copied from
   4879  *      hardware state instead of having their current software state used.
   4880  *      This is to preserve the API semantic that bcm_field_entry_(re)install
   4881  *      only affects the single specified entry, but it makes the routine of
   4882  *      create, config, commit something approaching an O(n^3) operation; it is
   4883  *      far better to use the create all, config all, commit group sequence.
   4884  */
   4885 extern int
   4886 _bcm_dpp_field_tcam_group_hw_refresh(bcm_dpp_field_info_OLD_t *unitData,
   4887                                      bcm_field_group_t group,
   4888                                      int cond);
   4889 
   4890 /*
   4891  *  Function
   4892  *     _bcm_dpp_field_tcam_entry_action_clear
   4893  *  Purpose
   4894  *     Remove an action from an entry
   4895  *  Parameters
   4896  *     (in) unitData = unit information
   4897  *     (in) entry = entry ID
   4898  *     (in) action = BCM action type
   4899  *  Returns
   4900  *     int (implied cast from bcm_error_t)
   4901  *        BCM_E_NONE if successful
   4902  *        BCM_E_* appropriately if not
   4903  *  Notes
   4904  *     Assumes the arguments are all valid.
   4905  *
   4906  *     Considers it BCM_E_CONFIG to manipulate actions that are not in the
   4907  *     ASET for the entry's group.
   4908  *
   4909  *     Marks the entry as changed, and the entry's group as containing changed
   4910  *     entry/entries.
   4911  *
   4912  *     Since it is possible that a single action at the BCM layer will require
   4913  *     multiple actions at PPD, this will clear all actions of an entry that
   4914  *     have the specified type (note that in this case the hardware types of
   4915  *     the different actions will be different).
   4916  */
   4917 extern int
   4918 _bcm_dpp_field_tcam_entry_action_clear(bcm_dpp_field_info_OLD_t *unitData,
   4919                                        uint8 isExternalTcam,
   4920                                        _bcm_dpp_field_ent_idx_t entry,
   4921                                        bcm_field_action_t type);
   4922 
   4923 /*
   4924  *  Function
   4925  *     _bcm_dpp_field_tcam_entry_clear_acts
   4926  *  Purpose
   4927  *     Clear explicit actions from an entry.
   4928  *  Parameters
   4929  *     (in) unitData = the unit information
   4930  *     (in) entry = entry ID
   4931  *  Returns
   4932  *     nothing
   4933  *  Notes
   4934  */
   4935 extern int
   4936 _bcm_dpp_field_tcam_entry_clear_acts(bcm_dpp_field_info_OLD_t *unitData,
   4937                                      uint8 isExternalTcam,
   4938                                      _bcm_dpp_field_ent_idx_t entry);
   4939 
   4940 /*
   4941  *  Function
   4942  *     _bcm_dpp_field_tcam_entry_clear
   4943  *  Purpose
   4944  *     Clear everything about an entry but next,prev linkx.
   4945  *  Parameters
   4946  *     (in) unitData = the unit information
   4947  *     (in) entry = entry ID
   4948  *  Returns
   4949  *     nothing
   4950  *  Notes
   4951  *     This is only called when allocating entries, so it does not adjust the
   4952  *     entry's group's flags (and the entry's flags are cleared).  This also
   4953  *     does not clean up the entry, on the assumption it was not used before
   4954  *     and so the resources it might appear to claim would be bogus.
   4955  */
   4956 extern void
   4957 _bcm_dpp_field_tcam_entry_clear(bcm_dpp_field_info_OLD_t *unitData,
   4958                                 uint8 isExternalTcam,
   4959                            _bcm_dpp_field_ent_idx_t entry);
   4960 
   4961 /*
   4962  *  Function
   4963  *     _bcm_dpp_field_tcam_entry_action_set
   4964  *  Purpose
   4965  *     Set an action to an entry
   4966  *  Parameters
   4967  *     (in) unitData = unit information
   4968  *     (in) core_id = core to perform the action
   4969  *     (in) entry = entry ID
   4970  *     (in) action = BCM qualifier type
   4971  *     (in) param0 = action argument 0
   4972  *     (in) param1 = action argument 1
   4973  *  Returns
   4974  *     int (implied cast from bcm_error_t)
   4975  *        BCM_E_NONE if successful
   4976  *        BCM_E_* appropriately if not
   4977  *  Notes
   4978  *     Actions can not be removed with this function because it is possible
   4979  *     for both arguments to be zero (or even don't care!).
   4980  *
   4981  *     If _BCM_PETRA_ALLOW_IMPLIED_ACTION_REPLACE is TRUE and the action
   4982  *     already exists, this will replace it.  If FALSE and the action already
   4983  *     exists, this will return BCM_E_EXISTS.
   4984  *
   4985  *     Several BCM layer actions share underlying hardware actions.  These
   4986  *     actions can only be added if there is not already another BCM action
   4987  *     using the underlying hardware action.
   4988  *
   4989  *     Some BCM layer actions require more than one PPD layer action to fully
   4990  *     implement.  These actions are added/manipulated atomically, and will be
   4991  *     considered together for other purposes (get, delete, &c) but can be
   4992  *     split during the add.  They can not be added if any part of them
   4993  *     conflicts with another existing action.
   4994  *
   4995  *     Considers it BCM_E_CONFIG to manipulate actions that are not in the
   4996  *     ASET for the entry's group.
   4997  *
   4998  *     Marks the entry as changed, and the entry's group as containing changed
   4999  *     entry/entries.
   5000  *
   5001  *     OutLif lookups are common between ingress and egress, but different
   5002  *     requirements and capabilities of ingress/egress for destinations require
   5003  *     GPORT lookups be tailored to the stage.
   5004  */
   5005 extern int
   5006 _bcm_dpp_field_tcam_entry_action_set(bcm_dpp_field_info_OLD_t *unitData,
   5007                                      uint8 isExternalTcam,
   5008                                      int core_id,
   5009                                      _bcm_dpp_field_ent_idx_t entry,
   5010                                      bcm_field_action_t type,
   5011                                      uint32 param0,
   5012                                      uint32 param1,
   5013                                      uint32 param2,
   5014                                      uint32 param3);
   5015 
   5016 /*
   5017  *  Function
   5018  *     _bcm_dpp_field_tcam_entry_destroy
   5019  *  Purpose
   5020  *     Destroy an entry, after (if needed) removal from hardware
   5021  *  Parameters
   5022  *     (in) unitData = unit information
   5023  *     (in) is_kaps_sw_remove = Remove large direct lookup software entry
   5024  *     (in) entry = entry number
   5025  *  Returns
   5026  *     int (implied cast from bcm_error_t)
   5027  *        BCM_E_NONE if successful
   5028  *        BCM_E_* appropriately if not
   5029  *  Notes
   5030  */
   5031 extern int
   5032 _bcm_dpp_field_tcam_entry_destroy(bcm_dpp_field_info_OLD_t *unitData,
   5033                                   uint8 is_kaps_sw_remove,
   5034                                   bcm_field_entry_t entry);
   5035 
   5036 /*
   5037  *  Function
   5038  *     _bcm_dpp_field_tcam_entry_add_to_group
   5039  *  Purpose
   5040  *     Insert an entry into a group.
   5041  *  Parameters
   5042  *     (in) unitData = the unit information
   5043  *     (in) group = group ID
   5044  *     (in) entry = entry ID
   5045  *  Returns
   5046  *     int (implied cast from bcm_error_t)
   5047  *        BCM_E_NONE if successful
   5048  *        BCM_E_* appropriately if not
   5049  *  Notes
   5050  *     If the entry is already in a group, it will remove the entry from that
   5051  *     group and insert it into the specified group, according to the BCM
   5052  *     priority rules.  If the entry is in hardware, this will remove the entry
   5053  *     from hardware.
   5054  *
   5055  *     Marks the entry as new/moved, changed, and in use.
   5056  *
   5057  *     Marks the entry's new group as containing net/moved entry/entries and
   5058  *     changed entry/entries.
   5059  */
   5060 int
   5061 _bcm_dpp_field_tcam_entry_add_to_group(bcm_dpp_field_info_OLD_t *unitData,
   5062                                        _bcm_dpp_field_grp_idx_t group,
   5063                                        _bcm_dpp_field_ent_idx_t entry);
   5064 
   5065 /*
   5066  *  Function
   5067  *     _bcm_dpp_field_tcam_entry_action_get
   5068  *  Purpose
   5069  *     Get an action from an entry
   5070  *  Parameters
   5071  *     (in) unitData = unit information
   5072  *     (in) entry = entry ID
   5073  *     (in) action = BCM qualifier type
   5074  *     (out) param0 = where to put arg0 value
   5075  *     (out) param1 = where to put arg1 value
   5076  *     (out) param2 = where to put arg2 value
   5077  *     (out) param3 = where to put arg3 value
   5078  *  Returns
   5079  *     int (implied cast from bcm_error_t)
   5080  *        BCM_E_NONE if successful
   5081  *        BCM_E_* appropriately if not
   5082  *  Notes
   5083  *     Considers it BCM_E_CONFIG to manipulate actions that are not in the
   5084  *     ASET for the entry's group.
   5085  *
   5086  *     Assumes the entry exists.
   5087  *
   5088  *     Returns the data for the first action of the type (since hardware can
   5089  *     have more than one action per BCM action, the first action will be the
   5090  *     one where the BCM layer parameters were kept, even though there may be
   5091  *     hardware parameters for all of the DPP layer actions)
   5092  */
   5093 extern int
   5094 _bcm_dpp_field_tcam_entry_action_get(bcm_dpp_field_info_OLD_t *unitData,
   5095                                      bcm_field_entry_t entry,
   5096                                      bcm_field_action_t type,
   5097                                      uint32 *param0,
   5098                                      uint32 *param1,
   5099                                      uint32 *param2,
   5100                                      uint32 *param3);
   5101 
   5102 /*
   5103  *  Function
   5104  *     _bcm_dpp_field_tcam_entry_copy_id
   5105  *  Purpose
   5106  *     Copy one field entry to another
   5107  *  Parameters
   5108  *     (in) unitData = the unit information
   5109  *     (in) dest = destination entry ID
   5110  *     (in) source = source entry ID
   5111  *  Returns
   5112  *     nothing
   5113  *  Notes
   5114  *     New entry has copy of stats settings, and the new entry will be in the
   5115  *     stats chain with the old entry if the old entry had a statistics set
   5116  *     associated.
   5117  *
   5118  *     Assumes dest entry is not in use, and source entry is in use.
   5119  *
   5120  *     Dest must be in same group as source.
   5121  */
   5122 extern void
   5123 _bcm_dpp_field_tcam_entry_copy_id(bcm_dpp_field_info_OLD_t *unitData,
   5124                                   uint8 isExternalTcam,
   5125                                   _bcm_dpp_field_ent_idx_t dest,
   5126                                   _bcm_dpp_field_ent_idx_t source);
   5127 
   5128 /*
   5129  *  Function
   5130  *     _bcm_dpp_field_tcam_entry_hit_get
   5131  *  Purpose
   5132  *     Get hit indication info for a specific TCAM entry per core.
   5133  *  Parameters
   5134  *     (in) unitData = the unit information
   5135  *     (in) flags = destination entry ID
   5136  *     (in) entry_handle = source entry ID
   5137  *     (out) entry_hit_core_bmp_p = 1 bit, which indicates that
   5138  *          the entry was hit. In case of Jericho1 and Jericho_Plus,
   5139  *          the entry is valid on both cores, which means that
   5140  *          in case of hit the returned values will be TRUE.
   5141  *          Otherwise FALSE will be returned.
   5142  *  Returns
   5143  *     int (implied cast from bcm_error_t)
   5144  *                    BCM_E_NONE if successful
   5145  *                    BCM_E_* appropriately if not
   5146  *  Notes
   5147  */
   5148 int _bcm_dpp_field_tcam_entry_hit_get(
   5149     bcm_dpp_field_info_OLD_t *unitData,
   5150     uint32 flags,
   5151     uint32 entry_handle,
   5152     uint8 *entry_hit_core_bmp_p);
   5153 
   5154 /*
   5155  *  Function
   5156  *     _bcm_dpp_field_tcam_entry_hit_flush
   5157  *  Purpose
   5158  *     This function flushes hit information of an entry or all entries,
   5159  *     from hardware.
   5160  *  Parameters
   5161  *     (in) unitData = the unit information
   5162  *     (in) flags = Flags to indicate what action should be performed
   5163  *                   by the API, currently in use is:
   5164  *               - BCM_FIELD_ENTRY_HIT_FLUSH_ALL - used for flushing hit
   5165  *                 indication info for all entries. No need to specify an entry ID.
   5166  *               - If no flag is specified, the API will clear information only for
   5167  *                 the given entry_handle.
   5168  *     (in) entry_handle = Unique entry handle for which the hit
   5169  *               information will be flushed.
   5170  *  Returns
   5171  *     int (implied cast from bcm_error_t)
   5172  *                    BCM_E_NONE if successful
   5173  *                    BCM_E_* appropriately if not
   5174  *  Notes
   5175  */
   5176 int _bcm_dpp_field_tcam_entry_hit_flush(
   5177     bcm_dpp_field_info_OLD_t *unitData,
   5178     uint32 flags,
   5179     uint32 entry_handle);
   5180 
   5181 /*
   5182  * Convert PPD-level (internal) stage to BCM stage.
   5183  * Note that, currently, it works only for 4 internal stages:
   5184  *   SOC_PPC_FP_DATABASE_STAGE_INGRESS_PMF
   5185  *   SOC_PPC_FP_DATABASE_STAGE_EGRESS
   5186  *   SOC_PPC_FP_DATABASE_STAGE_INGRESS_FLP
   5187  *   SOC_PPC_FP_DATABASE_STAGE_INGRESS_SLB
   5188  * See:
   5189  *   _bcm_arad_field_stage_info[], bcm_petra_field_stage_info_get(),
   5190  *   _bcm_arad_field_device_info
   5191  */
   5192 /* static */
   5193 int _bcm_dpp_field_internal_stage_to_bcm_stage(
   5194   int unit,
   5195   SOC_PPC_FP_DATABASE_STAGE internal_stage,
   5196   bcm_field_stage_t         *bcm_stage);
   5197 
   5198 /*
   5199  *   Function
   5200  *      bcm_petra_field_data_qualifier_get
   5201  *   Purpose
   5202  *      Get a data qualifier configuration
   5203  *   Parameters
   5204  *      (in) unitData = unit information
   5205  *      (in) int qual_id = which qualifier ID to use
   5206  *      (out) bcm_field_data_qualifier_t *qual = where to put description
   5207  *   Returns
   5208  *      int (implied cast from bcm_error_t)
   5209  *                    BCM_E_NONE if successful
   5210  *                    BCM_E_* appropriately if not
   5211  *   Notes
   5212  *      Assumes all parameters already verified, except whether the data
   5213  *      qualifier exists.
   5214  */
   5215 extern int
   5216 _bcm_petra_field_data_qualifier_get(bcm_dpp_field_info_OLD_t *unitData,
   5217                                     int qual_id,
   5218                                     bcm_field_data_qualifier_t *qual);
   5219 
   5220 #if _BCM_DPP_FIELD_GET_VERIFY_PPD || _BCM_DPP_FIELD_GET_USE_PPD
   5221 /*
   5222  *  Function
   5223  *    _bcm_dpp_field_tcam_hardware_entry_check
   5224  *  Purpose
   5225  *    Get a TCAM entry from the PPD layer, verifying (according to settings)
   5226  *    that it is consistent with the expected BCM layer values.
   5227  *  Parameters
   5228  *    (in) unitData = the unit information
   5229  *    (in) entry = the entry ID
   5230  *    (out) entInfoTc = where to put the hardware entry description
   5231  *  Returns
   5232  *     int (implied cast from bcm_error_t)
   5233  *        BCM_E_NONE if successful
   5234  *        BCM_E_* appropriately if not
   5235  *  Notes
   5236  *    Might return an error for mismatch or just display a warning, according
   5237  *    to configuration.
   5238  *
   5239  *    Is also used to retrieve the entry in preparation for using the PPD layer
   5240  *    values for a 'get' operation.
   5241  */
   5242 int
   5243 _bcm_dpp_field_tcam_hardware_entry_check(bcm_dpp_field_info_OLD_t *unitData,
   5244                                          bcm_field_entry_t entry,
   5245                                          SOC_PPC_FP_ENTRY_INFO *entInfoTc);
   5246 
   5247 /*
   5248  *  Function
   5249  *    _bcm_dpp_field_entry_ppd_to_bcm
   5250  *  Purpose
   5251  *    Given a PPD entry ID (hwHandle) find the corresponding BCM entry ID.
   5252  *  Parameters
   5253  *    (in) unitData = the unit information
   5254  *    (in) hwHandle = the PPD entry ID
   5255  *    (out) bcm_entry = the BCM entry ID
   5256  *    (out) found = indication if entry was founds
   5257  *  Returns
   5258  *     int (implied cast from bcm_error_t)
   5259  *        BCM_E_NONE if successful
   5260  *        BCM_E_* appropriately if not
   5261  */
   5262 int
   5263 _bcm_dpp_field_entry_ppd_to_bcm(int unit,
   5264                                 uint32 hwHandle,
   5265                                 bcm_field_entry_t *bcm_entry,
   5266                                 uint8 *found);
   5267 
   5268 #endif /* _BCM_DPP_FIELD_GET_VERIFY_PPD || _BCM_DPP_FIELD_GET_USE_PPD */
   5269 
   5270 
   5271 int
   5272 _bcm_dpp_field_action_config_add_verify_params(int unit, 
   5273                                                bcm_field_entry_t entry, 
   5274                                                bcm_field_action_t action, 
   5275                                                int core_config_arr_len, 
   5276                                                bcm_field_action_core_config_t *core_config_arr);
   5277 
   5278 /*
   5279  * Internal Output of bcm_petra_field_internal_to_bcm_action_map():
   5280  *
   5281  * Indication on not getting enough space to load output to.
   5282  */
   5283 #define INTERNAL_TO_BCM_ACTION_NO_SPACE    -1
   5284 /*
   5285  * Internal error for arad_pmf_fem_action_init_if_required()
   5286  * NOTE: This macro MUST be smaller than zero
   5287  *
   5288  * General error
   5289  */
   5290 #define ACTION_INIT_IF_REQUIRED_FAIL       -1
   5291 /*
   5292  * Internal output of arad_pmf_fem_action_type_array_element_get_unsafe()
   5293  *
   5294  * General failure
   5295  */
   5296 #define ACTION_TYPE_ARRAY_ELEMENT_GET_FAIL -2
   5297 /*
   5298  * Output of arad_pmf_fem_action_width_set_unsafe()
   5299  *
   5300  * If *db_identifier_p is set to this value then no
   5301  * DB was found to be using input internal action.
   5302  */
   5303 #define NO_DB_FOUND                        -1
   5304 /*
   5305  * Output of arad_pmf_fem_action_width_get_unsafe()
   5306  *
   5307  * If input internal action is not found on runtime array
   5308  * the *out_action_width is loaded by this value.
   5309  * NOTE: This macro MUST be smaller than zero
   5310  */
   5311 #define NOT_ON_RUNTIME_ARRAY               -1
   5312 
   5313 #endif /* ndef _DPP_PETRA_FIELD_INT_H_ */