Open Network Switch Layer (OpenNSL) is a library of network switch APIs that is openly available for programming Broadcom network switch silicon based platforms. These open APIs enable development of networking application software based on Broadcom network switch architecture based platforms. Because of the wide variety of switch devices the OpenNSL APIs run on, not all functions are available on all underlying devices. The API exports silicon features in an independent manner as much as possible, but does not implement in software those functions that the underlying devices do not support.
From the OpenNSL point of view, the system is a collection of interconnected devices, each controlling ports. Operations are carried out on a particular device and ports on that device are often specified as a bitmap. After devices, the most important object is the port. This is illustrated by the fact that the OpenNSL Port API is the largest set of functions by far. The OpenNSL API uses small integers to refer to ports. These are generally the physical port numbers on the device. Thus, it is necessary to know the particulars of the device being updated to address the ports on that device.
OpenNSL software contains the files needed for development of switch applications: C header files, libraries and documentation.
Software Architecture
This section describes fundamental concepts needed for understanding the OpenNSL API calls. It describes the basic types and function calls for manipulating those types. Figure 1 is a block diagram representation of the various components of OpenNSL.
Figure 1
The following is a list of fundamental aspects of switching which are all managed by the OpenNSL API.
- Error Codes: With few exceptions, all OpenNSL routines return an integer indicating the success or error status of the call. All error codes (except OPENNSL_E_NONE) are negative.
- Initialization: The OpenNSL API provide the functions to attach the device and then to initialize the software resources necessary to control the device and to initialize the device itself. The order of these operations is critical.
- KNET: The Kernel Network (KNET) module provides a software connector that forwards packets to and from the native network interfaces of the operating system. The KNET module maps the packet streams from the network interfaces to OpenNSL transmit APIs. Similarly, the incoming packets from OpenNSL receive callback are mapped in to the network interfaces.
- Layer 2: Switch devices in the system generally inspect the Layer 2 header of a packet, possibly learn the source address and switch the packet based on the destination address. Managing the Layer 2 forwarding data base is an important part of the software.
- Layer 3: Some devices support examining deeper into the packet to determine the Layer 3 characteristics of the packet, updating the packet and forwarding the packet based on this information. Typically, software is responsible for the learning of Layer 3 routes, but there-after, hardware may be able to forward these packets without software intervention.
- Link Monitor: The OpenNSL API provides a mechanism to scan the ports, monitoring for link-up and link-down events. This is accomplished using a thread to constantly monitor the PHYs for link status, and then calling user-supplied callbacks.
- Packet transmit and receive: The OpenNSL packet transmit and receive APIs provides the ability to receive packets captured from data plane and to send packets to the data plane from the host CPU. Typical uses for these functions are to implement various networking control protocols or "slow path" session handling.
- Port Configuration: The port configuration API's provide control over a significant number of port attributes. The port attributes are typically controlled by using set or get API's.
- Statistics: The Statistics module allows for retrieval of common SNMP statistics for use with switch management and diagnostics software. Both 64-bit and 32-bit counters are supported. The statistics API uses an enumerated type indicating the type of statistics to retrieve.
- STG: Spanning tree groups are groups of VLANs. A port has a forwarding state for each spanning tree group and this is the state used for each VLAN in that group.
- Switch Control : Some operating modes within switching devices can be set a few ways, but are usually not changed after device initialization. These often are properties that do not fit well into other parts of the OpenNSL APIs. They have been collected into one set of control APIs.
- Trunk: Trunking, or link aggregation, is a mechanism that allows several ports to be bundled together to form a single logical group. This is useful when higher bandwidth or redundancy between Switches, or both, are required.
- VLAN: A virtual network to which ports may belong. Ports may maintain state which is VLAN specific. A port may belong to multiple VLANs.
- VSI: Virtual Switching Instance (VSI) is used in DNX devices to switch between logical interfaces. Each VSI has associated MAC table for forwarding decisions and MAC learning.