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

mirror.h (21477B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      6  *
      7  * This file contains Mirroring definitions internal to the BCM library.
      8  */
      9 
     10 #ifndef _BCM_INT_MIRROR_H
     11 #define _BCM_INT_MIRROR_H
     12 
     13 #include <bcm/mirror.h>
     14 #include <soc/profile_mem.h>
     15 
     16 #define _BCM_MIRROR_INVALID_MTP    (-1)
     17 
     18 /* Mirroring destination managment structure. */
     19 typedef struct _bcm_mirror_dest_config_s {
     20     bcm_mirror_destination_t mirror_dest; /* Mirroring destination.  */
     21     int                      ref_count;   /* Reference count.        */
     22     struct _bcm_mirror_dest_config_s *next; /* Mirroring dest config link list for shared destination */
     23 } _bcm_mirror_dest_config_t, *_bcm_mirror_dest_config_p;
     24 
     25 /* MTP managment structure. */
     26 typedef struct _bcm_mtp_config_s {
     27     bcm_gport_t dest_id;       /* Mirroring destination id. */
     28     int         ref_count;     /* Reference count.          */
     29     uint8       egress;        /* Indicator if egress MTP or ingress */         
     30 } _bcm_mtp_config_t, *_bcm_mtp_config_p;
     31 
     32 /* Legacy MTP Slot managment structure. */
     33 typedef struct _bcm_mtp_slot_config_s {
     34     int       ref_count;                          /* Slot Reference count.     */
     35     int       slot_owner;                         /* Slot Owner module.        */
     36 } _bcm_mtp_slot_config_t, *_bcm_mtp_slot_config_p;
     37 
     38 #define BCM_MIRROR_MTP_METHOD_NON_DIRECTED      0
     39 #define BCM_MIRROR_MTP_METHOD_DIRECTED_LOCKED   1
     40 #define BCM_MIRROR_MTP_METHOD_DIRECTED_FLEXIBLE 2
     41 
     42 #define _BCM_SWITCH_MIRROR_NON_EXCLUSIVE        0
     43 #define _BCM_SWITCH_MIRROR_EXCLUSIVE            1
     44 
     45 /* Flags for slot check ingress/egress status */
     46 #define _BCM_MIRROR_SLOT_INGRESS             (1 << 0) /* Ingress mirroring */
     47 #define _BCM_MIRROR_SLOT_EGRESS              (1 << 1) /* Egress mirroring */
     48 #define _BCM_MIRROR_SLOT_PORT                (1 << 2) /* PORT module */
     49 #define _BCM_MIRROR_SLOT_FP                  (1 << 3) /* FP module */
     50 
     51 /* Mirror Container */
     52 #define _BCM_MIRROR_SLOT_CONT0              0
     53 #define _BCM_MIRROR_SLOT_CONT1              1
     54 
     55 /* Flags for slot management */
     56 #define _BCM_MIRROR_SLOT_OWNER_NONE         0      /* Slot Owner is None */
     57 #define _BCM_MIRROR_SLOT_OWNER_PORT       (1 << 0) /* Slot Owner is PORT */
     58 #define _BCM_MIRROR_SLOT_OWNER_FP         (1 << 1) /* Slot owner is FP */
     59 
     60 #define BCM_MIRROR_MTP_ONE                    (1 << 0)
     61 #define BCM_MIRROR_MTP_TWO                    (1 << 1)
     62 #define BCM_MIRROR_MTP_THREE                  (1 << 2)
     63 #define BCM_MIRROR_MTP_FOUR                   (1 << 3)
     64 #define BCM_MIRROR_MTP_COUNT                    4
     65 
     66 /* Flexible MTP legacy egress Draco 1.5 mode */
     67 #define BCM_MIRROR_MTP_FLEX_EGRESS_D15        BCM_MIRROR_MTP_THREE
     68 #define BCM_MIRROR_MTP_FLEX_EGRESS_D15_INDEX  2
     69 
     70 #define BCM_MIRROR_MTP_REF_PORT_MASK            0x0000FFFF
     71 #define BCM_MIRROR_MTP_REF_FP_MASK              0xFFFF0000
     72 #define BCM_MIRROR_MTP_REF_FP_OFFSET            16
     73 
     74 #define BCM_XGS3_MIRROR_MTP_MASK              (BCM_MIRROR_MTP_ONE)
     75 #define BCM_TRX_MIRROR_MTP_MASK (BCM_MIRROR_MTP_ONE | BCM_MIRROR_MTP_TWO)
     76 #define BCM_TR2_MIRROR_MTP_MASK (BCM_MIRROR_MTP_ONE | BCM_MIRROR_MTP_TWO | \
     77                                  BCM_MIRROR_MTP_THREE | BCM_MIRROR_MTP_FOUR)
     78 
     79 #define BCM_MIRROR_MTP_ITER(_mask,_slot) \
     80     for ((_slot) = 0; (_slot) < BCM_MIRROR_MTP_COUNT; (_slot)++)  \
     81         if ((_mask) & (1 << (_slot)))
     82 
     83 #define BCM_MIRROR_MTP_FLEX_SLOT_SHIFT        16
     84 #define BCM_MIRROR_MTP_FLEX_SLOT_MASK         0x3
     85 
     86 #define BCM_MTP_SLOT_TYPE_PORT                0
     87 #define BCM_MTP_SLOT_TYPE_FP                  1
     88 #define BCM_MTP_SLOT_TYPE_IPFIX               2
     89 #define BCM_MTP_SLOT_TYPE_SFLOW               3 
     90 #define BCM_MTP_SLOT_TYPE_INT                 4 
     91 #define BCM_MTP_SLOT_TYPE_ELEPHANT            5
     92 #define BCM_MTP_SLOT_TYPE_DLB_MONITOR         6
     93 #define BCM_MTP_SLOT_TYPES                    7
     94 
     95 #define BCM_MIRROR_DEST_TUNNELS  (BCM_MIRROR_DEST_TUNNEL_L2 |\
     96                                   BCM_MIRROR_DEST_TUNNEL_IP_GRE |\
     97                                   BCM_MIRROR_DEST_TUNNEL_WITH_SEQ |\
     98                                   BCM_MIRROR_DEST_TUNNEL_TRILL  |\
     99                                   BCM_MIRROR_DEST_TUNNEL_NIV |\
    100                                   BCM_MIRROR_DEST_TUNNEL_ETAG |\
    101                                   BCM_MIRROR_DEST_TUNNEL_PSAMP |\
    102                                   BCM_MIRROR_DEST_TUNNEL_SFLOW)  
    103 
    104 #define BCM_MIRROR_DEST_FLAGS2_TUNNELS  (BCM_MIRROR_DEST_FLAGS2_TUNNEL_VXLAN |\
    105                                       BCM_MIRROR_DEST_FLAGS2_PSAMP_FORMAT_2 | \
    106                                       BCM_MIRROR_DEST_FLAGS2_IFA | \
    107                                       BCM_MIRROR_DEST_FLAGS2_INT_PROBE)
    108 
    109 #if defined(BCM_TRIDENT_SUPPORT) || defined(BCM_GREYHOUND_SUPPORT)
    110 #define BCM_TD_MIRROR_TRUNK_MAX_PORTCNT       8  
    111 
    112 #define BCM_TD_MIRROR_ENCAP_TYPE_RSPAN        0  
    113 #define BCM_TD_MIRROR_ENCAP_TYPE_ERSPAN       1  
    114 #define BCM_TD_MIRROR_ENCAP_TYPE_SFLOW        2
    115 
    116 #define BCM_TD_MIRROR_HEADER_ONLY             0
    117 #define BCM_TD_MIRROR_HEADER_VNTAG            1
    118 #define BCM_TD_MIRROR_HEADER_TRILL            2
    119 
    120 #define BCM_TD_MIRROR_TRILL_VERSION           0
    121 /* bits  31 and 30 of the TRILL header is the version */
    122 #define BCM_TD_MIRROR_TRILL_VERSION_OFFSET    29
    123 /* Bits 24..16 of the TRILL header is the hopecount */
    124 #define BCM_TD_MIRROR_TRILL_HOPCOUNT_OFFSET   16
    125 /* Bits 0..15 is the TRILL source name and TRILL destination name 
    126 (Ingress RBridge Nickname) is positioned on bits 31..16 of the second word. */
    127 #define BCM_TD_MIRROR_TRILL_DEST_NAME_OFFSET  16
    128 
    129 /* 20 byte IPv4 header = 5 words */
    130 #define _BCM_TD_MIRROR_V4_GRE_BUFFER_SZ  (0x5)
    131 
    132 /* 6 bytes TRILL header, no options = 2 words */
    133 #define _BCM_TD_MIRROR_TRILL_BUFFER_SZ  (0x2)  
    134 
    135 #define _BCM_TD_MIRROR_TRILL_NAME_MASK       (0xffff)
    136 #define _BCM_TD_MIRROR_TRILL_HOPCOUNT_MASK  (0xff)
    137 
    138 
    139 #define _BCM_TD_MIRROR_NIV_LOOP_BIT         (0x8000)  
    140 #define _BCM_TD_MIRROR_NIV_DST_VIF_OFFSET   16
    141 #define _BCM_TD_MIRROR_NIV_SRC_VIF_MASK     (0xfff)
    142 #define _BCM_TD_MIRROR_NIV_DST_VIF_MASK     (0xffff)
    143 
    144 #if defined(BCM_TOMAHAWK3_SUPPORT)
    145 /* Encoding for various encapsulations supported on TH3. Values map directly to
    146  * memory fields, modify only if required and after referring to the regsfile
    147  */
    148 #define _BCM_TH3_MIRROR_ENCAP_TYPE_RSPAN             0
    149 #define _BCM_TH3_MIRROR_ENCAP_TYPE_ERSPAN            1
    150 #define _BCM_TH3_MIRROR_ENCAP_TYPE_SFLOW             2
    151 #define _BCM_TH3_MIRROR_ENCAP_TYPE_PSAMP             3
    152 #define _BCM_TH3_MIRROR_ENCAP_TYPE_ERSPAN_V6         4
    153 #define _BCM_TH3_MIRROR_ENCAP_TYPE_SFLOW_V6          5
    154 #define _BCM_TH3_MIRROR_ENCAP_TYPE_PSAMP_V6          6
    155 #define _BCM_TH3_MIRROR_ENCAP_TYPE_SFLOW_SEQ         7
    156 #define _BCM_TH3_MIRROR_ENCAP_TYPE_SFLOW_V6_SEQ      8
    157 #define _BCM_TH3_MIRROR_ENCAP_TYPE_PSAMP_FORMAT_2    9
    158 #define _BCM_TH3_MIRROR_ENCAP_TYPE_PSAMP_FORMAT_2_V6 10
    159 /* Refer ARCHTH3-444 for encoding below */
    160 /* Non-tunneled MTP. Used with truncate/truncate and zero */
    161 #define _BCM_TH3_MIRROR_ENCAP_TYPE_NONE              15
    162 
    163 /* IPv4 buffer size in 32-bit words (IPv4 has 20 bytes, without IP options)*/
    164 /* Used for Sflow, Psamp v4 */
    165 #define _BCM_TH3_MIRROR_V4_BUFFER_SZ  5
    166 
    167 /* IPv6 buffer size in 32-bit words (IPv6 has 40 bytes) */
    168 /* Used for Sflow, Psamp v6 */
    169 #define _BCM_TH3_MIRROR_V6_BUFFER_SZ  10
    170 
    171 /* Buffer size in 32-bit words (UDP header has 8 bytes) */
    172 #define _BCM_TH3_MIRROR_UDP_BUFFER_SZ 2
    173 
    174 /* 10 32-bit words for IPv6 */
    175 #define _BCM_TH3_MIRROR_V6_GRE_BUFFER_SZ  (10)
    176 
    177 /* Copy to field buffer. This macro is for a very specific purpose,
    178  * do not modify, or reuse
    179  */
    180 /* dst must be uint32 and src must be (uint8 *) */
    181 #define _BCM_TH3_IP6_ADDR_COPY_TO(dst, src) \
    182             dst = (src)[0] << 24 | (src)[1] << 16 | (src)[2] << 8 | (src)[3];
    183 
    184 /* Copy from field buffer. This macro is for a very specific purpose,
    185  * do not modify, or reuse
    186  */
    187 /* dst must be (uint8 *) and src must be uint32 */
    188 #define _BCM_TH3_IP6_ADDR_COPY_FROM(dst, src) \
    189     (dst)[0] = (uint8)(((src) & 0xFF000000) >> 24); \
    190     (dst)[1] = (uint8)(((src) & 0x00FF0000) >> 16); \
    191     (dst)[2] = (uint8)(((src) & 0x0000FF00) >> 8); \
    192     (dst)[3] = (uint8)(((src) & 0x000000FF) >> 0);
    193 
    194 #define _BCM_TH3_PAYLOAD_PARAM_RANGE_CHECK(_v, _fldlen) \
    195             (((_v) >= (1 << (_fldlen)))) ?  -1 : 0
    196 
    197 #endif /* BCM_TOMAHAWK3_SUPPORT */
    198 
    199 #endif
    200 
    201 
    202 #define BCM_MIRROR_HEADER_ETAG            3
    203 
    204 #define _BCM_MIRROR_ETAG_SRC_VID_OFFSET  16
    205 #define _BCM_MIRROR_ETAG_SRC_VID_MASK    (0xfff)
    206 #define _BCM_MIRROR_ETAG_DST_VID_MASK    (0x3fff)
    207 
    208 #if defined(BCM_TRIDENT3_SUPPORT)
    209 /* EGR_SEQUENCE_NUMBER_TABLE is shared by EGR_IP_TUNNEL and
    210  * EGR_MPLS_VC_AND_SWAP_LABEL_TABLE. SEQNUM_OFFSET for EGR_IP_TUNNEL is 0 and
    211  * VC_SWAP Table is 4096. SEQNUM_OFFSET for mirroring should start from 12288
    212  * since depth of EGR_IP_TUNNELm is 4k and VC_SWAP Table is 8k.
    213  * In HR4: Set as 3K as EGR_IP_TUNNEL is 1K and VC_SWAP is 2K.
    214  */
    215 #define EGR_MIRROR_TABLE_SEQNUM_OFFSET(_u_) \
    216              (SOC_IS_HURRICANE4(_u_) ? 3072: 12288)
    217 #endif /* BCM_TRIDENT3_SUPPORT */
    218 
    219 /* Module control structure. */
    220 typedef struct _bcm_mirror_config_s {
    221     int                       mtp_method;     /* Non-directed,
    222                                                * directed-locked, or
    223                                                * directed-flexible */
    224     int                       mode;           /* L2/L2_L3/DISABLED.        */
    225     _bcm_mirror_dest_config_p dest_arr;       /* Mirror destination array  */
    226     uint8                     dest_count;     /* Mirror destinations size. */
    227     _bcm_mtp_config_p         ing_mtp;        /* Ingress mtp array.        */
    228     uint8                     ing_mtp_count;  /* Ingress mtp array size.   */
    229     _bcm_mtp_config_p         egr_mtp;        /* Egress mtp array.         */
    230     uint8                     egr_mtp_count;  /* Egress mtp array size.    */
    231     _bcm_mtp_config_p         shared_mtp;     /* MTP array shared for Ing and Egr   */
    232     uint8                     port_im_mtp_count; /* Maximal ingress mtp allowed per port */
    233     uint8                     port_em_mtp_count; /* Maximal egress mtp allowed per port */
    234     uint8                     mtp_dev_mask;   /* MTPs allowed on device    */
    235     uint8                     mtp_mode_bmp;   /* MTP ingress/egress bitmap */
    236     int                       mtp_mode_ref_count[BCM_MIRROR_MTP_COUNT];
    237                                               /* MTP container references  */
    238     _bcm_mtp_config_p         egr_true_mtp;   /* True egress mtp array.    */
    239     uint8                     egr_true_mtp_count;  /* True egress mtp array size. */
    240     _bcm_mtp_config_p         mtp_slot[BCM_MTP_SLOT_TYPES];
    241                                               /* FP/other mtp slot arrays. */
    242     uint8                     mtp_slot_count[BCM_MTP_SLOT_TYPES];
    243                                           /* FP/other mtp slot array size. */
    244     sal_mutex_t               mutex;          /* Protection mutex.         */
    245     bcm_pbmp_t                pbmp_mtp_slot_used[BCM_MIRROR_MTP_COUNT];
    246                                          /* pbmp of mtp slot which is used */
    247     _bcm_mtp_slot_config_p    ing_slot_container;
    248                                               /* Ingress Legacy Mirror Slot
    249                                                  reference. Used only for devices
    250                                                  not supporting flex mirroring */
    251     _bcm_mtp_slot_config_p    egr_slot_container;
    252                                               /* Egress Mirror Slot
    253                                                  reference. Used only for devices
    254                                                  not supporting flex mirroring */
    255 #if defined(BCM_TOMAHAWK3_SUPPORT)
    256     soc_profile_mem_t         mirror_zeroing_profile; 
    257                                               /* Mirror Zero Profile
    258                                                  in Payload Wiping */
    259 #endif
    260 } _bcm_mirror_config_t, *_bcm_mirror_config_p;
    261 
    262 
    263 #define MIRROR_INIT(_unit_) (NULL != _bcm_mirror_config[(_unit_)])
    264 #define MIRROR_CONFIG(_unit_) (_bcm_mirror_config[(_unit_)])
    265 #define MIRROR_CONFIG_MODE(_unit_)  ((MIRROR_CONFIG(_unit_))->mode)
    266 
    267 #define MIRROR_CONFIG_MTP_METHOD(_unit_)  \
    268         ((MIRROR_CONFIG(_unit_))->mtp_method)
    269 
    270 #define MIRROR_MTP_METHOD_IS_NON_DIRECTED(unit) \
    271         (BCM_MIRROR_MTP_METHOD_NON_DIRECTED == \
    272                     MIRROR_CONFIG_MTP_METHOD(unit))
    273 
    274 #define MIRROR_MTP_METHOD_IS_DIRECTED_LOCKED(unit) \
    275         (BCM_MIRROR_MTP_METHOD_DIRECTED_LOCKED == \
    276                     MIRROR_CONFIG_MTP_METHOD(unit))
    277 
    278 #define MIRROR_MTP_METHOD_IS_DIRECTED_FLEXIBLE(unit) \
    279         (BCM_MIRROR_MTP_METHOD_DIRECTED_FLEXIBLE == \
    280                     MIRROR_CONFIG_MTP_METHOD(unit))
    281 
    282 #define MIRROR_SWITCH_IS_EXCLUSIVE(unit) \
    283         ((_BCM_SWITCH_MIRROR_EXCLUSIVE == \
    284              _bcm_switch_mirror_exclusive_config[unit]) ? TRUE : FALSE)
    285 
    286 #define MIRROR_CONFIG_ING_MTP(_unit_, _idx_) \
    287     ((MIRROR_CONFIG(_unit_))->ing_mtp[(_idx_)])
    288 
    289 #define MIRROR_CONFIG_EGR_MTP(_unit_, _idx_) \
    290     ((MIRROR_CONFIG(_unit_))->egr_mtp[(_idx_)])
    291 
    292 #define MIRROR_CONFIG_EGR_TRUE_MTP(_unit_, _idx_) \
    293     ((MIRROR_CONFIG(_unit_))->egr_true_mtp[(_idx_)])
    294 
    295 #define MIRROR_CONFIG_TYPE_MTP(_unit_, _idx_, _type_) \
    296     (((MIRROR_CONFIG(_unit_))->mtp_slot[(_type_)])[(_idx_)])
    297 
    298 #define MIRROR_CONFIG_ING_MTP_SLOT(_unit_, _slotidx_) \
    299      ((MIRROR_CONFIG(_unit_))->ing_slot_container[(_slotidx_)])
    300 
    301 #define MIRROR_CONFIG_EGR_MTP_SLOT(_unit_, _slotidx_) \
    302      ((MIRROR_CONFIG(_unit_))->egr_slot_container[(_slotidx_)])
    303 
    304 #define MIRROR_CONFIG_ING_MTP_SLOT_OWNER(_unit_, _slotidx_) \
    305      MIRROR_CONFIG_ING_MTP_SLOT((_unit_),(_slotidx_)).slot_owner
    306 
    307 #define MIRROR_CONFIG_EGR_MTP_SLOT_OWNER(_unit_, _slotidx_) \
    308       MIRROR_CONFIG_EGR_MTP_SLOT((_unit_),(_slotidx_)).slot_owner
    309 
    310 #define MIRROR_CONFIG_ING_MTP_SLOT_REF(_unit_, _slotidx_) \
    311     MIRROR_CONFIG_ING_MTP_SLOT((_unit_),(_slotidx_)).ref_count
    312 
    313 #define MIRROR_CONFIG_EGR_MTP_SLOT_REF(_unit_, _slotidx_) \
    314     MIRROR_CONFIG_EGR_MTP_SLOT((_unit_),(_slotidx_)).ref_count
    315 
    316 #define MIRROR_CONFIG_MTP(_unit_, _idx_, _flags_) \
    317     ((soc_feature(_unit_, soc_feature_mirror_flexible) &&    \
    318       !MIRROR_MTP_METHOD_IS_DIRECTED_FLEXIBLE(unit)) ?       \
    319      ((_flags_ & (BCM_MIRROR_PORT_INGRESS |                  \
    320                   BCM_MIRROR_PORT_EGRESS)) ?                 \
    321       &(MIRROR_CONFIG_SHARED_MTP(_unit_, _idx_)) :           \
    322       &(MIRROR_CONFIG_EGR_TRUE_MTP(_unit_, _idx_))) :        \
    323      ((_flags_ & BCM_MIRROR_PORT_INGRESS) ?                  \
    324       &MIRROR_CONFIG_ING_MTP(_unit_, _idx_) :                \
    325       ((_flags_ & BCM_MIRROR_PORT_EGRESS) ?                  \
    326        &MIRROR_CONFIG_EGR_MTP(_unit_, _idx_) :               \
    327        &MIRROR_CONFIG_EGR_TRUE_MTP(_unit_, _idx_))))
    328 
    329 #define MIRROR_CONFIG_SHARED_MTP(_unit_, _idx_) \
    330     ((MIRROR_CONFIG(_unit_))->shared_mtp[(_idx_)])
    331 
    332 #define MIRROR_CONFIG_ING_MTP_DEST(_unit_, _idx_) \
    333     MIRROR_CONFIG_ING_MTP((_unit_), (_idx_)).dest_id
    334 
    335 #define MIRROR_CONFIG_EGR_MTP_DEST(_unit_, _idx_) \
    336     MIRROR_CONFIG_EGR_MTP((_unit_),(_idx_)).dest_id
    337 
    338 #define MIRROR_CONFIG_EGR_TRUE_MTP_DEST(_unit_, _idx_) \
    339     MIRROR_CONFIG_EGR_TRUE_MTP((_unit_),(_idx_)).dest_id
    340 
    341 #define MIRROR_CONFIG_SHARED_MTP_DEST(_unit_, _idx_) \
    342     MIRROR_CONFIG_SHARED_MTP((_unit_),(_idx_)).dest_id
    343 
    344 #define MIRROR_CONFIG_MTP_DEV_MASK(_unit_) \
    345     ((MIRROR_CONFIG(_unit_))->mtp_dev_mask)
    346 
    347 #define MIRROR_CONFIG_EGR_MTP_REF_COUNT(_unit_, _idx_) \
    348     MIRROR_CONFIG_EGR_MTP((_unit_),(_idx_)).ref_count
    349 
    350 #define MIRROR_CONFIG_EGR_TRUE_MTP_REF_COUNT(_unit_, _idx_) \
    351     MIRROR_CONFIG_EGR_TRUE_MTP((_unit_),(_idx_)).ref_count
    352 
    353 #define MIRROR_CONFIG_SHARED_MTP_REF_COUNT(_unit_, _idx_) \
    354     MIRROR_CONFIG_SHARED_MTP((_unit_),(_idx_)).ref_count
    355 
    356 #define MIRROR_CONFIG_MTP_MODE_BMP(_unit_) \
    357     ((MIRROR_CONFIG(_unit_))->mtp_mode_bmp)
    358 
    359 #define MIRROR_CONFIG_ING_MTP_REF_COUNT(_unit_, _idx_) \
    360     MIRROR_CONFIG_ING_MTP((_unit_), (_idx_)).ref_count
    361 
    362 #define MIRROR_CONFIG_MTP_MODE_REF_COUNT(_unit_, _idx_) \
    363     ((MIRROR_CONFIG(_unit_))->mtp_mode_ref_count[(_idx_)])
    364 
    365 #define MIRROR_CONFIG_TYPE_MTP_SLOT(_unit_, _idx_, _type_) \
    366     MIRROR_CONFIG_TYPE_MTP((_unit_),(_idx_),(_type_)).dest_id
    367 
    368 #define MIRROR_CONFIG_TYPE_MTP_REF_COUNT(_unit_, _idx_, _type_) \
    369     MIRROR_CONFIG_TYPE_MTP((_unit_),(_idx_),(_type_)).ref_count
    370 
    371 #define MIRROR_CONFIG_PBMP_MTP_SLOT_USED(_unit_, _idx_) \
    372     ((MIRROR_CONFIG(_unit_))->pbmp_mtp_slot_used[(_idx_)])
    373 
    374 #define MIRROR_DEST_CONFIG_COUNT(_unit_) \
    375     ((MIRROR_CONFIG(_unit_))->dest_count)
    376 
    377 #define MIRROR_DEST_CONFIG(_unit_, _idx_) \
    378     ((MIRROR_CONFIG(_unit_))->dest_arr[BCM_GPORT_MIRROR_GET(_idx_)])
    379 
    380 #define MIRROR_DEST(_unit_, _idx_) \
    381     (&MIRROR_DEST_CONFIG((_unit_),(_idx_)).mirror_dest)
    382 
    383 #define MIRROR_DEST_GPORT(_unit_, _idx_) \
    384     (MIRROR_DEST((_unit_), (_idx_))->gport)
    385 
    386 #define MIRROR_DEST_REF_COUNT(_unit_, _idx_) \
    387     (MIRROR_DEST_CONFIG((_unit_), (_idx_)).ref_count)
    388 
    389 #define MIRROR_DEST_IS_TUNNEL(_unit_, _idx_) \
    390     (((MIRROR_DEST(unit, _idx_))->flags & (BCM_MIRROR_DEST_TUNNELS)) || \
    391      ((MIRROR_DEST(unit, _idx_))->flags2 & (BCM_MIRROR_DEST_FLAGS2_TUNNELS)))
    392 
    393 #define MIRROR_LOCK(_unit_)  \
    394             sal_mutex_take(MIRROR_CONFIG(_unit_)->mutex, sal_mutex_FOREVER)
    395 #define MIRROR_UNLOCK(_unit_)   sal_mutex_give(MIRROR_CONFIG(_unit_)->mutex)
    396 extern int _bcm_esw_mirror_fp_dest_add(int unit, int modid, int port, 
    397                                        uint32 flags, int *mtp_index);
    398 
    399 extern int _bcm_esw_mirror_fp_dest_delete(int unit, int mtp_index, uint32 flags);
    400 
    401 extern int _bcm_esw_mirror_stk_update(int unit, bcm_module_t modid, bcm_port_t port,
    402                                       bcm_pbmp_t pbmp);
    403 extern int _bcm_esw_mirror_flexible_get(int unit, int *enable);
    404 extern int _bcm_esw_mirror_flexible_set(int unit, int enable);
    405 extern int bcm_esw_mirror_deinit(int unit);
    406 
    407 extern void bcm_esw_mirror_lock(int unit);
    408 extern void bcm_esw_mirror_unlock(int unit);
    409 
    410 extern int _bcm_esw_mtp_slot_valid_get(int unit,
    411                                        uint32 flags,int *mtp_slot_status);
    412 extern int _bcm_esw_mirror_fp_slot_add_ref(int unit,
    413                                            uint32 flags,
    414                                            uint32 mtp_slot);
    415 extern int _bcm_esw_mirror_fp_slot_del_ref(int unit,
    416                                            uint32 flags,
    417                                            uint32 mtp_slot);
    418 extern int _bcm_esw_mirror_exclusive_get(int unit, int *enable);
    419 extern int _bcm_esw_mirror_exclusive_set(int unit, int enable);
    420 extern int _bcm_esw_mirror_enable_set(int unit, int port, int enable);
    421 extern int _bcm_esw_mirror_mtp_match(int unit, bcm_gport_t gport, uint32 flags,
    422                                      int *match_idx);
    423 extern int _bcm_esw_mirror_mtp_reserve(int unit, bcm_gport_t dest_id,
    424                                        uint32 flags, int *index_used);
    425 extern int _bcm_esw_mirror_mtp_unreserve(int unit, int mtp_index, int is_port,
    426                                          uint32 flags);
    427 extern int
    428 bcmi_esw_mirror_port_attach(int unit, bcm_port_t port);
    429 extern int
    430 bcmi_esw_mirror_port_detach(int unit, bcm_port_t port);
    431 
    432 #if defined (BCM_TOMAHAWK3_SUPPORT)
    433 extern int _bcm_esw_mirror_zero_profile_ref_count_get(int unit, 
    434                                            uint32 profile_index,
    435                                            int *ref_count);
    436 extern int _bcm_esw_mirror_zero_profile_get(int unit,
    437                                             soc_profile_mem_t **profile);
    438 #define MIRROR_ZERO_PROFILE_INDEX_MAX 7
    439 #define MIRROR_ZERO_PROFILE_INDEX_MIN 1
    440 #endif
    441 
    442 #if defined(BCM_TRIDENT3_SUPPORT)
    443 extern int
    444 _bcm_mirror_port_match_add(int unit, bcm_mirror_destination_t *mirror_dest,
    445                            bcm_gport_t match_port, bcm_vlan_t match_vlan,
    446                            bcm_port_match_t match_type);
    447 extern int
    448 _bcm_mirror_port_match_delete(int unit, bcm_mirror_destination_t *mirror_dest,
    449                               bcm_gport_t match_port, bcm_vlan_t match_vlan,
    450                               bcm_port_match_t match_type);
    451 extern int
    452 _bcm_mirror_port_match_multi_get(int unit, bcm_gport_t gport, int size,
    453                                  bcm_port_match_info_t *match_array,
    454                                  int *count);
    455 #endif /* BCM_TRIDENT3_SUPPORT */
    456 #if defined(BCM_TRX_SUPPORT)
    457 /* 18 byte L2 header + 20 byte IPv4 header + 4 byte GRE header = 11 words */
    458 #define _BCM_TRX_MIRROR_TUNNEL_BUFFER_SZ  (0x11) 
    459 #endif /* BCM_TRX_SUPPORT */
    460 #if defined(BCM_XGS3_SWITCH_SUPPORT)
    461 extern int _bcm_xgs3_mirror_trunk_update(int unit, bcm_trunk_t tid);
    462 #endif /* BCM_XGS3_SWITCH_SUPPORT */
    463 
    464 #ifdef BCM_WARM_BOOT_SUPPORT
    465 extern int _bcm_esw_mirror_sync(int unit);
    466 extern int _bcm_esw_mirror_mtp_to_modport(int unit, int mtp_index,
    467                                           int modport, int flags,
    468                                           bcm_module_t *modid,
    469                                           bcm_gport_t *port);
    470 /* Mirror Zero Profile management structure. */
    471 typedef struct _bcm_mirror_zero_profile_s {
    472     int         prof_index;    /* Profile Index */
    473     int         ref_count;     /* Reference count.*/
    474 } _bcm_mirror_zero_profile_t;
    475 
    476 #endif /* BCM_WARM_BOOT_SUPPORT */
    477 
    478 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP
    479 extern void _bcm_mirror_sw_dump(int unit);
    480 #endif /* BCM_WARM_BOOT_SUPPORT_SW_DUMP */
    481 
    482 #endif	/* !_BCM_INT_MIRROR_H */