* [RFC PATCH v4 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path
@ 2023-04-23 3:28 Maxim Georgiev
2023-04-25 15:58 ` Jakub Kicinski
0 siblings, 1 reply; 6+ messages in thread
From: Maxim Georgiev @ 2023-04-23 3:28 UTC (permalink / raw)
To: kory.maincent
Cc: kuba, netdev, glipus, maxime.chevallier, vladimir.oltean,
vadim.fedorenko, richardcochran, gerhard
This patch makes VLAN and MAXVLAN drivers 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
subsystems falls back to calling ndo_eth_ioctl.
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Maxim Georgiev <glipus@gmail.com>
---
Notes:
Changes in v4:
- Moved hw timestamp get/set request processing logic
from vlan_dev_ioctl() to .ndo_hwtstamp_get/set callbacks.
- Use the shared generic_hwtstamp_get/set_lower() functions
to handle ndo_hwtstamp_get/set requests.
- Applay the same changes to macvlan driver.
---
drivers/net/macvlan.c | 34 +++++++++++++---------------------
net/8021q/vlan_dev.c | 25 ++++++++++++++++++++-----
2 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 4a53debf9d7c..32683d859f5f 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -868,31 +868,22 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu)
return 0;
}
-static int macvlan_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int macvlan_hwtstamp_get(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
{
struct net_device *real_dev = macvlan_dev_real_dev(dev);
- const struct net_device_ops *ops = real_dev->netdev_ops;
- struct ifreq ifrr;
- int err = -EOPNOTSUPP;
- strscpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ);
- ifrr.ifr_ifru = ifr->ifr_ifru;
-
- switch (cmd) {
- case SIOCSHWTSTAMP:
- if (!net_eq(dev_net(dev), &init_net))
- break;
- fallthrough;
- case SIOCGHWTSTAMP:
- if (netif_device_present(real_dev) && ops->ndo_eth_ioctl)
- err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd);
- break;
- }
+ return generic_hwtstamp_get_lower(real_dev, cfg, extack);
+}
- if (!err)
- ifr->ifr_ifru = ifrr.ifr_ifru;
+static int macvlan_hwtstamp_set(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ struct net_device *real_dev = macvlan_dev_real_dev(dev);
- return err;
+ return generic_hwtstamp_set_lower(real_dev, cfg, extack);
}
/*
@@ -1193,7 +1184,6 @@ static const struct net_device_ops macvlan_netdev_ops = {
.ndo_stop = macvlan_stop,
.ndo_start_xmit = macvlan_start_xmit,
.ndo_change_mtu = macvlan_change_mtu,
- .ndo_eth_ioctl = macvlan_eth_ioctl,
.ndo_fix_features = macvlan_fix_features,
.ndo_change_rx_flags = macvlan_change_rx_flags,
.ndo_set_mac_address = macvlan_set_mac_address,
@@ -1212,6 +1202,8 @@ static const struct net_device_ops macvlan_netdev_ops = {
#endif
.ndo_get_iflink = macvlan_dev_get_iflink,
.ndo_features_check = passthru_features_check,
+ .ndo_hwtstamp_get = macvlan_hwtstamp_get,
+ .ndo_hwtstamp_set = macvlan_hwtstamp_set,
};
static void macvlan_dev_free(struct net_device *dev)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 5920544e93e8..38a31dca3bb9 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -353,6 +353,24 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
return 0;
}
+static int vlan_hwtstamp_get(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
+
+ return generic_hwtstamp_get_lower(real_dev, cfg, extack);
+}
+
+static int vlan_hwtstamp_set(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
+
+ return generic_hwtstamp_set_lower(real_dev, cfg, extack);
+}
+
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;
@@ -364,14 +382,9 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
ifrr.ifr_ifru = ifr->ifr_ifru;
switch (cmd) {
- case SIOCSHWTSTAMP:
- if (!net_eq(dev_net(dev), dev_net(real_dev)))
- break;
- fallthrough;
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;
@@ -842,6 +855,8 @@ static const struct net_device_ops vlan_netdev_ops = {
.ndo_fix_features = vlan_dev_fix_features,
.ndo_get_iflink = vlan_dev_get_iflink,
.ndo_fill_forward_path = vlan_dev_fill_forward_path,
+ .ndo_hwtstamp_get = vlan_hwtstamp_get,
+ .ndo_hwtstamp_set = vlan_hwtstamp_set,
};
static void vlan_dev_free(struct net_device *dev)
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC PATCH v4 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path
2023-04-23 3:28 [RFC PATCH v4 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path Maxim Georgiev
@ 2023-04-25 15:58 ` Jakub Kicinski
2023-04-26 4:43 ` Max Georgiev
0 siblings, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2023-04-25 15:58 UTC (permalink / raw)
To: Maxim Georgiev
Cc: kory.maincent, netdev, maxime.chevallier, vladimir.oltean,
vadim.fedorenko, richardcochran, gerhard
On Sat, 22 Apr 2023 21:28:35 -0600 Maxim Georgiev wrote:
> - if (!net_eq(dev_net(dev), &init_net))
> - break;
Did we agree that the net namespace check is no longer needed?
I don't see it anywhere after the changes.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH v4 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path
2023-04-25 15:58 ` Jakub Kicinski
@ 2023-04-26 4:43 ` Max Georgiev
2023-04-26 4:55 ` [RFC PATCH v5 " Maxim Georgiev
2023-04-27 2:37 ` [RFC PATCH v4 " Jakub Kicinski
0 siblings, 2 replies; 6+ messages in thread
From: Max Georgiev @ 2023-04-26 4:43 UTC (permalink / raw)
To: Jakub Kicinski
Cc: kory.maincent, netdev, maxime.chevallier, vladimir.oltean,
vadim.fedorenko, richardcochran, gerhard
On Tue, Apr 25, 2023 at 9:58 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Sat, 22 Apr 2023 21:28:35 -0600 Maxim Georgiev wrote:
> > - if (!net_eq(dev_net(dev), &init_net))
> > - break;
>
> Did we agree that the net namespace check is no longer needed?
> I don't see it anywhere after the changes.
My bad, I was under the impression that you, guys, decided that this
check wasn't needed.
Let me add it back and resend the patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFC PATCH v5 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path
2023-04-26 4:43 ` Max Georgiev
@ 2023-04-26 4:55 ` Maxim Georgiev
2023-04-27 2:37 ` [RFC PATCH v4 " Jakub Kicinski
1 sibling, 0 replies; 6+ messages in thread
From: Maxim Georgiev @ 2023-04-26 4:55 UTC (permalink / raw)
To: kory.maincent
Cc: kuba, netdev, glipus, maxime.chevallier, vladimir.oltean,
vadim.fedorenko, richardcochran, gerhard, liuhangbin
This patch makes VLAN and MAXVLAN drivers 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
subsystems falls back to calling ndo_eth_ioctl.
Suggested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Maxim Georgiev <glipus@gmail.com>
---
Notes:
Changes in v5:
- Re-introduced the net namespace check which
was dropped in v4.
Changes in v4:
- Moved hw timestamp get/set request processing logic
from vlan_dev_ioctl() to .ndo_hwtstamp_get/set callbacks.
- Use the shared generic_hwtstamp_get/set_lower() functions
to handle ndo_hwtstamp_get/set requests.
- Applay the same changes to macvlan driver.
---
drivers/net/macvlan.c | 35 +++++++++++++++--------------------
net/8021q/vlan_dev.c | 28 +++++++++++++++++++++++-----
2 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 4a53debf9d7c..58515c9fdf49 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -868,31 +868,25 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu)
return 0;
}
-static int macvlan_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int macvlan_hwtstamp_get(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
{
struct net_device *real_dev = macvlan_dev_real_dev(dev);
- const struct net_device_ops *ops = real_dev->netdev_ops;
- struct ifreq ifrr;
- int err = -EOPNOTSUPP;
- strscpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ);
- ifrr.ifr_ifru = ifr->ifr_ifru;
+ return generic_hwtstamp_get_lower(real_dev, cfg, extack);
+}
- switch (cmd) {
- case SIOCSHWTSTAMP:
- if (!net_eq(dev_net(dev), &init_net))
- break;
- fallthrough;
- case SIOCGHWTSTAMP:
- if (netif_device_present(real_dev) && ops->ndo_eth_ioctl)
- err = ops->ndo_eth_ioctl(real_dev, &ifrr, cmd);
- break;
- }
+static int macvlan_hwtstamp_set(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ struct net_device *real_dev = macvlan_dev_real_dev(dev);
- if (!err)
- ifr->ifr_ifru = ifrr.ifr_ifru;
+ if (!net_eq(dev_net(dev), &init_net))
+ return -EOPNOTSUPP;
- return err;
+ return generic_hwtstamp_set_lower(real_dev, cfg, extack);
}
/*
@@ -1193,7 +1187,6 @@ static const struct net_device_ops macvlan_netdev_ops = {
.ndo_stop = macvlan_stop,
.ndo_start_xmit = macvlan_start_xmit,
.ndo_change_mtu = macvlan_change_mtu,
- .ndo_eth_ioctl = macvlan_eth_ioctl,
.ndo_fix_features = macvlan_fix_features,
.ndo_change_rx_flags = macvlan_change_rx_flags,
.ndo_set_mac_address = macvlan_set_mac_address,
@@ -1212,6 +1205,8 @@ static const struct net_device_ops macvlan_netdev_ops = {
#endif
.ndo_get_iflink = macvlan_dev_get_iflink,
.ndo_features_check = passthru_features_check,
+ .ndo_hwtstamp_get = macvlan_hwtstamp_get,
+ .ndo_hwtstamp_set = macvlan_hwtstamp_set,
};
static void macvlan_dev_free(struct net_device *dev)
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 5920544e93e8..02c64d4f8d3e 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -353,6 +353,27 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
return 0;
}
+static int vlan_hwtstamp_get(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
+
+ return generic_hwtstamp_get_lower(real_dev, cfg, extack);
+}
+
+static int vlan_hwtstamp_set(struct net_device *dev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
+
+ if (!net_eq(dev_net(dev), &init_net))
+ return -EOPNOTSUPP;
+
+ return generic_hwtstamp_set_lower(real_dev, cfg, extack);
+}
+
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;
@@ -364,14 +385,9 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
ifrr.ifr_ifru = ifr->ifr_ifru;
switch (cmd) {
- case SIOCSHWTSTAMP:
- if (!net_eq(dev_net(dev), dev_net(real_dev)))
- break;
- fallthrough;
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;
@@ -842,6 +858,8 @@ static const struct net_device_ops vlan_netdev_ops = {
.ndo_fix_features = vlan_dev_fix_features,
.ndo_get_iflink = vlan_dev_get_iflink,
.ndo_fill_forward_path = vlan_dev_fill_forward_path,
+ .ndo_hwtstamp_get = vlan_hwtstamp_get,
+ .ndo_hwtstamp_set = vlan_hwtstamp_set,
};
static void vlan_dev_free(struct net_device *dev)
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC PATCH v4 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path
2023-04-26 4:43 ` Max Georgiev
2023-04-26 4:55 ` [RFC PATCH v5 " Maxim Georgiev
@ 2023-04-27 2:37 ` Jakub Kicinski
2023-04-27 4:07 ` Max Georgiev
1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2023-04-27 2:37 UTC (permalink / raw)
To: Max Georgiev
Cc: kory.maincent, netdev, maxime.chevallier, vladimir.oltean,
vadim.fedorenko, richardcochran, gerhard
On Tue, 25 Apr 2023 22:43:34 -0600 Max Georgiev wrote:
> > On Sat, 22 Apr 2023 21:28:35 -0600 Maxim Georgiev wrote:
> > > - if (!net_eq(dev_net(dev), &init_net))
> > > - break;
> >
> > Did we agree that the net namespace check is no longer needed?
> > I don't see it anywhere after the changes.
>
> My bad, I was under the impression that you, guys, decided that this
> check wasn't needed.
> Let me add it back and resend the patch.
My memory holds for like a week at best :)
I was genuinely asking if we agreed, if we did just mention that
in the commit msg and add a link to the discussion :)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH v4 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path
2023-04-27 2:37 ` [RFC PATCH v4 " Jakub Kicinski
@ 2023-04-27 4:07 ` Max Georgiev
0 siblings, 0 replies; 6+ messages in thread
From: Max Georgiev @ 2023-04-27 4:07 UTC (permalink / raw)
To: Jakub Kicinski
Cc: kory.maincent, netdev, maxime.chevallier, vladimir.oltean,
vadim.fedorenko, richardcochran, gerhard
On Wed, Apr 26, 2023 at 8:37 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Tue, 25 Apr 2023 22:43:34 -0600 Max Georgiev wrote:
> > > On Sat, 22 Apr 2023 21:28:35 -0600 Maxim Georgiev wrote:
> > > > - if (!net_eq(dev_net(dev), &init_net))
> > > > - break;
> > >
> > > Did we agree that the net namespace check is no longer needed?
> > > I don't see it anywhere after the changes.
> >
> > My bad, I was under the impression that you, guys, decided that this
> > check wasn't needed.
> > Let me add it back and resend the patch.
>
> My memory holds for like a week at best :)
> I was genuinely asking if we agreed, if we did just mention that
> in the commit msg and add a link to the discussion :)
I looked through the discussion between you and Vladimir on vlan
and maxvlan driver conversion - there were no comments on the namespace
check
(https://lore.kernel.org/netdev/20230406165055.egz32amam6o2bmqu@skbuf/T/)
I guess I was delusional by excluding this check - thank you for catching it!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-27 4:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-23 3:28 [RFC PATCH v4 3/5] Add ndo_hwtstamp_get/set support to vlan/maxvlan code path Maxim Georgiev
2023-04-25 15:58 ` Jakub Kicinski
2023-04-26 4:43 ` Max Georgiev
2023-04-26 4:55 ` [RFC PATCH v5 " Maxim Georgiev
2023-04-27 2:37 ` [RFC PATCH v4 " Jakub Kicinski
2023-04-27 4:07 ` Max Georgiev
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.