<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Swaroop,<br>
    <br>
    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.)<br>
    <br>
    <i>modify_field_with_hash_based_offset(salvatores_metadata.hashfield,
      0, output_value, 0);<br>
      <br>
    </i>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).<br>
    <i><br>
    </i>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.  <br>
    <br>
    Thanks,<br>
    Salvatore<br>
    <br>
    <div class="moz-cite-prefix">On 08/19/2015 07:11 PM, Swaroop Thool
      wrote:<br>
    </div>
    <blockquote cite="mid:BAY167-W1060838C879A95A4F821C50CB670@phx.gbl"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
      <div dir="ltr"><br>
        Hi Salvatore,<br>
        <br>
        Referred to given field_list_calculation. Will this work for
        you? I am not yet sure<br>
        <br>
        <i>modify_field_with_hash_based_offset(salvatores_metadata.hashfield,
          0, output_value, 1000);</i>  //where 1000 is range of hash
        value<br>
        <br>
        <br>
        Best,<br>
        Swaroop<br>
        <div>
          <hr id="stopSpelling">Date: Wed, 19 Aug 2015 15:14:07 +0200<br>
          From: <a class="moz-txt-link-abbreviated" href="mailto:salvatore.signorello@uni.lu">salvatore.signorello@uni.lu</a><br>
          To: <a class="moz-txt-link-abbreviated" href="mailto:ljw@barefootnetworks.com">ljw@barefootnetworks.com</a>; <a class="moz-txt-link-abbreviated" href="mailto:p4-dev@p4.org">p4-dev@p4.org</a><br>
          Subject: Re: [P4-dev] storing field_list_calculation into a
          metadata field<br>
          <br>
          Hi lj,<br>
          <br>
          thanks, more inline<br>
          <br>
          Best,<br>
          Salvo<br>
          <br>
          <div class="ecxmoz-cite-prefix">On 08/19/2015 01:26 PM, LJ
            Wobker wrote:<br>
          </div>
          <blockquote
            cite="mid:24ce97f47e35c79f2d9a7fc62c02c818@mail.gmail.com">
            <style><!--
.ExternalClass p.ecxMsoNormal, .ExternalClass li.ecxMsoNormal, .ExternalClass div.ecxMsoNormal {
font-size:11.0pt;
font-family:"Calibri",sans-serif;
}

.ExternalClass a:link, .ExternalClass span.ecxMsoHyperlink {
color:#0563C1;
text-decoration:underline;
}

.ExternalClass span.ecxMsoHyperlinkFollowed {
color:#954F72;
text-decoration:underline;
}

.ExternalClass p.ecxMsoPlainText, .ExternalClass li.ecxMsoPlainText, .ExternalClass div.ecxMsoPlainText {
font-size:11.0pt;
font-family:"Calibri",sans-serif;
}

.ExternalClass p.ecxMsoNoSpacing, .ExternalClass li.ecxMsoNoSpacing, .ExternalClass div.ecxMsoNoSpacing {
font-size:9.0pt;
font-family:"Lucida Console";
color:#0070C0;
}

.ExternalClass span.ecxPlainTextChar {
font-family:"Calibri",sans-serif;
}

.ExternalClass .ecxMsoChpDefault {
}

.ExternalClass div.ecxWordSection1 {
}

--></style>
            <div class="ecxWordSection1">
              <p class="ecxMsoPlainText">Per section 2.4 & 3 of the
                spec, you should be able to use</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText"> <b>field_list_calculation</b>
                <b><i>output_value</i></b></p>
              <p class="ecxMsoPlainText"><b><i> </i></b></p>
              <p class="ecxMsoPlainText"><b><i> </i></b> to obtain a
                hash value from your set of fields.  The output of this
                (output_value) can then be referenced in action
                primitives…</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoNoSpacing"> </p>
              <p class="ecxMsoNoSpacing">field_list <i>something</i> {
              </p>
              <p class="ecxMsoNoSpacing">    ipv4.source;</p>
              <p class="ecxMsoNoSpacing">    ipv4.dest;</p>
              <p class="ecxMsoNoSpacing">    tcp.source;</p>
              <p class="ecxMsoNoSpacing">    tcp.dest;</p>
              <p class="ecxMsoNoSpacing">}</p>
              <p class="ecxMsoNoSpacing"> </p>
              <p class="ecxMsoNoSpacing">field_list_calculation <b>output_value</b>
                {</p>
              <p class="ecxMsoNoSpacing">    input {</p>
              <p class="ecxMsoNoSpacing">       <i>something</i>;</p>
              <p class="ecxMsoNoSpacing">    }</p>
              <p class="ecxMsoNoSpacing">    algorithm : crc32;</p>
              <p class="ecxMsoNoSpacing">    output_width : 32;</p>
              <p class="ecxMsoNoSpacing">}</p>
              <p class="ecxMsoNoSpacing"> </p>
              <p class="ecxMsoNoSpacing">modify_field
                (salvatores_metadata.hashfield, <b>output_value</b>)</p>
              <p class="ecxMsoNoSpacing">//
                “salvatores_metadata.hashfield” is a 32b field defined
                in the metadata header somewhere…</p>
              <p class="ecxMsoPlainText">                                                   

              </p>
              <p class="ecxMsoPlainText">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… </p>
            </div>
          </blockquote>
          that's exactly what I've tried and it hasn't worked. This
          produces a semantic error for a type mismatch, that is,<br>
          <br>
          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<br>
          <br>
          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.<br>
          <br>
          <br>
          <blockquote
            cite="mid:24ce97f47e35c79f2d9a7fc62c02c818@mail.gmail.com">
            <div class="ecxWordSection1">
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">--lj        </p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">-----Original Message-----<br>
                From: P4-dev [mailto:<a moz-do-not-send="true"
                  href="mailto:p4-dev-bounces@p4.org">p4-dev-bounces@p4.org</a>]
                On Behalf Of Salvatore Signorello<br>
                Sent: Wednesday, August 19, 2015 12:07 PM<br>
                To: <a moz-do-not-send="true"
                  href="mailto:p4-dev@p4.org">p4-dev@p4.org</a><br>
                Subject: [P4-dev] storing field_list_calculation into a
                metadata field</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">Hi all,</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">is there any way to store the
                hash of a fields list (so a field list </p>
              <p class="ecxMsoPlainText">calculation) into a metadata
                field for further matching into a table?</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">The signature of the primitive
                action "modify_field" does not accept a </p>
              <p class="ecxMsoPlainText">field list as src parameter.
                Could please someone point out if there was </p>
              <p class="ecxMsoPlainText">any specific rationale for not
                allowing such thing?</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">Note: I still refer to the old
                specification (ver 1.0.2).</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">Best,</p>
              <p class="ecxMsoPlainText">Salvatore</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">-- </p>
              <p class="ecxMsoPlainText">Salvatore Signorello</p>
              <p class="ecxMsoPlainText">PhD student @ SecanLab</p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">Interdisciplinary Centre for
                Security, Reliability and Trust</p>
              <p class="ecxMsoPlainText">SnT, University of Luxembourg</p>
              <p class="ecxMsoPlainText"><a moz-do-not-send="true"
                  href="http://wwwen.uni.lu/snt/people/salvatore_signorello"
                  target="_blank"><span
                    style="color:windowtext;text-decoration:none;">http://wwwen.uni.lu/snt/people/salvatore_signorello</span></a></p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText"> </p>
              <p class="ecxMsoPlainText">_______________________________________________</p>
              <p class="ecxMsoPlainText">P4-dev mailing list</p>
              <p class="ecxMsoPlainText"><a moz-do-not-send="true"
                  href="mailto:P4-dev@p4.org"><span
                    style="color:windowtext;text-decoration:none;">P4-dev@p4.org</span></a></p>
              <p class="ecxMsoPlainText">Listinfo - <a
                  moz-do-not-send="true"
                  href="http://mail.p4.org/mailman/listinfo/p4-dev_p4.org"
                  target="_blank"><span
                    style="color:windowtext;text-decoration:none;">http://mail.p4.org/mailman/listinfo/p4-dev_p4.org</span></a></p>
              <p class="ecxMsoPlainText">Archives - <a
                  moz-do-not-send="true"
                  href="http://mail.p4.org/pipermail/p4-dev_p4.org/"
                  target="_blank"><span
                    style="color:windowtext;text-decoration:none;">http://mail.p4.org/pipermail/p4-dev_p4.org/</span></a></p>
            </div>
          </blockquote>
          <br>
          <pre class="ecxmoz-signature">-- 
Salvatore Signorello
PhD student @ SecanLab

Interdisciplinary Centre for Security, Reliability and Trust
SnT, University of Luxembourg
<a moz-do-not-send="true" class="ecxmoz-txt-link-freetext" href="http://wwwen.uni.lu/snt/people/salvatore_signorello" target="_blank">http://wwwen.uni.lu/snt/people/salvatore_signorello</a></pre>
          <br>
          _______________________________________________
          P4-dev mailing list
          <a class="moz-txt-link-abbreviated" href="mailto:P4-dev@p4.org">P4-dev@p4.org</a>
          Listinfo - <a class="moz-txt-link-freetext" href="http://mail.p4.org/mailman/listinfo/p4-dev_p4.org">http://mail.p4.org/mailman/listinfo/p4-dev_p4.org</a>
          Archives - <a class="moz-txt-link-freetext" href="http://mail.p4.org/pipermail/p4-dev_p4.org/">http://mail.p4.org/pipermail/p4-dev_p4.org/</a></div>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Salvatore Signorello
PhD student @ SecanLab

Interdisciplinary Centre for Security, Reliability and Trust
SnT, University of Luxembourg
<a class="moz-txt-link-freetext" href="http://wwwen.uni.lu/snt/people/salvatore_signorello">http://wwwen.uni.lu/snt/people/salvatore_signorello</a></pre>
  </body>
</html>