-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify add-on-miss #64
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -930,7 +930,8 @@ property is `true` for a table, the P4 developer is allowed to define | |
a default action for the table that calls the `add_entry` extern | ||
function. `add_entry` adds a new entry to the table whose default | ||
action calls the `add_entry` function. The new entry will have the | ||
same key that was just looked up. | ||
same key that was just looked up. The new entry gets its value, as in | ||
key-value pair, from the parameters to `add_entry`. | ||
|
||
The control plane API is still allowed to add, modify, and delete | ||
entries of such a table, but any entries added via the `add_entry` | ||
|
@@ -940,10 +941,14 @@ sustain `add_entry` calls at a large fraction of their line rate, but | |
it need not be at the same packet rate supported for processing | ||
packets that do not call `add_entry`. The new table entry will be | ||
matchable when the next packet is processed that applies this table. | ||
Use `add_on_miss` with caution because the data plane must have | ||
enough information to verify that adding an entry on miss is correct. | ||
TCP connection tracking is one application to use `add_on_miss`. | ||
|
||
~Begin P4Example | ||
extern bool add_entry<T>(string action_name, | ||
in T action_params); | ||
in T action_params, | ||
in ExpireTimeProfileId_t expire_time_profile_id); | ||
~End P4Example | ||
|
||
It is expected that many PNA implementations will restrict | ||
|
@@ -960,14 +965,33 @@ It is expected that many PNA implementations will restrict | |
names must match the hit action parameter names, and their types | ||
must be the same as the corresponding hit action parameters. | ||
|
||
The new entry will have the same key field values that were | ||
searched for in the table when the miss occurred, which caused the | ||
table's default action to be executed. The action will be the one | ||
named by the string that is passed as the parameter `action_name`. | ||
The new entry will have the same key that was searched for in the table | ||
when the miss occurred, which caused the table's default action to be | ||
executed. The action will be the one named by the string that is passed | ||
as the parameter `action_name`. | ||
|
||
If the attempt to add a table entry succeeds, the return value is | ||
`true`, otherwise `false`. | ||
|
||
An example program is included below using `add_entry`. | ||
|
||
~Begin P4Example | ||
action hit(bit<8> a0, bit<16> a1) {} | ||
action miss(bit<8> a0, bit<16> a1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This program won't compile, I'm nearly certain, because no action parameters are provided to the action I would recommend changing the definition of You could also consider adding a link to a more complete example program such as the one in the examples directory like https://github.com/p4lang/pna/blob/main/examples/pna-example-tcp-connection-tracking.p4 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. I read the P4-16 working doc and see text in |
||
meta.a0 = a0; | ||
meta.a1 = a1; | ||
add_entry("hit", {hdr.a0, hdr.a1}, expire_time_prof_id); | ||
} | ||
|
||
table foo { | ||
key = { hdr.ipv6.src_addr : exact; | ||
hdr.ipv6.dst_addr : exact; | ||
} | ||
add_on_miss = true; | ||
actions = { hit; miss;}; | ||
default_action = miss; | ||
} | ||
~End P4Example | ||
|
||
## Table entry timeout notification {#sec-idle-timeout} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I have said this before, but why a special warning for add-on-miss? Why not for every assignment statement you write? Every action? Every if statement? For all of them, and everything else in a P4 program, the data plane must have enough information to verify that doing that thing is correct. add-on-miss isn't special in that regard.