xdp-project / xdp-tutorial

XDP tutorial
2.43k stars 574 forks source link

Packet flow #257

Open Adarsh97 opened 2 years ago

Adarsh97 commented 2 years ago

I am having some doubts w.r.t the packet flow through xdp, please correct it if I am wrong. Packet will reach to nic. Nic will verify it and store it in its local buffer. Nic will dma the packet to ram. It wil create an interrupt. Driver will service the interrupt, by providing it's address in the rx ring, based on the availability in fill ring. User space will receive packet from rx ring by taking adress from it. Is the above path correct ? How nic understanding the umem area location ? How driver is getting the ring locations. Can I have some docs, I checked in internet not found any complete doc.

Adarsh97 commented 2 years ago

@tohojo @magnus-karlsson is the above idea correct ?

magnus-karlsson commented 2 years ago

The driver provides the NIC with buffer addresses. These are used by the NIC when it gets packets to DMA the packet into. When you have a zero-copy umem, these buffer addresses are taken from the fill ring. If you are in copy mode, internally kernel allocated buffers will be used instead and once DMA is completed the data will be copied out to UMEM. Driver does not need to know the ring locations as this is hidden by the core AF_XDP code.

Take a look at this paper: http://vger.kernel.org/lpc_net2018_talks/lpc18_paper_af_xdp_perf-v2.pdf