OpenNSL API Guide and Reference Manual
Files | Typedefs | Enumerations | Functions
Spanning Tree

Files

file  stg.h
 
file  stgX.h
 

Typedefs

typedef enum opennsl_stg_stp_e opennsl_stg_stp_t
 opennsl_stg_stp_e
 

Enumerations

enum  opennsl_stg_stp_e {
  OPENNSL_STG_STP_DISABLE = _SHR_PORT_STP_DISABLE,
  OPENNSL_STG_STP_BLOCK = _SHR_PORT_STP_BLOCK,
  OPENNSL_STG_STP_LISTEN = _SHR_PORT_STP_LISTEN,
  OPENNSL_STG_STP_LEARN = _SHR_PORT_STP_LEARN,
  OPENNSL_STG_STP_FORWARD = _SHR_PORT_STP_FORWARD,
  OPENNSL_STG_STP_COUNT = _SHR_PORT_STP_COUNT
}
 opennsl_stg_stp_e More...
 

Functions

int opennsl_stg_clear (int unit) LIB_DLL_EXPORTED
 Destroy all STGs and initialize the Spanning Tree Group (STG) module to its initial configuration.
 
int opennsl_stg_count_get (int unit, int *max_stg) LIB_DLL_EXPORTED
 Return the maximum number of STGs that the underlying hardware can support.
 
int opennsl_stg_create (int unit, opennsl_stg_t *stg_ptr) LIB_DLL_EXPORTED
 Create a new STG, using a new STG ID.
 
int opennsl_stg_default_get (int unit, opennsl_stg_t *stg_ptr) LIB_DLL_EXPORTED
 Return the current default STG ID for the chip.
 
int opennsl_stg_default_set (int unit, opennsl_stg_t stg) LIB_DLL_EXPORTED
 Designate the default STG ID for the chip.
 
int opennsl_stg_destroy (int unit, opennsl_stg_t stg) LIB_DLL_EXPORTED
 Destroys the specified STG.
 
int opennsl_stg_init (int unit) LIB_DLL_EXPORTED
 Initialize the Spanning Tree Group (STG) module to its initial configuration.
 
int opennsl_stg_list (int unit, opennsl_stg_t **list, int *count) LIB_DLL_EXPORTED
 Generates a list of IDs for currently defined STGs.
 
int opennsl_stg_list_destroy (int unit, opennsl_stg_t *list, int count) LIB_DLL_EXPORTED
 Destroys a previously returned list of STG IDs; the STGs themselves are not affected.
 
int opennsl_stg_stp_get (int unit, opennsl_stg_t stg, opennsl_port_t port, int *stp_state) LIB_DLL_EXPORTED
 Return the Spanning Tree Protocol state of a port in the specified STG.
 
int opennsl_stg_stp_set (int unit, opennsl_stg_t stg, opennsl_port_t port, int stp_state) LIB_DLL_EXPORTED
 Set the Spanning Tree Protocol state of a port/VP in the specified STG.
 
int opennsl_stg_vlan_add (int unit, opennsl_stg_t stg, opennsl_vlan_t vid) LIB_DLL_EXPORTED
 Add a VLAN to a specified STG.
 
int opennsl_stg_vlan_list (int unit, opennsl_stg_t stg, opennsl_vlan_t **list, int *count) LIB_DLL_EXPORTED
 Generates a list of VLANs in a specified STG.
 
int opennsl_stg_vlan_list_destroy (int unit, opennsl_vlan_t *list, int count) LIB_DLL_EXPORTED
 Destroy a list returned by =opennsl_stg_vlan_list .
 
int opennsl_stg_vlan_remove (int unit, opennsl_stg_t stg, opennsl_vlan_t vid) LIB_DLL_EXPORTED
 Remove a VLAN from a Spanning Tree Group.
 
int opennsl_stg_vlan_remove_all (int unit, opennsl_stg_t stg) LIB_DLL_EXPORTED
 Remove all VLANs from a Spanning Tree Group.
 

Detailed Description

Typedef Documentation

opennsl_stg_stp_e

Enumeration Type Documentation

opennsl_stg_stp_e

Enumerator:
OPENNSL_STG_STP_DISABLE 

Disabled.

OPENNSL_STG_STP_BLOCK 

BPDUs/no learns.

OPENNSL_STG_STP_LISTEN 

BPDUs/no learns.

OPENNSL_STG_STP_LEARN 

BPDUs/learns.

OPENNSL_STG_STP_FORWARD 

Normal operation.

OPENNSL_STG_STP_COUNT 

Definition at line 31 of file stg.h.

Function Documentation

int opennsl_stg_clear ( int  unit)

Destroy all STGs and initialize the Spanning Tree Group (STG) module to its initial configuration.

Description
Destroys any current STGs and initializes the STG module to its initial configuration as described in =opennsl_stg_init . .
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_UNITInvalid device ID
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_XXXOther possible errors; for details, see
int opennsl_stg_count_get ( int  unit,
int *  max_stg 
)

Return the maximum number of STGs that the underlying hardware can support.

Description
Returns the maximum total number of STGs that the underlying hardware can support. The returned number is chip specific, and is not dependent upon the number of currently defined STGs.
Parameters
unit[IN] Unit number.
max_stg[OUT] Pointer to the returned max allowable STGs
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
int opennsl_stg_create ( int  unit,
opennsl_stg_t stg_ptr 
)

Create a new STG, using a new STG ID.

Description
Creates a new STG, and assigns the lowest available STG ID to it. All ports in the new STG are initialized to the OPENNSL_STG_STP_DISABLE state.
Parameters
unit[IN] Unit number.
stg_ptr[OUT] Pointer to returned STG ID
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_FULLif all available STG IDs are already being used
OPENNSL_E_XXXOther possible errors; for details, see

Referenced by example_stg_init().

int opennsl_stg_default_get ( int  unit,
opennsl_stg_t stg_ptr 
)

Return the current default STG ID for the chip.

Description
Returns the default STG ID of the chip.
Parameters
unit[IN] Unit number.
stg_ptr[OUT] Pointer to returned default STG ID.
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
int opennsl_stg_default_set ( int  unit,
opennsl_stg_t  stg 
)

Designate the default STG ID for the chip.

Description
Sets the default STG ID of the chip. The indicated STG must be currently defined.
Parameters
unit[IN] Unit number.
stg[IN] Default STG ID for the chip.
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
int opennsl_stg_destroy ( int  unit,
opennsl_stg_t  stg 
)

Destroys the specified STG.

Description
Destroys the specified STG. Any VLAN(s) belonging to the specified STG will be put into the default STG. The default STG cannot be destroyed.
Parameters
unit[IN] Unit number.
stg[IN] STG ID
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
OPENNSL_E_XXXOther possible errors; for details, see

Referenced by revert_stg().

int opennsl_stg_init ( int  unit)

Initialize the Spanning Tree Group (STG) module to its initial configuration.

Description
Initializes the STG module. A default STG is then created, with all its ports in the OPENNSL_STG_STP_DISABLE state. Any previously existing STG information is lost. .
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_UNITInvalid device ID
OPENNSL_E_XXXOther possible errors; for details, see
int opennsl_stg_list ( int  unit,
opennsl_stg_t **  list,
int *  count 
)

Generates a list of IDs for currently defined STGs.

Description
Returns a (pointer to a) sorted list of currently active STGs. If there are no currently defined STGs, *list will be NULL and *count is 0. Otherwise, *list will point to an array of the *count currently defined STG IDs. The caller is responsible for freeing the memory allocated for the returned list, that is, calling.
Parameters
unit[IN] Unit number.
list[OUT] Pointer to returned pointer-to-array of STG IDs
count[OUT] Pointer to returned count of STG IDs
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_XXXOther possible errors; for details, see
int opennsl_stg_list_destroy ( int  unit,
opennsl_stg_t list,
int  count 
)

Destroys a previously returned list of STG IDs; the STGs themselves are not affected.

Description
Destroys a list of STG IDs previously returned by =opennsl_stg_list, effectively freeing the memory previously allocated by opennsl_stg_list() for the list of STGs. The status of each STG in the list is not affected.
Parameters
unit[IN] Unit number.
list[IN] Pointer to array of STG IDs
count[IN] Count of STG IDs in the array
Return values
OPENNSL_E_NONESuccess
int opennsl_stg_stp_get ( int  unit,
opennsl_stg_t  stg,
opennsl_port_t  port,
int *  stp_state 
)

Return the Spanning Tree Protocol state of a port in the specified STG.

Description
Returns the Spanning Tree Protocol state of the specified local port. The indicated STG must be currently defined. On some switches, the LISTENING state can be indistinguishable from the BLOCKING state.
Parameters
unit[IN] Unit number.
stg[IN] STG ID
port[IN] Local port number
stp_state[OUT] Pointer to the returned Spanning Tree Protocol state
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID
OPENNSL_E_PORTif invalid port specified
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
OPENNSL_E_XXXOther possible errors; for details, see

Referenced by main().

int opennsl_stg_stp_set ( int  unit,
opennsl_stg_t  stg,
opennsl_port_t  port,
int  stp_state 
)

Set the Spanning Tree Protocol state of a port/VP in the specified STG.

   VP GROUP STP state need to be setted per direction, Please use
   =opennsl_vlan_gport_add for this.
Description
Sets the specified local port to the indicated Spanning TreeProtocol (STP) state. The indicated STG must be currently defined. On some switches the LISTENING state can be indistinguishable from the BLOCKING state.
Parameters
unit[IN] Unit number.
stg[IN] STG ID
port[IN] Local port number
stp_state[IN] Spanning Tree Protocol state
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID
OPENNSL_E_PORTif invalid port specified
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
OPENNSL_E_XXXOther possible errors; for details, see

Referenced by example_port_default_config(), example_stg_create(), and main().

int opennsl_stg_vlan_add ( int  unit,
opennsl_stg_t  stg,
opennsl_vlan_t  vid 
)

Add a VLAN to a specified STG.

Description
Adds the specified VLAN to the specified STG. Both VLAN and STG must be currently defined. The VLAN is implicitly removed from the STG it currently belongs to before it is added to the new STG. Note: STG Id 0 is reserved, created during initialization, and used for internal purposes. VLANs should not be added to this group. .
Parameters
unit[IN] Unit number.
stg[IN] STG ID
vid[IN] VLAN ID
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID or VLAN ID
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
OPENNSL_E_XXXOther possible errors; for details, see

Referenced by example_stg_create().

int opennsl_stg_vlan_list ( int  unit,
opennsl_stg_t  stg,
opennsl_vlan_t **  list,
int *  count 
)

Generates a list of VLANs in a specified STG.

Description
Returns a pointer to a sorted list of VLANs belonging to the specified STG. If the STG currently contains no VLANs, *list is NULL and *count is 0. Otherwise, *list points to an array of the *count VLAN IDs in the indicated STG. The indicated STG must be currently defined. The caller is responsible for freeing the memory allocated for the returned list, that is, calling =opennsl_stg_vlan_list_destroy .
Parameters
unit[IN] Unit number.
stg[IN] STG ID
list[OUT] Pointer to returned pointer-to-array of VLAN IDs
count[OUT] Pointer to returned count of VLAN IDs
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID or VLAN ID
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
OPENNSL_E_XXXOther possible errors; for details, see
int opennsl_stg_vlan_list_destroy ( int  unit,
opennsl_vlan_t list,
int  count 
)

Destroy a list returned by =opennsl_stg_vlan_list .

Description
Destroys a list of VLAN IDs previously returned by =opennsl_stg_vlan_list , freeing the memory previously allocated by =opennsl_stg_vlan_list for the list of VLANs. The status of each VLAN in the list is not affected.
Parameters
unit[IN] Unit number.
list[IN] Pointer to array of VLAN IDs
count[IN] Count of VLAN IDs in the array
Return values
OPENNSL_E_NONESuccess
int opennsl_stg_vlan_remove ( int  unit,
opennsl_stg_t  stg,
opennsl_vlan_t  vid 
)

Remove a VLAN from a Spanning Tree Group.

Description
Removes the specified VLAN from the specified STG and assigns it to the default STG. Both VLAN and STG must be currently defined.
Parameters
unit[IN] Unit number.
stg[IN] STG ID
vid[IN] VLAN ID
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID or VLAN ID
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
OPENNSL_E_XXXOther possible errors; for details, see
int opennsl_stg_vlan_remove_all ( int  unit,
opennsl_stg_t  stg 
)

Remove all VLANs from a Spanning Tree Group.

Description
Removes all VLANs from the specified STG and assigns them to the default STG. The STG must be currently defined.
Parameters
unit[IN] Unit number.
stg[IN] STG ID
Return values
OPENNSL_E_NONESuccess
OPENNSL_E_INITSTG module is not currently initialized.
OPENNSL_E_BADIDInvalid STG ID or VLAN ID
OPENNSL_E_NOT_FOUNDSTG ID is not currently defined
OPENNSL_E_XXXOther possible errors; for details, see