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.c (234595B)


      1 /* 
      2  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      3  * 
      4  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      5  *
      6  * File:        field.c
      7  * Purpose:     BCM56624 Field Processor installation functions.
      8  */
      9 #include <shared/bsl.h>
     10 
     11 #include <soc/defs.h>
     12 #if defined(BCM_TRX_SUPPORT) && defined(BCM_FIELD_SUPPORT)
     13 
     14 #include <soc/drv.h>
     15 #include <soc/scache.h>
     16 
     17 #include <bcm/error.h>
     18 #include <bcm/l3.h>
     19 #include <bcm/field.h>
     20 #include <bcm/tunnel.h>
     21 
     22 #include <bcm_int/esw_dispatch.h>
     23 
     24 #include <bcm_int/esw/field.h>
     25 #include <bcm_int/esw/l3.h>
     26 #include <bcm_int/esw/firebolt.h>
     27 #include <bcm_int/esw/trx.h>
     28 #include <bcm_int/esw/triumph.h>
     29 #include <bcm_int/esw/triumph3.h>
     30 #include <bcm_int/esw/katana.h>
     31 #include <bcm_int/esw/katana2.h>
     32 #include <bcm_int/esw/trident2.h>
     33 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT) || \
     34     defined(BCM_GREYHOUND2_SUPPORT)
     35 #include <bcm_int/esw/policer.h>
     36 #include <bcm_int/esw/flex_ctr.h>
     37 #endif /* BCM_KATANA_SUPPORT || BCM_TRIUMPH3_SUPPORT ||
     38           BCM_GREYHOUND2_SUPPORT */
     39 
     40 /* local/static function prototypes */
     41 STATIC void _field_tr_functions_init(_field_funct_t *functions) ;
     42 
     43 /*
     44  * Function:
     45  *     _bcm_field_tr_hw_clear
     46  * Purpose:
     47  *     Clear hardware memory of requested stage. 
     48  * Parameters:
     49  *     unit       - (IN) BCM device number.
     50  *     stage_fc   - (IN) Field Processor stage control structure. 
     51  *
     52  * Returns:
     53  *     BCM_E_NONE
     54  * Notes:
     55  */
     56 int
     57 _bcm_field_tr_hw_clear(int unit, _field_stage_t *stage_fc)
     58 {
     59     bcm_pbmp_t valid_pbm;         /* Holds valid pbm supported */
     60     bcm_port_t port;              /* Port iterator.           */
     61     int idx;                      /* Stages/slices iterator.  */
     62     int rv;                       /* Operation return status. */
     63 
     64     if (SOC_WARM_BOOT(unit)) {
     65         return (BCM_E_NONE);
     66     }
     67 
     68     switch (stage_fc->stage_id) {
     69       case _BCM_FIELD_STAGE_INGRESS:
     70 #if defined(BCM_TRIUMPH2_SUPPORT)
     71           if (SOC_MEM_IS_VALID(unit, FP_UDF_TCAMm)) {
     72               rv = soc_mem_clear(unit, FP_UDF_TCAMm, COPYNO_ALL, TRUE);
     73               BCM_IF_ERROR_RETURN(rv);
     74           }
     75 #endif
     76           rv = soc_mem_clear(unit, FP_UDF_OFFSETm, COPYNO_ALL, TRUE);
     77           BCM_IF_ERROR_RETURN(rv);
     78           rv = soc_mem_clear(unit, FP_RANGE_CHECKm, COPYNO_ALL, TRUE);
     79           BCM_IF_ERROR_RETURN(rv);
     80           rv = soc_mem_clear(unit, FP_TCAMm, COPYNO_ALL, TRUE);
     81           BCM_IF_ERROR_RETURN(rv);
     82           rv = soc_mem_clear(unit, FP_POLICY_TABLEm, COPYNO_ALL, TRUE);
     83           BCM_IF_ERROR_RETURN(rv);
     84           rv = soc_mem_clear(unit, FP_METER_TABLEm, COPYNO_ALL, TRUE);
     85           BCM_IF_ERROR_RETURN(rv);
     86           rv = soc_mem_clear(unit, FP_COUNTER_TABLEm, COPYNO_ALL, TRUE);
     87           BCM_IF_ERROR_RETURN(rv);
     88           rv = soc_mem_clear(unit, FP_PORT_FIELD_SELm, COPYNO_ALL, TRUE);
     89           BCM_IF_ERROR_RETURN(rv);
     90           rv = soc_mem_clear(unit, FP_SLICE_MAPm, COPYNO_ALL, TRUE);
     91           BCM_IF_ERROR_RETURN(rv);
     92           rv = soc_mem_clear(unit, FP_SLICE_KEY_CONTROLm, COPYNO_ALL, TRUE);
     93           BCM_IF_ERROR_RETURN(rv);
     94           break;
     95 
     96       case _BCM_FIELD_STAGE_LOOKUP:
     97           rv = soc_mem_clear((unit), VFP_TCAMm, COPYNO_ALL, TRUE);
     98           BCM_IF_ERROR_RETURN(rv);
     99           rv = soc_mem_clear((unit), VFP_POLICY_TABLEm, COPYNO_ALL, TRUE);
    100           BCM_IF_ERROR_RETURN(rv);
    101           break;
    102 
    103       case _BCM_FIELD_STAGE_EGRESS:
    104           rv = soc_mem_clear(unit, EFP_TCAMm, COPYNO_ALL, TRUE);
    105           BCM_IF_ERROR_RETURN(rv);
    106           rv = soc_mem_clear(unit, EFP_POLICY_TABLEm, COPYNO_ALL, TRUE);
    107           BCM_IF_ERROR_RETURN(rv);
    108           rv = soc_mem_clear(unit, EFP_METER_TABLEm, COPYNO_ALL, TRUE);
    109           BCM_IF_ERROR_RETURN(rv);
    110           rv = soc_mem_clear(unit, EFP_COUNTER_TABLEm, COPYNO_ALL, TRUE);
    111           BCM_IF_ERROR_RETURN(rv);
    112           break;
    113 
    114       case _BCM_FIELD_STAGE_EXTERNAL:
    115           /* Read device port configuration. */
    116           BCM_PBMP_CLEAR(valid_pbm);
    117           BCM_IF_ERROR_RETURN(_bcm_field_valid_pbmp_get(unit, &valid_pbm));
    118 
    119           /* Reset the ACL related fields in ESM_MODE_PER_PORTr register */
    120           BCM_PBMP_ITER(valid_pbm, port) {
    121               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    122                                           L2_ACL_ENf, 0);
    123               BCM_IF_ERROR_RETURN(rv);
    124               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    125                                           L2_ACL_144_ENf, 0);
    126               BCM_IF_ERROR_RETURN(rv);
    127               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    128                                           IPV4_ACL_TYPEf, 0);
    129               BCM_IF_ERROR_RETURN(rv);
    130               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    131                                           IPV4_ACL_MODEf, 0);
    132               BCM_IF_ERROR_RETURN(rv);
    133               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    134                                           IPV4_ACL_144_ENf, 0);
    135               BCM_IF_ERROR_RETURN(rv);
    136               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    137                                           IPV6_ACL_TYPEf, 0);
    138               BCM_IF_ERROR_RETURN(rv);
    139               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    140                                           IPV6_ACL_MODEf, 0);
    141               BCM_IF_ERROR_RETURN(rv);
    142               rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    143                                           IPV6_ACL_144_ENf, 0);
    144               BCM_IF_ERROR_RETURN(rv);
    145               rv =  soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
    146                                            IPV6_FULL_ACLf, 0);
    147               BCM_IF_ERROR_RETURN(rv);
    148           }
    149 
    150           /* Clear the TCAM, Policy mems */
    151           for (idx = 0; idx < stage_fc->tcam_slices; idx++) {
    152               if (_bcm_field_ext_data_mask_mems[idx] != 0) {
    153                   rv = soc_mem_clear((unit), _bcm_field_ext_data_mask_mems[idx], 
    154                                      COPYNO_ALL, TRUE);
    155                   BCM_IF_ERROR_RETURN(rv);
    156               }
    157               if (_bcm_field_ext_data_mems[idx] != 0) {
    158                   rv = soc_mem_clear((unit), _bcm_field_ext_data_mems[idx], 
    159                                      COPYNO_ALL, TRUE);
    160                   BCM_IF_ERROR_RETURN(rv);
    161               }
    162               if (_bcm_field_ext_mask_mems[idx] != 0) {
    163                   rv = soc_mem_clear((unit), _bcm_field_ext_mask_mems[idx], COPYNO_ALL, TRUE);
    164                   BCM_IF_ERROR_RETURN(rv);
    165               }
    166               rv = soc_mem_clear((unit), _bcm_field_ext_policy_mems[idx], COPYNO_ALL, TRUE);
    167               BCM_IF_ERROR_RETURN(rv);
    168           }
    169 
    170           /* Clear other mems */
    171           rv = soc_mem_clear((unit), EXT_FP_CNTRm, COPYNO_ALL, TRUE);
    172           BCM_IF_ERROR_RETURN(rv);
    173           rv = soc_mem_clear((unit), ESM_RANGE_CHECKm, COPYNO_ALL, TRUE);
    174           BCM_IF_ERROR_RETURN(rv);
    175           break;
    176     } /* end switch */
    177 
    178     return (BCM_E_NONE);
    179 }
    180 
    181 /*
    182  * Function:
    183  *     _field_tr_ingress_qualifiers_init
    184  * Purpose:
    185  *     Initialize device stage ingress qaualifiers 
    186  *     select codes & offsets
    187  * Parameters:
    188  *     unit       - (IN) BCM device number.
    189  *     stage_fc   - (IN) Field Processor stage control structure. 
    190  *
    191  * Returns:
    192  *     BCM_E_NONE
    193  */
    194 STATIC int
    195 _field_tr_ingress_qualifiers_init(int unit, _field_stage_t *stage_fc)
    196 {
    197     _FP_QUAL_DECL;
    198 
    199     /* Input parameters check. */
    200     if (NULL == stage_fc) {
    201         return (BCM_E_PARAM);
    202     }
    203 
    204     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyStage,
    205                  _bcmFieldSliceSelDisable, 0, 0, 0);
    206     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyStageIngress,
    207                  _bcmFieldSliceSelDisable, 0, 0, 0);
    208     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp4,
    209                  _bcmFieldSliceSelDisable, 0, 0, 0);
    210     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
    211                  _bcmFieldSliceSelDisable, 0, 0, 0);
    212     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
    213                  _bcmFieldSliceSelDisable, 0, 0, 0);
    214     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPorts,
    215                  _bcmFieldSliceSelDisable, 0, 0, 0);
    216 
    217     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
    218                  _bcmFieldSliceSelDisable, 0, 6, 1);
    219     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
    220                  _bcmFieldSliceSelDisable, 0, 7, 4);
    221     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4Ports,
    222                  _bcmFieldSliceSelDisable, 0, 11, 1);
    223     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
    224                  _bcmFieldSliceSelDisable, 0, 12, 1);
    225     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
    226                  _bcmFieldSliceSelDisable, 0, 13, 1);
    227     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMplsTerminated,
    228                  _bcmFieldSliceSelDisable, 0, 14, 1);
    229     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
    230                  _bcmFieldSliceSelDisable, 0, 15, 1);
    231     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
    232                  _bcmFieldSliceSelDisable, 0, 16, 1);
    233 
    234     /* FPF3 primary slice single wide. */
    235     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
    236                                _bcmFieldSliceSelFpf3, 0,
    237                                _bcmFieldSliceDstClassSelect, 0, 19, 6);
    238     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
    239                                _bcmFieldSliceSelFpf3, 0,
    240                                _bcmFieldSliceDstClassSelect, 1, 19, 6);
    241     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    242                                _bcmFieldSliceSelFpf3, 0,
    243                                _bcmFieldSliceDstClassSelect, 2, 19, 6);
    244     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    245                                _bcmFieldSliceSelFpf3, 0,
    246                                _bcmFieldSliceSrcClassSelect, 2, 25, 6);
    247     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
    248                                _bcmFieldSliceSelFpf3, 0,
    249                                _bcmFieldSliceSrcClassSelect, 0, 25, 6);
    250     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
    251                                _bcmFieldSliceSelFpf3, 0,
    252                                _bcmFieldSliceSrcClassSelect, 1, 25, 6);
    253     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    254                                _bcmFieldSliceSelFpf3, 0,
    255                                _bcmFieldSliceSrcClassSelect, 3, 25, 6);
    256     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    257                                _bcmFieldSliceSelFpf3, 0,
    258                                _bcmFieldSliceDstClassSelect, 3, 19, 6);
    259     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Ingress,
    260                  _bcmFieldSliceSelFpf3, 0, 39, 12);
    261     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
    262                  _bcmFieldSliceSelFpf3, 0, 31, 8);
    263 
    264     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
    265                                _bcmFieldSliceSelFpf3, 1,
    266                                _bcmFieldSliceDstClassSelect, 0, 19, 6);
    267     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
    268                                _bcmFieldSliceSelFpf3, 1,
    269                                _bcmFieldSliceDstClassSelect, 1, 19, 6);
    270     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    271                                _bcmFieldSliceSelFpf3, 1,
    272                                _bcmFieldSliceDstClassSelect, 2, 19, 6);
    273     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    274                                _bcmFieldSliceSelFpf3, 1,
    275                                _bcmFieldSliceSrcClassSelect, 2, 25, 6);
    276     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
    277                                _bcmFieldSliceSelFpf3, 1,
    278                                _bcmFieldSliceSrcClassSelect, 0, 25, 6);
    279     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
    280                                _bcmFieldSliceSelFpf3, 1,
    281                                _bcmFieldSliceSrcClassSelect, 1, 25, 6);
    282     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    283                                _bcmFieldSliceSelFpf3, 1,
    284                                _bcmFieldSliceSrcClassSelect, 3, 25, 6);
    285     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    286                                _bcmFieldSliceSelFpf3, 1,
    287                                _bcmFieldSliceDstClassSelect, 3, 19, 6);
    288     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
    289                  _bcmFieldSliceSelFpf3, 1, 31, 8);
    290     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    291                  _bcmFieldSliceSelFpf3, 1, 39, 12);
    292 
    293     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstPort,
    294                  _bcmFieldSliceSelFpf3, 2, 19, 14);
    295     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstTrunk,
    296                  _bcmFieldSliceSelFpf3, 2, 19, 14);
    297     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcPort,
    298                  _bcmFieldSliceSelFpf3, 2, 33, 14);
    299     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcTrunk,
    300                  _bcmFieldSliceSelFpf3, 2, 33, 14);
    301     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMHOpcode,
    302                  _bcmFieldSliceSelFpf3, 2, 47, 3);
    303 
    304     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    305                  _bcmFieldSliceSelFpf3, 3, 19, 16);
    306     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    307                  _bcmFieldSliceSelFpf3, 3, 19, 12);
    308     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    309                  _bcmFieldSliceSelFpf3, 3, 31, 1);
    310     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    311                  _bcmFieldSliceSelFpf3, 3, 32, 3);
    312     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
    313                  _bcmFieldSliceSelFpf3, 3, 35, 2);
    314     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTranslatedVlanFormat,
    315                  _bcmFieldSliceSelFpf3, 3, 35, 2);
    316     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2Format,
    317                  _bcmFieldSliceSelFpf3, 3, 37, 2);
    318     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMHOpcode,
    319                  _bcmFieldSliceSelFpf3, 3, 39, 3);
    320     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyPacketRes,
    321                  _bcmFieldSliceSelFpf3, 3, 42, 4);
    322     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpInfo,
    323                  _bcmFieldSliceSelFpf3, 3, 46, 3);
    324 
    325     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    326                  _bcmFieldSliceSelFpf3, 4, 19, 16);
    327     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    328                  _bcmFieldSliceSelFpf3, 4, 19, 12);
    329     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    330                  _bcmFieldSliceSelFpf3, 4, 31, 1);
    331     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    332                  _bcmFieldSliceSelFpf3, 4, 32, 3);
    333     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
    334                  _bcmFieldSliceSelFpf3, 4, 35, 16);
    335     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
    336                  _bcmFieldSliceSelFpf3, 4, 35, 12);
    337     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
    338                  _bcmFieldSliceSelFpf3, 4, 47, 1);
    339     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
    340                  _bcmFieldSliceSelFpf3, 4, 48, 3);
    341 
    342     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    343                  _bcmFieldSliceSelFpf3, 5, 19, 16);
    344     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    345                  _bcmFieldSliceSelFpf3, 5, 19, 12);
    346     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    347                  _bcmFieldSliceSelFpf3, 5, 31, 1);
    348     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    349                  _bcmFieldSliceSelFpf3, 5, 32, 3);
    350     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
    351                  _bcmFieldSliceSelFpf3, 5, 35, 16);
    352 
    353     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanTranslationHit,
    354                  _bcmFieldSliceSelFpf3, 6, 20, 1);
    355     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyForwardingVlanValid,
    356                  _bcmFieldSliceSelFpf3, 6, 21, 1);
    357     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIngressStpState,
    358                  _bcmFieldSliceSelFpf3, 6, 22, 2);
    359     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2SrcHit,
    360                  _bcmFieldSliceSelFpf3, 6, 24, 1);
    361     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2SrcStatic,
    362                  _bcmFieldSliceSelFpf3, 6, 25, 1);
    363     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2DestHit,
    364                  _bcmFieldSliceSelFpf3, 6, 26, 1);
    365     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2CacheHit,
    366                  _bcmFieldSliceSelFpf3, 6, 28, 1);
    367     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3SrcHostHit,
    368                  _bcmFieldSliceSelFpf3, 6, 29, 1);
    369     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3DestHostHit,
    370                  _bcmFieldSliceSelFpf3, 6, 30, 1);
    371     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpmcStarGroupHit,
    372                  _bcmFieldSliceSelFpf3, 6, 31, 1);
    373     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3DestRouteHit,
    374                  _bcmFieldSliceSelFpf3, 6, 32, 1);
    375     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2StationMove,
    376                  _bcmFieldSliceSelFpf3, 6, 33, 1);
    377     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDosAttack,
    378                  _bcmFieldSliceSelFpf3, 6, 34, 1);
    379     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
    380                  _bcmFieldSliceSelFpf3, 6, 35, 16);
    381     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
    382                  _bcmFieldSliceSelFpf3, 6, 35, 12);
    383     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
    384                  _bcmFieldSliceSelFpf3, 6, 47, 1);
    385     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
    386                  _bcmFieldSliceSelFpf3, 6, 48, 3);
    387     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
    388                  _bcmFieldSliceSelFpf3, 7, 19, 24);
    389     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, _bcmFieldQualifyRangeCheckBits24_31,
    390                                _bcmFieldSliceSelFpf3, 7,
    391                                _bcmFieldSliceIntfClassSelect, 3, 43, 8);
    392     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassPort,
    393                                _bcmFieldSliceSelFpf3, 7,
    394                                _bcmFieldSliceIntfClassSelect, 0, 43, 8);
    395     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassL3,
    396                                _bcmFieldSliceSelFpf3, 7,
    397                                _bcmFieldSliceIntfClassSelect, 1, 43, 8);
    398     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassL2,
    399                                _bcmFieldSliceSelFpf3, 7,
    400                                _bcmFieldSliceIntfClassSelect, 2, 43, 8);
    401 
    402     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6FlowLabel,
    403                  _bcmFieldSliceSelFpf3, 8, 19, 20);
    404     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
    405                  _bcmFieldSliceSelFpf3, 8, 39, 2);
    406     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTranslatedVlanFormat,
    407                  _bcmFieldSliceSelFpf3, 8, 39, 2);
    408     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2Format,
    409                  _bcmFieldSliceSelFpf3, 8, 41, 2);
    410     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerTpid,
    411                  _bcmFieldSliceSelFpf3, 8, 43, 2);
    412     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterTpid,
    413                  _bcmFieldSliceSelFpf3, 8, 45, 2);
    414 
    415     /* FPF2 */
    416     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
    417                  _bcmFieldSliceSelFpf2, 0,
    418                  _bcmFieldSliceTtlClassSelect, 0,
    419                  51, 8);
    420     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtlClassZero,
    421                  _bcmFieldSliceSelFpf2, 0,
    422                  _bcmFieldSliceTtlClassSelect, 0,
    423                  51, 8);
    424     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtlClassOne,
    425                  _bcmFieldSliceSelFpf2, 0,
    426                  _bcmFieldSliceTtlClassSelect, 1,
    427                  51, 8);
    428     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
    429                  _bcmFieldSliceSelFpf2, 0,
    430                  _bcmFieldSliceTcpClassSelect, 0,
    431                  59, 6);
    432     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpClassZero,
    433                  _bcmFieldSliceSelFpf2, 0,
    434                  _bcmFieldSliceTcpClassSelect, 0,
    435                  59, 6);
    436     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpClassOne,
    437                  _bcmFieldSliceSelFpf2, 0,
    438                  _bcmFieldSliceTcpClassSelect, 1,
    439                  59, 6);
    440     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFlags,
    441                  _bcmFieldSliceSelFpf2, 0, 65, 2);
    442     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
    443                  _bcmFieldSliceSelFpf2, 0,
    444                  _bcmFieldSliceTosClassSelect, 0,
    445                  67, 8);
    446     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassZero,
    447                  _bcmFieldSliceSelFpf2, 0,
    448                  _bcmFieldSliceTosClassSelect, 0,
    449                  67, 8);
    450     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassOne,
    451                  _bcmFieldSliceSelFpf2, 0,
    452                  _bcmFieldSliceTosClassSelect, 1,
    453                  67, 8);
    454     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
    455                  _bcmFieldSliceSelFpf2, 0, 75, 16);
    456     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
    457                  _bcmFieldSliceSelFpf2, 0, 91, 16);
    458     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
    459                  _bcmFieldSliceSelFpf2, 0, 107, 8);
    460     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
    461                  _bcmFieldSliceSelFpf2, 0, 115, 32);
    462     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
    463                  _bcmFieldSliceSelFpf2, 0, 147, 32);
    464 
    465     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
    466                  _bcmFieldSliceSelFpf2, 1,
    467                  _bcmFieldSliceTtlClassSelect, 0,
    468                  51, 8);
    469     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtlClassZero,
    470                  _bcmFieldSliceSelFpf2, 1,
    471                  _bcmFieldSliceTtlClassSelect, 0,
    472                  51, 8);
    473     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtlClassOne,
    474                  _bcmFieldSliceSelFpf2, 1,
    475                  _bcmFieldSliceTtlClassSelect, 1,
    476                  51, 8);
    477     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
    478                  _bcmFieldSliceSelFpf2, 1,
    479                  _bcmFieldSliceTcpClassSelect, 0,
    480                  59, 6);
    481     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpClassZero,
    482                  _bcmFieldSliceSelFpf2, 1,
    483                  _bcmFieldSliceTcpClassSelect, 0,
    484                  59, 6);
    485     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpClassOne,
    486                  _bcmFieldSliceSelFpf2, 1,
    487                  _bcmFieldSliceTcpClassSelect, 1,
    488                  59, 6);
    489     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
    490                  _bcmFieldSliceSelFpf2, 1, 65, 2);
    491     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
    492                  _bcmFieldSliceSelFpf2, 1,
    493                  _bcmFieldSliceTosClassSelect, 0,
    494                  67, 8);
    495     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassZero,
    496                  _bcmFieldSliceSelFpf2, 1,
    497                  _bcmFieldSliceTosClassSelect, 0,
    498                  67, 8);
    499     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassOne,
    500                  _bcmFieldSliceSelFpf2, 1,
    501                  _bcmFieldSliceTosClassSelect, 1,
    502                  67, 8);
    503     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
    504                  _bcmFieldSliceSelFpf2, 1, 75, 16);
    505     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
    506                  _bcmFieldSliceSelFpf2, 1, 91, 16);
    507     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
    508                  _bcmFieldSliceSelFpf2, 1, 107, 8);
    509     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
    510                  _bcmFieldSliceSelFpf2, 1, 115, 32);
    511     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
    512                  _bcmFieldSliceSelFpf2, 1, 147, 32);
    513 
    514     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
    515                  _bcmFieldSliceSelFpf2, 2, 51, 128);
    516 
    517     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6,
    518                  _bcmFieldSliceSelFpf2, 3, 51, 128);
    519 
    520     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
    521                  _bcmFieldSliceSelFpf2, 4,
    522                  _bcmFieldSliceTtlClassSelect, 0,
    523                  51, 8);
    524     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtlClassZero,
    525                  _bcmFieldSliceSelFpf2, 4,
    526                  _bcmFieldSliceTtlClassSelect, 0,
    527                  51, 8);
    528     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtlClassOne,
    529                  _bcmFieldSliceSelFpf2, 4,
    530                  _bcmFieldSliceTtlClassSelect, 1,
    531                  51, 8);
    532     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
    533                  _bcmFieldSliceSelFpf2, 4,
    534                  _bcmFieldSliceTcpClassSelect, 0,
    535                  59, 6);
    536     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpClassZero,
    537                  _bcmFieldSliceSelFpf2, 4,
    538                  _bcmFieldSliceTcpClassSelect, 0,
    539                  59, 6);
    540     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTcpClassOne,
    541                  _bcmFieldSliceSelFpf2, 4,
    542                  _bcmFieldSliceTcpClassSelect, 1,
    543                  59, 6);
    544     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6FlowLabel,
    545                  _bcmFieldSliceSelFpf2, 4, 65, 20);
    546     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
    547                  _bcmFieldSliceSelFpf2, 4,
    548                  _bcmFieldSliceTosClassSelect, 0,
    549                  85, 8);
    550     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassZero,
    551                  _bcmFieldSliceSelFpf2, 4,
    552                  _bcmFieldSliceTosClassSelect, 0,
    553                  85, 8);
    554     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassOne,
    555                  _bcmFieldSliceSelFpf2, 4,
    556                  _bcmFieldSliceTosClassSelect, 1,
    557                  85, 8);
    558     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
    559                  _bcmFieldSliceSelFpf2, 4, 93, 8);
    560     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6High,
    561                  _bcmFieldSliceSelFpf2, 4, 101, 64);
    562 
    563     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    564                  _bcmFieldSliceSelFpf2, 5, 51, 16);
    565     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    566                  _bcmFieldSliceSelFpf2, 5, 51, 12);
    567     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    568                  _bcmFieldSliceSelFpf2, 5, 63, 1);
    569     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    570                  _bcmFieldSliceSelFpf2, 5, 64, 3);
    571     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
    572                  _bcmFieldSliceSelFpf2, 5, 67, 16);
    573     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
    574                  _bcmFieldSliceSelFpf2, 5, 83, 48);
    575     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
    576                  _bcmFieldSliceSelFpf2, 5, 131, 48);
    577 
    578     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    579                  _bcmFieldSliceSelFpf2, 6, 51, 16);
    580     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    581                  _bcmFieldSliceSelFpf2, 6, 51, 12);
    582     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    583                  _bcmFieldSliceSelFpf2, 6, 63, 1);
    584     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    585                  _bcmFieldSliceSelFpf2, 6, 64, 3);
    586     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
    587                  _bcmFieldSliceSelFpf2, 6, 67, 16);
    588     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
    589                  _bcmFieldSliceSelFpf2, 6, 83, 32);
    590     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
    591                  _bcmFieldSliceSelFpf2, 6, 115, 48);
    592 
    593     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    594                  _bcmFieldSliceSelFpf2, 7, 51, 16);
    595     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    596                  _bcmFieldSliceSelFpf2, 7, 51, 12);
    597     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    598                  _bcmFieldSliceSelFpf2, 7, 63, 1);
    599     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    600                  _bcmFieldSliceSelFpf2, 7, 64, 3);
    601     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
    602                  _bcmFieldSliceSelFpf2, 7, 67, 16);
    603     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
    604                  _bcmFieldSliceSelFpf2, 7, 83, 32);
    605     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
    606                  _bcmFieldSliceSelFpf2, 7, 115, 48);
    607 
    608     _FP_QUAL_ADD(unit, stage_fc, _bcmFieldQualifyData0,
    609                  _bcmFieldSliceSelFpf2, 8, 51, 128);
    610 
    611     _FP_QUAL_ADD(unit, stage_fc, _bcmFieldQualifyData1,
    612                  _bcmFieldSliceSelFpf2, 9, 51, 128);
    613 
    614     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp6High,
    615                  _bcmFieldSliceSelFpf2, 10, 51, 64);
    616     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6High,
    617                  _bcmFieldSliceSelFpf2, 10, 115, 64);
    618 
    619 
    620     /* FPF1 */ 
    621     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
    622                                _bcmFieldSliceSelFpf1, 0,
    623                                _bcmFieldSliceDstClassSelect, 0, 179, 6);
    624     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
    625                                _bcmFieldSliceSelFpf1, 0,
    626                                _bcmFieldSliceDstClassSelect, 1, 179, 6);
    627     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    628                                _bcmFieldSliceSelFpf1, 0,
    629                                _bcmFieldSliceDstClassSelect, 2, 179, 6);
    630     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    631                                _bcmFieldSliceSelFpf1, 0,
    632                                _bcmFieldSliceSrcClassSelect, 2, 185, 6);
    633     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
    634                                _bcmFieldSliceSelFpf1, 0,
    635                                _bcmFieldSliceSrcClassSelect, 0, 185, 6);
    636     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
    637                                _bcmFieldSliceSelFpf1, 0,
    638                                _bcmFieldSliceSrcClassSelect, 1, 185, 6);
    639     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    640                                _bcmFieldSliceSelFpf1, 0,
    641                                _bcmFieldSliceSrcClassSelect, 3, 185, 6);
    642     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    643                                _bcmFieldSliceSelFpf1, 0,
    644                                _bcmFieldSliceDstClassSelect, 3, 179, 6);
    645     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
    646                  _bcmFieldSliceSelFpf1, 0, 191, 10);
    647     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Ingress,
    648                  _bcmFieldSliceSelFpf1, 0, 201, 12);
    649 
    650     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstPort,
    651                  _bcmFieldSliceSelFpf1, 1, 179, 14);
    652     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstTrunk,
    653                  _bcmFieldSliceSelFpf1, 1, 179, 14);
    654     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcPort,
    655                  _bcmFieldSliceSelFpf1, 1, 193, 14);
    656     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcTrunk,
    657                  _bcmFieldSliceSelFpf1, 1, 193, 14);
    658     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMHOpcode,
    659                  _bcmFieldSliceSelFpf1, 1, 207, 3);
    660 
    661     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstPort,
    662                  _bcmFieldSliceSelFpf1, 2, 179, 14);
    663     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstTrunk,
    664                  _bcmFieldSliceSelFpf1, 2, 179, 14);
    665     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMHOpcode,
    666                  _bcmFieldSliceSelFpf1, 2, 193, 3);
    667     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
    668                                _bcmFieldSliceSelFpf1, 2,
    669                                _bcmFieldSliceDstClassSelect, 0, 196, 6);
    670     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
    671                                _bcmFieldSliceSelFpf1, 2,
    672                                _bcmFieldSliceDstClassSelect, 1, 196, 6);
    673     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    674                                _bcmFieldSliceSelFpf1, 2,
    675                                _bcmFieldSliceDstClassSelect, 2, 196, 6);
    676     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    677                                _bcmFieldSliceSelFpf1, 2,
    678                                _bcmFieldSliceSrcClassSelect, 2, 202, 6);
    679     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
    680                                _bcmFieldSliceSelFpf1, 2,
    681                                _bcmFieldSliceSrcClassSelect, 0, 202, 6);
    682     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
    683                                _bcmFieldSliceSelFpf1, 2,
    684                                _bcmFieldSliceSrcClassSelect, 1, 202, 6);
    685     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    686                                _bcmFieldSliceSelFpf1, 2,
    687                                _bcmFieldSliceSrcClassSelect, 3, 202, 6);
    688     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    689                                _bcmFieldSliceSelFpf1, 2,
    690                                _bcmFieldSliceDstClassSelect, 3, 196, 6);
    691     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
    692                  _bcmFieldSliceSelFpf1, 3, 179, 16);
    693     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
    694                  _bcmFieldSliceSelFpf1, 3, 179, 12);
    695     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
    696                  _bcmFieldSliceSelFpf1, 3, 191, 1);
    697     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
    698                  _bcmFieldSliceSelFpf1, 3, 192, 3);
    699     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    700                  _bcmFieldSliceSelFpf1, 3, 195, 16);
    701     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    702                  _bcmFieldSliceSelFpf1, 3, 195, 12);
    703     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    704                  _bcmFieldSliceSelFpf1, 3, 207, 1);
    705     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    706                  _bcmFieldSliceSelFpf1, 3, 208, 3);
    707     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterTpid,
    708                  _bcmFieldSliceSelFpf1, 3, 211, 2);
    709 
    710     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    711                  _bcmFieldSliceSelFpf1, 4, 179, 16);
    712     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    713                  _bcmFieldSliceSelFpf1, 4, 179, 12);
    714     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    715                  _bcmFieldSliceSelFpf1, 4, 191, 1);
    716     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    717                  _bcmFieldSliceSelFpf1, 4, 192, 3);
    718     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
    719                  _bcmFieldSliceSelFpf1, 4, 195, 16);
    720 
    721     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanTranslationHit,
    722                  _bcmFieldSliceSelFpf1, 5, 180, 1);
    723     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyForwardingVlanValid,
    724                  _bcmFieldSliceSelFpf1, 5, 181, 1);
    725     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIngressStpState,
    726                  _bcmFieldSliceSelFpf1, 5, 182, 2);
    727     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2SrcHit,
    728                  _bcmFieldSliceSelFpf1, 5, 184, 1);
    729     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2SrcStatic,
    730                  _bcmFieldSliceSelFpf1, 5, 185, 1);
    731     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2DestHit,
    732                  _bcmFieldSliceSelFpf1, 5, 186, 1);
    733     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2CacheHit,
    734                  _bcmFieldSliceSelFpf1, 5, 188, 1);
    735     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3SrcHostHit,
    736                  _bcmFieldSliceSelFpf1, 5, 189, 1);
    737     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3DestHostHit,
    738                  _bcmFieldSliceSelFpf1, 5, 190, 1);
    739     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpmcStarGroupHit,
    740                  _bcmFieldSliceSelFpf1, 5, 191, 1);
    741     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3DestRouteHit,
    742                  _bcmFieldSliceSelFpf1, 5, 192, 1);
    743     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2StationMove,
    744                  _bcmFieldSliceSelFpf1, 5, 193, 1);
    745     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDosAttack,
    746                  _bcmFieldSliceSelFpf1, 5, 194, 1);
    747     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
    748                  _bcmFieldSliceSelFpf1, 5, 195, 16);
    749     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
    750                  _bcmFieldSliceSelFpf1, 5, 195, 12);
    751     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
    752                  _bcmFieldSliceSelFpf1, 5, 207, 1);
    753     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
    754                  _bcmFieldSliceSelFpf1, 5, 208, 3);
    755     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerTpid,
    756                  _bcmFieldSliceSelFpf1, 5, 211, 2);
    757 
    758     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    759                  _bcmFieldSliceSelFpf1, 6, 179, 16);
    760     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    761                  _bcmFieldSliceSelFpf1, 6, 179, 12);
    762     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    763                  _bcmFieldSliceSelFpf1, 6, 191, 1);
    764     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    765                  _bcmFieldSliceSelFpf1, 6, 192, 3);
    766     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
    767                  _bcmFieldSliceSelFpf1, 6, 195, 2);
    768     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTranslatedVlanFormat,
    769                  _bcmFieldSliceSelFpf1, 6, 195, 2);
    770     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2Format,
    771                  _bcmFieldSliceSelFpf1, 6, 197, 2);
    772     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMHOpcode,
    773                  _bcmFieldSliceSelFpf1, 6, 201, 3);
    774     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyPacketRes,
    775                  _bcmFieldSliceSelFpf1, 6, 204, 4);
    776     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpInfo,
    777                  _bcmFieldSliceSelFpf1, 6, 208, 3);
    778 
    779 
    780     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
    781                  _bcmFieldSliceSelFpf1, 7, 179, 16);
    782     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
    783                  _bcmFieldSliceSelFpf1, 7, 179, 12);
    784     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
    785                  _bcmFieldSliceSelFpf1, 7, 191, 1);
    786     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
    787                  _bcmFieldSliceSelFpf1, 7, 192, 3);
    788     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
    789                                _bcmFieldSliceSelFpf1, 7,
    790                                _bcmFieldSliceSrcClassSelect, 0, 195, 6);
    791     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
    792                                _bcmFieldSliceSelFpf1, 7,
    793                                _bcmFieldSliceSrcClassSelect, 1, 195, 6);
    794     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    795                                _bcmFieldSliceSelFpf1, 7,
    796                                _bcmFieldSliceSrcClassSelect, 3, 195, 6);
    797     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    798                                _bcmFieldSliceSelFpf1, 7,
    799                                _bcmFieldSliceSrcClassSelect, 2, 195, 6);
    800     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
    801                  _bcmFieldSliceSelFpf1, 7, 201, 11);
    802 
    803 
    804     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
    805                  _bcmFieldSliceSelFpf1, 8, 179, 8);
    806     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
    807                  _bcmFieldSliceSelFpf1, 8,
    808                  _bcmFieldSliceTosClassSelect, 0,
    809                  187, 8);
    810     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassZero,
    811                  _bcmFieldSliceSelFpf1, 8,
    812                  _bcmFieldSliceTosClassSelect, 0,
    813                  187, 8);
    814     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTosClassOne,
    815                  _bcmFieldSliceSelFpf1, 8,
    816                  _bcmFieldSliceTosClassSelect, 1,
    817                  187, 8);
    818     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
    819                                _bcmFieldSliceSelFpf1, 8,
    820                                _bcmFieldSliceSrcClassSelect, 0, 195, 6);
    821     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
    822                                _bcmFieldSliceSelFpf1, 8,
    823                                _bcmFieldSliceSrcClassSelect, 1, 195, 6);
    824     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
    825                                _bcmFieldSliceSelFpf1, 8,
    826                                _bcmFieldSliceSrcClassSelect, 3, 195, 6);
    827     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
    828                                _bcmFieldSliceSelFpf1, 8,
    829                                _bcmFieldSliceSrcClassSelect, 2, 195, 6);
    830     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
    831                  _bcmFieldSliceSelFpf1, 8, 201, 11);
    832 
    833 
    834     /* DWF4 */
    835     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
    836                             _bcmFieldSliceSelFpf4, 1,
    837                             _bcmFieldSliceTcpClassSelect, 0, 0, 6);
    838     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTcpClassZero,
    839                             _bcmFieldSliceSelFpf4, 1,
    840                             _bcmFieldSliceTcpClassSelect, 0, 0, 6);
    841     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTcpClassOne,
    842                             _bcmFieldSliceSelFpf4, 1,
    843                             _bcmFieldSliceTcpClassSelect, 1, 0, 6);
    844 
    845     /* DWF3 */
    846     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTos,
    847                             _bcmFieldSliceSelDisable, 0,
    848                             _bcmFieldSliceTosClassSelect, 0, 6, 8);
    849     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTosClassZero,
    850                             _bcmFieldSliceSelDisable, 0,
    851                             _bcmFieldSliceTosClassSelect, 0, 6, 8);
    852     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTosClassOne,
    853                             _bcmFieldSliceSelDisable, 0,
    854                             _bcmFieldSliceTosClassSelect, 1, 6, 8);
    855     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
    856                             _bcmFieldSliceSelDisable, 0,
    857                             _bcmFieldSliceSelDisable, 0, 14, 8);
    858     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc,
    859                             bcmFieldQualifyExtensionHeaderSubCode,
    860                             _bcmFieldSliceSelDisable, 0,
    861                             _bcmFieldSliceSelDisable, 0, 22, 8);
    862     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderType,
    863                             _bcmFieldSliceSelDisable, 0,
    864                             _bcmFieldSliceSelDisable, 0, 30, 8);
    865 
    866     /* DWF2 */
    867     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyVlanTranslationHit,
    868                             _bcmFieldSliceSelFpf2, 0,
    869                             _bcmFieldSliceSelDisable, 0, 55, 1);
    870     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyForwardingVlanValid,
    871                             _bcmFieldSliceSelFpf2, 0,
    872                             _bcmFieldSliceSelDisable, 0, 56, 1);
    873     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIngressStpState,
    874                             _bcmFieldSliceSelFpf2, 0,
    875                             _bcmFieldSliceSelDisable, 0, 57, 2);
    876     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL2SrcHit,
    877                             _bcmFieldSliceSelFpf2, 0,
    878                             _bcmFieldSliceSelDisable, 0, 59, 1);
    879     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL2SrcStatic,
    880                             _bcmFieldSliceSelFpf2, 0,
    881                             _bcmFieldSliceSelDisable, 0, 60, 1);
    882     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL2DestHit,
    883                             _bcmFieldSliceSelFpf2, 0,
    884                             _bcmFieldSliceSelDisable, 0, 61, 1);
    885     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL2CacheHit,
    886                             _bcmFieldSliceSelFpf2, 0,
    887                             _bcmFieldSliceSelDisable, 0, 63, 1);
    888     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL3SrcHostHit,
    889                             _bcmFieldSliceSelFpf2, 0,
    890                             _bcmFieldSliceSelDisable, 0, 64, 1);
    891     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL3DestHostHit,
    892                             _bcmFieldSliceSelFpf2, 0,
    893                             _bcmFieldSliceSelDisable, 0, 65, 1);
    894     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIpmcStarGroupHit,
    895                             _bcmFieldSliceSelFpf2, 0,
    896                             _bcmFieldSliceSelDisable, 0, 66, 1);
    897     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL3DestRouteHit,
    898                             _bcmFieldSliceSelFpf2, 0,
    899                             _bcmFieldSliceSelDisable, 0, 67, 1);
    900     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL2StationMove,
    901                             _bcmFieldSliceSelFpf2, 0,
    902                             _bcmFieldSliceSelDisable, 0, 68, 1);
    903     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyDosAttack,
    904                             _bcmFieldSliceSelFpf2, 0,
    905                             _bcmFieldSliceSelDisable, 0, 69, 1);
    906     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
    907                             _bcmFieldSliceSelFpf2, 0,
    908                             _bcmFieldSliceSelDisable, 0, 70, 24);
    909     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, _bcmFieldQualifyRangeCheckBits24_31,
    910                             _bcmFieldSliceSelFpf2, 0,
    911                             _bcmFieldSliceIntfClassSelect, 3, 94, 8);
    912     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassPort,
    913                             _bcmFieldSliceSelFpf2, 0,
    914                             _bcmFieldSliceIntfClassSelect, 0, 94, 8);
    915     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassL3,
    916                             _bcmFieldSliceSelFpf2, 0,
    917                             _bcmFieldSliceIntfClassSelect, 1, 94, 8);
    918     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassL2,
    919                             _bcmFieldSliceSelFpf2, 0,
    920                             _bcmFieldSliceIntfClassSelect, 2, 94, 8);
    921     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
    922                             _bcmFieldSliceSelFpf2, 0,
    923                             _bcmFieldSliceSelDisable, 0, 102, 32);
    924     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
    925                             _bcmFieldSliceSelFpf2, 0,
    926                             _bcmFieldSliceSelDisable, 0, 134, 32);
    927     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
    928                             _bcmFieldSliceSelFpf2, 1,
    929                             _bcmFieldSliceSelDisable, 0, 38, 128);
    930     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, _bcmFieldQualifyData1,
    931                             _bcmFieldSliceSelFpf2, 2,
    932                             _bcmFieldSliceSelDisable, 0, 38, 128);
    933     /* DWF1 */
    934     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTtl,
    935                             _bcmFieldSliceSelDisable, 0,
    936                             _bcmFieldSliceTtlClassSelect, 0, 166, 7);
    937     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTtlClassZero,
    938                             _bcmFieldSliceSelDisable, 0,
    939                             _bcmFieldSliceTtlClassSelect, 0, 166, 7);
    940     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTtlClassOne,
    941                             _bcmFieldSliceSelDisable, 0,
    942                             _bcmFieldSliceTtlClassSelect, 1, 166, 7);
    943     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
    944                             _bcmFieldSliceSelDisable, 0,
    945                             _bcmFieldSliceSelDisable, 0, 173, 2);
    946     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
    947                             _bcmFieldSliceSelDisable, 0,
    948                             _bcmFieldSliceSelDisable, 0, 175, 16);
    949     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
    950                             _bcmFieldSliceSelDisable, 0,
    951                             _bcmFieldSliceSelDisable, 0, 191, 16);
    952     /* DONE DWF */
    953     return (BCM_E_NONE);
    954 }
    955 
    956 /*
    957  * Function:
    958  *     _field_tr_lookup_qualifiers_init
    959  * Purpose:
    960  *     Initialize device stage lookup qaualifiers 
    961  *     select codes & offsets
    962  * Parameters:
    963  *     unit       - (IN) BCM device number.
    964  *     stage_fc   - (IN) Field Processor stage control structure. 
    965  *
    966  * Returns:
    967  *     BCM_E_NONE
    968  */
    969 STATIC int
    970 _field_tr_lookup_qualifiers_init(int unit, _field_stage_t *stage_fc)
    971 {
    972     _FP_QUAL_DECL;
    973 
    974     /* Input parameters check. */
    975     if (NULL == stage_fc) {
    976         return (BCM_E_PARAM);
    977     }
    978 
    979     /* Enable the overlay of Sender Ethernet Address onto MACSA
    980      * on ARP/RARP packets.
    981      */
    982     BCM_IF_ERROR_RETURN
    983         (soc_reg_field32_modify(unit, ING_CONFIG_64r, REG_PORT_ANY,
    984                                 ARP_VALIDATION_ENf, 1));
    985 
    986     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyStageLookup,
    987                  _bcmFieldSliceSelDisable, 0, 0, 0);
    988     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp4,
    989                  _bcmFieldSliceSelDisable, 0, 0, 0);
    990     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
    991                  _bcmFieldSliceSelDisable, 0, 0, 0);
    992 
    993     /* FPF3 */
    994     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
    995                  _bcmFieldSliceSelFpf3, 0, 0, 16);
    996     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
    997                  _bcmFieldSliceSelFpf3, 0, 0, 12);
    998     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
    999                  _bcmFieldSliceSelFpf3, 0, 12, 1);
   1000     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
   1001                  _bcmFieldSliceSelFpf3, 0, 13, 3);
   1002     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
   1003                  _bcmFieldSliceSelFpf3, 0, 16, 16);
   1004 
   1005     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyInnerL4DstPort,
   1006                                _bcmFieldSliceSelFpf3, 1,
   1007                                _bcmFieldSliceIpHeaderSelect, 1, 0, 16);
   1008     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   1009                                _bcmFieldSliceSelFpf3, 1,
   1010                                _bcmFieldSliceIpHeaderSelect, 0, 0, 16);
   1011     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyInnerL4SrcPort,
   1012                                _bcmFieldSliceSelFpf3, 1,
   1013                                _bcmFieldSliceIpHeaderSelect, 1, 16, 16);
   1014     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   1015                                _bcmFieldSliceSelFpf3, 1,
   1016                                _bcmFieldSliceIpHeaderSelect, 0, 16, 16);
   1017     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1018                                bcmFieldQualifyInnerTos,
   1019                                _bcmFieldSliceSelFpf3, 2,
   1020                                _bcmFieldSliceIpHeaderSelect, 1, 0, 8);
   1021     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1022                                _bcmFieldSliceSelFpf3, 2,
   1023                                _bcmFieldSliceIpHeaderSelect, 0, 0, 8);
   1024     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1025                                bcmFieldQualifyInnerIpProtocol,
   1026                                _bcmFieldSliceSelFpf3, 2,
   1027                                _bcmFieldSliceIpHeaderSelect, 1, 8, 8);
   1028     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1029                                _bcmFieldSliceSelFpf3, 2,
   1030                                _bcmFieldSliceIpHeaderSelect, 0, 8, 8);
   1031     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIp6NextHeader,
   1032                                _bcmFieldSliceSelFpf3, 2,
   1033                                _bcmFieldSliceIpHeaderSelect, 0, 8, 8);
   1034     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderSubCode,
   1035                  _bcmFieldSliceSelFpf3, 2, 16, 8);
   1036     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderType,
   1037                  _bcmFieldSliceSelFpf3, 2, 24, 8);
   1038     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassL3,
   1039                  _bcmFieldSliceSelFpf3, 3, 0, 8);
   1040     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
   1041                  _bcmFieldSliceSelFpf3, 3, 8, 16);
   1042     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
   1043                  _bcmFieldSliceSelFpf3, 3, 8, 12);
   1044     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
   1045                  _bcmFieldSliceSelFpf3, 3, 20, 1);
   1046     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
   1047                  _bcmFieldSliceSelFpf3, 3, 21, 3);
   1048 
   1049     /* FPF2 */
   1050     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1051                                bcmFieldQualifyInnerTtl,
   1052                                _bcmFieldSliceSelFpf2, 0,
   1053                                _bcmFieldSliceIpHeaderSelect, 1, 32, 8);
   1054     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   1055                                _bcmFieldSliceSelFpf2, 0,
   1056                                _bcmFieldSliceIpHeaderSelect, 0, 32, 8);
   1057     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   1058                  _bcmFieldSliceSelFpf2, 0, 40, 6);
   1059     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1060                                bcmFieldQualifyInnerIpFrag,
   1061                                _bcmFieldSliceSelFpf2, 0,
   1062                                _bcmFieldSliceIpHeaderSelect, 1, 46, 2);
   1063     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1064                                _bcmFieldSliceSelFpf2, 0,
   1065                                _bcmFieldSliceIpHeaderSelect, 0, 46, 2);
   1066     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1067                                bcmFieldQualifyInnerTos,
   1068                                _bcmFieldSliceSelFpf2, 0,
   1069                                _bcmFieldSliceIpHeaderSelect, 1, 48, 8);
   1070     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1071                                _bcmFieldSliceSelFpf2, 0,
   1072                                _bcmFieldSliceIpHeaderSelect, 0, 48, 8);
   1073     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyInnerL4DstPort,
   1074                                _bcmFieldSliceSelFpf2, 0,
   1075                                _bcmFieldSliceIpHeaderSelect, 1, 56, 16);
   1076     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   1077                                _bcmFieldSliceSelFpf2, 0,
   1078                                _bcmFieldSliceIpHeaderSelect, 0, 56, 16);
   1079     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyInnerL4SrcPort,
   1080                                _bcmFieldSliceSelFpf2, 0,
   1081                                _bcmFieldSliceIpHeaderSelect, 1, 72, 16);
   1082     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   1083                                _bcmFieldSliceSelFpf2, 0,
   1084                                _bcmFieldSliceIpHeaderSelect, 0, 72, 16);
   1085     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1086                                bcmFieldQualifyInnerIpProtocol,
   1087                                _bcmFieldSliceSelFpf2, 0,
   1088                                _bcmFieldSliceIpHeaderSelect, 1, 88, 8);
   1089     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1090                                _bcmFieldSliceSelFpf2, 0,
   1091                                _bcmFieldSliceIpHeaderSelect, 0, 88, 8);
   1092     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1093                                bcmFieldQualifyInnerDstIp,
   1094                                _bcmFieldSliceSelFpf2, 0,
   1095                                _bcmFieldSliceIpHeaderSelect, 1, 96, 32);
   1096     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1097                                _bcmFieldSliceSelFpf2, 0,
   1098                                _bcmFieldSliceIpHeaderSelect, 0, 96, 32);
   1099     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1100                                bcmFieldQualifyInnerSrcIp,
   1101                                _bcmFieldSliceSelFpf2, 0,
   1102                                _bcmFieldSliceIpHeaderSelect, 1, 128, 32);
   1103     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1104                                _bcmFieldSliceSelFpf2, 0,
   1105                                _bcmFieldSliceIpHeaderSelect, 0, 128, 32);
   1106     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1107                                bcmFieldQualifyInnerSrcIp6,
   1108                                _bcmFieldSliceSelFpf2, 1,
   1109                                _bcmFieldSliceIpHeaderSelect, 1, 32, 128);
   1110     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
   1111                                _bcmFieldSliceSelFpf2, 1,
   1112                                _bcmFieldSliceIpHeaderSelect, 0, 32, 128);
   1113     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1114                                bcmFieldQualifyInnerDstIp6,
   1115                                _bcmFieldSliceSelFpf2, 2,
   1116                                _bcmFieldSliceIpHeaderSelect, 1, 32, 128);
   1117     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6,
   1118                                _bcmFieldSliceSelFpf2, 2,
   1119                                _bcmFieldSliceIpHeaderSelect, 0, 32, 128);
   1120     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
   1121                  _bcmFieldSliceSelFpf2, 3, 48, 16);
   1122     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   1123                  _bcmFieldSliceSelFpf2, 3, 64, 48);
   1124     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   1125                  _bcmFieldSliceSelFpf2, 3, 112, 48);
   1126     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1127                                bcmFieldQualifyInnerTos,
   1128                                _bcmFieldSliceSelFpf2, 4,
   1129                                _bcmFieldSliceIpHeaderSelect, 1, 32, 8);
   1130     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1131                                _bcmFieldSliceSelFpf2, 4,
   1132                                _bcmFieldSliceIpHeaderSelect, 0, 32, 8);
   1133     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1134                                bcmFieldQualifyInnerIpProtocol,
   1135                                _bcmFieldSliceSelFpf2, 4,
   1136                                _bcmFieldSliceIpHeaderSelect, 1, 40, 8);
   1137     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1138                                _bcmFieldSliceSelFpf2, 4,
   1139                                _bcmFieldSliceIpHeaderSelect, 0, 40, 8);
   1140     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1141                                bcmFieldQualifyInnerDstIp,
   1142                                _bcmFieldSliceSelFpf2, 4,
   1143                                _bcmFieldSliceIpHeaderSelect, 1, 48, 32);
   1144     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1145                                _bcmFieldSliceSelFpf2, 4,
   1146                                _bcmFieldSliceIpHeaderSelect, 0, 48, 32);
   1147     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1148                                bcmFieldQualifyInnerSrcIp,
   1149                                _bcmFieldSliceSelFpf2, 4,
   1150                                _bcmFieldSliceIpHeaderSelect, 1, 80, 32);
   1151     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1152                                _bcmFieldSliceSelFpf2, 4,
   1153                                _bcmFieldSliceIpHeaderSelect, 0, 80, 32);
   1154     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   1155                  _bcmFieldSliceSelFpf2, 4, 112, 48);
   1156 
   1157     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1158                                bcmFieldQualifyInnerTos,
   1159                                _bcmFieldSliceSelFpf2, 5,
   1160                                _bcmFieldSliceIpHeaderSelect, 1, 32, 8);
   1161     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1162                                _bcmFieldSliceSelFpf2, 5,
   1163                                _bcmFieldSliceIpHeaderSelect, 0, 32, 8);
   1164     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1165                                bcmFieldQualifyInnerIpProtocol,
   1166                                _bcmFieldSliceSelFpf2, 5,
   1167                                _bcmFieldSliceIpHeaderSelect, 1, 40, 8);
   1168     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1169                                _bcmFieldSliceSelFpf2, 5,
   1170                                _bcmFieldSliceIpHeaderSelect, 0, 40, 8);
   1171     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1172                                bcmFieldQualifyInnerDstIp,
   1173                                _bcmFieldSliceSelFpf2, 5,
   1174                                _bcmFieldSliceIpHeaderSelect, 1, 48, 32);
   1175     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1176                                _bcmFieldSliceSelFpf2, 5,
   1177                                _bcmFieldSliceIpHeaderSelect, 0, 48, 32);
   1178     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1179                                bcmFieldQualifyInnerSrcIp,
   1180                                _bcmFieldSliceSelFpf2, 5,
   1181                                _bcmFieldSliceIpHeaderSelect, 1, 80, 32);
   1182     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1183                                _bcmFieldSliceSelFpf2, 5,
   1184                                _bcmFieldSliceIpHeaderSelect, 0, 80, 32);
   1185     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   1186                  _bcmFieldSliceSelFpf2, 5, 112, 48);
   1187     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1188                                bcmFieldQualifyInnerSrcIp6High,
   1189                                _bcmFieldSliceSelFpf2, 6,
   1190                                _bcmFieldSliceIpHeaderSelect, 1, 32, 64);
   1191     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcIp6High,
   1192                                _bcmFieldSliceSelFpf2, 6,
   1193                                _bcmFieldSliceIpHeaderSelect, 0, 32, 64);
   1194     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1195                                bcmFieldQualifyInnerDstIp6High,
   1196                                _bcmFieldSliceSelFpf2, 6,
   1197                                _bcmFieldSliceIpHeaderSelect, 1, 96, 64);
   1198     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6High,
   1199                                _bcmFieldSliceSelFpf2, 6,
   1200                                _bcmFieldSliceIpHeaderSelect, 0, 96, 64);
   1201     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySnap,
   1202                  _bcmFieldSliceSelFpf2, 7, 96, 40);
   1203     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyLlc,
   1204                  _bcmFieldSliceSelFpf2, 7, 136, 24);
   1205 
   1206     /* FPF1 */
   1207     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1208                                bcmFieldQualifyInnerIpProtocolCommon,
   1209                                _bcmFieldSliceSelFpf1, 0,
   1210                                _bcmFieldSliceIpHeaderSelect, 1, 160, 3);
   1211     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocolCommon,
   1212                                _bcmFieldSliceSelFpf1, 0,
   1213                                _bcmFieldSliceIpHeaderSelect, 0, 160, 3);
   1214     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   1215                  _bcmFieldSliceSelFpf1, 0, 163, 1);
   1216     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerTpid,
   1217                  _bcmFieldSliceSelFpf1, 0, 165, 2);
   1218     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterTpid,
   1219                  _bcmFieldSliceSelFpf1, 0, 167, 2);
   1220     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2Format,
   1221                  _bcmFieldSliceSelFpf1, 0, 169, 2);
   1222     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGigProxy,
   1223                  _bcmFieldSliceSelFpf1, 0, 171, 1);
   1224     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   1225                  _bcmFieldSliceSelFpf1, 0, 172, 1);
   1226     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1227                  _bcmFieldSliceSelFpf1, 0, 173, 16);
   1228     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1229                  _bcmFieldSliceSelFpf1, 0, 173, 12);
   1230     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1231                  _bcmFieldSliceSelFpf1, 0, 185, 1);
   1232     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1233                  _bcmFieldSliceSelFpf1, 0, 186, 3);
   1234     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
   1235                  _bcmFieldSliceSelFpf1, 0, 189, 2);
   1236     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort, 
   1237                  _bcmFieldSliceSelFpf1, 0, 191, 6);
   1238     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassPort, 
   1239                  _bcmFieldSliceSelFpf1, 0, 197, 8);
   1240     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1241                                bcmFieldQualifyInnerIpType,
   1242                                _bcmFieldSliceSelFpf1, 0,
   1243                                _bcmFieldSliceIpHeaderSelect, 1, 205, 4);
   1244     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   1245                                _bcmFieldSliceSelFpf1, 0,
   1246                                _bcmFieldSliceIpHeaderSelect, 0, 205, 4);
   1247     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4Ports, 
   1248                  _bcmFieldSliceSelFpf1, 0, 209, 1);
   1249     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpInfo,
   1250                  _bcmFieldSliceSelFpf1, 0, 4, 1);
   1251 
   1252     /* DWF3 */
   1253     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerTos,
   1254                             _bcmFieldSliceSelFpf3, 0,
   1255                             _bcmFieldSliceIpHeaderSelect, 1, 0, 8);
   1256     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1257                             _bcmFieldSliceSelFpf3, 0,
   1258                             _bcmFieldSliceIpHeaderSelect, 0, 0, 8);
   1259     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerTtl,
   1260                             _bcmFieldSliceSelFpf3, 0,
   1261                             _bcmFieldSliceIpHeaderSelect, 1, 8, 8);
   1262     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   1263                             _bcmFieldSliceSelFpf3, 0,
   1264                             _bcmFieldSliceIpHeaderSelect, 0, 8, 8);
   1265     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   1266                             _bcmFieldSliceSelFpf3, 0,
   1267                             _bcmFieldSliceIpHeaderSelect, 0, 16, 6);
   1268     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerIpFrag,
   1269                             _bcmFieldSliceSelFpf3, 0,
   1270                             _bcmFieldSliceIpHeaderSelect, 1, 22, 2);
   1271     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1272                             _bcmFieldSliceSelFpf3, 0,
   1273                             _bcmFieldSliceIpHeaderSelect, 0, 22, 2);
   1274     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1275                             _bcmFieldSliceSelFpf3, 0,
   1276                             _bcmFieldSliceIpHeaderSelect, 0, 24, 8);
   1277     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerIpProtocol,
   1278                             _bcmFieldSliceSelFpf3, 0,
   1279                             _bcmFieldSliceIpHeaderSelect, 1, 24, 8);
   1280     /* DWF2 */
   1281     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerTtl,
   1282                             _bcmFieldSliceSelFpf2, 0,
   1283                             _bcmFieldSliceIpHeaderSelect, 1, 32, 8);
   1284     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   1285                             _bcmFieldSliceSelFpf2, 0,
   1286                             _bcmFieldSliceIpHeaderSelect, 0, 32, 8);
   1287     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   1288                             _bcmFieldSliceSelFpf2, 0,
   1289                             _bcmFieldSliceIpHeaderSelect, 0, 40, 6);
   1290     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerIpFrag,
   1291                             _bcmFieldSliceSelFpf2, 0,
   1292                             _bcmFieldSliceIpHeaderSelect, 1, 46, 2);
   1293     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1294                             _bcmFieldSliceSelFpf2, 0,
   1295                             _bcmFieldSliceIpHeaderSelect, 0, 46, 2);
   1296     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerTos,
   1297                             _bcmFieldSliceSelFpf2, 0,
   1298                             _bcmFieldSliceIpHeaderSelect, 1, 48, 8);
   1299     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1300                             _bcmFieldSliceSelFpf2, 0,
   1301                             _bcmFieldSliceIpHeaderSelect, 0, 48, 8);
   1302     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerL4DstPort,
   1303                             _bcmFieldSliceSelFpf2, 0,
   1304                             _bcmFieldSliceIpHeaderSelect, 1, 56, 16);
   1305     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   1306                             _bcmFieldSliceSelFpf2, 0,
   1307                             _bcmFieldSliceIpHeaderSelect, 0, 56, 16);
   1308     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerL4SrcPort,
   1309                             _bcmFieldSliceSelFpf2, 0,
   1310                             _bcmFieldSliceIpHeaderSelect, 1, 72, 16);
   1311     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   1312                             _bcmFieldSliceSelFpf2, 0,
   1313                             _bcmFieldSliceIpHeaderSelect, 0, 72, 16);
   1314     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerIpProtocol,
   1315                             _bcmFieldSliceSelFpf2, 0,
   1316                             _bcmFieldSliceIpHeaderSelect, 1, 88, 8);
   1317     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1318                             _bcmFieldSliceSelFpf2, 0,
   1319                             _bcmFieldSliceIpHeaderSelect, 0, 88, 8);
   1320     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerDstIp,
   1321                             _bcmFieldSliceSelFpf2, 0,
   1322                             _bcmFieldSliceIpHeaderSelect, 1, 96, 32);
   1323     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1324                             _bcmFieldSliceSelFpf2, 0,
   1325                             _bcmFieldSliceIpHeaderSelect, 0, 96, 32);
   1326     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerSrcIp,
   1327                             _bcmFieldSliceSelFpf2, 0,
   1328                             _bcmFieldSliceIpHeaderSelect, 1, 128, 32);
   1329     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1330                             _bcmFieldSliceSelFpf2, 0,
   1331                             _bcmFieldSliceIpHeaderSelect, 0, 128, 32);
   1332     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInnerSrcIp6,
   1333                             _bcmFieldSliceSelFpf2, 1,
   1334                             _bcmFieldSliceIpHeaderSelect, 1, 32, 128);
   1335     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
   1336                             _bcmFieldSliceSelFpf2, 1,
   1337                             _bcmFieldSliceIpHeaderSelect, 0, 32, 128);
   1338     /* FPF1 */
   1339     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderSubCode,
   1340                             _bcmFieldSliceSelFpf1, 0,
   1341                             _bcmFieldSliceIpHeaderSelect, 0, 160, 8);
   1342     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderType,
   1343                             _bcmFieldSliceSelFpf1, 0,
   1344                             _bcmFieldSliceIpHeaderSelect, 0, 168, 8);
   1345     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassL3,
   1346                             _bcmFieldSliceSelFpf1, 0,
   1347                             _bcmFieldSliceIpHeaderSelect, 0, 176, 8);
   1348     _FP_QUAL_INTRASLICE_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
   1349                             _bcmFieldSliceSelFpf1, 0,
   1350                             _bcmFieldSliceIpHeaderSelect, 0, 184, 16);
   1351 
   1352     return (BCM_E_NONE);
   1353 }
   1354 
   1355 /*
   1356  * Function:
   1357  *     _field_tr_external_qualifiers_init
   1358  * Purpose:
   1359  *     Initialize device stage external qaualifiers 
   1360  *     select codes & offsets
   1361  * Parameters:
   1362  *     unit       - (IN) BCM device number.
   1363  *     stage_fc   - (IN) Field Processor stage control structure. 
   1364  *
   1365  * Returns:
   1366  *     BCM_E_NONE
   1367  */
   1368 STATIC int
   1369 _field_tr_external_qualifiers_init(int unit, _field_stage_t *stage_fc)
   1370 {
   1371     uint32 rval;
   1372     uint32 keygen_type;
   1373     _FP_QUAL_DECL;
   1374 
   1375     BCM_IF_ERROR_RETURN(READ_ESM_KEYGEN_CTLr(unit, &rval));
   1376     keygen_type = soc_reg_field_get(unit, ESM_KEYGEN_CTLr, rval, TCAM_TYPEf);
   1377 
   1378     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyStage,
   1379                  _bcmFieldSliceSelDisable, 0, 0, 0);
   1380     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyStageExternal,
   1381                  _bcmFieldSliceSelDisable, 0, 0, 0);
   1382 
   1383     /* _FP_EXT_ACL_144_L2 */
   1384     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   1385                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 0, 48);
   1386     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1387                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 48, 16);
   1388     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1389                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 48, 12);
   1390     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1391                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 60, 1);
   1392     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1393                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 61, 3);
   1394     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   1395                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 64, 6);
   1396     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   1397                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 70, 1);
   1398     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   1399                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 72, 48);
   1400     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
   1401                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_L2, 120, 16);
   1402 
   1403     if (keygen_type != 3) {
   1404         /* _FP_EXT_ACL_L2 */
   1405         
   1406         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   1407                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 12, 48);
   1408         
   1409         
   1410         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   1411                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 62, 1);
   1412         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   1413                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 64, 4);
   1414         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   1415                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 68, 1);
   1416         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
   1417                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 69, 2);
   1418         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMplsTerminated,
   1419                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 71, 1);
   1420         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   1421                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 72, 48);
   1422         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
   1423                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 120, 16);
   1424         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2Format,
   1425                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 136, 2);
   1426         
   1427         /* Unused: 2 bits */
   1428         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   1429                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 143, 1);
   1430         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   1431                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 144, 6);
   1432         
   1433         /* Unused: 1 bit */
   1434         /* L2 or IPV4: 1 bit: the tcam_write will handle this */
   1435         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   1436                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 216, 1);
   1437         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   1438                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 217, 1);
   1439         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
   1440                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1441                                    _bcmFieldSliceDstClassSelect, 0, 218, 6);
   1442         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1443                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1444                                    _bcmFieldSliceDstClassSelect, 2, 218, 6);
   1445         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1446                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1447                                    _bcmFieldSliceSrcClassSelect, 2, 224, 6);
   1448         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
   1449                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1450                                    _bcmFieldSliceSrcClassSelect, 0, 224, 6);
   1451         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1452                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1453                                    _bcmFieldSliceSrcClassSelect, 3, 224, 6);
   1454         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1455                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1456                                    _bcmFieldSliceDstClassSelect, 3, 218, 6);
   1457         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
   1458                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 230, 8);
   1459         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1460                                    bcmFieldQualifyInterfaceClassPort,
   1461                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1462                                    _bcmFieldSliceIntfClassSelect, 0, 238, 8);
   1463         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1464                                    bcmFieldQualifyInterfaceClassL3,
   1465                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1466                                    _bcmFieldSliceIntfClassSelect, 1, 238, 8);
   1467         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1468                                    bcmFieldQualifyInterfaceClassL2,
   1469                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1470                                    _bcmFieldSliceIntfClassSelect, 2, 238, 8);
   1471         _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   1472                          _bcmFieldDevSelDisable, 0,
   1473                          _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 
   1474                          _bcmFieldSliceSelDisable, 0, 0,
   1475                          246, 8, 138, 3, 0, 0, 0);
   1476         /* Unused: 2 bits */
   1477         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMplsGport,
   1478                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 256, 13);
   1479         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
   1480                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 256, 16);
   1481         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
   1482                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 256, 12);
   1483         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
   1484                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 268, 1);
   1485         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
   1486                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 269, 3);
   1487         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1488                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 272, 16);
   1489         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1490                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 272, 12);
   1491         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1492                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 284, 1);
   1493         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1494                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 285, 3);
   1495     } else {
   1496         /* _FP_EXT_ACL_L2 (for 7K 350MHz) */
   1497 /* not for 7K
   1498         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1499                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 272,16);
   1500 */
   1501         /* Unused: 12 bits */
   1502         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   1503                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 12, 48);
   1504         /* Unused: 2 bits */
   1505         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   1506                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 62, 1);
   1507         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   1508                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 64, 4);
   1509         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   1510                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 68, 1);
   1511         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
   1512                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 69, 2);
   1513         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMplsTerminated,
   1514                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 71, 1);
   1515         
   1516         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
   1517                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 120, 16);
   1518         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2Format,
   1519                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 136, 2);
   1520         
   1521         /* Unused: 2 bits */
   1522         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   1523                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 143, 1);
   1524         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1525                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 144, 12);
   1526         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   1527                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 156, 48);
   1528         
   1529         
   1530         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   1531                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 206, 6);
   1532         
   1533         /* Unused: 1 bit */
   1534         /* L2 or IPV4: 1 bit: the tcam_write will handle this */
   1535         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   1536                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 216, 1);
   1537         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   1538                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 217, 1);
   1539         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
   1540                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1541                                    _bcmFieldSliceDstClassSelect, 0, 218, 6);
   1542         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1543                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1544                                    _bcmFieldSliceDstClassSelect, 2, 218, 6);
   1545         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1546                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1547                                    _bcmFieldSliceSrcClassSelect, 2, 224, 6);
   1548         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
   1549                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1550                                    _bcmFieldSliceSrcClassSelect, 0, 224, 6);
   1551         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1552                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1553                                    _bcmFieldSliceSrcClassSelect, 3, 224, 6);
   1554         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1555                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1556                                    _bcmFieldSliceDstClassSelect, 3, 218, 6);
   1557         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
   1558                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 230, 8);
   1559         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1560                                    bcmFieldQualifyInterfaceClassPort,
   1561                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1562                                    _bcmFieldSliceIntfClassSelect, 0, 238, 8);
   1563         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1564                                    bcmFieldQualifyInterfaceClassL3,
   1565                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1566                                    _bcmFieldSliceIntfClassSelect, 1, 238, 8);
   1567         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1568                                    bcmFieldQualifyInterfaceClassL2,
   1569                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2,
   1570                                    _bcmFieldSliceIntfClassSelect, 2, 238, 8);
   1571         _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   1572                          _bcmFieldDevSelDisable, 0,
   1573                          _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 
   1574                          _bcmFieldSliceSelDisable, 0, 0,
   1575                          246, 8, 138, 3, 0, 0, 0);
   1576         
   1577         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMplsGport,
   1578                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 256, 13);
   1579         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
   1580                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 256, 16);
   1581         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
   1582                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 256, 12);
   1583         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
   1584                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 268, 1);
   1585         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
   1586                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2, 269, 3);
   1587         
   1588     }
   1589 
   1590     /* _FP_EXT_ACL_144_IPV4 */
   1591     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp4,
   1592                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 0, 0);
   1593     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1594                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 0, 32);
   1595     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   1596                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 32, 16);
   1597     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1598                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 48, 16);
   1599     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1600                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 48, 12);
   1601     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1602                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 60, 1);
   1603     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1604                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 61, 3);
   1605     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   1606                      _bcmFieldDevSelDisable, 0,
   1607                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 
   1608                      _bcmFieldSliceSelDisable, 0, 0,
   1609                      64, 8, 138, 3, 0, 0, 0);
   1610     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   1611                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 72, 1);
   1612     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1613                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 73, 32);
   1614     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   1615                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 105, 16);
   1616     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1617                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 121, 8);
   1618     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1619                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 129, 8);
   1620     /* ESM_IP_PROTOCOL_OVERLAY_EN 137, 1: Useless: 
   1621                  See ESM_KEYGEN_CTLr.IP_PROT_OVERLAY_EN */
   1622     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1623                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 141, 2);
   1624     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   1625                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV4, 143, 1);
   1626 
   1627     if (keygen_type != 3) {
   1628         /* _FP_EXT_ACL_IPV4 */
   1629         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp4,
   1630                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 0, 0);
   1631         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1632                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 0, 32);
   1633         /* Unused: 18 + 3 + 8 bits */
   1634         
   1635         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   1636                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 62, 1);
   1637         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   1638                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 63, 4);
   1639         /* Unused: 1 bit */
   1640         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   1641                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 68, 1);
   1642         /* Unused: 2 bits */
   1643         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMplsTerminated,
   1644                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 71, 1);
   1645         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1646                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 72, 32);
   1647         
   1648         
   1649         /* Unused: 29 bits */
   1650         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   1651                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 143, 1);
   1652         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   1653                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 144, 6);
   1654         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   1655                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 150, 16);
   1656         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   1657                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 166, 16);
   1658         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   1659                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 182, 6);
   1660         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   1661                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 188, 8);
   1662         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1663                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 196, 8);
   1664         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1665                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 204, 8);
   1666         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1667                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 212, 2);
   1668         /* ACL_Type: 1 bit: tcam_write will handle this */
   1669         /* L2 or IPV4: 1 bit: the tcam_write will handle this */
   1670         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   1671                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 216, 1);
   1672         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   1673                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 217, 1);
   1674         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
   1675                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1676                                    _bcmFieldSliceDstClassSelect, 0, 218, 6);
   1677         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
   1678                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1679                                    _bcmFieldSliceDstClassSelect, 1, 218, 6);
   1680         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1681                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1682                                    _bcmFieldSliceDstClassSelect, 2, 218, 6);
   1683         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1684                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1685                                    _bcmFieldSliceSrcClassSelect, 2, 224, 6);
   1686         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
   1687                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1688                                    _bcmFieldSliceSrcClassSelect, 0, 224, 6);
   1689         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
   1690                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1691                                    _bcmFieldSliceSrcClassSelect, 1, 224, 6);
   1692         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1693                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1694                                    _bcmFieldSliceSrcClassSelect, 3, 224, 6);
   1695         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1696                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1697                                    _bcmFieldSliceDstClassSelect, 3, 218, 6);
   1698         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
   1699                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 230, 8);
   1700         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1701                                    bcmFieldQualifyInterfaceClassPort,
   1702                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1703                                    _bcmFieldSliceIntfClassSelect, 0, 238, 8);
   1704         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1705                                    bcmFieldQualifyInterfaceClassL3,
   1706                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1707                                    _bcmFieldSliceIntfClassSelect, 1, 238, 8);
   1708         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1709                                    bcmFieldQualifyInterfaceClassL2,
   1710                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1711                                    _bcmFieldSliceIntfClassSelect, 2, 238, 8);
   1712         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   1713                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 246, 11);
   1714         /* Unused: 15 bits */
   1715         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1716                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 272, 16);
   1717         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1718                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 272, 12);
   1719         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1720                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 284, 1);
   1721         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1722                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 285, 3);
   1723     } else {
   1724         /* _FP_EXT_ACL_IPV4 (for 7K 350 MHz) */
   1725         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1726                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 0, 32);
   1727         /* Unused: 18 + 3 + 8 bits */
   1728         
   1729         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   1730                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 62, 1);
   1731         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   1732                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 63, 4);
   1733         /* Unused: 1 bit */
   1734         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   1735                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 68, 1);
   1736         /* Unused: 2 bits */
   1737         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMplsTerminated,
   1738                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 71, 1);
   1739         /* Unused: 17 bits */
   1740         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   1741                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 89, 6);
   1742         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   1743                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 95, 6);
   1744         
   1745         
   1746         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   1747                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 111, 16);
   1748         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   1749                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 127, 16);
   1750         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   1751                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 143, 1);
   1752         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp4,
   1753                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 144, 0);
   1754         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1755                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 144, 32);
   1756         /* Unused: 12 bits */
   1757         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   1758                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 188, 8);
   1759         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1760                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 196, 8);
   1761         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1762                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 204, 8);
   1763         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1764                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 212, 2);
   1765         /* ACL_Type: 1 bit: tcam_write will handle this */
   1766         /* L2 or IPV4: 1 bit: the tcam_write will handle this */
   1767         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   1768                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 216, 1);
   1769         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   1770                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 217, 1);
   1771         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
   1772                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1773                                    _bcmFieldSliceDstClassSelect, 0, 218, 6);
   1774         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
   1775                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1776                                    _bcmFieldSliceDstClassSelect, 1, 218, 6);
   1777         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1778                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1779                                    _bcmFieldSliceDstClassSelect, 2, 218, 6);
   1780         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1781                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1782                                    _bcmFieldSliceSrcClassSelect, 2, 224, 6);
   1783         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
   1784                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1785                                    _bcmFieldSliceSrcClassSelect, 0, 224, 6);
   1786         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
   1787                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1788                                    _bcmFieldSliceSrcClassSelect, 1, 224, 6);
   1789         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1790                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1791                                    _bcmFieldSliceSrcClassSelect, 3, 224, 6);
   1792         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1793                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1794                                    _bcmFieldSliceDstClassSelect, 3, 218, 6);
   1795         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
   1796                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 230, 8);
   1797         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1798                                    bcmFieldQualifyInterfaceClassPort,
   1799                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1800                                    _bcmFieldSliceIntfClassSelect, 0, 238, 8);
   1801         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1802                                    bcmFieldQualifyInterfaceClassL3,
   1803                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1804                                    _bcmFieldSliceIntfClassSelect, 1, 238, 8);
   1805         _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1806                                    bcmFieldQualifyInterfaceClassL2,
   1807                                    _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4,
   1808                                    _bcmFieldSliceIntfClassSelect, 2, 238, 8);
   1809         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   1810                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 246, 11);
   1811         /* Unused: 15 bits */
   1812         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1813                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 272, 16);
   1814         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1815                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 272, 12);
   1816         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1817                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 284, 1);
   1818         _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1819                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV4, 285, 3);
   1820     }
   1821 
   1822     /* _FP_EXT_ACL_L2_IPV4 */
   1823     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp4,
   1824                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 0, 0);
   1825     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   1826                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 0, 32);
   1827     /* Unused: 18 + 3 + 8 bits */
   1828     
   1829     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   1830                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 62, 1);
   1831     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   1832                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 63, 4);
   1833     /* Unused: 1 bit */
   1834     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   1835                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 68, 1);
   1836     /* Unused: 2 bits */
   1837     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMplsTerminated,
   1838                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 71, 1);
   1839     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   1840                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 72, 32);
   1841     
   1842     
   1843     /* Unused: 29 bits */
   1844     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   1845                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 143, 1);
   1846     /* Unused: 12 bits */
   1847     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   1848                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 156, 48);
   1849     /* Unused: 11 + 1 bits */
   1850     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   1851                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 216, 6);
   1852     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   1853                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 222, 16);
   1854     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   1855                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 238, 16);
   1856     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   1857                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 254, 6);
   1858     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   1859                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 260, 8);
   1860     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   1861                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 268, 8);
   1862     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   1863                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 276, 8);
   1864     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1865                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 284, 2);
   1866     /* ACL_Type: 1 bit: tcam_write will handle this */
   1867     /* L2 or IPV4: 1 bit: the tcam_write will handle this */
   1868     
   1869     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   1870                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 300, 48);
   1871     
   1872     /* Unused: 11 bits */
   1873     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   1874                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 360, 1);
   1875     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   1876                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 361, 1);
   1877     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
   1878                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1879                                _bcmFieldSliceDstClassSelect, 0, 362, 6);
   1880     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
   1881                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1882                                _bcmFieldSliceDstClassSelect, 1, 362, 6);
   1883     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1884                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1885                                _bcmFieldSliceDstClassSelect, 2, 362, 6);
   1886     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   1887                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1888                                _bcmFieldSliceSrcClassSelect, 2, 368, 6);
   1889     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
   1890                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1891                                _bcmFieldSliceSrcClassSelect, 0, 368, 6);
   1892     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
   1893                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1894                                _bcmFieldSliceSrcClassSelect, 1, 368, 6);
   1895     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1896                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1897                                _bcmFieldSliceSrcClassSelect, 3, 368, 6);
   1898     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1899                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1900                                _bcmFieldSliceDstClassSelect, 3, 362, 6);
   1901     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
   1902                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1903                                _bcmFieldSliceDstClassSelect, 3, 374, 8);
   1904     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1905                                bcmFieldQualifyInterfaceClassPort,
   1906                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1907                                _bcmFieldSliceIntfClassSelect, 0, 382, 8);
   1908     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1909                                bcmFieldQualifyInterfaceClassL3,
   1910                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1911                                _bcmFieldSliceIntfClassSelect, 1, 382, 8);
   1912     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   1913                                bcmFieldQualifyInterfaceClassL2,
   1914                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4,
   1915                                _bcmFieldSliceIntfClassSelect, 2, 382, 8);
   1916     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   1917                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 390, 11);
   1918     /* Unused: 15 bits */
   1919     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1920                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 416, 16);
   1921     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1922                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 416, 12);
   1923     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1924                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 428, 1);
   1925     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1926                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV4, 429, 3);
   1927 
   1928     /* _FP_EXT_ACL_144_IPV6 */
   1929     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
   1930                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV6, 0, 0);
   1931     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6Low,
   1932                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV6, 0, 64);
   1933     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp6Low,
   1934                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV6, 72, 64);
   1935     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1936                      _bcmFieldDevSelDisable, 0,
   1937                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV6, 
   1938                      _bcmFieldSliceSelDisable, 0, 0,
   1939                      136, 8, 64, 8, 0, 0, 0);
   1940     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1941                      _bcmFieldDevSelDisable, 0,
   1942                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV6, 
   1943                      _bcmFieldSliceSelDisable, 0, 0,
   1944                      136, 8, 64, 4, 0, 0, 0);
   1945     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1946                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV6, 68, 1);
   1947     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1948                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_144_IPV6, 69, 3);
   1949 
   1950     /* _FP_EXT_ACL_IPV6_SHORT */
   1951     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
   1952                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 0, 0);
   1953     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyDstIp6,
   1954                      _bcmFieldDevSelDisable, 0,
   1955                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 
   1956                      _bcmFieldSliceSelDisable, 0, 0,
   1957                      80, 64, 0, 64, 0, 0, 0);
   1958     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   1959                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 64, 8);
   1960     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   1961                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 72, 1);
   1962     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   1963                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 73, 4);
   1964     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   1965                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 77, 1);
   1966     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   1967                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 78, 2);
   1968     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
   1969                      _bcmFieldDevSelDisable, 0,
   1970                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 
   1971                      _bcmFieldSliceSelDisable, 0, 0,
   1972                      216, 72, 144, 56, 0, 0, 0);
   1973     
   1974     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
   1975                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 200, 8);
   1976     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   1977                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 200, 16);
   1978     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   1979                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 200, 12);
   1980     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   1981                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 212, 1);
   1982     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   1983                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 213, 3);
   1984     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   1985                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 288, 1);
   1986     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   1987                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 289, 1);
   1988     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
   1989                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT,
   1990                                _bcmFieldSliceSrcClassSelect, 0, 290, 6);
   1991     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
   1992                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT,
   1993                                _bcmFieldSliceSrcClassSelect, 1, 290, 6);
   1994     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1995                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT,
   1996                                _bcmFieldSliceSrcClassSelect, 3, 290, 6);
   1997     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   1998                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT,
   1999                                _bcmFieldSliceDstClassSelect, 3, 290, 6);
   2000     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   2001                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 296, 16);
   2002     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   2003                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 312, 16);
   2004     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   2005                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 328, 6);
   2006     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6HopLimit,
   2007                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 334, 8);
   2008     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6NextHeader,
   2009                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 342, 8);
   2010     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6TrafficClass,
   2011                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_SHORT, 350, 8);
   2012 
   2013 
   2014     /* _FP_EXT_ACL_IPV6_FULL */
   2015     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
   2016                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 0, 0);
   2017     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyDstIp6,
   2018                      _bcmFieldDevSelDisable, 0,
   2019                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 
   2020                      _bcmFieldSliceSelDisable, 0, 0,
   2021                      80, 64, 0, 64, 0, 0, 0);
   2022     /* Unused: 8 bits */
   2023     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderSubCode,
   2024                      _bcmFieldDevSelDisable, 0,
   2025                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 
   2026                      _bcmFieldSliceSelDisable, 0, 0,
   2027                      213, 3, 72, 5, 0, 0, 0);
   2028     /* Unused: 3 bits */
   2029     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyIp6NextHeader,
   2030                      _bcmFieldDevSelDisable, 0,
   2031                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 
   2032                      _bcmFieldSliceSelDisable, 0, 0,
   2033                      284, 4, 144, 4, 0, 0, 0);
   2034     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6TrafficClass,
   2035                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 148, 8);
   2036     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   2037                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 156, 16);
   2038     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   2039                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 156, 12);
   2040     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   2041                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 168, 1);
   2042     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   2043                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 169, 3);
   2044     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   2045                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 182, 6);
   2046     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   2047                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 188, 2);
   2048     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   2049                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 190, 1);
   2050     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   2051                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 191, 4);
   2052     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   2053                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 195, 1);
   2054     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyRangeCheck,
   2055                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 196, 8);
   2056     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMplsTerminated,
   2057                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 204, 1);
   2058     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderType,
   2059                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 205, 8);
   2060     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   2061                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 216, 1);
   2062     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   2063                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 217, 1);
   2064     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL2,
   2065                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2066                                _bcmFieldSliceDstClassSelect, 0, 218, 6);
   2067     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassL3,
   2068                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2069                                _bcmFieldSliceDstClassSelect, 1, 218, 6);
   2070     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   2071                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2072                                _bcmFieldSliceDstClassSelect, 2, 218, 6);
   2073     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstClassField,
   2074                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2075                                _bcmFieldSliceSrcClassSelect, 2, 224, 6);
   2076     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL2,
   2077                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2078                                _bcmFieldSliceSrcClassSelect, 0, 224, 6);
   2079     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassL3,
   2080                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2081                                _bcmFieldSliceSrcClassSelect, 1, 224, 6);
   2082     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   2083                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2084                                _bcmFieldSliceSrcClassSelect, 3, 224, 6);
   2085     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcClassField,
   2086                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2087                                _bcmFieldSliceDstClassSelect, 3, 218, 6);
   2088     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   2089                                bcmFieldQualifyInterfaceClassPort,
   2090                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2091                                _bcmFieldSliceIntfClassSelect, 0, 230, 8);
   2092     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   2093                                bcmFieldQualifyInterfaceClassL3,
   2094                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2095                                _bcmFieldSliceIntfClassSelect, 1, 230, 8);
   2096     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc,
   2097                                bcmFieldQualifyInterfaceClassL2,
   2098                                _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL,
   2099                                _bcmFieldSliceIntfClassSelect, 2, 230, 8);
   2100     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   2101                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 238, 16);
   2102     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   2103                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 254, 16);
   2104     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   2105                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 270, 6);
   2106     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6HopLimit,
   2107                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 276, 8);
   2108     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6HopLimit,
   2109                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 276, 8);
   2110     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
   2111                      _bcmFieldDevSelDisable, 0,
   2112                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 
   2113                      _bcmFieldSliceSelDisable, 0, 0,
   2114                      368, 64, 288, 64, 0, 0, 0);
   2115 
   2116     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   2117                      _bcmFieldDevSelDisable, 0,
   2118                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 
   2119                      _bcmFieldSliceSelDisable, 0, 0,
   2120                      352, 8, 365, 3, 0, 0, 0);
   2121     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   2122                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_IPV6_FULL, 363, 8);
   2123 
   2124     /* _FP_EXT_ACL_L2_IPV6 */
   2125     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
   2126                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 0, 0);
   2127     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   2128                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 0, 0);
   2129 
   2130     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyDstIp6,
   2131                      _bcmFieldDevSelDisable, 0,
   2132                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 
   2133                      _bcmFieldSliceSelDisable, 0, 0,
   2134                      423, 9, 288, 72, 216, 47, 0);
   2135 
   2136     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
   2137                      _bcmFieldDevSelDisable, 0,
   2138                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 
   2139                      _bcmFieldSliceSelDisable, 0, 0,
   2140                      263, 25, 144, 72, 72, 31, 0);
   2141     _FP_QUAL_EXT_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   2142                      _bcmFieldDevSelDisable, 0,
   2143                      _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 
   2144                      _bcmFieldSliceSelDisable, 0, 0,
   2145                      115, 29, 0, 19, 0, 0, 0);
   2146 
   2147     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   2148                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 19, 48);
   2149     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   2150                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 68, 2);
   2151     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   2152                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 70, 1);
   2153     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTunnelTerminated,
   2154                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 71, 1);
   2155     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   2156                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 103, 12);
   2157     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVrf,
   2158                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 103, 11);
   2159     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   2160                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 360, 1);
   2161     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   2162                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 361, 1);
   2163     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   2164                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 372, 16);
   2165     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   2166                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 388, 16);
   2167     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6NextHeader,
   2168                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 404, 8);
   2169     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6TrafficClass,
   2170                  _bcmFieldSliceSelExternal, _FP_EXT_ACL_L2_IPV6, 415, 8);
   2171 
   2172     
   2173     /* ESM_IP_PROTOCOL_OVERLAY_EN 412, 1: Useless: 
   2174                                         See ESM_KEYGEN_CTLr.IP_PROT_OVERLAY_EN */
   2175     /* bcmFieldQualifyTcpControl 404, 8: OVERLAY: not used: 
   2176                                        see ESM_KEYGEN_CTLr.IP_PROT_OVERLAY_EN */
   2177     
   2178     
   2179     /* bcmFieldQualifyInPort 362, 6: OVERLAY: not used: see ESM_KEYGEN_CTL */
   2180     
   2181     
   2182     return (BCM_E_NONE);
   2183 }
   2184 
   2185 
   2186 /*
   2187  * Function:
   2188  *     _field_tr_egress_qualifiers_init
   2189  * Purpose:
   2190  *     Initialize device stage egress qaualifiers 
   2191  *     select codes & offsets
   2192  * Parameters:
   2193  *     unit       - (IN) BCM device number.
   2194  *     stage_fc   - (IN) Field Processor stage control structure. 
   2195  *
   2196  * Returns:
   2197  *     BCM_E_NONE
   2198  */
   2199 STATIC int
   2200 _field_tr_egress_qualifiers_init(int unit, _field_stage_t *stage_fc)
   2201 {
   2202     _FP_QUAL_DECL;
   2203     _key_fld_ = KEYf;
   2204 
   2205     /* Input parameters check. */
   2206     if (NULL == stage_fc) {
   2207         return (BCM_E_PARAM);
   2208     }
   2209 
   2210     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyStageEgress,
   2211                  _bcmFieldSliceSelDisable, 0, 0, 0);
   2212 
   2213     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4Ports,
   2214                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 0, 1);
   2215     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL2Format,
   2216                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 25, 2);
   2217     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyEtherType,
   2218                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 27, 16);
   2219     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcMac,
   2220                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 43, 48);
   2221     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstMac,
   2222                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 91, 48);
   2223     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyCpuQueue,
   2224                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 139, 6);
   2225     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanTranslationHit,
   2226                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 145, 1);
   2227     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGigProxy,
   2228                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 146, 1);
   2229     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   2230                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 147, 1);
   2231     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlan,
   2232                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 148, 16);
   2233     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanCfi,
   2234                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 148, 1);
   2235     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanPri,
   2236                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 149, 3);
   2237     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
   2238                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 152, 12);
   2239     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   2240                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 165, 6);
   2241     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   2242                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 171, 1);
   2243     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   2244                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 172, 1);
   2245     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   2246                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 173, 16);
   2247     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   2248                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 173, 12);
   2249     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   2250                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 185, 1);
   2251     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   2252                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 186, 3);
   2253     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
   2254                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 189, 2);
   2255     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstHiGig,
   2256                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 191, 1);
   2257     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassPort,
   2258                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 192, 8);
   2259     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOutPort,
   2260                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 200, 6);
   2261     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   2262                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 206, 4);
   2263     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   2264                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY4, 210, 1);
   2265 
   2266     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4Ports,
   2267                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 0, 1);
   2268     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   2269                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 14, 2);
   2270     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   2271                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 16, 6);
   2272     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   2273                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 22, 16);
   2274     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   2275                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 38, 16);
   2276     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   2277                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 54, 8);
   2278     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   2279                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 62, 8);
   2280     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp,
   2281                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 70, 32);
   2282     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifySrcIp,
   2283                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 102, 32);
   2284     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   2285                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 134, 8);
   2286     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGigProxy,
   2287                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 142, 1);
   2288     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   2289                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 143, 1);
   2290     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
   2291                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 152, 12);
   2292     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   2293                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 165, 6);
   2294     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   2295                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 171, 1);
   2296     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   2297                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 172, 1);
   2298     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   2299                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 173, 16);
   2300     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   2301                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 173, 12);
   2302     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   2303                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 185, 1);
   2304     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   2305                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 186, 3);
   2306     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
   2307                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 189, 2);
   2308     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstHiGig,
   2309                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 191, 1);
   2310     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassPort,
   2311                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 192, 8);
   2312     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOutPort,
   2313                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 200, 6);
   2314     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   2315                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 206, 4);
   2316     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   2317                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 210, 1);
   2318     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp4,
   2319                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1, 0, 0);
   2320 
   2321     /* KEY1 without v4 specific fields. */
   2322     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4Ports,
   2323                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 0, 1);
   2324     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   2325                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 16, 6);
   2326     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   2327                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 22, 16);
   2328     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   2329                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 38, 16);
   2330     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   2331                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 54, 8);
   2332     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   2333                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 62, 8);
   2334     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   2335                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 134, 8);
   2336     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGigProxy,
   2337                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 142, 1);
   2338     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   2339                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 143, 1);
   2340     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
   2341                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 152, 12);
   2342     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   2343                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 165, 6);
   2344     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   2345                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 171, 1);
   2346     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   2347                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 172, 1);
   2348     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   2349                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 173, 16);
   2350     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   2351                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 173, 12);
   2352     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   2353                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 185, 1);
   2354     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   2355                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 186, 3);
   2356     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
   2357                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 189, 2);
   2358     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstHiGig,
   2359                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 191, 1);
   2360     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassPort,
   2361                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 192, 8);
   2362     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOutPort,
   2363                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 200, 6);
   2364     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   2365                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 206, 4);
   2366     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   2367                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY1_NO_V4, 210, 1);
   2368 
   2369     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4Ports,
   2370                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 0, 1);
   2371     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpProtocol,
   2372                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 6, 8);
   2373     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcIp6,
   2374                                _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2,
   2375                                _bcmFieldSliceIp6AddrSelect, 
   2376                                _BCM_FIELD_EGRESS_SLICE_V6_KEY_MODE_SIP6, 
   2377                                14, 128);
   2378     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6,
   2379                                _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2,
   2380                                _bcmFieldSliceIp6AddrSelect, 
   2381                                _BCM_FIELD_EGRESS_SLICE_V6_KEY_MODE_DIP6,
   2382                                14, 128);
   2383 
   2384     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifySrcIp6Low,
   2385         _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2,
   2386         _bcmFieldSliceIp6AddrSelect,
   2387         _BCM_FIELD_EGRESS_SLICE_V6_KEY_MODE_SIP_DIP_64, 14, 64);
   2388 
   2389     _FP_QUAL_TWO_SLICE_SEL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6Low,
   2390         _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2,
   2391         _bcmFieldSliceIp6AddrSelect,
   2392         _BCM_FIELD_EGRESS_SLICE_V6_KEY_MODE_SIP_DIP_64, 78, 64);
   2393     
   2394     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTos,
   2395                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 142, 8);
   2396     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGigProxy,
   2397                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 150, 1);
   2398     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyHiGig,
   2399                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 151, 1);
   2400     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInnerVlanId,
   2401                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 152, 12);
   2402     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInPort,
   2403                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 165, 6);
   2404     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL3Routable,
   2405                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 171, 1);
   2406     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyMirrorCopy,
   2407                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 172, 1);
   2408     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlan,
   2409                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 173, 16);
   2410     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanId,
   2411                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 173, 12);
   2412     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanCfi,
   2413                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 185, 1);
   2414     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOuterVlanPri,
   2415                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 186, 3);
   2416     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyVlanFormat,
   2417                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 189, 2);
   2418     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstHiGig,
   2419                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 191, 1);
   2420     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyInterfaceClassPort,
   2421                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 192, 8);
   2422     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyOutPort,
   2423                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 200, 6);
   2424     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   2425                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 206, 4);
   2426     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   2427                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 210, 1);
   2428     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
   2429                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY2, 0, 0);
   2430 
   2431     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4Ports,
   2432                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 0, 1);
   2433     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpFrag,
   2434                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 14, 2);
   2435     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTcpControl,
   2436                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 16, 6);
   2437     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4DstPort,
   2438                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 22, 16);
   2439     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyL4SrcPort,
   2440                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 38, 16);
   2441     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyTtl,
   2442                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 54, 8);
   2443     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDstIp6,
   2444                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 62, 128);
   2445     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderSubCode,
   2446                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 190, 8);
   2447     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyExtensionHeaderType,
   2448                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 198, 8);
   2449     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIpType,
   2450                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 206, 4);
   2451     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyDrop,
   2452                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 210, 1);
   2453     _FP_QUAL_ADD(unit, stage_fc, bcmFieldQualifyIp6,
   2454                  _bcmFieldSliceSelFpf3, _BCM_FIELD_EFP_KEY3, 0, 0);
   2455 
   2456     return (BCM_E_NONE);
   2457 }
   2458 
   2459 /*
   2460  * Function:
   2461  *     _field_tr_qualifiers_init
   2462  * Purpose:
   2463  *     Initialize device qaualifiers select codes & offsets
   2464  * Parameters:
   2465  *     unit       - (IN) BCM device number.
   2466  *     stage_fc   - (IN) Field Processor stage control structure. 
   2467  *
   2468  * Returns:
   2469  *     BCM_E_NONE
   2470  * Notes:
   2471  */
   2472 STATIC int
   2473 _field_tr_qualifiers_init(int unit, _field_stage_t *stage_fc)
   2474 {
   2475     int rv;           /* Operation return status. */
   2476 
   2477     /* Input parameters check. */
   2478     if (NULL == stage_fc) {
   2479         return (BCM_E_PARAM);
   2480     }
   2481 
   2482     /* Allocated stage qualifiers configuration array. */
   2483     _FP_XGS3_ALLOC(stage_fc->f_qual_arr, 
   2484                    (_bcmFieldQualifyCount * sizeof(_bcm_field_qual_info_t *)), 
   2485                    "Field qualifiers");
   2486     if (NULL == stage_fc->f_qual_arr) {
   2487         return (BCM_E_MEMORY);
   2488     }
   2489     
   2490     switch (stage_fc->stage_id) {
   2491       case _BCM_FIELD_STAGE_INGRESS:
   2492           rv = _field_tr_ingress_qualifiers_init(unit, stage_fc);
   2493           break;
   2494       case _BCM_FIELD_STAGE_LOOKUP:
   2495           rv = _field_tr_lookup_qualifiers_init(unit, stage_fc);
   2496           break;
   2497       case _BCM_FIELD_STAGE_EGRESS:
   2498           rv = _field_tr_egress_qualifiers_init(unit, stage_fc);
   2499           break;
   2500       case _BCM_FIELD_STAGE_EXTERNAL:  
   2501           rv = _field_tr_external_qualifiers_init(unit, stage_fc);
   2502           break;
   2503       default: 
   2504           sal_free(stage_fc->f_qual_arr);
   2505           return (BCM_E_PARAM);
   2506     }
   2507     return (rv);
   2508 }
   2509 
   2510 
   2511 /*
   2512  * Function:
   2513  *     _bcm_field_tr_external_init
   2514  * Purpose:
   2515  *     Initialize the External TCAM
   2516  * Parameters:
   2517  *     unit       - (IN) BCM device number.
   2518  *     stage_fc   - (IN) (External) stage
   2519  * Returns:
   2520  *     BCM_E_XXX
   2521  * Notes:
   2522  *     IMPORTANT FPF_SZ_MAX should be >= stage_fc->tcam_slices
   2523  *     Note the difference between size and size_with_pad. The latter is 
   2524  *         used mainly for DMAing in counter collection
   2525  *     The fields for all keys are from the perforce database:
   2526  *         //depot/arch/include/triumph_regs/regsfile/arch/esm_formats.regs
   2527  */
   2528 int
   2529 _bcm_field_tr_external_init(int unit, _field_stage_t *stage_fc)
   2530 {
   2531     int i, size, total_size = 0;
   2532     soc_mem_t mem;
   2533     int entry_words;
   2534     _field_slice_t *fs;
   2535     int alloc_size;
   2536     int rv;
   2537 
   2538     /* Read the sizes for various external databases */
   2539     for (i = 0; i < stage_fc->tcam_slices; i++) {
   2540         /* slice i is valid for a particular pkt_type (L2, IPV4, IPV6) */
   2541         fs = stage_fc->slices[_FP_DEF_INST] + i;
   2542         switch (i) {
   2543           case _FP_EXT_ACL_144_L2:
   2544           case _FP_EXT_ACL_L2: 
   2545               fs->pkt_type[_FP_EXT_L2] = 1;
   2546               fs->pkt_type[_FP_EXT_IP4] = 0;
   2547               fs->pkt_type[_FP_EXT_IP6] = 0;
   2548               break;
   2549           case _FP_EXT_ACL_144_IPV4:
   2550           case _FP_EXT_ACL_IPV4:
   2551           case _FP_EXT_ACL_L2_IPV4:
   2552               fs->pkt_type[_FP_EXT_L2] = 0;
   2553               fs->pkt_type[_FP_EXT_IP4] = 1;
   2554               fs->pkt_type[_FP_EXT_IP6] = 0;
   2555               break;
   2556           case _FP_EXT_ACL_144_IPV6:
   2557           case _FP_EXT_ACL_IPV6_SHORT:
   2558           case _FP_EXT_ACL_IPV6_FULL:
   2559           case _FP_EXT_ACL_L2_IPV6:
   2560               fs->pkt_type[_FP_EXT_L2] = 0;
   2561               fs->pkt_type[_FP_EXT_IP4] = 0;
   2562               fs->pkt_type[_FP_EXT_IP6] = 1;
   2563               break;
   2564           default: 
   2565               continue;
   2566         }
   2567         BCM_PBMP_CLEAR(fs->ext_pbmp[_FP_EXT_L2]);
   2568         BCM_PBMP_CLEAR(fs->ext_pbmp[_FP_EXT_IP4]);
   2569         BCM_PBMP_CLEAR(fs->ext_pbmp[_FP_EXT_IP6]);
   2570 
   2571         /* We use policy_mem as it is in one array as compared to data_mems */
   2572         size = soc_mem_index_count(unit, _bcm_field_ext_policy_mems[i]);
   2573         fs->entry_count = size;
   2574         fs->free_count  = size;
   2575 
   2576 #ifdef BCM_WARM_BOOT_SUPPORT
   2577         {
   2578             int stable_size;
   2579 
   2580             SOC_IF_ERROR_RETURN(soc_stable_size_get(unit, &stable_size));
   2581             
   2582             if (stable_size > 0 && !SOC_WARM_BOOT_SCACHE_IS_LIMITED(unit)) {
   2583                 /* Level-2 warm boot supported */
   2584                 
   2585                 /* The number of entries need to be adjusted, to allow for space for
   2586                    storing scache information for FP ESM level-2 warm boot.
   2587                    We carve off some portion of each paritition for this storage
   2588                    area.
   2589                 */
   2590 
   2591                 fs->entry_count -= _bcm_esw_field_tr2_ext_scache_size(unit, i);
   2592                 fs->free_count  =  fs->entry_count;
   2593             }
   2594         }
   2595 #endif /* BCM_WARM_BOOT_SUPPORT */
   2596 
   2597         if (size) {
   2598             alloc_size = size * sizeof (_field_entry_t *); 
   2599             _FP_XGS3_ALLOC(fs->entries, alloc_size, "array of external entry pointers");
   2600             if (NULL == fs->entries) {
   2601                 _bcm_field_stage_entries_free(unit, stage_fc);
   2602                 return (BCM_E_MEMORY);
   2603             }
   2604             total_size += size;
   2605         }
   2606     }
   2607     stage_fc->tcam_sz = total_size;
   2608 
   2609     /* Initialize the profiles */
   2610     /* 
   2611      * redirect_profile will be used from IFP;
   2612      *     both IFP and External TCAM share the same profile
   2613      */
   2614     mem = EXT_IFP_ACTION_PROFILEm;
   2615     entry_words = sizeof(ext_ifp_action_profile_entry_t) / sizeof(uint32);
   2616     rv = soc_profile_mem_create(unit, &mem, &entry_words, 1,
   2617                                 &stage_fc->ext_act_profile);
   2618     if (BCM_FAILURE(rv)) {
   2619         _bcm_field_stage_entries_free(unit, stage_fc);
   2620         return (rv);
   2621     }
   2622 
   2623     /* Set the Seed-ID for range creation */
   2624     stage_fc->range_id = 1;
   2625 
   2626     /* Initialize the prio_mgmt structure */
   2627     rv = _bcm_field_prio_mgmt_init(unit, stage_fc);
   2628     if (BCM_FAILURE(rv)) {
   2629         _bcm_field_stage_entries_free(unit, stage_fc);
   2630         return (rv);
   2631     }
   2632     return (BCM_E_NONE);
   2633 }
   2634 
   2635 /*
   2636  * Function:
   2637  *     _bcm_field_tr_init
   2638  * Purpose:
   2639  *     Perform initializations that are specific to BCM56624. This
   2640  *     includes initializing the FP field select bit offset tables for FPF[1-3]
   2641  *     for every stage. 
   2642  * Parameters:
   2643  *     unit       - (IN) BCM device number.
   2644  *     fc         - (IN) Field Processor control structure. 
   2645  *
   2646  * Returns:
   2647  *     BCM_E_NONE
   2648  * Notes:
   2649  */
   2650 int
   2651 _bcm_field_tr_init(int unit, _field_control_t *fc) 
   2652 {
   2653     _field_stage_t *stage_fc; /* Stages iteration pointer */
   2654 
   2655     /* Input parameters check. */
   2656     if (NULL == fc) {
   2657         return (BCM_E_PARAM);
   2658     }
   2659 
   2660     stage_fc = fc->stages;
   2661     while (stage_fc) {
   2662         /* Clear hardware table */
   2663         BCM_IF_ERROR_RETURN(_bcm_field_tr_hw_clear(unit, stage_fc));
   2664 
   2665         /* Initialize qualifiers info. */
   2666         BCM_IF_ERROR_RETURN(_field_tr_qualifiers_init(unit, stage_fc));
   2667 
   2668         if (_BCM_FIELD_STAGE_EXTERNAL == stage_fc->stage_id) {
   2669             _bcm_field_tr_external_init(unit, stage_fc);
   2670             stage_fc = stage_fc->next;
   2671             continue;
   2672         }
   2673 
   2674         /* Goto next stage */
   2675         stage_fc = stage_fc->next;
   2676     }
   2677 
   2678 
   2679     /* Initialize the TOS_FN, TTL_FN, TCP_FN tables */
   2680     BCM_IF_ERROR_RETURN(_bcm_field_trx_tcp_ttl_tos_init(unit));
   2681     
   2682     if (0 == SOC_WARM_BOOT(unit)) {
   2683         /* Enable filter processor */
   2684         BCM_IF_ERROR_RETURN(_field_port_filter_enable_set(unit, fc, TRUE));
   2685 
   2686         /* Enable meter refresh */
   2687         BCM_IF_ERROR_RETURN(_field_meter_refresh_enable_set(unit, fc, TRUE));
   2688     }
   2689 
   2690     /* Initialize the function pointers */
   2691     _field_tr_functions_init(&fc->functions);;
   2692 
   2693     return (BCM_E_NONE);
   2694 }
   2695 
   2696 /*
   2697  * Function:
   2698  *     _bcm_field_tr_detach
   2699  *
   2700  * Purpose:
   2701  *     Deallocates BCM56624 field tables.
   2702  *
   2703  * Parameters:
   2704  *     unit - BCM device number
   2705  *
   2706  * Returns:
   2707  *     BCM_E_NONE
   2708  */
   2709 int
   2710 _bcm_field_tr_detach(int unit, _field_control_t *fc)
   2711 {
   2712     _field_stage_t   *stage_p;  /* Stage iteration pointer. */
   2713 
   2714     stage_p = fc->stages;
   2715 
   2716     while (stage_p) { 
   2717        /* Clear the hardware tables */
   2718 #ifdef BCM_TRIUMPH3_SUPPORT
   2719         if (SOC_IS_TRIUMPH3(unit)) {
   2720             BCM_IF_ERROR_RETURN(_bcm_field_tr3_hw_clear(unit, stage_p));
   2721         } else
   2722 #endif
   2723             {
   2724                 BCM_IF_ERROR_RETURN(_bcm_field_tr_hw_clear(unit, stage_p));
   2725             }
   2726       
   2727         /* Goto next stage */
   2728         stage_p = stage_p->next; 
   2729     }
   2730 
   2731     /* Clear udf match criteria registers. */
   2732     BCM_IF_ERROR_RETURN(_bcm_field_fb_udf_ipprotocol_delete_all(unit));
   2733     BCM_IF_ERROR_RETURN(_bcm_field_fb_udf_ethertype_delete_all(unit));
   2734 
   2735     /* Don't disable port controls during Warmboot or Reloading state */
   2736     if (0 == SOC_HW_ACCESS_DISABLE(unit)) {
   2737         /* Clear the Filter Enable flags in the port table */
   2738         BCM_IF_ERROR_RETURN (_field_port_filter_enable_set(unit, fc, FALSE));
   2739     }
   2740 
   2741     BCM_IF_ERROR_RETURN (_field_meter_refresh_enable_set(unit, fc, FALSE));
   2742  
   2743     return (BCM_E_NONE);
   2744 }
   2745 
   2746 /*
   2747  * Function:
   2748  *     _field_tr_write_slice_map_ingress
   2749  *
   2750  * Purpose:
   2751  *     Write the FP_SLICE_MAP (INGRESS)
   2752  *
   2753  * Parameters:
   2754  *     unit
   2755  *     stage_fc - pointer to stage control blocki
   2756  *
   2757  * Returns:
   2758  *     nothing
   2759  *     
   2760  * Notes:
   2761  */
   2762 STATIC int
   2763 _field_tr_write_slice_map_ingress(int unit, _field_stage_t *stage_fc)
   2764 {
   2765     fp_slice_map_entry_t map_entry;  /* HW entry buffer.         */
   2766     soc_field_t field;               /* HW entry fields.         */
   2767     int vmap_size;                   /* Virtual map index count. */
   2768     uint32 value;                    /* Field entry value.       */
   2769     int map_id;                      /* L2/IP4/IP6 map id.       */
   2770     int idx;                         /* Map fields iterator.     */     
   2771     int rv;                          /* Operation return status. */
   2772     uint32 virtual_to_physical_map_tr[3][17] = {
   2773         {VIRTUAL_SLICE_0_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2774             VIRTUAL_SLICE_1_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2775             VIRTUAL_SLICE_2_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2776             VIRTUAL_SLICE_3_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2777             VIRTUAL_SLICE_4_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2778             VIRTUAL_SLICE_5_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2779             VIRTUAL_SLICE_6_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2780             VIRTUAL_SLICE_7_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2781             VIRTUAL_SLICE_8_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2782             VIRTUAL_SLICE_9_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2783             VIRTUAL_SLICE_10_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2784             VIRTUAL_SLICE_11_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2785             VIRTUAL_SLICE_12_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2786             VIRTUAL_SLICE_13_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2787             VIRTUAL_SLICE_14_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2788             VIRTUAL_SLICE_15_PHYSICAL_SLICE_NUMBER_ENTRY_0f,
   2789             VIRTUAL_SLICE_16_PHYSICAL_SLICE_NUMBER_ENTRY_0f},
   2790         {VIRTUAL_SLICE_0_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2791             VIRTUAL_SLICE_1_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2792             VIRTUAL_SLICE_2_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2793             VIRTUAL_SLICE_3_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2794             VIRTUAL_SLICE_4_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2795             VIRTUAL_SLICE_5_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2796             VIRTUAL_SLICE_6_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2797             VIRTUAL_SLICE_7_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2798             VIRTUAL_SLICE_8_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2799             VIRTUAL_SLICE_9_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2800             VIRTUAL_SLICE_10_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2801             VIRTUAL_SLICE_11_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2802             VIRTUAL_SLICE_12_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2803             VIRTUAL_SLICE_13_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2804             VIRTUAL_SLICE_14_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2805             VIRTUAL_SLICE_15_PHYSICAL_SLICE_NUMBER_ENTRY_1f,
   2806             VIRTUAL_SLICE_16_PHYSICAL_SLICE_NUMBER_ENTRY_1f},
   2807         {VIRTUAL_SLICE_0_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2808             VIRTUAL_SLICE_1_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2809             VIRTUAL_SLICE_2_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2810             VIRTUAL_SLICE_3_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2811             VIRTUAL_SLICE_4_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2812             VIRTUAL_SLICE_5_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2813             VIRTUAL_SLICE_6_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2814             VIRTUAL_SLICE_7_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2815             VIRTUAL_SLICE_8_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2816             VIRTUAL_SLICE_9_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2817             VIRTUAL_SLICE_10_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2818             VIRTUAL_SLICE_11_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2819             VIRTUAL_SLICE_12_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2820             VIRTUAL_SLICE_13_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2821             VIRTUAL_SLICE_14_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2822             VIRTUAL_SLICE_15_PHYSICAL_SLICE_NUMBER_ENTRY_2f,
   2823             VIRTUAL_SLICE_16_PHYSICAL_SLICE_NUMBER_ENTRY_2f}
   2824     };
   2825     uint32 virtual_to_group_map_tr[3][17] = {
   2826         {VIRTUAL_SLICE_0_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2827             VIRTUAL_SLICE_1_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2828             VIRTUAL_SLICE_2_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2829             VIRTUAL_SLICE_3_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2830             VIRTUAL_SLICE_4_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2831             VIRTUAL_SLICE_5_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2832             VIRTUAL_SLICE_6_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2833             VIRTUAL_SLICE_7_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2834             VIRTUAL_SLICE_8_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2835             VIRTUAL_SLICE_9_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2836             VIRTUAL_SLICE_10_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2837             VIRTUAL_SLICE_11_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2838             VIRTUAL_SLICE_12_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2839             VIRTUAL_SLICE_13_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2840             VIRTUAL_SLICE_14_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2841             VIRTUAL_SLICE_15_VIRTUAL_SLICE_GROUP_ENTRY_0f,
   2842             VIRTUAL_SLICE_16_VIRTUAL_SLICE_GROUP_ENTRY_0f},
   2843         {VIRTUAL_SLICE_0_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2844             VIRTUAL_SLICE_1_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2845             VIRTUAL_SLICE_2_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2846             VIRTUAL_SLICE_3_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2847             VIRTUAL_SLICE_4_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2848             VIRTUAL_SLICE_5_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2849             VIRTUAL_SLICE_6_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2850             VIRTUAL_SLICE_7_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2851             VIRTUAL_SLICE_8_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2852             VIRTUAL_SLICE_9_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2853             VIRTUAL_SLICE_10_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2854             VIRTUAL_SLICE_11_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2855             VIRTUAL_SLICE_12_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2856             VIRTUAL_SLICE_13_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2857             VIRTUAL_SLICE_14_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2858             VIRTUAL_SLICE_15_VIRTUAL_SLICE_GROUP_ENTRY_1f,
   2859             VIRTUAL_SLICE_16_VIRTUAL_SLICE_GROUP_ENTRY_1f},
   2860         {VIRTUAL_SLICE_0_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2861             VIRTUAL_SLICE_1_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2862             VIRTUAL_SLICE_2_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2863             VIRTUAL_SLICE_3_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2864             VIRTUAL_SLICE_4_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2865             VIRTUAL_SLICE_5_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2866             VIRTUAL_SLICE_6_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2867             VIRTUAL_SLICE_7_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2868             VIRTUAL_SLICE_8_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2869             VIRTUAL_SLICE_9_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2870             VIRTUAL_SLICE_10_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2871             VIRTUAL_SLICE_11_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2872             VIRTUAL_SLICE_12_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2873             VIRTUAL_SLICE_13_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2874             VIRTUAL_SLICE_14_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2875             VIRTUAL_SLICE_15_VIRTUAL_SLICE_GROUP_ENTRY_2f,
   2876             VIRTUAL_SLICE_16_VIRTUAL_SLICE_GROUP_ENTRY_2f}
   2877     };
   2878 
   2879     /* Calculate virtual map size. */
   2880     rv = _bcm_field_virtual_map_size_get(unit, stage_fc, &vmap_size); 
   2881     BCM_IF_ERROR_RETURN(rv);
   2882 
   2883     rv = READ_FP_SLICE_MAPm(unit, MEM_BLOCK_ANY, 0, &map_entry);
   2884     BCM_IF_ERROR_RETURN(rv);
   2885 
   2886     for (idx = 0; idx < vmap_size; idx++) {
   2887         for (map_id = 0; map_id < _FP_VMAP_CNT; map_id++) {
   2888             value = stage_fc->vmap[_FP_DEF_INST][map_id][idx].vmap_key;
   2889             field = virtual_to_physical_map_tr[map_id][idx];
   2890             soc_FP_SLICE_MAPm_field32_set(unit, &map_entry, field, value);
   2891 
   2892             value = stage_fc->vmap[_FP_DEF_INST][map_id][idx].virtual_group;
   2893             field = virtual_to_group_map_tr[map_id][idx];
   2894             soc_FP_SLICE_MAPm_field32_set(unit, &map_entry, field, value);
   2895         }
   2896     }
   2897 
   2898     rv = WRITE_FP_SLICE_MAPm(unit, MEM_BLOCK_ALL, 0, &map_entry);
   2899     return (rv);
   2900 }
   2901 
   2902 /*
   2903  * Function:
   2904  *     _bcm_field_tr_write_slice_map
   2905  *
   2906  * Purpose:
   2907  *     Write the FP_SLICE_MAP
   2908  *
   2909  * Parameters:
   2910  *     unit
   2911  *     stage_fc - pointer to stage control block
   2912  *     fg - reference to field group structure.
   2913  *
   2914  * Returns:
   2915  *     nothing
   2916  *     
   2917  * Notes:
   2918  */
   2919 int
   2920 _bcm_field_tr_write_slice_map(int unit, _field_stage_t *stage_fc,
   2921                               _field_group_t *fg)
   2922 {
   2923     int rv = BCM_E_PARAM;   /* Operation return status. */
   2924 
   2925     if (stage_fc->stage_id == _BCM_FIELD_STAGE_INGRESS) {
   2926         rv = _field_tr_write_slice_map_ingress(unit, stage_fc);
   2927     } else if (stage_fc->stage_id == _BCM_FIELD_STAGE_EGRESS) {
   2928         rv = _bcm_field_trx_write_slice_map_egress(unit, stage_fc);
   2929     } else if (stage_fc->stage_id == _BCM_FIELD_STAGE_LOOKUP) {
   2930         rv = _bcm_field_trx_write_slice_map_vfp(unit, stage_fc);
   2931     }
   2932     return (rv);
   2933 }
   2934 
   2935 /*
   2936  * Function:
   2937  *     _bcm_field_tr_entry_reinstall
   2938  * Purpose:
   2939  *     Write entry into the chip's memory. 
   2940  * Parameters:
   2941  *     unit     -   BCM Unit
   2942  *     f_ent    -   Physical entry structure to be installed 
   2943  *     tcam_idx - common index of various tables
   2944  * Returns:
   2945  *     BCM_E_XXX        On TCAM read/write errors
   2946  *     BCM_E_NONE
   2947  * Note:
   2948  *     Unit lock should be held by calling function.
   2949  */
   2950 int
   2951 _bcm_field_tr_entry_reinstall(int unit, _field_entry_t *f_ent, int tcam_idx)
   2952 {
   2953     uint32  e[SOC_MAX_MEM_FIELD_WORDS]; /* Buffer to fill Policy & TCAM entry.*/
   2954     soc_mem_t        tcam_mem;          /* TCAM memory id.                    */
   2955     soc_mem_t        policy_mem;        /* Policy table memory id .           */
   2956     int              rv;                /* Operation return status.           */
   2957     _field_action_t *fa = NULL;
   2958 
   2959     /* Input parameters check. */
   2960     if (NULL == f_ent) {
   2961         return (BCM_E_PARAM);
   2962     }
   2963 
   2964     if (NULL == f_ent->fs) {
   2965         return (BCM_E_PARAM);
   2966     }
   2967 
   2968     rv = _field_fb_tcam_policy_mem_get(unit, f_ent->group->stage_id, 
   2969                                        &tcam_mem, &policy_mem);
   2970     BCM_IF_ERROR_RETURN(rv);
   2971 
   2972     if ((tcam_idx < soc_mem_index_min(unit, tcam_mem)) ||
   2973         (tcam_idx > soc_mem_index_max(unit, tcam_mem))) {
   2974         return (BCM_E_PARAM);
   2975     }
   2976 
   2977     /* Handle the actions (policy) */
   2978     /* Start with an empty POLICY entry */
   2979     sal_memset(e, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   2980 
   2981     /* Extract the policy info from the entry structure. */
   2982     for (fa = f_ent->actions; fa != NULL;fa = fa->next) {
   2983         /* Skip the invalid entries */
   2984         if (_FP_ACTION_VALID & fa->flags) {
   2985             rv = _bcm_field_trx_action_get(unit, policy_mem, f_ent, 
   2986                                            tcam_idx, fa, e);
   2987             BCM_IF_ERROR_RETURN(rv);
   2988         }
   2989     }
   2990 
   2991     /* Handle color dependence/independence */
   2992     if (soc_mem_field_valid(unit, policy_mem, GREEN_TO_PIDf)) {
   2993         soc_mem_field32_set(unit, policy_mem, e, GREEN_TO_PIDf, 
   2994                             (f_ent->flags & _FP_ENTRY_COLOR_INDEPENDENT) ? 1 : 0);
   2995     }
   2996 
   2997     /* Extract meter related policy fields */
   2998 #ifdef BCM_TRIUMPH3_SUPPORT
   2999     if (SOC_IS_TRIUMPH3(unit)) {
   3000         rv = _bcm_field_tr3_policer_action_set(unit, f_ent, policy_mem, e);
   3001     } else
   3002 #endif
   3003         {
   3004             rv = _bcm_field_trx_policer_action_set(unit, f_ent, policy_mem, e);
   3005         }
   3006     BCM_IF_ERROR_RETURN(rv);
   3007 
   3008     /* Extract counter related policy fields */
   3009 #ifdef BCM_TRIUMPH3_SUPPORT
   3010     if (SOC_IS_TRIUMPH3(unit)) {
   3011         rv = _bcm_field_tr3_stat_action_set(unit, f_ent, policy_mem,
   3012                                             tcam_idx, e);
   3013     } else
   3014 #endif
   3015     {
   3016         rv = _bcm_field_trx_stat_action_set(unit, f_ent, policy_mem,
   3017                                             tcam_idx, e);
   3018 #ifdef BCM_TRIDENT2PLUS_SUPPORT
   3019         if (SOC_IS_TD2P_TT2P(unit) || SOC_IS_APACHE(unit)) {
   3020             rv = _bcm_field_td2plus_extended_stat_action_set (unit, f_ent, policy_mem,
   3021                                                                 tcam_idx, e);
   3022         }
   3023 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
   3024     }
   3025     BCM_IF_ERROR_RETURN(rv);
   3026 
   3027 #if defined BCM_TRIDENT2PLUS_SUPPORT
   3028     if (soc_feature(unit, soc_feature_fp_based_oam)) {
   3029         rv = _bcm_field_oam_stat_action_set (unit, f_ent, policy_mem, e);
   3030         BCM_IF_ERROR_RETURN(rv);
   3031     }
   3032 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
   3033 
   3034     /* Write the POLICY Table */
   3035     rv = soc_mem_write(unit, policy_mem, MEM_BLOCK_ALL, tcam_idx, e);
   3036     BCM_IF_ERROR_RETURN(rv);
   3037    
   3038     return BCM_E_NONE;
   3039 }
   3040 
   3041 /*
   3042  * Function:
   3043  *     _bcm_field_tr_entry_install
   3044  * Purpose:
   3045  *     Write entry into the chip's memory. 
   3046  * Parameters:
   3047  *     unit     -   BCM Unit
   3048  *     f_ent    -   Physical entry structure to be installed 
   3049  *     tcam_idx - common index of various tables
   3050  * Returns:
   3051  *     BCM_E_XXX        On TCAM read/write errors
   3052  *     BCM_E_NONE
   3053  * Note:
   3054  *     Unit lock should be held by calling function.
   3055  */
   3056 int
   3057 _bcm_field_tr_entry_install(int unit, _field_entry_t *f_ent, int tcam_idx)
   3058 {
   3059     uint32  e[SOC_MAX_MEM_FIELD_WORDS]; /* Buffer to fill Policy & TCAM entry.*/
   3060     soc_mem_t        tcam_mem;          /* TCAM memory id.                    */
   3061     soc_mem_t        policy_mem;        /* Policy table memory id .           */
   3062     int              rv;                /* Operation return status.           */
   3063     _field_action_t *fa = NULL;
   3064     fp_global_mask_tcam_entry_t ipbm_entry;
   3065 #ifdef BCM_TRIDENT_SUPPORT
   3066     bcm_pbmp_t pbmp_x;
   3067     bcm_pbmp_t pbmp_y;
   3068     fp_global_mask_tcam_x_entry_t ipbm_entry_x;
   3069     fp_global_mask_tcam_y_entry_t ipbm_entry_y;
   3070 #endif
   3071 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT) || \
   3072     defined(BCM_GREYHOUND2_SUPPORT)
   3073     int offset_mode = 0;
   3074     int index = 0;
   3075 #endif /* BCM_KATANA_SUPPORT || BCM_TRIUMPH3_SUPPORT ||
   3076           BCM_GREYHOUND2_SUPPORT */
   3077 
   3078     /* Input parameters check. */
   3079     if (NULL == f_ent) {
   3080         return (BCM_E_PARAM);
   3081     }
   3082 
   3083     if (NULL == f_ent->fs) {
   3084         return (BCM_E_PARAM);
   3085     }
   3086 
   3087     sal_memset(&ipbm_entry, 0, sizeof(fp_global_mask_tcam_entry_t));
   3088 
   3089 #if defined(BCM_TOMAHAWK_SUPPORT)
   3090     if (soc_feature(unit, soc_feature_field_multi_pipe_support)) {
   3091        rv = _bcm_field_th_tcam_policy_mem_get(unit, f_ent,
   3092                                        &tcam_mem, &policy_mem);
   3093     } else
   3094 #endif /* BCM_TOMAHAWK_SUPPORT */
   3095     {
   3096        rv = _field_fb_tcam_policy_mem_get(unit, f_ent->group->stage_id, 
   3097                                        &tcam_mem, &policy_mem);
   3098     }
   3099     BCM_IF_ERROR_RETURN(rv);
   3100 
   3101     if ((tcam_idx < soc_mem_index_min(unit, tcam_mem)) ||
   3102         (tcam_idx > soc_mem_index_max(unit, tcam_mem))) {
   3103         return (BCM_E_PARAM);
   3104     }
   3105 
   3106     /* First Erase the TCAM: Valid bits = b00 */
   3107     sal_memset(e, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3108 
   3109     rv = soc_mem_write(unit, tcam_mem, MEM_BLOCK_ALL, tcam_idx, e);
   3110     BCM_IF_ERROR_RETURN(rv);
   3111 
   3112     /* Handle the actions (policy) */
   3113     /* Start with an empty POLICY entry */
   3114     sal_memset(e, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3115     /* Extract the policy info from the entry structure. */
   3116     for (fa = f_ent->actions; fa != NULL; fa = fa->next) {
   3117         /* Skip the invalid entries */
   3118         if (_FP_ACTION_VALID & fa->flags) {
   3119             rv = _bcm_field_trx_action_get(unit, policy_mem, f_ent, 
   3120                                            tcam_idx, fa, e);
   3121             BCM_IF_ERROR_RETURN(rv);
   3122         }
   3123     }
   3124 
   3125     /* Handle color dependence/independence */
   3126     if (soc_mem_field_valid(unit, policy_mem, GREEN_TO_PIDf)) {
   3127         soc_mem_field32_set(unit, policy_mem, e, GREEN_TO_PIDf, 
   3128                             (f_ent->flags & _FP_ENTRY_COLOR_INDEPENDENT) ? 1 : 0);
   3129     }
   3130 
   3131     /* Extract meter related policy fields */
   3132 #ifdef BCM_TRIUMPH3_SUPPORT
   3133     if (SOC_IS_TRIUMPH3(unit)) {
   3134         rv = _bcm_field_tr3_policer_action_set(unit, f_ent, policy_mem, e);
   3135     } else
   3136 #endif
   3137     {
   3138         rv = _bcm_field_trx_policer_action_set(unit, f_ent, policy_mem, e);
   3139     }
   3140     BCM_IF_ERROR_RETURN(rv);
   3141 
   3142 #if defined(BCM_GREYHOUND2_SUPPORT)
   3143     if (SOC_IS_GREYHOUND2(unit)) {
   3144     /* Extract global meter policer fields */
   3145         if (f_ent->global_meter_policer.pid > 0) {
   3146             BCM_IF_ERROR_RETURN(
   3147                 _bcm_esw_policer_offset_mode_get(
   3148                     unit, f_ent->global_meter_policer.pid, &offset_mode));
   3149             if (soc_mem_field_valid(unit, policy_mem, SVC_METER_OFFSET_MODEf)) {
   3150                 soc_mem_field32_set(
   3151                     unit, policy_mem, e, SVC_METER_OFFSET_MODEf, offset_mode);
   3152             }
   3153             _bcm_esw_get_policer_table_index(
   3154                 unit, f_ent->global_meter_policer.pid, &index);
   3155             if (soc_mem_field_valid(unit, policy_mem, SVC_METER_INDEXf)) {
   3156                 soc_mem_field32_set(
   3157                     unit, policy_mem, e, SVC_METER_INDEXf, index);
   3158             }
   3159         }
   3160     }
   3161 #endif /* BCM_GREYHOUND2_SUPPORT */
   3162 
   3163 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_TRIUMPH3_SUPPORT) || \
   3164     defined(BCM_KATANA2_SUPPORT) || defined(BCM_APACHE_SUPPORT)
   3165     if (SOC_IS_KATANAX(unit) || SOC_IS_TRIUMPH3(unit)
   3166             || SOC_IS_APACHE(unit)) {
   3167     /* Extract global meter policer fields */
   3168         if (f_ent->global_meter_policer.pid > 0) {
   3169             offset_mode = ((f_ent->global_meter_policer.pid & 
   3170                                   BCM_POLICER_GLOBAL_METER_MODE_MASK) >>
   3171                                   BCM_POLICER_GLOBAL_METER_MODE_SHIFT);
   3172             if (offset_mode >= 1) {
   3173                 offset_mode = offset_mode - 1;
   3174             }
   3175             if (soc_mem_field_valid(unit, policy_mem, SVC_METER_OFFSET_MODEf)) {
   3176                 soc_mem_field32_set(unit, policy_mem, e, SVC_METER_OFFSET_MODEf, 
   3177                                                                 offset_mode);
   3178             }
   3179             _bcm_esw_get_policer_table_index(unit, 
   3180                                       f_ent->global_meter_policer.pid, &index);
   3181             if (soc_mem_field_valid(unit, policy_mem, SVC_METER_INDEXf)) {
   3182                 soc_mem_field32_set(unit, policy_mem, e, SVC_METER_INDEXf, index);
   3183             }
   3184 #if defined(BCM_TRIUMPH3_SUPPORT) || defined(BCM_KATANA2_SUPPORT) || \
   3185     defined(BCM_APACHE_SUPPORT)
   3186             if (SOC_IS_TRIUMPH3(unit) || SOC_IS_KATANA2(unit)
   3187                     || SOC_IS_APACHE(unit)) {
   3188                 if (soc_mem_field32_get(unit, 
   3189                                    policy_mem, e, ACTION_PRI_MODIFIERf) == 0 ) {
   3190                     soc_mem_field32_set(unit, policy_mem, e, 
   3191                                    SVC_METER_INDEX_PRIORITYf,
   3192                                   (f_ent->global_meter_policer.flags) & 0x1);
   3193                 }
   3194             } else
   3195 #endif 
   3196             {
   3197                 soc_mem_field32_set(unit, policy_mem, e, 
   3198                                  SVC_METER_INDEX_PRIORITYf,
   3199                                    (f_ent->global_meter_policer.flags) & 0x1); 
   3200                    
   3201             }
   3202         }
   3203     }
   3204 #endif /* BCM_KATANA_SUPPORT  or BCM_TRIUMPH3_SUPPORT*/
   3205 
   3206     /* Extract counter related policy fields */
   3207 #ifdef BCM_TRIUMPH3_SUPPORT
   3208     if (SOC_IS_TRIUMPH3(unit)) {
   3209         rv = _bcm_field_tr3_stat_action_set(unit,
   3210                                             f_ent,
   3211                                             policy_mem,
   3212                                             tcam_idx,
   3213                                             e);
   3214     } else
   3215 #endif
   3216     {
   3217         rv = _bcm_field_trx_stat_action_set(unit,
   3218                                             f_ent,
   3219                                             policy_mem,
   3220                                             tcam_idx,
   3221                                             e);
   3222 #ifdef BCM_TRIDENT2PLUS_SUPPORT
   3223         if (SOC_IS_TD2P_TT2P(unit) || SOC_IS_APACHE(unit)) {
   3224             rv = _bcm_field_td2plus_extended_stat_action_set (unit, f_ent, policy_mem,
   3225                     tcam_idx, e);
   3226         }
   3227 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
   3228     }
   3229     BCM_IF_ERROR_RETURN(rv);
   3230 
   3231 #if defined BCM_TRIDENT2PLUS_SUPPORT
   3232     if (soc_feature(unit, soc_feature_fp_based_oam)) {
   3233         rv = _bcm_field_oam_stat_action_set (unit, f_ent, policy_mem, e);
   3234         BCM_IF_ERROR_RETURN(rv);
   3235     }
   3236 #endif /* BCM_TRIDENT2PLUS_SUPPORT */
   3237 
   3238     /* Write the POLICY Table */
   3239     rv = soc_mem_write(unit, policy_mem, MEM_BLOCK_ALL, tcam_idx, e);
   3240     BCM_IF_ERROR_RETURN(rv);
   3241 
   3242 #ifdef BCM_TRIDENT2_SUPPORT
   3243     if (SOC_IS_TD2_TT2(unit)) {
   3244         /* Write qualifiers to TCAM */
   3245 
   3246         return (_bcm_field_td2_qual_tcam_key_mask_set(unit, f_ent, TRUE));
   3247     } else
   3248 #endif
   3249 
   3250 #ifdef BCM_TRIUMPH3_SUPPORT
   3251     if (SOC_IS_TRIUMPH3(unit)) {
   3252         /* Write qualifiers to TCAM */
   3253 
   3254         return (_bcm_field_tr3_qual_tcam_key_mask_set(unit, f_ent, TRUE));
   3255     }
   3256 #endif
   3257 
   3258 #ifdef BCM_KATANA2_SUPPORT
   3259         if (SOC_IS_KATANA2(unit)) {
   3260             /* Write qualifiers to TCAM */
   3261             return (_bcm_field_kt2_qual_tcam_key_mask_set(unit, f_ent, TRUE));
   3262         }
   3263 #endif
   3264 
   3265 
   3266     /* 
   3267      * Write the FP_GLOBAL_MASK_TCAM table if necessary 
   3268      *     For wide/paired mode entries, f_ent->pbmp will be valid ONLY
   3269      * for one of the entries. For others it will be zero. f_ent->pbmp.mask
   3270      * will take care of this.
   3271      * (But for Trident, this may contain qualifiers in the secondary entry)
   3272      */
   3273     if (f_ent->fs->stage_id == _BCM_FIELD_STAGE_INGRESS) {
   3274         if (BCM_FIELD_QSET_TEST(f_ent->group->qset, bcmFieldQualifyInPort) ||
   3275             BCM_FIELD_QSET_TEST(f_ent->group->qset, bcmFieldQualifyInPorts)) {
   3276             soc_mem_field_set(unit, FP_GLOBAL_MASK_TCAMm, (uint32 *)&ipbm_entry,
   3277                           IPBMf, (uint32 *)&(f_ent->pbmp.data));
   3278             soc_mem_field_width_fit_set(unit, FP_GLOBAL_MASK_TCAMm, 
   3279                                     (uint32 *)&ipbm_entry, IPBM_MASKf, 
   3280                                     (uint32 *)&(f_ent->pbmp.mask));
   3281             rv = WRITE_FP_GLOBAL_MASK_TCAMm(unit,
   3282                     MEM_BLOCK_ALL, tcam_idx, &ipbm_entry);
   3283             BCM_IF_ERROR_RETURN(rv);
   3284         }
   3285 #if defined(BCM_KATANA_SUPPORT) || defined(BCM_HURRICANE2_SUPPORT)
   3286         /* For Katana, the VALID field of FP_GLOBAL_MASK_TCAM must be set,
   3287          * even if IPBM and IPBM_MASK are all zeroes.
   3288          */
   3289         if (SOC_IS_KATANAX(unit) || SOC_IS_HURRICANE2(unit) ||
   3290             SOC_IS_GREYHOUND(unit) || SOC_IS_HURRICANE3(unit) ||
   3291             SOC_IS_GREYHOUND2(unit)) {
   3292             if (soc_mem_field_valid(unit, FP_GLOBAL_MASK_TCAMm, VALIDf)) {
   3293                 soc_mem_field32_set(unit, FP_GLOBAL_MASK_TCAMm,
   3294                     (uint32 *)&ipbm_entry, VALIDf, SOC_IS_KATANA2(unit) ? 3: 1);
   3295                 rv = WRITE_FP_GLOBAL_MASK_TCAMm(unit,
   3296                         MEM_BLOCK_ALL, tcam_idx, &ipbm_entry);
   3297                 BCM_IF_ERROR_RETURN(rv);
   3298             }
   3299         }
   3300 #endif
   3301     } 
   3302 
   3303     /* For Trident, the VALID field of FP_GLOBAL_MASK_TCAM must be set,
   3304      * even if IPBM and IPBM_MASK are all zeroes.
   3305      */
   3306 #if defined( BCM_TRIDENT_SUPPORT)
   3307     if (SOC_IS_TD_TT (unit)) {
   3308         if (soc_mem_field_valid(unit, FP_GLOBAL_MASK_TCAMm, VALIDf)
   3309             && (f_ent->fs->stage_id == _BCM_FIELD_STAGE_INGRESS)) {
   3310 
   3311             BCM_PBMP_CLEAR(pbmp_x);
   3312             BCM_PBMP_CLEAR(pbmp_y);
   3313             sal_memset(&ipbm_entry_x, 0, sizeof(fp_global_mask_tcam_x_entry_t));
   3314             sal_memset(&ipbm_entry_y, 0, sizeof(fp_global_mask_tcam_y_entry_t));
   3315 
   3316             rv = READ_FP_GLOBAL_MASK_TCAM_Xm(unit, MEM_BLOCK_ANY, tcam_idx,
   3317                     &ipbm_entry_x);
   3318             BCM_IF_ERROR_RETURN(rv);
   3319             rv = READ_FP_GLOBAL_MASK_TCAM_Ym(unit, MEM_BLOCK_ANY, tcam_idx,
   3320                     &ipbm_entry_y);
   3321             BCM_IF_ERROR_RETURN(rv);
   3322 
   3323         soc_mem_pbmp_field_get(unit, FP_GLOBAL_MASK_TCAM_Xm, &ipbm_entry_x, IPBMf,
   3324             &pbmp_x);
   3325         soc_mem_pbmp_field_get(unit, FP_GLOBAL_MASK_TCAM_Ym, &ipbm_entry_y, IPBMf,
   3326             &pbmp_y);
   3327 
   3328         BCM_PBMP_OR(pbmp_x, pbmp_y);
   3329         soc_mem_pbmp_field_set(unit, FP_GLOBAL_MASK_TCAMm, &ipbm_entry, IPBMf,
   3330             &pbmp_x);
   3331 
   3332         BCM_PBMP_CLEAR(pbmp_x);
   3333         BCM_PBMP_CLEAR(pbmp_y);
   3334 
   3335         soc_mem_pbmp_field_get(unit, FP_GLOBAL_MASK_TCAM_Xm, &ipbm_entry_x, IPBM_MASKf,
   3336             &pbmp_x);
   3337         soc_mem_pbmp_field_get(unit, FP_GLOBAL_MASK_TCAM_Ym, &ipbm_entry_y, IPBM_MASKf,
   3338             &pbmp_y);
   3339 
   3340         BCM_PBMP_OR(pbmp_x, pbmp_y);
   3341         soc_mem_pbmp_field_set(unit, FP_GLOBAL_MASK_TCAMm, &ipbm_entry, 
   3342             IPBM_MASKf, &pbmp_x); 
   3343         soc_mem_field32_set(unit, FP_GLOBAL_MASK_TCAMm,
   3344                             (uint32 *)&ipbm_entry, VALIDf, 1);
   3345 
   3346             rv = WRITE_FP_GLOBAL_MASK_TCAMm(unit, MEM_BLOCK_ALL, 
   3347                     tcam_idx, &ipbm_entry);
   3348             BCM_IF_ERROR_RETURN(rv);
   3349         }
   3350     }
   3351 #endif
   3352 
   3353     /* Handle the rules (TCAM) */
   3354     /* Start with an empty TCAM entry */
   3355     sal_memset(e, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3356     /* Extract the qualifier info from the entry structure. */
   3357     rv = _bcm_field_trx_tcam_get(unit, tcam_mem, f_ent, e);
   3358     BCM_IF_ERROR_RETURN(rv);
   3359     /* Write the TCAM Table */
   3360     rv = soc_mem_write(unit, tcam_mem, MEM_BLOCK_ALL, tcam_idx, e);
   3361     BCM_IF_ERROR_RETURN(rv);
   3362 
   3363 #ifdef BCM_TRIDENT_SUPPORT
   3364     LOG_DEBUG(BSL_LS_BCM_FP,
   3365               (BSL_META_U(unit,
   3366                           "Checking for IPBM overlay\n")));
   3367 
   3368     if ((SOC_IS_TD_TT(unit)) && (f_ent->flags & _FP_ENTRY_USES_IPBM_OVERLAY))
   3369     {
   3370         LOG_DEBUG(BSL_LS_BCM_FP,
   3371                   (BSL_META_U(unit,
   3372                               "Overlay in use\n")));
   3373 
   3374         sal_memset(e, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3375 
   3376         BCM_IF_ERROR_RETURN(_bcm_field_trx_tcam_get(unit, FP_GM_FIELDSm,
   3377             f_ent, e));
   3378 
   3379         BCM_IF_ERROR_RETURN(WRITE_FP_GM_FIELDSm(unit, MEM_BLOCK_ALL, tcam_idx,
   3380             e));
   3381     } else
   3382 #endif
   3383     if ((SOC_IS_TRIUMPH2(unit) || SOC_IS_APOLLO(unit) || SOC_IS_KATANAX(unit))
   3384         && (f_ent->flags & _FP_ENTRY_USES_IPBM_OVERLAY)) {
   3385 
   3386         LOG_DEBUG(BSL_LS_BCM_FP,
   3387                   (BSL_META_U(unit,
   3388                               "Overlay in use\n")));
   3389 
   3390         sal_memset(e, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3391 
   3392         BCM_IF_ERROR_RETURN(_bcm_field_trx_tcam_get(unit, FP_GLOBAL_MASK_TCAMm,
   3393             f_ent, e));
   3394 
   3395         BCM_IF_ERROR_RETURN(WRITE_FP_GLOBAL_MASK_TCAMm(unit, MEM_BLOCK_ALL, tcam_idx,
   3396             e));
   3397     }
   3398     return BCM_E_NONE;
   3399 }
   3400 
   3401 /*
   3402  * Function:
   3403  *     _field_tr_external_counter_idx_get
   3404  * Purpose:
   3405  *     Calculate external tcam counter index.
   3406  * Parameters:
   3407  *     unit     - (IN) unit
   3408  *     stage_fc - (IN) Field stage structure
   3409  *     fg       - (IN) Field group structure
   3410  * Returns: 
   3411  *     BCM_E_RESOURCE - No select code will satisfy qualifier set
   3412  *     BCM_E_NONE     - Success
   3413  */
   3414 int
   3415 _bcm_field_tr_external_counter_idx_get(int unit, uint8  slice_number, 
   3416                                         bcm_field_entry_t entry_index, 
   3417                                         int  *idx)
   3418 {
   3419     if (NULL == idx) {
   3420         return (BCM_E_PARAM);
   3421     }
   3422 
   3423     return soc_tcam_part_index_to_mem_index(unit,
   3424                                             _bcm_field_fp_tcam_partitions[slice_number],
   3425                                             entry_index, EXT_FP_CNTRm, idx);
   3426 
   3427 }
   3428 
   3429 /*
   3430  * Function:
   3431  *     _bcm_field_tr_external_slice_clear
   3432  * Purpose:
   3433  *     Remove an external ACL group
   3434  * Parameters:
   3435  *     unit     - (IN) unit
   3436  *     fg       - (IN) Field group structure
   3437  *     fs       - (IN) Field slice structure
   3438  * Returns: 
   3439  *     BCM_E_XXX
   3440  */
   3441 int
   3442 _bcm_field_tr_external_slice_clear(int unit, _field_group_t *fg)
   3443 {
   3444     bcm_port_t port;
   3445     int        rv;
   3446 
   3447     if (BCM_FIELD_QSET_TEST(fg->qset, bcmFieldQualifyIp6)) {
   3448         /* V6 group */
   3449         BCM_PBMP_ITER(fg->pbmp, port) {
   3450             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   3451                                         IPV6_ACL_MODEf, 0);
   3452             BCM_IF_ERROR_RETURN(rv);
   3453             
   3454             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   3455                                         IPV6_ACL_144_ENf, 0);
   3456             BCM_IF_ERROR_RETURN(rv);
   3457 
   3458             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   3459                                         IPV6_FULL_ACLf, 0);
   3460             BCM_IF_ERROR_RETURN(rv);
   3461 
   3462         }
   3463     } else if (BCM_FIELD_QSET_TEST(fg->qset, bcmFieldQualifyIp4)) {
   3464         /* V4 group */
   3465         BCM_PBMP_ITER(fg->pbmp, port) {
   3466             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   3467                                         IPV4_ACL_MODEf, 0);
   3468             BCM_IF_ERROR_RETURN(rv);
   3469             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   3470                                         IPV4_ACL_144_ENf, 0);
   3471             BCM_IF_ERROR_RETURN(rv);
   3472 
   3473             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   3474                                         IPV4_ACL_TYPEf, 0);
   3475             BCM_IF_ERROR_RETURN(rv);
   3476         }
   3477     } else {
   3478         /* L2 group */
   3479         BCM_PBMP_ITER(fg->pbmp, port) {
   3480             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   3481                                         L2_ACL_ENf, 0);
   3482             BCM_IF_ERROR_RETURN(rv);
   3483             rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   3484                                         L2_ACL_144_ENf, 0);
   3485             BCM_IF_ERROR_RETURN(rv);
   3486         }
   3487     }
   3488 
   3489     return BCM_E_NONE;
   3490 }
   3491 
   3492 /*
   3493  * Function:
   3494  *     _field_tr_external_tcam_write
   3495  * Purpose:
   3496  *     Writes an ACL h/w entry
   3497  * Parameters:
   3498  *     unit     - (IN) unit
   3499  *     f_ent    - (IN) entry to be writted
   3500  *     index    - (IN) index at which to be written
   3501  * Returns: 
   3502  *     BCM_E_NONE     - Success
   3503  *     BCM_E_XXX
   3504  * Notes:
   3505  *     It is not necessary that f_ent->slice_idx == index
   3506  *         e.g. if called from _bcm_field_tr_external_entry_move.
   3507  *     The 1 bit field mentioned in various (9) ACL inits are not set
   3508  *         (i.e. left as Don't Care),
   3509  *         as we DONOT allow sharing of key types in same block.
   3510  *     Also we have ESM_MODE_PER_PORTr.IPV4_ACL_TYPE and
   3511  *                  ESM_MODE_PER_PORTr.IPV6_ACL_TYPE as 0 (port based ACL)
   3512  */
   3513 int
   3514 _field_tr_external_tcam_write(int unit, _field_entry_t *f_ent, int index)
   3515 {
   3516     uint32 buf[SOC_MAX_MEM_FIELD_WORDS];
   3517     int slice;
   3518     _field_tcam_t *tcam;
   3519     int rv;
   3520 
   3521     tcam = &f_ent->tcam;
   3522 
   3523     slice = f_ent->fs->slice_number;
   3524     switch (slice) {
   3525       case _FP_EXT_ACL_144_L2:
   3526       case _FP_EXT_ACL_L2:
   3527       case _FP_EXT_ACL_144_IPV4:
   3528       case _FP_EXT_ACL_IPV4:
   3529       case _FP_EXT_ACL_144_IPV6:
   3530           sal_memset(buf, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3531           soc_mem_field_set(unit, _bcm_field_ext_data_mask_mems[slice], 
   3532                             buf, DATAf, tcam->key_hw);
   3533           /* 
   3534            * External TCAM: mask polarity is reversed.
   3535            *     Use this instead of soc_mem_field_set
   3536            */
   3537           soc_mem_mask_field_set(unit, _bcm_field_ext_data_mask_mems[slice], 
   3538                                  buf, MASKf, tcam->mask_hw);
   3539 
   3540           rv = soc_mem_write(unit, _bcm_field_ext_data_mask_mems[slice], 
   3541                              MEM_BLOCK_ALL, index, buf);
   3542           BCM_IF_ERROR_RETURN(rv);
   3543           break;
   3544       case _FP_EXT_ACL_L2_IPV4:
   3545       case _FP_EXT_ACL_IPV6_SHORT:
   3546       case _FP_EXT_ACL_IPV6_FULL:
   3547       case _FP_EXT_ACL_L2_IPV6:
   3548           /* Write the mask */
   3549           sal_memset(buf, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3550           /* 
   3551            * External TCAM: mask polarity is reversed.
   3552            *     Use this instead of soc_mem_field_set
   3553            */
   3554           soc_mem_mask_field_set(unit, _bcm_field_ext_mask_mems[slice], 
   3555                                  buf, MASKf, tcam->mask_hw);
   3556           rv = soc_mem_write(unit, _bcm_field_ext_mask_mems[slice], 
   3557                              MEM_BLOCK_ALL, 0, buf);
   3558           BCM_IF_ERROR_RETURN(rv);
   3559 
   3560           /* Write the data */
   3561           sal_memset(buf, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3562           soc_mem_field_set(unit, _bcm_field_ext_data_mems[slice], 
   3563                             buf, DATAf, tcam->key_hw);
   3564 
   3565           rv =  soc_mem_write(unit, _bcm_field_ext_data_mems[slice], 
   3566                               MEM_BLOCK_ALL, index, buf);
   3567           BCM_IF_ERROR_RETURN(rv);
   3568           break;
   3569       default:
   3570           /* should not come here */
   3571           return (BCM_E_INTERNAL);
   3572     }
   3573     return (BCM_E_NONE);
   3574 }
   3575 
   3576 /*
   3577  * Function:
   3578  *     _bcm_field_tr_external_policy_mem_get
   3579  * Purpose:
   3580  *     Get external policy table name.
   3581  * Parameters:
   3582  *     unit     - (IN) unit
   3583  *     stage_fc - (IN) stage (External)
   3584  *     f_ent    - (IN) Field entry to be installed
   3585  * Returns: 
   3586  *     BCM_E_XXX
   3587  */
   3588 int
   3589 _bcm_field_tr_external_policy_mem_get(int unit, _field_action_t *fa, soc_mem_t *mem)
   3590 {
   3591     /* Input parameters check. */
   3592     if ((NULL == mem) || (NULL == fa)) {
   3593         return (BCM_E_PARAM); 
   3594     }
   3595 
   3596     switch (fa->action) {
   3597         /* These actions are in a separate table */
   3598         case bcmFieldActionPrioPktCopy:
   3599         case bcmFieldActionRpPrioPktCopy:
   3600         case bcmFieldActionYpPrioPktCopy:
   3601         case bcmFieldActionGpPrioPktCopy:
   3602         case bcmFieldActionPrioPktNew:
   3603         case bcmFieldActionRpPrioPktNew:
   3604         case bcmFieldActionYpPrioPktNew:
   3605         case bcmFieldActionGpPrioPktNew:
   3606         case bcmFieldActionPrioPktTos:
   3607         case bcmFieldActionRpPrioPktTos:
   3608         case bcmFieldActionYpPrioPktTos:
   3609         case bcmFieldActionGpPrioPktTos:
   3610         case bcmFieldActionPrioPktCancel:
   3611         case bcmFieldActionRpPrioPktCancel:
   3612         case bcmFieldActionYpPrioPktCancel:
   3613         case bcmFieldActionGpPrioPktCancel:
   3614         case bcmFieldActionPrioIntCopy:
   3615         case bcmFieldActionRpPrioIntCopy:
   3616         case bcmFieldActionYpPrioIntCopy:
   3617         case bcmFieldActionGpPrioIntCopy:
   3618         case bcmFieldActionPrioIntNew:
   3619         case bcmFieldActionRpPrioIntNew:
   3620         case bcmFieldActionYpPrioIntNew:
   3621         case bcmFieldActionGpPrioIntNew:
   3622         case bcmFieldActionPrioIntTos:
   3623         case bcmFieldActionRpPrioIntTos:
   3624         case bcmFieldActionYpPrioIntTos:
   3625         case bcmFieldActionGpPrioIntTos:
   3626         case bcmFieldActionPrioIntCancel:
   3627         case bcmFieldActionRpPrioIntCancel:
   3628         case bcmFieldActionYpPrioIntCancel:
   3629         case bcmFieldActionGpPrioIntCancel:
   3630         case bcmFieldActionPrioPktAndIntNew:
   3631         case bcmFieldActionRpPrioPktAndIntNew:
   3632         case bcmFieldActionYpPrioPktAndIntNew:
   3633         case bcmFieldActionGpPrioPktAndIntNew:
   3634         case bcmFieldActionPrioPktAndIntCopy:
   3635         case bcmFieldActionRpPrioPktAndIntCopy:
   3636         case bcmFieldActionYpPrioPktAndIntCopy:
   3637         case bcmFieldActionGpPrioPktAndIntCopy:
   3638         case bcmFieldActionPrioPktAndIntTos:
   3639         case bcmFieldActionRpPrioPktAndIntTos:
   3640         case bcmFieldActionYpPrioPktAndIntTos:
   3641         case bcmFieldActionGpPrioPktAndIntTos:
   3642         case bcmFieldActionPrioPktAndIntCancel:
   3643         case bcmFieldActionRpPrioPktAndIntCancel:
   3644         case bcmFieldActionYpPrioPktAndIntCancel:
   3645         case bcmFieldActionGpPrioPktAndIntCancel:
   3646         case bcmFieldActionDscpNew:
   3647         case bcmFieldActionRpDscpNew:
   3648         case bcmFieldActionYpDscpNew:
   3649         case bcmFieldActionGpDscpNew:
   3650         case bcmFieldActionDscpCancel:
   3651         case bcmFieldActionRpDscpCancel:
   3652         case bcmFieldActionYpDscpCancel:
   3653         case bcmFieldActionGpDscpCancel:
   3654         case bcmFieldActionCosQNew:
   3655         case bcmFieldActionRpCosQNew:
   3656         case bcmFieldActionYpCosQNew:
   3657         case bcmFieldActionGpCosQNew:
   3658         case bcmFieldActionVlanCosQNew:
   3659         case bcmFieldActionRpVlanCosQNew:
   3660         case bcmFieldActionYpVlanCosQNew:
   3661         case bcmFieldActionGpVlanCosQNew:
   3662         case bcmFieldActionGpTosPrecedenceCopy:
   3663         case bcmFieldActionGpTosPrecedenceNew:
   3664             *mem = EXT_IFP_ACTION_PROFILEm;
   3665             break;
   3666         default:
   3667             *mem = EXT_FP_POLICYm;
   3668     }
   3669     return (BCM_E_NONE);
   3670 }
   3671  
   3672 /*
   3673  * Function:
   3674  *     _field_tr_external_policy_install
   3675  * Purpose:
   3676  *     Installs an (external) policy entry into hardware.
   3677  * Parameters:
   3678  *     unit     - (IN) unit
   3679  *     stage_fc - (IN) stage (External)
   3680  *     f_ent    - (IN) Field entry to be installed
   3681  * Returns: 
   3682  *     BCM_E_NONE     - Success
   3683  *     BCM_E_XXX
   3684  */
   3685 
   3686 int
   3687 _field_tr_external_policy_install(int unit, _field_stage_t *stage_fc, 
   3688                                        _field_entry_t *f_ent)
   3689 {
   3690     soc_mem_t policy_mem;
   3691     uint32 policy[SOC_MAX_MEM_FIELD_WORDS];
   3692     uint32 ext_act_profile_index;
   3693     uint32 ext_act_profile[SOC_MAX_MEM_FIELD_WORDS];
   3694     _field_action_t *fa;
   3695     void *entries[1];
   3696     int rv;
   3697 
   3698 
   3699     /* Start with an empty POLICY entry */
   3700     sal_memset(policy, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3701     sal_memset(ext_act_profile, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3702 
   3703     /* Extract the policy info from the entry structure. */
   3704     for (fa = f_ent->actions; fa != NULL; fa = fa->next) {
   3705 
   3706        /* skip invalid actions. */
   3707        if (!(_FP_ACTION_VALID & fa->flags)) {
   3708            continue;
   3709         }
   3710 
   3711         rv = _bcm_field_tr_external_policy_mem_get(unit, fa, &policy_mem);
   3712         BCM_IF_ERROR_RETURN(rv);
   3713         if (EXT_IFP_ACTION_PROFILEm == policy_mem) {
   3714             rv = _bcm_field_trx_action_get(unit, policy_mem, f_ent, 
   3715                                            f_ent->slice_idx, fa, 
   3716                                            ext_act_profile);
   3717             BCM_IF_ERROR_RETURN(rv);
   3718         } else {
   3719             rv = _bcm_field_trx_action_get(unit, policy_mem, f_ent, 
   3720                                            f_ent->slice_idx, fa, policy);
   3721             BCM_IF_ERROR_RETURN(rv);
   3722         }
   3723     }
   3724 
   3725     /* Setup the PROFILE_PTR for EXT_IFP_ACTION_PROFILEm */
   3726     entries[0] = ext_act_profile;
   3727     rv = soc_profile_mem_add(unit, &stage_fc->ext_act_profile, 
   3728                              entries, 1, &ext_act_profile_index);
   3729     BCM_IF_ERROR_RETURN(rv);
   3730 
   3731     f_ent->ext_act_profile_idx = ext_act_profile_index;
   3732 
   3733     /* Set slice dependent policy memory name. */
   3734     policy_mem = _bcm_field_ext_policy_mems[f_ent->fs->slice_number];
   3735 
   3736     soc_mem_field32_set(unit, policy_mem, policy, PROFILE_PTRf, 
   3737                         ext_act_profile_index);
   3738 
   3739     /* Handle color dependence/independence */
   3740     soc_mem_field32_set(unit, policy_mem, policy, GREEN_TO_PIDf, 
   3741                    (f_ent->flags & _FP_ENTRY_COLOR_INDEPENDENT) ? 1 : 0);
   3742 
   3743     /* Extract meter related policy fields */
   3744     rv = _bcm_field_trx_policer_action_set(unit, f_ent, policy_mem, policy);
   3745     BCM_IF_ERROR_RETURN(rv);
   3746 
   3747     /* Extract counter related policy fields */
   3748     rv = _bcm_field_trx_stat_action_set(unit, f_ent, policy_mem,
   3749                                         f_ent->slice_idx, policy);
   3750     BCM_IF_ERROR_RETURN(rv);
   3751 
   3752     /* Set policy entry valid bit. */
   3753     soc_mem_field32_set(unit, policy_mem, policy, VALIDf, 1 );
   3754 
   3755     /* Write into the Table */
   3756     rv = soc_mem_write(unit, policy_mem, MEM_BLOCK_ALL, 
   3757                        f_ent->slice_idx, policy);
   3758     BCM_IF_ERROR_RETURN(rv);
   3759 
   3760     return (BCM_E_NONE);
   3761 }
   3762 
   3763 /*
   3764  * Function:
   3765  *     _field_tr_external_counter_reset
   3766  * Purpose:
   3767  *     Initializes the external-FP counter to 0
   3768  * Parameters:
   3769  *     unit     - (IN) unit
   3770  *     stage_fc - (IN) Stage structure
   3771  *     f_ent    - (IN) Field entry to be installed
   3772  * Returns: 
   3773  *     BCM_E_NONE     - Success
   3774  *     BCM_E_XXX
   3775  */
   3776 int
   3777 _field_tr_external_counter_reset(int unit, _field_stage_t *stage_fc, 
   3778                                       _field_entry_t *f_ent)
   3779 {
   3780     int index;
   3781     ext_fp_cntr_entry_t ext_fp_cntr;
   3782     _field_stat_t  *f_st; 
   3783     int rv; 
   3784 
   3785     if (f_ent->statistic.flags & _FP_ENTRY_STAT_INSTALLED) {
   3786         rv = _bcm_field_stat_get(unit, f_ent->statistic.sid, &f_st); 
   3787         BCM_IF_ERROR_RETURN(rv);
   3788         f_st->hw_index = f_ent->slice_idx;
   3789     }
   3790 
   3791     /* Get absolute index */
   3792     BCM_IF_ERROR_RETURN(soc_tcam_part_index_to_mem_index(unit, 
   3793                             _bcm_field_fp_tcam_partitions[f_ent->fs->slice_number], 
   3794                             f_ent->slice_idx, EXT_FP_CNTRm, &index));
   3795 
   3796     sal_memcpy(&ext_fp_cntr, soc_mem_entry_null(unit, EXT_FP_CNTRm), 
   3797                soc_mem_entry_words(unit, EXT_FP_CNTRm) * sizeof(uint32)); 
   3798     SOC_IF_ERROR_RETURN(
   3799         soc_mem_write(unit, EXT_FP_CNTRm, MEM_BLOCK_ALL, index, &ext_fp_cntr));
   3800 
   3801     /* Clear the counter collection S/W */
   3802     sal_memset(&stage_fc->_field_x32_counters[f_ent->slice_idx], 0, 
   3803                    sizeof(_field_counter32_collect_t));
   3804     sal_memset(&stage_fc->_field_x64_counters[f_ent->slice_idx], 0, 
   3805                    sizeof(_field_counter64_collect_t));
   3806     
   3807     return (BCM_E_NONE);
   3808 }
   3809 
   3810 
   3811 /*
   3812  * Function:
   3813  *     _field_tr_external_entry_clear
   3814  * Purpose:
   3815  *     Clears an ACL h/w entry
   3816  * Parameters:
   3817  *     unit     - (IN) unit
   3818  *     slice    - (IN) slice having the index to be cleared
   3819  *     index    - (IN) index to be cleared
   3820  * Returns: 
   3821  *     BCM_E_NONE     - Success
   3822  *     BCM_E_XXX
   3823  */
   3824 int
   3825 _field_tr_external_entry_clear(int unit, int slice, int index)
   3826 {
   3827     int rv; 
   3828     uint32 buf[SOC_MAX_MEM_FIELD_WORDS];
   3829 
   3830     sal_memset(buf, 0, SOC_MAX_MEM_FIELD_WORDS * sizeof(uint32));
   3831 
   3832     switch (slice) {
   3833       case _FP_EXT_ACL_144_L2:
   3834       case _FP_EXT_ACL_L2:
   3835       case _FP_EXT_ACL_144_IPV4:
   3836       case _FP_EXT_ACL_IPV4: 
   3837       case _FP_EXT_ACL_144_IPV6:
   3838           rv = soc_mem_write(unit, _bcm_field_ext_data_mask_mems[slice], 
   3839                              MEM_BLOCK_ALL, index, buf);
   3840           BCM_IF_ERROR_RETURN(rv);
   3841           break;
   3842       case _FP_EXT_ACL_L2_IPV4:
   3843       case _FP_EXT_ACL_IPV6_SHORT:
   3844       case _FP_EXT_ACL_IPV6_FULL:
   3845       case _FP_EXT_ACL_L2_IPV6:
   3846           /* Write the mask */
   3847           rv =  soc_mem_write(unit, _bcm_field_ext_mask_mems[slice], 
   3848                               MEM_BLOCK_ALL, 0, buf);
   3849           BCM_IF_ERROR_RETURN(rv);
   3850           /* Write the data */
   3851           rv = soc_mem_write(unit, _bcm_field_ext_data_mems[slice], 
   3852                              MEM_BLOCK_ALL, index, buf);
   3853           BCM_IF_ERROR_RETURN(rv);
   3854           break;
   3855       default:
   3856           /* should not come here */
   3857           return (BCM_E_INTERNAL);
   3858     }
   3859     /* Clear policy entry */
   3860     rv =  soc_mem_write(unit, _bcm_field_ext_policy_mems[slice],
   3861                         MEM_BLOCK_ALL, index, buf);
   3862     return (BCM_E_NONE);
   3863 }
   3864 
   3865 /*
   3866  * Function:
   3867  *     _bcm_field_tr_external_entry_reinstall
   3868  * Purpose:
   3869  *     Re-Installs an (external) ACL entry into hardware.
   3870  * Parameters:
   3871  *     unit     - (IN) unit
   3872  *     f_ent    - (IN) Field entry to be installed
   3873  * Returns: 
   3874  *     BCM_E_NONE     - Success
   3875  *     BCM_E_XXX
   3876  */
   3877 int
   3878 _bcm_field_tr_external_entry_reinstall(int unit, _field_entry_t *f_ent)
   3879 {
   3880     soc_profile_mem_t   ext_act_profile;
   3881     _field_stage_t     *stage_fc;
   3882     uint32              ext_act_profile_index = 0;
   3883 
   3884     BCM_IF_ERROR_RETURN
   3885         (_field_stage_control_get(unit, f_ent->fs->stage_id, &stage_fc));
   3886 
   3887     /* Store the existing profile index so that it can be cleared later.
   3888        When reinstall API is called, it is assumed that the priority is not
   3889        changed. When priority is modified, then a separate API is used since
   3890        change in priority will affect the ordering in TCAM. This API should
   3891        modify only the policy table and not the TCAM table
   3892      */
   3893 
   3894     ext_act_profile = stage_fc->ext_act_profile;
   3895     ext_act_profile_index = f_ent->ext_act_profile_idx;
   3896 
   3897     /* Write EXT_FP_CNTR to 0 */
   3898     BCM_IF_ERROR_RETURN(_field_tr_external_counter_reset(unit, 
   3899                 stage_fc, f_ent));
   3900 
   3901     /* Write EXT_FP_POLICY */
   3902     BCM_IF_ERROR_RETURN
   3903         (_field_tr_external_policy_install(unit, stage_fc, f_ent));
   3904 
   3905     BCM_IF_ERROR_RETURN
   3906         (soc_profile_mem_delete(unit, &ext_act_profile, ext_act_profile_index));
   3907 
   3908 
   3909     return (BCM_E_NONE);
   3910 }
   3911 
   3912 /*
   3913  * Function:
   3914  *     _bcm_field_tr_external_entry_install
   3915  * Purpose:
   3916  *     Installs an (external) ACL entry into hardware.
   3917  * Parameters:
   3918  *     unit     - (IN) unit
   3919  *     f_ent    - (IN) Field entry to be installed
   3920  * Returns: 
   3921  *     BCM_E_NONE     - Success
   3922  *     BCM_E_XXX
   3923  */
   3924 int
   3925 _bcm_field_tr_external_entry_install(int unit, _field_entry_t *f_ent)
   3926 {
   3927     _field_stage_t *stage_fc;
   3928     uint32 new_location;
   3929 
   3930     BCM_IF_ERROR_RETURN
   3931         (_field_stage_control_get(unit, f_ent->fs->stage_id, &stage_fc));
   3932 
   3933     BCM_IF_ERROR_RETURN(_bcm_field_entry_target_location(unit, 
   3934                 stage_fc, f_ent, f_ent->prio, &new_location));
   3935 
   3936     f_ent->slice_idx = new_location;
   3937     f_ent->fs->entries[new_location] = f_ent;
   3938 
   3939     BCM_IF_ERROR_RETURN
   3940         (_bcm_field_entry_prio_mgmt_update(unit, f_ent, 1, 0));
   3941 
   3942     /* Write EXT_FP_CNTR to 0 */
   3943     BCM_IF_ERROR_RETURN(_field_tr_external_counter_reset(unit, 
   3944                 stage_fc, f_ent));
   3945 
   3946     /* Write EXT_FP_POLICY */
   3947     _field_tr_external_policy_install(unit, stage_fc, f_ent);
   3948 
   3949     /* Write TCAM */
   3950     _field_tr_external_tcam_write(unit, f_ent, f_ent->slice_idx);
   3951 
   3952     return (BCM_E_NONE);
   3953 }
   3954 
   3955 /*
   3956  * Function:
   3957  *     _bcm_field_tr_external_entry_remove
   3958  * Purpose:
   3959  *     Removes an (external) ACL entry from hardware.
   3960  * Parameters:
   3961  *     unit     - (IN) unit
   3962  *     f_ent    - (IN) Field entry to be removed
   3963  * Returns: 
   3964  *     BCM_E_NONE     - Success
   3965  * Notes:
   3966  *      This also zeros out the H/W replica,
   3967  *          and removes the entry from the slice's entry list.
   3968  *      Now the entry only exists in the hash list.
   3969  */
   3970 int
   3971 _bcm_field_tr_external_entry_remove(int unit, _field_entry_t *f_ent)
   3972 {
   3973     uint32 policy[SOC_MAX_MEM_FIELD_WORDS];
   3974     _field_stage_t *stage_fc;
   3975     soc_mem_t policy_mem;
   3976     uint32 profile_idx; 
   3977     int rv;
   3978     
   3979     /* Get stage field control. */
   3980     rv = _field_stage_control_get(unit, f_ent->fs->stage_id, &stage_fc);
   3981     BCM_IF_ERROR_RETURN(rv);
   3982 
   3983     policy_mem = _bcm_field_ext_policy_mems[f_ent->fs->slice_number];
   3984 
   3985     /* Read EXT_FP_POLICY from index1 */
   3986     rv = soc_mem_read(unit, policy_mem, MEM_BLOCK_ANY, 
   3987                       f_ent->slice_idx, policy);
   3988     BCM_IF_ERROR_RETURN(rv);
   3989    
   3990     profile_idx = soc_mem_field32_get(unit, policy_mem, policy, PROFILE_PTRf);
   3991     /* Release the PROFILE_PTR for EXT_IFP_ACTION_PROFILEm */
   3992     rv = soc_profile_mem_delete(unit, &stage_fc->ext_act_profile, profile_idx);
   3993     BCM_IF_ERROR_RETURN(rv);
   3994 
   3995     /* Clear the H/W entry */
   3996     _field_tr_external_entry_clear(unit, f_ent->fs->slice_number, 
   3997                                               f_ent->slice_idx);
   3998     /* Clear the H/W replica */
   3999     sal_memset(f_ent->tcam.key_hw, 0, f_ent->tcam.key_size);
   4000         sal_memset(f_ent->tcam.mask_hw, 0, f_ent->tcam.key_size);
   4001 
   4002     f_ent->fs->entries[f_ent->slice_idx] = NULL;
   4003 
   4004     BCM_IF_ERROR_RETURN
   4005         (_bcm_field_entry_prio_mgmt_update(unit, f_ent, -1, f_ent->slice_idx));
   4006 
   4007     return (BCM_E_NONE);
   4008 }
   4009 
   4010 /*
   4011  * Function:
   4012  *     _bcm_field_tr_external_entry_move
   4013  * Purpose:
   4014  *     Moves an external entry
   4015  * Parameters:
   4016  *     unit     - (IN) unit
   4017  *     f_ent    - (IN) Field entry to be moved
   4018  *     index1   - (IN) original index
   4019  *     index2   - (IN) destination index
   4020  * Returns: 
   4021  *     BCM_E_NONE     - Success
   4022  * Notes:
   4023  *     It is the calling function's responsibility to
   4024  *         update the prio_mgmt structure.
   4025  */
   4026 int
   4027 _bcm_field_tr_external_entry_move(int unit, _field_entry_t *f_ent,
   4028                                        int index1, int index2)
   4029 {
   4030     _field_stage_t *stage_fc;           /* Stage information */
   4031     _field_stat_t *f_st;                /* Stats information */
   4032     _field_stat_t f_st_old;             /* Old Stats information */
   4033     uint32  policy[SOC_MAX_MEM_FIELD_WORDS]; /* policy info */
   4034     soc_mem_t policy_mem;               /* policy table memory */
   4035     int counter_index1, counter_index2; /* New and old Hw Cntr index */
   4036     int rv;                             /* Operation return status */ 
   4037 
   4038     /* Check if entry move is required. */
   4039     if (index1 == index2) {
   4040         return (BCM_E_NONE);
   4041     }
   4042 
   4043     rv = _field_stage_control_get(unit, f_ent->fs->stage_id, &stage_fc);
   4044     BCM_IF_ERROR_RETURN(rv);
   4045 
   4046     /* Clear TCAM at index2 */
   4047     _field_tr_external_entry_clear(unit, f_ent->fs->slice_number, index2);
   4048 
   4049     policy_mem = _bcm_field_ext_policy_mems[f_ent->fs->slice_number];
   4050     /* Read EXT_FP_POLICY from index1 */
   4051     rv = soc_mem_read(unit, policy_mem, MEM_BLOCK_ANY, index1, policy);
   4052     BCM_IF_ERROR_RETURN(rv);
   4053 
   4054     /* Write EXT_FP_POLICY to index2 */
   4055     rv = soc_mem_write(unit, policy_mem, MEM_BLOCK_ALL, index2, policy);
   4056     BCM_IF_ERROR_RETURN(rv);
   4057 
   4058     /* Write TCAM at index2 */
   4059     _field_tr_external_tcam_write(unit, f_ent, index2);
   4060 
   4061     /* Clear TCAM at index1 */
   4062     _field_tr_external_entry_clear(unit, f_ent->fs->slice_number, index1);
   4063 
   4064     /* Move the counters */
   4065     rv = soc_tcam_part_index_to_mem_index(unit, 
   4066                                           _bcm_field_fp_tcam_partitions[f_ent->fs->slice_number],
   4067                                           index1, EXT_FP_CNTRm, &counter_index1);
   4068     BCM_IF_ERROR_RETURN(rv);
   4069 
   4070     rv = soc_tcam_part_index_to_mem_index(unit, 
   4071                                           _bcm_field_fp_tcam_partitions[f_ent->fs->slice_number], 
   4072                                           index2, EXT_FP_CNTRm, &counter_index2);
   4073 
   4074 
   4075     /* Update the software */
   4076     f_ent->fs->entries[index1] = NULL;
   4077     f_ent->slice_idx = index2;
   4078     if (f_ent->statistic.flags & _FP_ENTRY_STAT_INSTALLED) {
   4079         rv = _bcm_field_stat_get(unit, f_ent->statistic.sid, &f_st);
   4080         BCM_IF_ERROR_RETURN(rv);
   4081 
   4082         /* Save old Stat info */
   4083         f_st_old = *f_st;
   4084 
   4085         f_st->hw_index = counter_index2;
   4086 
   4087         /* Perform counter move operation */
   4088         rv = _bcm_field_entry_counter_move(unit, stage_fc, 
   4089                                            f_ent->fs->slice_number,
   4090                                            counter_index1, &f_st_old, f_st);
   4091         BCM_IF_ERROR_RETURN(rv);
   4092 
   4093         f_st->hw_index = index2;
   4094     }
   4095     f_ent->fs->entries[index2] = f_ent;
   4096 
   4097     return (BCM_E_NONE);
   4098 }
   4099 
   4100 /*
   4101  * Function:
   4102  *     _bcm_field_tr_external_entry_prio_set
   4103  * Purpose:
   4104  *     Sets the priority of an external entry
   4105  * Parameters:
   4106  *     unit     - (IN) unit
   4107  *     f_ent    - (IN) Field entry to be removed
   4108  *     prio     - (IN) new priority for the entry
   4109  * Returns: 
   4110  *     BCM_E_NONE     - Success
   4111  *     BCM_E_XXX
   4112  * Notes:
   4113  *     1. If not installed, just update the priority
   4114  *     2. Find the target location (this may move the entry)
   4115  *     3. Move the entry to target location
   4116  *     4. Update the prio_mgmt structure
   4117  */
   4118 int
   4119 _bcm_field_tr_external_entry_prio_set(int unit, _field_entry_t *f_ent, 
   4120                                        int prio)
   4121 {
   4122     _field_stage_t *stage_fc;
   4123     uint32 new_location;
   4124     uint32 old_location;
   4125 
   4126     /* If entry is not installed, just update the priority */
   4127     if (!(f_ent->flags & _FP_ENTRY_INSTALLED)) {
   4128         f_ent->prio = prio;
   4129         return (BCM_E_NONE);
   4130     }
   4131     
   4132     BCM_IF_ERROR_RETURN
   4133         (_field_stage_control_get(unit, f_ent->fs->stage_id, &stage_fc));
   4134 
   4135     /* This may change f_ent->slice_idx, as it involves moves */
   4136     BCM_IF_ERROR_RETURN(_bcm_field_entry_target_location(unit, 
   4137                             stage_fc, f_ent, prio, &new_location));
   4138 
   4139     old_location = f_ent->slice_idx;
   4140 
   4141 #if defined (BCM_TRIUMPH3_SUPPORT)
   4142 if (SOC_IS_TRIUMPH3(unit)) {
   4143         _bcm_field_tr3_external_entry_move(unit, f_ent, f_ent->slice_idx, new_location);
   4144 } else 
   4145 #endif /* BCM_TRIUMPH3_SUPPORT */
   4146 {
   4147     BCM_IF_ERROR_RETURN(_bcm_field_tr_external_entry_move(unit, 
   4148                             f_ent, f_ent->slice_idx, new_location));
   4149 }
   4150     
   4151     /* 
   4152      * Update the prio_mgmt structure 
   4153      *     to reflect number of entries of each prio 
   4154      */
   4155     BCM_IF_ERROR_RETURN
   4156         (_bcm_field_entry_prio_mgmt_update(unit, f_ent, -1, old_location));
   4157     f_ent->prio = prio;
   4158     BCM_IF_ERROR_RETURN(_bcm_field_entry_prio_mgmt_update(unit, f_ent, +1, 0));
   4159 
   4160     return (BCM_E_NONE);
   4161 }
   4162 
   4163 
   4164 /*
   4165  * Function:
   4166  *     _bcm_field_tr_external_tcam_key_mask_get
   4167  * Purpose:
   4168  *     Allocate & read from hw tcam key/mask image. 
   4169  * Parameters:
   4170  *     unit  - (IN)     BCM device number. 
   4171  *     f_ent - (IN/OUT) Field entry.
   4172  * Returns:
   4173  *     BCM_E_XXX 
   4174  * Notes:
   4175  *     - 1st time: allocate both key and key_hw
   4176  *     - at install time: copy key to key_hw and free key 
   4177  *                         (_field_tcam_policy_install function)
   4178  *     - other times: allocate key, and copy key_hw to key
   4179  * 
   4180  *     Also, for Triumph, we are using the key_width according to
   4181  *         regs file, not the actual width. e.g. _FP_EXT_ACL_L2 = 274. 
   4182  */
   4183 int
   4184 _bcm_field_tr_external_tcam_key_mask_get(int unit, _field_entry_t *f_ent)
   4185 {
   4186     int key_size;  /* in bytes */
   4187 
   4188     switch (f_ent->fs->slice_number) {
   4189       case _FP_EXT_ACL_144_L2:
   4190       case _FP_EXT_ACL_144_IPV4:
   4191       case _FP_EXT_ACL_144_IPV6:
   4192           key_size = 18;
   4193           break;
   4194       case _FP_EXT_ACL_L2:
   4195       case _FP_EXT_ACL_IPV4:
   4196           key_size = 36;
   4197           break;
   4198       case _FP_EXT_ACL_IPV6_SHORT:
   4199           key_size = 45;
   4200           break;
   4201       case _FP_EXT_ACL_L2_IPV4:
   4202       case _FP_EXT_ACL_IPV6_FULL:
   4203       case _FP_EXT_ACL_L2_IPV6:
   4204           key_size = 54;
   4205           break;
   4206       default:
   4207           /* should not come here */
   4208           return (BCM_E_INTERNAL);
   4209     }
   4210     /* Bytes: Full number of words alligned */
   4211     key_size = (((key_size >> 2) + 1) << 2);
   4212     f_ent->tcam.key_size = key_size;
   4213 
   4214     /* Allocate S/W Tcam copy */
   4215     if (NULL == f_ent->tcam.key) {
   4216         f_ent->tcam.key  = sal_alloc(key_size, "field_entry_tcam_key");
   4217         f_ent->tcam.mask = sal_alloc(key_size, "field_entry_tcam_mask");
   4218         if ((NULL == f_ent->tcam.key) || (NULL == f_ent->tcam.mask)) {
   4219             LOG_ERROR(BSL_LS_BCM_FP,
   4220                       (BSL_META_U(unit,
   4221                                   "FP(unit %d) Error: allocation failure for field_entry tcam\n"),
   4222                        unit));
   4223             if (f_ent->tcam.key) sal_free(f_ent->tcam.key); 
   4224             if (f_ent->tcam.mask) sal_free(f_ent->tcam.mask); 
   4225             return (BCM_E_MEMORY);
   4226         }
   4227     }
   4228     sal_memset(f_ent->tcam.key, 0, key_size);
   4229     sal_memset(f_ent->tcam.mask, 0, key_size);
   4230 
   4231     /* 
   4232      * Allocate H/W replica copy: only happens 1st time 
   4233      *     O/W copy H/W copy to S/W copy
   4234      */
   4235     if (f_ent->tcam.key_hw == NULL) {
   4236         f_ent->tcam.key_hw  = sal_alloc(key_size, "field_entry_tcam_key");
   4237         f_ent->tcam.mask_hw = sal_alloc(key_size, "field_entry_tcam_mask");
   4238         if ((NULL == f_ent->tcam.key_hw) || (NULL == f_ent->tcam.mask_hw)) {
   4239             LOG_ERROR(BSL_LS_BCM_FP,
   4240                       (BSL_META_U(unit,
   4241                                   "FP(unit %d) Error: allocation failure for field_entry tcam\n"),
   4242                        unit));
   4243             if (f_ent->tcam.key_hw) sal_free(f_ent->tcam.key_hw); 
   4244             if (f_ent->tcam.mask_hw) sal_free(f_ent->tcam.mask_hw); 
   4245             return (BCM_E_MEMORY);
   4246         }
   4247         sal_memset(f_ent->tcam.key_hw, 0, key_size);
   4248         sal_memset(f_ent->tcam.mask_hw, 0, key_size);
   4249     } else {
   4250         sal_memcpy(f_ent->tcam.key, f_ent->tcam.key_hw, key_size);
   4251         sal_memcpy(f_ent->tcam.mask, f_ent->tcam.mask_hw, key_size);
   4252     }
   4253 
   4254     return (BCM_E_NONE);
   4255 }
   4256 
   4257 /*
   4258  * Function:
   4259  *     _bcm_field_tr_external_counters_collect
   4260  * Purpose:
   4261  *     Counter collection thread
   4262  * Parameters:
   4263  *     unit  - 
   4264  *     qi    - qualifier info
   4265  *     f_ent - Field entry
   4266  *     data  - 128 bit address
   4267  *     mask  - 128 bit mask
   4268  * Returns:
   4269  *     BCM_E_XXX
   4270  * Notes: 
   4271  *     Each time we donot do all tables,  but part of one of them.
   4272  *     The stage variables counter_collect_table and 
   4273  *         counter_collect_index keeps track of this.
   4274  *     The variable magic_number says how many DMAs to be done each time.
   4275  *         We choose 16, which leads to 8K (size of Internal FP_COUNTER_TABLE)
   4276  */
   4277 int
   4278 _bcm_field_tr_external_counters_collect(int unit, _field_stage_t *stage_fc)
   4279 {
   4280     soc_mem_t mem;
   4281     int alloc_size;            /* DMA buffer size.             */
   4282     char *buf;                 /* Buffer to read the table.    */
   4283     int idx, max_idx, min_idx, buf_end_idx;
   4284     int magic_number = 16;     /* Maximum number of dma ops.   */
   4285     int retval = BCM_E_NONE;   /* Operation return value.      */
   4286     int table_id;              /* Extern ACL memory id.        */
   4287     int unified_start_index;   /* Index min EXT_FP_CNTR table. */
   4288     int unified_end_index;     /* Index max EXT_FP_CNTR table. */
   4289     uint32 prev_index;
   4290 
   4291     table_id = stage_fc->counter_collect_table;
   4292     prev_index = stage_fc->counter_collect_index;
   4293     while (soc_mem_index_max(unit, _bcm_field_ext_counter_mems[table_id]) == -1) {
   4294         /* Skip Empty tables */
   4295         table_id = (table_id + 1) % stage_fc->tcam_slices;
   4296         prev_index = 0;
   4297         if (table_id == stage_fc->counter_collect_table) {
   4298             /* 
   4299              * Should not come here, 
   4300              *     as no counters => stage_fc->_field_counters will be NULL
   4301              */
   4302             return (BCM_E_EMPTY);
   4303         }
   4304     }
   4305     mem = _bcm_field_ext_counter_mems[table_id];
   4306     
   4307     /* Allocate memory buffer. */
   4308     alloc_size = (_FP_64_COUNTER_BUCKET * sizeof(ext_fp_cntr_entry_t));
   4309     buf = soc_cm_salloc(unit, alloc_size, "fp_64_bit_counter");
   4310     if (buf == NULL) {
   4311         return (BCM_E_MEMORY);
   4312     }
   4313 
   4314     min_idx = prev_index;
   4315     max_idx = min_idx + magic_number * _FP_64_COUNTER_BUCKET - 1;
   4316     if (max_idx > soc_mem_index_max(unit, mem)) {
   4317         max_idx = soc_mem_index_max(unit, mem);
   4318     }
   4319 
   4320     /* Dma part of the table & update software counters. */
   4321     soc_mem_lock(unit, mem);
   4322     for (idx = min_idx; idx <= max_idx; idx += _FP_64_COUNTER_BUCKET) {
   4323         buf_end_idx = MIN(max_idx, (idx + _FP_64_COUNTER_BUCKET - 1));
   4324         /* Dma range of entries in counter table. */
   4325         retval = soc_mem_read_range(unit, mem, MEM_BLOCK_ANY, idx,
   4326                                     buf_end_idx, buf);
   4327         if (BCM_FAILURE(retval)) {
   4328             break;
   4329         }
   4330 
   4331         /* Get start index in the unified S/W view table */
   4332         soc_tcam_part_index_to_mem_index(unit, _bcm_field_fp_tcam_partitions[table_id], 
   4333                                          idx, EXT_FP_CNTRm, 
   4334                                          &unified_start_index);
   4335         /* Get end index in the unified S/W view table */
   4336         soc_tcam_part_index_to_mem_index(unit, _bcm_field_fp_tcam_partitions[table_id], 
   4337                                          buf_end_idx, EXT_FP_CNTRm, 
   4338                                          &unified_end_index);
   4339 
   4340 
   4341         /* Update software counters. */
   4342         retval = _bcm_field_sw_counter_update(unit, stage_fc, EXT_FP_CNTRm, 
   4343                                               unified_start_index,
   4344                                               unified_end_index, buf, 
   4345                                               _FIELD_FIRST_MEMORY_COUNTERS);
   4346 
   4347         if (BCM_FAILURE(retval)) {
   4348             break;
   4349         }
   4350     }
   4351     soc_mem_unlock(unit, mem);
   4352     soc_cm_sfree(unit, buf);
   4353 
   4354     if (retval == BCM_E_NONE) {
   4355         if (max_idx >= (soc_mem_index_max(unit, _bcm_field_ext_counter_mems[table_id]))) {
   4356             stage_fc->counter_collect_table = (table_id + 1) % 
   4357                                                    stage_fc->tcam_slices;
   4358             stage_fc->counter_collect_index = 0;
   4359         } else {
   4360             stage_fc->counter_collect_table = table_id;
   4361             stage_fc->counter_collect_index = max_idx + 1;
   4362         }
   4363     }
   4364 
   4365     return (retval);
   4366 
   4367 }
   4368 
   4369 /*
   4370  * Function:
   4371  *     _bcm_field_tr_counter_set
   4372  * Purpose:
   4373  *     Set accumulated sw counter and return current counter value.
   4374  * Parameters:
   4375  *   unit          - (IN)  BCM device number.
   4376  *   stage_fc      - (IN)  Stage field control. 
   4377  *   counter_x_mem - (IN)  HW memory name.
   4378  *   mem_x_buf     - (IN)  Memory table entry.
   4379  *   counter_y_mem - (IN)  HW memory name.
   4380  *   mem_y_buf     - (IN)  Memory table entry.
   4381  *   idx           - (IN)  Counter index.
   4382  *   packet_count  - (OUT) Packet Counter value
   4383  *   byte_count    - (OUT) Byte Counter value
   4384  * Returns:
   4385  *    BCM_E_XXX
   4386  */
   4387 int
   4388 _bcm_field_tr_counter_set(int unit, _field_stage_t *stage_fc,
   4389                       soc_mem_t counter_x_mem, uint32 *mem_x_buf,
   4390                       soc_mem_t counter_y_mem, uint32 *mem_y_buf,
   4391                       int idx, uint64 *packet_count, uint64 *byte_count)
   4392 {
   4393     _field_counter32_collect_t *cntrs32_buf;  /* Sw packet counter value    */
   4394     _field_counter64_collect_t *cntrs64_buf;  /* Sw byte counter value      */
   4395     uint32                     hw_val[2];     /* Parsed field counter value.*/
   4396 
   4397     /* Input parameters check. */
   4398     if ((NULL == mem_x_buf) || (INVALIDm == counter_x_mem) || \
   4399         (NULL == stage_fc)) {
   4400         return (BCM_E_PARAM);
   4401     }
   4402 
   4403     /* Byte counter. */
   4404     if (NULL != byte_count) {
   4405         cntrs64_buf = &stage_fc->_field_x64_counters[idx];
   4406         COMPILER_64_ZERO(cntrs64_buf->accumulated_counter);
   4407         COMPILER_64_OR(cntrs64_buf->accumulated_counter, (*byte_count));
   4408         COMPILER_64_SET(cntrs64_buf->last_hw_value,
   4409                         COMPILER_64_HI(*byte_count) & 0x7,
   4410                         COMPILER_64_LO(*byte_count));
   4411         hw_val[0] = COMPILER_64_LO(cntrs64_buf->last_hw_value);
   4412         hw_val[1] = COMPILER_64_HI(cntrs64_buf->last_hw_value);
   4413         soc_mem_field_set(unit, counter_x_mem, mem_x_buf, 
   4414                           BYTE_COUNTERf, hw_val);
   4415     }
   4416 
   4417     /* Packet counter. */
   4418     if (NULL != packet_count) {
   4419         cntrs32_buf = &stage_fc->_field_x32_counters[idx];
   4420         COMPILER_64_ZERO(cntrs32_buf->accumulated_counter);
   4421         COMPILER_64_OR(cntrs32_buf->accumulated_counter, (*packet_count));
   4422         COMPILER_64_TO_32_LO(cntrs32_buf->last_hw_value, (*packet_count));
   4423         cntrs32_buf->last_hw_value &= 0x1fffffff; /* 29 bits */
   4424         hw_val[0] = cntrs32_buf->last_hw_value;
   4425         hw_val[1] = 0;
   4426         soc_mem_field_set(unit, counter_x_mem, mem_x_buf, 
   4427                           PACKET_COUNTERf, hw_val);
   4428     }
   4429     return  soc_mem_write(unit, counter_x_mem, MEM_BLOCK_ALL, idx, mem_x_buf);
   4430 }
   4431 
   4432 /*
   4433  * Function:
   4434  *     _bcm_field_tr_counter_get
   4435  * Purpose:
   4436  *     Update accumulated sw counter and return current counter value.
   4437  * Parameters:
   4438  *   unit          - (IN)  BCM device number.
   4439  *   stage_fc      - (IN)  Stage field control. 
   4440  *   counter_x_mem - (IN)  HW memory name.
   4441  *   mem_x_buf     - (IN)  Memory table entry.
   4442  *   counter_y_mem - (IN)  HW memory name.
   4443  *   mem_y_buf     - (IN)  Memory table entry.
   4444  *   idx           - (IN)  Counter index.
   4445  *   packet_count  - (OUT) Packet Counter value
   4446  *   byte_count    - (OUT) Byte Counter value
   4447  * Returns:
   4448  *    BCM_E_XXX
   4449  */
   4450 int
   4451 _bcm_field_tr_counter_get(int unit, _field_stage_t *stage_fc,
   4452                       soc_mem_t counter_x_mem, uint32 *mem_x_buf,
   4453                       soc_mem_t counter_y_mem, uint32 *mem_y_buf,
   4454                       int idx, uint64 *packet_count, uint64 *byte_count)
   4455 {
   4456     _field_counter32_collect_t *cntrs32_buf;  /* Sw packet counter value    */
   4457     _field_counter64_collect_t *cntrs64_buf;  /* Sw byte counter value      */
   4458     uint32                     hw_val[2];     /* Parsed field counter value.*/
   4459     soc_memacc_t *memacc_pkt, *memacc_byte;   /* Memory access cache.   */
   4460 
   4461     /* Input parameters check. */
   4462     if ((NULL == mem_x_buf) || (INVALIDm == counter_x_mem) || \
   4463         (NULL == stage_fc)) {
   4464         return (BCM_E_PARAM);
   4465     }
   4466 
   4467     /* Byte counter. */
   4468     hw_val[0] = hw_val[1] = 0;
   4469     cntrs64_buf = &stage_fc->_field_x64_counters[idx];
   4470     memacc_byte =
   4471         &(stage_fc->_field_memacc_counters[_FIELD_COUNTER_MEMACC_BYTE]);
   4472     soc_memacc_field_get(memacc_byte, mem_x_buf, hw_val);
   4473     _bcm_field_35bit_counter_update(unit, hw_val, cntrs64_buf);
   4474     /* Return counter value to caller if (out) pointer was provided. */ 
   4475     if (NULL != byte_count) {
   4476         COMPILER_64_OR((*byte_count), cntrs64_buf->accumulated_counter);
   4477     }
   4478 
   4479     /* Packet counter. */
   4480     cntrs32_buf = &stage_fc->_field_x32_counters[idx];
   4481     memacc_pkt =
   4482         &(stage_fc->_field_memacc_counters[_FIELD_COUNTER_MEMACC_PACKET]);
   4483     soc_memacc_field_get(memacc_pkt, mem_x_buf, hw_val);
   4484     _bcm_field_29bit_counter_update(unit, hw_val, cntrs32_buf);
   4485     /* Return counter value to caller if (out) pointer was provided. */ 
   4486     if (NULL != packet_count) {
   4487         COMPILER_64_OR((*packet_count), cntrs32_buf->accumulated_counter);
   4488     }
   4489     return (BCM_E_NONE);
   4490 }
   4491 
   4492 /*      
   4493  * Function:
   4494  *      _bcm_field_tr_multipath_hashcontrol_set
   4495  * Description:
   4496  *      Set the Hash Control for FP L3 Switch to ecmp group action.
   4497  * Parameters:
   4498  *      unit - Bcm device number
   4499  *      arg  - BCM_HASH_XXX
   4500  * Returns:
   4501  *      BCM_E_XXX
   4502  */
   4503 int 
   4504 _bcm_field_tr_multipath_hashcontrol_set(int unit, int arg)
   4505 {
   4506     _field_control_t *fc;        /* Field control structure. */
   4507     int rv;                      /* Operation return status. */
   4508     soc_field_t  fields[] = {ENABLEf, USE_CRCf, USE_UPPERf};
   4509     uint32 values[] = {FALSE, FALSE, FALSE};
   4510     soc_reg_t reg;
   4511 
   4512 #if defined BCM_TOMAHAWK_SUPPORT
   4513     if (soc_feature(unit, soc_feature_field_multi_pipe_support)) {
   4514        reg = IFP_ECMP_HASH_CONTROLr;
   4515     } else
   4516 #endif
   4517     {
   4518        reg = FP_ECMP_HASH_CONTROLr;
   4519     }
   4520 
   4521     if (0 == SOC_REG_IS_VALID(unit, reg)) {
   4522         return (BCM_E_UNAVAIL);
   4523     }
   4524 
   4525     FP_LOCK(unit);
   4526     /* Get unit FP control structure. */
   4527     rv = _field_control_get(unit, &fc);
   4528     if (BCM_FAILURE(rv)) {
   4529         FP_UNLOCK(unit);
   4530         return rv;
   4531     }
   4532 
   4533     switch (arg) {
   4534       case BCM_HASH_ZERO:
   4535           break;
   4536       case BCM_HASH_XORL:
   4537           values[0] = TRUE;
   4538           break;
   4539       case BCM_HASH_CRC32L:
   4540           values[0] = TRUE;
   4541           values[1] = TRUE;
   4542           break;
   4543       case BCM_HASH_XORU:
   4544           values[0] = TRUE;
   4545           values[2] = TRUE;
   4546           break;
   4547       case BCM_HASH_CRC32U:
   4548           values[0] = TRUE;
   4549           values[1] = TRUE;
   4550           values[2] = TRUE;
   4551           break;
   4552       default:
   4553           FP_UNLOCK(unit);
   4554           return (BCM_E_UNAVAIL);
   4555     }
   4556 
   4557     rv = soc_reg_fields32_modify(unit, reg, REG_PORT_ANY, 
   4558                                  COUNTOF(fields), fields, values);
   4559     FP_UNLOCK(unit);
   4560     return (rv);
   4561 }
   4562 
   4563 /*      
   4564  * Function:
   4565  *      _bcm_field_tr_multipath_hashcontrol_get
   4566  * Description:
   4567  *      Get the Hash Control for FP L3 Switch to ecmp group action.
   4568  * Parameters:
   4569  *      unit - (IN) Bcm device number
   4570  *      arg  - (OUT) BCM_HASH_XXX
   4571  * Returns:
   4572  *      BCM_E_XXX
   4573  */
   4574 int 
   4575 _bcm_field_tr_multipath_hashcontrol_get(int unit, int *arg)
   4576 {
   4577     uint32 hash_control;         /* Hash control value.      */
   4578     int rv;                      /* Operation return status. */
   4579     soc_reg_t reg;
   4580 
   4581 #if defined BCM_TOMAHAWK_SUPPORT
   4582     if (soc_feature(unit, soc_feature_field_multi_pipe_support)) {
   4583        reg = IFP_ECMP_HASH_CONTROLr;
   4584     } else
   4585 #endif
   4586     {
   4587        reg = FP_ECMP_HASH_CONTROLr;
   4588     }
   4589 
   4590     if (0 == SOC_REG_IS_VALID(unit, reg)) {
   4591         return (BCM_E_UNAVAIL);
   4592     }
   4593 
   4594     rv = soc_reg32_get(unit, reg, REG_PORT_ANY, 0, &hash_control);
   4595     BCM_IF_ERROR_RETURN(rv);
   4596 
   4597     if (0 == soc_reg_field_get(unit, reg, 
   4598                                hash_control, ENABLEf)) {
   4599         /* Hash overwrite disable.*/
   4600         *arg = BCM_HASH_ZERO;
   4601     } else if (soc_reg_field_get(unit, reg, 
   4602                                  hash_control, USE_CRCf)) {
   4603         /* CRC32 hash algorithm enabled. .*/
   4604         if (soc_reg_field_get(unit, reg, 
   4605                               hash_control, USE_UPPERf)) {
   4606             *arg = BCM_HASH_CRC32U;
   4607         } else {
   4608             *arg = BCM_HASH_CRC32L;
   4609         }
   4610     } else {
   4611         /* Byte XOR hash algorithm enabled .*/
   4612         if (soc_reg_field_get(unit, reg, 
   4613                               hash_control, USE_UPPERf)) {
   4614             *arg = BCM_HASH_XORU;
   4615         } else {
   4616             *arg = BCM_HASH_XORL;
   4617         }
   4618     }
   4619     return (rv);
   4620 }
   4621 
   4622 
   4623 /*
   4624  * Function:
   4625  *     _field_tr_external_port_conflict_check
   4626  * Purpose:
   4627  *     Verify if specific key can satisfy user requested qset. 
   4628  *     
   4629  * Parameters:
   4630  *     unit      - (IN) BCM unit number.
   4631  *     stage_fc  - (IN) Stage Field control structure.
   4632  *     qset_req  - (IN) Client qualifier set.
   4633  *     fg        - (IN/OUT)Select code information filled into the group.  
   4634  * 
   4635  * Returns:
   4636  *     BCM_E_XXX
   4637  */
   4638 STATIC int
   4639 _field_tr_external_port_conflict_check(int unit, _field_stage_t *stage_fc,
   4640                                        bcm_field_qset_t *qset_req,
   4641                                        _field_group_t *fg)
   4642 {
   4643     _field_slice_t *fs;          /* Field slice structure.   */ 
   4644     bcm_pbmp_t pbmp;             /* Aggregated IPv6 pbmp.    */
   4645 
   4646     /* Input parameters check. */
   4647     if ((NULL == fg) || (NULL == qset_req) || (NULL == stage_fc)) {
   4648         return (BCM_E_PARAM);
   4649     }
   4650 
   4651     BCM_PBMP_CLEAR(pbmp);
   4652 
   4653     if (BCM_FIELD_QSET_TEST(fg->qset, bcmFieldQualifyIp6)) {
   4654         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_144_IPV6;
   4655         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_IP6]);
   4656         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_IPV6_SHORT;
   4657         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_IP6]);
   4658         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_IPV6_FULL;
   4659         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_IP6]);
   4660         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_L2_IPV6;
   4661         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_IP6]);
   4662     } else if (BCM_FIELD_QSET_TEST(fg->qset, bcmFieldQualifyIp4)) {
   4663         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_144_IPV4;
   4664         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_IP4]);
   4665         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_IPV4;
   4666         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_IP4]);
   4667         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_L2_IPV4;
   4668         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_IP4]);
   4669     } else {
   4670         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_144_L2;
   4671         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_L2]);
   4672         fs = stage_fc->slices[_FP_DEF_INST] + _FP_EXT_ACL_L2;
   4673         BCM_PBMP_OR(pbmp, fs->ext_pbmp[_FP_EXT_L2]);
   4674     }
   4675     /* Check if the pbmps are disjoint for IPV6 */
   4676     BCM_PBMP_AND(pbmp, fg->pbmp);
   4677     if (BCM_PBMP_NOT_NULL(pbmp)) {
   4678         return (BCM_E_RESOURCE);
   4679     }
   4680     return (BCM_E_NONE);
   4681 }
   4682 
   4683 
   4684 /*
   4685  * Function:
   4686  *     _field_tr_external_key_attempt
   4687  * Purpose:
   4688  *     Verify if specific key can satisfy user requested qset. 
   4689  *     
   4690  * Parameters:
   4691  *     unit      - (IN) BCM unit number.
   4692  *     stage_fc  - (IN) Stage Field control structure.
   4693  *     qset_req  - (IN) Client qualifier set.
   4694  *     key_id    - (IN) External key id.
   4695  *     pkt_type  - (IN) Packet type (V6/V4/L2).
   4696  *     fg        - (IN/OUT)Select code information filled into the group.  
   4697  * 
   4698  * Returns:
   4699  *     BCM_E_XXX
   4700  */
   4701 STATIC int
   4702 _field_tr_external_key_attempt(int unit, _field_stage_t *stage_fc, 
   4703                                bcm_field_qset_t *qset_req,
   4704                                uint8 key_id, uint8 pkt_type,
   4705                                _field_group_t *fg)
   4706 {
   4707     _field_slice_t *fs;          /* Field slice structure.   */ 
   4708 
   4709     /* Input parameters check. */
   4710     if ((NULL == fg) || (NULL == qset_req) || (NULL == stage_fc)) {
   4711         return (BCM_E_PARAM);
   4712     }
   4713 
   4714     /* Get specific key slice pointer. */
   4715     fs = stage_fc->slices[_FP_DEF_INST] + key_id;
   4716     /* If slice present and not used -> attempt to satisfy requested qset.*/
   4717     if ((fs->entry_count) && (BCM_PBMP_IS_NULL(fs->ext_pbmp[pkt_type])) &&
   4718         (0 != fs->pkt_type[pkt_type])) {
   4719         fg->sel_codes[0].extn = key_id; 
   4720         /* Verify that each requested qualifier present in the key. */
   4721         return _bcm_field_selcode_get(unit, stage_fc, &fg->qset, fg);
   4722     }
   4723 
   4724     return (BCM_E_RESOURCE);
   4725 }
   4726 
   4727 /*
   4728  * Function:
   4729  *     _field_tr_external_selcode_get
   4730  * Purpose:
   4731  *     Finds a select encodings that will satisfy the
   4732  *     requested qualifier set (Qset).
   4733  * Parameters:
   4734  *     unit      - (IN) BCM unit number.
   4735  *     stage_fc  - (IN) Stage Field control structure.
   4736  *     qset_req  - (IN) Client qualifier set.
   4737  *     fg        - (IN/OUT)Select code information filled into the group.  
   4738  * 
   4739  * Returns:
   4740  *     BCM_E_XXX
   4741  */
   4742 STATIC int
   4743 _field_tr_external_selcode_get(int unit, _field_stage_t *stage_fc, 
   4744                                bcm_field_qset_t *qset_req,
   4745                                _field_group_t *fg)
   4746 {
   4747     int             rv;          /* Operation return status. */
   4748 
   4749     /* Input parameters check. */
   4750     if ((NULL == fg) || (NULL == qset_req) || (NULL == stage_fc)) {
   4751         return (BCM_E_PARAM);
   4752     }
   4753 
   4754     /* Only single wide groups are supported. */
   4755     if ((fg->flags & _FP_GROUP_STATUS_MASK) != _FP_GROUP_SPAN_SINGLE_SLICE) {
   4756         return (BCM_E_RESOURCE);
   4757     }
   4758 
   4759     /* Check if ports are already committed for a specific packet type. */
   4760     rv = _field_tr_external_port_conflict_check(unit, stage_fc, qset_req, fg);
   4761     BCM_IF_ERROR_RETURN(rv);
   4762 
   4763     /* selcode_get depending on ACL type: L2/V4/V6 */
   4764     if (BCM_FIELD_QSET_TEST(fg->qset, bcmFieldQualifyIp6)) {
   4765 
   4766         /* Attempt _FP_EXT_ACL_144_IPV6  key. */
   4767         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4768                                             _FP_EXT_ACL_144_IPV6, 
   4769                                             _FP_EXT_IP6, fg);
   4770         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4771             return rv;
   4772         }
   4773 
   4774         /* Attempt _FP_EXT_ACL_IPV6_SHORT key. */
   4775         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4776                                             _FP_EXT_ACL_IPV6_SHORT, 
   4777                                             _FP_EXT_IP6, fg);
   4778         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4779             return rv;
   4780         }
   4781 
   4782         /* Attempt _FP_EXT_ACL_IPV6_FULL key. */
   4783         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4784                                             _FP_EXT_ACL_IPV6_FULL, 
   4785                                             _FP_EXT_IP6, fg);
   4786         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4787             return rv;
   4788         }
   4789 
   4790         /* Attempt _FP_EXT_ACL_L2_IPV6 key. */
   4791         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4792                                             _FP_EXT_ACL_L2_IPV6, 
   4793                                             _FP_EXT_IP6, fg);
   4794         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4795             return rv;
   4796         }
   4797     } else if (BCM_FIELD_QSET_TEST(fg->qset, bcmFieldQualifyIp4)) {
   4798 
   4799         /* Attempt _FP_EXT_ACL_144_IPV4  key. */
   4800         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4801                                             _FP_EXT_ACL_144_IPV4, 
   4802                                             _FP_EXT_IP4, fg);
   4803         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4804             return rv;
   4805         }
   4806 
   4807         /* Attempt _FP_EXT_ACL_IPV4 key. */
   4808         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4809                                             _FP_EXT_ACL_IPV4, 
   4810                                             _FP_EXT_IP4, fg);
   4811         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4812             return rv;
   4813         }
   4814 
   4815         /* Attempt _FP_EXT_ACL_L2_IPV4 key. */
   4816         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4817                                             _FP_EXT_ACL_L2_IPV4, 
   4818                                             _FP_EXT_IP4, fg);
   4819         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4820             return rv;
   4821         }
   4822     } else {
   4823         /* Attempt _FP_EXT_ACL_144_IPV4  key. */
   4824         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4825                                             _FP_EXT_ACL_144_L2, 
   4826                                             _FP_EXT_L2, fg);
   4827         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4828             return rv;
   4829         }
   4830 
   4831         /* Attempt _FP_EXT_ACL_IPV4 key. */
   4832         rv = _field_tr_external_key_attempt(unit, stage_fc, qset_req, 
   4833                                             _FP_EXT_ACL_L2, 
   4834                                             _FP_EXT_L2, fg);
   4835         if (BCM_SUCCESS(rv) || (BCM_FAILURE(rv) && (rv != BCM_E_RESOURCE))) {
   4836             return rv;
   4837         }
   4838     }
   4839     return (BCM_E_RESOURCE);
   4840 }
   4841 
   4842 /*
   4843  * Function:
   4844  *     _bcm_field_tr_selcode_get
   4845  * Purpose:
   4846  *     Finds a 4-tuple of select encodings that will satisfy the
   4847  *     requested qualifier set (Qset).
   4848  * Parameters:
   4849  *     unit      - (IN) BCM unit number.
   4850  *     stage_fc  - (IN) Stage Field control structure.
   4851  *     qset_req  - (IN) Client qualifier set.
   4852  *     fg        - (IN/OUT)Select code information filled into the group.  
   4853  * 
   4854  * Returns:
   4855  *     BCM_E_XXX
   4856  */
   4857 int
   4858 _bcm_field_tr_selcode_get(int unit, _field_stage_t *stage_fc, 
   4859                       bcm_field_qset_t *qset_req,
   4860                       _field_group_t *fg)
   4861 {
   4862     int  rv;                     /* Operation return status. */
   4863 
   4864     /* Input parameters check. */
   4865     if ((NULL == fg) || (NULL == qset_req) || (NULL == stage_fc)) {
   4866         return (BCM_E_PARAM);
   4867     }
   4868 
   4869     /* Egress qualifiers are selected based on Key. */
   4870     switch (stage_fc->stage_id) {
   4871       case _BCM_FIELD_STAGE_EXTERNAL:
   4872           rv =  _field_tr_external_selcode_get(unit, stage_fc, qset_req, fg);
   4873           break;
   4874       case _BCM_FIELD_STAGE_EGRESS:
   4875           rv =  _bcm_field_trx_egress_selcode_get(unit, stage_fc, qset_req, fg);
   4876           break;
   4877       default:
   4878           rv =  _bcm_field_selcode_get(unit, stage_fc, qset_req, fg);
   4879     }
   4880     return (rv);
   4881 }
   4882 
   4883 
   4884 /*
   4885  * Function:
   4886  *     _field_v4_external_mode_set
   4887  *
   4888  * Purpose:
   4889  *     Auxiliary routine used to program external key selector.
   4890  * Parameters:
   4891  *     unit       - (IN) BCM device number. 
   4892  *     slice_numb - (IN) Slice number to set mode for.
   4893  *     fg         - (IN) Installed group structure. 
   4894  *     flags      - (IN) New group/slice mode.
   4895  *
   4896  * Returns:
   4897  *     BCM_E_XXX
   4898  */
   4899 STATIC int
   4900 _field_v4_external_mode_set(int unit, uint8 slice_numb, 
   4901                                 _field_group_t *fg, uint8 flags)
   4902 {
   4903     bcm_port_t port;
   4904     uint32  mode = 0;
   4905     uint32  acl144 = 0;
   4906     int     rv;
   4907 
   4908     /* Input parameters check. */
   4909     if (NULL == fg) {
   4910         return (BCM_E_PARAM);
   4911     }
   4912 
   4913     switch (slice_numb) {
   4914       case _FP_EXT_ACL_144_IPV4:
   4915           acl144 = 1;
   4916           mode = 2;
   4917           break;
   4918       case _FP_EXT_ACL_IPV4:
   4919           mode = 2;
   4920           break;
   4921       case _FP_EXT_ACL_L2_IPV4:
   4922           mode = 3;
   4923           break;
   4924       default:
   4925           /* should not come here */
   4926           return BCM_E_INTERNAL;
   4927     }
   4928 
   4929     BCM_PBMP_ITER(fg->pbmp, port) {
   4930         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   4931                                     IPV4_ACL_MODEf, mode);
   4932         BCM_IF_ERROR_RETURN(rv);
   4933         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   4934                                     IPV4_ACL_144_ENf, acl144);
   4935         BCM_IF_ERROR_RETURN(rv);
   4936 
   4937         /*
   4938          * IPV4_ACL_TYPE = 1:
   4939          * Means OuterVlan/Tunnel info are part of this key.
   4940          */
   4941         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   4942                                     IPV4_ACL_TYPEf, 1);
   4943         BCM_IF_ERROR_RETURN(rv);
   4944     }
   4945     return (BCM_E_NONE);
   4946 }
   4947 
   4948 /*
   4949  * Function:
   4950  *     _field_l2_external_mode_set
   4951  *
   4952  * Purpose:
   4953  *     Auxiliary routine used to program external key selector.
   4954  * Parameters:
   4955  *     unit       - (IN) BCM device number. 
   4956  *     slice_numb - (IN) Slice number to set mode for.
   4957  *     fg         - (IN) Installed group structure. 
   4958  *     flags      - (IN) New group/slice mode.
   4959  *
   4960  * Returns:
   4961  *     BCM_E_XXX
   4962  */
   4963 STATIC int
   4964 _field_l2_external_mode_set(int unit, uint8 slice_numb, 
   4965                                 _field_group_t *fg, uint8 flags)
   4966 {
   4967     bcm_port_t port;
   4968     int rv;
   4969 
   4970     /* Input parameters check. */
   4971     if (NULL == fg) {
   4972         return (BCM_E_PARAM);
   4973     }
   4974 
   4975     BCM_PBMP_ITER(fg->pbmp, port) {
   4976         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   4977                                     L2_ACL_ENf, 1);
   4978         BCM_IF_ERROR_RETURN(rv);
   4979 
   4980         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   4981                                     IPV4_ACL_MODEf, 1);
   4982         BCM_IF_ERROR_RETURN(rv);
   4983 
   4984         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   4985                                     IPV6_ACL_MODEf, 1);
   4986         BCM_IF_ERROR_RETURN(rv);
   4987 
   4988         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   4989                                     L2_ACL_144_ENf, 
   4990                                     (_FP_EXT_ACL_144_L2 == slice_numb) ? 1 : 0);
   4991         BCM_IF_ERROR_RETURN(rv);
   4992     }
   4993     return (BCM_E_NONE);
   4994 }
   4995 
   4996 /*
   4997  * Function:
   4998  *     _field_v6_external_mode_set
   4999  *
   5000  * Purpose:
   5001  *     Auxiliary routine used to program external key selector.
   5002  * Parameters:
   5003  *     unit       - (IN) BCM device number. 
   5004  *     slice_numb - (IN) Slice number to set mode for.
   5005  *     fg         - (IN) Installed group structure. 
   5006  *     flags      - (IN) New group/slice mode.
   5007  *
   5008  * Returns:
   5009  *     BCM_E_XXX
   5010  */
   5011 STATIC int
   5012 _field_v6_external_mode_set(int unit, uint8 slice_numb, 
   5013                                 _field_group_t *fg, uint8 flags)
   5014 {
   5015     bcm_port_t port;
   5016     uint32  mode = 0;
   5017     uint32  acl144 = 0;
   5018     uint32  ipv6_full = 0;
   5019     int     rv;
   5020 
   5021     /* Input parameters check. */
   5022     if (NULL == fg) {
   5023         return (BCM_E_PARAM);
   5024     }
   5025 
   5026     switch (slice_numb) {
   5027       case _FP_EXT_ACL_144_IPV6:
   5028           acl144 = 1;
   5029           mode = 2;
   5030           break;
   5031       case _FP_EXT_ACL_IPV6_SHORT:
   5032           mode = 2;
   5033           break;
   5034       case _FP_EXT_ACL_IPV6_FULL:
   5035           ipv6_full = 1;
   5036           mode = 2;
   5037           break;
   5038       case _FP_EXT_ACL_L2_IPV6:
   5039           mode = 3;
   5040           break;
   5041       default:
   5042           /* should not come here */
   5043           return BCM_E_INTERNAL;
   5044     }
   5045 
   5046     BCM_PBMP_ITER(fg->pbmp, port) {
   5047         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port, 
   5048                                     IPV6_ACL_MODEf, mode);
   5049         BCM_IF_ERROR_RETURN(rv);
   5050         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   5051                                     IPV6_ACL_144_ENf, acl144);
   5052         BCM_IF_ERROR_RETURN(rv);
   5053         rv = soc_reg_field32_modify(unit, ESM_MODE_PER_PORTr, port,
   5054                                     IPV6_FULL_ACLf, ipv6_full);
   5055         BCM_IF_ERROR_RETURN(rv);
   5056     }
   5057     return (BCM_E_NONE);
   5058 }
   5059 
   5060 /*
   5061  * Function:
   5062  *     _bcm_field_tr_external_mode_set
   5063  *
   5064  * Purpose:
   5065  *     Auxiliary routine used to program external key selector.
   5066  * Parameters:
   5067  *     unit       - (IN) BCM device number. 
   5068  *     slice_numb - (IN) Slice number to set mode for.
   5069  *     fg         - (IN) Installed group structure. 
   5070  *     flags      - (IN) New group/slice mode.
   5071  *
   5072  * Returns:
   5073  *     BCM_E_XXX
   5074  */
   5075 
   5076 int
   5077 _bcm_field_tr_external_mode_set(int unit, uint8 slice_numb, 
   5078                                 _field_group_t *fg, uint8 flags)
   5079 {
   5080     int rv; 
   5081 
   5082     /* Input parameters check. */
   5083     if (NULL == fg) {
   5084         return (BCM_E_PARAM);
   5085     }
   5086 
   5087     switch (slice_numb) {
   5088       case _FP_EXT_ACL_144_IPV6:
   5089       case _FP_EXT_ACL_IPV6_SHORT:
   5090       case _FP_EXT_ACL_IPV6_FULL:
   5091       case _FP_EXT_ACL_L2_IPV6:
   5092           rv = _field_v6_external_mode_set(unit, slice_numb, fg, flags);
   5093           break;
   5094       case _FP_EXT_ACL_144_IPV4:
   5095       case _FP_EXT_ACL_IPV4:
   5096       case _FP_EXT_ACL_L2_IPV4:
   5097           rv = _field_v4_external_mode_set(unit, slice_numb, fg, flags);
   5098           break;
   5099       case _FP_EXT_ACL_144_L2:
   5100       case _FP_EXT_ACL_L2:
   5101           rv = _field_l2_external_mode_set(unit, slice_numb, fg, flags);
   5102           break;
   5103       default:
   5104           rv = BCM_E_INTERNAL;
   5105     }
   5106     return (rv);
   5107 }
   5108 
   5109 /*
   5110  * Function:
   5111  *     _field_tr_functions_init
   5112  *
   5113  * Purpose:
   5114  *     Set up functions pointers 
   5115  *
   5116  * Parameters:
   5117  *     stage_fc - (IN/OUT) pointers to stage control block whe the device 
   5118  *                         and stage specific functions will be registered.
   5119  *
   5120  * Returns:
   5121  *     nothing
   5122  * Notes:
   5123  */
   5124 STATIC void
   5125 _field_tr_functions_init(_field_funct_t *functions)
   5126 {
   5127     functions->fp_detach               = _bcm_field_tr_detach;
   5128     functions->fp_group_install        = _bcm_field_fb_group_install;
   5129     functions->fp_selcodes_install     = _bcm_field_trx_selcodes_install;
   5130     functions->fp_slice_clear          = _bcm_field_trx_slice_clear;
   5131     functions->fp_entry_remove         = _bcm_field_fb_entry_remove;
   5132     functions->fp_entry_move           = _bcm_field_fb_entry_move;
   5133     functions->fp_selcode_get          = _bcm_field_tr_selcode_get;
   5134     functions->fp_selcode_to_qset      = _bcm_field_selcode_to_qset;
   5135     functions->fp_qual_list_get        = _bcm_field_qual_lists_get;
   5136     functions->fp_tcam_policy_clear    = NULL;
   5137     functions->fp_tcam_policy_install  = _bcm_field_tr_entry_install;
   5138     functions->fp_tcam_policy_reinstall  = _bcm_field_tr_entry_reinstall;
   5139     functions->fp_policer_install      = _bcm_field_trx_policer_install;
   5140     functions->fp_write_slice_map      = _bcm_field_tr_write_slice_map;
   5141     functions->fp_qualify_ip_type      = _bcm_field_trx_qualify_ip_type;
   5142     functions->fp_qualify_ip_type_get  = _bcm_field_trx_qualify_ip_type_get;
   5143     functions->fp_action_support_check = _bcm_field_trx_action_support_check;
   5144     functions->fp_action_conflict_check = _bcm_field_trx_action_conflict_check;
   5145     functions->fp_counter_get          = _bcm_field_tr_counter_get;
   5146     functions->fp_counter_set          = _bcm_field_tr_counter_set;
   5147     functions->fp_stat_index_get       = _bcm_field_trx_stat_index_get;
   5148     functions->fp_egress_key_match_type_set = 
   5149         _bcm_field_trx_egress_key_match_type_set;
   5150     functions->fp_external_entry_install  = _bcm_field_tr_external_entry_install;
   5151     functions->fp_external_entry_reinstall  = _bcm_field_tr_external_entry_reinstall;
   5152     functions->fp_external_entry_remove   = _bcm_field_tr_external_entry_remove;
   5153     functions->fp_external_entry_prio_set = _bcm_field_tr_external_entry_prio_set;
   5154     functions->fp_action_params_check  = _bcm_field_trx_action_params_check;
   5155     functions->fp_data_qualifier_ethertype_add = 
   5156                        _bcm_field_fb_data_qualifier_ethertype_add;
   5157     functions->fp_data_qualifier_ethertype_delete= 
   5158                        _bcm_field_fb_data_qualifier_ethertype_delete;
   5159     functions->fp_data_qualifier_ip_protocol_add = 
   5160                        _bcm_field_fb_data_qualifier_ip_protocol_add;
   5161     functions->fp_data_qualifier_ip_protocol_delete= 
   5162                        _bcm_field_fb_data_qualifier_ip_protocol_delete;
   5163     functions->fp_data_qualifier_packet_format_add= 
   5164                        _bcm_field_fb_data_qualifier_packet_format_add;
   5165     functions->fp_data_qualifier_packet_format_delete=
   5166                        _bcm_field_fb_data_qualifier_packet_format_delete;
   5167     functions->fp_stat_value_get = NULL;
   5168     functions->fp_stat_value_set = NULL;
   5169     functions->fp_control_set = _bcm_field_control_set;
   5170     functions->fp_control_get = _bcm_field_control_get;
   5171     functions->fp_stat_hw_mode_get = _bcm_field_stat_hw_mode_get;
   5172     functions->fp_stat_hw_alloc = _bcm_field_stat_hw_alloc;
   5173     functions->fp_stat_hw_free = _bcm_field_stat_hw_free;
   5174     functions->fp_group_add = NULL;
   5175     functions->fp_qualify_trunk = _bcm_field_qualify_trunk;
   5176     functions->fp_qualify_trunk_get = _bcm_field_qualify_trunk_get;
   5177     functions->fp_qualify_inports = _bcm_field_qualify_InPorts;
   5178     functions->fp_entry_stat_extended_attach = NULL;
   5179     functions->fp_entry_stat_extended_get = NULL;
   5180     functions->fp_entry_stat_detach = _bcm_field_entry_stat_detach;
   5181     functions->fp_class_size_get = NULL;
   5182     functions->fp_qualify_packet_res = _field_qualify_PacketRes;
   5183     functions->fp_qualify_packet_res_get = _field_qualify_PacketRes_get;
   5184 }
   5185 #else /* BCM_TRIUMPH_SUPPORT && BCM_FIELD_SUPPORT */
   5186 int _triumph_field_not_empty;
   5187 #endif  /* BCM_TRIUMPH_SUPPORT && BCM_FIELD_SUPPORT */