[P4-dev] I have some questions, please help me.

Antonin Bas antonin at barefootnetworks.com
Thu Apr 6 14:37:30 EDT 2017


1) This question makes me wonder if you have done your due diligence; did
you read the P4 spec? You should also try to do this tutorial (
https://github.com/p4lang/tutorials/tree/master/SIGCOMM_2015) and try to
understand what is going on.

2) Some tentative support for OpenFlow was added (https://github.com/p4lang/
p4ofagent) but it is not being supported very actively. Writing an OpenFlow
agent for P4 is a broad and difficult task. It is my belief that you cannot
write an OF agent that will work with any P4 program (at least for OF 1.3)
because of the protocol-independent character of P4. However it should
possible to manage L2/L3 tables in your P4 program (providing your program
has such tables) using a generic OF agent, and that's what p4lang/p4ofagent
tries to do.

Regarding NOS integration: as for the OF agent, NOS integration can only be
truly achieved for a specific P4 program. The most popular open-source P4
program is switch.p4 (https://github.com/p4lang/switch) which is the P4
implementation of a traditional datacenter switch. The Switch Abstraction
Interface (SAI) has been implemented on switch.p4 (see
http://p4.org/p4/an-open-source-p4-switch-with-sai-support/). There is also
some support to run the OpenSwitch NOS with switch.p4. You should be able
to find some information online.

3) P4 lets you configure your dataplane: you can define the parse graph and
the tables that constitute the match-action pipeline. However, you still
need to be able to populate the match-action tables at runtime.
For example, assuming you have the following table for IPv4 forwarding:
action drop_() { drop(); }
action set_nhop(nhop, port) { ... }
table ipv4_lpm {
    reads { ipv4.dstAddr : lpm; }
    actions {set_nhop; drop_; }
You need to be able to add prefixes to this table at runtime, e.g.
- / 16 => (nhop), 10 (port)
- / 8 => drop_
In order to let the application populate tables, we generate C headers & a
C library which can be linked to the application, which we call the PD
(program-dependent) API. For each table, we generate functions to add /
remove / modify / ... entries. For the above table, we will have the
following functions:
pd_<P4 prog name>_ipv4_lpm_table_add_with_drop_(<match_key>)
pd_<P4 prog name>_ipv4_lpm_table_add_with_set_nhop_(<match_key>, nhop, port)
The application can then call these methods to add prefixes to the ipv4_lpm

If you want to generate the PD library for a given P4 program, please look
at p4-build: https://github.com/p4lang/p4-build

We use the generated PD API for switch.p4 to implement SAI:

4) The assumptions made by P4_14 are:
- all headers are available to both pipelines
- all the metadata fields are available to both pipelines
How the sharing is implemented in practice is outside of the scope of P4
and would be a property of the target (e.g. ASIC, NIC, software switch,...).

5) Just like for 5), this is a property of the target and outside of the
scope of P4. In the case of the behavioral-model software switch (at least
for simple_switch), the packet is not deparsed / serialized between the 2

On Thu, Apr 6, 2017 at 12:04 AM, <ding.rui at zte.com.cn> wrote:

> I am stuying  behavioral-model/targets/l2_switch/*l2_switch.p4* example,
> I have some questions.
> 1)
> action forward(port) {                                   // where is the
> port parameter come from?  use forward action place doesn't pass any
> parameter.
>     modify_field(standard_metadata.egress_port, port);
> }
> action broadcast() {
>     modify_field(intrinsic_metadata.mgid, 1);  // what about  mgid means?
> }
> table dmac {
>     reads {
>         ethernet.dstAddr : exact;                      // Macth + Action,
>  where is the match action? what match with what?
> Does the keyword "exact" means match every thing?
>     }
>     actions {forward; broadcast;}   //In traditonal l2 switch, I think it
> must query existed forwarding tables according the dmac,
>                                                       if cannot find the
> correct entry, the packet will be flood to evey port except it come from,
> but
>                                                       in this example, I
> cannot find the query action.
>     size : 512;  //does the size means dmac  table max count?
> }
> 2) Is there is a standard channel between P4 devices and SDN controller or
> other NOS?
> 3) what does "Auto Generated API" means ?  In http://p4.org/wp-content/
> uploads/2015/03/p4-tutorial-12201423.pdf, page 11.
>     who use this API ?
> 4) Is the metedata and header shared from one pipe line to the other?
> similar to data bus?
> 5) when the ingress pipe line is finished, is the packet deparsered  as
> the egress pipe line's input ? or not deparsered?
> _______________________________________________
> 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/20170406/8d13e975/attachment-0002.html>

More information about the P4-dev mailing list