[P4-dev] detect port status changes in the dataplane?

Antonin Bas antonin at barefootnetworks.com
Tue Jun 27 13:51:08 EDT 2017


Hi,

There is no mechanism in the P4 v1model to query port status. This is the
architecture (to use the P4_16 terminology) which bmv2 simple_switch tries
to support, so the short answer to your question is no. There is however a
mechanism to send port status updates to the control plane.
AFAIK, the Portable Switch Architecture (PSA), which aims to replace
v1model as the de facto architecture to write portable P4 programs, will
not include such a mechanism either.

That being said, bmv2 itself is supposed to be a framework for implementing
various P4_16 architectures. So were you inclined to define your own
architecture and include an extern type that enables you to query the
status of a port, it should not be too hard to implement your architecture
using the bmv2 C++ library. The major issue I see here is that the p4c
compiler bmv2 backend is still a work in progress and doesn't support
arbitrary architectures with arbitrary externs at this stage. So you would
not be able to compile your programs easily. Once the backend is more
stable (which IMO means once the backend supports PSA), you should be able
to do what you are trying to do with some amount of work.

If you are using P4_14 and the legacy compiler for bmv2 (
https://github.com/p4lang/p4c-bm), it may be much easier to achieve support
for this. You would simply need to define your own primitive action and
implement it in C++ in bmv2 simple_switch. Your primitive action could look
like this: query_port_status(<dest field>, <port number>). Now the C++
implementation may not be trivial, as you would need to get a handler on
the bmv2 PortMonitor object, but that wouldn't be too hard either. If you
are interested in trying this, there should be quite a few email threads on
the mailing list that cover how to add a custom primitive action to the
P4_14 compiler and implement it in bmv2.

Thanks,

Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20170627/c663c238/attachment-0002.html>


More information about the P4-dev mailing list