Skip to content

This application allows ONOS to control the basic P4 pipeline, deployed for Tofino switch, via the ONOS application reactive forwarding and/or installation of custom flow rules via ONOS REST API .

Notifications You must be signed in to change notification settings

Dscano/Basic-tna

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic-TNA

basic-tna is a simple P4 program that realise the basic pipeline, SDN-enabled programmable network capable to provide a simple forwarding. More in details, this application allows ONOS to control a P4 pipeline, deployed for Tofino switch, via the ONOS application reactive forwarding and installation of custom flow rules via ONOS REST API .

basic-tna.p4 follows a similar design to basic.p4.

Disclaimer

The repository is inspired by SD-Fabric project and provides a simple forwarding pipelines. The goal is provide a full stack deployment (data plane + control pane) in order to help the beginner to work in the SDN and P4 environment.

Content

P4 Program

The directory p4src/tna contains the P4 program for the TNA architecture. p4src/v1model contains an equivalent version of the same program based on the V1Model architecture, to be used for development and testing together with the BMv2 software switch.

ONOS Pipeconf

src/ contains the Java implementation and tests for the ONOS pipeconf, which is essentially a set of drivers enabling ONOS to control different aspects of the switch pipeline defined by the P4 program.

Requirements

To build and test this project you will need the following software:

  • Barefoot SDE (a.k.a. Intel P4 Studio) = 9.7.0
  • ONOS = 3.0.0
  • Docker (to run the build scripts without worrying about dependencies)
  • cURL (to interact with the ONOS REST APIs)

Intel P4 Studio (SDE) Docker Image

To facilitate managing different versions of the Intel P4 Studio (SDE), the build scripts expect the Barefoot SDE to be provided as a Docker image. We do not provide such image, but one can be easily generated by:

  • executing the regular SDE install instructions inside a Dockerfile
  • making sure executables such as bf-p4c and tofino-model are on $PATH

Once you obtain such Docker image, set the following environment variables:

export SDE_VERSION=9.7.0
export SDE_DOCKER_IMG=my-docker-repo/bf-sde:9.7.0

Quick steps

To compile the P4 program with a given <profile>:

make basic

To build the ONOS pipeconf .oar package which includes the compiled P4 artifacts for the previously built profile(s):

make pipeconf

To learn more about pipeconfs, keep reading.

Detailed steps to build the basic-tna pipeconf

ONOS uses "pipeconfs" to deploy and manage a given P4 program on a device. Pipeconfs include mainly two things:

  1. the P4 compiled artifacts (e.g., tofino.bin, context.json, etc.) to deploy on devices.
  2. Java classes implementing ONOS driver behaviors to control capabilities of the particular P4 program.

Pipeconfs are distributed as ONOS applications, hence using the .oar packaging. The following steps provide instructions on how to generate an oar package that includes one or more profiles.

To build basic-tna.p4 using the Barefoot compiler and to create the pipeconf .oar package in one command:

make basic

The P4 compiler outputs to include in the .oar package will be placed under src/main/resources/p4c-out.

When done, the pipeconf .oar package can be found in target/basic-tna-<VERSION>.oar

Steps to use the fabric-tna pipeconf with ONOS

1 - Get and run ONOS

You can either build from sources or run one the released versions: https://wiki.onosproject.org/display/ONOS/Downloads

Pre-built ONOS Docker images are available here: https://hub.docker.com/r/onosproject/onos/tags

For more information on how to get and run ONOS: https://wiki.onosproject.org/display/ONOS/Guides

2 - Start Stratum on your switch

To run Stratum on a Tofino-based switch, please follow instructions in this document: https://github.com/stratum/stratum/blob/main/stratum/hal/bin/barefoot/README.run.md

Note that basic-tna uses the @p4runtime_translation annotation for certain P4 tables, you must enable P4Runtime translation with the following flags when starting Stratum:

-experimental_enable_p4runtime_translation
-incompatible_enable_bfrt_legacy_bytestring_responses

3 - Install pipeconf app in ONOS

To install the pipeconf app built in the previous step, assuming ONOS is running on the local machine:

make pipeconf-install ONOS_HOST=localhost

Use the ONOS_HOST argument to specify the hostname/IP address of the machine where ONOS is running.

This command is a wrapper to a curl command that uses the ONOS REST API to upload and activate the .oar package previously built.

You should see the ONOS log updating with messages notifying the registration of new pipeconfs in the system, depending on the profiles compiled before, and the Barefoot SDE version:

New pipeconf registered: org.stratumproject.basic.mavericks_sde_9_7_0 (fingerprint=...)
New pipeconf registered: org.stratumproject.basic.montara_sde_9_7_0 (fingerprint=...)
...

NOTE: it might take up to one minute for the pipeconfs to be registered.

To check all pipeconfs registered in the system, use the ONOS CLI:

onos> pipeconfs

4 - Connect ONOS to a Stratum switch

Activate the Barefoot drivers in ONOS:

onos> app activate org.onosproject.drivers.barefoot

This command will register a new driver named stratum-tofino. As the name suggests, this driver allows ONOS to control Tofino switches running Stratum.

For ONOS to be able to discover your switch, you need to push a JSON file, usually referred to as the "netcfg" file. We provide an example of such tofino-netcfg.json file in this repository. Make sure to modify the following values:

  • managementAddress is expected to contain a valid URI with host and port of the Stratum gRPC server running on the switch;
  • The device_id URI query parameter is the P4Runtime-internal device_id, also known as the Stratum "Node ID". Usually, you can leave this value set to 1;
  • Use the pipeconf field to specify which pipeconf/fabric profile to deploy on the switch.

Push the tofino-netcfg.json to ONOS using the command:

make netcfg ONOS_HOST=localhost

Like before, this command is a wrapper to a curl command that uses the ONOS REST API to push the tofino-netcfg.json file.

Check the ONOS log for potential errors.

Examples

The video shows how to install the basic-tna application and the devices and links discovery set_up_and_discovery

The video presents the Tofino+Stratum device and the flow rules installed, the forwarding flow rules contains all the match criteria avaiable in table0. device

Acknowledge

Check the official SD-Fabric project here: https://docs.sd-fabric.org

Check the official Stratum project here: https://github.com/stratum/stratum

About

This application allows ONOS to control the basic P4 pipeline, deployed for Tofino switch, via the ONOS application reactive forwarding and/or installation of custom flow rules via ONOS REST API .

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published