OpenNSL API Guide and Reference Manual
Data Structures | Files | Macros | Typedefs | Functions
Layer 2 Address Management

Data Structures

struct  opennsl_l2_addr_s
 Device-independent L2 address structure. More...
 
struct  opennsl_l2_cache_addr_s
 Device-independent L2 cache address structure. More...
 
struct  opennsl_l2_learn_limit_s
 L2 learn limit structure. More...
 
struct  opennsl_l2_station_s
 L2 Station address info. More...
 

Files

file  l2.h
 
file  l2X.h
 

Macros

#define OPENNSL_L2_CACHE_BPDU   0x00000010
 Packet is BPDU.
 
#define OPENNSL_L2_CACHE_CPU   0x00000001
 Packet is copied to CPU.
 
#define OPENNSL_L2_CACHE_DISCARD   0x00000002
 Packet is not switched.
 
#define OPENNSL_L2_CALLBACK_ADD   1
 
#define OPENNSL_L2_CALLBACK_AGE_EVENT   4
 
#define OPENNSL_L2_CALLBACK_DELETE   0
 
#define OPENNSL_L2_CALLBACK_LEARN_EVENT   3
 
#define OPENNSL_L2_CALLBACK_MOVE_EVENT   5
 
#define OPENNSL_L2_CALLBACK_REPORT   2
 
#define OPENNSL_L2_COPY_TO_CPU   0x00000008
 
#define OPENNSL_L2_DELETE_NO_CALLBACKS   0x00000004
 
#define OPENNSL_L2_DELETE_PENDING   0x00000002
 
#define OPENNSL_L2_DELETE_STATIC   0x00000001
 
#define OPENNSL_L2_DES_HIT   0x00000800
 
#define OPENNSL_L2_DISCARD_DST   0x00000004
 
#define OPENNSL_L2_DISCARD_SRC   0x00000002
 
#define OPENNSL_L2_HIT   0x00000040
 
#define OPENNSL_L2_L3LOOKUP   0x00000010
 
#define OPENNSL_L2_LEARN_LIMIT_SYSTEM   0x00000001
 Limit is system wide.
 
#define OPENNSL_L2_LOCAL_CPU   0x00200000
 Entry is for the local CPU on the device.
 
#define OPENNSL_L2_MCAST   0x00000100
 
#define OPENNSL_L2_MOVE_PORT   0x00100000
 
#define OPENNSL_L2_REPLACE_DELETE   0x00000100
 L2 replace will perform delete operation instead of replace on matching entries.
 
#define OPENNSL_L2_REPLACE_MATCH_DEST   0x00000008
 Replace all L2 entries matching given modid port/tgid.
 
#define OPENNSL_L2_REPLACE_MATCH_MAC   0x00000002
 Replace all L2 entries matching given MAC address.
 
#define OPENNSL_L2_REPLACE_MATCH_STATIC   0x00000001
 Replace L2 static entries.
 
#define OPENNSL_L2_REPLACE_MATCH_VLAN   0x00000004
 Replace all L2 entries matching given VLAN id.
 
#define OPENNSL_L2_REPLACE_NO_CALLBACKS   0x00000800
 Replace L2 entries without callbacks.
 
#define OPENNSL_L2_SRC_HIT   0x00000400
 
#define OPENNSL_L2_STATIC   0x00000020
 
#define OPENNSL_L2_STATION_ARP_RARP   (1 << 4)
 Subject packets matching this entry to ARP/RARP processing.
 
#define OPENNSL_L2_STATION_IPV4   (1 << 2)
 Subject packets matching this entry to L3 processing.
 
#define OPENNSL_L2_STATION_IPV6   (1 << 3)
 Subject packets matching this entry to L3 processing.
 
#define OPENNSL_L2_STATION_WITH_ID   (1 << 0)
 Use the specified Station ID.
 
#define OPENNSL_L2_TRUNK_MEMBER   0x00000080
 

Typedefs

typedef void(* opennsl_l2_addr_callback_t )(int unit, opennsl_l2_addr_t *l2addr, int operation, void *userdata)
 Callback function used for receiving notification about insertions into and deletions from the L2 table dynamically as they occur.
 
typedef struct opennsl_l2_addr_s opennsl_l2_addr_t
 Device-independent L2 address structure.
 
typedef struct
opennsl_l2_cache_addr_s 
opennsl_l2_cache_addr_t
 Device-independent L2 cache address structure.
 
typedef struct
opennsl_l2_learn_limit_s 
opennsl_l2_learn_limit_t
 L2 learn limit structure.
 
typedef struct opennsl_l2_station_s opennsl_l2_station_t
 L2 Station address info.
 
typedef int(* opennsl_l2_traverse_cb )(int unit, opennsl_l2_addr_t *info, void *user_data)
 

Functions

int opennsl_l2_addr_add (int unit, opennsl_l2_addr_t *l2addr) LIB_DLL_EXPORTED
 Add an L2 address entry to the specified device.
 
int opennsl_l2_addr_delete (int unit, opennsl_mac_t mac, opennsl_vlan_t vid) LIB_DLL_EXPORTED
 Delete an L2 address entry from the specified device.
 
int opennsl_l2_addr_delete_by_mac (int unit, opennsl_mac_t mac, uint32 flags) LIB_DLL_EXPORTED
 Delete L2 entries associated with a MAC address.
 
int opennsl_l2_addr_delete_by_mac_port (int unit, opennsl_mac_t mac, opennsl_module_t mod, opennsl_port_t port, uint32 flags) LIB_DLL_EXPORTED
 Delete L2 entries associated with a MAC address and a destination module/port.
 
int opennsl_l2_addr_delete_by_port (int unit, opennsl_module_t mod, opennsl_port_t port, uint32 flags) LIB_DLL_EXPORTED
 Delete L2 entries associated with a destination module/port.
 
int opennsl_l2_addr_delete_by_trunk (int unit, opennsl_trunk_t tid, uint32 flags) LIB_DLL_EXPORTED
 Delete L2 entries associated with a trunk.
 
int opennsl_l2_addr_delete_by_vlan (int unit, opennsl_vlan_t vid, uint32 flags) LIB_DLL_EXPORTED
 Delete L2 entries associated with a VLAN.
 
int opennsl_l2_addr_delete_by_vlan_port (int unit, opennsl_vlan_t vid, opennsl_module_t mod, opennsl_port_t port, uint32 flags) LIB_DLL_EXPORTED
 Delete L2 entries associated with a VLAN and a destination module/port.
 
int opennsl_l2_addr_delete_by_vlan_trunk (int unit, opennsl_vlan_t vid, opennsl_trunk_t tid, uint32 flags) LIB_DLL_EXPORTED
 Delete L2 entries associated with a VLAN and a destination module/port.
 
int opennsl_l2_addr_freeze (int unit) LIB_DLL_EXPORTED
 Temporarily stop/restore L2 table from changing.
 
int opennsl_l2_addr_get (int unit, opennsl_mac_t mac_addr, opennsl_vlan_t vid, opennsl_l2_addr_t *l2addr) LIB_DLL_EXPORTED
 Check if an L2 entry is present in the L2 table.
 
int opennsl_l2_addr_register (int unit, opennsl_l2_addr_callback_t callback, void *userdata) LIB_DLL_EXPORTED
 Register/Unregister a callback routine for OPENNSL L2 subsystem.
 
void opennsl_l2_addr_t_init (opennsl_l2_addr_t *l2addr, const opennsl_mac_t mac_addr, opennsl_vlan_t vid) LIB_DLL_EXPORTED
 Initialize an L2 address structure to a specified MAC address and VLAN ID.
 
int opennsl_l2_addr_thaw (int unit) LIB_DLL_EXPORTED
 Temporarily stop/restore L2 table from changing.
 
int opennsl_l2_addr_unregister (int unit, opennsl_l2_addr_callback_t callback, void *userdata) LIB_DLL_EXPORTED
 Register/Unregister a callback routine for OPENNSL L2 subsystem.
 
int opennsl_l2_age_timer_get (int unit, int *age_seconds) LIB_DLL_EXPORTED
 Set/Get the age timer.
 
int opennsl_l2_age_timer_set (int unit, int age_seconds) LIB_DLL_EXPORTED
 Set/Get the age timer.
 
void opennsl_l2_cache_addr_t_init (opennsl_l2_cache_addr_t *addr) LIB_DLL_EXPORTED
 Initialize an L2 cache address structure.
 
int opennsl_l2_cache_delete (int unit, int index) LIB_DLL_EXPORTED
 Clear an L2 cache entry.
 
int opennsl_l2_cache_delete_all (int unit) LIB_DLL_EXPORTED
 Clear all L2 cache entries.
 
int opennsl_l2_cache_get (int unit, int index, opennsl_l2_cache_addr_t *addr) LIB_DLL_EXPORTED
 Get an L2 cache entry.
 
int opennsl_l2_cache_init (int unit) LIB_DLL_EXPORTED
 Initialize the L2 cache.
 
int opennsl_l2_cache_set (int unit, int index, opennsl_l2_cache_addr_t *addr, int *index_used) LIB_DLL_EXPORTED
 Set an L2 cache entry.
 
int opennsl_l2_cache_size_get (int unit, int *size) LIB_DLL_EXPORTED
 Get number of L2 cache entries.
 
int opennsl_l2_learn_limit_get (int unit, opennsl_l2_learn_limit_t *limit) LIB_DLL_EXPORTED
 Set/Get L2 addresses learn limit.
 
int opennsl_l2_learn_limit_set (int unit, opennsl_l2_learn_limit_t *limit) LIB_DLL_EXPORTED
 Set/Get L2 addresses learn limit.
 
void opennsl_l2_learn_limit_t_init (opennsl_l2_learn_limit_t *limit) LIB_DLL_EXPORTED
 Initialize an L2 learn limit structure.
 
int opennsl_l2_replace (int unit, uint32 flags, opennsl_l2_addr_t *match_addr, opennsl_module_t new_module, opennsl_port_t new_port, opennsl_trunk_t new_trunk) LIB_DLL_EXPORTED
 Replace destination (or delete) multiple L2 entries.
 
int opennsl_l2_station_add (int unit, int *station_id, opennsl_l2_station_t *station) LIB_DLL_EXPORTED
 Add an entry to L2 Station table.
 
int opennsl_l2_station_delete (int unit, int station_id) LIB_DLL_EXPORTED
 Delete an entry from L2 Station Table.
 
int opennsl_l2_station_get (int unit, int station_id, opennsl_l2_station_t *station) LIB_DLL_EXPORTED
 Get L2 station entry details from Station Table.
 
void opennsl_l2_station_t_init (opennsl_l2_station_t *addr) LIB_DLL_EXPORTED
 Initialize L2 Station structure.
 
int opennsl_l2_traverse (int unit, opennsl_l2_traverse_cb trav_fn, void *user_data) LIB_DLL_EXPORTED
 Iterates over all entries in the L2 table and executes user callback function for each entry.
 
int opennsl_l2_tunnel_add (int unit, opennsl_mac_t mac, opennsl_vlan_t vlan) LIB_DLL_EXPORTED
 Add a destination L2 address to trigger tunnel processing.
 

Detailed Description

Macro Definition Documentation

#define OPENNSL_L2_CACHE_BPDU   0x00000010

Packet is BPDU.

Definition at line 83 of file l2.h.

#define OPENNSL_L2_CACHE_CPU   0x00000001

Packet is copied to CPU.

Definition at line 81 of file l2.h.

#define OPENNSL_L2_CACHE_DISCARD   0x00000002

Packet is not switched.

Definition at line 82 of file l2.h.

#define OPENNSL_L2_CALLBACK_ADD   1

Definition at line 43 of file l2.h.

#define OPENNSL_L2_CALLBACK_AGE_EVENT   4

Definition at line 46 of file l2.h.

#define OPENNSL_L2_CALLBACK_DELETE   0

Definition at line 42 of file l2.h.

#define OPENNSL_L2_CALLBACK_LEARN_EVENT   3

Definition at line 45 of file l2.h.

#define OPENNSL_L2_CALLBACK_MOVE_EVENT   5

Definition at line 47 of file l2.h.

#define OPENNSL_L2_CALLBACK_REPORT   2

Definition at line 44 of file l2.h.

#define OPENNSL_L2_COPY_TO_CPU   0x00000008

Definition at line 31 of file l2.h.

#define OPENNSL_L2_DELETE_NO_CALLBACKS   0x00000004

Definition at line 156 of file l2.h.

#define OPENNSL_L2_DELETE_PENDING   0x00000002

Definition at line 155 of file l2.h.

#define OPENNSL_L2_DELETE_STATIC   0x00000001

Definition at line 154 of file l2.h.

#define OPENNSL_L2_DES_HIT   0x00000800

Definition at line 38 of file l2.h.

#define OPENNSL_L2_DISCARD_DST   0x00000004

Definition at line 30 of file l2.h.

Referenced by example_l2_firewall_block_station().

#define OPENNSL_L2_DISCARD_SRC   0x00000002

Definition at line 29 of file l2.h.

Referenced by example_l2_firewall_block_station().

#define OPENNSL_L2_HIT   0x00000040

Definition at line 34 of file l2.h.

#define OPENNSL_L2_L3LOOKUP   0x00000010

Definition at line 32 of file l2.h.

Referenced by example_l2_addr_add().

#define OPENNSL_L2_LEARN_LIMIT_SYSTEM   0x00000001

Limit is system wide.

Definition at line 21 of file l2X.h.

#define OPENNSL_L2_LOCAL_CPU   0x00200000

Entry is for the local CPU on the device.

Definition at line 40 of file l2.h.

#define OPENNSL_L2_MCAST   0x00000100

Definition at line 36 of file l2.h.

Referenced by example_l2_entry_add(), example_setup_mac_forwarding(), and example_vxlan().

#define OPENNSL_L2_MOVE_PORT   0x00100000

Definition at line 39 of file l2.h.

#define OPENNSL_L2_REPLACE_DELETE   0x00000100

L2 replace will perform delete operation instead of replace on matching entries.

Definition at line 824 of file l2.h.

#define OPENNSL_L2_REPLACE_MATCH_DEST   0x00000008

Replace all L2 entries matching given modid port/tgid.

Definition at line 821 of file l2.h.

#define OPENNSL_L2_REPLACE_MATCH_MAC   0x00000002

Replace all L2 entries matching given MAC address.

Definition at line 817 of file l2.h.

#define OPENNSL_L2_REPLACE_MATCH_STATIC   0x00000001

Replace L2 static entries.

Definition at line 816 of file l2.h.

#define OPENNSL_L2_REPLACE_MATCH_VLAN   0x00000004

Replace all L2 entries matching given VLAN id.

Definition at line 819 of file l2.h.

#define OPENNSL_L2_REPLACE_NO_CALLBACKS   0x00000800

Replace L2 entries without callbacks.

Definition at line 828 of file l2.h.

#define OPENNSL_L2_SRC_HIT   0x00000400

Definition at line 37 of file l2.h.

#define OPENNSL_L2_STATIC   0x00000020
#define OPENNSL_L2_STATION_ARP_RARP   (1 << 4)

Subject packets matching this entry to ARP/RARP processing.

Definition at line 898 of file l2.h.

#define OPENNSL_L2_STATION_IPV4   (1 << 2)

Subject packets matching this entry to L3 processing.

Definition at line 894 of file l2.h.

#define OPENNSL_L2_STATION_IPV6   (1 << 3)

Subject packets matching this entry to L3 processing.

Definition at line 896 of file l2.h.

#define OPENNSL_L2_STATION_WITH_ID   (1 << 0)

Use the specified Station ID.

Definition at line 893 of file l2.h.

#define OPENNSL_L2_TRUNK_MEMBER   0x00000080

Definition at line 35 of file l2.h.

Typedef Documentation

typedef void(* opennsl_l2_addr_callback_t)(int unit, opennsl_l2_addr_t *l2addr, int operation, void *userdata)

Callback function used for receiving notification about insertions into and deletions from the L2 table dynamically as they occur.

Valid operations are: delete, add, and report. A report with l2addr=NULL indicates a scan completion of the L2 table.

Definition at line 482 of file l2.h.

Device-independent L2 address structure.

Device-independent L2 cache address structure.

L2 learn limit structure.

L2 Station address info.

typedef int(* opennsl_l2_traverse_cb)(int unit, opennsl_l2_addr_t *info, void *user_data)

Definition at line 787 of file l2.h.

Function Documentation

int opennsl_l2_addr_add ( int  unit,
opennsl_l2_addr_t l2addr 
)

Add an L2 address entry to the specified device.

Description
Add a MAC address to the switch Address Resolution Logic (ARL) port with the given VLAN ID and parameters. Use CMIC_PORT for the port value to associate the entry with the CPU. Use flag of OPENNSL_L2_COPY_TO_CPU to send a copy to the CPU. Use flag of OPENNSL_L2_TRUNK_MEMBER to set trunking (TGID must be passed as well with a valid trunk group ID).
Parameters
unit[IN] Unit number.
l2addr[IN] L2 address which is properly initialized
Return values
OPENNSL_E_XXX

Referenced by add_to_l2_table(), example_create_policy(), example_l2_addr_add(), example_l2_entry_add(), example_l2_firewall_block_station(), example_setup_mac_forwarding(), and example_vxlan().

int opennsl_l2_addr_delete ( int  unit,
opennsl_mac_t  mac,
opennsl_vlan_t  vid 
)

Delete an L2 address entry from the specified device.

Description
Delete the given MAC address with the specified VLAN ID from the device. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines.
Parameters
unit[IN] Unit number.
mac[IN] 802.3 MAC address
vid[IN] VLAN ID
Return values
OPENNSL_E_XXX

Referenced by example_l2_firewall_allow_station().

int opennsl_l2_addr_delete_by_mac ( int  unit,
opennsl_mac_t  mac,
uint32  flags 
)

Delete L2 entries associated with a MAC address.

Description
Delete L2 entries associated with a MAC address. Static entries are removed only if OPENNSL_L2_DELETE_STATIC flag is used and L2 aging and learning are disabled during this operation. On switch family III devices which support an L2 pending cache (see =opennsl_port_learn_set), pending entries can be removed if the OPENNSL_L2_DELETE_PENDING flags is used. For quick deletions and optimum performance OPENNSL_L2_DELETE_NO_CALLBACKS should be used. By setting this flag, no registered callbacks will be called during L2 entry deletions. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines and use this API without OPENNSL_L2_DELETE_NO_CALLBACKS.
Parameters
unit[IN] Unit number.
mac[IN] MAC address
flags[IN] OPENNSL_L2_DELETE_STATIC for removing static entries ; OPENNSL_L2_DELETE_PENDING for removing pending entries ; OPENNSL_L2_DELETE_NO_CALLBACKS for removing entries faster without registered callbacks being called
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_delete_by_mac_port ( int  unit,
opennsl_mac_t  mac,
opennsl_module_t  mod,
opennsl_port_t  port,
uint32  flags 
)

Delete L2 entries associated with a MAC address and a destination module/port.

Description
Delete L2 entries associated with a MAC address and a destination module/port. Static entries are removed only if OPENNSL_L2_DELETE_STATIC flag is used and L2 aging and learning are disabled during this operation. On switch family III devices which support an L2 pending cache (see =opennsl_port_learn_set), pending entries can be removed if the OPENNSL_L2_DELETE_PENDING flags is used. For quick deletions and optimum performance OPENNSL_L2_DELETE_NO_CALLBACKS should be used. By setting this flag, no registered callbacks will be called during L2 entry deletions. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines and use this API without OPENNSL_L2_DELETE_NO_CALLBACKS.
Parameters
unit[IN] Unit number.
mac[IN] MAC address
mod[IN] Module ID
port[IN] Device or logical port number
flags[IN] OPENNSL_L2_DELETE_STATIC for removing static entries ; OPENNSL_L2_DELETE_PENDING for removing pending entries ; OPENNSL_L2_DELETE_NO_CALLBACKS for removing entries faster without registered callbacks being called
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_delete_by_port ( int  unit,
opennsl_module_t  mod,
opennsl_port_t  port,
uint32  flags 
)

Delete L2 entries associated with a destination module/port.

Description
Delete L2 addresses associated with a destination module/port. Static entries are removed only if OPENNSL_L2_DELETE_STATIC flag is used and L2 aging and learning are disabled during this operation. For switch family II and switch family I chips, mcast L2 entries associated with the destination module/port are removed if OPENNSL_L2_DELETE_STATIC flag is used. On the other hand, for switch family III chips, mcast L2 entries associated with the destination module/port are not removed if OPENNSL_L2_DELETE_STATIC flag is used. On switch family III devices which support an L2 pending cache (see =opennsl_port_learn_set), pending entries can be removed if the OPENNSL_L2_DELETE_PENDING flags is used. For quick deletions and optimum performance OPENNSL_L2_DELETE_NO_CALLBACKS should be used. By setting this flag, no registered callbacks will be called during L2 entry deletions. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines and use this API without OPENNSL_L2_DELETE_NO_CALLBACKS. The port parameter can also be an MPLS, MiM or WLAN Gport ID.
Parameters
unit[IN] Unit number.
mod[IN] Module ID (or -1 for local unit)
port[IN] Device or logical port number
flags[IN] OPENNSL_L2_DELETE_STATIC for removing static entries ; OPENNSL_L2_DELETE_PENDING for removing pending entries ; OPENNSL_L2_DELETE_NO_CALLBACKS for removing entries faster without registered callbacks being called
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_delete_by_trunk ( int  unit,
opennsl_trunk_t  tid,
uint32  flags 
)

Delete L2 entries associated with a trunk.

Description
Delete L2 entries associated with a trunk ID. Static entries are removed only if OPENNSL_L2_DELETE_STATIC flag is used and L2 aging and learning are disabled during this operation. For switch family II and switch family I chips, mcast L2 entries associated with a trunk ID are removed if OPENNSL_L2_DELETE_STATIC flag is used. Conversely, for switch family III chips, mcast L2 entries associated with a trunk ID are not removed if OPENNSL_L2_DELETE_STATIC flag is used. On switch family III devices which support an L2 pending cache (see =opennsl_port_learn_set), pending entries can be removed if the OPENNSL_L2_DELETE_PENDING flags is used. For quick deletions and optimum performance OPENNSL_L2_DELETE_NO_CALLBACKS should be used. By setting this flag, no registered callbacks will be called during L2 entry deletions. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines and use this API without OPENNSL_L2_DELETE_NO_CALLBACKS.
Parameters
unit[IN] Unit number.
tid[IN] Trunk ID
flags[IN] OPENNSL_L2_DELETE_STATIC for removing static entries ; OPENNSL_L2_DELETE_PENDING for removing pending entries ; OPENNSL_L2_DELETE_NO_CALLBACKS for removing entries faster without registered callbacks being called
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_delete_by_vlan ( int  unit,
opennsl_vlan_t  vid,
uint32  flags 
)

Delete L2 entries associated with a VLAN.

Description
Delete L2 entries associated with a VLAN ID. Static entries are removed only if OPENNSL_L2_DELETE_STATIC flag is used and L2 aging and learning are disabled during this operation. For switch family II and switch family I chips, mcast L2 entries associated with a VLAN ID are removed if OPENNSL_L2_DELETE_STATIC flag is used. Conversely, for switch family III chips, mcast L2 entries associated with a VLAN ID are not removed if OPENNSL_L2_DELETE_STATIC flag is used. On switch family III devices which support an L2 pending cache (see =opennsl_port_learn_set), pending entries can be removed if the OPENNSL_L2_DELETE_PENDING flags is used. For quick deletions and optimum performance OPENNSL_L2_DELETE_NO_CALLBACKS should be used. By setting this flag, no registered callbacks will be called during L2 entry deletions. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines and use this API without OPENNSL_L2_DELETE_NO_CALLBACKS.
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
flags[IN] OPENNSL_L2_DELETE_STATIC for removing static entries ; OPENNSL_L2_DELETE_PENDING for removing pending entries ; OPENNSL_L2_DELETE_NO_CALLBACKS for removing entries faster without registered callbacks being called
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_delete_by_vlan_port ( int  unit,
opennsl_vlan_t  vid,
opennsl_module_t  mod,
opennsl_port_t  port,
uint32  flags 
)

Delete L2 entries associated with a VLAN and a destination module/port.

Description
Delete L2 entries associated with a VLAN ID and a destination module/port. Static entries are removed only if OPENNSL_L2_DELETE_STATIC flag is used and L2 aging and learning are disabled during this operation. For switch family II and switch family I chips, mcast L2 entries associated with a VLAN ID and a destination module/port are removed if OPENNSL_L2_DELETE_STATIC flag is used. Conversely, for switch family III chips, mcast L2 entries associated with a VLAN ID and a destination module/port are not removed if OPENNSL_L2_DELETE_STATIC flag is used. On switch family III devices which support an L2 pending cache (see =opennsl_port_learn_set), pending entries can be removed if the OPENNSL_L2_DELETE_PENDING flags is used. For quick deletions and optimum performance OPENNSL_L2_DELETE_NO_CALLBACKS should be used. By setting this flag, no registered callbacks will be called during L2 entry deletions. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines and use this API without OPENNSL_L2_DELETE_NO_CALLBACKS.
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
mod[IN] Module ID
port[IN] Device or logical port number
flags[IN] OPENNSL_L2_DELETE_STATIC for removing static entries ; OPENNSL_L2_DELETE_PENDING for removing pending entries ; OPENNSL_L2_DELETE_NO_CALLBACKS for removing entries faster without registered callbacks being called
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_delete_by_vlan_trunk ( int  unit,
opennsl_vlan_t  vid,
opennsl_trunk_t  tid,
uint32  flags 
)

Delete L2 entries associated with a VLAN and a destination module/port.

Description
Delete L2 entries associated with a VLAN ID and a destination trunk. Static entries are removed only if OPENNSL_L2_DELETE_STATIC flag is used and L2 aging and learning are disabled during this operation. For switch family II and switch family I chips, mcast L2 entries associated with a VLAN ID and a destination trunk are removed if OPENNSL_L2_DELETE_STATIC flag is used. Conversely, for switch family III chips, mcast L2 entries associated with a VLAN ID and a destination trunk are not removed if OPENNSL_L2_DELETE_STATIC flag is used. On switch family III devices which support an L2 pending cache (see =opennsl_port_learn_set), pending entries can be removed if the OPENNSL_L2_DELETE_PENDING flags is used. For quick deletions and optimum performance OPENNSL_L2_DELETE_NO_CALLBACKS should be used. By setting this flag, no registered callbacks will be called during L2 entry deletions. If users want to know which entries are deleted, they should register callback routines by API opennsl_l2_addr_register(). If L2_MOD_FIFO is used, but the thread opennslL2MOD.x is stopped, users can not know which entries are deleted, even though they already had registered callback routines and use this API without OPENNSL_L2_DELETE_NO_CALLBACKS.
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
tid[IN] Trunk ID
flags[IN] OPENNSL_L2_DELETE_STATIC for removing static entries ; OPENNSL_L2_DELETE_PENDING for removing pending entries ; OPENNSL_L2_DELETE_NO_CALLBACKS for removing entries faster without registered callbacks being called
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_freeze ( int  unit)

Temporarily stop/restore L2 table from changing.

Description
Use opennsl_l2_addr_freeze() to temporarily stop the L2 table from being modified by any activity including learning, aging, or software modifications by another task. When opennsl_l2_addr_freeze is called, api opennsl_l2_age_timer_set just save age_seconds to cache, and it does not affect l2 aging. During opennsl_l2_addr_thaw, SDK will update age_seconds from cache to destination, and it will affect l2 aging. Use opennsl_l2_addr_thaw() to restore normal L2 table activity. Use opennsl_switch_control_set with parameter opennslSwitchHWL2Freeze to temporarily stop the L2 table from being modified by H/W activity, but not prohibit software modifications. Also can use opennsl_switch_control_set with opennslSwitchHWL2Freeze to restore normal L2 table H/W activity. opennsl_l2_addr_freeze() must match with opennsl_l2_addr_thaw().
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_get ( int  unit,
opennsl_mac_t  mac_addr,
opennsl_vlan_t  vid,
opennsl_l2_addr_t l2addr 
)

Check if an L2 entry is present in the L2 table.

Description
Given a MAC address and VLAN ID, check if the entry is present in the L2 table, and if so, return all associated information.
Parameters
unit[IN] Unit number.
mac_addr[IN] Input MAC address to search
vid[IN] Input VLAN ID to search
l2addr[OUT] Pointer to L2 address structure to receive results
Return values
OPENNSL_E_XXX

Referenced by example_l2_firewall_allow_station().

int opennsl_l2_addr_register ( int  unit,
opennsl_l2_addr_callback_t  callback,
void *  userdata 
)

Register/Unregister a callback routine for OPENNSL L2 subsystem.

Description
Register/Unregister a callback routine that will be called whenever an entry is added into or deleted from the L2 address table. Both callback and userdata must match for register and unregister calls. If there is l2xmsg_mode=1 in file config.opennsl, the thread opennslL2MOD.x may be triggered/stopped when register/unregister a callback routine.
Parameters
unit[IN] Unit number.
callback[IN] Callback function of type opennsl_l2_addr_callback_t
userdata[IN] Arbitrary value passed to callback along with messages
Return values
OPENNSL_E_XXX
void opennsl_l2_addr_t_init ( opennsl_l2_addr_t l2addr,
const opennsl_mac_t  mac_addr,
opennsl_vlan_t  vid 
)

Initialize an L2 address structure to a specified MAC address and VLAN ID.

Description
Setup L2 address structure with given MAC address and VLAN ID with all other fields zeroing out. After this call is made, the flags field can be modified with the fields defined by opennsl_l2_addr_add().
Parameters
l2addr[IN,OUT] Pointer to layer 2 address type
mac_addr[IN,OUT]
vid[IN] VLAN ID
Return values
None.

Referenced by add_to_l2_table(), example_create_policy(), example_l2_addr_add(), example_l2_entry_add(), example_l2_firewall_block_station(), example_setup_mac_forwarding(), and example_vxlan().

int opennsl_l2_addr_thaw ( int  unit)

Temporarily stop/restore L2 table from changing.

Description
Use opennsl_l2_addr_freeze() to temporarily stop the L2 table from being modified by any activity including learning, aging, or software modifications by another task. When opennsl_l2_addr_freeze is called, api opennsl_l2_age_timer_set just save age_seconds to cache, and it does not affect l2 aging. During opennsl_l2_addr_thaw, SDK will update age_seconds from cache to destination, and it will affect l2 aging. Use opennsl_l2_addr_thaw() to restore normal L2 table activity. Use opennsl_switch_control_set with parameter opennslSwitchHWL2Freeze to temporarily stop the L2 table from being modified by H/W activity, but not prohibit software modifications. Also can use opennsl_switch_control_set with opennslSwitchHWL2Freeze to restore normal L2 table H/W activity. opennsl_l2_addr_freeze() must match with opennsl_l2_addr_thaw().
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_XXX
int opennsl_l2_addr_unregister ( int  unit,
opennsl_l2_addr_callback_t  callback,
void *  userdata 
)

Register/Unregister a callback routine for OPENNSL L2 subsystem.

Description
Register/Unregister a callback routine that will be called whenever an entry is added into or deleted from the L2 address table. Both callback and userdata must match for register and unregister calls. If there is l2xmsg_mode=1 in file config.opennsl, the thread opennslL2MOD.x may be triggered/stopped when register/unregister a callback routine.
Parameters
unit[IN] Unit number.
callback[IN] Callback function of type opennsl_l2_addr_callback_t
userdata[IN] Arbitrary value passed to callback along with messages
Return values
OPENNSL_E_XXX
int opennsl_l2_age_timer_get ( int  unit,
int *  age_seconds 
)

Set/Get the age timer.

Description
Set/Get the age timer of the specified switch unit. Setting the age_seconds value to 0 disables the age timer. If age_seconds is other than 0 Every specified interval aging task will iterate over L2 table entries and do the following: If the entry is active (one of the hit bit is set) it will mark the entry as inactive (clear the hit bit) otherwise it will remove the entry from the table. Thus if entry with one of the hit bits set added to L2 table and aging interval set to X seconds then the entry should be expected to completely disappear from L2 table after 2X seconds if not hit during this period. When l2 table is frozoen by api opennsl_l2_addr_freeze() or opennsl_switch_control_set(with parameter opennslSwitchHWL2Freeze), this api cannot take effect until l2 table is unfrozen by api opennsl_l2_addr_thaw() or opennsl_switch_control_set (with opennslSwitchHWL2Freeze). .
Parameters
unit[IN] Unit number.
age_seconds[OUT] Age timer value in seconds (0 to disable)
Return values
OPENNSL_E_XXX

Referenced by main().

int opennsl_l2_age_timer_set ( int  unit,
int  age_seconds 
)

Set/Get the age timer.

Description
Set/Get the age timer of the specified switch unit. Setting the age_seconds value to 0 disables the age timer. If age_seconds is other than 0 Every specified interval aging task will iterate over L2 table entries and do the following: If the entry is active (one of the hit bit is set) it will mark the entry as inactive (clear the hit bit) otherwise it will remove the entry from the table. Thus if entry with one of the hit bits set added to L2 table and aging interval set to X seconds then the entry should be expected to completely disappear from L2 table after 2X seconds if not hit during this period. When l2 table is frozoen by api opennsl_l2_addr_freeze() or opennsl_switch_control_set(with parameter opennslSwitchHWL2Freeze), this api cannot take effect until l2 table is unfrozen by api opennsl_l2_addr_thaw() or opennsl_switch_control_set (with opennslSwitchHWL2Freeze). .
Parameters
unit[IN] Unit number.
age_seconds[IN] Age timer value in seconds (0 to disable)
Return values
OPENNSL_E_XXX

Referenced by main().

void opennsl_l2_cache_addr_t_init ( opennsl_l2_cache_addr_t addr)

Initialize an L2 cache address structure.

Description
Initialize an L2 cache address structure. All masks in the structure are cleared.
Parameters
addr[IN,OUT] L2 cache address to initialize
Return values
Nothing.
int opennsl_l2_cache_delete ( int  unit,
int  index 
)

Clear an L2 cache entry.

Description
Clear the L2 cache entry at the specified index.
Parameters
unit[IN] Unit number.
index[IN] L2 cache entry index
Return values
OPENNSL_E_XXX
int opennsl_l2_cache_delete_all ( int  unit)

Clear all L2 cache entries.

Description
Clear all L2 cache entries including the preloaded entries.
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_XXX
int opennsl_l2_cache_get ( int  unit,
int  index,
opennsl_l2_cache_addr_t addr 
)

Get an L2 cache entry.

Description
Get the L2 cache entry at the specified index. For ROBO devices, the OPENNSL_L2_CACHE_BPDU is used to get the BPDU addresses on device.
Parameters
unit[IN] Unit number.
index[IN] L2 cache entry index
addr[OUT] L2 cache address
Return values
OPENNSL_E_XXX
int opennsl_l2_cache_init ( int  unit)

Initialize the L2 cache.

Description
Clear all entries and preload a few entries to match previous generation of devices. The preloaded entries are shown in the table below.
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_XXX
int opennsl_l2_cache_set ( int  unit,
int  index,
opennsl_l2_cache_addr_t addr,
int *  index_used 
)

Set an L2 cache entry.

Description
Insert an L2 cache entry at the specified index. If -1 is given then the entry used will be the first available entry if the l2 cache address mac_mask field is all ones or the last available entry if the mac_mask field has some zeros. Cache entries are matched from lowest entry to highest entry. For ROBO devices, the OPENNSL_L2_CACHE_BPDU is used to set the BPDU addresses on device and the zero BPDU address is used for the special process to indicate a BPDU address delete process. For network switch, OPENNSL_L2_CACHE_SETPRI and OPENNSL_L2_CACHE_BPDU cannot be used together while OPENNSL_L2_CACHE_CPU and OPENNSL_L2_CACHE_DISCARD are not set. Instead, a FP entry can be used to set PRI field for BPDU packet. Take note of the preloaded entries as defined in.
Parameters
unit[IN] Unit number.
index[IN] L2 cache entry number (or -1)
addr[IN] L2 cache address
index_used[OUT] l2 cache entry number actually used
Return values
OPENNSL_E_XXX
int opennsl_l2_cache_size_get ( int  unit,
int *  size 
)

Get number of L2 cache entries.

Description
Get number of L2 cache entries.
Parameters
unit[IN] Unit number.
size[OUT] Number of entries in cache
Return values
OPENNSL_E_XXX
int opennsl_l2_learn_limit_get ( int  unit,
opennsl_l2_learn_limit_t limit 
)

Set/Get L2 addresses learn limit.

Description
Set/Get L2 learned address limit. Use OPENNSL_L2_LEARN_LIMIT_SYSTEM or combination of OPENNSL_L2_LEARN_LIMIT_VLAN, OPENNSL_L2_LEARN_LIMIT_PORT, and OPENNSL_L2_LEARN_LIMIT_TRUNK in flags of opennsl_l2_learn_limit_t structure to indicate whether the limit is applied to system wide, per-VLAN, per-port, or per-trunk. For devices which do not support per-VLAN learn limits, only the system wide, per-port, and per-trunk can be configured. Use flags to specify the action to be taken if learned L2 address exceeds the specified limit. OPENNSL_L2_LEARN_LIMIT_ACTION_PREFER flag indicates that system wide limit actions should be used when both system wide and a non-system wide limit is exceeded. This flag is not longer supported starting form network switch device To remove a configured learn limit, specify the appropriate flags along with a negative value for the limit field of the opennsl_l2_learn_limit_t structure. For the feature to function properly, following requirements must be fulfilled: When port moves to trunk, all MAC addresses previously learned on that port should be deleted. When port moves out of a trunk and it is last port or trunk is destroyed, all MAC addresses previously learned on that trunk should be deleted. It is recommended that all MAC addresses deletion will be done using the following sequence: a. Setting the limit on the resource to 0, to disable further learning b. Delete all associated MAC addresses by calling opennsl_l2_addr_delete_by_port or opennsl_l2_addr_delete_by_trunk.
Parameters
unit[IN] Unit number.
limit[IN,OUT] (for _set) Pointer to L2 address learn limit info structure
Return values
OPENNSL_E_XXX
int opennsl_l2_learn_limit_set ( int  unit,
opennsl_l2_learn_limit_t limit 
)

Set/Get L2 addresses learn limit.

Description
Set/Get L2 learned address limit. Use OPENNSL_L2_LEARN_LIMIT_SYSTEM or combination of OPENNSL_L2_LEARN_LIMIT_VLAN, OPENNSL_L2_LEARN_LIMIT_PORT, and OPENNSL_L2_LEARN_LIMIT_TRUNK in flags of opennsl_l2_learn_limit_t structure to indicate whether the limit is applied to system wide, per-VLAN, per-port, or per-trunk. For devices which do not support per-VLAN learn limits, only the system wide, per-port, and per-trunk can be configured. Use flags to specify the action to be taken if learned L2 address exceeds the specified limit. OPENNSL_L2_LEARN_LIMIT_ACTION_PREFER flag indicates that system wide limit actions should be used when both system wide and a non-system wide limit is exceeded. This flag is not longer supported starting form network switch device To remove a configured learn limit, specify the appropriate flags along with a negative value for the limit field of the opennsl_l2_learn_limit_t structure. For the feature to function properly, following requirements must be fulfilled: When port moves to trunk, all MAC addresses previously learned on that port should be deleted. When port moves out of a trunk and it is last port or trunk is destroyed, all MAC addresses previously learned on that trunk should be deleted. It is recommended that all MAC addresses deletion will be done using the following sequence: a. Setting the limit on the resource to 0, to disable further learning b. Delete all associated MAC addresses by calling opennsl_l2_addr_delete_by_port or opennsl_l2_addr_delete_by_trunk.
Parameters
unit[IN] Unit number.
limit[IN] (for _set) Pointer to L2 address learn limit info structure
Return values
OPENNSL_E_XXX
void opennsl_l2_learn_limit_t_init ( opennsl_l2_learn_limit_t limit)

Initialize an L2 learn limit structure.

Description
Initialize an L2 learn limit structure opennsl_l2_learn_limit_t zeroing all fields.
Parameters
limit[IN,OUT] Pointer to L2 learn limit structure to initialize
Return values
Nothing
int opennsl_l2_replace ( int  unit,
uint32  flags,
opennsl_l2_addr_t match_addr,
opennsl_module_t  new_module,
opennsl_port_t  new_port,
opennsl_trunk_t  new_trunk 
)

Replace destination (or delete) multiple L2 entries.

Description
Replace destination (or delete) multiple L2 entries. Matching is done by setting fields in the match_addr and setting OPENNSL_L2_REPLACE_* flags to match entries with those fields. If L2_MOD_FIFO is used, and users want to know which l2 entries are replaced, they should not only confirm opennslL2MOD.x thread is running, but also call-back functions have been registered. Normal action for each matching entry is to replace the destination of that entry with a new mod/port specified in new_module and new_port. Using the OPENNSL_L2_REPLACE_NEW_TRUNK flag will replace the destination with the trunk specified in new_trunk. Using the OPENNSL_L2_REPLACE_DELETE flag will delete the matching entries and parameters new_module, new_port and new_trunk will be ignored. Using the OPENNSL_L2_REPLACE_DELETE flag and matching_addr as NULL will delete all addresses from the L2 table and parameters new_module, new_port and new_trunk will be ignored. Using the OPENNSL_L2_REPLACE_DELETE flag and matching_addr as NULL and with flag OPENNSL_L2_REPLACE_MATCH_MC, OPENNSL_L2_REPLACE_MATCH_UC or both to delete all Unicast entries, Multicast entries or both respectively, and parameters new_module, new_port and new_trunk will be ignored. SDK releases supporting opennsl_gport_t can simply set new_port to the new destination gport. Once new destination gport is used, new_module and new_trunk parameters will be ignored and information encoded in gprot will be used. Valid L2 replace flags are described in table =OPENNSL_L2_REPLACE_FLAGS_table .
Parameters
unit[IN] Unit number.
flags[IN] Replace/delete flags OPENNSL_L2_REPLACE_*
match_addr[IN] L2 parameters to match on delete/replace
new_module[IN] New module ID for a replace
new_port[IN] New port for a replace
new_trunk[IN] New trunk ID for a replace
Return values
OPENNSL_E_XXX
int opennsl_l2_station_add ( int  unit,
int *  station_id,
opennsl_l2_station_t station 
)

Add an entry to L2 Station table.

Description
Use this API to create an entry in hardware for lookup based on MAC destination address and VLAN ID. For element-encapsulated packets, ingress port is used as an endpoint during lookup. To create an entry with a desired ID, set the ID value in station_id parameter and set the OPENNSL_L2_STATION_WITH_ID flag bit in flags structure member variable. If OPENNSL_L2_STATION_WITH_ID flag is not set, API internally generates an ID and returns this value in station_id parameter. The packet termination settings for an entry are specified in the flags structure member variable. OPENNSL_L2_STATION_IPV4/IPV6/ARP_RARP/MPLS/MIM/TRILL/FCOE and OPENNSL_L2_STATION_OAM are allowed termination settings. But actual support depends on the device capability. OPENNSL_E_UNAVAIL error will be returned if a device does not support a termination option. The entries in TCAM are ordered based on priority value specified during entry create process. Default priority value is zero after initializing station variable with opennsl_l2_station_t_init() API. Application can specify a value different from the default priority value to manage the order of entries in TCAM. When there are multiple matches for a packet in TCAM, then termination settings from the highest priority rule will take effect. So, application must intelligently manage entries that have same data value but different mask values.
Parameters
unit[IN] Unit number.
station_id[IN,OUT] Station ID
station[IN] Station ID
Return values
OPENNSL_E_XXX

Referenced by example_create_l3_intf(), and example_l3_intf_rif_create().

int opennsl_l2_station_delete ( int  unit,
int  station_id 
)

Delete an entry from L2 Station Table.

Description
Delete an entry from L2 station table with specified Station ID.
Parameters
unit[IN] Unit number.
station_id[IN] L2 station ID
Return values
OPENNSL_E_XXX
int opennsl_l2_station_get ( int  unit,
int  station_id,
opennsl_l2_station_t station 
)

Get L2 station entry details from Station Table.

Description
Get L2 station entry details from Station Table.
Parameters
unit[IN] Unit number.
station_id[IN] L2 station ID
station[OUT] L2 station ID
Return values
OPENNSL_E_XXX
void opennsl_l2_station_t_init ( opennsl_l2_station_t addr)

Initialize L2 Station structure.

Description
All members of the opennsl_l2_station_t structure are cleared and initialized to zero.
Parameters
addr[IN,OUT] Pointer to L2 station structure
Return values
OPENNSL_E_XXX

Referenced by example_create_l3_intf(), and example_l3_intf_rif_create().

int opennsl_l2_traverse ( int  unit,
opennsl_l2_traverse_cb  trav_fn,
void *  user_data 
)

Iterates over all entries in the L2 table and executes user callback function for each entry.

Description
Iterates over all valid entries in the L2 table and executes user provided callback function that defined as following: typedef int (*opennsl_l2_traverse_cb)(int unit, opennsl_l2_addr_t *info, void *user_data); .
Parameters
unit[IN] Unit number.
trav_fn[IN] Call back function provided by API caller
user_data[IN] Pointer to any data provided by API caller
Return values
OPENNSL_E_XXX

Referenced by main().

int opennsl_l2_tunnel_add ( int  unit,
opennsl_mac_t  mac,
opennsl_vlan_t  vlan 
)

Add a destination L2 address to trigger tunnel processing.

Description
Add a destination L2 address (MAC, VLAN) to initiate tunnel/MPLS processing. Frames received with this destination L2 address will be checked for tunnel and MPLS processing.
Parameters
unit[IN] Unit number.
mac[IN] MAC address
vlan[IN] VLAN ID
Return values
OPENNSL_E_XXX