Skip to content

Commit

Permalink
moved actions outside control to macros (p4lang#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Calin Cascaval authored and hanw committed May 8, 2017
1 parent 6a3b14b commit d11a579
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
17 changes: 4 additions & 13 deletions p4include/p4d2model.p4
Original file line number Diff line number Diff line change
Expand Up @@ -176,22 +176,13 @@ extern digest<T> {
* Note: These actions assume that the parameters in the user-instantiated
* controls are named the same way as in the architecture definition
*/
action mark_for_drop() {
// output_meta.drop_flag = 1;
}
#define mark_for_drop() { standard_metadata.drop_bit = 1; }

action drop() {
mark_for_drop();
exit;
}
#define drop() { mark_for_drop(standard_metadata); exit; }

action resubmit() {
// output_meta.resubmit_flag = 1;
}
#define resubmit() { standard_metadata.resubmit_flag = 1; }

action clone_to_egress(cloneid_t clone_id) {
// output_meta.clone_id = clone_id;
}
#define clone_to_egress(clone_id) { standard_metadata.clone_id = clone_id; }

/***************************************************************************
***************** P A C K A G E C O M P O N E N T S ********************
Expand Down
8 changes: 2 additions & 6 deletions testdata/p4_16_samples/l3_switch-bmv2.p4
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ control MyIngress(
in ingress_input_t input_meta,
inout standard_metadata_t standard_metadata)
{
action drop() {
mark_to_drop();
exit;
}

action set_dst_info(mac_addr_t mac_da,
mac_addr_t mac_sa,
Expand All @@ -210,7 +206,7 @@ control MyIngress(
hdr.ethernet.srcAddr = meta.mac_sa;
hdr.ipv4.ttl = hdr.ipv4.ttl - 1;

standard_metadata.egress_spec = meta.egress_port;
standard_metadata.egress_port = meta.egress_port;
}

action send_arp_reply() {
Expand Down Expand Up @@ -286,7 +282,7 @@ control MyEgress(
inout my_metadata_t meta,
in egress_input_t input_meta,
inout standard_metadata_t standard_metadata) {
apply { }
apply { }
}

/*************************************************************************
Expand Down

0 comments on commit d11a579

Please sign in to comment.