e1000: Add device IDs of blade version of the 82571 quad port
[pv_ops_mirror.git] / net / core / ethtool.c
blobc5e059352d43f1e4cfe8f17589825c82a28523a4
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.
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)
40 if (data)
41 dev->features |= NETIF_F_IP_CSUM;
42 else
43 dev->features &= ~NETIF_F_IP_CSUM;
45 return 0;
48 int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
50 if (data)
51 dev->features |= NETIF_F_HW_CSUM;
52 else
53 dev->features &= ~NETIF_F_HW_CSUM;
55 return 0;
58 int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data)
60 if (data)
61 dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
62 else
63 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
65 return 0;
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)
75 if (data)
76 dev->features |= NETIF_F_SG;
77 else
78 dev->features &= ~NETIF_F_SG;
80 return 0;
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)
90 if (data)
91 dev->features |= NETIF_F_TSO;
92 else
93 dev->features &= ~NETIF_F_TSO;
95 return 0;
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)
105 if (data)
106 dev->features |= NETIF_F_UFO;
107 else
108 dev->features &= ~NETIF_F_UFO;
109 return 0;
112 /* Handlers for each ethtool command */
114 static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
116 struct ethtool_cmd cmd = { ETHTOOL_GSET };
117 int err;
119 if (!dev->ethtool_ops->get_settings)
120 return -EOPNOTSUPP;
122 err = dev->ethtool_ops->get_settings(dev, &cmd);
123 if (err < 0)
124 return err;
126 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
127 return -EFAULT;
128 return 0;
131 static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
133 struct ethtool_cmd cmd;
135 if (!dev->ethtool_ops->set_settings)
136 return -EOPNOTSUPP;
138 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
139 return -EFAULT;
141 return dev->ethtool_ops->set_settings(dev, &cmd);
144 static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
146 struct ethtool_drvinfo info;
147 const struct ethtool_ops *ops = dev->ethtool_ops;
149 if (!ops->get_drvinfo)
150 return -EOPNOTSUPP;
152 memset(&info, 0, sizeof(info));
153 info.cmd = ETHTOOL_GDRVINFO;
154 ops->get_drvinfo(dev, &info);
156 if (ops->self_test_count)
157 info.testinfo_len = ops->self_test_count(dev);
158 if (ops->get_stats_count)
159 info.n_stats = ops->get_stats_count(dev);
160 if (ops->get_regs_len)
161 info.regdump_len = ops->get_regs_len(dev);
162 if (ops->get_eeprom_len)
163 info.eedump_len = ops->get_eeprom_len(dev);
165 if (copy_to_user(useraddr, &info, sizeof(info)))
166 return -EFAULT;
167 return 0;
170 static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
172 struct ethtool_regs regs;
173 const struct ethtool_ops *ops = dev->ethtool_ops;
174 void *regbuf;
175 int reglen, ret;
177 if (!ops->get_regs || !ops->get_regs_len)
178 return -EOPNOTSUPP;
180 if (copy_from_user(&regs, useraddr, sizeof(regs)))
181 return -EFAULT;
183 reglen = ops->get_regs_len(dev);
184 if (regs.len > reglen)
185 regs.len = reglen;
187 regbuf = kmalloc(reglen, GFP_USER);
188 if (!regbuf)
189 return -ENOMEM;
191 ops->get_regs(dev, &regs, regbuf);
193 ret = -EFAULT;
194 if (copy_to_user(useraddr, &regs, sizeof(regs)))
195 goto out;
196 useraddr += offsetof(struct ethtool_regs, data);
197 if (copy_to_user(useraddr, regbuf, regs.len))
198 goto out;
199 ret = 0;
201 out:
202 kfree(regbuf);
203 return ret;
206 static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
208 struct ethtool_wolinfo wol = { ETHTOOL_GWOL };
210 if (!dev->ethtool_ops->get_wol)
211 return -EOPNOTSUPP;
213 dev->ethtool_ops->get_wol(dev, &wol);
215 if (copy_to_user(useraddr, &wol, sizeof(wol)))
216 return -EFAULT;
217 return 0;
220 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
222 struct ethtool_wolinfo wol;
224 if (!dev->ethtool_ops->set_wol)
225 return -EOPNOTSUPP;
227 if (copy_from_user(&wol, useraddr, sizeof(wol)))
228 return -EFAULT;
230 return dev->ethtool_ops->set_wol(dev, &wol);
233 static int ethtool_get_msglevel(struct net_device *dev, char __user *useraddr)
235 struct ethtool_value edata = { ETHTOOL_GMSGLVL };
237 if (!dev->ethtool_ops->get_msglevel)
238 return -EOPNOTSUPP;
240 edata.data = dev->ethtool_ops->get_msglevel(dev);
242 if (copy_to_user(useraddr, &edata, sizeof(edata)))
243 return -EFAULT;
244 return 0;
247 static int ethtool_set_msglevel(struct net_device *dev, char __user *useraddr)
249 struct ethtool_value edata;
251 if (!dev->ethtool_ops->set_msglevel)
252 return -EOPNOTSUPP;
254 if (copy_from_user(&edata, useraddr, sizeof(edata)))
255 return -EFAULT;
257 dev->ethtool_ops->set_msglevel(dev, edata.data);
258 return 0;
261 static int ethtool_nway_reset(struct net_device *dev)
263 if (!dev->ethtool_ops->nway_reset)
264 return -EOPNOTSUPP;
266 return dev->ethtool_ops->nway_reset(dev);
269 static int ethtool_get_link(struct net_device *dev, void __user *useraddr)
271 struct ethtool_value edata = { ETHTOOL_GLINK };
273 if (!dev->ethtool_ops->get_link)
274 return -EOPNOTSUPP;
276 edata.data = dev->ethtool_ops->get_link(dev);
278 if (copy_to_user(useraddr, &edata, sizeof(edata)))
279 return -EFAULT;
280 return 0;
283 static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
285 struct ethtool_eeprom eeprom;
286 const struct ethtool_ops *ops = dev->ethtool_ops;
287 u8 *data;
288 int ret;
290 if (!ops->get_eeprom || !ops->get_eeprom_len)
291 return -EOPNOTSUPP;
293 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
294 return -EFAULT;
296 /* Check for wrap and zero */
297 if (eeprom.offset + eeprom.len <= eeprom.offset)
298 return -EINVAL;
300 /* Check for exceeding total eeprom len */
301 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
302 return -EINVAL;
304 data = kmalloc(eeprom.len, GFP_USER);
305 if (!data)
306 return -ENOMEM;
308 ret = -EFAULT;
309 if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
310 goto out;
312 ret = ops->get_eeprom(dev, &eeprom, data);
313 if (ret)
314 goto out;
316 ret = -EFAULT;
317 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
318 goto out;
319 if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
320 goto out;
321 ret = 0;
323 out:
324 kfree(data);
325 return ret;
328 static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
330 struct ethtool_eeprom eeprom;
331 const struct ethtool_ops *ops = dev->ethtool_ops;
332 u8 *data;
333 int ret;
335 if (!ops->set_eeprom || !ops->get_eeprom_len)
336 return -EOPNOTSUPP;
338 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
339 return -EFAULT;
341 /* Check for wrap and zero */
342 if (eeprom.offset + eeprom.len <= eeprom.offset)
343 return -EINVAL;
345 /* Check for exceeding total eeprom len */
346 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
347 return -EINVAL;
349 data = kmalloc(eeprom.len, GFP_USER);
350 if (!data)
351 return -ENOMEM;
353 ret = -EFAULT;
354 if (copy_from_user(data, useraddr + sizeof(eeprom), eeprom.len))
355 goto out;
357 ret = ops->set_eeprom(dev, &eeprom, data);
358 if (ret)
359 goto out;
361 if (copy_to_user(useraddr + sizeof(eeprom), data, eeprom.len))
362 ret = -EFAULT;
364 out:
365 kfree(data);
366 return ret;
369 static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
371 struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE };
373 if (!dev->ethtool_ops->get_coalesce)
374 return -EOPNOTSUPP;
376 dev->ethtool_ops->get_coalesce(dev, &coalesce);
378 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
379 return -EFAULT;
380 return 0;
383 static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
385 struct ethtool_coalesce coalesce;
387 if (!dev->ethtool_ops->set_coalesce)
388 return -EOPNOTSUPP;
390 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
391 return -EFAULT;
393 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
396 static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
398 struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM };
400 if (!dev->ethtool_ops->get_ringparam)
401 return -EOPNOTSUPP;
403 dev->ethtool_ops->get_ringparam(dev, &ringparam);
405 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
406 return -EFAULT;
407 return 0;
410 static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
412 struct ethtool_ringparam ringparam;
414 if (!dev->ethtool_ops->set_ringparam)
415 return -EOPNOTSUPP;
417 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
418 return -EFAULT;
420 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
423 static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
425 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
427 if (!dev->ethtool_ops->get_pauseparam)
428 return -EOPNOTSUPP;
430 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
432 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
433 return -EFAULT;
434 return 0;
437 static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
439 struct ethtool_pauseparam pauseparam;
441 if (!dev->ethtool_ops->set_pauseparam)
442 return -EOPNOTSUPP;
444 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
445 return -EFAULT;
447 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
450 static int ethtool_get_rx_csum(struct net_device *dev, char __user *useraddr)
452 struct ethtool_value edata = { ETHTOOL_GRXCSUM };
454 if (!dev->ethtool_ops->get_rx_csum)
455 return -EOPNOTSUPP;
457 edata.data = dev->ethtool_ops->get_rx_csum(dev);
459 if (copy_to_user(useraddr, &edata, sizeof(edata)))
460 return -EFAULT;
461 return 0;
464 static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
466 struct ethtool_value edata;
468 if (!dev->ethtool_ops->set_rx_csum)
469 return -EOPNOTSUPP;
471 if (copy_from_user(&edata, useraddr, sizeof(edata)))
472 return -EFAULT;
474 dev->ethtool_ops->set_rx_csum(dev, edata.data);
475 return 0;
478 static int ethtool_get_tx_csum(struct net_device *dev, char __user *useraddr)
480 struct ethtool_value edata = { ETHTOOL_GTXCSUM };
482 if (!dev->ethtool_ops->get_tx_csum)
483 return -EOPNOTSUPP;
485 edata.data = dev->ethtool_ops->get_tx_csum(dev);
487 if (copy_to_user(useraddr, &edata, sizeof(edata)))
488 return -EFAULT;
489 return 0;
492 static int __ethtool_set_sg(struct net_device *dev, u32 data)
494 int err;
496 if (!data && dev->ethtool_ops->set_tso) {
497 err = dev->ethtool_ops->set_tso(dev, 0);
498 if (err)
499 return err;
502 if (!data && dev->ethtool_ops->set_ufo) {
503 err = dev->ethtool_ops->set_ufo(dev, 0);
504 if (err)
505 return err;
507 return dev->ethtool_ops->set_sg(dev, data);
510 static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
512 struct ethtool_value edata;
513 int err;
515 if (!dev->ethtool_ops->set_tx_csum)
516 return -EOPNOTSUPP;
518 if (copy_from_user(&edata, useraddr, sizeof(edata)))
519 return -EFAULT;
521 if (!edata.data && dev->ethtool_ops->set_sg) {
522 err = __ethtool_set_sg(dev, 0);
523 if (err)
524 return err;
527 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
530 static int ethtool_get_sg(struct net_device *dev, char __user *useraddr)
532 struct ethtool_value edata = { ETHTOOL_GSG };
534 if (!dev->ethtool_ops->get_sg)
535 return -EOPNOTSUPP;
537 edata.data = dev->ethtool_ops->get_sg(dev);
539 if (copy_to_user(useraddr, &edata, sizeof(edata)))
540 return -EFAULT;
541 return 0;
544 static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
546 struct ethtool_value edata;
548 if (!dev->ethtool_ops->set_sg)
549 return -EOPNOTSUPP;
551 if (copy_from_user(&edata, useraddr, sizeof(edata)))
552 return -EFAULT;
554 if (edata.data &&
555 !(dev->features & NETIF_F_ALL_CSUM))
556 return -EINVAL;
558 return __ethtool_set_sg(dev, edata.data);
561 static int ethtool_get_tso(struct net_device *dev, char __user *useraddr)
563 struct ethtool_value edata = { ETHTOOL_GTSO };
565 if (!dev->ethtool_ops->get_tso)
566 return -EOPNOTSUPP;
568 edata.data = dev->ethtool_ops->get_tso(dev);
570 if (copy_to_user(useraddr, &edata, sizeof(edata)))
571 return -EFAULT;
572 return 0;
575 static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
577 struct ethtool_value edata;
579 if (!dev->ethtool_ops->set_tso)
580 return -EOPNOTSUPP;
582 if (copy_from_user(&edata, useraddr, sizeof(edata)))
583 return -EFAULT;
585 if (edata.data && !(dev->features & NETIF_F_SG))
586 return -EINVAL;
588 return dev->ethtool_ops->set_tso(dev, edata.data);
591 static int ethtool_get_ufo(struct net_device *dev, char __user *useraddr)
593 struct ethtool_value edata = { ETHTOOL_GUFO };
595 if (!dev->ethtool_ops->get_ufo)
596 return -EOPNOTSUPP;
597 edata.data = dev->ethtool_ops->get_ufo(dev);
598 if (copy_to_user(useraddr, &edata, sizeof(edata)))
599 return -EFAULT;
600 return 0;
603 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
605 struct ethtool_value edata;
607 if (!dev->ethtool_ops->set_ufo)
608 return -EOPNOTSUPP;
609 if (copy_from_user(&edata, useraddr, sizeof(edata)))
610 return -EFAULT;
611 if (edata.data && !(dev->features & NETIF_F_SG))
612 return -EINVAL;
613 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
614 return -EINVAL;
615 return dev->ethtool_ops->set_ufo(dev, edata.data);
618 static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
620 struct ethtool_value edata = { ETHTOOL_GGSO };
622 edata.data = dev->features & NETIF_F_GSO;
623 if (copy_to_user(useraddr, &edata, sizeof(edata)))
624 return -EFAULT;
625 return 0;
628 static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
630 struct ethtool_value edata;
632 if (copy_from_user(&edata, useraddr, sizeof(edata)))
633 return -EFAULT;
634 if (edata.data)
635 dev->features |= NETIF_F_GSO;
636 else
637 dev->features &= ~NETIF_F_GSO;
638 return 0;
641 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
643 struct ethtool_test test;
644 const struct ethtool_ops *ops = dev->ethtool_ops;
645 u64 *data;
646 int ret;
648 if (!ops->self_test || !ops->self_test_count)
649 return -EOPNOTSUPP;
651 if (copy_from_user(&test, useraddr, sizeof(test)))
652 return -EFAULT;
654 test.len = ops->self_test_count(dev);
655 data = kmalloc(test.len * sizeof(u64), GFP_USER);
656 if (!data)
657 return -ENOMEM;
659 ops->self_test(dev, &test, data);
661 ret = -EFAULT;
662 if (copy_to_user(useraddr, &test, sizeof(test)))
663 goto out;
664 useraddr += sizeof(test);
665 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
666 goto out;
667 ret = 0;
669 out:
670 kfree(data);
671 return ret;
674 static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
676 struct ethtool_gstrings gstrings;
677 const struct ethtool_ops *ops = dev->ethtool_ops;
678 u8 *data;
679 int ret;
681 if (!ops->get_strings)
682 return -EOPNOTSUPP;
684 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
685 return -EFAULT;
687 switch (gstrings.string_set) {
688 case ETH_SS_TEST:
689 if (!ops->self_test_count)
690 return -EOPNOTSUPP;
691 gstrings.len = ops->self_test_count(dev);
692 break;
693 case ETH_SS_STATS:
694 if (!ops->get_stats_count)
695 return -EOPNOTSUPP;
696 gstrings.len = ops->get_stats_count(dev);
697 break;
698 default:
699 return -EINVAL;
702 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
703 if (!data)
704 return -ENOMEM;
706 ops->get_strings(dev, gstrings.string_set, data);
708 ret = -EFAULT;
709 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
710 goto out;
711 useraddr += sizeof(gstrings);
712 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
713 goto out;
714 ret = 0;
716 out:
717 kfree(data);
718 return ret;
721 static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
723 struct ethtool_value id;
725 if (!dev->ethtool_ops->phys_id)
726 return -EOPNOTSUPP;
728 if (copy_from_user(&id, useraddr, sizeof(id)))
729 return -EFAULT;
731 return dev->ethtool_ops->phys_id(dev, id.data);
734 static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
736 struct ethtool_stats stats;
737 const struct ethtool_ops *ops = dev->ethtool_ops;
738 u64 *data;
739 int ret;
741 if (!ops->get_ethtool_stats || !ops->get_stats_count)
742 return -EOPNOTSUPP;
744 if (copy_from_user(&stats, useraddr, sizeof(stats)))
745 return -EFAULT;
747 stats.n_stats = ops->get_stats_count(dev);
748 data = kmalloc(stats.n_stats * sizeof(u64), GFP_USER);
749 if (!data)
750 return -ENOMEM;
752 ops->get_ethtool_stats(dev, &stats, data);
754 ret = -EFAULT;
755 if (copy_to_user(useraddr, &stats, sizeof(stats)))
756 goto out;
757 useraddr += sizeof(stats);
758 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
759 goto out;
760 ret = 0;
762 out:
763 kfree(data);
764 return ret;
767 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
769 struct ethtool_perm_addr epaddr;
771 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
772 return -EFAULT;
774 if (epaddr.size < dev->addr_len)
775 return -ETOOSMALL;
776 epaddr.size = dev->addr_len;
778 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
779 return -EFAULT;
780 useraddr += sizeof(epaddr);
781 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
782 return -EFAULT;
783 return 0;
786 /* The main entry point in this file. Called from net/core/dev.c */
788 int dev_ethtool(struct ifreq *ifr)
790 struct net_device *dev = __dev_get_by_name(ifr->ifr_name);
791 void __user *useraddr = ifr->ifr_data;
792 u32 ethcmd;
793 int rc;
794 unsigned long old_features;
796 if (!dev || !netif_device_present(dev))
797 return -ENODEV;
799 if (!dev->ethtool_ops)
800 return -EOPNOTSUPP;
802 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
803 return -EFAULT;
805 /* Allow some commands to be done by anyone */
806 switch(ethcmd) {
807 case ETHTOOL_GDRVINFO:
808 case ETHTOOL_GMSGLVL:
809 case ETHTOOL_GCOALESCE:
810 case ETHTOOL_GRINGPARAM:
811 case ETHTOOL_GPAUSEPARAM:
812 case ETHTOOL_GRXCSUM:
813 case ETHTOOL_GTXCSUM:
814 case ETHTOOL_GSG:
815 case ETHTOOL_GSTRINGS:
816 case ETHTOOL_GTSO:
817 case ETHTOOL_GPERMADDR:
818 case ETHTOOL_GUFO:
819 case ETHTOOL_GGSO:
820 break;
821 default:
822 if (!capable(CAP_NET_ADMIN))
823 return -EPERM;
826 if (dev->ethtool_ops->begin)
827 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
828 return rc;
830 old_features = dev->features;
832 switch (ethcmd) {
833 case ETHTOOL_GSET:
834 rc = ethtool_get_settings(dev, useraddr);
835 break;
836 case ETHTOOL_SSET:
837 rc = ethtool_set_settings(dev, useraddr);
838 break;
839 case ETHTOOL_GDRVINFO:
840 rc = ethtool_get_drvinfo(dev, useraddr);
841 break;
842 case ETHTOOL_GREGS:
843 rc = ethtool_get_regs(dev, useraddr);
844 break;
845 case ETHTOOL_GWOL:
846 rc = ethtool_get_wol(dev, useraddr);
847 break;
848 case ETHTOOL_SWOL:
849 rc = ethtool_set_wol(dev, useraddr);
850 break;
851 case ETHTOOL_GMSGLVL:
852 rc = ethtool_get_msglevel(dev, useraddr);
853 break;
854 case ETHTOOL_SMSGLVL:
855 rc = ethtool_set_msglevel(dev, useraddr);
856 break;
857 case ETHTOOL_NWAY_RST:
858 rc = ethtool_nway_reset(dev);
859 break;
860 case ETHTOOL_GLINK:
861 rc = ethtool_get_link(dev, useraddr);
862 break;
863 case ETHTOOL_GEEPROM:
864 rc = ethtool_get_eeprom(dev, useraddr);
865 break;
866 case ETHTOOL_SEEPROM:
867 rc = ethtool_set_eeprom(dev, useraddr);
868 break;
869 case ETHTOOL_GCOALESCE:
870 rc = ethtool_get_coalesce(dev, useraddr);
871 break;
872 case ETHTOOL_SCOALESCE:
873 rc = ethtool_set_coalesce(dev, useraddr);
874 break;
875 case ETHTOOL_GRINGPARAM:
876 rc = ethtool_get_ringparam(dev, useraddr);
877 break;
878 case ETHTOOL_SRINGPARAM:
879 rc = ethtool_set_ringparam(dev, useraddr);
880 break;
881 case ETHTOOL_GPAUSEPARAM:
882 rc = ethtool_get_pauseparam(dev, useraddr);
883 break;
884 case ETHTOOL_SPAUSEPARAM:
885 rc = ethtool_set_pauseparam(dev, useraddr);
886 break;
887 case ETHTOOL_GRXCSUM:
888 rc = ethtool_get_rx_csum(dev, useraddr);
889 break;
890 case ETHTOOL_SRXCSUM:
891 rc = ethtool_set_rx_csum(dev, useraddr);
892 break;
893 case ETHTOOL_GTXCSUM:
894 rc = ethtool_get_tx_csum(dev, useraddr);
895 break;
896 case ETHTOOL_STXCSUM:
897 rc = ethtool_set_tx_csum(dev, useraddr);
898 break;
899 case ETHTOOL_GSG:
900 rc = ethtool_get_sg(dev, useraddr);
901 break;
902 case ETHTOOL_SSG:
903 rc = ethtool_set_sg(dev, useraddr);
904 break;
905 case ETHTOOL_GTSO:
906 rc = ethtool_get_tso(dev, useraddr);
907 break;
908 case ETHTOOL_STSO:
909 rc = ethtool_set_tso(dev, useraddr);
910 break;
911 case ETHTOOL_TEST:
912 rc = ethtool_self_test(dev, useraddr);
913 break;
914 case ETHTOOL_GSTRINGS:
915 rc = ethtool_get_strings(dev, useraddr);
916 break;
917 case ETHTOOL_PHYS_ID:
918 rc = ethtool_phys_id(dev, useraddr);
919 break;
920 case ETHTOOL_GSTATS:
921 rc = ethtool_get_stats(dev, useraddr);
922 break;
923 case ETHTOOL_GPERMADDR:
924 rc = ethtool_get_perm_addr(dev, useraddr);
925 break;
926 case ETHTOOL_GUFO:
927 rc = ethtool_get_ufo(dev, useraddr);
928 break;
929 case ETHTOOL_SUFO:
930 rc = ethtool_set_ufo(dev, useraddr);
931 break;
932 case ETHTOOL_GGSO:
933 rc = ethtool_get_gso(dev, useraddr);
934 break;
935 case ETHTOOL_SGSO:
936 rc = ethtool_set_gso(dev, useraddr);
937 break;
938 default:
939 rc = -EOPNOTSUPP;
942 if (dev->ethtool_ops->complete)
943 dev->ethtool_ops->complete(dev);
945 if (old_features != dev->features)
946 netdev_features_change(dev);
948 return rc;
951 EXPORT_SYMBOL(ethtool_op_get_link);
952 EXPORT_SYMBOL(ethtool_op_get_sg);
953 EXPORT_SYMBOL(ethtool_op_get_tso);
954 EXPORT_SYMBOL(ethtool_op_get_tx_csum);
955 EXPORT_SYMBOL(ethtool_op_set_sg);
956 EXPORT_SYMBOL(ethtool_op_set_tso);
957 EXPORT_SYMBOL(ethtool_op_set_tx_csum);
958 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
959 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
960 EXPORT_SYMBOL(ethtool_op_set_ufo);
961 EXPORT_SYMBOL(ethtool_op_get_ufo);