All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudiu Manoil <claudiu.manoil@nxp.com>
To: netdev@vger.kernel.org
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	james.jurack@ametek.com
Subject: [PATCH net] gianfar: Account for Tx PTP timestamp in the skb headroom
Date: Tue, 20 Oct 2020 20:36:05 +0300	[thread overview]
Message-ID: <20201020173605.1173-1-claudiu.manoil@nxp.com> (raw)
In-Reply-To: <fa12d66e-de52-3e2e-154c-90c775bb4fe4@ametek.com>

When PTP timestamping is enabled on Tx, the controller
inserts the Tx timestamp at the beginning of the frame
buffer, between SFD and the L2 frame header. This means
that the skb provided by the stack is required to have
enough headroom otherwise a new skb needs to be created
by the driver to accommodate the timestamp inserted by h/w.
Up until now the driver was relying on the second option,
using skb_realloc_headroom() to create a new skb to accommodate
PTP frames. Turns out that this method is not reliable, as
reallocation of skbs for PTP frames along with the required
overhead (skb_set_owner_w, consume_skb) is causing random
crashes in subsequent skb_*() calls, when multiple concurrent
TCP streams are run at the same time on the same device
(as seen in James' report).
Note that these crashes don't occur with a single TCP stream,
nor with multiple concurrent UDP streams, but only when multiple
TCP streams are run concurrently with the PTP packet flow
(doing skb reallocation).
This patch enforces the first method, by requesting enough
headroom from the stack to accommodate PTP frames, and so avoiding
skb_realloc_headroom() & co, and the crashes no longer occur.
There's no reason not to set needed_headroom to a large enough
value to accommodate PTP frames, so in this regard this patch
is a fix.

Reported-by: James Jurack <james.jurack@ametek.com>
Fixes: bee9e58c9e98 ("gianfar:don't add FCB length to hard_header_len")
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 41dd3d0f3452..d0842c2c88f3 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -3380,7 +3380,7 @@ static int gfar_probe(struct platform_device *ofdev)
 
 	if (dev->features & NETIF_F_IP_CSUM ||
 	    priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
-		dev->needed_headroom = GMAC_FCB_LEN;
+		dev->needed_headroom = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
 
 	/* Initializing some of the rx/tx queue level parameters */
 	for (i = 0; i < priv->num_tx_queues; i++) {
-- 
2.17.1


  reply	other threads:[~2020-10-20 17:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-14 13:53 PROBLEM: Crash when timestamping outgoing PTP packets under heavy network load (ppc, gianfar) James Jurack
2020-10-20 17:36 ` Claudiu Manoil [this message]
2020-10-21 17:59   ` [PATCH net] gianfar: Account for Tx PTP timestamp in the skb headroom Jakub Kicinski
2020-10-22 12:09     ` Claudiu Manoil
2020-10-23  2:54       ` Jakub Kicinski
2020-10-23 11:37         ` Claudiu Manoil
2020-10-29  8:10 ` [PATCH net v2 1/2] gianfar: Replace skb_realloc_headroom with skb_cow_head for PTP Claudiu Manoil
2020-10-29  8:10   ` [PATCH net v2 2/2] gianfar: Account for Tx PTP timestamp in the skb headroom Claudiu Manoil
2020-10-30 16:41   ` [PATCH net v2 1/2] gianfar: Replace skb_realloc_headroom with skb_cow_head for PTP Jakub Kicinski
2020-11-03 16:13   ` Vladimir Oltean
2020-11-03 16:30     ` Jakub Kicinski
2020-11-03 17:18       ` Claudiu Manoil
2020-11-03 17:30         ` Vladimir Oltean
2020-11-03 17:36           ` Jakub Kicinski
2020-11-03 17:39             ` Jakub Kicinski
2020-11-03 17:51             ` Vladimir Oltean
2020-11-03 17:41           ` Claudiu Manoil
2020-11-03 17:49             ` Vladimir Oltean
2020-11-03 18:16               ` Eric Dumazet
2020-11-04 16:45                 ` Claudiu Manoil
2020-11-03 18:16               ` Vladimir Oltean
2020-11-03 16:36     ` Julian Wiedmann
2020-11-03 17:08       ` Claudiu Manoil
2020-11-03 17:12         ` Jakub Kicinski
2020-11-03 17:24           ` Vladimir Oltean
2020-11-03 17:38             ` Vladimir Oltean
2020-11-03 17:18       ` Vladimir Oltean
2020-11-03 17:27         ` Vladimir Oltean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201020173605.1173-1-claudiu.manoil@nxp.com \
    --to=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=james.jurack@ametek.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.