l2.h (9704B)
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_L2_H__ 14 #define __BCMX_L2_H__ 15 16 #include <bcm/types.h> 17 #include <bcmx/bcmx.h> 18 #include <bcmx/lport.h> 19 #include <bcmx/lplist.h> 20 #include <bcm/l2.h> 21 22 /* Device-independent L2 address structure. */ 23 typedef struct bcmx_l2_addr_s { 24 uint32 flags; /* BCM_L2_xxx flags. */ 25 bcm_mac_t mac; /* 802.3 MAC address. */ 26 bcm_vlan_t vid; /* VLAN identifier. */ 27 bcmx_lport_t lport; /* Logical port number. */ 28 bcm_trunk_t tgid; /* Trunk group ID. */ 29 int trunk_sel; /* Trunk port select formula. */ 30 bcm_cos_t cos_dst; /* COS based on dst addr. */ 31 bcm_cos_t cos_src; /* COS based on src addr. */ 32 bcm_multicast_t l2mc_group; /* XGS: index in L2MC table */ 33 int auth; /* Used if auth enabled on port. */ 34 int bcm_unit; /* The bcm_unit number can be used to record the 35 reporting unit for adds and deletes. This 36 may differ from the unit associated with the 37 lport. */ 38 int group; /* Group number for FP. */ 39 } bcmx_l2_addr_t; 40 41 /* Device-independent L2 cache address structure. */ 42 typedef struct bcmx_l2_cache_addr_s { 43 uint32 flags; /* BCM_L2_CACHE_xxx flags. */ 44 bcm_mac_t mac; /* Destination MAC address to match. */ 45 bcm_mac_t mac_mask; /* MAC address mask. */ 46 bcm_vlan_t vlan; /* VLAN to match. */ 47 bcm_vlan_t vlan_mask; /* VLAN mask. */ 48 bcmx_lport_t src_port; /* Ingress port to match (BCM5660x). */ 49 bcmx_lport_t src_port_mask; /* Ingress port mask (must be 0 if not 50 BCM5660x). */ 51 bcmx_lport_t dest_lport; /* Switch destination port. */ 52 bcm_trunk_t dest_trunk; /* Switch destination trunk ID. */ 53 int prio; /* Internal priority, use -1 to not set. */ 54 bcmx_lplist_t dest_ports; /* Destination ports for Multiport L2 address 55 forwarding. */ 56 int lookup_class; /* Classification class ID. */ 57 } bcmx_l2_cache_addr_t; 58 59 /* L2 learn limit structure. */ 60 typedef struct bcmx_l2_learn_limit_s { 61 uint32 flags; /* BCM_L2_LEARN_LIMIT_xxx actions and qualifiers. */ 62 bcm_vlan_t vlan; /* VLAN identifier. */ 63 bcm_vpn_t vpn; /* VPN identifier. */ 64 bcmx_lport_t lport; /* Port number. */ 65 bcm_trunk_t trunk; /* Trunk identifier. */ 66 int limit; /* Maximum number of learned entries, -1 for unlimited. */ 67 } bcmx_l2_learn_limit_t; 68 69 /* 70 * Initialize an L2 address structure to a specified MAC address and VLAN 71 * ID. 72 */ 73 extern void bcmx_l2_addr_t_init( 74 bcmx_l2_addr_t *l2addr, 75 bcm_mac_t mac_addr, 76 bcm_vlan_t vid); 77 78 /* Backward compatibility. */ 79 #define bcmx_l2_addr_init bcmx_l2_addr_t_init 80 81 /* Initialize an L2 learn limit structure. */ 82 extern void bcmx_l2_learn_limit_t_init( 83 bcmx_l2_learn_limit_t *limit); 84 85 /* Add an L2 address entry to the specified device. */ 86 extern int bcmx_l2_addr_add( 87 bcmx_l2_addr_t *l2addr, 88 bcmx_lplist_t *port_block); 89 90 /* Delete an L2 address entry from the specified device. */ 91 extern int bcmx_l2_addr_delete( 92 bcm_mac_t mac, 93 bcm_vlan_t vid); 94 95 /* Delete L2 entries associated with a destination port. */ 96 extern int bcmx_l2_addr_delete_by_port( 97 bcmx_lport_t port, 98 uint32 flags); 99 100 /* Delete L2 entries associated with a MAC address. */ 101 extern int bcmx_l2_addr_delete_by_mac( 102 bcm_mac_t mac, 103 uint32 flags); 104 105 /* Delete L2 entries associated with a VLAN. */ 106 extern int bcmx_l2_addr_delete_by_vlan( 107 bcm_vlan_t vid, 108 uint32 flags); 109 110 /* Delete L2 entries associated with a trunk. */ 111 extern int bcmx_l2_addr_delete_by_trunk( 112 bcm_trunk_t tid, 113 uint32 flags); 114 115 /* 116 * Delete L2 entries associated with a MAC address and a destination 117 * port. 118 */ 119 extern int bcmx_l2_addr_delete_by_mac_port( 120 bcm_mac_t mac, 121 bcmx_lport_t port, 122 uint32 flags); 123 124 /* Delete L2 entries associated with a VLAN and a destination port. */ 125 extern int bcmx_l2_addr_delete_by_vlan_port( 126 bcm_vlan_t vid, 127 bcmx_lport_t port, 128 uint32 flags); 129 130 /* Delete L2 entries associated with a VLAN and a trunk. */ 131 extern int bcmx_l2_addr_delete_by_vlan_trunk( 132 bcm_vlan_t vid, 133 bcm_trunk_t tid, 134 uint32 flags); 135 136 /* Check if an L2 entry is present in the L2 table. */ 137 extern int bcmx_l2_addr_get( 138 bcm_mac_t mac_addr, 139 bcm_vlan_t vid, 140 bcmx_l2_addr_t *l2addr, 141 bcmx_lplist_t *port_block); 142 143 /* 144 * Callback function used for receiving notification about insertions 145 * into and deletions from the L2 table dynamically as they occur. Valid 146 * operations are: delete, add, and report. A report with l2addr=NULL 147 * indicates a scan completion of the L2 table. 148 */ 149 typedef void (*bcmx_l2_notify_f)( 150 bcmx_l2_addr_t *l2addr, 151 int insert, 152 void *cookie); 153 154 /* Register/Unregister a callback routine for L2 subsystem. */ 155 extern int bcmx_l2_notify_register( 156 bcmx_l2_notify_f callback, 157 void *userdata); 158 159 /* Register/Unregister a callback routine for L2 subsystem. */ 160 extern int bcmx_l2_notify_unregister( 161 bcmx_l2_notify_f callback, 162 void *userdata); 163 164 /* Start/stop notifications to L2 table. */ 165 extern int bcmx_l2_notify_start(void); 166 167 /* Start/stop notifications to L2 table. */ 168 extern int bcmx_l2_notify_stop(void); 169 170 /* Add a device to the L2 notification list. */ 171 extern int bcmx_l2_device_add( 172 int bcm_unit); 173 174 /* Remove device from the L2 notification list. */ 175 extern int bcmx_l2_device_remove( 176 int bcm_unit); 177 178 /* Set the age timer. */ 179 extern int bcmx_l2_age_timer_set( 180 int age_seconds); 181 182 /* Get the age timer. */ 183 extern int bcmx_l2_age_timer_get( 184 int *age_seconds); 185 186 /* Temporarily stop/restore L2 table from changing. */ 187 extern int bcmx_l2_addr_freeze(void); 188 189 /* Temporarily stop/restore L2 table from changing. */ 190 extern int bcmx_l2_addr_thaw(void); 191 192 /* 193 * Given an L2 address entry, return existing addresses which could 194 * conflict. 195 */ 196 extern int bcmx_l2_conflict_get( 197 bcmx_l2_addr_t *addr, 198 bcmx_l2_addr_t *cf_array, 199 int cf_max, 200 int *cf_count); 201 202 /* Convert BCMX to BCM L2 address structure. */ 203 extern int bcmx_l2_addr_to_bcm( 204 int bcm_unit, 205 bcm_l2_addr_t *dest, 206 bcmx_l2_addr_t *source, 207 bcmx_lplist_t *port_block); 208 209 /* Convert BCM to BCMX L2 address structure. */ 210 extern int bcmx_l2_addr_from_bcm( 211 bcmx_l2_addr_t *dest, 212 bcmx_lplist_t *port_block, 213 bcm_l2_addr_t *source); 214 215 /* Update an L2 address entry. */ 216 extern int bcmx_l2_addr_refresh( 217 bcmx_l2_addr_t *l2addr, 218 bcmx_lplist_t *port_block); 219 220 /* 221 * Check if an L2 entry is present in the L2 table of a device that 222 * contains a native port. 223 */ 224 extern int bcmx_l2_addr_native_get( 225 bcm_mac_t mac_addr, 226 bcm_vlan_t vid, 227 bcmx_l2_addr_t *l2addr); 228 229 /* Check if an L2 entry is present in the L2 table on a given device. */ 230 extern int bcmx_l2_addr_port_get( 231 bcmx_lport_t port, 232 bcm_mac_t mac_addr, 233 bcm_vlan_t vid, 234 bcmx_l2_addr_t *l2addr); 235 236 /* Initialize the L2 cache. */ 237 extern int bcmx_l2_cache_init(void); 238 239 /* Initialize an L2 cache address structure. */ 240 extern void bcmx_l2_cache_addr_t_init( 241 bcmx_l2_cache_addr_t *addr); 242 243 /* Deallocate port list in bcmx_l2_cache_addr_t. */ 244 extern void bcmx_l2_cache_addr_t_free( 245 bcmx_l2_cache_addr_t *addr); 246 247 /* Get number of L2 cache entries. */ 248 extern int bcmx_l2_cache_size_get( 249 int *size); 250 251 /* Set an L2 cache entry. */ 252 extern int bcmx_l2_cache_set( 253 int index, 254 bcmx_l2_cache_addr_t *addr, 255 int *index_used); 256 257 /* Get an L2 cache entry. */ 258 extern int bcmx_l2_cache_get( 259 int index, 260 bcmx_l2_cache_addr_t *addr); 261 262 /* Clear an L2 cache entry. */ 263 extern int bcmx_l2_cache_delete( 264 int index); 265 266 /* Clear all L2 cache entries. */ 267 extern int bcmx_l2_cache_delete_all(void); 268 269 /* Add a destination L2 address to trigger tunnel processing. */ 270 extern int bcmx_l2_tunnel_add( 271 bcm_mac_t mac, 272 bcm_vlan_t vlan); 273 274 /* Clear a destination L2 address used to trigger tunnel processing. */ 275 extern int bcmx_l2_tunnel_delete( 276 bcm_mac_t mac, 277 bcm_vlan_t vlan); 278 279 /* Clear all destination L2 addresses used to trigger tunnel processing. */ 280 extern int bcmx_l2_tunnel_delete_all(void); 281 282 /* Set/Get L2 addresses learn limit. */ 283 extern int bcmx_l2_learn_limit_set( 284 bcmx_l2_learn_limit_t *limit); 285 286 /* Set/Get L2 addresses learn limit. */ 287 extern int bcmx_l2_learn_limit_get( 288 bcmx_l2_learn_limit_t *limit); 289 290 /* Set/Get attributes for the specified L2 learning class. */ 291 extern int bcmx_l2_learn_class_set( 292 int lclass, 293 int lclass_prio, 294 uint32 flags); 295 296 /* Set/Get attributes for the specified L2 learning class. */ 297 extern int bcmx_l2_learn_class_get( 298 int lclass, 299 int *lclass_prio, 300 uint32 *flags); 301 302 /* Set/Get L2 learning class for the specified port. */ 303 extern int bcmx_l2_learn_port_class_set( 304 bcmx_lport_t port, 305 int lclass); 306 307 /* Set/Get L2 learning class for the specified port. */ 308 extern int bcmx_l2_learn_port_class_get( 309 bcmx_lport_t port, 310 int *lclass); 311 312 /* Replace L2 entries matching given criterions */ 313 extern int bcmx_l2_replace( 314 uint32 flags, 315 bcmx_l2_addr_t *match_addr, 316 bcmx_lport_t new_port, 317 bcm_trunk_t new_trunk); 318 319 #endif /* __BCMX_L2_H__ */