[P4-dev] concat fields

Salvatore Signorello salvatore.signorello at uni.lu
Thu Mar 31 21:40:45 EDT 2016

Hi Yuliang,

you can use field list calculation (see sec. 4 "Checksums and Hash-value 
generators" of the language specification). For instance, you define a 
field list which is a structure containing all the header fields you 
want to concat, like follows:

field_list tuple_fl {

then you define a field list calculation which maps the result of a 
function computed over a field list to an integer value, like follows:

field_list_calculation tuple_xor {
     input {
     algorithm : xor16; // a list of the supported algorithms is 
provided within the aforementioned sec. of the specification
     output_width : 16;

Then, you need to copy the tuple_xor value first in a metadata and later 
in a register by calling an action that could be defined like follows:

action set_xor_value(base, count) {
     modify_field_with_hash_based_offset(your_metadata.tuple_xor, base, 
tuple_xor, ecmp_count);
     register_write(register_name, index, your_metadata.tuple_xor)

While back, the operation above could not be performed in one step, 
because the "modify_field_with_hash_based_offset" didn't accept a 
register as 1st argument. Today, I'm not sure that this is still the case.

Of course, finally, you also need a table that triggers the action above.

There should be the flowlet switching example that performs a similar 
operation at

Hope that this helps,

On 04/01/2016 02:58 AM, Yuliang Li wrote:
> Hi,
> I need to xor the 5-tuple of each packet into a register. So I need 
> something like concat(srcip, dstip, srcport, dstport, protocol), and 
> xor it to my register. Does anyone know how to do it in p4 data plane?
> Thanks,
> Yuliang
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org

Salvatore Signorello
PhD student of the SEDAN research group at SnT

Interdisciplinary Centre for Security, Reliability and Trust
University of Luxembourg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20160401/9fc3017d/attachment-0002.html>

More information about the P4-dev mailing list