[P4-dev] Fwd: Simple_switch_CLI

Antonin Bas antonin at barefootnetworks.com
Tue Nov 21 00:19:49 EST 2017


Hi,

bmv2 does not support using variable-length fields as match fields. I'm
actually surprised that the bmv2 compiler does not reject your program. I
opened an issue on Github to fix this:
https://github.com/p4lang/p4c-bm/issues/92
Although I don't believe that the P4_14 spec explicitly prevents the
programmer from matching on a variable-length field in a table, it is
difficult to define good semantics for operations on variable-length fields
(and the P4_14 spec does not define anything with respect to this). Note
that in P4_16, very few operations are defined on variable-length fields,
aka varbits:
https://p4lang.github.io/p4-spec/docs/P4-16-v1.0.0-spec.html#sec-varbit-string

On Mon, Nov 20, 2017 at 8:33 PM, Lucas Souza Santos <
lucassouzasantos at gmail.com> wrote:

> Hey guys, good night, i am having a problem with some with CLI commands,
> someone have any idea to solve it?
>
> *That's the problem:*
> [image: Imagem inline 1]
> *The command:* table_add table_priority set_priority 92 => 1
>
> *The p4 code:*
>
> header_type intrinsic_metadata_t {
>    fields {
>        ingress_global_timestamp : 48;
>        lf_field_list : 8;
>        mcast_grp : 16;
>        egress_rid : 16;
>        resubmit_flag : 8;
>        recirculate_flag : 8;
>        priority : 3;
>    }
> }
>
> metadata intrinsic_metadata_t intrinsic_metadata;
>
> header_type pre_t {
>     fields {
>         preamble: 64;
>     }
> }
>
> header pre_t pre;
>
> header_type rns_t {
>     fields {
>         rot_len: 8;
>         rotulo: *;
>     }
>     length: (rot_len + 1);
>     max_length: 256;
> }
>
> header rns_t rns;
>
> parser start {
>     return select(current(0, 64)) {
>         0: parse_port;
>         default: ingress;
>     }
> }
>
> parser parse_port {
>     extract(rns);
>     return ingress;
> }
>
> action _drop() {
>     drop();
> }
>
> action set_priority(priority){
>     modify_field(standard_metadata.egress_spec, (rns.rotulo%2));
>     modify_field(intrinsic_metadata.priority, priority);
> }
>
> action forward() {
>     modify_field(standard_metadata.egress_spec, (rns.rotulo%2));
>     modify_field(intrinsic_metadata.priority, 7);
> }
>
> table table_priority {
>     reads {
>         rns.rotulo: exact;
>     }
>     actions {
>         set_priority;
>         _drop;
>         forward;
>     }
>     size: 1;
> }
>
> control ingress {
>     apply(table_priority);
> }
>
> control egress {
>     // leave empty
> }
>
> Thanks,
> Lucas Santos
>
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171120/799f533a/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WhatsApp Image 2017-11-21 at 00.48.22.jpeg
Type: image/jpeg
Size: 96148 bytes
Desc: not available
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171120/799f533a/attachment.jpeg>


More information about the P4-dev mailing list