OpenNSL API Guide and Reference Manual
Data Structures | Files | Macros | Typedefs | Functions
Kernel Network (KNET) Configuration

Data Structures

struct  opennsl_knet_filter_s
 Kernel packet filter structure. More...
 
struct  opennsl_knet_netif_s
 Kernel network interface structure. More...
 

Files

file  knet.h
 
file  knetX.h
 

Macros

#define OPENNSL_KNET_DEST_T_NETIF   1
 Send packet to virtual network interface.
 
#define OPENNSL_KNET_DEST_T_OPENNSL_RX_API   2
 Send packet to OPENNSL Rx API.
 
#define OPENNSL_KNET_FILTER_DESC_MAX   32
 
#define OPENNSL_KNET_FILTER_F_STRIP_TAG   0x00000001
 Strip VLAN tag from packets sent to vitual network interfaces.
 
#define OPENNSL_KNET_FILTER_M_FP_RULE   0x00000040
 Match filter processor rule number.
 
#define OPENNSL_KNET_FILTER_M_INGPORT   0x00000004
 Match local ingress port.
 
#define OPENNSL_KNET_FILTER_M_RAW   0x00000001
 Match raw packet data.
 
#define OPENNSL_KNET_FILTER_M_REASON   0x00000020
 Match copy-to-CPU reason code.
 
#define OPENNSL_KNET_FILTER_M_VLAN   0x00000002
 Match VLAN ID.
 
#define OPENNSL_KNET_FILTER_SIZE_MAX   256
 
#define OPENNSL_KNET_FILTER_T_RX_PKT   1
 Rx packet filter.
 
#define OPENNSL_KNET_NETIF_F_ADD_TAG   0x00000001
 Add VLAN tag to packets sent directly to physical port.
 
#define OPENNSL_KNET_NETIF_NAME_MAX   16
 
#define OPENNSL_KNET_NETIF_T_TX_CPU_INGRESS   1
 Tx packets are sent through CPU port ingress logic.
 
#define OPENNSL_KNET_NETIF_T_TX_LOCAL_PORT   2
 Tx packets are sent to local device port bypassing switch logic.
 

Typedefs

typedef struct
opennsl_knet_filter_s 
opennsl_knet_filter_t
 Kernel packet filter structure.
 
typedef int(* opennsl_knet_filter_traverse_cb )(int unit, opennsl_knet_filter_t *filter, void *user_data)
 
typedef struct opennsl_knet_netif_s opennsl_knet_netif_t
 Kernel network interface structure.
 
typedef int(* opennsl_knet_netif_traverse_cb )(int unit, opennsl_knet_netif_t *netif, void *user_data)
 

Functions

int opennsl_knet_filter_create (int unit, opennsl_knet_filter_t *filter) LIB_DLL_EXPORTED
 Create a kernel packet filter.
 
int opennsl_knet_filter_destroy (int unit, int filter_id) LIB_DLL_EXPORTED
 Destroy a kernel packet filter.
 
void opennsl_knet_filter_t_init (opennsl_knet_filter_t *filter) LIB_DLL_EXPORTED
 Initialize a opennsl_knet_filter_t structure.
 
int opennsl_knet_filter_traverse (int unit, opennsl_knet_filter_traverse_cb trav_fn, void *user_data) LIB_DLL_EXPORTED
 Traverse kernel packet filter objects.
 
int opennsl_knet_init (int unit) LIB_DLL_EXPORTED
 Initialize the kernel networking subsystem.
 
int opennsl_knet_netif_create (int unit, opennsl_knet_netif_t *netif) LIB_DLL_EXPORTED
 Create a kernel network interface.
 
int opennsl_knet_netif_destroy (int unit, int netif_id) LIB_DLL_EXPORTED
 Destroy a kernel network interface.
 
void opennsl_knet_netif_t_init (opennsl_knet_netif_t *netif) LIB_DLL_EXPORTED
 Initialize a opennsl_knet_netif_t structure.
 
int opennsl_knet_netif_traverse (int unit, opennsl_knet_netif_traverse_cb trav_fn, void *user_data) LIB_DLL_EXPORTED
 Traverse kernel network interface objects.
 

Detailed Description

Macro Definition Documentation

#define OPENNSL_KNET_DEST_T_NETIF   1

Send packet to virtual network interface.

Definition at line 62 of file knet.h.

Referenced by example_linux_interface_create().

#define OPENNSL_KNET_DEST_T_OPENNSL_RX_API   2

Send packet to OPENNSL Rx API.

Definition at line 64 of file knet.h.

#define OPENNSL_KNET_FILTER_DESC_MAX   32

Definition at line 69 of file knet.h.

#define OPENNSL_KNET_FILTER_F_STRIP_TAG   0x00000001

Strip VLAN tag from packets sent to vitual network interfaces.

Definition at line 66 of file knet.h.

Referenced by example_linux_interface_create().

#define OPENNSL_KNET_FILTER_M_FP_RULE   0x00000040

Match filter processor rule number.

Definition at line 76 of file knet.h.

#define OPENNSL_KNET_FILTER_M_INGPORT   0x00000004

Match local ingress port.

Definition at line 73 of file knet.h.

Referenced by example_linux_interface_create().

#define OPENNSL_KNET_FILTER_M_RAW   0x00000001

Match raw packet data.

Definition at line 71 of file knet.h.

#define OPENNSL_KNET_FILTER_M_REASON   0x00000020

Match copy-to-CPU reason code.

Definition at line 74 of file knet.h.

#define OPENNSL_KNET_FILTER_M_VLAN   0x00000002

Match VLAN ID.

Definition at line 72 of file knet.h.

#define OPENNSL_KNET_FILTER_SIZE_MAX   256

Definition at line 70 of file knet.h.

#define OPENNSL_KNET_FILTER_T_RX_PKT   1

Rx packet filter.

Definition at line 61 of file knet.h.

Referenced by example_linux_interface_create().

#define OPENNSL_KNET_NETIF_F_ADD_TAG   0x00000001

Add VLAN tag to packets sent directly to physical port.

Definition at line 37 of file knet.h.

#define OPENNSL_KNET_NETIF_NAME_MAX   16

Definition at line 40 of file knet.h.

Referenced by example_knet_intf_create(), and example_knet_intf_delete().

#define OPENNSL_KNET_NETIF_T_TX_CPU_INGRESS   1

Tx packets are sent through CPU port ingress logic.

Definition at line 30 of file knet.h.

#define OPENNSL_KNET_NETIF_T_TX_LOCAL_PORT   2

Tx packets are sent to local device port bypassing switch logic.

Definition at line 33 of file knet.h.

Referenced by example_linux_interface_create().

Typedef Documentation

Kernel packet filter structure.

typedef int(* opennsl_knet_filter_traverse_cb)(int unit, opennsl_knet_filter_t *filter, void *user_data)

Definition at line 277 of file knet.h.

Kernel network interface structure.

typedef int(* opennsl_knet_netif_traverse_cb)(int unit, opennsl_knet_netif_t *netif, void *user_data)

Definition at line 202 of file knet.h.

Function Documentation

int opennsl_knet_filter_create ( int  unit,
opennsl_knet_filter_t filter 
)

Create a kernel packet filter.

Description
Create a kernel packet filter that will direct packets received from the CPU port to a virtual network interface (or the OPENNSL Rx API) based on out-of-band data and/or packet data.
Parameters
unit[IN] Unit number.
filter[IN,OUT] Rx packet filter configuration
Return values
OPENNSL_E_NONE
OPENNSL_E_UNAVAIL
OPENNSL_E_INTERNAL
OPENNSL_E_TIMEOUT
OPENNSL_E_PARAM
OPENNSL_E_RESOURCE

Referenced by example_linux_interface_create().

int opennsl_knet_filter_destroy ( int  unit,
int  filter_id 
)

Destroy a kernel packet filter.

Description
Destroy a kernel packet filter.
Parameters
unit[IN] Unit number.
filter_id[IN] Rx packet filter ID
Return values
OPENNSL_E_NONE
OPENNSL_E_UNAVAIL
OPENNSL_E_INTERNAL
OPENNSL_E_TIMEOUT
OPENNSL_E_PARAM
OPENNSL_E_NOT_FOUND

Referenced by example_knet_intf_delete().

void opennsl_knet_filter_t_init ( opennsl_knet_filter_t filter)

Initialize a opennsl_knet_filter_t structure.

Description
Initialize a opennsl_knet_filter_t structure.
Parameters
filter[IN,OUT] Pointer to struct to be initialized
Return values
None.

Referenced by example_linux_interface_create().

int opennsl_knet_filter_traverse ( int  unit,
opennsl_knet_filter_traverse_cb  trav_fn,
void *  user_data 
)

Traverse kernel packet filter objects.

Description
Iterates over kernel packet filters for this unit and executes user callback function for each packet filter. The callback function is defined as follows: typedef int (*opennsl_knet_filter_traverse_cb)( int unit, opennsl_knet_filter_t *filter, void *user_data);
Parameters
unit[IN] Unit number.
trav_fn[IN] User provided callback function
user_data[IN] User provided data used as input param for callback function
Return values
OPENNSL_E_NONE
OPENNSL_E_UNAVAIL
OPENNSL_E_INTERNAL
OPENNSL_E_TIMEOUT
OPENNSL_E_PARAM
OPENNSL_E_NOT_FOUND
int opennsl_knet_init ( int  unit)

Initialize the kernel networking subsystem.

Description
Initialize the kernel networking subsystem.
Parameters
unit[IN] Unit number.
Return values
OPENNSL_E_NONE
OPENNSL_E_UNAVAIL
OPENNSL_E_CONFIG
OPENNSL_E_INTERNAL
OPENNSL_E_TIMEOUT
OPENNSL_E_PARAM
OPENNSL_E_RESOURCE
OPENNSL_E_NOT_FOUND
int opennsl_knet_netif_create ( int  unit,
opennsl_knet_netif_t netif 
)

Create a kernel network interface.

Description
Create a virtual network interface in the kernel (operating system). The ID and name fields of the structure will be assigned be the API. Once created, the application is responsible for managing the network interface through the appropriate system calls such as the POSIX sockets interface.
Parameters
unit[IN] Unit number.
netif[IN,OUT] Network interface configuration
Return values
OPENNSL_E_NONE
OPENNSL_E_UNAVAIL
OPENNSL_E_INTERNAL
OPENNSL_E_TIMEOUT
OPENNSL_E_PARAM
OPENNSL_E_RESOURCE

Referenced by example_linux_interface_create().

int opennsl_knet_netif_destroy ( int  unit,
int  netif_id 
)

Destroy a kernel network interface.

Description
Remove a previously created virtual network interface from the kernel (operating system). The application is responsible for properly shutting down the network interface prior to calling this API.
Parameters
unit[IN] Unit number.
netif_id[IN] Network interface ID
Return values
OPENNSL_E_NONE
OPENNSL_E_UNAVAIL
OPENNSL_E_INTERNAL
OPENNSL_E_TIMEOUT
OPENNSL_E_PARAM
OPENNSL_E_NOT_FOUND

Referenced by example_knet_intf_delete().

void opennsl_knet_netif_t_init ( opennsl_knet_netif_t netif)

Initialize a opennsl_knet_netif_t structure.

Description
Initialize a opennsl_knet_netif_t structure.
Parameters
netif[IN,OUT] Pointer to struct to be initialized
Return values
None.

Referenced by example_linux_interface_create().

int opennsl_knet_netif_traverse ( int  unit,
opennsl_knet_netif_traverse_cb  trav_fn,
void *  user_data 
)

Traverse kernel network interface objects.

Description
Iterates over virtual network interfaces for this unit and executes user callback function for each interface. The callback function is defined as follows: typedef int (*opennsl_knet_netif_traverse_cb)( int unit, opennsl_knet_netif_t *netif, void *user_data); .
Parameters
unit[IN] Unit number.
trav_fn[IN] User provided callback function
user_data[IN] User provided data used as input param for callback function
Return values
OPENNSL_E_NONE
OPENNSL_E_UNAVAIL
OPENNSL_E_INTERNAL
OPENNSL_E_TIMEOUT
OPENNSL_E_PARAM
OPENNSL_E_NOT_FOUND