lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 22 Mar 2022 22:07:20 +0100
From:   Gerhard Engleder <gerhard@...leder-embedded.com>
To:     richardcochran@...il.com, yangbo.lu@....com, davem@...emloft.net,
        kuba@...nel.org
Cc:     mlichvar@...hat.com, vinicius.gomes@...el.com,
        netdev@...r.kernel.org,
        Gerhard Engleder <gerhard@...leder-embedded.com>
Subject: [PATCH net-next v1 4/6] ethtool: Add kernel API for PHC index

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@...leder-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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ