mirror.h (96187B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_MIRROR_H__ 11 #define __BCM_MIRROR_H__ 12 13 #include <bcm/types.h> 14 #include <bcm/pkt.h> 15 16 /* Mirror modes for bcm_mirror_mode_set/get. */ 17 #define BCM_MIRROR_DISABLE 0 /* Disable mirroring. */ 18 #define BCM_MIRROR_L2 1 /* Enable mirroring. */ 19 #define BCM_MIRROR_L2_L3 2 /* Deprecated. */ 20 21 /* Flags for bcm_mirror_port_set/get. */ 22 #define BCM_MIRROR_PORT_ENABLE 0x00000001 /* Enable mirroring. */ 23 #define BCM_MIRROR_PORT_INGRESS 0x00000002 /* Ingress mirroring. */ 24 #define BCM_MIRROR_PORT_EGRESS 0x00000004 /* Egress mirroring. */ 25 #define BCM_MIRROR_PORT_EGRESS_TRUE 0x00000008 /* True egress mirroring. */ 26 #define BCM_MIRROR_PORT_DEST_TRUNK 0x00000010 /* Parameter dest_port is a 27 trunk. */ 28 #define BCM_MIRROR_PORT_EGRESS_ACL 0x00000020 /* Enable Egress Mirroring 29 for ACLs */ 30 #define BCM_MIRROR_PORT_SFLOW 0x00000040 /* sFlow mirroring */ 31 #define BCM_MIRROR_PORT_UNTAGGED_ONLY 0x00000080 /* Mirror Untagged traffic - 32 Ingress Mirroring only. */ 33 #define BCM_MIRROR_PORT_TAGGED_DEFAULT 0x00000100 /* Mirror tagged traffic with 34 unspecified VID - Ingress 35 Mirroring only. */ 36 #define BCM_MIRROR_PORT_PSAMP 0x00000200 /* Packet Sampling - Ingress 37 only. */ 38 #define BCM_MIRROR_PORT_INT 0x00000400 /* INT (Inband Network 39 Telemetry) Mirroring - 40 Ingress only. */ 41 #define BCM_MIRROR_PORT_ELEPHANT 0x00000800 /* Elephant Flow Mirroring - 42 Ingress only. */ 43 #define BCM_MIRROR_PORT_DLB_MONITOR 0x00001000 /* DLB Flow Monitor Mirroring 44 - Ingress only */ 45 46 /* Flags for bcm_mirror_destination_create/traverse. */ 47 #define BCM_MIRROR_DEST_REPLACE (1U << 0) /* Replace mirror 48 destination. */ 49 #define BCM_MIRROR_DEST_WITH_ID (1U << 1) /* Mirror destination id 50 is valid. */ 51 #define BCM_MIRROR_DEST_TUNNEL_L2 (1U << 2) /* Mirrored packet should 52 be L2 tunneled. */ 53 #define BCM_MIRROR_DEST_TUNNEL_IP_GRE (1U << 3) /* Mirrored packet should 54 be L3 GRE tunneled. */ 55 #define BCM_MIRROR_DEST_PAYLOAD_UNTAGGED (1U << 4) /* Strip vlan tag from 56 mirrored packet. */ 57 #define BCM_MIRROR_DEST_TUNNEL_TRILL (1U << 5) /* Mirrored packet should 58 be TRILL tunneled. */ 59 #define BCM_MIRROR_DEST_TUNNEL_NIV (1U << 6) /* Mirrored packet should 60 be NIV tunneled. */ 61 #define BCM_MIRROR_DEST_UPDATE_POLICER (1U << 7) /* update policer using 62 policer_id */ 63 #define BCM_MIRROR_DEST_UPDATE_COUNTER (1U << 8) /* update counter using 64 stat_id */ 65 #define BCM_MIRROR_DEST_DEST_MULTICAST (1U << 9) /* destination is ingress 66 multicast */ 67 #define BCM_MIRROR_DEST_TUNNEL_WITH_ENCAP_ID (1U << 10) /* Mirror destination 68 encap_id is valid */ 69 #define BCM_MIRROR_DEST_TUNNEL_WITH_SPAN_ID (1U << 11) /* Mirrored packet should 70 be with ERSPAN 71 encapsulation */ 72 #define BCM_MIRROR_DEST_TUNNEL_RSPAN (1U << 12) /* Mirrored packet should 73 be RSPAN (VLAN) 74 tunneled */ 75 #define BCM_MIRROR_DEST_INT_PRI_SET (1U << 13) /* Mirrored packet should 76 set with internal 77 priority */ 78 #define BCM_MIRROR_DEST_TUNNEL_ETAG (1U << 14) /* Mirrored packet should 79 be ETAG tunneled. */ 80 #define BCM_MIRROR_DEST_TUNNEL_SFLOW (1U << 15) /* Mirrored packet should 81 be with sFlow 82 encapsulation */ 83 #define BCM_MIRROR_DEST_IS_SNOOP (1U << 16) /* Specify that the 84 destination type is a 85 snoop destination. */ 86 #define BCM_MIRROR_DEST_IS_TRAP (1U << 17) /* Specify that the 87 destination is a trap 88 destination. */ 89 #define BCM_MIRROR_DEST_IS_STAT_SAMPLE (1U << 17) /* Specify that the 90 destination type is a 91 STATISTIC SAMPLING 92 destination. */ 93 #define BCM_MIRROR_DEST_EGRESS_ADD_ORIG_SYSTEM_HEADER (1U << 18) /* The start of the 94 original packet system 95 header will be 96 included in the 97 outbound mirrored 98 packets. */ 99 #define BCM_MIRROR_DEST_FIELD (1U << 19) /* Specify that mirror 100 destination owner is 101 FP. */ 102 #define BCM_MIRROR_DEST_PORT (1U << 20) /* Specify that mirror 103 destination owner is 104 PORT. */ 105 #define BCM_MIRROR_DEST_DROP_SNIFF_IF_FWD_DROPPED (1U << 21) /* Drop the sniff packet 106 if the original packet 107 is dropped */ 108 #define BCM_MIRROR_DEST_UPDATE_COUNTER_1 (1U << 21) /* update counter No.1 */ 109 #define BCM_MIRROR_DEST_UPDATE_COUNTER_2 (1U << 22) /* update counter No.2 */ 110 #define BCM_MIRROR_DEST_DROP_FWD_IF_SNIFF_DROPPED (1U << 22) /* Drop the original 111 packet if the sniff 112 packet is dropped */ 113 #define BCM_MIRROR_DEST_UPDATE_TUNNEL_SFLOW (1U << 23) /* Update mirror 114 destination with sflow 115 encapsulation */ 116 #define BCM_MIRROR_DEST_ID_SHARE (1U << 24) /* Share mirror 117 destination id among 118 multi ports */ 119 #define BCM_MIRROR_DEST_EEI_INVALID (1U << 24) /* Set EEI invalid */ 120 #define BCM_MIRROR_DEST_MTP_ADD (1U << 25) /* Add an MTP into a 121 shared-id mirror 122 destination */ 123 #define BCM_MIRROR_DEST_MTP_DELETE (1U << 26) /* Delete an MTP from a 124 shared-id mirror 125 destination */ 126 #define BCM_MIRROR_DEST_MTP_REPLACE (1U << 27) /* REPLACE an MTP of a 127 shared-id mirror 128 destination */ 129 #define BCM_MIRROR_DEST_EGRESS_TRAP_WITH_SYSTEM_HEADER (1U << 28) /* For packets recycled 130 by egress applications 131 and not forwarded, 132 retain the incoming 133 packet's system 134 headers as received 135 from the fabric, and 136 in case of an Egress 137 MC packet, stamp the 138 FTMH.OutLIF field with 139 the CUD. */ 140 #define BCM_MIRROR_DEST_TUNNEL_PSAMP (1U << 29) /* Update mirror 141 destination with PSAMP 142 encapsulation */ 143 #define BCM_MIRROR_DEST_OUT_MIRROR_DISABLE (1U << 30) /* Assert out mirror 144 disable */ 145 #define BCM_MIRROR_DEST_TUNNEL_WITH_SEQ (1U << 31) /* Include Sequence 146 number in header. */ 147 #define BCM_MIRROR_DEST_UPDATE_EXT_COUNTERS (1U << 31) /* Set statistic 148 interfaces for 149 mirrored packets. */ 150 #define BCM_MIRROR_DEST_FLAGS2_TUNNEL_VXLAN (1U << 0) /* Mirror Tunnel is 151 VXLAN. */ 152 #define BCM_MIRROR_DEST_FLAGS2_PSAMP_FORMAT_2 (1U << 1) /* Use format2 header for 153 PSAMP */ 154 #define BCM_MIRROR_DEST_FLAGS2_INT_PROBE (1U << 2) /* Add INT(Inband Network 155 Telemetry) probe 156 header. */ 157 #define BCM_MIRROR_DEST_FLAGS2_IFA (1U << 3) /* Add IFA(In-band Flow 158 Analyzer) header. */ 159 #define BCM_MIRROR_DEST_FLAGS2_UPDATE_EXT_STAT_VALID (1U << 4) /* Update external 160 statistics valid bit 161 for mirror packets */ 162 #define BCM_MIRROR_DEST_FLAGS2_UPDATE_EXT_STAT_TYPES (1U << 5) /* Update external 163 statistics types for 164 mirror packets */ 165 #define BCM_MIRROR_DEST_FLAGS2_MIRROR_ON_DROP (1U << 6) /* Indicate mirror on 166 drop profile. */ 167 #define BCM_MIRROR_DEST_FLAGS2_MOD_TUNNEL_PSAMP (1U << 7) /* Mirror packet with 168 PSAMP mirror-on-drop 169 encapsulation. */ 170 #define BCM_MIRROR_DEST_FLAGS2_LOOPBACK_ENABLE (1U << 8) /* Enable to mirror 171 packet to loopback 172 port. */ 173 #define BCM_MIRROR_DEST_FLAGS2_TRUE_EGRESS (1U << 9) /* True egress mirroring. */ 174 #define BCM_MIRROR_DEST_FLAGS2_BTE_TIMESTAMP_UPDATE (1U << 10) /* Enable timestamp 175 update in BTE. */ 176 177 /* Flags for bcm_mirror_pkt_header_updates_t. */ 178 #define BCM_MIRROR_PKT_HEADER_UPDATE_COLOR (1 << 0) /* Drop precedence. */ 179 #define BCM_MIRROR_PKT_HEADER_UPDATE_PRIO (1 << 1) /* Internal packet 180 priority. */ 181 #define BCM_MIRROR_PKT_HEADER_UPDATE_ECN_VALUE (1 << 2) /* ECN capable and 182 congestion encoding. */ 183 #define BCM_MIRROR_PKT_HEADER_UPDATE_ECN_CNM_CANCEL (1 << 3) /* Ignore Congestion 184 Point. */ 185 #define BCM_MIRROR_PKT_HEADER_UPDATE_TRUNK_HASH_RESULT (1 << 4) /* LAG load balancing 186 key. */ 187 #define BCM_MIRROR_PKT_HEADER_UPDATE_IN_PORT (1 << 5) /* 8b should be exposed? */ 188 #define BCM_MIRROR_PKT_HEADER_UPDATE_VSQ (1 << 6) /* selects STF 189 (statistics flow) VSQ. */ 190 #define BCM_MIRROR_PKT_HEADER_UPDATE_FABRIC_HEADER_EDITING (1 << 7) /* changes to the fabric 191 headers */ 192 #define BCM_MIRROR_PKT_HEADER_UPDATE_METADATA (1 << 14) /* The metadata for CRPS 193 should be set 194 explicitly updated */ 195 196 /* Flags for mirror NIV tunneling */ 197 #define BCM_MIRROR_NIV_LOOP 1 /* Mirrored packet is a loop in NIV 198 path */ 199 200 /* represents the options for the mirroring of packets */ 201 typedef struct bcm_mirror_options_s { 202 uint32 flags; 203 uint8 forward_strength; 204 uint8 copy_strength; 205 uint32 recycle_cmd; /* dedicated for ETPP traps */ 206 } bcm_mirror_options_t; 207 208 /* Flags for ftmh_valid in bcm_mirror_pkt_header_fabric_t */ 209 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_PACKET_SIZE (1 << 0) /* Packet size. */ 210 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_PRIO (1 << 1) /* Traffic Class. */ 211 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_SRC_SYSPORT (1 << 2) /* Source System port. */ 212 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_DST_PORT (1 << 3) /* Destination local 213 port. */ 214 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_DP (1 << 4) /* Drop precedence. */ 215 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_ACTION_TYPE (1 << 5) /* Action type */ 216 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_OUT_MIRROR_DISABLE (1 << 6) /* Disable Outbound 217 mirroring. */ 218 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_IS_MC_TRAFFIC (1 << 7) /* Indicate if the 219 traffic is multicast */ 220 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_MULTICAST_ID (1 << 8) /* Multicast ID */ 221 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_OUT_VPORT (1 << 9) /* Virtual port */ 222 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_CNI (1 << 10) /* Congestion indication */ 223 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_LB_KEY (1 << 11) /* Load Balancing Key */ 224 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_DST_SYSPORT (1 << 12) /* Destination System 225 Port */ 226 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_STACK_ROUTE (1 << 13) /* Route bitmap to 227 prevent loops in 228 stacking system */ 229 230 /* Flags for oam_ts_valid in bcm_mirror_pkt_header_fabric_t. */ 231 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_TYPE (1 << 0) /* Type */ 232 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_SUB_TYPE (1 << 1) /* OAM-Sub-Type */ 233 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_UP_MEP (1 << 2) /* MEP-Type */ 234 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_TP_CMD (1 << 3) /* TP-Cmd */ 235 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_ENCAPS (1 << 4) /* TS-Encaps */ 236 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_DATA (1 << 5) /* OAM-TS-Data */ 237 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_LATENCY_FLOW_ID (1 << 6) /* Latency flow ID */ 238 #define BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_OFFSET (1 << 7) /* Offset */ 239 240 /* Fabric header updates of mirrored packets */ 241 typedef struct bcm_mirror_pkt_header_fabric_s { 242 uint32 ftmh_valid; /* Used to specify which fields to use 243 for header changes. Possible values 244 will be named 245 BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_FTMH_ */ 246 uint32 internal_valid; /* Used to specify which fields to use 247 for header changes. Possible values 248 will be named 249 BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_INTERNAL_ */ 250 uint32 oam_ts_valid; /* Used to specify which fields to use 251 for header changes. Possible values 252 will be named 253 BCM_MIRROR_PKT_HEADER_FABRIC_UPDATE_OAM_TS_ */ 254 bcm_pkt_dnx_ftmh_t ftmh; /* FTMH header fields */ 255 bcm_pkt_dnx_internal_t internal; /* Internal header fields */ 256 bcm_pkt_dnx_otsh_t oam_ts; /* OAM-TS header fields */ 257 } bcm_mirror_pkt_header_fabric_t; 258 259 /* Flags for bcm_mirror_options_s */ 260 #define BCM_MIRROR_OPTIONS_COPY_DROP (1 << 0) /* drop the copied packet */ 261 #define BCM_MIRROR_OPTIONS_FORWARD_DROP (1 << 1) /* drop the original packet */ 262 263 /* represents header updates of mirrored packets */ 264 typedef struct bcm_mirror_pkt_header_updates_s { 265 uint32 valid; /* Used to specify which fields to use 266 for header changes. Possible values 267 will be named 268 BCM_MIRROR_PKT_HEADER_UPDATE_* */ 269 bcm_color_t color; /* drop precedence */ 270 uint8 prio; /* the internal packet priority (traffic 271 class before ingress mapping to cosq) */ 272 uint8 ecn_value; /* ECN capable and congestion encoding */ 273 uint8 cnm_cancel; /* Ignore Congestion Point (CNM) */ 274 uint32 trunk_hash_result; /* LAG load balancing key */ 275 bcm_gport_t in_port; /* 8b should be exposed? */ 276 uint16 vsq; /* selects STF (statistics flow) VSQ */ 277 uint16 fabric_header_editing; /* changes to the fabric headers */ 278 bcm_mirror_pkt_header_fabric_t header_fabric; /* Fabric header updates of mirrored 279 packets */ 280 uint32 metadata; /* Metadata for counting */ 281 } bcm_mirror_pkt_header_updates_t; 282 283 /* Do not perform truncation or payload zeroing */ 284 #define BCM_MIRROR_PAYLOAD_DO_NOT_TRUNCATE 0 285 286 /* Perform payload truncation of mirrored packets */ 287 #define BCM_MIRROR_PAYLOAD_TRUNCATE 1 288 289 /* Perform payload truncation and zeroing of mirrored packets */ 290 #define BCM_MIRROR_PAYLOAD_TRUNCATE_AND_ZERO 2 291 292 /* 293 * Invalid protocol or port value. Used when there is no associated 294 * protocol or port value for a given offset 295 */ 296 #define BCM_MIRROR_PAYLOAD_ZERO_INVALID_PROTO_PORT 0xFFFFFFFF 297 298 /* Invalid offset value. Used to set a offset field in case of an error */ 299 #define BCM_MIRROR_PAYLOAD_ZERO_INVALID_OFFSET 0xFFFFFFFF 300 301 /* 302 * The following enum defines identifiers for accessing protocol/port 303 * numbers and/or the corresponding offset values for a particular 304 * protocol, or a layer 305 */ 306 typedef enum bcm_mirror_payload_zero_field_e { 307 bcmMirrorPayloadZeroIp4Protocol0 = 0, /* 1st of upto 3 IPv4 protocol values */ 308 bcmMirrorPayloadZeroIp4Protocol1 = 1, /* 2nd of upto 3 IPv4 protocol values */ 309 bcmMirrorPayloadZeroIp4Protocol2 = 2, /* 3rd of upto 3 IPv4 protocol values */ 310 bcmMirrorPayloadZeroIp6NxtHdr0 = 3, /* 1st of upto 3 IPv6 nxthdr values */ 311 bcmMirrorPayloadZeroIp6NxtHdr1 = 4, /* 2nd of upto 3 IPv6 nxthdr values */ 312 bcmMirrorPayloadZeroIp6NxtHdr2 = 5, /* 3rd of upto 3 IPv6 nxthdr values */ 313 bcmMirrorPayloadZeroUdpPort0 = 6, /* First of upto 2 UDP port values */ 314 bcmMirrorPayloadZeroUdpPort1 = 7, /* Second of upto 2 UDP port values */ 315 bcmMirrorPayloadZeroIpInIpOffset = 8, /* IpInIP offset. No corresponding 316 protocol value associated */ 317 bcmMirrorPayloadZeroL2Offset = 9, /* L2 offset. No corresponding protocol 318 value associated */ 319 bcmMirrorPayloadZeroL3Offset = 10, /* L3 offset. No corresponding protocol 320 value associated */ 321 bcmMirrorPayloadZeroMplsOffset = 11, /* MPLS offset. No corresponding 322 protocol value associated */ 323 bcmMirrorPayloadZeroCount = 12 /* Last member, not a usable value */ 324 } bcm_mirror_payload_zero_field_t; 325 326 /* 327 * Structure to pass information from, or to the caller. Used for 328 * accessing protocol/port numbers and/or the corresponding offset values 329 * for a particular protocol, or a layer 330 */ 331 typedef struct bcm_mirror_payload_zero_info_s { 332 bcm_mirror_payload_zero_field_t field_id; /* Identifies protocol or port item to 333 be programmed, or read. Values below 334 belong to this item */ 335 uint32 protocol_port_value; /* Specifies protocol number or port 336 number. Is not valid for all 337 field_id's */ 338 uint32 protocol_port_offset; /* Offset, in bytes, corresponding to 339 field_id. Valid for all field_id's */ 340 } bcm_mirror_payload_zero_info_t; 341 342 /* 343 * Sflow/Psamp hdr's meta data field carries one of the values mentioned 344 * below 345 */ 346 typedef enum bcm_mirror_psamp_fmt2_meta_data_e { 347 bcmMirrorPsampFmt2HeaderZeroes = 0, /* All zeroes */ 348 bcmMirrorPsampFmt2HeaderI2eClassId = 1, /* I2E class id */ 349 bcmMirrorPsampFmt2HeaderNextHopClassId = 2, /* Next hop class id */ 350 bcmMirrorPsampFmt2HeaderUserMeta = 3, /* User meta data (opaque) value */ 351 bcmMirrorPsampFmt2HeaderCount = 4 /* Last member. Not a usable value */ 352 } bcm_mirror_psamp_fmt2_meta_data_t; 353 354 /* Timestamp mode for Mirror encapsulation. */ 355 typedef enum bcm_mirror_timestamp_mode_e { 356 bcmMirrorTimestampModePTP = 0, /* PTP timestamp mode. */ 357 bcmMirrorTimestampModeNTP = 1, /* NTP timestamp mode. */ 358 bcmMirrorTimestampModeCount = 2 /* Must be last. Not a valid value. */ 359 } bcm_mirror_timestamp_mode_t; 360 361 /* Multiple destination IP group. */ 362 typedef int bcm_mirror_multi_dip_group_t; 363 364 /* 365 * Invalid multiple destination IP group (feature disabled). Default 366 * value for multi_dip_group. 367 */ 368 #define BCM_MIRROR_MULTI_DIP_GROUP_INVALID 0 /* Default value for 369 multi_dip_group. */ 370 371 /* Port Selection Criteria for mirroring. */ 372 typedef enum bcm_mirror_psc_e { 373 bcmMirrorPscNone = 0, /* Invalid rtag. */ 374 bcmMirrorPscSrcMac = 1, /* Source MAC address. */ 375 bcmMirrorPscDstMac = 2, /* Destination MAC address. */ 376 bcmMirrorPscSrcDstMac = 3, /* Source+dest MAC address. */ 377 bcmMirrorPscSrcIp = 4, /* Source IP address. */ 378 bcmMirrorPscDstIp = 5, /* Destination IP address. */ 379 bcmMirrorPscSrcDstIp = 6, /* Source+dest IP address. */ 380 bcmMirrorPscCount = 7 /* Must be last. Not a usable value. */ 381 } bcm_mirror_psc_t; 382 383 #define BCM_MIRROR_EXT_STAT_ID_COUNT 4 /* Number of statistic 384 interfaces for mirrored 385 packets. */ 386 387 /* Contains information required for ERSPAN encapsulation header. */ 388 typedef struct bcm_mirror_pkt_erspan_encap_s { 389 uint8 truncated_flag; /* If set to 0x1, the frame copy 390 encapsulated in the ERSPAN packet will be 391 truncated. This should be set if ERSPAN 392 encapsulated frame exceeds the configured 393 MTU. */ 394 uint16 session_id; /* Identification associated with each 395 ERSPAN session. */ 396 uint16 gbp_sid; /* Group Based Policy Source Id */ 397 uint8 hw_id; /* Unique identifier of an ERSPAN engine 398 within a system. */ 399 uint8 timestamp_granularity; /* If it is not set, NTP timestamp will be 400 used. If it is set to 0x1, PTP timestamp 401 will used. */ 402 uint8 optional_hdr; /* Indicates if the optional 403 platform-specific sub-header is present. */ 404 uint8 platform_id; /* Platform identifier to parse the optional 405 platform-specific sub-header. Valid only 406 if optional_hdr is set. */ 407 uint16 user_defined_value; /* To store the user defined field */ 408 uint16 switch_id; /* Identifies a source switch at the 409 receiving end. Valid only if optional_hdr 410 is set and platform_id as 0x5 or 0x6. */ 411 } bcm_mirror_pkt_erspan_encap_t; 412 413 /* Mirror truncate mode. */ 414 typedef enum bcm_mirror_truncate_mode_e { 415 bcmMirrorTruncateDefault = 0, /* Truncate to one cell by default. */ 416 bcmMirrorTruncateAdjustment = 1, /* Adjust payload truncate length. */ 417 bcmMirrorTruncateAdjustFromL2Encap = 2, /* Truncate from the end of L2 418 encapsulation headers with 419 adjustment. */ 420 bcmMirrorTruncateAdjustFromL3L4Encap = 3, /* Truncate from the end of L3 and L4 421 encapsulation headers with 422 adjustment. */ 423 bcmMirrorTruncateAdjustFromL2 = 4, /* Truncate from the end of the known L2 424 headers with adjustment. */ 425 bcmMirrorTruncateAdjustFromL3L4 = 5, /* Truncate from the end of the known L3 426 and L4 headers with adjustment. */ 427 bcmMirrorTruncateToMultipleOf64 = 6, /* Truncate to the size in multiples of 428 64 bytes where adjustment_length 429 specifies the multiplier. */ 430 bcmMirrorTruncateCount = 7 /* Last member, not a usable value. */ 431 } bcm_mirror_truncate_mode_t; 432 433 /* Flags for bcm_mirror_int_probe_header_t. */ 434 #define BCM_MIRROR_INT_PROBE_HEADER_UPDATE_MAX_LENGTH (1 << 0) /* Indicates to fill 435 maximum length field 436 with specified value. */ 437 #define BCM_MIRROR_INT_PROBE_HEADER_UPDATE_HOP_LIMIT (1 << 1) /* Indicates to fill hop 438 limit field with 439 specified value. */ 440 441 /* INT(Inband Network Telemetry) probe header information. */ 442 typedef struct bcm_mirror_int_probe_header_s { 443 uint32 flags; /* See BCM_MIRROR_INT_PROBE_HEADER_xxx flag definitions. */ 444 uint16 max_length; /* Maximum length. */ 445 uint8 hop_limit; /* Hop limit */ 446 } bcm_mirror_int_probe_header_t; 447 448 /* Mirror loopback header type. */ 449 typedef enum bcm_mirror_loopback_header_type_e { 450 bcmMirrorLoopbackHeaderGeneric = 0, /* Generic loopback header. */ 451 bcmMirrorLoopbackHeaderIfa = 1, /* IFA specific loopback header. */ 452 bcmMirrorLoopbackHeaderCount = 2 /* Last member, not a usable value. */ 453 } bcm_mirror_loopback_header_type_t; 454 455 /* 456 * Mirror destination Structure 457 * 458 * Contains information required for manipulating mirror destinations. 459 */ 460 typedef struct bcm_mirror_destination_s { 461 bcm_gport_t mirror_dest_id; /* Unique mirror destination and 462 encapsulation identifier. */ 463 uint32 flags; /* See BCM_MIRROR_DEST_xxx flag 464 definitions. */ 465 bcm_gport_t gport; /* Mirror destination. */ 466 uint8 version; /* IP header version. */ 467 uint8 tos; /* Traffic Class/Tos byte. */ 468 uint8 ttl; /* Hop limit. */ 469 bcm_ip_t src_addr; /* Tunnel source ip address (IPv4). */ 470 bcm_ip_t dst_addr; /* Tunnel destination ip address (IPv4). */ 471 bcm_ip6_t src6_addr; /* Tunnel source ip address (IPv6). */ 472 bcm_ip6_t dst6_addr; /* Tunnel destination ip address (IPv6). */ 473 uint32 flow_label; /* IPv6 header flow label field. */ 474 bcm_mac_t src_mac; /* L2 source mac address. */ 475 bcm_mac_t dst_mac; /* L2 destination mac address. */ 476 uint16 tpid; /* L2 header outer TPID. */ 477 bcm_vlan_t vlan_id; /* Vlan id. */ 478 bcm_trill_name_t trill_src_name; /* TRILL source bridge nickname */ 479 bcm_trill_name_t trill_dst_name; /* TRILL destination bridge nickname */ 480 int trill_hopcount; /* TRILL hop count */ 481 uint16 niv_src_vif; /* Source Virtual Interface of NIV tag */ 482 uint16 niv_dst_vif; /* Destination Virtual Interface of NIV 483 tag */ 484 uint32 niv_flags; /* NIV flags BCM_MIRROR_NIV_XXX */ 485 uint16 gre_protocol; /* L3 GRE header protocol */ 486 bcm_policer_t policer_id; /* policer_id */ 487 int stat_id; /* stat_id */ 488 int stat_id2; /* stat_id2 for second counter pointer */ 489 bcm_if_t encap_id; /* Encapsulation index */ 490 bcm_if_t tunnel_id; /* IP tunnel for encapsulation. Valid 491 only if BCM_MIRROR_DEST_TUNNEL_IP_GRE 492 is set */ 493 uint16 span_id; /* SPAN-ID. Valid only if 494 BCM_MIRROR_DEST_TUNNEL_WITH_SPAN_ID 495 is set */ 496 uint8 pkt_prio; /* L2 header PCP */ 497 uint32 sample_rate_dividend; /* The probability of mirroring a packet 498 is: sample_rate_dividend >= 499 sample_rate_divisor ? 1 : 500 sample_rate_dividend / 501 sample_rate_divisor */ 502 uint32 sample_rate_divisor; 503 uint8 int_pri; /* Internal Priority */ 504 uint16 etag_src_vid; /* Extended (source) port vlan id */ 505 uint16 etag_dst_vid; /* Extended (destination) port vlan id */ 506 uint16 udp_src_port; /* UDP source port */ 507 uint16 udp_dst_port; /* UDP destination port */ 508 uint32 egress_sample_rate_dividend; /* The probability of outbound mirroring 509 a packet from the destination is 510 sample_rate_dividend >= 511 sample_rate_divisor ? 1 : 512 sample_rate_dividend / 513 sample_rate_divisor */ 514 uint32 egress_sample_rate_divisor; 515 uint8 recycle_context; /* recycle context of egress originating 516 packets */ 517 uint16 packet_copy_size; /* If non zero, the copied packet will 518 be truncated to the first 519 packet_copy_size . Current supported 520 values for DNX are 0, 64, 128, 192 */ 521 uint16 egress_packet_copy_size; /* If non zero and the packet is copied 522 from the egress, the packet will be 523 truncated to the first 524 packet_copy_size . Current supported 525 values for DNX are 0, 256. */ 526 bcm_mirror_pkt_header_updates_t packet_control_updates; 527 bcm_mirror_psc_t rtag; /* specify RTAG HASH algorithm used for 528 shared-id mirror destination */ 529 uint8 df; /* Set the do not fragment bit of IP 530 header in mirror encapsulation */ 531 uint8 truncate; /* Setting truncate would result in 532 mirroring a truncated frame */ 533 uint16 template_id; /* Template ID for IPFIX HDR */ 534 uint32 observation_domain; /* Observation domain for IPFIX HDR */ 535 uint32 is_recycle_strict_priority; /* Recycle priority (1-lossless, 0-high) */ 536 int ext_stat_id[BCM_MIRROR_EXT_STAT_ID_COUNT]; /* ext_stat_id to support statistic 537 interface for mirror packets. */ 538 uint32 flags2; /* See BCM_MIRROR_DEST_FLAGS2_xxx flag 539 definitions. */ 540 uint32 vni; /* Virtual Network Interface ID. */ 541 uint32 gre_seq_number; /* Sequence number value used in GRE 542 header. If no value is provided, 543 gre_seq_number will start with 0. 544 Valid only if 545 BCM_MIRROR_DEST_TUNNEL_IP_GRE is set. */ 546 bcm_mirror_pkt_erspan_encap_t erspan_header; /* ERSPAN encapsulation header fields. 547 Valid only if only 548 BCM_MIRROR_DEST_TUNNEL_IP_GRE is set. */ 549 uint32 initial_seq_number; /* Starting seq number in SFLOW or PSAMP 550 header */ 551 bcm_mirror_psamp_fmt2_meta_data_t meta_data_type; /* Type of item in 'meta_data' */ 552 uint16 meta_data; /* Actual value of class id or meta 553 data, based on 'meta_data_type' */ 554 int ext_stat_valid; /* Validates the ext_stat. */ 555 int ext_stat_type_id[BCM_MIRROR_EXT_STAT_ID_COUNT]; /* Type ids for statistic interface. */ 556 uint16 ipfix_version; /* IPFIX version number in PSAMP 557 encapsulation. */ 558 uint16 psamp_epoch; /* PSAMP epoch field. */ 559 int cosq; /* Queue id that mirror copy is enqueued 560 into. */ 561 uint8 cfi; /* CFI of VLAN tag. */ 562 bcm_mirror_timestamp_mode_t timestamp_mode; /* Set timestamp mode for mirror 563 encapsulation. */ 564 bcm_mirror_multi_dip_group_t multi_dip_group; /* Multiple destination IP group. */ 565 int drop_group_bmp; 566 bcm_port_t second_pass_src_port; /* Source port in the second pass. */ 567 bcm_mirror_truncate_mode_t encap_truncate_mode; /* Truncate mode for mirror 568 encapsulation packets. */ 569 int encap_truncate_profile_id; /* Truncate length profile ID for mirror 570 encapsulation packets. */ 571 bcm_mirror_loopback_header_type_t loopback_header_type; /* Loopback header type. */ 572 bcm_port_t second_pass_dst_port; /* Destination port in the second pass. */ 573 bcm_mirror_int_probe_header_t int_probe_header; /* INT(Inband Network Telemetry) probe 574 header for mirror encapsulation 575 packets. */ 576 uint8 duplicate_pri; /* The priority of duplicate mirror 577 packets. The packet with highest 578 priority (0 is lowest) will be 579 mirrored and others will be dropped. 580 Applicable only if duplication is not 581 allowed. */ 582 int ip_proto; /* IP Protocol number in ERSPAN IP 583 encap. */ 584 } bcm_mirror_destination_t; 585 586 /* Mirror destination callback function prototype. */ 587 typedef int (*bcm_mirror_destination_traverse_cb)( 588 int unit, 589 bcm_mirror_destination_t *mirror_dest, 590 void *user_data); 591 592 #ifndef BCM_HIDE_DISPATCHABLE 593 594 /* Initialize the mirroring module to its initial configuration. */ 595 extern int bcm_mirror_init( 596 int unit); 597 598 /* Set the current mirroring mode for the device. */ 599 extern int bcm_mirror_mode_set( 600 int unit, 601 int mode); 602 603 #endif /* BCM_HIDE_DISPATCHABLE */ 604 605 /* 606 * extended versions of existing _dest_ APIs using a bcm_mirror_options_t 607 * argument 608 */ 609 extern void bcm_mirror_options_t_init( 610 bcm_mirror_options_t *mirror_dest); 611 612 /* Initialized bcm_mirror_pkt_header_updates_t struct */ 613 extern void bcm_mirror_pkt_header_updates_t_init( 614 bcm_mirror_pkt_header_updates_t *mirror_dest); 615 616 /* Initialize a bcm_mirror_int_probe_header_t struct */ 617 extern void bcm_mirror_int_probe_header_t_init( 618 bcm_mirror_int_probe_header_t *header); 619 620 /* Initialize a mirror destination structure. */ 621 extern void bcm_mirror_destination_t_init( 622 bcm_mirror_destination_t *mirror_dest); 623 624 #ifndef BCM_HIDE_DISPATCHABLE 625 626 /* Add mirror destination descriptor. */ 627 extern int bcm_mirror_destination_create( 628 int unit, 629 bcm_mirror_destination_t *mirror_dest); 630 631 /* Read content of mirror destination descriptor */ 632 extern int bcm_mirror_destination_get( 633 int unit, 634 bcm_gport_t mirror_dest_id, 635 bcm_mirror_destination_t *mirror_dest); 636 637 /* Remove mirror destination descriptor. */ 638 extern int bcm_mirror_destination_destroy( 639 int unit, 640 bcm_gport_t mirror_dest_id); 641 642 /* Traverse over all installed mirror destination descriptors. */ 643 extern int bcm_mirror_destination_traverse( 644 int unit, 645 bcm_mirror_destination_traverse_cb cb, 646 void *user_data); 647 648 /* Get the current mirroring mode for the device. */ 649 extern int bcm_mirror_mode_get( 650 int unit, 651 int *mode); 652 653 /* Set the mirror-to port for the device. */ 654 extern int bcm_mirror_to_set( 655 int unit, 656 bcm_port_t port); 657 658 /* Get the mirror-to port for the device. */ 659 extern int bcm_mirror_to_get( 660 int unit, 661 bcm_port_t *port); 662 663 /* Enable or Disable ingress mirroring for a port on the device. */ 664 extern int bcm_mirror_ingress_set( 665 int unit, 666 bcm_port_t port, 667 int val); 668 669 /* 670 * Get the ingress mirroring enabled/disabled status for a port on the 671 * device. 672 */ 673 extern int bcm_mirror_ingress_get( 674 int unit, 675 bcm_port_t port, 676 int *val); 677 678 /* Enable or Disable egress mirroring for a port on the device. */ 679 extern int bcm_mirror_egress_set( 680 int unit, 681 bcm_port_t port, 682 int val); 683 684 /* 685 * Get the egress mirroring enabled/disabled status for a port on the 686 * device. 687 */ 688 extern int bcm_mirror_egress_get( 689 int unit, 690 bcm_port_t port, 691 int *val); 692 693 /* Set the mirror-to port bitmap for the device. */ 694 extern int bcm_mirror_to_pbmp_set( 695 int unit, 696 bcm_port_t port, 697 bcm_pbmp_t pbmp); 698 699 /* Get the mirror-to port bitmap for the device. */ 700 extern int bcm_mirror_to_pbmp_get( 701 int unit, 702 bcm_port_t port, 703 bcm_pbmp_t *pbmp); 704 705 /* Set mirroring configuration for a port. */ 706 extern int bcm_mirror_port_set( 707 int unit, 708 bcm_port_t port, 709 bcm_module_t dest_mod, 710 bcm_port_t dest_port, 711 uint32 flags); 712 713 /* Get mirroring configuration for a port. */ 714 extern int bcm_mirror_port_get( 715 int unit, 716 bcm_port_t port, 717 bcm_module_t *dest_mod, 718 bcm_port_t *dest_port, 719 uint32 *flags); 720 721 /* Set VLAN for egressing mirrored packets on a port (RSPAN). */ 722 extern int bcm_mirror_vlan_set( 723 int unit, 724 bcm_port_t port, 725 uint16 tpid, 726 uint16 vlan); 727 728 /* Get VLAN for egressing mirrored packets on a port (RSPAN). */ 729 extern int bcm_mirror_vlan_get( 730 int unit, 731 bcm_port_t port, 732 uint16 *tpid, 733 uint16 *vlan); 734 735 /* Add mirroring destination to a port */ 736 extern int bcm_mirror_port_dest_add( 737 int unit, 738 bcm_port_t port, 739 uint32 flags, 740 bcm_gport_t mirror_dest_id); 741 742 /* 743 * extended versions of existing _dest_ APIs using a bcm_mirror_options_t 744 * argument 745 */ 746 extern int bcm_mirror_port_destination_add( 747 int unit, 748 bcm_port_t port, 749 uint32 flags, 750 bcm_gport_t mirror_dest, 751 bcm_mirror_options_t options); 752 753 /* Delete mirroring destination from a port */ 754 extern int bcm_mirror_port_dest_delete( 755 int unit, 756 bcm_port_t port, 757 uint32 flags, 758 bcm_gport_t mirror_dest_id); 759 760 /* Delete all mirroring destinations from a port */ 761 extern int bcm_mirror_port_dest_delete_all( 762 int unit, 763 bcm_port_t port, 764 uint32 flags); 765 766 /* Get port mirroring destinations */ 767 extern int bcm_mirror_port_dest_get( 768 int unit, 769 bcm_port_t port, 770 uint32 flags, 771 int mirror_dest_size, 772 bcm_gport_t *mirror_dest, 773 int *mirror_dest_count); 774 775 /* 776 * extended versions of existing _dest_ APIs using a bcm_mirror_options_t 777 * argument 778 */ 779 extern int bcm_mirror_port_destination_get( 780 int unit, 781 bcm_port_t port, 782 uint32 flags, 783 int mirror_dest_size, 784 bcm_gport_t *mirror_dest, 785 int *mirror_dest_count, 786 bcm_mirror_options_t *options); 787 788 #endif /* BCM_HIDE_DISPATCHABLE */ 789 790 /* Backward compatibility. */ 791 #define bcm_mirror_mode bcm_mirror_mode_set 792 793 #ifndef BCM_HIDE_DISPATCHABLE 794 795 /* Set mirroring configuration for a port-vlan. */ 796 extern int bcm_mirror_port_vlan_set( 797 int unit, 798 bcm_port_t port, 799 bcm_vlan_t vlan, 800 bcm_gport_t destport, 801 uint32 flags); 802 803 /* Get mirroring configuration for a port-vlan */ 804 extern int bcm_mirror_port_vlan_get( 805 int unit, 806 bcm_port_t port, 807 bcm_vlan_t vlan, 808 bcm_gport_t *dest_port, 809 uint32 *flags); 810 811 /* Add mirroring destination to a port-vlan */ 812 extern int bcm_mirror_port_vlan_dest_add( 813 int unit, 814 bcm_port_t port, 815 bcm_vlan_t vlan, 816 uint32 flags, 817 bcm_gport_t destid); 818 819 /* 820 * extended versions of existing _dest_ APIs using a bcm_mirror_options_t 821 * argument 822 */ 823 extern int bcm_mirror_port_vlan_destination_add( 824 int unit, 825 bcm_port_t port, 826 bcm_vlan_t vlan, 827 uint32 flags, 828 bcm_gport_t destid, 829 bcm_mirror_options_t options); 830 831 /* Delete mirroring destination from a port-vlan */ 832 extern int bcm_mirror_port_vlan_dest_delete( 833 int unit, 834 bcm_port_t port, 835 bcm_vlan_t vlan, 836 uint32 flags, 837 bcm_gport_t destid); 838 839 /* Delete all mirroring destinations from a port-vlan. */ 840 extern int bcm_mirror_port_vlan_dest_delete_all( 841 int unit, 842 bcm_port_t port, 843 bcm_vlan_t vlan, 844 uint32 flags); 845 846 /* Get port-vlan mirroring destinations */ 847 extern int bcm_mirror_port_vlan_dest_get( 848 int unit, 849 bcm_port_t port, 850 bcm_vlan_t vlan, 851 uint32 flags, 852 uint32 mirror_dest_size, 853 bcm_gport_t *destid, 854 uint32 *destcount); 855 856 /* 857 * extended versions of existing _dest_ APIs using a bcm_mirror_options_t 858 * argument 859 */ 860 extern int bcm_mirror_port_vlan_destination_get( 861 int unit, 862 bcm_port_t port, 863 bcm_vlan_t vlan, 864 uint32 flags, 865 uint32 mirror_dest_size, 866 bcm_gport_t *destid, 867 uint32 *destcount, 868 bcm_mirror_options_t *options); 869 870 /* Set values of one or more payload zeroing parameters. */ 871 extern int bcm_mirror_payload_zero_control_multi_set( 872 int unit, 873 bcm_mirror_payload_zero_info_t *payload_zero_config_array, 874 int num_configs); 875 876 /* Get values of one or more payload zeroing parameters. */ 877 extern int bcm_mirror_payload_zero_control_multi_get( 878 int unit, 879 bcm_mirror_payload_zero_info_t *payload_zero_config_array, 880 int num_configs); 881 882 #endif /* BCM_HIDE_DISPATCHABLE */ 883 884 /* Initialize a payload zero information structure. */ 885 extern void bcm_mirror_payload_zero_info_t_init( 886 bcm_mirror_payload_zero_info_t *info); 887 888 /* 889 * Mirror port Structure 890 * 891 * Contains information required for mirror port settings. 892 */ 893 typedef struct bcm_mirror_port_info_s { 894 bcm_gport_t mirror_system_id; /* Unique mirror System identifier. */ 895 } bcm_mirror_port_info_t; 896 897 /* Initialize a mirror port information structure. */ 898 extern void bcm_mirror_port_info_t_init( 899 bcm_mirror_port_info_t *info); 900 901 #ifndef BCM_HIDE_DISPATCHABLE 902 903 /* Set mirroring information per port. */ 904 extern int bcm_mirror_port_info_set( 905 int unit, 906 bcm_port_t port, 907 uint32 flags, 908 bcm_mirror_port_info_t *info); 909 910 /* Get mirroring information per port. */ 911 extern int bcm_mirror_port_info_get( 912 int unit, 913 bcm_port_t port, 914 uint32 flags, 915 bcm_mirror_port_info_t *info); 916 917 #endif /* BCM_HIDE_DISPATCHABLE */ 918 919 /* 920 * Invalid mirror/snoop profile value, used in bcm_mirror_port_dest_get 921 * and bcm_mirror_destination_get 922 */ 923 #define BCM_MIRROR_INVALID_PROFILE 0xffff /* Invalid mirror/snoop profile 924 value */ 925 926 #define BCM_MIRROR_DROP_GROUP_BMP_ALL -1 /* Map all mirror on drop 927 profile to the same 928 profile. */ 929 930 /* 931 * Value to disable counting of the snooped/mirrored copy, used in 932 * bcm_mirror_destination_create when flags 933 * BCM_MIRROR_DEST_UPDATE_COUNTER_1 and BCM_MIRROR_DEST_UPDATE_COUNTER_2 934 * are given. 935 */ 936 #define BCM_MIRROR_DEST_NO_COUNT -2 /* Value to disable counting of 937 the snooped/mirrored copy. */ 938 939 /* 940 * Default value to be used for Template id for the IPFIX header in case 941 * of PSAMP. 942 */ 943 #define BCM_MIRROR_IPFIX_TEMPLATE_ID_DFLT 0x1234 /* Default value to be 944 used for Template id. */ 945 946 /* 947 * Default value to be used for Template id for the IPFIX header in case 948 * of PSAMP. 949 */ 950 #define BCM_MIRROR_IPFIX_OBSERVATION_DOMAIN_DFLT 100 /* Default value to be 951 used for observation 952 domain. */ 953 954 /* Info about mirror port and priorities */ 955 typedef struct bcm_mirror_port_to_rcy_map_info_s { 956 bcm_port_t rcy_mirror_port; /* Mirror port */ 957 uint32 priority_bitmap; /* Used to specify which priorities to map. 958 Possible values will be named 959 BCM_MIRROR_PORT_TO_RCY_MAP_INFO_PRIORITY_ */ 960 } bcm_mirror_port_to_rcy_map_info_t; 961 962 #ifndef BCM_HIDE_DISPATCHABLE 963 964 /* 965 * Map/unmap forward port to recycle mirror port (to unmap set 966 * rcy_mirror_port to BCM_MIRROR_INVALID_RCY_PORT) 967 */ 968 extern int bcm_mirror_port_to_rcy_port_map_set( 969 int unit, 970 uint32 flags, 971 bcm_port_t forward_port, 972 bcm_mirror_port_to_rcy_map_info_t *rcy_map_info); 973 974 /* Get recycle mirror port from forward port. */ 975 extern int bcm_mirror_port_to_rcy_port_map_get( 976 int unit, 977 uint32 flags, 978 bcm_port_t forward_port, 979 bcm_mirror_port_to_rcy_map_info_t *rcy_map_info); 980 981 #endif /* BCM_HIDE_DISPATCHABLE */ 982 983 #define BCM_MIRROR_PORT_TO_RCY_MAP_INFO_PRIORITY_NORMAL 0x00000001 /* Assign the port to 984 normal priority 985 recycle context. */ 986 #define BCM_MIRROR_PORT_TO_RCY_MAP_INFO_PRIORITY_HIGH 0x00000002 /* Assign the port to 987 high priority recycle 988 context. */ 989 990 /* Mirror profile counting parameters for command. */ 991 typedef struct bcm_mirror_profile_cmd_count_s { 992 int is_counted; /* Is the mirror packet should be counted for this 993 command. */ 994 int object_stat_id; /* Statistic id to be counted for this command. */ 995 int type_id; /* Type id to be counted for this command. */ 996 int is_meter; /* Object is meter or crps. */ 997 } bcm_mirror_profile_cmd_count_t; 998 999 #define BCM_MIRROR_COUNT_AS_ORIG -1 1000 1001 #define BCM_MIRROR_PORT_DELETE_ALL 0x00000400 /* Delete all destinations */ 1002 1003 #ifndef BCM_HIDE_DISPATCHABLE 1004 1005 extern int bcm_mirror_destination_count_command_get( 1006 int unit, 1007 bcm_core_t core_id, 1008 bcm_gport_t mirror_dest_id, 1009 int counter_cmd_id, 1010 uint32 flags, 1011 bcm_mirror_profile_cmd_count_t *mirror_count_info); 1012 1013 extern int bcm_mirror_destination_count_command_set( 1014 int unit, 1015 bcm_core_t core_id, 1016 bcm_gport_t mirror_dest_id, 1017 int counter_cmd_id, 1018 uint32 flags, 1019 bcm_mirror_profile_cmd_count_t *mirror_count_info); 1020 1021 #endif /* BCM_HIDE_DISPATCHABLE */ 1022 1023 /* TM header information for mirrored packet in DNX devices */ 1024 typedef struct bcm_mirror_pkt_dnx_ftmh_header_s { 1025 bcm_gport_t src_sysport; /* Source System port */ 1026 uint8 tc; /* Traffic class */ 1027 uint8 dp; /* Drop precedence */ 1028 uint8 is_mc_traffic; /* Destination is multicast */ 1029 bcm_multicast_t mc_id; /* Destination Multicast ID (when 1030 is_mc_traffic is set) */ 1031 bcm_gport_t out_vport; /* Destination Outlif (when 1032 is_mc_traffic is cleared) */ 1033 bcm_pkt_dnx_ftmh_ase_extension_t ase_ext; /* FTMH Application Specific Extension */ 1034 bcm_pkt_dnx_ftmh_flow_id_extension_t flow_id_ext; /* FTMH Flow-ID Extension */ 1035 } bcm_mirror_pkt_dnx_ftmh_header_t; 1036 1037 /* PP header information for mirrored packet in DNX devices */ 1038 typedef struct bcm_mirror_pkt_dnx_pp_header_s { 1039 uint8 tail_edit_profile; /* Tail edit profile, used at ETPP for tail 1040 editing */ 1041 uint8 eth_header_remove; /* Indication to remove Ethernet header from 1042 mirror copy */ 1043 bcm_gport_t out_vport_ext[3]; /* Extended outlif(s) */ 1044 } bcm_mirror_pkt_dnx_pp_header_t; 1045 1046 /* Mirror packet system header information for DNX devices */ 1047 typedef struct bcm_mirror_header_info_s { 1048 bcm_mirror_pkt_dnx_ftmh_header_t tm; /* TM header */ 1049 bcm_mirror_pkt_dnx_pp_header_t pp; /* PP header */ 1050 bcm_pkt_dnx_udh_t udh[4]; /* UDH header */ 1051 } bcm_mirror_header_info_t; 1052 1053 /* Initialize a bcm_mirror_header_info_t structure. */ 1054 extern void bcm_mirror_header_info_t_init( 1055 bcm_mirror_header_info_t *mirror_header_info); 1056 1057 #ifndef BCM_HIDE_DISPATCHABLE 1058 1059 /* Set system header information */ 1060 extern int bcm_mirror_header_info_set( 1061 int unit, 1062 uint32 flags, 1063 bcm_gport_t mirror_dest_id, 1064 bcm_mirror_header_info_t *mirror_header_info); 1065 1066 /* Get system header information */ 1067 extern int bcm_mirror_header_info_get( 1068 int unit, 1069 bcm_gport_t mirror_dest_id, 1070 uint32 *flags, 1071 bcm_mirror_header_info_t *mirror_header_info); 1072 1073 #endif /* BCM_HIDE_DISPATCHABLE */ 1074 1075 /* Denotes that profile is used by Field Processor Module */ 1076 #define BCM_MIRROR_PAYLOAD_ZERO_FP (1 << 0) 1077 1078 /* Mirror Payload Zeroing Profile Information */ 1079 typedef struct bcm_mirror_payload_zero_offsets_s { 1080 int l2_offset; /* offset from the end of the known L2 headers to 1081 start zeroing */ 1082 int l3_offset; /* offset from the end of the known L3 headers to 1083 start zeroing for non-UDP packets */ 1084 int udp_offset; /* offset from the end of the known L3 headers to 1085 start zeroing for UDP packets */ 1086 int l2_offset_disable; /* disable zeroing the truncated mirrored packets 1087 from the end of the known L2 header */ 1088 int l3_offset_disable; /* disable zeroing the truncated mirrored non-UDP 1089 packets from the end of the known L3 header */ 1090 int udp_offset_disable; /* disable zeroing the truncated mirrored UDP 1091 packets from the end of the known L3 header */ 1092 } bcm_mirror_payload_zero_offsets_t; 1093 1094 #ifndef BCM_HIDE_DISPATCHABLE 1095 1096 /* Creates a profile for Payload Zeroing. */ 1097 extern int bcm_mirror_payload_zero_profile_create( 1098 int unit, 1099 bcm_mirror_payload_zero_offsets_t *mirror_payload_offset_info, 1100 uint32 flags, 1101 uint32 *profile_index); 1102 1103 /* 1104 * Deletes a created profile for Payload Zeroing. 1105 * Please make sure that all related configurations 1106 * in other dependent modules like Field 1107 * need to be cleaned up before calling the destroy. 1108 * Otherwise the related configs will become stale/improper 1109 * entries in the dependent modules. 1110 */ 1111 extern int bcm_mirror_payload_zero_profile_destroy( 1112 int unit, 1113 uint32 flags, 1114 uint32 profile_index); 1115 1116 #endif /* BCM_HIDE_DISPATCHABLE */ 1117 1118 /* Initialize a bcm_mirror_payload_zero_offsets_t structure. */ 1119 extern void bcm_mirror_payload_zero_offsets_t_init( 1120 bcm_mirror_payload_zero_offsets_t *mirror_payload_zero_offset); 1121 1122 /* Sample type. */ 1123 typedef enum bcm_mirror_sample_type_e { 1124 bcmMirrorSampleTypeIngress = 0, /* Ingress sample. */ 1125 bcmMirrorSampleTypeFlex = 1, /* Flex sample. */ 1126 bcmMirrorSampleTypeCount = 2 /* The last one, not valid. */ 1127 } bcm_mirror_sample_type_t; 1128 1129 /* Sample mirror mode. */ 1130 typedef enum bcm_mirror_sample_mirror_mode_e { 1131 bcmMirrorSampleMirrorModeNone = 0, /* No mirror. */ 1132 bcmMirrorSampleMirrorModeBelowRate = 1, /* Mirror packets below sample rate. */ 1133 bcmMirrorSampleMirrorModeAboveRate = 2, /* Mirror packets above sample rate. */ 1134 bcmMirrorSampleMirrorModeCount = 3 /* The last one, not valid. */ 1135 } bcm_mirror_sample_mirror_mode_t; 1136 1137 /* Sample profile structure. */ 1138 typedef struct bcm_mirror_sample_profile_s { 1139 uint8 enable; /* Sample enable. */ 1140 uint32 rate; /* Sample rate. */ 1141 uint8 pool_count_enable; /* Enable to count the packets seen by 1142 the sampler. */ 1143 uint8 sample_count_enable; /* Enable to count the packets sampled 1144 by the sampler. */ 1145 uint8 trace_enable; /* Enable to generate trace event. */ 1146 bcm_mirror_sample_mirror_mode_t mirror_mode; /* Sample mirror mode. */ 1147 } bcm_mirror_sample_profile_t; 1148 1149 /* Initialize a sample profile structure. */ 1150 extern void bcm_mirror_sample_profile_t_init( 1151 bcm_mirror_sample_profile_t *profile); 1152 1153 /* Sample profile option flags. */ 1154 #define BCM_MIRROR_SAMPLE_PROFILE_OPTIONS_WITH_ID 0x00000001 /* Create sample profile 1155 with id. */ 1156 1157 #ifndef BCM_HIDE_DISPATCHABLE 1158 1159 /* Create a sample profile. */ 1160 extern int bcm_mirror_sample_profile_create( 1161 int unit, 1162 uint32 options, 1163 bcm_mirror_sample_type_t type, 1164 int *profile_id); 1165 1166 /* Destroy a sample profile. */ 1167 extern int bcm_mirror_sample_profile_destroy( 1168 int unit, 1169 bcm_mirror_sample_type_t type, 1170 int profile_id); 1171 1172 /* Set sample profile entry with given profile id and type. */ 1173 extern int bcm_mirror_sample_profile_set( 1174 int unit, 1175 bcm_mirror_sample_type_t type, 1176 int profile_id, 1177 bcm_mirror_sample_profile_t *profile); 1178 1179 /* Get sample profile entry with given profile id and type. */ 1180 extern int bcm_mirror_sample_profile_get( 1181 int unit, 1182 bcm_mirror_sample_type_t type, 1183 int profile_id, 1184 bcm_mirror_sample_profile_t *profile); 1185 1186 /* Attach counter entries to a sample type. */ 1187 extern int bcm_mirror_sample_stat_attach( 1188 int unit, 1189 bcm_mirror_sample_type_t type, 1190 uint32 stat_counter_id); 1191 1192 /* Detach counter entries from a sample type. */ 1193 extern int bcm_mirror_sample_stat_detach( 1194 int unit, 1195 bcm_mirror_sample_type_t type, 1196 uint32 stat_counter_id); 1197 1198 #endif /* BCM_HIDE_DISPATCHABLE */ 1199 1200 /* Mirror source type enum. */ 1201 typedef enum bcm_mirror_source_type_e { 1202 bcmMirrorSourceTypePort = 0, /* Port/gport type. */ 1203 bcmMirrorSourceTypePktTraceEvent = 1, /* Packet trace event type. */ 1204 bcmMirrorSourceTypePktDropEvent = 2, /* Packet drop event type. */ 1205 bcmMirrorSourceTypeCosqMod = 3, /* MMU mirror-on-drop type. */ 1206 bcmMirrorSourceTypeSampleIngress = 4, /* Ingress sample type. */ 1207 bcmMirrorSourceTypeSampleFlex = 5, /* Flex sample type. */ 1208 bcmMirrorSourceTypeIngressMod = 6, /* Ingress mirror-on-drop type. */ 1209 bcmMirrorSourceTypeEpRecirc = 7, /* EP Recirculate type. */ 1210 bcmMirrorSourceTypeCount = 8 /* Must Be Last. Not a valid value. */ 1211 } bcm_mirror_source_type_t; 1212 1213 /* Mirror source flags. */ 1214 #define BCM_MIRROR_SOURCE_INGRESS 0x00000001 /* Ingress Mirroring. */ 1215 #define BCM_MIRROR_SOURCE_EGRESS 0x00000002 /* Egress Mirroring. */ 1216 1217 /* Mirror source structure. */ 1218 typedef struct bcm_mirror_source_s { 1219 bcm_mirror_source_type_t type; /* Mirror source type. */ 1220 uint32 flags; /* Mirror source flags only with port 1221 source type. */ 1222 bcm_port_t port; /* Port/gport id. */ 1223 bcm_pkt_trace_event_t trace_event; /* Trace event. */ 1224 bcm_pkt_drop_event_t drop_event; /* Drop event. */ 1225 int mod_profile_id; /* Mirror-on-drop profile id. */ 1226 uint32 sample_profile_id; /* Sample profile id. */ 1227 int ep_recirc_profile_id; /* EP Recirculate profile id. */ 1228 } bcm_mirror_source_t; 1229 1230 /* Initialize mirror source structure. */ 1231 extern void bcm_mirror_source_t_init( 1232 bcm_mirror_source_t *source); 1233 1234 #ifndef BCM_HIDE_DISPATCHABLE 1235 1236 /* Add a mirror destination to a mirror source. */ 1237 extern int bcm_mirror_source_dest_add( 1238 int unit, 1239 bcm_mirror_source_t *source, 1240 bcm_gport_t mirror_dest_id); 1241 1242 /* Delete a mirror destination from a mirror source. */ 1243 extern int bcm_mirror_source_dest_delete( 1244 int unit, 1245 bcm_mirror_source_t *source, 1246 bcm_gport_t mirror_dest_id); 1247 1248 /* Delete all mirror destinations applied on a mirror source. */ 1249 extern int bcm_mirror_source_dest_delete_all( 1250 int unit, 1251 bcm_mirror_source_t *source); 1252 1253 /* Get all mirror destinations applied on a mirror source. */ 1254 extern int bcm_mirror_source_dest_get_all( 1255 int unit, 1256 bcm_mirror_source_t *source, 1257 int array_size, 1258 bcm_gport_t *mirror_dest, 1259 int *count); 1260 1261 #endif /* BCM_HIDE_DISPATCHABLE */ 1262 1263 /* Mirror statistics object structure. */ 1264 typedef struct bcm_mirror_stat_object_s { 1265 uint32 source_flags; /* Mirror source flags. */ 1266 bcm_gport_t mirror_dest_id; /* Mirror destination id. */ 1267 } bcm_mirror_stat_object_t; 1268 1269 /* Initialize mirror statistics object structure. */ 1270 extern void bcm_mirror_stat_object_t_init( 1271 bcm_mirror_stat_object_t *object); 1272 1273 /* Mirror statistics type enum. */ 1274 typedef enum bcm_mirror_stat_e { 1275 bcmMirrorStatPackets = 0, /* Packet statistics. */ 1276 bcmMirrorStatCount = 1 /* Max value defined for this enum. */ 1277 } bcm_mirror_stat_t; 1278 1279 #ifndef BCM_HIDE_DISPATCHABLE 1280 1281 /* Get statistics counter for specific mirror statistics object and type. */ 1282 extern int bcm_mirror_stat_get( 1283 int unit, 1284 bcm_mirror_stat_object_t *object, 1285 bcm_mirror_stat_t type, 1286 uint64 *value); 1287 1288 /* Get statistics counter for specific mirror statistics object and type. */ 1289 extern int bcm_mirror_stat_sync_get( 1290 int unit, 1291 bcm_mirror_stat_object_t *object, 1292 bcm_mirror_stat_t type, 1293 uint64 *value); 1294 1295 /* Set statistics counter for specific mirror statistics object and type. */ 1296 extern int bcm_mirror_stat_set( 1297 int unit, 1298 bcm_mirror_stat_object_t *object, 1299 bcm_mirror_stat_t type, 1300 uint64 value); 1301 1302 #endif /* BCM_HIDE_DISPATCHABLE */ 1303 1304 /* Ingress mirror-on-drop event type enum. */ 1305 typedef enum bcm_mirror_ingress_mod_event_e { 1306 bcmMirrorIngModEventInvalidVlan = 0, /* Enable to select packets dropped due 1307 to invalid VLAN. */ 1308 bcmMirrorIngModEventTagUntagDiscard = 1, /* Enable to count packets dropped due 1309 to port configuration for dropping 1310 all tagged packets or untagged 1311 packets. */ 1312 bcmMirrorIngModEventInvalidTpid = 2, /* Enable to select packets dropped due 1313 to TPID mismatch. */ 1314 bcmMirrorIngModEventPvlanVidMismatch = 3, /* Enable to select packets dropped due 1315 to PVLAN VID mismatch. */ 1316 bcmMirrorIngModEventPortIngVlanMembership = 4, /* Enable to select packets dropped due 1317 to ingress port not in VLAN 1318 membership */ 1319 bcmMirrorIngModEventVlanCcOrPbt = 5, /* Enable to select VLAN cross-connect 1320 drop. */ 1321 bcmMirrorIngModEventVlanFp = 6, /* Enable to select packets dropped due 1322 to VLAN FP. */ 1323 bcmMirrorIngModEventMcIndexErr = 7, /* Enable to select packets with 1324 multicast index error. */ 1325 bcmMirrorIngModEventMplsTtlCheckFail = 8, /* Enable to select packets dropped due 1326 to MPLS TTL check fail. */ 1327 bcmMirrorIngModEventMplsLabelMiss = 9, /* Enable to select packets dropped due 1328 to MPLS label lookup miss. */ 1329 bcmMirrorIngModEventMplsInvalidPayload = 10, /* Enable to select packets dropped due 1330 to MPLS invalid payload. */ 1331 bcmMirrorIngModEventMplsInvalidCw = 11, /* Enable to select packets dropped due 1332 to MPLS invalid control word. */ 1333 bcmMirrorIngModEventMplsInvalidAction = 12, /* Enable to select packets dropped due 1334 to MPLS invalid action. */ 1335 bcmMirrorIngModEventMplsGalLabel = 13, /* Enable to select packets dropped due 1336 to MPLS generic associated label 1337 lookup miss. */ 1338 bcmMirrorIngModEventTnlDecapEcnDrop = 14, /* Enable to select tunnel decap ECN 1339 error drop. */ 1340 bcmMirrorIngModEventTimeSyncDrop = 15, /* Enable to select time sync drop. */ 1341 bcmMirrorIngModEventSrcRoute = 16, /* Enable to select packets dropped due 1342 to source route. */ 1343 bcmMirrorIngModEventSpanningTreeState = 17, /* Enable to select packets dropped due 1344 to spanning tree. */ 1345 bcmMirrorIngModEventTnlErr = 18, /* Enable to select packets dropped due 1346 to tunnel errors. */ 1347 bcmMirrorIngModEventProtectionDataDrop = 19, /* Enable to select packets dropped due 1348 to protection. */ 1349 bcmMirrorIngModEventNhopDrop = 20, /* Enable to select packets dropped due 1350 to next hop indication. */ 1351 bcmMirrorIngModEventFpIngDrop = 21, /* Enable to select packets dropped due 1352 to ingress FP drop. */ 1353 bcmMirrorIngModEventFpRedirectDrop = 22, /* Enable to select packets dropped due 1354 to invalid FP redirection. */ 1355 bcmMirrorIngModEventEcmpResolutionErr = 23, /* Enable to select packets dropped due 1356 to ECMP resolution error. */ 1357 bcmMirrorIngModEventProtcolPktCtrlDrop = 24, /* Enable to select packets dropped due 1358 to protocol packet drop control. */ 1359 bcmMirrorIngModEventPortFilteringMode = 25, /* Enable to select port filtering mode 1360 drop. */ 1361 bcmMirrorIngModEventL2MyStation = 26, /* Enable to select packets dropped due 1362 to L2 my station lookup miss. */ 1363 bcmMirrorIngModEventMplsStage = 27, /* Enable to select MPLS stage drop. */ 1364 bcmMirrorIngModEventSrcMacZero = 28, /* Enable to select source MAC address 1365 is zero. */ 1366 bcmMirrorIngModEventL3TtlErr = 29, /* Enable to select L3 TTL error drop. */ 1367 bcmMirrorIngModEventL3HdrErr = 30, /* Enable to select L3 header error 1368 drop. */ 1369 bcmMirrorIngModEventDstL3LookupMiss = 31, /* Enable to select L3 destination 1370 lookup miss drop. */ 1371 bcmMirrorIngModEventDstL3Discard = 32, /* Enable to select L3 destination 1372 discard drop. */ 1373 bcmMirrorIngModEventSrcL2StaticMove = 33, /* Enable to select L2 source static 1374 move drop. */ 1375 bcmMirrorIngModEventSrcL2Discard = 34, /* Enable to select packets dropped due 1376 to L2 source discard. */ 1377 bcmMirrorIngModEventDstL2Discard = 35, /* Enable to select packets dropped due 1378 to L2 destination discard. */ 1379 bcmMirrorIngModEventIpMcDrop = 36, /* Enable to select IP multicast header 1380 error drop. */ 1381 bcmMirrorIngModEventSrcMacEqualsDstMac = 37, /* Enable to select packets dropped due 1382 to source MAC address equals to 1383 destination MAC address. */ 1384 bcmMirrorIngModEventTrunkFailLoopback = 38, /* Enable to select packets looped back 1385 because of trunk failover in packet 1386 discard stage. */ 1387 bcmMirrorIngModEventDosL4Attack = 39, /* Enable to select packets dropped due 1388 to L4 DoS attack. */ 1389 bcmMirrorIngModEventDosL3Attack = 40, /* Enable to select packets dropped due 1390 to L3 DoS attack. */ 1391 bcmMirrorIngModEventIpv6ProtocolErr = 41, /* Enable to select packets dropped due 1392 to IPv6 protocol error. */ 1393 bcmMirrorIngModEventIpv4ProtocolErr = 42, /* Enable to select packets dropped due 1394 to IPv4 protocol error. */ 1395 bcmMirrorIngModEventMacControlFrame = 43, /* Enable to select packets dropped due 1396 to MAC control frame. */ 1397 bcmMirrorIngModEventCompositeError = 44, /* Enable to select packets dropped due 1398 to parity/ECC errors. */ 1399 bcmMirrorIngModEventCpuManagedLearning = 45, /* Enable to select packets dropped due 1400 to CPU managed learning (CML). */ 1401 bcmMirrorIngModEventCfiOrL3Disable = 46, /* Enable to select packets dropped due 1402 to CFI or L3 disable. */ 1403 bcmMirrorIngModEventBpdu = 47, /* Enable to select packets dropped due 1404 to BPDU. */ 1405 bcmMirrorIngModEventBfdTerminated = 48, /* Enable to select BFD terminated drop. */ 1406 bcmMirrorIngModEventBfdUnknownVerOrDiscard = 49, /* Enable to select counter update for 1407 unknown BFD version or discard 1408 dropped. */ 1409 bcmMirrorIngModEventBfdUnknownAchErr = 50, /* Enable to select counter update for 1410 BFD packets with non-zero version in 1411 the ACH header or the ACH channel 1412 type unknown. */ 1413 bcmMirrorIngModEventBfdUnknownCtrlPkt = 51, /* Enable to select counter update for 1414 unrecognized BFD control packets 1415 received from the PW VCCM type 1/2/3 1416 or MPLS-TP control channel. */ 1417 bcmMirrorIngModEventDosL2 = 52, /* Enable to select counter update for 1418 L2 DoS attack packets. */ 1419 bcmMirrorIngModEventParityErrDrop = 53, /* Enable to select counter update for 1420 packets dropped due to parity error. */ 1421 bcmMirrorIngModEventTrunkFailoverLoopbackDiscard = 54, /* Enable to select counter update for 1422 trunk failover loopback packets 1423 discarded due to the backup port 1424 being down in packet pre-processing 1425 stage. */ 1426 bcmMirrorIngModEventTrunkFailoverLoopback = 55, /* Enable to select counter update for 1427 trunk failover loopback packets in 1428 packet pre-processing stage. */ 1429 bcmMirrorIngModEventDosFragment = 56, /* Enable to select counter update for 1430 DoS fragment error packets. */ 1431 bcmMirrorIngModEventDosIcmp = 57, /* Enable to select counter update for 1432 DoS ICMP error packets. */ 1433 bcmMirrorIngModEventRxTnlErr = 58, /* Enable to select counter update for 1434 received tunnel error packets. */ 1435 bcmMirrorIngModEventRxTnl = 59, /* Enable to select counter update for 1436 the number of tunnel packets 1437 received. */ 1438 bcmMirrorIngModEventRxDrop = 60, /* Enable to select counter update for 1439 zero port bitmap drop condition. */ 1440 bcmMirrorIngModEventRxMcDrop = 61, /* Enable to select counter update for 1441 multicast (L2+L3) packets that are 1442 dropped. */ 1443 bcmMirrorIngModEventMcBridged = 62, /* Enable to select counter update for 1444 bridged multicast packets. */ 1445 bcmMirrorIngModEventRxPortDrop = 63, /* Enable to select counter update for 1446 packets dropped when the ingress port 1447 is not in a forwarding state. */ 1448 bcmMirrorIngModEventRxUc = 64, /* Enable to select counter update for 1449 good received unicast (L2+L3) 1450 packets. */ 1451 bcmMirrorIngModEventIpv6McRouted = 65, /* Enable to select counter update for 1452 routed IPv6 multicast packets. */ 1453 bcmMirrorIngModEventRxIpv6HdrErr = 66, /* Enable to select counter update for 1454 received IPv6 header error packets 1455 (IPv6 martian error addresses + link 1456 local). */ 1457 bcmMirrorIngModEventRxIpv6 = 67, /* Enable to select counter update for 1458 good received IPv6 L3 packets, 1459 including tunneled packets. */ 1460 bcmMirrorIngModEventRxIpv6Discard = 68, /* Enable to select counter update for 1461 received L3 IPv6 discarded packets. */ 1462 bcmMirrorIngModEventIpv4McRouted = 69, /* Enable to select counter update for 1463 routed IPv4 multicast packets. */ 1464 bcmMirrorIngModEventRxIpv4HdrErr = 70, /* Enable to select counter update for 1465 received IPv4 header error packets 1466 (martian error address + unicast with 1467 Class D + multicast & ~ClassD) */ 1468 bcmMirrorIngModEventRxIpv4 = 71, /* Enable to select counter update for 1469 good received IPv4 L3, including 1470 tunneled packets. */ 1471 bcmMirrorIngModEventRxIpv4Discard = 72, /* Enable to select counter update for 1472 received L3 IPv4 discarded packets. */ 1473 bcmMirrorIngModEventVlanMembershipDrop = 73, /* Enable to select counter update for 1474 packets dropped due to mismatched 1475 egress port for the VLAN. */ 1476 bcmMirrorIngModEventVlanBlockedDrop = 74, /* Enable to select counter update for 1477 packets dropped due to VLAN blocked 1478 ports. */ 1479 bcmMirrorIngModEventVlanStgDrop = 75, /* Enable to select counter update for 1480 packets dropped due to spanning tree 1481 group state. */ 1482 bcmMirrorIngModEventNonucTrunkResolutionMask = 76, /* Enable to select counter update for 1483 packets dropped due to multicast and 1484 broadcast trunk block mask. */ 1485 bcmMirrorIngModEventNonucMask = 77, /* Enable to select counter update for 1486 packets dropped due to unknown 1487 unicast, unknown multicast, known 1488 multicast, and broadcast block masks. */ 1489 bcmMirrorIngModEventMcDrop = 78, /* Enable to select counter update for 1490 packets dropped due to multicast 1491 errors. */ 1492 bcmMirrorIngModEventMacMask = 79, /* Enable to select counter update for 1493 packets dropped due to MAC block 1494 mask. */ 1495 bcmMirrorIngModEventIngEgrMask = 80, /* Enable to select counter update for 1496 packets dropped due to block traffic 1497 from egressing based on the ingress 1498 port. */ 1499 bcmMirrorIngModEventFpIngDelayedDrop = 81, /* Enable to select counter update for 1500 packets dropped due to ingress FP 1501 delayed action. */ 1502 bcmMirrorIngModEventFpRedirectMask = 82, /* Enable to select counter update for 1503 packets dropped due to FP redirection 1504 mask. */ 1505 bcmMirrorIngModEventEgrMask = 83, /* Enable to select counter update for 1506 packets dropped due to egress mask. */ 1507 bcmMirrorIngModEventSrcPortKnockoutDrop = 84, /* Enable to select counter update for 1508 packets dropped due to source port 1509 knockout. */ 1510 bcmMirrorIngModEventNonIpDiscard = 85, /* Enable to select counter update for 1511 non-IP packet discard dropped. */ 1512 bcmMirrorIngModEventMtuCheckFail = 86, /* Enable to select counter update for 1513 packets dropped due to MTU check 1514 fail. */ 1515 bcmMirrorIngModEventBlockMaskDrop = 87, /* Enable to select counter update for 1516 packets dropped due to block masks. */ 1517 bcmMirrorIngModEventBfdError = 88, /* Enable to select packet copied to CPU 1518 due to BFD error. */ 1519 bcmMirrorIngModEventBfdSlowpath = 89, /* Enable to select packet copied to CPU 1520 due to BFD slow path. */ 1521 bcmMirrorIngModEventTimeSyncToCpu = 90, /* Enable to select network time sync 1522 packet copied to CPU. */ 1523 bcmMirrorIngModEventIeee1588UnknownVersion = 91, /* Enable to select packet copied to CPU 1524 due to IEEE 1588 unknown version. */ 1525 bcmMirrorIngModEventMplsUnknownAchType = 92, /* Enable to select packet copied to CPU 1526 due to MPLS unknown generic 1527 associated channel type or version. */ 1528 bcmMirrorIngModEventMplsIllegalReservedLabel = 93, /* Enable to select packet copied to CPU 1529 due to illegal reserved MPLS label. 1530 Such packets have GAL (Generic 1531 Associated Channel Label) that is not 1532 at the bottom of the stack. */ 1533 bcmMirrorIngModEventMplsAlertLabelExposed = 94, /* Enable to select packet copied to CPU 1534 due to GAL (Generic Associated 1535 channel Label) or RAL (Router Alert 1536 Label) being exposed. */ 1537 bcmMirrorIngModEventMplsTtlCheckFailToCpu = 95, /* Enable to select packet copied to CPU 1538 due to MPLS Header TTL value being 0 1539 or 1. */ 1540 bcmMirrorIngModEventMplsInvalidPayloadToCpu = 96, /* Enable to select packet copied to CPU 1541 due to MPLS payload being invalid. */ 1542 bcmMirrorIngModEventMplsInvalidActionToCpu = 97, /* Enable to select packet copied to CPU 1543 due to MPLS invalid action. */ 1544 bcmMirrorIngModEventMplsLabelMissToCpu = 98, /* Enable to select packet copied to CPU 1545 due to MPLS label lookup miss. 1546 Applicable only for MPLS tunnel 1547 termination. */ 1548 bcmMirrorIngModEventSflowFlexSample = 99, /* Enable to select SFLOW flex sampled 1549 packet copied to CPU. */ 1550 bcmMirrorIngModEventSflowIngSample = 100, /* Enable to select SFLOW ingress 1551 sampled packet copied to CPU. */ 1552 bcmMirrorIngModEventSflowEgrSample = 101, /* Enable to select SFLOW egress sampled 1553 packet copied to CPU. */ 1554 bcmMirrorIngModEventTnlDecapEcnToCpu = 102, /* Enable to select packet copied to CPU 1555 from tunnel decap ECN. */ 1556 bcmMirrorIngModEventTnlErrToCpu = 103, /* Enable to select packet copied to CPU 1557 due to tunnel error. */ 1558 bcmMirrorIngModEventCbsmPrevented = 104, /* Enable to select packet copied to CPU 1559 due to CBSM (Class Based Station 1560 Movement) prevention. */ 1561 bcmMirrorIngModEventDlbMonitor = 105, /* Enable to select packet copied to CPU 1562 by DLB monitor. */ 1563 bcmMirrorIngModEventEtrapMonitor = 106, /* Enable to select packet copied to CPU 1564 by Etrap (elephant trap) monitor. */ 1565 bcmMirrorIngModEventFpIng = 107, /* Enable to select packet copied to CPU 1566 due to ingress FP action. */ 1567 bcmMirrorIngModEventVfp = 108, /* Enable to select packet copied to CPU 1568 due to VFP action. */ 1569 bcmMirrorIngModEventMcIndexErrToCpu = 109, /* Enable to select packet copied to CPU 1570 due to multicast index error. */ 1571 bcmMirrorIngModEventIcmpRedirect = 110, /* Enable to select ICMP redirect packet 1572 copied to CPU. */ 1573 bcmMirrorIngModEventNhop = 111, /* Enable to select packet copied to CPU 1574 from next hop table. */ 1575 bcmMirrorIngModEventMartianAddr = 112, /* Enable to select packet copied to CPU 1576 due to Martian address. */ 1577 bcmMirrorIngModEventL3HdrErrToCpu = 113, /* Enable to select packet copied to CPU 1578 due to L3 header error. */ 1579 bcmMirrorIngModEventIpMcMiss = 114, /* Enable to select packet copied to CPU 1580 due to IPMC miss. */ 1581 bcmMirrorIngModEventIpMcL3IifMismatch = 115, /* Enable to select packet copied to CPU 1582 due to IP multicast interface 1583 mismatch. */ 1584 bcmMirrorIngModEventL3SrcMove = 116, /* Enable to select packet copied to CPU 1585 due to L3 station movement. */ 1586 bcmMirrorIngModEventL3DstMiss = 117, /* Enable to select packet copied to CPU 1587 due to L3 destination IP miss or 1588 broadcast destination IP. */ 1589 bcmMirrorIngModEventL3SrcMiss = 118, /* Enable to select packet copied to CPU 1590 due to L3 source IP miss. */ 1591 bcmMirrorIngModEventMtuCheckFailToCpu = 119, /* Enable to select packet copied to CPU 1592 due to L3 MTU check failure. */ 1593 bcmMirrorIngModEventIpOptionsPkt = 120, /* Enable to select packet copied to CPU 1594 due to an IP packet with options. */ 1595 bcmMirrorIngModEventTtl1 = 121, /* Enable to select IPMC or L3UC packet 1596 with TTL equal to 1 copied to CPU. */ 1597 bcmMirrorIngModEventPbtNonucPkt = 122, /* Enable to select packet copied to CPU 1598 due to PBT (Provider Backbone 1599 Transport) packet being non unicast. */ 1600 bcmMirrorIngModEventL2 = 123, /* Enable to select packet copied to CPU 1601 from L2 table. */ 1602 bcmMirrorIngModEventL2Move = 124, /* Enable to select packet copied to CPU 1603 due to L2 station movement. */ 1604 bcmMirrorIngModEventL2DstLookupFailure = 125, /* Enable to select packet copied to CPU 1605 due to L2 destination lookup failure. */ 1606 bcmMirrorIngModEventL2SrcLookupFailure = 126, /* Enable to select packet copied to CPU 1607 due to L2 source lookup failure. */ 1608 bcmMirrorIngModEventL2MyStationHit = 127, /* Enable to select packet copied to CPU 1609 due to MY_STATION hit. */ 1610 bcmMirrorIngModEventL2McMiss = 128, /* Enable to select packet copied to CPU 1611 due to L2MC miss. */ 1612 bcmMirrorIngModEventParityError = 129, /* Enable to select packet copied to CPU 1613 due to parity error in ingress 1614 pipeline tables. */ 1615 bcmMirrorIngModEventPktTrace = 130, /* Enable to select packet copied to CPU 1616 due to packet trace function. */ 1617 bcmMirrorIngModEventDosAttack = 131, /* Enable to select DOS attack packet 1618 copied to CPU. */ 1619 bcmMirrorIngModEventPvlanIdMismatchToCpu = 132, /* Enable to select Private VLAN ID 1620 mismatch packet copied to CPU. */ 1621 bcmMirrorIngModEventUnknownVlan = 133, /* Enable to select Unknown VLAN packet 1622 copied to CPU. */ 1623 bcmMirrorIngModEventL2Proto = 134, /* Enable to select L2 protocol packet 1624 copied to CPU. */ 1625 bcmMirrorIngModEventSrpProtocol = 135, /* Enable to select SRP (Stream 1626 Registration Protocol) packet copied 1627 to CPU. */ 1628 bcmMirrorIngModEventMmrpProtocol = 136, /* Enable to select MMRP (Multiple Mac 1629 Registration Protocol) packet copied 1630 to CPU. */ 1631 bcmMirrorIngModEventArpProtocol = 137, /* Enable to select ARP packet copied to 1632 CPU. */ 1633 bcmMirrorIngModEventIgmpProtocol = 138, /* Enable to select IGMP packet copied 1634 to CPU. */ 1635 bcmMirrorIngModEventDhcpProtocol = 139, /* Enable to select DHCP packet copied 1636 to CPU. */ 1637 bcmMirrorIngModEventIpMcRsvdProtocol = 140, /* Enable to select IPMC reserved packet 1638 copied to CPU. */ 1639 bcmMirrorIngModEventBpduProtocol = 141, /* Enable to select BPDU packet copied 1640 to CPU. */ 1641 bcmMirrorIngModEventVfiIngAdaptLookupMiss = 142, /* Enable to select VFI ingress 1642 adaptation first lookup miss drop or 1643 both first and second lookup miss 1644 drop. */ 1645 bcmMirrorIngModEventVfiIngAdaptLookupMissToCpu = 143, /* Enable to select VFI ingress 1646 adaptation first lookup miss or both 1647 first and second lookup miss copied 1648 to CPU. */ 1649 bcmMirrorIngModEventOlUlNhopEifRangeError = 144, /* Enable to select overlay and underlay 1650 next hop or L3 egress interface ID 1651 range error drop. */ 1652 bcmMirrorIngModEventCount = 145 /* Must be last. Not a valid value. */ 1653 } bcm_mirror_ingress_mod_event_t; 1654 1655 /* Ingress mirror-on-drop event group. */ 1656 typedef int bcm_mirror_ingress_mod_event_group_t; 1657 1658 #ifndef BCM_HIDE_DISPATCHABLE 1659 1660 /* Create an ingress mirror-on-drop event group. */ 1661 extern int bcm_mirror_ingress_mod_event_group_create( 1662 int unit, 1663 bcm_mirror_ingress_mod_event_t *event_array, 1664 int num_events, 1665 bcm_mirror_ingress_mod_event_group_t *group); 1666 1667 /* Destroy an ingress mirror-on-drop event group. */ 1668 extern int bcm_mirror_ingress_mod_event_group_destroy( 1669 int unit, 1670 bcm_mirror_ingress_mod_event_group_t group); 1671 1672 /* Get all ingress mirror-on-drop event groups. */ 1673 extern int bcm_mirror_ingress_mod_event_group_get_all( 1674 int unit, 1675 bcm_mirror_ingress_mod_event_group_t *group_array, 1676 int *count); 1677 1678 /* Get an ingress mirror-on-drop event group. */ 1679 extern int bcm_mirror_ingress_mod_event_group_get( 1680 int unit, 1681 bcm_mirror_ingress_mod_event_group_t group, 1682 bcm_mirror_ingress_mod_event_t *event_array, 1683 int *count); 1684 1685 #endif /* BCM_HIDE_DISPATCHABLE */ 1686 1687 /* Ingress mirror-on-drop event profile structure. */ 1688 typedef struct bcm_mirror_ingress_mod_event_profile_s { 1689 uint8 reason_code; /* Configurable reason code for ingress mirror-on-drop 1690 packets. */ 1691 uint32 sample_rate; /* Sampler threshold. Sample the mirror packets if the 1692 generated sFlow random number is less than or equal 1693 to the threshold. Set 0 to disable sampler. */ 1694 uint32 priority; /* Profile priority. Higher value means higher priority. 1695 When multiple profiles are hit simultaneously, the 1696 profile with the highest priority will be chosen to 1697 mirror. */ 1698 } bcm_mirror_ingress_mod_event_profile_t; 1699 1700 /* Initialize an ingress mirror-on-drop event profile structure. */ 1701 extern void bcm_mirror_ingress_mod_event_profile_t_init( 1702 bcm_mirror_ingress_mod_event_profile_t *profile); 1703 1704 #ifndef BCM_HIDE_DISPATCHABLE 1705 1706 /* Create an ingress mirror-on-drop event profile. */ 1707 extern int bcm_mirror_ingress_mod_event_profile_create( 1708 int unit, 1709 bcm_mirror_ingress_mod_event_profile_t *profile, 1710 int *profile_id); 1711 1712 /* Destroy an ingress mirror-on-drop event profile. */ 1713 extern int bcm_mirror_ingress_mod_event_profile_destroy( 1714 int unit, 1715 int profile_id); 1716 1717 /* Get all ingress mirror-on-drop event profile ids. */ 1718 extern int bcm_mirror_ingress_mod_event_profile_get_all( 1719 int unit, 1720 int *profile_id_array, 1721 int *count); 1722 1723 /* Get an ingress mirror-on-drop event profile config. */ 1724 extern int bcm_mirror_ingress_mod_event_profile_get( 1725 int unit, 1726 int profile_id, 1727 bcm_mirror_ingress_mod_event_profile_t *profile); 1728 1729 /* Add an ingress mirror-on-drop event group to an event profile. */ 1730 extern int bcm_mirror_ingress_mod_event_profile_group_add( 1731 int unit, 1732 int profile_id, 1733 bcm_mirror_ingress_mod_event_group_t group, 1734 int hit); 1735 1736 /* Delete an ingress mirror-on-drop event group to an event profile. */ 1737 extern int bcm_mirror_ingress_mod_event_profile_group_delete( 1738 int unit, 1739 int profile_id, 1740 bcm_mirror_ingress_mod_event_group_t group); 1741 1742 /* Get all event groups of an ingress mirror-on-drop event profile. */ 1743 extern int bcm_mirror_ingress_mod_event_profile_group_get_all( 1744 int unit, 1745 int profile_id, 1746 bcm_mirror_ingress_mod_event_group_t *group_array, 1747 int *count); 1748 1749 /* 1750 * Get hit expectation of an ingress mirror-on-drop event group from an 1751 * event profile. 1752 */ 1753 extern int bcm_mirror_ingress_mod_event_profile_group_get( 1754 int unit, 1755 int profile_id, 1756 bcm_mirror_ingress_mod_event_group_t group, 1757 int *hit); 1758 1759 #endif /* BCM_HIDE_DISPATCHABLE */ 1760 1761 /* Number of entries for a group of multiple destination IP addresses. */ 1762 typedef enum bcm_mirror_multi_dip_entry_num_e { 1763 bcmMirrorMultiDipEntryNum1 = 0, /* 1 entry. */ 1764 bcmMirrorMultiDipEntryNum2 = 1, /* 2 entries. */ 1765 bcmMirrorMultiDipEntryNum4 = 2, /* 4 entries. */ 1766 bcmMirrorMultiDipEntryNum8 = 3, /* 8 entries. */ 1767 bcmMirrorMultiDipEntryNum16 = 4, /* 16 entries. */ 1768 bcmMirrorMultiDipEntryNum32 = 5, /* 32 entries. */ 1769 bcmMirrorMultiDipEntryNum64 = 6, /* 64 entries. */ 1770 bcmMirrorMultiDipEntryNumCount = 7 /* Must Be Last. Not a valid value. */ 1771 } bcm_mirror_multi_dip_entry_num_t; 1772 1773 #ifndef BCM_HIDE_DISPATCHABLE 1774 1775 /* Create a group of multiple destination IPv4 addresses. */ 1776 extern int bcm_mirror_multi_dip_group_ipv4_create( 1777 int unit, 1778 bcm_mirror_multi_dip_entry_num_t num_entries, 1779 bcm_ip_t *ipv4_addr_array, 1780 bcm_mirror_multi_dip_group_t *group); 1781 1782 /* Remove a group of multiple destination IPv4 addresses. */ 1783 extern int bcm_mirror_multi_dip_group_ipv4_destroy( 1784 int unit, 1785 bcm_mirror_multi_dip_group_t group); 1786 1787 /* Get all groups of multiple destination IPv4 addresses. */ 1788 extern int bcm_mirror_multi_dip_group_ipv4_get_all( 1789 int unit, 1790 bcm_mirror_multi_dip_group_t *ipv4_group_array, 1791 int *count); 1792 1793 /* Get a group of multiple destination IPv4 addresses. */ 1794 extern int bcm_mirror_multi_dip_group_ipv4_get( 1795 int unit, 1796 bcm_mirror_multi_dip_group_t group, 1797 bcm_ip_t *ipv4_addr_array, 1798 int *count); 1799 1800 /* Create a group of multiple destination IPv6 addresses. */ 1801 extern int bcm_mirror_multi_dip_group_ipv6_create( 1802 int unit, 1803 bcm_mirror_multi_dip_entry_num_t num_entries, 1804 bcm_ip6_t *ipv6_addr_array, 1805 bcm_mirror_multi_dip_group_t *group); 1806 1807 /* Remove a group of multiple destination IPv6 addresses. */ 1808 extern int bcm_mirror_multi_dip_group_ipv6_destroy( 1809 int unit, 1810 bcm_mirror_multi_dip_group_t group); 1811 1812 /* Get all groups of multiple destination IPv6 addresses. */ 1813 extern int bcm_mirror_multi_dip_group_ipv6_get_all( 1814 int unit, 1815 bcm_mirror_multi_dip_group_t *ipv6_group_array, 1816 int *count); 1817 1818 /* Get a group of multiple destination IPv6 addresses. */ 1819 extern int bcm_mirror_multi_dip_group_ipv6_get( 1820 int unit, 1821 bcm_mirror_multi_dip_group_t group, 1822 bcm_ip6_t *ipv6_addr_array, 1823 int *count); 1824 1825 #endif /* BCM_HIDE_DISPATCHABLE */ 1826 1827 /* Truncate length profile structure. */ 1828 typedef struct bcm_mirror_truncate_length_profile_s { 1829 bcm_mirror_truncate_mode_t mode; /* Truncate mode. */ 1830 int adjustment_length; /* Mirror payload adjustment length 1831 after truncation. */ 1832 } bcm_mirror_truncate_length_profile_t; 1833 1834 /* Initialize bcm_mirror_truncate_length_profile_t struct */ 1835 extern void bcm_mirror_truncate_length_profile_t_init( 1836 bcm_mirror_truncate_length_profile_t *profile); 1837 1838 /* Truncate length profile option flags. */ 1839 #define BCM_MIRROR_TRUNCATE_LENGTH_PROFILE_OPTIONS_REPLACE 0x00000001 /* Update truncate length 1840 profile entry. */ 1841 #define BCM_MIRROR_TRUNCATE_LENGTH_PROFILE_OPTIONS_WITH_ID 0x00000002 /* Create or update 1842 truncate length 1843 profile with id. */ 1844 1845 #ifndef BCM_HIDE_DISPATCHABLE 1846 1847 /* Create the truncate length profile. */ 1848 extern int bcm_mirror_truncate_length_profile_create( 1849 int unit, 1850 uint32 options, 1851 int *profile_id, 1852 bcm_mirror_truncate_length_profile_t *profile); 1853 1854 /* Destroy the truncate length profile. */ 1855 extern int bcm_mirror_truncate_length_profile_destroy( 1856 int unit, 1857 int profile_id); 1858 1859 /* Get the truncate length profile entry with a given profile id. */ 1860 extern int bcm_mirror_truncate_length_profile_get( 1861 int unit, 1862 int profile_id, 1863 bcm_mirror_truncate_length_profile_t *profile); 1864 1865 #endif /* BCM_HIDE_DISPATCHABLE */ 1866 1867 /* Mirror global truncate for non-encapsulation mirror packets. */ 1868 typedef struct bcm_mirror_global_truncate_s { 1869 bcm_mirror_truncate_mode_t mode; /* Truncate mode. */ 1870 int profile_id; /* Profile ID to adjust payload truncate 1871 length.Applicable only for adjustment 1872 truncate mode. */ 1873 } bcm_mirror_global_truncate_t; 1874 1875 /* Initialize a mirror global truncate structure. */ 1876 extern void bcm_mirror_global_truncate_t_init( 1877 bcm_mirror_global_truncate_t *global_truncate); 1878 1879 #ifndef BCM_HIDE_DISPATCHABLE 1880 1881 /* Set mirror global truncate for non-encapsulation mirror packets. */ 1882 extern int bcm_mirror_global_truncate_set( 1883 int unit, 1884 bcm_mirror_global_truncate_t *global_truncate); 1885 1886 /* Get mirror global truncate for non-encapsulation mirror packets. */ 1887 extern int bcm_mirror_global_truncate_get( 1888 int unit, 1889 bcm_mirror_global_truncate_t *global_truncate); 1890 1891 #endif /* BCM_HIDE_DISPATCHABLE */ 1892 1893 #endif /* __BCM_MIRROR_H__ */