int ret = 0;
int reserve_size = ETH_AF_XDP_DFLT_NUM_DESCS;
struct rte_mbuf *fq_bufs[reserve_size];
+ bool reserve_before;
rxq->umem = xdp_umem_configure(internals, rxq);
if (rxq->umem == NULL)
return -ENOMEM;
txq->umem = rxq->umem;
+ reserve_before = __atomic_load_n(&rxq->umem->refcnt, __ATOMIC_ACQUIRE) <= 1;
#if defined(XDP_UMEM_UNALIGNED_CHUNK_FLAG)
ret = rte_pktmbuf_alloc_bulk(rxq->umem->mb_pool, fq_bufs, reserve_size);
}
#endif
- ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs, &rxq->fq);
- if (ret) {
- AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
- goto out_umem;
+ /* reserve fill queue of queues not (yet) sharing UMEM */
+ if (reserve_before) {
+ ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs, &rxq->fq);
+ if (ret) {
+ AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
+ goto out_umem;
+ }
}
cfg.rx_size = ring_size;
cfg.bind_flags |= XDP_USE_NEED_WAKEUP;
#endif
- if (strnlen(internals->prog_path, PATH_MAX) &&
- !internals->custom_prog_configured) {
- ret = load_custom_xdp_prog(internals->prog_path,
- internals->if_index,
- &internals->map);
- if (ret) {
- AF_XDP_LOG(ERR, "Failed to load custom XDP program %s\n",
- internals->prog_path);
- goto out_umem;
+ if (strnlen(internals->prog_path, PATH_MAX)) {
+ if (!internals->custom_prog_configured) {
+ ret = load_custom_xdp_prog(internals->prog_path,
+ internals->if_index,
+ &internals->map);
+ if (ret) {
+ AF_XDP_LOG(ERR, "Failed to load custom XDP program %s\n",
+ internals->prog_path);
+ goto out_umem;
+ }
+ internals->custom_prog_configured = 1;
}
- internals->custom_prog_configured = 1;
- cfg.libbpf_flags = XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;
+ cfg.libbpf_flags |= XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;
}
if (internals->shared_umem)
goto out_umem;
}
+ if (!reserve_before) {
+ /* reserve fill queue of queues sharing UMEM */
+ ret = reserve_fill_queue(rxq->umem, reserve_size, fq_bufs, &rxq->fq);
+ if (ret) {
+ AF_XDP_LOG(ERR, "Failed to reserve fill queue.\n");
+ goto out_xsk;
+ }
+ }
+
/* insert the xsk into the xsks_map */
if (internals->custom_prog_configured) {
int err, fd;