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 struct ethtool_value edata = {
362 .data = !!(dev->features & ethtool_get_feature_mask(ethcmd)),
364 u32 (*actor)(struct net_device *);
366 actor = __ethtool_get_one_feature_actor(dev, ethcmd);
368 edata.data = actor(dev);
370 if (copy_to_user(useraddr, &edata, sizeof(edata)))
375 static int __ethtool_set_tx_csum(struct net_device *dev, u32 data);
376 static int __ethtool_set_sg(struct net_device *dev, u32 data);
377 static int __ethtool_set_tso(struct net_device *dev, u32 data);
378 static int __ethtool_set_ufo(struct net_device *dev, u32 data);
380 static int ethtool_set_one_feature(struct net_device *dev,
381 void __user *useraddr, u32 ethcmd)
383 struct ethtool_value edata;
386 if (copy_from_user(&edata, useraddr, sizeof(edata)))
390 case ETHTOOL_STXCSUM:
391 return __ethtool_set_tx_csum(dev, edata.data);
393 return __ethtool_set_sg(dev, edata.data);
395 return __ethtool_set_tso(dev, edata.data);
397 return __ethtool_set_ufo(dev, edata.data);
400 mask = ethtool_get_feature_mask(ethcmd);
402 dev->features |= mask;
404 dev->features &= ~mask;
411 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
413 struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
416 if (!dev->ethtool_ops->get_settings)
419 err = dev->ethtool_ops->get_settings(dev, &cmd);
423 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
428 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
430 struct ethtool_cmd cmd;
432 if (!dev->ethtool_ops->set_settings)
435 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
438 return dev->ethtool_ops->set_settings(dev, &cmd);
441 static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
442 void __user *useraddr)
444 struct ethtool_drvinfo info;
445 const struct ethtool_ops *ops = dev->ethtool_ops;
447 memset(&info, 0, sizeof(info));
448 info.cmd = ETHTOOL_GDRVINFO;
449 if (ops && ops->get_drvinfo) {
450 ops->get_drvinfo(dev, &info);
451 } else if (dev->dev.parent && dev->dev.parent->driver) {
452 strlcpy(info.bus_info, dev_name(dev->dev.parent),
453 sizeof(info.bus_info));
454 strlcpy(info.driver, dev->dev.parent->driver->name,
455 sizeof(info.driver));
461 * this method of obtaining string set info is deprecated;
462 * Use ETHTOOL_GSSET_INFO instead.
464 if (ops && ops->get_sset_count) {
467 rc = ops->get_sset_count(dev, ETH_SS_TEST);
469 info.testinfo_len = rc;
470 rc = ops->get_sset_count(dev, ETH_SS_STATS);
473 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
475 info.n_priv_flags = rc;
477 if (ops && ops->get_regs_len)
478 info.regdump_len = ops->get_regs_len(dev);
479 if (ops && ops->get_eeprom_len)
480 info.eedump_len = ops->get_eeprom_len(dev);
482 if (copy_to_user(useraddr, &info, sizeof(info)))
487 static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
488 void __user *useraddr)
490 struct ethtool_sset_info info;
492 int i, idx = 0, n_bits = 0, ret, rc;
493 u32 *info_buf = NULL;
495 if (copy_from_user(&info, useraddr, sizeof(info)))
498 /* store copy of mask, because we zero struct later on */
499 sset_mask = info.sset_mask;
503 /* calculate size of return buffer */
504 n_bits = hweight64(sset_mask);
506 memset(&info, 0, sizeof(info));
507 info.cmd = ETHTOOL_GSSET_INFO;
509 info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER);
514 * fill return buffer based on input bitmask and successful
515 * get_sset_count return
517 for (i = 0; i < 64; i++) {
518 if (!(sset_mask & (1ULL << i)))
521 rc = __ethtool_get_sset_count(dev, i);
523 info.sset_mask |= (1ULL << i);
524 info_buf[idx++] = rc;
529 if (copy_to_user(useraddr, &info, sizeof(info)))
532 useraddr += offsetof(struct ethtool_sset_info, data);
533 if (copy_to_user(useraddr, info_buf, idx * sizeof(u32)))
543 static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
544 u32 cmd, void __user *useraddr)
546 struct ethtool_rxnfc info;
547 size_t info_size = sizeof(info);
549 if (!dev->ethtool_ops->set_rxnfc)
552 /* struct ethtool_rxnfc was originally defined for
553 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
554 * members. User-space might still be using that
556 if (cmd == ETHTOOL_SRXFH)
557 info_size = (offsetof(struct ethtool_rxnfc, data) +
560 if (copy_from_user(&info, useraddr, info_size))
563 return dev->ethtool_ops->set_rxnfc(dev, &info);
566 static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
567 u32 cmd, void __user *useraddr)
569 struct ethtool_rxnfc info;
570 size_t info_size = sizeof(info);
571 const struct ethtool_ops *ops = dev->ethtool_ops;
573 void *rule_buf = NULL;
578 /* struct ethtool_rxnfc was originally defined for
579 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
580 * members. User-space might still be using that
582 if (cmd == ETHTOOL_GRXFH)
583 info_size = (offsetof(struct ethtool_rxnfc, data) +
586 if (copy_from_user(&info, useraddr, info_size))
589 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
590 if (info.rule_cnt > 0) {
591 if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
592 rule_buf = kzalloc(info.rule_cnt * sizeof(u32),
599 ret = ops->get_rxnfc(dev, &info, rule_buf);
604 if (copy_to_user(useraddr, &info, info_size))
608 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
609 if (copy_to_user(useraddr, rule_buf,
610 info.rule_cnt * sizeof(u32)))
621 static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
622 void __user *useraddr)
624 struct ethtool_rxfh_indir *indir;
629 if (!dev->ethtool_ops->get_rxfh_indir)
632 if (copy_from_user(&table_size,
633 useraddr + offsetof(struct ethtool_rxfh_indir, size),
638 (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index))
640 full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size;
641 indir = kzalloc(full_size, GFP_USER);
645 indir->cmd = ETHTOOL_GRXFHINDIR;
646 indir->size = table_size;
647 ret = dev->ethtool_ops->get_rxfh_indir(dev, indir);
651 if (copy_to_user(useraddr, indir, full_size))
659 static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
660 void __user *useraddr)
662 struct ethtool_rxfh_indir *indir;
667 if (!dev->ethtool_ops->set_rxfh_indir)
670 if (copy_from_user(&table_size,
671 useraddr + offsetof(struct ethtool_rxfh_indir, size),
676 (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index))
678 full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size;
679 indir = kmalloc(full_size, GFP_USER);
683 if (copy_from_user(indir, useraddr, full_size)) {
688 ret = dev->ethtool_ops->set_rxfh_indir(dev, indir);
695 static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
696 struct ethtool_rx_ntuple_flow_spec *spec,
697 struct ethtool_rx_ntuple_flow_spec_container *fsc)
700 /* don't add filters forever */
701 if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY) {
702 /* free the container */
707 /* Copy the whole filter over */
708 fsc->fs.flow_type = spec->flow_type;
709 memcpy(&fsc->fs.h_u, &spec->h_u, sizeof(spec->h_u));
710 memcpy(&fsc->fs.m_u, &spec->m_u, sizeof(spec->m_u));
712 fsc->fs.vlan_tag = spec->vlan_tag;
713 fsc->fs.vlan_tag_mask = spec->vlan_tag_mask;
714 fsc->fs.data = spec->data;
715 fsc->fs.data_mask = spec->data_mask;
716 fsc->fs.action = spec->action;
718 /* add to the list */
719 list_add_tail_rcu(&fsc->list, &list->list);
724 * ethtool does not (or did not) set masks for flow parameters that are
725 * not specified, so if both value and mask are 0 then this must be
726 * treated as equivalent to a mask with all bits set. Implement that
727 * here rather than in drivers.
729 static void rx_ntuple_fix_masks(struct ethtool_rx_ntuple_flow_spec *fs)
731 struct ethtool_tcpip4_spec *entry = &fs->h_u.tcp_ip4_spec;
732 struct ethtool_tcpip4_spec *mask = &fs->m_u.tcp_ip4_spec;
734 if (fs->flow_type != TCP_V4_FLOW &&
735 fs->flow_type != UDP_V4_FLOW &&
736 fs->flow_type != SCTP_V4_FLOW)
739 if (!(entry->ip4src | mask->ip4src))
740 mask->ip4src = htonl(0xffffffff);
741 if (!(entry->ip4dst | mask->ip4dst))
742 mask->ip4dst = htonl(0xffffffff);
743 if (!(entry->psrc | mask->psrc))
744 mask->psrc = htons(0xffff);
745 if (!(entry->pdst | mask->pdst))
746 mask->pdst = htons(0xffff);
747 if (!(entry->tos | mask->tos))
749 if (!(fs->vlan_tag | fs->vlan_tag_mask))
750 fs->vlan_tag_mask = 0xffff;
751 if (!(fs->data | fs->data_mask))
752 fs->data_mask = 0xffffffffffffffffULL;
755 static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev,
756 void __user *useraddr)
758 struct ethtool_rx_ntuple cmd;
759 const struct ethtool_ops *ops = dev->ethtool_ops;
760 struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL;
763 if (!(dev->features & NETIF_F_NTUPLE))
766 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
769 rx_ntuple_fix_masks(&cmd.fs);
772 * Cache filter in dev struct for GET operation only if
773 * the underlying driver doesn't have its own GET operation, and
774 * only if the filter was added successfully. First make sure we
775 * can allocate the filter, then continue if successful.
777 if (!ops->get_rx_ntuple) {
778 fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC);
783 ret = ops->set_rx_ntuple(dev, &cmd);
789 if (!ops->get_rx_ntuple)
790 __rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs, fsc);
795 static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr)
797 struct ethtool_gstrings gstrings;
798 const struct ethtool_ops *ops = dev->ethtool_ops;
799 struct ethtool_rx_ntuple_flow_spec_container *fsc;
802 int ret, i, num_strings = 0;
804 if (!ops->get_sset_count)
807 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
810 ret = ops->get_sset_count(dev, gstrings.string_set);
816 data = kzalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
820 if (ops->get_rx_ntuple) {
821 /* driver-specific filter grab */
822 ret = ops->get_rx_ntuple(dev, gstrings.string_set, data);
826 /* default ethtool filter grab */
829 list_for_each_entry(fsc, &dev->ethtool_ntuple_list.list, list) {
830 sprintf(p, "Filter %d:\n", i);
831 p += ETH_GSTRING_LEN;
834 switch (fsc->fs.flow_type) {
836 sprintf(p, "\tFlow Type: TCP\n");
837 p += ETH_GSTRING_LEN;
841 sprintf(p, "\tFlow Type: UDP\n");
842 p += ETH_GSTRING_LEN;
846 sprintf(p, "\tFlow Type: SCTP\n");
847 p += ETH_GSTRING_LEN;
851 sprintf(p, "\tFlow Type: AH ESP\n");
852 p += ETH_GSTRING_LEN;
856 sprintf(p, "\tFlow Type: ESP\n");
857 p += ETH_GSTRING_LEN;
861 sprintf(p, "\tFlow Type: Raw IP\n");
862 p += ETH_GSTRING_LEN;
866 sprintf(p, "\tFlow Type: IPv4\n");
867 p += ETH_GSTRING_LEN;
871 sprintf(p, "\tFlow Type: Unknown\n");
872 p += ETH_GSTRING_LEN;
877 /* now the rest of the filters */
878 switch (fsc->fs.flow_type) {
882 sprintf(p, "\tSrc IP addr: 0x%x\n",
883 fsc->fs.h_u.tcp_ip4_spec.ip4src);
884 p += ETH_GSTRING_LEN;
886 sprintf(p, "\tSrc IP mask: 0x%x\n",
887 fsc->fs.m_u.tcp_ip4_spec.ip4src);
888 p += ETH_GSTRING_LEN;
890 sprintf(p, "\tDest IP addr: 0x%x\n",
891 fsc->fs.h_u.tcp_ip4_spec.ip4dst);
892 p += ETH_GSTRING_LEN;
894 sprintf(p, "\tDest IP mask: 0x%x\n",
895 fsc->fs.m_u.tcp_ip4_spec.ip4dst);
896 p += ETH_GSTRING_LEN;
898 sprintf(p, "\tSrc Port: %d, mask: 0x%x\n",
899 fsc->fs.h_u.tcp_ip4_spec.psrc,
900 fsc->fs.m_u.tcp_ip4_spec.psrc);
901 p += ETH_GSTRING_LEN;
903 sprintf(p, "\tDest Port: %d, mask: 0x%x\n",
904 fsc->fs.h_u.tcp_ip4_spec.pdst,
905 fsc->fs.m_u.tcp_ip4_spec.pdst);
906 p += ETH_GSTRING_LEN;
908 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
909 fsc->fs.h_u.tcp_ip4_spec.tos,
910 fsc->fs.m_u.tcp_ip4_spec.tos);
911 p += ETH_GSTRING_LEN;
916 sprintf(p, "\tSrc IP addr: 0x%x\n",
917 fsc->fs.h_u.ah_ip4_spec.ip4src);
918 p += ETH_GSTRING_LEN;
920 sprintf(p, "\tSrc IP mask: 0x%x\n",
921 fsc->fs.m_u.ah_ip4_spec.ip4src);
922 p += ETH_GSTRING_LEN;
924 sprintf(p, "\tDest IP addr: 0x%x\n",
925 fsc->fs.h_u.ah_ip4_spec.ip4dst);
926 p += ETH_GSTRING_LEN;
928 sprintf(p, "\tDest IP mask: 0x%x\n",
929 fsc->fs.m_u.ah_ip4_spec.ip4dst);
930 p += ETH_GSTRING_LEN;
932 sprintf(p, "\tSPI: %d, mask: 0x%x\n",
933 fsc->fs.h_u.ah_ip4_spec.spi,
934 fsc->fs.m_u.ah_ip4_spec.spi);
935 p += ETH_GSTRING_LEN;
937 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
938 fsc->fs.h_u.ah_ip4_spec.tos,
939 fsc->fs.m_u.ah_ip4_spec.tos);
940 p += ETH_GSTRING_LEN;
944 sprintf(p, "\tSrc IP addr: 0x%x\n",
945 fsc->fs.h_u.usr_ip4_spec.ip4src);
946 p += ETH_GSTRING_LEN;
948 sprintf(p, "\tSrc IP mask: 0x%x\n",
949 fsc->fs.m_u.usr_ip4_spec.ip4src);
950 p += ETH_GSTRING_LEN;
952 sprintf(p, "\tDest IP addr: 0x%x\n",
953 fsc->fs.h_u.usr_ip4_spec.ip4dst);
954 p += ETH_GSTRING_LEN;
956 sprintf(p, "\tDest IP mask: 0x%x\n",
957 fsc->fs.m_u.usr_ip4_spec.ip4dst);
958 p += ETH_GSTRING_LEN;
962 sprintf(p, "\tSrc IP addr: 0x%x\n",
963 fsc->fs.h_u.usr_ip4_spec.ip4src);
964 p += ETH_GSTRING_LEN;
966 sprintf(p, "\tSrc IP mask: 0x%x\n",
967 fsc->fs.m_u.usr_ip4_spec.ip4src);
968 p += ETH_GSTRING_LEN;
970 sprintf(p, "\tDest IP addr: 0x%x\n",
971 fsc->fs.h_u.usr_ip4_spec.ip4dst);
972 p += ETH_GSTRING_LEN;
974 sprintf(p, "\tDest IP mask: 0x%x\n",
975 fsc->fs.m_u.usr_ip4_spec.ip4dst);
976 p += ETH_GSTRING_LEN;
978 sprintf(p, "\tL4 bytes: 0x%x, mask: 0x%x\n",
979 fsc->fs.h_u.usr_ip4_spec.l4_4_bytes,
980 fsc->fs.m_u.usr_ip4_spec.l4_4_bytes);
981 p += ETH_GSTRING_LEN;
983 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
984 fsc->fs.h_u.usr_ip4_spec.tos,
985 fsc->fs.m_u.usr_ip4_spec.tos);
986 p += ETH_GSTRING_LEN;
988 sprintf(p, "\tIP Version: %d, mask: 0x%x\n",
989 fsc->fs.h_u.usr_ip4_spec.ip_ver,
990 fsc->fs.m_u.usr_ip4_spec.ip_ver);
991 p += ETH_GSTRING_LEN;
993 sprintf(p, "\tProtocol: %d, mask: 0x%x\n",
994 fsc->fs.h_u.usr_ip4_spec.proto,
995 fsc->fs.m_u.usr_ip4_spec.proto);
996 p += ETH_GSTRING_LEN;
1000 sprintf(p, "\tVLAN: %d, mask: 0x%x\n",
1001 fsc->fs.vlan_tag, fsc->fs.vlan_tag_mask);
1002 p += ETH_GSTRING_LEN;
1004 sprintf(p, "\tUser-defined: 0x%Lx\n", fsc->fs.data);
1005 p += ETH_GSTRING_LEN;
1007 sprintf(p, "\tUser-defined mask: 0x%Lx\n", fsc->fs.data_mask);
1008 p += ETH_GSTRING_LEN;
1010 if (fsc->fs.action == ETHTOOL_RXNTUPLE_ACTION_DROP)
1011 sprintf(p, "\tAction: Drop\n");
1013 sprintf(p, "\tAction: Direct to queue %d\n",
1015 p += ETH_GSTRING_LEN;
1021 /* indicate to userspace how many strings we actually have */
1022 gstrings.len = num_strings;
1024 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1026 useraddr += sizeof(gstrings);
1027 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1036 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
1038 struct ethtool_regs regs;
1039 const struct ethtool_ops *ops = dev->ethtool_ops;
1043 if (!ops->get_regs || !ops->get_regs_len)
1046 if (copy_from_user(®s, useraddr, sizeof(regs)))
1049 reglen = ops->get_regs_len(dev);
1050 if (regs.len > reglen)
1053 regbuf = vzalloc(reglen);
1057 ops->get_regs(dev, ®s, regbuf);
1060 if (copy_to_user(useraddr, ®s, sizeof(regs)))
1062 useraddr += offsetof(struct ethtool_regs, data);
1063 if (copy_to_user(useraddr, regbuf, regs.len))
1072 static int ethtool_reset(struct net_device *dev, char __user *useraddr)
1074 struct ethtool_value reset;
1077 if (!dev->ethtool_ops->reset)
1080 if (copy_from_user(&reset, useraddr, sizeof(reset)))
1083 ret = dev->ethtool_ops->reset(dev, &reset.data);
1087 if (copy_to_user(useraddr, &reset, sizeof(reset)))
1092 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
1094 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
1096 if (!dev->ethtool_ops->get_wol)
1099 dev->ethtool_ops->get_wol(dev, &wol);
1101 if (copy_to_user(useraddr, &wol, sizeof(wol)))
1106 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
1108 struct ethtool_wolinfo wol;
1110 if (!dev->ethtool_ops->set_wol)
1113 if (copy_from_user(&wol, useraddr, sizeof(wol)))
1116 return dev->ethtool_ops->set_wol(dev, &wol);
1119 static int ethtool_nway_reset(struct net_device *dev)
1121 if (!dev->ethtool_ops->nway_reset)
1124 return dev->ethtool_ops->nway_reset(dev);
1127 static int ethtool_get_link(struct net_device *dev, char __user *useraddr)
1129 struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
1131 if (!dev->ethtool_ops->get_link)
1134 edata.data = netif_running(dev) && dev->ethtool_ops->get_link(dev);
1136 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1141 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
1143 struct ethtool_eeprom eeprom;
1144 const struct ethtool_ops *ops = dev->ethtool_ops;
1145 void __user *userbuf = useraddr + sizeof(eeprom);
1146 u32 bytes_remaining;
1150 if (!ops->get_eeprom || !ops->get_eeprom_len)
1153 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
1156 /* Check for wrap and zero */
1157 if (eeprom.offset + eeprom.len <= eeprom.offset)
1160 /* Check for exceeding total eeprom len */
1161 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
1164 data = kmalloc(PAGE_SIZE, GFP_USER);
1168 bytes_remaining = eeprom.len;
1169 while (bytes_remaining > 0) {
1170 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1172 ret = ops->get_eeprom(dev, &eeprom, data);
1175 if (copy_to_user(userbuf, data, eeprom.len)) {
1179 userbuf += eeprom.len;
1180 eeprom.offset += eeprom.len;
1181 bytes_remaining -= eeprom.len;
1184 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
1185 eeprom.offset -= eeprom.len;
1186 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
1193 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
1195 struct ethtool_eeprom eeprom;
1196 const struct ethtool_ops *ops = dev->ethtool_ops;
1197 void __user *userbuf = useraddr + sizeof(eeprom);
1198 u32 bytes_remaining;
1202 if (!ops->set_eeprom || !ops->get_eeprom_len)
1205 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
1208 /* Check for wrap and zero */
1209 if (eeprom.offset + eeprom.len <= eeprom.offset)
1212 /* Check for exceeding total eeprom len */
1213 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
1216 data = kmalloc(PAGE_SIZE, GFP_USER);
1220 bytes_remaining = eeprom.len;
1221 while (bytes_remaining > 0) {
1222 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
1224 if (copy_from_user(data, userbuf, eeprom.len)) {
1228 ret = ops->set_eeprom(dev, &eeprom, data);
1231 userbuf += eeprom.len;
1232 eeprom.offset += eeprom.len;
1233 bytes_remaining -= eeprom.len;
1240 static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev,
1241 void __user *useraddr)
1243 struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
1245 if (!dev->ethtool_ops->get_coalesce)
1248 dev->ethtool_ops->get_coalesce(dev, &coalesce);
1250 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
1255 static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
1256 void __user *useraddr)
1258 struct ethtool_coalesce coalesce;
1260 if (!dev->ethtool_ops->set_coalesce)
1263 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
1266 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
1269 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
1271 struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM };
1273 if (!dev->ethtool_ops->get_ringparam)
1276 dev->ethtool_ops->get_ringparam(dev, &ringparam);
1278 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
1283 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
1285 struct ethtool_ringparam ringparam;
1287 if (!dev->ethtool_ops->set_ringparam)
1290 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
1293 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
1296 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
1298 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
1300 if (!dev->ethtool_ops->get_pauseparam)
1303 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
1305 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
1310 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
1312 struct ethtool_pauseparam pauseparam;
1314 if (!dev->ethtool_ops->set_pauseparam)
1317 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
1320 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
1323 static int __ethtool_set_sg(struct net_device *dev, u32 data)
1327 if (data && !(dev->features & NETIF_F_ALL_CSUM))
1330 if (!data && dev->ethtool_ops->set_tso) {
1331 err = dev->ethtool_ops->set_tso(dev, 0);
1336 if (!data && dev->ethtool_ops->set_ufo) {
1337 err = dev->ethtool_ops->set_ufo(dev, 0);
1341 return dev->ethtool_ops->set_sg(dev, data);
1344 static int __ethtool_set_tx_csum(struct net_device *dev, u32 data)
1348 if (!dev->ethtool_ops->set_tx_csum)
1351 if (!data && dev->ethtool_ops->set_sg) {
1352 err = __ethtool_set_sg(dev, 0);
1357 return dev->ethtool_ops->set_tx_csum(dev, data);
1360 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
1362 struct ethtool_value edata;
1364 if (!dev->ethtool_ops->set_rx_csum)
1367 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1370 if (!edata.data && dev->ethtool_ops->set_sg)
1371 dev->features &= ~NETIF_F_GRO;
1373 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
1376 static int __ethtool_set_tso(struct net_device *dev, u32 data)
1378 if (!dev->ethtool_ops->set_tso)
1381 if (data && !(dev->features & NETIF_F_SG))
1384 return dev->ethtool_ops->set_tso(dev, data);
1387 static int __ethtool_set_ufo(struct net_device *dev, u32 data)
1389 if (!dev->ethtool_ops->set_ufo)
1391 if (data && !(dev->features & NETIF_F_SG))
1393 if (data && !((dev->features & NETIF_F_GEN_CSUM) ||
1394 (dev->features & (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM))
1395 == (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM)))
1397 return dev->ethtool_ops->set_ufo(dev, data);
1400 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
1402 struct ethtool_test test;
1403 const struct ethtool_ops *ops = dev->ethtool_ops;
1407 if (!ops->self_test || !ops->get_sset_count)
1410 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
1413 WARN_ON(test_len == 0);
1415 if (copy_from_user(&test, useraddr, sizeof(test)))
1418 test.len = test_len;
1419 data = kmalloc(test_len * sizeof(u64), GFP_USER);
1423 ops->self_test(dev, &test, data);
1426 if (copy_to_user(useraddr, &test, sizeof(test)))
1428 useraddr += sizeof(test);
1429 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
1438 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1440 struct ethtool_gstrings gstrings;
1444 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
1447 ret = __ethtool_get_sset_count(dev, gstrings.string_set);
1453 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
1457 __ethtool_get_strings(dev, gstrings.string_set, data);
1460 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1462 useraddr += sizeof(gstrings);
1463 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1472 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1474 struct ethtool_value id;
1476 if (!dev->ethtool_ops->phys_id)
1479 if (copy_from_user(&id, useraddr, sizeof(id)))
1482 return dev->ethtool_ops->phys_id(dev, id.data);
1485 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
1487 struct ethtool_stats stats;
1488 const struct ethtool_ops *ops = dev->ethtool_ops;
1492 if (!ops->get_ethtool_stats || !ops->get_sset_count)
1495 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
1498 WARN_ON(n_stats == 0);
1500 if (copy_from_user(&stats, useraddr, sizeof(stats)))
1503 stats.n_stats = n_stats;
1504 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
1508 ops->get_ethtool_stats(dev, &stats, data);
1511 if (copy_to_user(useraddr, &stats, sizeof(stats)))
1513 useraddr += sizeof(stats);
1514 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
1523 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
1525 struct ethtool_perm_addr epaddr;
1527 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
1530 if (epaddr.size < dev->addr_len)
1532 epaddr.size = dev->addr_len;
1534 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
1536 useraddr += sizeof(epaddr);
1537 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
1542 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
1543 u32 cmd, u32 (*actor)(struct net_device *))
1545 struct ethtool_value edata = { .cmd = cmd };
1550 edata.data = actor(dev);
1552 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1557 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
1558 void (*actor)(struct net_device *, u32))
1560 struct ethtool_value edata;
1565 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1568 actor(dev, edata.data);
1572 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
1573 int (*actor)(struct net_device *, u32))
1575 struct ethtool_value edata;
1580 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1583 return actor(dev, edata.data);
1586 static noinline_for_stack int ethtool_flash_device(struct net_device *dev,
1587 char __user *useraddr)
1589 struct ethtool_flash efl;
1591 if (copy_from_user(&efl, useraddr, sizeof(efl)))
1594 if (!dev->ethtool_ops->flash_device)
1597 return dev->ethtool_ops->flash_device(dev, &efl);
1600 /* The main entry point in this file. Called from net/core/dev.c */
1602 int dev_ethtool(struct net *net, struct ifreq *ifr)
1604 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
1605 void __user *useraddr = ifr->ifr_data;
1610 if (!dev || !netif_device_present(dev))
1613 if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
1616 if (!dev->ethtool_ops) {
1617 /* ETHTOOL_GDRVINFO does not require any driver support.
1618 * It is also unprivileged and does not change anything,
1619 * so we can take a shortcut to it. */
1620 if (ethcmd == ETHTOOL_GDRVINFO)
1621 return ethtool_get_drvinfo(dev, useraddr);
1626 /* Allow some commands to be done by anyone */
1629 case ETHTOOL_GDRVINFO:
1630 case ETHTOOL_GMSGLVL:
1631 case ETHTOOL_GCOALESCE:
1632 case ETHTOOL_GRINGPARAM:
1633 case ETHTOOL_GPAUSEPARAM:
1634 case ETHTOOL_GRXCSUM:
1635 case ETHTOOL_GTXCSUM:
1637 case ETHTOOL_GSTRINGS:
1639 case ETHTOOL_GPERMADDR:
1643 case ETHTOOL_GFLAGS:
1644 case ETHTOOL_GPFLAGS:
1646 case ETHTOOL_GRXRINGS:
1647 case ETHTOOL_GRXCLSRLCNT:
1648 case ETHTOOL_GRXCLSRULE:
1649 case ETHTOOL_GRXCLSRLALL:
1650 case ETHTOOL_GFEATURES:
1653 if (!capable(CAP_NET_ADMIN))
1657 if (dev->ethtool_ops->begin) {
1658 rc = dev->ethtool_ops->begin(dev);
1662 old_features = dev->features;
1666 rc = ethtool_get_settings(dev, useraddr);
1669 rc = ethtool_set_settings(dev, useraddr);
1671 case ETHTOOL_GDRVINFO:
1672 rc = ethtool_get_drvinfo(dev, useraddr);
1675 rc = ethtool_get_regs(dev, useraddr);
1678 rc = ethtool_get_wol(dev, useraddr);
1681 rc = ethtool_set_wol(dev, useraddr);
1683 case ETHTOOL_GMSGLVL:
1684 rc = ethtool_get_value(dev, useraddr, ethcmd,
1685 dev->ethtool_ops->get_msglevel);
1687 case ETHTOOL_SMSGLVL:
1688 rc = ethtool_set_value_void(dev, useraddr,
1689 dev->ethtool_ops->set_msglevel);
1691 case ETHTOOL_NWAY_RST:
1692 rc = ethtool_nway_reset(dev);
1695 rc = ethtool_get_link(dev, useraddr);
1697 case ETHTOOL_GEEPROM:
1698 rc = ethtool_get_eeprom(dev, useraddr);
1700 case ETHTOOL_SEEPROM:
1701 rc = ethtool_set_eeprom(dev, useraddr);
1703 case ETHTOOL_GCOALESCE:
1704 rc = ethtool_get_coalesce(dev, useraddr);
1706 case ETHTOOL_SCOALESCE:
1707 rc = ethtool_set_coalesce(dev, useraddr);
1709 case ETHTOOL_GRINGPARAM:
1710 rc = ethtool_get_ringparam(dev, useraddr);
1712 case ETHTOOL_SRINGPARAM:
1713 rc = ethtool_set_ringparam(dev, useraddr);
1715 case ETHTOOL_GPAUSEPARAM:
1716 rc = ethtool_get_pauseparam(dev, useraddr);
1718 case ETHTOOL_SPAUSEPARAM:
1719 rc = ethtool_set_pauseparam(dev, useraddr);
1721 case ETHTOOL_GRXCSUM:
1722 rc = ethtool_get_value(dev, useraddr, ethcmd,
1723 (dev->ethtool_ops->get_rx_csum ?
1724 dev->ethtool_ops->get_rx_csum :
1725 ethtool_op_get_rx_csum));
1727 case ETHTOOL_SRXCSUM:
1728 rc = ethtool_set_rx_csum(dev, useraddr);
1731 rc = ethtool_self_test(dev, useraddr);
1733 case ETHTOOL_GSTRINGS:
1734 rc = ethtool_get_strings(dev, useraddr);
1736 case ETHTOOL_PHYS_ID:
1737 rc = ethtool_phys_id(dev, useraddr);
1739 case ETHTOOL_GSTATS:
1740 rc = ethtool_get_stats(dev, useraddr);
1742 case ETHTOOL_GPERMADDR:
1743 rc = ethtool_get_perm_addr(dev, useraddr);
1745 case ETHTOOL_GFLAGS:
1746 rc = ethtool_get_value(dev, useraddr, ethcmd,
1747 (dev->ethtool_ops->get_flags ?
1748 dev->ethtool_ops->get_flags :
1749 ethtool_op_get_flags));
1751 case ETHTOOL_SFLAGS:
1752 rc = ethtool_set_value(dev, useraddr,
1753 dev->ethtool_ops->set_flags);
1755 case ETHTOOL_GPFLAGS:
1756 rc = ethtool_get_value(dev, useraddr, ethcmd,
1757 dev->ethtool_ops->get_priv_flags);
1759 case ETHTOOL_SPFLAGS:
1760 rc = ethtool_set_value(dev, useraddr,
1761 dev->ethtool_ops->set_priv_flags);
1764 case ETHTOOL_GRXRINGS:
1765 case ETHTOOL_GRXCLSRLCNT:
1766 case ETHTOOL_GRXCLSRULE:
1767 case ETHTOOL_GRXCLSRLALL:
1768 rc = ethtool_get_rxnfc(dev, ethcmd, useraddr);
1771 case ETHTOOL_SRXCLSRLDEL:
1772 case ETHTOOL_SRXCLSRLINS:
1773 rc = ethtool_set_rxnfc(dev, ethcmd, useraddr);
1775 case ETHTOOL_FLASHDEV:
1776 rc = ethtool_flash_device(dev, useraddr);
1779 rc = ethtool_reset(dev, useraddr);
1781 case ETHTOOL_SRXNTUPLE:
1782 rc = ethtool_set_rx_ntuple(dev, useraddr);
1784 case ETHTOOL_GRXNTUPLE:
1785 rc = ethtool_get_rx_ntuple(dev, useraddr);
1787 case ETHTOOL_GSSET_INFO:
1788 rc = ethtool_get_sset_info(dev, useraddr);
1790 case ETHTOOL_GRXFHINDIR:
1791 rc = ethtool_get_rxfh_indir(dev, useraddr);
1793 case ETHTOOL_SRXFHINDIR:
1794 rc = ethtool_set_rxfh_indir(dev, useraddr);
1796 case ETHTOOL_GFEATURES:
1797 rc = ethtool_get_features(dev, useraddr);
1799 case ETHTOOL_SFEATURES:
1800 rc = ethtool_set_features(dev, useraddr);
1802 case ETHTOOL_GTXCSUM:
1808 rc = ethtool_get_one_feature(dev, useraddr, ethcmd);
1810 case ETHTOOL_STXCSUM:
1816 rc = ethtool_set_one_feature(dev, useraddr, ethcmd);
1822 if (dev->ethtool_ops->complete)
1823 dev->ethtool_ops->complete(dev);
1825 if (old_features != dev->features)
1826 netdev_features_change(dev);