-
Notifications
You must be signed in to change notification settings - Fork 329
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
Added Recirculation functionality in PNA_NIC #1273
base: main
Are you sure you want to change the base?
Added Recirculation functionality in PNA_NIC #1273
Conversation
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.
All of this looks correct as far as I can tell. Future new P4 program test cases that exercise this new code with p4c compiling the program, then packets passing through pna_nic in the expected ways, are the best assurance of that.
Yes, Will include a test case |
dfae1c6
to
60848c9
Compare
@@ -79,6 +79,7 @@ class PnaNic : public Switch { | |||
|
|||
private: | |||
static packet_id_t packet_id; | |||
static constexpr port_t PNA_PORT_RECIRCULATE = 0xfffffffa; |
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.
There is no mention of a recirculation port in the PNA spec. @jafingerhut is this correct?
All I know is that this is the SDN port value defined by the P4Runtime spec as the recirculation port.
I guess targets are free to "choose" (or define) the value used for the recirculation port.
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.
Yes, there is a recirculate() operation in PNA, and if that is done, then the packet should recirculate when it completes the current execution of the main control. There is NO recirculation port like there is in PSA or v1model architectures.
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.
Note: As an implementation technique, it is probably a reasonable idea to have a C++ boolean or 1-bit flag somewhere associated with the packet in the PNA implementation that is initialized to 0/false whenever a packet begins execution of the main control, and it is set to 1/true when the recirculate() extern function is called.
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 couldn't find a recirculate()
extern function in pna.p4? Is there a reference to it somehere.
If PNA specifies such an extern function, then this is what this PR should introduce (not a special port value). Implementation of the extern function can use a special port value if appropriate (the boolean flag approach you suggested may be a bit more difficult within the constraints of bmv2).
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.
Yes. I didn't find any recirculate()
extern function in pna.p4. So, I followed the PSA implementation.
If introducing a new recirculate()
function is better approach, we can implement that.
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.
Hi @antoninbas, Is the current approach Ok? Or should I change it recirculate() extern approach?
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.
One approach is to wait until there is an official PNA definition for how recirculation is done, and behaves, and implement other features that are already well-defined.
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.
Ok
|
||
phv->get_field("pna_main_parser_input_metadata.recirculated") | ||
.set(1); | ||
input_buffer.push_front(std::move(packet)); |
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.
what's the expected value of pna_main_parser_input_metadata.input_port
for recirculated packets?
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 believe it should be unchanged from the original. Unfortunately some things like this are not yet spelled out in as precise a form in the PNA architecture as they are in the PSA architecture, but I believe "input_port is unchanged after recirculate operation" is a reasonable starting place (and maybe finishing place, too).
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.
Thanks. This is not what the current PR does, but it can be done easily. See PSA implementation:
behavioral-model/targets/psa_switch/psa_switch.cpp
Lines 618 to 619 in 28b736c
phv->get_field("psa_ingress_parser_input_metadata.ingress_port") | |
.set(PSA_PORT_RECIRCULATE); |
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.
Ok. Will update the line.
Just a doubt: Why are we setting ingress_port
field to PSA_PORT_RECIRCULATE
? The P4 programs will find whether the packet is recirculated on not using recirculated_flag
field.
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.
According to @jafingerhut, the port should be set to the original ingress port, not PSA_PORT_RECIRCULATE
But we should still set the port to something. With your current implementation, the port will always be set to 0. At least that's what will happen I think based on the reset_metadata
call (I didn't test).
Signed-off-by: Rupesh Chiluka <[email protected]>
60848c9
to
3da4f69
Compare
Part of #1245 issue.
Need to add below declaration in p4c/p4include/bmv2/pna.p4: