[P4-dev] A problem that has troubled me for a long time

Antonin Bas antonin at barefootnetworks.com
Thu May 11 14:08:29 EDT 2017


We are not advertising PI too much at the moment as it is still very much a
work in progress. We will be announcing the P4 API WG at the upcoming P4
workshop to encourage feedback and contributions to the project.
There is value to both program-independent and program-dependent APIs in my
opinion. As a matter of fact, if you look at the P4 workshop agenda (
http://p4.org/p4-workshop-2017/), you will see a talk by Google engineers
titled "P4 Program-dependent Controller interface for SDN applications". As
you can tell by the title, they will be describing a PD-type interface. In
general the PD API provides compile-time checking, which will limit the
number of runtime errors in your application. On the other hand, a PI API
can only provide runtime checking (of table names, table match keys,
possible actions, ...). The advantage of only exposing the PI to the switch
is that a new P4 program can be pushed to the device without the need to
update / recompile any switch code. My belief is that the right thing to do
in general is to expose both and implement the PD on top of the PI to
reduce code duplication.

Regarding your other questions:
- load_new_config and swap_config_files in bmv2 will not update the
auto-generated API. The bmv2 Thrift interface which exposes these
primitives is completely program-independent and does not know about the
PD. Which is why it is pretty difficult to do P4 program updates when using
the PD. You need to compile the PD for your new P4 program (using
p4-build), re-compile your application to use the new PD (which may require
some big changes in your application depending on the amount of changes in
your P4 program), kill the old application, start the new one and perform a
bmv2 json update when it starts.
- your attachment looks correct at a high-level. There is indeed a DB-like
resource which is accessible by the controller and the PI implementation
and contains the P4 information relevant to the control-plane.

prog.p4 -- P4 compiler --> p4info + bmv2 JSON
  bmv2 JSON ---> bmv2 target
  p4info ---> controller + PI implementation

controller -- | --> gRPC server ---> PI implementation ---> bmv2 target

On Wed, May 10, 2017 at 3:39 AM, <ding.rui at zte.com.cn> wrote:

> Hi,everyone
> I am still confused about PI,PD and auto-generated API.what's
> relationship between them?
> If PI is program-independent, why we need PD? when and who will use
> auto-generated API?
> If I use "load_new_config_file", "swap_config_files" in bmv2, will the auto-generated
> API be updated?
> I write my understanding in the attachment,please point out my errors and
> expain why.
> _______________________________________________
> 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/20170511/61edf983/attachment-0002.html>

More information about the P4-dev mailing list