• Maxim Mikityanskiy's avatar
    net/mlx5e: Refactor struct mlx5e_xdp_info · d963fa15
    Maxim Mikityanskiy authored
    Currently, struct mlx5e_xdp_info has some issues that have to be cleaned
    up before the upcoming AF_XDP support makes things too complicated and
    messy. This structure is used both when sending the packet and on
    completion. Moreover, the cleanup procedure on completion depends on the
    origin of the packet (XDP_REDIRECT, XDP_TX). Adding AF_XDP support will
    add new flows that use this structure even differently. To avoid
    overcomplicating the code, this commit refactors the usage of this
    structure in the following ways:
    
    1. struct mlx5e_xdp_info is split into two different structures. One is
    struct mlx5e_xdp_xmit_data, a transient structure that doesn't need to
    be stored and is only used while sending the packet. The other is still
    struct mlx5e_xdp_info that is stored in a FIFO and contains the fields
    needed on completion.
    
    2. The fields of struct mlx5e_xdp_info that are used in different flows
    are put into a union. A special enum indicates the cleanup mode and
    helps choose the right union member. This approach is clear and
    explicit. Although it could be possible to "guess" the mode by looking
    at the values of the fields and at the XDP SQ type, it wouldn't be that
    clear and extendable and would require looking through the whole chain
    to understand what's going on.
    
    For the reference, there are the fields of struct mlx5e_xdp_info that
    are used in different flows (including AF_XDP ones):
    
    Packet origin          | Fields used on completion | Cleanup steps
    -----------------------+---------------------------+------------------
    XDP_REDIRECT,          | xdpf, dma_addr            | DMA unmap and
    XDP_TX from XSK RQ     |                           | xdp_return_frame.
    -----------------------+---------------------------+------------------
    XDP_TX from regular RQ | di                        | Recycle page.
    -----------------------+---------------------------+------------------
    AF_XDP TX              | (none)                    | Increment the
                           |                           | producer index in
                           |                           | Completion Ring.
    
    On send, the same set of mlx5e_xdp_xmit_data fields is used in all
    flows: DMA and virtual addresses and length.
    Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@mellanox.com>
    Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
    Acked-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    d963fa15
xdp.h 5.15 KB