macvlan: Pass SIOC[SG]HWTSTAMP ioctls and get_ts_info to lower device
Subsystems (2)
PATCH 1/1 macvlan: Pass SIOC[SG]HWTSTAMP ioctls and get_ts_info to lower device
This patch allows to enable hardware timestamping on macvlan intefaces and find out capabilities of the lower device.
--- drivers/net/macvlan.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/net/macvlan.c +1 -0
@@ -23,6 +23,7 @@#include <linux/rculist.h> #include <linux/notifier.h> #include <linux/netdevice.h> +#include <linux/net_tstamp.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/if_arp.h>
@@ -942,6 +943,30 @@ static void macvlan_dev_get_stats64(struct net_device *dev,
}
}
+static int macvlan_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +{
+ struct macvlan_dev *vlan = netdev_priv(dev);
+ const struct net_device_ops *ops = vlan->lowerdev->netdev_ops;
+ struct ifreq ifrl;
+ int err = -EOPNOTSUPP;
+
+ strncpy(ifrl.ifr_name, vlan->lowerdev->name, IFNAMSIZ);
+ ifrl.ifr_ifru = ifr->ifr_ifru;
+
+ switch (cmd) {
+ case SIOCGHWTSTAMP:
+ case SIOCSHWTSTAMP:
+ if (ops->ndo_do_ioctl)
+ err = ops->ndo_do_ioctl(vlan->lowerdev, &ifrl, cmd);
+ break;
+ }
+
+ if (!err)
+ ifr->ifr_ifru = ifrl.ifr_ifru;
+
+ return err;
+}
+
static int macvlan_vlan_rx_add_vid(struct net_device *dev,
__be16 proto, u16 vid)
{
@@ -1022,6 +1047,22 @@ static int macvlan_ethtool_get_link_ksettings(struct net_device *dev,
return __ethtool_get_link_ksettings(vlan->lowerdev, cmd);}
+static int macvlan_ethtool_get_ts_info(struct net_device *dev,
+ struct ethtool_ts_info *ts_info)
+{
+ const struct macvlan_dev *vlan = netdev_priv(dev);
+ const struct ethtool_ops *eth_ops = vlan->lowerdev->ethtool_ops;
+
+ if (eth_ops->get_ts_info)
+ return eth_ops->get_ts_info(vlan->lowerdev, ts_info);
+
+ ts_info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
+ SOF_TIMESTAMPING_SOFTWARE;
+ ts_info->phc_index = -1;
+
+ return 0;
+}
+
static netdev_features_t macvlan_fix_features(struct net_device *dev,
netdev_features_t features)
{
@@ -1096,6 +1137,7 @@ static const struct ethtool_ops macvlan_ethtool_ops = {
.get_link = ethtool_op_get_link,
.get_link_ksettings = macvlan_ethtool_get_link_ksettings,
.get_drvinfo = macvlan_ethtool_get_drvinfo,
+ .get_ts_info = macvlan_ethtool_get_ts_info,
};
static const struct net_device_ops macvlan_netdev_ops = {
@@ -1111,6 +1153,7 @@ static const struct net_device_ops macvlan_netdev_ops = {
.ndo_set_rx_mode = macvlan_set_mac_lists,
.ndo_get_stats64 = macvlan_dev_get_stats64,
.ndo_validate_addr = eth_validate_addr,
+ .ndo_do_ioctl = macvlan_do_ioctl,
.ndo_vlan_rx_add_vid = macvlan_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = macvlan_vlan_rx_kill_vid, .ndo_fdb_add = macvlan_fdb_add,
Quoted 3 lines · On Thu, 18 Jan 2018 02:12:34 +0100, [email protected] wrote:
This patch allows to enable hardware timestamping on macvlan intefaces and find out capabilities of the lower device.
Signed-off-by Grzegorz Halat <[email protected]>
NACK. This does not work.
For start, how do you deal with fwd_priv? When a packet is sent to other software ports, it wouldn't be time stamped. And I expect more cases like this to be there in macvlan, I only spent 10 seconds checking it.
Please study how time stamping in the kernel works. A good start is Documentation/networking/timestamping.txt. Then examine all possible packet paths with macvlan, both egress and ingress.
Review
Quoted 12 lines
(quoted diff) +12
-0+static int macvlan_ethtool_get_ts_info(struct net_device *dev, + struct ethtool_ts_info *ts_info) +{ + const struct macvlan_dev *vlan = netdev_priv(dev); + const struct ethtool_ops *eth_ops = vlan->lowerdev->ethtool_ops; + + if (eth_ops->get_ts_info) + return eth_ops->get_ts_info(vlan->lowerdev, ts_info); + + ts_info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | + SOF_TIMESTAMPING_SOFTWARE; + ts_info->phc_index = -1;
What calls skb_tx_timestamp if the driver does not support it?
Jiri