ipmc.h (19167B)
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_IPMC_H__ 11 #define __BCM_IPMC_H__ 12 13 #if defined(INCLUDE_L3) 14 15 #include <bcm/types.h> 16 #include <bcm/l3.h> 17 18 /* IPMC address type. */ 19 typedef struct bcm_ipmc_addr_s { 20 bcm_ip_t s_ip_addr; /* IPv4 Source address. */ 21 bcm_ip_t mc_ip_addr; /* IPv4 Destination address. */ 22 bcm_ip6_t s_ip6_addr; /* IPv6 Source address. */ 23 bcm_ip6_t mc_ip6_addr; /* IPv6 Destination address. */ 24 bcm_vlan_t vid; /* VLAN identifier. */ 25 bcm_vrf_t vrf; /* Virtual Router Instance. */ 26 bcm_cos_t cos; /* COS based on dst IP multicast addr. */ 27 int ts; /* Source port or TGID bit. */ 28 int port_tgid; /* Source port or TGID. */ 29 int v; /* Valid bit. */ 30 int mod_id; /* Module ID. */ 31 bcm_multicast_t group; /* Use this index to program IPMC table 32 for XGS chips based on flags value */ 33 uint32 flags; /* See BCM_IPMC_XXX flag definitions. */ 34 int lookup_class; /* Classification lookup class ID. */ 35 bcm_fabric_distribution_t distribution_class; /* Fabric Distribution Class. */ 36 bcm_if_t l3a_intf; /* L3 interface associated with route. */ 37 int rp_id; /* Rendezvous point ID. */ 38 bcm_ip_t s_ip_mask; /* IPv4 Source subnet mask. */ 39 bcm_if_t ing_intf; /* L3 interface associated with this 40 Entry */ 41 bcm_ip_t mc_ip_mask; /* IPv4 Destination subnet mask. */ 42 bcm_ip6_t mc_ip6_mask; /* IPv6 Destination subnet mask. */ 43 bcm_multicast_t group_l2; /* Use this index to program IPMC table 44 for l2 recipients if TTL/RPF check 45 fails. */ 46 uint32 stat_id; /* Object statistics ID. */ 47 int stat_pp_profile; /* Statistics profile. */ 48 bcm_ip6_t s_ip6_mask; /* IPv6 Source subnet mask. */ 49 int priority; /* Entry priority. */ 50 uint32 flow_handle; /* FLOW handle for flex entries. */ 51 uint32 flow_option_handle; /* FLOW option handle for flex entries. */ 52 bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex 53 entries. */ 54 uint32 num_logical_fields; /* number of logical fields. */ 55 int mtu; /* MTU. */ 56 int opaque_ctrl_id; /* Opaque control ID. */ 57 } bcm_ipmc_addr_t; 58 59 /* IPMC address flags. */ 60 #define BCM_IPMC_KEEP_ENTRY 0x00000001 /* Internal use. */ 61 #define BCM_IPMC_HIT 0x00000002 /* On get, indicates if 62 L3 hit is on for 63 entry. */ 64 #define BCM_IPMC_SOURCE_PORT_NOCHECK 0x80000000 /* Do not source port 65 check this entry (XGS 66 only). */ 67 #define BCM_IPMC_DISABLED 0x00000008 /* Add entry in disabled 68 state. */ 69 #define BCM_IPMC_REPLACE 0x00000010 /* Replace an existing 70 entry. */ 71 #define BCM_IPMC_IP6 0x00000020 /* IPv6 support. */ 72 #define BCM_IPMC_HIT_CLEAR 0x00000040 /* Clear hit bit. */ 73 #define BCM_IPMC_SETPRI 0x00000080 /* Pick up new priority 74 (XGS3 only). */ 75 #define BCM_IPMC_PROXY_IP6 0x00000100 /* IPv6 Proxy MC egress 76 ports on XGS2. */ 77 #define BCM_IPMC_ADD_DISABLED BCM_IPMC_DISABLED 78 #define BCM_IPMC_USE_FABRIC_DISTRIBUTION 0x00000400 /* Use specified fabric 79 distribution class. */ 80 #define BCM_IPMC_COPYTOCPU 0x00000800 /* When set, Copy the 81 packet to CPU. */ 82 #define BCM_IPMC_POST_LOOKUP_RPF_CHECK 0x00001000 /* When set, perform RPF 83 check. */ 84 #define BCM_IPMC_RPF_FAIL_DROP 0x00002000 /* Drop packet on RPF 85 failure. */ 86 #define BCM_IPMC_RPF_FAIL_TOCPU 0x00004000 /* Copy packets to CPU on 87 RPF failure. */ 88 #define BCM_IPMC_L2 0x00008000 /* XGS: Define IPMC L2 89 domain lookup 90 (VLAN/VFI) in L3 IPMC 91 table. DNX: Add a 92 bridged MC entry */ 93 #define BCM_IPMC_RAW_ENTRY 0x00010000 /* Insert raw data 94 payload */ 95 #define BCM_IPMC_DECAP_ROE_HEADER 0x00020000 /* Indicates the 96 decapsulation of 97 ROE/ROE Custom Header. */ 98 #define BCM_IPMC_TCAM 0x00040000 /* Indicates MC TCAM 99 entry. */ 100 #define BCM_IPMC_RP_ID_EXPECTED_INTF_RESOLVE 0x00080000 /* Indicates 101 configuration 102 resolution between 103 rendezvous point ID 104 (l3a_rp) and L3 105 interface 106 (l3a_expected_intf) is 107 not successful during 108 route 109 get/find/traverse 110 APIs. bcm_l3_route_t 111 has l3a_rp and 112 l3a_expected_intf 113 members set without 114 BCM_IPMC_POST_LOOKUP_RPF_CHECK 115 in l3a_ipmc_flags. End 116 user application 117 should resolve based 118 on application 119 configuration. Flag is 120 set as a result of 121 route get, find and 122 traverse operations 123 and is not applicable 124 for any other 125 operations. */ 126 #define BCM_IPMC_DISCARD 0x00100000 /* Indicates to discard 127 packets on entry hit. */ 128 #define BCM_IPMC_DEFAULT_ENTRY 0x00200000 /* Indicates a default 129 entry. */ 130 #define BCM_IPMC_HIT_ENABLE 0x00400000 /* Indicates to enable 131 hit-bit on entry. */ 132 133 /* Invalid value for rendezvous point ID parameter. */ 134 #define BCM_IPMC_RP_ID_INVALID -1 /* Invalid rendezvous point ID */ 135 136 /* IPMC counters structure. */ 137 typedef struct bcm_ipmc_counters_s { 138 uint64 rmca; /* Received L2 multicast frame. */ 139 uint64 tmca; /* Transmit L2 multicast packet counter. */ 140 uint64 imbp; /* Number of IPMC packets bridged. */ 141 uint64 imrp; /* Number of IPMC packets routed. */ 142 uint64 rimdr; /* Number of IPMC dropped in ingress. */ 143 uint64 timdr; /* Number of IPMC dropped in egress. */ 144 } bcm_ipmc_counters_t; 145 146 /* bcm_ipmc_traverse_cb */ 147 typedef int (*bcm_ipmc_traverse_cb)( 148 int unit, 149 bcm_ipmc_addr_t *info, 150 void *user_data); 151 152 #ifndef BCM_HIDE_DISPATCHABLE 153 154 /* Initialize the BCM IPMC subsystem. */ 155 extern int bcm_ipmc_init( 156 int unit); 157 158 /* Detach the BCM IPMC subsystem. */ 159 extern int bcm_ipmc_detach( 160 int unit); 161 162 /* Enable/disable IPMC support. */ 163 extern int bcm_ipmc_enable( 164 int unit, 165 int enable); 166 167 #endif /* BCM_HIDE_DISPATCHABLE */ 168 169 /* Initialize a bcm_ipmc_addr_t. */ 170 extern void bcm_ipmc_addr_t_init( 171 bcm_ipmc_addr_t *data); 172 173 #ifndef BCM_HIDE_DISPATCHABLE 174 175 /* Add a new entry to IPMC table. */ 176 extern int bcm_ipmc_add( 177 int unit, 178 bcm_ipmc_addr_t *data); 179 180 /* Find info about an IPMC entry. */ 181 extern int bcm_ipmc_find( 182 int unit, 183 bcm_ipmc_addr_t *data); 184 185 /* Remove an entry from IPMC table. */ 186 extern int bcm_ipmc_remove( 187 int unit, 188 bcm_ipmc_addr_t *data); 189 190 /* Remove all entries from IPMC table. */ 191 extern int bcm_ipmc_remove_all( 192 int unit); 193 194 /* Set flex counter object value for the given IPMC group. */ 195 extern int bcm_ipmc_flexctr_object_set( 196 int unit, 197 bcm_ipmc_addr_t *info, 198 uint32 value); 199 200 /* Get flex counter object value for the given IPMC group. */ 201 extern int bcm_ipmc_flexctr_object_get( 202 int unit, 203 bcm_ipmc_addr_t *info, 204 uint32 *value); 205 206 /* Reinitialize/clear the egress IP multicast configuration. */ 207 extern int bcm_ipmc_egress_port_init( 208 int unit); 209 210 /* Configure the IP Multicast egress properties. */ 211 extern int bcm_ipmc_egress_port_set( 212 int unit, 213 bcm_port_t port, 214 const bcm_mac_t mac, 215 int untag, 216 bcm_vlan_t vid, 217 int ttl_threshold); 218 219 /* Get the egress IP multicast configuration properties. */ 220 extern int bcm_ipmc_egress_port_get( 221 int unit, 222 bcm_port_t port, 223 bcm_mac_t mac, 224 int *untag, 225 bcm_vlan_t *vid, 226 int *ttl_threshold); 227 228 /* Get the combined IP multicast statistics. */ 229 extern int bcm_ipmc_counters_get( 230 int unit, 231 bcm_port_t port, 232 bcm_ipmc_counters_t *counters); 233 234 /* Provides the maximum IPMC index that this fabric can handle. */ 235 extern int bcm_ipmc_bitmap_max_get( 236 int unit, 237 int *max_index); 238 239 /* Set the IPMC forwarding port bitmap. */ 240 extern int bcm_ipmc_bitmap_set( 241 int unit, 242 int ipmc_idx, 243 bcm_port_t port, 244 bcm_pbmp_t pbmp); 245 246 /* Get the IPMC forwarding port bitmap */ 247 extern int bcm_ipmc_bitmap_get( 248 int unit, 249 int ipmc_idx, 250 bcm_port_t port, 251 bcm_pbmp_t *pbmp); 252 253 /* Remove IPMC forwarding port bitmap */ 254 extern int bcm_ipmc_bitmap_del( 255 int unit, 256 int ipmc_idx, 257 bcm_port_t port, 258 bcm_pbmp_t pbmp); 259 260 #endif /* BCM_HIDE_DISPATCHABLE */ 261 262 /* Initialize an IPMC counters structure. */ 263 extern void bcm_ipmc_counters_t_init( 264 bcm_ipmc_counters_t *ipmc_counter); 265 266 #ifndef BCM_HIDE_DISPATCHABLE 267 268 /* Run IPMC table aging. */ 269 extern int bcm_ipmc_age( 270 int unit, 271 uint32 flags, 272 bcm_ipmc_traverse_cb age_cb, 273 void *user_data); 274 275 /* 276 * Traverse through the IPMC table and run callback at each valid IPMC 277 * entry. 278 */ 279 extern int bcm_ipmc_traverse( 280 int unit, 281 uint32 flags, 282 bcm_ipmc_traverse_cb cb, 283 void *user_data); 284 285 #endif /* BCM_HIDE_DISPATCHABLE */ 286 287 /* Rendezvous point flags. */ 288 #define BCM_IPMC_RP_WITH_ID 0x00000001 /* Rendezvous point ID is provided. */ 289 290 /* Configurational flags for cascaded entries */ 291 #define BCM_IPMC_CONFIG_TRAVERSE_DELETE_ALL 0x1 /* Cleared 292 configurational tables */ 293 294 #ifndef BCM_HIDE_DISPATCHABLE 295 296 /* Create a rendezvous point tree. */ 297 extern int bcm_ipmc_rp_create( 298 int unit, 299 uint32 flags, 300 int *rp_id); 301 302 /* Destroy a rendezvous point tree. */ 303 extern int bcm_ipmc_rp_destroy( 304 int unit, 305 int rp_id); 306 307 /* Set active L3 interfaces of a rendezvous point tree. */ 308 extern int bcm_ipmc_rp_set( 309 int unit, 310 int rp_id, 311 int intf_count, 312 bcm_if_t *intf_array); 313 314 /* Get active L3 interfaces of a rendezvous point tree. */ 315 extern int bcm_ipmc_rp_get( 316 int unit, 317 int rp_id, 318 int intf_max, 319 bcm_if_t *intf_array, 320 int *intf_count); 321 322 /* Add an active L3 interface to a rendezvous point tree. */ 323 extern int bcm_ipmc_rp_add( 324 int unit, 325 int rp_id, 326 bcm_if_t intf_id); 327 328 /* Delete an active L3 interface from a rendezvous point tree. */ 329 extern int bcm_ipmc_rp_delete( 330 int unit, 331 int rp_id, 332 bcm_if_t intf_id); 333 334 /* Delete all active L3 interfaces from a rendezvous point tree. */ 335 extern int bcm_ipmc_rp_delete_all( 336 int unit, 337 int rp_id); 338 339 #endif /* BCM_HIDE_DISPATCHABLE */ 340 341 /* IPMC address range info. */ 342 typedef struct bcm_ipmc_range_s { 343 uint32 flags; /* BCM_IPMC_RANGE_xxx flags. */ 344 int priority; /* Priority. */ 345 bcm_ip_t mc_ip_addr; /* IPv4 group address. */ 346 bcm_ip_t mc_ip_addr_mask; /* IPv4 group address mask. */ 347 bcm_ip6_t mc_ip6_addr; /* IPv6 group address. */ 348 bcm_ip6_t mc_ip6_addr_mask; /* IPv6 group address mask. */ 349 bcm_vrf_t vrf; /* Virtual router instance. */ 350 bcm_vrf_t vrf_mask; /* Virtual router instance mask. */ 351 int rp_id; /* Rendezvous Point ID */ 352 } bcm_ipmc_range_t; 353 354 /* Flags for bcm_ipmc_range APIs. */ 355 #define BCM_IPMC_RANGE_WITH_ID (1 << 0) /* Use the specified range ID. */ 356 #define BCM_IPMC_RANGE_REPLACE (1 << 1) /* Replace an existing range. */ 357 #define BCM_IPMC_RANGE_IP6 (1 << 2) /* IPv6 group address range is 358 valid. */ 359 #define BCM_IPMC_RANGE_PIM_BIDIR (1 << 3) /* Packets matching this range 360 are subject to PIM-BIDIR 361 processing. */ 362 363 /* Encap Id used to add or delete a trunk member */ 364 #define BCM_ENCAP_TRUNK_MEMBER 0xfffffffe /* Encap Identifier */ 365 366 /* Initialize a bcm_ipmc_range_t structure. */ 367 extern void bcm_ipmc_range_t_init( 368 bcm_ipmc_range_t *range); 369 370 #ifndef BCM_HIDE_DISPATCHABLE 371 372 /* Add a range of IP multicast addresses. */ 373 extern int bcm_ipmc_range_add( 374 int unit, 375 int *range_id, 376 bcm_ipmc_range_t *range); 377 378 /* Delete a range of IP multicast addresses. */ 379 extern int bcm_ipmc_range_delete( 380 int unit, 381 int range_id); 382 383 /* Delete all ranges of IP multicast addresses. */ 384 extern int bcm_ipmc_range_delete_all( 385 int unit); 386 387 /* Get a range of IP multicast addresses. */ 388 extern int bcm_ipmc_range_get( 389 int unit, 390 int range_id, 391 bcm_ipmc_range_t *range); 392 393 /* Get the maximum number of IP multicast address ranges supported. */ 394 extern int bcm_ipmc_range_size_get( 395 int unit, 396 int *size); 397 398 #endif /* BCM_HIDE_DISPATCHABLE */ 399 400 /* Ipmc statistics maintained per IPMC group. */ 401 typedef enum bcm_ipmc_stat_e { 402 bcmIpmcInPackets = 0, /* Packets that ingress on the IPMC group. */ 403 bcmIpmcInBytes = 1 /* Bytes that ingress on the IPMC group. */ 404 } bcm_ipmc_stat_t; 405 406 #ifndef BCM_HIDE_DISPATCHABLE 407 408 /* Attach counters entries to the given IPMC group. */ 409 extern int bcm_ipmc_stat_attach( 410 int unit, 411 bcm_ipmc_addr_t *info, 412 uint32 stat_counter_id); 413 414 /* Detach counters entries to the given IPMC group. */ 415 extern int bcm_ipmc_stat_detach( 416 int unit, 417 bcm_ipmc_addr_t *info); 418 419 /* Get counter statistic values for an IPMC group. */ 420 extern int bcm_ipmc_stat_counter_get( 421 int unit, 422 bcm_ipmc_addr_t *info, 423 bcm_ipmc_stat_t stat, 424 uint32 num_entries, 425 uint32 *counter_indexes, 426 bcm_stat_value_t *counter_values); 427 428 /* 429 * Force an immediate counter update and retrieve counter statistic 430 * values 431 * for an IPMC group. 432 */ 433 extern int bcm_ipmc_stat_counter_sync_get( 434 int unit, 435 bcm_ipmc_addr_t *info, 436 bcm_ipmc_stat_t stat, 437 uint32 num_entries, 438 uint32 *counter_indexes, 439 bcm_stat_value_t *counter_values); 440 441 /* Set counter statistic values for an IPMC group. */ 442 extern int bcm_ipmc_stat_counter_set( 443 int unit, 444 bcm_ipmc_addr_t *info, 445 bcm_ipmc_stat_t stat, 446 uint32 num_entries, 447 uint32 *counter_indexes, 448 bcm_stat_value_t *counter_values); 449 450 /* Get multiple counter statistic values for multiple IPMC group. */ 451 extern int bcm_ipmc_stat_multi_get( 452 int unit, 453 bcm_ipmc_addr_t *info, 454 int nstat, 455 bcm_ipmc_stat_t *stat_arr, 456 uint64 *value_arr); 457 458 /* Get 32bit multiple counter statistic values for multiple IPMC group. */ 459 extern int bcm_ipmc_stat_multi_get32( 460 int unit, 461 bcm_ipmc_addr_t *info, 462 int nstat, 463 bcm_ipmc_stat_t *stat_arr, 464 uint32 *value_arr); 465 466 /* Set multiple counter statistic values for multiple IPMC group. */ 467 extern int bcm_ipmc_stat_multi_set( 468 int unit, 469 bcm_ipmc_addr_t *info, 470 int nstat, 471 bcm_ipmc_stat_t *stat_arr, 472 uint64 *value_arr); 473 474 /* Set 32bit multiple counter statistic values for multiple IPMC group. */ 475 extern int bcm_ipmc_stat_multi_set32( 476 int unit, 477 bcm_ipmc_addr_t *info, 478 int nstat, 479 bcm_ipmc_stat_t *stat_arr, 480 uint32 *value_arr); 481 482 /* Get stat counter ID associated with given IPMC group. */ 483 extern int bcm_ipmc_stat_id_get( 484 int unit, 485 bcm_ipmc_addr_t *info, 486 bcm_ipmc_stat_t stat, 487 uint32 *stat_counter_id); 488 489 #endif /* BCM_HIDE_DISPATCHABLE */ 490 491 /* bcm_ipmc_config_traverse_cb */ 492 typedef int (*bcm_ipmc_config_traverse_cb)( 493 int unit, 494 bcm_ipmc_addr_t *info, 495 void *user_data); 496 497 #ifndef BCM_HIDE_DISPATCHABLE 498 499 /* Add a new configurational entry. */ 500 extern int bcm_ipmc_config_add( 501 int unit, 502 bcm_ipmc_addr_t *config); 503 504 /* Find a configurational entry. */ 505 extern int bcm_ipmc_config_find( 506 int unit, 507 bcm_ipmc_addr_t *config); 508 509 /* Remove a configurational entry */ 510 extern int bcm_ipmc_config_remove( 511 int unit, 512 bcm_ipmc_addr_t *config); 513 514 /* Traverse all configurational entries. */ 515 extern int bcm_ipmc_config_traverse( 516 int unit, 517 uint32 flags, 518 bcm_ipmc_config_traverse_cb cb, 519 void *user_data); 520 521 #endif /* defined(INCLUDE_L3) */ 522 523 #endif /* BCM_HIDE_DISPATCHABLE */ 524 525 #endif /* __BCM_IPMC_H__ */