• Saeed Mahameed's avatar
    net/mlx4_en: Don't reuse RX page when XDP is set · 432e629e
    Saeed Mahameed authored
    When a new rx packet arrives, the rx path will decide whether to reuse
    the remainder of the page or not according to one of the below conditions:
    1. frag_info->frag_stride == PAGE_SIZE / 2
    2. frags->page_offset + frag_info->frag_size > PAGE_SIZE;
    
    The first condition is no met for when XDP is set.
    For XDP, page_offset is always set to priv->rx_headroom which is
    XDP_PACKET_HEADROOM and frag_info->frag_size is around mtu size + some
    padding, still the 2nd release condition will hold since
    XDP_PACKET_HEADROOM + 1536 < PAGE_SIZE, as a result the page will not
    be released and will be _wrongly_ reused for next free rx descriptor.
    
    In XDP there is an assumption to have a page per packet and reuse can
    break such assumption and might cause packet data corruptions.
    
    Fix this by adding an extra condition (!priv->rx_headroom) to the 2nd
    case to avoid page reuse when XDP is set, since rx_headroom is set to 0
    for non XDP setup and set to XDP_PACKET_HEADROOM for XDP setup.
    
    No additional cache line is required for the new condition.
    
    Fixes: 34db548b ("mlx4: add page recycling in receive path")
    Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
    Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
    Suggested-by: default avatarMartin KaFai Lau <kafai@fb.com>
    CC: Eric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    432e629e
en_rx.c 34.2 KB