Skip to content

Incorrect mmap arguments regarding Completion / Fill Rings #239

@Vivida1

Description

@Vivida1

https://docs.ebpf.io/linux/concepts/af_xdp/#setting-up-a-xsk

void *{rx,tx,fill,completion}_ring_mmap = mmap(
    NULL,
    offsets.{rx,tx,fr,cr}.desc + ring_size * sizeof(struct xdp_desc),
    PROT_READ|PROT_WRITE,
    MAP_SHARED|MAP_POPULATE,
    fd, 
    {XDP_PGOFF_RX_RING,XDP_PGOFF_TX_RING,XDP_UMEM_PGOFF_FILL_RING,XDP_UMEM_PGOFF_COMPLETION_RING});

sizeof(struct xdp_desc) is only for RX/TX Rings, it should be sizeof(__u64) for Fill/Completion Rings.

See https://github.com/xdp-project/xdp-tools/blob/2074703b0e332d0a39cd86c1b6883ba023284b8d/lib/libxdp/xsk.c#L258 and https://github.com/xdp-project/xdp-tools/blob/2074703b0e332d0a39cd86c1b6883ba023284b8d/lib/libxdp/xsk.c#L1167

So in total it should be something like

void *{rx,tx,fill,completion}_ring_mmap = mmap(
    NULL,
    offsets.{rx,tx,fr,cr}.desc + ring_size * sizeof({struct xdp_desc,__u64}),
    PROT_READ|PROT_WRITE,
    MAP_SHARED|MAP_POPULATE,
    fd, 
    {XDP_PGOFF_RX_RING,XDP_PGOFF_TX_RING,XDP_UMEM_PGOFF_FILL_RING,XDP_UMEM_PGOFF_COMPLETION_RING});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions