• Tirthendu Sarkar's avatar
    xsk: add support for AF_XDP multi-buffer on Rx path · 80462775
    Tirthendu Sarkar authored
    Add multi-buffer support for AF_XDP by extending the XDP multi-buffer
    support to be reflected in user-space when a packet is redirected to
    an AF_XDP socket.
    
    In the XDP implementation, the NIC driver builds the xdp_buff from the
    first frag of the packet and adds any subsequent frags in the skb_shinfo
    area of the xdp_buff. In AF_XDP core, XDP buffers are allocated from
    xdp_sock's pool and data is copied from the driver's xdp_buff and frags.
    
    Once an allocated XDP buffer is full and there is still data to be
    copied, the 'XDP_PKT_CONTD' flag in'options' field of the corresponding
    xdp ring descriptor is set and passed to the application. When application
    sees the aforementioned flag set it knows there is pending data for this
    packet that will be carried in the following descriptors. If there is no
    more data to be copied, the flag in 'options' field is cleared for that
    descriptor signalling EOP to the application.
    
    If application reads a batch of descriptors using for example the libxdp
    interfaces, it is not guaranteed that the batch will end with a full
    packet. It might end in the middle of a packet and the rest of the frames
    of that packet will arrive at the beginning of the next batch.
    
    AF_XDP ensures that only a complete packet (along with all its frags) is
    sent to application.
    Signed-off-by: default avatarTirthendu Sarkar <tirthendu.sarkar@intel.com>
    Link: https://lore.kernel.org/r/20230719132421.584801-6-maciej.fijalkowski@intel.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    80462775
xsk.c 34.9 KB