clean-up trailing whitespace (#453)
These changes have been mostly auto-generated with: find . -type f -print0 | xargs -0 perl -pi -e 's/ +$//' Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
committed by
GitHub
parent
071b89ad30
commit
50f397b249
@@ -23,7 +23,7 @@ switch in Mininet to test its behavior.
|
||||
```
|
||||
This will:
|
||||
* compile `calc.p4`, and
|
||||
|
||||
|
||||
* start a Mininet instance with one switches (`s1`) connected to
|
||||
two hosts (`h1`, `h2`).
|
||||
* The hosts are assigned IPs of `10.0.1.1` and `10.0.1.2`.
|
||||
@@ -33,8 +33,8 @@ you to test your calculator. You can run the driver program directly
|
||||
from the Mininet command prompt:
|
||||
|
||||
```
|
||||
mininet> h1 python calc.py
|
||||
>
|
||||
mininet> h1 python calc.py
|
||||
>
|
||||
```
|
||||
|
||||
3. The driver program will provide a new prompt, at which you can type
|
||||
@@ -70,7 +70,7 @@ We will use the following header format:
|
||||
+----------------+----------------+----------------+---------------+
|
||||
| Result |
|
||||
+----------------+----------------+----------------+---------------+
|
||||
|
||||
|
||||
|
||||
- P is an ASCII Letter 'P' (0x50)
|
||||
- 4 is an ASCII Letter '4' (0x34)
|
||||
@@ -81,7 +81,7 @@ We will use the following header format:
|
||||
- '&' (0x26) Result = OperandA & OperandB
|
||||
- '|' (0x7c) Result = OperandA | OperandB
|
||||
- '^' (0x5e) Result = OperandA ^ OperandB
|
||||
|
||||
|
||||
|
||||
We will assume that the calculator header is carried over Ethernet,
|
||||
and we will use the Ethernet type 0x1234 to indicate the presence of
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
* '|' (0x7c) Result = OperandA | OperandB
|
||||
* '^' (0x5e) Result = OperandA ^ OperandB
|
||||
*
|
||||
* The device receives a packet, performs the requested operation, fills in the
|
||||
* result and sends the packet back out of the same port it came in on, while
|
||||
* The device receives a packet, performs the requested operation, fills in the
|
||||
* result and sends the packet back out of the same port it came in on, while
|
||||
* swapping the source and destination addresses.
|
||||
*
|
||||
* If an unknown operation is specified or the header is not valid, the packet
|
||||
* is dropped
|
||||
* is dropped
|
||||
*/
|
||||
|
||||
#include <core.p4>
|
||||
@@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Standard Ethernet header
|
||||
* Standard Ethernet header
|
||||
*/
|
||||
header ethernet_t {
|
||||
bit<48> dstAddr;
|
||||
@@ -54,7 +54,7 @@ header ethernet_t {
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a custom protocol header for the calculator. We'll use
|
||||
* This is a custom protocol header for the calculator. We'll use
|
||||
* etherType 0x1234 for it (see parser)
|
||||
*/
|
||||
const bit<16> P4CALC_ETYPE = 0x1234;
|
||||
@@ -86,12 +86,12 @@ struct headers {
|
||||
}
|
||||
|
||||
/*
|
||||
* All metadata, globally used in the program, also needs to be assembled
|
||||
* into a single struct. As in the case of the headers, we only need to
|
||||
* All metadata, globally used in the program, also needs to be assembled
|
||||
* into a single struct. As in the case of the headers, we only need to
|
||||
* declare the type, but there is no need to instantiate it,
|
||||
* because it is done "by the architecture", i.e. outside of P4 functions
|
||||
*/
|
||||
|
||||
|
||||
struct metadata {
|
||||
/* In our case it is empty */
|
||||
}
|
||||
@@ -102,7 +102,7 @@ struct metadata {
|
||||
parser MyParser(packet_in packet,
|
||||
out headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
state start {
|
||||
packet.extract(hdr.ethernet);
|
||||
transition select(hdr.ethernet.etherType) {
|
||||
@@ -110,10 +110,10 @@ parser MyParser(packet_in packet,
|
||||
default : accept;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
state check_p4calc {
|
||||
/* TODO: just uncomment the following parse block */
|
||||
/*
|
||||
/*
|
||||
transition select(packet.lookahead<p4calc_t>().p,
|
||||
packet.lookahead<p4calc_t>().four,
|
||||
packet.lookahead<p4calc_t>().ver) {
|
||||
@@ -122,7 +122,7 @@ parser MyParser(packet_in packet,
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
state parse_p4calc {
|
||||
packet.extract(hdr.p4calc);
|
||||
transition accept;
|
||||
@@ -151,21 +151,21 @@ control MyIngress(inout headers hdr,
|
||||
* - Send the packet back to the port it came from
|
||||
by saving standard_metadata.ingress_port into
|
||||
standard_metadata.egress_spec
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
action operation_add() {
|
||||
/* TODO call send_back with operand_a + operand_b */
|
||||
}
|
||||
|
||||
|
||||
action operation_sub() {
|
||||
/* TODO call send_back with operand_a - operand_b */
|
||||
}
|
||||
|
||||
|
||||
action operation_and() {
|
||||
/* TODO call send_back with operand_a & operand_b */
|
||||
}
|
||||
|
||||
|
||||
action operation_or() {
|
||||
/* TODO call send_back with operand_a | operand_b */
|
||||
}
|
||||
@@ -177,7 +177,7 @@ control MyIngress(inout headers hdr,
|
||||
action operation_drop() {
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
|
||||
table calculate {
|
||||
key = {
|
||||
hdr.p4calc.op : exact;
|
||||
@@ -199,7 +199,7 @@ control MyIngress(inout headers hdr,
|
||||
P4CALC_CARET: operation_xor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
apply {
|
||||
if (hdr.p4calc.isValid()) {
|
||||
calculate.apply();
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
* '|' (0x7c) Result = OperandA | OperandB
|
||||
* '^' (0x5e) Result = OperandA ^ OperandB
|
||||
*
|
||||
* The device receives a packet, performs the requested operation, fills in the
|
||||
* result and sends the packet back out of the same port it came in on, while
|
||||
* The device receives a packet, performs the requested operation, fills in the
|
||||
* result and sends the packet back out of the same port it came in on, while
|
||||
* swapping the source and destination addresses.
|
||||
*
|
||||
* If an unknown operation is specified or the header is not valid, the packet
|
||||
* is dropped
|
||||
* is dropped
|
||||
*/
|
||||
|
||||
#include <core.p4>
|
||||
@@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Standard ethernet header
|
||||
* Standard ethernet header
|
||||
*/
|
||||
header ethernet_t {
|
||||
bit<48> dstAddr;
|
||||
@@ -54,7 +54,7 @@ header ethernet_t {
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a custom protocol header for the calculator. We'll use
|
||||
* This is a custom protocol header for the calculator. We'll use
|
||||
* ethertype 0x1234 for is (see parser)
|
||||
*/
|
||||
const bit<16> P4CALC_ETYPE = 0x1234;
|
||||
@@ -88,12 +88,12 @@ struct headers {
|
||||
}
|
||||
|
||||
/*
|
||||
* All metadata, globally used in the program, also needs to be assembed
|
||||
* into a single struct. As in the case of the headers, we only need to
|
||||
* All metadata, globally used in the program, also needs to be assembed
|
||||
* into a single struct. As in the case of the headers, we only need to
|
||||
* declare the type, but there is no need to instantiate it,
|
||||
* because it is done "by the architecture", i.e. outside of P4 functions
|
||||
*/
|
||||
|
||||
|
||||
struct metadata {
|
||||
/* In our case it is empty */
|
||||
}
|
||||
@@ -113,7 +113,7 @@ parser MyParser(packet_in packet,
|
||||
default : accept;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
state check_p4calc {
|
||||
transition select(packet.lookahead<p4calc_t>().p,
|
||||
packet.lookahead<p4calc_t>().four,
|
||||
@@ -122,7 +122,7 @@ parser MyParser(packet_in packet,
|
||||
default : accept;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
state parse_p4calc {
|
||||
packet.extract(hdr.p4calc);
|
||||
transition accept;
|
||||
@@ -143,34 +143,34 @@ control MyVerifyChecksum(inout headers hdr,
|
||||
control MyIngress(inout headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
|
||||
|
||||
action send_back(bit<32> result) {
|
||||
bit<48> tmp;
|
||||
|
||||
/* Put the result back in */
|
||||
hdr.p4calc.res = result;
|
||||
|
||||
|
||||
/* Swap the MAC addresses */
|
||||
tmp = hdr.ethernet.dstAddr;
|
||||
hdr.ethernet.dstAddr = hdr.ethernet.srcAddr;
|
||||
hdr.ethernet.srcAddr = tmp;
|
||||
|
||||
|
||||
/* Send the packet back to the port it came from */
|
||||
standard_metadata.egress_spec = standard_metadata.ingress_port;
|
||||
}
|
||||
|
||||
|
||||
action operation_add() {
|
||||
send_back(hdr.p4calc.operand_a + hdr.p4calc.operand_b);
|
||||
}
|
||||
|
||||
|
||||
action operation_sub() {
|
||||
send_back(hdr.p4calc.operand_a - hdr.p4calc.operand_b);
|
||||
}
|
||||
|
||||
|
||||
action operation_and() {
|
||||
send_back(hdr.p4calc.operand_a & hdr.p4calc.operand_b);
|
||||
}
|
||||
|
||||
|
||||
action operation_or() {
|
||||
send_back(hdr.p4calc.operand_a | hdr.p4calc.operand_b);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ control MyIngress(inout headers hdr,
|
||||
action operation_drop() {
|
||||
mark_to_drop(standard_metadata);
|
||||
}
|
||||
|
||||
|
||||
table calculate {
|
||||
key = {
|
||||
hdr.p4calc.op : exact;
|
||||
@@ -205,7 +205,7 @@ control MyIngress(inout headers hdr,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
apply {
|
||||
if (hdr.p4calc.isValid()) {
|
||||
calculate.apply();
|
||||
|
||||
Reference in New Issue
Block a user