mim.h (16590B)
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_MIM_H__ 11 #define __BCM_MIM_H__ 12 13 #if defined(INCLUDE_L3) 14 15 #include <bcm/types.h> 16 #include <bcm/multicast.h> 17 #include <bcm/l3.h> 18 #include <bcm/switch.h> 19 20 /* MAC-in-MAC VPN Flags. */ 21 #define BCM_MIM_VPN_MIM 0x00000001 /* ELAN VPN service */ 22 #define BCM_MIM_VPN_WITH_ID 0x00000002 23 #define BCM_MIM_VPN_REPLACE 0x00000004 24 #define BCM_MIM_VPN_MATCH_SERVICE_VLAN_TPID 0x00000008 25 #define BCM_MIM_VPN_PBB_TE 0x00000010 /* P2P service for 26 Provider Backbone 27 Transport */ 28 #define BCM_MIM_VPN_BVLAN 0x00000020 /* Creates Backbone VLAN */ 29 #define BCM_MIM_VPN_SERVICE_ENCAP_WITH_ID 0x00000040 /* Used when the 30 application provides 31 service_encap_id */ 32 #define BCM_MIM_VPN_QOS_SDTAG_NO_ACTION 0x00000080 /* SDTAG priority control 33 per VPN */ 34 #define BCM_MIM_VPN_QOS_SDTAG_FIX_PRIORITY 0x00000100 /* SDTAG priority control 35 per VPN, fixed 36 priority */ 37 #define BCM_MIM_VPN_QOS_SDTAG_MAP_INT_PRIORITY 0x00000200 /* SDTAG priority control 38 per VPN, map priority */ 39 #define BCM_MIM_VPN_QOS_ITAG_FIX_PRIORITY 0x00000400 /* ITAG priority control 40 per VPN, fixed 41 priority */ 42 #define BCM_MIM_VPN_QOS_ITAG_MAP_SDTAG_PRIORITY 0x00000800 /* ITAG priority control 43 per VPN, map priority */ 44 #define BCM_MIM_VPN_QOS_INGRESS_MAP_FIX_INT_PRIORITY 0x00001000 /* Fixed internal 45 priority based on VFI */ 46 #define BCM_MIM_VPN_QOS_INGRESS_MAP_INT_PRIORITY 0x00002000 /* Map internal priority 47 based on VFI */ 48 #define BCM_MIM_VPN_BVID_DROP_NOMATCH 0x00004000 /* Drop pkt if BVID check 49 fails */ 50 #define BCM_MIM_VPN_ELINE 0x00008000 /* Point-to-Point VPN 51 service */ 52 #define BCM_MIM_VPN_SERVICE_ENCAP_INGRESS_WIDE 0x00010000 /* create 53 service_encap_id wide 54 mode */ 55 #define BCM_MIM_VPN_EGRESS_SERVICE_TPID_REPLACE 0x00020000 /* Replace TPID in 56 SD-TAG on MIM egress */ 57 #define BCM_MIM_VPN_INGRESS_ONLY 0x00040000 /* Create the MiM VPN on 58 ingress pipe only 59 (InLIF, Spanning tree, 60 MC groups) */ 61 #define BCM_MIM_VPN_EGRESS_ONLY 0x00080000 /* Create the MiM VPN on 62 egress pipe only (VSI 63 to ISID table) */ 64 #define BCM_MIM_VPN_MATCH_SERVICE_SMAC 0x00100000 /* Match entry include 65 Source B-MAC address */ 66 67 /* MAC-in-MAC Port Flags. */ 68 #define BCM_MIM_PORT_WITH_ID 0x00000001 69 #define BCM_MIM_PORT_ENCAP_WITH_ID 0x00000002 70 #define BCM_MIM_PORT_REPLACE 0x00000004 71 #define BCM_MIM_PORT_DROP 0x00000008 72 #define BCM_MIM_PORT_TYPE_ACCESS 0x00000010 73 #define BCM_MIM_PORT_TYPE_BACKBONE 0x00000020 74 #define BCM_MIM_PORT_TYPE_PEER 0x00000040 75 #define BCM_MIM_PORT_MATCH_SERVICE_VLAN_TPID 0x00000080 76 #define BCM_MIM_PORT_EGRESS_TUNNEL_SERVICE_REPLACE 0x00000100 77 #define BCM_MIM_PORT_EGRESS_LABEL 0x00000200 78 #define BCM_MIM_PORT_EGRESS_SERVICE_VLAN_TAGGED 0x00000400 79 #define BCM_MIM_PORT_EGRESS_SERVICE_VLAN_ADD 0x00000800 80 #define BCM_MIM_PORT_EGRESS_SERVICE_VLAN_REPLACE 0x00001000 81 #define BCM_MIM_PORT_EGRESS_SERVICE_VLAN_DELETE 0x00002000 82 #define BCM_MIM_PORT_EGRESS_SERVICE_VLAN_TPID_REPLACE 0x00004000 83 #define BCM_MIM_PORT_EGRESS_SERVICE_VLAN_PRI_REPLACE 0x00008000 84 #define BCM_MIM_PORT_EGRESS_SERVICE_VLAN_PRI_TPID_REPLACE 0x00010000 85 #define BCM_MIM_PORT_EGRESS_TUNNEL_DEST_MAC_USE_SERVICE 0x00020000 86 #define BCM_MIM_PORT_EXTENDED 0x00040000 /* Use the extended P2P 87 service */ 88 #define BCM_MIM_PORT_LOCAL_PROTECTION 0x00080000 /* Local protection 89 according to link 90 status */ 91 #define BCM_MIM_PORT_SERVICE_ENCAP_WITH_ID 0x00100000 /* Used when the 92 application provides 93 service_encap_id */ 94 #define BCM_MIM_PORT_FIX_PRIORITY 0x00200000 /* Assign fixed priority */ 95 #define BCM_MIM_PORT_DEFAULT 0x00400000 /* MiM default SVP */ 96 #define BCM_MIM_PORT_SERVICE_ENCAP_INGERSS_WIDE 0x00800000 /* Used when the 97 application creates 98 service_encap_id wide 99 mode */ 100 #define BCM_MIM_PORT_FAILOVER_DROP 0x01000000 /* Be enabled to drop 101 data for 1+1 102 protection */ 103 #define BCM_MIM_PORT_CASCADED 0x02000000 /* Create hierarchical 104 FEC */ 105 #define BCM_MIM_PORT_ENCAP_OVERLAY 0x04000000 /* Create overlay link 106 layer */ 107 #define BCM_MIM_PORT_EGRESS_SERVICE_PRI_REPLACE 0x08000000 /* Replace priority in 108 SD-TAG on MIM egress */ 109 #define BCM_MIM_PORT_EGRESS_SERVICE_TPID_REPLACE 0x10000000 /* Replace TPID in SD-TAG 110 on MIM egress */ 111 #define BCM_MIM_PORT_SHARE 0x20000000 /* A flag only to be used 112 with 113 BCM_MIM_PORT_TYPE_PEER 114 flag for creating a 115 share peer port */ 116 #define BCM_MIM_PORT_PEER_NO_BTAG 0x40000000 /* Control whether add 117 B-TAG for peer port 118 traffic */ 119 #define BCM_MIM_PORT_NO_LEARN_ENTRY 0x80000000 120 121 /* MAC-in-MAC Port match criteria. */ 122 typedef enum bcm_mim_port_match_e { 123 BCM_MIM_PORT_MATCH_INVALID = 0, /* Illegal. */ 124 BCM_MIM_PORT_MATCH_PORT = 1, 125 BCM_MIM_PORT_MATCH_PORT_VLAN = 2, 126 BCM_MIM_PORT_MATCH_PORT_VLAN_STACKED = 3, 127 BCM_MIM_PORT_MATCH_TUNNEL_VLAN_SRCMAC = 4, 128 BCM_MIM_PORT_MATCH_LABEL = 5, 129 BCM_MIM_PORT_MATCH_SHARE = 6 130 } bcm_mim_port_match_t; 131 132 /* MAC-in-MAC VPN structure. */ 133 typedef struct bcm_mim_vpn_config_s { 134 uint32 flags; /* Configuration flags */ 135 bcm_mim_vpn_t vpn; /* VPN ID. */ 136 int lookup_id; /* The I-SID value */ 137 uint16 match_service_tpid; /* Incoming SD tag TPID */ 138 bcm_multicast_t broadcast_group; /* Broadcast group */ 139 bcm_multicast_t unknown_unicast_group; /* Unknown unicast group */ 140 bcm_multicast_t unknown_multicast_group; /* Unknown multicast group */ 141 bcm_policer_t policer_id; /* Policer ID to be used */ 142 bcm_if_t service_encap_id; /* Service encap Identifier */ 143 uint8 int_pri; /* Fixed internal priority */ 144 int qos_map_id; /* Mapped priority */ 145 bcm_vlan_t tunnel_vlan; /* B-domain VID */ 146 int inlif_counting_profile; /* In LIF counting profile */ 147 int outlif_counting_profile; /* Out LIF counting profile */ 148 bcm_vlan_protocol_packet_ctrl_t protocol_pkt; /* Protocol packet control */ 149 uint16 egress_service_tpid; /* egress SD tag TPID */ 150 bcm_mac_t match_service_smac; /* Source B-MAC address */ 151 bcm_vlan_t default_vlan; /* Requires BROADCOM_PREMIUM license */ 152 } bcm_mim_vpn_config_t; 153 154 /* MAC-in-MAC Port structure. */ 155 typedef struct bcm_mim_port_s { 156 bcm_gport_t mim_port_id; /* Interface id (VP). */ 157 uint32 flags; /* Configuration flags */ 158 int if_class; /* Interface class ID. */ 159 bcm_gport_t port; /* Physical port / trunk. */ 160 bcm_mim_port_match_t criteria; /* Match criteria. */ 161 bcm_vlan_t match_vlan; /* S-Tag. */ 162 bcm_vlan_t match_inner_vlan; /* C-Tag. */ 163 bcm_mpls_label_t match_label; /* MPLS label. */ 164 bcm_vlan_t match_tunnel_vlan; /* B-domain VID. */ 165 bcm_mac_t match_tunnel_srcmac; /* Source MAC address. */ 166 uint16 match_service_tpid; /* Incoming SD tag TPID */ 167 bcm_vlan_t egress_tunnel_vlan; /* B-domain VID. */ 168 bcm_mac_t egress_tunnel_srcmac; /* Source MAC address. */ 169 bcm_mac_t egress_tunnel_dstmac; /* Dest MAC address. */ 170 uint32 egress_tunnel_service; /* Egress I-SID translation. */ 171 uint16 egress_service_tpid; /* SD tag. */ 172 bcm_vlan_t egress_service_vlan; /* SD tag. */ 173 uint8 egress_service_pri; /* SD tag pri. */ 174 uint8 egress_service_cfi; /* SD tag cfi. */ 175 bcm_if_t encap_id; /* Encap identifier. */ 176 bcm_failover_t failover_id; /* Failover Object identifier. */ 177 bcm_gport_t failover_gport_id; /* Failover MiM Port identifier. */ 178 bcm_policer_t policer_id; /* Policer ID to be associated with the 179 MiM gport */ 180 bcm_multicast_t failover_mc_group; /* MC group used for bi-cast. */ 181 bcm_failover_t ingress_failover_id; /* 1+1 protection. */ 182 bcm_if_t service_encap_id; /* Service encap Identifier */ 183 uint8 int_pri; /* Fixed priority */ 184 bcm_switch_network_group_t network_group_id; /* Split Horizon network group 185 identifier */ 186 int inlif_counting_profile; /* In LIF counting profile */ 187 int outlif_counting_profile; /* Out LIF counting profile */ 188 } bcm_mim_port_t; 189 190 /* Initialize the MAC-in-MAC VPN config structure. */ 191 extern void bcm_mim_vpn_config_t_init( 192 bcm_mim_vpn_config_t *mim_vpn_config); 193 194 /* Initialize the MAC-in-MAC port structure. */ 195 extern void bcm_mim_port_t_init( 196 bcm_mim_port_t *mim_port); 197 198 #ifndef BCM_HIDE_DISPATCHABLE 199 200 /* Initialize the BCM MAC-in-MAC subsystem */ 201 extern int bcm_mim_init( 202 int unit); 203 204 /* Detach the MAC-in-MAC software module. */ 205 extern int bcm_mim_detach( 206 int unit); 207 208 /* Create a MAC-in-MAC VPN. */ 209 extern int bcm_mim_vpn_create( 210 int unit, 211 bcm_mim_vpn_config_t *info); 212 213 /* Destroy a MAC-in-MAC VPN. */ 214 extern int bcm_mim_vpn_destroy( 215 int unit, 216 bcm_mim_vpn_t vpn); 217 218 /* Destroy a MAC-in-MAC VPN. */ 219 extern int bcm_mim_vpn_destroy_all( 220 int unit); 221 222 /* Get a MAC-in-MAC VPN. */ 223 extern int bcm_mim_vpn_get( 224 int unit, 225 bcm_mim_vpn_t vpn, 226 bcm_mim_vpn_config_t *info); 227 228 #endif /* BCM_HIDE_DISPATCHABLE */ 229 230 /* MIM VPN callback function prototype. */ 231 typedef int (*bcm_mim_vpn_traverse_cb)( 232 int unit, 233 bcm_mim_vpn_config_t *info, 234 void *user_data); 235 236 #ifndef BCM_HIDE_DISPATCHABLE 237 238 /* bcm_mim_vpn_traverse */ 239 extern int bcm_mim_vpn_traverse( 240 int unit, 241 bcm_mim_vpn_traverse_cb cb, 242 void *user_data); 243 244 /* Add a MAC-in-MAC port to a VPN. */ 245 extern int bcm_mim_port_add( 246 int unit, 247 bcm_mim_vpn_t vpn, 248 bcm_mim_port_t *mim_port); 249 250 /* Delete a MAC-in-MAC port from a VPN. */ 251 extern int bcm_mim_port_delete( 252 int unit, 253 bcm_mim_vpn_t vpn, 254 bcm_gport_t mim_port_id); 255 256 /* Delete a MAC-in-MAC port from a VPN. */ 257 extern int bcm_mim_port_delete_all( 258 int unit, 259 bcm_mim_vpn_t vpn); 260 261 /* Get a MAC-in-MAC port from a VPN. */ 262 extern int bcm_mim_port_get( 263 int unit, 264 bcm_mim_vpn_t vpn, 265 bcm_mim_port_t *mim_port); 266 267 /* Get all MAC-in-MAC ports from a VPN. */ 268 extern int bcm_mim_port_get_all( 269 int unit, 270 bcm_mim_vpn_t vpn, 271 int port_max, 272 bcm_mim_port_t *port_array, 273 int *port_count); 274 275 #endif /* BCM_HIDE_DISPATCHABLE */ 276 277 /* Types of statistics that are maintained per MIM interface. */ 278 typedef enum bcm_mim_stat_e { 279 bcmMimStatIngressPackets = 0, /* Packets that ingress on MIM interface */ 280 bcmMimStatIngressBytes = 1, /* Bytes that ingress on MIM interface */ 281 bcmMimStatEgressPackets = 2, /* Packets that egress on MIM interface */ 282 bcmMimStatEgressBytes = 3 /* Bytes that egress on MIM interface */ 283 } bcm_mim_stat_t; 284 285 #ifndef BCM_HIDE_DISPATCHABLE 286 287 /* attach counters entries to the given MiM I-SID entry */ 288 extern int bcm_mim_lookup_id_stat_attach( 289 int unit, 290 int lookup_id, 291 uint32 stat_counter_id); 292 293 /* detach counters entries to the given MiM I-SID entry */ 294 extern int bcm_mim_lookup_id_stat_detach( 295 int unit, 296 int lookup_id); 297 298 /* Get counter statistic values for specific MiM I-SID entry. */ 299 extern int bcm_mim_lookup_id_stat_counter_get( 300 int unit, 301 int lookup_id, 302 bcm_mim_stat_t stat, 303 uint32 num_entries, 304 uint32 *counter_indexes, 305 bcm_stat_value_t *counter_values); 306 307 /* 308 * Force an immediate counter update and retrieve counter statistic 309 * values 310 * for specific MiM I-SID entry. 311 */ 312 extern int bcm_mim_lookup_id_stat_counter_sync_get( 313 int unit, 314 int lookup_id, 315 bcm_mim_stat_t stat, 316 uint32 num_entries, 317 uint32 *counter_indexes, 318 bcm_stat_value_t *counter_values); 319 320 /* Set counter statistic values for specific MiM I-SID entry */ 321 extern int bcm_mim_lookup_id_stat_counter_set( 322 int unit, 323 int lookup_id, 324 bcm_mim_stat_t stat, 325 uint32 num_entries, 326 uint32 *counter_indexes, 327 bcm_stat_value_t *counter_values); 328 329 /* Get stat counter id associated with given MiM I-SID entry */ 330 extern int bcm_mim_lookup_id_stat_id_get( 331 int unit, 332 int lookup_id, 333 bcm_mim_stat_t stat, 334 uint32 *stat_counter_id); 335 336 /* Attach counters entries to the given MiM VPN entry */ 337 extern int bcm_mim_vpn_stat_attach( 338 int unit, 339 bcm_mim_vpn_t vpn, 340 uint32 stat_counter_id); 341 342 /* Detach counters entries to the given MiM VPN entry */ 343 extern int bcm_mim_vpn_stat_detach( 344 int unit, 345 bcm_mim_vpn_t vpn); 346 347 /* Get counter statistic values for specific MiM VPN entry */ 348 extern int bcm_mim_vpn_stat_counter_get( 349 int unit, 350 bcm_mim_vpn_t vpn, 351 bcm_mim_stat_t stat, 352 uint32 num_entries, 353 uint32 *counter_indexes, 354 bcm_stat_value_t *counter_values); 355 356 /* 357 * Force an immediate counter update and retrieve counter statistic 358 * values for 359 * specific MiM VPN entry 360 */ 361 extern int bcm_mim_vpn_stat_counter_sync_get( 362 int unit, 363 bcm_mim_vpn_t vpn, 364 bcm_mim_stat_t stat, 365 uint32 num_entries, 366 uint32 *counter_indexes, 367 bcm_stat_value_t *counter_values); 368 369 /* Set counter statistic values for specific MiM VPN entry */ 370 extern int bcm_mim_vpn_stat_counter_set( 371 int unit, 372 bcm_mim_vpn_t vpn, 373 bcm_mim_stat_t stat, 374 uint32 num_entries, 375 uint32 *counter_indexes, 376 bcm_stat_value_t *counter_values); 377 378 /* Get stat counter id associated with given MiM VPN entry */ 379 extern int bcm_mim_vpn_stat_id_get( 380 int unit, 381 bcm_mim_vpn_t vpn, 382 bcm_mim_stat_t stat, 383 uint32 *stat_counter_id); 384 385 #endif /* defined(INCLUDE_L3) */ 386 387 #endif /* BCM_HIDE_DISPATCHABLE */ 388 389 #endif /* __BCM_MIM_H__ */