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 <asm/uaccess.h>
23 * Some useful ethtool_ops methods that're device independent.
24 * If we find that all drivers want to do the same thing here,
25 * we can turn these into dev_() function calls.
28 u32 ethtool_op_get_link(struct net_device *dev)
30 return netif_carrier_ok(dev) ? 1 : 0;
33 u32 ethtool_op_get_tx_csum(struct net_device *dev)
35 return (dev->features & NETIF_F_ALL_CSUM) != 0;
38 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
41 dev->features |= NETIF_F_IP_CSUM;
43 dev->features &= ~NETIF_F_IP_CSUM;
48 int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
51 dev->features |= NETIF_F_HW_CSUM;
53 dev->features &= ~NETIF_F_HW_CSUM;
58 int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data)
61 dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
63 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
68 u32 ethtool_op_get_sg(struct net_device *dev)
70 return (dev->features & NETIF_F_SG) != 0;
73 int ethtool_op_set_sg(struct net_device *dev, u32 data)
76 dev->features |= NETIF_F_SG;
78 dev->features &= ~NETIF_F_SG;
83 u32 ethtool_op_get_tso(struct net_device *dev)
85 return (dev->features & NETIF_F_TSO) != 0;
88 int ethtool_op_set_tso(struct net_device *dev, u32 data)
91 dev->features |= NETIF_F_TSO;
93 dev->features &= ~NETIF_F_TSO;
98 u32 ethtool_op_get_ufo(struct net_device *dev)
100 return (dev->features & NETIF_F_UFO) != 0;
103 int ethtool_op_set_ufo(struct net_device *dev, u32 data)
106 dev->features |= NETIF_F_UFO;
108 dev->features &= ~NETIF_F_UFO;
112 /* the following list of flags are the same as their associated
113 * NETIF_F_xxx values in include/linux/netdevice.h
115 static const u32 flags_dup_features =
118 u32 ethtool_op_get_flags(struct net_device *dev)
120 /* in the future, this function will probably contain additional
121 * handling for flags which are not so easily handled
122 * by a simple masking operation
125 return dev->features & flags_dup_features;
128 int ethtool_op_set_flags(struct net_device *dev, u32 data)
130 if (data & ETH_FLAG_LRO)
131 dev->features |= NETIF_F_LRO;
133 dev->features &= ~NETIF_F_LRO;
138 /* Handlers for each ethtool command */
140 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
142 struct ethtool_cmd cmd = { ETHTOOL_GSET };
145 if (!dev->ethtool_ops->get_settings)
148 err = dev->ethtool_ops->get_settings(dev, &cmd);
152 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
157 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
159 struct ethtool_cmd cmd;
161 if (!dev->ethtool_ops->set_settings)
164 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
167 return dev->ethtool_ops->set_settings(dev, &cmd);
170 static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
172 struct ethtool_drvinfo info;
173 const struct ethtool_ops *ops = dev->ethtool_ops;
175 if (!ops->get_drvinfo)
178 memset(&info, 0, sizeof(info));
179 info.cmd = ETHTOOL_GDRVINFO;
180 ops->get_drvinfo(dev, &info);
182 if (ops->get_sset_count) {
185 rc = ops->get_sset_count(dev, ETH_SS_TEST);
187 info.testinfo_len = rc;
188 rc = ops->get_sset_count(dev, ETH_SS_STATS);
191 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
193 info.n_priv_flags = rc;
195 /* code path for obsolete hooks */
197 if (ops->self_test_count)
198 info.testinfo_len = ops->self_test_count(dev);
199 if (ops->get_stats_count)
200 info.n_stats = ops->get_stats_count(dev);
202 if (ops->get_regs_len)
203 info.regdump_len = ops->get_regs_len(dev);
204 if (ops->get_eeprom_len)
205 info.eedump_len = ops->get_eeprom_len(dev);
207 if (copy_to_user(useraddr, &info, sizeof(info)))
212 static int ethtool_set_rxhash(struct net_device *dev, void __user *useraddr)
214 struct ethtool_rxnfc cmd;
216 if (!dev->ethtool_ops->set_rxhash)
219 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
222 return dev->ethtool_ops->set_rxhash(dev, &cmd);
225 static int ethtool_get_rxhash(struct net_device *dev, void __user *useraddr)
227 struct ethtool_rxnfc info;
229 if (!dev->ethtool_ops->get_rxhash)
232 if (copy_from_user(&info, useraddr, sizeof(info)))
235 dev->ethtool_ops->get_rxhash(dev, &info);
237 if (copy_to_user(useraddr, &info, sizeof(info)))
242 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
244 struct ethtool_regs regs;
245 const struct ethtool_ops *ops = dev->ethtool_ops;
249 if (!ops->get_regs || !ops->get_regs_len)
252 if (copy_from_user(®s, useraddr, sizeof(regs)))
255 reglen = ops->get_regs_len(dev);
256 if (regs.len > reglen)
259 regbuf = kmalloc(reglen, GFP_USER);
263 ops->get_regs(dev, ®s, regbuf);
266 if (copy_to_user(useraddr, ®s, sizeof(regs)))
268 useraddr += offsetof(struct ethtool_regs, data);
269 if (copy_to_user(useraddr, regbuf, regs.len))
278 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
280 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
282 if (!dev->ethtool_ops->get_wol)
285 dev->ethtool_ops->get_wol(dev, &wol);
287 if (copy_to_user(useraddr, &wol, sizeof(wol)))
292 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
294 struct ethtool_wolinfo wol;
296 if (!dev->ethtool_ops->set_wol)
299 if (copy_from_user(&wol, useraddr, sizeof(wol)))
302 return dev->ethtool_ops->set_wol(dev, &wol);
305 static int ethtool_nway_reset(struct net_device *dev)
307 if (!dev->ethtool_ops->nway_reset)
310 return dev->ethtool_ops->nway_reset(dev);
313 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
315 struct ethtool_eeprom eeprom;
316 const struct ethtool_ops *ops = dev->ethtool_ops;
317 void __user *userbuf = useraddr + sizeof(eeprom);
322 if (!ops->get_eeprom || !ops->get_eeprom_len)
325 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
328 /* Check for wrap and zero */
329 if (eeprom.offset + eeprom.len <= eeprom.offset)
332 /* Check for exceeding total eeprom len */
333 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
336 data = kmalloc(PAGE_SIZE, GFP_USER);
340 bytes_remaining = eeprom.len;
341 while (bytes_remaining > 0) {
342 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
344 ret = ops->get_eeprom(dev, &eeprom, data);
347 if (copy_to_user(userbuf, data, eeprom.len)) {
351 userbuf += eeprom.len;
352 eeprom.offset += eeprom.len;
353 bytes_remaining -= eeprom.len;
356 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
357 eeprom.offset -= eeprom.len;
358 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
365 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
367 struct ethtool_eeprom eeprom;
368 const struct ethtool_ops *ops = dev->ethtool_ops;
369 void __user *userbuf = useraddr + sizeof(eeprom);
374 if (!ops->set_eeprom || !ops->get_eeprom_len)
377 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
380 /* Check for wrap and zero */
381 if (eeprom.offset + eeprom.len <= eeprom.offset)
384 /* Check for exceeding total eeprom len */
385 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
388 data = kmalloc(PAGE_SIZE, GFP_USER);
392 bytes_remaining = eeprom.len;
393 while (bytes_remaining > 0) {
394 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
396 if (copy_from_user(data, userbuf, eeprom.len)) {
400 ret = ops->set_eeprom(dev, &eeprom, data);
403 userbuf += eeprom.len;
404 eeprom.offset += eeprom.len;
405 bytes_remaining -= eeprom.len;
412 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
414 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
416 if (!dev->ethtool_ops->get_coalesce)
419 dev->ethtool_ops->get_coalesce(dev, &coalesce);
421 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
426 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
428 struct ethtool_coalesce coalesce;
430 if (!dev->ethtool_ops->set_coalesce)
433 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
436 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
439 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
441 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
443 if (!dev->ethtool_ops->get_ringparam)
446 dev->ethtool_ops->get_ringparam(dev, &ringparam);
448 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
453 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
455 struct ethtool_ringparam ringparam;
457 if (!dev->ethtool_ops->set_ringparam)
460 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
463 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
466 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
468 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
470 if (!dev->ethtool_ops->get_pauseparam)
473 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
475 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
480 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
482 struct ethtool_pauseparam pauseparam;
484 if (!dev->ethtool_ops->set_pauseparam)
487 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
490 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
493 static int __ethtool_set_sg(struct net_device *dev, u32 data)
497 if (!data && dev->ethtool_ops->set_tso) {
498 err = dev->ethtool_ops->set_tso(dev, 0);
503 if (!data && dev->ethtool_ops->set_ufo) {
504 err = dev->ethtool_ops->set_ufo(dev, 0);
508 return dev->ethtool_ops->set_sg(dev, data);
511 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
513 struct ethtool_value edata;
516 if (!dev->ethtool_ops->set_tx_csum)
519 if (copy_from_user(&edata, useraddr, sizeof(edata)))
522 if (!edata.data && dev->ethtool_ops->set_sg) {
523 err = __ethtool_set_sg(dev, 0);
528 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
531 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
533 struct ethtool_value edata;
535 if (!dev->ethtool_ops->set_rx_csum)
538 if (copy_from_user(&edata, useraddr, sizeof(edata)))
541 if (!edata.data && dev->ethtool_ops->set_sg)
542 dev->features &= ~NETIF_F_GRO;
544 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
547 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
549 struct ethtool_value edata;
551 if (!dev->ethtool_ops->set_sg)
554 if (copy_from_user(&edata, useraddr, sizeof(edata)))
558 !(dev->features & NETIF_F_ALL_CSUM))
561 return __ethtool_set_sg(dev, edata.data);
564 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
566 struct ethtool_value edata;
568 if (!dev->ethtool_ops->set_tso)
571 if (copy_from_user(&edata, useraddr, sizeof(edata)))
574 if (edata.data && !(dev->features & NETIF_F_SG))
577 return dev->ethtool_ops->set_tso(dev, edata.data);
580 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
582 struct ethtool_value edata;
584 if (!dev->ethtool_ops->set_ufo)
586 if (copy_from_user(&edata, useraddr, sizeof(edata)))
588 if (edata.data && !(dev->features & NETIF_F_SG))
590 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
592 return dev->ethtool_ops->set_ufo(dev, edata.data);
595 static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
597 struct ethtool_value edata = { ETHTOOL_GGSO };
599 edata.data = dev->features & NETIF_F_GSO;
600 if (copy_to_user(useraddr, &edata, sizeof(edata)))
605 static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
607 struct ethtool_value edata;
609 if (copy_from_user(&edata, useraddr, sizeof(edata)))
612 dev->features |= NETIF_F_GSO;
614 dev->features &= ~NETIF_F_GSO;
618 static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
620 struct ethtool_value edata = { ETHTOOL_GGRO };
622 edata.data = dev->features & NETIF_F_GRO;
623 if (copy_to_user(useraddr, &edata, sizeof(edata)))
628 static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
630 struct ethtool_value edata;
632 if (copy_from_user(&edata, useraddr, sizeof(edata)))
636 if (!dev->ethtool_ops->get_rx_csum ||
637 !dev->ethtool_ops->get_rx_csum(dev))
639 dev->features |= NETIF_F_GRO;
641 dev->features &= ~NETIF_F_GRO;
646 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
648 struct ethtool_test test;
649 const struct ethtool_ops *ops = dev->ethtool_ops;
655 if (!ops->get_sset_count && !ops->self_test_count)
658 if (ops->get_sset_count)
659 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
661 /* code path for obsolete hook */
662 test_len = ops->self_test_count(dev);
665 WARN_ON(test_len == 0);
667 if (copy_from_user(&test, useraddr, sizeof(test)))
671 data = kmalloc(test_len * sizeof(u64), GFP_USER);
675 ops->self_test(dev, &test, data);
678 if (copy_to_user(useraddr, &test, sizeof(test)))
680 useraddr += sizeof(test);
681 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
690 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
692 struct ethtool_gstrings gstrings;
693 const struct ethtool_ops *ops = dev->ethtool_ops;
697 if (!ops->get_strings)
700 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
703 if (ops->get_sset_count) {
704 ret = ops->get_sset_count(dev, gstrings.string_set);
710 /* code path for obsolete hooks */
712 switch (gstrings.string_set) {
714 if (!ops->self_test_count)
716 gstrings.len = ops->self_test_count(dev);
719 if (!ops->get_stats_count)
721 gstrings.len = ops->get_stats_count(dev);
728 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
732 ops->get_strings(dev, gstrings.string_set, data);
735 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
737 useraddr += sizeof(gstrings);
738 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
747 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
749 struct ethtool_value id;
751 if (!dev->ethtool_ops->phys_id)
754 if (copy_from_user(&id, useraddr, sizeof(id)))
757 return dev->ethtool_ops->phys_id(dev, id.data);
760 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
762 struct ethtool_stats stats;
763 const struct ethtool_ops *ops = dev->ethtool_ops;
767 if (!ops->get_ethtool_stats)
769 if (!ops->get_sset_count && !ops->get_stats_count)
772 if (ops->get_sset_count)
773 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
775 /* code path for obsolete hook */
776 n_stats = ops->get_stats_count(dev);
779 WARN_ON(n_stats == 0);
781 if (copy_from_user(&stats, useraddr, sizeof(stats)))
784 stats.n_stats = n_stats;
785 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
789 ops->get_ethtool_stats(dev, &stats, data);
792 if (copy_to_user(useraddr, &stats, sizeof(stats)))
794 useraddr += sizeof(stats);
795 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
804 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
806 struct ethtool_perm_addr epaddr;
808 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
811 if (epaddr.size < dev->addr_len)
813 epaddr.size = dev->addr_len;
815 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
817 useraddr += sizeof(epaddr);
818 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
823 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
824 u32 cmd, u32 (*actor)(struct net_device *))
826 struct ethtool_value edata = { cmd };
831 edata.data = actor(dev);
833 if (copy_to_user(useraddr, &edata, sizeof(edata)))
838 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
839 void (*actor)(struct net_device *, u32))
841 struct ethtool_value edata;
846 if (copy_from_user(&edata, useraddr, sizeof(edata)))
849 actor(dev, edata.data);
853 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
854 int (*actor)(struct net_device *, u32))
856 struct ethtool_value edata;
861 if (copy_from_user(&edata, useraddr, sizeof(edata)))
864 return actor(dev, edata.data);
867 /* The main entry point in this file. Called from net/core/dev.c */
869 int dev_ethtool(struct net *net, struct ifreq *ifr)
871 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
872 void __user *useraddr = ifr->ifr_data;
875 unsigned long old_features;
877 if (!dev || !netif_device_present(dev))
880 if (!dev->ethtool_ops)
883 if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
886 /* Allow some commands to be done by anyone */
888 case ETHTOOL_GDRVINFO:
889 case ETHTOOL_GMSGLVL:
890 case ETHTOOL_GCOALESCE:
891 case ETHTOOL_GRINGPARAM:
892 case ETHTOOL_GPAUSEPARAM:
893 case ETHTOOL_GRXCSUM:
894 case ETHTOOL_GTXCSUM:
896 case ETHTOOL_GSTRINGS:
898 case ETHTOOL_GPERMADDR:
902 case ETHTOOL_GPFLAGS:
906 if (!capable(CAP_NET_ADMIN))
910 if (dev->ethtool_ops->begin)
911 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
914 old_features = dev->features;
918 rc = ethtool_get_settings(dev, useraddr);
921 rc = ethtool_set_settings(dev, useraddr);
923 case ETHTOOL_GDRVINFO:
924 rc = ethtool_get_drvinfo(dev, useraddr);
927 rc = ethtool_get_regs(dev, useraddr);
930 rc = ethtool_get_wol(dev, useraddr);
933 rc = ethtool_set_wol(dev, useraddr);
935 case ETHTOOL_GMSGLVL:
936 rc = ethtool_get_value(dev, useraddr, ethcmd,
937 dev->ethtool_ops->get_msglevel);
939 case ETHTOOL_SMSGLVL:
940 rc = ethtool_set_value_void(dev, useraddr,
941 dev->ethtool_ops->set_msglevel);
943 case ETHTOOL_NWAY_RST:
944 rc = ethtool_nway_reset(dev);
947 rc = ethtool_get_value(dev, useraddr, ethcmd,
948 dev->ethtool_ops->get_link);
950 case ETHTOOL_GEEPROM:
951 rc = ethtool_get_eeprom(dev, useraddr);
953 case ETHTOOL_SEEPROM:
954 rc = ethtool_set_eeprom(dev, useraddr);
956 case ETHTOOL_GCOALESCE:
957 rc = ethtool_get_coalesce(dev, useraddr);
959 case ETHTOOL_SCOALESCE:
960 rc = ethtool_set_coalesce(dev, useraddr);
962 case ETHTOOL_GRINGPARAM:
963 rc = ethtool_get_ringparam(dev, useraddr);
965 case ETHTOOL_SRINGPARAM:
966 rc = ethtool_set_ringparam(dev, useraddr);
968 case ETHTOOL_GPAUSEPARAM:
969 rc = ethtool_get_pauseparam(dev, useraddr);
971 case ETHTOOL_SPAUSEPARAM:
972 rc = ethtool_set_pauseparam(dev, useraddr);
974 case ETHTOOL_GRXCSUM:
975 rc = ethtool_get_value(dev, useraddr, ethcmd,
976 dev->ethtool_ops->get_rx_csum);
978 case ETHTOOL_SRXCSUM:
979 rc = ethtool_set_rx_csum(dev, useraddr);
981 case ETHTOOL_GTXCSUM:
982 rc = ethtool_get_value(dev, useraddr, ethcmd,
983 (dev->ethtool_ops->get_tx_csum ?
984 dev->ethtool_ops->get_tx_csum :
985 ethtool_op_get_tx_csum));
987 case ETHTOOL_STXCSUM:
988 rc = ethtool_set_tx_csum(dev, useraddr);
991 rc = ethtool_get_value(dev, useraddr, ethcmd,
992 (dev->ethtool_ops->get_sg ?
993 dev->ethtool_ops->get_sg :
997 rc = ethtool_set_sg(dev, useraddr);
1000 rc = ethtool_get_value(dev, useraddr, ethcmd,
1001 (dev->ethtool_ops->get_tso ?
1002 dev->ethtool_ops->get_tso :
1003 ethtool_op_get_tso));
1006 rc = ethtool_set_tso(dev, useraddr);
1009 rc = ethtool_self_test(dev, useraddr);
1011 case ETHTOOL_GSTRINGS:
1012 rc = ethtool_get_strings(dev, useraddr);
1014 case ETHTOOL_PHYS_ID:
1015 rc = ethtool_phys_id(dev, useraddr);
1017 case ETHTOOL_GSTATS:
1018 rc = ethtool_get_stats(dev, useraddr);
1020 case ETHTOOL_GPERMADDR:
1021 rc = ethtool_get_perm_addr(dev, useraddr);
1024 rc = ethtool_get_value(dev, useraddr, ethcmd,
1025 (dev->ethtool_ops->get_ufo ?
1026 dev->ethtool_ops->get_ufo :
1027 ethtool_op_get_ufo));
1030 rc = ethtool_set_ufo(dev, useraddr);
1033 rc = ethtool_get_gso(dev, useraddr);
1036 rc = ethtool_set_gso(dev, useraddr);
1038 case ETHTOOL_GFLAGS:
1039 rc = ethtool_get_value(dev, useraddr, ethcmd,
1040 dev->ethtool_ops->get_flags);
1042 case ETHTOOL_SFLAGS:
1043 rc = ethtool_set_value(dev, useraddr,
1044 dev->ethtool_ops->set_flags);
1046 case ETHTOOL_GPFLAGS:
1047 rc = ethtool_get_value(dev, useraddr, ethcmd,
1048 dev->ethtool_ops->get_priv_flags);
1050 case ETHTOOL_SPFLAGS:
1051 rc = ethtool_set_value(dev, useraddr,
1052 dev->ethtool_ops->set_priv_flags);
1055 rc = ethtool_get_rxhash(dev, useraddr);
1058 rc = ethtool_set_rxhash(dev, useraddr);
1061 rc = ethtool_get_gro(dev, useraddr);
1064 rc = ethtool_set_gro(dev, useraddr);
1070 if (dev->ethtool_ops->complete)
1071 dev->ethtool_ops->complete(dev);
1073 if (old_features != dev->features)
1074 netdev_features_change(dev);
1079 EXPORT_SYMBOL(ethtool_op_get_link);
1080 EXPORT_SYMBOL(ethtool_op_get_sg);
1081 EXPORT_SYMBOL(ethtool_op_get_tso);
1082 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
1083 EXPORT_SYMBOL(ethtool_op_set_sg);
1084 EXPORT_SYMBOL(ethtool_op_set_tso);
1085 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
1086 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
1087 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
1088 EXPORT_SYMBOL(ethtool_op_set_ufo);
1089 EXPORT_SYMBOL(ethtool_op_get_ufo);
1090 EXPORT_SYMBOL(ethtool_op_set_flags);
1091 EXPORT_SYMBOL(ethtool_op_get_flags);