Skip to content

GitLab

  • Menu
项目 Groups 代码片段
    • 正在加载...
  • 帮助
    • 帮助
    • 支持
    • 社区论坛
    • 提交反馈
  • 登录/注册
  • P p4-learning
  • Project information
    • Project information
    • 动态
    • 标记
    • 成员
  • 仓库
    • 仓库
    • 文件
    • 提交
    • 分支
    • 标签
    • 贡献者
    • 分支图
    • 比较
  • 议题 0
    • 议题 0
    • 列表
    • 看板
    • 服务台
    • 里程碑
  • 合并请求 0
    • 合并请求 0
  • CI/CD
    • CI/CD
    • 流水线
    • 作业
    • 计划
  • Deployments
    • Deployments
    • 环境
    • 发布
  • Monitor
    • Monitor
    • 事件
  • 软件包与镜像库
    • 软件包与镜像库
    • 软件包注册表
    • Infrastructure Registry
  • 分析
    • 分析
    • CI/CD
    • 仓库
    • Value stream
  • Wiki
    • Wiki
  • 代码片段
    • 代码片段
  • 动态
  • 分支图
  • 创建新议题
  • 作业
  • 提交
  • 议题看板
收起侧边栏
  • p4git
  • p4-learning
  • Wiki
  • BMv2 Simple Switch

BMv2 Simple Switch · 变更

页面历史
Updated BMv2 Simple Switch (markdown) 编辑于 7月 24, 2021 作者: Jurij Nota's avatar Jurij Nota
Hide whitespace changes
Inline Side-by-side
Showing with 24 addition and 5 deletion
+24 -5
  • BMv2-Simple-Switch.md BMv2-Simple-Switch.md +24 -5
  • 未找到文件。
BMv2-Simple-Switch.md
查看页面@ 7919ba48
...@@ -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
......
克隆仓库

P4-Learning Documentation

  • BMv2 Simple Switch
  • Control Plane
  • Debugging and Troubleshooting

沪ICP备19002739号