All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vedang Patel <vedang.patel@intel.com>
To: netdev@vger.kernel.org
Cc: jeffrey.t.kirsher@intel.com, davem@davemloft.net,
	jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	intel-wired-lan@lists.osuosl.org, vinicius.gomes@intel.com,
	l@dorileo.org, jakub.kicinski@netronome.com, m-karicheri2@ti.com,
	sergei.shtylyov@cogentembedded.com, eric.dumazet@gmail.com,
	aaron.f.brown@intel.com, Vedang Patel <vedang.patel@intel.com>
Subject: [PATCH net-next v5 1/7] igb: clear out skb->tstamp after reading the txtime
Date: Fri, 21 Jun 2019 10:28:22 -0700	[thread overview]
Message-ID: <1561138108-12943-2-git-send-email-vedang.patel@intel.com> (raw)
In-Reply-To: <1561138108-12943-1-git-send-email-vedang.patel@intel.com>

If a packet which is utilizing the launchtime feature (via SO_TXTIME socket
option) also requests the hardware transmit timestamp, the hardware
timestamp is not delivered to the userspace. This is because the value in
skb->tstamp is mistaken as the software timestamp.

Applications, like ptp4l, request a hardware timestamp by setting the
SOF_TIMESTAMPING_TX_HARDWARE socket option. Whenever a new timestamp is
detected by the driver (this work is done in igb_ptp_tx_work() which calls
igb_ptp_tx_hwtstamps() in igb_ptp.c[1]), it will queue the timestamp in the
ERR_QUEUE for the userspace to read. When the userspace is ready, it will
issue a recvmsg() call to collect this timestamp.  The problem is in this
recvmsg() call. If the skb->tstamp is not cleared out, it will be
interpreted as a software timestamp and the hardware tx timestamp will not
be successfully sent to the userspace. Look at skb_is_swtx_tstamp() and the
callee function __sock_recv_timestamp() in net/socket.c for more details.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index fc925adbd9fa..f66dae72fe37 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -5688,6 +5688,7 @@ static void igb_tx_ctxtdesc(struct igb_ring *tx_ring,
 	 */
 	if (tx_ring->launchtime_enable) {
 		ts = ns_to_timespec64(first->skb->tstamp);
+		first->skb->tstamp = 0;
 		context_desc->seqnum_seed = cpu_to_le32(ts.tv_nsec / 32);
 	} else {
 		context_desc->seqnum_seed = 0;
-- 
2.7.3


WARNING: multiple messages have this Message-ID (diff)
From: Vedang Patel <vedang.patel@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next v5 1/7] igb: clear out skb->tstamp after reading the txtime
Date: Fri, 21 Jun 2019 10:28:22 -0700	[thread overview]
Message-ID: <1561138108-12943-2-git-send-email-vedang.patel@intel.com> (raw)
In-Reply-To: <1561138108-12943-1-git-send-email-vedang.patel@intel.com>

If a packet which is utilizing the launchtime feature (via SO_TXTIME socket
option) also requests the hardware transmit timestamp, the hardware
timestamp is not delivered to the userspace. This is because the value in
skb->tstamp is mistaken as the software timestamp.

Applications, like ptp4l, request a hardware timestamp by setting the
SOF_TIMESTAMPING_TX_HARDWARE socket option. Whenever a new timestamp is
detected by the driver (this work is done in igb_ptp_tx_work() which calls
igb_ptp_tx_hwtstamps() in igb_ptp.c[1]), it will queue the timestamp in the
ERR_QUEUE for the userspace to read. When the userspace is ready, it will
issue a recvmsg() call to collect this timestamp.  The problem is in this
recvmsg() call. If the skb->tstamp is not cleared out, it will be
interpreted as a software timestamp and the hardware tx timestamp will not
be successfully sent to the userspace. Look at skb_is_swtx_tstamp() and the
callee function __sock_recv_timestamp() in net/socket.c for more details.

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index fc925adbd9fa..f66dae72fe37 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -5688,6 +5688,7 @@ static void igb_tx_ctxtdesc(struct igb_ring *tx_ring,
 	 */
 	if (tx_ring->launchtime_enable) {
 		ts = ns_to_timespec64(first->skb->tstamp);
+		first->skb->tstamp = 0;
 		context_desc->seqnum_seed = cpu_to_le32(ts.tv_nsec / 32);
 	} else {
 		context_desc->seqnum_seed = 0;
-- 
2.7.3


  reply	other threads:[~2019-06-21 17:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 17:28 [PATCH net-next v5 0/7] net/sched: Add txtime-assist support for taprio Vedang Patel
2019-06-21 17:28 ` [Intel-wired-lan] " Vedang Patel
2019-06-21 17:28 ` Vedang Patel [this message]
2019-06-21 17:28   ` [Intel-wired-lan] [PATCH net-next v5 1/7] igb: clear out skb->tstamp after reading the txtime Vedang Patel
2019-06-21 17:28 ` [PATCH net-next v5 2/7] etf: Add skip_sock_check Vedang Patel
2019-06-21 17:28   ` [Intel-wired-lan] " Vedang Patel
2019-06-24 21:40   ` Jakub Kicinski
2019-06-24 21:40     ` [Intel-wired-lan] " Jakub Kicinski
2019-06-24 23:34     ` Patel, Vedang
2019-06-24 23:34       ` [Intel-wired-lan] " Patel, Vedang
2019-06-21 17:28 ` [PATCH net-next v5 3/7] taprio: calculate cycle_time when schedule is installed Vedang Patel
2019-06-21 17:28   ` [Intel-wired-lan] " Vedang Patel
2019-06-21 17:28 ` [PATCH net-next v5 4/7] taprio: Remove inline directive Vedang Patel
2019-06-21 17:28   ` [Intel-wired-lan] " Vedang Patel
2019-06-21 17:28 ` [PATCH net-next v5 5/7] taprio: Add support for txtime-assist mode Vedang Patel
2019-06-21 17:28   ` [Intel-wired-lan] " Vedang Patel
2019-06-23  3:29   ` kbuild test robot
2019-06-23  3:29     ` [Intel-wired-lan] " kbuild test robot
2019-06-21 17:28 ` [PATCH net-next v5 6/7] taprio: make clock reference conversions easier Vedang Patel
2019-06-21 17:28   ` [Intel-wired-lan] " Vedang Patel
2019-06-21 17:28 ` [PATCH net-next v5 7/7] taprio: Adjust timestamps for TCP packets Vedang Patel
2019-06-21 17:28   ` [Intel-wired-lan] " Vedang Patel

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=1561138108-12943-2-git-send-email-vedang.patel@intel.com \
    --to=vedang.patel@intel.com \
    --cc=aaron.f.brown@intel.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jakub.kicinski@netronome.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=l@dorileo.org \
    --cc=m-karicheri2@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=vinicius.gomes@intel.com \
    --cc=xiyou.wangcong@gmail.com \
    /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.