[PATCH] ARM: Lindent GCC helper functions
[linux-2.6/libata-dev.git] / net / core / ethtool.c
bloba3eeb88e1c81fabe1eea26499958723955b08615
1 /*
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. We fall back to calling do_ioctl()
7 * for drivers which haven't been converted to ethtool_ops yet.
9 * It's GPL, stupid.
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/errno.h>
15 #include <linux/ethtool.h>
16 #include <linux/netdevice.h>
17 #include <asm/uaccess.h>
19 /*
20 * Some useful ethtool_ops methods that're device independent.
21 * If we find that all drivers want to do the same thing here,
22 * we can turn these into dev_() function calls.
25 u32 ethtool_op_get_link(struct net_device *dev)
27 return netif_carrier_ok(dev) ? 1 : 0;
30 u32 ethtool_op_get_tx_csum(struct net_device *dev)
32 return (dev->features & (NETIF_F_IP_CSUM | NETIF_F_HW_CSUM)) != 0;
35 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
37 if (data)
38 dev->features |= NETIF_F_IP_CSUM;
39 else
40 dev->features &= ~NETIF_F_IP_CSUM;
42 return 0;
45 int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
47 if (data)
48 dev->features |= NETIF_F_HW_CSUM;
49 else
50 dev->features &= ~NETIF_F_HW_CSUM;
52 return 0;
54 u32 ethtool_op_get_sg(struct net_device *dev)
56 return (dev->features & NETIF_F_SG) != 0;
59 int ethtool_op_set_sg(struct net_device *dev, u32 data)
61 if (data)
62 dev->features |= NETIF_F_SG;
63 else
64 dev->features &= ~NETIF_F_SG;
66 return 0;
69 u32 ethtool_op_get_tso(struct net_device *dev)
71 return (dev->features & NETIF_F_TSO) != 0;
74 int ethtool_op_set_tso(struct net_device *dev, u32 data)
76 if (data)
77 dev->features |= NETIF_F_TSO;
78 else
79 dev->features &= ~NETIF_F_TSO;
81 return 0;
84 /* Handlers for each ethtool command */
86 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
88 struct ethtool_cmd cmd = { ETHTOOL_GSET };
89 int err;
91 if (!dev->ethtool_ops->get_settings)
92 return -EOPNOTSUPP;
94 err = dev->ethtool_ops->get_settings(dev, &cmd);
95 if (err < 0)
96 return err;
98 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
99 return -EFAULT;
100 return 0;
103 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
105 struct ethtool_cmd cmd;
107 if (!dev->ethtool_ops->set_settings)
108 return -EOPNOTSUPP;
110 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
111 return -EFAULT;
113 return dev->ethtool_ops->set_settings(dev, &cmd);
116 static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
118 struct ethtool_drvinfo info;
119 struct ethtool_ops *ops = dev->ethtool_ops;
121 if (!ops->get_drvinfo)
122 return -EOPNOTSUPP;
124 memset(&info, 0, sizeof(info));
125 info.cmd = ETHTOOL_GDRVINFO;
126 ops->get_drvinfo(dev, &info);
128 if (ops->self_test_count)
129 info.testinfo_len = ops->self_test_count(dev);
130 if (ops->get_stats_count)
131 info.n_stats = ops->get_stats_count(dev);
132 if (ops->get_regs_len)
133 info.regdump_len = ops->get_regs_len(dev);
134 if (ops->get_eeprom_len)
135 info.eedump_len = ops->get_eeprom_len(dev);
137 if (copy_to_user(useraddr, &info, sizeof(info)))
138 return -EFAULT;
139 return 0;
142 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
144 struct ethtool_regs regs;
145 struct ethtool_ops *ops = dev->ethtool_ops;
146 void *regbuf;
147 int reglen, ret;
149 if (!ops->get_regs || !ops->get_regs_len)
150 return -EOPNOTSUPP;
152 if (copy_from_user(&regs, useraddr, sizeof(regs)))
153 return -EFAULT;
155 reglen = ops->get_regs_len(dev);
156 if (regs.len > reglen)
157 regs.len = reglen;
159 regbuf = kmalloc(reglen, GFP_USER);
160 if (!regbuf)
161 return -ENOMEM;
163 ops->get_regs(dev, &regs, regbuf);
165 ret = -EFAULT;
166 if (copy_to_user(useraddr, &regs, sizeof(regs)))
167 goto out;
168 useraddr += offsetof(struct ethtool_regs, data);
169 if (copy_to_user(useraddr, regbuf, regs.len))
170 goto out;
171 ret = 0;
173 out:
174 kfree(regbuf);
175 return ret;
178 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
180 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
182 if (!dev->ethtool_ops->get_wol)
183 return -EOPNOTSUPP;
185 dev->ethtool_ops->get_wol(dev, &wol);
187 if (copy_to_user(useraddr, &wol, sizeof(wol)))
188 return -EFAULT;
189 return 0;
192 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
194 struct ethtool_wolinfo wol;
196 if (!dev->ethtool_ops->set_wol)
197 return -EOPNOTSUPP;
199 if (copy_from_user(&wol, useraddr, sizeof(wol)))
200 return -EFAULT;
202 return dev->ethtool_ops->set_wol(dev, &wol);
205 static int ethtool_get_msglevel(struct net_device *dev, char __user *useraddr)
207 struct ethtool_value edata = { ETHTOOL_GMSGLVL };
209 if (!dev->ethtool_ops->get_msglevel)
210 return -EOPNOTSUPP;
212 edata.data = dev->ethtool_ops->get_msglevel(dev);
214 if (copy_to_user(useraddr, &edata, sizeof(edata)))
215 return -EFAULT;
216 return 0;
219 static int ethtool_set_msglevel(struct net_device *dev, char __user *useraddr)
221 struct ethtool_value edata;
223 if (!dev->ethtool_ops->set_msglevel)
224 return -EOPNOTSUPP;
226 if (copy_from_user(&edata, useraddr, sizeof(edata)))
227 return -EFAULT;
229 dev->ethtool_ops->set_msglevel(dev, edata.data);
230 return 0;
233 static int ethtool_nway_reset(struct net_device *dev)
235 if (!dev->ethtool_ops->nway_reset)
236 return -EOPNOTSUPP;
238 return dev->ethtool_ops->nway_reset(dev);
241 static int ethtool_get_link(struct net_device *dev, void __user *useraddr)
243 struct ethtool_value edata = { ETHTOOL_GLINK };
245 if (!dev->ethtool_ops->get_link)
246 return -EOPNOTSUPP;
248 edata.data = dev->ethtool_ops->get_link(dev);
250 if (copy_to_user(useraddr, &edata, sizeof(edata)))
251 return -EFAULT;
252 return 0;
255 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
257 struct ethtool_eeprom eeprom;
258 struct ethtool_ops *ops = dev->ethtool_ops;
259 u8 *data;
260 int ret;
262 if (!ops->get_eeprom || !ops->get_eeprom_len)
263 return -EOPNOTSUPP;
265 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
266 return -EFAULT;
268 /* Check for wrap and zero */
269 if (eeprom.offset + eeprom.len <= eeprom.offset)
270 return -EINVAL;
272 /* Check for exceeding total eeprom len */
273 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
274 return -EINVAL;
276 data = kmalloc(eeprom.len, GFP_USER);
277 if (!data)
278 return -ENOMEM;
280 ret = -EFAULT;
281 if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
282 goto out;
284 ret = ops->get_eeprom(dev, &eeprom, data);
285 if (ret)
286 goto out;
288 ret = -EFAULT;
289 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
290 goto out;
291 if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
292 goto out;
293 ret = 0;
295 out:
296 kfree(data);
297 return ret;
300 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
302 struct ethtool_eeprom eeprom;
303 struct ethtool_ops *ops = dev->ethtool_ops;
304 u8 *data;
305 int ret;
307 if (!ops->set_eeprom || !ops->get_eeprom_len)
308 return -EOPNOTSUPP;
310 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
311 return -EFAULT;
313 /* Check for wrap and zero */
314 if (eeprom.offset + eeprom.len <= eeprom.offset)
315 return -EINVAL;
317 /* Check for exceeding total eeprom len */
318 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
319 return -EINVAL;
321 data = kmalloc(eeprom.len, GFP_USER);
322 if (!data)
323 return -ENOMEM;
325 ret = -EFAULT;
326 if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
327 goto out;
329 ret = ops->set_eeprom(dev, &eeprom, data);
330 if (ret)
331 goto out;
333 if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
334 ret = -EFAULT;
336 out:
337 kfree(data);
338 return ret;
341 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
343 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
345 if (!dev->ethtool_ops->get_coalesce)
346 return -EOPNOTSUPP;
348 dev->ethtool_ops->get_coalesce(dev, &coalesce);
350 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
351 return -EFAULT;
352 return 0;
355 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
357 struct ethtool_coalesce coalesce;
359 if (!dev->ethtool_ops->set_coalesce)
360 return -EOPNOTSUPP;
362 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
363 return -EFAULT;
365 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
368 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
370 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
372 if (!dev->ethtool_ops->get_ringparam)
373 return -EOPNOTSUPP;
375 dev->ethtool_ops->get_ringparam(dev, &ringparam);
377 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
378 return -EFAULT;
379 return 0;
382 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
384 struct ethtool_ringparam ringparam;
386 if (!dev->ethtool_ops->set_ringparam)
387 return -EOPNOTSUPP;
389 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
390 return -EFAULT;
392 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
395 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
397 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
399 if (!dev->ethtool_ops->get_pauseparam)
400 return -EOPNOTSUPP;
402 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
404 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
405 return -EFAULT;
406 return 0;
409 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
411 struct ethtool_pauseparam pauseparam;
413 if (!dev->ethtool_ops->get_pauseparam)
414 return -EOPNOTSUPP;
416 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
417 return -EFAULT;
419 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
422 static int ethtool_get_rx_csum(struct net_device *dev, char __user *useraddr)
424 struct ethtool_value edata = { ETHTOOL_GRXCSUM };
426 if (!dev->ethtool_ops->get_rx_csum)
427 return -EOPNOTSUPP;
429 edata.data = dev->ethtool_ops->get_rx_csum(dev);
431 if (copy_to_user(useraddr, &edata, sizeof(edata)))
432 return -EFAULT;
433 return 0;
436 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
438 struct ethtool_value edata;
440 if (!dev->ethtool_ops->set_rx_csum)
441 return -EOPNOTSUPP;
443 if (copy_from_user(&edata, useraddr, sizeof(edata)))
444 return -EFAULT;
446 dev->ethtool_ops->set_rx_csum(dev, edata.data);
447 return 0;
450 static int ethtool_get_tx_csum(struct net_device *dev, char __user *useraddr)
452 struct ethtool_value edata = { ETHTOOL_GTXCSUM };
454 if (!dev->ethtool_ops->get_tx_csum)
455 return -EOPNOTSUPP;
457 edata.data = dev->ethtool_ops->get_tx_csum(dev);
459 if (copy_to_user(useraddr, &edata, sizeof(edata)))
460 return -EFAULT;
461 return 0;
464 static int __ethtool_set_sg(struct net_device *dev, u32 data)
466 int err;
468 if (!data && dev->ethtool_ops->set_tso) {
469 err = dev->ethtool_ops->set_tso(dev, 0);
470 if (err)
471 return err;
474 return dev->ethtool_ops->set_sg(dev, data);
477 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
479 struct ethtool_value edata;
480 int err;
482 if (!dev->ethtool_ops->set_tx_csum)
483 return -EOPNOTSUPP;
485 if (copy_from_user(&edata, useraddr, sizeof(edata)))
486 return -EFAULT;
488 if (!edata.data && dev->ethtool_ops->set_sg) {
489 err = __ethtool_set_sg(dev, 0);
490 if (err)
491 return err;
494 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
497 static int ethtool_get_sg(struct net_device *dev, char __user *useraddr)
499 struct ethtool_value edata = { ETHTOOL_GSG };
501 if (!dev->ethtool_ops->get_sg)
502 return -EOPNOTSUPP;
504 edata.data = dev->ethtool_ops->get_sg(dev);
506 if (copy_to_user(useraddr, &edata, sizeof(edata)))
507 return -EFAULT;
508 return 0;
511 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
513 struct ethtool_value edata;
515 if (!dev->ethtool_ops->set_sg)
516 return -EOPNOTSUPP;
518 if (copy_from_user(&edata, useraddr, sizeof(edata)))
519 return -EFAULT;
521 if (edata.data &&
522 !(dev->features & (NETIF_F_IP_CSUM |
523 NETIF_F_NO_CSUM |
524 NETIF_F_HW_CSUM)))
525 return -EINVAL;
527 return __ethtool_set_sg(dev, edata.data);
530 static int ethtool_get_tso(struct net_device *dev, char __user *useraddr)
532 struct ethtool_value edata = { ETHTOOL_GTSO };
534 if (!dev->ethtool_ops->get_tso)
535 return -EOPNOTSUPP;
537 edata.data = dev->ethtool_ops->get_tso(dev);
539 if (copy_to_user(useraddr, &edata, sizeof(edata)))
540 return -EFAULT;
541 return 0;
544 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
546 struct ethtool_value edata;
548 if (!dev->ethtool_ops->set_tso)
549 return -EOPNOTSUPP;
551 if (copy_from_user(&edata, useraddr, sizeof(edata)))
552 return -EFAULT;
554 if (edata.data && !(dev->features & NETIF_F_SG))
555 return -EINVAL;
557 return dev->ethtool_ops->set_tso(dev, edata.data);
560 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
562 struct ethtool_test test;
563 struct ethtool_ops *ops = dev->ethtool_ops;
564 u64 *data;
565 int ret;
567 if (!ops->self_test || !ops->self_test_count)
568 return -EOPNOTSUPP;
570 if (copy_from_user(&test, useraddr, sizeof(test)))
571 return -EFAULT;
573 test.len = ops->self_test_count(dev);
574 data = kmalloc(test.len * sizeof(u64), GFP_USER);
575 if (!data)
576 return -ENOMEM;
578 ops->self_test(dev, &test, data);
580 ret = -EFAULT;
581 if (copy_to_user(useraddr, &test, sizeof(test)))
582 goto out;
583 useraddr += sizeof(test);
584 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
585 goto out;
586 ret = 0;
588 out:
589 kfree(data);
590 return ret;
593 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
595 struct ethtool_gstrings gstrings;
596 struct ethtool_ops *ops = dev->ethtool_ops;
597 u8 *data;
598 int ret;
600 if (!ops->get_strings)
601 return -EOPNOTSUPP;
603 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
604 return -EFAULT;
606 switch (gstrings.string_set) {
607 case ETH_SS_TEST:
608 if (!ops->self_test_count)
609 return -EOPNOTSUPP;
610 gstrings.len = ops->self_test_count(dev);
611 break;
612 case ETH_SS_STATS:
613 if (!ops->get_stats_count)
614 return -EOPNOTSUPP;
615 gstrings.len = ops->get_stats_count(dev);
616 break;
617 default:
618 return -EINVAL;
621 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
622 if (!data)
623 return -ENOMEM;
625 ops->get_strings(dev, gstrings.string_set, data);
627 ret = -EFAULT;
628 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
629 goto out;
630 useraddr += sizeof(gstrings);
631 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
632 goto out;
633 ret = 0;
635 out:
636 kfree(data);
637 return ret;
640 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
642 struct ethtool_value id;
644 if (!dev->ethtool_ops->phys_id)
645 return -EOPNOTSUPP;
647 if (copy_from_user(&id, useraddr, sizeof(id)))
648 return -EFAULT;
650 return dev->ethtool_ops->phys_id(dev, id.data);
653 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
655 struct ethtool_stats stats;
656 struct ethtool_ops *ops = dev->ethtool_ops;
657 u64 *data;
658 int ret;
660 if (!ops->get_ethtool_stats || !ops->get_stats_count)
661 return -EOPNOTSUPP;
663 if (copy_from_user(&stats, useraddr, sizeof(stats)))
664 return -EFAULT;
666 stats.n_stats = ops->get_stats_count(dev);
667 data = kmalloc(stats.n_stats * sizeof(u64), GFP_USER);
668 if (!data)
669 return -ENOMEM;
671 ops->get_ethtool_stats(dev, &stats, data);
673 ret = -EFAULT;
674 if (copy_to_user(useraddr, &stats, sizeof(stats)))
675 goto out;
676 useraddr += sizeof(stats);
677 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
678 goto out;
679 ret = 0;
681 out:
682 kfree(data);
683 return ret;
686 /* The main entry point in this file. Called from net/core/dev.c */
688 int dev_ethtool(struct ifreq *ifr)
690 struct net_device *dev = __dev_get_by_name(ifr->ifr_name);
691 void __user *useraddr = ifr->ifr_data;
692 u32 ethcmd;
693 int rc;
694 unsigned long old_features;
697 * XXX: This can be pushed down into the ethtool_* handlers that
698 * need it. Keep existing behaviour for the moment.
700 if (!capable(CAP_NET_ADMIN))
701 return -EPERM;
703 if (!dev || !netif_device_present(dev))
704 return -ENODEV;
706 if (!dev->ethtool_ops)
707 goto ioctl;
709 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
710 return -EFAULT;
712 if(dev->ethtool_ops->begin)
713 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
714 return rc;
716 old_features = dev->features;
718 switch (ethcmd) {
719 case ETHTOOL_GSET:
720 rc = ethtool_get_settings(dev, useraddr);
721 break;
722 case ETHTOOL_SSET:
723 rc = ethtool_set_settings(dev, useraddr);
724 break;
725 case ETHTOOL_GDRVINFO:
726 rc = ethtool_get_drvinfo(dev, useraddr);
727 break;
728 case ETHTOOL_GREGS:
729 rc = ethtool_get_regs(dev, useraddr);
730 break;
731 case ETHTOOL_GWOL:
732 rc = ethtool_get_wol(dev, useraddr);
733 break;
734 case ETHTOOL_SWOL:
735 rc = ethtool_set_wol(dev, useraddr);
736 break;
737 case ETHTOOL_GMSGLVL:
738 rc = ethtool_get_msglevel(dev, useraddr);
739 break;
740 case ETHTOOL_SMSGLVL:
741 rc = ethtool_set_msglevel(dev, useraddr);
742 break;
743 case ETHTOOL_NWAY_RST:
744 rc = ethtool_nway_reset(dev);
745 break;
746 case ETHTOOL_GLINK:
747 rc = ethtool_get_link(dev, useraddr);
748 break;
749 case ETHTOOL_GEEPROM:
750 rc = ethtool_get_eeprom(dev, useraddr);
751 break;
752 case ETHTOOL_SEEPROM:
753 rc = ethtool_set_eeprom(dev, useraddr);
754 break;
755 case ETHTOOL_GCOALESCE:
756 rc = ethtool_get_coalesce(dev, useraddr);
757 break;
758 case ETHTOOL_SCOALESCE:
759 rc = ethtool_set_coalesce(dev, useraddr);
760 break;
761 case ETHTOOL_GRINGPARAM:
762 rc = ethtool_get_ringparam(dev, useraddr);
763 break;
764 case ETHTOOL_SRINGPARAM:
765 rc = ethtool_set_ringparam(dev, useraddr);
766 break;
767 case ETHTOOL_GPAUSEPARAM:
768 rc = ethtool_get_pauseparam(dev, useraddr);
769 break;
770 case ETHTOOL_SPAUSEPARAM:
771 rc = ethtool_set_pauseparam(dev, useraddr);
772 break;
773 case ETHTOOL_GRXCSUM:
774 rc = ethtool_get_rx_csum(dev, useraddr);
775 break;
776 case ETHTOOL_SRXCSUM:
777 rc = ethtool_set_rx_csum(dev, useraddr);
778 break;
779 case ETHTOOL_GTXCSUM:
780 rc = ethtool_get_tx_csum(dev, useraddr);
781 break;
782 case ETHTOOL_STXCSUM:
783 rc = ethtool_set_tx_csum(dev, useraddr);
784 break;
785 case ETHTOOL_GSG:
786 rc = ethtool_get_sg(dev, useraddr);
787 break;
788 case ETHTOOL_SSG:
789 rc = ethtool_set_sg(dev, useraddr);
790 break;
791 case ETHTOOL_GTSO:
792 rc = ethtool_get_tso(dev, useraddr);
793 break;
794 case ETHTOOL_STSO:
795 rc = ethtool_set_tso(dev, useraddr);
796 break;
797 case ETHTOOL_TEST:
798 rc = ethtool_self_test(dev, useraddr);
799 break;
800 case ETHTOOL_GSTRINGS:
801 rc = ethtool_get_strings(dev, useraddr);
802 break;
803 case ETHTOOL_PHYS_ID:
804 rc = ethtool_phys_id(dev, useraddr);
805 break;
806 case ETHTOOL_GSTATS:
807 rc = ethtool_get_stats(dev, useraddr);
808 break;
809 default:
810 rc = -EOPNOTSUPP;
813 if(dev->ethtool_ops->complete)
814 dev->ethtool_ops->complete(dev);
816 if (old_features != dev->features)
817 netdev_features_change(dev);
819 return rc;
821 ioctl:
822 if (dev->do_ioctl)
823 return dev->do_ioctl(dev, ifr, SIOCETHTOOL);
824 return -EOPNOTSUPP;
827 EXPORT_SYMBOL(dev_ethtool);
828 EXPORT_SYMBOL(ethtool_op_get_link);
829 EXPORT_SYMBOL(ethtool_op_get_sg);
830 EXPORT_SYMBOL(ethtool_op_get_tso);
831 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
832 EXPORT_SYMBOL(ethtool_op_set_sg);
833 EXPORT_SYMBOL(ethtool_op_set_tso);
834 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
835 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);