[P4-dev] Does P4 imply a specific programming model ?

hemant at mnkcg.com hemant at mnkcg.com
Thu Oct 19 18:12:59 EDT 2017


Vladimir,

 

Got it – thanks.

 

Hemant

 

From: Vladimir Gurevich [mailto:vladimir.gurevich at barefootnetworks.com] 
Sent: Thursday, October 19, 2017 4:13 PM
To: hemant at mnkcg.com
Cc: Chuck Ashley <chuck.ashley4 at gmail.com>; p4-dev <p4-dev at lists.p4.org>
Subject: Re: [P4-dev] Does P4 imply a specific programming model ?

 

Hello Hemant,

 

On slide 31, you speak of active tables.  How is a table determined to be active?  Is it because the table is used in a table.apply()?

 

 

Suppose you have the code that looks like this:

 

t1.apply();

if (hdr.ipv4.isValid()) {

    t2.apply();

    t3.apply();

} else {

    if (t4.apply().hit) {

        t5.apply();

    } else {

        t6.apply();

    }

}

 

Suppose all these tables fit in a single pipeline stage, which is certainly possible if you have enough resources (SRAM, TCAM, etc.) to fit all these tables and

1.	tables t2-t6 do not have to match on the fields that actions in t1 modify
2.	tables t2-t6 and do not modify the same fields actions in t1 modify
3.	table t3 doesn't have to match on the fields that actions in t2 modify
4.	table t3 doesn't have to modify the fields that actions in t2 modify
5.	tables t5-t6 do not have to match on the same fields that actions in t4 modify
6.	tables t5-t6 do not have to modify the same fields actions in t4 modify

Now, let's imagine that we are processing a non-IPv4 packet (hdr.ipv4.isValid() is False) and that this packet will not match any entries in t4 (t.apply().hit is False).

 

When the packet enters the pipeline stage where all these tables are located, here is what might happen (on a highly parallel architecture):

1.	Either all tables t1-t6 will start doing the match or, if the architecture can inexpensively check hdr.ipv4.isValid() condition beforehand, it might even deactivate the match in t2 and t3 (to save energy)
2.	Once the match is complete, each table tN will output the result of the match which is:

1.	Whether there was a hit or a amiss
2.	The chosen action (aN)
3.	The action data for the chosen action

3.	At that point it becomes clear that for this packet the match in t2, t3, and t5 (see above) was a waste (for t2 and t3 it might've been decided earlier, but if not, it will for sure be decided here), but we don't care -- it's hardware and it works in parallel anyways. We declare these tables "inactive" and throw the results away
4.	The remaining tables, i.e. t1, t4 and t6 are "the survivors" and they are declared "active". Note from the conditions before that they all modify different fields (otherwise we would not put them in the same stage).
5.	The last step is to combine actions a1, a4 and a6 into one (because they operate on different fields) and execute them in parallel

Hope that clarifies.

 

Thanks,
Vladimir

 

On Thu, Oct 19, 2017 at 8:48 AM, <hemant at mnkcg.com <mailto:hemant at mnkcg.com> > wrote:

 

From: P4-dev [mailto:p4-dev-bounces at lists.p4.org <mailto:p4-dev-bounces at lists.p4.org> ] On Behalf Of Vladimir Gurevich
Sent: Thursday, October 19, 2017 2:00 AM
To: Chuck Ashley <chuck.ashley4 at gmail.com <mailto:chuck.ashley4 at gmail.com> >
Cc: p4-dev <p4-dev at lists.p4.org <mailto:p4-dev at lists.p4.org> >
Subject: Re: [P4-dev] Does P4 imply a specific programming model ?

 

>In terms of your second question, I think that the presentation I gave at the P4 Developers' Day (P4D2) in May 2017 (https://www.youtube.com/watch?v=DptVDfxjoSk) might provide some useful insights on how this mapping is achieved in practice. 

 

Good talk and slides.  A question:  

 

On slide 31, you speak of active tables.  How is a table determined to be active?  Is it because the table is used in a table.apply()?

 

Thanks,

 

Hemant

 

 

 





 

-- 

Vladimir Gurevich

 

Barefoot Networks

Technical Lead, Customer Engineering

Email: vag at barefootnetworks.com <mailto:vag at barefootnetworks.com> 

Phone: (408) 833-4505

 

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


More information about the P4-dev mailing list