Skip to contentSkip to conversation

Convert netdevsim driver to use ndo_hwtstamp_get/set for hw timestamp requests

RFC PATCH In review Maxim Georgiev 2 participants 3 messages Apr 5, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

Changing netdevsim driver to use the newly introduced ndo_hwtstamp_get/set callback functions instead of implementing full-blown SIOCGHWTSTAMP/ SIOCSHWTSTAMP IOCTLs handling logic.

---
 drivers/net/netdevsim/netdev.c    | 24 ++++++++++++++++++++++++
 drivers/net/netdevsim/netdevsim.h |  1 +
 2 files changed, 25 insertions(+)
drivers/net/netdevsim/netdev.c +24 -0
index 35fa1ca98671..6c29dfa3bb4e 100644
@@ -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 = {
drivers/net/netdevsim/netdevsim.h +1 -0
index 7d8ed8d8df5c..e78e88a0baa1 100644
@@ -102,6 +102,7 @@ struct netdevsim {
 	} udp_ports;
 
 	struct nsim_ethtool ethtool;
+	struct kernel_hwtstamp_config hw_tstamp_config;
 };
 
 struct netdevsim *
Signature · 1 line
2.39.2
#1 lore raw
Quoted 7 lines · Maxim Georgiev

Changing netdevsim driver to use the newly introduced ndo_hwtstamp_get/set callback functions instead of implementing full-blown SIOCGHWTSTAMP/ SIOCSHWTSTAMP IOCTLs handling logic.

---

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/[email protected]/

#2 lore raw
Quoted 6 lines · Vladimir Oltean
Quoted 4 lines · Maxim Georgiev

Changing netdevsim driver to use the newly introduced ndo_hwtstamp_get/set callback functions instead of implementing full-blown SIOCGHWTSTAMP/ SIOCSHWTSTAMP IOCTLs handling logic.

Quoted 6 lines
Quoted 3 lines

---

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.

Quoted 8 lines

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/[email protected]/