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_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)))
270 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
272 struct ethtool_regs regs;
273 const struct ethtool_ops *ops = dev->ethtool_ops;
277 if (!ops->get_regs || !ops->get_regs_len)
280 if (copy_from_user(®s, useraddr, sizeof(regs)))
283 reglen = ops->get_regs_len(dev);
284 if (regs.len > reglen)
287 regbuf = kmalloc(reglen, GFP_USER);
291 ops->get_regs(dev, ®s, regbuf);
294 if (copy_to_user(useraddr, ®s, sizeof(regs)))
296 useraddr += offsetof(struct ethtool_regs, data);
297 if (copy_to_user(useraddr, regbuf, regs.len))
306 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
308 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
310 if (!dev->ethtool_ops->get_wol)
313 dev->ethtool_ops->get_wol(dev, &wol);
315 if (copy_to_user(useraddr, &wol, sizeof(wol)))
320 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
322 struct ethtool_wolinfo wol;
324 if (!dev->ethtool_ops->set_wol)
327 if (copy_from_user(&wol, useraddr, sizeof(wol)))
330 return dev->ethtool_ops->set_wol(dev, &wol);
333 static int ethtool_nway_reset(struct net_device *dev)
335 if (!dev->ethtool_ops->nway_reset)
338 return dev->ethtool_ops->nway_reset(dev);
341 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
343 struct ethtool_eeprom eeprom;
344 const struct ethtool_ops *ops = dev->ethtool_ops;
345 void __user *userbuf = useraddr + sizeof(eeprom);
350 if (!ops->get_eeprom || !ops->get_eeprom_len)
353 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
356 /* Check for wrap and zero */
357 if (eeprom.offset + eeprom.len <= eeprom.offset)
360 /* Check for exceeding total eeprom len */
361 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
364 data = kmalloc(PAGE_SIZE, GFP_USER);
368 bytes_remaining = eeprom.len;
369 while (bytes_remaining > 0) {
370 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
372 ret = ops->get_eeprom(dev, &eeprom, data);
375 if (copy_to_user(userbuf, data, eeprom.len)) {
379 userbuf += eeprom.len;
380 eeprom.offset += eeprom.len;
381 bytes_remaining -= eeprom.len;
384 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
385 eeprom.offset -= eeprom.len;
386 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
393 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
395 struct ethtool_eeprom eeprom;
396 const struct ethtool_ops *ops = dev->ethtool_ops;
397 void __user *userbuf = useraddr + sizeof(eeprom);
402 if (!ops->set_eeprom || !ops->get_eeprom_len)
405 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
408 /* Check for wrap and zero */
409 if (eeprom.offset + eeprom.len <= eeprom.offset)
412 /* Check for exceeding total eeprom len */
413 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
416 data = kmalloc(PAGE_SIZE, GFP_USER);
420 bytes_remaining = eeprom.len;
421 while (bytes_remaining > 0) {
422 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
424 if (copy_from_user(data, userbuf, eeprom.len)) {
428 ret = ops->set_eeprom(dev, &eeprom, data);
431 userbuf += eeprom.len;
432 eeprom.offset += eeprom.len;
433 bytes_remaining -= eeprom.len;
440 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
442 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
444 if (!dev->ethtool_ops->get_coalesce)
447 dev->ethtool_ops->get_coalesce(dev, &coalesce);
449 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
454 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
456 struct ethtool_coalesce coalesce;
458 if (!dev->ethtool_ops->set_coalesce)
461 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
464 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
467 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
469 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
471 if (!dev->ethtool_ops->get_ringparam)
474 dev->ethtool_ops->get_ringparam(dev, &ringparam);
476 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
481 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
483 struct ethtool_ringparam ringparam;
485 if (!dev->ethtool_ops->set_ringparam)
488 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
491 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
494 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
496 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
498 if (!dev->ethtool_ops->get_pauseparam)
501 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
503 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
508 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
510 struct ethtool_pauseparam pauseparam;
512 if (!dev->ethtool_ops->set_pauseparam)
515 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
518 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
521 static int __ethtool_set_sg(struct net_device *dev, u32 data)
525 if (!data && dev->ethtool_ops->set_tso) {
526 err = dev->ethtool_ops->set_tso(dev, 0);
531 if (!data && dev->ethtool_ops->set_ufo) {
532 err = dev->ethtool_ops->set_ufo(dev, 0);
536 return dev->ethtool_ops->set_sg(dev, data);
539 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
541 struct ethtool_value edata;
544 if (!dev->ethtool_ops->set_tx_csum)
547 if (copy_from_user(&edata, useraddr, sizeof(edata)))
550 if (!edata.data && dev->ethtool_ops->set_sg) {
551 err = __ethtool_set_sg(dev, 0);
556 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
559 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
561 struct ethtool_value edata;
563 if (!dev->ethtool_ops->set_rx_csum)
566 if (copy_from_user(&edata, useraddr, sizeof(edata)))
569 if (!edata.data && dev->ethtool_ops->set_sg)
570 dev->features &= ~NETIF_F_GRO;
572 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
575 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
577 struct ethtool_value edata;
579 if (!dev->ethtool_ops->set_sg)
582 if (copy_from_user(&edata, useraddr, sizeof(edata)))
586 !(dev->features & NETIF_F_ALL_CSUM))
589 return __ethtool_set_sg(dev, edata.data);
592 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
594 struct ethtool_value edata;
596 if (!dev->ethtool_ops->set_tso)
599 if (copy_from_user(&edata, useraddr, sizeof(edata)))
602 if (edata.data && !(dev->features & NETIF_F_SG))
605 return dev->ethtool_ops->set_tso(dev, edata.data);
608 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
610 struct ethtool_value edata;
612 if (!dev->ethtool_ops->set_ufo)
614 if (copy_from_user(&edata, useraddr, sizeof(edata)))
616 if (edata.data && !(dev->features & NETIF_F_SG))
618 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
620 return dev->ethtool_ops->set_ufo(dev, edata.data);
623 static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
625 struct ethtool_value edata = { ETHTOOL_GGSO };
627 edata.data = dev->features & NETIF_F_GSO;
628 if (copy_to_user(useraddr, &edata, sizeof(edata)))
633 static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
635 struct ethtool_value edata;
637 if (copy_from_user(&edata, useraddr, sizeof(edata)))
640 dev->features |= NETIF_F_GSO;
642 dev->features &= ~NETIF_F_GSO;
646 static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
648 struct ethtool_value edata = { ETHTOOL_GGRO };
650 edata.data = dev->features & NETIF_F_GRO;
651 if (copy_to_user(useraddr, &edata, sizeof(edata)))
656 static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
658 struct ethtool_value edata;
660 if (copy_from_user(&edata, useraddr, sizeof(edata)))
664 if (!dev->ethtool_ops->get_rx_csum ||
665 !dev->ethtool_ops->get_rx_csum(dev))
667 dev->features |= NETIF_F_GRO;
669 dev->features &= ~NETIF_F_GRO;
674 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
676 struct ethtool_test test;
677 const struct ethtool_ops *ops = dev->ethtool_ops;
683 if (!ops->get_sset_count && !ops->self_test_count)
686 if (ops->get_sset_count)
687 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
689 /* code path for obsolete hook */
690 test_len = ops->self_test_count(dev);
693 WARN_ON(test_len == 0);
695 if (copy_from_user(&test, useraddr, sizeof(test)))
699 data = kmalloc(test_len * sizeof(u64), GFP_USER);
703 ops->self_test(dev, &test, data);
706 if (copy_to_user(useraddr, &test, sizeof(test)))
708 useraddr += sizeof(test);
709 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
718 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
720 struct ethtool_gstrings gstrings;
721 const struct ethtool_ops *ops = dev->ethtool_ops;
725 if (!ops->get_strings)
728 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
731 if (ops->get_sset_count) {
732 ret = ops->get_sset_count(dev, gstrings.string_set);
738 /* code path for obsolete hooks */
740 switch (gstrings.string_set) {
742 if (!ops->self_test_count)
744 gstrings.len = ops->self_test_count(dev);
747 if (!ops->get_stats_count)
749 gstrings.len = ops->get_stats_count(dev);
756 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
760 ops->get_strings(dev, gstrings.string_set, data);
763 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
765 useraddr += sizeof(gstrings);
766 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
775 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
777 struct ethtool_value id;
779 if (!dev->ethtool_ops->phys_id)
782 if (copy_from_user(&id, useraddr, sizeof(id)))
785 return dev->ethtool_ops->phys_id(dev, id.data);
788 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
790 struct ethtool_stats stats;
791 const struct ethtool_ops *ops = dev->ethtool_ops;
795 if (!ops->get_ethtool_stats)
797 if (!ops->get_sset_count && !ops->get_stats_count)
800 if (ops->get_sset_count)
801 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
803 /* code path for obsolete hook */
804 n_stats = ops->get_stats_count(dev);
807 WARN_ON(n_stats == 0);
809 if (copy_from_user(&stats, useraddr, sizeof(stats)))
812 stats.n_stats = n_stats;
813 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
817 ops->get_ethtool_stats(dev, &stats, data);
820 if (copy_to_user(useraddr, &stats, sizeof(stats)))
822 useraddr += sizeof(stats);
823 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
832 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
834 struct ethtool_perm_addr epaddr;
836 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
839 if (epaddr.size < dev->addr_len)
841 epaddr.size = dev->addr_len;
843 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
845 useraddr += sizeof(epaddr);
846 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
851 static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
852 u32 cmd, u32 (*actor)(struct net_device *))
854 struct ethtool_value edata = { cmd };
859 edata.data = actor(dev);
861 if (copy_to_user(useraddr, &edata, sizeof(edata)))
866 static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
867 void (*actor)(struct net_device *, u32))
869 struct ethtool_value edata;
874 if (copy_from_user(&edata, useraddr, sizeof(edata)))
877 actor(dev, edata.data);
881 static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
882 int (*actor)(struct net_device *, u32))
884 struct ethtool_value edata;
889 if (copy_from_user(&edata, useraddr, sizeof(edata)))
892 return actor(dev, edata.data);
895 /* The main entry point in this file. Called from net/core/dev.c */
897 int dev_ethtool(struct net *net, struct ifreq *ifr)
899 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
900 void __user *useraddr = ifr->ifr_data;
903 unsigned long old_features;
905 if (!dev || !netif_device_present(dev))
908 if (!dev->ethtool_ops)
911 if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
914 /* Allow some commands to be done by anyone */
916 case ETHTOOL_GDRVINFO:
917 case ETHTOOL_GMSGLVL:
918 case ETHTOOL_GCOALESCE:
919 case ETHTOOL_GRINGPARAM:
920 case ETHTOOL_GPAUSEPARAM:
921 case ETHTOOL_GRXCSUM:
922 case ETHTOOL_GTXCSUM:
924 case ETHTOOL_GSTRINGS:
926 case ETHTOOL_GPERMADDR:
930 case ETHTOOL_GPFLAGS:
932 case ETHTOOL_GRXRINGS:
933 case ETHTOOL_GRXCLSRLCNT:
934 case ETHTOOL_GRXCLSRULE:
935 case ETHTOOL_GRXCLSRLALL:
938 if (!capable(CAP_NET_ADMIN))
942 if (dev->ethtool_ops->begin)
943 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
946 old_features = dev->features;
950 rc = ethtool_get_settings(dev, useraddr);
953 rc = ethtool_set_settings(dev, useraddr);
955 case ETHTOOL_GDRVINFO:
956 rc = ethtool_get_drvinfo(dev, useraddr);
959 rc = ethtool_get_regs(dev, useraddr);
962 rc = ethtool_get_wol(dev, useraddr);
965 rc = ethtool_set_wol(dev, useraddr);
967 case ETHTOOL_GMSGLVL:
968 rc = ethtool_get_value(dev, useraddr, ethcmd,
969 dev->ethtool_ops->get_msglevel);
971 case ETHTOOL_SMSGLVL:
972 rc = ethtool_set_value_void(dev, useraddr,
973 dev->ethtool_ops->set_msglevel);
975 case ETHTOOL_NWAY_RST:
976 rc = ethtool_nway_reset(dev);
979 rc = ethtool_get_value(dev, useraddr, ethcmd,
980 dev->ethtool_ops->get_link);
982 case ETHTOOL_GEEPROM:
983 rc = ethtool_get_eeprom(dev, useraddr);
985 case ETHTOOL_SEEPROM:
986 rc = ethtool_set_eeprom(dev, useraddr);
988 case ETHTOOL_GCOALESCE:
989 rc = ethtool_get_coalesce(dev, useraddr);
991 case ETHTOOL_SCOALESCE:
992 rc = ethtool_set_coalesce(dev, useraddr);
994 case ETHTOOL_GRINGPARAM:
995 rc = ethtool_get_ringparam(dev, useraddr);
997 case ETHTOOL_SRINGPARAM:
998 rc = ethtool_set_ringparam(dev, useraddr);
1000 case ETHTOOL_GPAUSEPARAM:
1001 rc = ethtool_get_pauseparam(dev, useraddr);
1003 case ETHTOOL_SPAUSEPARAM:
1004 rc = ethtool_set_pauseparam(dev, useraddr);
1006 case ETHTOOL_GRXCSUM:
1007 rc = ethtool_get_value(dev, useraddr, ethcmd,
1008 dev->ethtool_ops->get_rx_csum);
1010 case ETHTOOL_SRXCSUM:
1011 rc = ethtool_set_rx_csum(dev, useraddr);
1013 case ETHTOOL_GTXCSUM:
1014 rc = ethtool_get_value(dev, useraddr, ethcmd,
1015 (dev->ethtool_ops->get_tx_csum ?
1016 dev->ethtool_ops->get_tx_csum :
1017 ethtool_op_get_tx_csum));
1019 case ETHTOOL_STXCSUM:
1020 rc = ethtool_set_tx_csum(dev, useraddr);
1023 rc = ethtool_get_value(dev, useraddr, ethcmd,
1024 (dev->ethtool_ops->get_sg ?
1025 dev->ethtool_ops->get_sg :
1026 ethtool_op_get_sg));
1029 rc = ethtool_set_sg(dev, useraddr);
1032 rc = ethtool_get_value(dev, useraddr, ethcmd,
1033 (dev->ethtool_ops->get_tso ?
1034 dev->ethtool_ops->get_tso :
1035 ethtool_op_get_tso));
1038 rc = ethtool_set_tso(dev, useraddr);
1041 rc = ethtool_self_test(dev, useraddr);
1043 case ETHTOOL_GSTRINGS:
1044 rc = ethtool_get_strings(dev, useraddr);
1046 case ETHTOOL_PHYS_ID:
1047 rc = ethtool_phys_id(dev, useraddr);
1049 case ETHTOOL_GSTATS:
1050 rc = ethtool_get_stats(dev, useraddr);
1052 case ETHTOOL_GPERMADDR:
1053 rc = ethtool_get_perm_addr(dev, useraddr);
1056 rc = ethtool_get_value(dev, useraddr, ethcmd,
1057 (dev->ethtool_ops->get_ufo ?
1058 dev->ethtool_ops->get_ufo :
1059 ethtool_op_get_ufo));
1062 rc = ethtool_set_ufo(dev, useraddr);
1065 rc = ethtool_get_gso(dev, useraddr);
1068 rc = ethtool_set_gso(dev, useraddr);
1070 case ETHTOOL_GFLAGS:
1071 rc = ethtool_get_value(dev, useraddr, ethcmd,
1072 dev->ethtool_ops->get_flags);
1074 case ETHTOOL_SFLAGS:
1075 rc = ethtool_set_value(dev, useraddr,
1076 dev->ethtool_ops->set_flags);
1078 case ETHTOOL_GPFLAGS:
1079 rc = ethtool_get_value(dev, useraddr, ethcmd,
1080 dev->ethtool_ops->get_priv_flags);
1082 case ETHTOOL_SPFLAGS:
1083 rc = ethtool_set_value(dev, useraddr,
1084 dev->ethtool_ops->set_priv_flags);
1087 case ETHTOOL_GRXRINGS:
1088 case ETHTOOL_GRXCLSRLCNT:
1089 case ETHTOOL_GRXCLSRULE:
1090 case ETHTOOL_GRXCLSRLALL:
1091 rc = ethtool_get_rxnfc(dev, useraddr);
1094 case ETHTOOL_SRXCLSRLDEL:
1095 case ETHTOOL_SRXCLSRLINS:
1096 rc = ethtool_set_rxnfc(dev, useraddr);
1099 rc = ethtool_get_gro(dev, useraddr);
1102 rc = ethtool_set_gro(dev, useraddr);
1108 if (dev->ethtool_ops->complete)
1109 dev->ethtool_ops->complete(dev);
1111 if (old_features != dev->features)
1112 netdev_features_change(dev);
1117 EXPORT_SYMBOL(ethtool_op_get_link);
1118 EXPORT_SYMBOL(ethtool_op_get_sg);
1119 EXPORT_SYMBOL(ethtool_op_get_tso);
1120 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
1121 EXPORT_SYMBOL(ethtool_op_set_sg);
1122 EXPORT_SYMBOL(ethtool_op_set_tso);
1123 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
1124 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
1125 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
1126 EXPORT_SYMBOL(ethtool_op_set_ufo);
1127 EXPORT_SYMBOL(ethtool_op_get_ufo);
1128 EXPORT_SYMBOL(ethtool_op_set_flags);
1129 EXPORT_SYMBOL(ethtool_op_get_flags);