74b46340e2
Kernel v5.10 will introduce the ability to efficiently share a UMEM between AF_XDP sockets bound to different queue ids on the same or different devices. This patch integrates that functionality into the AF_XDP PMD. A PMD will attempt to share a UMEM with others if the shared_umem=1 vdev arg is set. UMEMs can only be shared across PMDs with the same mempool, up to a limited number of PMDs goverened by the size of the given mempool. Sharing UMEMs is not supported for non-zero-copy (aligned) mode. The benefit of sharing UMEM across PMDs is a saving in memory due to not having to register the UMEM multiple times. Throughput was measured to remain within 2% of the default mode (not sharing UMEM). A version of libbpf >= v0.2.0 is required and the appropriate pkg-config file for libbpf must be installed such that meson can determine the version. Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
42 lines
1.2 KiB
C
42 lines
1.2 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright(c) 2020 Intel Corporation.
|
|
*/
|
|
|
|
#include <bpf/xsk.h>
|
|
#include <linux/version.h>
|
|
|
|
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE && \
|
|
defined(RTE_LIBRTE_AF_XDP_PMD_SHARED_UMEM)
|
|
#define ETH_AF_XDP_SHARED_UMEM 1
|
|
#endif
|
|
|
|
#ifdef ETH_AF_XDP_SHARED_UMEM
|
|
static __rte_always_inline int
|
|
create_shared_socket(struct xsk_socket **xsk_ptr,
|
|
const char *ifname,
|
|
__u32 queue_id, struct xsk_umem *umem,
|
|
struct xsk_ring_cons *rx,
|
|
struct xsk_ring_prod *tx,
|
|
struct xsk_ring_prod *fill,
|
|
struct xsk_ring_cons *comp,
|
|
const struct xsk_socket_config *config)
|
|
{
|
|
return xsk_socket__create_shared(xsk_ptr, ifname, queue_id, umem, rx,
|
|
tx, fill, comp, config);
|
|
}
|
|
#else
|
|
static __rte_always_inline int
|
|
create_shared_socket(struct xsk_socket **xsk_ptr __rte_unused,
|
|
const char *ifname __rte_unused,
|
|
__u32 queue_id __rte_unused,
|
|
struct xsk_umem *umem __rte_unused,
|
|
struct xsk_ring_cons *rx __rte_unused,
|
|
struct xsk_ring_prod *tx __rte_unused,
|
|
struct xsk_ring_prod *fill __rte_unused,
|
|
struct xsk_ring_cons *comp __rte_unused,
|
|
const struct xsk_socket_config *config __rte_unused)
|
|
{
|
|
return -1;
|
|
}
|
|
#endif
|