mirror.h (21375B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * 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) < 0) || ((_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 */ 214 #define EGR_MIRROR_TABLE_SEQNUM_OFFSET 12288 215 #endif /* BCM_TRIDENT3_SUPPORT */ 216 217 /* Module control structure. */ 218 typedef struct _bcm_mirror_config_s { 219 int mtp_method; /* Non-directed, 220 * directed-locked, or 221 * directed-flexible */ 222 int mode; /* L2/L2_L3/DISABLED. */ 223 _bcm_mirror_dest_config_p dest_arr; /* Mirror destination array */ 224 uint8 dest_count; /* Mirror destinations size. */ 225 _bcm_mtp_config_p ing_mtp; /* Ingress mtp array. */ 226 uint8 ing_mtp_count; /* Ingress mtp array size. */ 227 _bcm_mtp_config_p egr_mtp; /* Egress mtp array. */ 228 uint8 egr_mtp_count; /* Egress mtp array size. */ 229 _bcm_mtp_config_p shared_mtp; /* MTP array shared for Ing and Egr */ 230 uint8 port_im_mtp_count; /* Maximal ingress mtp allowed per port */ 231 uint8 port_em_mtp_count; /* Maximal egress mtp allowed per port */ 232 uint8 mtp_dev_mask; /* MTPs allowed on device */ 233 uint8 mtp_mode_bmp; /* MTP ingress/egress bitmap */ 234 int mtp_mode_ref_count[BCM_MIRROR_MTP_COUNT]; 235 /* MTP container references */ 236 _bcm_mtp_config_p egr_true_mtp; /* True egress mtp array. */ 237 uint8 egr_true_mtp_count; /* True egress mtp array size. */ 238 _bcm_mtp_config_p mtp_slot[BCM_MTP_SLOT_TYPES]; 239 /* FP/other mtp slot arrays. */ 240 uint8 mtp_slot_count[BCM_MTP_SLOT_TYPES]; 241 /* FP/other mtp slot array size. */ 242 sal_mutex_t mutex; /* Protection mutex. */ 243 bcm_pbmp_t pbmp_mtp_slot_used[BCM_MIRROR_MTP_COUNT]; 244 /* pbmp of mtp slot which is used */ 245 _bcm_mtp_slot_config_p ing_slot_container; 246 /* Ingress Legacy Mirror Slot 247 reference. Used only for devices 248 not supporting flex mirroring */ 249 _bcm_mtp_slot_config_p egr_slot_container; 250 /* Egress Mirror Slot 251 reference. Used only for devices 252 not supporting flex mirroring */ 253 #if defined(BCM_TOMAHAWK3_SUPPORT) 254 soc_profile_mem_t mirror_zeroing_profile; 255 /* Mirror Zero Profile 256 in Payload Wiping */ 257 #endif 258 } _bcm_mirror_config_t, *_bcm_mirror_config_p; 259 260 261 #define MIRROR_INIT(_unit_) (NULL != _bcm_mirror_config[(_unit_)]) 262 #define MIRROR_CONFIG(_unit_) (_bcm_mirror_config[(_unit_)]) 263 #define MIRROR_CONFIG_MODE(_unit_) ((MIRROR_CONFIG(_unit_))->mode) 264 265 #define MIRROR_CONFIG_MTP_METHOD(_unit_) \ 266 ((MIRROR_CONFIG(_unit_))->mtp_method) 267 268 #define MIRROR_MTP_METHOD_IS_NON_DIRECTED(unit) \ 269 (BCM_MIRROR_MTP_METHOD_NON_DIRECTED == \ 270 MIRROR_CONFIG_MTP_METHOD(unit)) 271 272 #define MIRROR_MTP_METHOD_IS_DIRECTED_LOCKED(unit) \ 273 (BCM_MIRROR_MTP_METHOD_DIRECTED_LOCKED == \ 274 MIRROR_CONFIG_MTP_METHOD(unit)) 275 276 #define MIRROR_MTP_METHOD_IS_DIRECTED_FLEXIBLE(unit) \ 277 (BCM_MIRROR_MTP_METHOD_DIRECTED_FLEXIBLE == \ 278 MIRROR_CONFIG_MTP_METHOD(unit)) 279 280 #define MIRROR_SWITCH_IS_EXCLUSIVE(unit) \ 281 ((_BCM_SWITCH_MIRROR_EXCLUSIVE == \ 282 _bcm_switch_mirror_exclusive_config[unit]) ? TRUE : FALSE) 283 284 #define MIRROR_CONFIG_ING_MTP(_unit_, _idx_) \ 285 ((MIRROR_CONFIG(_unit_))->ing_mtp[(_idx_)]) 286 287 #define MIRROR_CONFIG_EGR_MTP(_unit_, _idx_) \ 288 ((MIRROR_CONFIG(_unit_))->egr_mtp[(_idx_)]) 289 290 #define MIRROR_CONFIG_EGR_TRUE_MTP(_unit_, _idx_) \ 291 ((MIRROR_CONFIG(_unit_))->egr_true_mtp[(_idx_)]) 292 293 #define MIRROR_CONFIG_TYPE_MTP(_unit_, _idx_, _type_) \ 294 (((MIRROR_CONFIG(_unit_))->mtp_slot[(_type_)])[(_idx_)]) 295 296 #define MIRROR_CONFIG_ING_MTP_SLOT(_unit_, _slotidx_) \ 297 ((MIRROR_CONFIG(_unit_))->ing_slot_container[(_slotidx_)]) 298 299 #define MIRROR_CONFIG_EGR_MTP_SLOT(_unit_, _slotidx_) \ 300 ((MIRROR_CONFIG(_unit_))->egr_slot_container[(_slotidx_)]) 301 302 #define MIRROR_CONFIG_ING_MTP_SLOT_OWNER(_unit_, _slotidx_) \ 303 MIRROR_CONFIG_ING_MTP_SLOT((_unit_),(_slotidx_)).slot_owner 304 305 #define MIRROR_CONFIG_EGR_MTP_SLOT_OWNER(_unit_, _slotidx_) \ 306 MIRROR_CONFIG_EGR_MTP_SLOT((_unit_),(_slotidx_)).slot_owner 307 308 #define MIRROR_CONFIG_ING_MTP_SLOT_REF(_unit_, _slotidx_) \ 309 MIRROR_CONFIG_ING_MTP_SLOT((_unit_),(_slotidx_)).ref_count 310 311 #define MIRROR_CONFIG_EGR_MTP_SLOT_REF(_unit_, _slotidx_) \ 312 MIRROR_CONFIG_EGR_MTP_SLOT((_unit_),(_slotidx_)).ref_count 313 314 #define MIRROR_CONFIG_MTP(_unit_, _idx_, _flags_) \ 315 ((soc_feature(_unit_, soc_feature_mirror_flexible) && \ 316 !MIRROR_MTP_METHOD_IS_DIRECTED_FLEXIBLE(unit)) ? \ 317 ((_flags_ & (BCM_MIRROR_PORT_INGRESS | \ 318 BCM_MIRROR_PORT_EGRESS)) ? \ 319 &(MIRROR_CONFIG_SHARED_MTP(_unit_, _idx_)) : \ 320 &(MIRROR_CONFIG_EGR_TRUE_MTP(_unit_, _idx_))) : \ 321 ((_flags_ & BCM_MIRROR_PORT_INGRESS) ? \ 322 &MIRROR_CONFIG_ING_MTP(_unit_, _idx_) : \ 323 ((_flags_ & BCM_MIRROR_PORT_EGRESS) ? \ 324 &MIRROR_CONFIG_EGR_MTP(_unit_, _idx_) : \ 325 &MIRROR_CONFIG_EGR_TRUE_MTP(_unit_, _idx_)))) 326 327 #define MIRROR_CONFIG_SHARED_MTP(_unit_, _idx_) \ 328 ((MIRROR_CONFIG(_unit_))->shared_mtp[(_idx_)]) 329 330 #define MIRROR_CONFIG_ING_MTP_DEST(_unit_, _idx_) \ 331 MIRROR_CONFIG_ING_MTP((_unit_), (_idx_)).dest_id 332 333 #define MIRROR_CONFIG_EGR_MTP_DEST(_unit_, _idx_) \ 334 MIRROR_CONFIG_EGR_MTP((_unit_),(_idx_)).dest_id 335 336 #define MIRROR_CONFIG_EGR_TRUE_MTP_DEST(_unit_, _idx_) \ 337 MIRROR_CONFIG_EGR_TRUE_MTP((_unit_),(_idx_)).dest_id 338 339 #define MIRROR_CONFIG_SHARED_MTP_DEST(_unit_, _idx_) \ 340 MIRROR_CONFIG_SHARED_MTP((_unit_),(_idx_)).dest_id 341 342 #define MIRROR_CONFIG_MTP_DEV_MASK(_unit_) \ 343 ((MIRROR_CONFIG(_unit_))->mtp_dev_mask) 344 345 #define MIRROR_CONFIG_EGR_MTP_REF_COUNT(_unit_, _idx_) \ 346 MIRROR_CONFIG_EGR_MTP((_unit_),(_idx_)).ref_count 347 348 #define MIRROR_CONFIG_EGR_TRUE_MTP_REF_COUNT(_unit_, _idx_) \ 349 MIRROR_CONFIG_EGR_TRUE_MTP((_unit_),(_idx_)).ref_count 350 351 #define MIRROR_CONFIG_SHARED_MTP_REF_COUNT(_unit_, _idx_) \ 352 MIRROR_CONFIG_SHARED_MTP((_unit_),(_idx_)).ref_count 353 354 #define MIRROR_CONFIG_MTP_MODE_BMP(_unit_) \ 355 ((MIRROR_CONFIG(_unit_))->mtp_mode_bmp) 356 357 #define MIRROR_CONFIG_ING_MTP_REF_COUNT(_unit_, _idx_) \ 358 MIRROR_CONFIG_ING_MTP((_unit_), (_idx_)).ref_count 359 360 #define MIRROR_CONFIG_MTP_MODE_REF_COUNT(_unit_, _idx_) \ 361 ((MIRROR_CONFIG(_unit_))->mtp_mode_ref_count[(_idx_)]) 362 363 #define MIRROR_CONFIG_TYPE_MTP_SLOT(_unit_, _idx_, _type_) \ 364 MIRROR_CONFIG_TYPE_MTP((_unit_),(_idx_),(_type_)).dest_id 365 366 #define MIRROR_CONFIG_TYPE_MTP_REF_COUNT(_unit_, _idx_, _type_) \ 367 MIRROR_CONFIG_TYPE_MTP((_unit_),(_idx_),(_type_)).ref_count 368 369 #define MIRROR_CONFIG_PBMP_MTP_SLOT_USED(_unit_, _idx_) \ 370 ((MIRROR_CONFIG(_unit_))->pbmp_mtp_slot_used[(_idx_)]) 371 372 #define MIRROR_DEST_CONFIG_COUNT(_unit_) \ 373 ((MIRROR_CONFIG(_unit_))->dest_count) 374 375 #define MIRROR_DEST_CONFIG(_unit_, _idx_) \ 376 ((MIRROR_CONFIG(_unit_))->dest_arr[BCM_GPORT_MIRROR_GET(_idx_)]) 377 378 #define MIRROR_DEST(_unit_, _idx_) \ 379 (&MIRROR_DEST_CONFIG((_unit_),(_idx_)).mirror_dest) 380 381 #define MIRROR_DEST_GPORT(_unit_, _idx_) \ 382 (MIRROR_DEST((_unit_), (_idx_))->gport) 383 384 #define MIRROR_DEST_REF_COUNT(_unit_, _idx_) \ 385 (MIRROR_DEST_CONFIG((_unit_), (_idx_)).ref_count) 386 387 #define MIRROR_DEST_IS_TUNNEL(_unit_, _idx_) \ 388 (((MIRROR_DEST(unit, _idx_))->flags & (BCM_MIRROR_DEST_TUNNELS)) || \ 389 ((MIRROR_DEST(unit, _idx_))->flags2 & (BCM_MIRROR_DEST_FLAGS2_TUNNELS))) 390 391 #define MIRROR_LOCK(_unit_) \ 392 sal_mutex_take(MIRROR_CONFIG(_unit_)->mutex, sal_mutex_FOREVER) 393 #define MIRROR_UNLOCK(_unit_) sal_mutex_give(MIRROR_CONFIG(_unit_)->mutex) 394 extern int _bcm_esw_mirror_fp_dest_add(int unit, int modid, int port, 395 uint32 flags, int *mtp_index); 396 397 extern int _bcm_esw_mirror_fp_dest_delete(int unit, int mtp_index, uint32 flags); 398 399 extern int _bcm_esw_mirror_stk_update(int unit, bcm_module_t modid, bcm_port_t port, 400 bcm_pbmp_t pbmp); 401 extern int _bcm_esw_mirror_flexible_get(int unit, int *enable); 402 extern int _bcm_esw_mirror_flexible_set(int unit, int enable); 403 extern int bcm_esw_mirror_deinit(int unit); 404 405 extern void bcm_esw_mirror_lock(int unit); 406 extern void bcm_esw_mirror_unlock(int unit); 407 408 extern int _bcm_esw_mtp_slot_valid_get(int unit, 409 uint32 flags,int *mtp_slot_status); 410 extern int _bcm_esw_mirror_fp_slot_add_ref(int unit, 411 uint32 flags, 412 uint32 mtp_slot); 413 extern int _bcm_esw_mirror_fp_slot_del_ref(int unit, 414 uint32 flags, 415 uint32 mtp_slot); 416 extern int _bcm_esw_mirror_exclusive_get(int unit, int *enable); 417 extern int _bcm_esw_mirror_exclusive_set(int unit, int enable); 418 extern int _bcm_esw_mirror_enable_set(int unit, int port, int enable); 419 extern int _bcm_esw_mirror_mtp_match(int unit, bcm_gport_t gport, uint32 flags, 420 int *match_idx); 421 extern int _bcm_esw_mirror_mtp_reserve(int unit, bcm_gport_t dest_id, 422 uint32 flags, int *index_used); 423 extern int _bcm_esw_mirror_mtp_unreserve(int unit, int mtp_index, int is_port, 424 uint32 flags); 425 extern int 426 bcmi_esw_mirror_port_attach(int unit, bcm_port_t port); 427 extern int 428 bcmi_esw_mirror_port_detach(int unit, bcm_port_t port); 429 430 #if defined (BCM_TOMAHAWK3_SUPPORT) 431 extern int _bcm_esw_mirror_zero_profile_ref_count_get(int unit, 432 uint32 profile_index, 433 int *ref_count); 434 extern int _bcm_esw_mirror_zero_profile_get(int unit, 435 soc_profile_mem_t **profile); 436 #define MIRROR_ZERO_PROFILE_INDEX_MAX 7 437 #define MIRROR_ZERO_PROFILE_INDEX_MIN 1 438 #endif 439 440 #if defined(BCM_TRIDENT3_SUPPORT) 441 extern int 442 _bcm_mirror_port_match_add(int unit, bcm_mirror_destination_t *mirror_dest, 443 bcm_gport_t match_port, bcm_vlan_t match_vlan, 444 bcm_port_match_t match_type); 445 extern int 446 _bcm_mirror_port_match_delete(int unit, bcm_mirror_destination_t *mirror_dest, 447 bcm_gport_t match_port, bcm_vlan_t match_vlan, 448 bcm_port_match_t match_type); 449 extern int 450 _bcm_mirror_port_match_multi_get(int unit, bcm_gport_t gport, int size, 451 bcm_port_match_info_t *match_array, 452 int *count); 453 #endif /* BCM_TRIDENT3_SUPPORT */ 454 #if defined(BCM_TRX_SUPPORT) 455 /* 18 byte L2 header + 20 byte IPv4 header + 4 byte GRE header = 11 words */ 456 #define _BCM_TRX_MIRROR_TUNNEL_BUFFER_SZ (0x11) 457 #endif /* BCM_TRX_SUPPORT */ 458 #if defined(BCM_XGS3_SWITCH_SUPPORT) 459 extern int _bcm_xgs3_mirror_trunk_update(int unit, bcm_trunk_t tid); 460 #endif /* BCM_XGS3_SWITCH_SUPPORT */ 461 462 #ifdef BCM_WARM_BOOT_SUPPORT 463 extern int _bcm_esw_mirror_sync(int unit); 464 extern int _bcm_esw_mirror_mtp_to_modport(int unit, int mtp_index, 465 int modport, int flags, 466 bcm_module_t *modid, 467 bcm_gport_t *port); 468 /* Mirror Zero Profile management structure. */ 469 typedef struct _bcm_mirror_zero_profile_s { 470 int prof_index; /* Profile Index */ 471 int ref_count; /* Reference count.*/ 472 } _bcm_mirror_zero_profile_t; 473 474 #endif /* BCM_WARM_BOOT_SUPPORT */ 475 476 #ifdef BCM_WARM_BOOT_SUPPORT_SW_DUMP 477 extern void _bcm_mirror_sw_dump(int unit); 478 #endif /* BCM_WARM_BOOT_SUPPORT_SW_DUMP */ 479 480 #endif /* !_BCM_INT_MIRROR_H */