openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

l2.h (61743B)


      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 __BCM_L2_H__
     14 #define __BCM_L2_H__
     15 
     16 #include <bcm/types.h>
     17 
     18 /* 
     19  * Flags for device-independent L2 address.
     20  * 
     21  * Special note on insert/delete/lookup-specific flags:
     22  * 
     23  *   BCM_L2_NATIVE
     24  *   BCM_L2_MOVE
     25  *   BCM_L2_FROM_NATIVE
     26  *   BCM_L2_TO_NATIVE
     27  *   BCM_L2_MOVE_PORT
     28  *   BCM_L2_LOCAL_CPU
     29  * 
     30  * On a move, two calls occur: delete and insert. The from native/to
     31  * native calls are set the same for both of these operations. On an age,
     32  * the move bit is not set and only one delete operation occurs.
     33  * 
     34  * Suggested application operation:
     35  * 
     36  *      Insert:  If native is set, send insert op to all units.
     37  *      Age:     If native is set, send delete operation to all units.
     38  *      Move:    Ignore delete indication and wait for insert operation.
     39  *               Treat insert like above.
     40  * 
     41  * That is, ignore move-delete operations; only forward other
     42  * operations if native.
     43  * 
     44  * The BCM_L2_LOCAL_CPU flag indicates the entry is for the local CPU on
     45  * the device. This is valid for _add operations only. Note that
     46  * BCM_L2_LOCAL_CPU is related to the L2_NATIVE value. L2_NATIVE is valid
     47  * on reads, L2_LOCAL_CPU is valid on move or write.
     48  */
     49 #define BCM_L2_COS_SRC_PRI              0x00000001 /* Source COS has priority
     50                                                       over destination COS. */
     51 #define BCM_L2_DISCARD_SRC              0x00000002 
     52 #define BCM_L2_DISCARD_DST              0x00000004 
     53 #define BCM_L2_COPY_TO_CPU              0x00000008 
     54 #define BCM_L2_L3LOOKUP                 0x00000010 
     55 #define BCM_L2_STATIC                   0x00000020 
     56 #define BCM_L2_HIT                      0x00000040 
     57 #define BCM_L2_TRUNK_MEMBER             0x00000080 
     58 #define BCM_L2_MCAST                    0x00000100 
     59 #define BCM_L2_REPLACE_DYNAMIC          0x00000200 
     60 #define BCM_L2_SRC_HIT                  0x00000400 
     61 #define BCM_L2_DES_HIT                  0x00000800 
     62 #define BCM_L2_REMOTE_TRUNK             0x00001000 
     63 #define BCM_L2_MIRROR                   0x00002000 
     64 #define BCM_L2_SETPRI                   0x00004000 
     65 #define BCM_L2_REMOTE_LOOKUP            0x00008000 
     66 #define BCM_L2_NATIVE                   0x00010000 
     67 #define BCM_L2_MOVE                     0x00020000 
     68 #define BCM_L2_FROM_NATIVE              0x00040000 
     69 #define BCM_L2_TO_NATIVE                0x00080000 
     70 #define BCM_L2_MOVE_PORT                0x00100000 
     71 #define BCM_L2_LOCAL_CPU                0x00200000 /* Entry is for the local CPU
     72                                                       on the device. */
     73 #define BCM_L2_USE_FABRIC_DISTRIBUTION  0x00400000 /* Use specified fabric
     74                                                       distribution class. */
     75 #define BCM_L2_PENDING                  0x00800000 
     76 #define BCM_L2_LEARN_LIMIT_EXEMPT       0x01000000 
     77 #define BCM_L2_LEARN_LIMIT              0x02000000 
     78 #define BCM_L2_ENTRY_OVERFLOW           0x04000000 
     79 #define BCM_L2_LEARN_LIMIT_EXEMPT_LOCAL 0x08000000 /* Only system wide MAC limit
     80                                                       counter will be
     81                                                       incremented. */
     82 #define BCM_L2_SET_ENCAP_VALID          0x10000000 /* DNX only: indication that
     83                                                       encap_id_valid needs to
     84                                                       set even when encap_id is
     85                                                       not valid. */
     86 #define BCM_L2_SET_ENCAP_INVALID        0x20000000 /* DNX only: encap_id is
     87                                                       added to MAC table as is,
     88                                                       however valid bit is
     89                                                       cleared. */
     90 #define BCM_L2_SR_SAN_DEST              0x40000000 /* Seamless Redundancy: the
     91                                                       destination is a SAN */
     92 #define BCM_L2_ADD_OVERRIDE_PENDING     0x80000000 /* Override pending entry
     93                                                       while the same hash bucket
     94                                                       is full. */
     95 
     96 /* These are in bit order. */
     97 #define BCM_L2_FLAGS_STR        \
     98 { \
     99     "SrcCOS", \
    100     "SrcDisc", \
    101     "DestDisc", \
    102     "CopyCPU", \
    103     "L3Lkup", \
    104     "Static", \
    105     "Hit", \
    106     "Trunk", \
    107     "Mcast", \
    108     "RplDyn", \
    109     "SrcHit", \
    110     "DestHit", \
    111     "RTrunk", \
    112     "Mirror", \
    113     "SetPri", \
    114     "RemoteLookup", \
    115     "Native", \
    116     "Move", \
    117     "FrNative", \
    118     "ToNative", \
    119     "MovePort", \
    120     "LclCPU", \
    121     "UseFabricDistribution", \
    122     "Pending", \
    123     "LearnLimitExempt", \
    124     "LearnLimit" \
    125 } 
    126 
    127 /* bcm_l2_flags_str */
    128 extern char *bcm_l2_flags_str[];
    129 
    130 /* bcm_l2_flags_count */
    131 extern int bcm_l2_flags_count;
    132 
    133 /* Flags2 for device-independent L2 address. */
    134 #define BCM_L2_FLAGS2_ROE_NHI           0x00000001 /* The destination of the l2
    135                                                       address is ROE/ROE Custom
    136                                                       Next Hop Index. */
    137 #define BCM_L2_FLAGS2_L3_MULTICAST      0x00000002 /* The destination of the l2
    138                                                       address is ROE/ROE Custom
    139                                                       IPMC Index. */
    140 #define BCM_L2_FLAGS2_BMACT_LEARN       0x00000004 /* Mac-in-Mac: BVID entries
    141                                                       will be added to dedicated
    142                                                       MiM learn table (instead
    143                                                       of BMACT FWD). */
    144 #define BCM_L2_FLAGS2_ADD_NO_CALLBACKS  0x00000008 /* The l2 fifo events will
    145                                                       not be generated if this
    146                                                       flag is set. */
    147 #define BCM_L2_FLAGS2_ADD_VPN_TYPE      0x00000010 /* Add VPN type l2 entry. */
    148 #define BCM_L2_FLAGS2_HIT_GET           0x00000020 /* Signal bcm_l2_addr_get to
    149                                                       return the hit status of
    150                                                       the MAC entry. */
    151 #define BCM_L2_FLAGS2_AGE_GET           0x00000040 /* Signal bcm_l2_addr_get to
    152                                                       return the age of the MAC
    153                                                       entry. */
    154 
    155 #define BCM_L2_AUTH_NONE            0          
    156 #define BCM_L2_AUTH_STATIC_ACCEPT   4          
    157 #define BCM_L2_AUTH_STATIC_REJECT   5          
    158 #define BCM_L2_AUTH_SA_NUM          6          
    159 #define BCM_L2_AUTH_SA_MATCH        7          
    160 
    161 #define BCM_L2_VID_MASK_ALL     0x0fff     
    162 #define BCM_L2_SRCPORT_MASK_ALL 0x3f       
    163 
    164 #define BCM_L2_CALLBACK_DELETE      0          
    165 #define BCM_L2_CALLBACK_ADD         1          
    166 #define BCM_L2_CALLBACK_REPORT      2          
    167 #define BCM_L2_CALLBACK_LEARN_EVENT 3          
    168 #define BCM_L2_CALLBACK_AGE_EVENT   4          
    169 #define BCM_L2_CALLBACK_MOVE_EVENT  5          
    170 
    171 #define BCM_L2_ADDR_DIST_LEARN_EVENT        0x00000001 /* learning events */
    172 #define BCM_L2_ADDR_DIST_STATION_MOVE_EVENT 0x00000002 /* station movement event */
    173 #define BCM_L2_ADDR_DIST_AGED_OUT_EVENT     0x00000004 /* aged out events */
    174 #define BCM_L2_ADDR_DIST_SET_LEARN_DISTRIBUTER 0x00000008 /* Send events to the
    175                                                           learning distributer */
    176 #define BCM_L2_ADDR_DIST_SET_SHADOW_DISTRIBUTER 0x00000010 /* Send events to the
    177                                                           shadow distributer */
    178 #define BCM_L2_ADDR_DIST_REFRESH_EVENT      0x00000020 /* Age refresh event */
    179 #define BCM_L2_ADDR_DIST_SET_NO_DISTRIBUTER 0x00000040 /* Do not send events to
    180                                                           any distributer */
    181 #define BCM_L2_ADDR_DIST_SET_CPU_DMA_DISTRIBUTER 0x00000080 /* Send events to the DMA
    182                                                           that copies them to
    183                                                           the CPU's memory */
    184 #define BCM_L2_ADDR_DIST_ACK_EVENT          0x00000100 /* acknowledge events */
    185 #define BCM_L2_ADDR_DIST_UPDATE_WITHOUT_ADD_EVENT 0x00000200 /* Update payload or age
    186                                                           state or fail in case
    187                                                           the entry doesn't
    188                                                           exist */
    189 
    190 #define BCM_L2_LEARN_MSG_DEST_MULTICAST 0x00000001 /* The destination of the
    191                                                       learning message is
    192                                                       Multicast group
    193                                                       'dest_group' in use, if
    194                                                       not present then the
    195                                                       destination is uc and
    196                                                       'dest_port' in use
    197                                                       dst_mac_addr ,
    198                                                       src_mac_addr, ether_type,
    199                                                       vlan_prio, vlan. */
    200 #define BCM_L2_LEARN_MSG_ETH_ENCAP      0x00000002 /* Learn message are
    201                                                       encapsulated with
    202                                                       Etherenet header. Use the
    203                                                       specified Ethernet
    204                                                       parameters */
    205 #define BCM_L2_LEARN_MSG_LEARNING       0x00000004 /* The specified
    206                                                       configuration are for
    207                                                       message generated to
    208                                                       learning */
    209 #define BCM_L2_LEARN_MSG_SHADOW         0x00000008 /* The specified
    210                                                       configuration are for
    211                                                       message generated to
    212                                                       manage a shadow of the ARL */
    213 
    214 /* Device-independent L2 address structure. */
    215 typedef struct bcm_l2_addr_s {
    216     uint32 flags;                       /* BCM_L2_xxx flags. */
    217     uint32 flags2;                      /* BCM_L2_FLAGS2_xxx flags. */
    218     uint32 station_flags;               /* BCM_L2_STATION_xxx flags. */
    219     bcm_mac_t mac;                      /* 802.3 MAC address. */
    220     bcm_vlan_t vid;                     /* VLAN identifier. */
    221     int port;                           /* Zero-based port number. */
    222     int modid;                          /* XGS: modid. */
    223     bcm_trunk_t tgid;                   /* Trunk group ID. */
    224     bcm_cos_t cos_dst;                  /* COS based on dst addr. */
    225     bcm_cos_t cos_src;                  /* COS based on src addr. */
    226     bcm_multicast_t l2mc_group;         /* XGS: index in L2MC table */
    227     bcm_if_t egress_if;                 /* XGS: index in Next Hop Tables. Used
    228                                            it with BCM_L2_FLAGS2_ROE_NHI flag */
    229     bcm_multicast_t l3mc_group;         /* XGS: index in L3_IPMC table. Use it
    230                                            with BCM_L2_FLAGS2_L3_MULTICAST. */
    231     bcm_pbmp_t block_bitmap;            /* XGS: blocked egress bitmap. */
    232     int auth;                           /* Used if auth enabled on port. */
    233     int group;                          /* Group number for FP. */
    234     bcm_fabric_distribution_t distribution_class; /* Fabric Distribution Class. */
    235     int encap_id;                       /* out logical interface */
    236     int age_state;                      /* Age state of the entry */
    237     uint32 flow_handle;                 /* FLOW handle for flex entries. */
    238     uint32 flow_option_handle;          /* FLOW option handle for flex entries. */
    239     bcm_flow_logical_field_t logical_fields[BCM_FLOW_MAX_NOF_LOGICAL_FIELDS]; /* logical fields array for flex
    240                                            entries. */
    241     uint32 num_of_fields;               /* number of logical fields. */
    242     bcm_pbmp_t sa_source_filter_pbmp;   /* Source port filter bitmap for this SA */
    243     bcm_tsn_flowset_t tsn_flowset;      /* Time-Sensitive Networking: associated
    244                                            flow set */
    245     bcm_tsn_sr_flowset_t sr_flowset;    /* Seamless Redundancy: associated flow
    246                                            set */
    247     bcm_policer_t policer_id;           /* Base policer to be used */
    248     bcm_tsn_pri_map_t taf_gate_primap;  /* TAF (Time Aware Filtering) gate
    249                                            priority mapping */
    250     uint32 stat_id;                     /* Object statistics ID */
    251     int stat_pp_profile;                /* Statistics profile */
    252 } bcm_l2_addr_t;
    253 
    254 /* Flags for device-independent L2 egress. */
    255 #define BCM_L2_EGRESS_WITH_ID               0x00000001 /* Use the specified
    256                                                           Encap ID while
    257                                                           creating. */
    258 #define BCM_L2_EGRESS_REPLACE               0x00000002 /* Replace config of
    259                                                           existing egress
    260                                                           object. */
    261 #define BCM_L2_EGRESS_DEST_MAC_REPLACE      0x00000004 /* Replace dest MAC. */
    262 #define BCM_L2_EGRESS_DEST_MAC_PREFIX5_REPLACE 0x00000008 /* Replace only 5 prefix
    263                                                           bytes of dest MAC. */
    264 #define BCM_L2_EGRESS_SRC_MAC_REPLACE       0x00000010 /* Replace source MAC. */
    265 #define BCM_L2_EGRESS_OUTER_VLAN_REPLACE    0x00000020 /* Replace outer vlan. */
    266 #define BCM_L2_EGRESS_OUTER_PRIO_REPLACE    0x00000040 /* Replace outer tag
    267                                                           priority. */
    268 #define BCM_L2_EGRESS_INNER_VLAN_REPLACE    0x00000080 /* Replace inner vlan. */
    269 #define BCM_L2_EGRESS_INNER_PRIO_REPLACE    0x00000100 /* Replace inner tag
    270                                                           priority. */
    271 #define BCM_L2_EGRESS_ETHERTYPE_REPLACE     0x00000200 /* Replace ethertype */
    272 #define BCM_L2_EGRESS_DEST_PORT             0x00000400 /* Associate l2 egress
    273                                                           entry with a
    274                                                           particular dest port */
    275 #define BCM_L2_EGRESS_OUTER_VLAN_ADD        0x00000800 /* add outer vlan, if set
    276                                                           then new vlan-tag is
    277                                                           added according to
    278                                                           outer_tpid,outer_prio,outer_vlan,
    279                                                           attributes */
    280 #define BCM_L2_EGRESS_VLAN_QOS_MAP_REPLACE  0x00001000 /* Replace VLAN PCP-DEI
    281                                                           QOS settings */
    282 #define BCM_L2_EGRESS_WIDE                  0x00002000 /* Set wide entry in
    283                                                           egress */
    284 #define BCM_L2_EGRESS_RECYCLE_HEADER        0x00004000 /* Recycle header */
    285 
    286 /* Device-independent L2 egress structure. */
    287 typedef struct bcm_l2_egress_s {
    288     uint32 flags;                   /* BCM_L2_EGRESS_XXX flags. */
    289     bcm_mac_t dest_mac;             /* Destination MAC address to replace with. */
    290     bcm_mac_t src_mac;              /* Source MAC address to replace with. */
    291     bcm_vlan_t outer_vlan;          /* outer vlan tag to replace with. */
    292     bcm_vlan_t inner_vlan;          /* inner vlan tag to replace with. */
    293     bcm_ethertype_t ethertype;      /* Ethertype to replace with. */
    294     bcm_gport_t dest_port;          /* Destination gport to associate this l2
    295                                        egress entry with */
    296     bcm_if_t encap_id;              /* Encapsulation index */
    297     uint16 outer_tpid;              /* outer vlan tag TPID */
    298     uint8 outer_prio;               /* outer vlan tag User Priority */
    299     uint16 inner_tpid;              /* inner vlan tag TPID */
    300     bcm_if_t l3_intf;               /* L3 interface (tunnel). Used only in
    301                                        Native Routing overlay protocols. */
    302     int vlan_qos_map_id;            /* VLAN PCP-DEI QoS settings. Used only in
    303                                        Native Routing overlay protocols. */
    304     int mpls_extended_label_value;  /* An extended label placed on top of a an
    305                                        egress encapsulation. */
    306 } bcm_l2_egress_t;
    307 
    308 /* Flags for device-independent L2 cache address. */
    309 #define BCM_L2_CACHE_CPU            0x00000001 /* Packet is copied to CPU. */
    310 #define BCM_L2_CACHE_DISCARD        0x00000002 /* Packet is not switched. */
    311 #define BCM_L2_CACHE_MIRROR         0x00000004 /* Packet is mirrored. */
    312 #define BCM_L2_CACHE_L3             0x00000008 /* Packet is to be L3 routed. */
    313 #define BCM_L2_CACHE_BPDU           0x00000010 /* Packet is BPDU. */
    314 #define BCM_L2_CACHE_SETPRI         0x00000020 /* Internal prio from prio field. */
    315 #define BCM_L2_CACHE_TRUNK          0x00000040 /* Destination is a trunk. */
    316 #define BCM_L2_CACHE_REMOTE_LOOKUP  0x00000080 /* Remote L2 lookup requested. */
    317 #define BCM_L2_CACHE_LEARN_DISABLE  0x00000100 /* Packet source address is not
    318                                                   learned for this destination
    319                                                   address. */
    320 #define BCM_L2_CACHE_TUNNEL         0x00000200 /* Tunnel termination address. */
    321 #define BCM_L2_CACHE_DESTPORTS      0x00000400 /* Packet is forwarded by
    322                                                   multiport L2 address. */
    323 #define BCM_L2_CACHE_SUBTYPE        0x00000800 /* Slow protocol subtype to
    324                                                   match. */
    325 #define BCM_L2_CACHE_LOOKUP         0x00001000 /* L2 lookup requested. */
    326 #define BCM_L2_CACHE_MULTICAST      0x00002000 /* Destination is (flood)
    327                                                   multicast group. */
    328 #define BCM_L2_CACHE_PROTO_PKT      0x00004000 /* Packet is protocol packets. */
    329 
    330 /* Device-independent L2 cache address structure. */
    331 typedef struct bcm_l2_cache_addr_s {
    332     uint32 flags;                   /* BCM_L2_CACHE_xxx flags. */
    333     uint32 station_flags;           /* BCM_L2_STATION_xxx flags. */
    334     bcm_mac_t mac;                  /* Destination MAC address to match. */
    335     bcm_mac_t mac_mask;             /* MAC address mask. */
    336     bcm_vlan_t vlan;                /* VLAN to match. */
    337     bcm_vlan_t vlan_mask;           /* VLAN mask. */
    338     bcm_port_t src_port;            /* Ingress port to match (BCM5660x). */
    339     bcm_port_t src_port_mask;       /* Ingress port mask (must be 0 if not
    340                                        BCM5660x). */
    341     bcm_module_t dest_modid;        /* Switch destination module ID. */
    342     bcm_port_t dest_port;           /* Switch destination port. */
    343     bcm_trunk_t dest_trunk;         /* Switch destination trunk ID. */
    344     int prio;                       /* Internal priority, use -1 to not set. */
    345     bcm_pbmp_t dest_ports;          /* Destination ports for Multiport L2
    346                                        address forwarding. */
    347     int lookup_class;               /* Classification class ID. */
    348     uint8 subtype;                  /* Slow protocol subtype to match. */
    349     bcm_if_t encap_id;              /* Encapsulation index. */
    350     bcm_multicast_t group;          /* Flood domain for L2CP. */
    351     bcm_ethertype_t ethertype;      /* Ethertype to match. */
    352     bcm_ethertype_t ethertype_mask; /* Mask. */
    353 } bcm_l2_cache_addr_t;
    354 
    355 /* Flags for L2 learn limit. */
    356 #define BCM_L2_LEARN_LIMIT_SYSTEM           0x00000001 /* Limit is system wide. */
    357 #define BCM_L2_LEARN_LIMIT_VLAN             0x00000002 /* Limit is on per VLAN
    358                                                           basis. */
    359 #define BCM_L2_LEARN_LIMIT_PORT             0x00000004 /* Limit is on per port
    360                                                           basis. */
    361 #define BCM_L2_LEARN_LIMIT_TRUNK            0x00000008 /* Limit is on per trunk
    362                                                           basis. */
    363 #define BCM_L2_LEARN_LIMIT_ACTION_DROP      0x00000010 /* Drop if over limit. */
    364 #define BCM_L2_LEARN_LIMIT_ACTION_CPU       0x00000020 /* Send to CPU if over
    365                                                           limit. */
    366 #define BCM_L2_LEARN_LIMIT_ACTION_PREFER    0x00000040 /* Use system drop/CPU if
    367                                                           over both system limit
    368                                                           and non-system limit,
    369                                                           used by system wide
    370                                                           setting only. */
    371 #define BCM_L2_LEARN_LIMIT_TUNNEL           0x00000080 /* Limit is on per tunnel
    372                                                           basis. */
    373 
    374 /* L2 learn limit structure. */
    375 typedef struct bcm_l2_learn_limit_s {
    376     uint32 flags;               /* BCM_L2_LEARN_LIMIT_xxx actions and
    377                                    qualifiers. */
    378     bcm_vlan_t vlan;            /* VLAN identifier. */
    379     bcm_port_t port;            /* Port number. */
    380     bcm_trunk_t trunk;          /* Trunk identifier. */
    381     bcm_tunnel_id_t tunnel_id;  /* Tunnel identifier. */
    382     int limit;                  /* Maximum number of learned entries, -1 for
    383                                    unlimited. */
    384 } bcm_l2_learn_limit_t;
    385 
    386 /* L2 learn message distribution info. */
    387 typedef struct bcm_l2_learn_msgs_config_s {
    388     uint32 flags;               /* BCM_L2_LEARN_MSG_XXX flags. */
    389     bcm_gport_t dest_port;      /* Destination port. */
    390     bcm_multicast_t dest_group; /* Destination group. */
    391     bcm_vlan_t vlan;            /* L2: vlan identifier. set to invalid for
    392                                    untagged Ethernet */
    393     uint16 tpid;                /* L2: vlan TPID. */
    394     uint16 vlan_prio;           /* L2: vlan priority. */
    395     uint16 ether_type;          /* L2: type in Ethernet II frame or 802.1Q tag. */
    396     bcm_mac_t src_mac_addr;     /* L2: source MAC address. */
    397     bcm_mac_t dst_mac_addr;     /* L2: destination MAC address. */
    398     uint8 priority;             /* L2: traffic class, Range: 0..7 */
    399     uint8 color;                /* L2: drop precedence, Range: 0..3 */
    400 } bcm_l2_learn_msgs_config_t;
    401 
    402 /* Learning events distibution. */
    403 typedef struct bcm_l2_addr_distribute_s {
    404     uint32 flags;   /* BCM_L2_ADDR_DIST_XXX flags. */
    405     bcm_vlan_t vid; /* VLAN or VPN identifier. */
    406 } bcm_l2_addr_distribute_t;
    407 
    408 #ifndef BCM_HIDE_DISPATCHABLE
    409 
    410 /* Initialize the BCM L2 subsystem. */
    411 extern int bcm_l2_init(
    412     int unit);
    413 
    414 /* Clear the BCM L2 subsystem. */
    415 extern int bcm_l2_clear(
    416     int unit);
    417 
    418 /* Finalize the BCM L2 subsystem. */
    419 extern int bcm_l2_detach(
    420     int unit);
    421 
    422 #endif /* BCM_HIDE_DISPATCHABLE */
    423 
    424 /* 
    425  * Initialize an L2 address structure to a specified MAC address and VLAN
    426  * ID.
    427  */
    428 extern void bcm_l2_addr_t_init(
    429     bcm_l2_addr_t *l2addr, 
    430     const bcm_mac_t mac_addr, 
    431     bcm_vlan_t vid);
    432 
    433 #define bcm_l2_addr_init        bcm_l2_addr_t_init 
    434 
    435 #ifndef BCM_HIDE_DISPATCHABLE
    436 
    437 /* Add an L2 address entry to the specified device. */
    438 extern int bcm_l2_addr_add(
    439     int unit, 
    440     bcm_l2_addr_t *l2addr);
    441 
    442 #endif /* BCM_HIDE_DISPATCHABLE */
    443 
    444 #define BCM_L2_DELETE_STATIC        0x00000001 
    445 #define BCM_L2_DELETE_PENDING       0x00000002 
    446 #define BCM_L2_DELETE_NO_CALLBACKS  0x00000004 
    447 
    448 #ifndef BCM_HIDE_DISPATCHABLE
    449 
    450 /* Delete an L2 address entry from the specified device. */
    451 extern int bcm_l2_addr_delete(
    452     int unit, 
    453     bcm_mac_t mac, 
    454     bcm_vlan_t vid);
    455 
    456 /* Delete L2 entries associated with a destination module/port. */
    457 extern int bcm_l2_addr_delete_by_port(
    458     int unit, 
    459     bcm_module_t mod, 
    460     bcm_port_t port, 
    461     uint32 flags);
    462 
    463 /* Delete L2 entries associated with a MAC address. */
    464 extern int bcm_l2_addr_delete_by_mac(
    465     int unit, 
    466     bcm_mac_t mac, 
    467     uint32 flags);
    468 
    469 /* Delete L2 entries associated with a VLAN. */
    470 extern int bcm_l2_addr_delete_by_vlan(
    471     int unit, 
    472     bcm_vlan_t vid, 
    473     uint32 flags);
    474 
    475 /* Delete L2 entries associated with a trunk. */
    476 extern int bcm_l2_addr_delete_by_trunk(
    477     int unit, 
    478     bcm_trunk_t tid, 
    479     uint32 flags);
    480 
    481 /* 
    482  * Delete L2 entries associated with a MAC address and a destination
    483  * module/port.
    484  */
    485 extern int bcm_l2_addr_delete_by_mac_port(
    486     int unit, 
    487     bcm_mac_t mac, 
    488     bcm_module_t mod, 
    489     bcm_port_t port, 
    490     uint32 flags);
    491 
    492 /* 
    493  * Delete L2 entries associated with a VLAN and a destination
    494  * module/port.
    495  */
    496 extern int bcm_l2_addr_delete_by_vlan_port(
    497     int unit, 
    498     bcm_vlan_t vid, 
    499     bcm_module_t mod, 
    500     bcm_port_t port, 
    501     uint32 flags);
    502 
    503 /* 
    504  * Delete L2 entries associated with a VLAN and a destination
    505  * module/port.
    506  */
    507 extern int bcm_l2_addr_delete_by_vlan_trunk(
    508     int unit, 
    509     bcm_vlan_t vid, 
    510     bcm_trunk_t tid, 
    511     uint32 flags);
    512 
    513 /* Check if an L2 entry is present in the L2 table. */
    514 extern int bcm_l2_addr_get(
    515     int unit, 
    516     bcm_mac_t mac_addr, 
    517     bcm_vlan_t vid, 
    518     bcm_l2_addr_t *l2addr);
    519 
    520 #endif /* BCM_HIDE_DISPATCHABLE */
    521 
    522 /* Dump a hardware-independent L2 address. */
    523 extern void bcm_l2_addr_dump(
    524     bcm_l2_addr_t *l2e);
    525 
    526 #ifndef BCM_HIDE_DISPATCHABLE
    527 
    528 /* Dump the key portion of a hardware-independent L2 address. */
    529 extern int bcm_l2_key_dump(
    530     int unit, 
    531     char *pfx, 
    532     bcm_l2_addr_t *entry, 
    533     char *sfx);
    534 
    535 #endif /* BCM_HIDE_DISPATCHABLE */
    536 
    537 /* 
    538  * Callback function used for receiving notification about insertions
    539  * into and deletions from the L2 table dynamically as they occur. Valid
    540  * operations are: delete, add, and report. A report with l2addr=NULL
    541  * indicates a scan completion of the L2 table.
    542  */
    543 typedef void (*bcm_l2_addr_callback_t)(
    544     int unit, 
    545     bcm_l2_addr_t *l2addr, 
    546     int operation, 
    547     void *userdata);
    548 
    549 #ifndef BCM_HIDE_DISPATCHABLE
    550 
    551 /* Register/Unregister a callback routine for BCM L2 subsystem. */
    552 extern int bcm_l2_addr_register(
    553     int unit, 
    554     bcm_l2_addr_callback_t callback, 
    555     void *userdata);
    556 
    557 /* Register/Unregister a callback routine for BCM L2 subsystem. */
    558 extern int bcm_l2_addr_unregister(
    559     int unit, 
    560     bcm_l2_addr_callback_t callback, 
    561     void *userdata);
    562 
    563 /* Set/Get the age timer. */
    564 extern int bcm_l2_age_timer_set(
    565     int unit, 
    566     int age_seconds);
    567 
    568 /* Set/Get the age timer. */
    569 extern int bcm_l2_age_timer_get(
    570     int unit, 
    571     int *age_seconds);
    572 
    573 /* Set the age time of one meta cycle in seconds. */
    574 extern int bcm_l2_age_timer_meta_cycle_set(
    575     int unit, 
    576     int meta_cycle_time);
    577 
    578 /* Get the age time of one meta cycle in seconds. */
    579 extern int bcm_l2_age_timer_meta_cycle_get(
    580     int unit, 
    581     int *meta_cycle_time);
    582 
    583 #endif /* BCM_HIDE_DISPATCHABLE */
    584 
    585 /* Initialize an L2 learn message structure. */
    586 extern void bcm_l2_learn_msgs_config_t_init(
    587     bcm_l2_learn_msgs_config_t *learn_msg_config);
    588 
    589 #ifndef BCM_HIDE_DISPATCHABLE
    590 
    591 /* 
    592  * Set device to distribute learning message to other devices in system
    593  * and/or Monitoring CPU. The monitoring CPU may be connected by Ethernet
    594  * header and in this case the Petra-B also append network header to the
    595  * learning related messages.
    596  */
    597 extern int bcm_l2_learn_msgs_config_set(
    598     int unit, 
    599     bcm_l2_learn_msgs_config_t *learn_msg_config);
    600 
    601 /* 
    602  * Get device configuration for distribute learning message to other
    603  * devices in system and/or Monitoring CPU. The monitoring CPU may be
    604  * connected by Ethernet header and in this case the Petra-B also append
    605  * network header to the learning related messages.
    606  */
    607 extern int bcm_l2_learn_msgs_config_get(
    608     int unit, 
    609     bcm_l2_learn_msgs_config_t *learn_msg_config);
    610 
    611 #endif /* BCM_HIDE_DISPATCHABLE */
    612 
    613 /* Initialize an L2 learn distribution structure. */
    614 extern void bcm_l2_addr_distribute_t_init(
    615     bcm_l2_addr_distribute_t *distribution);
    616 
    617 #ifndef BCM_HIDE_DISPATCHABLE
    618 
    619 /* 
    620  * Per VSI set which events (learn, station move (transplant), aged-out)
    621  * to inform CPU about.
    622  */
    623 extern int bcm_l2_addr_msg_distribute_set(
    624     int unit, 
    625     bcm_l2_addr_distribute_t *distribution);
    626 
    627 /* 
    628  * Per VSI get which events (learn, station move (transplant), aged-out)
    629  * to inform CPU about.
    630  */
    631 extern int bcm_l2_addr_msg_distribute_get(
    632     int unit, 
    633     bcm_l2_addr_distribute_t *distribution);
    634 
    635 /* Temporarily stop/restore L2 table from changing. */
    636 extern int bcm_l2_addr_freeze(
    637     int unit);
    638 
    639 /* Temporarily stop/restore L2 table from changing. */
    640 extern int bcm_l2_addr_thaw(
    641     int unit);
    642 
    643 /* 
    644  * Given an L2 address entry, return existing addresses which could
    645  * conflict.
    646  */
    647 extern int bcm_l2_conflict_get(
    648     int unit, 
    649     bcm_l2_addr_t *addr, 
    650     bcm_l2_addr_t *cf_array, 
    651     int cf_max, 
    652     int *cf_count);
    653 
    654 /* Determine if the given port is "native" from the point of view of L2. */
    655 extern int bcm_l2_port_native(
    656     int unit, 
    657     int modid, 
    658     int port);
    659 
    660 /* Initialize the L2 cache. */
    661 extern int bcm_l2_cache_init(
    662     int unit);
    663 
    664 #endif /* BCM_HIDE_DISPATCHABLE */
    665 
    666 /* Initialize an L2 cache address structure. */
    667 extern void bcm_l2_cache_addr_t_init(
    668     bcm_l2_cache_addr_t *addr);
    669 
    670 #ifndef BCM_HIDE_DISPATCHABLE
    671 
    672 /* Get number of L2 cache entries. */
    673 extern int bcm_l2_cache_size_get(
    674     int unit, 
    675     int *size);
    676 
    677 /* Set an L2 cache entry. */
    678 extern int bcm_l2_cache_set(
    679     int unit, 
    680     int index, 
    681     bcm_l2_cache_addr_t *addr, 
    682     int *index_used);
    683 
    684 /* Get an L2 cache entry. */
    685 extern int bcm_l2_cache_get(
    686     int unit, 
    687     int index, 
    688     bcm_l2_cache_addr_t *addr);
    689 
    690 /* Clear an L2 cache entry. */
    691 extern int bcm_l2_cache_delete(
    692     int unit, 
    693     int index);
    694 
    695 /* Clear all L2 cache entries. */
    696 extern int bcm_l2_cache_delete_all(
    697     int unit);
    698 
    699 #endif /* BCM_HIDE_DISPATCHABLE */
    700 
    701 /* Initialize an l2 egress object. */
    702 extern void bcm_l2_egress_t_init(
    703     bcm_l2_egress_t *egr);
    704 
    705 #ifndef BCM_HIDE_DISPATCHABLE
    706 
    707 /* Create an l2 encapsulation index. */
    708 extern int bcm_l2_egress_create(
    709     int unit, 
    710     bcm_l2_egress_t *egr);
    711 
    712 /* Destroy an l2 encapsulation index. */
    713 extern int bcm_l2_egress_destroy(
    714     int unit, 
    715     bcm_if_t encap_id);
    716 
    717 /* Get l2 egress object configuration. */
    718 extern int bcm_l2_egress_get(
    719     int unit, 
    720     bcm_if_t encap_id, 
    721     bcm_l2_egress_t *egr);
    722 
    723 /* Find an encapsulation index with a specific l2 egress configuration. */
    724 extern int bcm_l2_egress_find(
    725     int unit, 
    726     bcm_l2_egress_t *egr, 
    727     bcm_if_t *encap_id);
    728 
    729 #endif /* BCM_HIDE_DISPATCHABLE */
    730 
    731 /* l2 egress traverse callback */
    732 typedef int (*bcm_l2_egress_traverse_cb)(
    733     int unit, 
    734     bcm_l2_egress_t *egr, 
    735     void *user_data);
    736 
    737 #ifndef BCM_HIDE_DISPATCHABLE
    738 
    739 /* Traverse L2 egress objects */
    740 extern int bcm_l2_egress_traverse(
    741     int unit, 
    742     bcm_l2_egress_traverse_cb trav_fn, 
    743     void *user_data);
    744 
    745 /* Add a destination L2 address to trigger tunnel processing. */
    746 extern int bcm_l2_tunnel_add(
    747     int unit, 
    748     bcm_mac_t mac, 
    749     bcm_vlan_t vlan);
    750 
    751 /* Clear a destination L2 address used to trigger tunnel processing. */
    752 extern int bcm_l2_tunnel_delete(
    753     int unit, 
    754     bcm_mac_t mac, 
    755     bcm_vlan_t vlan);
    756 
    757 /* Clear all destination L2 addresses used to trigger tunnel processing. */
    758 extern int bcm_l2_tunnel_delete_all(
    759     int unit);
    760 
    761 #endif /* BCM_HIDE_DISPATCHABLE */
    762 
    763 /* Initialize an L2 learn limit structure. */
    764 extern void bcm_l2_learn_limit_t_init(
    765     bcm_l2_learn_limit_t *limit);
    766 
    767 #ifndef BCM_HIDE_DISPATCHABLE
    768 
    769 /* Enable the BCM L2 learn limit subsystem. */
    770 extern int bcm_l2_learn_limit_enable(
    771     int unit);
    772 
    773 /* Disable the BCM L2 learn limit subsystem. */
    774 extern int bcm_l2_learn_limit_disable(
    775     int unit);
    776 
    777 /* Set/Get L2 addresses learn limit. */
    778 extern int bcm_l2_learn_limit_set(
    779     int unit, 
    780     bcm_l2_learn_limit_t *limit);
    781 
    782 /* Set/Get L2 addresses learn limit. */
    783 extern int bcm_l2_learn_limit_get(
    784     int unit, 
    785     bcm_l2_learn_limit_t *limit);
    786 
    787 #endif /* BCM_HIDE_DISPATCHABLE */
    788 
    789 #define BCM_L2_LEARN_CLASS_MOVE 0x01       
    790 
    791 #ifndef BCM_HIDE_DISPATCHABLE
    792 
    793 /* Set/Get attributes for the specified L2 learning class. */
    794 extern int bcm_l2_learn_class_set(
    795     int unit, 
    796     int lclass, 
    797     int lclass_prio, 
    798     uint32 flags);
    799 
    800 /* Set/Get attributes for the specified L2 learning class. */
    801 extern int bcm_l2_learn_class_get(
    802     int unit, 
    803     int lclass, 
    804     int *lclass_prio, 
    805     uint32 *flags);
    806 
    807 /* Set/Get L2 learning class for the specified port. */
    808 extern int bcm_l2_learn_port_class_set(
    809     int unit, 
    810     bcm_gport_t port, 
    811     int lclass);
    812 
    813 #endif /* BCM_HIDE_DISPATCHABLE */
    814 
    815 /* L2 Statistics. */
    816 typedef enum bcm_l2_stat_e {
    817     bcmL2StatSourcePackets = 0, 
    818     bcmL2StatSourceBytes = 1, 
    819     bcmL2StatDestPackets = 2, 
    820     bcmL2StatDestBytes = 3, 
    821     bcmL2StatDropPackets = 4, 
    822     bcmL2StatDropBytes = 5 
    823 } bcm_l2_stat_t;
    824 
    825 #define BCM_STAT_CHECK_L2_STAT(type)  do { if ( ((type) < bcmL2StatSourcePackets) || ((type) > bcmL2StatDropBytes) ) { return (BCM_E_BADID); } } while (0) 
    826 
    827 #ifndef BCM_HIDE_DISPATCHABLE
    828 
    829 /* Get the specified L2 statistic from the chip. */
    830 extern int bcm_l2_stat_get(
    831     int unit, 
    832     bcm_l2_addr_t *l2_addr, 
    833     bcm_l2_stat_t stat, 
    834     uint64 *val);
    835 
    836 /* Get the specified L2 statistic from the chip. */
    837 extern int bcm_l2_stat_get32(
    838     int unit, 
    839     bcm_l2_addr_t *l2_addr, 
    840     bcm_l2_stat_t stat, 
    841     uint32 *val);
    842 
    843 /* 
    844  * Set the specified L2 statistic to the indicated value for the
    845  * specified L2 address.
    846  */
    847 extern int bcm_l2_stat_set(
    848     int unit, 
    849     bcm_l2_addr_t *l2_addr, 
    850     bcm_l2_stat_t stat, 
    851     uint64 val);
    852 
    853 /* 
    854  * Set the specified L2 statistic to the indicated value for the
    855  * specified L2 address.
    856  */
    857 extern int bcm_l2_stat_set32(
    858     int unit, 
    859     bcm_l2_addr_t *l2_addr, 
    860     bcm_l2_stat_t stat, 
    861     uint32 val);
    862 
    863 /* Enable/disable collection of statistics on the indicated L2 entry. */
    864 extern int bcm_l2_stat_enable_set(
    865     int unit, 
    866     bcm_l2_addr_t *l2_addr, 
    867     int enable);
    868 
    869 /* Set/Get L2 learning class for the specified port. */
    870 extern int bcm_l2_learn_port_class_get(
    871     int unit, 
    872     bcm_gport_t port, 
    873     int *lclass);
    874 
    875 #endif /* BCM_HIDE_DISPATCHABLE */
    876 
    877 /* L2 Learned Statistic Type. */
    878 typedef enum bcm_l2_learn_stat_type_e {
    879     bcmL2LearnStatL2TableLearned = 0,   /* The counter of L2_ENTRY learned. */
    880     bcmL2LearnStatOverflowPoolLearned = 1, /* The counter of 128_OVERFLOW_ENTRY
    881                                            learned. */
    882     bcmL2LearnStatHashCollisions = 2,   /* The counter of L2_ENTRY hash
    883                                            collision. */
    884     bcmL2LearnStatCount = 3             /* Must be last. */
    885 } bcm_l2_learn_stat_type_t;
    886 
    887 /* L2 Learned Statistic info. */
    888 typedef struct bcm_l2_learn_stat_s {
    889     bcm_l2_learn_stat_type_t type;  /* L2 learned statistic type. */
    890     uint32 value;                   /* 32-bit data value for L2 learned
    891                                        statistic. */
    892 } bcm_l2_learn_stat_t;
    893 
    894 /* Initialize an L2 learned statistic structure. */
    895 extern void bcm_l2_learn_stat_t_init(
    896     bcm_l2_learn_stat_t *learn_stat);
    897 
    898 #ifndef BCM_HIDE_DISPATCHABLE
    899 
    900 /* Set or clear the specified L2 hash counter to the indicated value. */
    901 extern int bcm_l2_learn_stat_set(
    902     int unit, 
    903     bcm_l2_learn_stat_t *learn_stat);
    904 
    905 /* Get the statistic of the specified L2 hash counter from chip. */
    906 extern int bcm_l2_learn_stat_get(
    907     int unit, 
    908     bcm_l2_learn_stat_t *learn_stat);
    909 
    910 #endif /* BCM_HIDE_DISPATCHABLE */
    911 
    912 /* bcm_l2_traverse_cb */
    913 typedef int (*bcm_l2_traverse_cb)(
    914     int unit, 
    915     bcm_l2_addr_t *info, 
    916     void *user_data);
    917 
    918 #ifndef BCM_HIDE_DISPATCHABLE
    919 
    920 /* Traverse L2 table */
    921 extern int bcm_l2_traverse(
    922     int unit, 
    923     bcm_l2_traverse_cb trav_fn, 
    924     void *user_data);
    925 
    926 /* 
    927  * The callback will be called on entries that match the given
    928  * match_addr, match_mask flags (similar to l2_replace)
    929  */
    930 extern int bcm_l2_match_masked_traverse(
    931     int unit, 
    932     uint32 flags, 
    933     bcm_l2_addr_t *match_addr, 
    934     bcm_l2_addr_t *mask_addr, 
    935     bcm_l2_traverse_cb trav_fn, 
    936     void *user_data);
    937 
    938 #endif /* BCM_HIDE_DISPATCHABLE */
    939 
    940 /* Flags for l2_replace API */
    941 #define BCM_L2_REPLACE_MATCH_STATIC         0x00000001 /* Replace L2 static
    942                                                           entries. */
    943 #define BCM_L2_REPLACE_MATCH_MAC            0x00000002 /* Replace all L2 entries
    944                                                           matching given MAC
    945                                                           address */
    946 #define BCM_L2_REPLACE_MATCH_VLAN           0x00000004 /* Replace all L2 entries
    947                                                           matching given VLAN id */
    948 #define BCM_L2_REPLACE_MATCH_DEST           0x00000008 /* Replace all L2 entries
    949                                                           matching given modid
    950                                                           port/tgid */
    951 #define BCM_L2_REPLACE_VPN_TYPE             0x00000010 /* Replace all VPN type
    952                                                           L2 entry */
    953 #define BCM_L2_REPLACE_VLAN_AND_VPN_TYPE    0x00000020 /* Replace all VLAN and
    954                                                           VPN type L2 entry */
    955 #define BCM_L2_REPLACE_DELETE               0x00000100 /* L2 replace will
    956                                                           perform delete
    957                                                           operation instead of
    958                                                           replace on matching
    959                                                           entries */
    960 #define BCM_L2_REPLACE_NEW_TRUNK            0x00000200 /* New destination is a
    961                                                           trunk group */
    962 #define BCM_L2_REPLACE_PENDING              0x00000400 /* Replace L2 pending
    963                                                           entries. */
    964 #define BCM_L2_REPLACE_NO_CALLBACKS         0x00000800 /* Replace L2 entries
    965                                                           without callbacks. */
    966 #define BCM_L2_REPLACE_LEARN_LIMIT          0x00001000 /* Force ALL entries
    967                                                           including static to be
    968                                                           counted for learn
    969                                                           limit */
    970 #define BCM_L2_REPLACE_IGNORE_PENDING       0x00002000 /* Force the L2 replace
    971                                                           process to ignore the
    972                                                           pending status check. */
    973 #define BCM_L2_REPLACE_PROTECTION_RING      0x00004000 /* Replace L2 protection
    974                                                           ring. */
    975 #define BCM_L2_REPLACE_MIGRATE_PORT         0x00008000 /* Replace L2 port. */
    976 #define BCM_L2_REPLACE_IGNORE_DISCARD_SRC   0x00010000 /* Match L2 entries with
    977                                                           given Discard on
    978                                                           source. */
    979 #define BCM_L2_REPLACE_IGNORE_DES_HIT       0x00020000 /* Match L2 entries
    980                                                           ignoring hit-bit
    981                                                           indication. */
    982 #define BCM_L2_REPLACE_DES_HIT_CLEAR        0x00040000 /* When set then reset
    983                                                           DES Hit-bit state. */
    984 #define BCM_L2_REPLACE_DISCARD_SRC_SET      0x00080000 /* When set then set
    985                                                           Discard on source */
    986 #define BCM_L2_REPLACE_DISCARD_SRC_CLEAR    0x00100000 /* When set then reset
    987                                                           Discard on source */
    988 #define BCM_L2_REPLACE_SRC_HIT_CLEAR        0x00200000 /* When set then reset
    989                                                           SRC Hit-bit state. */
    990 #define BCM_L2_REPLACE_AGE                  0x01000000 /* L2 replace will
    991                                                           perform age operation
    992                                                           instead of replace on
    993                                                           matching entries */
    994 #define BCM_L2_REPLACE_MATCH_UC             0x02000000 /* L2 replace will be
    995                                                           performed on Unicast
    996                                                           entries */
    997 #define BCM_L2_REPLACE_MATCH_MC             0x04000000 /* L2 replace will be
    998                                                           performed on Multicast
    999                                                           entries */
   1000 #define BCM_L2_REPLACE_DYNAMIC_SET          0x08000000 /* L2 replace changes the
   1001                                                           MACT entries to be
   1002                                                           dynamic */
   1003 #define BCM_L2_REPLACE_DYNAMIC_CLEAR        0x10000000 /* L2 replace changes the
   1004                                                           MACT entries to be
   1005                                                           static */
   1006 #define BCM_L2_REPLACE_MATCH_AGE            0x20000000 /* L2 replace will be
   1007                                                           performed on L2
   1008                                                           entries of a given age
   1009                                                           state */
   1010 #define BCM_L2_REPLACE_MATCH_CLASS_ID       0x40000000 /* L2 replace will be
   1011                                                           performed on L2
   1012                                                           entries of a given
   1013                                                           class id */
   1014 #define BCM_L2_REPLACE_MATCH_GROUP          0x40000000 /* L2 replace L2 entries
   1015                                                           with a given group */
   1016 #define BCM_L2_REPLACE_MATCH_INT_PRI        0x80000000 /* L2 replace will be
   1017                                                           performed on L2
   1018                                                           entries of a given
   1019                                                           internal priority */
   1020 
   1021 #ifndef BCM_HIDE_DISPATCHABLE
   1022 
   1023 /* Replace L2 entries matching given criterions */
   1024 extern int bcm_l2_replace(
   1025     int unit, 
   1026     uint32 flags, 
   1027     bcm_l2_addr_t *match_addr, 
   1028     bcm_module_t new_module, 
   1029     bcm_port_t new_port, 
   1030     bcm_trunk_t new_trunk);
   1031 
   1032 /* Replace by match_addr and mask_addr */
   1033 extern int bcm_l2_replace_match(
   1034     int unit, 
   1035     uint32 flags, 
   1036     bcm_l2_addr_t *match_addr, 
   1037     bcm_l2_addr_t *mask_addr, 
   1038     bcm_l2_addr_t *replace_addr, 
   1039     bcm_l2_addr_t *replace_mask_addr);
   1040 
   1041 #endif /* BCM_HIDE_DISPATCHABLE */
   1042 
   1043 /* L2 Station address info. */
   1044 typedef struct bcm_l2_station_s {
   1045     uint32 flags;                       /* BCM_L2_STATION_xxx flags. */
   1046     int priority;                       /* Entry priority. */
   1047     bcm_mac_t dst_mac;                  /* Destination MAC address to match. */
   1048     bcm_mac_t dst_mac_mask;             /* Destination MAC address mask value. */
   1049     bcm_vlan_t vlan;                    /* VLAN to match. */
   1050     bcm_vlan_t vlan_mask;               /* VLAN mask value. */
   1051     bcm_port_t src_port;                /* Ingress port to match. */
   1052     bcm_port_t src_port_mask;           /* Ingress port mask value. */
   1053     bcm_tsn_pri_map_t taf_gate_primap;  /* TAF (Time Aware Filtering) gate
   1054                                            priority mapping */
   1055 } bcm_l2_station_t;
   1056 
   1057 /* bcm_l2_station_traverse_cb */
   1058 typedef int (*bcm_l2_station_traverse_cb)(
   1059     int unit, 
   1060     bcm_l2_station_t *l2_station_addr, 
   1061     void *user_data);
   1062 
   1063 #ifndef BCM_HIDE_DISPATCHABLE
   1064 
   1065 /* Traverse L2 station table */
   1066 extern int bcm_l2_station_traverse(
   1067     int unit, 
   1068     bcm_l2_station_traverse_cb trav_fn, 
   1069     void *user_data);
   1070 
   1071 #endif /* BCM_HIDE_DISPATCHABLE */
   1072 
   1073 /* Flags for bcm_l2_station_add/get APIs. */
   1074 #define BCM_L2_STATION_WITH_ID      (1 << 0)   /* Use the specified Station ID. */
   1075 #define BCM_L2_STATION_REPLACE      (1 << 1)   /* Replace an existing L2 Station
   1076                                                   table entry. */
   1077 #define BCM_L2_STATION_IPV4         (1 << 2)   /* Subject packets matching this
   1078                                                   entry to L3 processing. */
   1079 #define BCM_L2_STATION_IPV6         (1 << 3)   /* Subject packets matching this
   1080                                                   entry to L3 processing. */
   1081 #define BCM_L2_STATION_ARP_RARP     (1 << 4)   /* Subject packets matching this
   1082                                                   entry to ARP/RARP processing. */
   1083 #define BCM_L2_STATION_MPLS         (1 << 5)   /* Subject packets matching this
   1084                                                   entry to MPLS processing. */
   1085 #define BCM_L2_STATION_MIM          (1 << 6)   /* Subject packets matching this
   1086                                                   entry to MiM processing. */
   1087 #define BCM_L2_STATION_TRILL        (1 << 7)   /* Subject packets matching this
   1088                                                   entry to Trill processing. */
   1089 #define BCM_L2_STATION_FCOE         (1 << 8)   /* Subject packets matching this
   1090                                                   entry to FCoE processing. */
   1091 #define BCM_L2_STATION_OAM          (1 << 9)   /* Subject packets matching this
   1092                                                   entry to OAM processing. */
   1093 #define BCM_L2_STATION_COPY_TO_CPU  (1 << 10)  /* Copy packet to CPU. */
   1094 #define BCM_L2_STATION_OLP          (1 << 11)  /* Subject packets matching this
   1095                                                   entry to OAM-OLP header
   1096                                                   processing. */
   1097 #define BCM_L2_STATION_XGS_MAC      (1 << 12)  /* Add this MAC address as source
   1098                                                   MAC in the OLP header for
   1099                                                   packets sent to OLP. */
   1100 #define BCM_L2_STATION_IPV4_MCAST   (1 << 13)  /* Subject packets matching this
   1101                                                   entry to IPV4 mcast
   1102                                                   processing. */
   1103 #define BCM_L2_STATION_IPV6_MCAST   (1 << 14)  /* Subject packets matching this
   1104                                                   entry to IPV6 mcast
   1105                                                   processing. */
   1106 #define BCM_L2_STATION_UNDERLAY     (1 << 15)  /* When RIOT is enabled, this
   1107                                                   flag must be set for creating
   1108                                                   tunnel mac addresses to
   1109                                                   distinguish them from routing
   1110                                                   mac addresses */
   1111 #define BCM_L2_STATION_DISCARD      (1 << 16)  /* Discard packets matching this
   1112                                                   entry */
   1113 #define BCM_L2_STATION_EXTENDED     (1 << 17)  /* Indicate extended memory usage */
   1114 
   1115 /* Initialize L2 Station structure. */
   1116 extern void bcm_l2_station_t_init(
   1117     bcm_l2_station_t *addr);
   1118 
   1119 #ifndef BCM_HIDE_DISPATCHABLE
   1120 
   1121 /* Add an entry to L2 Station Table. */
   1122 extern int bcm_l2_station_add(
   1123     int unit, 
   1124     int *station_id, 
   1125     bcm_l2_station_t *station);
   1126 
   1127 /* Delete an entry from L2 Station Table. */
   1128 extern int bcm_l2_station_delete(
   1129     int unit, 
   1130     int station_id);
   1131 
   1132 /* Clear all L2 Station Table entries. */
   1133 extern int bcm_l2_station_delete_all(
   1134     int unit);
   1135 
   1136 /* Get L2 station entry detail from Station Table. */
   1137 extern int bcm_l2_station_get(
   1138     int unit, 
   1139     int station_id, 
   1140     bcm_l2_station_t *station);
   1141 
   1142 /* Get size of L2 Station Table. */
   1143 extern int bcm_l2_station_size_get(
   1144     int unit, 
   1145     int *size);
   1146 
   1147 #endif /* BCM_HIDE_DISPATCHABLE */
   1148 
   1149 /* L2 ring structure. */
   1150 typedef struct bcm_l2_ring_s {
   1151     uint32 flags;                   /* flags */
   1152     bcm_vlan_vector_t vlan_vector;  /* List of Vlans. */
   1153     bcm_gport_t port0;              /* VLAN gport */
   1154     bcm_gport_t port1;              /* VLAN gport */
   1155     bcm_vpn_vector_t vpn_vector;    /* List of VPN IDs. */
   1156 } bcm_l2_ring_t;
   1157 
   1158 /* Initialize an L2 ring structure. */
   1159 extern void bcm_l2_ring_t_init(
   1160     bcm_l2_ring_t *l2_ring);
   1161 
   1162 #ifndef BCM_HIDE_DISPATCHABLE
   1163 
   1164 /* Replace an L2 ring with the provided configuration. */
   1165 extern int bcm_l2_ring_replace(
   1166     int unit, 
   1167     bcm_l2_ring_t *l2_ring);
   1168 
   1169 #endif /* BCM_HIDE_DISPATCHABLE */
   1170 
   1171 /* Device-independent L2 SA authentication structure. */
   1172 typedef struct bcm_l2_auth_addr_s {
   1173     uint32 flags;           /* BCM_L2_AUTH_XXX flags. */
   1174     bcm_mac_t sa_mac;       /* SA MAC address to match. */
   1175     bcm_vlan_t vlan;        /* VLAN to match. */
   1176     bcm_port_t src_port;    /* ingress port to match. */
   1177 } bcm_l2_auth_addr_t;
   1178 
   1179 /* The callback function called for each valid entry in l2-auth. */
   1180 typedef int (*bcm_l2_auth_traverse_cb)(
   1181     int unit, 
   1182     bcm_l2_auth_addr_t *info, 
   1183     void *userdata);
   1184 
   1185 #define BCM_L2_AUTH_CHECK_IN_PORT       0x00000001 /* check packet with sa_mac
   1186                                                       received on the expected
   1187                                                       src_port. */
   1188 #define BCM_L2_AUTH_CHECK_VLAN          0x00000002 /* check packet with sa_mac
   1189                                                       received on the expected
   1190                                                       vlan */
   1191 #define BCM_L2_AUTH_PERMIT_TAGGED_ONLY  0x00000004 /* permit only tagged packets */
   1192 
   1193 /* 
   1194  * Initialize an L2  SA authentication structure to a specified MAC
   1195  * address and VLAN ID.
   1196  */
   1197 extern void bcm_l2_auth_addr_t_init(
   1198     bcm_l2_auth_addr_t *addr);
   1199 
   1200 #ifndef BCM_HIDE_DISPATCHABLE
   1201 
   1202 /* Add an L2 SA authentication entry to the specified device. */
   1203 extern int bcm_l2_auth_add(
   1204     int unit, 
   1205     bcm_l2_auth_addr_t *addr);
   1206 
   1207 /* Check if an L2 SA authentication entry is present in the L2 table. */
   1208 extern int bcm_l2_auth_get(
   1209     int unit, 
   1210     bcm_l2_auth_addr_t *addr);
   1211 
   1212 /* Delete an L2 address entry from the specified device. */
   1213 extern int bcm_l2_auth_delete(
   1214     int unit, 
   1215     bcm_l2_auth_addr_t *addr);
   1216 
   1217 /* Delete an L2 address entry from the specified device. */
   1218 extern int bcm_l2_auth_delete_all(
   1219     int unit);
   1220 
   1221 /* Traverse L2 SA authentication objects */
   1222 extern int bcm_l2_auth_traverse(
   1223     int unit, 
   1224     bcm_l2_auth_traverse_cb trav_fn, 
   1225     void *user_data);
   1226 
   1227 /* 
   1228  * The callback will be called on entries that match the given entry and
   1229  * flags (similar to l2_replace)
   1230  */
   1231 extern int bcm_l2_matched_traverse(
   1232     int unit, 
   1233     uint32 flags, 
   1234     bcm_l2_addr_t *match_addr, 
   1235     bcm_l2_traverse_cb trav_fn, 
   1236     void *user_data);
   1237 
   1238 #endif /* BCM_HIDE_DISPATCHABLE */
   1239 
   1240 /* Flags for bcm_l2_traverse_match API. */
   1241 #define BCM_L2_TRAVERSE_MATCH_STATIC        (1 << 0)   /* Match L2 static
   1242                                                           entries only, if it
   1243                                                           and
   1244                                                           L2_TRAVERSE_MATCH_DYNAMIC
   1245                                                           not present match
   1246                                                           static entries
   1247                                                           together with all
   1248                                                           other entries */
   1249 #define BCM_L2_TRAVERSE_MATCH_MAC           (1 << 1)   /* Match L2 entries with
   1250                                                           given MAC address */
   1251 #define BCM_L2_TRAVERSE_MATCH_VLAN          (1 << 2)   /* Match L2 entries with
   1252                                                           given VLAN ID */
   1253 #define BCM_L2_TRAVERSE_MATCH_DEST          (1 << 3)   /* Match L2 entries with
   1254                                                           given modid port/tgid */
   1255 #define BCM_L2_TRAVERSE_IGNORE_DISCARD_SRC  (1 << 4)   /* match entries ignoring
   1256                                                           destination SA-discard
   1257                                                           indication */
   1258 #define BCM_L2_TRAVERSE_IGNORE_DES_HIT      (1 << 5)   /* match entries ignoring
   1259                                                           destination hit-bit
   1260                                                           indication */
   1261 #define BCM_L2_TRAVERSE_IGNORE_SRC_HIT      (1 << 6)   /* match entries ignoring
   1262                                                           source hit-bit
   1263                                                           indication */
   1264 #define BCM_L2_TRAVERSE_MATCH_NATIVE        (1 << 7)   /* Match entries with
   1265                                                           given local address
   1266                                                           indication */
   1267 #define BCM_L2_TRAVERSE_MATCH_DYNAMIC       (1 << 8)   /* Match L2 non-static
   1268                                                           entries only, if it
   1269                                                           and
   1270                                                           L2_TRAVERSE_MATCH_STATIC
   1271                                                           not present match
   1272                                                           dynamic entries
   1273                                                           together with all
   1274                                                           other entries */
   1275 #define BCM_L2_TRAVERSE_MATCH_IVL           (1 << 9)   /* Traverse l2 entries
   1276                                                           that have an IVL
   1277                                                           format. */
   1278 #define BCM_L2_TRAVERSE_MATCH_GROUP         (1 << 10)  /* Match L2 entries with
   1279                                                           a given group. */
   1280 
   1281 /* BCM_L2_MAC_PORT_* flags. */
   1282 #define BCM_L2_MAC_PORT_WITH_ID 0x00000001 /* create mac port with specified ID */
   1283 #define BCM_L2_MAC_PORT_REPLACE 0x00000002 /* Replace existing mac port */
   1284 
   1285 /* MAC port type. */
   1286 typedef struct bcm_l2_mac_port_s {
   1287     uint32 flags;               /* BCM_L2_MAC_PORT_xxx. */
   1288     bcm_mac_t mac;              /* MAC address to match. */
   1289     bcm_gport_t port;           /* Physical port / trunk */
   1290     bcm_gport_t mac_port_id;    /* MAC GPORT ID. */
   1291 } bcm_l2_mac_port_t;
   1292 
   1293 /* Initialize the MAC port structure. */
   1294 extern void bcm_l2_mac_port_t_init(
   1295     bcm_l2_mac_port_t *mac_port);
   1296 
   1297 #ifndef BCM_HIDE_DISPATCHABLE
   1298 
   1299 /* Create MAC port */
   1300 extern int bcm_l2_mac_port_create(
   1301     int unit, 
   1302     bcm_l2_mac_port_t *mac_port);
   1303 
   1304 /* Destroy MAC port. */
   1305 extern int bcm_l2_mac_port_destroy(
   1306     int unit, 
   1307     bcm_gport_t mac_port_id);
   1308 
   1309 /* Destroy all MAC ports. */
   1310 extern int bcm_l2_mac_port_destroy_all(
   1311     int unit);
   1312 
   1313 /* Get MAC Port information */
   1314 extern int bcm_l2_mac_port_get(
   1315     int unit, 
   1316     bcm_l2_mac_port_t *mac_port);
   1317 
   1318 #endif /* BCM_HIDE_DISPATCHABLE */
   1319 
   1320 /* MAC port traverse function prototype. */
   1321 typedef int (*bcm_l2_mac_port_traverse_cb)(
   1322     int unit, 
   1323     bcm_l2_mac_port_t *mac_port, 
   1324     void *user_data);
   1325 
   1326 #ifndef BCM_HIDE_DISPATCHABLE
   1327 
   1328 /* Traverse MAC ports */
   1329 extern int bcm_l2_mac_port_traverse(
   1330     int unit, 
   1331     bcm_l2_mac_port_traverse_cb cb, 
   1332     void *user_data);
   1333 
   1334 #endif /* BCM_HIDE_DISPATCHABLE */
   1335 
   1336 /* Struct to get gport forward info */
   1337 typedef struct bcm_l2_gport_forward_info_s {
   1338     int phy_gport; 
   1339     int encap_id; 
   1340 } bcm_l2_gport_forward_info_t;
   1341 
   1342 /* Initialize bcm_l2_gport_forward_info_t struct */
   1343 extern void bcm_l2_gport_forward_info_t_init(
   1344     bcm_l2_gport_forward_info_t *forward_info);
   1345 
   1346 #ifndef BCM_HIDE_DISPATCHABLE
   1347 
   1348 /* Map gport-id to forwarding information */
   1349 extern int bcm_l2_gport_forward_info_get(
   1350     int unit, 
   1351     int gport_id, 
   1352     bcm_l2_gport_forward_info_t *forward_info);
   1353 
   1354 /* Purge L2 Entries for the specific set of (port,vlan) pairs. */
   1355 extern int bcm_l2_addr_delete_by_vlan_gport_multi(
   1356     int unit, 
   1357     uint32 flags, 
   1358     int num_pairs, 
   1359     bcm_vlan_t *vlan, 
   1360     bcm_gport_t *gport);
   1361 
   1362 /* Add an multi L2 address entry to the specified device. */
   1363 extern int bcm_l2_addr_multi_add(
   1364     int unit, 
   1365     bcm_l2_addr_t *l2addr, 
   1366     int count);
   1367 
   1368 /* Delete multi L2 address entry from the specified device. */
   1369 extern int bcm_l2_addr_multi_delete(
   1370     int unit, 
   1371     bcm_l2_addr_t *l2addr, 
   1372     int count);
   1373 
   1374 #endif /* BCM_HIDE_DISPATCHABLE */
   1375 
   1376 /* Max number of MACs in the structure below. */
   1377 #define BCM_RX_TRAP_L2CP_NOF_ENTRIES    64         
   1378 
   1379 /* Set of MACS for L2CP traps profile build. */
   1380 typedef struct bcm_l2cp_profile_info_s {
   1381     int nof_entries; 
   1382     bcm_mac_t mac_add[BCM_RX_TRAP_L2CP_NOF_ENTRIES]; 
   1383 } bcm_l2cp_profile_info_t;
   1384 
   1385 #ifndef BCM_HIDE_DISPATCHABLE
   1386 
   1387 /* Build L2CP trap profile */
   1388 extern int bcm_l2_cache_profile_set(
   1389     int unit, 
   1390     int trap_type, 
   1391     uint32 profile_idx, 
   1392     uint32 flags, 
   1393     bcm_l2cp_profile_info_t *l2cp_profile_info);
   1394 
   1395 /* Read L2CP trap profile */
   1396 extern int bcm_l2_cache_profile_get(
   1397     int unit, 
   1398     int trap_type, 
   1399     uint32 profile_idx, 
   1400     uint32 flags, 
   1401     bcm_l2cp_profile_info_t *l2cp_profile_info);
   1402 
   1403 /* Assign profile index to VSI */
   1404 extern int bcm_l2_cache_vpn_to_profile_map_set(
   1405     int unit, 
   1406     uint32 vsi, 
   1407     uint32 profile_idx);
   1408 
   1409 /* Get profile index assigned to VSI */
   1410 extern int bcm_l2_cache_vpn_to_profile_map_get(
   1411     int unit, 
   1412     uint32 vsi, 
   1413     uint32 *profile_idx);
   1414 
   1415 /* 
   1416  * Retrieve a MAC entry according to mac, vid (used as VSI) and modid.
   1417  * When modid != 0 it should hold a VLAN ID for IVL entries.
   1418  */
   1419 extern int bcm_l2_addr_by_struct_get(
   1420     int unit, 
   1421     bcm_l2_addr_t *l2addr);
   1422 
   1423 /* 
   1424  * Delete a MAC entry according to mac, vid (used as VSI) and modid. When
   1425  * modid != 0 it should hold a VLAN ID for IVL entries.
   1426  */
   1427 extern int bcm_l2_addr_by_struct_delete(
   1428     int unit, 
   1429     bcm_l2_addr_t *l2addr);
   1430 
   1431 #endif /* BCM_HIDE_DISPATCHABLE */
   1432 
   1433 #if defined(INCLUDE_L3)
   1434 /* Change L2 Fields flags. */
   1435 #define BCM_L2_CHANGE_FIELDS_DVP            (1 << 0)   /* DVP key paramter is
   1436                                                           valid. */
   1437 #define BCM_L2_CHANGE_FIELDS_REPLACE        (1 << 1)   /* Replace L2 Change
   1438                                                           Fields entry for given
   1439                                                           key fields. */
   1440 #define BCM_L2_CHANGE_FIELDS_VLAN_ADD       (1 << 2)   /* Add payload VLAN tag. */
   1441 #define BCM_L2_CHANGE_FIELDS_VLAN_DELETE    (1 << 3)   /* Delete payload vlan. */
   1442 #define BCM_L2_CHANGE_FIELDS_VLAN_REPLACE   (1 << 4)   /* Replace payload vlan
   1443                                                           tag. */
   1444 #define BCM_L2_CHANGE_FIELDS_VLAN_PRI_TPID_REPLACE (1 << 5)   /* Replace payload vlan,
   1445                                                           priority and tpid. */
   1446 #define BCM_L2_CHANGE_FIELDS_VLAN_TPID_REPLACE (1 << 6)   /* Replace payload vlan
   1447                                                           and tpid. */
   1448 #define BCM_L2_CHANGE_FIELDS_VLAN_PRI_REPLACE (1 << 7)   /* Replace payload vlan
   1449                                                           and priority. */
   1450 #define BCM_L2_CHANGE_FIELDS_PRI_REPLACE    (1 << 8)   /* Replace payload
   1451                                                           priority only. */
   1452 #define BCM_L2_CHANGE_FIELDS_TPID_REPLACE   (1 << 9)   /* Replace payload tpid
   1453                                                           only. */
   1454 #endif
   1455 
   1456 #if defined(INCLUDE_L3)
   1457 /* Change L2 Fields entry specification. */
   1458 typedef struct bcm_l2_change_fields_s {
   1459     uint32 flags;                       /* See BCM_L2_CHANGE_FIELDS_XXX flag
   1460                                            definitions. */
   1461     bcm_mac_t macda;                    /* New payload MACDA. */
   1462     bcm_mac_t macsa;                    /* New payload MACSA. */
   1463     uint8 pri;                          /* payload tag priority. */
   1464     uint8 cfi;                          /* payload tag CFI. */
   1465     uint16 tpid;                        /* payload tag TIP value. */
   1466     uint16 vlan;                        /* payload vlan tag. */
   1467     uint32 change_l2_fields_class_id;   /* Change L2 Fields class ID assigned by
   1468                                            ingress FP. */
   1469     bcm_gport_t dvp;                    /* Optional DVP key. */
   1470 } bcm_l2_change_fields_t;
   1471 #endif
   1472 
   1473 /* bcm_l2_change_fields_traverse_cb */
   1474 #if defined(INCLUDE_L3)
   1475 typedef int (*bcm_l2_change_fields_traverse_cb)(
   1476     int unit, 
   1477     bcm_l2_change_fields_t *l2_fields_info, 
   1478     void *user_data);
   1479 #endif
   1480 
   1481 #if defined(INCLUDE_L3)
   1482 /* Initialize a bcm_l2_change_fields_t structure. */
   1483 extern void bcm_l2_change_fields_t_init(
   1484     bcm_l2_change_fields_t *l2_fields_info);
   1485 #endif
   1486 
   1487 #ifndef BCM_HIDE_DISPATCHABLE
   1488 
   1489 #if defined(INCLUDE_L3)
   1490 /* 
   1491  * Add a Change L2 Fields entry in the Egress Adaptation Table. If
   1492  * REPLACE flag is specified then update the entry identified by the
   1493  * l2_fields_info.
   1494  */
   1495 extern int bcm_l2_change_fields_add(
   1496     int unit, 
   1497     bcm_l2_change_fields_t *l2_fields_info);
   1498 #endif
   1499 
   1500 #if defined(INCLUDE_L3)
   1501 /* Delete a Change L2 Fields entry from the Egress Adaptation table. */
   1502 extern int bcm_l2_change_fields_delete(
   1503     int unit, 
   1504     bcm_l2_change_fields_t *l2_fields_info);
   1505 #endif
   1506 
   1507 #if defined(INCLUDE_L3)
   1508 /* 
   1509  * Retrieve the Change L2 Fields entry specified in l2_fields_info
   1510  * structure
   1511  */
   1512 extern int bcm_l2_change_fields_get(
   1513     int unit, 
   1514     bcm_l2_change_fields_t *l2_fields_info);
   1515 #endif
   1516 
   1517 #if defined(INCLUDE_L3)
   1518 /* 
   1519  * Traverse through the Change L2 Fields entries in the Egress Adaptation
   1520  * table and invoke a user provided callback for each valid entry.
   1521  */
   1522 extern int bcm_l2_change_fields_traverse(
   1523     int unit, 
   1524     bcm_l2_change_fields_traverse_cb cb, 
   1525     void *user_data);
   1526 #endif
   1527 
   1528 #endif /* BCM_HIDE_DISPATCHABLE */
   1529 
   1530 #endif /* __BCM_L2_H__ */