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;
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_get_wol(struct net_device *dev, char __user *useraddr)
307 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
309 if (!dev->ethtool_ops->get_wol)
312 dev->ethtool_ops->get_wol(dev, &wol);
314 if (copy_to_user(useraddr, &wol, sizeof(wol)))
319 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
321 struct ethtool_wolinfo wol;
323 if (!dev->ethtool_ops->set_wol)
326 if (copy_from_user(&wol, useraddr, sizeof(wol)))
329 return dev->ethtool_ops->set_wol(dev, &wol);
332 static int ethtool_nway_reset(struct net_device *dev)
334 if (!dev->ethtool_ops->nway_reset)
337 return dev->ethtool_ops->nway_reset(dev);
340 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
342 struct ethtool_eeprom eeprom;
343 const struct ethtool_ops *ops = dev->ethtool_ops;
344 void __user *userbuf = useraddr + sizeof(eeprom);
349 if (!ops->get_eeprom || !ops->get_eeprom_len)
352 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
355 /* Check for wrap and zero */
356 if (eeprom.offset + eeprom.len <= eeprom.offset)
359 /* Check for exceeding total eeprom len */
360 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
363 data = kmalloc(PAGE_SIZE, GFP_USER);
367 bytes_remaining = eeprom.len;
368 while (bytes_remaining > 0) {
369 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
371 ret = ops->get_eeprom(dev, &eeprom, data);
374 if (copy_to_user(userbuf, data, eeprom.len)) {
378 userbuf += eeprom.len;
379 eeprom.offset += eeprom.len;
380 bytes_remaining -= eeprom.len;
383 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
384 eeprom.offset -= eeprom.len;
385 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
392 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
394 struct ethtool_eeprom eeprom;
395 const struct ethtool_ops *ops = dev->ethtool_ops;
396 void __user *userbuf = useraddr + sizeof(eeprom);
401 if (!ops->set_eeprom || !ops->get_eeprom_len)
404 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
407 /* Check for wrap and zero */
408 if (eeprom.offset + eeprom.len <= eeprom.offset)
411 /* Check for exceeding total eeprom len */
412 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
415 data = kmalloc(PAGE_SIZE, GFP_USER);
419 bytes_remaining = eeprom.len;
420 while (bytes_remaining > 0) {
421 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
423 if (copy_from_user(data, userbuf, eeprom.len)) {
427 ret = ops->set_eeprom(dev, &eeprom, data);
430 userbuf += eeprom.len;
431 eeprom.offset += eeprom.len;
432 bytes_remaining -= eeprom.len;
439 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
441 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
443 if (!dev->ethtool_ops->get_coalesce)
446 dev->ethtool_ops->get_coalesce(dev, &coalesce);
448 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
453 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
455 struct ethtool_coalesce coalesce;
457 if (!dev->ethtool_ops->set_coalesce)
460 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
463 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
466 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
468 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
470 if (!dev->ethtool_ops->get_ringparam)
473 dev->ethtool_ops->get_ringparam(dev, &ringparam);
475 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
480 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
482 struct ethtool_ringparam ringparam;
484 if (!dev->ethtool_ops->set_ringparam)
487 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
490 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
493 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
495 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
497 if (!dev->ethtool_ops->get_pauseparam)
500 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
502 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
507 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
509 struct ethtool_pauseparam pauseparam;
511 if (!dev->ethtool_ops->set_pauseparam)
514 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
517 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
520 static int __ethtool_set_sg(struct net_device *dev, u32 data)
524 if (!data && dev->ethtool_ops->set_tso) {
525 err = dev->ethtool_ops->set_tso(dev, 0);
530 if (!data && dev->ethtool_ops->set_ufo) {
531 err = dev->ethtool_ops->set_ufo(dev, 0);
535 return dev->ethtool_ops->set_sg(dev, data);
538 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
540 struct ethtool_value edata;
543 if (!dev->ethtool_ops->set_tx_csum)
546 if (copy_from_user(&edata, useraddr, sizeof(edata)))
549 if (!edata.data && dev->ethtool_ops->set_sg) {
550 err = __ethtool_set_sg(dev, 0);
555 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
558 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
560 struct ethtool_value edata;
562 if (!dev->ethtool_ops->set_rx_csum)
565 if (copy_from_user(&edata, useraddr, sizeof(edata)))
568 if (!edata.data && dev->ethtool_ops->set_sg)
569 dev->features &= ~NETIF_F_GRO;
571 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
574 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
576 struct ethtool_value edata;
578 if (!dev->ethtool_ops->set_sg)
581 if (copy_from_user(&edata, useraddr, sizeof(edata)))
585 !(dev->features & NETIF_F_ALL_CSUM))
588 return __ethtool_set_sg(dev, edata.data);
591 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
593 struct ethtool_value edata;
595 if (!dev->ethtool_ops->set_tso)
598 if (copy_from_user(&edata, useraddr, sizeof(edata)))
601 if (edata.data && !(dev->features & NETIF_F_SG))
604 return dev->ethtool_ops->set_tso(dev, edata.data);
607 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
609 struct ethtool_value edata;
611 if (!dev->ethtool_ops->set_ufo)
613 if (copy_from_user(&edata, useraddr, sizeof(edata)))
615 if (edata.data && !(dev->features & NETIF_F_SG))
617 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
619 return dev->ethtool_ops->set_ufo(dev, edata.data);
622 static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
624 struct ethtool_value edata = { ETHTOOL_GGSO };
626 edata.data = dev->features & NETIF_F_GSO;
627 if (copy_to_user(useraddr, &edata, sizeof(edata)))
632 static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
634 struct ethtool_value edata;
636 if (copy_from_user(&edata, useraddr, sizeof(edata)))
639 dev->features |= NETIF_F_GSO;
641 dev->features &= ~NETIF_F_GSO;
645 static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
647 struct ethtool_value edata = { ETHTOOL_GGRO };
649 edata.data = dev->features & NETIF_F_GRO;
650 if (copy_to_user(useraddr, &edata, sizeof(edata)))
655 static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
657 struct ethtool_value edata;
659 if (copy_from_user(&edata, useraddr, sizeof(edata)))
663 if (!dev->ethtool_ops->get_rx_csum ||
664 !dev->ethtool_ops->get_rx_csum(dev))
666 dev->features |= NETIF_F_GRO;
668 dev->features &= ~NETIF_F_GRO;
673 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
675 struct ethtool_test test;
676 const struct ethtool_ops *ops = dev->ethtool_ops;
680 if (!ops->self_test || !ops->get_sset_count)
683 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
686 WARN_ON(test_len == 0);
688 if (copy_from_user(&test, useraddr, sizeof(test)))
692 data = kmalloc(test_len * sizeof(u64), GFP_USER);
696 ops->self_test(dev, &test, data);
699 if (copy_to_user(useraddr, &test, sizeof(test)))
701 useraddr += sizeof(test);
702 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
711 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
713 struct ethtool_gstrings gstrings;
714 const struct ethtool_ops *ops = dev->ethtool_ops;
718 if (!ops->get_strings || !ops->get_sset_count)
721 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
724 ret = ops->get_sset_count(dev, gstrings.string_set);
730 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
734 ops->get_strings(dev, gstrings.string_set, data);
737 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
739 useraddr += sizeof(gstrings);
740 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
749 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
751 struct ethtool_value id;
753 if (!dev->ethtool_ops->phys_id)
756 if (copy_from_user(&id, useraddr, sizeof(id)))
759 return dev->ethtool_ops->phys_id(dev, id.data);
762 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
764 struct ethtool_stats stats;
765 const struct ethtool_ops *ops = dev->ethtool_ops;
769 if (!ops->get_ethtool_stats || !ops->get_sset_count)
772 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
775 WARN_ON(n_stats == 0);
777 if (copy_from_user(&stats, useraddr, sizeof(stats)))
780 stats.n_stats = n_stats;
781 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
785 ops->get_ethtool_stats(dev, &stats, data);
788 if (copy_to_user(useraddr, &stats, sizeof(stats)))
790 useraddr += sizeof(stats);
791 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
800 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
802 struct ethtool_perm_addr epaddr;
804 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
807 if (epaddr.size < dev->addr_len)
809 epaddr.size = dev->addr_len;
811 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
813 useraddr += sizeof(epaddr);
814 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
819 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
820 u32 cmd, u32 (*actor)(struct net_device *))
822 struct ethtool_value edata = { cmd };
827 edata.data = actor(dev);
829 if (copy_to_user(useraddr, &edata, sizeof(edata)))
834 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
835 void (*actor)(struct net_device *, u32))
837 struct ethtool_value edata;
842 if (copy_from_user(&edata, useraddr, sizeof(edata)))
845 actor(dev, edata.data);
849 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
850 int (*actor)(struct net_device *, u32))
852 struct ethtool_value edata;
857 if (copy_from_user(&edata, useraddr, sizeof(edata)))
860 return actor(dev, edata.data);
863 static int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
865 struct ethtool_flash efl;
867 if (copy_from_user(&efl, useraddr, sizeof(efl)))
870 if (!dev->ethtool_ops->flash_device)
873 return dev->ethtool_ops->flash_device(dev, &efl);
876 /* The main entry point in this file. Called from net/core/dev.c */
878 int dev_ethtool(struct net *net, struct ifreq *ifr)
880 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
881 void __user *useraddr = ifr->ifr_data;
884 unsigned long old_features;
886 if (!dev || !netif_device_present(dev))
889 if (!dev->ethtool_ops)
892 if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
895 /* Allow some commands to be done by anyone */
897 case ETHTOOL_GDRVINFO:
898 case ETHTOOL_GMSGLVL:
899 case ETHTOOL_GCOALESCE:
900 case ETHTOOL_GRINGPARAM:
901 case ETHTOOL_GPAUSEPARAM:
902 case ETHTOOL_GRXCSUM:
903 case ETHTOOL_GTXCSUM:
905 case ETHTOOL_GSTRINGS:
907 case ETHTOOL_GPERMADDR:
911 case ETHTOOL_GPFLAGS:
913 case ETHTOOL_GRXRINGS:
914 case ETHTOOL_GRXCLSRLCNT:
915 case ETHTOOL_GRXCLSRULE:
916 case ETHTOOL_GRXCLSRLALL:
919 if (!capable(CAP_NET_ADMIN))
923 if (dev->ethtool_ops->begin)
924 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
927 old_features = dev->features;
931 rc = ethtool_get_settings(dev, useraddr);
934 rc = ethtool_set_settings(dev, useraddr);
936 case ETHTOOL_GDRVINFO:
937 rc = ethtool_get_drvinfo(dev, useraddr);
940 rc = ethtool_get_regs(dev, useraddr);
943 rc = ethtool_get_wol(dev, useraddr);
946 rc = ethtool_set_wol(dev, useraddr);
948 case ETHTOOL_GMSGLVL:
949 rc = ethtool_get_value(dev, useraddr, ethcmd,
950 dev->ethtool_ops->get_msglevel);
952 case ETHTOOL_SMSGLVL:
953 rc = ethtool_set_value_void(dev, useraddr,
954 dev->ethtool_ops->set_msglevel);
956 case ETHTOOL_NWAY_RST:
957 rc = ethtool_nway_reset(dev);
960 rc = ethtool_get_value(dev, useraddr, ethcmd,
961 dev->ethtool_ops->get_link);
963 case ETHTOOL_GEEPROM:
964 rc = ethtool_get_eeprom(dev, useraddr);
966 case ETHTOOL_SEEPROM:
967 rc = ethtool_set_eeprom(dev, useraddr);
969 case ETHTOOL_GCOALESCE:
970 rc = ethtool_get_coalesce(dev, useraddr);
972 case ETHTOOL_SCOALESCE:
973 rc = ethtool_set_coalesce(dev, useraddr);
975 case ETHTOOL_GRINGPARAM:
976 rc = ethtool_get_ringparam(dev, useraddr);
978 case ETHTOOL_SRINGPARAM:
979 rc = ethtool_set_ringparam(dev, useraddr);
981 case ETHTOOL_GPAUSEPARAM:
982 rc = ethtool_get_pauseparam(dev, useraddr);
984 case ETHTOOL_SPAUSEPARAM:
985 rc = ethtool_set_pauseparam(dev, useraddr);
987 case ETHTOOL_GRXCSUM:
988 rc = ethtool_get_value(dev, useraddr, ethcmd,
989 (dev->ethtool_ops->get_rx_csum ?
990 dev->ethtool_ops->get_rx_csum :
991 ethtool_op_get_rx_csum));
993 case ETHTOOL_SRXCSUM:
994 rc = ethtool_set_rx_csum(dev, useraddr);
996 case ETHTOOL_GTXCSUM:
997 rc = ethtool_get_value(dev, useraddr, ethcmd,
998 (dev->ethtool_ops->get_tx_csum ?
999 dev->ethtool_ops->get_tx_csum :
1000 ethtool_op_get_tx_csum));
1002 case ETHTOOL_STXCSUM:
1003 rc = ethtool_set_tx_csum(dev, useraddr);
1006 rc = ethtool_get_value(dev, useraddr, ethcmd,
1007 (dev->ethtool_ops->get_sg ?
1008 dev->ethtool_ops->get_sg :
1009 ethtool_op_get_sg));
1012 rc = ethtool_set_sg(dev, useraddr);
1015 rc = ethtool_get_value(dev, useraddr, ethcmd,
1016 (dev->ethtool_ops->get_tso ?
1017 dev->ethtool_ops->get_tso :
1018 ethtool_op_get_tso));
1021 rc = ethtool_set_tso(dev, useraddr);
1024 rc = ethtool_self_test(dev, useraddr);
1026 case ETHTOOL_GSTRINGS:
1027 rc = ethtool_get_strings(dev, useraddr);
1029 case ETHTOOL_PHYS_ID:
1030 rc = ethtool_phys_id(dev, useraddr);
1032 case ETHTOOL_GSTATS:
1033 rc = ethtool_get_stats(dev, useraddr);
1035 case ETHTOOL_GPERMADDR:
1036 rc = ethtool_get_perm_addr(dev, useraddr);
1039 rc = ethtool_get_value(dev, useraddr, ethcmd,
1040 (dev->ethtool_ops->get_ufo ?
1041 dev->ethtool_ops->get_ufo :
1042 ethtool_op_get_ufo));
1045 rc = ethtool_set_ufo(dev, useraddr);
1048 rc = ethtool_get_gso(dev, useraddr);
1051 rc = ethtool_set_gso(dev, useraddr);
1053 case ETHTOOL_GFLAGS:
1054 rc = ethtool_get_value(dev, useraddr, ethcmd,
1055 (dev->ethtool_ops->get_flags ?
1056 dev->ethtool_ops->get_flags :
1057 ethtool_op_get_flags));
1059 case ETHTOOL_SFLAGS:
1060 rc = ethtool_set_value(dev, useraddr,
1061 dev->ethtool_ops->set_flags);
1063 case ETHTOOL_GPFLAGS:
1064 rc = ethtool_get_value(dev, useraddr, ethcmd,
1065 dev->ethtool_ops->get_priv_flags);
1067 case ETHTOOL_SPFLAGS:
1068 rc = ethtool_set_value(dev, useraddr,
1069 dev->ethtool_ops->set_priv_flags);
1072 case ETHTOOL_GRXRINGS:
1073 case ETHTOOL_GRXCLSRLCNT:
1074 case ETHTOOL_GRXCLSRULE:
1075 case ETHTOOL_GRXCLSRLALL:
1076 rc = ethtool_get_rxnfc(dev, useraddr);
1079 case ETHTOOL_SRXCLSRLDEL:
1080 case ETHTOOL_SRXCLSRLINS:
1081 rc = ethtool_set_rxnfc(dev, useraddr);
1084 rc = ethtool_get_gro(dev, useraddr);
1087 rc = ethtool_set_gro(dev, useraddr);
1089 case ETHTOOL_FLASHDEV:
1090 rc = ethtool_flash_device(dev, useraddr);
1096 if (dev->ethtool_ops->complete)
1097 dev->ethtool_ops->complete(dev);
1099 if (old_features != dev->features)
1100 netdev_features_change(dev);
1105 EXPORT_SYMBOL(ethtool_op_get_link);
1106 EXPORT_SYMBOL(ethtool_op_get_sg);
1107 EXPORT_SYMBOL(ethtool_op_get_tso);
1108 EXPORT_SYMBOL(ethtool_op_set_sg);
1109 EXPORT_SYMBOL(ethtool_op_set_tso);
1110 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
1111 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
1112 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
1113 EXPORT_SYMBOL(ethtool_op_set_ufo);
1114 EXPORT_SYMBOL(ethtool_op_get_ufo);
1115 EXPORT_SYMBOL(ethtool_op_set_flags);
1116 EXPORT_SYMBOL(ethtool_op_get_flags);