[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20201002233743.1688517-1-jacob.e.keller@intel.com>
Date: Fri, 2 Oct 2020 16:37:43 -0700
From: Jacob Keller <jacob.e.keller@...el.com>
To: netdev@...r.kernel.org, Richard Cochran <richardcochran@...il.com>
Cc: Jacob Keller <jacob.e.keller@...el.com>
Subject: [RFC net-next] ptp: add clock_index as a device attribute
The PTP clock associated with a networking device is reported by the
ETHTOOL_GET_TS_INFO ioctl, by using the ptp->index clock index variable.
In order to associate this clock index with the proper device,
userspace applications make the assumption that /dev/ptpX has a clock
index of X. If this assumption is wrong, such as if user space renames
a device, then there isn't a mechanism to associate the clock index with
the device.
Add a new device attribute to the device sysfs folder, clock_index,
which will report the exact clock index of the device. This enables
userspace applications to determine the clock_index of the PTP devices
in a more robust way.
Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
---
drivers/ptp/ptp_sysfs.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index be076a91e20e..8ba9556c939a 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -17,6 +17,14 @@ static ssize_t clock_name_show(struct device *dev,
}
static DEVICE_ATTR_RO(clock_name);
+static ssize_t clock_index_show(struct device *dev,
+ struct device_attribute *attr, char *page)
+{
+ struct ptp_clock *ptp = dev_get_drvdata(dev);
+ return snprintf(page, PAGE_SIZE-1, "%d\n", ptp->index);
+}
+static DEVICE_ATTR_RO(clock_index);
+
#define PTP_SHOW_INT(name, var) \
static ssize_t var##_show(struct device *dev, \
struct device_attribute *attr, char *page) \
@@ -150,6 +158,7 @@ static DEVICE_ATTR(pps_enable, 0220, NULL, pps_enable_store);
static struct attribute *ptp_attrs[] = {
&dev_attr_clock_name.attr,
+ &dev_attr_clock_index.attr,
&dev_attr_max_adjustment.attr,
&dev_attr_n_alarms.attr,
base-commit: 0c2a01dc27f68024108b7303002678bd72446a4e
--
2.28.0.497.g54e85e7af1ac
Powered by blists - more mailing lists