forked from p4lang/p4c
-
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.
- Loading branch information
mbudiu-vmw
committed
Apr 26, 2017
1 parent
a6eaf28
commit 1c88f05
Showing
6 changed files
with
218 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct s1_t { | ||
bit<8> f8; | ||
} | ||
|
||
struct choices_t { | ||
s1_t entry0; | ||
s1_t entry1; | ||
s1_t entry2; | ||
s1_t entry3; | ||
} | ||
|
||
struct my_meta_t { | ||
s1_t entry; | ||
} | ||
|
||
struct parsed_packet_t { } | ||
|
||
parser parse(packet_in pk, out parsed_packet_t hdr, | ||
inout my_meta_t my_metadata, | ||
inout standard_metadata_t standard_metadata) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
extern s1_t choose_entry(in choices_t choices); | ||
|
||
control ingress (inout parsed_packet_t hdr, | ||
inout my_meta_t my_meta, | ||
inout standard_metadata_t standard_metadata) { | ||
action select_entry(choices_t choices) { | ||
my_meta.entry = choose_entry(choices); | ||
} | ||
table t { | ||
actions = { | ||
select_entry; NoAction; | ||
} | ||
const default_action = NoAction(); | ||
} | ||
|
||
apply { t.apply(); } | ||
} | ||
|
||
control egress(inout parsed_packet_t hdr, | ||
inout my_meta_t my_meta, | ||
inout standard_metadata_t standard_metadata) { | ||
apply { } | ||
} | ||
|
||
control deparser(packet_out b, in parsed_packet_t hdr) { | ||
apply { } | ||
} | ||
|
||
control verify_checksum(in parsed_packet_t hdr, | ||
inout my_meta_t my_meta) { | ||
apply { } | ||
} | ||
|
||
control compute_checksum(inout parsed_packet_t hdr, | ||
inout my_meta_t my_meta) { | ||
apply { } | ||
} | ||
|
||
V1Switch(parse(), verify_checksum(), ingress(), egress(), | ||
compute_checksum(), deparser()) main; |
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,67 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct s1_t { | ||
bit<8> f8; | ||
} | ||
|
||
struct choices_t { | ||
s1_t entry0; | ||
s1_t entry1; | ||
s1_t entry2; | ||
s1_t entry3; | ||
} | ||
|
||
struct my_meta_t { | ||
s1_t entry; | ||
} | ||
|
||
struct parsed_packet_t { | ||
} | ||
|
||
parser parse(packet_in pk, out parsed_packet_t hdr, inout my_meta_t my_metadata, inout standard_metadata_t standard_metadata) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
extern s1_t choose_entry(in choices_t choices); | ||
control ingress(inout parsed_packet_t hdr, inout my_meta_t my_meta, inout standard_metadata_t standard_metadata) { | ||
s1_t tmp; | ||
@name("select_entry") action select_entry_0(choices_t choices) { | ||
tmp = choose_entry(choices); | ||
my_meta.entry = tmp; | ||
} | ||
@name("t") table t_0 { | ||
actions = { | ||
select_entry_0(); | ||
NoAction(); | ||
} | ||
const default_action = NoAction(); | ||
} | ||
apply { | ||
t_0.apply(); | ||
} | ||
} | ||
|
||
control egress(inout parsed_packet_t hdr, inout my_meta_t my_meta, inout standard_metadata_t standard_metadata) { | ||
apply { | ||
} | ||
} | ||
|
||
control deparser(packet_out b, in parsed_packet_t hdr) { | ||
apply { | ||
} | ||
} | ||
|
||
control verify_checksum(in parsed_packet_t hdr, inout my_meta_t my_meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control compute_checksum(inout parsed_packet_t hdr, inout my_meta_t my_meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch<parsed_packet_t, my_meta_t>(parse(), verify_checksum(), ingress(), egress(), compute_checksum(), deparser()) main; |
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,65 @@ | ||
#include <core.p4> | ||
#include <v1model.p4> | ||
|
||
struct s1_t { | ||
bit<8> f8; | ||
} | ||
|
||
struct choices_t { | ||
s1_t entry0; | ||
s1_t entry1; | ||
s1_t entry2; | ||
s1_t entry3; | ||
} | ||
|
||
struct my_meta_t { | ||
s1_t entry; | ||
} | ||
|
||
struct parsed_packet_t { | ||
} | ||
|
||
parser parse(packet_in pk, out parsed_packet_t hdr, inout my_meta_t my_metadata, inout standard_metadata_t standard_metadata) { | ||
state start { | ||
transition accept; | ||
} | ||
} | ||
|
||
extern s1_t choose_entry(in choices_t choices); | ||
control ingress(inout parsed_packet_t hdr, inout my_meta_t my_meta, inout standard_metadata_t standard_metadata) { | ||
action select_entry(choices_t choices) { | ||
my_meta.entry = choose_entry(choices); | ||
} | ||
table t { | ||
actions = { | ||
select_entry; | ||
NoAction; | ||
} | ||
const default_action = NoAction(); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
control egress(inout parsed_packet_t hdr, inout my_meta_t my_meta, inout standard_metadata_t standard_metadata) { | ||
apply { | ||
} | ||
} | ||
|
||
control deparser(packet_out b, in parsed_packet_t hdr) { | ||
apply { | ||
} | ||
} | ||
|
||
control verify_checksum(in parsed_packet_t hdr, inout my_meta_t my_meta) { | ||
apply { | ||
} | ||
} | ||
|
||
control compute_checksum(inout parsed_packet_t hdr, inout my_meta_t my_meta) { | ||
apply { | ||
} | ||
} | ||
|
||
V1Switch(parse(), verify_checksum(), ingress(), egress(), compute_checksum(), deparser()) main; |
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,3 @@ | ||
../testdata/p4_16_errors/issue532.p4(35): error: choose_entry: functions or methods returning structures are not supported on this target | ||
my_meta.entry = choose_entry(choices); | ||
^^^^^^^^^^^^^^^^^^^^^ |