p4lang / p4runtime

Specification documents for the P4Runtime control-plane API
Apache License 2.0
140 stars 86 forks source link

Multiple key candidates #398

Open varonen opened 1 year ago

varonen commented 1 year ago

Hi, I would like to use a L2 host table where its key is a mac_addr (48 bits) and exact match. The question is how I can perform a search on that same table with source MAC and another with dest MAC. For each match I would like to take a different action. One way would be to use two tables l2_host_src and l2_host_dest that are mapped to the same physical memory. However, I am not sure that there are any provisions in p4 to force memory mapping. Any ideas?

jfingerh commented 1 year ago

I am not aware of any standard way in P4 to do what you ask for.

I could imagine that there might be particular P4 targets that might let you define two different P4 tables, one for source MAC lookup with its own set of actions, and a separate P4 table for dest MAC lookup with its own set of actions, and some kind of annotation to associate them with each other that tells the compiler back end "the set of keys in these two tables is always the same, because they share key storage with each other". That is not a standard P4 annotation, though.