From mboxrd@z Thu Jan 1 00:00:00 1970 From: grzegorz.halat@gmail.com 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 Message-ID: <20180118011233.GA14152@HTGD74-02.ds.mot.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: netdev@vger.kernel.org, davem@davemloft.net Return-path: Received: from mail-lf0-f68.google.com ([209.85.215.68]:43002 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752294AbeARBMi (ORCPT ); Wed, 17 Jan 2018 20:12:38 -0500 Received: by mail-lf0-f68.google.com with SMTP id q17so14196222lfa.9 for ; Wed, 17 Jan 2018 17:12:37 -0800 (PST) Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: This patch allows to enable hardware timestamping on macvlan intefaces and find out capabilities of the lower device. Signed-off-by: Grzegorz Halat --- 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 #include #include +#include #include #include #include @@ -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,