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_IPIP_BIT
] = "tx-ipip-segmentation",
85 [NETIF_F_GSO_SIT_BIT
] = "tx-sit-segmentation",
86 [NETIF_F_GSO_UDP_TUNNEL_BIT
] = "tx-udp_tnl-segmentation",
87 [NETIF_F_GSO_MPLS_BIT
] = "tx-mpls-segmentation",
89 [NETIF_F_FCOE_CRC_BIT
] = "tx-checksum-fcoe-crc",
90 [NETIF_F_SCTP_CSUM_BIT
] = "tx-checksum-sctp",
91 [NETIF_F_FCOE_MTU_BIT
] = "fcoe-mtu",
92 [NETIF_F_NTUPLE_BIT
] = "rx-ntuple-filter",
93 [NETIF_F_RXHASH_BIT
] = "rx-hashing",
94 [NETIF_F_RXCSUM_BIT
] = "rx-checksum",
95 [NETIF_F_NOCACHE_COPY_BIT
] = "tx-nocache-copy",
96 [NETIF_F_LOOPBACK_BIT
] = "loopback",
97 [NETIF_F_RXFCS_BIT
] = "rx-fcs",
98 [NETIF_F_RXALL_BIT
] = "rx-all",
101 static int ethtool_get_features(struct net_device
*dev
, void __user
*useraddr
)
103 struct ethtool_gfeatures cmd
= {
104 .cmd
= ETHTOOL_GFEATURES
,
105 .size
= ETHTOOL_DEV_FEATURE_WORDS
,
107 struct ethtool_get_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
108 u32 __user
*sizeaddr
;
112 /* in case feature bits run out again */
113 BUILD_BUG_ON(ETHTOOL_DEV_FEATURE_WORDS
* sizeof(u32
) > sizeof(netdev_features_t
));
115 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
116 features
[i
].available
= (u32
)(dev
->hw_features
>> (32 * i
));
117 features
[i
].requested
= (u32
)(dev
->wanted_features
>> (32 * i
));
118 features
[i
].active
= (u32
)(dev
->features
>> (32 * i
));
119 features
[i
].never_changed
=
120 (u32
)(NETIF_F_NEVER_CHANGE
>> (32 * i
));
123 sizeaddr
= useraddr
+ offsetof(struct ethtool_gfeatures
, size
);
124 if (get_user(copy_size
, sizeaddr
))
127 if (copy_size
> ETHTOOL_DEV_FEATURE_WORDS
)
128 copy_size
= ETHTOOL_DEV_FEATURE_WORDS
;
130 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
132 useraddr
+= sizeof(cmd
);
133 if (copy_to_user(useraddr
, features
, copy_size
* sizeof(*features
)))
139 static int ethtool_set_features(struct net_device
*dev
, void __user
*useraddr
)
141 struct ethtool_sfeatures cmd
;
142 struct ethtool_set_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
143 netdev_features_t wanted
= 0, valid
= 0;
146 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
148 useraddr
+= sizeof(cmd
);
150 if (cmd
.size
!= ETHTOOL_DEV_FEATURE_WORDS
)
153 if (copy_from_user(features
, useraddr
, sizeof(features
)))
156 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
157 valid
|= (netdev_features_t
)features
[i
].valid
<< (32 * i
);
158 wanted
|= (netdev_features_t
)features
[i
].requested
<< (32 * i
);
161 if (valid
& ~NETIF_F_ETHTOOL_BITS
)
164 if (valid
& ~dev
->hw_features
) {
165 valid
&= dev
->hw_features
;
166 ret
|= ETHTOOL_F_UNSUPPORTED
;
169 dev
->wanted_features
&= ~valid
;
170 dev
->wanted_features
|= wanted
& valid
;
171 __netdev_update_features(dev
);
173 if ((dev
->wanted_features
^ dev
->features
) & valid
)
174 ret
|= ETHTOOL_F_WISH
;
179 static int __ethtool_get_sset_count(struct net_device
*dev
, int sset
)
181 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
183 if (sset
== ETH_SS_FEATURES
)
184 return ARRAY_SIZE(netdev_features_strings
);
186 if (ops
->get_sset_count
&& ops
->get_strings
)
187 return ops
->get_sset_count(dev
, sset
);
192 static void __ethtool_get_strings(struct net_device
*dev
,
193 u32 stringset
, u8
*data
)
195 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
197 if (stringset
== ETH_SS_FEATURES
)
198 memcpy(data
, netdev_features_strings
,
199 sizeof(netdev_features_strings
));
201 /* ops->get_strings is valid because checked earlier */
202 ops
->get_strings(dev
, stringset
, data
);
205 static netdev_features_t
ethtool_get_feature_mask(u32 eth_cmd
)
207 /* feature masks of legacy discrete ethtool ops */
210 case ETHTOOL_GTXCSUM
:
211 case ETHTOOL_STXCSUM
:
212 return NETIF_F_ALL_CSUM
| NETIF_F_SCTP_CSUM
;
213 case ETHTOOL_GRXCSUM
:
214 case ETHTOOL_SRXCSUM
:
215 return NETIF_F_RXCSUM
;
221 return NETIF_F_ALL_TSO
;
236 static int ethtool_get_one_feature(struct net_device
*dev
,
237 char __user
*useraddr
, u32 ethcmd
)
239 netdev_features_t mask
= ethtool_get_feature_mask(ethcmd
);
240 struct ethtool_value edata
= {
242 .data
= !!(dev
->features
& mask
),
245 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
250 static int ethtool_set_one_feature(struct net_device
*dev
,
251 void __user
*useraddr
, u32 ethcmd
)
253 struct ethtool_value edata
;
254 netdev_features_t mask
;
256 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
259 mask
= ethtool_get_feature_mask(ethcmd
);
260 mask
&= dev
->hw_features
;
265 dev
->wanted_features
|= mask
;
267 dev
->wanted_features
&= ~mask
;
269 __netdev_update_features(dev
);
274 #define ETH_ALL_FLAGS (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | \
275 ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH)
276 #define ETH_ALL_FEATURES (NETIF_F_LRO | NETIF_F_HW_VLAN_CTAG_RX | \
277 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_NTUPLE | \
280 static u32
__ethtool_get_flags(struct net_device
*dev
)
284 if (dev
->features
& NETIF_F_LRO
)
285 flags
|= ETH_FLAG_LRO
;
286 if (dev
->features
& NETIF_F_HW_VLAN_CTAG_RX
)
287 flags
|= ETH_FLAG_RXVLAN
;
288 if (dev
->features
& NETIF_F_HW_VLAN_CTAG_TX
)
289 flags
|= ETH_FLAG_TXVLAN
;
290 if (dev
->features
& NETIF_F_NTUPLE
)
291 flags
|= ETH_FLAG_NTUPLE
;
292 if (dev
->features
& NETIF_F_RXHASH
)
293 flags
|= ETH_FLAG_RXHASH
;
298 static int __ethtool_set_flags(struct net_device
*dev
, u32 data
)
300 netdev_features_t features
= 0, changed
;
302 if (data
& ~ETH_ALL_FLAGS
)
305 if (data
& ETH_FLAG_LRO
)
306 features
|= NETIF_F_LRO
;
307 if (data
& ETH_FLAG_RXVLAN
)
308 features
|= NETIF_F_HW_VLAN_CTAG_RX
;
309 if (data
& ETH_FLAG_TXVLAN
)
310 features
|= NETIF_F_HW_VLAN_CTAG_TX
;
311 if (data
& ETH_FLAG_NTUPLE
)
312 features
|= NETIF_F_NTUPLE
;
313 if (data
& ETH_FLAG_RXHASH
)
314 features
|= NETIF_F_RXHASH
;
316 /* allow changing only bits set in hw_features */
317 changed
= (features
^ dev
->features
) & ETH_ALL_FEATURES
;
318 if (changed
& ~dev
->hw_features
)
319 return (changed
& dev
->hw_features
) ? -EINVAL
: -EOPNOTSUPP
;
321 dev
->wanted_features
=
322 (dev
->wanted_features
& ~changed
) | (features
& changed
);
324 __netdev_update_features(dev
);
329 int __ethtool_get_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
333 if (!dev
->ethtool_ops
->get_settings
)
336 memset(cmd
, 0, sizeof(struct ethtool_cmd
));
337 cmd
->cmd
= ETHTOOL_GSET
;
338 return dev
->ethtool_ops
->get_settings(dev
, cmd
);
340 EXPORT_SYMBOL(__ethtool_get_settings
);
342 static int ethtool_get_settings(struct net_device
*dev
, void __user
*useraddr
)
345 struct ethtool_cmd cmd
;
347 err
= __ethtool_get_settings(dev
, &cmd
);
351 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
356 static int ethtool_set_settings(struct net_device
*dev
, void __user
*useraddr
)
358 struct ethtool_cmd cmd
;
360 if (!dev
->ethtool_ops
->set_settings
)
363 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
366 return dev
->ethtool_ops
->set_settings(dev
, &cmd
);
369 static noinline_for_stack
int ethtool_get_drvinfo(struct net_device
*dev
,
370 void __user
*useraddr
)
372 struct ethtool_drvinfo info
;
373 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
375 memset(&info
, 0, sizeof(info
));
376 info
.cmd
= ETHTOOL_GDRVINFO
;
377 if (ops
->get_drvinfo
) {
378 ops
->get_drvinfo(dev
, &info
);
379 } else if (dev
->dev
.parent
&& dev
->dev
.parent
->driver
) {
380 strlcpy(info
.bus_info
, dev_name(dev
->dev
.parent
),
381 sizeof(info
.bus_info
));
382 strlcpy(info
.driver
, dev
->dev
.parent
->driver
->name
,
383 sizeof(info
.driver
));
389 * this method of obtaining string set info is deprecated;
390 * Use ETHTOOL_GSSET_INFO instead.
392 if (ops
->get_sset_count
) {
395 rc
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
397 info
.testinfo_len
= rc
;
398 rc
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
401 rc
= ops
->get_sset_count(dev
, ETH_SS_PRIV_FLAGS
);
403 info
.n_priv_flags
= rc
;
405 if (ops
->get_regs_len
)
406 info
.regdump_len
= ops
->get_regs_len(dev
);
407 if (ops
->get_eeprom_len
)
408 info
.eedump_len
= ops
->get_eeprom_len(dev
);
410 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
415 static noinline_for_stack
int ethtool_get_sset_info(struct net_device
*dev
,
416 void __user
*useraddr
)
418 struct ethtool_sset_info info
;
420 int i
, idx
= 0, n_bits
= 0, ret
, rc
;
421 u32
*info_buf
= NULL
;
423 if (copy_from_user(&info
, useraddr
, sizeof(info
)))
426 /* store copy of mask, because we zero struct later on */
427 sset_mask
= info
.sset_mask
;
431 /* calculate size of return buffer */
432 n_bits
= hweight64(sset_mask
);
434 memset(&info
, 0, sizeof(info
));
435 info
.cmd
= ETHTOOL_GSSET_INFO
;
437 info_buf
= kzalloc(n_bits
* sizeof(u32
), GFP_USER
);
442 * fill return buffer based on input bitmask and successful
443 * get_sset_count return
445 for (i
= 0; i
< 64; i
++) {
446 if (!(sset_mask
& (1ULL << i
)))
449 rc
= __ethtool_get_sset_count(dev
, i
);
451 info
.sset_mask
|= (1ULL << i
);
452 info_buf
[idx
++] = rc
;
457 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
460 useraddr
+= offsetof(struct ethtool_sset_info
, data
);
461 if (copy_to_user(useraddr
, info_buf
, idx
* sizeof(u32
)))
471 static noinline_for_stack
int ethtool_set_rxnfc(struct net_device
*dev
,
472 u32 cmd
, void __user
*useraddr
)
474 struct ethtool_rxnfc info
;
475 size_t info_size
= sizeof(info
);
478 if (!dev
->ethtool_ops
->set_rxnfc
)
481 /* struct ethtool_rxnfc was originally defined for
482 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
483 * members. User-space might still be using that
485 if (cmd
== ETHTOOL_SRXFH
)
486 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
489 if (copy_from_user(&info
, useraddr
, info_size
))
492 rc
= dev
->ethtool_ops
->set_rxnfc(dev
, &info
);
496 if (cmd
== ETHTOOL_SRXCLSRLINS
&&
497 copy_to_user(useraddr
, &info
, info_size
))
503 static noinline_for_stack
int ethtool_get_rxnfc(struct net_device
*dev
,
504 u32 cmd
, void __user
*useraddr
)
506 struct ethtool_rxnfc info
;
507 size_t info_size
= sizeof(info
);
508 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
510 void *rule_buf
= NULL
;
515 /* struct ethtool_rxnfc was originally defined for
516 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
517 * members. User-space might still be using that
519 if (cmd
== ETHTOOL_GRXFH
)
520 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
523 if (copy_from_user(&info
, useraddr
, info_size
))
526 if (info
.cmd
== ETHTOOL_GRXCLSRLALL
) {
527 if (info
.rule_cnt
> 0) {
528 if (info
.rule_cnt
<= KMALLOC_MAX_SIZE
/ sizeof(u32
))
529 rule_buf
= kzalloc(info
.rule_cnt
* sizeof(u32
),
536 ret
= ops
->get_rxnfc(dev
, &info
, rule_buf
);
541 if (copy_to_user(useraddr
, &info
, info_size
))
545 useraddr
+= offsetof(struct ethtool_rxnfc
, rule_locs
);
546 if (copy_to_user(useraddr
, rule_buf
,
547 info
.rule_cnt
* sizeof(u32
)))
558 static noinline_for_stack
int ethtool_get_rxfh_indir(struct net_device
*dev
,
559 void __user
*useraddr
)
561 u32 user_size
, dev_size
;
565 if (!dev
->ethtool_ops
->get_rxfh_indir_size
||
566 !dev
->ethtool_ops
->get_rxfh_indir
)
568 dev_size
= dev
->ethtool_ops
->get_rxfh_indir_size(dev
);
572 if (copy_from_user(&user_size
,
573 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
577 if (copy_to_user(useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
578 &dev_size
, sizeof(dev_size
)))
581 /* If the user buffer size is 0, this is just a query for the
582 * device table size. Otherwise, if it's smaller than the
583 * device table size it's an error.
585 if (user_size
< dev_size
)
586 return user_size
== 0 ? 0 : -EINVAL
;
588 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
592 ret
= dev
->ethtool_ops
->get_rxfh_indir(dev
, indir
);
596 if (copy_to_user(useraddr
+
597 offsetof(struct ethtool_rxfh_indir
, ring_index
[0]),
598 indir
, dev_size
* sizeof(indir
[0])))
606 static noinline_for_stack
int ethtool_set_rxfh_indir(struct net_device
*dev
,
607 void __user
*useraddr
)
609 struct ethtool_rxnfc rx_rings
;
610 u32 user_size
, dev_size
, i
;
612 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
615 if (!ops
->get_rxfh_indir_size
|| !ops
->set_rxfh_indir
||
619 dev_size
= ops
->get_rxfh_indir_size(dev
);
623 if (copy_from_user(&user_size
,
624 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
628 if (user_size
!= 0 && user_size
!= dev_size
)
631 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
635 rx_rings
.cmd
= ETHTOOL_GRXRINGS
;
636 ret
= ops
->get_rxnfc(dev
, &rx_rings
, NULL
);
640 if (user_size
== 0) {
641 for (i
= 0; i
< dev_size
; i
++)
642 indir
[i
] = ethtool_rxfh_indir_default(i
, rx_rings
.data
);
644 if (copy_from_user(indir
,
646 offsetof(struct ethtool_rxfh_indir
,
648 dev_size
* sizeof(indir
[0]))) {
653 /* Validate ring indices */
654 for (i
= 0; i
< dev_size
; i
++) {
655 if (indir
[i
] >= rx_rings
.data
) {
662 ret
= ops
->set_rxfh_indir(dev
, indir
);
669 static int ethtool_get_regs(struct net_device
*dev
, char __user
*useraddr
)
671 struct ethtool_regs regs
;
672 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
676 if (!ops
->get_regs
|| !ops
->get_regs_len
)
679 if (copy_from_user(®s
, useraddr
, sizeof(regs
)))
682 reglen
= ops
->get_regs_len(dev
);
683 if (regs
.len
> reglen
)
686 regbuf
= vzalloc(reglen
);
687 if (reglen
&& !regbuf
)
690 ops
->get_regs(dev
, ®s
, regbuf
);
693 if (copy_to_user(useraddr
, ®s
, sizeof(regs
)))
695 useraddr
+= offsetof(struct ethtool_regs
, data
);
696 if (regbuf
&& copy_to_user(useraddr
, regbuf
, regs
.len
))
705 static int ethtool_reset(struct net_device
*dev
, char __user
*useraddr
)
707 struct ethtool_value reset
;
710 if (!dev
->ethtool_ops
->reset
)
713 if (copy_from_user(&reset
, useraddr
, sizeof(reset
)))
716 ret
= dev
->ethtool_ops
->reset(dev
, &reset
.data
);
720 if (copy_to_user(useraddr
, &reset
, sizeof(reset
)))
725 static int ethtool_get_wol(struct net_device
*dev
, char __user
*useraddr
)
727 struct ethtool_wolinfo wol
= { .cmd
= ETHTOOL_GWOL
};
729 if (!dev
->ethtool_ops
->get_wol
)
732 dev
->ethtool_ops
->get_wol(dev
, &wol
);
734 if (copy_to_user(useraddr
, &wol
, sizeof(wol
)))
739 static int ethtool_set_wol(struct net_device
*dev
, char __user
*useraddr
)
741 struct ethtool_wolinfo wol
;
743 if (!dev
->ethtool_ops
->set_wol
)
746 if (copy_from_user(&wol
, useraddr
, sizeof(wol
)))
749 return dev
->ethtool_ops
->set_wol(dev
, &wol
);
752 static int ethtool_get_eee(struct net_device
*dev
, char __user
*useraddr
)
754 struct ethtool_eee edata
;
757 if (!dev
->ethtool_ops
->get_eee
)
760 memset(&edata
, 0, sizeof(struct ethtool_eee
));
761 edata
.cmd
= ETHTOOL_GEEE
;
762 rc
= dev
->ethtool_ops
->get_eee(dev
, &edata
);
767 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
773 static int ethtool_set_eee(struct net_device
*dev
, char __user
*useraddr
)
775 struct ethtool_eee edata
;
777 if (!dev
->ethtool_ops
->set_eee
)
780 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
783 return dev
->ethtool_ops
->set_eee(dev
, &edata
);
786 static int ethtool_nway_reset(struct net_device
*dev
)
788 if (!dev
->ethtool_ops
->nway_reset
)
791 return dev
->ethtool_ops
->nway_reset(dev
);
794 static int ethtool_get_link(struct net_device
*dev
, char __user
*useraddr
)
796 struct ethtool_value edata
= { .cmd
= ETHTOOL_GLINK
};
798 if (!dev
->ethtool_ops
->get_link
)
801 edata
.data
= netif_running(dev
) && dev
->ethtool_ops
->get_link(dev
);
803 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
808 static int ethtool_get_any_eeprom(struct net_device
*dev
, void __user
*useraddr
,
809 int (*getter
)(struct net_device
*,
810 struct ethtool_eeprom
*, u8
*),
813 struct ethtool_eeprom eeprom
;
814 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
819 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
822 /* Check for wrap and zero */
823 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
826 /* Check for exceeding total eeprom len */
827 if (eeprom
.offset
+ eeprom
.len
> total_len
)
830 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
834 bytes_remaining
= eeprom
.len
;
835 while (bytes_remaining
> 0) {
836 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
838 ret
= getter(dev
, &eeprom
, data
);
841 if (copy_to_user(userbuf
, data
, eeprom
.len
)) {
845 userbuf
+= eeprom
.len
;
846 eeprom
.offset
+= eeprom
.len
;
847 bytes_remaining
-= eeprom
.len
;
850 eeprom
.len
= userbuf
- (useraddr
+ sizeof(eeprom
));
851 eeprom
.offset
-= eeprom
.len
;
852 if (copy_to_user(useraddr
, &eeprom
, sizeof(eeprom
)))
859 static int ethtool_get_eeprom(struct net_device
*dev
, void __user
*useraddr
)
861 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
863 if (!ops
->get_eeprom
|| !ops
->get_eeprom_len
)
866 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_eeprom
,
867 ops
->get_eeprom_len(dev
));
870 static int ethtool_set_eeprom(struct net_device
*dev
, void __user
*useraddr
)
872 struct ethtool_eeprom eeprom
;
873 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
874 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
879 if (!ops
->set_eeprom
|| !ops
->get_eeprom_len
)
882 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
885 /* Check for wrap and zero */
886 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
889 /* Check for exceeding total eeprom len */
890 if (eeprom
.offset
+ eeprom
.len
> ops
->get_eeprom_len(dev
))
893 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
897 bytes_remaining
= eeprom
.len
;
898 while (bytes_remaining
> 0) {
899 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
901 if (copy_from_user(data
, userbuf
, eeprom
.len
)) {
905 ret
= ops
->set_eeprom(dev
, &eeprom
, data
);
908 userbuf
+= eeprom
.len
;
909 eeprom
.offset
+= eeprom
.len
;
910 bytes_remaining
-= eeprom
.len
;
917 static noinline_for_stack
int ethtool_get_coalesce(struct net_device
*dev
,
918 void __user
*useraddr
)
920 struct ethtool_coalesce coalesce
= { .cmd
= ETHTOOL_GCOALESCE
};
922 if (!dev
->ethtool_ops
->get_coalesce
)
925 dev
->ethtool_ops
->get_coalesce(dev
, &coalesce
);
927 if (copy_to_user(useraddr
, &coalesce
, sizeof(coalesce
)))
932 static noinline_for_stack
int ethtool_set_coalesce(struct net_device
*dev
,
933 void __user
*useraddr
)
935 struct ethtool_coalesce coalesce
;
937 if (!dev
->ethtool_ops
->set_coalesce
)
940 if (copy_from_user(&coalesce
, useraddr
, sizeof(coalesce
)))
943 return dev
->ethtool_ops
->set_coalesce(dev
, &coalesce
);
946 static int ethtool_get_ringparam(struct net_device
*dev
, void __user
*useraddr
)
948 struct ethtool_ringparam ringparam
= { .cmd
= ETHTOOL_GRINGPARAM
};
950 if (!dev
->ethtool_ops
->get_ringparam
)
953 dev
->ethtool_ops
->get_ringparam(dev
, &ringparam
);
955 if (copy_to_user(useraddr
, &ringparam
, sizeof(ringparam
)))
960 static int ethtool_set_ringparam(struct net_device
*dev
, void __user
*useraddr
)
962 struct ethtool_ringparam ringparam
;
964 if (!dev
->ethtool_ops
->set_ringparam
)
967 if (copy_from_user(&ringparam
, useraddr
, sizeof(ringparam
)))
970 return dev
->ethtool_ops
->set_ringparam(dev
, &ringparam
);
973 static noinline_for_stack
int ethtool_get_channels(struct net_device
*dev
,
974 void __user
*useraddr
)
976 struct ethtool_channels channels
= { .cmd
= ETHTOOL_GCHANNELS
};
978 if (!dev
->ethtool_ops
->get_channels
)
981 dev
->ethtool_ops
->get_channels(dev
, &channels
);
983 if (copy_to_user(useraddr
, &channels
, sizeof(channels
)))
988 static noinline_for_stack
int ethtool_set_channels(struct net_device
*dev
,
989 void __user
*useraddr
)
991 struct ethtool_channels channels
;
993 if (!dev
->ethtool_ops
->set_channels
)
996 if (copy_from_user(&channels
, useraddr
, sizeof(channels
)))
999 return dev
->ethtool_ops
->set_channels(dev
, &channels
);
1002 static int ethtool_get_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1004 struct ethtool_pauseparam pauseparam
= { ETHTOOL_GPAUSEPARAM
};
1006 if (!dev
->ethtool_ops
->get_pauseparam
)
1009 dev
->ethtool_ops
->get_pauseparam(dev
, &pauseparam
);
1011 if (copy_to_user(useraddr
, &pauseparam
, sizeof(pauseparam
)))
1016 static int ethtool_set_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1018 struct ethtool_pauseparam pauseparam
;
1020 if (!dev
->ethtool_ops
->set_pauseparam
)
1023 if (copy_from_user(&pauseparam
, useraddr
, sizeof(pauseparam
)))
1026 return dev
->ethtool_ops
->set_pauseparam(dev
, &pauseparam
);
1029 static int ethtool_self_test(struct net_device
*dev
, char __user
*useraddr
)
1031 struct ethtool_test test
;
1032 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1036 if (!ops
->self_test
|| !ops
->get_sset_count
)
1039 test_len
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
1042 WARN_ON(test_len
== 0);
1044 if (copy_from_user(&test
, useraddr
, sizeof(test
)))
1047 test
.len
= test_len
;
1048 data
= kmalloc(test_len
* sizeof(u64
), GFP_USER
);
1052 ops
->self_test(dev
, &test
, data
);
1055 if (copy_to_user(useraddr
, &test
, sizeof(test
)))
1057 useraddr
+= sizeof(test
);
1058 if (copy_to_user(useraddr
, data
, test
.len
* sizeof(u64
)))
1067 static int ethtool_get_strings(struct net_device
*dev
, void __user
*useraddr
)
1069 struct ethtool_gstrings gstrings
;
1073 if (copy_from_user(&gstrings
, useraddr
, sizeof(gstrings
)))
1076 ret
= __ethtool_get_sset_count(dev
, gstrings
.string_set
);
1082 data
= kmalloc(gstrings
.len
* ETH_GSTRING_LEN
, GFP_USER
);
1086 __ethtool_get_strings(dev
, gstrings
.string_set
, data
);
1089 if (copy_to_user(useraddr
, &gstrings
, sizeof(gstrings
)))
1091 useraddr
+= sizeof(gstrings
);
1092 if (copy_to_user(useraddr
, data
, gstrings
.len
* ETH_GSTRING_LEN
))
1101 static int ethtool_phys_id(struct net_device
*dev
, void __user
*useraddr
)
1103 struct ethtool_value id
;
1105 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1108 if (!ops
->set_phys_id
)
1114 if (copy_from_user(&id
, useraddr
, sizeof(id
)))
1117 rc
= ops
->set_phys_id(dev
, ETHTOOL_ID_ACTIVE
);
1121 /* Drop the RTNL lock while waiting, but prevent reentry or
1122 * removal of the device.
1129 /* Driver will handle this itself */
1130 schedule_timeout_interruptible(
1131 id
.data
? (id
.data
* HZ
) : MAX_SCHEDULE_TIMEOUT
);
1133 /* Driver expects to be called at twice the frequency in rc */
1134 int n
= rc
* 2, i
, interval
= HZ
/ n
;
1136 /* Count down seconds */
1138 /* Count down iterations per second */
1142 rc
= ops
->set_phys_id(dev
,
1143 (i
& 1) ? ETHTOOL_ID_OFF
: ETHTOOL_ID_ON
);
1147 schedule_timeout_interruptible(interval
);
1148 } while (!signal_pending(current
) && --i
!= 0);
1149 } while (!signal_pending(current
) &&
1150 (id
.data
== 0 || --id
.data
!= 0));
1157 (void) ops
->set_phys_id(dev
, ETHTOOL_ID_INACTIVE
);
1161 static int ethtool_get_stats(struct net_device
*dev
, void __user
*useraddr
)
1163 struct ethtool_stats stats
;
1164 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1168 if (!ops
->get_ethtool_stats
|| !ops
->get_sset_count
)
1171 n_stats
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
1174 WARN_ON(n_stats
== 0);
1176 if (copy_from_user(&stats
, useraddr
, sizeof(stats
)))
1179 stats
.n_stats
= n_stats
;
1180 data
= kmalloc(n_stats
* sizeof(u64
), GFP_USER
);
1184 ops
->get_ethtool_stats(dev
, &stats
, data
);
1187 if (copy_to_user(useraddr
, &stats
, sizeof(stats
)))
1189 useraddr
+= sizeof(stats
);
1190 if (copy_to_user(useraddr
, data
, stats
.n_stats
* sizeof(u64
)))
1199 static int ethtool_get_perm_addr(struct net_device
*dev
, void __user
*useraddr
)
1201 struct ethtool_perm_addr epaddr
;
1203 if (copy_from_user(&epaddr
, useraddr
, sizeof(epaddr
)))
1206 if (epaddr
.size
< dev
->addr_len
)
1208 epaddr
.size
= dev
->addr_len
;
1210 if (copy_to_user(useraddr
, &epaddr
, sizeof(epaddr
)))
1212 useraddr
+= sizeof(epaddr
);
1213 if (copy_to_user(useraddr
, dev
->perm_addr
, epaddr
.size
))
1218 static int ethtool_get_value(struct net_device
*dev
, char __user
*useraddr
,
1219 u32 cmd
, u32 (*actor
)(struct net_device
*))
1221 struct ethtool_value edata
= { .cmd
= cmd
};
1226 edata
.data
= actor(dev
);
1228 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
1233 static int ethtool_set_value_void(struct net_device
*dev
, char __user
*useraddr
,
1234 void (*actor
)(struct net_device
*, u32
))
1236 struct ethtool_value edata
;
1241 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1244 actor(dev
, edata
.data
);
1248 static int ethtool_set_value(struct net_device
*dev
, char __user
*useraddr
,
1249 int (*actor
)(struct net_device
*, u32
))
1251 struct ethtool_value edata
;
1256 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1259 return actor(dev
, edata
.data
);
1262 static noinline_for_stack
int ethtool_flash_device(struct net_device
*dev
,
1263 char __user
*useraddr
)
1265 struct ethtool_flash efl
;
1267 if (copy_from_user(&efl
, useraddr
, sizeof(efl
)))
1270 if (!dev
->ethtool_ops
->flash_device
)
1273 efl
.data
[ETHTOOL_FLASH_MAX_FILENAME
- 1] = 0;
1275 return dev
->ethtool_ops
->flash_device(dev
, &efl
);
1278 static int ethtool_set_dump(struct net_device
*dev
,
1279 void __user
*useraddr
)
1281 struct ethtool_dump dump
;
1283 if (!dev
->ethtool_ops
->set_dump
)
1286 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1289 return dev
->ethtool_ops
->set_dump(dev
, &dump
);
1292 static int ethtool_get_dump_flag(struct net_device
*dev
,
1293 void __user
*useraddr
)
1296 struct ethtool_dump dump
;
1297 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1299 if (!ops
->get_dump_flag
)
1302 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1305 ret
= ops
->get_dump_flag(dev
, &dump
);
1309 if (copy_to_user(useraddr
, &dump
, sizeof(dump
)))
1314 static int ethtool_get_dump_data(struct net_device
*dev
,
1315 void __user
*useraddr
)
1319 struct ethtool_dump dump
, tmp
;
1320 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1323 if (!ops
->get_dump_data
|| !ops
->get_dump_flag
)
1326 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1329 memset(&tmp
, 0, sizeof(tmp
));
1330 tmp
.cmd
= ETHTOOL_GET_DUMP_FLAG
;
1331 ret
= ops
->get_dump_flag(dev
, &tmp
);
1335 len
= min(tmp
.len
, dump
.len
);
1339 /* Don't ever let the driver think there's more space available
1340 * than it requested with .get_dump_flag().
1344 /* Always allocate enough space to hold the whole thing so that the
1345 * driver does not need to check the length and bother with partial
1348 data
= vzalloc(tmp
.len
);
1351 ret
= ops
->get_dump_data(dev
, &dump
, data
);
1355 /* There are two sane possibilities:
1356 * 1. The driver's .get_dump_data() does not touch dump.len.
1357 * 2. Or it may set dump.len to how much it really writes, which
1358 * should be tmp.len (or len if it can do a partial dump).
1359 * In any case respond to userspace with the actual length of data
1362 WARN_ON(dump
.len
!= len
&& dump
.len
!= tmp
.len
);
1365 if (copy_to_user(useraddr
, &dump
, sizeof(dump
))) {
1369 useraddr
+= offsetof(struct ethtool_dump
, data
);
1370 if (copy_to_user(useraddr
, data
, len
))
1377 static int ethtool_get_ts_info(struct net_device
*dev
, void __user
*useraddr
)
1380 struct ethtool_ts_info info
;
1381 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1382 struct phy_device
*phydev
= dev
->phydev
;
1384 memset(&info
, 0, sizeof(info
));
1385 info
.cmd
= ETHTOOL_GET_TS_INFO
;
1387 if (phydev
&& phydev
->drv
&& phydev
->drv
->ts_info
) {
1388 err
= phydev
->drv
->ts_info(phydev
, &info
);
1389 } else if (ops
->get_ts_info
) {
1390 err
= ops
->get_ts_info(dev
, &info
);
1392 info
.so_timestamping
=
1393 SOF_TIMESTAMPING_RX_SOFTWARE
|
1394 SOF_TIMESTAMPING_SOFTWARE
;
1395 info
.phc_index
= -1;
1401 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
1407 static int ethtool_get_module_info(struct net_device
*dev
,
1408 void __user
*useraddr
)
1411 struct ethtool_modinfo modinfo
;
1412 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1414 if (!ops
->get_module_info
)
1417 if (copy_from_user(&modinfo
, useraddr
, sizeof(modinfo
)))
1420 ret
= ops
->get_module_info(dev
, &modinfo
);
1424 if (copy_to_user(useraddr
, &modinfo
, sizeof(modinfo
)))
1430 static int ethtool_get_module_eeprom(struct net_device
*dev
,
1431 void __user
*useraddr
)
1434 struct ethtool_modinfo modinfo
;
1435 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1437 if (!ops
->get_module_info
|| !ops
->get_module_eeprom
)
1440 ret
= ops
->get_module_info(dev
, &modinfo
);
1444 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_module_eeprom
,
1445 modinfo
.eeprom_len
);
1448 /* The main entry point in this file. Called from net/core/dev_ioctl.c */
1450 int dev_ethtool(struct net
*net
, struct ifreq
*ifr
)
1452 struct net_device
*dev
= __dev_get_by_name(net
, ifr
->ifr_name
);
1453 void __user
*useraddr
= ifr
->ifr_data
;
1456 netdev_features_t old_features
;
1458 if (!dev
|| !netif_device_present(dev
))
1461 if (copy_from_user(ðcmd
, useraddr
, sizeof(ethcmd
)))
1464 /* Allow some commands to be done by anyone */
1467 case ETHTOOL_GDRVINFO
:
1468 case ETHTOOL_GMSGLVL
:
1470 case ETHTOOL_GCOALESCE
:
1471 case ETHTOOL_GRINGPARAM
:
1472 case ETHTOOL_GPAUSEPARAM
:
1473 case ETHTOOL_GRXCSUM
:
1474 case ETHTOOL_GTXCSUM
:
1476 case ETHTOOL_GSSET_INFO
:
1477 case ETHTOOL_GSTRINGS
:
1478 case ETHTOOL_GSTATS
:
1480 case ETHTOOL_GPERMADDR
:
1484 case ETHTOOL_GFLAGS
:
1485 case ETHTOOL_GPFLAGS
:
1487 case ETHTOOL_GRXRINGS
:
1488 case ETHTOOL_GRXCLSRLCNT
:
1489 case ETHTOOL_GRXCLSRULE
:
1490 case ETHTOOL_GRXCLSRLALL
:
1491 case ETHTOOL_GRXFHINDIR
:
1492 case ETHTOOL_GFEATURES
:
1493 case ETHTOOL_GCHANNELS
:
1494 case ETHTOOL_GET_TS_INFO
:
1498 if (!ns_capable(net
->user_ns
, CAP_NET_ADMIN
))
1502 if (dev
->ethtool_ops
->begin
) {
1503 rc
= dev
->ethtool_ops
->begin(dev
);
1507 old_features
= dev
->features
;
1511 rc
= ethtool_get_settings(dev
, useraddr
);
1514 rc
= ethtool_set_settings(dev
, useraddr
);
1516 case ETHTOOL_GDRVINFO
:
1517 rc
= ethtool_get_drvinfo(dev
, useraddr
);
1520 rc
= ethtool_get_regs(dev
, useraddr
);
1523 rc
= ethtool_get_wol(dev
, useraddr
);
1526 rc
= ethtool_set_wol(dev
, useraddr
);
1528 case ETHTOOL_GMSGLVL
:
1529 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1530 dev
->ethtool_ops
->get_msglevel
);
1532 case ETHTOOL_SMSGLVL
:
1533 rc
= ethtool_set_value_void(dev
, useraddr
,
1534 dev
->ethtool_ops
->set_msglevel
);
1537 rc
= ethtool_get_eee(dev
, useraddr
);
1540 rc
= ethtool_set_eee(dev
, useraddr
);
1542 case ETHTOOL_NWAY_RST
:
1543 rc
= ethtool_nway_reset(dev
);
1546 rc
= ethtool_get_link(dev
, useraddr
);
1548 case ETHTOOL_GEEPROM
:
1549 rc
= ethtool_get_eeprom(dev
, useraddr
);
1551 case ETHTOOL_SEEPROM
:
1552 rc
= ethtool_set_eeprom(dev
, useraddr
);
1554 case ETHTOOL_GCOALESCE
:
1555 rc
= ethtool_get_coalesce(dev
, useraddr
);
1557 case ETHTOOL_SCOALESCE
:
1558 rc
= ethtool_set_coalesce(dev
, useraddr
);
1560 case ETHTOOL_GRINGPARAM
:
1561 rc
= ethtool_get_ringparam(dev
, useraddr
);
1563 case ETHTOOL_SRINGPARAM
:
1564 rc
= ethtool_set_ringparam(dev
, useraddr
);
1566 case ETHTOOL_GPAUSEPARAM
:
1567 rc
= ethtool_get_pauseparam(dev
, useraddr
);
1569 case ETHTOOL_SPAUSEPARAM
:
1570 rc
= ethtool_set_pauseparam(dev
, useraddr
);
1573 rc
= ethtool_self_test(dev
, useraddr
);
1575 case ETHTOOL_GSTRINGS
:
1576 rc
= ethtool_get_strings(dev
, useraddr
);
1578 case ETHTOOL_PHYS_ID
:
1579 rc
= ethtool_phys_id(dev
, useraddr
);
1581 case ETHTOOL_GSTATS
:
1582 rc
= ethtool_get_stats(dev
, useraddr
);
1584 case ETHTOOL_GPERMADDR
:
1585 rc
= ethtool_get_perm_addr(dev
, useraddr
);
1587 case ETHTOOL_GFLAGS
:
1588 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1589 __ethtool_get_flags
);
1591 case ETHTOOL_SFLAGS
:
1592 rc
= ethtool_set_value(dev
, useraddr
, __ethtool_set_flags
);
1594 case ETHTOOL_GPFLAGS
:
1595 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1596 dev
->ethtool_ops
->get_priv_flags
);
1598 case ETHTOOL_SPFLAGS
:
1599 rc
= ethtool_set_value(dev
, useraddr
,
1600 dev
->ethtool_ops
->set_priv_flags
);
1603 case ETHTOOL_GRXRINGS
:
1604 case ETHTOOL_GRXCLSRLCNT
:
1605 case ETHTOOL_GRXCLSRULE
:
1606 case ETHTOOL_GRXCLSRLALL
:
1607 rc
= ethtool_get_rxnfc(dev
, ethcmd
, useraddr
);
1610 case ETHTOOL_SRXCLSRLDEL
:
1611 case ETHTOOL_SRXCLSRLINS
:
1612 rc
= ethtool_set_rxnfc(dev
, ethcmd
, useraddr
);
1614 case ETHTOOL_FLASHDEV
:
1615 rc
= ethtool_flash_device(dev
, useraddr
);
1618 rc
= ethtool_reset(dev
, useraddr
);
1620 case ETHTOOL_GSSET_INFO
:
1621 rc
= ethtool_get_sset_info(dev
, useraddr
);
1623 case ETHTOOL_GRXFHINDIR
:
1624 rc
= ethtool_get_rxfh_indir(dev
, useraddr
);
1626 case ETHTOOL_SRXFHINDIR
:
1627 rc
= ethtool_set_rxfh_indir(dev
, useraddr
);
1629 case ETHTOOL_GFEATURES
:
1630 rc
= ethtool_get_features(dev
, useraddr
);
1632 case ETHTOOL_SFEATURES
:
1633 rc
= ethtool_set_features(dev
, useraddr
);
1635 case ETHTOOL_GTXCSUM
:
1636 case ETHTOOL_GRXCSUM
:
1642 rc
= ethtool_get_one_feature(dev
, useraddr
, ethcmd
);
1644 case ETHTOOL_STXCSUM
:
1645 case ETHTOOL_SRXCSUM
:
1651 rc
= ethtool_set_one_feature(dev
, useraddr
, ethcmd
);
1653 case ETHTOOL_GCHANNELS
:
1654 rc
= ethtool_get_channels(dev
, useraddr
);
1656 case ETHTOOL_SCHANNELS
:
1657 rc
= ethtool_set_channels(dev
, useraddr
);
1659 case ETHTOOL_SET_DUMP
:
1660 rc
= ethtool_set_dump(dev
, useraddr
);
1662 case ETHTOOL_GET_DUMP_FLAG
:
1663 rc
= ethtool_get_dump_flag(dev
, useraddr
);
1665 case ETHTOOL_GET_DUMP_DATA
:
1666 rc
= ethtool_get_dump_data(dev
, useraddr
);
1668 case ETHTOOL_GET_TS_INFO
:
1669 rc
= ethtool_get_ts_info(dev
, useraddr
);
1671 case ETHTOOL_GMODULEINFO
:
1672 rc
= ethtool_get_module_info(dev
, useraddr
);
1674 case ETHTOOL_GMODULEEEPROM
:
1675 rc
= ethtool_get_module_eeprom(dev
, useraddr
);
1681 if (dev
->ethtool_ops
->complete
)
1682 dev
->ethtool_ops
->complete(dev
);
1684 if (old_features
!= dev
->features
)
1685 netdev_features_change(dev
);