All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC V1 net-next 3/4] net: Let the active time stamping layer be selectable.
@ 2022-01-03 23:25 Richard Cochran
  2022-01-03 23:53 ` Russell King (Oracle)
                   ` (3 more replies)
  0 siblings, 4 replies; 31+ messages in thread
From: Richard Cochran @ 2022-01-03 23:25 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Andrew Lunn, David Miller, Grygorii Strashko,
	Jakub Kicinski, Joakim Zhang, Kurt Kanzenbach, Miroslav Lichvar,
	Russell King, Vladimir Oltean

Make the sysfs knob writable, and add checks in the ioctl and time
stamping paths to respect the currently selected time stamping layer.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 .../ABI/testing/sysfs-class-net-timestamping  |  5 +-
 net/core/dev_ioctl.c                          | 44 ++++++++++++++--
 net/core/net-sysfs.c                          | 50 +++++++++++++++++--
 net/core/timestamping.c                       |  6 +++
 net/ethtool/common.c                          | 18 +++++--
 5 files changed, 111 insertions(+), 12 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-class-net-timestamping b/Documentation/ABI/testing/sysfs-class-net-timestamping
index 529c3a6eb607..6dfd59740cad 100644
--- a/Documentation/ABI/testing/sysfs-class-net-timestamping
+++ b/Documentation/ABI/testing/sysfs-class-net-timestamping
@@ -11,7 +11,10 @@ What:		/sys/class/net/<iface>/current_timestamping_provider
 Date:		January 2022
 Contact:	Richard Cochran <richardcochran@gmail.com>
 Description:
-		Show the current SO_TIMESTAMPING provider.
+		Shows or sets the current SO_TIMESTAMPING provider.
+		When changing the value, some packets in the kernel
+		networking stack may still be delivered with time
+		stamps from the previous provider.
 		The possible values are:
 		- "mac"  The MAC provides time stamping.
 		- "phy"  The PHY or MII device provides time stamping.
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 1b807d119da5..269068ce3a51 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -260,6 +260,43 @@ static int dev_eth_ioctl(struct net_device *dev,
 	return err;
 }
 
+static int dev_hwtstamp_ioctl(struct net_device *dev,
+			      struct ifreq *ifr, unsigned int cmd)
+{
+	const struct net_device_ops *ops = dev->netdev_ops;
+	int err;
+
+	err = dsa_ndo_eth_ioctl(dev, ifr, cmd);
+	if (err == 0 || err != -EOPNOTSUPP)
+		return err;
+
+	if (!netif_device_present(dev))
+		return -ENODEV;
+
+	switch (dev->selected_timestamping_layer) {
+
+	case MAC_TIMESTAMPING:
+		if (ops->ndo_do_ioctl == phy_do_ioctl) {
+			/* Some drivers set .ndo_do_ioctl to phy_do_ioctl. */
+			err = -EOPNOTSUPP;
+		} else {
+			err = ops->ndo_eth_ioctl(dev, ifr, cmd);
+		}
+		break;
+
+	case PHY_TIMESTAMPING:
+		if (phy_has_hwtstamp(dev->phydev)) {
+			err = phy_mii_ioctl(dev->phydev, ifr, cmd);
+		} else {
+			err = -ENODEV;
+			WARN_ON(1);
+		}
+		break;
+	}
+
+	return err;
+}
+
 static int dev_siocbond(struct net_device *dev,
 			struct ifreq *ifr, unsigned int cmd)
 {
@@ -395,6 +432,9 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data,
 			return err;
 		fallthrough;
 
+	case SIOCGHWTSTAMP:
+		return dev_hwtstamp_ioctl(dev, ifr, cmd);
+
 	/*
 	 *	Unknown or private ioctl
 	 */
@@ -405,9 +445,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data,
 
 		if (cmd == SIOCGMIIPHY ||
 		    cmd == SIOCGMIIREG ||
-		    cmd == SIOCSMIIREG ||
-		    cmd == SIOCSHWTSTAMP ||
-		    cmd == SIOCGHWTSTAMP) {
+		    cmd == SIOCSMIIREG) {
 			err = dev_eth_ioctl(dev, ifr, cmd);
 		} else if (cmd == SIOCBONDENSLAVE ||
 		    cmd == SIOCBONDRELEASE ||
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 4ff7ef417c38..c27f01a1a285 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -664,17 +664,59 @@ static ssize_t current_timestamping_provider_show(struct device *dev,
 	if (!rtnl_trylock())
 		return restart_syscall();
 
-	if (phy_has_tsinfo(phydev)) {
-		ret = sprintf(buf, "%s\n", "phy");
-	} else {
+	switch (netdev->selected_timestamping_layer) {
+	case MAC_TIMESTAMPING:
 		ret = sprintf(buf, "%s\n", "mac");
+		break;
+	case PHY_TIMESTAMPING:
+		ret = sprintf(buf, "%s\n", "phy");
+		break;
 	}
 
 	rtnl_unlock();
 
 	return ret;
 }
-static DEVICE_ATTR_RO(current_timestamping_provider);
+
+static ssize_t current_timestamping_provider_store(struct device *dev,
+						   struct device_attribute *attr,
+						   const char *buf, size_t len)
+{
+	struct net_device *netdev = to_net_dev(dev);
+	struct net *net = dev_net(netdev);
+	enum timestamping_layer flavor;
+
+	if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
+		return -EPERM;
+
+	if (!strcmp(buf, "mac\n"))
+		flavor = MAC_TIMESTAMPING;
+	else if (!strcmp(buf, "phy\n"))
+		flavor = PHY_TIMESTAMPING;
+	else
+		return -EINVAL;
+
+	if (!rtnl_trylock())
+		return restart_syscall();
+
+	if (!dev_isalive(netdev))
+		goto out;
+
+	if (netdev->selected_timestamping_layer != flavor) {
+		const struct net_device_ops *ops = netdev->netdev_ops;
+		struct ifreq ifr = {0};
+
+		/* Disable time stamping in the current layer. */
+		if (netif_device_present(netdev) && ops->ndo_eth_ioctl)
+			ops->ndo_eth_ioctl(netdev, &ifr, SIOCSHWTSTAMP);
+
+		netdev->selected_timestamping_layer = flavor;
+	}
+out:
+	rtnl_unlock();
+	return len;
+}
+static DEVICE_ATTR_RW(current_timestamping_provider);
 
 static struct attribute *net_class_attrs[] __ro_after_init = {
 	&dev_attr_netdev_group.attr,
diff --git a/net/core/timestamping.c b/net/core/timestamping.c
index 04840697fe79..31c3142787b7 100644
--- a/net/core/timestamping.c
+++ b/net/core/timestamping.c
@@ -28,6 +28,9 @@ void skb_clone_tx_timestamp(struct sk_buff *skb)
 	if (!skb->sk)
 		return;
 
+	if (skb->dev->selected_timestamping_layer != PHY_TIMESTAMPING)
+		return;
+
 	type = classify(skb);
 	if (type == PTP_CLASS_NONE)
 		return;
@@ -50,6 +53,9 @@ bool skb_defer_rx_timestamp(struct sk_buff *skb)
 	if (!skb->dev || !skb->dev->phydev || !skb->dev->phydev->mii_ts)
 		return false;
 
+	if (skb->dev->selected_timestamping_layer != PHY_TIMESTAMPING)
+		return false;
+
 	if (skb_headroom(skb) < ETH_HLEN)
 		return false;
 
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 651d18eef589..7b50820c1d1d 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -545,10 +545,20 @@ int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
 	memset(info, 0, sizeof(*info));
 	info->cmd = ETHTOOL_GET_TS_INFO;
 
-	if (phy_has_tsinfo(phydev))
-		return phy_ts_info(phydev, info);
-	if (ops->get_ts_info)
-		return ops->get_ts_info(dev, info);
+	switch (dev->selected_timestamping_layer) {
+
+	case MAC_TIMESTAMPING:
+		if (ops->get_ts_info)
+			return ops->get_ts_info(dev, info);
+		break;
+
+	case PHY_TIMESTAMPING:
+		if (phy_has_tsinfo(phydev)) {
+			return phy_ts_info(phydev, info);
+		}
+		WARN_ON(1);
+		return -ENODEV;
+	}
 
 	info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
 				SOF_TIMESTAMPING_SOFTWARE;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread
* Re: [PATCH RFC V1 net-next 3/4] net: Let the active time stamping layer be selectable.
@ 2022-01-10 15:46 kernel test robot
  0 siblings, 0 replies; 31+ messages in thread
From: kernel test robot @ 2022-01-10 15:46 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 18183 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220103232555.19791-4-richardcochran@gmail.com>
References: <20220103232555.19791-4-richardcochran@gmail.com>
TO: Richard Cochran <richardcochran@gmail.com>

Hi Richard,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Richard-Cochran/Make-MAC-PHY-time-stamping-selectable/20220104-072717
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 3d694552fd8fe502e7ffd22ffa0e085bfd73b19a
:::::: branch date: 7 days ago
:::::: commit date: 7 days ago
config: x86_64-randconfig-c007-20220105 (https://download.01.org/0day-ci/archive/20220110/202201102352.6hOYMc7y-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d5b6e30ed3acad794dd0aec400e617daffc6cc3d)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/33070417b78b3844a2b2f55f94313072859da977
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Richard-Cochran/Make-MAC-PHY-time-stamping-selectable/20220104-072717
        git checkout 33070417b78b3844a2b2f55f94313072859da977
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
                              ^
   include/linux/compiler_types.h:302:3: note: expanded from macro '__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
            ^
   drivers/infiniband/core/addr.c:508:28: note: Left side of '||' is false
           struct net_device *ndev = READ_ONCE(dst->dev);
                                     ^
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                              ^
   include/linux/compiler_types.h:302:3: note: expanded from macro '__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
            ^
   drivers/infiniband/core/addr.c:508:28: note: Left side of '||' is false
           struct net_device *ndev = READ_ONCE(dst->dev);
                                     ^
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:21: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                              ^
   include/linux/compiler_types.h:302:3: note: expanded from macro '__native_word'
           (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \
            ^
   drivers/infiniband/core/addr.c:508:28: note: Left side of '||' is true
           struct net_device *ndev = READ_ONCE(dst->dev);
                                     ^
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:38: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
                                               ^
   drivers/infiniband/core/addr.c:508:28: note: Taking false branch
           struct net_device *ndev = READ_ONCE(dst->dev);
                                     ^
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:2: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
           ^
   include/linux/compiler_types.h:335:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:323:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:315:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/infiniband/core/addr.c:508:28: note: Loop condition is false.  Exiting loop
           struct net_device *ndev = READ_ONCE(dst->dev);
                                     ^
   include/asm-generic/rwonce.h:49:2: note: expanded from macro 'READ_ONCE'
           compiletime_assert_rwonce_type(x);                              \
           ^
   include/asm-generic/rwonce.h:36:2: note: expanded from macro 'compiletime_assert_rwonce_type'
           compiletime_assert(__native_word(t) || sizeof(t) == sizeof(long long),  \
           ^
   include/linux/compiler_types.h:335:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:323:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:307:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   drivers/infiniband/core/addr.c:508:28: note: Dereference of null pointer
           struct net_device *ndev = READ_ONCE(dst->dev);
                                     ^
   include/asm-generic/rwonce.h:50:2: note: expanded from macro 'READ_ONCE'
           __READ_ONCE(x);                                                 \
           ^~~~~~~~~~~~~~
   include/asm-generic/rwonce.h:44:24: note: expanded from macro '__READ_ONCE'
   #define __READ_ONCE(x)  (*(const volatile __unqual_scalar_typeof(x) *)&(x))
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   net/core/net-sysfs.c:632:2: warning: Value stored to 'ops' is never read [clang-analyzer-deadcode.DeadStores]
           ops = netdev->ethtool_ops;
           ^     ~~~~~~~~~~~~~~~~~~~
   net/core/net-sysfs.c:632:2: note: Value stored to 'ops' is never read
           ops = netdev->ethtool_ops;
           ^     ~~~~~~~~~~~~~~~~~~~
   net/core/net-sysfs.c:642:3: warning: Value stored to 'buf' is never read [clang-analyzer-deadcode.DeadStores]
                   buf += 4;
                   ^      ~
   net/core/net-sysfs.c:642:3: note: Value stored to 'buf' is never read
                   buf += 4;
                   ^      ~
>> net/core/net-sysfs.c:661:2: warning: Value stored to 'phydev' is never read [clang-analyzer-deadcode.DeadStores]
           phydev = netdev->phydev;
           ^        ~~~~~~~~~~~~~~
   net/core/net-sysfs.c:661:2: note: Value stored to 'phydev' is never read
           phydev = netdev->phydev;
           ^        ~~~~~~~~~~~~~~
   net/core/net-sysfs.c:662:2: warning: Value stored to 'ops' is never read [clang-analyzer-deadcode.DeadStores]
           ops = netdev->ethtool_ops;
           ^     ~~~~~~~~~~~~~~~~~~~
   net/core/net-sysfs.c:662:2: note: Value stored to 'ops' is never read
           ops = netdev->ethtool_ops;
           ^     ~~~~~~~~~~~~~~~~~~~
   net/core/net-sysfs.c:1871:2: warning: Value stored to 'txq' is never read [clang-analyzer-deadcode.DeadStores]
           txq = real_tx;
           ^     ~~~~~~~
   net/core/net-sysfs.c:1871:2: note: Value stored to 'txq' is never read
           txq = real_tx;
           ^     ~~~~~~~
   Suppressed 11 warnings (8 in non-user code, 3 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   57 warnings generated.
   Suppressed 57 warnings (57 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   net/core/drop_monitor.c:870:2: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
           kfree(hw_metadata->fa_cookie);
           ^
   net/core/drop_monitor.c:941:6: note: Assuming field 'trap_type' is not equal to DEVLINK_TRAP_TYPE_CONTROL
           if (metadata->trap_type == DEVLINK_TRAP_TYPE_CONTROL)
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                      ^~~~
   net/core/drop_monitor.c:941:2: note: '?' condition is false
           if (metadata->trap_type == DEVLINK_TRAP_TYPE_CONTROL)
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                 ^
   net/core/drop_monitor.c:941:16: note: Field 'trap_type' is not equal to DEVLINK_TRAP_TYPE_CONTROL
           if (metadata->trap_type == DEVLINK_TRAP_TYPE_CONTROL)
                         ^
   net/core/drop_monitor.c:941:2: note: '?' condition is false
           if (metadata->trap_type == DEVLINK_TRAP_TYPE_CONTROL)
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   net/core/drop_monitor.c:941:2: note: Taking false branch
           if (metadata->trap_type == DEVLINK_TRAP_TYPE_CONTROL)
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   net/core/drop_monitor.c:944:2: note: '?' condition is false
           if (!skb_mac_header_was_set(skb))
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                 ^
   net/core/drop_monitor.c:944:2: note: '?' condition is false
           if (!skb_mac_header_was_set(skb))
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   net/core/drop_monitor.c:944:2: note: Taking false branch
           if (!skb_mac_header_was_set(skb))
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   net/core/drop_monitor.c:948:6: note: Assuming 'nskb' is non-null
           if (!nskb)

vim +/phydev +661 net/core/net-sysfs.c

5fdd2f0e5c6484 Wei Wang        2021-02-08  620  
c7ffd872b92c08 Richard Cochran 2022-01-03  621  static ssize_t available_timestamping_providers_show(struct device *dev,
c7ffd872b92c08 Richard Cochran 2022-01-03  622  						     struct device_attribute *attr,
c7ffd872b92c08 Richard Cochran 2022-01-03  623  						     char *buf)
c7ffd872b92c08 Richard Cochran 2022-01-03  624  {
c7ffd872b92c08 Richard Cochran 2022-01-03  625  	const struct ethtool_ops *ops;
c7ffd872b92c08 Richard Cochran 2022-01-03  626  	struct net_device *netdev;
c7ffd872b92c08 Richard Cochran 2022-01-03  627  	struct phy_device *phydev;
c7ffd872b92c08 Richard Cochran 2022-01-03  628  	int ret = 0;
c7ffd872b92c08 Richard Cochran 2022-01-03  629  
c7ffd872b92c08 Richard Cochran 2022-01-03  630  	netdev = to_net_dev(dev);
c7ffd872b92c08 Richard Cochran 2022-01-03  631  	phydev = netdev->phydev;
c7ffd872b92c08 Richard Cochran 2022-01-03 @632  	ops = netdev->ethtool_ops;
c7ffd872b92c08 Richard Cochran 2022-01-03  633  
c7ffd872b92c08 Richard Cochran 2022-01-03  634  	if (!rtnl_trylock())
c7ffd872b92c08 Richard Cochran 2022-01-03  635  		return restart_syscall();
c7ffd872b92c08 Richard Cochran 2022-01-03  636  
c7ffd872b92c08 Richard Cochran 2022-01-03  637  	ret += sprintf(buf, "%s\n", "mac");
c7ffd872b92c08 Richard Cochran 2022-01-03  638  	buf += 4;
c7ffd872b92c08 Richard Cochran 2022-01-03  639  
c7ffd872b92c08 Richard Cochran 2022-01-03  640  	if (phy_has_tsinfo(phydev)) {
c7ffd872b92c08 Richard Cochran 2022-01-03  641  		ret += sprintf(buf, "%s\n", "phy");
c7ffd872b92c08 Richard Cochran 2022-01-03  642  		buf += 4;
c7ffd872b92c08 Richard Cochran 2022-01-03  643  	}
c7ffd872b92c08 Richard Cochran 2022-01-03  644  
c7ffd872b92c08 Richard Cochran 2022-01-03  645  	rtnl_unlock();
c7ffd872b92c08 Richard Cochran 2022-01-03  646  
c7ffd872b92c08 Richard Cochran 2022-01-03  647  	return ret;
c7ffd872b92c08 Richard Cochran 2022-01-03  648  }
c7ffd872b92c08 Richard Cochran 2022-01-03  649  static DEVICE_ATTR_RO(available_timestamping_providers);
c7ffd872b92c08 Richard Cochran 2022-01-03  650  
c7ffd872b92c08 Richard Cochran 2022-01-03  651  static ssize_t current_timestamping_provider_show(struct device *dev,
c7ffd872b92c08 Richard Cochran 2022-01-03  652  						  struct device_attribute *attr,
c7ffd872b92c08 Richard Cochran 2022-01-03  653  						  char *buf)
c7ffd872b92c08 Richard Cochran 2022-01-03  654  {
c7ffd872b92c08 Richard Cochran 2022-01-03  655  	const struct ethtool_ops *ops;
c7ffd872b92c08 Richard Cochran 2022-01-03  656  	struct net_device *netdev;
c7ffd872b92c08 Richard Cochran 2022-01-03  657  	struct phy_device *phydev;
c7ffd872b92c08 Richard Cochran 2022-01-03  658  	int ret;
c7ffd872b92c08 Richard Cochran 2022-01-03  659  
c7ffd872b92c08 Richard Cochran 2022-01-03  660  	netdev = to_net_dev(dev);
c7ffd872b92c08 Richard Cochran 2022-01-03 @661  	phydev = netdev->phydev;
c7ffd872b92c08 Richard Cochran 2022-01-03  662  	ops = netdev->ethtool_ops;
c7ffd872b92c08 Richard Cochran 2022-01-03  663  
c7ffd872b92c08 Richard Cochran 2022-01-03  664  	if (!rtnl_trylock())
c7ffd872b92c08 Richard Cochran 2022-01-03  665  		return restart_syscall();
c7ffd872b92c08 Richard Cochran 2022-01-03  666  
33070417b78b38 Richard Cochran 2022-01-03  667  	switch (netdev->selected_timestamping_layer) {
33070417b78b38 Richard Cochran 2022-01-03  668  	case MAC_TIMESTAMPING:
c7ffd872b92c08 Richard Cochran 2022-01-03  669  		ret = sprintf(buf, "%s\n", "mac");
33070417b78b38 Richard Cochran 2022-01-03  670  		break;
33070417b78b38 Richard Cochran 2022-01-03  671  	case PHY_TIMESTAMPING:
33070417b78b38 Richard Cochran 2022-01-03  672  		ret = sprintf(buf, "%s\n", "phy");
33070417b78b38 Richard Cochran 2022-01-03  673  		break;
c7ffd872b92c08 Richard Cochran 2022-01-03  674  	}
c7ffd872b92c08 Richard Cochran 2022-01-03  675  
c7ffd872b92c08 Richard Cochran 2022-01-03  676  	rtnl_unlock();
c7ffd872b92c08 Richard Cochran 2022-01-03  677  
c7ffd872b92c08 Richard Cochran 2022-01-03  678  	return ret;
c7ffd872b92c08 Richard Cochran 2022-01-03  679  }
33070417b78b38 Richard Cochran 2022-01-03  680  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2022-04-06 13:48 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 23:25 [PATCH RFC V1 net-next 3/4] net: Let the active time stamping layer be selectable Richard Cochran
2022-01-03 23:53 ` Russell King (Oracle)
2022-01-04  1:42   ` Richard Cochran
2022-04-04 15:05     ` Michael Walle
2022-04-04 15:20       ` Andrew Lunn
2022-04-04 17:12         ` Michael Walle
2022-04-05  5:59           ` Richard Cochran
2022-04-05  8:48             ` Michael Walle
2022-04-05 15:46               ` Richard Cochran
2022-04-05  9:01           ` Kurt Kanzenbach
2022-04-05  9:19             ` Michael Walle
2022-04-05 11:19               ` Kurt Kanzenbach
2022-04-05 13:15                 ` Grygorii Strashko
2022-04-05 13:29                   ` Andrew Lunn
2022-04-05 15:48                     ` Richard Cochran
2022-04-06 11:18                       ` Grygorii Strashko
2022-01-04  6:29 ` kernel test robot
2022-01-04  6:50 ` kernel test robot
2022-01-20 16:48 ` Vladimir Oltean
2022-01-21  3:38   ` Andrew Lunn
2022-01-21  4:05     ` Richard Cochran
2022-01-21 14:50       ` Vladimir Oltean
2022-01-21 15:28         ` Richard Cochran
2022-01-21 16:23           ` Vladimir Oltean
2022-01-22  2:08             ` Richard Cochran
2022-01-24  9:28           ` Miroslav Lichvar
2022-01-24 15:37             ` Richard Cochran
2022-01-25 15:37               ` Vladimir Oltean
2022-01-21 11:05   ` Kurt Kanzenbach
2022-01-21 15:31     ` Richard Cochran
2022-01-10 15:46 kernel test robot

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.