2 * net/core/ethtool.c - Ethtool ioctl handler
3 * Copyright (c) 2003 Matthew Wilcox <matthew@wil.cx>
5 * This file is where we call all the ethtool_ops commands to get
6 * the information ethtool needs.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/capability.h>
17 #include <linux/errno.h>
18 #include <linux/ethtool.h>
19 #include <linux/netdevice.h>
20 #include <linux/net_tstamp.h>
21 #include <linux/phy.h>
22 #include <linux/bitops.h>
23 #include <linux/uaccess.h>
24 #include <linux/vmalloc.h>
25 #include <linux/slab.h>
26 #include <linux/rtnetlink.h>
27 #include <linux/sched.h>
30 * Some useful ethtool_ops methods that're device independent.
31 * If we find that all drivers want to do the same thing here,
32 * we can turn these into dev_() function calls.
35 u32 ethtool_op_get_link(struct net_device *dev)
37 return netif_carrier_ok(dev) ? 1 : 0;
39 EXPORT_SYMBOL(ethtool_op_get_link);
41 int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
43 info->so_timestamping =
44 SOF_TIMESTAMPING_TX_SOFTWARE |
45 SOF_TIMESTAMPING_RX_SOFTWARE |
46 SOF_TIMESTAMPING_SOFTWARE;
50 EXPORT_SYMBOL(ethtool_op_get_ts_info);
52 /* Handlers for each ethtool command */
54 #define ETHTOOL_DEV_FEATURE_WORDS ((NETDEV_FEATURE_COUNT + 31) / 32)
56 static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
57 [NETIF_F_SG_BIT] = "tx-scatter-gather",
58 [NETIF_F_IP_CSUM_BIT] = "tx-checksum-ipv4",
59 [NETIF_F_HW_CSUM_BIT] = "tx-checksum-ip-generic",
60 [NETIF_F_IPV6_CSUM_BIT] = "tx-checksum-ipv6",
61 [NETIF_F_HIGHDMA_BIT] = "highdma",
62 [NETIF_F_FRAGLIST_BIT] = "tx-scatter-gather-fraglist",
63 [NETIF_F_HW_VLAN_CTAG_TX_BIT] = "tx-vlan-hw-insert",
65 [NETIF_F_HW_VLAN_CTAG_RX_BIT] = "rx-vlan-hw-parse",
66 [NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-filter",
67 [NETIF_F_HW_VLAN_STAG_TX_BIT] = "tx-vlan-stag-hw-insert",
68 [NETIF_F_HW_VLAN_STAG_RX_BIT] = "rx-vlan-stag-hw-parse",
69 [NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter",
70 [NETIF_F_VLAN_CHALLENGED_BIT] = "vlan-challenged",
71 [NETIF_F_GSO_BIT] = "tx-generic-segmentation",
72 [NETIF_F_LLTX_BIT] = "tx-lockless",
73 [NETIF_F_NETNS_LOCAL_BIT] = "netns-local",
74 [NETIF_F_GRO_BIT] = "rx-gro",
75 [NETIF_F_LRO_BIT] = "rx-lro",
77 [NETIF_F_TSO_BIT] = "tx-tcp-segmentation",
78 [NETIF_F_UFO_BIT] = "tx-udp-fragmentation",
79 [NETIF_F_GSO_ROBUST_BIT] = "tx-gso-robust",
80 [NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation",
81 [NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation",
82 [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation",
83 [NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation",
84 [NETIF_F_GSO_IPIP_BIT] = "tx-ipip-segmentation",
85 [NETIF_F_GSO_SIT_BIT] = "tx-sit-segmentation",
86 [NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation",
88 [NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc",
89 [NETIF_F_SCTP_CSUM_BIT] = "tx-checksum-sctp",
90 [NETIF_F_FCOE_MTU_BIT] = "fcoe-mtu",
91 [NETIF_F_NTUPLE_BIT] = "rx-ntuple-filter",
92 [NETIF_F_RXHASH_BIT] = "rx-hashing",
93 [NETIF_F_RXCSUM_BIT] = "rx-checksum",
94 [NETIF_F_NOCACHE_COPY_BIT] = "tx-nocache-copy",
95 [NETIF_F_LOOPBACK_BIT] = "loopback",
96 [NETIF_F_RXFCS_BIT] = "rx-fcs",
97 [NETIF_F_RXALL_BIT] = "rx-all",
98 [NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload",
99 [NETIF_F_BUSY_POLL_BIT] = "busy-poll",
102 static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
104 struct ethtool_gfeatures cmd = {
105 .cmd = ETHTOOL_GFEATURES,
106 .size = ETHTOOL_DEV_FEATURE_WORDS,
108 struct ethtool_get_features_block features[ETHTOOL_DEV_FEATURE_WORDS];
109 u32 __user *sizeaddr;
113 /* in case feature bits run out again */
114 BUILD_BUG_ON(ETHTOOL_DEV_FEATURE_WORDS * sizeof(u32) > sizeof(netdev_features_t));
116 for (i = 0; i < ETHTOOL_DEV_FEATURE_WORDS; ++i) {
117 features[i].available = (u32)(dev->hw_features >> (32 * i));
118 features[i].requested = (u32)(dev->wanted_features >> (32 * i));
119 features[i].active = (u32)(dev->features >> (32 * i));
120 features[i].never_changed =
121 (u32)(NETIF_F_NEVER_CHANGE >> (32 * i));
124 sizeaddr = useraddr + offsetof(struct ethtool_gfeatures, size);
125 if (get_user(copy_size, sizeaddr))
128 if (copy_size > ETHTOOL_DEV_FEATURE_WORDS)
129 copy_size = ETHTOOL_DEV_FEATURE_WORDS;
131 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
133 useraddr += sizeof(cmd);
134 if (copy_to_user(useraddr, features, copy_size * sizeof(*features)))
140 static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
142 struct ethtool_sfeatures cmd;
143 struct ethtool_set_features_block features[ETHTOOL_DEV_FEATURE_WORDS];
144 netdev_features_t wanted = 0, valid = 0;
147 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
149 useraddr += sizeof(cmd);
151 if (cmd.size != ETHTOOL_DEV_FEATURE_WORDS)
154 if (copy_from_user(features, useraddr, sizeof(features)))
157 for (i = 0; i < ETHTOOL_DEV_FEATURE_WORDS; ++i) {
158 valid |= (netdev_features_t)features[i].valid << (32 * i);
159 wanted |= (netdev_features_t)features[i].requested << (32 * i);
162 if (valid & ~NETIF_F_ETHTOOL_BITS)
165 if (valid & ~dev->hw_features) {
166 valid &= dev->hw_features;
167 ret |= ETHTOOL_F_UNSUPPORTED;
170 dev->wanted_features &= ~valid;
171 dev->wanted_features |= wanted & valid;
172 __netdev_update_features(dev);
174 if ((dev->wanted_features ^ dev->features) & valid)
175 ret |= ETHTOOL_F_WISH;
180 static int __ethtool_get_sset_count(struct net_device *dev, int sset)
182 const struct ethtool_ops *ops = dev->ethtool_ops;
184 if (sset == ETH_SS_FEATURES)
185 return ARRAY_SIZE(netdev_features_strings);
187 if (ops->get_sset_count && ops->get_strings)
188 return ops->get_sset_count(dev, sset);
193 static void __ethtool_get_strings(struct net_device *dev,
194 u32 stringset, u8 *data)
196 const struct ethtool_ops *ops = dev->ethtool_ops;
198 if (stringset == ETH_SS_FEATURES)
199 memcpy(data, netdev_features_strings,
200 sizeof(netdev_features_strings));
202 /* ops->get_strings is valid because checked earlier */
203 ops->get_strings(dev, stringset, data);
206 static netdev_features_t ethtool_get_feature_mask(u32 eth_cmd)
208 /* feature masks of legacy discrete ethtool ops */
211 case ETHTOOL_GTXCSUM:
212 case ETHTOOL_STXCSUM:
213 return NETIF_F_ALL_CSUM | NETIF_F_SCTP_CSUM;
214 case ETHTOOL_GRXCSUM:
215 case ETHTOOL_SRXCSUM:
216 return NETIF_F_RXCSUM;
222 return NETIF_F_ALL_TSO;
237 static int ethtool_get_one_feature(struct net_device *dev,
238 char __user *useraddr, u32 ethcmd)
240 netdev_features_t mask = ethtool_get_feature_mask(ethcmd);
241 struct ethtool_value edata = {
243 .data = !!(dev->features & mask),
246 if (copy_to_user(useraddr, &edata, sizeof(edata)))
251 static int ethtool_set_one_feature(struct net_device *dev,
252 void __user *useraddr, u32 ethcmd)
254 struct ethtool_value edata;
255 netdev_features_t mask;
257 if (copy_from_user(&edata, useraddr, sizeof(edata)))
260 mask = ethtool_get_feature_mask(ethcmd);
261 mask &= dev->hw_features;
266 dev->wanted_features |= mask;
268 dev->wanted_features &= ~mask;
270 __netdev_update_features(dev);
275 #define ETH_ALL_FLAGS (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | \
276 ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH)
277 #define ETH_ALL_FEATURES (NETIF_F_LRO | NETIF_F_HW_VLAN_CTAG_RX | \
278 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_NTUPLE | \
281 static u32 __ethtool_get_flags(struct net_device *dev)
285 if (dev->features & NETIF_F_LRO)
286 flags |= ETH_FLAG_LRO;
287 if (dev->features & NETIF_F_HW_VLAN_CTAG_RX)
288 flags |= ETH_FLAG_RXVLAN;
289 if (dev->features & NETIF_F_HW_VLAN_CTAG_TX)
290 flags |= ETH_FLAG_TXVLAN;
291 if (dev->features & NETIF_F_NTUPLE)
292 flags |= ETH_FLAG_NTUPLE;
293 if (dev->features & NETIF_F_RXHASH)
294 flags |= ETH_FLAG_RXHASH;
299 static int __ethtool_set_flags(struct net_device *dev, u32 data)
301 netdev_features_t features = 0, changed;
303 if (data & ~ETH_ALL_FLAGS)
306 if (data & ETH_FLAG_LRO)
307 features |= NETIF_F_LRO;
308 if (data & ETH_FLAG_RXVLAN)
309 features |= NETIF_F_HW_VLAN_CTAG_RX;
310 if (data & ETH_FLAG_TXVLAN)
311 features |= NETIF_F_HW_VLAN_CTAG_TX;
312 if (data & ETH_FLAG_NTUPLE)
313 features |= NETIF_F_NTUPLE;
314 if (data & ETH_FLAG_RXHASH)
315 features |= NETIF_F_RXHASH;
317 /* allow changing only bits set in hw_features */
318 changed = (features ^ dev->features) & ETH_ALL_FEATURES;
319 if (changed & ~dev->hw_features)
320 return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;
322 dev->wanted_features =
323 (dev->wanted_features & ~changed) | (features & changed);
325 __netdev_update_features(dev);
330 int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
334 if (!dev->ethtool_ops->get_settings)
337 memset(cmd, 0, sizeof(struct ethtool_cmd));
338 cmd->cmd = ETHTOOL_GSET;
339 return dev->ethtool_ops->get_settings(dev, cmd);
341 EXPORT_SYMBOL(__ethtool_get_settings);
343 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
346 struct ethtool_cmd cmd;
348 err = __ethtool_get_settings(dev, &cmd);
352 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
357 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
359 struct ethtool_cmd cmd;
361 if (!dev->ethtool_ops->set_settings)
364 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
367 return dev->ethtool_ops->set_settings(dev, &cmd);
370 static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
371 void __user *useraddr)
373 struct ethtool_drvinfo info;
374 const struct ethtool_ops *ops = dev->ethtool_ops;
376 memset(&info, 0, sizeof(info));
377 info.cmd = ETHTOOL_GDRVINFO;
378 if (ops->get_drvinfo) {
379 ops->get_drvinfo(dev, &info);
380 } else if (dev->dev.parent && dev->dev.parent->driver) {
381 strlcpy(info.bus_info, dev_name(dev->dev.parent),
382 sizeof(info.bus_info));
383 strlcpy(info.driver, dev->dev.parent->driver->name,
384 sizeof(info.driver));
390 * this method of obtaining string set info is deprecated;
391 * Use ETHTOOL_GSSET_INFO instead.
393 if (ops->get_sset_count) {
396 rc = ops->get_sset_count(dev, ETH_SS_TEST);
398 info.testinfo_len = rc;
399 rc = ops->get_sset_count(dev, ETH_SS_STATS);
402 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
404 info.n_priv_flags = rc;
406 if (ops->get_regs_len)
407 info.regdump_len = ops->get_regs_len(dev);
408 if (ops->get_eeprom_len)
409 info.eedump_len = ops->get_eeprom_len(dev);
411 if (copy_to_user(useraddr, &info, sizeof(info)))
416 static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
417 void __user *useraddr)
419 struct ethtool_sset_info info;
421 int i, idx = 0, n_bits = 0, ret, rc;
422 u32 *info_buf = NULL;
424 if (copy_from_user(&info, useraddr, sizeof(info)))
427 /* store copy of mask, because we zero struct later on */
428 sset_mask = info.sset_mask;
432 /* calculate size of return buffer */
433 n_bits = hweight64(sset_mask);
435 memset(&info, 0, sizeof(info));
436 info.cmd = ETHTOOL_GSSET_INFO;
438 info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER);
443 * fill return buffer based on input bitmask and successful
444 * get_sset_count return
446 for (i = 0; i < 64; i++) {
447 if (!(sset_mask & (1ULL << i)))
450 rc = __ethtool_get_sset_count(dev, i);
452 info.sset_mask |= (1ULL << i);
453 info_buf[idx++] = rc;
458 if (copy_to_user(useraddr, &info, sizeof(info)))
461 useraddr += offsetof(struct ethtool_sset_info, data);
462 if (copy_to_user(useraddr, info_buf, idx * sizeof(u32)))
472 static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
473 u32 cmd, void __user *useraddr)
475 struct ethtool_rxnfc info;
476 size_t info_size = sizeof(info);
479 if (!dev->ethtool_ops->set_rxnfc)
482 /* struct ethtool_rxnfc was originally defined for
483 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
484 * members. User-space might still be using that
486 if (cmd == ETHTOOL_SRXFH)
487 info_size = (offsetof(struct ethtool_rxnfc, data) +
490 if (copy_from_user(&info, useraddr, info_size))
493 rc = dev->ethtool_ops->set_rxnfc(dev, &info);
497 if (cmd == ETHTOOL_SRXCLSRLINS &&
498 copy_to_user(useraddr, &info, info_size))
504 static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
505 u32 cmd, void __user *useraddr)
507 struct ethtool_rxnfc info;
508 size_t info_size = sizeof(info);
509 const struct ethtool_ops *ops = dev->ethtool_ops;
511 void *rule_buf = NULL;
516 /* struct ethtool_rxnfc was originally defined for
517 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
518 * members. User-space might still be using that
520 if (cmd == ETHTOOL_GRXFH)
521 info_size = (offsetof(struct ethtool_rxnfc, data) +
524 if (copy_from_user(&info, useraddr, info_size))
527 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
528 if (info.rule_cnt > 0) {
529 if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
530 rule_buf = kzalloc(info.rule_cnt * sizeof(u32),
537 ret = ops->get_rxnfc(dev, &info, rule_buf);
542 if (copy_to_user(useraddr, &info, info_size))
546 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
547 if (copy_to_user(useraddr, rule_buf,
548 info.rule_cnt * sizeof(u32)))
559 static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
560 struct ethtool_rxnfc *rx_rings,
565 if (copy_from_user(indir, useraddr, size * sizeof(indir[0])))
568 /* Validate ring indices */
569 for (i = 0; i < size; i++)
570 if (indir[i] >= rx_rings->data)
576 static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
577 void __user *useraddr)
579 u32 user_size, dev_size;
583 if (!dev->ethtool_ops->get_rxfh_indir_size ||
584 !dev->ethtool_ops->get_rxfh)
586 dev_size = dev->ethtool_ops->get_rxfh_indir_size(dev);
590 if (copy_from_user(&user_size,
591 useraddr + offsetof(struct ethtool_rxfh_indir, size),
595 if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh_indir, size),
596 &dev_size, sizeof(dev_size)))
599 /* If the user buffer size is 0, this is just a query for the
600 * device table size. Otherwise, if it's smaller than the
601 * device table size it's an error.
603 if (user_size < dev_size)
604 return user_size == 0 ? 0 : -EINVAL;
606 indir = kcalloc(dev_size, sizeof(indir[0]), GFP_USER);
610 ret = dev->ethtool_ops->get_rxfh(dev, indir, NULL);
614 if (copy_to_user(useraddr +
615 offsetof(struct ethtool_rxfh_indir, ring_index[0]),
616 indir, dev_size * sizeof(indir[0])))
624 static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
625 void __user *useraddr)
627 struct ethtool_rxnfc rx_rings;
628 u32 user_size, dev_size, i;
630 const struct ethtool_ops *ops = dev->ethtool_ops;
632 u32 ringidx_offset = offsetof(struct ethtool_rxfh_indir, ring_index[0]);
634 if (!ops->get_rxfh_indir_size || !ops->set_rxfh ||
638 dev_size = ops->get_rxfh_indir_size(dev);
642 if (copy_from_user(&user_size,
643 useraddr + offsetof(struct ethtool_rxfh_indir, size),
647 if (user_size != 0 && user_size != dev_size)
650 indir = kcalloc(dev_size, sizeof(indir[0]), GFP_USER);
654 rx_rings.cmd = ETHTOOL_GRXRINGS;
655 ret = ops->get_rxnfc(dev, &rx_rings, NULL);
659 if (user_size == 0) {
660 for (i = 0; i < dev_size; i++)
661 indir[i] = ethtool_rxfh_indir_default(i, rx_rings.data);
663 ret = ethtool_copy_validate_indir(indir,
664 useraddr + ringidx_offset,
671 ret = ops->set_rxfh(dev, indir, NULL);
678 static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
679 void __user *useraddr)
682 const struct ethtool_ops *ops = dev->ethtool_ops;
683 u32 user_indir_size, user_key_size;
684 u32 dev_indir_size = 0, dev_key_size = 0;
685 struct ethtool_rxfh rxfh;
692 if (!(dev->ethtool_ops->get_rxfh_indir_size ||
693 dev->ethtool_ops->get_rxfh_key_size) ||
694 !dev->ethtool_ops->get_rxfh)
697 if (ops->get_rxfh_indir_size)
698 dev_indir_size = ops->get_rxfh_indir_size(dev);
699 if (ops->get_rxfh_key_size)
700 dev_key_size = ops->get_rxfh_key_size(dev);
702 if ((dev_key_size + dev_indir_size) == 0)
705 if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
707 user_indir_size = rxfh.indir_size;
708 user_key_size = rxfh.key_size;
710 /* Check that reserved fields are 0 for now */
711 if (rxfh.rss_context || rxfh.rsvd[0] || rxfh.rsvd[1])
714 rxfh.indir_size = dev_indir_size;
715 rxfh.key_size = dev_key_size;
716 if (copy_to_user(useraddr, &rxfh, sizeof(rxfh)))
719 /* If the user buffer size is 0, this is just a query for the
720 * device table size and key size. Otherwise, if the User size is
721 * not equal to device table size or key size it's an error.
723 if (!user_indir_size && !user_key_size)
726 if ((user_indir_size && (user_indir_size != dev_indir_size)) ||
727 (user_key_size && (user_key_size != dev_key_size)))
730 indir_bytes = user_indir_size * sizeof(indir[0]);
731 total_size = indir_bytes + user_key_size;
732 rss_config = kzalloc(total_size, GFP_USER);
737 indir = (u32 *)rss_config;
740 hkey = rss_config + indir_bytes;
742 ret = dev->ethtool_ops->get_rxfh(dev, indir, hkey);
744 if (copy_to_user(useraddr +
745 offsetof(struct ethtool_rxfh, rss_config[0]),
746 rss_config, total_size))
755 static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
756 void __user *useraddr)
759 const struct ethtool_ops *ops = dev->ethtool_ops;
760 struct ethtool_rxnfc rx_rings;
761 struct ethtool_rxfh rxfh;
762 u32 dev_indir_size = 0, dev_key_size = 0, i;
763 u32 *indir = NULL, indir_bytes = 0;
766 u32 rss_cfg_offset = offsetof(struct ethtool_rxfh, rss_config[0]);
768 if (!(ops->get_rxfh_indir_size || ops->get_rxfh_key_size) ||
769 !ops->get_rxnfc || !ops->set_rxfh)
772 if (ops->get_rxfh_indir_size)
773 dev_indir_size = ops->get_rxfh_indir_size(dev);
774 if (ops->get_rxfh_key_size)
775 dev_key_size = dev->ethtool_ops->get_rxfh_key_size(dev);
776 if ((dev_key_size + dev_indir_size) == 0)
779 if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
782 /* Check that reserved fields are 0 for now */
783 if (rxfh.rss_context || rxfh.rsvd[0] || rxfh.rsvd[1])
786 /* If either indir or hash key is valid, proceed further.
787 * It is not valid to request that both be unchanged.
789 if ((rxfh.indir_size &&
790 rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
791 rxfh.indir_size != dev_indir_size) ||
792 (rxfh.key_size && (rxfh.key_size != dev_key_size)) ||
793 (rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE &&
797 if (rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE)
798 indir_bytes = dev_indir_size * sizeof(indir[0]);
800 rss_config = kzalloc(indir_bytes + rxfh.key_size, GFP_USER);
804 rx_rings.cmd = ETHTOOL_GRXRINGS;
805 ret = ops->get_rxnfc(dev, &rx_rings, NULL);
809 /* rxfh.indir_size == 0 means reset the indir table to default.
810 * rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE means leave it unchanged.
812 if (rxfh.indir_size &&
813 rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE) {
814 indir = (u32 *)rss_config;
815 ret = ethtool_copy_validate_indir(indir,
816 useraddr + rss_cfg_offset,
821 } else if (rxfh.indir_size == 0) {
822 indir = (u32 *)rss_config;
823 for (i = 0; i < dev_indir_size; i++)
824 indir[i] = ethtool_rxfh_indir_default(i, rx_rings.data);
828 hkey = rss_config + indir_bytes;
829 if (copy_from_user(hkey,
830 useraddr + rss_cfg_offset + indir_bytes,
837 ret = ops->set_rxfh(dev, indir, hkey);
844 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
846 struct ethtool_regs regs;
847 const struct ethtool_ops *ops = dev->ethtool_ops;
851 if (!ops->get_regs || !ops->get_regs_len)
854 if (copy_from_user(®s, useraddr, sizeof(regs)))
857 reglen = ops->get_regs_len(dev);
858 if (regs.len > reglen)
861 regbuf = vzalloc(reglen);
862 if (reglen && !regbuf)
865 ops->get_regs(dev, ®s, regbuf);
868 if (copy_to_user(useraddr, ®s, sizeof(regs)))
870 useraddr += offsetof(struct ethtool_regs, data);
871 if (regbuf && copy_to_user(useraddr, regbuf, regs.len))
880 static int ethtool_reset(struct net_device *dev, char __user *useraddr)
882 struct ethtool_value reset;
885 if (!dev->ethtool_ops->reset)
888 if (copy_from_user(&reset, useraddr, sizeof(reset)))
891 ret = dev->ethtool_ops->reset(dev, &reset.data);
895 if (copy_to_user(useraddr, &reset, sizeof(reset)))
900 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
902 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
904 if (!dev->ethtool_ops->get_wol)
907 dev->ethtool_ops->get_wol(dev, &wol);
909 if (copy_to_user(useraddr, &wol, sizeof(wol)))
914 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
916 struct ethtool_wolinfo wol;
918 if (!dev->ethtool_ops->set_wol)
921 if (copy_from_user(&wol, useraddr, sizeof(wol)))
924 return dev->ethtool_ops->set_wol(dev, &wol);
927 static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
929 struct ethtool_eee edata;
932 if (!dev->ethtool_ops->get_eee)
935 memset(&edata, 0, sizeof(struct ethtool_eee));
936 edata.cmd = ETHTOOL_GEEE;
937 rc = dev->ethtool_ops->get_eee(dev, &edata);
942 if (copy_to_user(useraddr, &edata, sizeof(edata)))
948 static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
950 struct ethtool_eee edata;
952 if (!dev->ethtool_ops->set_eee)
955 if (copy_from_user(&edata, useraddr, sizeof(edata)))
958 return dev->ethtool_ops->set_eee(dev, &edata);
961 static int ethtool_nway_reset(struct net_device *dev)
963 if (!dev->ethtool_ops->nway_reset)
966 return dev->ethtool_ops->nway_reset(dev);
969 static int ethtool_get_link(struct net_device *dev, char __user *useraddr)
971 struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
973 if (!dev->ethtool_ops->get_link)
976 edata.data = netif_running(dev) && dev->ethtool_ops->get_link(dev);
978 if (copy_to_user(useraddr, &edata, sizeof(edata)))
983 static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr,
984 int (*getter)(struct net_device *,
985 struct ethtool_eeprom *, u8 *),
988 struct ethtool_eeprom eeprom;
989 void __user *userbuf = useraddr + sizeof(eeprom);
994 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
997 /* Check for wrap and zero */
998 if (eeprom.offset + eeprom.len <= eeprom.offset)
1001 /* Check for exceeding total eeprom len */
1002 if (eeprom.offset + eeprom.len > total_len)
1005 data = kmalloc(PAGE_SIZE, GFP_USER);
1009 bytes_remaining = eeprom.len;
1010 while (bytes_remaining > 0) {
1011 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1013 ret = getter(dev, &eeprom, data);
1016 if (copy_to_user(userbuf, data, eeprom.len)) {
1020 userbuf += eeprom.len;
1021 eeprom.offset += eeprom.len;
1022 bytes_remaining -= eeprom.len;
1025 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
1026 eeprom.offset -= eeprom.len;
1027 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
1034 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
1036 const struct ethtool_ops *ops = dev->ethtool_ops;
1038 if (!ops->get_eeprom || !ops->get_eeprom_len ||
1039 !ops->get_eeprom_len(dev))
1042 return ethtool_get_any_eeprom(dev, useraddr, ops->get_eeprom,
1043 ops->get_eeprom_len(dev));
1046 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
1048 struct ethtool_eeprom eeprom;
1049 const struct ethtool_ops *ops = dev->ethtool_ops;
1050 void __user *userbuf = useraddr + sizeof(eeprom);
1051 u32 bytes_remaining;
1055 if (!ops->set_eeprom || !ops->get_eeprom_len ||
1056 !ops->get_eeprom_len(dev))
1059 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
1062 /* Check for wrap and zero */
1063 if (eeprom.offset + eeprom.len <= eeprom.offset)
1066 /* Check for exceeding total eeprom len */
1067 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
1070 data = kmalloc(PAGE_SIZE, GFP_USER);
1074 bytes_remaining = eeprom.len;
1075 while (bytes_remaining > 0) {
1076 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1078 if (copy_from_user(data, userbuf, eeprom.len)) {
1082 ret = ops->set_eeprom(dev, &eeprom, data);
1085 userbuf += eeprom.len;
1086 eeprom.offset += eeprom.len;
1087 bytes_remaining -= eeprom.len;
1094 static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev,
1095 void __user *useraddr)
1097 struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
1099 if (!dev->ethtool_ops->get_coalesce)
1102 dev->ethtool_ops->get_coalesce(dev, &coalesce);
1104 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
1109 static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
1110 void __user *useraddr)
1112 struct ethtool_coalesce coalesce;
1114 if (!dev->ethtool_ops->set_coalesce)
1117 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
1120 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
1123 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
1125 struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM };
1127 if (!dev->ethtool_ops->get_ringparam)
1130 dev->ethtool_ops->get_ringparam(dev, &ringparam);
1132 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
1137 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
1139 struct ethtool_ringparam ringparam;
1141 if (!dev->ethtool_ops->set_ringparam)
1144 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
1147 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
1150 static noinline_for_stack int ethtool_get_channels(struct net_device *dev,
1151 void __user *useraddr)
1153 struct ethtool_channels channels = { .cmd = ETHTOOL_GCHANNELS };
1155 if (!dev->ethtool_ops->get_channels)
1158 dev->ethtool_ops->get_channels(dev, &channels);
1160 if (copy_to_user(useraddr, &channels, sizeof(channels)))
1165 static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
1166 void __user *useraddr)
1168 struct ethtool_channels channels;
1170 if (!dev->ethtool_ops->set_channels)
1173 if (copy_from_user(&channels, useraddr, sizeof(channels)))
1176 return dev->ethtool_ops->set_channels(dev, &channels);
1179 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
1181 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
1183 if (!dev->ethtool_ops->get_pauseparam)
1186 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
1188 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
1193 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
1195 struct ethtool_pauseparam pauseparam;
1197 if (!dev->ethtool_ops->set_pauseparam)
1200 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
1203 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
1206 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
1208 struct ethtool_test test;
1209 const struct ethtool_ops *ops = dev->ethtool_ops;
1213 if (!ops->self_test || !ops->get_sset_count)
1216 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
1219 WARN_ON(test_len == 0);
1221 if (copy_from_user(&test, useraddr, sizeof(test)))
1224 test.len = test_len;
1225 data = kmalloc(test_len * sizeof(u64), GFP_USER);
1229 ops->self_test(dev, &test, data);
1232 if (copy_to_user(useraddr, &test, sizeof(test)))
1234 useraddr += sizeof(test);
1235 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
1244 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1246 struct ethtool_gstrings gstrings;
1250 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
1253 ret = __ethtool_get_sset_count(dev, gstrings.string_set);
1259 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
1263 __ethtool_get_strings(dev, gstrings.string_set, data);
1266 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1268 useraddr += sizeof(gstrings);
1269 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1278 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1280 struct ethtool_value id;
1282 const struct ethtool_ops *ops = dev->ethtool_ops;
1285 if (!ops->set_phys_id)
1291 if (copy_from_user(&id, useraddr, sizeof(id)))
1294 rc = ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE);
1298 /* Drop the RTNL lock while waiting, but prevent reentry or
1299 * removal of the device.
1306 /* Driver will handle this itself */
1307 schedule_timeout_interruptible(
1308 id.data ? (id.data * HZ) : MAX_SCHEDULE_TIMEOUT);
1310 /* Driver expects to be called at twice the frequency in rc */
1311 int n = rc * 2, i, interval = HZ / n;
1313 /* Count down seconds */
1315 /* Count down iterations per second */
1319 rc = ops->set_phys_id(dev,
1320 (i & 1) ? ETHTOOL_ID_OFF : ETHTOOL_ID_ON);
1324 schedule_timeout_interruptible(interval);
1325 } while (!signal_pending(current) && --i != 0);
1326 } while (!signal_pending(current) &&
1327 (id.data == 0 || --id.data != 0));
1334 (void) ops->set_phys_id(dev, ETHTOOL_ID_INACTIVE);
1338 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
1340 struct ethtool_stats stats;
1341 const struct ethtool_ops *ops = dev->ethtool_ops;
1345 if (!ops->get_ethtool_stats || !ops->get_sset_count)
1348 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
1351 WARN_ON(n_stats == 0);
1353 if (copy_from_user(&stats, useraddr, sizeof(stats)))
1356 stats.n_stats = n_stats;
1357 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
1361 ops->get_ethtool_stats(dev, &stats, data);
1364 if (copy_to_user(useraddr, &stats, sizeof(stats)))
1366 useraddr += sizeof(stats);
1367 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
1376 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
1378 struct ethtool_perm_addr epaddr;
1380 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
1383 if (epaddr.size < dev->addr_len)
1385 epaddr.size = dev->addr_len;
1387 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
1389 useraddr += sizeof(epaddr);
1390 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
1395 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
1396 u32 cmd, u32 (*actor)(struct net_device *))
1398 struct ethtool_value edata = { .cmd = cmd };
1403 edata.data = actor(dev);
1405 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1410 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
1411 void (*actor)(struct net_device *, u32))
1413 struct ethtool_value edata;
1418 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1421 actor(dev, edata.data);
1425 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
1426 int (*actor)(struct net_device *, u32))
1428 struct ethtool_value edata;
1433 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1436 return actor(dev, edata.data);
1439 static noinline_for_stack int ethtool_flash_device(struct net_device *dev,
1440 char __user *useraddr)
1442 struct ethtool_flash efl;
1444 if (copy_from_user(&efl, useraddr, sizeof(efl)))
1447 if (!dev->ethtool_ops->flash_device)
1450 efl.data[ETHTOOL_FLASH_MAX_FILENAME - 1] = 0;
1452 return dev->ethtool_ops->flash_device(dev, &efl);
1455 static int ethtool_set_dump(struct net_device *dev,
1456 void __user *useraddr)
1458 struct ethtool_dump dump;
1460 if (!dev->ethtool_ops->set_dump)
1463 if (copy_from_user(&dump, useraddr, sizeof(dump)))
1466 return dev->ethtool_ops->set_dump(dev, &dump);
1469 static int ethtool_get_dump_flag(struct net_device *dev,
1470 void __user *useraddr)
1473 struct ethtool_dump dump;
1474 const struct ethtool_ops *ops = dev->ethtool_ops;
1476 if (!ops->get_dump_flag)
1479 if (copy_from_user(&dump, useraddr, sizeof(dump)))
1482 ret = ops->get_dump_flag(dev, &dump);
1486 if (copy_to_user(useraddr, &dump, sizeof(dump)))
1491 static int ethtool_get_dump_data(struct net_device *dev,
1492 void __user *useraddr)
1496 struct ethtool_dump dump, tmp;
1497 const struct ethtool_ops *ops = dev->ethtool_ops;
1500 if (!ops->get_dump_data || !ops->get_dump_flag)
1503 if (copy_from_user(&dump, useraddr, sizeof(dump)))
1506 memset(&tmp, 0, sizeof(tmp));
1507 tmp.cmd = ETHTOOL_GET_DUMP_FLAG;
1508 ret = ops->get_dump_flag(dev, &tmp);
1512 len = min(tmp.len, dump.len);
1516 /* Don't ever let the driver think there's more space available
1517 * than it requested with .get_dump_flag().
1521 /* Always allocate enough space to hold the whole thing so that the
1522 * driver does not need to check the length and bother with partial
1525 data = vzalloc(tmp.len);
1528 ret = ops->get_dump_data(dev, &dump, data);
1532 /* There are two sane possibilities:
1533 * 1. The driver's .get_dump_data() does not touch dump.len.
1534 * 2. Or it may set dump.len to how much it really writes, which
1535 * should be tmp.len (or len if it can do a partial dump).
1536 * In any case respond to userspace with the actual length of data
1539 WARN_ON(dump.len != len && dump.len != tmp.len);
1542 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
1546 useraddr += offsetof(struct ethtool_dump, data);
1547 if (copy_to_user(useraddr, data, len))
1554 static int ethtool_get_ts_info(struct net_device *dev, void __user *useraddr)
1557 struct ethtool_ts_info info;
1558 const struct ethtool_ops *ops = dev->ethtool_ops;
1559 struct phy_device *phydev = dev->phydev;
1561 memset(&info, 0, sizeof(info));
1562 info.cmd = ETHTOOL_GET_TS_INFO;
1564 if (phydev && phydev->drv && phydev->drv->ts_info) {
1565 err = phydev->drv->ts_info(phydev, &info);
1566 } else if (ops->get_ts_info) {
1567 err = ops->get_ts_info(dev, &info);
1569 info.so_timestamping =
1570 SOF_TIMESTAMPING_RX_SOFTWARE |
1571 SOF_TIMESTAMPING_SOFTWARE;
1572 info.phc_index = -1;
1578 if (copy_to_user(useraddr, &info, sizeof(info)))
1584 static int ethtool_get_module_info(struct net_device *dev,
1585 void __user *useraddr)
1588 struct ethtool_modinfo modinfo;
1589 const struct ethtool_ops *ops = dev->ethtool_ops;
1591 if (!ops->get_module_info)
1594 if (copy_from_user(&modinfo, useraddr, sizeof(modinfo)))
1597 ret = ops->get_module_info(dev, &modinfo);
1601 if (copy_to_user(useraddr, &modinfo, sizeof(modinfo)))
1607 static int ethtool_get_module_eeprom(struct net_device *dev,
1608 void __user *useraddr)
1611 struct ethtool_modinfo modinfo;
1612 const struct ethtool_ops *ops = dev->ethtool_ops;
1614 if (!ops->get_module_info || !ops->get_module_eeprom)
1617 ret = ops->get_module_info(dev, &modinfo);
1621 return ethtool_get_any_eeprom(dev, useraddr, ops->get_module_eeprom,
1622 modinfo.eeprom_len);
1625 static int ethtool_tunable_valid(const struct ethtool_tunable *tuna)
1628 case ETHTOOL_RX_COPYBREAK:
1629 case ETHTOOL_TX_COPYBREAK:
1630 if (tuna->len != sizeof(u32) ||
1631 tuna->type_id != ETHTOOL_TUNABLE_U32)
1641 static int ethtool_get_tunable(struct net_device *dev, void __user *useraddr)
1644 struct ethtool_tunable tuna;
1645 const struct ethtool_ops *ops = dev->ethtool_ops;
1648 if (!ops->get_tunable)
1650 if (copy_from_user(&tuna, useraddr, sizeof(tuna)))
1652 ret = ethtool_tunable_valid(&tuna);
1655 data = kmalloc(tuna.len, GFP_USER);
1658 ret = ops->get_tunable(dev, &tuna, data);
1661 useraddr += sizeof(tuna);
1663 if (copy_to_user(useraddr, data, tuna.len))
1672 static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr)
1675 struct ethtool_tunable tuna;
1676 const struct ethtool_ops *ops = dev->ethtool_ops;
1679 if (!ops->set_tunable)
1681 if (copy_from_user(&tuna, useraddr, sizeof(tuna)))
1683 ret = ethtool_tunable_valid(&tuna);
1686 data = kmalloc(tuna.len, GFP_USER);
1689 useraddr += sizeof(tuna);
1691 if (copy_from_user(data, useraddr, tuna.len))
1693 ret = ops->set_tunable(dev, &tuna, data);
1700 /* The main entry point in this file. Called from net/core/dev_ioctl.c */
1702 int dev_ethtool(struct net *net, struct ifreq *ifr)
1704 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
1705 void __user *useraddr = ifr->ifr_data;
1708 netdev_features_t old_features;
1710 if (!dev || !netif_device_present(dev))
1713 if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
1716 /* Allow some commands to be done by anyone */
1719 case ETHTOOL_GDRVINFO:
1720 case ETHTOOL_GMSGLVL:
1722 case ETHTOOL_GCOALESCE:
1723 case ETHTOOL_GRINGPARAM:
1724 case ETHTOOL_GPAUSEPARAM:
1725 case ETHTOOL_GRXCSUM:
1726 case ETHTOOL_GTXCSUM:
1728 case ETHTOOL_GSSET_INFO:
1729 case ETHTOOL_GSTRINGS:
1730 case ETHTOOL_GSTATS:
1732 case ETHTOOL_GPERMADDR:
1736 case ETHTOOL_GFLAGS:
1737 case ETHTOOL_GPFLAGS:
1739 case ETHTOOL_GRXRINGS:
1740 case ETHTOOL_GRXCLSRLCNT:
1741 case ETHTOOL_GRXCLSRULE:
1742 case ETHTOOL_GRXCLSRLALL:
1743 case ETHTOOL_GRXFHINDIR:
1745 case ETHTOOL_GFEATURES:
1746 case ETHTOOL_GCHANNELS:
1747 case ETHTOOL_GET_TS_INFO:
1749 case ETHTOOL_GTUNABLE:
1752 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
1756 if (dev->ethtool_ops->begin) {
1757 rc = dev->ethtool_ops->begin(dev);
1761 old_features = dev->features;
1765 rc = ethtool_get_settings(dev, useraddr);
1768 rc = ethtool_set_settings(dev, useraddr);
1770 case ETHTOOL_GDRVINFO:
1771 rc = ethtool_get_drvinfo(dev, useraddr);
1774 rc = ethtool_get_regs(dev, useraddr);
1777 rc = ethtool_get_wol(dev, useraddr);
1780 rc = ethtool_set_wol(dev, useraddr);
1782 case ETHTOOL_GMSGLVL:
1783 rc = ethtool_get_value(dev, useraddr, ethcmd,
1784 dev->ethtool_ops->get_msglevel);
1786 case ETHTOOL_SMSGLVL:
1787 rc = ethtool_set_value_void(dev, useraddr,
1788 dev->ethtool_ops->set_msglevel);
1791 rc = ethtool_get_eee(dev, useraddr);
1794 rc = ethtool_set_eee(dev, useraddr);
1796 case ETHTOOL_NWAY_RST:
1797 rc = ethtool_nway_reset(dev);
1800 rc = ethtool_get_link(dev, useraddr);
1802 case ETHTOOL_GEEPROM:
1803 rc = ethtool_get_eeprom(dev, useraddr);
1805 case ETHTOOL_SEEPROM:
1806 rc = ethtool_set_eeprom(dev, useraddr);
1808 case ETHTOOL_GCOALESCE:
1809 rc = ethtool_get_coalesce(dev, useraddr);
1811 case ETHTOOL_SCOALESCE:
1812 rc = ethtool_set_coalesce(dev, useraddr);
1814 case ETHTOOL_GRINGPARAM:
1815 rc = ethtool_get_ringparam(dev, useraddr);
1817 case ETHTOOL_SRINGPARAM:
1818 rc = ethtool_set_ringparam(dev, useraddr);
1820 case ETHTOOL_GPAUSEPARAM:
1821 rc = ethtool_get_pauseparam(dev, useraddr);
1823 case ETHTOOL_SPAUSEPARAM:
1824 rc = ethtool_set_pauseparam(dev, useraddr);
1827 rc = ethtool_self_test(dev, useraddr);
1829 case ETHTOOL_GSTRINGS:
1830 rc = ethtool_get_strings(dev, useraddr);
1832 case ETHTOOL_PHYS_ID:
1833 rc = ethtool_phys_id(dev, useraddr);
1835 case ETHTOOL_GSTATS:
1836 rc = ethtool_get_stats(dev, useraddr);
1838 case ETHTOOL_GPERMADDR:
1839 rc = ethtool_get_perm_addr(dev, useraddr);
1841 case ETHTOOL_GFLAGS:
1842 rc = ethtool_get_value(dev, useraddr, ethcmd,
1843 __ethtool_get_flags);
1845 case ETHTOOL_SFLAGS:
1846 rc = ethtool_set_value(dev, useraddr, __ethtool_set_flags);
1848 case ETHTOOL_GPFLAGS:
1849 rc = ethtool_get_value(dev, useraddr, ethcmd,
1850 dev->ethtool_ops->get_priv_flags);
1852 case ETHTOOL_SPFLAGS:
1853 rc = ethtool_set_value(dev, useraddr,
1854 dev->ethtool_ops->set_priv_flags);
1857 case ETHTOOL_GRXRINGS:
1858 case ETHTOOL_GRXCLSRLCNT:
1859 case ETHTOOL_GRXCLSRULE:
1860 case ETHTOOL_GRXCLSRLALL:
1861 rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
1864 case ETHTOOL_SRXCLSRLDEL:
1865 case ETHTOOL_SRXCLSRLINS:
1866 rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
1868 case ETHTOOL_FLASHDEV:
1869 rc = ethtool_flash_device(dev, useraddr);
1872 rc = ethtool_reset(dev, useraddr);
1874 case ETHTOOL_GSSET_INFO:
1875 rc = ethtool_get_sset_info(dev, useraddr);
1877 case ETHTOOL_GRXFHINDIR:
1878 rc = ethtool_get_rxfh_indir(dev, useraddr);
1880 case ETHTOOL_SRXFHINDIR:
1881 rc = ethtool_set_rxfh_indir(dev, useraddr);
1884 rc = ethtool_get_rxfh(dev, useraddr);
1887 rc = ethtool_set_rxfh(dev, useraddr);
1889 case ETHTOOL_GFEATURES:
1890 rc = ethtool_get_features(dev, useraddr);
1892 case ETHTOOL_SFEATURES:
1893 rc = ethtool_set_features(dev, useraddr);
1895 case ETHTOOL_GTXCSUM:
1896 case ETHTOOL_GRXCSUM:
1902 rc = ethtool_get_one_feature(dev, useraddr, ethcmd);
1904 case ETHTOOL_STXCSUM:
1905 case ETHTOOL_SRXCSUM:
1911 rc = ethtool_set_one_feature(dev, useraddr, ethcmd);
1913 case ETHTOOL_GCHANNELS:
1914 rc = ethtool_get_channels(dev, useraddr);
1916 case ETHTOOL_SCHANNELS:
1917 rc = ethtool_set_channels(dev, useraddr);
1919 case ETHTOOL_SET_DUMP:
1920 rc = ethtool_set_dump(dev, useraddr);
1922 case ETHTOOL_GET_DUMP_FLAG:
1923 rc = ethtool_get_dump_flag(dev, useraddr);
1925 case ETHTOOL_GET_DUMP_DATA:
1926 rc = ethtool_get_dump_data(dev, useraddr);
1928 case ETHTOOL_GET_TS_INFO:
1929 rc = ethtool_get_ts_info(dev, useraddr);
1931 case ETHTOOL_GMODULEINFO:
1932 rc = ethtool_get_module_info(dev, useraddr);
1934 case ETHTOOL_GMODULEEEPROM:
1935 rc = ethtool_get_module_eeprom(dev, useraddr);
1937 case ETHTOOL_GTUNABLE:
1938 rc = ethtool_get_tunable(dev, useraddr);
1940 case ETHTOOL_STUNABLE:
1941 rc = ethtool_set_tunable(dev, useraddr);
1947 if (dev->ethtool_ops->complete)
1948 dev->ethtool_ops->complete(dev);
1950 if (old_features != dev->features)
1951 netdev_features_change(dev);