[P4-dev] p4-validate warning message

Roshan sedar at oasis.uclouvain.be
Fri Dec 15 16:44:51 EST 2017


thanks Antonin. I will follow what you said.


On 2017-12-15 22:34, Antonin Bas wrote:
> As Andy explained, because P4_14 isn't strongly typed for action 
> parameters, the compiler tries to infer the bitwidth of port_to_send 
> from the action primitives where it is used. This information 
> necessary for generating the control-plane APIs.
>
> In this case port_to_send is used in 2 assignments:
> 1. modify_field(myhdr.source_port, port_to_send);
> 2. modify_field(standard_metadata.egress_spec, port_to_send);
> From 1 the compiler infers a bitwidth of 8 because myhdr.source_port 
> is a 8-bit field.
> From 2 the compiler infers a bitwidth of 9 because 
> standard_metadata.egress_spec is a 9-bit field. I do not think that 
> this is part of the P4_14 specification, but the definition of 
> standard_metadata.egress_spec is injected by the compiler, and I used 
> a bitwidth of 9 when I wrote that code 
> (https://github.com/p4lang/p4-hlir/blob/master/p4_hlir/frontend/semantic_check.py#L218) 
> in order to accommodate for up to 512 ports.
>
> The compiler keeps the largest inferred bitwidth, which may mean that 
> the first assignment will truncate the value if port_to_send is 
> greater than 255.
> You can get rid of the warning by making myhdr.source_port 9-bit 
> because then it will match standard_metadata.egress_spec.
>
> It is possible that p4c-bmv2 silences the warning for some reason, it 
> should probably not do that.
>
> On Fri, Dec 15, 2017 at 1:25 PM, Roshan <sedar at oasis.uclouvain.be 
> <mailto:sedar at oasis.uclouvain.be>> wrote:
>
>     here is the full program. I did some changes to original version
>     once I saw warnings.
>
>     header_type header_source_t {
>        fields {
>             preamble: 64;
>             path_length: 8;
>             source_port: 8;
>             is_src: 1;
>        }
>     }
>
>     header header_source_t myhdr;
>
>     parser start {
>         return ingress;
>     }
>
>     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;
>         }
>     }
>     metadata intrinsic_metadata_t intrinsic_metadata;
>
>
>     action send_pkt(port_to_send) {
>       modify_field(myhdr.is_src, 1);
>       add_to_field(myhdr.path_length, 1);
>       modify_field(myhdr.source_port, port_to_send);
>       modify_field(standard_metadata.egress_spec, port_to_send);
>     }
>
>     table route_pkt {
>       reads {
>             standard_metadata.ingress_port: exact;
>       }
>       actions {
>             send_pkt;
>       }
>     }
>
>
>     control ingress{
>        apply(route_pkt);
>     }
>
>     control egress {}
>
>      thanks!
>
>
>     On 2017-12-15 18:02, Antonin Bas wrote:
>>     Your program cannot compile as it is, there is no start parser
>>     and no ingress control flow.
>>     In your original email, you mention an error message for argument
>>     "'port_to_send" but there is no "'port_to_send" in this program.
>>
>>     On Thu, Dec 14, 2017 at 1:47 PM, Roshan <sedar at oasis.uclouvain.be
>>     <mailto:sedar at oasis.uclouvain.be>> wrote:
>>
>>         Hi Andy,
>>
>>         warning comes from the following:
>>
>>         header_type header_source_t {
>>            fields {
>>                 preamble: 64;
>>                 hopCount: 8;
>>                 is_src: 1;
>>            }
>>         }
>>
>>         header header_source_t myhdr;
>>
>>         action send_pkt(egress_spec) {// p4-validate warning shows
>>         this line
>>            modify_field(standard_metadata.egress_spec, egress_spec);
>>            add_to_field(myhdr.hopCount, 1);
>>            modify_field(myhdr.is_src, 1);
>>         }
>>
>>         table route_pkt {
>>           reads {
>>                 standard_metadata.ingress_port: exact;
>>           }
>>           actions {
>>                 send_pkt;
>>           }
>>         }
>>
>>
>>         Yes, it is P4_14.
>>         p4-validate gives this warning but with p4c-bmv2 no warnings.
>>
>>         thanks,
>>         Roshan.
>>
>>
>>         On 2017-12-14 18:26, Andy Fingerhut wrote:
>>>         If you are willing to share the P4 program that gives this
>>>         warning, it would be easier to give a definitive answer.
>>>
>>>         I am guessing this is a P4_14 program, not P4_16?  There are
>>>         cases in P4_14 programs, especially for the definitions of
>>>         actions, where because the action parameters have no defined
>>>         bit width, the compiler must try to infer what they ought to
>>>         be, based upon the operations they are used in within that
>>>         action.  If there are multiple different widths that could
>>>         be inferred, the warning could occur.  That, or it could be
>>>         a compiler bug.  Here is a Github issue that might be
>>>         related to what you are seeing:
>>>         https://github.com/p4lang/p4c/issues/1095
>>>         <https://github.com/p4lang/p4c/issues/1095>
>>>
>>>         Andy
>>>
>>>         On Thu, Dec 14, 2017 at 7:29 AM, Roshan
>>>         <sedar at oasis.uclouvain.be <mailto:sedar at oasis.uclouvain.be>>
>>>         wrote:
>>>
>>>             Hi,
>>>
>>>             p4-validate gives this warning: "WARNING in route.p4
>>>             line 25: Inferred conflicting widths for argument
>>>             'port_to_send' (9 and 8), using larger width".
>>>
>>>
>>>             Any idea what could be the reason.
>>>
>>>
>>>             Thanks in advance,
>>>
>>>             Roshan.
>>>
>>>
>>>             _______________________________________________
>>>             P4-dev mailing list
>>>             P4-dev at lists.p4.org <mailto:P4-dev at lists.p4.org>
>>>             http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>             <http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org>
>>>
>>>
>>>
>>>
>>>         _______________________________________________
>>>         P4-dev mailing list
>>>         P4-dev at lists.p4.org <mailto:P4-dev at lists.p4.org>
>>>         http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>>         <http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org>
>>
>>
>>         _______________________________________________
>>         P4-dev mailing list
>>         P4-dev at lists.p4.org <mailto:P4-dev at lists.p4.org>
>>         http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>         <http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org>
>>
>>
>>
>>
>>     -- 
>>     Antonin
>>
>>
>>     _______________________________________________
>>     P4-dev mailing list
>>     P4-dev at lists.p4.org <mailto:P4-dev at lists.p4.org>
>>     http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>>     <http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org>
>
>
>
>
> -- 
> Antonin
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org

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


More information about the P4-dev mailing list