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",
85 [NETIF_F_GSO_MPLS_BIT
] = "tx-mpls-segmentation",
87 [NETIF_F_FCOE_CRC_BIT
] = "tx-checksum-fcoe-crc",
88 [NETIF_F_SCTP_CSUM_BIT
] = "tx-checksum-sctp",
89 [NETIF_F_FCOE_MTU_BIT
] = "fcoe-mtu",
90 [NETIF_F_NTUPLE_BIT
] = "rx-ntuple-filter",
91 [NETIF_F_RXHASH_BIT
] = "rx-hashing",
92 [NETIF_F_RXCSUM_BIT
] = "rx-checksum",
93 [NETIF_F_NOCACHE_COPY_BIT
] = "tx-nocache-copy",
94 [NETIF_F_LOOPBACK_BIT
] = "loopback",
95 [NETIF_F_RXFCS_BIT
] = "rx-fcs",
96 [NETIF_F_RXALL_BIT
] = "rx-all",
99 static int ethtool_get_features(struct net_device
*dev
, void __user
*useraddr
)
101 struct ethtool_gfeatures cmd
= {
102 .cmd
= ETHTOOL_GFEATURES
,
103 .size
= ETHTOOL_DEV_FEATURE_WORDS
,
105 struct ethtool_get_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
106 u32 __user
*sizeaddr
;
110 /* in case feature bits run out again */
111 BUILD_BUG_ON(ETHTOOL_DEV_FEATURE_WORDS
* sizeof(u32
) > sizeof(netdev_features_t
));
113 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
114 features
[i
].available
= (u32
)(dev
->hw_features
>> (32 * i
));
115 features
[i
].requested
= (u32
)(dev
->wanted_features
>> (32 * i
));
116 features
[i
].active
= (u32
)(dev
->features
>> (32 * i
));
117 features
[i
].never_changed
=
118 (u32
)(NETIF_F_NEVER_CHANGE
>> (32 * i
));
121 sizeaddr
= useraddr
+ offsetof(struct ethtool_gfeatures
, size
);
122 if (get_user(copy_size
, sizeaddr
))
125 if (copy_size
> ETHTOOL_DEV_FEATURE_WORDS
)
126 copy_size
= ETHTOOL_DEV_FEATURE_WORDS
;
128 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
130 useraddr
+= sizeof(cmd
);
131 if (copy_to_user(useraddr
, features
, copy_size
* sizeof(*features
)))
137 static int ethtool_set_features(struct net_device
*dev
, void __user
*useraddr
)
139 struct ethtool_sfeatures cmd
;
140 struct ethtool_set_features_block features
[ETHTOOL_DEV_FEATURE_WORDS
];
141 netdev_features_t wanted
= 0, valid
= 0;
144 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
146 useraddr
+= sizeof(cmd
);
148 if (cmd
.size
!= ETHTOOL_DEV_FEATURE_WORDS
)
151 if (copy_from_user(features
, useraddr
, sizeof(features
)))
154 for (i
= 0; i
< ETHTOOL_DEV_FEATURE_WORDS
; ++i
) {
155 valid
|= (netdev_features_t
)features
[i
].valid
<< (32 * i
);
156 wanted
|= (netdev_features_t
)features
[i
].requested
<< (32 * i
);
159 if (valid
& ~NETIF_F_ETHTOOL_BITS
)
162 if (valid
& ~dev
->hw_features
) {
163 valid
&= dev
->hw_features
;
164 ret
|= ETHTOOL_F_UNSUPPORTED
;
167 dev
->wanted_features
&= ~valid
;
168 dev
->wanted_features
|= wanted
& valid
;
169 __netdev_update_features(dev
);
171 if ((dev
->wanted_features
^ dev
->features
) & valid
)
172 ret
|= ETHTOOL_F_WISH
;
177 static int __ethtool_get_sset_count(struct net_device
*dev
, int sset
)
179 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
181 if (sset
== ETH_SS_FEATURES
)
182 return ARRAY_SIZE(netdev_features_strings
);
184 if (ops
->get_sset_count
&& ops
->get_strings
)
185 return ops
->get_sset_count(dev
, sset
);
190 static void __ethtool_get_strings(struct net_device
*dev
,
191 u32 stringset
, u8
*data
)
193 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
195 if (stringset
== ETH_SS_FEATURES
)
196 memcpy(data
, netdev_features_strings
,
197 sizeof(netdev_features_strings
));
199 /* ops->get_strings is valid because checked earlier */
200 ops
->get_strings(dev
, stringset
, data
);
203 static netdev_features_t
ethtool_get_feature_mask(u32 eth_cmd
)
205 /* feature masks of legacy discrete ethtool ops */
208 case ETHTOOL_GTXCSUM
:
209 case ETHTOOL_STXCSUM
:
210 return NETIF_F_ALL_CSUM
| NETIF_F_SCTP_CSUM
;
211 case ETHTOOL_GRXCSUM
:
212 case ETHTOOL_SRXCSUM
:
213 return NETIF_F_RXCSUM
;
219 return NETIF_F_ALL_TSO
;
234 static int ethtool_get_one_feature(struct net_device
*dev
,
235 char __user
*useraddr
, u32 ethcmd
)
237 netdev_features_t mask
= ethtool_get_feature_mask(ethcmd
);
238 struct ethtool_value edata
= {
240 .data
= !!(dev
->features
& mask
),
243 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
248 static int ethtool_set_one_feature(struct net_device
*dev
,
249 void __user
*useraddr
, u32 ethcmd
)
251 struct ethtool_value edata
;
252 netdev_features_t mask
;
254 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
257 mask
= ethtool_get_feature_mask(ethcmd
);
258 mask
&= dev
->hw_features
;
263 dev
->wanted_features
|= mask
;
265 dev
->wanted_features
&= ~mask
;
267 __netdev_update_features(dev
);
272 #define ETH_ALL_FLAGS (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | \
273 ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH)
274 #define ETH_ALL_FEATURES (NETIF_F_LRO | NETIF_F_HW_VLAN_CTAG_RX | \
275 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_NTUPLE | \
278 static u32
__ethtool_get_flags(struct net_device
*dev
)
282 if (dev
->features
& NETIF_F_LRO
)
283 flags
|= ETH_FLAG_LRO
;
284 if (dev
->features
& NETIF_F_HW_VLAN_CTAG_RX
)
285 flags
|= ETH_FLAG_RXVLAN
;
286 if (dev
->features
& NETIF_F_HW_VLAN_CTAG_TX
)
287 flags
|= ETH_FLAG_TXVLAN
;
288 if (dev
->features
& NETIF_F_NTUPLE
)
289 flags
|= ETH_FLAG_NTUPLE
;
290 if (dev
->features
& NETIF_F_RXHASH
)
291 flags
|= ETH_FLAG_RXHASH
;
296 static int __ethtool_set_flags(struct net_device
*dev
, u32 data
)
298 netdev_features_t features
= 0, changed
;
300 if (data
& ~ETH_ALL_FLAGS
)
303 if (data
& ETH_FLAG_LRO
)
304 features
|= NETIF_F_LRO
;
305 if (data
& ETH_FLAG_RXVLAN
)
306 features
|= NETIF_F_HW_VLAN_CTAG_RX
;
307 if (data
& ETH_FLAG_TXVLAN
)
308 features
|= NETIF_F_HW_VLAN_CTAG_TX
;
309 if (data
& ETH_FLAG_NTUPLE
)
310 features
|= NETIF_F_NTUPLE
;
311 if (data
& ETH_FLAG_RXHASH
)
312 features
|= NETIF_F_RXHASH
;
314 /* allow changing only bits set in hw_features */
315 changed
= (features
^ dev
->features
) & ETH_ALL_FEATURES
;
316 if (changed
& ~dev
->hw_features
)
317 return (changed
& dev
->hw_features
) ? -EINVAL
: -EOPNOTSUPP
;
319 dev
->wanted_features
=
320 (dev
->wanted_features
& ~changed
) | (features
& changed
);
322 __netdev_update_features(dev
);
327 int __ethtool_get_settings(struct net_device
*dev
, struct ethtool_cmd
*cmd
)
331 if (!dev
->ethtool_ops
->get_settings
)
334 memset(cmd
, 0, sizeof(struct ethtool_cmd
));
335 cmd
->cmd
= ETHTOOL_GSET
;
336 return dev
->ethtool_ops
->get_settings(dev
, cmd
);
338 EXPORT_SYMBOL(__ethtool_get_settings
);
340 static int ethtool_get_settings(struct net_device
*dev
, void __user
*useraddr
)
343 struct ethtool_cmd cmd
;
345 err
= __ethtool_get_settings(dev
, &cmd
);
349 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
354 static int ethtool_set_settings(struct net_device
*dev
, void __user
*useraddr
)
356 struct ethtool_cmd cmd
;
358 if (!dev
->ethtool_ops
->set_settings
)
361 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
364 return dev
->ethtool_ops
->set_settings(dev
, &cmd
);
367 static noinline_for_stack
int ethtool_get_drvinfo(struct net_device
*dev
,
368 void __user
*useraddr
)
370 struct ethtool_drvinfo info
;
371 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
373 memset(&info
, 0, sizeof(info
));
374 info
.cmd
= ETHTOOL_GDRVINFO
;
375 if (ops
->get_drvinfo
) {
376 ops
->get_drvinfo(dev
, &info
);
377 } else if (dev
->dev
.parent
&& dev
->dev
.parent
->driver
) {
378 strlcpy(info
.bus_info
, dev_name(dev
->dev
.parent
),
379 sizeof(info
.bus_info
));
380 strlcpy(info
.driver
, dev
->dev
.parent
->driver
->name
,
381 sizeof(info
.driver
));
387 * this method of obtaining string set info is deprecated;
388 * Use ETHTOOL_GSSET_INFO instead.
390 if (ops
->get_sset_count
) {
393 rc
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
395 info
.testinfo_len
= rc
;
396 rc
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
399 rc
= ops
->get_sset_count(dev
, ETH_SS_PRIV_FLAGS
);
401 info
.n_priv_flags
= rc
;
403 if (ops
->get_regs_len
)
404 info
.regdump_len
= ops
->get_regs_len(dev
);
405 if (ops
->get_eeprom_len
)
406 info
.eedump_len
= ops
->get_eeprom_len(dev
);
408 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
413 static noinline_for_stack
int ethtool_get_sset_info(struct net_device
*dev
,
414 void __user
*useraddr
)
416 struct ethtool_sset_info info
;
418 int i
, idx
= 0, n_bits
= 0, ret
, rc
;
419 u32
*info_buf
= NULL
;
421 if (copy_from_user(&info
, useraddr
, sizeof(info
)))
424 /* store copy of mask, because we zero struct later on */
425 sset_mask
= info
.sset_mask
;
429 /* calculate size of return buffer */
430 n_bits
= hweight64(sset_mask
);
432 memset(&info
, 0, sizeof(info
));
433 info
.cmd
= ETHTOOL_GSSET_INFO
;
435 info_buf
= kzalloc(n_bits
* sizeof(u32
), GFP_USER
);
440 * fill return buffer based on input bitmask and successful
441 * get_sset_count return
443 for (i
= 0; i
< 64; i
++) {
444 if (!(sset_mask
& (1ULL << i
)))
447 rc
= __ethtool_get_sset_count(dev
, i
);
449 info
.sset_mask
|= (1ULL << i
);
450 info_buf
[idx
++] = rc
;
455 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
458 useraddr
+= offsetof(struct ethtool_sset_info
, data
);
459 if (copy_to_user(useraddr
, info_buf
, idx
* sizeof(u32
)))
469 static noinline_for_stack
int ethtool_set_rxnfc(struct net_device
*dev
,
470 u32 cmd
, void __user
*useraddr
)
472 struct ethtool_rxnfc info
;
473 size_t info_size
= sizeof(info
);
476 if (!dev
->ethtool_ops
->set_rxnfc
)
479 /* struct ethtool_rxnfc was originally defined for
480 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
481 * members. User-space might still be using that
483 if (cmd
== ETHTOOL_SRXFH
)
484 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
487 if (copy_from_user(&info
, useraddr
, info_size
))
490 rc
= dev
->ethtool_ops
->set_rxnfc(dev
, &info
);
494 if (cmd
== ETHTOOL_SRXCLSRLINS
&&
495 copy_to_user(useraddr
, &info
, info_size
))
501 static noinline_for_stack
int ethtool_get_rxnfc(struct net_device
*dev
,
502 u32 cmd
, void __user
*useraddr
)
504 struct ethtool_rxnfc info
;
505 size_t info_size
= sizeof(info
);
506 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
508 void *rule_buf
= NULL
;
513 /* struct ethtool_rxnfc was originally defined for
514 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
515 * members. User-space might still be using that
517 if (cmd
== ETHTOOL_GRXFH
)
518 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
521 if (copy_from_user(&info
, useraddr
, info_size
))
524 if (info
.cmd
== ETHTOOL_GRXCLSRLALL
) {
525 if (info
.rule_cnt
> 0) {
526 if (info
.rule_cnt
<= KMALLOC_MAX_SIZE
/ sizeof(u32
))
527 rule_buf
= kzalloc(info
.rule_cnt
* sizeof(u32
),
534 ret
= ops
->get_rxnfc(dev
, &info
, rule_buf
);
539 if (copy_to_user(useraddr
, &info
, info_size
))
543 useraddr
+= offsetof(struct ethtool_rxnfc
, rule_locs
);
544 if (copy_to_user(useraddr
, rule_buf
,
545 info
.rule_cnt
* sizeof(u32
)))
556 static noinline_for_stack
int ethtool_get_rxfh_indir(struct net_device
*dev
,
557 void __user
*useraddr
)
559 u32 user_size
, dev_size
;
563 if (!dev
->ethtool_ops
->get_rxfh_indir_size
||
564 !dev
->ethtool_ops
->get_rxfh_indir
)
566 dev_size
= dev
->ethtool_ops
->get_rxfh_indir_size(dev
);
570 if (copy_from_user(&user_size
,
571 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
575 if (copy_to_user(useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
576 &dev_size
, sizeof(dev_size
)))
579 /* If the user buffer size is 0, this is just a query for the
580 * device table size. Otherwise, if it's smaller than the
581 * device table size it's an error.
583 if (user_size
< dev_size
)
584 return user_size
== 0 ? 0 : -EINVAL
;
586 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
590 ret
= dev
->ethtool_ops
->get_rxfh_indir(dev
, indir
);
594 if (copy_to_user(useraddr
+
595 offsetof(struct ethtool_rxfh_indir
, ring_index
[0]),
596 indir
, dev_size
* sizeof(indir
[0])))
604 static noinline_for_stack
int ethtool_set_rxfh_indir(struct net_device
*dev
,
605 void __user
*useraddr
)
607 struct ethtool_rxnfc rx_rings
;
608 u32 user_size
, dev_size
, i
;
610 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
613 if (!ops
->get_rxfh_indir_size
|| !ops
->set_rxfh_indir
||
617 dev_size
= ops
->get_rxfh_indir_size(dev
);
621 if (copy_from_user(&user_size
,
622 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
626 if (user_size
!= 0 && user_size
!= dev_size
)
629 indir
= kcalloc(dev_size
, sizeof(indir
[0]), GFP_USER
);
633 rx_rings
.cmd
= ETHTOOL_GRXRINGS
;
634 ret
= ops
->get_rxnfc(dev
, &rx_rings
, NULL
);
638 if (user_size
== 0) {
639 for (i
= 0; i
< dev_size
; i
++)
640 indir
[i
] = ethtool_rxfh_indir_default(i
, rx_rings
.data
);
642 if (copy_from_user(indir
,
644 offsetof(struct ethtool_rxfh_indir
,
646 dev_size
* sizeof(indir
[0]))) {
651 /* Validate ring indices */
652 for (i
= 0; i
< dev_size
; i
++) {
653 if (indir
[i
] >= rx_rings
.data
) {
660 ret
= ops
->set_rxfh_indir(dev
, indir
);
667 static int ethtool_get_regs(struct net_device
*dev
, char __user
*useraddr
)
669 struct ethtool_regs regs
;
670 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
674 if (!ops
->get_regs
|| !ops
->get_regs_len
)
677 if (copy_from_user(®s
, useraddr
, sizeof(regs
)))
680 reglen
= ops
->get_regs_len(dev
);
681 if (regs
.len
> reglen
)
684 regbuf
= vzalloc(reglen
);
685 if (reglen
&& !regbuf
)
688 ops
->get_regs(dev
, ®s
, regbuf
);
691 if (copy_to_user(useraddr
, ®s
, sizeof(regs
)))
693 useraddr
+= offsetof(struct ethtool_regs
, data
);
694 if (regbuf
&& copy_to_user(useraddr
, regbuf
, regs
.len
))
703 static int ethtool_reset(struct net_device
*dev
, char __user
*useraddr
)
705 struct ethtool_value reset
;
708 if (!dev
->ethtool_ops
->reset
)
711 if (copy_from_user(&reset
, useraddr
, sizeof(reset
)))
714 ret
= dev
->ethtool_ops
->reset(dev
, &reset
.data
);
718 if (copy_to_user(useraddr
, &reset
, sizeof(reset
)))
723 static int ethtool_get_wol(struct net_device
*dev
, char __user
*useraddr
)
725 struct ethtool_wolinfo wol
= { .cmd
= ETHTOOL_GWOL
};
727 if (!dev
->ethtool_ops
->get_wol
)
730 dev
->ethtool_ops
->get_wol(dev
, &wol
);
732 if (copy_to_user(useraddr
, &wol
, sizeof(wol
)))
737 static int ethtool_set_wol(struct net_device
*dev
, char __user
*useraddr
)
739 struct ethtool_wolinfo wol
;
741 if (!dev
->ethtool_ops
->set_wol
)
744 if (copy_from_user(&wol
, useraddr
, sizeof(wol
)))
747 return dev
->ethtool_ops
->set_wol(dev
, &wol
);
750 static int ethtool_get_eee(struct net_device
*dev
, char __user
*useraddr
)
752 struct ethtool_eee edata
;
755 if (!dev
->ethtool_ops
->get_eee
)
758 memset(&edata
, 0, sizeof(struct ethtool_eee
));
759 edata
.cmd
= ETHTOOL_GEEE
;
760 rc
= dev
->ethtool_ops
->get_eee(dev
, &edata
);
765 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
771 static int ethtool_set_eee(struct net_device
*dev
, char __user
*useraddr
)
773 struct ethtool_eee edata
;
775 if (!dev
->ethtool_ops
->set_eee
)
778 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
781 return dev
->ethtool_ops
->set_eee(dev
, &edata
);
784 static int ethtool_nway_reset(struct net_device
*dev
)
786 if (!dev
->ethtool_ops
->nway_reset
)
789 return dev
->ethtool_ops
->nway_reset(dev
);
792 static int ethtool_get_link(struct net_device
*dev
, char __user
*useraddr
)
794 struct ethtool_value edata
= { .cmd
= ETHTOOL_GLINK
};
796 if (!dev
->ethtool_ops
->get_link
)
799 edata
.data
= netif_running(dev
) && dev
->ethtool_ops
->get_link(dev
);
801 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
806 static int ethtool_get_any_eeprom(struct net_device
*dev
, void __user
*useraddr
,
807 int (*getter
)(struct net_device
*,
808 struct ethtool_eeprom
*, u8
*),
811 struct ethtool_eeprom eeprom
;
812 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
817 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
820 /* Check for wrap and zero */
821 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
824 /* Check for exceeding total eeprom len */
825 if (eeprom
.offset
+ eeprom
.len
> total_len
)
828 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
832 bytes_remaining
= eeprom
.len
;
833 while (bytes_remaining
> 0) {
834 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
836 ret
= getter(dev
, &eeprom
, data
);
839 if (copy_to_user(userbuf
, data
, eeprom
.len
)) {
843 userbuf
+= eeprom
.len
;
844 eeprom
.offset
+= eeprom
.len
;
845 bytes_remaining
-= eeprom
.len
;
848 eeprom
.len
= userbuf
- (useraddr
+ sizeof(eeprom
));
849 eeprom
.offset
-= eeprom
.len
;
850 if (copy_to_user(useraddr
, &eeprom
, sizeof(eeprom
)))
857 static int ethtool_get_eeprom(struct net_device
*dev
, void __user
*useraddr
)
859 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
861 if (!ops
->get_eeprom
|| !ops
->get_eeprom_len
)
864 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_eeprom
,
865 ops
->get_eeprom_len(dev
));
868 static int ethtool_set_eeprom(struct net_device
*dev
, void __user
*useraddr
)
870 struct ethtool_eeprom eeprom
;
871 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
872 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
877 if (!ops
->set_eeprom
|| !ops
->get_eeprom_len
)
880 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
883 /* Check for wrap and zero */
884 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
887 /* Check for exceeding total eeprom len */
888 if (eeprom
.offset
+ eeprom
.len
> ops
->get_eeprom_len(dev
))
891 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
895 bytes_remaining
= eeprom
.len
;
896 while (bytes_remaining
> 0) {
897 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
899 if (copy_from_user(data
, userbuf
, eeprom
.len
)) {
903 ret
= ops
->set_eeprom(dev
, &eeprom
, data
);
906 userbuf
+= eeprom
.len
;
907 eeprom
.offset
+= eeprom
.len
;
908 bytes_remaining
-= eeprom
.len
;
915 static noinline_for_stack
int ethtool_get_coalesce(struct net_device
*dev
,
916 void __user
*useraddr
)
918 struct ethtool_coalesce coalesce
= { .cmd
= ETHTOOL_GCOALESCE
};
920 if (!dev
->ethtool_ops
->get_coalesce
)
923 dev
->ethtool_ops
->get_coalesce(dev
, &coalesce
);
925 if (copy_to_user(useraddr
, &coalesce
, sizeof(coalesce
)))
930 static noinline_for_stack
int ethtool_set_coalesce(struct net_device
*dev
,
931 void __user
*useraddr
)
933 struct ethtool_coalesce coalesce
;
935 if (!dev
->ethtool_ops
->set_coalesce
)
938 if (copy_from_user(&coalesce
, useraddr
, sizeof(coalesce
)))
941 return dev
->ethtool_ops
->set_coalesce(dev
, &coalesce
);
944 static int ethtool_get_ringparam(struct net_device
*dev
, void __user
*useraddr
)
946 struct ethtool_ringparam ringparam
= { .cmd
= ETHTOOL_GRINGPARAM
};
948 if (!dev
->ethtool_ops
->get_ringparam
)
951 dev
->ethtool_ops
->get_ringparam(dev
, &ringparam
);
953 if (copy_to_user(useraddr
, &ringparam
, sizeof(ringparam
)))
958 static int ethtool_set_ringparam(struct net_device
*dev
, void __user
*useraddr
)
960 struct ethtool_ringparam ringparam
;
962 if (!dev
->ethtool_ops
->set_ringparam
)
965 if (copy_from_user(&ringparam
, useraddr
, sizeof(ringparam
)))
968 return dev
->ethtool_ops
->set_ringparam(dev
, &ringparam
);
971 static noinline_for_stack
int ethtool_get_channels(struct net_device
*dev
,
972 void __user
*useraddr
)
974 struct ethtool_channels channels
= { .cmd
= ETHTOOL_GCHANNELS
};
976 if (!dev
->ethtool_ops
->get_channels
)
979 dev
->ethtool_ops
->get_channels(dev
, &channels
);
981 if (copy_to_user(useraddr
, &channels
, sizeof(channels
)))
986 static noinline_for_stack
int ethtool_set_channels(struct net_device
*dev
,
987 void __user
*useraddr
)
989 struct ethtool_channels channels
;
991 if (!dev
->ethtool_ops
->set_channels
)
994 if (copy_from_user(&channels
, useraddr
, sizeof(channels
)))
997 return dev
->ethtool_ops
->set_channels(dev
, &channels
);
1000 static int ethtool_get_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1002 struct ethtool_pauseparam pauseparam
= { ETHTOOL_GPAUSEPARAM
};
1004 if (!dev
->ethtool_ops
->get_pauseparam
)
1007 dev
->ethtool_ops
->get_pauseparam(dev
, &pauseparam
);
1009 if (copy_to_user(useraddr
, &pauseparam
, sizeof(pauseparam
)))
1014 static int ethtool_set_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1016 struct ethtool_pauseparam pauseparam
;
1018 if (!dev
->ethtool_ops
->set_pauseparam
)
1021 if (copy_from_user(&pauseparam
, useraddr
, sizeof(pauseparam
)))
1024 return dev
->ethtool_ops
->set_pauseparam(dev
, &pauseparam
);
1027 static int ethtool_self_test(struct net_device
*dev
, char __user
*useraddr
)
1029 struct ethtool_test test
;
1030 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1034 if (!ops
->self_test
|| !ops
->get_sset_count
)
1037 test_len
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
1040 WARN_ON(test_len
== 0);
1042 if (copy_from_user(&test
, useraddr
, sizeof(test
)))
1045 test
.len
= test_len
;
1046 data
= kmalloc(test_len
* sizeof(u64
), GFP_USER
);
1050 ops
->self_test(dev
, &test
, data
);
1053 if (copy_to_user(useraddr
, &test
, sizeof(test
)))
1055 useraddr
+= sizeof(test
);
1056 if (copy_to_user(useraddr
, data
, test
.len
* sizeof(u64
)))
1065 static int ethtool_get_strings(struct net_device
*dev
, void __user
*useraddr
)
1067 struct ethtool_gstrings gstrings
;
1071 if (copy_from_user(&gstrings
, useraddr
, sizeof(gstrings
)))
1074 ret
= __ethtool_get_sset_count(dev
, gstrings
.string_set
);
1080 data
= kmalloc(gstrings
.len
* ETH_GSTRING_LEN
, GFP_USER
);
1084 __ethtool_get_strings(dev
, gstrings
.string_set
, data
);
1087 if (copy_to_user(useraddr
, &gstrings
, sizeof(gstrings
)))
1089 useraddr
+= sizeof(gstrings
);
1090 if (copy_to_user(useraddr
, data
, gstrings
.len
* ETH_GSTRING_LEN
))
1099 static int ethtool_phys_id(struct net_device
*dev
, void __user
*useraddr
)
1101 struct ethtool_value id
;
1103 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1106 if (!ops
->set_phys_id
)
1112 if (copy_from_user(&id
, useraddr
, sizeof(id
)))
1115 rc
= ops
->set_phys_id(dev
, ETHTOOL_ID_ACTIVE
);
1119 /* Drop the RTNL lock while waiting, but prevent reentry or
1120 * removal of the device.
1127 /* Driver will handle this itself */
1128 schedule_timeout_interruptible(
1129 id
.data
? (id
.data
* HZ
) : MAX_SCHEDULE_TIMEOUT
);
1131 /* Driver expects to be called at twice the frequency in rc */
1132 int n
= rc
* 2, i
, interval
= HZ
/ n
;
1134 /* Count down seconds */
1136 /* Count down iterations per second */
1140 rc
= ops
->set_phys_id(dev
,
1141 (i
& 1) ? ETHTOOL_ID_OFF
: ETHTOOL_ID_ON
);
1145 schedule_timeout_interruptible(interval
);
1146 } while (!signal_pending(current
) && --i
!= 0);
1147 } while (!signal_pending(current
) &&
1148 (id
.data
== 0 || --id
.data
!= 0));
1155 (void) ops
->set_phys_id(dev
, ETHTOOL_ID_INACTIVE
);
1159 static int ethtool_get_stats(struct net_device
*dev
, void __user
*useraddr
)
1161 struct ethtool_stats stats
;
1162 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1166 if (!ops
->get_ethtool_stats
|| !ops
->get_sset_count
)
1169 n_stats
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
1172 WARN_ON(n_stats
== 0);
1174 if (copy_from_user(&stats
, useraddr
, sizeof(stats
)))
1177 stats
.n_stats
= n_stats
;
1178 data
= kmalloc(n_stats
* sizeof(u64
), GFP_USER
);
1182 ops
->get_ethtool_stats(dev
, &stats
, data
);
1185 if (copy_to_user(useraddr
, &stats
, sizeof(stats
)))
1187 useraddr
+= sizeof(stats
);
1188 if (copy_to_user(useraddr
, data
, stats
.n_stats
* sizeof(u64
)))
1197 static int ethtool_get_perm_addr(struct net_device
*dev
, void __user
*useraddr
)
1199 struct ethtool_perm_addr epaddr
;
1201 if (copy_from_user(&epaddr
, useraddr
, sizeof(epaddr
)))
1204 if (epaddr
.size
< dev
->addr_len
)
1206 epaddr
.size
= dev
->addr_len
;
1208 if (copy_to_user(useraddr
, &epaddr
, sizeof(epaddr
)))
1210 useraddr
+= sizeof(epaddr
);
1211 if (copy_to_user(useraddr
, dev
->perm_addr
, epaddr
.size
))
1216 static int ethtool_get_value(struct net_device
*dev
, char __user
*useraddr
,
1217 u32 cmd
, u32 (*actor
)(struct net_device
*))
1219 struct ethtool_value edata
= { .cmd
= cmd
};
1224 edata
.data
= actor(dev
);
1226 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
1231 static int ethtool_set_value_void(struct net_device
*dev
, char __user
*useraddr
,
1232 void (*actor
)(struct net_device
*, u32
))
1234 struct ethtool_value edata
;
1239 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1242 actor(dev
, edata
.data
);
1246 static int ethtool_set_value(struct net_device
*dev
, char __user
*useraddr
,
1247 int (*actor
)(struct net_device
*, u32
))
1249 struct ethtool_value edata
;
1254 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1257 return actor(dev
, edata
.data
);
1260 static noinline_for_stack
int ethtool_flash_device(struct net_device
*dev
,
1261 char __user
*useraddr
)
1263 struct ethtool_flash efl
;
1265 if (copy_from_user(&efl
, useraddr
, sizeof(efl
)))
1268 if (!dev
->ethtool_ops
->flash_device
)
1271 efl
.data
[ETHTOOL_FLASH_MAX_FILENAME
- 1] = 0;
1273 return dev
->ethtool_ops
->flash_device(dev
, &efl
);
1276 static int ethtool_set_dump(struct net_device
*dev
,
1277 void __user
*useraddr
)
1279 struct ethtool_dump dump
;
1281 if (!dev
->ethtool_ops
->set_dump
)
1284 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1287 return dev
->ethtool_ops
->set_dump(dev
, &dump
);
1290 static int ethtool_get_dump_flag(struct net_device
*dev
,
1291 void __user
*useraddr
)
1294 struct ethtool_dump dump
;
1295 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1297 if (!ops
->get_dump_flag
)
1300 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1303 ret
= ops
->get_dump_flag(dev
, &dump
);
1307 if (copy_to_user(useraddr
, &dump
, sizeof(dump
)))
1312 static int ethtool_get_dump_data(struct net_device
*dev
,
1313 void __user
*useraddr
)
1317 struct ethtool_dump dump
, tmp
;
1318 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1321 if (!ops
->get_dump_data
|| !ops
->get_dump_flag
)
1324 if (copy_from_user(&dump
, useraddr
, sizeof(dump
)))
1327 memset(&tmp
, 0, sizeof(tmp
));
1328 tmp
.cmd
= ETHTOOL_GET_DUMP_FLAG
;
1329 ret
= ops
->get_dump_flag(dev
, &tmp
);
1333 len
= min(tmp
.len
, dump
.len
);
1337 /* Don't ever let the driver think there's more space available
1338 * than it requested with .get_dump_flag().
1342 /* Always allocate enough space to hold the whole thing so that the
1343 * driver does not need to check the length and bother with partial
1346 data
= vzalloc(tmp
.len
);
1349 ret
= ops
->get_dump_data(dev
, &dump
, data
);
1353 /* There are two sane possibilities:
1354 * 1. The driver's .get_dump_data() does not touch dump.len.
1355 * 2. Or it may set dump.len to how much it really writes, which
1356 * should be tmp.len (or len if it can do a partial dump).
1357 * In any case respond to userspace with the actual length of data
1360 WARN_ON(dump
.len
!= len
&& dump
.len
!= tmp
.len
);
1363 if (copy_to_user(useraddr
, &dump
, sizeof(dump
))) {
1367 useraddr
+= offsetof(struct ethtool_dump
, data
);
1368 if (copy_to_user(useraddr
, data
, len
))
1375 static int ethtool_get_ts_info(struct net_device
*dev
, void __user
*useraddr
)
1378 struct ethtool_ts_info info
;
1379 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1380 struct phy_device
*phydev
= dev
->phydev
;
1382 memset(&info
, 0, sizeof(info
));
1383 info
.cmd
= ETHTOOL_GET_TS_INFO
;
1385 if (phydev
&& phydev
->drv
&& phydev
->drv
->ts_info
) {
1386 err
= phydev
->drv
->ts_info(phydev
, &info
);
1387 } else if (ops
->get_ts_info
) {
1388 err
= ops
->get_ts_info(dev
, &info
);
1390 info
.so_timestamping
=
1391 SOF_TIMESTAMPING_RX_SOFTWARE
|
1392 SOF_TIMESTAMPING_SOFTWARE
;
1393 info
.phc_index
= -1;
1399 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
1405 static int ethtool_get_module_info(struct net_device
*dev
,
1406 void __user
*useraddr
)
1409 struct ethtool_modinfo modinfo
;
1410 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1412 if (!ops
->get_module_info
)
1415 if (copy_from_user(&modinfo
, useraddr
, sizeof(modinfo
)))
1418 ret
= ops
->get_module_info(dev
, &modinfo
);
1422 if (copy_to_user(useraddr
, &modinfo
, sizeof(modinfo
)))
1428 static int ethtool_get_module_eeprom(struct net_device
*dev
,
1429 void __user
*useraddr
)
1432 struct ethtool_modinfo modinfo
;
1433 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1435 if (!ops
->get_module_info
|| !ops
->get_module_eeprom
)
1438 ret
= ops
->get_module_info(dev
, &modinfo
);
1442 return ethtool_get_any_eeprom(dev
, useraddr
, ops
->get_module_eeprom
,
1443 modinfo
.eeprom_len
);
1446 /* The main entry point in this file. Called from net/core/dev_ioctl.c */
1448 int dev_ethtool(struct net
*net
, struct ifreq
*ifr
)
1450 struct net_device
*dev
= __dev_get_by_name(net
, ifr
->ifr_name
);
1451 void __user
*useraddr
= ifr
->ifr_data
;
1454 netdev_features_t old_features
;
1456 if (!dev
|| !netif_device_present(dev
))
1459 if (copy_from_user(ðcmd
, useraddr
, sizeof(ethcmd
)))
1462 /* Allow some commands to be done by anyone */
1465 case ETHTOOL_GDRVINFO
:
1466 case ETHTOOL_GMSGLVL
:
1468 case ETHTOOL_GCOALESCE
:
1469 case ETHTOOL_GRINGPARAM
:
1470 case ETHTOOL_GPAUSEPARAM
:
1471 case ETHTOOL_GRXCSUM
:
1472 case ETHTOOL_GTXCSUM
:
1474 case ETHTOOL_GSSET_INFO
:
1475 case ETHTOOL_GSTRINGS
:
1476 case ETHTOOL_GSTATS
:
1478 case ETHTOOL_GPERMADDR
:
1482 case ETHTOOL_GFLAGS
:
1483 case ETHTOOL_GPFLAGS
:
1485 case ETHTOOL_GRXRINGS
:
1486 case ETHTOOL_GRXCLSRLCNT
:
1487 case ETHTOOL_GRXCLSRULE
:
1488 case ETHTOOL_GRXCLSRLALL
:
1489 case ETHTOOL_GRXFHINDIR
:
1490 case ETHTOOL_GFEATURES
:
1491 case ETHTOOL_GCHANNELS
:
1492 case ETHTOOL_GET_TS_INFO
:
1496 if (!ns_capable(net
->user_ns
, CAP_NET_ADMIN
))
1500 if (dev
->ethtool_ops
->begin
) {
1501 rc
= dev
->ethtool_ops
->begin(dev
);
1505 old_features
= dev
->features
;
1509 rc
= ethtool_get_settings(dev
, useraddr
);
1512 rc
= ethtool_set_settings(dev
, useraddr
);
1514 case ETHTOOL_GDRVINFO
:
1515 rc
= ethtool_get_drvinfo(dev
, useraddr
);
1518 rc
= ethtool_get_regs(dev
, useraddr
);
1521 rc
= ethtool_get_wol(dev
, useraddr
);
1524 rc
= ethtool_set_wol(dev
, useraddr
);
1526 case ETHTOOL_GMSGLVL
:
1527 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1528 dev
->ethtool_ops
->get_msglevel
);
1530 case ETHTOOL_SMSGLVL
:
1531 rc
= ethtool_set_value_void(dev
, useraddr
,
1532 dev
->ethtool_ops
->set_msglevel
);
1535 rc
= ethtool_get_eee(dev
, useraddr
);
1538 rc
= ethtool_set_eee(dev
, useraddr
);
1540 case ETHTOOL_NWAY_RST
:
1541 rc
= ethtool_nway_reset(dev
);
1544 rc
= ethtool_get_link(dev
, useraddr
);
1546 case ETHTOOL_GEEPROM
:
1547 rc
= ethtool_get_eeprom(dev
, useraddr
);
1549 case ETHTOOL_SEEPROM
:
1550 rc
= ethtool_set_eeprom(dev
, useraddr
);
1552 case ETHTOOL_GCOALESCE
:
1553 rc
= ethtool_get_coalesce(dev
, useraddr
);
1555 case ETHTOOL_SCOALESCE
:
1556 rc
= ethtool_set_coalesce(dev
, useraddr
);
1558 case ETHTOOL_GRINGPARAM
:
1559 rc
= ethtool_get_ringparam(dev
, useraddr
);
1561 case ETHTOOL_SRINGPARAM
:
1562 rc
= ethtool_set_ringparam(dev
, useraddr
);
1564 case ETHTOOL_GPAUSEPARAM
:
1565 rc
= ethtool_get_pauseparam(dev
, useraddr
);
1567 case ETHTOOL_SPAUSEPARAM
:
1568 rc
= ethtool_set_pauseparam(dev
, useraddr
);
1571 rc
= ethtool_self_test(dev
, useraddr
);
1573 case ETHTOOL_GSTRINGS
:
1574 rc
= ethtool_get_strings(dev
, useraddr
);
1576 case ETHTOOL_PHYS_ID
:
1577 rc
= ethtool_phys_id(dev
, useraddr
);
1579 case ETHTOOL_GSTATS
:
1580 rc
= ethtool_get_stats(dev
, useraddr
);
1582 case ETHTOOL_GPERMADDR
:
1583 rc
= ethtool_get_perm_addr(dev
, useraddr
);
1585 case ETHTOOL_GFLAGS
:
1586 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1587 __ethtool_get_flags
);
1589 case ETHTOOL_SFLAGS
:
1590 rc
= ethtool_set_value(dev
, useraddr
, __ethtool_set_flags
);
1592 case ETHTOOL_GPFLAGS
:
1593 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1594 dev
->ethtool_ops
->get_priv_flags
);
1596 case ETHTOOL_SPFLAGS
:
1597 rc
= ethtool_set_value(dev
, useraddr
,
1598 dev
->ethtool_ops
->set_priv_flags
);
1601 case ETHTOOL_GRXRINGS
:
1602 case ETHTOOL_GRXCLSRLCNT
:
1603 case ETHTOOL_GRXCLSRULE
:
1604 case ETHTOOL_GRXCLSRLALL
:
1605 rc
= ethtool_get_rxnfc(dev
, ethcmd
, useraddr
);
1608 case ETHTOOL_SRXCLSRLDEL
:
1609 case ETHTOOL_SRXCLSRLINS
:
1610 rc
= ethtool_set_rxnfc(dev
, ethcmd
, useraddr
);
1612 case ETHTOOL_FLASHDEV
:
1613 rc
= ethtool_flash_device(dev
, useraddr
);
1616 rc
= ethtool_reset(dev
, useraddr
);
1618 case ETHTOOL_GSSET_INFO
:
1619 rc
= ethtool_get_sset_info(dev
, useraddr
);
1621 case ETHTOOL_GRXFHINDIR
:
1622 rc
= ethtool_get_rxfh_indir(dev
, useraddr
);
1624 case ETHTOOL_SRXFHINDIR
:
1625 rc
= ethtool_set_rxfh_indir(dev
, useraddr
);
1627 case ETHTOOL_GFEATURES
:
1628 rc
= ethtool_get_features(dev
, useraddr
);
1630 case ETHTOOL_SFEATURES
:
1631 rc
= ethtool_set_features(dev
, useraddr
);
1633 case ETHTOOL_GTXCSUM
:
1634 case ETHTOOL_GRXCSUM
:
1640 rc
= ethtool_get_one_feature(dev
, useraddr
, ethcmd
);
1642 case ETHTOOL_STXCSUM
:
1643 case ETHTOOL_SRXCSUM
:
1649 rc
= ethtool_set_one_feature(dev
, useraddr
, ethcmd
);
1651 case ETHTOOL_GCHANNELS
:
1652 rc
= ethtool_get_channels(dev
, useraddr
);
1654 case ETHTOOL_SCHANNELS
:
1655 rc
= ethtool_set_channels(dev
, useraddr
);
1657 case ETHTOOL_SET_DUMP
:
1658 rc
= ethtool_set_dump(dev
, useraddr
);
1660 case ETHTOOL_GET_DUMP_FLAG
:
1661 rc
= ethtool_get_dump_flag(dev
, useraddr
);
1663 case ETHTOOL_GET_DUMP_DATA
:
1664 rc
= ethtool_get_dump_data(dev
, useraddr
);
1666 case ETHTOOL_GET_TS_INFO
:
1667 rc
= ethtool_get_ts_info(dev
, useraddr
);
1669 case ETHTOOL_GMODULEINFO
:
1670 rc
= ethtool_get_module_info(dev
, useraddr
);
1672 case ETHTOOL_GMODULEEEPROM
:
1673 rc
= ethtool_get_module_eeprom(dev
, useraddr
);
1679 if (dev
->ethtool_ops
->complete
)
1680 dev
->ethtool_ops
->complete(dev
);
1682 if (old_features
!= dev
->features
)
1683 netdev_features_change(dev
);