[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230405063330.36287-1-glipus@gmail.com>
Date: Wed, 5 Apr 2023 00:33:30 -0600
From: Maxim Georgiev <glipus@...il.com>
To: kory.maincent@...tlin.com
Cc: kuba@...nel.org, netdev@...r.kernel.org, glipus@...il.com,
maxime.chevallier@...tlin.com, vladimir.oltean@....com,
vadim.fedorenko@...ux.dev, richardcochran@...il.com,
gerhard@...leder-embedded.com
Subject: [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.
Suggested-by: Jakub Kicinski <kuba@...nel.org>
Signed-off-by: Maxim Georgiev <glipus@...il.com>
---
drivers/net/netdevsim/netdev.c | 24 ++++++++++++++++++++++++
drivers/net/netdevsim/netdevsim.h | 1 +
2 files changed, 25 insertions(+)
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 *
--
2.39.2
Powered by blists - more mailing lists