In this tutorial, you will learn how to set up a P4Runtime-enabled Mellanox Spectrum switch, using the ONOS SDN controller. The following set of instructions have been tested using the ONOS fabric.p4 topology.
Requirements
- 1 or more Spectrum DVS based switches with the following minimum versions:
- 4.9.30-OpenNetworkLinux
- SX-SDK Version: 4_2_7000X019
- SX-API Version: 1.0.0
- SXD Version: 1.00
- Firmware Version of Device #1: 13.1600.156
- Custom P4-Runtime gRPC server
- 1 server with the ONOS release 1.13 installed:
Prepare the switch
With the SDK and all necessary MST tools installed the switch process can be started.
spectrum-switch> /usr/bin/dvs_start.sh spectrum-switch> /usr/local/bin/mlnx_grpc_server
Alternatively, you may install the provided init.d scripts that perform the above commands on reboot. Currently, the mlnx_grpc_server starts on the switch with the fabric.P4 program deployed. The program is configured later by ONOS using P4Runtime.
Understanding the pipeconf for the fabric.P4 program
In ONOS the term pipeconf (short of pipeline configuration) is used to describe the ensemble of P4 compiler artifacts and ONOS driver for a specific P4 program. A pipeconf is the entity that allows ONOS to deploy and control a given P4 program. A pipeconf is defined as an ONOS application that can be loaded at runtime. Currently the only pipeline supported for Spectrum is fabric.p4, although support for other pipelines will be forethcoming. You can see the ONOS repository for the fabric.p4 pipeline description. It provides basic MPLS based forwarding capabilities along with packet-in/out support and counters. Among others, this pipeconf defines two important classes, an interpreter implementation, and a pipeconf loader. The fabric pipeline can be found in github here.
Interpreter
The interpreter is what enables ONOS to understand the specific constructs of your P4 Program. For example, the Interpreter enables the translation from ONOS traffic treatments to P4-defined actions.
The interpreter implementation for the fabric pipeconf can be found here.
Pipeconf loader
This class is usually defined as an OSGi runtime component and is used to register the pipeconf at runtime. As part of this operation, this class is responsible for putting together all the pieces of a pipeconf, such as:
- P4Info for your program.
- any binary or target specific configuration files
Binaries and target configurations are generated with the Mellanox P4C backend compiler, which is not open-source. For this reason, ONOS provides the compiler output of the fabric P4 program for BMv2 (generated using the publicly available p4c compiler), but cannot provide the mlnx_grpc_server binary and configuration files in the ONOS repository. For more information on how to obtain the mlnx_grpc_server binary, please reach out to Mellanox.
Looking at the pipeconf loader implementation, you can see we can also add driver behaviors specific to that P4 program/pipeline, such as the Pipeliner and the PortStatisticsDiscovery. We also need to set a pipeconf ID, which has to be globally unique as it will be used to refer to that pipeconf in the netcfg JSON later.
Walkthrough
Moving to the ONOS controller on the server, assuming you downloaded it and placed your pipeconf in it.
Run ONOS
$ buck run onos-local -- clean debug
It's worth noting that this start ONOS in a single instance cluster. The command also build ONOS and purges any previous state. The debug option offers the possibility to attach the debugger on port 5005.
Login into the ONOS CLI
Having started ONOS we need to login in its CLI.
onos localhost
Start the Mellanox drivers
onos> app activate org.onosproject.drivers.mellanox
This command brings in all the needed applications to interact with the Spectrum-based switch. If running another switch in the topology (e.g. bmv2 as a leaf), also activate it now.
Load the pipeconf
onos> app activate org.onosproject.pipelines.fabric onos> app activate lldpprovider hostprovider
Verify the active applications
onos> apps -s -a
Verify that these apps at least are active in your ONOS environment:
org.onosproject.generaldeviceprovider (General Device Provider)
org.onosproject.drivers (Default Drivers)
org.onosproject.protocols.grpc (gRPC Protocol Subsystem)
org.onosproject.protocols.p4runtime (P4Runtime Protocol Subsystem)
org.onosproject.p4runtime (P4Runtime Provider)
org.onosproject.drivers.p4runtime (P4Runtime Drivers)
org.onosproject.drivers.mellanox (Mellanox Drivers)
Build and push a configuration json
Having all the needed components in ONOS in place we can now tell ONOS about the device(s) and let the interaction begin.
First we need to create a .json file containing all the needed information such as IP/port of the P4Runtime server running on the device, its data plane ports and the pipeconf we want to deploy.
{ "devices": { "device:mellanox:spine1": { "generalprovider": { "p4runtime": { "ip": "10.209.80.43", "port": 50051, "deviceKeyId": "p4runtime:device:mellanox:spine1", "deviceId": 0 } }, "piPipeconf": { "piPipeconfId": "org.onosproject.pipelines.fabric" }, "ports": { "2/0": { "name": "2/0 VM5", "speed": 100000, "enabled": true, "number": 2, "removed": false, "type": "copper" }, "3/0": { "name": "3/0 VM6", "speed": 100000, "enabled": true, "number": 3, "removed": false, "type": "copper" }, "10/0": { "name": "10/0 VM7", "speed": 100000, "enabled": true, "number": 10, "removed": false, "type": "copper" } }, "basic": { "driver": "mellanox", "name": "spine1" } } } }
In this example, we assumed the device has been configured with 3 data plane ports, for each port the "number" value corresponds to the label port value on the Mellanox Spectrum switch (see section below). The port number by default for the gRPC/P4Runtime server is 50051, so unless you made any changes to that leave it as is.
Upload the configuration you just wrote to the instance of ONOS you are running:
<your_machine>~$ onos-netcfg localhost <path_to_your_json_configuration_file>
Check the ONOS log for possible errors.
To check if the device, links and interfaces have been discovered by ONOS:
onos> devices onos> links onos> interfaces
Configure ports on the device.
The last step to perform is to configure the ports on the switch. This needs to be done after having pushed the pipeline config, hence after having pushed the netcfg JSON to ONOS.
spectrum-switch> /usr/bin/sx_api_port_speed_set_100G.py spectrum-switch> /usr/bin/sx_api_ports_dump.py
You should see that the connected label ports are plugged in, administratively and operationally up.
Use
At this point if everything went well you should be able to push flow rules defined with PiCriterion and PiInstruction according to the fabric.P4 program deployed on the device.
Simulation using Mininet and BMV2
You can simulate a fabric topology using a physical Spectrum switch and virtial software switches (BMV2 under mininet).
Instructions: TBD