-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fixes] updates based on tesing on Oxide p4 programs
- Loading branch information
1 parent
12f4d2b
commit 91478f6
Showing
20 changed files
with
19,328 additions
and
12,606 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
# tree-sitter-p4 | ||
# tree-sitter-p4: P4 grammar for tree-sitter | ||
|
||
P4 grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter). | ||
|
||
## Setup | ||
|
||
To build the parser, you need to have `tree-sitter` installed. You can install | ||
it using most OS package managers, from source, or through `npm`: | ||
|
||
```sh | ||
npm install tree-sitter-cli | ||
``` | ||
|
||
or with `cargo`: | ||
|
||
```sh | ||
cargo install tree-sitter-cli | ||
``` | ||
|
||
## Contributing | ||
|
||
This project is still in its early stages, so there are many things that can be | ||
improved, as we aim toward capturing more of the [`P4_16` specification][p4-16-spec]. | ||
|
||
To contribute, just open a pull request! | ||
|
||
[p4-16-spec]: https://p4.org/p4-spec/docs/P4-16-v1.0.0-spec.html |
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,13 @@ | ||
action multicast_inbound() { | ||
hdr.sidecar.sc_code = 4; | ||
hdr.sidecar.sc_ingress = (bit<16>) meta.in_port; | ||
hdr.sidecar.sc_egress = (bit<16>) ig_tm_md.ucast_egress_port; | ||
hdr.sidecar.sc_ether_type = hdr.ethernet.ether_type; | ||
hdr.sidecar.sc_payload = 0; | ||
hdr.sidecar.setValid(); | ||
hdr.ethernet.ether_type = ETHERTYPE_SIDECAR; | ||
meta.routed = false; | ||
meta.service_routed = true; | ||
ig_tm_md.ucast_egress_port = USER_SPACE_SERVICE_PORT; | ||
meta.multicast = true; | ||
} |
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 @@ | ||
control Services( | ||
inout sidecar_headers_t hdr, | ||
inout sidecar_ingress_meta_t meta, | ||
inout ingress_intrinsic_metadata_for_deparser_t ig_dprsr_md, | ||
inout ingress_intrinsic_metadata_for_tm_t ig_tm_md) | ||
{ | ||
Counter<bit<32>, bit<8>>(SVC_COUNTER_MAX, CounterType_t.PACKETS) service_ctr; | ||
} |
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,72 @@ | ||
#include <core.p4> | ||
#include <softnpu.p4> | ||
|
||
SoftNPU( | ||
parse(), | ||
ingress(), | ||
egress() | ||
) main; | ||
|
||
struct headers_t { } | ||
|
||
parser parse( | ||
packet_in pkt, | ||
out headers_t headers, | ||
inout ingress_metadata_t ingress, | ||
){ | ||
state start { transition accept; } | ||
} | ||
|
||
control resolver( | ||
in bit<32> x, | ||
out bool resolved, | ||
) { | ||
action resolve() { | ||
resolved = true; | ||
} | ||
table arp { | ||
key = { x: exact; } | ||
actions = { resolve; } | ||
default_action = NoAction; | ||
} | ||
apply { arp.apply(); } | ||
} | ||
|
||
control foo() { | ||
resolver() resolver; | ||
apply { | ||
//bool resolved; | ||
resolver.apply(32w47, resolved); | ||
} | ||
} | ||
|
||
control bar() { | ||
// resolver() resolver; | ||
// resolver() taco; | ||
// apply { | ||
// bool resolved; | ||
// resolver.apply(32w1701, resolved); | ||
// } | ||
} | ||
|
||
control ingress( | ||
inout headers_t hdr, | ||
inout ingress_metadata_t ingress, | ||
inout egress_metadata_t egress, | ||
) { | ||
foo() taco; | ||
bar() pizza; | ||
|
||
apply { | ||
taco.apply(); | ||
pizza.apply(); | ||
} | ||
} | ||
|
||
control egress( | ||
inout headers_t hdr, | ||
inout ingress_metadata_t ingress, | ||
inout egress_metadata_t egress, | ||
) { | ||
|
||
} |
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,14 @@ | ||
/* | ||
* This is core.p4 | ||
*/ | ||
extern packet_in { | ||
void extract<T>(out T headerLvalue); | ||
void extract<T>(out T variableSizeHeader, in bit<32> varFieldSizeBits); | ||
T lookahead<T>(); | ||
bit<32> length(); // This method may be unavailable in some architectures | ||
void advance(bit<32> bits); | ||
} | ||
|
||
extern packet_out { | ||
void emit<T>(in T hdr); | ||
} |
Oops, something went wrong.