Thanks, Stephen, Is it possible to add a new option (XDP_ATTACH_MODE) to AF_XDP PMD https://doc.dpdk.org/guides/nics/af_xdp.html#options ? Because in container scenario, we need to assign xdp attach mode manually. Currently I have a workaround solution, in xsk_configure() function, to get the mode from environment variable and assign to xsk_socket_config.xdp_flags. But it's not easy to maintain for DPDK version upgrades. So here is the request for DPDK AF_XDP PMD to add new option for xdp attach mode in future new release.
========================================================================= static int xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq, int ring_size) { struct xsk_socket_config cfg; struct pkt_tx_queue *txq = rxq->pair; 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); if (ret) { AF_XDP_LOG(DEBUG, "Failed to get enough buffers for fq.\n"); goto out_umem; } else { AF_XDP_LOG(DEBUG, "XDP_UMEM_UNALIGNED_CHUNK_FLAG Got enough buffers for fq.\n"); } #endif /* 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; } else { AF_XDP_LOG(DEBUG, "Reserved fill queue.\n"); } } else { AF_XDP_LOG(DEBUG, "No need to reserve fill queue.\n"); } cfg.rx_size = ring_size; cfg.tx_size = ring_size; cfg.libbpf_flags = 0; cfg.xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST; cfg.bind_flags = 0; /* Force AF_XDP socket into copy mode when users want it */ if (internals->force_copy) cfg.bind_flags |= XDP_COPY; /* #define XDP_FLAGS_UPDATE_IF_NOEXIST (1U << 0) * #define XDP_FLAGS_SKB_MODE (1U << 1) * #define XDP_FLAGS_DRV_MODE (1U << 2) * #define XDP_FLAGS_HW_MODE (1U << 3) */ const char *env_xdp_attach_mode; env_xdp_attach_mode = getenv(XDP_ATTACH_MODE); if (env_xdp_attach_mode) { AF_XDP_LOG(INFO,"XDP attach mode enviroment variable is %s.\n", env_xdp_attach_mode); if (env_xdp_attach_mode[0] == '1' && env_xdp_attach_mode[1] == '\0') cfg.xdp_flags |= XDP_FLAGS_SKB_MODE; else if (env_xdp_attach_mode[0] == '2' && env_xdp_attach_mode[1] == '\0') cfg.xdp_flags |= XDP_FLAGS_DRV_MODE; else if (env_xdp_attach_mode[0] == '3' && env_xdp_attach_mode[1] == '\0') cfg.xdp_flags |= XDP_FLAGS_HW_MODE; else AF_XDP_LOG(INFO,"XDP attach mode enviroment variable shall be 1 or 2 or 3.\n"); } else { AF_XDP_LOG(INFO,"No XDP attach mode enviroment variable.\n"); } ============================================================================================== ________________________________ From: Stephen Hemminger <step...@networkplumber.org> Sent: Thursday, October 24, 2024 12:09 AM To: Xiaohua Wang <xiaohua.w...@ericsson.com> Cc: dev@dpdk.org <dev@dpdk.org> Subject: Re: Can DPDK AF_XDP PMD support macvlan driver in container? [You don't often get email from step...@networkplumber.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] On Wed, 23 Oct 2024 06:07:22 +0000 Xiaohua Wang <xiaohua.w...@ericsson.com> wrote: > Hi, > > dpdk-testpmd with AF_XDP PMD can't work on p1p1 (macvlan) interface, but can > work on eth0 (veth) interface. > > And is there a method to enable AF_XDP PMD to work in XDP SKB mode? Or add > one option to set "SKB mode" in AF_XDP > Options<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoc.dpdk.org%2Fguides%2Fnics%2Faf_xdp.html&data=05%7C02%7Cxiaohua.wang%40ericsson.com%7C14f8bea31e1e4e0ac53108dcf37d1236%7C92e84cebfbfd47abbe52080c6b87953f%7C0%7C0%7C638652965715198137%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=pmAq6ayeNH1K41zMkWbvvcMCsGsAg0RWPflT4zw0Zmo%3D&reserved=0<https://doc.dpdk.org/guides/nics/af_xdp.html>> > ? Maybe a kernel problem not an issue directly with AF_XDP PMD.