[P4-dev] storing field_list_calculation into a metadata field

Antonin Bas antonin at barefootnetworks.com
Wed Aug 19 15:11:08 EDT 2015


Hi all,

modify_field_with_hash_based_offset is indeed the correct primitive to use
(the name is an old name, and has not been updated since v1.0.0 of the
spec...). Some people use it to implement ECMP as you mentioned, although
we can also use an action profile with a selector. We will actually be
using this primitive to implement TCP flowlet switching at the SIGCOMM P4
tutorial on Friday. The material for the tutorial will be uploaded online
next week.

2 things:
1) we could have modify_field accept a field_list_calculation as an input
parameter. However people are usually interested in adding the hash to a
base and doing a modulo operation. This primitive is therefore more
general. You are actually the first person asking for this :)

2) if we are using the P4 software switch, I am pretty confident that using
a size of 0 will crash / won't compile. I think I missed that specific
behavior when I implemented the primitive. Therefore, if your output is,
for example, 16 bit wide and if you use a zero base, I would set the size
to 16,536.

Best,

Antonin

On Wed, Aug 19, 2015 at 11:52 AM, Salvatore Signorello <
salvatore.signorello at uni.lu> wrote:

> Hi Swaroop,
>
> your suggestion should do the job, I just need to set the 'size' argument
> (the 4th one) to zero, so that (base+hash_value) equals 0 (see action
> description on page 38 of the spec.)
>
>
>
> *modify_field_with_hash_based_offset(salvatores_metadata.hashfield, 0,
> output_value, 0); *Btw, I think that the action above has been introduced
> with a different aim in mind, that is, to generate random indexes for
> actions selection in ECMP-like cases (I'm having a déjà-vu, because someone
> else has probably pointed out such thing in a previous discussion).
>
> That's solved, I still don't understand why the field_list_calculation was
> omitted from the accepted type for the modify_field option. I'm sure that
> the dev-fellows will shed some light on this soon.
>
> Thanks,
> Salvatore
>
>
> On 08/19/2015 07:11 PM, Swaroop Thool wrote:
>
>
> Hi Salvatore,
>
> Referred to given field_list_calculation. Will this work for you? I am not
> yet sure
>
> *modify_field_with_hash_based_offset(salvatores_metadata.hashfield, 0,
> output_value, 1000);*  //where 1000 is range of hash value
>
>
> Best,
> Swaroop
> ------------------------------
> Date: Wed, 19 Aug 2015 15:14:07 +0200
> From: salvatore.signorello at uni.lu
> To: ljw at barefootnetworks.com; p4-dev at p4.org
> Subject: Re: [P4-dev] storing field_list_calculation into a metadata field
>
> Hi lj,
>
> thanks, more inline
>
> Best,
> Salvo
>
> On 08/19/2015 01:26 PM, LJ Wobker wrote:
>
> Per section 2.4 & 3 of the spec, you should be able to use
>
>
>
> *field_list_calculation* *output_value*
>
>
>
>  to obtain a hash value from your set of fields.  The output of this
> (output_value) can then be referenced in action primitives…
>
>
>
>
>
> field_list *something* {
>
>     ipv4.source;
>
>     ipv4.dest;
>
>     tcp.source;
>
>     tcp.dest;
>
> }
>
>
>
> field_list_calculation *output_value* {
>
>     input {
>
>        *something*;
>
>     }
>
>     algorithm : crc32;
>
>     output_width : 32;
>
> }
>
>
>
> modify_field (salvatores_metadata.hashfield, *output_value*)
>
> // “salvatores_metadata.hashfield” is a 32b field defined in the metadata
> header somewhere…
>
>
>
> Have you tried this and found it not to be working?  I didn’t pull this
> from working code, but it should be pretty close…
>
> that's exactly what I've tried and it hasn't worked. This produces a
> semantic error for a type mismatch, that is,
>
> Semantic error: Error when calling primitive modify_field (countComp ->
> countComponents -> modify_field) in file myfile.p4 at line 40: argument 1
> has type field list calculation, but formal src has type field, integer
> value
>
> I guess that you may have a look at the primitives.json file to see which
> are the types accepted by this primitive action. Field_list is not included.
>
>
>
>
>
>
> --lj
>
>
>
>
>
>
>
>
>
>
>
> -----Original Message-----
> From: P4-dev [mailto:p4-dev-bounces at p4.org] On Behalf Of Salvatore
> Signorello
> Sent: Wednesday, August 19, 2015 12:07 PM
> To: p4-dev at p4.org
> Subject: [P4-dev] storing field_list_calculation into a metadata field
>
>
>
> Hi all,
>
>
>
> is there any way to store the hash of a fields list (so a field list
>
> calculation) into a metadata field for further matching into a table?
>
>
>
> The signature of the primitive action "modify_field" does not accept a
>
> field list as src parameter. Could please someone point out if there was
>
> any specific rationale for not allowing such thing?
>
>
>
> Note: I still refer to the old specification (ver 1.0.2).
>
>
>
> Best,
>
> Salvatore
>
>
>
> --
>
> Salvatore Signorello
>
> PhD student @ SecanLab
>
>
>
> Interdisciplinary Centre for Security, Reliability and Trust
>
> SnT, University of Luxembourg
>
> http://wwwen.uni.lu/snt/people/salvatore_signorello
>
>
>
>
>
> _______________________________________________
>
> P4-dev mailing list
>
> P4-dev at p4.org
>
> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
>
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
>
>
> --
> Salvatore Signorello
> PhD student @ SecanLab
>
> Interdisciplinary Centre for Security, Reliability and Trust
> SnT, University of Luxembourghttp://wwwen.uni.lu/snt/people/salvatore_signorello
>
>
> _______________________________________________ P4-dev mailing list
> P4-dev at p4.org Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
>
>
> --
> Salvatore Signorello
> PhD student @ SecanLab
>
> Interdisciplinary Centre for Security, Reliability and Trust
> SnT, University of Luxembourghttp://wwwen.uni.lu/snt/people/salvatore_signorello
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at p4.org
> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150819/dd1ac68f/attachment-0001.html>


More information about the P4-dev mailing list