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_rx_csum(struct net_device *dev)
39 return (dev->features & NETIF_F_ALL_CSUM) != 0;
41 EXPORT_SYMBOL(ethtool_op_get_rx_csum);
43 u32 ethtool_op_get_tx_csum(struct net_device *dev)
45 return (dev->features & NETIF_F_ALL_CSUM) != 0;
47 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
49 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
52 dev->features |= NETIF_F_IP_CSUM;
54 dev->features &= ~NETIF_F_IP_CSUM;
58 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
60 int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
63 dev->features |= NETIF_F_HW_CSUM;
65 dev->features &= ~NETIF_F_HW_CSUM;
69 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
71 int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data)
74 dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
76 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
80 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
82 u32 ethtool_op_get_sg(struct net_device *dev)
84 return (dev->features & NETIF_F_SG) != 0;
86 EXPORT_SYMBOL(ethtool_op_get_sg);
88 int ethtool_op_set_sg(struct net_device *dev, u32 data)
91 dev->features |= NETIF_F_SG;
93 dev->features &= ~NETIF_F_SG;
97 EXPORT_SYMBOL(ethtool_op_set_sg);
99 u32 ethtool_op_get_tso(struct net_device *dev)
101 return (dev->features & NETIF_F_TSO) != 0;
103 EXPORT_SYMBOL(ethtool_op_get_tso);
105 int ethtool_op_set_tso(struct net_device *dev, u32 data)
108 dev->features |= NETIF_F_TSO;
110 dev->features &= ~NETIF_F_TSO;
114 EXPORT_SYMBOL(ethtool_op_set_tso);
116 u32 ethtool_op_get_ufo(struct net_device *dev)
118 return (dev->features & NETIF_F_UFO) != 0;
120 EXPORT_SYMBOL(ethtool_op_get_ufo);
122 int ethtool_op_set_ufo(struct net_device *dev, u32 data)
125 dev->features |= NETIF_F_UFO;
127 dev->features &= ~NETIF_F_UFO;
130 EXPORT_SYMBOL(ethtool_op_set_ufo);
132 /* the following list of flags are the same as their associated
133 * NETIF_F_xxx values in include/linux/netdevice.h
135 static const u32 flags_dup_features =
136 (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | ETH_FLAG_NTUPLE |
139 u32 ethtool_op_get_flags(struct net_device *dev)
141 /* in the future, this function will probably contain additional
142 * handling for flags which are not so easily handled
143 * by a simple masking operation
146 return dev->features & flags_dup_features;
148 EXPORT_SYMBOL(ethtool_op_get_flags);
150 int ethtool_op_set_flags(struct net_device *dev, u32 data, u32 supported)
152 if (data & ~supported)
155 dev->features = ((dev->features & ~flags_dup_features) |
156 (data & flags_dup_features));
159 EXPORT_SYMBOL(ethtool_op_set_flags);
161 void ethtool_ntuple_flush(struct net_device *dev)
163 struct ethtool_rx_ntuple_flow_spec_container *fsc, *f;
165 list_for_each_entry_safe(fsc, f, &dev->ethtool_ntuple_list.list, list) {
166 list_del(&fsc->list);
169 dev->ethtool_ntuple_list.count = 0;
171 EXPORT_SYMBOL(ethtool_ntuple_flush);
173 /* Handlers for each ethtool command */
175 #define ETHTOOL_DEV_FEATURE_WORDS 1
177 static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
179 struct ethtool_gfeatures cmd = {
180 .cmd = ETHTOOL_GFEATURES,
181 .size = ETHTOOL_DEV_FEATURE_WORDS,
183 struct ethtool_get_features_block features[ETHTOOL_DEV_FEATURE_WORDS] = {
185 .available = dev->hw_features,
186 .requested = dev->wanted_features,
187 .active = dev->features,
188 .never_changed = NETIF_F_NEVER_CHANGE,
191 u32 __user *sizeaddr;
194 sizeaddr = useraddr + offsetof(struct ethtool_gfeatures, size);
195 if (get_user(copy_size, sizeaddr))
198 if (copy_size > ETHTOOL_DEV_FEATURE_WORDS)
199 copy_size = ETHTOOL_DEV_FEATURE_WORDS;
201 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
203 useraddr += sizeof(cmd);
204 if (copy_to_user(useraddr, features, copy_size * sizeof(*features)))
210 static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
212 struct ethtool_sfeatures cmd;
213 struct ethtool_set_features_block features[ETHTOOL_DEV_FEATURE_WORDS];
216 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
218 useraddr += sizeof(cmd);
220 if (cmd.size != ETHTOOL_DEV_FEATURE_WORDS)
223 if (copy_from_user(features, useraddr, sizeof(features)))
226 if (features[0].valid & ~NETIF_F_ETHTOOL_BITS)
229 if (features[0].valid & ~dev->hw_features) {
230 features[0].valid &= dev->hw_features;
231 ret |= ETHTOOL_F_UNSUPPORTED;
234 dev->wanted_features &= ~features[0].valid;
235 dev->wanted_features |= features[0].valid & features[0].requested;
236 netdev_update_features(dev);
238 if ((dev->wanted_features ^ dev->features) & features[0].valid)
239 ret |= ETHTOOL_F_WISH;
244 static const char netdev_features_strings[ETHTOOL_DEV_FEATURE_WORDS * 32][ETH_GSTRING_LEN] = {
245 /* NETIF_F_SG */ "tx-scatter-gather",
246 /* NETIF_F_IP_CSUM */ "tx-checksum-ipv4",
247 /* NETIF_F_NO_CSUM */ "tx-checksum-unneeded",
248 /* NETIF_F_HW_CSUM */ "tx-checksum-ip-generic",
249 /* NETIF_F_IPV6_CSUM */ "tx_checksum-ipv6",
250 /* NETIF_F_HIGHDMA */ "highdma",
251 /* NETIF_F_FRAGLIST */ "tx-scatter-gather-fraglist",
252 /* NETIF_F_HW_VLAN_TX */ "tx-vlan-hw-insert",
254 /* NETIF_F_HW_VLAN_RX */ "rx-vlan-hw-parse",
255 /* NETIF_F_HW_VLAN_FILTER */ "rx-vlan-filter",
256 /* NETIF_F_VLAN_CHALLENGED */ "vlan-challenged",
257 /* NETIF_F_GSO */ "tx-generic-segmentation",
258 /* NETIF_F_LLTX */ "tx-lockless",
259 /* NETIF_F_NETNS_LOCAL */ "netns-local",
260 /* NETIF_F_GRO */ "rx-gro",
261 /* NETIF_F_LRO */ "rx-lro",
263 /* NETIF_F_TSO */ "tx-tcp-segmentation",
264 /* NETIF_F_UFO */ "tx-udp-fragmentation",
265 /* NETIF_F_GSO_ROBUST */ "tx-gso-robust",
266 /* NETIF_F_TSO_ECN */ "tx-tcp-ecn-segmentation",
267 /* NETIF_F_TSO6 */ "tx-tcp6-segmentation",
268 /* NETIF_F_FSO */ "tx-fcoe-segmentation",
272 /* NETIF_F_FCOE_CRC */ "tx-checksum-fcoe-crc",
273 /* NETIF_F_SCTP_CSUM */ "tx-checksum-sctp",
274 /* NETIF_F_FCOE_MTU */ "fcoe-mtu",
275 /* NETIF_F_NTUPLE */ "rx-ntuple-filter",
276 /* NETIF_F_RXHASH */ "rx-hashing",
282 static int __ethtool_get_sset_count(struct net_device *dev, int sset)
284 const struct ethtool_ops *ops = dev->ethtool_ops;
286 if (sset == ETH_SS_FEATURES)
287 return ARRAY_SIZE(netdev_features_strings);
289 if (ops && ops->get_sset_count && ops->get_strings)
290 return ops->get_sset_count(dev, sset);
295 static void __ethtool_get_strings(struct net_device *dev,
296 u32 stringset, u8 *data)
298 const struct ethtool_ops *ops = dev->ethtool_ops;
300 if (stringset == ETH_SS_FEATURES)
301 memcpy(data, netdev_features_strings,
302 sizeof(netdev_features_strings));
304 /* ops->get_strings is valid because checked earlier */
305 ops->get_strings(dev, stringset, data);
308 static u32 ethtool_get_feature_mask(u32 eth_cmd)
310 /* feature masks of legacy discrete ethtool ops */
313 case ETHTOOL_GTXCSUM:
314 case ETHTOOL_STXCSUM:
315 return NETIF_F_ALL_CSUM | NETIF_F_SCTP_CSUM;
321 return NETIF_F_ALL_TSO;
336 static void *__ethtool_get_one_feature_actor(struct net_device *dev, u32 ethcmd)
338 const struct ethtool_ops *ops = dev->ethtool_ops;
344 case ETHTOOL_GTXCSUM:
345 return ops->get_tx_csum;
357 static int ethtool_get_one_feature(struct net_device *dev,
358 char __user *useraddr, u32 ethcmd)
360 u32 mask = ethtool_get_feature_mask(ethcmd);
361 struct ethtool_value edata = {
363 .data = !!(dev->features & mask),
366 /* compatibility with discrete get_ ops */
367 if (!(dev->hw_features & mask)) {
368 u32 (*actor)(struct net_device *);
370 actor = __ethtool_get_one_feature_actor(dev, ethcmd);
373 edata.data = actor(dev);
376 if (copy_to_user(useraddr, &edata, sizeof(edata)))
381 static int __ethtool_set_tx_csum(struct net_device *dev, u32 data);
382 static int __ethtool_set_sg(struct net_device *dev, u32 data);
383 static int __ethtool_set_tso(struct net_device *dev, u32 data);
384 static int __ethtool_set_ufo(struct net_device *dev, u32 data);
386 static int ethtool_set_one_feature(struct net_device *dev,
387 void __user *useraddr, u32 ethcmd)
389 struct ethtool_value edata;
392 if (copy_from_user(&edata, useraddr, sizeof(edata)))
395 mask = ethtool_get_feature_mask(ethcmd);
396 mask &= dev->hw_features;
399 dev->wanted_features |= mask;
401 dev->wanted_features &= ~mask;
403 netdev_update_features(dev);
407 /* Driver is not converted to ndo_fix_features or does not
408 * support changing this offload. In the latter case it won't
409 * have corresponding ethtool_ops field set.
411 * Following part is to be removed after all drivers advertise
412 * their changeable features in netdev->hw_features and stop
413 * using discrete offload setting ops.
417 case ETHTOOL_STXCSUM:
418 return __ethtool_set_tx_csum(dev, edata.data);
420 return __ethtool_set_sg(dev, edata.data);
422 return __ethtool_set_tso(dev, edata.data);
424 return __ethtool_set_ufo(dev, edata.data);
430 static int __ethtool_set_flags(struct net_device *dev, u32 data)
434 if (data & ~flags_dup_features)
437 /* legacy set_flags() op */
438 if (dev->ethtool_ops->set_flags) {
439 if (unlikely(dev->hw_features & flags_dup_features))
441 "driver BUG: mixed hw_features and set_flags()\n");
442 return dev->ethtool_ops->set_flags(dev, data);
445 /* allow changing only bits set in hw_features */
446 changed = (data ^ dev->wanted_features) & flags_dup_features;
447 if (changed & ~dev->hw_features)
448 return (changed & dev->hw_features) ? -EINVAL : -EOPNOTSUPP;
450 dev->wanted_features =
451 (dev->wanted_features & ~changed) | data;
453 netdev_update_features(dev);
458 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
460 struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
463 if (!dev->ethtool_ops->get_settings)
466 err = dev->ethtool_ops->get_settings(dev, &cmd);
470 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
475 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
477 struct ethtool_cmd cmd;
479 if (!dev->ethtool_ops->set_settings)
482 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
485 return dev->ethtool_ops->set_settings(dev, &cmd);
488 static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
489 void __user *useraddr)
491 struct ethtool_drvinfo info;
492 const struct ethtool_ops *ops = dev->ethtool_ops;
494 memset(&info, 0, sizeof(info));
495 info.cmd = ETHTOOL_GDRVINFO;
496 if (ops && ops->get_drvinfo) {
497 ops->get_drvinfo(dev, &info);
498 } else if (dev->dev.parent && dev->dev.parent->driver) {
499 strlcpy(info.bus_info, dev_name(dev->dev.parent),
500 sizeof(info.bus_info));
501 strlcpy(info.driver, dev->dev.parent->driver->name,
502 sizeof(info.driver));
508 * this method of obtaining string set info is deprecated;
509 * Use ETHTOOL_GSSET_INFO instead.
511 if (ops && ops->get_sset_count) {
514 rc = ops->get_sset_count(dev, ETH_SS_TEST);
516 info.testinfo_len = rc;
517 rc = ops->get_sset_count(dev, ETH_SS_STATS);
520 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
522 info.n_priv_flags = rc;
524 if (ops && ops->get_regs_len)
525 info.regdump_len = ops->get_regs_len(dev);
526 if (ops && ops->get_eeprom_len)
527 info.eedump_len = ops->get_eeprom_len(dev);
529 if (copy_to_user(useraddr, &info, sizeof(info)))
534 static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
535 void __user *useraddr)
537 struct ethtool_sset_info info;
539 int i, idx = 0, n_bits = 0, ret, rc;
540 u32 *info_buf = NULL;
542 if (copy_from_user(&info, useraddr, sizeof(info)))
545 /* store copy of mask, because we zero struct later on */
546 sset_mask = info.sset_mask;
550 /* calculate size of return buffer */
551 n_bits = hweight64(sset_mask);
553 memset(&info, 0, sizeof(info));
554 info.cmd = ETHTOOL_GSSET_INFO;
556 info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER);
561 * fill return buffer based on input bitmask and successful
562 * get_sset_count return
564 for (i = 0; i < 64; i++) {
565 if (!(sset_mask & (1ULL << i)))
568 rc = __ethtool_get_sset_count(dev, i);
570 info.sset_mask |= (1ULL << i);
571 info_buf[idx++] = rc;
576 if (copy_to_user(useraddr, &info, sizeof(info)))
579 useraddr += offsetof(struct ethtool_sset_info, data);
580 if (copy_to_user(useraddr, info_buf, idx * sizeof(u32)))
590 static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
591 u32 cmd, void __user *useraddr)
593 struct ethtool_rxnfc info;
594 size_t info_size = sizeof(info);
596 if (!dev->ethtool_ops->set_rxnfc)
599 /* struct ethtool_rxnfc was originally defined for
600 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
601 * members. User-space might still be using that
603 if (cmd == ETHTOOL_SRXFH)
604 info_size = (offsetof(struct ethtool_rxnfc, data) +
607 if (copy_from_user(&info, useraddr, info_size))
610 return dev->ethtool_ops->set_rxnfc(dev, &info);
613 static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
614 u32 cmd, void __user *useraddr)
616 struct ethtool_rxnfc info;
617 size_t info_size = sizeof(info);
618 const struct ethtool_ops *ops = dev->ethtool_ops;
620 void *rule_buf = NULL;
625 /* struct ethtool_rxnfc was originally defined for
626 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
627 * members. User-space might still be using that
629 if (cmd == ETHTOOL_GRXFH)
630 info_size = (offsetof(struct ethtool_rxnfc, data) +
633 if (copy_from_user(&info, useraddr, info_size))
636 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
637 if (info.rule_cnt > 0) {
638 if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
639 rule_buf = kzalloc(info.rule_cnt * sizeof(u32),
646 ret = ops->get_rxnfc(dev, &info, rule_buf);
651 if (copy_to_user(useraddr, &info, info_size))
655 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
656 if (copy_to_user(useraddr, rule_buf,
657 info.rule_cnt * sizeof(u32)))
668 static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
669 void __user *useraddr)
671 struct ethtool_rxfh_indir *indir;
676 if (!dev->ethtool_ops->get_rxfh_indir)
679 if (copy_from_user(&table_size,
680 useraddr + offsetof(struct ethtool_rxfh_indir, size),
685 (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index))
687 full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size;
688 indir = kzalloc(full_size, GFP_USER);
692 indir->cmd = ETHTOOL_GRXFHINDIR;
693 indir->size = table_size;
694 ret = dev->ethtool_ops->get_rxfh_indir(dev, indir);
698 if (copy_to_user(useraddr, indir, full_size))
706 static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
707 void __user *useraddr)
709 struct ethtool_rxfh_indir *indir;
714 if (!dev->ethtool_ops->set_rxfh_indir)
717 if (copy_from_user(&table_size,
718 useraddr + offsetof(struct ethtool_rxfh_indir, size),
723 (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index))
725 full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size;
726 indir = kmalloc(full_size, GFP_USER);
730 if (copy_from_user(indir, useraddr, full_size)) {
735 ret = dev->ethtool_ops->set_rxfh_indir(dev, indir);
742 static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
743 struct ethtool_rx_ntuple_flow_spec *spec,
744 struct ethtool_rx_ntuple_flow_spec_container *fsc)
747 /* don't add filters forever */
748 if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY) {
749 /* free the container */
754 /* Copy the whole filter over */
755 fsc->fs.flow_type = spec->flow_type;
756 memcpy(&fsc->fs.h_u, &spec->h_u, sizeof(spec->h_u));
757 memcpy(&fsc->fs.m_u, &spec->m_u, sizeof(spec->m_u));
759 fsc->fs.vlan_tag = spec->vlan_tag;
760 fsc->fs.vlan_tag_mask = spec->vlan_tag_mask;
761 fsc->fs.data = spec->data;
762 fsc->fs.data_mask = spec->data_mask;
763 fsc->fs.action = spec->action;
765 /* add to the list */
766 list_add_tail_rcu(&fsc->list, &list->list);
771 * ethtool does not (or did not) set masks for flow parameters that are
772 * not specified, so if both value and mask are 0 then this must be
773 * treated as equivalent to a mask with all bits set. Implement that
774 * here rather than in drivers.
776 static void rx_ntuple_fix_masks(struct ethtool_rx_ntuple_flow_spec *fs)
778 struct ethtool_tcpip4_spec *entry = &fs->h_u.tcp_ip4_spec;
779 struct ethtool_tcpip4_spec *mask = &fs->m_u.tcp_ip4_spec;
781 if (fs->flow_type != TCP_V4_FLOW &&
782 fs->flow_type != UDP_V4_FLOW &&
783 fs->flow_type != SCTP_V4_FLOW)
786 if (!(entry->ip4src | mask->ip4src))
787 mask->ip4src = htonl(0xffffffff);
788 if (!(entry->ip4dst | mask->ip4dst))
789 mask->ip4dst = htonl(0xffffffff);
790 if (!(entry->psrc | mask->psrc))
791 mask->psrc = htons(0xffff);
792 if (!(entry->pdst | mask->pdst))
793 mask->pdst = htons(0xffff);
794 if (!(entry->tos | mask->tos))
796 if (!(fs->vlan_tag | fs->vlan_tag_mask))
797 fs->vlan_tag_mask = 0xffff;
798 if (!(fs->data | fs->data_mask))
799 fs->data_mask = 0xffffffffffffffffULL;
802 static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev,
803 void __user *useraddr)
805 struct ethtool_rx_ntuple cmd;
806 const struct ethtool_ops *ops = dev->ethtool_ops;
807 struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL;
810 if (!(dev->features & NETIF_F_NTUPLE))
813 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
816 rx_ntuple_fix_masks(&cmd.fs);
819 * Cache filter in dev struct for GET operation only if
820 * the underlying driver doesn't have its own GET operation, and
821 * only if the filter was added successfully. First make sure we
822 * can allocate the filter, then continue if successful.
824 if (!ops->get_rx_ntuple) {
825 fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC);
830 ret = ops->set_rx_ntuple(dev, &cmd);
836 if (!ops->get_rx_ntuple)
837 __rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs, fsc);
842 static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr)
844 struct ethtool_gstrings gstrings;
845 const struct ethtool_ops *ops = dev->ethtool_ops;
846 struct ethtool_rx_ntuple_flow_spec_container *fsc;
849 int ret, i, num_strings = 0;
851 if (!ops->get_sset_count)
854 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
857 ret = ops->get_sset_count(dev, gstrings.string_set);
863 data = kzalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
867 if (ops->get_rx_ntuple) {
868 /* driver-specific filter grab */
869 ret = ops->get_rx_ntuple(dev, gstrings.string_set, data);
873 /* default ethtool filter grab */
876 list_for_each_entry(fsc, &dev->ethtool_ntuple_list.list, list) {
877 sprintf(p, "Filter %d:\n", i);
878 p += ETH_GSTRING_LEN;
881 switch (fsc->fs.flow_type) {
883 sprintf(p, "\tFlow Type: TCP\n");
884 p += ETH_GSTRING_LEN;
888 sprintf(p, "\tFlow Type: UDP\n");
889 p += ETH_GSTRING_LEN;
893 sprintf(p, "\tFlow Type: SCTP\n");
894 p += ETH_GSTRING_LEN;
898 sprintf(p, "\tFlow Type: AH ESP\n");
899 p += ETH_GSTRING_LEN;
903 sprintf(p, "\tFlow Type: ESP\n");
904 p += ETH_GSTRING_LEN;
908 sprintf(p, "\tFlow Type: Raw IP\n");
909 p += ETH_GSTRING_LEN;
913 sprintf(p, "\tFlow Type: IPv4\n");
914 p += ETH_GSTRING_LEN;
918 sprintf(p, "\tFlow Type: Unknown\n");
919 p += ETH_GSTRING_LEN;
924 /* now the rest of the filters */
925 switch (fsc->fs.flow_type) {
929 sprintf(p, "\tSrc IP addr: 0x%x\n",
930 fsc->fs.h_u.tcp_ip4_spec.ip4src);
931 p += ETH_GSTRING_LEN;
933 sprintf(p, "\tSrc IP mask: 0x%x\n",
934 fsc->fs.m_u.tcp_ip4_spec.ip4src);
935 p += ETH_GSTRING_LEN;
937 sprintf(p, "\tDest IP addr: 0x%x\n",
938 fsc->fs.h_u.tcp_ip4_spec.ip4dst);
939 p += ETH_GSTRING_LEN;
941 sprintf(p, "\tDest IP mask: 0x%x\n",
942 fsc->fs.m_u.tcp_ip4_spec.ip4dst);
943 p += ETH_GSTRING_LEN;
945 sprintf(p, "\tSrc Port: %d, mask: 0x%x\n",
946 fsc->fs.h_u.tcp_ip4_spec.psrc,
947 fsc->fs.m_u.tcp_ip4_spec.psrc);
948 p += ETH_GSTRING_LEN;
950 sprintf(p, "\tDest Port: %d, mask: 0x%x\n",
951 fsc->fs.h_u.tcp_ip4_spec.pdst,
952 fsc->fs.m_u.tcp_ip4_spec.pdst);
953 p += ETH_GSTRING_LEN;
955 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
956 fsc->fs.h_u.tcp_ip4_spec.tos,
957 fsc->fs.m_u.tcp_ip4_spec.tos);
958 p += ETH_GSTRING_LEN;
963 sprintf(p, "\tSrc IP addr: 0x%x\n",
964 fsc->fs.h_u.ah_ip4_spec.ip4src);
965 p += ETH_GSTRING_LEN;
967 sprintf(p, "\tSrc IP mask: 0x%x\n",
968 fsc->fs.m_u.ah_ip4_spec.ip4src);
969 p += ETH_GSTRING_LEN;
971 sprintf(p, "\tDest IP addr: 0x%x\n",
972 fsc->fs.h_u.ah_ip4_spec.ip4dst);
973 p += ETH_GSTRING_LEN;
975 sprintf(p, "\tDest IP mask: 0x%x\n",
976 fsc->fs.m_u.ah_ip4_spec.ip4dst);
977 p += ETH_GSTRING_LEN;
979 sprintf(p, "\tSPI: %d, mask: 0x%x\n",
980 fsc->fs.h_u.ah_ip4_spec.spi,
981 fsc->fs.m_u.ah_ip4_spec.spi);
982 p += ETH_GSTRING_LEN;
984 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
985 fsc->fs.h_u.ah_ip4_spec.tos,
986 fsc->fs.m_u.ah_ip4_spec.tos);
987 p += ETH_GSTRING_LEN;
991 sprintf(p, "\tSrc IP addr: 0x%x\n",
992 fsc->fs.h_u.usr_ip4_spec.ip4src);
993 p += ETH_GSTRING_LEN;
995 sprintf(p, "\tSrc IP mask: 0x%x\n",
996 fsc->fs.m_u.usr_ip4_spec.ip4src);
997 p += ETH_GSTRING_LEN;
999 sprintf(p, "\tDest IP addr: 0x%x\n",
1000 fsc->fs.h_u.usr_ip4_spec.ip4dst);
1001 p += ETH_GSTRING_LEN;
1003 sprintf(p, "\tDest IP mask: 0x%x\n",
1004 fsc->fs.m_u.usr_ip4_spec.ip4dst);
1005 p += ETH_GSTRING_LEN;
1009 sprintf(p, "\tSrc IP addr: 0x%x\n",
1010 fsc->fs.h_u.usr_ip4_spec.ip4src);
1011 p += ETH_GSTRING_LEN;
1013 sprintf(p, "\tSrc IP mask: 0x%x\n",
1014 fsc->fs.m_u.usr_ip4_spec.ip4src);
1015 p += ETH_GSTRING_LEN;
1017 sprintf(p, "\tDest IP addr: 0x%x\n",
1018 fsc->fs.h_u.usr_ip4_spec.ip4dst);
1019 p += ETH_GSTRING_LEN;
1021 sprintf(p, "\tDest IP mask: 0x%x\n",
1022 fsc->fs.m_u.usr_ip4_spec.ip4dst);
1023 p += ETH_GSTRING_LEN;
1025 sprintf(p, "\tL4 bytes: 0x%x, mask: 0x%x\n",
1026 fsc->fs.h_u.usr_ip4_spec.l4_4_bytes,
1027 fsc->fs.m_u.usr_ip4_spec.l4_4_bytes);
1028 p += ETH_GSTRING_LEN;
1030 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
1031 fsc->fs.h_u.usr_ip4_spec.tos,
1032 fsc->fs.m_u.usr_ip4_spec.tos);
1033 p += ETH_GSTRING_LEN;
1035 sprintf(p, "\tIP Version: %d, mask: 0x%x\n",
1036 fsc->fs.h_u.usr_ip4_spec.ip_ver,
1037 fsc->fs.m_u.usr_ip4_spec.ip_ver);
1038 p += ETH_GSTRING_LEN;
1040 sprintf(p, "\tProtocol: %d, mask: 0x%x\n",
1041 fsc->fs.h_u.usr_ip4_spec.proto,
1042 fsc->fs.m_u.usr_ip4_spec.proto);
1043 p += ETH_GSTRING_LEN;
1047 sprintf(p, "\tVLAN: %d, mask: 0x%x\n",
1048 fsc->fs.vlan_tag, fsc->fs.vlan_tag_mask);
1049 p += ETH_GSTRING_LEN;
1051 sprintf(p, "\tUser-defined: 0x%Lx\n", fsc->fs.data);
1052 p += ETH_GSTRING_LEN;
1054 sprintf(p, "\tUser-defined mask: 0x%Lx\n", fsc->fs.data_mask);
1055 p += ETH_GSTRING_LEN;
1057 if (fsc->fs.action == ETHTOOL_RXNTUPLE_ACTION_DROP)
1058 sprintf(p, "\tAction: Drop\n");
1060 sprintf(p, "\tAction: Direct to queue %d\n",
1062 p += ETH_GSTRING_LEN;
1068 /* indicate to userspace how many strings we actually have */
1069 gstrings.len = num_strings;
1071 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1073 useraddr += sizeof(gstrings);
1074 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1083 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
1085 struct ethtool_regs regs;
1086 const struct ethtool_ops *ops = dev->ethtool_ops;
1090 if (!ops->get_regs || !ops->get_regs_len)
1093 if (copy_from_user(®s, useraddr, sizeof(regs)))
1096 reglen = ops->get_regs_len(dev);
1097 if (regs.len > reglen)
1100 regbuf = vzalloc(reglen);
1104 ops->get_regs(dev, ®s, regbuf);
1107 if (copy_to_user(useraddr, ®s, sizeof(regs)))
1109 useraddr += offsetof(struct ethtool_regs, data);
1110 if (copy_to_user(useraddr, regbuf, regs.len))
1119 static int ethtool_reset(struct net_device *dev, char __user *useraddr)
1121 struct ethtool_value reset;
1124 if (!dev->ethtool_ops->reset)
1127 if (copy_from_user(&reset, useraddr, sizeof(reset)))
1130 ret = dev->ethtool_ops->reset(dev, &reset.data);
1134 if (copy_to_user(useraddr, &reset, sizeof(reset)))
1139 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
1141 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
1143 if (!dev->ethtool_ops->get_wol)
1146 dev->ethtool_ops->get_wol(dev, &wol);
1148 if (copy_to_user(useraddr, &wol, sizeof(wol)))
1153 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
1155 struct ethtool_wolinfo wol;
1157 if (!dev->ethtool_ops->set_wol)
1160 if (copy_from_user(&wol, useraddr, sizeof(wol)))
1163 return dev->ethtool_ops->set_wol(dev, &wol);
1166 static int ethtool_nway_reset(struct net_device *dev)
1168 if (!dev->ethtool_ops->nway_reset)
1171 return dev->ethtool_ops->nway_reset(dev);
1174 static int ethtool_get_link(struct net_device *dev, char __user *useraddr)
1176 struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
1178 if (!dev->ethtool_ops->get_link)
1181 edata.data = netif_running(dev) && dev->ethtool_ops->get_link(dev);
1183 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1188 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
1190 struct ethtool_eeprom eeprom;
1191 const struct ethtool_ops *ops = dev->ethtool_ops;
1192 void __user *userbuf = useraddr + sizeof(eeprom);
1193 u32 bytes_remaining;
1197 if (!ops->get_eeprom || !ops->get_eeprom_len)
1200 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
1203 /* Check for wrap and zero */
1204 if (eeprom.offset + eeprom.len <= eeprom.offset)
1207 /* Check for exceeding total eeprom len */
1208 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
1211 data = kmalloc(PAGE_SIZE, GFP_USER);
1215 bytes_remaining = eeprom.len;
1216 while (bytes_remaining > 0) {
1217 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1219 ret = ops->get_eeprom(dev, &eeprom, data);
1222 if (copy_to_user(userbuf, data, eeprom.len)) {
1226 userbuf += eeprom.len;
1227 eeprom.offset += eeprom.len;
1228 bytes_remaining -= eeprom.len;
1231 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
1232 eeprom.offset -= eeprom.len;
1233 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
1240 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
1242 struct ethtool_eeprom eeprom;
1243 const struct ethtool_ops *ops = dev->ethtool_ops;
1244 void __user *userbuf = useraddr + sizeof(eeprom);
1245 u32 bytes_remaining;
1249 if (!ops->set_eeprom || !ops->get_eeprom_len)
1252 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
1255 /* Check for wrap and zero */
1256 if (eeprom.offset + eeprom.len <= eeprom.offset)
1259 /* Check for exceeding total eeprom len */
1260 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
1263 data = kmalloc(PAGE_SIZE, GFP_USER);
1267 bytes_remaining = eeprom.len;
1268 while (bytes_remaining > 0) {
1269 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1271 if (copy_from_user(data, userbuf, eeprom.len)) {
1275 ret = ops->set_eeprom(dev, &eeprom, data);
1278 userbuf += eeprom.len;
1279 eeprom.offset += eeprom.len;
1280 bytes_remaining -= eeprom.len;
1287 static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev,
1288 void __user *useraddr)
1290 struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
1292 if (!dev->ethtool_ops->get_coalesce)
1295 dev->ethtool_ops->get_coalesce(dev, &coalesce);
1297 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
1302 static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
1303 void __user *useraddr)
1305 struct ethtool_coalesce coalesce;
1307 if (!dev->ethtool_ops->set_coalesce)
1310 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
1313 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
1316 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
1318 struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM };
1320 if (!dev->ethtool_ops->get_ringparam)
1323 dev->ethtool_ops->get_ringparam(dev, &ringparam);
1325 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
1330 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
1332 struct ethtool_ringparam ringparam;
1334 if (!dev->ethtool_ops->set_ringparam)
1337 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
1340 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
1343 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
1345 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
1347 if (!dev->ethtool_ops->get_pauseparam)
1350 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
1352 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
1357 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
1359 struct ethtool_pauseparam pauseparam;
1361 if (!dev->ethtool_ops->set_pauseparam)
1364 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
1367 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
1370 static int __ethtool_set_sg(struct net_device *dev, u32 data)
1374 if (data && !(dev->features & NETIF_F_ALL_CSUM))
1377 if (!data && dev->ethtool_ops->set_tso) {
1378 err = dev->ethtool_ops->set_tso(dev, 0);
1383 if (!data && dev->ethtool_ops->set_ufo) {
1384 err = dev->ethtool_ops->set_ufo(dev, 0);
1388 return dev->ethtool_ops->set_sg(dev, data);
1391 static int __ethtool_set_tx_csum(struct net_device *dev, u32 data)
1395 if (!dev->ethtool_ops->set_tx_csum)
1398 if (!data && dev->ethtool_ops->set_sg) {
1399 err = __ethtool_set_sg(dev, 0);
1404 return dev->ethtool_ops->set_tx_csum(dev, data);
1407 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
1409 struct ethtool_value edata;
1411 if (!dev->ethtool_ops->set_rx_csum)
1414 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1417 if (!edata.data && dev->ethtool_ops->set_sg)
1418 dev->features &= ~NETIF_F_GRO;
1420 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
1423 static int __ethtool_set_tso(struct net_device *dev, u32 data)
1425 if (!dev->ethtool_ops->set_tso)
1428 if (data && !(dev->features & NETIF_F_SG))
1431 return dev->ethtool_ops->set_tso(dev, data);
1434 static int __ethtool_set_ufo(struct net_device *dev, u32 data)
1436 if (!dev->ethtool_ops->set_ufo)
1438 if (data && !(dev->features & NETIF_F_SG))
1440 if (data && !((dev->features & NETIF_F_GEN_CSUM) ||
1441 (dev->features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
1442 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)))
1444 return dev->ethtool_ops->set_ufo(dev, data);
1447 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
1449 struct ethtool_test test;
1450 const struct ethtool_ops *ops = dev->ethtool_ops;
1454 if (!ops->self_test || !ops->get_sset_count)
1457 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
1460 WARN_ON(test_len == 0);
1462 if (copy_from_user(&test, useraddr, sizeof(test)))
1465 test.len = test_len;
1466 data = kmalloc(test_len * sizeof(u64), GFP_USER);
1470 ops->self_test(dev, &test, data);
1473 if (copy_to_user(useraddr, &test, sizeof(test)))
1475 useraddr += sizeof(test);
1476 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
1485 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1487 struct ethtool_gstrings gstrings;
1491 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
1494 ret = __ethtool_get_sset_count(dev, gstrings.string_set);
1500 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
1504 __ethtool_get_strings(dev, gstrings.string_set, data);
1507 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1509 useraddr += sizeof(gstrings);
1510 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1519 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1521 struct ethtool_value id;
1523 if (!dev->ethtool_ops->phys_id)
1526 if (copy_from_user(&id, useraddr, sizeof(id)))
1529 return dev->ethtool_ops->phys_id(dev, id.data);
1532 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
1534 struct ethtool_stats stats;
1535 const struct ethtool_ops *ops = dev->ethtool_ops;
1539 if (!ops->get_ethtool_stats || !ops->get_sset_count)
1542 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
1545 WARN_ON(n_stats == 0);
1547 if (copy_from_user(&stats, useraddr, sizeof(stats)))
1550 stats.n_stats = n_stats;
1551 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
1555 ops->get_ethtool_stats(dev, &stats, data);
1558 if (copy_to_user(useraddr, &stats, sizeof(stats)))
1560 useraddr += sizeof(stats);
1561 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
1570 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
1572 struct ethtool_perm_addr epaddr;
1574 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
1577 if (epaddr.size < dev->addr_len)
1579 epaddr.size = dev->addr_len;
1581 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
1583 useraddr += sizeof(epaddr);
1584 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
1589 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
1590 u32 cmd, u32 (*actor)(struct net_device *))
1592 struct ethtool_value edata = { .cmd = cmd };
1597 edata.data = actor(dev);
1599 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1604 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
1605 void (*actor)(struct net_device *, u32))
1607 struct ethtool_value edata;
1612 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1615 actor(dev, edata.data);
1619 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
1620 int (*actor)(struct net_device *, u32))
1622 struct ethtool_value edata;
1627 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1630 return actor(dev, edata.data);
1633 static noinline_for_stack int ethtool_flash_device(struct net_device *dev,
1634 char __user *useraddr)
1636 struct ethtool_flash efl;
1638 if (copy_from_user(&efl, useraddr, sizeof(efl)))
1641 if (!dev->ethtool_ops->flash_device)
1644 return dev->ethtool_ops->flash_device(dev, &efl);
1647 /* The main entry point in this file. Called from net/core/dev.c */
1649 int dev_ethtool(struct net *net, struct ifreq *ifr)
1651 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
1652 void __user *useraddr = ifr->ifr_data;
1657 if (!dev || !netif_device_present(dev))
1660 if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
1663 if (!dev->ethtool_ops) {
1664 /* ETHTOOL_GDRVINFO does not require any driver support.
1665 * It is also unprivileged and does not change anything,
1666 * so we can take a shortcut to it. */
1667 if (ethcmd == ETHTOOL_GDRVINFO)
1668 return ethtool_get_drvinfo(dev, useraddr);
1673 /* Allow some commands to be done by anyone */
1676 case ETHTOOL_GDRVINFO:
1677 case ETHTOOL_GMSGLVL:
1678 case ETHTOOL_GCOALESCE:
1679 case ETHTOOL_GRINGPARAM:
1680 case ETHTOOL_GPAUSEPARAM:
1681 case ETHTOOL_GRXCSUM:
1682 case ETHTOOL_GTXCSUM:
1684 case ETHTOOL_GSTRINGS:
1686 case ETHTOOL_GPERMADDR:
1690 case ETHTOOL_GFLAGS:
1691 case ETHTOOL_GPFLAGS:
1693 case ETHTOOL_GRXRINGS:
1694 case ETHTOOL_GRXCLSRLCNT:
1695 case ETHTOOL_GRXCLSRULE:
1696 case ETHTOOL_GRXCLSRLALL:
1697 case ETHTOOL_GFEATURES:
1700 if (!capable(CAP_NET_ADMIN))
1704 if (dev->ethtool_ops->begin) {
1705 rc = dev->ethtool_ops->begin(dev);
1709 old_features = dev->features;
1713 rc = ethtool_get_settings(dev, useraddr);
1716 rc = ethtool_set_settings(dev, useraddr);
1718 case ETHTOOL_GDRVINFO:
1719 rc = ethtool_get_drvinfo(dev, useraddr);
1722 rc = ethtool_get_regs(dev, useraddr);
1725 rc = ethtool_get_wol(dev, useraddr);
1728 rc = ethtool_set_wol(dev, useraddr);
1730 case ETHTOOL_GMSGLVL:
1731 rc = ethtool_get_value(dev, useraddr, ethcmd,
1732 dev->ethtool_ops->get_msglevel);
1734 case ETHTOOL_SMSGLVL:
1735 rc = ethtool_set_value_void(dev, useraddr,
1736 dev->ethtool_ops->set_msglevel);
1738 case ETHTOOL_NWAY_RST:
1739 rc = ethtool_nway_reset(dev);
1742 rc = ethtool_get_link(dev, useraddr);
1744 case ETHTOOL_GEEPROM:
1745 rc = ethtool_get_eeprom(dev, useraddr);
1747 case ETHTOOL_SEEPROM:
1748 rc = ethtool_set_eeprom(dev, useraddr);
1750 case ETHTOOL_GCOALESCE:
1751 rc = ethtool_get_coalesce(dev, useraddr);
1753 case ETHTOOL_SCOALESCE:
1754 rc = ethtool_set_coalesce(dev, useraddr);
1756 case ETHTOOL_GRINGPARAM:
1757 rc = ethtool_get_ringparam(dev, useraddr);
1759 case ETHTOOL_SRINGPARAM:
1760 rc = ethtool_set_ringparam(dev, useraddr);
1762 case ETHTOOL_GPAUSEPARAM:
1763 rc = ethtool_get_pauseparam(dev, useraddr);
1765 case ETHTOOL_SPAUSEPARAM:
1766 rc = ethtool_set_pauseparam(dev, useraddr);
1768 case ETHTOOL_GRXCSUM:
1769 rc = ethtool_get_value(dev, useraddr, ethcmd,
1770 (dev->ethtool_ops->get_rx_csum ?
1771 dev->ethtool_ops->get_rx_csum :
1772 ethtool_op_get_rx_csum));
1774 case ETHTOOL_SRXCSUM:
1775 rc = ethtool_set_rx_csum(dev, useraddr);
1778 rc = ethtool_self_test(dev, useraddr);
1780 case ETHTOOL_GSTRINGS:
1781 rc = ethtool_get_strings(dev, useraddr);
1783 case ETHTOOL_PHYS_ID:
1784 rc = ethtool_phys_id(dev, useraddr);
1786 case ETHTOOL_GSTATS:
1787 rc = ethtool_get_stats(dev, useraddr);
1789 case ETHTOOL_GPERMADDR:
1790 rc = ethtool_get_perm_addr(dev, useraddr);
1792 case ETHTOOL_GFLAGS:
1793 rc = ethtool_get_value(dev, useraddr, ethcmd,
1794 (dev->ethtool_ops->get_flags ?
1795 dev->ethtool_ops->get_flags :
1796 ethtool_op_get_flags));
1798 case ETHTOOL_SFLAGS:
1799 rc = ethtool_set_value(dev, useraddr, __ethtool_set_flags);
1801 case ETHTOOL_GPFLAGS:
1802 rc = ethtool_get_value(dev, useraddr, ethcmd,
1803 dev->ethtool_ops->get_priv_flags);
1805 case ETHTOOL_SPFLAGS:
1806 rc = ethtool_set_value(dev, useraddr,
1807 dev->ethtool_ops->set_priv_flags);
1810 case ETHTOOL_GRXRINGS:
1811 case ETHTOOL_GRXCLSRLCNT:
1812 case ETHTOOL_GRXCLSRULE:
1813 case ETHTOOL_GRXCLSRLALL:
1814 rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
1817 case ETHTOOL_SRXCLSRLDEL:
1818 case ETHTOOL_SRXCLSRLINS:
1819 rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
1821 case ETHTOOL_FLASHDEV:
1822 rc = ethtool_flash_device(dev, useraddr);
1825 rc = ethtool_reset(dev, useraddr);
1827 case ETHTOOL_SRXNTUPLE:
1828 rc = ethtool_set_rx_ntuple(dev, useraddr);
1830 case ETHTOOL_GRXNTUPLE:
1831 rc = ethtool_get_rx_ntuple(dev, useraddr);
1833 case ETHTOOL_GSSET_INFO:
1834 rc = ethtool_get_sset_info(dev, useraddr);
1836 case ETHTOOL_GRXFHINDIR:
1837 rc = ethtool_get_rxfh_indir(dev, useraddr);
1839 case ETHTOOL_SRXFHINDIR:
1840 rc = ethtool_set_rxfh_indir(dev, useraddr);
1842 case ETHTOOL_GFEATURES:
1843 rc = ethtool_get_features(dev, useraddr);
1845 case ETHTOOL_SFEATURES:
1846 rc = ethtool_set_features(dev, useraddr);
1848 case ETHTOOL_GTXCSUM:
1854 rc = ethtool_get_one_feature(dev, useraddr, ethcmd);
1856 case ETHTOOL_STXCSUM:
1862 rc = ethtool_set_one_feature(dev, useraddr, ethcmd);
1868 if (dev->ethtool_ops->complete)
1869 dev->ethtool_ops->complete(dev);
1871 if (old_features != dev->features)
1872 netdev_features_change(dev);