-
Notifications
You must be signed in to change notification settings - Fork 38
NDP Switch P4
To get started with the NDP Switch implemented in P4, first clone the NDP repository. The code is in the switch/p4/ndp_router.p4. You need an instalation of the P4 suite to run this project; download the latest one from p4.org.
Note that this implementation has only been tested in the behavioral mode switch (a software P4 switch), so it may not work as is on actual hardware (e.g. the Barefoot Tofino switch).
The design of the P4 implementation of the NDP switch is shown in the figure below. It assumes the existence of at least two queues between the ingress and egress pipelines, with the egress_priority metadata deciding which packet goes into which queue. The NDP modifications are demonstrated on the simple switch device assuming a single output interface, but they could be added to any P4 switch and easily modified to handle multiple output ports.
The implementation needs to know the size of the two per-port queues to decide whether the packet should be trimmed. To this end, it could leverage current queue size registers to make the decision of whether to send packets to the priority queue or not; however not all P4 platforms will have this register, so we have chosen to implement a register with a similar functionality by counting all packets that go into the normal buffer and packets that enter the egress pipeline. As Match/Action tables in P4 only match on packet data, we use an additional table (Readregister) to read qs from the register and save it as packet metadata. If qs is below the allowed buffer size, packets will go in the normal queue. Once we hit the threshold, packets will be truncated (using a P4 primitive action called truncate) and fed into the priority queue. NDP packets without a data payload automatically enter the priority queue, due to the Directprio table. The egress pipeline only handles queue size book-keeping: the qs register is decreased if the packet came from the normal queue.