2 * net/core/ethtool.c - Ethtool ioctl handler
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;
37 EXPORT_SYMBOL(ethtool_op_get_rx_csum);
39 u32 ethtool_op_get_tx_csum(struct net_device *dev)
41 return (dev->features & NETIF_F_ALL_CSUM) != 0;
43 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
45 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
48 dev->features |= NETIF_F_IP_CSUM;
50 dev->features &= ~NETIF_F_IP_CSUM;
55 int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
58 dev->features |= NETIF_F_HW_CSUM;
60 dev->features &= ~NETIF_F_HW_CSUM;
65 int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data)
68 dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
70 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
75 u32 ethtool_op_get_sg(struct net_device *dev)
77 return (dev->features & NETIF_F_SG) != 0;
80 int ethtool_op_set_sg(struct net_device *dev, u32 data)
83 dev->features |= NETIF_F_SG;
85 dev->features &= ~NETIF_F_SG;
90 u32 ethtool_op_get_tso(struct net_device *dev)
92 return (dev->features & NETIF_F_TSO) != 0;
95 int ethtool_op_set_tso(struct net_device *dev, u32 data)
98 dev->features |= NETIF_F_TSO;
100 dev->features &= ~NETIF_F_TSO;
105 u32 ethtool_op_get_ufo(struct net_device *dev)
107 return (dev->features & NETIF_F_UFO) != 0;
110 int ethtool_op_set_ufo(struct net_device *dev, u32 data)
113 dev->features |= NETIF_F_UFO;
115 dev->features &= ~NETIF_F_UFO;
119 /* the following list of flags are the same as their associated
120 * NETIF_F_xxx values in include/linux/netdevice.h
122 static const u32 flags_dup_features =
125 u32 ethtool_op_get_flags(struct net_device *dev)
127 /* in the future, this function will probably contain additional
128 * handling for flags which are not so easily handled
129 * by a simple masking operation
132 return dev->features & flags_dup_features;
135 int ethtool_op_set_flags(struct net_device *dev, u32 data)
137 if (data & ETH_FLAG_LRO)
138 dev->features |= NETIF_F_LRO;
140 dev->features &= ~NETIF_F_LRO;
145 /* Handlers for each ethtool command */
147 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
149 struct ethtool_cmd cmd = { ETHTOOL_GSET };
152 if (!dev->ethtool_ops->get_settings)
155 err = dev->ethtool_ops->get_settings(dev, &cmd);
159 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
164 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
166 struct ethtool_cmd cmd;
168 if (!dev->ethtool_ops->set_settings)
171 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
174 return dev->ethtool_ops->set_settings(dev, &cmd);
177 static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
179 struct ethtool_drvinfo info;
180 const struct ethtool_ops *ops = dev->ethtool_ops;
182 if (!ops->get_drvinfo)
185 memset(&info, 0, sizeof(info));
186 info.cmd = ETHTOOL_GDRVINFO;
187 ops->get_drvinfo(dev, &info);
189 if (ops->get_sset_count) {
192 rc = ops->get_sset_count(dev, ETH_SS_TEST);
194 info.testinfo_len = rc;
195 rc = ops->get_sset_count(dev, ETH_SS_STATS);
198 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
200 info.n_priv_flags = rc;
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_rxnfc(struct net_device *dev, void __user *useraddr)
214 struct ethtool_rxnfc cmd;
216 if (!dev->ethtool_ops->set_rxnfc)
219 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
222 return dev->ethtool_ops->set_rxnfc(dev, &cmd);
225 static int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr)
227 struct ethtool_rxnfc info;
228 const struct ethtool_ops *ops = dev->ethtool_ops;
230 void *rule_buf = NULL;
235 if (copy_from_user(&info, useraddr, sizeof(info)))
238 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
239 if (info.rule_cnt > 0) {
240 rule_buf = kmalloc(info.rule_cnt * sizeof(u32),
247 ret = ops->get_rxnfc(dev, &info, rule_buf);
252 if (copy_to_user(useraddr, &info, sizeof(info)))
256 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
257 if (copy_to_user(useraddr, rule_buf,
258 info.rule_cnt * sizeof(u32)))
269 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
271 struct ethtool_regs regs;
272 const struct ethtool_ops *ops = dev->ethtool_ops;
276 if (!ops->get_regs || !ops->get_regs_len)
279 if (copy_from_user(®s, useraddr, sizeof(regs)))
282 reglen = ops->get_regs_len(dev);
283 if (regs.len > reglen)
286 regbuf = kmalloc(reglen, GFP_USER);
290 ops->get_regs(dev, ®s, regbuf);
293 if (copy_to_user(useraddr, ®s, sizeof(regs)))
295 useraddr += offsetof(struct ethtool_regs, data);
296 if (copy_to_user(useraddr, regbuf, regs.len))
305 static int ethtool_reset(struct net_device *dev, char __user *useraddr)
307 struct ethtool_value reset;
310 if (!dev->ethtool_ops->reset)
313 if (copy_from_user(&reset, useraddr, sizeof(reset)))
316 ret = dev->ethtool_ops->reset(dev, &reset.data);
320 if (copy_to_user(useraddr, &reset, sizeof(reset)))
325 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
327 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
329 if (!dev->ethtool_ops->get_wol)
332 dev->ethtool_ops->get_wol(dev, &wol);
334 if (copy_to_user(useraddr, &wol, sizeof(wol)))
339 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
341 struct ethtool_wolinfo wol;
343 if (!dev->ethtool_ops->set_wol)
346 if (copy_from_user(&wol, useraddr, sizeof(wol)))
349 return dev->ethtool_ops->set_wol(dev, &wol);
352 static int ethtool_nway_reset(struct net_device *dev)
354 if (!dev->ethtool_ops->nway_reset)
357 return dev->ethtool_ops->nway_reset(dev);
360 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
362 struct ethtool_eeprom eeprom;
363 const struct ethtool_ops *ops = dev->ethtool_ops;
364 void __user *userbuf = useraddr + sizeof(eeprom);
369 if (!ops->get_eeprom || !ops->get_eeprom_len)
372 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
375 /* Check for wrap and zero */
376 if (eeprom.offset + eeprom.len <= eeprom.offset)
379 /* Check for exceeding total eeprom len */
380 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
383 data = kmalloc(PAGE_SIZE, GFP_USER);
387 bytes_remaining = eeprom.len;
388 while (bytes_remaining > 0) {
389 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
391 ret = ops->get_eeprom(dev, &eeprom, data);
394 if (copy_to_user(userbuf, data, eeprom.len)) {
398 userbuf += eeprom.len;
399 eeprom.offset += eeprom.len;
400 bytes_remaining -= eeprom.len;
403 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
404 eeprom.offset -= eeprom.len;
405 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
412 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
414 struct ethtool_eeprom eeprom;
415 const struct ethtool_ops *ops = dev->ethtool_ops;
416 void __user *userbuf = useraddr + sizeof(eeprom);
421 if (!ops->set_eeprom || !ops->get_eeprom_len)
424 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
427 /* Check for wrap and zero */
428 if (eeprom.offset + eeprom.len <= eeprom.offset)
431 /* Check for exceeding total eeprom len */
432 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
435 data = kmalloc(PAGE_SIZE, GFP_USER);
439 bytes_remaining = eeprom.len;
440 while (bytes_remaining > 0) {
441 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
443 if (copy_from_user(data, userbuf, eeprom.len)) {
447 ret = ops->set_eeprom(dev, &eeprom, data);
450 userbuf += eeprom.len;
451 eeprom.offset += eeprom.len;
452 bytes_remaining -= eeprom.len;
459 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
461 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
463 if (!dev->ethtool_ops->get_coalesce)
466 dev->ethtool_ops->get_coalesce(dev, &coalesce);
468 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
473 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
475 struct ethtool_coalesce coalesce;
477 if (!dev->ethtool_ops->set_coalesce)
480 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
483 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
486 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
488 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
490 if (!dev->ethtool_ops->get_ringparam)
493 dev->ethtool_ops->get_ringparam(dev, &ringparam);
495 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
500 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
502 struct ethtool_ringparam ringparam;
504 if (!dev->ethtool_ops->set_ringparam)
507 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
510 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
513 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
515 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
517 if (!dev->ethtool_ops->get_pauseparam)
520 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
522 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
527 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
529 struct ethtool_pauseparam pauseparam;
531 if (!dev->ethtool_ops->set_pauseparam)
534 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
537 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
540 static int __ethtool_set_sg(struct net_device *dev, u32 data)
544 if (!data && dev->ethtool_ops->set_tso) {
545 err = dev->ethtool_ops->set_tso(dev, 0);
550 if (!data && dev->ethtool_ops->set_ufo) {
551 err = dev->ethtool_ops->set_ufo(dev, 0);
555 return dev->ethtool_ops->set_sg(dev, data);
558 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
560 struct ethtool_value edata;
563 if (!dev->ethtool_ops->set_tx_csum)
566 if (copy_from_user(&edata, useraddr, sizeof(edata)))
569 if (!edata.data && dev->ethtool_ops->set_sg) {
570 err = __ethtool_set_sg(dev, 0);
575 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
578 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
580 struct ethtool_value edata;
582 if (!dev->ethtool_ops->set_rx_csum)
585 if (copy_from_user(&edata, useraddr, sizeof(edata)))
588 if (!edata.data && dev->ethtool_ops->set_sg)
589 dev->features &= ~NETIF_F_GRO;
591 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
594 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
596 struct ethtool_value edata;
598 if (!dev->ethtool_ops->set_sg)
601 if (copy_from_user(&edata, useraddr, sizeof(edata)))
605 !(dev->features & NETIF_F_ALL_CSUM))
608 return __ethtool_set_sg(dev, edata.data);
611 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
613 struct ethtool_value edata;
615 if (!dev->ethtool_ops->set_tso)
618 if (copy_from_user(&edata, useraddr, sizeof(edata)))
621 if (edata.data && !(dev->features & NETIF_F_SG))
624 return dev->ethtool_ops->set_tso(dev, edata.data);
627 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
629 struct ethtool_value edata;
631 if (!dev->ethtool_ops->set_ufo)
633 if (copy_from_user(&edata, useraddr, sizeof(edata)))
635 if (edata.data && !(dev->features & NETIF_F_SG))
637 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
639 return dev->ethtool_ops->set_ufo(dev, edata.data);
642 static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
644 struct ethtool_value edata = { ETHTOOL_GGSO };
646 edata.data = dev->features & NETIF_F_GSO;
647 if (copy_to_user(useraddr, &edata, sizeof(edata)))
652 static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
654 struct ethtool_value edata;
656 if (copy_from_user(&edata, useraddr, sizeof(edata)))
659 dev->features |= NETIF_F_GSO;
661 dev->features &= ~NETIF_F_GSO;
665 static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
667 struct ethtool_value edata = { ETHTOOL_GGRO };
669 edata.data = dev->features & NETIF_F_GRO;
670 if (copy_to_user(useraddr, &edata, sizeof(edata)))
675 static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
677 struct ethtool_value edata;
679 if (copy_from_user(&edata, useraddr, sizeof(edata)))
683 if (!dev->ethtool_ops->get_rx_csum ||
684 !dev->ethtool_ops->get_rx_csum(dev))
686 dev->features |= NETIF_F_GRO;
688 dev->features &= ~NETIF_F_GRO;
693 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
695 struct ethtool_test test;
696 const struct ethtool_ops *ops = dev->ethtool_ops;
700 if (!ops->self_test || !ops->get_sset_count)
703 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
706 WARN_ON(test_len == 0);
708 if (copy_from_user(&test, useraddr, sizeof(test)))
712 data = kmalloc(test_len * sizeof(u64), GFP_USER);
716 ops->self_test(dev, &test, data);
719 if (copy_to_user(useraddr, &test, sizeof(test)))
721 useraddr += sizeof(test);
722 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
731 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
733 struct ethtool_gstrings gstrings;
734 const struct ethtool_ops *ops = dev->ethtool_ops;
738 if (!ops->get_strings || !ops->get_sset_count)
741 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
744 ret = ops->get_sset_count(dev, gstrings.string_set);
750 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
754 ops->get_strings(dev, gstrings.string_set, data);
757 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
759 useraddr += sizeof(gstrings);
760 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
769 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
771 struct ethtool_value id;
773 if (!dev->ethtool_ops->phys_id)
776 if (copy_from_user(&id, useraddr, sizeof(id)))
779 return dev->ethtool_ops->phys_id(dev, id.data);
782 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
784 struct ethtool_stats stats;
785 const struct ethtool_ops *ops = dev->ethtool_ops;
789 if (!ops->get_ethtool_stats || !ops->get_sset_count)
792 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
795 WARN_ON(n_stats == 0);
797 if (copy_from_user(&stats, useraddr, sizeof(stats)))
800 stats.n_stats = n_stats;
801 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
805 ops->get_ethtool_stats(dev, &stats, data);
808 if (copy_to_user(useraddr, &stats, sizeof(stats)))
810 useraddr += sizeof(stats);
811 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
820 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
822 struct ethtool_perm_addr epaddr;
824 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
827 if (epaddr.size < dev->addr_len)
829 epaddr.size = dev->addr_len;
831 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
833 useraddr += sizeof(epaddr);
834 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
839 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
840 u32 cmd, u32 (*actor)(struct net_device *))
842 struct ethtool_value edata = { cmd };
847 edata.data = actor(dev);
849 if (copy_to_user(useraddr, &edata, sizeof(edata)))
854 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
855 void (*actor)(struct net_device *, u32))
857 struct ethtool_value edata;
862 if (copy_from_user(&edata, useraddr, sizeof(edata)))
865 actor(dev, edata.data);
869 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
870 int (*actor)(struct net_device *, u32))
872 struct ethtool_value edata;
877 if (copy_from_user(&edata, useraddr, sizeof(edata)))
880 return actor(dev, edata.data);
883 static int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
885 struct ethtool_flash efl;
887 if (copy_from_user(&efl, useraddr, sizeof(efl)))
890 if (!dev->ethtool_ops->flash_device)
893 return dev->ethtool_ops->flash_device(dev, &efl);
896 /* The main entry point in this file. Called from net/core/dev.c */
898 int dev_ethtool(struct net *net, struct ifreq *ifr)
900 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
901 void __user *useraddr = ifr->ifr_data;
904 unsigned long old_features;
906 if (!dev || !netif_device_present(dev))
909 if (!dev->ethtool_ops)
912 if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
915 /* Allow some commands to be done by anyone */
917 case ETHTOOL_GDRVINFO:
918 case ETHTOOL_GMSGLVL:
919 case ETHTOOL_GCOALESCE:
920 case ETHTOOL_GRINGPARAM:
921 case ETHTOOL_GPAUSEPARAM:
922 case ETHTOOL_GRXCSUM:
923 case ETHTOOL_GTXCSUM:
925 case ETHTOOL_GSTRINGS:
927 case ETHTOOL_GPERMADDR:
932 case ETHTOOL_GPFLAGS:
934 case ETHTOOL_GRXRINGS:
935 case ETHTOOL_GRXCLSRLCNT:
936 case ETHTOOL_GRXCLSRULE:
937 case ETHTOOL_GRXCLSRLALL:
940 if (!capable(CAP_NET_ADMIN))
944 if (dev->ethtool_ops->begin)
945 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
948 old_features = dev->features;
952 rc = ethtool_get_settings(dev, useraddr);
955 rc = ethtool_set_settings(dev, useraddr);
957 case ETHTOOL_GDRVINFO:
958 rc = ethtool_get_drvinfo(dev, useraddr);
961 rc = ethtool_get_regs(dev, useraddr);
964 rc = ethtool_get_wol(dev, useraddr);
967 rc = ethtool_set_wol(dev, useraddr);
969 case ETHTOOL_GMSGLVL:
970 rc = ethtool_get_value(dev, useraddr, ethcmd,
971 dev->ethtool_ops->get_msglevel);
973 case ETHTOOL_SMSGLVL:
974 rc = ethtool_set_value_void(dev, useraddr,
975 dev->ethtool_ops->set_msglevel);
977 case ETHTOOL_NWAY_RST:
978 rc = ethtool_nway_reset(dev);
981 rc = ethtool_get_value(dev, useraddr, ethcmd,
982 dev->ethtool_ops->get_link);
984 case ETHTOOL_GEEPROM:
985 rc = ethtool_get_eeprom(dev, useraddr);
987 case ETHTOOL_SEEPROM:
988 rc = ethtool_set_eeprom(dev, useraddr);
990 case ETHTOOL_GCOALESCE:
991 rc = ethtool_get_coalesce(dev, useraddr);
993 case ETHTOOL_SCOALESCE:
994 rc = ethtool_set_coalesce(dev, useraddr);
996 case ETHTOOL_GRINGPARAM:
997 rc = ethtool_get_ringparam(dev, useraddr);
999 case ETHTOOL_SRINGPARAM:
1000 rc = ethtool_set_ringparam(dev, useraddr);
1002 case ETHTOOL_GPAUSEPARAM:
1003 rc = ethtool_get_pauseparam(dev, useraddr);
1005 case ETHTOOL_SPAUSEPARAM:
1006 rc = ethtool_set_pauseparam(dev, useraddr);
1008 case ETHTOOL_GRXCSUM:
1009 rc = ethtool_get_value(dev, useraddr, ethcmd,
1010 (dev->ethtool_ops->get_rx_csum ?
1011 dev->ethtool_ops->get_rx_csum :
1012 ethtool_op_get_rx_csum));
1014 case ETHTOOL_SRXCSUM:
1015 rc = ethtool_set_rx_csum(dev, useraddr);
1017 case ETHTOOL_GTXCSUM:
1018 rc = ethtool_get_value(dev, useraddr, ethcmd,
1019 (dev->ethtool_ops->get_tx_csum ?
1020 dev->ethtool_ops->get_tx_csum :
1021 ethtool_op_get_tx_csum));
1023 case ETHTOOL_STXCSUM:
1024 rc = ethtool_set_tx_csum(dev, useraddr);
1027 rc = ethtool_get_value(dev, useraddr, ethcmd,
1028 (dev->ethtool_ops->get_sg ?
1029 dev->ethtool_ops->get_sg :
1030 ethtool_op_get_sg));
1033 rc = ethtool_set_sg(dev, useraddr);
1036 rc = ethtool_get_value(dev, useraddr, ethcmd,
1037 (dev->ethtool_ops->get_tso ?
1038 dev->ethtool_ops->get_tso :
1039 ethtool_op_get_tso));
1042 rc = ethtool_set_tso(dev, useraddr);
1045 rc = ethtool_self_test(dev, useraddr);
1047 case ETHTOOL_GSTRINGS:
1048 rc = ethtool_get_strings(dev, useraddr);
1050 case ETHTOOL_PHYS_ID:
1051 rc = ethtool_phys_id(dev, useraddr);
1053 case ETHTOOL_GSTATS:
1054 rc = ethtool_get_stats(dev, useraddr);
1056 case ETHTOOL_GPERMADDR:
1057 rc = ethtool_get_perm_addr(dev, useraddr);
1060 rc = ethtool_get_value(dev, useraddr, ethcmd,
1061 (dev->ethtool_ops->get_ufo ?
1062 dev->ethtool_ops->get_ufo :
1063 ethtool_op_get_ufo));
1066 rc = ethtool_set_ufo(dev, useraddr);
1069 rc = ethtool_get_gso(dev, useraddr);
1072 rc = ethtool_set_gso(dev, useraddr);
1074 case ETHTOOL_GFLAGS:
1075 rc = ethtool_get_value(dev, useraddr, ethcmd,
1076 (dev->ethtool_ops->get_flags ?
1077 dev->ethtool_ops->get_flags :
1078 ethtool_op_get_flags));
1080 case ETHTOOL_SFLAGS:
1081 rc = ethtool_set_value(dev, useraddr,
1082 dev->ethtool_ops->set_flags);
1084 case ETHTOOL_GPFLAGS:
1085 rc = ethtool_get_value(dev, useraddr, ethcmd,
1086 dev->ethtool_ops->get_priv_flags);
1088 case ETHTOOL_SPFLAGS:
1089 rc = ethtool_set_value(dev, useraddr,
1090 dev->ethtool_ops->set_priv_flags);
1093 case ETHTOOL_GRXRINGS:
1094 case ETHTOOL_GRXCLSRLCNT:
1095 case ETHTOOL_GRXCLSRULE:
1096 case ETHTOOL_GRXCLSRLALL:
1097 rc = ethtool_get_rxnfc(dev, useraddr);
1100 case ETHTOOL_SRXCLSRLDEL:
1101 case ETHTOOL_SRXCLSRLINS:
1102 rc = ethtool_set_rxnfc(dev, useraddr);
1105 rc = ethtool_get_gro(dev, useraddr);
1108 rc = ethtool_set_gro(dev, useraddr);
1110 case ETHTOOL_FLASHDEV:
1111 rc = ethtool_flash_device(dev, useraddr);
1114 rc = ethtool_reset(dev, useraddr);
1120 if (dev->ethtool_ops->complete)
1121 dev->ethtool_ops->complete(dev);
1123 if (old_features != dev->features)
1124 netdev_features_change(dev);
1129 EXPORT_SYMBOL(ethtool_op_get_link);
1130 EXPORT_SYMBOL(ethtool_op_get_sg);
1131 EXPORT_SYMBOL(ethtool_op_get_tso);
1132 EXPORT_SYMBOL(ethtool_op_set_sg);
1133 EXPORT_SYMBOL(ethtool_op_set_tso);
1134 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
1135 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
1136 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
1137 EXPORT_SYMBOL(ethtool_op_set_ufo);
1138 EXPORT_SYMBOL(ethtool_op_get_ufo);
1139 EXPORT_SYMBOL(ethtool_op_set_flags);
1140 EXPORT_SYMBOL(ethtool_op_get_flags);