From: Maxim Georgiev <glipus@gmail.com>
To: kory.maincent@bootlin.com
Cc: kuba@kernel.org, netdev@vger.kernel.org, glipus@gmail.com,
maxime.chevallier@bootlin.com, vladimir.oltean@nxp.com,
vadim.fedorenko@linux.dev, richardcochran@gmail.com,
gerhard@engleder-embedded.com
Subject: [RFC PATCH v3 3/5] Add ndo_hwtstamp_get/set support to vlan code path
Date: Wed, 5 Apr 2023 00:33:23 -0600 [thread overview]
Message-ID: <20230405063323.36270-1-glipus@gmail.com> (raw)
This patch makes VLAN subsystem to use the newly introduced
ndo_hwtstamp_get/set API to pass hw timestamp requests to
underlying NIC drivers in case if these drivers implement
ndo_hwtstamp_get/set functions. Otherwise VLAN·subsystem
falls back to calling ndo_eth_ioctl.
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Maxim Georgiev <glipus@gmail.com>
---
net/8021q/vlan_dev.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 5920544e93e8..66d54c610aa5 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -353,6 +353,44 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
return 0;
}
+static int vlan_dev_hwtstamp(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ const struct net_device_ops *ops = dev->netdev_ops;
+ struct kernel_hwtstamp_config kernel_config = {};
+ struct hwtstamp_config config;
+ int err;
+
+ if (!netif_device_present(dev))
+ return -ENODEV;
+
+ if ((cmd == SIOCSHWTSTAMP && !ops->ndo_hwtstamp_set) ||
+ (cmd == SIOCGHWTSTAMP && !ops->ndo_hwtstamp_get)) {
+ if (ops->ndo_eth_ioctl) {
+ return ops->ndo_eth_ioctl(real_dev, &ifr, cmd);
+ else
+ return -EOPNOTSUPP;
+ }
+
+ kernel_config.ifr = ifr;
+ if (cmd == SIOCSHWTSTAMP) {
+ if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
+ return -EFAULT;
+
+ hwtstamp_config_to_kernel(&kernel_config, &config);
+ err = ops->ndo_hwtstamp_set(dev, &kernel_config, NULL);
+ } else if (cmd == SIOCGHWTSTAMP) {
+ err = ops->ndo_hwtstamp_get(dev, &kernel_config, NULL);
+ }
+
+ if (err)
+ return err;
+
+ hwtstamp_kernel_to_config(&config, &kernel_config);
+ if (copy_to_user(ifr->ifr_data, &config, sizeof(config)))
+ return -EFAULT;
+ return 0;
+}
+
static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
@@ -368,10 +406,12 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
if (!net_eq(dev_net(dev), dev_net(real_dev)))
break;
fallthrough;
+ case SIOCGHWTSTAMP:
+ err = vlan_dev_hwtstamp(real_dev, &ifrr, cmd);
+ break;
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
- case SIOCGHWTSTAMP:
if (netif_device_present(real_dev) && ops->ndo_eth_ioctl)
err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd);
break;
--
2.39.2
next reply other threads:[~2023-04-05 6:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 6:33 Maxim Georgiev [this message]
2023-04-05 12:26 ` [RFC PATCH v3 3/5] Add ndo_hwtstamp_get/set support to vlan code path Vladimir Oltean
2023-04-05 16:19 ` Max Georgiev
2023-04-05 16:28 ` Vladimir Oltean
2023-04-05 15:50 ` kernel test robot
2023-04-05 16:42 ` Jakub Kicinski
2023-04-05 17:03 ` Vladimir Oltean
2023-04-05 17:13 ` Jakub Kicinski
2023-04-05 17:28 ` Vladimir Oltean
2023-04-05 17:34 ` Vladimir Oltean
2023-04-05 17:42 ` Jakub Kicinski
2023-04-05 18:01 ` Vladimir Oltean
2023-04-06 0:00 ` Jakub Kicinski
2023-04-06 6:21 ` Max Georgiev
2023-04-06 15:01 ` Vladimir Oltean
2023-04-06 16:18 ` Max Georgiev
2023-04-06 16:50 ` Vladimir Oltean
2023-04-08 13:56 ` Richard Cochran
2023-04-05 18:33 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230405063323.36270-1-glipus@gmail.com \
--to=glipus@gmail.com \
--cc=gerhard@engleder-embedded.com \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.