Saeed Mahameed 432e629e56 net/mlx4_en: Don't reuse RX page when XDP is set
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: 34db548bfb95 ("mlx4: add page recycling in receive path")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Suggested-by: Martin KaFai Lau <kafai@fb.com>
CC: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-16 14:05:25 -07:00
..
2018-06-12 16:19:22 -07:00
2018-06-30 21:24:18 +09:00
2018-06-25 09:41:37 +02:00
2018-06-04 10:58:12 -07:00
2018-06-30 10:47:46 -07:00
2018-06-15 18:10:01 -03:00
2018-06-07 10:23:33 -07:00
2018-06-12 16:19:22 -07:00
2018-06-12 16:19:22 -07:00
2018-06-12 16:19:22 -07:00
2018-06-30 10:47:46 -07:00
2018-06-12 16:19:22 -07:00
2018-06-16 16:40:36 -07:00
2018-06-11 12:09:19 -07:00
2018-06-12 16:19:22 -07:00
2018-06-28 16:21:35 +09:00
2018-06-12 16:19:22 -07:00
2018-06-24 06:33:54 +08:00
2018-06-07 10:23:33 -07:00
2018-06-25 21:36:45 +08:00
2018-06-12 16:19:22 -07:00
2018-06-04 10:58:12 -07:00
2018-06-15 18:10:01 -03:00
2018-06-12 16:19:22 -07:00
2018-06-07 12:34:37 -07:00
2018-06-12 16:19:22 -07:00
2018-06-14 16:25:43 +09:00
2018-06-11 07:20:17 -07:00
2018-06-27 09:42:16 -07:00
2018-06-12 16:19:22 -07:00
2018-06-12 16:19:22 -07:00
2018-06-26 10:42:31 -07:00
2018-07-01 12:20:20 -07:00
2018-06-12 16:19:22 -07:00
2018-06-28 19:19:10 +09:00
2018-06-12 13:11:26 -07:00
2018-06-12 16:19:22 -07:00
2018-06-16 06:35:02 +09:00
2018-06-05 16:20:22 -07:00
2018-06-12 12:56:02 -07:00
2018-06-23 20:44:11 +08:00