DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xiaohua Wang <xiaohua.wang@ericsson.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: 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 ?//Re: Can DPDK AF_XDP PMD support macvlan driver in container?
Date: Thu, 2 Jan 2025 01:52:38 +0000	[thread overview]
Message-ID: <AS8PR07MB9495B86EA3E6C67B676FDCCAFB142@AS8PR07MB9495.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <20241023090923.720a849f@hermes.local>

[-- Attachment #1: Type: text/plain, Size: 4693 bytes --]

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 <stephen@networkplumber.org>
Sent: Thursday, October 24, 2024 12:09 AM
To: Xiaohua Wang <xiaohua.wang@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 stephen@networkplumber.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On Wed, 23 Oct 2024 06:07:22 +0000
Xiaohua Wang <xiaohua.wang@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.


[-- Attachment #2: Type: text/html, Size: 22148 bytes --]

  parent reply	other threads:[~2025-01-05 22:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23  6:07 Xiaohua Wang
2024-10-23 16:09 ` Stephen Hemminger
2024-10-24  1:57   ` Xiaohua Wang
2025-01-02  1:52   ` Xiaohua Wang [this message]
2024-10-24  2:12 ` Stephen Hemminger
2024-10-24  9:16 ` Maryam Tahhan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8PR07MB9495B86EA3E6C67B676FDCCAFB142@AS8PR07MB9495.eurprd07.prod.outlook.com \
    --to=xiaohua.wang@ericsson.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).