Forum Discussion

torstein18's avatar
torstein18
Icon for New Contributor rankNew Contributor
6 days ago
Solved

XDP on agilex3

Hi

I'm wondering if anybody have been able to implement XDP transmit on an agilex3 soc. As far as I understand the smmc driver should support the full XDP zero copy stack. But when I try to run an example program it just send a few packets then stops. My end goal is to be able to transmit packets close to 1Gbit with minimal CPU usage where the fpga write DMA desscriptor to shared memory then CPU just read them and send directly to NIC using XDP-zero copy. When I use normal sendto/sendmmsg using the linux network stack I only get about 500Mbit with 100% CPU usage. 
Here is the example code I tried to run: 

https://github.com/mas-bandwidth/af_xdp/blob/main/001/

  • Hi Torstein18,

    Stmmac does not implement a full zero‑copy TX path, even on recent kernels. The “few packets then stops” behavior you see is a classic symptom of that gap.

    mas-bandwidth/af_xdp/001 is a pure AF_XDP userspace TX loop.

    On stmmac, what typically happens:

    1. First packets go out (driver does a fallback copy or partial DMA)
    2. TX completion path never frees UMEM frames correctly
    3. TX ring fills up
    4. Kernel stops accepting new descriptors
    5. sendto() succeeds briefly, then silently stalls

    This is not a userspace bug in your example.

    For AF_XDP ZC TX, the driver must implement:

    ndo_xsk_wakeup

    ZC‑capable TX rings

    Correct UMEM lifetime handling

    What does work reliably is XDP_TX / XDP_REDIRECT from an XDP program, not AF_XDP userspace TX ZC.

    You may consider implementing below flow.

    FPGA → shared memory → XDP program → XDP_TX

    Key points:

    • FPGA writes packet buffers into shared memory (ensure cache coherency/IO-MMU mapping is correct).
    • CPU does NOT copy payload
    • XDP program simply sets headers and returns XDP_TX
    • No AF_XDP socket involved

    Hope this is helpful.

    Archer_Altera

2 Replies

  • Archer_Altera's avatar
    Archer_Altera
    Icon for Occasional Contributor rankOccasional Contributor

    Hi Torstein18,

    Stmmac does not implement a full zero‑copy TX path, even on recent kernels. The “few packets then stops” behavior you see is a classic symptom of that gap.

    mas-bandwidth/af_xdp/001 is a pure AF_XDP userspace TX loop.

    On stmmac, what typically happens:

    1. First packets go out (driver does a fallback copy or partial DMA)
    2. TX completion path never frees UMEM frames correctly
    3. TX ring fills up
    4. Kernel stops accepting new descriptors
    5. sendto() succeeds briefly, then silently stalls

    This is not a userspace bug in your example.

    For AF_XDP ZC TX, the driver must implement:

    ndo_xsk_wakeup

    ZC‑capable TX rings

    Correct UMEM lifetime handling

    What does work reliably is XDP_TX / XDP_REDIRECT from an XDP program, not AF_XDP userspace TX ZC.

    You may consider implementing below flow.

    FPGA → shared memory → XDP program → XDP_TX

    Key points:

    • FPGA writes packet buffers into shared memory (ensure cache coherency/IO-MMU mapping is correct).
    • CPU does NOT copy payload
    • XDP program simply sets headers and returns XDP_TX
    • No AF_XDP socket involved

    Hope this is helpful.

    Archer_Altera