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 <linux/net_tstamp.h>
21 #include <linux/phy.h>
22 #include <linux/bitops.h>
23 #include <linux/uaccess.h>
24 #include <linux/vmalloc.h>
25 #include <linux/slab.h>
26 #include <linux/rtnetlink.h>
27 #include <linux/sched.h>
30 * Some useful ethtool_ops methods that're device independent.
31 * If we find that all drivers want to do the same thing here,
32 * we can turn these into dev_() function calls.
35 u32
ethtool_op_get_link(struct net_device
*dev
)
37 return netif_carrier_ok(dev
) ? 1 : 0;
39 EXPORT_SYMBOL(ethtool_op_get_link
);
41 int ethtool_op_get_ts_info(struct net_device
*dev
, struct ethtool_ts_info
*info
)
43 info
->so_timestamping
=
44 SOF_TIMESTAMPING_TX_SOFTWARE
|
45 SOF_TIMESTAMPING_RX_SOFTWARE
|
46 SOF_TIMESTAMPING_SOFTWARE
;
50 EXPORT_SYMBOL(ethtool_op_get_ts_info
);
52 /* Handlers for each ethtool command */
54 #define ETHTOOL_DEV_FEATURE_WORDS ((NETDEV_FEATURE_COUNT + 31) / 32)
56 static const char netdev_features_strings
[NETDEV_FEATURE_COUNT
][ETH_GSTRING_LEN
] = {
57 [NETIF_F_SG_BIT
] = "tx-scatter-gather",
58 [NETIF_F_IP_CSUM_BIT
] = "tx-checksum-ipv4",
59 [NETIF_F_HW_CSUM_BIT
] = "tx-checksum-ip-generic",
60 [NETIF_F_IPV6_CSUM_BIT
] = "tx-checksum-ipv6",
61 [NETIF_F_HIGHDMA_BIT
] = "highdma",
62 [NETIF_F_FRAGLIST_BIT
] = "tx-scatter-gather-fraglist",
63 [NETIF_F_HW_VLAN_CTAG_TX_BIT
] = "tx-vlan-hw-insert",
65 [NETIF_F_HW_VLAN_CTAG_RX_BIT
] = "rx-vlan-hw-parse",
66 [NETIF_F_HW_VLAN_CTAG_FILTER_BIT
] = "rx-vlan-filter",
67 [NETIF_F_HW_VLAN_STAG_TX_BIT
] = "tx-vlan-stag-hw-insert",
68 [NETIF_F_HW_VLAN_STAG_RX_BIT
] = "rx-vlan-stag-hw-parse",
69 [NETIF_F_HW_VLAN_STAG_FILTER_BIT
] = "rx-vlan-stag-filter",
70 [NETIF_F_VLAN_CHALLENGED_BIT
] = "vlan-challenged",
71 [NETIF_F_GSO_BIT
] = "tx-generic-segmentation",
72 [NETIF_F_LLTX_BIT
] = "tx-lockless",
73 [NETIF_F_NETNS_LOCAL_BIT
] = "netns-local",
74 [NETIF_F_GRO_BIT
] = "rx-gro",
75 [NETIF_F_LRO_BIT
] = "rx-lro",
77 [NETIF_F_TSO_BIT
] = "tx-tcp-segmentation",
78 [NETIF_F_UFO_BIT
] = "tx-udp-fragmentation",
79 [NETIF_F_GSO_ROBUST_BIT
] = "tx-gso-robust",
80 [NETIF_F_TSO_ECN_BIT
] = "tx-tcp-ecn-segmentation",
81 [NETIF_F_TSO6_BIT
] = "tx-tcp6-segmentation",
82 [NETIF_F_FSO_BIT
] = "tx-fcoe-segmentation",
83 [NETIF_F_GSO_GRE_BIT
] = "tx-gre-segmentation",
84 [NETIF_F_GSO_UDP_TUNNEL_BIT
] = "tx-udp_tnl-segmentation",
86 [NETIF_F_FCOE_CRC_BIT
] = "tx-checksum-fcoe-crc",
87 [NETIF_F_SCTP_CSUM_BIT
] = "tx-checksum-sctp",
88 [NETIF_F_FCOE_MTU_BIT
] = "fcoe-mtu",
89 [NETIF_F_NTUPLE_BIT
] = "rx-ntuple-filter",
90 [NETIF_F_RXHASH_BIT
] = "rx-hashing",
91 [NETIF_F_RXCSUM_BIT
] = "rx-checksum",
92 [NETIF_F_NOCACHE_COPY_BIT
] = "tx-nocache-copy",
93 [NETIF_F_LOOPBACK_BIT
] = "loopback",
94 [NETIF_F_RXFCS_BIT
] = "rx-fcs",
95 [NETIF_F_RXALL_BIT
] = "rx-all",
98 static int ethtool_get_features(struct net_device
*dev
, void __user
*useraddr
)
100 struct ethtool_gfeatures cmd
= {
101 .cmd
= ETHTOOL_GFEATURES
,
102 .size
= ETHTOOL_DEV_FEATURE_WORDS
,
104 struct ethtool_get_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
105 u32 __user
*sizeaddr
;
109 /* in case feature bits run out again */
110 BUILD_BUG_ON(ETHTOOL_DEV_FEATURE_WORDS
* sizeof(u32
) > sizeof(netdev_features_t
));
112 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
113 features
[i
].available
= (u32
)(dev
->hw_features
>> (32 * i
));
114 features
[i
].requested
= (u32
)(dev
->wanted_features
>> (32 * i
));
115 features
[i
].active
= (u32
)(dev
->features
>> (32 * i
));
116 features
[i
].never_changed
=
117 (u32
)(NETIF_F_NEVER_CHANGE
>> (32 * i
));
120 sizeaddr
= useraddr
+ offsetof(struct ethtool_gfeatures
, size
);
121 if (get_user(copy_size
, sizeaddr
))
124 if (copy_size
> ETHTOOL_DEV_FEATURE_WORDS
)
125 copy_size
= ETHTOOL_DEV_FEATURE_WORDS
;
127 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
129 useraddr
+= sizeof(cmd
);
130 if (copy_to_user(useraddr
, features
, copy_size
* sizeof(*features
)))
136 static int ethtool_set_features(struct net_device
*dev
, void __user
*useraddr
)
138 struct ethtool_sfeatures cmd
;
139 struct ethtool_set_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
140 netdev_features_t wanted
= 0, valid
= 0;
143 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
145 useraddr
+= sizeof(cmd
);
147 if (cmd
.size
!= ETHTOOL_DEV_FEATURE_WORDS
)
150 if (copy_from_user(features
, useraddr
, sizeof(features
)))
153 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
154 valid
|= (netdev_features_t
)features
[i
].valid
<< (32 * i
);
155 wanted
|= (netdev_features_t
)features
[i
].requested
<< (32 * i
);
158 if (valid
& ~NETIF_F_ETHTOOL_BITS
)
161 if (valid
& ~dev
->hw_features
) {
162 valid
&= dev
->hw_features
;
163 ret
|= ETHTOOL_F_UNSUPPORTED
;
166 dev
->wanted_features
&= ~valid
;
167 dev
->wanted_features
|= wanted
& valid
;
168 __netdev_update_features(dev
);
170 if ((dev
->wanted_features
^ dev
->features
) & valid
)
171 ret
|= ETHTOOL_F_WISH
;
176 static int __ethtool_get_sset_count(struct net_device
*dev
, int sset
)
178 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
180 if (sset
== ETH_SS_FEATURES
)
181 return ARRAY_SIZE(netdev_features_strings
);
183 if (ops
->get_sset_count
&& ops
->get_strings
)
184 return ops
->get_sset_count(dev
, sset
);
189 static void __ethtool_get_strings(struct net_device
*dev
,
190 u32 stringset
, u8
*data
)
192 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
194 if (stringset
== ETH_SS_FEATURES
)
195 memcpy(data
, netdev_features_strings
,
196 sizeof(netdev_features_strings
));
198 /* ops->get_strings is valid because checked earlier */
199 ops
->get_strings(dev
, stringset
, data
);
202 static netdev_features_t
ethtool_get_feature_mask(u32 eth_cmd
)
204 /* feature masks of legacy discrete ethtool ops */
207 case ETHTOOL_GTXCSUM
:
208 case ETHTOOL_STXCSUM
:
209 return NETIF_F_ALL_CSUM
| NETIF_F_SCTP_CSUM
;
210 case ETHTOOL_GRXCSUM
:
211 case ETHTOOL_SRXCSUM
:
212 return NETIF_F_RXCSUM
;
218 return NETIF_F_ALL_TSO
;
233 static int ethtool_get_one_feature(struct net_device
*dev
,
234 char __user
*useraddr
, u32 ethcmd
)
236 netdev_features_t mask
= ethtool_get_feature_mask(ethcmd
);
237 struct ethtool_value edata
= {
239 .data
= !!(dev
->features
& mask
),
242 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
247 static int ethtool_set_one_feature(struct net_device
*dev
,
248 void __user
*useraddr
, u32 ethcmd
)
250 struct ethtool_value edata
;
251 netdev_features_t mask
;
253 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
256 mask
= ethtool_get_feature_mask(ethcmd
);
257 mask
&= dev
->hw_features
;
262 dev
->wanted_features
|= mask
;
264 dev
->wanted_features
&= ~mask
;
266 __netdev_update_features(dev
);
271 #define ETH_ALL_FLAGS (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | \
272 ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH)
273 #define ETH_ALL_FEATURES (NETIF_F_LRO | NETIF_F_HW_VLAN_CTAG_RX | \
274 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_NTUPLE | \
277 static u32
__ethtool_get_flags(struct net_device
*dev
)
281 if (dev
->features
& NETIF_F_LRO
) flags
|= ETH_FLAG_LRO
;
282 if (dev
->features
& NETIF_F_HW_VLAN_CTAG_RX
) flags
|= ETH_FLAG_RXVLAN
;
283 if (dev
->features
& NETIF_F_HW_VLAN_CTAG_TX
) flags
|= ETH_FLAG_TXVLAN
;
284 if (dev
->features
& NETIF_F_NTUPLE
) flags
|= ETH_FLAG_NTUPLE
;
285 if (dev
->features
& NETIF_F_RXHASH
) flags
|= ETH_FLAG_RXHASH
;
290 static int __ethtool_set_flags(struct net_device
*dev
, u32 data
)
292 netdev_features_t features
= 0, changed
;
294 if (data
& ~ETH_ALL_FLAGS
)
297 if (data
& ETH_FLAG_LRO
) features
|= NETIF_F_LRO
;
298 if (data
& ETH_FLAG_RXVLAN
) features
|= NETIF_F_HW_VLAN_CTAG_RX
;
299 if (data
& ETH_FLAG_TXVLAN
) features
|= NETIF_F_HW_VLAN_CTAG_TX
;
300 if (data
& ETH_FLAG_NTUPLE
) features
|= NETIF_F_NTUPLE
;
301 if (data
& ETH_FLAG_RXHASH
) features
|= NETIF_F_RXHASH
;
303 /* allow changing only bits set in hw_features */
304 changed
= (features
^ dev
->features
) & ETH_ALL_FEATURES
;
305 if (changed
& ~dev
->hw_features
)
306 return (changed
& dev
->hw_features
) ? -EINVAL
: -EOPNOTSUPP
;
308 dev
->wanted_features
=
309 (dev
->wanted_features
& ~changed
) | (features
& changed
);
311 __netdev_update_features(dev
);
316 int __ethtool_get_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
320 if (!dev
->ethtool_ops
->get_settings
)
323 memset(cmd
, 0, sizeof(struct ethtool_cmd
));
324 cmd
->cmd
= ETHTOOL_GSET
;
325 return dev
->ethtool_ops
->get_settings(dev
, cmd
);
327 EXPORT_SYMBOL(__ethtool_get_settings
);
329 static int ethtool_get_settings(struct net_device
*dev
, void __user
*useraddr
)
332 struct ethtool_cmd cmd
;
334 err
= __ethtool_get_settings(dev
, &cmd
);
338 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
343 static int ethtool_set_settings(struct net_device
*dev
, void __user
*useraddr
)
345 struct ethtool_cmd cmd
;
347 if (!dev
->ethtool_ops
->set_settings
)
350 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
353 return dev
->ethtool_ops
->set_settings(dev
, &cmd
);
356 static noinline_for_stack
int ethtool_get_drvinfo(struct net_device
*dev
,
357 void __user
*useraddr
)
359 struct ethtool_drvinfo info
;
360 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
362 memset(&info
, 0, sizeof(info
));
363 info
.cmd
= ETHTOOL_GDRVINFO
;
364 if (ops
->get_drvinfo
) {
365 ops
->get_drvinfo(dev
, &info
);
366 } else if (dev
->dev
.parent
&& dev
->dev
.parent
->driver
) {
367 strlcpy(info
.bus_info
, dev_name(dev
->dev
.parent
),
368 sizeof(info
.bus_info
));
369 strlcpy(info
.driver
, dev
->dev
.parent
->driver
->name
,
370 sizeof(info
.driver
));
376 * this method of obtaining string set info is deprecated;
377 * Use ETHTOOL_GSSET_INFO instead.
379 if (ops
->get_sset_count
) {
382 rc
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
384 info
.testinfo_len
= rc
;
385 rc
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
388 rc
= ops
->get_sset_count(dev
, ETH_SS_PRIV_FLAGS
);
390 info
.n_priv_flags
= rc
;
392 if (ops
->get_regs_len
)
393 info
.regdump_len
= ops
->get_regs_len(dev
);
394 if (ops
->get_eeprom_len
)
395 info
.eedump_len
= ops
->get_eeprom_len(dev
);
397 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
402 static noinline_for_stack
int ethtool_get_sset_info(struct net_device
*dev
,
403 void __user
*useraddr
)
405 struct ethtool_sset_info info
;
407 int i
, idx
= 0, n_bits
= 0, ret
, rc
;
408 u32
*info_buf
= NULL
;
410 if (copy_from_user(&info
, useraddr
, sizeof(info
)))
413 /* store copy of mask, because we zero struct later on */
414 sset_mask
= info
.sset_mask
;
418 /* calculate size of return buffer */
419 n_bits
= hweight64(sset_mask
);
421 memset(&info
, 0, sizeof(info
));
422 info
.cmd
= ETHTOOL_GSSET_INFO
;
424 info_buf
= kzalloc(n_bits
* sizeof(u32
), GFP_USER
);
429 * fill return buffer based on input bitmask and successful
430 * get_sset_count return
432 for (i
= 0; i
< 64; i
++) {
433 if (!(sset_mask
& (1ULL << i
)))
436 rc
= __ethtool_get_sset_count(dev
, i
);
438 info
.sset_mask
|= (1ULL << i
);
439 info_buf
[idx
++] = rc
;
444 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
447 useraddr
+= offsetof(struct ethtool_sset_info
, data
);
448 if (copy_to_user(useraddr
, info_buf
, idx
* sizeof(u32
)))
458 static noinline_for_stack
int ethtool_set_rxnfc(struct net_device
*dev
,
459 u32 cmd
, void __user
*useraddr
)
461 struct ethtool_rxnfc info
;
462 size_t info_size
= sizeof(info
);
465 if (!dev
->ethtool_ops
->set_rxnfc
)
468 /* struct ethtool_rxnfc was originally defined for
469 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
470 * members. User-space might still be using that
472 if (cmd
== ETHTOOL_SRXFH
)
473 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
476 if (copy_from_user(&info
, useraddr
, info_size
))
479 rc
= dev
->ethtool_ops
->set_rxnfc(dev
, &info
);
483 if (cmd
== ETHTOOL_SRXCLSRLINS
&&
484 copy_to_user(useraddr
, &info
, info_size
))
490 static noinline_for_stack
int ethtool_get_rxnfc(struct net_device
*dev
,
491 u32 cmd
, void __user
*useraddr
)
493 struct ethtool_rxnfc info
;
494 size_t info_size
= sizeof(info
);
495 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
497 void *rule_buf
= NULL
;
502 /* struct ethtool_rxnfc was originally defined for
503 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
504 * members. User-space might still be using that
506 if (cmd
== ETHTOOL_GRXFH
)
507 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
510 if (copy_from_user(&info
, useraddr
, info_size
))
513 if (info
.cmd
== ETHTOOL_GRXCLSRLALL
) {
514 if (info
.rule_cnt
> 0) {
515 if (info
.rule_cnt
<= KMALLOC_MAX_SIZE
/ sizeof(u32
))
516 rule_buf
= kzalloc(info
.rule_cnt
* sizeof(u32
),
523 ret
= ops
->get_rxnfc(dev
, &info
, rule_buf
);
528 if (copy_to_user(useraddr
, &info
, info_size
))
532 useraddr
+= offsetof(struct ethtool_rxnfc
, rule_locs
);
533 if (copy_to_user(useraddr
, rule_buf
,
534 info
.rule_cnt
* sizeof(u32
)))
545 static noinline_for_stack
int ethtool_get_rxfh_indir(struct net_device
*dev
,
546 void __user
*useraddr
)
548 u32 user_size
, dev_size
;
552 if (!dev
->ethtool_ops
->get_rxfh_indir_size
||
553 !dev
->ethtool_ops
->get_rxfh_indir
)
555 dev_size
= dev
->ethtool_ops
->get_rxfh_indir_size(dev
);
559 if (copy_from_user(&user_size
,
560 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
564 if (copy_to_user(useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
565 &dev_size
, sizeof(dev_size
)))
568 /* If the user buffer size is 0, this is just a query for the
569 * device table size. Otherwise, if it's smaller than the
570 * device table size it's an error.
572 if (user_size
< dev_size
)
573 return user_size
== 0 ? 0 : -EINVAL
;
575 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
579 ret
= dev
->ethtool_ops
->get_rxfh_indir(dev
, indir
);
583 if (copy_to_user(useraddr
+
584 offsetof(struct ethtool_rxfh_indir
, ring_index
[0]),
585 indir
, dev_size
* sizeof(indir
[0])))
593 static noinline_for_stack
int ethtool_set_rxfh_indir(struct net_device
*dev
,
594 void __user
*useraddr
)
596 struct ethtool_rxnfc rx_rings
;
597 u32 user_size
, dev_size
, i
;
599 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
602 if (!ops
->get_rxfh_indir_size
|| !ops
->set_rxfh_indir
||
606 dev_size
= ops
->get_rxfh_indir_size(dev
);
610 if (copy_from_user(&user_size
,
611 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
615 if (user_size
!= 0 && user_size
!= dev_size
)
618 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
622 rx_rings
.cmd
= ETHTOOL_GRXRINGS
;
623 ret
= ops
->get_rxnfc(dev
, &rx_rings
, NULL
);
627 if (user_size
== 0) {
628 for (i
= 0; i
< dev_size
; i
++)
629 indir
[i
] = ethtool_rxfh_indir_default(i
, rx_rings
.data
);
631 if (copy_from_user(indir
,
633 offsetof(struct ethtool_rxfh_indir
,
635 dev_size
* sizeof(indir
[0]))) {
640 /* Validate ring indices */
641 for (i
= 0; i
< dev_size
; i
++) {
642 if (indir
[i
] >= rx_rings
.data
) {
649 ret
= ops
->set_rxfh_indir(dev
, indir
);
656 static int ethtool_get_regs(struct net_device
*dev
, char __user
*useraddr
)
658 struct ethtool_regs regs
;
659 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
663 if (!ops
->get_regs
|| !ops
->get_regs_len
)
666 if (copy_from_user(®s
, useraddr
, sizeof(regs
)))
669 reglen
= ops
->get_regs_len(dev
);
670 if (regs
.len
> reglen
)
673 regbuf
= vzalloc(reglen
);
674 if (reglen
&& !regbuf
)
677 ops
->get_regs(dev
, ®s
, regbuf
);
680 if (copy_to_user(useraddr
, ®s
, sizeof(regs
)))
682 useraddr
+= offsetof(struct ethtool_regs
, data
);
683 if (regbuf
&& copy_to_user(useraddr
, regbuf
, regs
.len
))
692 static int ethtool_reset(struct net_device
*dev
, char __user
*useraddr
)
694 struct ethtool_value reset
;
697 if (!dev
->ethtool_ops
->reset
)
700 if (copy_from_user(&reset
, useraddr
, sizeof(reset
)))
703 ret
= dev
->ethtool_ops
->reset(dev
, &reset
.data
);
707 if (copy_to_user(useraddr
, &reset
, sizeof(reset
)))
712 static int ethtool_get_wol(struct net_device
*dev
, char __user
*useraddr
)
714 struct ethtool_wolinfo wol
= { .cmd
= ETHTOOL_GWOL
};
716 if (!dev
->ethtool_ops
->get_wol
)
719 dev
->ethtool_ops
->get_wol(dev
, &wol
);
721 if (copy_to_user(useraddr
, &wol
, sizeof(wol
)))
726 static int ethtool_set_wol(struct net_device
*dev
, char __user
*useraddr
)
728 struct ethtool_wolinfo wol
;
730 if (!dev
->ethtool_ops
->set_wol
)
733 if (copy_from_user(&wol
, useraddr
, sizeof(wol
)))
736 return dev
->ethtool_ops
->set_wol(dev
, &wol
);
739 static int ethtool_get_eee(struct net_device
*dev
, char __user
*useraddr
)
741 struct ethtool_eee edata
;
744 if (!dev
->ethtool_ops
->get_eee
)
747 memset(&edata
, 0, sizeof(struct ethtool_eee
));
748 edata
.cmd
= ETHTOOL_GEEE
;
749 rc
= dev
->ethtool_ops
->get_eee(dev
, &edata
);
754 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
760 static int ethtool_set_eee(struct net_device
*dev
, char __user
*useraddr
)
762 struct ethtool_eee edata
;
764 if (!dev
->ethtool_ops
->set_eee
)
767 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
770 return dev
->ethtool_ops
->set_eee(dev
, &edata
);
773 static int ethtool_nway_reset(struct net_device
*dev
)
775 if (!dev
->ethtool_ops
->nway_reset
)
778 return dev
->ethtool_ops
->nway_reset(dev
);
781 static int ethtool_get_link(struct net_device
*dev
, char __user
*useraddr
)
783 struct ethtool_value edata
= { .cmd
= ETHTOOL_GLINK
};
785 if (!dev
->ethtool_ops
->get_link
)
788 edata
.data
= netif_running(dev
) && dev
->ethtool_ops
->get_link(dev
);
790 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
795 static int ethtool_get_any_eeprom(struct net_device
*dev
, void __user
*useraddr
,
796 int (*getter
)(struct net_device
*,
797 struct ethtool_eeprom
*, u8
*),
800 struct ethtool_eeprom eeprom
;
801 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
806 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
809 /* Check for wrap and zero */
810 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
813 /* Check for exceeding total eeprom len */
814 if (eeprom
.offset
+ eeprom
.len
> total_len
)
817 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
821 bytes_remaining
= eeprom
.len
;
822 while (bytes_remaining
> 0) {
823 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
825 ret
= getter(dev
, &eeprom
, data
);
828 if (copy_to_user(userbuf
, data
, eeprom
.len
)) {
832 userbuf
+= eeprom
.len
;
833 eeprom
.offset
+= eeprom
.len
;
834 bytes_remaining
-= eeprom
.len
;
837 eeprom
.len
= userbuf
- (useraddr
+ sizeof(eeprom
));
838 eeprom
.offset
-= eeprom
.len
;
839 if (copy_to_user(useraddr
, &eeprom
, sizeof(eeprom
)))
846 static int ethtool_get_eeprom(struct net_device
*dev
, void __user
*useraddr
)
848 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
850 if (!ops
->get_eeprom
|| !ops
->get_eeprom_len
)
853 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_eeprom
,
854 ops
->get_eeprom_len(dev
));
857 static int ethtool_set_eeprom(struct net_device
*dev
, void __user
*useraddr
)
859 struct ethtool_eeprom eeprom
;
860 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
861 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
866 if (!ops
->set_eeprom
|| !ops
->get_eeprom_len
)
869 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
872 /* Check for wrap and zero */
873 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
876 /* Check for exceeding total eeprom len */
877 if (eeprom
.offset
+ eeprom
.len
> ops
->get_eeprom_len(dev
))
880 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
884 bytes_remaining
= eeprom
.len
;
885 while (bytes_remaining
> 0) {
886 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
888 if (copy_from_user(data
, userbuf
, eeprom
.len
)) {
892 ret
= ops
->set_eeprom(dev
, &eeprom
, data
);
895 userbuf
+= eeprom
.len
;
896 eeprom
.offset
+= eeprom
.len
;
897 bytes_remaining
-= eeprom
.len
;
904 static noinline_for_stack
int ethtool_get_coalesce(struct net_device
*dev
,
905 void __user
*useraddr
)
907 struct ethtool_coalesce coalesce
= { .cmd
= ETHTOOL_GCOALESCE
};
909 if (!dev
->ethtool_ops
->get_coalesce
)
912 dev
->ethtool_ops
->get_coalesce(dev
, &coalesce
);
914 if (copy_to_user(useraddr
, &coalesce
, sizeof(coalesce
)))
919 static noinline_for_stack
int ethtool_set_coalesce(struct net_device
*dev
,
920 void __user
*useraddr
)
922 struct ethtool_coalesce coalesce
;
924 if (!dev
->ethtool_ops
->set_coalesce
)
927 if (copy_from_user(&coalesce
, useraddr
, sizeof(coalesce
)))
930 return dev
->ethtool_ops
->set_coalesce(dev
, &coalesce
);
933 static int ethtool_get_ringparam(struct net_device
*dev
, void __user
*useraddr
)
935 struct ethtool_ringparam ringparam
= { .cmd
= ETHTOOL_GRINGPARAM
};
937 if (!dev
->ethtool_ops
->get_ringparam
)
940 dev
->ethtool_ops
->get_ringparam(dev
, &ringparam
);
942 if (copy_to_user(useraddr
, &ringparam
, sizeof(ringparam
)))
947 static int ethtool_set_ringparam(struct net_device
*dev
, void __user
*useraddr
)
949 struct ethtool_ringparam ringparam
;
951 if (!dev
->ethtool_ops
->set_ringparam
)
954 if (copy_from_user(&ringparam
, useraddr
, sizeof(ringparam
)))
957 return dev
->ethtool_ops
->set_ringparam(dev
, &ringparam
);
960 static noinline_for_stack
int ethtool_get_channels(struct net_device
*dev
,
961 void __user
*useraddr
)
963 struct ethtool_channels channels
= { .cmd
= ETHTOOL_GCHANNELS
};
965 if (!dev
->ethtool_ops
->get_channels
)
968 dev
->ethtool_ops
->get_channels(dev
, &channels
);
970 if (copy_to_user(useraddr
, &channels
, sizeof(channels
)))
975 static noinline_for_stack
int ethtool_set_channels(struct net_device
*dev
,
976 void __user
*useraddr
)
978 struct ethtool_channels channels
;
980 if (!dev
->ethtool_ops
->set_channels
)
983 if (copy_from_user(&channels
, useraddr
, sizeof(channels
)))
986 return dev
->ethtool_ops
->set_channels(dev
, &channels
);
989 static int ethtool_get_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
991 struct ethtool_pauseparam pauseparam
= { ETHTOOL_GPAUSEPARAM
};
993 if (!dev
->ethtool_ops
->get_pauseparam
)
996 dev
->ethtool_ops
->get_pauseparam(dev
, &pauseparam
);
998 if (copy_to_user(useraddr
, &pauseparam
, sizeof(pauseparam
)))
1003 static int ethtool_set_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1005 struct ethtool_pauseparam pauseparam
;
1007 if (!dev
->ethtool_ops
->set_pauseparam
)
1010 if (copy_from_user(&pauseparam
, useraddr
, sizeof(pauseparam
)))
1013 return dev
->ethtool_ops
->set_pauseparam(dev
, &pauseparam
);
1016 static int ethtool_self_test(struct net_device
*dev
, char __user
*useraddr
)
1018 struct ethtool_test test
;
1019 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1023 if (!ops
->self_test
|| !ops
->get_sset_count
)
1026 test_len
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
1029 WARN_ON(test_len
== 0);
1031 if (copy_from_user(&test
, useraddr
, sizeof(test
)))
1034 test
.len
= test_len
;
1035 data
= kmalloc(test_len
* sizeof(u64
), GFP_USER
);
1039 ops
->self_test(dev
, &test
, data
);
1042 if (copy_to_user(useraddr
, &test
, sizeof(test
)))
1044 useraddr
+= sizeof(test
);
1045 if (copy_to_user(useraddr
, data
, test
.len
* sizeof(u64
)))
1054 static int ethtool_get_strings(struct net_device
*dev
, void __user
*useraddr
)
1056 struct ethtool_gstrings gstrings
;
1060 if (copy_from_user(&gstrings
, useraddr
, sizeof(gstrings
)))
1063 ret
= __ethtool_get_sset_count(dev
, gstrings
.string_set
);
1069 data
= kmalloc(gstrings
.len
* ETH_GSTRING_LEN
, GFP_USER
);
1073 __ethtool_get_strings(dev
, gstrings
.string_set
, data
);
1076 if (copy_to_user(useraddr
, &gstrings
, sizeof(gstrings
)))
1078 useraddr
+= sizeof(gstrings
);
1079 if (copy_to_user(useraddr
, data
, gstrings
.len
* ETH_GSTRING_LEN
))
1088 static int ethtool_phys_id(struct net_device
*dev
, void __user
*useraddr
)
1090 struct ethtool_value id
;
1092 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1095 if (!ops
->set_phys_id
)
1101 if (copy_from_user(&id
, useraddr
, sizeof(id
)))
1104 rc
= ops
->set_phys_id(dev
, ETHTOOL_ID_ACTIVE
);
1108 /* Drop the RTNL lock while waiting, but prevent reentry or
1109 * removal of the device.
1116 /* Driver will handle this itself */
1117 schedule_timeout_interruptible(
1118 id
.data
? (id
.data
* HZ
) : MAX_SCHEDULE_TIMEOUT
);
1120 /* Driver expects to be called at twice the frequency in rc */
1121 int n
= rc
* 2, i
, interval
= HZ
/ n
;
1123 /* Count down seconds */
1125 /* Count down iterations per second */
1129 rc
= ops
->set_phys_id(dev
,
1130 (i
& 1) ? ETHTOOL_ID_OFF
: ETHTOOL_ID_ON
);
1134 schedule_timeout_interruptible(interval
);
1135 } while (!signal_pending(current
) && --i
!= 0);
1136 } while (!signal_pending(current
) &&
1137 (id
.data
== 0 || --id
.data
!= 0));
1144 (void) ops
->set_phys_id(dev
, ETHTOOL_ID_INACTIVE
);
1148 static int ethtool_get_stats(struct net_device
*dev
, void __user
*useraddr
)
1150 struct ethtool_stats stats
;
1151 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1155 if (!ops
->get_ethtool_stats
|| !ops
->get_sset_count
)
1158 n_stats
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
1161 WARN_ON(n_stats
== 0);
1163 if (copy_from_user(&stats
, useraddr
, sizeof(stats
)))
1166 stats
.n_stats
= n_stats
;
1167 data
= kmalloc(n_stats
* sizeof(u64
), GFP_USER
);
1171 ops
->get_ethtool_stats(dev
, &stats
, data
);
1174 if (copy_to_user(useraddr
, &stats
, sizeof(stats
)))
1176 useraddr
+= sizeof(stats
);
1177 if (copy_to_user(useraddr
, data
, stats
.n_stats
* sizeof(u64
)))
1186 static int ethtool_get_perm_addr(struct net_device
*dev
, void __user
*useraddr
)
1188 struct ethtool_perm_addr epaddr
;
1190 if (copy_from_user(&epaddr
, useraddr
, sizeof(epaddr
)))
1193 if (epaddr
.size
< dev
->addr_len
)
1195 epaddr
.size
= dev
->addr_len
;
1197 if (copy_to_user(useraddr
, &epaddr
, sizeof(epaddr
)))
1199 useraddr
+= sizeof(epaddr
);
1200 if (copy_to_user(useraddr
, dev
->perm_addr
, epaddr
.size
))
1205 static int ethtool_get_value(struct net_device
*dev
, char __user
*useraddr
,
1206 u32 cmd
, u32 (*actor
)(struct net_device
*))
1208 struct ethtool_value edata
= { .cmd
= cmd
};
1213 edata
.data
= actor(dev
);
1215 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
1220 static int ethtool_set_value_void(struct net_device
*dev
, char __user
*useraddr
,
1221 void (*actor
)(struct net_device
*, u32
))
1223 struct ethtool_value edata
;
1228 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1231 actor(dev
, edata
.data
);
1235 static int ethtool_set_value(struct net_device
*dev
, char __user
*useraddr
,
1236 int (*actor
)(struct net_device
*, u32
))
1238 struct ethtool_value edata
;
1243 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1246 return actor(dev
, edata
.data
);
1249 static noinline_for_stack
int ethtool_flash_device(struct net_device
*dev
,
1250 char __user
*useraddr
)
1252 struct ethtool_flash efl
;
1254 if (copy_from_user(&efl
, useraddr
, sizeof(efl
)))
1257 if (!dev
->ethtool_ops
->flash_device
)
1260 efl
.data
[ETHTOOL_FLASH_MAX_FILENAME
- 1] = 0;
1262 return dev
->ethtool_ops
->flash_device(dev
, &efl
);
1265 static int ethtool_set_dump(struct net_device
*dev
,
1266 void __user
*useraddr
)
1268 struct ethtool_dump dump
;
1270 if (!dev
->ethtool_ops
->set_dump
)
1273 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1276 return dev
->ethtool_ops
->set_dump(dev
, &dump
);
1279 static int ethtool_get_dump_flag(struct net_device
*dev
,
1280 void __user
*useraddr
)
1283 struct ethtool_dump dump
;
1284 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1286 if (!ops
->get_dump_flag
)
1289 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1292 ret
= ops
->get_dump_flag(dev
, &dump
);
1296 if (copy_to_user(useraddr
, &dump
, sizeof(dump
)))
1301 static int ethtool_get_dump_data(struct net_device
*dev
,
1302 void __user
*useraddr
)
1306 struct ethtool_dump dump
, tmp
;
1307 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1310 if (!ops
->get_dump_data
|| !ops
->get_dump_flag
)
1313 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1316 memset(&tmp
, 0, sizeof(tmp
));
1317 tmp
.cmd
= ETHTOOL_GET_DUMP_FLAG
;
1318 ret
= ops
->get_dump_flag(dev
, &tmp
);
1322 len
= (tmp
.len
> dump
.len
) ? dump
.len
: tmp
.len
;
1326 data
= vzalloc(tmp
.len
);
1329 ret
= ops
->get_dump_data(dev
, &dump
, data
);
1333 if (copy_to_user(useraddr
, &dump
, sizeof(dump
))) {
1337 useraddr
+= offsetof(struct ethtool_dump
, data
);
1338 if (copy_to_user(useraddr
, data
, len
))
1345 static int ethtool_get_ts_info(struct net_device
*dev
, void __user
*useraddr
)
1348 struct ethtool_ts_info info
;
1349 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1350 struct phy_device
*phydev
= dev
->phydev
;
1352 memset(&info
, 0, sizeof(info
));
1353 info
.cmd
= ETHTOOL_GET_TS_INFO
;
1355 if (phydev
&& phydev
->drv
&& phydev
->drv
->ts_info
) {
1356 err
= phydev
->drv
->ts_info(phydev
, &info
);
1357 } else if (ops
->get_ts_info
) {
1358 err
= ops
->get_ts_info(dev
, &info
);
1360 info
.so_timestamping
=
1361 SOF_TIMESTAMPING_RX_SOFTWARE
|
1362 SOF_TIMESTAMPING_SOFTWARE
;
1363 info
.phc_index
= -1;
1369 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
1375 static int ethtool_get_module_info(struct net_device
*dev
,
1376 void __user
*useraddr
)
1379 struct ethtool_modinfo modinfo
;
1380 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1382 if (!ops
->get_module_info
)
1385 if (copy_from_user(&modinfo
, useraddr
, sizeof(modinfo
)))
1388 ret
= ops
->get_module_info(dev
, &modinfo
);
1392 if (copy_to_user(useraddr
, &modinfo
, sizeof(modinfo
)))
1398 static int ethtool_get_module_eeprom(struct net_device
*dev
,
1399 void __user
*useraddr
)
1402 struct ethtool_modinfo modinfo
;
1403 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1405 if (!ops
->get_module_info
|| !ops
->get_module_eeprom
)
1408 ret
= ops
->get_module_info(dev
, &modinfo
);
1412 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_module_eeprom
,
1413 modinfo
.eeprom_len
);
1416 /* The main entry point in this file. Called from net/core/dev.c */
1418 int dev_ethtool(struct net
*net
, struct ifreq
*ifr
)
1420 struct net_device
*dev
= __dev_get_by_name(net
, ifr
->ifr_name
);
1421 void __user
*useraddr
= ifr
->ifr_data
;
1424 netdev_features_t old_features
;
1426 if (!dev
|| !netif_device_present(dev
))
1429 if (copy_from_user(ðcmd
, useraddr
, sizeof(ethcmd
)))
1432 /* Allow some commands to be done by anyone */
1435 case ETHTOOL_GDRVINFO
:
1436 case ETHTOOL_GMSGLVL
:
1438 case ETHTOOL_GCOALESCE
:
1439 case ETHTOOL_GRINGPARAM
:
1440 case ETHTOOL_GPAUSEPARAM
:
1441 case ETHTOOL_GRXCSUM
:
1442 case ETHTOOL_GTXCSUM
:
1444 case ETHTOOL_GSSET_INFO
:
1445 case ETHTOOL_GSTRINGS
:
1446 case ETHTOOL_GSTATS
:
1448 case ETHTOOL_GPERMADDR
:
1452 case ETHTOOL_GFLAGS
:
1453 case ETHTOOL_GPFLAGS
:
1455 case ETHTOOL_GRXRINGS
:
1456 case ETHTOOL_GRXCLSRLCNT
:
1457 case ETHTOOL_GRXCLSRULE
:
1458 case ETHTOOL_GRXCLSRLALL
:
1459 case ETHTOOL_GRXFHINDIR
:
1460 case ETHTOOL_GFEATURES
:
1461 case ETHTOOL_GCHANNELS
:
1462 case ETHTOOL_GET_TS_INFO
:
1466 if (!ns_capable(net
->user_ns
, CAP_NET_ADMIN
))
1470 if (dev
->ethtool_ops
->begin
) {
1471 rc
= dev
->ethtool_ops
->begin(dev
);
1475 old_features
= dev
->features
;
1479 rc
= ethtool_get_settings(dev
, useraddr
);
1482 rc
= ethtool_set_settings(dev
, useraddr
);
1484 case ETHTOOL_GDRVINFO
:
1485 rc
= ethtool_get_drvinfo(dev
, useraddr
);
1488 rc
= ethtool_get_regs(dev
, useraddr
);
1491 rc
= ethtool_get_wol(dev
, useraddr
);
1494 rc
= ethtool_set_wol(dev
, useraddr
);
1496 case ETHTOOL_GMSGLVL
:
1497 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1498 dev
->ethtool_ops
->get_msglevel
);
1500 case ETHTOOL_SMSGLVL
:
1501 rc
= ethtool_set_value_void(dev
, useraddr
,
1502 dev
->ethtool_ops
->set_msglevel
);
1505 rc
= ethtool_get_eee(dev
, useraddr
);
1508 rc
= ethtool_set_eee(dev
, useraddr
);
1510 case ETHTOOL_NWAY_RST
:
1511 rc
= ethtool_nway_reset(dev
);
1514 rc
= ethtool_get_link(dev
, useraddr
);
1516 case ETHTOOL_GEEPROM
:
1517 rc
= ethtool_get_eeprom(dev
, useraddr
);
1519 case ETHTOOL_SEEPROM
:
1520 rc
= ethtool_set_eeprom(dev
, useraddr
);
1522 case ETHTOOL_GCOALESCE
:
1523 rc
= ethtool_get_coalesce(dev
, useraddr
);
1525 case ETHTOOL_SCOALESCE
:
1526 rc
= ethtool_set_coalesce(dev
, useraddr
);
1528 case ETHTOOL_GRINGPARAM
:
1529 rc
= ethtool_get_ringparam(dev
, useraddr
);
1531 case ETHTOOL_SRINGPARAM
:
1532 rc
= ethtool_set_ringparam(dev
, useraddr
);
1534 case ETHTOOL_GPAUSEPARAM
:
1535 rc
= ethtool_get_pauseparam(dev
, useraddr
);
1537 case ETHTOOL_SPAUSEPARAM
:
1538 rc
= ethtool_set_pauseparam(dev
, useraddr
);
1541 rc
= ethtool_self_test(dev
, useraddr
);
1543 case ETHTOOL_GSTRINGS
:
1544 rc
= ethtool_get_strings(dev
, useraddr
);
1546 case ETHTOOL_PHYS_ID
:
1547 rc
= ethtool_phys_id(dev
, useraddr
);
1549 case ETHTOOL_GSTATS
:
1550 rc
= ethtool_get_stats(dev
, useraddr
);
1552 case ETHTOOL_GPERMADDR
:
1553 rc
= ethtool_get_perm_addr(dev
, useraddr
);
1555 case ETHTOOL_GFLAGS
:
1556 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1557 __ethtool_get_flags
);
1559 case ETHTOOL_SFLAGS
:
1560 rc
= ethtool_set_value(dev
, useraddr
, __ethtool_set_flags
);
1562 case ETHTOOL_GPFLAGS
:
1563 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1564 dev
->ethtool_ops
->get_priv_flags
);
1566 case ETHTOOL_SPFLAGS
:
1567 rc
= ethtool_set_value(dev
, useraddr
,
1568 dev
->ethtool_ops
->set_priv_flags
);
1571 case ETHTOOL_GRXRINGS
:
1572 case ETHTOOL_GRXCLSRLCNT
:
1573 case ETHTOOL_GRXCLSRULE
:
1574 case ETHTOOL_GRXCLSRLALL
:
1575 rc
= ethtool_get_rxnfc(dev
, ethcmd
, useraddr
);
1578 case ETHTOOL_SRXCLSRLDEL
:
1579 case ETHTOOL_SRXCLSRLINS
:
1580 rc
= ethtool_set_rxnfc(dev
, ethcmd
, useraddr
);
1582 case ETHTOOL_FLASHDEV
:
1583 rc
= ethtool_flash_device(dev
, useraddr
);
1586 rc
= ethtool_reset(dev
, useraddr
);
1588 case ETHTOOL_GSSET_INFO
:
1589 rc
= ethtool_get_sset_info(dev
, useraddr
);
1591 case ETHTOOL_GRXFHINDIR
:
1592 rc
= ethtool_get_rxfh_indir(dev
, useraddr
);
1594 case ETHTOOL_SRXFHINDIR
:
1595 rc
= ethtool_set_rxfh_indir(dev
, useraddr
);
1597 case ETHTOOL_GFEATURES
:
1598 rc
= ethtool_get_features(dev
, useraddr
);
1600 case ETHTOOL_SFEATURES
:
1601 rc
= ethtool_set_features(dev
, useraddr
);
1603 case ETHTOOL_GTXCSUM
:
1604 case ETHTOOL_GRXCSUM
:
1610 rc
= ethtool_get_one_feature(dev
, useraddr
, ethcmd
);
1612 case ETHTOOL_STXCSUM
:
1613 case ETHTOOL_SRXCSUM
:
1619 rc
= ethtool_set_one_feature(dev
, useraddr
, ethcmd
);
1621 case ETHTOOL_GCHANNELS
:
1622 rc
= ethtool_get_channels(dev
, useraddr
);
1624 case ETHTOOL_SCHANNELS
:
1625 rc
= ethtool_set_channels(dev
, useraddr
);
1627 case ETHTOOL_SET_DUMP
:
1628 rc
= ethtool_set_dump(dev
, useraddr
);
1630 case ETHTOOL_GET_DUMP_FLAG
:
1631 rc
= ethtool_get_dump_flag(dev
, useraddr
);
1633 case ETHTOOL_GET_DUMP_DATA
:
1634 rc
= ethtool_get_dump_data(dev
, useraddr
);
1636 case ETHTOOL_GET_TS_INFO
:
1637 rc
= ethtool_get_ts_info(dev
, useraddr
);
1639 case ETHTOOL_GMODULEINFO
:
1640 rc
= ethtool_get_module_info(dev
, useraddr
);
1642 case ETHTOOL_GMODULEEEPROM
:
1643 rc
= ethtool_get_module_eeprom(dev
, useraddr
);
1649 if (dev
->ethtool_ops
->complete
)
1650 dev
->ethtool_ops
->complete(dev
);
1652 if (old_features
!= dev
->features
)
1653 netdev_features_change(dev
);