[P4-dev] How to know the flow_id from a table.

Kamal Bhatt Kamal.Bhatt at stordis.com
Mon Nov 5 05:38:08 EST 2018

Thanks for the example Andy,
By flow_id I mean entry_hdl field which is automatically generated for each entry in the table.
In your example it will be control plane’s responsibility to maintain uniqueness of flow_id, although that can be done.

From: Andy Fingerhut <andy.fingerhut at gmail.com>
Sent: 04 November 2018 18:39
To: Kamal Bhatt <Kamal.Bhatt at stordis.com>
Cc: p4-dev <p4-dev at lists.p4.org>
Subject: Re: [P4-dev] How to know the flow_id from a table.

You may need to explain what 'flow_id on a hit' means in the context you are thinking about it, before anyone can give you an answer.

For example, perhaps by that phrase you mean that you want to get back a 'hardware address' of the matching table entry.  If so, there is no way in the standard language specs for P4_14 or P4_16 to get that.  Some implementations might provide a way to do it as an extension over and above what the language specs require, but for that you would need to consult the documentation for your implementation.  I am pretty sure BMV2 does not implement such an extension.

If by 'flow_id on a hit' you mean 'an id that is different for each table entry, and is chosen by the control plane software when it created the table entry', then that is straightforward -- make the flow_id a parameter of all of the actions for that table, like this (code snippet uses P4_16 syntax):

table t1 {
    action a1 (bit<16> flow_id, // ... other a1 action parameters here
        meta.my_flow_id = flow_id;
        // other a1 action statements go here
    // action a2 and a3 are similar, in that they all have a bit<16> flow_id parameter, and an assignment of it to meta.my_flow_id
    key = {
        // ... table key fields go here, not relevant for this example ...
    actions = { a1; a2; a3; }
    // other table properties go here


On Sun, Nov 4, 2018 at 8:53 AM Kamal Bhatt <Kamal.Bhatt at stordis.com<mailto:Kamal.Bhatt at stordis.com>> wrote:

Hello Everyone,

How to know the flow_id on a hit , in BMV2 for example.​


Kamal Bhatt.
P4-dev mailing list
P4-dev at lists.p4.org<mailto:P4-dev at lists.p4.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20181105/8f36d31f/attachment.html>

More information about the P4-dev mailing list