[P4-dev] [bmv2] Need some help about the stateful merories on P4 programming
antonin at barefootnetworks.com
Thu Sep 8 19:09:42 EDT 2016
As of today we do not support periodic / triggered push notifications from
the switch to the controller, except for learning notifications (e.g. for
L2 learning) and ageing (table entry expiring). It would be a significant
amount of work to modify bmv2 (you mention simple_switch.cpp, but in this
case most of the changes would be in the bmv2 core library, which is a key
part of simple_switch) to actively generate push notifications for stats /
meters / register updates on the switch.
However we are actively working on the P4 runtime APIs and enabling the
switch to generate push notifications is definitely part of our roadmap.
After thinking some more about this, you may be able to use the learning
notification mechanism to proactively send the content of stateful memories
to the controller. For example, let's say you define a register array in
P4, with 1024 32-bit entries. Let's assume that you use these registers as
counters. Based on packet data (e.g. IPv4 src address), you increment one
of the register entries. Now maybe you want the controller to be notified
when the register entry reaches a certain threshold. You could do the
- copy the register entry to a metadata field
- match on this metadata field in a table (e.g. to compare the value to a
threshold) or use a control flow condition
- if your condition is met perform learning (using generate_digest()) in an
action to send a learning notification to the drivers, including the new
register entry value
For an example of a learning P4 program, please refer to
We also have some example code which retrieves learning notifications and
On Thu, Sep 8, 2016 at 7:52 AM, zhilong zheng <zhengzl0715 at gmail.com> wrote:
> Hi guys,
> I am trying to do a research about collecting states of the network(eg.
> states of switches). And I want to present another method for some special
> collecting tasks.
> For example, when collecting the counter state of a switch, I think it's
> better that the switch reports its state proactively to the upper
> application like a controller.
> So, I'd like to know whether it's possible to do such a thing on P4. If
> it's ok, I should do that coding in the .P4 files(p4src) or .cpp files(eg.
> P4-dev mailing list
> P4-dev at lists.p4.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the P4-dev