[P4-dev] Is it possible to transfer value from packet fields to action?

LJ Wobker ljw at barefootnetworks.com
Mon Jul 20 21:45:05 EDT 2015


Archie-



When you define the action you give it the parameter list.  Just for an
example,  I pulled this from like 121 of the following file:

https://github.com/p4lang/p4factory/blob/master/targets/switch/p4src/nexthop.p4



action set_nexthop_details(ifindex, bd) {

    modify_field(ingress_metadata.egress_ifindex, ifindex);

    bit_xor(l3_metadata.same_bd_check, ingress_metadata.ingress_bd, bd);

}



Here, the set_nexthop_details action takes two parameters.  These
parameters can be anything that has been parsed into the parsed
representation.  So as long as you have parsed (or learned via metadata)
the value that you want to pass to the action, this is how you do it.  (I
think that’s what you’re asking here…)





And the code you reference is indeed an array, in this case it’s an array
of “vlan_tag” types that has a (maximum) depth of 2.  See section 2.2.2 of
the p4 language spec :
http://p4.org/wp-content/uploads/2015/04/p4-latest.pdf



--lj











*From:* P4-dev [mailto:p4-dev-bounces at p4.org] *On Behalf Of *Archie
*Sent:* Monday, July 20, 2015 6:24 PM
*To:* p4-dev at p4.org
*Subject:* [P4-dev] Is it possible to transfer value from packet fields to
action?



Hi,

     I was wondering whether it is possible to transfer data from the field
values mentioned in the table to the action part of P4.



e.g. if you have the following table



table forward {

    reads {

        ethernet.dstAddr : exact;

    }

    actions {

        set_egr;

    }

}



then is it possible to transfer the value of ethernet.dstAddr to set_egr?



Also can anyone explain the following code to me? I found it in the here
<https://github.com/p4lang/p4factory/blob/master/targets/switch/p4src/includes/parser.p4>
and
am not sure what this is. Is it an array?



#define VLAN_DEPTH 2

header vlan_tag_t vlan_tag_[VLAN_DEPTH];
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150720/5f1df8e6/attachment-0001.html>


More information about the P4-dev mailing list