netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gerhard Engleder <gerhard@engleder-embedded.com>
To: richardcochran@gmail.com, yangbo.lu@nxp.com, davem@davemloft.net,
	kuba@kernel.org
Cc: mlichvar@redhat.com, vinicius.gomes@intel.com,
	netdev@vger.kernel.org,
	Gerhard Engleder <gerhard@engleder-embedded.com>
Subject: [PATCH net-next v1 4/6] ethtool: Add kernel API for PHC index
Date: Tue, 22 Mar 2022 22:07:20 +0100	[thread overview]
Message-ID: <20220322210722.6405-5-gerhard@engleder-embedded.com> (raw)
In-Reply-To: <20220322210722.6405-1-gerhard@engleder-embedded.com>

Add a new function, which returns the physical clock index of a
networking device. This function will be used to get the physical clock
of a device for timestamp manipulation in the receive path.

Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
---
 include/linux/ethtool.h |  8 ++++++++
 net/ethtool/common.c    | 13 +++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 4af58459a1e7..e107069f37a4 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -820,6 +820,14 @@ void
 ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings,
 			      enum ethtool_link_mode_bit_indices link_mode);
 
+/**
+ * ethtool_get_phc - Get phc index
+ * @dev: pointer to net_device structure
+ *
+ * Return index of phc
+ */
+int ethtool_get_phc(struct net_device *dev);
+
 /**
  * ethtool_get_phc_vclocks - Derive phc vclocks information, and caller
  *                           is responsible to free memory of vclock_index
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 0c5210015911..8218e3b3e98a 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -557,6 +557,19 @@ int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
 	return 0;
 }
 
+int ethtool_get_phc(struct net_device *dev)
+{
+	struct ethtool_ts_info info;
+	int ret;
+
+	ret = __ethtool_get_ts_info(dev, &info);
+	if (ret)
+		return ret;
+
+	return info.phc_index;
+}
+EXPORT_SYMBOL(ethtool_get_phc);
+
 int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index)
 {
 	struct ethtool_ts_info info = { };
-- 
2.20.1


  parent reply	other threads:[~2022-03-22 21:07 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 21:07 [PATCH net-next v1 0/6] ptp: Support hardware clocks with additional free running time Gerhard Engleder
2022-03-22 21:07 ` [PATCH net-next v1 1/6] ptp: Add cycles support for virtual clocks Gerhard Engleder
2022-03-24 13:43   ` Richard Cochran
2022-03-24 19:39     ` Gerhard Engleder
2022-03-22 21:07 ` [PATCH net-next v1 2/6] ptp: Request cycles for TX timestamp Gerhard Engleder
2022-03-24 13:49   ` Richard Cochran
2022-03-24 13:55     ` Miroslav Lichvar
2022-03-24 19:43     ` Gerhard Engleder
2022-03-22 21:07 ` [PATCH net-next v1 3/6] ptp: Pass hwtstamp to ptp_convert_timestamp() Gerhard Engleder
2022-03-24 13:50   ` Richard Cochran
2022-03-22 21:07 ` Gerhard Engleder [this message]
2022-03-24 13:51   ` [PATCH net-next v1 4/6] ethtool: Add kernel API for PHC index Richard Cochran
2022-03-22 21:07 ` [PATCH net-next v1 5/6] ptp: Support late timestamp determination Gerhard Engleder
2022-03-23  0:54   ` kernel test robot
2022-03-23  1:05   ` kernel test robot
2022-03-23  2:06   ` kernel test robot
2022-03-24 14:01   ` Richard Cochran
2022-03-24 19:52     ` Gerhard Engleder
2022-03-25  0:04       ` Richard Cochran
2022-03-25  0:08         ` Richard Cochran
2022-03-25 20:51           ` Gerhard Engleder
2022-03-26  0:27   ` Vinicius Costa Gomes
2022-03-22 21:07 ` [PATCH net-next v1 6/6] tsnep: Add physical clock cycles support Gerhard Engleder
2022-03-25  0:01 ` [PATCH net-next v1 0/6] ptp: Support hardware clocks with additional free running time Vinicius Costa Gomes
2022-03-25 22:01   ` Gerhard Engleder

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=20220322210722.6405-5-gerhard@engleder-embedded.com \
    --to=gerhard@engleder-embedded.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=vinicius.gomes@intel.com \
    --cc=yangbo.lu@nxp.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 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).