bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: ethernet: mvneta: fix MVNETA_SKB_HEADROOM alignment
@ 2020-06-05 12:53 Alexander Lobakin
  2020-06-05 20:13 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Lobakin @ 2020-06-05 12:53 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Thomas Petazzoni, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Sven Auhagen,
	Alexander Lobakin, netdev, linux-kernel, bpf

Commit ca23cb0bc50f ("mvneta: MVNETA_SKB_HEADROOM set last 3 bits to zero")
added headroom alignment check against 8.
Hovewer (if we imagine that NET_SKB_PAD or XDP_PACKET_HEADROOM is not
aligned to cacheline size), it actually aligns headroom down, while
skb/xdp_buff headroom should be *at least* equal to one of the values
(depending on XDP prog presence).
So, fix the check to align the value up. This satisfies both
hardware/driver and network stack requirements.

Fixes: ca23cb0bc50f ("mvneta: MVNETA_SKB_HEADROOM set last 3 bits to zero")
Signed-off-by: Alexander Lobakin <bloodyreaper@yandex.ru>
---
 drivers/net/ethernet/marvell/mvneta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 011cd26953d9..4cc9abd61c43 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -325,7 +325,7 @@
 	      cache_line_size())
 
 /* Driver assumes that the last 3 bits are 0 */
-#define MVNETA_SKB_HEADROOM	(max(XDP_PACKET_HEADROOM, NET_SKB_PAD) & ~0x7)
+#define MVNETA_SKB_HEADROOM	ALIGN(max(NET_SKB_PAD, XDP_PACKET_HEADROOM), 8)
 #define MVNETA_SKB_PAD	(SKB_DATA_ALIGN(sizeof(struct skb_shared_info) + \
 			 MVNETA_SKB_HEADROOM))
 #define MVNETA_SKB_SIZE(len)	(SKB_DATA_ALIGN(len) + MVNETA_SKB_PAD)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: ethernet: mvneta: fix MVNETA_SKB_HEADROOM alignment
  2020-06-05 12:53 [PATCH net] net: ethernet: mvneta: fix MVNETA_SKB_HEADROOM alignment Alexander Lobakin
@ 2020-06-05 20:13 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-06-05 20:13 UTC (permalink / raw)
  To: bloodyreaper
  Cc: kuba, thomas.petazzoni, ast, daniel, hawk, john.fastabend,
	sven.auhagen, netdev, linux-kernel, bpf

From: Alexander Lobakin <bloodyreaper@yandex.ru>
Date: Fri,  5 Jun 2020 15:53:24 +0300

> Commit ca23cb0bc50f ("mvneta: MVNETA_SKB_HEADROOM set last 3 bits to zero")
> added headroom alignment check against 8.
> Hovewer (if we imagine that NET_SKB_PAD or XDP_PACKET_HEADROOM is not
> aligned to cacheline size), it actually aligns headroom down, while
> skb/xdp_buff headroom should be *at least* equal to one of the values
> (depending on XDP prog presence).
> So, fix the check to align the value up. This satisfies both
> hardware/driver and network stack requirements.
> 
> Fixes: ca23cb0bc50f ("mvneta: MVNETA_SKB_HEADROOM set last 3 bits to zero")
> Signed-off-by: Alexander Lobakin <bloodyreaper@yandex.ru>

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-05 20:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 12:53 [PATCH net] net: ethernet: mvneta: fix MVNETA_SKB_HEADROOM alignment Alexander Lobakin
2020-06-05 20:13 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).