netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: grzegorz.halat@gmail.com
To: netdev@vger.kernel.org, davem@davemloft.net
Subject: [PATCH net-next] macvlan: Pass SIOC[SG]HWTSTAMP ioctls and get_ts_info to lower device
Date: Thu, 18 Jan 2018 02:12:34 +0100	[thread overview]
Message-ID: <20180118011233.GA14152@HTGD74-02.ds.mot.com> (raw)

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@gmail.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,

             reply	other threads:[~2018-01-18  1:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18  1:12 grzegorz.halat [this message]
2018-01-18 10:57 ` [PATCH net-next] macvlan: Pass SIOC[SG]HWTSTAMP ioctls and get_ts_info to lower device Jiri Benc

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=20180118011233.GA14152@HTGD74-02.ds.mot.com \
    --to=grzegorz.halat@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).