diff mbox series

[RFC,v3,4/5] Convert netdevsim driver to use ndo_hwtstamp_get/set for hw timestamp requests

Message ID 20230405063330.36287-1-glipus@gmail.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series [RFC,v3,1/5] Add NDOs for hardware timestamp get/set | expand

Checks

Context Check Description
netdev/series_format warning Series does not have a cover letter; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 27 this patch: 27
netdev/cc_maintainers warning 3 maintainers not CCed: edumazet@google.com pabeni@redhat.com davem@davemloft.net
netdev/build_clang fail Errors and warnings before: 44 this patch: 44
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 27 this patch: 27
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 43 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Max Georgiev April 5, 2023, 6:33 a.m. UTC
Changing netdevsim driver to use the newly introduced ndo_hwtstamp_get/set
callback functions instead of implementing full-blown SIOCGHWTSTAMP/
SIOCSHWTSTAMP IOCTLs handling logic.

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Maxim Georgiev <glipus@gmail.com>
---
 drivers/net/netdevsim/netdev.c    | 24 ++++++++++++++++++++++++
 drivers/net/netdevsim/netdevsim.h |  1 +
 2 files changed, 25 insertions(+)

Comments

Vladimir Oltean April 5, 2023, 12:18 p.m. UTC | #1
On Wed, Apr 05, 2023 at 12:33:30AM -0600, Maxim Georgiev wrote:
> Changing netdevsim driver to use the newly introduced ndo_hwtstamp_get/set
> callback functions instead of implementing full-blown SIOCGHWTSTAMP/
> SIOCSHWTSTAMP IOCTLs handling logic.
> 
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Maxim Georgiev <glipus@gmail.com>
> ---

The commit message describes a conversion, but this isn't a conversion,
it's new functionality (which to my eyes is also incomplete).

Also, what happened to:

| I'd vote to split netdevsim out, and it needs a selftest which
| exercises it under tools/testing/selftests/drivers/net/netdevsim/
| to get merged...

https://lore.kernel.org/netdev/20230403141918.3257a195@kernel.org/
Max Georgiev April 5, 2023, 4:35 p.m. UTC | #2
On Wed, Apr 5, 2023 at 6:18 AM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> On Wed, Apr 05, 2023 at 12:33:30AM -0600, Maxim Georgiev wrote:
> > Changing netdevsim driver to use the newly introduced ndo_hwtstamp_get/set
> > callback functions instead of implementing full-blown SIOCGHWTSTAMP/
> > SIOCSHWTSTAMP IOCTLs handling logic.
> >
> > Suggested-by: Jakub Kicinski <kuba@kernel.org>
> > Signed-off-by: Maxim Georgiev <glipus@gmail.com>
> > ---
>
> The commit message describes a conversion, but this isn't a conversion,
> it's new functionality (which to my eyes is also incomplete).

That's true, the commit message is misleading, the patch misses the logic
allowing ethtool to read the timestamp config, and I still don't have test
results for this patch. I didn't get to it yet.
Let me do the right thing and drop patches 4/5 and 5/5 from the stack
temporarily until I get them right.

>
> Also, what happened to:
>
> | I'd vote to split netdevsim out, and it needs a selftest which
> | exercises it under tools/testing/selftests/drivers/net/netdevsim/
> | to get merged...
>
> https://lore.kernel.org/netdev/20230403141918.3257a195@kernel.org/
diff mbox series

Patch

diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 35fa1ca98671..6c29dfa3bb4e 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -238,6 +238,28 @@  nsim_set_features(struct net_device *dev, netdev_features_t features)
 	return 0;
 }
 
+static int
+nsim_hwtstamp_get(struct net_device *dev,
+		  struct kernel_hwtstamp_config *kernel_config,
+		  struct netlink_ext_ack *extack)
+{
+	struct netdevsim *ns = netdev_priv(dev);
+
+	*kernel_config = ns->hw_tstamp_config;
+	return 0;
+}
+
+static int
+nsim_hwtstamp_set(struct net_device *dev,
+		  struct kernel_hwtstamp_config *kernel_config,
+		  struct netlink_ext_ack *extack)
+{
+	struct netdevsim *ns = netdev_priv(dev);
+
+	ns->hw_tstamp_config = *kernel_config;
+	return 0;
+}
+
 static const struct net_device_ops nsim_netdev_ops = {
 	.ndo_start_xmit		= nsim_start_xmit,
 	.ndo_set_rx_mode	= nsim_set_rx_mode,
@@ -256,6 +278,8 @@  static const struct net_device_ops nsim_netdev_ops = {
 	.ndo_setup_tc		= nsim_setup_tc,
 	.ndo_set_features	= nsim_set_features,
 	.ndo_bpf		= nsim_bpf,
+	.ndo_hwtstamp_get	= nsim_hwtstamp_get,
+	.ndo_hwtstamp_set	= nsim_hwtstamp_set,
 };
 
 static const struct net_device_ops nsim_vf_netdev_ops = {
diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h
index 7d8ed8d8df5c..e78e88a0baa1 100644
--- a/drivers/net/netdevsim/netdevsim.h
+++ b/drivers/net/netdevsim/netdevsim.h
@@ -102,6 +102,7 @@  struct netdevsim {
 	} udp_ports;
 
 	struct nsim_ethtool ethtool;
+	struct kernel_hwtstamp_config hw_tstamp_config;
 };
 
 struct netdevsim *