-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
351 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright 2013-present Barefoot Networks, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
header_type data_t { | ||
fields { | ||
f1 : 32; | ||
f2 : 32; | ||
h1 : 16; | ||
b1 : 8; | ||
b2 : 8; | ||
} | ||
} | ||
header data_t data; | ||
|
||
parser start { | ||
extract(data); | ||
return ingress; | ||
} | ||
|
||
action noop() { } | ||
action setb1(val, port) { | ||
modify_field(data.b1, val); | ||
modify_field(standard_metadata.egress_spec, port); | ||
} | ||
|
||
table test1 { | ||
reads { | ||
data.f1 mask 0xff00ff : exact; | ||
} | ||
actions { | ||
setb1; | ||
noop; | ||
} | ||
} | ||
|
||
control ingress { | ||
apply(test1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
add test1 data.f1:0x010001 setb1(val:0x7f, port:2) | ||
add test1 data.f1:0x020002 setb1(val:7, port:3) | ||
|
||
expect 2 01010101 ******** **** 7f 66 | ||
packet 0 01010101 00000202 0303 55 66 77 88 | ||
expect 3 02020202 ******** **** 07 66 | ||
packet 2 02020202 00000303 0404 55 66 77 88 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
header data_t { | ||
bit<32> f1; | ||
bit<32> f2; | ||
bit<16> h1; | ||
bit<8> b1; | ||
bit<8> b2; | ||
} | ||
|
||
struct metadata { | ||
} | ||
|
||
struct headers { | ||
@name("data") | ||
data_t data; | ||
} | ||
|
||
parser ParserImpl(packet_in packet, out headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { | ||
@name("start") state start { | ||
packet.extract<data_t>(hdr.data); | ||
transition accept; | ||
} | ||
} | ||
|
||
control ingress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { | ||
@name("setb1") action setb1(bit<8> val, bit<9> port) { | ||
hdr.data.b1 = val; | ||
standard_metadata.egress_spec = port; | ||
} | ||
@name("noop") action noop() { | ||
} | ||
@name("test1") table test1 { | ||
actions = { | ||
setb1(); | ||
noop(); | ||
@default_only NoAction(); | ||
} | ||
key = { | ||
hdr.data.f1 & 32w0xff00ff: exact @name("hdr.data.f1") ; | ||
} | ||
default_action = NoAction(); | ||
} | ||
apply { | ||
test1.apply(); | ||
} | ||
} | ||
|
||
control egress(inout headers hdr, inout metadata meta, inout standard_metadata_t standard_metadata) { | ||
apply { | ||
} | ||
} | ||
|
||
control DeparserImpl(packet_out packet, in headers hdr) { | ||
apply { | ||
packet.emit<data_t>(hdr.data); | ||
} | ||
} | ||
|
||
control verifyChecksum(in headers hdr, inout metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control computeChecksum(inout headers hdr, inout metadata meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<headers, metadata>(ParserImpl(), verifyChecksum(), ingress(), egress(), computeChecksum(), DeparserImpl()) main; |
Oops, something went wrong.