Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Muhammad Husaini Zulkifli <muhammad.husaini.zulkifli@intel.com>
To: intel-wired-lan@osuosl.org
Cc: leon@kernel.org, netdev@vger.kernel.org,
	richardcochran@gmail.com, saeed@kernel.org, edumazet@google.com,
	gal@nvidia.com, kuba@kernel.org, michael.chan@broadcom.com,
	muhammad.husaini.zulkifli@intel.com, davem@davemloft.net,
	andy@greyhouse.net
Subject: [Intel-wired-lan] [PATCH v2 3/5] net: sock: extend SO_TIMESTAMPING for DMA Fetch
Date: Tue, 18 Oct 2022 09:07:31 +0800	[thread overview]
Message-ID: <20221018010733.4765-4-muhammad.husaini.zulkifli@intel.com> (raw)
In-Reply-To: <20221018010733.4765-1-muhammad.husaini.zulkifli@intel.com>

This patch is to extend SO_TIMESTAMPING API to support the DMA Time
Stamp by adding a new flag SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH.
User space application can configure this flag into hwtstamp_config flag
if require to use the DMA Time Stamp for that socket application.

Suggested-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Muhammad Husaini Zulkifli <muhammad.husaini.zulkifli@intel.com>
---
 include/linux/skbuff.h          | 3 +++
 include/uapi/linux/net_tstamp.h | 6 ++++--
 net/ethtool/common.c            | 1 +
 net/socket.c                    | 3 +++
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9fcf534f2d92..49f0ef60701a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -485,6 +485,9 @@ enum {
 
 	/* generate software time stamp when entering packet scheduling */
 	SKBTX_SCHED_TSTAMP = 1 << 6,
+
+	/* generate hardware DMA time stamp */
+	SKBTX_HW_DMA_TSTAMP = 1 << 7,
 };
 
 #define SKBTX_ANY_SW_TSTAMP	(SKBTX_SW_TSTAMP    | \
diff --git a/include/uapi/linux/net_tstamp.h b/include/uapi/linux/net_tstamp.h
index 4966d5ca521f..c9e113cea883 100644
--- a/include/uapi/linux/net_tstamp.h
+++ b/include/uapi/linux/net_tstamp.h
@@ -31,8 +31,9 @@ enum {
 	SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),
 	SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14),
 	SOF_TIMESTAMPING_BIND_PHC = (1 << 15),
+	SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH = (1 << 16),
 
-	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_BIND_PHC,
+	SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH,
 	SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
 				 SOF_TIMESTAMPING_LAST
 };
@@ -45,7 +46,8 @@ enum {
 #define SOF_TIMESTAMPING_TX_RECORD_MASK	(SOF_TIMESTAMPING_TX_HARDWARE | \
 					 SOF_TIMESTAMPING_TX_SOFTWARE | \
 					 SOF_TIMESTAMPING_TX_SCHED | \
-					 SOF_TIMESTAMPING_TX_ACK)
+					 SOF_TIMESTAMPING_TX_ACK | \
+					 SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH)
 
 /**
  * struct so_timestamping - SO_TIMESTAMPING parameter
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index f2a178d162ef..24f8e7f9b4a5 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -403,6 +403,7 @@ const char sof_timestamping_names[][ETH_GSTRING_LEN] = {
 	[const_ilog2(SOF_TIMESTAMPING_OPT_PKTINFO)]  = "option-pktinfo",
 	[const_ilog2(SOF_TIMESTAMPING_OPT_TX_SWHW)]  = "option-tx-swhw",
 	[const_ilog2(SOF_TIMESTAMPING_BIND_PHC)]     = "bind-phc",
+	[const_ilog2(SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH)]	= "hardware-dma-transmit",
 };
 static_assert(ARRAY_SIZE(sof_timestamping_names) == __SOF_TIMESTAMPING_CNT);
 
diff --git a/net/socket.c b/net/socket.c
index ab5d8973e719..9e2175685f4e 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -695,6 +695,9 @@ void __sock_tx_timestamp(__u32 tsflags, __u8 *tx_flags)
 			flags |= SKBTX_HW_TSTAMP_USE_CYCLES;
 	}
 
+	if (tsflags & SOF_TIMESTAMPING_TX_HARDWARE_DMA_FETCH)
+		flags |= SKBTX_HW_DMA_TSTAMP;
+
 	if (tsflags & SOF_TIMESTAMPING_TX_SOFTWARE)
 		flags |= SKBTX_SW_TSTAMP;
 
-- 
2.17.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

  parent reply	other threads:[~2022-10-18  1:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18  1:07 [Intel-wired-lan] [PATCH v2 0/5] Add support for DMA timestamp for non-PTP packets Muhammad Husaini Zulkifli
2022-10-18  1:07 ` [Intel-wired-lan] [PATCH v2 1/5] ethtool: Add new hwtstamp flag Muhammad Husaini Zulkifli
2022-10-18  1:07 ` [Intel-wired-lan] [PATCH v2 2/5] net-timestamp: Increase the size of tsflags Muhammad Husaini Zulkifli
2022-10-18  5:57   ` Paul Menzel
2022-10-18 12:42     ` Zulkifli, Muhammad Husaini
2022-10-18  1:07 ` Muhammad Husaini Zulkifli [this message]
2022-10-18  1:07 ` [Intel-wired-lan] [PATCH v2 4/5] igc: Add support for DMA timestamp for non-PTP packets Muhammad Husaini Zulkifli
2022-10-20 22:39   ` Jacob Keller
2022-10-18  1:07 ` [Intel-wired-lan] [PATCH v2 5/5] ethtool: Add support for HWTSTAMP_FILTER_DMA_TIMESTAMP Muhammad Husaini Zulkifli
2022-10-18 11:45 ` [Intel-wired-lan] [PATCH v2 0/5] Add support for DMA timestamp for non-PTP packets Richard Cochran
2022-10-18 14:12   ` Zulkifli, Muhammad Husaini
2022-10-19  2:37     ` Richard Cochran
2022-10-21  0:25       ` Zulkifli, Muhammad Husaini
2022-10-21 12:48         ` Richard Cochran
2022-10-21 15:16           ` Jakub Kicinski
2022-10-18 14:23 ` Gal Pressman
2022-10-19 14:23   ` Zulkifli, Muhammad Husaini
2022-10-23  7:15     ` Gal Pressman
2022-10-18 19:02 ` Jakub Kicinski
2022-10-20  2:16   ` Zulkifli, Muhammad Husaini
2022-10-20  2:47     ` Jakub Kicinski

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=20221018010733.4765-4-muhammad.husaini.zulkifli@intel.com \
    --to=muhammad.husaini.zulkifli@intel.com \
    --cc=andy@greyhouse.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=intel-wired-lan@osuosl.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=saeed@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox