• Jesper Dangaard Brouer's avatar
    xdp: rhashtable with allocator ID to pointer mapping · 8d5d8852
    Jesper Dangaard Brouer authored
    Use the IDA infrastructure for getting a cyclic increasing ID number,
    that is used for keeping track of each registered allocator per
    RX-queue xdp_rxq_info.  Instead of using the IDR infrastructure, which
    uses a radix tree, use a dynamic rhashtable, for creating ID to
    pointer lookup table, because this is faster.
    
    The problem that is being solved here is that, the xdp_rxq_info
    pointer (stored in xdp_buff) cannot be used directly, as the
    guaranteed lifetime is too short.  The info is needed on a
    (potentially) remote CPU during DMA-TX completion time . In an
    xdp_frame the xdp_mem_info is stored, when it got converted from an
    xdp_buff, which is sufficient for the simple page refcnt based recycle
    schemes.
    
    For more advanced allocators there is a need to store a pointer to the
    registered allocator.  Thus, there is a need to guard the lifetime or
    validity of the allocator pointer, which is done through this
    rhashtable ID map to pointer. The removal and validity of of the
    allocator and helper struct xdp_mem_allocator is guarded by RCU.  The
    allocator will be created by the driver, and registered with
    xdp_rxq_info_reg_mem_model().
    
    It is up-to debate who is responsible for freeing the allocator
    pointer or invoking the allocator destructor function.  In any case,
    this must happen via RCU freeing.
    
    Use the IDA infrastructure for getting a cyclic increasing ID number,
    that is used for keeping track of each registered allocator per
    RX-queue xdp_rxq_info.
    
    V4: Per req of Jason Wang
    - Use xdp_rxq_info_reg_mem_model() in all drivers implementing
      XDP_REDIRECT, even-though it's not strictly necessary when
      allocator==NULL for type MEM_TYPE_PAGE_SHARED (given it's zero).
    
    V6: Per req of Alex Duyck
    - Introduce rhashtable_lookup() call in later patch
    
    V8: Address sparse should be static warnings (from kbuild test robot)
    Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    8d5d8852
xdp.c 6.52 KB