net: factor out ethtool invocation of vlan/macvlan drivers
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4510d7cb8b
commit
b1b67dd45a
|
@ -374,36 +374,20 @@ static void macvlan_ethtool_get_drvinfo(struct net_device *dev,
|
||||||
static u32 macvlan_ethtool_get_rx_csum(struct net_device *dev)
|
static u32 macvlan_ethtool_get_rx_csum(struct net_device *dev)
|
||||||
{
|
{
|
||||||
const struct macvlan_dev *vlan = netdev_priv(dev);
|
const struct macvlan_dev *vlan = netdev_priv(dev);
|
||||||
struct net_device *lowerdev = vlan->lowerdev;
|
return dev_ethtool_get_rx_csum(vlan->lowerdev);
|
||||||
|
|
||||||
if (lowerdev->ethtool_ops == NULL ||
|
|
||||||
lowerdev->ethtool_ops->get_rx_csum == NULL)
|
|
||||||
return 0;
|
|
||||||
return lowerdev->ethtool_ops->get_rx_csum(lowerdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int macvlan_ethtool_get_settings(struct net_device *dev,
|
static int macvlan_ethtool_get_settings(struct net_device *dev,
|
||||||
struct ethtool_cmd *cmd)
|
struct ethtool_cmd *cmd)
|
||||||
{
|
{
|
||||||
const struct macvlan_dev *vlan = netdev_priv(dev);
|
const struct macvlan_dev *vlan = netdev_priv(dev);
|
||||||
struct net_device *lowerdev = vlan->lowerdev;
|
return dev_ethtool_get_settings(vlan->lowerdev, cmd);
|
||||||
|
|
||||||
if (!lowerdev->ethtool_ops ||
|
|
||||||
!lowerdev->ethtool_ops->get_settings)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
return lowerdev->ethtool_ops->get_settings(lowerdev, cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 macvlan_ethtool_get_flags(struct net_device *dev)
|
static u32 macvlan_ethtool_get_flags(struct net_device *dev)
|
||||||
{
|
{
|
||||||
const struct macvlan_dev *vlan = netdev_priv(dev);
|
const struct macvlan_dev *vlan = netdev_priv(dev);
|
||||||
struct net_device *lowerdev = vlan->lowerdev;
|
return dev_ethtool_get_flags(vlan->lowerdev);
|
||||||
|
|
||||||
if (!lowerdev->ethtool_ops ||
|
|
||||||
!lowerdev->ethtool_ops->get_flags)
|
|
||||||
return 0;
|
|
||||||
return lowerdev->ethtool_ops->get_flags(lowerdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ethtool_ops macvlan_ethtool_ops = {
|
static const struct ethtool_ops macvlan_ethtool_ops = {
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <linux/dmaengine.h>
|
#include <linux/dmaengine.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
|
|
||||||
|
#include <linux/ethtool.h>
|
||||||
#include <net/net_namespace.h>
|
#include <net/net_namespace.h>
|
||||||
#include <net/dsa.h>
|
#include <net/dsa.h>
|
||||||
#ifdef CONFIG_DCB
|
#ifdef CONFIG_DCB
|
||||||
|
@ -49,7 +50,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct vlan_group;
|
struct vlan_group;
|
||||||
struct ethtool_ops;
|
|
||||||
struct netpoll_info;
|
struct netpoll_info;
|
||||||
/* 802.11 specific */
|
/* 802.11 specific */
|
||||||
struct wireless_dev;
|
struct wireless_dev;
|
||||||
|
@ -1906,6 +1906,28 @@ static inline int skb_bond_should_drop(struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern struct pernet_operations __net_initdata loopback_net_ops;
|
extern struct pernet_operations __net_initdata loopback_net_ops;
|
||||||
|
|
||||||
|
static inline int dev_ethtool_get_settings(struct net_device *dev,
|
||||||
|
struct ethtool_cmd *cmd)
|
||||||
|
{
|
||||||
|
if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
return dev->ethtool_ops->get_settings(dev, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev)
|
||||||
|
{
|
||||||
|
if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum)
|
||||||
|
return 0;
|
||||||
|
return dev->ethtool_ops->get_rx_csum(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32 dev_ethtool_get_flags(struct net_device *dev)
|
||||||
|
{
|
||||||
|
if (!dev->ethtool_ops || !dev->ethtool_ops->get_flags)
|
||||||
|
return 0;
|
||||||
|
return dev->ethtool_ops->get_flags(dev);
|
||||||
|
}
|
||||||
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
#endif /* _LINUX_DEV_H */
|
#endif /* _LINUX_DEV_H */
|
||||||
|
|
|
@ -666,13 +666,7 @@ static int vlan_ethtool_get_settings(struct net_device *dev,
|
||||||
struct ethtool_cmd *cmd)
|
struct ethtool_cmd *cmd)
|
||||||
{
|
{
|
||||||
const struct vlan_dev_info *vlan = vlan_dev_info(dev);
|
const struct vlan_dev_info *vlan = vlan_dev_info(dev);
|
||||||
struct net_device *real_dev = vlan->real_dev;
|
return dev_ethtool_get_settings(vlan->real_dev, cmd);
|
||||||
|
|
||||||
if (!real_dev->ethtool_ops ||
|
|
||||||
!real_dev->ethtool_ops->get_settings)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
return real_dev->ethtool_ops->get_settings(real_dev, cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vlan_ethtool_get_drvinfo(struct net_device *dev,
|
static void vlan_ethtool_get_drvinfo(struct net_device *dev,
|
||||||
|
@ -686,24 +680,13 @@ static void vlan_ethtool_get_drvinfo(struct net_device *dev,
|
||||||
static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
|
static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
|
||||||
{
|
{
|
||||||
const struct vlan_dev_info *vlan = vlan_dev_info(dev);
|
const struct vlan_dev_info *vlan = vlan_dev_info(dev);
|
||||||
struct net_device *real_dev = vlan->real_dev;
|
return dev_ethtool_get_rx_csum(vlan->real_dev);
|
||||||
|
|
||||||
if (real_dev->ethtool_ops == NULL ||
|
|
||||||
real_dev->ethtool_ops->get_rx_csum == NULL)
|
|
||||||
return 0;
|
|
||||||
return real_dev->ethtool_ops->get_rx_csum(real_dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 vlan_ethtool_get_flags(struct net_device *dev)
|
static u32 vlan_ethtool_get_flags(struct net_device *dev)
|
||||||
{
|
{
|
||||||
const struct vlan_dev_info *vlan = vlan_dev_info(dev);
|
const struct vlan_dev_info *vlan = vlan_dev_info(dev);
|
||||||
struct net_device *real_dev = vlan->real_dev;
|
return dev_ethtool_get_flags(vlan->real_dev);
|
||||||
|
|
||||||
if (!(real_dev->features & NETIF_F_HW_VLAN_RX) ||
|
|
||||||
real_dev->ethtool_ops == NULL ||
|
|
||||||
real_dev->ethtool_ops->get_flags == NULL)
|
|
||||||
return 0;
|
|
||||||
return real_dev->ethtool_ops->get_flags(real_dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ethtool_ops vlan_ethtool_ops = {
|
static const struct ethtool_ops vlan_ethtool_ops = {
|
||||||
|
|
Loading…
Reference in New Issue