... | @@ -4,6 +4,22 @@ |
... | @@ -4,6 +4,22 @@ |
|
|
|
|
|
The *Simple Switch* target is the de-facto architecture used in P4 development. The *Simple Switch* architecture is an implementation of the *abstract switch model* presented in the [*P4-14* Specification](https://p4.org/p4-spec/p4-14/v1.1.0/tex/p4.pdf) (the first version of the P4 language). The *Simple Switch* target has been implemented using the [*Behavioral Model* (BMv2)](https://github.com/p4lang/behavioral-model) library, which is a framework that allows developers to implement their own software P4 targets.
|
|
The *Simple Switch* target is the de-facto architecture used in P4 development. The *Simple Switch* architecture is an implementation of the *abstract switch model* presented in the [*P4-14* Specification](https://p4.org/p4-spec/p4-14/v1.1.0/tex/p4.pdf) (the first version of the P4 language). The *Simple Switch* target has been implemented using the [*Behavioral Model* (BMv2)](https://github.com/p4lang/behavioral-model) library, which is a framework that allows developers to implement their own software P4 targets.
|
|
|
|
|
|
|
|
The BMv2 repository implements two different versions of the *Simple Switch* that have different control plane interfaces.
|
|
|
|
|
|
|
|
| Target | Control Plane |
|
|
|
|
|:--------------------------------------------------------------------------------------------------------|:----------------------|
|
|
|
|
| [`simple_switch`](https://github.com/p4lang/behavioral-model/tree/main/targets/simple_switch) | `Thrift` |
|
|
|
|
| [`simple_switch_grpc`](https://github.com/p4lang/behavioral-model/tree/main/targets/simple_switch_grpc) | `P4Runtime`, `Thrift` |
|
|
|
|
|
|
|
|
The targets, however, still keep the **same** data plane configuration options using P4. Therefore, the instruction given in this document, which are mostly related to data plane, are valid for both. For what concerns the control plane, the following tables shows different methods to configure the *Simple Switch*.
|
|
|
|
|
|
|
|
| Control Plane | Methods |
|
|
|
|
|:--------------|:--------------------------------------------|
|
|
|
|
| `Thrift` | [`SimpleSwitchThriftAPI`](https://github.com/nsg-ethz/p4-utils/blob/junota/p4utils/utils/sswitch_thrift_API.py), `simple_switch_CLI`|
|
|
|
|
| `P4Runtime` | [`SimpleSwitchP4RuntimeAPI`](https://github.com/nsg-ethz/p4-utils/blob/junota/p4utils/utils/sswitch_p4runtime_API.py)|
|
|
|
|
|
|
|
|
Further details are available in the [control plane documentation page](./Control-Plane).
|
|
|
|
|
|
In the second version of the language (*P4-16*, the one we use in this repository), several backwards-incompatible changes were made to the language and syntax. In particular, a large number of language features were eliminated from the language and moved into libraries including counters, checksum units, meters, etc. And thus, the core of the *P4-16* language has been made very simple and advanced features that are unique to a target architecture are now described in the so called *architecture libraries*. The *v1model* architecture (the one we import at the beginning of every program) is the architecture library for the *Simple Switch* target. It includes the declaration of all the standard metadata and intrinsic metadata fields, extern functions, and switch architecture (or pipeline) package description.
|
|
In the second version of the language (*P4-16*, the one we use in this repository), several backwards-incompatible changes were made to the language and syntax. In particular, a large number of language features were eliminated from the language and moved into libraries including counters, checksum units, meters, etc. And thus, the core of the *P4-16* language has been made very simple and advanced features that are unique to a target architecture are now described in the so called *architecture libraries*. The *v1model* architecture (the one we import at the beginning of every program) is the architecture library for the *Simple Switch* target. It includes the declaration of all the standard metadata and intrinsic metadata fields, extern functions, and switch architecture (or pipeline) package description.
|
|
|
|
|
|
The *P4_16* language also now has a *Portable Switch Architecture* (PSA) defined in [its own specification](https://p4.org/p4-spec/docs/PSA-v1.1.0.pdf). As of September 2018, a partial implementation of the PSA architecture has been done, but it is not yet complete. It will be implemented in a separate executable program named `psa_switch`, different from the `simple_switch` program described here.
|
|
The *P4_16* language also now has a *Portable Switch Architecture* (PSA) defined in [its own specification](https://p4.org/p4-spec/docs/PSA-v1.1.0.pdf). As of September 2018, a partial implementation of the PSA architecture has been done, but it is not yet complete. It will be implemented in a separate executable program named `psa_switch`, different from the `simple_switch` program described here.
|
... | @@ -138,9 +154,12 @@ In this section we explain how to use some of the most advanced features the *Si |
... | @@ -138,9 +154,12 @@ In this section we explain how to use some of the most advanced features the *Si |
|
|
|
|
|
### Creating Multicast Groups
|
|
### Creating Multicast Groups
|
|
|
|
|
|
In order to use the packet replication engine of the *Simple Switch* several things need to be done both in the P4 program and using the runtime interface or CLI.
|
|
In order to use the packet replication engine of the *Simple Switch* several things need to be done both in the P4 program and using the runtime interfaces (`SimpleSwitchThriftAPI`, `SimpleSwitchP4RuntimeAPI`) or `simple_switch_CLI`.
|
|
|
|
|
|
|
|
> **Notice**
|
|
|
|
> `simple_switch` cannot be controlled using `SimpleSwitchP4RuntimeAPI`.
|
|
|
|
|
|
First of all you need to create multicast groups, multicast nodes and associate them to ports and groups. That can be done using the `simple_switch_CLI` or the `SimpleSwitchThriftAPI` provided by *P4-Utils*:
|
|
First of all you need to create multicast groups, multicast nodes and associate them to ports and groups. That can be done using the `simple_switch_CLI` or the APIs provided by *P4-Utils*:
|
|
|
|
|
|
1. Create a multicast group:
|
|
1. Create a multicast group:
|
|
```
|
|
```
|
... | @@ -160,7 +179,7 @@ First of all you need to create multicast groups, multicast nodes and associate |
... | @@ -160,7 +179,7 @@ First of all you need to create multicast groups, multicast nodes and associate |
|
mc_node_associate <mcast_grp_id> <node_handle_id>
|
|
mc_node_associate <mcast_grp_id> <node_handle_id>
|
|
```
|
|
```
|
|
|
|
|
|
In the following example we will associate port `1`,`2` and `3` to the same multicast group using the `CLI` (translation to `SimpleSwitchThriftAPI` is one to one):
|
|
In the following example we will associate port `1`,`2` and `3` to the same multicast group using the `simple_switch_CLI` (translation to the one of the APIs is straightforward):
|
|
|
|
|
|
```
|
|
```
|
|
mc_mgrp_create 1
|
|
mc_mgrp_create 1
|
... | @@ -197,7 +216,7 @@ The *Simple Switch* provides two `extern` functions that can be used to clone pa |
... | @@ -197,7 +216,7 @@ The *Simple Switch* provides two `extern` functions that can be used to clone pa |
|
|
|
|
|
1. The first parameter in both externs is the type, *Simple Switch* allows two types `CloneType.I2E`, and `CloneType.E2E`. The first type can be used to send a copy of the original packet to the egress pipeline, the later sends a copy of the egress packet to the buffer mechanism.
|
|
1. The first parameter in both externs is the type, *Simple Switch* allows two types `CloneType.I2E`, and `CloneType.E2E`. The first type can be used to send a copy of the original packet to the egress pipeline, the later sends a copy of the egress packet to the buffer mechanism.
|
|
|
|
|
|
2. The second parameter is the `*mirror id* or *session id*. The mirroring ID is used by the switch to know to which port the packet should be cloned to. This mapping needs to be configured using the control plane API or CLI by doing the following:
|
|
2. The second parameter is the `*mirror id* or *session id*. The mirroring ID is used by the switch to know to which port the packet should be cloned to. This mapping needs to be configured using the control plane APIs or client by doing the following:
|
|
|
|
|
|
```
|
|
```
|
|
mirroring_add <session> <output_port>
|
|
mirroring_add <session> <output_port>
|
... | @@ -208,7 +227,7 @@ The *Simple Switch* provides two `extern` functions that can be used to clone pa |
... | @@ -208,7 +227,7 @@ The *Simple Switch* provides two `extern` functions that can be used to clone pa |
|
|
|
|
|
For example, lets say we want to send a copy of every packet to a controller that is listening at port number `7`, to do what we would:
|
|
For example, lets say we want to send a copy of every packet to a controller that is listening at port number `7`, to do what we would:
|
|
|
|
|
|
1. Add mirroring session using the CLI or API:
|
|
1. Add mirroring session using the client or APIs:
|
|
|
|
|
|
```
|
|
```
|
|
mirroring_add 100 7
|
|
mirroring_add 100 7
|
... | | ... | |