OpenNSL API Guide and Reference Manual
Data Structures | Files | Macros | Typedefs | Enumerations | Functions
Virtual LAN Management

Data Structures

struct  opennsl_vlan_control_vlan_s
 This structure contains the configuration of a VLAN. More...
 
struct  opennsl_vlan_data_s
 Initialize a VLAN data information structure. More...
 
struct  opennsl_vlan_port_s
 Layer 2 Logical port type. More...
 
struct  opennsl_vlan_protocol_packet_ctrl_s
 Per VLAN Protocol Packet control. More...
 

Files

file  vlan.h
 
file  vlanX.h
 

Macros

#define OPENNSL_VLAN_LEARN_DISABLE   0x00000001
 
#define OPENNSL_VLAN_PORT_INNER_VLAN_PRESERVE   0x00000004
 Preserve the inner VLAN tag (by default it is stripped).
 
#define OPENNSL_VLAN_PORT_OUTER_VLAN_PRESERVE   0x00000100
 Preserve the outer VLAN tag (by default it is stripped).
 
#define OPENNSL_VLAN_PORT_REPLACE   0x00000001
 Replace existing entry.
 
#define OPENNSL_VLAN_PORT_WITH_ID   0x00000002
 Add using the specified ID.
 
#define OPENNSL_VLAN_PROTO_PKT_DROP_ENABLE   0x00000004
 
#define OPENNSL_VLAN_PROTO_PKT_FLOOD_ENABLE   0x00000008
 
#define OPENNSL_VLAN_PROTO_PKT_FORWARD_ENABLE   0x00000002
 
#define OPENNSL_VLAN_PROTO_PKT_TOCPU_ENABLE   0x00000001
 

Typedefs

typedef enum
opennsl_vlan_control_port_e 
opennsl_vlan_control_port_t
 opennsl_vlan_control_port_t
 
typedef enum opennsl_vlan_control_e opennsl_vlan_control_t
 opennsl_vlan_control_t
 
typedef struct
opennsl_vlan_control_vlan_s 
opennsl_vlan_control_vlan_t
 This structure contains the configuration of a VLAN.
 
typedef struct opennsl_vlan_data_s opennsl_vlan_data_t
 Initialize a VLAN data information structure.
 
typedef enum opennsl_vlan_forward_e opennsl_vlan_forward_t
 Per VLAN forwarding behavior.
 
typedef enum
opennsl_vlan_mcast_flood_e 
opennsl_vlan_mcast_flood_t
 VLAN multicast flood modes.
 
typedef enum
opennsl_vlan_port_match_e 
opennsl_vlan_port_match_t
 Logical layer 2 port match criteria.
 
typedef struct opennsl_vlan_port_s opennsl_vlan_port_t
 Layer 2 Logical port type.
 
typedef struct
opennsl_vlan_protocol_packet_ctrl_s 
opennsl_vlan_protocol_packet_ctrl_t
 Per VLAN Protocol Packet control.
 
typedef enum opennsl_vlan_stat_e opennsl_vlan_stat_t
 Types of statistics that are maintained per VLAN.
 
typedef enum
opennsl_vlan_urpf_mode_e 
opennsl_vlan_urpf_mode_t
 Per VLAN URPF Mode setting.
 
typedef enum
opennsl_vlan_vp_mc_ctrl_e 
opennsl_vlan_vp_mc_ctrl_t
 Per VLAN VP Mode control.
 

Enumerations

enum  opennsl_vlan_control_e {
  opennslVlanDropUnknown = 0,
  opennslVlanShared = 3,
  opennslVlanSharedID = 4,
  opennslVlanTranslate = 5,
  opennslVlanIgnorePktTag = 6,
  opennslVlanMemberMismatchToCpu = 21
}
 opennsl_vlan_control_t More...
 
enum  opennsl_vlan_control_port_e {
  opennslVlanTranslateIngressEnable = 2,
  opennslVlanTranslateIngressMissDrop = 4,
  opennslVlanTranslateEgressEnable = 5,
  opennslVlanTranslateEgressMissDrop = 6
}
 opennsl_vlan_control_port_t More...
 
enum  opennsl_vlan_forward_e {
  opennslVlanForwardBridging = 0,
  opennslVlanForwardSingleCrossConnect = 1,
  opennslVlanForwardDoubleCrossConnect = 2
}
 Per VLAN forwarding behavior. More...
 
enum  opennsl_vlan_mcast_flood_e {
  OPENNSL_VLAN_MCAST_FLOOD_ALL = _SHR_PORT_MCAST_FLOOD_ALL,
  OPENNSL_VLAN_MCAST_FLOOD_UNKNOWN = _SHR_PORT_MCAST_FLOOD_UNKNOWN,
  OPENNSL_VLAN_MCAST_FLOOD_NONE = _SHR_PORT_MCAST_FLOOD_NONE,
  OPENNSL_VLAN_MCAST_FLOOD_COUNT = _SHR_PORT_MCAST_FLOOD_COUNT
}
 VLAN multicast flood modes. More...
 
enum  opennsl_vlan_port_match_e {
  OPENNSL_VLAN_PORT_MATCH_INVALID = 0,
  OPENNSL_VLAN_PORT_MATCH_NONE = 1,
  OPENNSL_VLAN_PORT_MATCH_PORT = 2,
  OPENNSL_VLAN_PORT_MATCH_PORT_VLAN = 3
}
 Logical layer 2 port match criteria. More...
 
enum  opennsl_vlan_stat_e {
  opennslVlanStatPackets = 0,
  opennslVlanStatIngressPackets = opennslVlanStatPackets,
  opennslVlanStatBytes = 1,
  opennslVlanStatIngressBytes = opennslVlanStatBytes,
  opennslVlanStatEgressPackets = 2,
  opennslVlanStatEgressBytes = 3,
  opennslVlanStatForwardedPackets = 4,
  opennslVlanStatForwardedBytes = 5,
  opennslVlanStatDropPackets = 6,
  opennslVlanStatDropBytes = 7,
  opennslVlanStatUnicastPackets = 8,
  opennslVlanStatUnicastBytes = 9,
  opennslVlanStatUnicastDropPackets = 10,
  opennslVlanStatUnicastDropBytes = 11,
  opennslVlanStatNonUnicastPackets = 12,
  opennslVlanStatNonUnicastBytes = 13,
  opennslVlanStatNonUnicastDropPackets = 14,
  opennslVlanStatNonUnicastDropBytes = 15,
  opennslVlanStatL3Packets = 16,
  opennslVlanStatL3Bytes = 17,
  opennslVlanStatL3DropPackets = 18,
  opennslVlanStatL3DropBytes = 19,
  opennslVlanStatFloodPackets = 20,
  opennslVlanStatFloodBytes = 21,
  opennslVlanStatFloodDropPackets = 22,
  opennslVlanStatFloodDropBytes = 23,
  opennslVlanStatGreenPackets = 24,
  opennslVlanStatGreenBytes = 25,
  opennslVlanStatYellowPackets = 26,
  opennslVlanStatYellowBytes = 27,
  opennslVlanStatRedPackets = 28,
  opennslVlanStatRedBytes = 29,
  opennslVlanStatCount = 30
}
 Types of statistics that are maintained per VLAN. More...
 
enum  opennsl_vlan_urpf_mode_e {
  opennslVlanUrpfDisable = 0,
  opennslVlanUrpfLoose = 1,
  opennslVlanUrpfStrict = 2
}
 Per VLAN URPF Mode setting. More...
 
enum  opennsl_vlan_vp_mc_ctrl_e {
  opennslVlanVPMcControlAuto = 0,
  opennslVlanVPMcControlEnable = 1,
  opennslVlanVPMcControlDisable = 2
}
 Per VLAN VP Mode control. More...
 

Functions

void opennsl_vlan_action_set_t_init (opennsl_vlan_action_set_t *action) LIB_DLL_EXPORTED
 Initialize a VLAN tag action set structure.
 
int opennsl_vlan_control_port_set (int unit, int port, opennsl_vlan_control_port_t type, int arg) LIB_DLL_EXPORTED
 Set/get miscellaneous port-specific VLAN options.
 
int opennsl_vlan_control_set (int unit, opennsl_vlan_control_t type, int arg) LIB_DLL_EXPORTED
 Set/get miscellaneous VLAN-specific chip options.
 
int opennsl_vlan_control_vlan_get (int unit, opennsl_vlan_t vlan, opennsl_vlan_control_vlan_t *control) LIB_DLL_EXPORTED
 Set or retrieve current VLAN properties.
 
int opennsl_vlan_control_vlan_set (int unit, opennsl_vlan_t vlan, opennsl_vlan_control_vlan_t control) LIB_DLL_EXPORTED
 Set or retrieve current VLAN properties.
 
void opennsl_vlan_control_vlan_t_init (opennsl_vlan_control_vlan_t *data) LIB_DLL_EXPORTED
 Initialize the opennsl_vlan_control_vlan_t structure.
 
int opennsl_vlan_create (int unit, opennsl_vlan_t vid) LIB_DLL_EXPORTED
 Allocate and configure a VLAN on the OPENNSL device.
 
int opennsl_vlan_default_get (int unit, opennsl_vlan_t *vid_ptr) LIB_DLL_EXPORTED
 Get the default VLAN ID.
 
int opennsl_vlan_default_set (int unit, opennsl_vlan_t vid) LIB_DLL_EXPORTED
 Set the default VLAN ID.
 
int opennsl_vlan_destroy (int unit, opennsl_vlan_t vid) LIB_DLL_EXPORTED
 Deallocate VLAN from the OPENNSL device.
 
int opennsl_vlan_destroy_all (int unit) LIB_DLL_EXPORTED
 Destroy all VLANs except the default VLAN.
 
int opennsl_vlan_gport_add (int unit, opennsl_vlan_t vlan, opennsl_gport_t port, int flags) LIB_DLL_EXPORTED
 Add a virtual or physical port to the specified VLAN.
 
int opennsl_vlan_gport_delete (int unit, opennsl_vlan_t vlan, opennsl_gport_t port) LIB_DLL_EXPORTED
 Remove a virtual or physical port from the specified VLAN.
 
int opennsl_vlan_gport_delete_all (int unit, opennsl_vlan_t vlan) LIB_DLL_EXPORTED
 Removes all virtual and physical port from the specified VLAN.
 
int opennsl_vlan_gport_get (int unit, opennsl_vlan_t vlan, opennsl_gport_t port, int *flags) LIB_DLL_EXPORTED
 Get a virtual or physical port from the specified VLAN.
 
int opennsl_vlan_list (int unit, opennsl_vlan_data_t **listp, int *countp) LIB_DLL_EXPORTED
 Returns an array of defined VLANs and their port bitmaps.
 
int opennsl_vlan_list_destroy (int unit, opennsl_vlan_data_t *list, int count) LIB_DLL_EXPORTED
 Destroy a list returned by opennsl_vlan_list.
 
int opennsl_vlan_port_add (int unit, opennsl_vlan_t vid, opennsl_pbmp_t pbmp, opennsl_pbmp_t ubmp) LIB_DLL_EXPORTED
 Add ports to the specified VLAN.
 
int opennsl_vlan_port_create (int unit, opennsl_vlan_port_t *vlan_port) LIB_DLL_EXPORTED
 Create a layer 2 logical port.
 
int opennsl_vlan_port_destroy (int unit, opennsl_gport_t gport) LIB_DLL_EXPORTED
 Destroy a layer 2 logical port.
 
int opennsl_vlan_port_find (int unit, opennsl_vlan_port_t *vlan_port) LIB_DLL_EXPORTED
 Get/find a layer 2 logical port given the GPORT ID or match criteria.
 
int opennsl_vlan_port_get (int unit, opennsl_vlan_t vid, opennsl_pbmp_t *pbmp, opennsl_pbmp_t *ubmp) LIB_DLL_EXPORTED
 Retrieves a list of the member ports of an existing VLAN.
 
int opennsl_vlan_port_remove (int unit, opennsl_vlan_t vid, opennsl_pbmp_t pbmp) LIB_DLL_EXPORTED
 Remove ports from a specified VLAN.
 
void opennsl_vlan_port_t_init (opennsl_vlan_port_t *vlan_port) LIB_DLL_EXPORTED
 Initialize the VLAN port structure.
 
int opennsl_vlan_stat_get (int unit, opennsl_vlan_t vlan, opennsl_cos_t cos, opennsl_vlan_stat_t stat, uint64 *val) LIB_DLL_EXPORTED
 Extract per-VLAN statistics from the chip.
 
int opennsl_vlan_stat_set (int unit, opennsl_vlan_t vlan, opennsl_cos_t cos, opennsl_vlan_stat_t stat, uint64 val) LIB_DLL_EXPORTED
 Set the specified statistic to the indicated value for the specified VLAN.
 
int opennsl_vlan_translate_egress_action_add (int unit, int port_class, opennsl_vlan_t outer_vlan, opennsl_vlan_t inner_vlan, opennsl_vlan_action_set_t *action) LIB_DLL_EXPORTED
 Add an entry to the egress VLAN Translation table and assign VLAN actions.
 
int opennsl_vlan_translate_egress_action_get (int unit, int port_class, opennsl_vlan_t outer_vlan, opennsl_vlan_t inner_vlan, opennsl_vlan_action_set_t *action) LIB_DLL_EXPORTED
 Get the assigned VLAN actions for egress VLAN translation on the given port class and VLAN tags.
 

Detailed Description

Macro Definition Documentation

#define OPENNSL_VLAN_LEARN_DISABLE   0x00000001

Definition at line 562 of file vlan.h.

#define OPENNSL_VLAN_PORT_INNER_VLAN_PRESERVE   0x00000004

Preserve the inner VLAN tag (by default it is stripped).

Definition at line 681 of file vlan.h.

Referenced by initial_qos_service_init().

#define OPENNSL_VLAN_PORT_OUTER_VLAN_PRESERVE   0x00000100

Preserve the outer VLAN tag (by default it is stripped).

Definition at line 684 of file vlan.h.

Referenced by initial_qos_service_init().

#define OPENNSL_VLAN_PORT_REPLACE   0x00000001

Replace existing entry.

Definition at line 677 of file vlan.h.

#define OPENNSL_VLAN_PORT_WITH_ID   0x00000002

Add using the specified ID.

Definition at line 679 of file vlan.h.

#define OPENNSL_VLAN_PROTO_PKT_DROP_ENABLE   0x00000004

Definition at line 560 of file vlan.h.

#define OPENNSL_VLAN_PROTO_PKT_FLOOD_ENABLE   0x00000008

Definition at line 561 of file vlan.h.

#define OPENNSL_VLAN_PROTO_PKT_FORWARD_ENABLE   0x00000002

Definition at line 559 of file vlan.h.

#define OPENNSL_VLAN_PROTO_PKT_TOCPU_ENABLE   0x00000001

Definition at line 558 of file vlan.h.

Typedef Documentation

opennsl_vlan_control_port_t

opennsl_vlan_control_t

This structure contains the configuration of a VLAN.

Initialize a VLAN data information structure.

Per VLAN forwarding behavior.

VLAN multicast flood modes.

Logical layer 2 port match criteria.

Layer 2 Logical port type.

Per VLAN Protocol Packet control.

A protocol packet type is copied to CPU if the packet control value is set to VLAN_PROTO_PKT_TOCPU_ENABLE. Additionally the control can be set to one of VLAN_PROTO_PKT_FORWARD_ENABLE, VLAN_PROTO_PKT_DROP_ENABLE, or VLAN_PROTO_PKT_FLOOD_ENABLE to forward, drop or flood in VLAN respectively.

Types of statistics that are maintained per VLAN.

Per VLAN URPF Mode setting.

Per VLAN VP Mode control.

Enumeration Type Documentation

opennsl_vlan_control_t

Enumerator:
opennslVlanDropUnknown 

Drop unknown/FFF VLAN pkts or send to CPU.

opennslVlanShared 

Shared vs.

Independent VLAN Learning.

opennslVlanSharedID 

Shared Learning VLAN ID.

opennslVlanTranslate 

Chip is in VLAN translate mode.

opennslVlanIgnorePktTag 

Ignore Packet VLAN tag.

Treat packet as untagged.

opennslVlanMemberMismatchToCpu 

Packets' incoming port is not the member of the VLAN are sent to CPU when set to 1.

Definition at line 440 of file vlan.h.

opennsl_vlan_control_port_t

Enumerator:
opennslVlanTranslateIngressEnable 
opennslVlanTranslateIngressMissDrop 
opennslVlanTranslateEgressEnable 
opennslVlanTranslateEgressMissDrop 

Definition at line 478 of file vlan.h.

Per VLAN forwarding behavior.

Enumerator:
opennslVlanForwardBridging 

Switching based on MAC and VLAN.

opennslVlanForwardSingleCrossConnect 

Switching based on outer VLAN.

opennslVlanForwardDoubleCrossConnect 

Switching based on outer+inner VLAN.

Definition at line 535 of file vlan.h.

VLAN multicast flood modes.

Enumerator:
OPENNSL_VLAN_MCAST_FLOOD_ALL 
OPENNSL_VLAN_MCAST_FLOOD_UNKNOWN 
OPENNSL_VLAN_MCAST_FLOOD_NONE 
OPENNSL_VLAN_MCAST_FLOOD_COUNT 

Definition at line 526 of file vlan.h.

Logical layer 2 port match criteria.

Enumerator:
OPENNSL_VLAN_PORT_MATCH_INVALID 

Illegal.

OPENNSL_VLAN_PORT_MATCH_NONE 

No source match criteria.

OPENNSL_VLAN_PORT_MATCH_PORT 

{Module, Port} or Trunk.

OPENNSL_VLAN_PORT_MATCH_PORT_VLAN 

Mod/port/trunk + outer VLAN.

Definition at line 688 of file vlan.h.

Types of statistics that are maintained per VLAN.

Enumerator:
opennslVlanStatPackets 

Packets that have hit the VLAN (forward/drop, L2/L3, unicast/multicast/broadcast/flood)

opennslVlanStatIngressPackets 

Packets that ingress on the VLAN.

opennslVlanStatBytes 

Bytes that have hit the VLAN (forward/drop, L2/L3, unicast/multicast/broadcast/flood)

opennslVlanStatIngressBytes 

Bytes that ingress on the VLAN.

opennslVlanStatEgressPackets 

Packets that egress on the VLAN.

opennslVlanStatEgressBytes 

Bytes that egress on the VLAN.

opennslVlanStatForwardedPackets 

Packets forwarded on the VLAN (L2/L3, unicast/multicast/broadcast/flood)

opennslVlanStatForwardedBytes 

Bytes forwarded on the VLAN (L2/L3, unicast/multicast/broadcast/flood)

opennslVlanStatDropPackets 

Packets dropped on the VLAN (L2/L3, unicast/multicast/broadcast/flood)

opennslVlanStatDropBytes 

Bytes dropped on the VLAN (L2/L3, unicast/multicast/broadcast/flood)

opennslVlanStatUnicastPackets 

L2 unicast packets forwarded on the VLAN.

opennslVlanStatUnicastBytes 

L2 unicast bytes forwarded on the VLAN.

opennslVlanStatUnicastDropPackets 

L2 unicast packets dropped on the VLAN.

opennslVlanStatUnicastDropBytes 

L2 unicast bytes dropped on the VLAN.

opennslVlanStatNonUnicastPackets 

L2 multicast packets forwarded on the VLAN.

opennslVlanStatNonUnicastBytes 

L2 multicast bytes forwarded on the VLAN.

opennslVlanStatNonUnicastDropPackets 

L2 non-unicast packets dropped on the VLAN.

opennslVlanStatNonUnicastDropBytes 

L2 non-unicast bytes dropped on the VLAN.

opennslVlanStatL3Packets 

Packets delivered to L3 for forwarding on the VLAN.

opennslVlanStatL3Bytes 

Bytes delivered to L3 for forwarding on the VLAN.

opennslVlanStatL3DropPackets 

Packets delivered to L3 for dropping on the VLAN.

opennslVlanStatL3DropBytes 

Bytes delivered to L3 for dropping on the VLAN.

opennslVlanStatFloodPackets 

L2 flood packets forwarded on the VLAN.

opennslVlanStatFloodBytes 

L2 flood bytes forwarded on the VLAN.

opennslVlanStatFloodDropPackets 

L2 flood packets dropped on the VLAN.

opennslVlanStatFloodDropBytes 

L2 flood bytes dropped on the VLAN.

opennslVlanStatGreenPackets 

Green packets forwarded on the VLAN.

opennslVlanStatGreenBytes 

Green bytes forwarded on the VLAN.

opennslVlanStatYellowPackets 

Yellow packets forwarded on the VLAN.

opennslVlanStatYellowBytes 

Yellow bytes forwared on the VLAN.

opennslVlanStatRedPackets 

Red packets forwarded on the VLAN.

opennslVlanStatRedBytes 

Red bytes forwarded on the VLAN.

opennslVlanStatCount 

Always last.

Not a usable value.

Definition at line 568 of file vlan.h.

Per VLAN URPF Mode setting.

Enumerator:
opennslVlanUrpfDisable 

Disable unicast RPF.

opennslVlanUrpfLoose 

Loose mode Unicast RPF.

opennslVlanUrpfStrict 

Strict mode Unicast RPF.

Definition at line 543 of file vlan.h.

Per VLAN VP Mode control.

Enumerator:
opennslVlanVPMcControlAuto 

VP Multicast replication auto control.

opennslVlanVPMcControlEnable 

Enable VP Multicast replication.

opennslVlanVPMcControlDisable 

Disable VP Multicast replication.

Definition at line 551 of file vlan.h.

Function Documentation

void opennsl_vlan_action_set_t_init ( opennsl_vlan_action_set_t action)

Initialize a VLAN tag action set structure.

Description
Initializes a VLAN tag action set structure to default values. This function should be used to initialize any VLAN tag action set structure prior to filling it out and passing it to an API function. This ensures that subsequent API releases may add new structure members to the opennsl_vlan_action_set_t structure, and opennsl_vlan_action_set_t_init will initialize the new members to correct default values. switch family?III devices that support the VLAN Action APIs can specify actions for a packet's inner and outer VLAN tag (add, delete, replace, copy, or do nothing). Depending on the number of VLAN tags in a packet along with the TPID value(s), a packet can be described as double-tagged, outer-tagged, inner-tagged, or untagged. In addition, VLAN tags with VLAN ID equal to 0 are referred to as 'priority-tagged'. Separate VLAN actions can be specified each of these types. The structure opennsl_vlan_action_set_t is used to specify each action:.
Parameters
action[IN,OUT] Pointer to VLAN tag action set structure to initialize.
Return values
None.

Referenced by initial_qos_service_vlan_action_set().

int opennsl_vlan_control_port_set ( int  unit,
int  port,
opennsl_vlan_control_port_t  type,
int  arg 
)

Set/get miscellaneous port-specific VLAN options.

Description
Sets/gets miscellaneous port-specific VLAN options. The options are from the VLAN Control Port selection =vlan_ctrl_port . Notes: (1) When setting egress vlan translation lookup key for virtual ports, control type should be one of {opennslVlanPortTranslateEgressKey or opennslVlanPortTranslateEgressKeyFirst}. Also, the argument specifying key type in case of virtual ports should be one of {opennslVlanTranslateEgressKeyVpn, opennslVlanTranslateEgressKeyVpnGport, opennslVlanTranslateEgressKeyVpnGportGroup}. (2) When setting the key for explicit second vlan translation lookup using opennslVlanPortTranslateEgressKeySecond, the argument specifying key type should be one of {opennslVlanTranslateEgressKeyPortGroupDouble, opennslVlanTranslateEgressKeyPortDouble}.
Parameters
unit[IN] Unit number.
port[IN] Device or logical port number
type[IN] A value from the opennsl_vlan_control_port_t enumerated list
arg[IN] (for _set) A parameter whose meaning is dependent on 'type'
Return values
OPENNSL_E_UNAVAILFeature not supported.
OPENNSL_E_XXX
int opennsl_vlan_control_set ( int  unit,
opennsl_vlan_control_t  type,
int  arg 
)

Set/get miscellaneous VLAN-specific chip options.

Description
Sets/gets miscellaneous VLAN-specific chip options. The options are from the VLAN Control selection =vlan_ctrl.
Parameters
unit[IN] Unit number.
type[IN] A value from the opennsl_vlan_control_t enumerated list
arg[IN] (for _set) A parameter whose meaning is dependent on 'type'
Return values
OPENNSL_E_UNAVAILFeature not supported.
OPENNSL_E_XXX
int opennsl_vlan_control_vlan_get ( int  unit,
opennsl_vlan_t  vlan,
opennsl_vlan_control_vlan_t control 
)

Set or retrieve current VLAN properties.

Description
Sets/gets miscellaneous VLAN-specific properties. The control properties are from =opennsl_vlan_control_vlan_t . The flags of the opennsl_vlan_control_vlan_t can be any combination of =OPENNSL_VLAN_CONTROL_VLAN_FLAG_table . On network switch devices that allow per-VLAN MPLS enable/disable, the only valid control parameter in this API is the OPENNSL_VLAN_MPLS_DISABLE control flag (all other control parameters are ignored). When only OPENNSL_VLAN_L2_CLASS_ID_ONLY is set, the if_class_id is set to VLAN_CLASS_ID(L3_IIF.CLASS_ID is not set). When only OPENNSL_VLAN_L3_CLASS_ID is set, the l3_if_class is set to L3_IIF.CLASS_ID(VLAN_CLASS_ID is not set). If none are set, the if_class_id is set to both VLAN_CLASS_ID and L3_IIF.CLASS_ID. If both are set, if_class_id is set to VLAN_CLASS_ID and l3_if_class is set to L3_IIF.CLASS_ID. Also, on a get, both the OPENNSL_VLAN_L2_CLASS_ID_ONLY and OPENNSL_VLAN_L3_CLASS_ID are set with the returned data, if_class is set to VLAN_CLASS_ID and l3_if_class is set to L3_IIF.CLASS_ID. For trident2 plus devices, this API can be used to derive VRF for a VPN. If VRF value is 0, the VRF is INVALID. If interface map mode (opennslSwitchL3IngressInterfaceMapSet =opennsl_switches) is not set, the vrf value set by this api can be overwritten by =opennsl_l3_intf_create(). If interface map mode is set, this api will not set vrf value. =opennsl_l3_ingress_create() api should be used to set vrf with an ingress interface. For Trident3 devices, OPENNSL_VLAN_UNKNOWN_UCAST_TOCPU now becomes a global configuration instead of per VLAN configuration, the last API call which programs OPENNSL_VLAN_UNKNOWN_UCAST_TOCPU takes effect. .
Parameters
unit[IN] Unit number.
vlan[IN] VLAN
control[OUT] structure which contains VLAN property, see opennsl_vlan_control_vlan_t =opennsl_vlan_control_vlan_t
Return values
OPENNSL_E_NONEOperation completed successfully
OPENNSL_E_UNAVAILOperation not supported
OPENNSL_E_XXXOperation failed.
int opennsl_vlan_control_vlan_set ( int  unit,
opennsl_vlan_t  vlan,
opennsl_vlan_control_vlan_t  control 
)

Set or retrieve current VLAN properties.

Description
Sets/gets miscellaneous VLAN-specific properties. The control properties are from =opennsl_vlan_control_vlan_t . The flags of the opennsl_vlan_control_vlan_t can be any combination of =OPENNSL_VLAN_CONTROL_VLAN_FLAG_table . On network switch devices that allow per-VLAN MPLS enable/disable, the only valid control parameter in this API is the OPENNSL_VLAN_MPLS_DISABLE control flag (all other control parameters are ignored). When only OPENNSL_VLAN_L2_CLASS_ID_ONLY is set, the if_class_id is set to VLAN_CLASS_ID(L3_IIF.CLASS_ID is not set). When only OPENNSL_VLAN_L3_CLASS_ID is set, the l3_if_class is set to L3_IIF.CLASS_ID(VLAN_CLASS_ID is not set). If none are set, the if_class_id is set to both VLAN_CLASS_ID and L3_IIF.CLASS_ID. If both are set, if_class_id is set to VLAN_CLASS_ID and l3_if_class is set to L3_IIF.CLASS_ID. Also, on a get, both the OPENNSL_VLAN_L2_CLASS_ID_ONLY and OPENNSL_VLAN_L3_CLASS_ID are set with the returned data, if_class is set to VLAN_CLASS_ID and l3_if_class is set to L3_IIF.CLASS_ID. For trident2 plus devices, this API can be used to derive VRF for a VPN. If VRF value is 0, the VRF is INVALID. If interface map mode (opennslSwitchL3IngressInterfaceMapSet =opennsl_switches) is not set, the vrf value set by this api can be overwritten by =opennsl_l3_intf_create(). If interface map mode is set, this api will not set vrf value. =opennsl_l3_ingress_create() api should be used to set vrf with an ingress interface. For Trident3 devices, OPENNSL_VLAN_UNKNOWN_UCAST_TOCPU now becomes a global configuration instead of per VLAN configuration, the last API call which programs OPENNSL_VLAN_UNKNOWN_UCAST_TOCPU takes effect. .
Parameters
unit[IN] Unit number.
vlan[IN] VLAN
control[IN] structure which contains VLAN property, see opennsl_vlan_control_vlan_t =opennsl_vlan_control_vlan_t
Return values
OPENNSL_E_NONEOperation completed successfully
OPENNSL_E_UNAVAILOperation not supported
OPENNSL_E_XXXOperation failed.
void opennsl_vlan_control_vlan_t_init ( opennsl_vlan_control_vlan_t data)

Initialize the opennsl_vlan_control_vlan_t structure.

Description
Initialize the opennsl_vlan_control_vlan_t structure.
Parameters
data[IN,OUT] Pointer to the structure to be initialized
Returns
Nothing
int opennsl_vlan_create ( int  unit,
opennsl_vlan_t  vid 
)

Allocate and configure a VLAN on the OPENNSL device.

Description
Create a new VLAN with the given ID. This routine will satisfy requests until the number of VLANs supported in the underlying hardware is reached. The VLAN is placed in the default STG and can be reassigned later. To deallocate the VLAN, opennsl_vlan_destroy must be used, not opennsl_vlan_init, since opennsl_vlan_init does not remove the VLAN from its STG. See =switch for default multicast flood mode configuration.
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
Return values
OPENNSL_E_NONESuccess or when the default VLAN is created, even if it already exists.
OPENNSL_E_XXX
OPENNSL_E_EXISTSVLAN ID already in use.

Referenced by example_create_l3_intf(), example_open_vlan_per_mc(), example_stg_create(), example_vlan_port_add(), and vlan_create_add_port().

int opennsl_vlan_default_get ( int  unit,
opennsl_vlan_t vid_ptr 
)

Get the default VLAN ID.

Description
Retrieve the current default VLAN ID.
Parameters
unit[IN] Unit number.
vid_ptr[OUT] Current default VLAN ID
Return values
OPENNSL_E_NONESuccess.
int opennsl_vlan_default_set ( int  unit,
opennsl_vlan_t  vid 
)

Set the default VLAN ID.

Description
Change the default VLAN to the specified VLAN ID. The new default VLAN must already exist. .
Parameters
unit[IN] Unit number.
vid[IN] New default VLAN ID
Return values
OPENNSL_E_XXX
int opennsl_vlan_destroy ( int  unit,
opennsl_vlan_t  vid 
)

Deallocate VLAN from the OPENNSL device.

Description
Remove references to previously created VLAN. Ports whose port-based VLAN is the destroyed VID are given the default VID.
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
Return values
OPENNSL_E_BADIDCannot remove default VLAN
OPENNSL_E_NOT_FOUNDVLAN ID not in use
OPENNSL_E_XXX

Referenced by revert_stg().

int opennsl_vlan_destroy_all ( int  unit)

Destroy all VLANs except the default VLAN.

Description
Destroy all VLANs except the default VLAN.
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_XXX
int opennsl_vlan_gport_add ( int  unit,
opennsl_vlan_t  vlan,
opennsl_gport_t  port,
int  flags 
)

Add a virtual or physical port to the specified VLAN.

Description
Adds the given port to the VLAN. For network switch and network switch, the port can be either a WLAN virtual port or a regular physical port. For network switch, the port can be a layer 2 logical port or a regular physical port. WLAN virtual ports or layer 2 logical ports that are members of a VLAN will receive broadcast, multicast and unknown unicast packets that are flooded to the VLAN. For applications that require different recipients for broadcast, unknown multicast and unknown unicast, the different multicast groups can be set using the =opennsl_vlan_control_vlan_set API. Virtual Port(VP) can be added to the vlan through this API to obtain the vlan membership. Due to the large amount of virtual port number, unlike physical port, switch hardware can not uses a port bitmap in the vlan table entry to represent the vlan membership. Instead the hardware uses two different methods: VP group and hash table to provide VP vlan membership. The hash table method is only available on opennsl56850 and later switch devices. The VP group referring as indirect vlan membership method is to associate a group of virtual port with a VP group and then the VP group establishes the membership with the vlan. The hardware uses the VLAN_MEMBERSHIP_PROFILE field in the SOURCE_VP table to associate a virtual port with the VP group, and use the VP_GROUP_BITMAP field in the vlan table to establish the vlan membership with the VP group. This method works well when a group of VPs belong to the same number of vlans such as in the following case:.
Parameters
unit[IN] Unit number.
vlan[IN] VLAN ID
port[IN] Virtual or physical port to be added to the VLAN
flags[IN] Control flags. See =OPENNSL_VLAN_PORT_t
Return values
OPENNSL_E_NOT_FOUNDVLAN ID not in use
OPENNSL_E_XXX

Referenced by example_add_vlan_on_port(), and example_create_l3_intf().

int opennsl_vlan_gport_delete ( int  unit,
opennsl_vlan_t  vlan,
opennsl_gport_t  port 
)

Remove a virtual or physical port from the specified VLAN.

Description
Removes the given port to the VLAN. For network switch and network switch, the port can be either a WLAN virtual port or a regular physical port. For network switch, the port can be a layer 2 logical port or a regular physical port.
Parameters
unit[IN] Unit number.
vlan[IN] VLAN ID
port[IN] Virtual or physical port to be removed from the VLAN
Return values
OPENNSL_E_NOT_FOUNDVLAN ID not in use
OPENNSL_E_XXX
int opennsl_vlan_gport_delete_all ( int  unit,
opennsl_vlan_t  vlan 
)

Removes all virtual and physical port from the specified VLAN.

Description
Removes all virtual and physical ports from the specified VLAN.
Parameters
unit[IN] Unit number.
vlan[IN] VLAN ID
Return values
OPENNSL_E_NOT_FOUNDVLAN ID not in use
OPENNSL_E_XXX
int opennsl_vlan_gport_get ( int  unit,
opennsl_vlan_t  vlan,
opennsl_gport_t  port,
int *  flags 
)

Get a virtual or physical port from the specified VLAN.

Description
Checks whether the given port is a member of the VLAN. For network switch and network switch, the port can be either a WLAN virtual port or a regular physical port. For network switch, the port can be a layer 2 logical port or a regular physical port.
Parameters
unit[IN] Unit number.
vlan[IN] VLAN ID
port[IN] Virtual or physical port to get VLAN information
flags[OUT] Control flags. See =OPENNSL_VLAN_PORT_t
Return values
OPENNSL_E_NOT_FOUNDVLAN ID not in use or port is not a member
OPENNSL_E_XXX
int opennsl_vlan_list ( int  unit,
opennsl_vlan_data_t **  listp,
int *  countp 
)

Returns an array of defined VLANs and their port bitmaps.

If by pbmp, then only VLANs which contain at least one of the specified ports are listed.

Description
Returns an array of defined VLANs and their port bitmaps. If by pbmp, only VLANs which contain at least one of the specified ports are listed. The array is allocated by this routine and the pointer to the list is returned in *listp. This array should be destroyed by opennsl_vlan_list_destroy when it is no longer needed. See =vlan_data .
Parameters
unit[IN] Unit number.
listp[OUT] Place where pointer to return array will be stored, which will be NULL if there are zero VLANs defined.
countp[OUT] Place where number of entries in array will be stored, which will be 0 if there are zero VLANs defined.
Return values
OPENNSL_E_MEMORYOut of system memory.
OPENNSL_E_XXX
int opennsl_vlan_list_destroy ( int  unit,
opennsl_vlan_data_t list,
int  count 
)

Destroy a list returned by opennsl_vlan_list.

Description
Deallocate the array created by opennsl_vlan_list or opennsl_vlan_list_by_pbmp. Also works for the zero-VLAN case (NULL list).
Parameters
unit[IN] Unit number.
list[IN] List returned by opennsl_vlan_list
count[IN] Count returned by opennsl_vlan_list
Return values
OPENNSL_E_NONESuccess.
int opennsl_vlan_port_add ( int  unit,
opennsl_vlan_t  vid,
opennsl_pbmp_t  pbmp,
opennsl_pbmp_t  ubmp 
)

Add ports to the specified VLAN.

Description
Adds the selected ports to the VLAN. The port bitmap specifies ALL ports to be added to the VLAN. The untagged bitmap specifies the subset of these ports that are untagged. If the port is already a member of the VLAN then the tagged attribute gets updated. Packets sent from the untagged ports will not contain the 802.1Q tag header. .
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
pbmp[IN] Port bitmap for members of VLAN
ubmp[IN] Port bitmap for untagged members of VLAN
Return values
OPENNSL_E_NOT_FOUNDVLAN ID not in use
OPENNSL_E_XXX

Referenced by example_stg_create(), example_switch_default_vlan_config(), example_vlan_port_add(), main(), and vlan_create_add_port().

int opennsl_vlan_port_create ( int  unit,
opennsl_vlan_port_t vlan_port 
)

Create a layer 2 logical port.

Description
Create a Layer 2 Logical Port based on the parameters passed via vlan_port structure. Uses the ID in the vlan_port_id field of the opennsl_vlan_port_t if the OPENNSL_VLAN_PORT_WITH_ID flag is specified, otherwise it places the new ID into the vlan_port_id field of the opennsl_vlan_port_t. This should be called on the home unit (where the logical port will physically exist) first, then the opennsl_vlan_port_t used as modified by this call to reproduce the data to any other units that may need to send to the logical port.
Parameters
unit[IN] Unit number.
vlan_port[IN,OUT] Layer 2 Logical port.
Return values
OPENNSL_E_XXX

Referenced by example_vlan_inLif_create(), and initial_qos_service().

int opennsl_vlan_port_destroy ( int  unit,
opennsl_gport_t  gport 
)

Destroy a layer 2 logical port.

Description
Destroy the given Layer 2 Logical Port.
Parameters
unit[IN] Unit number.
gport[IN] Gport
Return values
OPENNSL_E_XXX

Referenced by initial_qos_service_cleanup().

int opennsl_vlan_port_find ( int  unit,
opennsl_vlan_port_t vlan_port 
)

Get/find a layer 2 logical port given the GPORT ID or match criteria.

Description
Given a GPORT ID or the match criteria of a logical layer 2 port, find/get the Layer 2 logical port information. When the VSI (or the VPN) is passed in opennsl_vlan_port_t parameter, the API will search only through VLAN gports that are connected to the VSI (or the VPN).
Parameters
unit[IN] Unit number.
vlan_port[IN,OUT] Layer 2 logical port
Return values
OPENNSL_E_XXX
int opennsl_vlan_port_get ( int  unit,
opennsl_vlan_t  vid,
opennsl_pbmp_t pbmp,
opennsl_pbmp_t ubmp 
)

Retrieves a list of the member ports of an existing VLAN.

Description
Retrieves a list of the member ports of an existing VLAN.
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
pbmp[OUT] Port bitmap for members of VLAN
ubmp[OUT] Port bitmap for untagged members of VLAN
Return values
OPENNSL_E_NOT_FOUNDVLAN ID not in use
OPENNSL_E_XXX
int opennsl_vlan_port_remove ( int  unit,
opennsl_vlan_t  vid,
opennsl_pbmp_t  pbmp 
)

Remove ports from a specified VLAN.

Description
Removes the specified ports from the given VLAN. If some or all of the requested ports are not already members of the VLAN, the routine returns OPENNSL_E_NOT_FOUND.
Parameters
unit[IN] Unit number.
vid[IN] VLAN ID
pbmp[IN] Port bitmap for members of VLAN
Return values
OPENNSL_E_NOT_FOUNDVLAN ID not in use
OPENNSL_E_XXX

Referenced by example_policer_test().

void opennsl_vlan_port_t_init ( opennsl_vlan_port_t vlan_port)

Initialize the VLAN port structure.

Description
This API initializes the opennsl_vlan_port_t structure.
Parameters
vlan_port[IN,OUT] Layer 2 Logical port.
Return values
OPENNSL_E_XXX

Referenced by example_vlan_inLif_create(), and initial_qos_service_init().

int opennsl_vlan_stat_get ( int  unit,
opennsl_vlan_t  vlan,
opennsl_cos_t  cos,
opennsl_vlan_stat_t  stat,
uint64 val 
)

Extract per-VLAN statistics from the chip.

Description
The cos param must be OPENNSL_COS_INVALID when fetching single or typed mode counters. For MEF mode counters, the opennsl_cos_t param must be valid. The cos param must be OPENNSL_COS_INVALID for switch family?switches.
Parameters
unit[IN] Unit number.
vlan[IN] VLAN ID.
cos[IN] CoS or priority
stat[IN] Type of the counter to retrieve.
val[OUT] Pointer to a counter value.
Return values
OPENNSL_E_XXX
int opennsl_vlan_stat_set ( int  unit,
opennsl_vlan_t  vlan,
opennsl_cos_t  cos,
opennsl_vlan_stat_t  stat,
uint64  val 
)

Set the specified statistic to the indicated value for the specified VLAN.

Description
The cos param must be OPENNSL_COS_INVALID when setting single or typed mode counters. For MEF mode counters, the opennsl_cos_t param must be valid. The cos param must be OPENNSL_COS_INVALID for switch family?switches.
Parameters
unit[IN] Unit number.
vlan[IN] VLAN ID.
cos[IN] CoS or priority
stat[IN] Type of the counter to set.
val[IN] New counter value.
Return values
OPENNSL_E_XXX
int opennsl_vlan_translate_egress_action_add ( int  unit,
int  port_class,
opennsl_vlan_t  outer_vlan,
opennsl_vlan_t  inner_vlan,
opennsl_vlan_action_set_t action 
)

Add an entry to the egress VLAN Translation table and assign VLAN actions.

Description
Add an entry to the egress VLAN Translation table and assign VLAN actions. The port class is a per-port property which is set using =opennsl_port_class_set along with opennslPortClassVlanTranslateEgress. This allows the same egress VLAN translation entry to match for all ports with the same port class. For devices that support the VLAN action APIs, within the system, a packet is either double-tagged or outer-tagged (that is, it always has an outer tag). For double-tagged packets, the outer tag and inner tag VLAN IDs from the packet are used as the key. For outer-tagged packets, the outer tag VLAN ID is used from the packet and the inner VLAN ID is set to zero as the key. The only actions that can be set for this API are the double-tag and outer-tag actions. For systems that support Destination Virtual Ports such could be specified in a appropriate GPORT format as port_class parameter and will be recognized by the API to perform matching based on Destination Virtual Port as a lookup key. For devices that support explicit second egress vlan translation lookup (key configured using =opennsl_vlan_control_port_set API with opennslVlanPortTranslateEgressKeySecond control), note that only the class-id in the resulting entry of second lookup will be used. Note: For GPORT based egress vlan translation entries,.
Parameters
unit[IN] Unit number.
port_class[IN] Port class
outer_vlan[IN] Outer VLAN ID
inner_vlan[IN] Inner VLAN ID
action[IN] VLAN tag action set, as specified in =OPENNSL_VLAN_ACTION_SET_t
Return values
OPENNSL_E_UNAVAILNot supported.
OPENNSL_E_XXX

Referenced by initial_qos_service_vlan_action_set().

int opennsl_vlan_translate_egress_action_get ( int  unit,
int  port_class,
opennsl_vlan_t  outer_vlan,
opennsl_vlan_t  inner_vlan,
opennsl_vlan_action_set_t action 
)

Get the assigned VLAN actions for egress VLAN translation on the given port class and VLAN tags.

Description
Get the assigned VLAN actions for egress VLAN translation on the given port class and VLAN tags.
Parameters
unit[IN] Unit number.
port_class[IN] Port class
outer_vlan[IN] Outer VLAN ID
inner_vlan[IN] Inner VLAN ID
action[IN,OUT] VLAN tag action set, as specified in =OPENNSL_VLAN_ACTION_SET_t
Return values
OPENNSL_E_UNAVAILNot supported.
OPENNSL_E_XXX