[P4-dev] move parser pointer forward

Gordon Brebner Gordon.Brebner at xilinx.com
Mon Aug 3 14:16:47 EDT 2015


I think that a generic “skip n bytes” operation can be done using a header with a single field of * width and a length expression to compute the desired n.  Is this correct?

Gordon.


From: P4-dev [mailto:p4-dev-bounces at p4.org] On Behalf Of LJ Wobker
Sent: Monday, August 03, 2015 11:08 AM
To: Salvatore Signorello; p4-dev at p4.org
Subject: Re: [P4-dev] move parser pointer forward


That's correct - there is no explicit "skip" functionality in the parser.  Think of the parse tree as a continuous graph that walks through the incoming bytestream in order: there are no gaps.  As Mihai suggests, you can always just use a dummy header field for bytes that you don't care about, although I would contend that in most cases it will make more sense to just parse the header with a meaningful name.



Let us consider a contrived case such as: RTP in UDP in ipv4 in ethernet.  Let's further assume (again, contrived) that you know you absolutely do not need to parse any of the specific fields within the UDP header, but you need/want to be able to get to the RTP headers underneath.



You could easily build a parse tree/header definition that treats the entire UDP header as one field, instead of the component fields.  This might or might not be simpler/easier/faster/cheaper for a given target or compiler to handle, and it might (or might not!) be more convenient for the P4 programmer.



Original UDP header format from p4factory/master/targets/switch/p4src/includes/headers.p4<https://github.com/p4lang/p4factory/blob/master/targets/switch/p4src/includes/headers.p4>


header_type udp_t {
    fields {
        srcPort : 16;
        dstPort : 16;
        length_ : 16;
        checksum : 16;
    }
}



Modified/ simpler version as described:


header_type udp_t {
    fields {
        meaningless_blob : 64;
    }
}





So that’s probably a longer answer than you really needed, but I figured I’d write it out for posterity.





--lj











-----Original Message-----
From: P4-dev [mailto:p4-dev-bounces at p4.org<mailto:p4-dev-bounces at p4.org>] On Behalf Of Salvatore Signorello
Sent: Monday, August 03, 2015 10:01 AM
To: p4-dev at p4.org<mailto:p4-dev at p4.org>
Subject: [P4-dev] move parser pointer forward



Hi all,



could someone confirm that the actual specification doesn't provide any

construct to advance the parsing pointer except the "extract" one?



Is it possible to skip the parsing of some fields without defining and

extracting a header including them?



Best,

Salvatore











_______________________________________________

P4-dev mailing list

P4-dev at p4.org<mailto: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/


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

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


More information about the P4-dev mailing list