aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-09-16 05:17:26 -0400
committerDavid S. Miller <davem@davemloft.net>2012-09-19 15:40:15 -0400
commit2c60db037034d27f8c636403355d52872da92f81 (patch)
tree68efc9ad7d95069bbc84feeb24bc58d250610ba3 /net/core
parent828de4f6bf6e785f7b5497f8f7cfd4d4fbcfdb7e (diff)
net: provide a default dev->ethtool_ops
Instead of forcing device drivers to provide empty ethtool_ops or tweak net/core/ethtool.c again, we could provide a generic ethtool_ops. This occurred to me when I wanted to add GSO support to GRE tunnels. ethtool -k support should be generic for all drivers. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Ben Hutchings <bhutchings@solarflare.com> Cc: Maciej Żenczykowski <maze@google.com> Reviewed-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/ethtool.c12
2 files changed, 4 insertions, 12 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index bb42eb161969..bbda81997f4f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5974,6 +5974,8 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
5974 return queue; 5974 return queue;
5975} 5975}
5976 5976
5977static const struct ethtool_ops default_ethtool_ops;
5978
5977/** 5979/**
5978 * alloc_netdev_mqs - allocate network device 5980 * alloc_netdev_mqs - allocate network device
5979 * @sizeof_priv: size of private data to allocate space for 5981 * @sizeof_priv: size of private data to allocate space for
@@ -6061,6 +6063,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
6061 6063
6062 strcpy(dev->name, name); 6064 strcpy(dev->name, name);
6063 dev->group = INIT_NETDEV_GROUP; 6065 dev->group = INIT_NETDEV_GROUP;
6066 if (!dev->ethtool_ops)
6067 dev->ethtool_ops = &default_ethtool_ops;
6064 return dev; 6068 return dev;
6065 6069
6066free_all: 6070free_all:
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index cbf033dcaf1f..4d64cc2e3fa9 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1426,18 +1426,6 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
1426 if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd))) 1426 if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
1427 return -EFAULT; 1427 return -EFAULT;
1428 1428
1429 if (!dev->ethtool_ops) {
1430 /* A few commands do not require any driver support,
1431 * are unprivileged, and do not change anything, so we
1432 * can take a shortcut to them. */
1433 if (ethcmd == ETHTOOL_GDRVINFO)
1434 return ethtool_get_drvinfo(dev, useraddr);
1435 else if (ethcmd == ETHTOOL_GET_TS_INFO)
1436 return ethtool_get_ts_info(dev, useraddr);
1437 else
1438 return -EOPNOTSUPP;
1439 }
1440
1441 /* Allow some commands to be done by anyone */ 1429 /* Allow some commands to be done by anyone */
1442 switch (ethcmd) { 1430 switch (ethcmd) {
1443 case ETHTOOL_GSET: 1431 case ETHTOOL_GSET: