l3.h (16184B)
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 * DO NOT EDIT THIS FILE! 9 * This file is auto-generated. 10 * Edits to this file will be lost when it is regenerated. 11 */ 12 13 #ifndef __BCMX_L3_H__ 14 #define __BCMX_L3_H__ 15 16 #if defined(INCLUDE_L3) 17 18 #include <bcm/types.h> 19 #include <bcmx/bcmx.h> 20 #include <bcmx/lplist.h> 21 #include <bcm/l3.h> 22 23 /* L3 Interface Structure */ 24 typedef bcm_l3_intf_t bcmx_l3_intf_t; 25 26 /* 27 * L3 Egress Structure. 28 * 29 * Description of an L3 forwarding destination. 30 */ 31 typedef struct bcmx_l3_egress_s { 32 uint32 flags; /* Interface flags (BCM_L3_TGID, 33 BCM_L3_L2TOCPU). */ 34 bcm_if_t intf; /* L3 interface (source MAC, tunnel). */ 35 bcm_mac_t mac_addr; /* Next hop forwarding destination mac. */ 36 bcm_vlan_t vlan; /* Next hop vlan id. */ 37 bcmx_lport_t lport; /* Port packet switched to (if 38 !BCM_L3_TGID). */ 39 bcm_trunk_t trunk; /* Trunk packet switched to (if 40 BCM_L3_TGID). */ 41 uint32 mpls_flags; /* BCM_MPLS flag definitions. */ 42 bcm_mpls_label_t mpls_label; /* MPLS label. */ 43 int mpls_qos_map_id; /* MPLS EXP map ID. */ 44 int mpls_ttl; /* MPLS TTL threshold. */ 45 uint8 mpls_pkt_pri; /* MPLS Packet Priority Value. */ 46 uint8 mpls_pkt_cfi; /* MPLS Packet CFI Value. */ 47 uint8 mpls_exp; /* MPLS Exp. */ 48 bcm_if_t encap_id; /* Encapsulation index. */ 49 bcm_failover_t failover_id; /* Failover Object Index. */ 50 bcm_if_t failover_if_id; /* Failover Egress Object index. */ 51 } bcmx_l3_egress_t; 52 53 /* 54 * L3 Host Structure. 55 * 56 * Contains information required for manipulating L3 host table entries. 57 * 58 * The BCM_L3_IP6 flag in l3a_flags must be set to specify whether the 59 * IPv4 or IPv6 addresses are valid. 60 */ 61 typedef struct bcmx_l3_host_s { 62 uint32 l3a_flags; /* See BCM_L3_xxx flag definitions. */ 63 bcm_vrf_t l3a_vrf; /* Virtual router instance. */ 64 bcm_ip_t l3a_ip_addr; /* Destination host IP address (IPv4). */ 65 bcm_ip6_t l3a_ip6_addr; /* Destination host IP address (IPv6). */ 66 bcm_cos_t l3a_pri; /* New priority in packet. */ 67 bcm_if_t l3a_intf; /* L3 intf associated with this address. */ 68 bcm_mac_t l3a_nexthop_mac; /* Next hop MAC addr. */ 69 bcmx_lport_t l3a_lport; /* if !(flags & BCM_L3_TGID) */ 70 bcm_trunk_t l3a_trunk; /* if (flags & BCM_L3_TGID) */ 71 int l3a_ipmc_ptr; /* Pointer to IPMC table. */ 72 int l3a_lookup_class; /* Classification lookup class ID. */ 73 } bcmx_l3_host_t; 74 75 /* Backward compatibility. */ 76 typedef bcmx_l3_host_t bcmx_l3_ip_t; 77 78 /* 79 * L3 Route Structure 80 * 81 * Contains information required for manipulating L3 route table entries. 82 * 83 * @pThe BCM_L3_IP6 flag in l3a_flags must be set to specify whether the 84 * IPv4 or IPv6 addresses are valid. 85 */ 86 typedef struct bcmx_l3_route_s { 87 uint32 l3a_flags; /* See BCM_L3_xxx flag definitions. */ 88 bcm_vrf_t l3a_vrf; /* Virtual router instance. */ 89 bcm_ip_t l3a_subnet; /* IP subnet address (IPv4). */ 90 bcm_ip6_t l3a_ip6_net; /* IP subnet address (IPv6). */ 91 bcm_ip_t l3a_ip_mask; /* IP subnet mask (IPv4). */ 92 bcm_ip6_t l3a_ip6_mask; /* IP subnet mask (IPv6). */ 93 bcm_if_t l3a_intf; /* L3 interface associated with route. */ 94 bcm_mac_t l3a_nexthop_mac; /* Next hop MAC address. */ 95 bcm_ip_t l3a_nexthop_ip; /* Next hop IP address (XGS1/2, IPv4). */ 96 bcmx_lport_t l3a_lport; /* if !(flags & BCM_L3_TGID) */ 97 bcm_trunk_t l3a_trunk; /* if (flags & BCM_L3_TGID) */ 98 bcm_vlan_t l3a_vid; /* BCM5695 only - for per-VLAN def 99 route. */ 100 bcm_cos_t l3a_pri; /* Priority (COS). */ 101 uint32 l3a_tunnel_option; /* Tunnel option value. */ 102 bcm_mpls_label_t l3a_mpls_label; /* MPLS label. */ 103 int l3a_lookup_class; /* Classification class ID. */ 104 } bcmx_l3_route_t; 105 106 /* L3 Information Structure */ 107 typedef bcm_l3_info_t bcmx_l3_info_t; 108 109 /* L3 Key Structure */ 110 typedef bcm_l3_key_t bcmx_l3_key_t; 111 112 /* L3 Source Binding Information Structure */ 113 typedef bcm_l3_source_bind_t bcmx_l3_source_bind_t; 114 115 /* L3 Ingress Structure */ 116 typedef bcm_l3_ingress_t bcmx_l3_ingress_t; 117 118 /* Initialize the L3 subsystem. */ 119 extern int bcmx_l3_init(void); 120 121 /* De-initialize the L3 subsystem. */ 122 extern int bcmx_l3_cleanup(void); 123 124 /* Enable/disable L3 function without clearing any L3 tables. */ 125 extern int bcmx_l3_enable_set( 126 int enable); 127 128 /* Get the status of hardware tables. */ 129 extern int bcmx_l3_info( 130 bcm_l3_info_t *l3info); 131 132 /* Initialize a bcm_l3_intf_t/bcmx_l3_intf_t structure. */ 133 extern int bcmx_l3_intf_t_init( 134 bcmx_l3_intf_t *intf); 135 136 /* Create a new L3 interface. */ 137 extern int bcmx_l3_intf_create( 138 bcm_l3_intf_t *intf); 139 140 /* Delete an L3 interface. */ 141 extern int bcmx_l3_intf_delete( 142 bcm_l3_intf_t *intf); 143 144 /* Delete all L3 interfaces. */ 145 extern int bcmx_l3_intf_delete_all(void); 146 147 /* Search for L3 interface by MAC address and VLAN. */ 148 extern int bcmx_l3_intf_find( 149 bcm_l3_intf_t *intf); 150 151 /* Search for L3 interface by VLAN only. */ 152 extern int bcmx_l3_intf_find_vlan( 153 bcm_l3_intf_t *intf); 154 155 /* Given the L3 interface number, return the interface information. */ 156 extern int bcmx_l3_intf_get( 157 bcm_l3_intf_t *intf); 158 159 /* Initialize a bcm_l3_egress_t/bcmx_l3_egress_t structure. */ 160 extern void bcmx_l3_egress_t_init( 161 bcmx_l3_egress_t *egr); 162 163 /* Create an Egress forwarding object. */ 164 extern int bcmx_l3_egress_create( 165 uint32 flags, 166 bcmx_l3_egress_t *egr, 167 bcm_if_t *intf); 168 169 /* Destroy an Egress forwarding object. */ 170 extern int bcmx_l3_egress_destroy( 171 bcm_if_t intf); 172 173 /* Get an Egress forwarding object. */ 174 extern int bcmx_l3_egress_get( 175 bcm_if_t intf, 176 bcmx_l3_egress_t *egr); 177 178 /* Find an interface pinting to an Egress forwarding object. */ 179 extern int bcmx_l3_egress_find( 180 bcmx_l3_egress_t *egr, 181 bcm_if_t *intf); 182 183 /* 184 * Traverse through the egress object table and run callback at each 185 * valid entry. 186 */ 187 extern int bcmx_l3_egress_traverse( 188 bcm_l3_egress_traverse_cb trav_fn, 189 void *user_data); 190 191 /* Create a Multipath Egress forwarding object. */ 192 extern int bcmx_l3_egress_multipath_create( 193 uint32 flags, 194 int intf_count, 195 bcm_if_t *intf_array, 196 bcm_if_t *mpintf); 197 198 /* Create a Multipath Egress forwarding object with specified path-width. */ 199 extern int bcmx_l3_egress_multipath_max_create( 200 uint32 flags, 201 int max_paths, 202 int intf_count, 203 bcm_if_t *intf_array, 204 bcm_if_t *mpintf); 205 206 /* Destroy an Egress Multipath forwarding object. */ 207 extern int bcmx_l3_egress_multipath_destroy( 208 bcm_if_t mpintf); 209 210 /* Get an Egress Multipath forwarding object. */ 211 extern int bcmx_l3_egress_multipath_get( 212 bcm_if_t mpintf, 213 int intf_size, 214 bcm_if_t *intf_array, 215 int *intf_count); 216 217 /* 218 * Add an Egress forwarding object to an Egress Multipath forwarding 219 * object. 220 */ 221 extern int bcmx_l3_egress_multipath_add( 222 bcm_if_t mpintf, 223 bcm_if_t intf); 224 225 /* 226 * Delete an Egress forwarding object from an Egress Multipath forwarding 227 * object. 228 */ 229 extern int bcmx_l3_egress_multipath_delete( 230 bcm_if_t mpintf, 231 bcm_if_t intf); 232 233 /* Find an interface pinting to an Egress Multipath forwarding object. */ 234 extern int bcmx_l3_egress_multipath_find( 235 int intf_count, 236 bcm_if_t *intf_array, 237 bcm_if_t *mpintf); 238 239 /* 240 * Traverse through the multipath egress object table and run callback at 241 * each valid entry. 242 */ 243 extern int bcmx_l3_egress_multipath_traverse( 244 bcm_l3_egress_multipath_traverse_cb trav_fn, 245 void *user_data); 246 247 /* Initialize a bcm_l3_ingress_t/bcmx_l3_ingress_t structure. */ 248 extern void bcmx_l3_ingress_t_init( 249 bcmx_l3_ingress_t *ing_intf); 250 251 /* Create an L3 Ingress Interface. */ 252 extern int bcmx_l3_ingress_create( 253 bcmx_l3_ingress_t *ing_intf, 254 bcm_if_t *intf_id); 255 256 /* Destroy an L3 Ingress Interface. */ 257 extern int bcmx_l3_ingress_destroy( 258 bcm_if_t intf_id); 259 260 /* Get L3 Ingress Interface configuration. */ 261 extern int bcmx_l3_ingress_get( 262 bcm_if_t intf, 263 bcmx_l3_ingress_t *ing_intf); 264 265 /* Find an identical ingress L3 interface. */ 266 extern int bcmx_l3_ingress_find( 267 bcmx_l3_ingress_t *ing_intf, 268 bcm_if_t *intf_id); 269 270 /* Initialize a bcm_l3_host_t/bcmx_l3_host_t structure. */ 271 extern int bcmx_l3_host_t_init( 272 bcmx_l3_host_t *ip); 273 274 /* Look up an L3 host table entry based on IP address. */ 275 extern int bcmx_l3_host_find( 276 bcmx_l3_host_t *info); 277 278 /* Add an entry into the L3 switching table. */ 279 extern int bcmx_l3_host_add( 280 bcmx_l3_host_t *info); 281 282 /* Delete an entry from the L3 host table. */ 283 extern int bcmx_l3_host_delete( 284 bcmx_l3_host_t *ip_addr); 285 286 /* Delete L3 entries based on IP prefix (network). */ 287 extern int bcmx_l3_host_delete_by_network( 288 bcmx_l3_route_t *ip_addr); 289 290 /* 291 * Deletes L3 entries that match or do not match a specified L3 interface 292 * number. 293 */ 294 extern int bcmx_l3_host_delete_by_interface( 295 bcmx_l3_host_t *info); 296 297 /* Deletes all L3 host table entries. */ 298 extern int bcmx_l3_host_delete_all( 299 bcmx_l3_host_t *info); 300 301 /* Return list of conflicts in the L3 table. */ 302 extern int bcmx_l3_host_conflict_get( 303 bcm_l3_key_t *ipkey, 304 bcm_l3_key_t *cf_array, 305 int cf_max, 306 int *cf_count); 307 308 /* Run L3 table aging. */ 309 extern int bcmx_l3_host_age( 310 uint32 flags, 311 bcm_l3_host_traverse_cb age_cb, 312 void *user_data); 313 314 /* Traverse through the L3 table and run callback at each valid L3 entry. */ 315 extern int bcmx_l3_host_traverse( 316 uint32 flags, 317 uint32 start, 318 uint32 end, 319 bcm_l3_host_traverse_cb cb, 320 void *user_data); 321 322 /* bcm_l3_host_invalidate_entry */ 323 extern int bcmx_l3_host_invalidate_entry( 324 bcm_ip_t info); 325 326 /* bcm_l3_host_validate_entry */ 327 extern int bcmx_l3_host_validate_entry( 328 bcm_ip_t info); 329 330 /* Initialize a bcm_l3_route_t/bcmx_l3_route_t_init structure. */ 331 extern int bcmx_l3_route_t_init( 332 bcmx_l3_route_t *route); 333 334 /* Add an IP route to the L3 route table. */ 335 extern int bcmx_l3_route_add( 336 bcmx_l3_route_t *info); 337 338 /* Delete an IP route from the DEFIP table. */ 339 extern int bcmx_l3_route_delete( 340 bcmx_l3_route_t *info); 341 342 /* Delete routes based on matching or non-matching L3 interface number. */ 343 extern int bcmx_l3_route_delete_by_interface( 344 bcmx_l3_route_t *info); 345 346 /* Delete all routes. */ 347 extern int bcmx_l3_route_delete_all( 348 bcmx_l3_route_t *info); 349 350 /* Look up a route given the network and netmask. */ 351 extern int bcmx_l3_route_get( 352 bcmx_l3_route_t *info); 353 354 /* Given a network, return all the paths for this route. */ 355 extern int bcmx_l3_route_multipath_get( 356 bcmx_l3_route_t *the_route, 357 bcmx_l3_route_t *path_array, 358 int max_path, 359 int *path_count); 360 361 /* Age the route table. */ 362 extern int bcmx_l3_route_age( 363 uint32 flags, 364 bcm_l3_route_traverse_cb age_out, 365 void *user_data); 366 367 /* Traverse through the routing table and run callback at each route. */ 368 extern int bcmx_l3_route_traverse( 369 uint32 flags, 370 uint32 start, 371 uint32 end, 372 bcm_l3_route_traverse_cb trav_fn, 373 void *user_data); 374 375 /* Set the maximum ECMP paths allowed for a route (XGS only). */ 376 extern int bcmx_l3_route_max_ecmp_set( 377 int max); 378 379 /* Get the maximum ECMP paths allowed for a route (XGS only). */ 380 extern int bcmx_l3_route_max_ecmp_get( 381 int *max); 382 383 /* 384 * Extract list of IPv6 prefixes which are forwarded based on lower 32 385 * bit of IPv6 address, treated as IPv4 address. 386 */ 387 extern int bcmx_l3_ip6_prefix_map_get( 388 int map_size, 389 bcm_ip6_t *ip6_array, 390 int *ip6_count); 391 392 /* 393 * Add IPv6 prefix to the list of prefixes which are forwarded based on 394 * lower 32 bit of IPv6 address, treated as IPv4 address. 395 */ 396 extern int bcmx_l3_ip6_prefix_map_add( 397 bcm_ip6_t ip6_addr); 398 399 /* 400 * Remove IPv6 prefix from the list of prefixes which are forwarded based 401 * on lower 32 bit of IPv6 address, treated as IPv4 address. 402 */ 403 extern int bcmx_l3_ip6_prefix_map_delete( 404 bcm_ip6_t ip6_addr); 405 406 /* 407 * Remove all the IPv6 prefixes from the list of prefixes which are 408 * forwarded based on lower 32 bit of IPv6 address, treated as IPv4 409 * address. 410 */ 411 extern int bcmx_l3_ip6_prefix_map_delete_all(void); 412 413 /* Enable/disable packet and byte counters for the selected VRF. */ 414 extern int bcmx_l3_vrf_stat_enable_set( 415 bcm_vrf_t vrf, 416 int enable); 417 418 /* Get 64-bit counter value for specified VRF statistic type. */ 419 extern int bcmx_l3_vrf_stat_get( 420 bcm_vrf_t vrf, 421 bcm_l3_vrf_stat_t stat, 422 uint64 *val); 423 424 /* Get lower 32-bit counter value for specified VRF statistic type. */ 425 extern int bcmx_l3_vrf_stat_get32( 426 bcm_vrf_t vrf, 427 bcm_l3_vrf_stat_t stat, 428 uint32 *val); 429 430 /* Set 64-bit counter value for specified VRF statistic type. */ 431 extern int bcmx_l3_vrf_stat_set( 432 bcm_vrf_t vrf, 433 bcm_l3_vrf_stat_t stat, 434 uint64 val); 435 436 /* Set lower 32-bit counter value for specified VRF statistic type. */ 437 extern int bcmx_l3_vrf_stat_set32( 438 bcm_vrf_t vrf, 439 bcm_l3_vrf_stat_t stat, 440 uint32 val); 441 442 /* Get 64-bit counter value for multiple VRF statistic types. */ 443 extern int bcmx_l3_vrf_stat_multi_get( 444 bcm_vrf_t vrf, 445 int nstat, 446 bcm_l3_vrf_stat_t *stat_arr, 447 uint64 *value_arr); 448 449 /* Get lower 32-bit counter value for multiple VRF statistic types. */ 450 extern int bcmx_l3_vrf_stat_multi_get32( 451 bcm_vrf_t vrf, 452 int nstat, 453 bcm_l3_vrf_stat_t *stat_arr, 454 uint32 *value_arr); 455 456 /* Set 64-bit counter value for multiple VRF statistic types. */ 457 extern int bcmx_l3_vrf_stat_multi_set( 458 bcm_vrf_t vrf, 459 int nstat, 460 bcm_l3_vrf_stat_t *stat_arr, 461 uint64 *value_arr); 462 463 /* Set lower 32-bit counter value for multiple VRF statistic types. */ 464 extern int bcmx_l3_vrf_stat_multi_set32( 465 bcm_vrf_t vrf, 466 int nstat, 467 bcm_l3_vrf_stat_t *stat_arr, 468 uint32 *value_arr); 469 470 /* Initialize a bcm_l3_source_bind_t structure. */ 471 extern void bcmx_l3_source_bind_t_init( 472 bcmx_l3_source_bind_t *info); 473 474 /* Enable or disable l3 source binding checks on an ingress port. */ 475 extern int bcmx_l3_source_bind_enable_set( 476 bcm_gport_t port, 477 int enable); 478 479 /* 480 * Retrieve whether l3 source binding checks are performed on an ingress 481 * port. 482 */ 483 extern int bcmx_l3_source_bind_enable_get( 484 bcm_gport_t port, 485 int *enable); 486 487 /* Add or replace an L3 source binding. */ 488 extern int bcmx_l3_source_bind_add( 489 bcmx_l3_source_bind_t *info); 490 491 /* Remove an existing L3 source binding. */ 492 extern int bcmx_l3_source_bind_delete( 493 bcmx_l3_source_bind_t *info); 494 495 /* Remove all existing L3 source bindings. */ 496 extern int bcmx_l3_source_bind_delete_all(void); 497 498 /* Retrieve the details of an existing L3 source binding. */ 499 extern int bcmx_l3_source_bind_get( 500 bcmx_l3_source_bind_t *info); 501 502 /* 503 * Add VRID for the given VSI. Adding a VRID using this API means the 504 * physical node has become the master for the virtual router 505 */ 506 extern int bcmx_l3_vrrp_add( 507 bcm_vlan_t vlan, 508 uint32 vrid); 509 510 /* Delete VRID for a particulat VLAN/VSI */ 511 extern int bcmx_l3_vrrp_delete( 512 bcm_vlan_t vlan, 513 uint32 vrid); 514 515 /* Delete all the VRIDs for a particular VLAN/VSI */ 516 extern int bcmx_l3_vrrp_delete_all( 517 bcm_vlan_t vlan); 518 519 /* 520 * Get all the VRIDs for which the physical node is master for the 521 * virtual routers on the given VLAN/VSI 522 */ 523 extern int bcmx_l3_vrrp_get( 524 bcm_vlan_t vlan, 525 int alloc_size, 526 int *vrid_array, 527 int *count); 528 529 /* Backward compatibility. */ 530 #define bcmx_l3_enable bcmx_l3_enable_set 531 532 /* Backward compatibility. */ 533 #define bcmx_l3_defip_ecmp_max_get bcmx_l3_defip_max_ecmp_get 534 535 #endif /* defined(INCLUDE_L3) */ 536 537 #endif /* __BCMX_L3_H__ */