[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180118011233.GA14152@HTGD74-02.ds.mot.com>
Date: Thu, 18 Jan 2018 02:12:34 +0100
From: grzegorz.halat@...il.com
To: netdev@...r.kernel.org, davem@...emloft.net
Subject: [PATCH net-next] 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.
Signed-off-by: Grzegorz Halat <grzegorz.halat@...il.com>
---
drivers/net/macvlan.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index a0f2be8..314e878 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -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,
--
2.7.4
Powered by blists - more mailing lists