[P4-dev] P4-dev Digest, Vol 15, Issue 4

hemant at mnkcg.com hemant at mnkcg.com
Wed Nov 2 13:39:25 EDT 2016


How would I find some conditionally compiled action, especially when I am in the p4-shell provided by the HLIR code?

 

This is some code in a parser.p4 that I am working with.

 

#define IP_PROTOCOLS_ICMP 1

#define IP_PROTOCOLS_TCP 6

#define IP_PROTOCOLS_UDP 17

#define IP_PROTOCOLS_ICMPV6 58

 

header ipv4_t ipv4;

 

parser parse_ipv4 {

    extract(ipv4);

    return select(latest.fragOffset, latest.protocol) {

        IP_PROTOCOLS_ICMP : parse_icmp;

        IP_PROTOCOLS_TCP : parse_tcp;

        IP_PROTOCOLS_UDP : parse_udp;

    }

}

 

Thanks,

 

Hemant

 

From: P4-dev [mailto:p4-dev-bounces at lists.p4.org] On Behalf Of Pavel Chuprikov
Sent: Wednesday, November 02, 2016 12:29 PM
To: Jahandad Khan <jehandad at vt.edu>; p4-dev at lists.p4.org
Subject: Re: [P4-dev] P4-dev Digest, Vol 15, Issue 4

 

The PP directives are lost on a very early stage <https://github.com/p4lang/p4-hlir/blob/master/p4_hlir/frontend/preprocessor.py#L48>  when the input is fed to gcc.

 

If those directives are actually used in p4 code, I can suggest to query the p4 object that depends on those directives, e.g., whether some conditionally compiled action is present or, if you have something like field_name : SOME_MACRO, what is the width of the field.

 

Regards,

Pavel

 

 

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


More information about the P4-dev mailing list