netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyen, Anthony L" <anthony.l.nguyen@intel.com>
To: "davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"Brandeburg, Jesse" <jesse.brandeburg@intel.com>,
	"kurt@linutronix.de" <kurt@linutronix.de>
Cc: "bigeasy@linutronix.de" <bigeasy@linutronix.de>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"ast@kernel.org" <ast@kernel.org>,
	"hawk@kernel.org" <hawk@kernel.org>,
	"lorenzo@kernel.org" <lorenzo@kernel.org>,
	"john.fastabend@gmail.com" <john.fastabend@gmail.com>,
	"alexander.duyck@gmail.com" <alexander.duyck@gmail.com>,
	"ilias.apalodimas@linaro.org" <ilias.apalodimas@linaro.org>,
	"richardcochran@gmail.com" <richardcochran@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"sven.auhagen@voleatech.de" <sven.auhagen@voleatech.de>,
	"intel-wired-lan@lists.osuosl.org"
	<intel-wired-lan@lists.osuosl.org>
Subject: Re: [PATCH net v2] igb: Fix XDP with PTP enabled
Date: Tue, 20 Apr 2021 16:33:33 +0000	[thread overview]
Message-ID: <c1eed5fe05a59f86ff868580e3ae89e251f498ec.camel@intel.com> (raw)
In-Reply-To: <20210419072332.7246-1-kurt@linutronix.de>

On Mon, 2021-04-19 at 09:23 +0200, Kurt Kanzenbach wrote:
> When using native XDP with the igb driver, the XDP frame data doesn't
> point to
> the beginning of the packet. It's off by 16 bytes. Everything works
> as expected
> with XDP skb mode.
> 
> Actually these 16 bytes are used to store the packet timestamps.
> Therefore, pull
> the timestamp before executing any XDP operations and adjust all
> other code
> accordingly. The igc driver does it like that as well.
> 
> Tested with Intel i210 card and AF_XDP sockets.
> 
> Fixes: 9cbc948b5a20 ("igb: add XDP support")
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---

<snip>

> @@ -8683,7 +8676,10 @@ static int igb_clean_rx_irq(struct
> igb_q_vector *q_vector, const int budget)
>  	while (likely(total_packets < budget)) {
>  		union e1000_adv_rx_desc *rx_desc;
>  		struct igb_rx_buffer *rx_buffer;
> +		ktime_t timestamp = 0;
> +		int pkt_offset = 0;
>  		unsigned int size;
> +		void *pktbuf;
>  
>  		/* return some buffers to hardware, one at a time is
> too slow */
>  		if (cleaned_count >= IGB_RX_BUFFER_WRITE) {
> @@ -8703,14 +8699,21 @@ static int igb_clean_rx_irq(struct
> igb_q_vector *q_vector, const int budget)
>  		dma_rmb();
>  
>  		rx_buffer = igb_get_rx_buffer(rx_ring, size,
> &rx_buf_pgcnt);
> +		pktbuf = page_address(rx_buffer->page) + rx_buffer-
> >page_offset;
> +
> +		/* pull rx packet timestamp if available */
> +		if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP))
> {
> +			timestamp = igb_ptp_rx_pktstamp(rx_ring-
> >q_vector,
> +							pktbuf);

The timestamp should be checked for failure and not adjust these values
if the timestamp was invalid.
 
> +			pkt_offset += IGB_TS_HDR_LEN;
> +			size -= IGB_TS_HDR_LEN;
> +		}


  reply	other threads:[~2021-04-20 16:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19  7:23 [PATCH net v2] igb: Fix XDP with PTP enabled Kurt Kanzenbach
2021-04-20 16:33 ` Nguyen, Anthony L [this message]
2021-04-21  6:35   ` Kurt Kanzenbach
2021-04-25 23:09 Tyler S
2021-04-26 14:15 ` Kurt Kanzenbach
2021-04-27 23:11   ` Tyler S
2021-05-03  7:31     ` Kurt Kanzenbach

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=c1eed5fe05a59f86ff868580e3ae89e251f498ec.camel@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=alexander.duyck@gmail.com \
    --cc=ast@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=sven.auhagen@voleatech.de \
    /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 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).