l2gre.h (15162B)
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_L2GRE_H__ 11 #define __BCM_L2GRE_H__ 12 13 #if defined(INCLUDE_L3) 14 15 #include <bcm/types.h> 16 #include <bcm/l3.h> 17 #include <bcm/tunnel.h> 18 19 #if defined(INCLUDE_L3) 20 /* BCM_L2GRE_VPN_* flags for L2GRE VPN Create. */ 21 #define BCM_L2GRE_VPN_ELINE 0x00000001 22 #define BCM_L2GRE_VPN_ELAN 0x00000002 23 #define BCM_L2GRE_VPN_WITH_ID 0x00000004 24 #define BCM_L2GRE_VPN_WITH_VPNID 0x00000008 25 #define BCM_L2GRE_VPN_SERVICE_TAGGED 0x00000010 26 #define BCM_L2GRE_VPN_SERVICE_VLAN_ADD 0x00000020 27 #define BCM_L2GRE_VPN_SERVICE_VLAN_REPLACE 0x00000040 28 #define BCM_L2GRE_VPN_SERVICE_VLAN_DELETE 0x00000080 29 #define BCM_L2GRE_VPN_SERVICE_VLAN_TPID_REPLACE 0x00000100 30 #define BCM_L2GRE_VPN_SERVICE_VLAN_PRI_TPID_REPLACE 0x00000200 31 #define BCM_L2GRE_VPN_SERVICE_VLAN_PRI_REPLACE 0x00000400 32 #define BCM_L2GRE_VPN_SERVICE_PRI_REPLACE 0x00000800 33 #define BCM_L2GRE_VPN_SERVICE_TPID_REPLACE 0x00001000 34 #define BCM_L2GRE_VPN_REPLACE 0x00002000 35 #define BCM_L2GRE_VPN_UNKNOWN_UCAST_REPLACE 0x00004000 36 #define BCM_L2GRE_VPN_UNKNOWN_MCAST_REPLACE 0x00008000 37 #define BCM_L2GRE_VPN_BCAST_REPLACE 0x00010000 38 #endif 39 40 #if defined(INCLUDE_L3) 41 /* BCM_L2GRE_MULTICAST_TUNNEL_STATE_BUD_* flags. */ 42 #define BCM_L2GRE_MULTICAST_TUNNEL_STATE_BUD_ENABLE 0x00000001 43 #define BCM_L2GRE_MULTICAST_TUNNEL_STATE_BUD_DISABLE 0x00000002 44 #endif 45 46 #if defined(INCLUDE_L3) 47 /* L2GRE VPN Definitions. */ 48 #define BCM_L2GRE_VPN_INVALID 0xFFFF /* Invalid L2GRE VPN */ 49 #endif 50 51 #if defined(INCLUDE_L3) 52 /* L2GRE-VPN Config Structure. */ 53 typedef struct bcm_l2gre_vpn_config_s { 54 uint32 flags; /* BCM_L2GRE_VPN_xxx. */ 55 bcm_vpn_t vpn; /* L2GRE VPN */ 56 uint32 vpnid; /* VPNID */ 57 uint8 pkt_pri; /* Packet Priority */ 58 uint8 pkt_cfi; /* Packet CFI */ 59 uint16 egress_service_tpid; /* Service TPID */ 60 bcm_vlan_t egress_service_vlan; /* Service VLAN */ 61 bcm_multicast_t broadcast_group; 62 bcm_multicast_t unknown_unicast_group; 63 bcm_multicast_t unknown_multicast_group; 64 bcm_gport_t match_port_class; /* local port vlan domain */ 65 } bcm_l2gre_vpn_config_t; 66 #endif 67 68 #if defined(INCLUDE_L3) 69 /* Initialize L2GRE VPN config structure. */ 70 extern void bcm_l2gre_vpn_config_t_init( 71 bcm_l2gre_vpn_config_t *info); 72 #endif 73 74 #ifndef BCM_HIDE_DISPATCHABLE 75 76 #if defined(INCLUDE_L3) 77 /* 78 * Create or update L2GRE VPN. 79 * When create a L2GRE VPN: 80 * If use BCM_L2GRE_VPN_WITH_VPNID, both VFI and VNID will be created. 81 * If not use flag BCM_L2GRE_VPN_WITH_VPNID, only VFI will be created. 82 * When update an exist L2GRE VPN(BCM_L2GRE_VPN_REPLACE should be used): 83 * If use both BCM_L2GRE_VPN_REPLACE and BCM_L2GRE_VPN_WITH_VPNID, both 84 * VFI and VNID will be created. 85 * If only use BCM_L2GRE_VPN_REPLACE, the VNID will be removed. 86 */ 87 extern int bcm_l2gre_vpn_create( 88 int unit, 89 bcm_l2gre_vpn_config_t *info); 90 #endif 91 92 #if defined(INCLUDE_L3) 93 /* Destroy L2GRE VPN. */ 94 extern int bcm_l2gre_vpn_destroy( 95 int unit, 96 bcm_vpn_t l2vpn); 97 #endif 98 99 #if defined(INCLUDE_L3) 100 /* Destroy L2GRE VPN. */ 101 extern int bcm_l2gre_vpn_destroy_all( 102 int unit); 103 #endif 104 105 #if defined(INCLUDE_L3) 106 /* Get L2GRE VPN. */ 107 extern int bcm_l2gre_vpn_get( 108 int unit, 109 bcm_vpn_t l2vpn, 110 bcm_l2gre_vpn_config_t *info); 111 #endif 112 113 #endif /* BCM_HIDE_DISPATCHABLE */ 114 115 /* L2GRE vpn callback function prototype */ 116 #if defined(INCLUDE_L3) 117 typedef int(*bcm_l2gre_vpn_traverse_cb)( 118 int unit, 119 bcm_l2gre_vpn_config_t *info, 120 void *user_data); 121 #endif 122 123 #ifndef BCM_HIDE_DISPATCHABLE 124 125 #if defined(INCLUDE_L3) 126 /* 127 * Traverse all valid L2GRE VPN entries and call the supplied callback 128 * routine. 129 */ 130 extern int bcm_l2gre_vpn_traverse( 131 int unit, 132 bcm_l2gre_vpn_traverse_cb cb, 133 void *user_data); 134 #endif 135 136 #endif /* BCM_HIDE_DISPATCHABLE */ 137 138 #if defined(INCLUDE_L3) 139 /* L2GRE port match criteria. */ 140 typedef enum bcm_l2gre_port_match_e { 141 BCM_L2GRE_PORT_MATCH_INVALID = 0, /* Illegal. */ 142 BCM_L2GRE_PORT_MATCH_NONE = 1, /* No source match criteria. */ 143 BCM_L2GRE_PORT_MATCH_PORT = 2, /* {Module, Port} or Trunk. */ 144 BCM_L2GRE_PORT_MATCH_PORT_VLAN = 3, /* Mod/port/trunk + outer VLAN. */ 145 BCM_L2GRE_PORT_MATCH_PORT_INNER_VLAN = 4, /* Mod/port/trunk + inner VLAN. */ 146 BCM_L2GRE_PORT_MATCH_PORT_VLAN_STACKED = 5, /* Mod/port/trunk + outer/inner VLAN. */ 147 BCM_L2GRE_PORT_MATCH_VLAN_PRI = 6, /* Mod/port/trunk + VLAN-PRI + VLAN-CFI. */ 148 BCM_L2GRE_PORT_MATCH_VPNID = 7, /* Match L2GRE VPNID */ 149 BCM_L2GRE_PORT_MATCH_SHARE = 8, /* Shared logical port */ 150 BCM_L2GRE_PORT_MATCH_PORT_ITAG = 9, /* Mod/port/trunk + inner TAG. */ 151 BCM_L2GRE_PORT_MATCH_COUNT = 10 /* Must be last. */ 152 } bcm_l2gre_port_match_t; 153 #endif 154 155 #if defined(INCLUDE_L3) 156 /* BCM_L2GRE_* flags. */ 157 #define BCM_L2GRE_PORT_WITH_ID (1 << 0) /* create L2GRE port with 158 specified ID */ 159 #define BCM_L2GRE_PORT_DROP (1 << 1) /* Drop matching packets */ 160 #define BCM_L2GRE_PORT_NETWORK (1 << 2) /* Network facing 161 interface */ 162 #define BCM_L2GRE_PORT_COUNTED (1 << 3) /* Maintain packet/byte 163 counts */ 164 #define BCM_L2GRE_PORT_REPLACE (1 << 4) /* Replace existing entry */ 165 #define BCM_L2GRE_PORT_INT_PRI_SET (1 << 5) /* Use Specified pri for 166 internal priority */ 167 #define BCM_L2GRE_PORT_INT_PRI_MAP (1 << 6) /* Use specified exp_map 168 for internal priority */ 169 #define BCM_L2GRE_PORT_EGRESS_TUNNEL (1 << 7) /* Specified Egress 170 tunnel is valid */ 171 #define BCM_L2GRE_PORT_SERVICE_TAGGED (1 << 8) /* Service tag mode */ 172 #define BCM_L2GRE_PORT_SERVICE_VLAN_ADD (1 << 9) /* Add SD-tag */ 173 #define BCM_L2GRE_PORT_SERVICE_VLAN_REPLACE (1 << 10) /* Replace VLAN not TPID */ 174 #define BCM_L2GRE_PORT_SERVICE_VLAN_DELETE (1 << 11) /* Delete VLAN Tag */ 175 #define BCM_L2GRE_PORT_SERVICE_VLAN_TPID_REPLACE (1 << 12) /* Replace VLAN and TPID */ 176 #define BCM_L2GRE_PORT_SERVICE_VLAN_PRI_TPID_REPLACE (1 << 13) /* Replace VLAN, VLAN-PRI 177 and TPID */ 178 #define BCM_L2GRE_PORT_SERVICE_VLAN_PRI_REPLACE (1 << 14) /* Replace VLAN and 179 VLAN-PRI */ 180 #define BCM_L2GRE_PORT_SERVICE_PRI_REPLACE (1 << 15) /* Replace VLAN-PRI only */ 181 #define BCM_L2GRE_PORT_SERVICE_TPID_REPLACE (1 << 16) /* Replace TPID only */ 182 #define BCM_L2GRE_PORT_MULTICAST (1 << 19) /* Create Multicast-only 183 L2GRE Tunnel */ 184 #define BCM_L2GRE_PORT_DEFAULT (1 << 20) /* Create L2GRE Default 185 Network Port */ 186 #define BCM_L2GRE_PORT_ENABLE_VLAN_CHECKS (1 << 21) /* Enable vlan check, 187 only for access VP 188 derived from 189 VLAN_XLATE */ 190 #endif 191 192 #if defined(INCLUDE_L3) 193 /* L2GRE Gport */ 194 typedef struct bcm_l2gre_port_s { 195 bcm_gport_t l2gre_port_id; /* GPORT identifier. */ 196 uint32 flags; /* BCM_L2GRE_PORT_xxx. */ 197 uint32 if_class; /* Interface class ID. */ 198 uint16 int_pri; /* Internal Priority */ 199 uint8 pkt_pri; /* Packet Priority */ 200 uint8 pkt_cfi; /* Packet CFI */ 201 uint16 egress_service_tpid; /* Service Vlan TPID Value */ 202 bcm_vlan_t egress_service_vlan; /* SD-TAG Vlan ID. */ 203 uint16 mtu; /* MTU */ 204 bcm_gport_t match_port; /* Match port / trunk */ 205 bcm_l2gre_port_match_t criteria; /* Match criteria */ 206 bcm_vlan_t match_vlan; /* Outer VLAN ID to match. */ 207 bcm_vlan_t match_inner_vlan; /* Inner VLAN ID to match. */ 208 bcm_gport_t egress_tunnel_id; /* Tunnel Initiator ID */ 209 bcm_gport_t match_tunnel_id; /* Tunnel Terminator ID */ 210 bcm_if_t egress_if; /* L2GRE egress object. */ 211 bcm_switch_network_group_t network_group_id; /* Split Horizon network group 212 identifier. */ 213 } bcm_l2gre_port_t; 214 #endif 215 216 #if defined(INCLUDE_L3) 217 /* Initialize L2GRE port structure. */ 218 extern void bcm_l2gre_port_t_init( 219 bcm_l2gre_port_t *l2gre_port); 220 #endif 221 222 #ifndef BCM_HIDE_DISPATCHABLE 223 224 #if defined(INCLUDE_L3) 225 /* Initialize the BCM L2GRE subsystem. */ 226 extern int bcm_l2gre_init( 227 int unit); 228 #endif 229 230 #if defined(INCLUDE_L3) 231 /* Detach the BCM L2GRE subsystem. */ 232 extern int bcm_l2gre_cleanup( 233 int unit); 234 #endif 235 236 #if defined(INCLUDE_L3) 237 /* bcm_l2gre_port_add adds a Access or Network L2GRE port */ 238 extern int bcm_l2gre_port_add( 239 int unit, 240 bcm_vpn_t l2vpn, 241 bcm_l2gre_port_t *l2gre_port); 242 #endif 243 244 #if defined(INCLUDE_L3) 245 /* bcm_l2gre_port_delete L2GRE port from L2GRE network. */ 246 extern int bcm_l2gre_port_delete( 247 int unit, 248 bcm_vpn_t l2vpn, 249 bcm_gport_t l2gre_port_id); 250 #endif 251 252 #if defined(INCLUDE_L3) 253 /* bcm_l2gre_port_delete L2GRE port from L2GRE network. */ 254 extern int bcm_l2gre_port_delete_all( 255 int unit, 256 bcm_vpn_t l2vpn); 257 #endif 258 259 #if defined(INCLUDE_L3) 260 /* Get L2GRE port information. */ 261 extern int bcm_l2gre_port_get( 262 int unit, 263 bcm_vpn_t l2vpn, 264 bcm_l2gre_port_t *l2gre_port); 265 #endif 266 267 #if defined(INCLUDE_L3) 268 /* Get all L2GRE port information. */ 269 extern int bcm_l2gre_port_get_all( 270 int unit, 271 bcm_vpn_t l2vpn, 272 int port_max, 273 bcm_l2gre_port_t *port_array, 274 int *port_count); 275 #endif 276 277 #if defined(INCLUDE_L3) 278 /* Create L2GRE Tunnel Initiator. */ 279 extern int bcm_l2gre_tunnel_initiator_create( 280 int unit, 281 bcm_tunnel_initiator_t *info); 282 #endif 283 284 #if defined(INCLUDE_L3) 285 /* Delete L2GRE Tunnel Initiator. */ 286 extern int bcm_l2gre_tunnel_initiator_destroy( 287 int unit, 288 bcm_gport_t l2gre_tunnel_id); 289 #endif 290 291 #if defined(INCLUDE_L3) 292 /* Destroy all L2GRE Tunnel Initiators */ 293 extern int bcm_l2gre_tunnel_initiator_destroy_all( 294 int unit); 295 #endif 296 297 #if defined(INCLUDE_L3) 298 /* Get L2GRE Tunnel Initiator. */ 299 extern int bcm_l2gre_tunnel_initiator_get( 300 int unit, 301 bcm_tunnel_initiator_t *info); 302 #endif 303 304 #if defined(INCLUDE_L3) 305 /* Traverse L2GRE Tunnel initiator. */ 306 extern int bcm_l2gre_tunnel_initiator_traverse( 307 int unit, 308 bcm_tunnel_initiator_traverse_cb cb, 309 void *user_data); 310 #endif 311 312 #if defined(INCLUDE_L3) 313 /* Create L2GRE Tunnel terminator. */ 314 extern int bcm_l2gre_tunnel_terminator_create( 315 int unit, 316 bcm_tunnel_terminator_t *info); 317 #endif 318 319 #if defined(INCLUDE_L3) 320 /* Update L2GRE Tunnel terminator. */ 321 extern int bcm_l2gre_tunnel_terminator_update( 322 int unit, 323 bcm_tunnel_terminator_t *info); 324 #endif 325 326 #if defined(INCLUDE_L3) 327 /* Delete L2GRE Tunnel terminator. */ 328 extern int bcm_l2gre_tunnel_terminator_destroy( 329 int unit, 330 bcm_gport_t l2gre_tunnel_id); 331 #endif 332 333 #if defined(INCLUDE_L3) 334 /* Destroy all L2GRE Tunnel terminators */ 335 extern int bcm_l2gre_tunnel_terminator_destroy_all( 336 int unit); 337 #endif 338 339 #if defined(INCLUDE_L3) 340 /* Get L2GRE Tunnel terminator. */ 341 extern int bcm_l2gre_tunnel_terminator_get( 342 int unit, 343 bcm_tunnel_terminator_t *info); 344 #endif 345 346 #if defined(INCLUDE_L3) 347 /* Traverse L2GRE Tunnel terminator. */ 348 extern int bcm_l2gre_tunnel_terminator_traverse( 349 int unit, 350 bcm_tunnel_terminator_traverse_cb cb, 351 void *user_data); 352 #endif 353 354 #endif /* BCM_HIDE_DISPATCHABLE */ 355 356 /* Ingress and Egress statistics maintained per L2gre. */ 357 typedef enum bcm_l2gre_stat_e { 358 bcmL2greInPackets = 0, /* Packets that ingress on the L2gre */ 359 bcmL2greOutPackets = 1, /* Packets that egress on the L2gre */ 360 bcmL2greInBytes = 2, /* Bytes that ingress on the L2gre */ 361 bcmL2greOutBytes = 3 /* Bytes that egress on the L2gre */ 362 } bcm_l2gre_stat_t; 363 364 #ifndef BCM_HIDE_DISPATCHABLE 365 366 /* Attach counters entries to the given l2gre vp/vpn index */ 367 extern int bcm_l2gre_stat_attach( 368 int unit, 369 bcm_gport_t port, 370 bcm_vpn_t vpn, 371 uint32 stat_counter_id); 372 373 /* Detach counters entries to the given l2gre vp/vpn index. */ 374 extern int bcm_l2gre_stat_detach( 375 int unit, 376 bcm_gport_t port, 377 bcm_vpn_t vpn); 378 379 /* Get counter statistic values for a l2gre vp/vpn index. */ 380 extern int bcm_l2gre_stat_counter_get( 381 int unit, 382 bcm_gport_t port, 383 bcm_vpn_t vpn, 384 bcm_l2gre_stat_t stat, 385 uint32 num_entries, 386 uint32 *counter_indexes, 387 bcm_stat_value_t *counter_values); 388 389 /* 390 * Force an immediate counter update and retrieve counter statistic 391 * values for 392 * a l2gre vp/vpn index. 393 */ 394 extern int bcm_l2gre_stat_counter_sync_get( 395 int unit, 396 bcm_gport_t port, 397 bcm_vpn_t vpn, 398 bcm_l2gre_stat_t stat, 399 uint32 num_entries, 400 uint32 *counter_indexes, 401 bcm_stat_value_t *counter_values); 402 403 /* Set counter statistic values for a l2gre vp/vpn index */ 404 extern int bcm_l2gre_stat_counter_set( 405 int unit, 406 bcm_gport_t port, 407 bcm_vpn_t vpn, 408 bcm_l2gre_stat_t stat, 409 uint32 num_entries, 410 uint32 *counter_indexes, 411 bcm_stat_value_t *counter_values); 412 413 /* Get multiple counter statistic values for multiple l2gre vp/vpn index. */ 414 extern int bcm_l2gre_stat_multi_get( 415 int unit, 416 bcm_gport_t port, 417 bcm_vpn_t vpn, 418 int nstat, 419 bcm_l2gre_stat_t *stat_arr, 420 uint64 *value_arr); 421 422 /* 423 * Get 32bit multiple counter statistic values for multiple l2gre vp/vpn 424 * index. 425 */ 426 extern int bcm_l2gre_stat_multi_get32( 427 int unit, 428 bcm_gport_t port, 429 bcm_vpn_t vpn, 430 int nstat, 431 bcm_l2gre_stat_t *stat_arr, 432 uint32 *value_arr); 433 434 /* Set multiple counter statistic values for multiple l2gre vp/vpn index. */ 435 extern int bcm_l2gre_stat_multi_set( 436 int unit, 437 bcm_gport_t port, 438 bcm_vpn_t vpn, 439 int nstat, 440 bcm_l2gre_stat_t *stat_arr, 441 uint64 *value_arr); 442 443 /* 444 * Set 32bit multiple counter statistic values for multiple l2gre vp/vpn 445 * index. 446 */ 447 extern int bcm_l2gre_stat_multi_set32( 448 int unit, 449 bcm_gport_t port, 450 bcm_vpn_t vpn, 451 int nstat, 452 bcm_l2gre_stat_t *stat_arr, 453 uint32 *value_arr); 454 455 /* Get stat counter ID associated with given l2gre vp/vpn index. */ 456 extern int bcm_l2gre_stat_id_get( 457 int unit, 458 bcm_gport_t port, 459 bcm_vpn_t vpn, 460 bcm_l2gre_stat_t stat, 461 uint32 *stat_counter_id); 462 463 #endif /* defined(INCLUDE_L3) */ 464 465 #endif /* BCM_HIDE_DISPATCHABLE */ 466 467 #endif /* __BCM_L2GRE_H__ */