An open API service indexing awesome lists of open source software.

https://github.com/stratum/fabric-tna

The SD-Fabric data plane
https://github.com/stratum/fabric-tna

onos p4 sdfabric stratum upf

Last synced: 5 months ago
JSON representation

The SD-Fabric data plane

Awesome Lists containing this project

README

          

# Fabric-TNA

[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=postmerge-fabric-tna&subject=Fabric-tna)](https://jenkins.onosproject.org/view/fabric-tna/job/postmerge-fabric-tna/)
[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=postmerge-fabric-int-tna&subject=Fabric-int-tna)](https://jenkins.onosproject.org/view/fabric-tna/job/postmerge-fabric-int-tna/)
[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?Subject=postmerge&job=postmerge-fabric-upf-int-tna&subject=Fabric-upf-int-tna)](https://jenkins.onosproject.org/view/fabric-tna/job/postmerge-fabric-upf-int-tna/)
[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=postmerge-fabric-upf-tna&subject=Fabric-upf-tna)](https://jenkins.onosproject.org/view/fabric-tna/job/postmerge-fabric-upf-tna/)
[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=postmerge-fabric-v1model&subject=Fabric-v1model)](https://jenkins.onosproject.org/view/fabric-tna/job/postmerge-fabric-v1model/)
[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=postmerge-fabric-upf-v1model&subject=Fabric-upf-v1model)](https://jenkins.onosproject.org/view/fabric-tna/job/postmerge-fabric-upf-v1model/)
[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=postmerge-fabric-int-v1model&subject=Fabric-int-v1model)](https://jenkins.onosproject.org/view/fabric-tna/job/postmerge-fabric-int-v1model/)
[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=postmerge-fabric-upf-int-v1model&subject=Fabric-upf-int-v1model)](https://jenkins.onosproject.org/job/postmerge-fabric-upf-int-v1model/1/)

[![Build Status](https://jenkins.onosproject.org/buildStatus/icon?job=fabric-tna-linerate-tests&subject=Line-Rate+Tests)](https://jenkins.onosproject.org/job/fabric-tna-linerate-tests/)

`fabric-tna` is a P4 program that realizes the data plane of [SD-Fabric], an
SDN-enabled programmable network fabric tailored for 5G-connected edge clouds,
with a focus on enterprise and Industry 4.0 use cases.

`fabric-tna` is based on the Tofino Native Architecture (TNA), hence it can be
used to program any switch based on the Intel Tofino ASIC. The P4 program is
specifically designed to run on [Stratum]-enabled switches controlled by the
[ONOS] SDN controller.

`fabric-tna.p4` is not to be confused with [fabric.p4], an older P4 program
hosted in the ONOS repository originally designed to support [Trellis].
`fabric-tna.p4` follows a similar design to `fabric.p4`, but has evolved
significantly to provide more advanced capabilities for 4G/5G mobile user plane
function (UPF), In-band Network Telemetry (INT), slicing, and QoS.

For up-to-date documentation on the architecture, capabilities, and
instructions to deploy and use SD-Fabric, please refer to the official
documentation:

## 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.

### PTF Tests

`ptf/` contains an extensive suite of test cases for the P4 program, based on
the Packet Test Framework (PTF). These tests are used to validate the forwarding
behavior of the switch. We provide scripts and instructions to run tests on
multiple targets:

* Tofino-Model (ASIC emulator)
* HW switch
* BMv2 software switch

## 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 >= 2.5.8
* 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:

```bash
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 ``:

```bash
make
```

The available profiles are:

| Profile name | Description |
|------------------|--------------------------------------|
| `fabric` | Basic L2/L3 forwarding capabilities |
| `fabric-upf` | With 4G/5G mobile user plane support |
| `fabric-int` | With INT support |
| `fabric-upf-int` | WITH UPF and INT support |

To run PTF tests on Stratum using Tofino Model:

```bash
./ptf/run/tm/run
```

For more information about running PTF tests, check [ptf/README.md](ptf/README.md).

If you want to test the pipeline manually with an interactive P4Runtime shell:

```bash
./ptf/run/tm/p4rt-shell
```

This command will start Tofino Model with Stratum and a P4Runtime Shell attached
to it. For more information about using P4Runtime Shell, check
[p4lang/p4runtime-shell](https://github.com/p4lang/p4runtime-shell).

Also, check [p4rt_shell_snippets.md](p4rt_shell_snippets.md) for some examples
of how to program tables in fabric-tna.

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

```bash
make pipeconf
```

To learn more about pipeconfs, keep reading.

## Detailed steps to build the fabric-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 learn more about pipeconfs and how ONOS supports P4-programmable devices:

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

```bash
make build [PROFILES=...]
```

This command will build the `fabric-tna.p4` profiles specified in the `PROFILES` argument.

To build all profiles, leave `PROFILES` unset.

To build a subset of the available profiles separate them with spaces:
`PROFILES="fabric fabric-int"`

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/fabric-tna-.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:

Pre-built ONOS Docker images are available here:

For more information on how to get and run ONOS:

### 2 - Start Stratum on your switch

To run Stratum on a Tofino-based switch, please follow instructions in this document:

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

```text
-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:

```bash
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:

```text
New pipeconf registered: org.stratumproject.fabric.mavericks_sde_9_7_0 (fingerprint=...)
New pipeconf registered: org.stratumproject.fabric.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:

```text
onos> pipeconfs
```

### 4 - Connect ONOS to a Stratum switch

Activate the Barefoot drivers in ONOS:

```text
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:

```bash
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.

## Using SD-Fabric with Stratum+Tofino switches

Check the official SD-Fabric documentation here:

In the "Network Configuration" section:

## Support

To report issues when compiling `fabric-tna.p4` for Tofino (i.e., P4 compiler
errors), please contact Intel support.

To report any other kind of problem, feel free to open a GitHub Issue or reach
out to the project maintainers on the ONF Community Slack.

[ONOS]: https://opennetworking.org/onos/
[Stratum]: https://github.com/stratum/stratum
[Trellis]: https://www.opennetworking.org/trellis
[SD-Fabric]: https://opennetworking.org/sd-fabric/
[fabric.p4]: https://github.com/opennetworkinglab/onos/tree/master/pipelines/fabric/impl/src/main/resources