p4lang / p4-spec

Apache License 2.0
175 stars 80 forks source link

[PSA] cpu_port semantics #321

Closed hanw closed 6 years ago

hanw commented 7 years ago

What does "send to CPU" mean? (CPU_PORT semantics)

DGeorgeNetro commented 7 years ago

I believe it means the packet either originates from the packet_out API or destined to the packet_in API at the controller, see: https://github.com/p4lang/PI/blob/master/proto/p4/p4runtime.proto

vgurevich commented 7 years ago

@DGeorgeNetro ,

I think this is a good start, but it confirms my point that the definition of the CPU port requires some terminology that lies outside of P4 :), because from P4 perspective it is just another port that happens to send/receive packets with some additional headers, defined by a particular data plane program (or it might send/receive exact same packets as any other port).

Whether the control plane has to use a different API to communicate with this port or not really depends on the particulars of a given API.

We can say that CPU_PORT is such a port that if you send a packet into it it is expected to reach the control plane (and vice versa), and that each PSA device is expected to have one such port.

DGeorgeNetro commented 7 years ago

Quite right, your description makes sense.

There seem to be movements in the PI to link P4 metadata to runtime as well, ie @controller_metadata("packet_in") and @controller_metadata("packet_out"). I suspect this may have dataplane implementation implications as well which may need to be represented in the PSA spec. I wouldn't close this off until that behaviour has been finalised.

jafingerhut commented 6 years ago

Recomendation: Add a few sentences to the PSA that point to the part of the P4 Runtime API spec that is specifically about sending packets from controller to a device and having the device process it via its P4 program (from the PSA perspective, the 'from CPU port' packet path), and for sending packets from a device to the controller (from the PSA perspective, 'to the CPU port'), which mentions how the bits/bytes of the P4 Runtime API calls turn into the bits/bytes in the packets as seen by PSA.

jafingerhut commented 6 years ago

Perhaps this comment by Antonin Bas would be a good reference to link to for this: https://github.com/p4lang/PI/issues/183#issuecomment-319161250

jafingerhut commented 6 years ago

I have created a PR that adds a few sentences to the PSA specification here: https://github.com/p4lang/p4-spec/pull/570

They simply mention that P4 Runtime "Packet Out" becomes a PSA input packet on the CPU port, and a packet that a PSA device sends out on its CPU port becomes a P4 Runtime "Packet In" packet. Also that there is no P4 metadata carried with such packets -- only the headers that the P4 code explicitly emits when sending the packet to the CPU port.

It does mention that some fields in headers may be numerically translated, e.g. fields with type PortId_t at least are expected to have this happen on these packets. Other than that, though, I am not aware of any plans to modify such packets between a controller and a PSA device.

jafingerhut commented 6 years ago

PR merged in, so closing this issue.