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_rx_csum(struct net_device *dev)
35 return (dev->features & NETIF_F_ALL_CSUM) != 0;
38 u32 ethtool_op_get_tx_csum(struct net_device *dev)
40 return (dev->features & NETIF_F_ALL_CSUM) != 0;
43 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
46 dev->features |= NETIF_F_IP_CSUM;
48 dev->features &= ~NETIF_F_IP_CSUM;
53 int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
56 dev->features |= NETIF_F_HW_CSUM;
58 dev->features &= ~NETIF_F_HW_CSUM;
63 int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data)
66 dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
68 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
73 u32 ethtool_op_get_sg(struct net_device *dev)
75 return (dev->features & NETIF_F_SG) != 0;
78 int ethtool_op_set_sg(struct net_device *dev, u32 data)
81 dev->features |= NETIF_F_SG;
83 dev->features &= ~NETIF_F_SG;
88 u32 ethtool_op_get_tso(struct net_device *dev)
90 return (dev->features & NETIF_F_TSO) != 0;
93 int ethtool_op_set_tso(struct net_device *dev, u32 data)
96 dev->features |= NETIF_F_TSO;
98 dev->features &= ~NETIF_F_TSO;
103 u32 ethtool_op_get_ufo(struct net_device *dev)
105 return (dev->features & NETIF_F_UFO) != 0;
108 int ethtool_op_set_ufo(struct net_device *dev, u32 data)
111 dev->features |= NETIF_F_UFO;
113 dev->features &= ~NETIF_F_UFO;
117 /* the following list of flags are the same as their associated
118 * NETIF_F_xxx values in include/linux/netdevice.h
120 static const u32 flags_dup_features =
123 u32 ethtool_op_get_flags(struct net_device *dev)
125 /* in the future, this function will probably contain additional
126 * handling for flags which are not so easily handled
127 * by a simple masking operation
130 return dev->features & flags_dup_features;
133 int ethtool_op_set_flags(struct net_device *dev, u32 data)
135 if (data & ETH_FLAG_LRO)
136 dev->features |= NETIF_F_LRO;
138 dev->features &= ~NETIF_F_LRO;
143 /* Handlers for each ethtool command */
145 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
147 struct ethtool_cmd cmd = { ETHTOOL_GSET };
150 if (!dev->ethtool_ops->get_settings)
153 err = dev->ethtool_ops->get_settings(dev, &cmd);
157 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
162 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
164 struct ethtool_cmd cmd;
166 if (!dev->ethtool_ops->set_settings)
169 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
172 return dev->ethtool_ops->set_settings(dev, &cmd);
175 static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
177 struct ethtool_drvinfo info;
178 const struct ethtool_ops *ops = dev->ethtool_ops;
180 if (!ops->get_drvinfo)
183 memset(&info, 0, sizeof(info));
184 info.cmd = ETHTOOL_GDRVINFO;
185 ops->get_drvinfo(dev, &info);
187 if (ops->get_sset_count) {
190 rc = ops->get_sset_count(dev, ETH_SS_TEST);
192 info.testinfo_len = rc;
193 rc = ops->get_sset_count(dev, ETH_SS_STATS);
196 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
198 info.n_priv_flags = rc;
200 /* code path for obsolete hooks */
202 if (ops->self_test_count)
203 info.testinfo_len = ops->self_test_count(dev);
204 if (ops->get_stats_count)
205 info.n_stats = ops->get_stats_count(dev);
207 if (ops->get_regs_len)
208 info.regdump_len = ops->get_regs_len(dev);
209 if (ops->get_eeprom_len)
210 info.eedump_len = ops->get_eeprom_len(dev);
212 if (copy_to_user(useraddr, &info, sizeof(info)))
217 static int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr)
219 struct ethtool_rxnfc cmd;
221 if (!dev->ethtool_ops->set_rxnfc)
224 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
227 return dev->ethtool_ops->set_rxnfc(dev, &cmd);
230 static int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr)
232 struct ethtool_rxnfc info;
233 const struct ethtool_ops *ops = dev->ethtool_ops;
235 void *rule_buf = NULL;
240 if (copy_from_user(&info, useraddr, sizeof(info)))
243 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
244 if (info.rule_cnt > 0) {
245 rule_buf = kmalloc(info.rule_cnt * sizeof(u32),
252 ret = ops->get_rxnfc(dev, &info, rule_buf);
257 if (copy_to_user(useraddr, &info, sizeof(info)))
261 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
262 if (copy_to_user(useraddr, rule_buf,
263 info.rule_cnt * sizeof(u32)))
274 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
276 struct ethtool_regs regs;
277 const struct ethtool_ops *ops = dev->ethtool_ops;
281 if (!ops->get_regs || !ops->get_regs_len)
284 if (copy_from_user(®s, useraddr, sizeof(regs)))
287 reglen = ops->get_regs_len(dev);
288 if (regs.len > reglen)
291 regbuf = kmalloc(reglen, GFP_USER);
295 ops->get_regs(dev, ®s, regbuf);
298 if (copy_to_user(useraddr, ®s, sizeof(regs)))
300 useraddr += offsetof(struct ethtool_regs, data);
301 if (copy_to_user(useraddr, regbuf, regs.len))
310 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
312 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
314 if (!dev->ethtool_ops->get_wol)
317 dev->ethtool_ops->get_wol(dev, &wol);
319 if (copy_to_user(useraddr, &wol, sizeof(wol)))
324 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
326 struct ethtool_wolinfo wol;
328 if (!dev->ethtool_ops->set_wol)
331 if (copy_from_user(&wol, useraddr, sizeof(wol)))
334 return dev->ethtool_ops->set_wol(dev, &wol);
337 static int ethtool_nway_reset(struct net_device *dev)
339 if (!dev->ethtool_ops->nway_reset)
342 return dev->ethtool_ops->nway_reset(dev);
345 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
347 struct ethtool_eeprom eeprom;
348 const struct ethtool_ops *ops = dev->ethtool_ops;
349 void __user *userbuf = useraddr + sizeof(eeprom);
354 if (!ops->get_eeprom || !ops->get_eeprom_len)
357 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
360 /* Check for wrap and zero */
361 if (eeprom.offset + eeprom.len <= eeprom.offset)
364 /* Check for exceeding total eeprom len */
365 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
368 data = kmalloc(PAGE_SIZE, GFP_USER);
372 bytes_remaining = eeprom.len;
373 while (bytes_remaining > 0) {
374 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
376 ret = ops->get_eeprom(dev, &eeprom, data);
379 if (copy_to_user(userbuf, data, eeprom.len)) {
383 userbuf += eeprom.len;
384 eeprom.offset += eeprom.len;
385 bytes_remaining -= eeprom.len;
388 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
389 eeprom.offset -= eeprom.len;
390 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
397 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
399 struct ethtool_eeprom eeprom;
400 const struct ethtool_ops *ops = dev->ethtool_ops;
401 void __user *userbuf = useraddr + sizeof(eeprom);
406 if (!ops->set_eeprom || !ops->get_eeprom_len)
409 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
412 /* Check for wrap and zero */
413 if (eeprom.offset + eeprom.len <= eeprom.offset)
416 /* Check for exceeding total eeprom len */
417 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
420 data = kmalloc(PAGE_SIZE, GFP_USER);
424 bytes_remaining = eeprom.len;
425 while (bytes_remaining > 0) {
426 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
428 if (copy_from_user(data, userbuf, eeprom.len)) {
432 ret = ops->set_eeprom(dev, &eeprom, data);
435 userbuf += eeprom.len;
436 eeprom.offset += eeprom.len;
437 bytes_remaining -= eeprom.len;
444 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
446 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
448 if (!dev->ethtool_ops->get_coalesce)
451 dev->ethtool_ops->get_coalesce(dev, &coalesce);
453 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
458 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
460 struct ethtool_coalesce coalesce;
462 if (!dev->ethtool_ops->set_coalesce)
465 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
468 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
471 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
473 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
475 if (!dev->ethtool_ops->get_ringparam)
478 dev->ethtool_ops->get_ringparam(dev, &ringparam);
480 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
485 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
487 struct ethtool_ringparam ringparam;
489 if (!dev->ethtool_ops->set_ringparam)
492 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
495 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
498 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
500 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
502 if (!dev->ethtool_ops->get_pauseparam)
505 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
507 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
512 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
514 struct ethtool_pauseparam pauseparam;
516 if (!dev->ethtool_ops->set_pauseparam)
519 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
522 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
525 static int __ethtool_set_sg(struct net_device *dev, u32 data)
529 if (!data && dev->ethtool_ops->set_tso) {
530 err = dev->ethtool_ops->set_tso(dev, 0);
535 if (!data && dev->ethtool_ops->set_ufo) {
536 err = dev->ethtool_ops->set_ufo(dev, 0);
540 return dev->ethtool_ops->set_sg(dev, data);
543 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
545 struct ethtool_value edata;
548 if (!dev->ethtool_ops->set_tx_csum)
551 if (copy_from_user(&edata, useraddr, sizeof(edata)))
554 if (!edata.data && dev->ethtool_ops->set_sg) {
555 err = __ethtool_set_sg(dev, 0);
560 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
563 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
565 struct ethtool_value edata;
567 if (!dev->ethtool_ops->set_rx_csum)
570 if (copy_from_user(&edata, useraddr, sizeof(edata)))
573 if (!edata.data && dev->ethtool_ops->set_sg)
574 dev->features &= ~NETIF_F_GRO;
576 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
579 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
581 struct ethtool_value edata;
583 if (!dev->ethtool_ops->set_sg)
586 if (copy_from_user(&edata, useraddr, sizeof(edata)))
590 !(dev->features & NETIF_F_ALL_CSUM))
593 return __ethtool_set_sg(dev, edata.data);
596 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
598 struct ethtool_value edata;
600 if (!dev->ethtool_ops->set_tso)
603 if (copy_from_user(&edata, useraddr, sizeof(edata)))
606 if (edata.data && !(dev->features & NETIF_F_SG))
609 return dev->ethtool_ops->set_tso(dev, edata.data);
612 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
614 struct ethtool_value edata;
616 if (!dev->ethtool_ops->set_ufo)
618 if (copy_from_user(&edata, useraddr, sizeof(edata)))
620 if (edata.data && !(dev->features & NETIF_F_SG))
622 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
624 return dev->ethtool_ops->set_ufo(dev, edata.data);
627 static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
629 struct ethtool_value edata = { ETHTOOL_GGSO };
631 edata.data = dev->features & NETIF_F_GSO;
632 if (copy_to_user(useraddr, &edata, sizeof(edata)))
637 static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
639 struct ethtool_value edata;
641 if (copy_from_user(&edata, useraddr, sizeof(edata)))
644 dev->features |= NETIF_F_GSO;
646 dev->features &= ~NETIF_F_GSO;
650 static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
652 struct ethtool_value edata = { ETHTOOL_GGRO };
654 edata.data = dev->features & NETIF_F_GRO;
655 if (copy_to_user(useraddr, &edata, sizeof(edata)))
660 static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
662 struct ethtool_value edata;
664 if (copy_from_user(&edata, useraddr, sizeof(edata)))
668 if (!dev->ethtool_ops->get_rx_csum ||
669 !dev->ethtool_ops->get_rx_csum(dev))
671 dev->features |= NETIF_F_GRO;
673 dev->features &= ~NETIF_F_GRO;
678 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
680 struct ethtool_test test;
681 const struct ethtool_ops *ops = dev->ethtool_ops;
687 if (!ops->get_sset_count && !ops->self_test_count)
690 if (ops->get_sset_count)
691 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
693 /* code path for obsolete hook */
694 test_len = ops->self_test_count(dev);
697 WARN_ON(test_len == 0);
699 if (copy_from_user(&test, useraddr, sizeof(test)))
703 data = kmalloc(test_len * sizeof(u64), GFP_USER);
707 ops->self_test(dev, &test, data);
710 if (copy_to_user(useraddr, &test, sizeof(test)))
712 useraddr += sizeof(test);
713 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
722 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
724 struct ethtool_gstrings gstrings;
725 const struct ethtool_ops *ops = dev->ethtool_ops;
729 if (!ops->get_strings)
732 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
735 if (ops->get_sset_count) {
736 ret = ops->get_sset_count(dev, gstrings.string_set);
742 /* code path for obsolete hooks */
744 switch (gstrings.string_set) {
746 if (!ops->self_test_count)
748 gstrings.len = ops->self_test_count(dev);
751 if (!ops->get_stats_count)
753 gstrings.len = ops->get_stats_count(dev);
760 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
764 ops->get_strings(dev, gstrings.string_set, data);
767 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
769 useraddr += sizeof(gstrings);
770 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
779 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
781 struct ethtool_value id;
783 if (!dev->ethtool_ops->phys_id)
786 if (copy_from_user(&id, useraddr, sizeof(id)))
789 return dev->ethtool_ops->phys_id(dev, id.data);
792 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
794 struct ethtool_stats stats;
795 const struct ethtool_ops *ops = dev->ethtool_ops;
799 if (!ops->get_ethtool_stats)
801 if (!ops->get_sset_count && !ops->get_stats_count)
804 if (ops->get_sset_count)
805 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
807 /* code path for obsolete hook */
808 n_stats = ops->get_stats_count(dev);
811 WARN_ON(n_stats == 0);
813 if (copy_from_user(&stats, useraddr, sizeof(stats)))
816 stats.n_stats = n_stats;
817 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
821 ops->get_ethtool_stats(dev, &stats, data);
824 if (copy_to_user(useraddr, &stats, sizeof(stats)))
826 useraddr += sizeof(stats);
827 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
836 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
838 struct ethtool_perm_addr epaddr;
840 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
843 if (epaddr.size < dev->addr_len)
845 epaddr.size = dev->addr_len;
847 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
849 useraddr += sizeof(epaddr);
850 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
855 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
856 u32 cmd, u32 (*actor)(struct net_device *))
858 struct ethtool_value edata = { cmd };
863 edata.data = actor(dev);
865 if (copy_to_user(useraddr, &edata, sizeof(edata)))
870 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
871 void (*actor)(struct net_device *, u32))
873 struct ethtool_value edata;
878 if (copy_from_user(&edata, useraddr, sizeof(edata)))
881 actor(dev, edata.data);
885 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
886 int (*actor)(struct net_device *, u32))
888 struct ethtool_value edata;
893 if (copy_from_user(&edata, useraddr, sizeof(edata)))
896 return actor(dev, edata.data);
899 /* The main entry point in this file. Called from net/core/dev.c */
901 int dev_ethtool(struct net *net, struct ifreq *ifr)
903 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
904 void __user *useraddr = ifr->ifr_data;
907 unsigned long old_features;
909 if (!dev || !netif_device_present(dev))
912 if (!dev->ethtool_ops)
915 if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
918 /* Allow some commands to be done by anyone */
920 case ETHTOOL_GDRVINFO:
921 case ETHTOOL_GMSGLVL:
922 case ETHTOOL_GCOALESCE:
923 case ETHTOOL_GRINGPARAM:
924 case ETHTOOL_GPAUSEPARAM:
925 case ETHTOOL_GRXCSUM:
926 case ETHTOOL_GTXCSUM:
928 case ETHTOOL_GSTRINGS:
930 case ETHTOOL_GPERMADDR:
934 case ETHTOOL_GPFLAGS:
936 case ETHTOOL_GRXRINGS:
937 case ETHTOOL_GRXCLSRLCNT:
938 case ETHTOOL_GRXCLSRULE:
939 case ETHTOOL_GRXCLSRLALL:
942 if (!capable(CAP_NET_ADMIN))
946 if (dev->ethtool_ops->begin)
947 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
950 old_features = dev->features;
954 rc = ethtool_get_settings(dev, useraddr);
957 rc = ethtool_set_settings(dev, useraddr);
959 case ETHTOOL_GDRVINFO:
960 rc = ethtool_get_drvinfo(dev, useraddr);
963 rc = ethtool_get_regs(dev, useraddr);
966 rc = ethtool_get_wol(dev, useraddr);
969 rc = ethtool_set_wol(dev, useraddr);
971 case ETHTOOL_GMSGLVL:
972 rc = ethtool_get_value(dev, useraddr, ethcmd,
973 dev->ethtool_ops->get_msglevel);
975 case ETHTOOL_SMSGLVL:
976 rc = ethtool_set_value_void(dev, useraddr,
977 dev->ethtool_ops->set_msglevel);
979 case ETHTOOL_NWAY_RST:
980 rc = ethtool_nway_reset(dev);
983 rc = ethtool_get_value(dev, useraddr, ethcmd,
984 dev->ethtool_ops->get_link);
986 case ETHTOOL_GEEPROM:
987 rc = ethtool_get_eeprom(dev, useraddr);
989 case ETHTOOL_SEEPROM:
990 rc = ethtool_set_eeprom(dev, useraddr);
992 case ETHTOOL_GCOALESCE:
993 rc = ethtool_get_coalesce(dev, useraddr);
995 case ETHTOOL_SCOALESCE:
996 rc = ethtool_set_coalesce(dev, useraddr);
998 case ETHTOOL_GRINGPARAM:
999 rc = ethtool_get_ringparam(dev, useraddr);
1001 case ETHTOOL_SRINGPARAM:
1002 rc = ethtool_set_ringparam(dev, useraddr);
1004 case ETHTOOL_GPAUSEPARAM:
1005 rc = ethtool_get_pauseparam(dev, useraddr);
1007 case ETHTOOL_SPAUSEPARAM:
1008 rc = ethtool_set_pauseparam(dev, useraddr);
1010 case ETHTOOL_GRXCSUM:
1011 rc = ethtool_get_value(dev, useraddr, ethcmd,
1012 (dev->ethtool_ops->get_rx_csum ?
1013 dev->ethtool_ops->get_rx_csum :
1014 ethtool_op_get_rx_csum));
1016 case ETHTOOL_SRXCSUM:
1017 rc = ethtool_set_rx_csum(dev, useraddr);
1019 case ETHTOOL_GTXCSUM:
1020 rc = ethtool_get_value(dev, useraddr, ethcmd,
1021 (dev->ethtool_ops->get_tx_csum ?
1022 dev->ethtool_ops->get_tx_csum :
1023 ethtool_op_get_tx_csum));
1025 case ETHTOOL_STXCSUM:
1026 rc = ethtool_set_tx_csum(dev, useraddr);
1029 rc = ethtool_get_value(dev, useraddr, ethcmd,
1030 (dev->ethtool_ops->get_sg ?
1031 dev->ethtool_ops->get_sg :
1032 ethtool_op_get_sg));
1035 rc = ethtool_set_sg(dev, useraddr);
1038 rc = ethtool_get_value(dev, useraddr, ethcmd,
1039 (dev->ethtool_ops->get_tso ?
1040 dev->ethtool_ops->get_tso :
1041 ethtool_op_get_tso));
1044 rc = ethtool_set_tso(dev, useraddr);
1047 rc = ethtool_self_test(dev, useraddr);
1049 case ETHTOOL_GSTRINGS:
1050 rc = ethtool_get_strings(dev, useraddr);
1052 case ETHTOOL_PHYS_ID:
1053 rc = ethtool_phys_id(dev, useraddr);
1055 case ETHTOOL_GSTATS:
1056 rc = ethtool_get_stats(dev, useraddr);
1058 case ETHTOOL_GPERMADDR:
1059 rc = ethtool_get_perm_addr(dev, useraddr);
1062 rc = ethtool_get_value(dev, useraddr, ethcmd,
1063 (dev->ethtool_ops->get_ufo ?
1064 dev->ethtool_ops->get_ufo :
1065 ethtool_op_get_ufo));
1068 rc = ethtool_set_ufo(dev, useraddr);
1071 rc = ethtool_get_gso(dev, useraddr);
1074 rc = ethtool_set_gso(dev, useraddr);
1076 case ETHTOOL_GFLAGS:
1077 rc = ethtool_get_value(dev, useraddr, ethcmd,
1078 (dev->ethtool_ops->get_flags ?
1079 dev->ethtool_ops->get_flags :
1080 ethtool_op_get_flags));
1082 case ETHTOOL_SFLAGS:
1083 rc = ethtool_set_value(dev, useraddr,
1084 dev->ethtool_ops->set_flags);
1086 case ETHTOOL_GPFLAGS:
1087 rc = ethtool_get_value(dev, useraddr, ethcmd,
1088 dev->ethtool_ops->get_priv_flags);
1090 case ETHTOOL_SPFLAGS:
1091 rc = ethtool_set_value(dev, useraddr,
1092 dev->ethtool_ops->set_priv_flags);
1095 case ETHTOOL_GRXRINGS:
1096 case ETHTOOL_GRXCLSRLCNT:
1097 case ETHTOOL_GRXCLSRULE:
1098 case ETHTOOL_GRXCLSRLALL:
1099 rc = ethtool_get_rxnfc(dev, useraddr);
1102 case ETHTOOL_SRXCLSRLDEL:
1103 case ETHTOOL_SRXCLSRLINS:
1104 rc = ethtool_set_rxnfc(dev, useraddr);
1107 rc = ethtool_get_gro(dev, useraddr);
1110 rc = ethtool_set_gro(dev, useraddr);
1116 if (dev->ethtool_ops->complete)
1117 dev->ethtool_ops->complete(dev);
1119 if (old_features != dev->features)
1120 netdev_features_change(dev);
1125 EXPORT_SYMBOL(ethtool_op_get_link);
1126 EXPORT_SYMBOL(ethtool_op_get_sg);
1127 EXPORT_SYMBOL(ethtool_op_get_tso);
1128 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
1129 EXPORT_SYMBOL(ethtool_op_set_sg);
1130 EXPORT_SYMBOL(ethtool_op_set_tso);
1131 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
1132 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
1133 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
1134 EXPORT_SYMBOL(ethtool_op_set_ufo);
1135 EXPORT_SYMBOL(ethtool_op_get_ufo);
1136 EXPORT_SYMBOL(ethtool_op_set_flags);
1137 EXPORT_SYMBOL(ethtool_op_get_flags);