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/bitops.h>
21 #include <linux/uaccess.h>
22 #include <linux/vmalloc.h>
23 #include <linux/slab.h>
26 * Some useful ethtool_ops methods that're device independent.
27 * If we find that all drivers want to do the same thing here,
28 * we can turn these into dev_() function calls.
31 u32 ethtool_op_get_link(struct net_device *dev)
33 return netif_carrier_ok(dev) ? 1 : 0;
35 EXPORT_SYMBOL(ethtool_op_get_link);
37 u32 ethtool_op_get_tx_csum(struct net_device *dev)
39 return (dev->features & NETIF_F_ALL_CSUM) != 0;
41 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
43 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
46 dev->features |= NETIF_F_IP_CSUM;
48 dev->features &= ~NETIF_F_IP_CSUM;
52 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
54 int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
57 dev->features |= NETIF_F_HW_CSUM;
59 dev->features &= ~NETIF_F_HW_CSUM;
63 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
65 int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data)
68 dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
70 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
74 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
76 u32 ethtool_op_get_sg(struct net_device *dev)
78 return (dev->features & NETIF_F_SG) != 0;
80 EXPORT_SYMBOL(ethtool_op_get_sg);
82 int ethtool_op_set_sg(struct net_device *dev, u32 data)
85 dev->features |= NETIF_F_SG;
87 dev->features &= ~NETIF_F_SG;
91 EXPORT_SYMBOL(ethtool_op_set_sg);
93 u32 ethtool_op_get_tso(struct net_device *dev)
95 return (dev->features & NETIF_F_TSO) != 0;
97 EXPORT_SYMBOL(ethtool_op_get_tso);
99 int ethtool_op_set_tso(struct net_device *dev, u32 data)
102 dev->features |= NETIF_F_TSO;
104 dev->features &= ~NETIF_F_TSO;
108 EXPORT_SYMBOL(ethtool_op_set_tso);
110 u32 ethtool_op_get_ufo(struct net_device *dev)
112 return (dev->features & NETIF_F_UFO) != 0;
114 EXPORT_SYMBOL(ethtool_op_get_ufo);
116 int ethtool_op_set_ufo(struct net_device *dev, u32 data)
119 dev->features |= NETIF_F_UFO;
121 dev->features &= ~NETIF_F_UFO;
124 EXPORT_SYMBOL(ethtool_op_set_ufo);
126 /* the following list of flags are the same as their associated
127 * NETIF_F_xxx values in include/linux/netdevice.h
129 static const u32 flags_dup_features =
130 (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | ETH_FLAG_NTUPLE |
133 u32 ethtool_op_get_flags(struct net_device *dev)
135 /* in the future, this function will probably contain additional
136 * handling for flags which are not so easily handled
137 * by a simple masking operation
140 return dev->features & flags_dup_features;
142 EXPORT_SYMBOL(ethtool_op_get_flags);
144 int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported)
146 if (data & ~supported)
149 dev->features = ((dev->features & ~flags_dup_features) |
150 (data & flags_dup_features));
153 EXPORT_SYMBOL(ethtool_op_set_flags);
155 void ethtool_ntuple_flush(struct net_device *dev)
157 struct ethtool_rx_ntuple_flow_spec_container *fsc, *f;
159 list_for_each_entry_safe(fsc, f, &dev->ethtool_ntuple_list.list, list) {
160 list_del(&fsc->list);
163 dev->ethtool_ntuple_list.count = 0;
165 EXPORT_SYMBOL(ethtool_ntuple_flush);
167 /* Handlers for each ethtool command */
169 #define ETHTOOL_DEV_FEATURE_WORDS 1
171 static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
173 struct ethtool_gfeatures cmd = {
174 .cmd = ETHTOOL_GFEATURES,
175 .size = ETHTOOL_DEV_FEATURE_WORDS,
177 struct ethtool_get_features_block features[ETHTOOL_DEV_FEATURE_WORDS] = {
179 .available = dev->hw_features,
180 .requested = dev->wanted_features,
181 .active = dev->features,
182 .never_changed = NETIF_F_NEVER_CHANGE,
185 u32 __user *sizeaddr;
188 sizeaddr = useraddr + offsetof(struct ethtool_gfeatures, size);
189 if (get_user(copy_size, sizeaddr))
192 if (copy_size > ETHTOOL_DEV_FEATURE_WORDS)
193 copy_size = ETHTOOL_DEV_FEATURE_WORDS;
195 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
197 useraddr += sizeof(cmd);
198 if (copy_to_user(useraddr, features, copy_size * sizeof(*features)))
204 static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
206 struct ethtool_sfeatures cmd;
207 struct ethtool_set_features_block features[ETHTOOL_DEV_FEATURE_WORDS];
210 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
212 useraddr += sizeof(cmd);
214 if (cmd.size != ETHTOOL_DEV_FEATURE_WORDS)
217 if (copy_from_user(features, useraddr, sizeof(features)))
220 if (features[0].valid & ~NETIF_F_ETHTOOL_BITS)
223 if (features[0].valid & ~dev->hw_features) {
224 features[0].valid &= dev->hw_features;
225 ret |= ETHTOOL_F_UNSUPPORTED;
228 dev->wanted_features &= ~features[0].valid;
229 dev->wanted_features |= features[0].valid & features[0].requested;
230 netdev_update_features(dev);
232 if ((dev->wanted_features ^ dev->features) & features[0].valid)
233 ret |= ETHTOOL_F_WISH;
238 static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GSTRING_LEN] = {
239 /* NETIF_F_SG */ "tx-scatter-gather",
240 /* NETIF_F_IP_CSUM */ "tx-checksum-ipv4",
241 /* NETIF_F_NO_CSUM */ "tx-checksum-unneeded",
242 /* NETIF_F_HW_CSUM */ "tx-checksum-ip-generic",
243 /* NETIF_F_IPV6_CSUM */ "tx_checksum-ipv6",
244 /* NETIF_F_HIGHDMA */ "highdma",
245 /* NETIF_F_FRAGLIST */ "tx-scatter-gather-fraglist",
246 /* NETIF_F_HW_VLAN_TX */ "tx-vlan-hw-insert",
248 /* NETIF_F_HW_VLAN_RX */ "rx-vlan-hw-parse",
249 /* NETIF_F_HW_VLAN_FILTER */ "rx-vlan-filter",
250 /* NETIF_F_VLAN_CHALLENGED */ "vlan-challenged",
251 /* NETIF_F_GSO */ "tx-generic-segmentation",
252 /* NETIF_F_LLTX */ "tx-lockless",
253 /* NETIF_F_NETNS_LOCAL */ "netns-local",
254 /* NETIF_F_GRO */ "rx-gro",
255 /* NETIF_F_LRO */ "rx-lro",
257 /* NETIF_F_TSO */ "tx-tcp-segmentation",
258 /* NETIF_F_UFO */ "tx-udp-fragmentation",
259 /* NETIF_F_GSO_ROBUST */ "tx-gso-robust",
260 /* NETIF_F_TSO_ECN */ "tx-tcp-ecn-segmentation",
261 /* NETIF_F_TSO6 */ "tx-tcp6-segmentation",
262 /* NETIF_F_FSO */ "tx-fcoe-segmentation",
266 /* NETIF_F_FCOE_CRC */ "tx-checksum-fcoe-crc",
267 /* NETIF_F_SCTP_CSUM */ "tx-checksum-sctp",
268 /* NETIF_F_FCOE_MTU */ "fcoe-mtu",
269 /* NETIF_F_NTUPLE */ "rx-ntuple-filter",
270 /* NETIF_F_RXHASH */ "rx-hashing",
271 /* NETIF_F_RXCSUM */ "rx-checksum",
276 static int __ethtool_get_sset_count(struct net_device *dev, int sset)
278 const struct ethtool_ops *ops = dev->ethtool_ops;
280 if (sset == ETH_SS_FEATURES)
281 return ARRAY_SIZE(netdev_features_strings);
283 if (ops && ops->get_sset_count && ops->get_strings)
284 return ops->get_sset_count(dev, sset);
289 static void __ethtool_get_strings(struct net_device *dev,
290 u32 stringset, u8 *data)
292 const struct ethtool_ops *ops = dev->ethtool_ops;
294 if (stringset == ETH_SS_FEATURES)
295 memcpy(data, netdev_features_strings,
296 sizeof(netdev_features_strings));
298 /* ops->get_strings is valid because checked earlier */
299 ops->get_strings(dev, stringset, data);
302 static u32 ethtool_get_feature_mask(u32 eth_cmd)
304 /* feature masks of legacy discrete ethtool ops */
307 case ETHTOOL_GTXCSUM:
308 case ETHTOOL_STXCSUM:
309 return NETIF_F_ALL_CSUM | NETIF_F_SCTP_CSUM;
310 case ETHTOOL_GRXCSUM:
311 case ETHTOOL_SRXCSUM:
312 return NETIF_F_RXCSUM;
318 return NETIF_F_ALL_TSO;
333 static void *__ethtool_get_one_feature_actor(struct net_device *dev, u32 ethcmd)
335 const struct ethtool_ops *ops = dev->ethtool_ops;
341 case ETHTOOL_GTXCSUM:
342 return ops->get_tx_csum;
343 case ETHTOOL_GRXCSUM:
344 return ops->get_rx_csum;
356 static u32 __ethtool_get_rx_csum_oldbug(struct net_device *dev)
358 return !!(dev->features & NETIF_F_ALL_CSUM);
361 static int ethtool_get_one_feature(struct net_device *dev,
362 char __user *useraddr, u32 ethcmd)
364 u32 mask = ethtool_get_feature_mask(ethcmd);
365 struct ethtool_value edata = {
367 .data = !!(dev->features & mask),
370 /* compatibility with discrete get_ ops */
371 if (!(dev->hw_features & mask)) {
372 u32 (*actor)(struct net_device *);
374 actor = __ethtool_get_one_feature_actor(dev, ethcmd);
376 /* bug compatibility with old get_rx_csum */
377 if (ethcmd == ETHTOOL_GRXCSUM && !actor)
378 actor = __ethtool_get_rx_csum_oldbug;
381 edata.data = actor(dev);
384 if (copy_to_user(useraddr, &edata, sizeof(edata)))
389 static int __ethtool_set_tx_csum(struct net_device *dev, u32 data);
390 static int __ethtool_set_rx_csum(struct net_device *dev, u32 data);
391 static int __ethtool_set_sg(struct net_device *dev, u32 data);
392 static int __ethtool_set_tso(struct net_device *dev, u32 data);
393 static int __ethtool_set_ufo(struct net_device *dev, u32 data);
395 static int ethtool_set_one_feature(struct net_device *dev,
396 void __user *useraddr, u32 ethcmd)
398 struct ethtool_value edata;
401 if (copy_from_user(&edata, useraddr, sizeof(edata)))
404 mask = ethtool_get_feature_mask(ethcmd);
405 mask &= dev->hw_features;
408 dev->wanted_features |= mask;
410 dev->wanted_features &= ~mask;
412 netdev_update_features(dev);
416 /* Driver is not converted to ndo_fix_features or does not
417 * support changing this offload. In the latter case it won't
418 * have corresponding ethtool_ops field set.
420 * Following part is to be removed after all drivers advertise
421 * their changeable features in netdev->hw_features and stop
422 * using discrete offload setting ops.
426 case ETHTOOL_STXCSUM:
427 return __ethtool_set_tx_csum(dev, edata.data);
428 case ETHTOOL_SRXCSUM:
429 return __ethtool_set_rx_csum(dev, edata.data);
431 return __ethtool_set_sg(dev, edata.data);
433 return __ethtool_set_tso(dev, edata.data);
435 return __ethtool_set_ufo(dev, edata.data);
441 static int __ethtool_set_flags(struct net_device *dev, u32 data)
445 if (data & ~flags_dup_features)
448 /* legacy set_flags() op */
449 if (dev->ethtool_ops->set_flags) {
450 if (unlikely(dev->hw_features & flags_dup_features))
452 "driver BUG: mixed hw_features and set_flags()\n");
453 return dev->ethtool_ops->set_flags(dev, data);
456 /* allow changing only bits set in hw_features */
457 changed = (data ^ dev->wanted_features) & flags_dup_features;
458 if (changed & ~dev->hw_features)
459 return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;
461 dev->wanted_features =
462 (dev->wanted_features & ~changed) | data;
464 netdev_update_features(dev);
469 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
471 struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
474 if (!dev->ethtool_ops->get_settings)
477 err = dev->ethtool_ops->get_settings(dev, &cmd);
481 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
486 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
488 struct ethtool_cmd cmd;
490 if (!dev->ethtool_ops->set_settings)
493 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
496 return dev->ethtool_ops->set_settings(dev, &cmd);
499 static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
500 void __user *useraddr)
502 struct ethtool_drvinfo info;
503 const struct ethtool_ops *ops = dev->ethtool_ops;
505 memset(&info, 0, sizeof(info));
506 info.cmd = ETHTOOL_GDRVINFO;
507 if (ops && ops->get_drvinfo) {
508 ops->get_drvinfo(dev, &info);
509 } else if (dev->dev.parent && dev->dev.parent->driver) {
510 strlcpy(info.bus_info, dev_name(dev->dev.parent),
511 sizeof(info.bus_info));
512 strlcpy(info.driver, dev->dev.parent->driver->name,
513 sizeof(info.driver));
519 * this method of obtaining string set info is deprecated;
520 * Use ETHTOOL_GSSET_INFO instead.
522 if (ops && ops->get_sset_count) {
525 rc = ops->get_sset_count(dev, ETH_SS_TEST);
527 info.testinfo_len = rc;
528 rc = ops->get_sset_count(dev, ETH_SS_STATS);
531 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
533 info.n_priv_flags = rc;
535 if (ops && ops->get_regs_len)
536 info.regdump_len = ops->get_regs_len(dev);
537 if (ops && ops->get_eeprom_len)
538 info.eedump_len = ops->get_eeprom_len(dev);
540 if (copy_to_user(useraddr, &info, sizeof(info)))
545 static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
546 void __user *useraddr)
548 struct ethtool_sset_info info;
550 int i, idx = 0, n_bits = 0, ret, rc;
551 u32 *info_buf = NULL;
553 if (copy_from_user(&info, useraddr, sizeof(info)))
556 /* store copy of mask, because we zero struct later on */
557 sset_mask = info.sset_mask;
561 /* calculate size of return buffer */
562 n_bits = hweight64(sset_mask);
564 memset(&info, 0, sizeof(info));
565 info.cmd = ETHTOOL_GSSET_INFO;
567 info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER);
572 * fill return buffer based on input bitmask and successful
573 * get_sset_count return
575 for (i = 0; i < 64; i++) {
576 if (!(sset_mask & (1ULL << i)))
579 rc = __ethtool_get_sset_count(dev, i);
581 info.sset_mask |= (1ULL << i);
582 info_buf[idx++] = rc;
587 if (copy_to_user(useraddr, &info, sizeof(info)))
590 useraddr += offsetof(struct ethtool_sset_info, data);
591 if (copy_to_user(useraddr, info_buf, idx * sizeof(u32)))
601 static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
602 u32 cmd, void __user *useraddr)
604 struct ethtool_rxnfc info;
605 size_t info_size = sizeof(info);
607 if (!dev->ethtool_ops->set_rxnfc)
610 /* struct ethtool_rxnfc was originally defined for
611 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
612 * members. User-space might still be using that
614 if (cmd == ETHTOOL_SRXFH)
615 info_size = (offsetof(struct ethtool_rxnfc, data) +
618 if (copy_from_user(&info, useraddr, info_size))
621 return dev->ethtool_ops->set_rxnfc(dev, &info);
624 static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
625 u32 cmd, void __user *useraddr)
627 struct ethtool_rxnfc info;
628 size_t info_size = sizeof(info);
629 const struct ethtool_ops *ops = dev->ethtool_ops;
631 void *rule_buf = NULL;
636 /* struct ethtool_rxnfc was originally defined for
637 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
638 * members. User-space might still be using that
640 if (cmd == ETHTOOL_GRXFH)
641 info_size = (offsetof(struct ethtool_rxnfc, data) +
644 if (copy_from_user(&info, useraddr, info_size))
647 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
648 if (info.rule_cnt > 0) {
649 if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
650 rule_buf = kzalloc(info.rule_cnt * sizeof(u32),
657 ret = ops->get_rxnfc(dev, &info, rule_buf);
662 if (copy_to_user(useraddr, &info, info_size))
666 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
667 if (copy_to_user(useraddr, rule_buf,
668 info.rule_cnt * sizeof(u32)))
679 static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
680 void __user *useraddr)
682 struct ethtool_rxfh_indir *indir;
687 if (!dev->ethtool_ops->get_rxfh_indir)
690 if (copy_from_user(&table_size,
691 useraddr + offsetof(struct ethtool_rxfh_indir, size),
696 (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index))
698 full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size;
699 indir = kzalloc(full_size, GFP_USER);
703 indir->cmd = ETHTOOL_GRXFHINDIR;
704 indir->size = table_size;
705 ret = dev->ethtool_ops->get_rxfh_indir(dev, indir);
709 if (copy_to_user(useraddr, indir, full_size))
717 static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
718 void __user *useraddr)
720 struct ethtool_rxfh_indir *indir;
725 if (!dev->ethtool_ops->set_rxfh_indir)
728 if (copy_from_user(&table_size,
729 useraddr + offsetof(struct ethtool_rxfh_indir, size),
734 (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index))
736 full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size;
737 indir = kmalloc(full_size, GFP_USER);
741 if (copy_from_user(indir, useraddr, full_size)) {
746 ret = dev->ethtool_ops->set_rxfh_indir(dev, indir);
753 static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
754 struct ethtool_rx_ntuple_flow_spec *spec,
755 struct ethtool_rx_ntuple_flow_spec_container *fsc)
758 /* don't add filters forever */
759 if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY) {
760 /* free the container */
765 /* Copy the whole filter over */
766 fsc->fs.flow_type = spec->flow_type;
767 memcpy(&fsc->fs.h_u, &spec->h_u, sizeof(spec->h_u));
768 memcpy(&fsc->fs.m_u, &spec->m_u, sizeof(spec->m_u));
770 fsc->fs.vlan_tag = spec->vlan_tag;
771 fsc->fs.vlan_tag_mask = spec->vlan_tag_mask;
772 fsc->fs.data = spec->data;
773 fsc->fs.data_mask = spec->data_mask;
774 fsc->fs.action = spec->action;
776 /* add to the list */
777 list_add_tail_rcu(&fsc->list, &list->list);
782 * ethtool does not (or did not) set masks for flow parameters that are
783 * not specified, so if both value and mask are 0 then this must be
784 * treated as equivalent to a mask with all bits set. Implement that
785 * here rather than in drivers.
787 static void rx_ntuple_fix_masks(struct ethtool_rx_ntuple_flow_spec *fs)
789 struct ethtool_tcpip4_spec *entry = &fs->h_u.tcp_ip4_spec;
790 struct ethtool_tcpip4_spec *mask = &fs->m_u.tcp_ip4_spec;
792 if (fs->flow_type != TCP_V4_FLOW &&
793 fs->flow_type != UDP_V4_FLOW &&
794 fs->flow_type != SCTP_V4_FLOW)
797 if (!(entry->ip4src | mask->ip4src))
798 mask->ip4src = htonl(0xffffffff);
799 if (!(entry->ip4dst | mask->ip4dst))
800 mask->ip4dst = htonl(0xffffffff);
801 if (!(entry->psrc | mask->psrc))
802 mask->psrc = htons(0xffff);
803 if (!(entry->pdst | mask->pdst))
804 mask->pdst = htons(0xffff);
805 if (!(entry->tos | mask->tos))
807 if (!(fs->vlan_tag | fs->vlan_tag_mask))
808 fs->vlan_tag_mask = 0xffff;
809 if (!(fs->data | fs->data_mask))
810 fs->data_mask = 0xffffffffffffffffULL;
813 static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev,
814 void __user *useraddr)
816 struct ethtool_rx_ntuple cmd;
817 const struct ethtool_ops *ops = dev->ethtool_ops;
818 struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL;
821 if (!(dev->features & NETIF_F_NTUPLE))
824 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
827 rx_ntuple_fix_masks(&cmd.fs);
830 * Cache filter in dev struct for GET operation only if
831 * the underlying driver doesn't have its own GET operation, and
832 * only if the filter was added successfully. First make sure we
833 * can allocate the filter, then continue if successful.
835 if (!ops->get_rx_ntuple) {
836 fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC);
841 ret = ops->set_rx_ntuple(dev, &cmd);
847 if (!ops->get_rx_ntuple)
848 __rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs, fsc);
853 static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr)
855 struct ethtool_gstrings gstrings;
856 const struct ethtool_ops *ops = dev->ethtool_ops;
857 struct ethtool_rx_ntuple_flow_spec_container *fsc;
860 int ret, i, num_strings = 0;
862 if (!ops->get_sset_count)
865 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
868 ret = ops->get_sset_count(dev, gstrings.string_set);
874 data = kzalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
878 if (ops->get_rx_ntuple) {
879 /* driver-specific filter grab */
880 ret = ops->get_rx_ntuple(dev, gstrings.string_set, data);
884 /* default ethtool filter grab */
887 list_for_each_entry(fsc, &dev->ethtool_ntuple_list.list, list) {
888 sprintf(p, "Filter %d:\n", i);
889 p += ETH_GSTRING_LEN;
892 switch (fsc->fs.flow_type) {
894 sprintf(p, "\tFlow Type: TCP\n");
895 p += ETH_GSTRING_LEN;
899 sprintf(p, "\tFlow Type: UDP\n");
900 p += ETH_GSTRING_LEN;
904 sprintf(p, "\tFlow Type: SCTP\n");
905 p += ETH_GSTRING_LEN;
909 sprintf(p, "\tFlow Type: AH ESP\n");
910 p += ETH_GSTRING_LEN;
914 sprintf(p, "\tFlow Type: ESP\n");
915 p += ETH_GSTRING_LEN;
919 sprintf(p, "\tFlow Type: Raw IP\n");
920 p += ETH_GSTRING_LEN;
924 sprintf(p, "\tFlow Type: IPv4\n");
925 p += ETH_GSTRING_LEN;
929 sprintf(p, "\tFlow Type: Unknown\n");
930 p += ETH_GSTRING_LEN;
935 /* now the rest of the filters */
936 switch (fsc->fs.flow_type) {
940 sprintf(p, "\tSrc IP addr: 0x%x\n",
941 fsc->fs.h_u.tcp_ip4_spec.ip4src);
942 p += ETH_GSTRING_LEN;
944 sprintf(p, "\tSrc IP mask: 0x%x\n",
945 fsc->fs.m_u.tcp_ip4_spec.ip4src);
946 p += ETH_GSTRING_LEN;
948 sprintf(p, "\tDest IP addr: 0x%x\n",
949 fsc->fs.h_u.tcp_ip4_spec.ip4dst);
950 p += ETH_GSTRING_LEN;
952 sprintf(p, "\tDest IP mask: 0x%x\n",
953 fsc->fs.m_u.tcp_ip4_spec.ip4dst);
954 p += ETH_GSTRING_LEN;
956 sprintf(p, "\tSrc Port: %d, mask: 0x%x\n",
957 fsc->fs.h_u.tcp_ip4_spec.psrc,
958 fsc->fs.m_u.tcp_ip4_spec.psrc);
959 p += ETH_GSTRING_LEN;
961 sprintf(p, "\tDest Port: %d, mask: 0x%x\n",
962 fsc->fs.h_u.tcp_ip4_spec.pdst,
963 fsc->fs.m_u.tcp_ip4_spec.pdst);
964 p += ETH_GSTRING_LEN;
966 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
967 fsc->fs.h_u.tcp_ip4_spec.tos,
968 fsc->fs.m_u.tcp_ip4_spec.tos);
969 p += ETH_GSTRING_LEN;
974 sprintf(p, "\tSrc IP addr: 0x%x\n",
975 fsc->fs.h_u.ah_ip4_spec.ip4src);
976 p += ETH_GSTRING_LEN;
978 sprintf(p, "\tSrc IP mask: 0x%x\n",
979 fsc->fs.m_u.ah_ip4_spec.ip4src);
980 p += ETH_GSTRING_LEN;
982 sprintf(p, "\tDest IP addr: 0x%x\n",
983 fsc->fs.h_u.ah_ip4_spec.ip4dst);
984 p += ETH_GSTRING_LEN;
986 sprintf(p, "\tDest IP mask: 0x%x\n",
987 fsc->fs.m_u.ah_ip4_spec.ip4dst);
988 p += ETH_GSTRING_LEN;
990 sprintf(p, "\tSPI: %d, mask: 0x%x\n",
991 fsc->fs.h_u.ah_ip4_spec.spi,
992 fsc->fs.m_u.ah_ip4_spec.spi);
993 p += ETH_GSTRING_LEN;
995 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
996 fsc->fs.h_u.ah_ip4_spec.tos,
997 fsc->fs.m_u.ah_ip4_spec.tos);
998 p += ETH_GSTRING_LEN;
1002 sprintf(p, "\tSrc IP addr: 0x%x\n",
1003 fsc->fs.h_u.usr_ip4_spec.ip4src);
1004 p += ETH_GSTRING_LEN;
1006 sprintf(p, "\tSrc IP mask: 0x%x\n",
1007 fsc->fs.m_u.usr_ip4_spec.ip4src);
1008 p += ETH_GSTRING_LEN;
1010 sprintf(p, "\tDest IP addr: 0x%x\n",
1011 fsc->fs.h_u.usr_ip4_spec.ip4dst);
1012 p += ETH_GSTRING_LEN;
1014 sprintf(p, "\tDest IP mask: 0x%x\n",
1015 fsc->fs.m_u.usr_ip4_spec.ip4dst);
1016 p += ETH_GSTRING_LEN;
1020 sprintf(p, "\tSrc IP addr: 0x%x\n",
1021 fsc->fs.h_u.usr_ip4_spec.ip4src);
1022 p += ETH_GSTRING_LEN;
1024 sprintf(p, "\tSrc IP mask: 0x%x\n",
1025 fsc->fs.m_u.usr_ip4_spec.ip4src);
1026 p += ETH_GSTRING_LEN;
1028 sprintf(p, "\tDest IP addr: 0x%x\n",
1029 fsc->fs.h_u.usr_ip4_spec.ip4dst);
1030 p += ETH_GSTRING_LEN;
1032 sprintf(p, "\tDest IP mask: 0x%x\n",
1033 fsc->fs.m_u.usr_ip4_spec.ip4dst);
1034 p += ETH_GSTRING_LEN;
1036 sprintf(p, "\tL4 bytes: 0x%x, mask: 0x%x\n",
1037 fsc->fs.h_u.usr_ip4_spec.l4_4_bytes,
1038 fsc->fs.m_u.usr_ip4_spec.l4_4_bytes);
1039 p += ETH_GSTRING_LEN;
1041 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
1042 fsc->fs.h_u.usr_ip4_spec.tos,
1043 fsc->fs.m_u.usr_ip4_spec.tos);
1044 p += ETH_GSTRING_LEN;
1046 sprintf(p, "\tIP Version: %d, mask: 0x%x\n",
1047 fsc->fs.h_u.usr_ip4_spec.ip_ver,
1048 fsc->fs.m_u.usr_ip4_spec.ip_ver);
1049 p += ETH_GSTRING_LEN;
1051 sprintf(p, "\tProtocol: %d, mask: 0x%x\n",
1052 fsc->fs.h_u.usr_ip4_spec.proto,
1053 fsc->fs.m_u.usr_ip4_spec.proto);
1054 p += ETH_GSTRING_LEN;
1058 sprintf(p, "\tVLAN: %d, mask: 0x%x\n",
1059 fsc->fs.vlan_tag, fsc->fs.vlan_tag_mask);
1060 p += ETH_GSTRING_LEN;
1062 sprintf(p, "\tUser-defined: 0x%Lx\n", fsc->fs.data);
1063 p += ETH_GSTRING_LEN;
1065 sprintf(p, "\tUser-defined mask: 0x%Lx\n", fsc->fs.data_mask);
1066 p += ETH_GSTRING_LEN;
1068 if (fsc->fs.action == ETHTOOL_RXNTUPLE_ACTION_DROP)
1069 sprintf(p, "\tAction: Drop\n");
1071 sprintf(p, "\tAction: Direct to queue %d\n",
1073 p += ETH_GSTRING_LEN;
1079 /* indicate to userspace how many strings we actually have */
1080 gstrings.len = num_strings;
1082 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1084 useraddr += sizeof(gstrings);
1085 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1094 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
1096 struct ethtool_regs regs;
1097 const struct ethtool_ops *ops = dev->ethtool_ops;
1101 if (!ops->get_regs || !ops->get_regs_len)
1104 if (copy_from_user(®s, useraddr, sizeof(regs)))
1107 reglen = ops->get_regs_len(dev);
1108 if (regs.len > reglen)
1111 regbuf = vzalloc(reglen);
1115 ops->get_regs(dev, ®s, regbuf);
1118 if (copy_to_user(useraddr, ®s, sizeof(regs)))
1120 useraddr += offsetof(struct ethtool_regs, data);
1121 if (copy_to_user(useraddr, regbuf, regs.len))
1130 static int ethtool_reset(struct net_device *dev, char __user *useraddr)
1132 struct ethtool_value reset;
1135 if (!dev->ethtool_ops->reset)
1138 if (copy_from_user(&reset, useraddr, sizeof(reset)))
1141 ret = dev->ethtool_ops->reset(dev, &reset.data);
1145 if (copy_to_user(useraddr, &reset, sizeof(reset)))
1150 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
1152 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
1154 if (!dev->ethtool_ops->get_wol)
1157 dev->ethtool_ops->get_wol(dev, &wol);
1159 if (copy_to_user(useraddr, &wol, sizeof(wol)))
1164 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
1166 struct ethtool_wolinfo wol;
1168 if (!dev->ethtool_ops->set_wol)
1171 if (copy_from_user(&wol, useraddr, sizeof(wol)))
1174 return dev->ethtool_ops->set_wol(dev, &wol);
1177 static int ethtool_nway_reset(struct net_device *dev)
1179 if (!dev->ethtool_ops->nway_reset)
1182 return dev->ethtool_ops->nway_reset(dev);
1185 static int ethtool_get_link(struct net_device *dev, char __user *useraddr)
1187 struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
1189 if (!dev->ethtool_ops->get_link)
1192 edata.data = netif_running(dev) && dev->ethtool_ops->get_link(dev);
1194 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1199 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
1201 struct ethtool_eeprom eeprom;
1202 const struct ethtool_ops *ops = dev->ethtool_ops;
1203 void __user *userbuf = useraddr + sizeof(eeprom);
1204 u32 bytes_remaining;
1208 if (!ops->get_eeprom || !ops->get_eeprom_len)
1211 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
1214 /* Check for wrap and zero */
1215 if (eeprom.offset + eeprom.len <= eeprom.offset)
1218 /* Check for exceeding total eeprom len */
1219 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
1222 data = kmalloc(PAGE_SIZE, GFP_USER);
1226 bytes_remaining = eeprom.len;
1227 while (bytes_remaining > 0) {
1228 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1230 ret = ops->get_eeprom(dev, &eeprom, data);
1233 if (copy_to_user(userbuf, data, eeprom.len)) {
1237 userbuf += eeprom.len;
1238 eeprom.offset += eeprom.len;
1239 bytes_remaining -= eeprom.len;
1242 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
1243 eeprom.offset -= eeprom.len;
1244 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
1251 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
1253 struct ethtool_eeprom eeprom;
1254 const struct ethtool_ops *ops = dev->ethtool_ops;
1255 void __user *userbuf = useraddr + sizeof(eeprom);
1256 u32 bytes_remaining;
1260 if (!ops->set_eeprom || !ops->get_eeprom_len)
1263 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
1266 /* Check for wrap and zero */
1267 if (eeprom.offset + eeprom.len <= eeprom.offset)
1270 /* Check for exceeding total eeprom len */
1271 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
1274 data = kmalloc(PAGE_SIZE, GFP_USER);
1278 bytes_remaining = eeprom.len;
1279 while (bytes_remaining > 0) {
1280 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1282 if (copy_from_user(data, userbuf, eeprom.len)) {
1286 ret = ops->set_eeprom(dev, &eeprom, data);
1289 userbuf += eeprom.len;
1290 eeprom.offset += eeprom.len;
1291 bytes_remaining -= eeprom.len;
1298 static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev,
1299 void __user *useraddr)
1301 struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
1303 if (!dev->ethtool_ops->get_coalesce)
1306 dev->ethtool_ops->get_coalesce(dev, &coalesce);
1308 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
1313 static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
1314 void __user *useraddr)
1316 struct ethtool_coalesce coalesce;
1318 if (!dev->ethtool_ops->set_coalesce)
1321 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
1324 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
1327 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
1329 struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM };
1331 if (!dev->ethtool_ops->get_ringparam)
1334 dev->ethtool_ops->get_ringparam(dev, &ringparam);
1336 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
1341 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
1343 struct ethtool_ringparam ringparam;
1345 if (!dev->ethtool_ops->set_ringparam)
1348 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
1351 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
1354 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
1356 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
1358 if (!dev->ethtool_ops->get_pauseparam)
1361 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
1363 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
1368 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
1370 struct ethtool_pauseparam pauseparam;
1372 if (!dev->ethtool_ops->set_pauseparam)
1375 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
1378 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
1381 static int __ethtool_set_sg(struct net_device *dev, u32 data)
1385 if (data && !(dev->features & NETIF_F_ALL_CSUM))
1388 if (!data && dev->ethtool_ops->set_tso) {
1389 err = dev->ethtool_ops->set_tso(dev, 0);
1394 if (!data && dev->ethtool_ops->set_ufo) {
1395 err = dev->ethtool_ops->set_ufo(dev, 0);
1399 return dev->ethtool_ops->set_sg(dev, data);
1402 static int __ethtool_set_tx_csum(struct net_device *dev, u32 data)
1406 if (!dev->ethtool_ops->set_tx_csum)
1409 if (!data && dev->ethtool_ops->set_sg) {
1410 err = __ethtool_set_sg(dev, 0);
1415 return dev->ethtool_ops->set_tx_csum(dev, data);
1418 static int __ethtool_set_rx_csum(struct net_device *dev, u32 data)
1420 if (!dev->ethtool_ops->set_rx_csum)
1424 dev->features &= ~NETIF_F_GRO;
1426 return dev->ethtool_ops->set_rx_csum(dev, data);
1429 static int __ethtool_set_tso(struct net_device *dev, u32 data)
1431 if (!dev->ethtool_ops->set_tso)
1434 if (data && !(dev->features & NETIF_F_SG))
1437 return dev->ethtool_ops->set_tso(dev, data);
1440 static int __ethtool_set_ufo(struct net_device *dev, u32 data)
1442 if (!dev->ethtool_ops->set_ufo)
1444 if (data && !(dev->features & NETIF_F_SG))
1446 if (data && !((dev->features & NETIF_F_GEN_CSUM) ||
1447 (dev->features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
1448 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)))
1450 return dev->ethtool_ops->set_ufo(dev, data);
1453 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
1455 struct ethtool_test test;
1456 const struct ethtool_ops *ops = dev->ethtool_ops;
1460 if (!ops->self_test || !ops->get_sset_count)
1463 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
1466 WARN_ON(test_len == 0);
1468 if (copy_from_user(&test, useraddr, sizeof(test)))
1471 test.len = test_len;
1472 data = kmalloc(test_len * sizeof(u64), GFP_USER);
1476 ops->self_test(dev, &test, data);
1479 if (copy_to_user(useraddr, &test, sizeof(test)))
1481 useraddr += sizeof(test);
1482 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
1491 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1493 struct ethtool_gstrings gstrings;
1497 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
1500 ret = __ethtool_get_sset_count(dev, gstrings.string_set);
1506 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
1510 __ethtool_get_strings(dev, gstrings.string_set, data);
1513 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1515 useraddr += sizeof(gstrings);
1516 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1525 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1527 struct ethtool_value id;
1529 if (!dev->ethtool_ops->phys_id)
1532 if (copy_from_user(&id, useraddr, sizeof(id)))
1535 return dev->ethtool_ops->phys_id(dev, id.data);
1538 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
1540 struct ethtool_stats stats;
1541 const struct ethtool_ops *ops = dev->ethtool_ops;
1545 if (!ops->get_ethtool_stats || !ops->get_sset_count)
1548 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
1551 WARN_ON(n_stats == 0);
1553 if (copy_from_user(&stats, useraddr, sizeof(stats)))
1556 stats.n_stats = n_stats;
1557 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
1561 ops->get_ethtool_stats(dev, &stats, data);
1564 if (copy_to_user(useraddr, &stats, sizeof(stats)))
1566 useraddr += sizeof(stats);
1567 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
1576 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
1578 struct ethtool_perm_addr epaddr;
1580 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
1583 if (epaddr.size < dev->addr_len)
1585 epaddr.size = dev->addr_len;
1587 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
1589 useraddr += sizeof(epaddr);
1590 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
1595 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
1596 u32 cmd, u32 (*actor)(struct net_device *))
1598 struct ethtool_value edata = { .cmd = cmd };
1603 edata.data = actor(dev);
1605 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1610 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
1611 void (*actor)(struct net_device *, u32))
1613 struct ethtool_value edata;
1618 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1621 actor(dev, edata.data);
1625 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
1626 int (*actor)(struct net_device *, u32))
1628 struct ethtool_value edata;
1633 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1636 return actor(dev, edata.data);
1639 static noinline_for_stack int ethtool_flash_device(struct net_device *dev,
1640 char __user *useraddr)
1642 struct ethtool_flash efl;
1644 if (copy_from_user(&efl, useraddr, sizeof(efl)))
1647 if (!dev->ethtool_ops->flash_device)
1650 return dev->ethtool_ops->flash_device(dev, &efl);
1653 /* The main entry point in this file. Called from net/core/dev.c */
1655 int dev_ethtool(struct net *net, struct ifreq *ifr)
1657 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
1658 void __user *useraddr = ifr->ifr_data;
1663 if (!dev || !netif_device_present(dev))
1666 if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
1669 if (!dev->ethtool_ops) {
1670 /* ETHTOOL_GDRVINFO does not require any driver support.
1671 * It is also unprivileged and does not change anything,
1672 * so we can take a shortcut to it. */
1673 if (ethcmd == ETHTOOL_GDRVINFO)
1674 return ethtool_get_drvinfo(dev, useraddr);
1679 /* Allow some commands to be done by anyone */
1682 case ETHTOOL_GDRVINFO:
1683 case ETHTOOL_GMSGLVL:
1684 case ETHTOOL_GCOALESCE:
1685 case ETHTOOL_GRINGPARAM:
1686 case ETHTOOL_GPAUSEPARAM:
1687 case ETHTOOL_GRXCSUM:
1688 case ETHTOOL_GTXCSUM:
1690 case ETHTOOL_GSTRINGS:
1692 case ETHTOOL_GPERMADDR:
1696 case ETHTOOL_GFLAGS:
1697 case ETHTOOL_GPFLAGS:
1699 case ETHTOOL_GRXRINGS:
1700 case ETHTOOL_GRXCLSRLCNT:
1701 case ETHTOOL_GRXCLSRULE:
1702 case ETHTOOL_GRXCLSRLALL:
1703 case ETHTOOL_GFEATURES:
1706 if (!capable(CAP_NET_ADMIN))
1710 if (dev->ethtool_ops->begin) {
1711 rc = dev->ethtool_ops->begin(dev);
1715 old_features = dev->features;
1719 rc = ethtool_get_settings(dev, useraddr);
1722 rc = ethtool_set_settings(dev, useraddr);
1724 case ETHTOOL_GDRVINFO:
1725 rc = ethtool_get_drvinfo(dev, useraddr);
1728 rc = ethtool_get_regs(dev, useraddr);
1731 rc = ethtool_get_wol(dev, useraddr);
1734 rc = ethtool_set_wol(dev, useraddr);
1736 case ETHTOOL_GMSGLVL:
1737 rc = ethtool_get_value(dev, useraddr, ethcmd,
1738 dev->ethtool_ops->get_msglevel);
1740 case ETHTOOL_SMSGLVL:
1741 rc = ethtool_set_value_void(dev, useraddr,
1742 dev->ethtool_ops->set_msglevel);
1744 case ETHTOOL_NWAY_RST:
1745 rc = ethtool_nway_reset(dev);
1748 rc = ethtool_get_link(dev, useraddr);
1750 case ETHTOOL_GEEPROM:
1751 rc = ethtool_get_eeprom(dev, useraddr);
1753 case ETHTOOL_SEEPROM:
1754 rc = ethtool_set_eeprom(dev, useraddr);
1756 case ETHTOOL_GCOALESCE:
1757 rc = ethtool_get_coalesce(dev, useraddr);
1759 case ETHTOOL_SCOALESCE:
1760 rc = ethtool_set_coalesce(dev, useraddr);
1762 case ETHTOOL_GRINGPARAM:
1763 rc = ethtool_get_ringparam(dev, useraddr);
1765 case ETHTOOL_SRINGPARAM:
1766 rc = ethtool_set_ringparam(dev, useraddr);
1768 case ETHTOOL_GPAUSEPARAM:
1769 rc = ethtool_get_pauseparam(dev, useraddr);
1771 case ETHTOOL_SPAUSEPARAM:
1772 rc = ethtool_set_pauseparam(dev, useraddr);
1775 rc = ethtool_self_test(dev, useraddr);
1777 case ETHTOOL_GSTRINGS:
1778 rc = ethtool_get_strings(dev, useraddr);
1780 case ETHTOOL_PHYS_ID:
1781 rc = ethtool_phys_id(dev, useraddr);
1783 case ETHTOOL_GSTATS:
1784 rc = ethtool_get_stats(dev, useraddr);
1786 case ETHTOOL_GPERMADDR:
1787 rc = ethtool_get_perm_addr(dev, useraddr);
1789 case ETHTOOL_GFLAGS:
1790 rc = ethtool_get_value(dev, useraddr, ethcmd,
1791 (dev->ethtool_ops->get_flags ?
1792 dev->ethtool_ops->get_flags :
1793 ethtool_op_get_flags));
1795 case ETHTOOL_SFLAGS:
1796 rc = ethtool_set_value(dev, useraddr, __ethtool_set_flags);
1798 case ETHTOOL_GPFLAGS:
1799 rc = ethtool_get_value(dev, useraddr, ethcmd,
1800 dev->ethtool_ops->get_priv_flags);
1802 case ETHTOOL_SPFLAGS:
1803 rc = ethtool_set_value(dev, useraddr,
1804 dev->ethtool_ops->set_priv_flags);
1807 case ETHTOOL_GRXRINGS:
1808 case ETHTOOL_GRXCLSRLCNT:
1809 case ETHTOOL_GRXCLSRULE:
1810 case ETHTOOL_GRXCLSRLALL:
1811 rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
1814 case ETHTOOL_SRXCLSRLDEL:
1815 case ETHTOOL_SRXCLSRLINS:
1816 rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
1818 case ETHTOOL_FLASHDEV:
1819 rc = ethtool_flash_device(dev, useraddr);
1822 rc = ethtool_reset(dev, useraddr);
1824 case ETHTOOL_SRXNTUPLE:
1825 rc = ethtool_set_rx_ntuple(dev, useraddr);
1827 case ETHTOOL_GRXNTUPLE:
1828 rc = ethtool_get_rx_ntuple(dev, useraddr);
1830 case ETHTOOL_GSSET_INFO:
1831 rc = ethtool_get_sset_info(dev, useraddr);
1833 case ETHTOOL_GRXFHINDIR:
1834 rc = ethtool_get_rxfh_indir(dev, useraddr);
1836 case ETHTOOL_SRXFHINDIR:
1837 rc = ethtool_set_rxfh_indir(dev, useraddr);
1839 case ETHTOOL_GFEATURES:
1840 rc = ethtool_get_features(dev, useraddr);
1842 case ETHTOOL_SFEATURES:
1843 rc = ethtool_set_features(dev, useraddr);
1845 case ETHTOOL_GTXCSUM:
1846 case ETHTOOL_GRXCSUM:
1852 rc = ethtool_get_one_feature(dev, useraddr, ethcmd);
1854 case ETHTOOL_STXCSUM:
1855 case ETHTOOL_SRXCSUM:
1861 rc = ethtool_set_one_feature(dev, useraddr, ethcmd);
1867 if (dev->ethtool_ops->complete)
1868 dev->ethtool_ops->complete(dev);
1870 if (old_features != dev->features)
1871 netdev_features_change(dev);