[P4-dev] Some questions about the architecture declaration P4_16 language .

Vladimir Gurevich vladimir.gurevich at barefootnetworks.com
Thu Oct 19 23:53:40 EDT 2017


Hello DingRui,

These are very good questions! The answers are as follows:

1) Why the first parameter (packet_in) has no direction?

The reason is that this is an extern, and externs do not have a direction.
I think there are two main reasons for that:

   1. Externs do not follow copy-in/copy-out semantics, but are rather
   passed by reference.
   2. By looking at the definition of the extern methods, a compiler cannot
   really say what a particular extern method does to an extern (does it
   modify it, does it modify just the part we care about, does it modify
   something else, etc.). So, enforcing the direction is not really possible
   -- extern is a blackbox.

In the example you are referring to (packet_in in the parser), we do not
know and cannot define the state packet_in will have after the packet
leaves the parser. And the reason is -- we don't care (at least in VSS or
V1 or PSA architectures), since we know we are not going to refer to this
extern again.

2) Why the parser declaration use the keyword 'parser', while deparser
declaration
use 'control' ?

This happens because parsers are coded using FSM style and therefore
contain parser states and control is passed via transition statement. In
case of a deparser, there is no need to do that: a simple (mostly linear)
control flow is all that is required and that's the style that is used
inside the controls. Thus, deparsers (in VSS and other architectures I know
of) are controls.

Having said that, please, understand that all these two constructs are is
just a representation of two styles of expressing control flows. If you
have an architecture, where the main ingress processing is done in some FSM
(e.g. it's a regular expression parsing), the authors are free to use
parser to represent that processing.

3) How to understand the extern objects in P4_16, I'm a little confused. Is
it a functional unit physically?

As another shameless plug on this mailing list, I'd recommend the
video Introduction
to P4_16. Part 2 <https://youtu.be/yqxpypXIOtQ> specifically starting at
the mark 45:27 <https://youtu.be/yqxpypXIOtQ?t=45m27s> as an introduction
to what externs are. Physically they can come in any form or shape; the
important thing is that we can't normally express in P4 what they are
doing, but we do have mechanisms to interface with these objects and take
advantages of their functionality.

Happy hacking,
Vladimir

On Thu, Oct 19, 2017 at 7:38 PM, <ding.rui at zte.com.cn> wrote:

> Hi, everyone.
>
>      In P4_16 language specifcation(version 1.0.0 2017-05-22) page 13, it provides
> a declaration of VSS in P4
>
> language, I would like to ask a few conceptual questions.
>
>
>
> 1) Why the first parameter has no direction? What kind of parameters need
> direction?  I think the packet_in
>
> parameter is an input of the parser. And I also want to know why the
> payload of the packet is not the output
>
> of the parser?
>
> parser Parser<H>(*pa**cket_in b*,
>
>                              out H parsedHeaders);
>
>
> 2)Why the parser declaration use the keyword 'parser', while deparser declaration
> use 'control' ?
>
>    What are the differences between the two keywords in semantics?
>
> control Pipe<H>(inout H headers,
>                           in error parseError,// parser error
>                           in InControl inCtrl,// input port
>                           out OutControl outCtrl); // output port
>
> *control* Deparser<H>(inout H outputHeaders,
>
>                                   *packet_out b*);
>
> 3) How to understand the extern objects in P4_16, I'm a little
> confused. Is it a functional unit physically?
>
>
>
>
>
>
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
>



-- 
*Vladimir Gurevich*

*Barefoot Networks*
*Technical Lead, Customer Engineering*
Email: vag at barefootnetworks.com
Phone: (408) 833-4505
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20171019/a41e9d3f/attachment-0002.html>


More information about the P4-dev mailing list