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_TX_BIT
] = "tx-vlan-hw-insert",
65 [NETIF_F_HW_VLAN_RX_BIT
] = "rx-vlan-hw-parse",
66 [NETIF_F_HW_VLAN_FILTER_BIT
] = "rx-vlan-filter",
67 [NETIF_F_VLAN_CHALLENGED_BIT
] = "vlan-challenged",
68 [NETIF_F_GSO_BIT
] = "tx-generic-segmentation",
69 [NETIF_F_LLTX_BIT
] = "tx-lockless",
70 [NETIF_F_NETNS_LOCAL_BIT
] = "netns-local",
71 [NETIF_F_GRO_BIT
] = "rx-gro",
72 [NETIF_F_LRO_BIT
] = "rx-lro",
74 [NETIF_F_TSO_BIT
] = "tx-tcp-segmentation",
75 [NETIF_F_UFO_BIT
] = "tx-udp-fragmentation",
76 [NETIF_F_GSO_ROBUST_BIT
] = "tx-gso-robust",
77 [NETIF_F_TSO_ECN_BIT
] = "tx-tcp-ecn-segmentation",
78 [NETIF_F_TSO6_BIT
] = "tx-tcp6-segmentation",
79 [NETIF_F_FSO_BIT
] = "tx-fcoe-segmentation",
80 [NETIF_F_GSO_GRE_BIT
] = "tx-gre-segmentation",
82 [NETIF_F_FCOE_CRC_BIT
] = "tx-checksum-fcoe-crc",
83 [NETIF_F_SCTP_CSUM_BIT
] = "tx-checksum-sctp",
84 [NETIF_F_FCOE_MTU_BIT
] = "fcoe-mtu",
85 [NETIF_F_NTUPLE_BIT
] = "rx-ntuple-filter",
86 [NETIF_F_RXHASH_BIT
] = "rx-hashing",
87 [NETIF_F_RXCSUM_BIT
] = "rx-checksum",
88 [NETIF_F_NOCACHE_COPY_BIT
] = "tx-nocache-copy",
89 [NETIF_F_LOOPBACK_BIT
] = "loopback",
90 [NETIF_F_RXFCS_BIT
] = "rx-fcs",
91 [NETIF_F_RXALL_BIT
] = "rx-all",
94 static int ethtool_get_features(struct net_device
*dev
, void __user
*useraddr
)
96 struct ethtool_gfeatures cmd
= {
97 .cmd
= ETHTOOL_GFEATURES
,
98 .size
= ETHTOOL_DEV_FEATURE_WORDS
,
100 struct ethtool_get_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
101 u32 __user
*sizeaddr
;
105 /* in case feature bits run out again */
106 BUILD_BUG_ON(ETHTOOL_DEV_FEATURE_WORDS
* sizeof(u32
) > sizeof(netdev_features_t
));
108 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
109 features
[i
].available
= (u32
)(dev
->hw_features
>> (32 * i
));
110 features
[i
].requested
= (u32
)(dev
->wanted_features
>> (32 * i
));
111 features
[i
].active
= (u32
)(dev
->features
>> (32 * i
));
112 features
[i
].never_changed
=
113 (u32
)(NETIF_F_NEVER_CHANGE
>> (32 * i
));
116 sizeaddr
= useraddr
+ offsetof(struct ethtool_gfeatures
, size
);
117 if (get_user(copy_size
, sizeaddr
))
120 if (copy_size
> ETHTOOL_DEV_FEATURE_WORDS
)
121 copy_size
= ETHTOOL_DEV_FEATURE_WORDS
;
123 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
125 useraddr
+= sizeof(cmd
);
126 if (copy_to_user(useraddr
, features
, copy_size
* sizeof(*features
)))
132 static int ethtool_set_features(struct net_device
*dev
, void __user
*useraddr
)
134 struct ethtool_sfeatures cmd
;
135 struct ethtool_set_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
136 netdev_features_t wanted
= 0, valid
= 0;
139 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
141 useraddr
+= sizeof(cmd
);
143 if (cmd
.size
!= ETHTOOL_DEV_FEATURE_WORDS
)
146 if (copy_from_user(features
, useraddr
, sizeof(features
)))
149 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
150 valid
|= (netdev_features_t
)features
[i
].valid
<< (32 * i
);
151 wanted
|= (netdev_features_t
)features
[i
].requested
<< (32 * i
);
154 if (valid
& ~NETIF_F_ETHTOOL_BITS
)
157 if (valid
& ~dev
->hw_features
) {
158 valid
&= dev
->hw_features
;
159 ret
|= ETHTOOL_F_UNSUPPORTED
;
162 dev
->wanted_features
&= ~valid
;
163 dev
->wanted_features
|= wanted
& valid
;
164 __netdev_update_features(dev
);
166 if ((dev
->wanted_features
^ dev
->features
) & valid
)
167 ret
|= ETHTOOL_F_WISH
;
172 static int __ethtool_get_sset_count(struct net_device
*dev
, int sset
)
174 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
176 if (sset
== ETH_SS_FEATURES
)
177 return ARRAY_SIZE(netdev_features_strings
);
179 if (ops
->get_sset_count
&& ops
->get_strings
)
180 return ops
->get_sset_count(dev
, sset
);
185 static void __ethtool_get_strings(struct net_device
*dev
,
186 u32 stringset
, u8
*data
)
188 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
190 if (stringset
== ETH_SS_FEATURES
)
191 memcpy(data
, netdev_features_strings
,
192 sizeof(netdev_features_strings
));
194 /* ops->get_strings is valid because checked earlier */
195 ops
->get_strings(dev
, stringset
, data
);
198 static netdev_features_t
ethtool_get_feature_mask(u32 eth_cmd
)
200 /* feature masks of legacy discrete ethtool ops */
203 case ETHTOOL_GTXCSUM
:
204 case ETHTOOL_STXCSUM
:
205 return NETIF_F_ALL_CSUM
| NETIF_F_SCTP_CSUM
;
206 case ETHTOOL_GRXCSUM
:
207 case ETHTOOL_SRXCSUM
:
208 return NETIF_F_RXCSUM
;
214 return NETIF_F_ALL_TSO
;
229 static int ethtool_get_one_feature(struct net_device
*dev
,
230 char __user
*useraddr
, u32 ethcmd
)
232 netdev_features_t mask
= ethtool_get_feature_mask(ethcmd
);
233 struct ethtool_value edata
= {
235 .data
= !!(dev
->features
& mask
),
238 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
243 static int ethtool_set_one_feature(struct net_device
*dev
,
244 void __user
*useraddr
, u32 ethcmd
)
246 struct ethtool_value edata
;
247 netdev_features_t mask
;
249 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
252 mask
= ethtool_get_feature_mask(ethcmd
);
253 mask
&= dev
->hw_features
;
258 dev
->wanted_features
|= mask
;
260 dev
->wanted_features
&= ~mask
;
262 __netdev_update_features(dev
);
267 #define ETH_ALL_FLAGS (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | \
268 ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH)
269 #define ETH_ALL_FEATURES (NETIF_F_LRO | NETIF_F_HW_VLAN_RX | \
270 NETIF_F_HW_VLAN_TX | NETIF_F_NTUPLE | NETIF_F_RXHASH)
272 static u32
__ethtool_get_flags(struct net_device
*dev
)
276 if (dev
->features
& NETIF_F_LRO
) flags
|= ETH_FLAG_LRO
;
277 if (dev
->features
& NETIF_F_HW_VLAN_RX
) flags
|= ETH_FLAG_RXVLAN
;
278 if (dev
->features
& NETIF_F_HW_VLAN_TX
) flags
|= ETH_FLAG_TXVLAN
;
279 if (dev
->features
& NETIF_F_NTUPLE
) flags
|= ETH_FLAG_NTUPLE
;
280 if (dev
->features
& NETIF_F_RXHASH
) flags
|= ETH_FLAG_RXHASH
;
285 static int __ethtool_set_flags(struct net_device
*dev
, u32 data
)
287 netdev_features_t features
= 0, changed
;
289 if (data
& ~ETH_ALL_FLAGS
)
292 if (data
& ETH_FLAG_LRO
) features
|= NETIF_F_LRO
;
293 if (data
& ETH_FLAG_RXVLAN
) features
|= NETIF_F_HW_VLAN_RX
;
294 if (data
& ETH_FLAG_TXVLAN
) features
|= NETIF_F_HW_VLAN_TX
;
295 if (data
& ETH_FLAG_NTUPLE
) features
|= NETIF_F_NTUPLE
;
296 if (data
& ETH_FLAG_RXHASH
) features
|= NETIF_F_RXHASH
;
298 /* allow changing only bits set in hw_features */
299 changed
= (features
^ dev
->features
) & ETH_ALL_FEATURES
;
300 if (changed
& ~dev
->hw_features
)
301 return (changed
& dev
->hw_features
) ? -EINVAL
: -EOPNOTSUPP
;
303 dev
->wanted_features
=
304 (dev
->wanted_features
& ~changed
) | (features
& changed
);
306 __netdev_update_features(dev
);
311 int __ethtool_get_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
315 if (!dev
->ethtool_ops
->get_settings
)
318 memset(cmd
, 0, sizeof(struct ethtool_cmd
));
319 cmd
->cmd
= ETHTOOL_GSET
;
320 return dev
->ethtool_ops
->get_settings(dev
, cmd
);
322 EXPORT_SYMBOL(__ethtool_get_settings
);
324 static int ethtool_get_settings(struct net_device
*dev
, void __user
*useraddr
)
327 struct ethtool_cmd cmd
;
329 err
= __ethtool_get_settings(dev
, &cmd
);
333 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
338 static int ethtool_set_settings(struct net_device
*dev
, void __user
*useraddr
)
340 struct ethtool_cmd cmd
;
342 if (!dev
->ethtool_ops
->set_settings
)
345 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
348 return dev
->ethtool_ops
->set_settings(dev
, &cmd
);
351 static noinline_for_stack
int ethtool_get_drvinfo(struct net_device
*dev
,
352 void __user
*useraddr
)
354 struct ethtool_drvinfo info
;
355 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
357 memset(&info
, 0, sizeof(info
));
358 info
.cmd
= ETHTOOL_GDRVINFO
;
359 if (ops
->get_drvinfo
) {
360 ops
->get_drvinfo(dev
, &info
);
361 } else if (dev
->dev
.parent
&& dev
->dev
.parent
->driver
) {
362 strlcpy(info
.bus_info
, dev_name(dev
->dev
.parent
),
363 sizeof(info
.bus_info
));
364 strlcpy(info
.driver
, dev
->dev
.parent
->driver
->name
,
365 sizeof(info
.driver
));
371 * this method of obtaining string set info is deprecated;
372 * Use ETHTOOL_GSSET_INFO instead.
374 if (ops
->get_sset_count
) {
377 rc
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
379 info
.testinfo_len
= rc
;
380 rc
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
383 rc
= ops
->get_sset_count(dev
, ETH_SS_PRIV_FLAGS
);
385 info
.n_priv_flags
= rc
;
387 if (ops
->get_regs_len
)
388 info
.regdump_len
= ops
->get_regs_len(dev
);
389 if (ops
->get_eeprom_len
)
390 info
.eedump_len
= ops
->get_eeprom_len(dev
);
392 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
397 static noinline_for_stack
int ethtool_get_sset_info(struct net_device
*dev
,
398 void __user
*useraddr
)
400 struct ethtool_sset_info info
;
402 int i
, idx
= 0, n_bits
= 0, ret
, rc
;
403 u32
*info_buf
= NULL
;
405 if (copy_from_user(&info
, useraddr
, sizeof(info
)))
408 /* store copy of mask, because we zero struct later on */
409 sset_mask
= info
.sset_mask
;
413 /* calculate size of return buffer */
414 n_bits
= hweight64(sset_mask
);
416 memset(&info
, 0, sizeof(info
));
417 info
.cmd
= ETHTOOL_GSSET_INFO
;
419 info_buf
= kzalloc(n_bits
* sizeof(u32
), GFP_USER
);
424 * fill return buffer based on input bitmask and successful
425 * get_sset_count return
427 for (i
= 0; i
< 64; i
++) {
428 if (!(sset_mask
& (1ULL << i
)))
431 rc
= __ethtool_get_sset_count(dev
, i
);
433 info
.sset_mask
|= (1ULL << i
);
434 info_buf
[idx
++] = rc
;
439 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
442 useraddr
+= offsetof(struct ethtool_sset_info
, data
);
443 if (copy_to_user(useraddr
, info_buf
, idx
* sizeof(u32
)))
453 static noinline_for_stack
int ethtool_set_rxnfc(struct net_device
*dev
,
454 u32 cmd
, void __user
*useraddr
)
456 struct ethtool_rxnfc info
;
457 size_t info_size
= sizeof(info
);
460 if (!dev
->ethtool_ops
->set_rxnfc
)
463 /* struct ethtool_rxnfc was originally defined for
464 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
465 * members. User-space might still be using that
467 if (cmd
== ETHTOOL_SRXFH
)
468 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
471 if (copy_from_user(&info
, useraddr
, info_size
))
474 rc
= dev
->ethtool_ops
->set_rxnfc(dev
, &info
);
478 if (cmd
== ETHTOOL_SRXCLSRLINS
&&
479 copy_to_user(useraddr
, &info
, info_size
))
485 static noinline_for_stack
int ethtool_get_rxnfc(struct net_device
*dev
,
486 u32 cmd
, void __user
*useraddr
)
488 struct ethtool_rxnfc info
;
489 size_t info_size
= sizeof(info
);
490 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
492 void *rule_buf
= NULL
;
497 /* struct ethtool_rxnfc was originally defined for
498 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
499 * members. User-space might still be using that
501 if (cmd
== ETHTOOL_GRXFH
)
502 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
505 if (copy_from_user(&info
, useraddr
, info_size
))
508 if (info
.cmd
== ETHTOOL_GRXCLSRLALL
) {
509 if (info
.rule_cnt
> 0) {
510 if (info
.rule_cnt
<= KMALLOC_MAX_SIZE
/ sizeof(u32
))
511 rule_buf
= kzalloc(info
.rule_cnt
* sizeof(u32
),
518 ret
= ops
->get_rxnfc(dev
, &info
, rule_buf
);
523 if (copy_to_user(useraddr
, &info
, info_size
))
527 useraddr
+= offsetof(struct ethtool_rxnfc
, rule_locs
);
528 if (copy_to_user(useraddr
, rule_buf
,
529 info
.rule_cnt
* sizeof(u32
)))
540 static noinline_for_stack
int ethtool_get_rxfh_indir(struct net_device
*dev
,
541 void __user
*useraddr
)
543 u32 user_size
, dev_size
;
547 if (!dev
->ethtool_ops
->get_rxfh_indir_size
||
548 !dev
->ethtool_ops
->get_rxfh_indir
)
550 dev_size
= dev
->ethtool_ops
->get_rxfh_indir_size(dev
);
554 if (copy_from_user(&user_size
,
555 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
559 if (copy_to_user(useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
560 &dev_size
, sizeof(dev_size
)))
563 /* If the user buffer size is 0, this is just a query for the
564 * device table size. Otherwise, if it's smaller than the
565 * device table size it's an error.
567 if (user_size
< dev_size
)
568 return user_size
== 0 ? 0 : -EINVAL
;
570 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
574 ret
= dev
->ethtool_ops
->get_rxfh_indir(dev
, indir
);
578 if (copy_to_user(useraddr
+
579 offsetof(struct ethtool_rxfh_indir
, ring_index
[0]),
580 indir
, dev_size
* sizeof(indir
[0])))
588 static noinline_for_stack
int ethtool_set_rxfh_indir(struct net_device
*dev
,
589 void __user
*useraddr
)
591 struct ethtool_rxnfc rx_rings
;
592 u32 user_size
, dev_size
, i
;
594 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
597 if (!ops
->get_rxfh_indir_size
|| !ops
->set_rxfh_indir
||
601 dev_size
= ops
->get_rxfh_indir_size(dev
);
605 if (copy_from_user(&user_size
,
606 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
610 if (user_size
!= 0 && user_size
!= dev_size
)
613 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
617 rx_rings
.cmd
= ETHTOOL_GRXRINGS
;
618 ret
= ops
->get_rxnfc(dev
, &rx_rings
, NULL
);
622 if (user_size
== 0) {
623 for (i
= 0; i
< dev_size
; i
++)
624 indir
[i
] = ethtool_rxfh_indir_default(i
, rx_rings
.data
);
626 if (copy_from_user(indir
,
628 offsetof(struct ethtool_rxfh_indir
,
630 dev_size
* sizeof(indir
[0]))) {
635 /* Validate ring indices */
636 for (i
= 0; i
< dev_size
; i
++) {
637 if (indir
[i
] >= rx_rings
.data
) {
644 ret
= ops
->set_rxfh_indir(dev
, indir
);
651 static int ethtool_get_regs(struct net_device
*dev
, char __user
*useraddr
)
653 struct ethtool_regs regs
;
654 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
658 if (!ops
->get_regs
|| !ops
->get_regs_len
)
661 if (copy_from_user(®s
, useraddr
, sizeof(regs
)))
664 reglen
= ops
->get_regs_len(dev
);
665 if (regs
.len
> reglen
)
668 regbuf
= vzalloc(reglen
);
669 if (reglen
&& !regbuf
)
672 ops
->get_regs(dev
, ®s
, regbuf
);
675 if (copy_to_user(useraddr
, ®s
, sizeof(regs
)))
677 useraddr
+= offsetof(struct ethtool_regs
, data
);
678 if (regbuf
&& copy_to_user(useraddr
, regbuf
, regs
.len
))
687 static int ethtool_reset(struct net_device
*dev
, char __user
*useraddr
)
689 struct ethtool_value reset
;
692 if (!dev
->ethtool_ops
->reset
)
695 if (copy_from_user(&reset
, useraddr
, sizeof(reset
)))
698 ret
= dev
->ethtool_ops
->reset(dev
, &reset
.data
);
702 if (copy_to_user(useraddr
, &reset
, sizeof(reset
)))
707 static int ethtool_get_wol(struct net_device
*dev
, char __user
*useraddr
)
709 struct ethtool_wolinfo wol
= { .cmd
= ETHTOOL_GWOL
};
711 if (!dev
->ethtool_ops
->get_wol
)
714 dev
->ethtool_ops
->get_wol(dev
, &wol
);
716 if (copy_to_user(useraddr
, &wol
, sizeof(wol
)))
721 static int ethtool_set_wol(struct net_device
*dev
, char __user
*useraddr
)
723 struct ethtool_wolinfo wol
;
725 if (!dev
->ethtool_ops
->set_wol
)
728 if (copy_from_user(&wol
, useraddr
, sizeof(wol
)))
731 return dev
->ethtool_ops
->set_wol(dev
, &wol
);
734 static int ethtool_get_eee(struct net_device
*dev
, char __user
*useraddr
)
736 struct ethtool_eee edata
;
739 if (!dev
->ethtool_ops
->get_eee
)
742 memset(&edata
, 0, sizeof(struct ethtool_eee
));
743 edata
.cmd
= ETHTOOL_GEEE
;
744 rc
= dev
->ethtool_ops
->get_eee(dev
, &edata
);
749 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
755 static int ethtool_set_eee(struct net_device
*dev
, char __user
*useraddr
)
757 struct ethtool_eee edata
;
759 if (!dev
->ethtool_ops
->set_eee
)
762 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
765 return dev
->ethtool_ops
->set_eee(dev
, &edata
);
768 static int ethtool_nway_reset(struct net_device
*dev
)
770 if (!dev
->ethtool_ops
->nway_reset
)
773 return dev
->ethtool_ops
->nway_reset(dev
);
776 static int ethtool_get_link(struct net_device
*dev
, char __user
*useraddr
)
778 struct ethtool_value edata
= { .cmd
= ETHTOOL_GLINK
};
780 if (!dev
->ethtool_ops
->get_link
)
783 edata
.data
= netif_running(dev
) && dev
->ethtool_ops
->get_link(dev
);
785 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
790 static int ethtool_get_any_eeprom(struct net_device
*dev
, void __user
*useraddr
,
791 int (*getter
)(struct net_device
*,
792 struct ethtool_eeprom
*, u8
*),
795 struct ethtool_eeprom eeprom
;
796 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
801 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
804 /* Check for wrap and zero */
805 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
808 /* Check for exceeding total eeprom len */
809 if (eeprom
.offset
+ eeprom
.len
> total_len
)
812 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
816 bytes_remaining
= eeprom
.len
;
817 while (bytes_remaining
> 0) {
818 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
820 ret
= getter(dev
, &eeprom
, data
);
823 if (copy_to_user(userbuf
, data
, eeprom
.len
)) {
827 userbuf
+= eeprom
.len
;
828 eeprom
.offset
+= eeprom
.len
;
829 bytes_remaining
-= eeprom
.len
;
832 eeprom
.len
= userbuf
- (useraddr
+ sizeof(eeprom
));
833 eeprom
.offset
-= eeprom
.len
;
834 if (copy_to_user(useraddr
, &eeprom
, sizeof(eeprom
)))
841 static int ethtool_get_eeprom(struct net_device
*dev
, void __user
*useraddr
)
843 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
845 if (!ops
->get_eeprom
|| !ops
->get_eeprom_len
)
848 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_eeprom
,
849 ops
->get_eeprom_len(dev
));
852 static int ethtool_set_eeprom(struct net_device
*dev
, void __user
*useraddr
)
854 struct ethtool_eeprom eeprom
;
855 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
856 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
861 if (!ops
->set_eeprom
|| !ops
->get_eeprom_len
)
864 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
867 /* Check for wrap and zero */
868 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
871 /* Check for exceeding total eeprom len */
872 if (eeprom
.offset
+ eeprom
.len
> ops
->get_eeprom_len(dev
))
875 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
879 bytes_remaining
= eeprom
.len
;
880 while (bytes_remaining
> 0) {
881 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
883 if (copy_from_user(data
, userbuf
, eeprom
.len
)) {
887 ret
= ops
->set_eeprom(dev
, &eeprom
, data
);
890 userbuf
+= eeprom
.len
;
891 eeprom
.offset
+= eeprom
.len
;
892 bytes_remaining
-= eeprom
.len
;
899 static noinline_for_stack
int ethtool_get_coalesce(struct net_device
*dev
,
900 void __user
*useraddr
)
902 struct ethtool_coalesce coalesce
= { .cmd
= ETHTOOL_GCOALESCE
};
904 if (!dev
->ethtool_ops
->get_coalesce
)
907 dev
->ethtool_ops
->get_coalesce(dev
, &coalesce
);
909 if (copy_to_user(useraddr
, &coalesce
, sizeof(coalesce
)))
914 static noinline_for_stack
int ethtool_set_coalesce(struct net_device
*dev
,
915 void __user
*useraddr
)
917 struct ethtool_coalesce coalesce
;
919 if (!dev
->ethtool_ops
->set_coalesce
)
922 if (copy_from_user(&coalesce
, useraddr
, sizeof(coalesce
)))
925 return dev
->ethtool_ops
->set_coalesce(dev
, &coalesce
);
928 static int ethtool_get_ringparam(struct net_device
*dev
, void __user
*useraddr
)
930 struct ethtool_ringparam ringparam
= { .cmd
= ETHTOOL_GRINGPARAM
};
932 if (!dev
->ethtool_ops
->get_ringparam
)
935 dev
->ethtool_ops
->get_ringparam(dev
, &ringparam
);
937 if (copy_to_user(useraddr
, &ringparam
, sizeof(ringparam
)))
942 static int ethtool_set_ringparam(struct net_device
*dev
, void __user
*useraddr
)
944 struct ethtool_ringparam ringparam
;
946 if (!dev
->ethtool_ops
->set_ringparam
)
949 if (copy_from_user(&ringparam
, useraddr
, sizeof(ringparam
)))
952 return dev
->ethtool_ops
->set_ringparam(dev
, &ringparam
);
955 static noinline_for_stack
int ethtool_get_channels(struct net_device
*dev
,
956 void __user
*useraddr
)
958 struct ethtool_channels channels
= { .cmd
= ETHTOOL_GCHANNELS
};
960 if (!dev
->ethtool_ops
->get_channels
)
963 dev
->ethtool_ops
->get_channels(dev
, &channels
);
965 if (copy_to_user(useraddr
, &channels
, sizeof(channels
)))
970 static noinline_for_stack
int ethtool_set_channels(struct net_device
*dev
,
971 void __user
*useraddr
)
973 struct ethtool_channels channels
;
975 if (!dev
->ethtool_ops
->set_channels
)
978 if (copy_from_user(&channels
, useraddr
, sizeof(channels
)))
981 return dev
->ethtool_ops
->set_channels(dev
, &channels
);
984 static int ethtool_get_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
986 struct ethtool_pauseparam pauseparam
= { ETHTOOL_GPAUSEPARAM
};
988 if (!dev
->ethtool_ops
->get_pauseparam
)
991 dev
->ethtool_ops
->get_pauseparam(dev
, &pauseparam
);
993 if (copy_to_user(useraddr
, &pauseparam
, sizeof(pauseparam
)))
998 static int ethtool_set_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1000 struct ethtool_pauseparam pauseparam
;
1002 if (!dev
->ethtool_ops
->set_pauseparam
)
1005 if (copy_from_user(&pauseparam
, useraddr
, sizeof(pauseparam
)))
1008 return dev
->ethtool_ops
->set_pauseparam(dev
, &pauseparam
);
1011 static int ethtool_self_test(struct net_device
*dev
, char __user
*useraddr
)
1013 struct ethtool_test test
;
1014 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1018 if (!ops
->self_test
|| !ops
->get_sset_count
)
1021 test_len
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
1024 WARN_ON(test_len
== 0);
1026 if (copy_from_user(&test
, useraddr
, sizeof(test
)))
1029 test
.len
= test_len
;
1030 data
= kmalloc(test_len
* sizeof(u64
), GFP_USER
);
1034 ops
->self_test(dev
, &test
, data
);
1037 if (copy_to_user(useraddr
, &test
, sizeof(test
)))
1039 useraddr
+= sizeof(test
);
1040 if (copy_to_user(useraddr
, data
, test
.len
* sizeof(u64
)))
1049 static int ethtool_get_strings(struct net_device
*dev
, void __user
*useraddr
)
1051 struct ethtool_gstrings gstrings
;
1055 if (copy_from_user(&gstrings
, useraddr
, sizeof(gstrings
)))
1058 ret
= __ethtool_get_sset_count(dev
, gstrings
.string_set
);
1064 data
= kmalloc(gstrings
.len
* ETH_GSTRING_LEN
, GFP_USER
);
1068 __ethtool_get_strings(dev
, gstrings
.string_set
, data
);
1071 if (copy_to_user(useraddr
, &gstrings
, sizeof(gstrings
)))
1073 useraddr
+= sizeof(gstrings
);
1074 if (copy_to_user(useraddr
, data
, gstrings
.len
* ETH_GSTRING_LEN
))
1083 static int ethtool_phys_id(struct net_device
*dev
, void __user
*useraddr
)
1085 struct ethtool_value id
;
1087 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1090 if (!ops
->set_phys_id
)
1096 if (copy_from_user(&id
, useraddr
, sizeof(id
)))
1099 rc
= ops
->set_phys_id(dev
, ETHTOOL_ID_ACTIVE
);
1103 /* Drop the RTNL lock while waiting, but prevent reentry or
1104 * removal of the device.
1111 /* Driver will handle this itself */
1112 schedule_timeout_interruptible(
1113 id
.data
? (id
.data
* HZ
) : MAX_SCHEDULE_TIMEOUT
);
1115 /* Driver expects to be called at twice the frequency in rc */
1116 int n
= rc
* 2, i
, interval
= HZ
/ n
;
1118 /* Count down seconds */
1120 /* Count down iterations per second */
1124 rc
= ops
->set_phys_id(dev
,
1125 (i
& 1) ? ETHTOOL_ID_OFF
: ETHTOOL_ID_ON
);
1129 schedule_timeout_interruptible(interval
);
1130 } while (!signal_pending(current
) && --i
!= 0);
1131 } while (!signal_pending(current
) &&
1132 (id
.data
== 0 || --id
.data
!= 0));
1139 (void) ops
->set_phys_id(dev
, ETHTOOL_ID_INACTIVE
);
1143 static int ethtool_get_stats(struct net_device
*dev
, void __user
*useraddr
)
1145 struct ethtool_stats stats
;
1146 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1150 if (!ops
->get_ethtool_stats
|| !ops
->get_sset_count
)
1153 n_stats
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
1156 WARN_ON(n_stats
== 0);
1158 if (copy_from_user(&stats
, useraddr
, sizeof(stats
)))
1161 stats
.n_stats
= n_stats
;
1162 data
= kmalloc(n_stats
* sizeof(u64
), GFP_USER
);
1166 ops
->get_ethtool_stats(dev
, &stats
, data
);
1169 if (copy_to_user(useraddr
, &stats
, sizeof(stats
)))
1171 useraddr
+= sizeof(stats
);
1172 if (copy_to_user(useraddr
, data
, stats
.n_stats
* sizeof(u64
)))
1181 static int ethtool_get_perm_addr(struct net_device
*dev
, void __user
*useraddr
)
1183 struct ethtool_perm_addr epaddr
;
1185 if (copy_from_user(&epaddr
, useraddr
, sizeof(epaddr
)))
1188 if (epaddr
.size
< dev
->addr_len
)
1190 epaddr
.size
= dev
->addr_len
;
1192 if (copy_to_user(useraddr
, &epaddr
, sizeof(epaddr
)))
1194 useraddr
+= sizeof(epaddr
);
1195 if (copy_to_user(useraddr
, dev
->perm_addr
, epaddr
.size
))
1200 static int ethtool_get_value(struct net_device
*dev
, char __user
*useraddr
,
1201 u32 cmd
, u32 (*actor
)(struct net_device
*))
1203 struct ethtool_value edata
= { .cmd
= cmd
};
1208 edata
.data
= actor(dev
);
1210 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
1215 static int ethtool_set_value_void(struct net_device
*dev
, char __user
*useraddr
,
1216 void (*actor
)(struct net_device
*, u32
))
1218 struct ethtool_value edata
;
1223 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1226 actor(dev
, edata
.data
);
1230 static int ethtool_set_value(struct net_device
*dev
, char __user
*useraddr
,
1231 int (*actor
)(struct net_device
*, u32
))
1233 struct ethtool_value edata
;
1238 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1241 return actor(dev
, edata
.data
);
1244 static noinline_for_stack
int ethtool_flash_device(struct net_device
*dev
,
1245 char __user
*useraddr
)
1247 struct ethtool_flash efl
;
1249 if (copy_from_user(&efl
, useraddr
, sizeof(efl
)))
1252 if (!dev
->ethtool_ops
->flash_device
)
1255 efl
.data
[ETHTOOL_FLASH_MAX_FILENAME
- 1] = 0;
1257 return dev
->ethtool_ops
->flash_device(dev
, &efl
);
1260 static int ethtool_set_dump(struct net_device
*dev
,
1261 void __user
*useraddr
)
1263 struct ethtool_dump dump
;
1265 if (!dev
->ethtool_ops
->set_dump
)
1268 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1271 return dev
->ethtool_ops
->set_dump(dev
, &dump
);
1274 static int ethtool_get_dump_flag(struct net_device
*dev
,
1275 void __user
*useraddr
)
1278 struct ethtool_dump dump
;
1279 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1281 if (!ops
->get_dump_flag
)
1284 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1287 ret
= ops
->get_dump_flag(dev
, &dump
);
1291 if (copy_to_user(useraddr
, &dump
, sizeof(dump
)))
1296 static int ethtool_get_dump_data(struct net_device
*dev
,
1297 void __user
*useraddr
)
1301 struct ethtool_dump dump
, tmp
;
1302 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1305 if (!ops
->get_dump_data
|| !ops
->get_dump_flag
)
1308 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1311 memset(&tmp
, 0, sizeof(tmp
));
1312 tmp
.cmd
= ETHTOOL_GET_DUMP_FLAG
;
1313 ret
= ops
->get_dump_flag(dev
, &tmp
);
1317 len
= (tmp
.len
> dump
.len
) ? dump
.len
: tmp
.len
;
1321 data
= vzalloc(tmp
.len
);
1324 ret
= ops
->get_dump_data(dev
, &dump
, data
);
1328 if (copy_to_user(useraddr
, &dump
, sizeof(dump
))) {
1332 useraddr
+= offsetof(struct ethtool_dump
, data
);
1333 if (copy_to_user(useraddr
, data
, len
))
1340 static int ethtool_get_ts_info(struct net_device
*dev
, void __user
*useraddr
)
1343 struct ethtool_ts_info info
;
1344 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1345 struct phy_device
*phydev
= dev
->phydev
;
1347 memset(&info
, 0, sizeof(info
));
1348 info
.cmd
= ETHTOOL_GET_TS_INFO
;
1350 if (phydev
&& phydev
->drv
&& phydev
->drv
->ts_info
) {
1351 err
= phydev
->drv
->ts_info(phydev
, &info
);
1352 } else if (ops
->get_ts_info
) {
1353 err
= ops
->get_ts_info(dev
, &info
);
1355 info
.so_timestamping
=
1356 SOF_TIMESTAMPING_RX_SOFTWARE
|
1357 SOF_TIMESTAMPING_SOFTWARE
;
1358 info
.phc_index
= -1;
1364 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
1370 static int ethtool_get_module_info(struct net_device
*dev
,
1371 void __user
*useraddr
)
1374 struct ethtool_modinfo modinfo
;
1375 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1377 if (!ops
->get_module_info
)
1380 if (copy_from_user(&modinfo
, useraddr
, sizeof(modinfo
)))
1383 ret
= ops
->get_module_info(dev
, &modinfo
);
1387 if (copy_to_user(useraddr
, &modinfo
, sizeof(modinfo
)))
1393 static int ethtool_get_module_eeprom(struct net_device
*dev
,
1394 void __user
*useraddr
)
1397 struct ethtool_modinfo modinfo
;
1398 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1400 if (!ops
->get_module_info
|| !ops
->get_module_eeprom
)
1403 ret
= ops
->get_module_info(dev
, &modinfo
);
1407 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_module_eeprom
,
1408 modinfo
.eeprom_len
);
1411 /* The main entry point in this file. Called from net/core/dev.c */
1413 int dev_ethtool(struct net
*net
, struct ifreq
*ifr
)
1415 struct net_device
*dev
= __dev_get_by_name(net
, ifr
->ifr_name
);
1416 void __user
*useraddr
= ifr
->ifr_data
;
1421 if (!dev
|| !netif_device_present(dev
))
1424 if (copy_from_user(ðcmd
, useraddr
, sizeof(ethcmd
)))
1427 /* Allow some commands to be done by anyone */
1430 case ETHTOOL_GDRVINFO
:
1431 case ETHTOOL_GMSGLVL
:
1433 case ETHTOOL_GCOALESCE
:
1434 case ETHTOOL_GRINGPARAM
:
1435 case ETHTOOL_GPAUSEPARAM
:
1436 case ETHTOOL_GRXCSUM
:
1437 case ETHTOOL_GTXCSUM
:
1439 case ETHTOOL_GSSET_INFO
:
1440 case ETHTOOL_GSTRINGS
:
1441 case ETHTOOL_GSTATS
:
1443 case ETHTOOL_GPERMADDR
:
1447 case ETHTOOL_GFLAGS
:
1448 case ETHTOOL_GPFLAGS
:
1450 case ETHTOOL_GRXRINGS
:
1451 case ETHTOOL_GRXCLSRLCNT
:
1452 case ETHTOOL_GRXCLSRULE
:
1453 case ETHTOOL_GRXCLSRLALL
:
1454 case ETHTOOL_GRXFHINDIR
:
1455 case ETHTOOL_GFEATURES
:
1456 case ETHTOOL_GCHANNELS
:
1457 case ETHTOOL_GET_TS_INFO
:
1461 if (!ns_capable(net
->user_ns
, CAP_NET_ADMIN
))
1465 if (dev
->ethtool_ops
->begin
) {
1466 rc
= dev
->ethtool_ops
->begin(dev
);
1470 old_features
= dev
->features
;
1474 rc
= ethtool_get_settings(dev
, useraddr
);
1477 rc
= ethtool_set_settings(dev
, useraddr
);
1479 case ETHTOOL_GDRVINFO
:
1480 rc
= ethtool_get_drvinfo(dev
, useraddr
);
1483 rc
= ethtool_get_regs(dev
, useraddr
);
1486 rc
= ethtool_get_wol(dev
, useraddr
);
1489 rc
= ethtool_set_wol(dev
, useraddr
);
1491 case ETHTOOL_GMSGLVL
:
1492 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1493 dev
->ethtool_ops
->get_msglevel
);
1495 case ETHTOOL_SMSGLVL
:
1496 rc
= ethtool_set_value_void(dev
, useraddr
,
1497 dev
->ethtool_ops
->set_msglevel
);
1500 rc
= ethtool_get_eee(dev
, useraddr
);
1503 rc
= ethtool_set_eee(dev
, useraddr
);
1505 case ETHTOOL_NWAY_RST
:
1506 rc
= ethtool_nway_reset(dev
);
1509 rc
= ethtool_get_link(dev
, useraddr
);
1511 case ETHTOOL_GEEPROM
:
1512 rc
= ethtool_get_eeprom(dev
, useraddr
);
1514 case ETHTOOL_SEEPROM
:
1515 rc
= ethtool_set_eeprom(dev
, useraddr
);
1517 case ETHTOOL_GCOALESCE
:
1518 rc
= ethtool_get_coalesce(dev
, useraddr
);
1520 case ETHTOOL_SCOALESCE
:
1521 rc
= ethtool_set_coalesce(dev
, useraddr
);
1523 case ETHTOOL_GRINGPARAM
:
1524 rc
= ethtool_get_ringparam(dev
, useraddr
);
1526 case ETHTOOL_SRINGPARAM
:
1527 rc
= ethtool_set_ringparam(dev
, useraddr
);
1529 case ETHTOOL_GPAUSEPARAM
:
1530 rc
= ethtool_get_pauseparam(dev
, useraddr
);
1532 case ETHTOOL_SPAUSEPARAM
:
1533 rc
= ethtool_set_pauseparam(dev
, useraddr
);
1536 rc
= ethtool_self_test(dev
, useraddr
);
1538 case ETHTOOL_GSTRINGS
:
1539 rc
= ethtool_get_strings(dev
, useraddr
);
1541 case ETHTOOL_PHYS_ID
:
1542 rc
= ethtool_phys_id(dev
, useraddr
);
1544 case ETHTOOL_GSTATS
:
1545 rc
= ethtool_get_stats(dev
, useraddr
);
1547 case ETHTOOL_GPERMADDR
:
1548 rc
= ethtool_get_perm_addr(dev
, useraddr
);
1550 case ETHTOOL_GFLAGS
:
1551 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1552 __ethtool_get_flags
);
1554 case ETHTOOL_SFLAGS
:
1555 rc
= ethtool_set_value(dev
, useraddr
, __ethtool_set_flags
);
1557 case ETHTOOL_GPFLAGS
:
1558 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1559 dev
->ethtool_ops
->get_priv_flags
);
1561 case ETHTOOL_SPFLAGS
:
1562 rc
= ethtool_set_value(dev
, useraddr
,
1563 dev
->ethtool_ops
->set_priv_flags
);
1566 case ETHTOOL_GRXRINGS
:
1567 case ETHTOOL_GRXCLSRLCNT
:
1568 case ETHTOOL_GRXCLSRULE
:
1569 case ETHTOOL_GRXCLSRLALL
:
1570 rc
= ethtool_get_rxnfc(dev
, ethcmd
, useraddr
);
1573 case ETHTOOL_SRXCLSRLDEL
:
1574 case ETHTOOL_SRXCLSRLINS
:
1575 rc
= ethtool_set_rxnfc(dev
, ethcmd
, useraddr
);
1577 case ETHTOOL_FLASHDEV
:
1578 rc
= ethtool_flash_device(dev
, useraddr
);
1581 rc
= ethtool_reset(dev
, useraddr
);
1583 case ETHTOOL_GSSET_INFO
:
1584 rc
= ethtool_get_sset_info(dev
, useraddr
);
1586 case ETHTOOL_GRXFHINDIR
:
1587 rc
= ethtool_get_rxfh_indir(dev
, useraddr
);
1589 case ETHTOOL_SRXFHINDIR
:
1590 rc
= ethtool_set_rxfh_indir(dev
, useraddr
);
1592 case ETHTOOL_GFEATURES
:
1593 rc
= ethtool_get_features(dev
, useraddr
);
1595 case ETHTOOL_SFEATURES
:
1596 rc
= ethtool_set_features(dev
, useraddr
);
1598 case ETHTOOL_GTXCSUM
:
1599 case ETHTOOL_GRXCSUM
:
1605 rc
= ethtool_get_one_feature(dev
, useraddr
, ethcmd
);
1607 case ETHTOOL_STXCSUM
:
1608 case ETHTOOL_SRXCSUM
:
1614 rc
= ethtool_set_one_feature(dev
, useraddr
, ethcmd
);
1616 case ETHTOOL_GCHANNELS
:
1617 rc
= ethtool_get_channels(dev
, useraddr
);
1619 case ETHTOOL_SCHANNELS
:
1620 rc
= ethtool_set_channels(dev
, useraddr
);
1622 case ETHTOOL_SET_DUMP
:
1623 rc
= ethtool_set_dump(dev
, useraddr
);
1625 case ETHTOOL_GET_DUMP_FLAG
:
1626 rc
= ethtool_get_dump_flag(dev
, useraddr
);
1628 case ETHTOOL_GET_DUMP_DATA
:
1629 rc
= ethtool_get_dump_data(dev
, useraddr
);
1631 case ETHTOOL_GET_TS_INFO
:
1632 rc
= ethtool_get_ts_info(dev
, useraddr
);
1634 case ETHTOOL_GMODULEINFO
:
1635 rc
= ethtool_get_module_info(dev
, useraddr
);
1637 case ETHTOOL_GMODULEEEPROM
:
1638 rc
= ethtool_get_module_eeprom(dev
, useraddr
);
1644 if (dev
->ethtool_ops
->complete
)
1645 dev
->ethtool_ops
->complete(dev
);
1647 if (old_features
!= dev
->features
)
1648 netdev_features_change(dev
);