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 /* code path for obsolete hooks */
204 if (ops->self_test_count)
205 info.testinfo_len = ops->self_test_count(dev);
206 if (ops->get_stats_count)
207 info.n_stats = ops->get_stats_count(dev);
209 if (ops->get_regs_len)
210 info.regdump_len = ops->get_regs_len(dev);
211 if (ops->get_eeprom_len)
212 info.eedump_len = ops->get_eeprom_len(dev);
214 if (copy_to_user(useraddr, &info, sizeof(info)))
219 static int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr)
221 struct ethtool_rxnfc cmd;
223 if (!dev->ethtool_ops->set_rxnfc)
226 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
229 return dev->ethtool_ops->set_rxnfc(dev, &cmd);
232 static int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr)
234 struct ethtool_rxnfc info;
235 const struct ethtool_ops *ops = dev->ethtool_ops;
237 void *rule_buf = NULL;
242 if (copy_from_user(&info, useraddr, sizeof(info)))
245 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
246 if (info.rule_cnt > 0) {
247 rule_buf = kmalloc(info.rule_cnt * sizeof(u32),
254 ret = ops->get_rxnfc(dev, &info, rule_buf);
259 if (copy_to_user(useraddr, &info, sizeof(info)))
263 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
264 if (copy_to_user(useraddr, rule_buf,
265 info.rule_cnt * sizeof(u32)))
276 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
278 struct ethtool_regs regs;
279 const struct ethtool_ops *ops = dev->ethtool_ops;
283 if (!ops->get_regs || !ops->get_regs_len)
286 if (copy_from_user(®s, useraddr, sizeof(regs)))
289 reglen = ops->get_regs_len(dev);
290 if (regs.len > reglen)
293 regbuf = kmalloc(reglen, GFP_USER);
297 ops->get_regs(dev, ®s, regbuf);
300 if (copy_to_user(useraddr, ®s, sizeof(regs)))
302 useraddr += offsetof(struct ethtool_regs, data);
303 if (copy_to_user(useraddr, regbuf, regs.len))
312 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
314 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
316 if (!dev->ethtool_ops->get_wol)
319 dev->ethtool_ops->get_wol(dev, &wol);
321 if (copy_to_user(useraddr, &wol, sizeof(wol)))
326 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
328 struct ethtool_wolinfo wol;
330 if (!dev->ethtool_ops->set_wol)
333 if (copy_from_user(&wol, useraddr, sizeof(wol)))
336 return dev->ethtool_ops->set_wol(dev, &wol);
339 static int ethtool_nway_reset(struct net_device *dev)
341 if (!dev->ethtool_ops->nway_reset)
344 return dev->ethtool_ops->nway_reset(dev);
347 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
349 struct ethtool_eeprom eeprom;
350 const struct ethtool_ops *ops = dev->ethtool_ops;
351 void __user *userbuf = useraddr + sizeof(eeprom);
356 if (!ops->get_eeprom || !ops->get_eeprom_len)
359 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
362 /* Check for wrap and zero */
363 if (eeprom.offset + eeprom.len <= eeprom.offset)
366 /* Check for exceeding total eeprom len */
367 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
370 data = kmalloc(PAGE_SIZE, GFP_USER);
374 bytes_remaining = eeprom.len;
375 while (bytes_remaining > 0) {
376 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
378 ret = ops->get_eeprom(dev, &eeprom, data);
381 if (copy_to_user(userbuf, data, eeprom.len)) {
385 userbuf += eeprom.len;
386 eeprom.offset += eeprom.len;
387 bytes_remaining -= eeprom.len;
390 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
391 eeprom.offset -= eeprom.len;
392 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
399 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
401 struct ethtool_eeprom eeprom;
402 const struct ethtool_ops *ops = dev->ethtool_ops;
403 void __user *userbuf = useraddr + sizeof(eeprom);
408 if (!ops->set_eeprom || !ops->get_eeprom_len)
411 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
414 /* Check for wrap and zero */
415 if (eeprom.offset + eeprom.len <= eeprom.offset)
418 /* Check for exceeding total eeprom len */
419 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
422 data = kmalloc(PAGE_SIZE, GFP_USER);
426 bytes_remaining = eeprom.len;
427 while (bytes_remaining > 0) {
428 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
430 if (copy_from_user(data, userbuf, eeprom.len)) {
434 ret = ops->set_eeprom(dev, &eeprom, data);
437 userbuf += eeprom.len;
438 eeprom.offset += eeprom.len;
439 bytes_remaining -= eeprom.len;
446 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
448 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
450 if (!dev->ethtool_ops->get_coalesce)
453 dev->ethtool_ops->get_coalesce(dev, &coalesce);
455 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
460 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
462 struct ethtool_coalesce coalesce;
464 if (!dev->ethtool_ops->set_coalesce)
467 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
470 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
473 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
475 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
477 if (!dev->ethtool_ops->get_ringparam)
480 dev->ethtool_ops->get_ringparam(dev, &ringparam);
482 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
487 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
489 struct ethtool_ringparam ringparam;
491 if (!dev->ethtool_ops->set_ringparam)
494 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
497 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
500 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
502 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
504 if (!dev->ethtool_ops->get_pauseparam)
507 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
509 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
514 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
516 struct ethtool_pauseparam pauseparam;
518 if (!dev->ethtool_ops->set_pauseparam)
521 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
524 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
527 static int __ethtool_set_sg(struct net_device *dev, u32 data)
531 if (!data && dev->ethtool_ops->set_tso) {
532 err = dev->ethtool_ops->set_tso(dev, 0);
537 if (!data && dev->ethtool_ops->set_ufo) {
538 err = dev->ethtool_ops->set_ufo(dev, 0);
542 return dev->ethtool_ops->set_sg(dev, data);
545 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
547 struct ethtool_value edata;
550 if (!dev->ethtool_ops->set_tx_csum)
553 if (copy_from_user(&edata, useraddr, sizeof(edata)))
556 if (!edata.data && dev->ethtool_ops->set_sg) {
557 err = __ethtool_set_sg(dev, 0);
562 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
565 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
567 struct ethtool_value edata;
569 if (!dev->ethtool_ops->set_rx_csum)
572 if (copy_from_user(&edata, useraddr, sizeof(edata)))
575 if (!edata.data && dev->ethtool_ops->set_sg)
576 dev->features &= ~NETIF_F_GRO;
578 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
581 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
583 struct ethtool_value edata;
585 if (!dev->ethtool_ops->set_sg)
588 if (copy_from_user(&edata, useraddr, sizeof(edata)))
592 !(dev->features & NETIF_F_ALL_CSUM))
595 return __ethtool_set_sg(dev, edata.data);
598 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
600 struct ethtool_value edata;
602 if (!dev->ethtool_ops->set_tso)
605 if (copy_from_user(&edata, useraddr, sizeof(edata)))
608 if (edata.data && !(dev->features & NETIF_F_SG))
611 return dev->ethtool_ops->set_tso(dev, edata.data);
614 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
616 struct ethtool_value edata;
618 if (!dev->ethtool_ops->set_ufo)
620 if (copy_from_user(&edata, useraddr, sizeof(edata)))
622 if (edata.data && !(dev->features & NETIF_F_SG))
624 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
626 return dev->ethtool_ops->set_ufo(dev, edata.data);
629 static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
631 struct ethtool_value edata = { ETHTOOL_GGSO };
633 edata.data = dev->features & NETIF_F_GSO;
634 if (copy_to_user(useraddr, &edata, sizeof(edata)))
639 static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
641 struct ethtool_value edata;
643 if (copy_from_user(&edata, useraddr, sizeof(edata)))
646 dev->features |= NETIF_F_GSO;
648 dev->features &= ~NETIF_F_GSO;
652 static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
654 struct ethtool_value edata = { ETHTOOL_GGRO };
656 edata.data = dev->features & NETIF_F_GRO;
657 if (copy_to_user(useraddr, &edata, sizeof(edata)))
662 static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
664 struct ethtool_value edata;
666 if (copy_from_user(&edata, useraddr, sizeof(edata)))
670 if (!dev->ethtool_ops->get_rx_csum ||
671 !dev->ethtool_ops->get_rx_csum(dev))
673 dev->features |= NETIF_F_GRO;
675 dev->features &= ~NETIF_F_GRO;
680 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
682 struct ethtool_test test;
683 const struct ethtool_ops *ops = dev->ethtool_ops;
689 if (!ops->get_sset_count && !ops->self_test_count)
692 if (ops->get_sset_count)
693 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
695 /* code path for obsolete hook */
696 test_len = ops->self_test_count(dev);
699 WARN_ON(test_len == 0);
701 if (copy_from_user(&test, useraddr, sizeof(test)))
705 data = kmalloc(test_len * sizeof(u64), GFP_USER);
709 ops->self_test(dev, &test, data);
712 if (copy_to_user(useraddr, &test, sizeof(test)))
714 useraddr += sizeof(test);
715 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
724 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
726 struct ethtool_gstrings gstrings;
727 const struct ethtool_ops *ops = dev->ethtool_ops;
731 if (!ops->get_strings)
734 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
737 if (ops->get_sset_count) {
738 ret = ops->get_sset_count(dev, gstrings.string_set);
744 /* code path for obsolete hooks */
746 switch (gstrings.string_set) {
748 if (!ops->self_test_count)
750 gstrings.len = ops->self_test_count(dev);
753 if (!ops->get_stats_count)
755 gstrings.len = ops->get_stats_count(dev);
762 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
766 ops->get_strings(dev, gstrings.string_set, data);
769 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
771 useraddr += sizeof(gstrings);
772 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
781 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
783 struct ethtool_value id;
785 if (!dev->ethtool_ops->phys_id)
788 if (copy_from_user(&id, useraddr, sizeof(id)))
791 return dev->ethtool_ops->phys_id(dev, id.data);
794 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
796 struct ethtool_stats stats;
797 const struct ethtool_ops *ops = dev->ethtool_ops;
801 if (!ops->get_ethtool_stats)
803 if (!ops->get_sset_count && !ops->get_stats_count)
806 if (ops->get_sset_count)
807 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
809 /* code path for obsolete hook */
810 n_stats = ops->get_stats_count(dev);
813 WARN_ON(n_stats == 0);
815 if (copy_from_user(&stats, useraddr, sizeof(stats)))
818 stats.n_stats = n_stats;
819 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
823 ops->get_ethtool_stats(dev, &stats, data);
826 if (copy_to_user(useraddr, &stats, sizeof(stats)))
828 useraddr += sizeof(stats);
829 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
838 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
840 struct ethtool_perm_addr epaddr;
842 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
845 if (epaddr.size < dev->addr_len)
847 epaddr.size = dev->addr_len;
849 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
851 useraddr += sizeof(epaddr);
852 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
857 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
858 u32 cmd, u32 (*actor)(struct net_device *))
860 struct ethtool_value edata = { cmd };
865 edata.data = actor(dev);
867 if (copy_to_user(useraddr, &edata, sizeof(edata)))
872 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
873 void (*actor)(struct net_device *, u32))
875 struct ethtool_value edata;
880 if (copy_from_user(&edata, useraddr, sizeof(edata)))
883 actor(dev, edata.data);
887 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
888 int (*actor)(struct net_device *, u32))
890 struct ethtool_value edata;
895 if (copy_from_user(&edata, useraddr, sizeof(edata)))
898 return actor(dev, edata.data);
901 /* The main entry point in this file. Called from net/core/dev.c */
903 int dev_ethtool(struct net *net, struct ifreq *ifr)
905 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
906 void __user *useraddr = ifr->ifr_data;
909 unsigned long old_features;
911 if (!dev || !netif_device_present(dev))
914 if (!dev->ethtool_ops)
917 if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
920 /* Allow some commands to be done by anyone */
922 case ETHTOOL_GDRVINFO:
923 case ETHTOOL_GMSGLVL:
924 case ETHTOOL_GCOALESCE:
925 case ETHTOOL_GRINGPARAM:
926 case ETHTOOL_GPAUSEPARAM:
927 case ETHTOOL_GRXCSUM:
928 case ETHTOOL_GTXCSUM:
930 case ETHTOOL_GSTRINGS:
932 case ETHTOOL_GPERMADDR:
936 case ETHTOOL_GPFLAGS:
938 case ETHTOOL_GRXRINGS:
939 case ETHTOOL_GRXCLSRLCNT:
940 case ETHTOOL_GRXCLSRULE:
941 case ETHTOOL_GRXCLSRLALL:
944 if (!capable(CAP_NET_ADMIN))
948 if (dev->ethtool_ops->begin)
949 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
952 old_features = dev->features;
956 rc = ethtool_get_settings(dev, useraddr);
959 rc = ethtool_set_settings(dev, useraddr);
961 case ETHTOOL_GDRVINFO:
962 rc = ethtool_get_drvinfo(dev, useraddr);
965 rc = ethtool_get_regs(dev, useraddr);
968 rc = ethtool_get_wol(dev, useraddr);
971 rc = ethtool_set_wol(dev, useraddr);
973 case ETHTOOL_GMSGLVL:
974 rc = ethtool_get_value(dev, useraddr, ethcmd,
975 dev->ethtool_ops->get_msglevel);
977 case ETHTOOL_SMSGLVL:
978 rc = ethtool_set_value_void(dev, useraddr,
979 dev->ethtool_ops->set_msglevel);
981 case ETHTOOL_NWAY_RST:
982 rc = ethtool_nway_reset(dev);
985 rc = ethtool_get_value(dev, useraddr, ethcmd,
986 dev->ethtool_ops->get_link);
988 case ETHTOOL_GEEPROM:
989 rc = ethtool_get_eeprom(dev, useraddr);
991 case ETHTOOL_SEEPROM:
992 rc = ethtool_set_eeprom(dev, useraddr);
994 case ETHTOOL_GCOALESCE:
995 rc = ethtool_get_coalesce(dev, useraddr);
997 case ETHTOOL_SCOALESCE:
998 rc = ethtool_set_coalesce(dev, useraddr);
1000 case ETHTOOL_GRINGPARAM:
1001 rc = ethtool_get_ringparam(dev, useraddr);
1003 case ETHTOOL_SRINGPARAM:
1004 rc = ethtool_set_ringparam(dev, useraddr);
1006 case ETHTOOL_GPAUSEPARAM:
1007 rc = ethtool_get_pauseparam(dev, useraddr);
1009 case ETHTOOL_SPAUSEPARAM:
1010 rc = ethtool_set_pauseparam(dev, useraddr);
1012 case ETHTOOL_GRXCSUM:
1013 rc = ethtool_get_value(dev, useraddr, ethcmd,
1014 (dev->ethtool_ops->get_rx_csum ?
1015 dev->ethtool_ops->get_rx_csum :
1016 ethtool_op_get_rx_csum));
1018 case ETHTOOL_SRXCSUM:
1019 rc = ethtool_set_rx_csum(dev, useraddr);
1021 case ETHTOOL_GTXCSUM:
1022 rc = ethtool_get_value(dev, useraddr, ethcmd,
1023 (dev->ethtool_ops->get_tx_csum ?
1024 dev->ethtool_ops->get_tx_csum :
1025 ethtool_op_get_tx_csum));
1027 case ETHTOOL_STXCSUM:
1028 rc = ethtool_set_tx_csum(dev, useraddr);
1031 rc = ethtool_get_value(dev, useraddr, ethcmd,
1032 (dev->ethtool_ops->get_sg ?
1033 dev->ethtool_ops->get_sg :
1034 ethtool_op_get_sg));
1037 rc = ethtool_set_sg(dev, useraddr);
1040 rc = ethtool_get_value(dev, useraddr, ethcmd,
1041 (dev->ethtool_ops->get_tso ?
1042 dev->ethtool_ops->get_tso :
1043 ethtool_op_get_tso));
1046 rc = ethtool_set_tso(dev, useraddr);
1049 rc = ethtool_self_test(dev, useraddr);
1051 case ETHTOOL_GSTRINGS:
1052 rc = ethtool_get_strings(dev, useraddr);
1054 case ETHTOOL_PHYS_ID:
1055 rc = ethtool_phys_id(dev, useraddr);
1057 case ETHTOOL_GSTATS:
1058 rc = ethtool_get_stats(dev, useraddr);
1060 case ETHTOOL_GPERMADDR:
1061 rc = ethtool_get_perm_addr(dev, useraddr);
1064 rc = ethtool_get_value(dev, useraddr, ethcmd,
1065 (dev->ethtool_ops->get_ufo ?
1066 dev->ethtool_ops->get_ufo :
1067 ethtool_op_get_ufo));
1070 rc = ethtool_set_ufo(dev, useraddr);
1073 rc = ethtool_get_gso(dev, useraddr);
1076 rc = ethtool_set_gso(dev, useraddr);
1078 case ETHTOOL_GFLAGS:
1079 rc = ethtool_get_value(dev, useraddr, ethcmd,
1080 (dev->ethtool_ops->get_flags ?
1081 dev->ethtool_ops->get_flags :
1082 ethtool_op_get_flags));
1084 case ETHTOOL_SFLAGS:
1085 rc = ethtool_set_value(dev, useraddr,
1086 dev->ethtool_ops->set_flags);
1088 case ETHTOOL_GPFLAGS:
1089 rc = ethtool_get_value(dev, useraddr, ethcmd,
1090 dev->ethtool_ops->get_priv_flags);
1092 case ETHTOOL_SPFLAGS:
1093 rc = ethtool_set_value(dev, useraddr,
1094 dev->ethtool_ops->set_priv_flags);
1097 case ETHTOOL_GRXRINGS:
1098 case ETHTOOL_GRXCLSRLCNT:
1099 case ETHTOOL_GRXCLSRULE:
1100 case ETHTOOL_GRXCLSRLALL:
1101 rc = ethtool_get_rxnfc(dev, useraddr);
1104 case ETHTOOL_SRXCLSRLDEL:
1105 case ETHTOOL_SRXCLSRLINS:
1106 rc = ethtool_set_rxnfc(dev, useraddr);
1109 rc = ethtool_get_gro(dev, useraddr);
1112 rc = ethtool_set_gro(dev, useraddr);
1118 if (dev->ethtool_ops->complete)
1119 dev->ethtool_ops->complete(dev);
1121 if (old_features != dev->features)
1122 netdev_features_change(dev);
1127 EXPORT_SYMBOL(ethtool_op_get_link);
1128 EXPORT_SYMBOL(ethtool_op_get_sg);
1129 EXPORT_SYMBOL(ethtool_op_get_tso);
1130 EXPORT_SYMBOL(ethtool_op_set_sg);
1131 EXPORT_SYMBOL(ethtool_op_set_tso);
1132 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
1133 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
1134 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
1135 EXPORT_SYMBOL(ethtool_op_set_ufo);
1136 EXPORT_SYMBOL(ethtool_op_get_ufo);
1137 EXPORT_SYMBOL(ethtool_op_set_flags);
1138 EXPORT_SYMBOL(ethtool_op_get_flags);