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/bitops.h>
21 #include <linux/uaccess.h>
22 #include <linux/vmalloc.h>
23 #include <linux/slab.h>
26 * Some useful ethtool_ops methods that're device independent.
27 * If we find that all drivers want to do the same thing here,
28 * we can turn these into dev_() function calls.
31 u32
ethtool_op_get_link(struct net_device
*dev
)
33 return netif_carrier_ok(dev
) ? 1 : 0;
35 EXPORT_SYMBOL(ethtool_op_get_link
);
37 u32
ethtool_op_get_rx_csum(struct net_device
*dev
)
39 return (dev
->features
& NETIF_F_ALL_CSUM
) != 0;
41 EXPORT_SYMBOL(ethtool_op_get_rx_csum
);
43 u32
ethtool_op_get_tx_csum(struct net_device
*dev
)
45 return (dev
->features
& NETIF_F_ALL_CSUM
) != 0;
47 EXPORT_SYMBOL(ethtool_op_get_tx_csum
);
49 int ethtool_op_set_tx_csum(struct net_device
*dev
, u32 data
)
52 dev
->features
|= NETIF_F_IP_CSUM
;
54 dev
->features
&= ~NETIF_F_IP_CSUM
;
59 int ethtool_op_set_tx_hw_csum(struct net_device
*dev
, u32 data
)
62 dev
->features
|= NETIF_F_HW_CSUM
;
64 dev
->features
&= ~NETIF_F_HW_CSUM
;
68 EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum
);
70 int ethtool_op_set_tx_ipv6_csum(struct net_device
*dev
, u32 data
)
73 dev
->features
|= NETIF_F_IP_CSUM
| NETIF_F_IPV6_CSUM
;
75 dev
->features
&= ~(NETIF_F_IP_CSUM
| NETIF_F_IPV6_CSUM
);
79 EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum
);
81 u32
ethtool_op_get_sg(struct net_device
*dev
)
83 return (dev
->features
& NETIF_F_SG
) != 0;
85 EXPORT_SYMBOL(ethtool_op_get_sg
);
87 int ethtool_op_set_sg(struct net_device
*dev
, u32 data
)
90 dev
->features
|= NETIF_F_SG
;
92 dev
->features
&= ~NETIF_F_SG
;
96 EXPORT_SYMBOL(ethtool_op_set_sg
);
98 u32
ethtool_op_get_tso(struct net_device
*dev
)
100 return (dev
->features
& NETIF_F_TSO
) != 0;
102 EXPORT_SYMBOL(ethtool_op_get_tso
);
104 int ethtool_op_set_tso(struct net_device
*dev
, u32 data
)
107 dev
->features
|= NETIF_F_TSO
;
109 dev
->features
&= ~NETIF_F_TSO
;
113 EXPORT_SYMBOL(ethtool_op_set_tso
);
115 u32
ethtool_op_get_ufo(struct net_device
*dev
)
117 return (dev
->features
& NETIF_F_UFO
) != 0;
119 EXPORT_SYMBOL(ethtool_op_get_ufo
);
121 int ethtool_op_set_ufo(struct net_device
*dev
, u32 data
)
124 dev
->features
|= NETIF_F_UFO
;
126 dev
->features
&= ~NETIF_F_UFO
;
129 EXPORT_SYMBOL(ethtool_op_set_ufo
);
131 /* the following list of flags are the same as their associated
132 * NETIF_F_xxx values in include/linux/netdevice.h
134 static const u32 flags_dup_features
=
135 (ETH_FLAG_LRO
| ETH_FLAG_RXVLAN
| ETH_FLAG_TXVLAN
| ETH_FLAG_NTUPLE
|
138 u32
ethtool_op_get_flags(struct net_device
*dev
)
140 /* in the future, this function will probably contain additional
141 * handling for flags which are not so easily handled
142 * by a simple masking operation
145 return dev
->features
& flags_dup_features
;
147 EXPORT_SYMBOL(ethtool_op_get_flags
);
149 int ethtool_op_set_flags(struct net_device
*dev
, u32 data
, u32 supported
)
151 if (data
& ~supported
)
154 dev
->features
= ((dev
->features
& ~flags_dup_features
) |
155 (data
& flags_dup_features
));
158 EXPORT_SYMBOL(ethtool_op_set_flags
);
160 void ethtool_ntuple_flush(struct net_device
*dev
)
162 struct ethtool_rx_ntuple_flow_spec_container
*fsc
, *f
;
164 list_for_each_entry_safe(fsc
, f
, &dev
->ethtool_ntuple_list
.list
, list
) {
165 list_del(&fsc
->list
);
168 dev
->ethtool_ntuple_list
.count
= 0;
170 EXPORT_SYMBOL(ethtool_ntuple_flush
);
172 /* Handlers for each ethtool command */
174 static int ethtool_get_settings(struct net_device
*dev
, void __user
*useraddr
)
176 struct ethtool_cmd cmd
= { .cmd
= ETHTOOL_GSET
};
179 if (!dev
->ethtool_ops
->get_settings
)
182 err
= dev
->ethtool_ops
->get_settings(dev
, &cmd
);
186 if (copy_to_user(useraddr
, &cmd
, sizeof(cmd
)))
191 static int ethtool_set_settings(struct net_device
*dev
, void __user
*useraddr
)
193 struct ethtool_cmd cmd
;
195 if (!dev
->ethtool_ops
->set_settings
)
198 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
201 return dev
->ethtool_ops
->set_settings(dev
, &cmd
);
204 static noinline_for_stack
int ethtool_get_drvinfo(struct net_device
*dev
,
205 void __user
*useraddr
)
207 struct ethtool_drvinfo info
;
208 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
210 memset(&info
, 0, sizeof(info
));
211 info
.cmd
= ETHTOOL_GDRVINFO
;
212 if (ops
&& ops
->get_drvinfo
) {
213 ops
->get_drvinfo(dev
, &info
);
214 } else if (dev
->dev
.parent
&& dev
->dev
.parent
->driver
) {
215 strlcpy(info
.bus_info
, dev_name(dev
->dev
.parent
),
216 sizeof(info
.bus_info
));
217 strlcpy(info
.driver
, dev
->dev
.parent
->driver
->name
,
218 sizeof(info
.driver
));
224 * this method of obtaining string set info is deprecated;
225 * Use ETHTOOL_GSSET_INFO instead.
227 if (ops
&& ops
->get_sset_count
) {
230 rc
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
232 info
.testinfo_len
= rc
;
233 rc
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
236 rc
= ops
->get_sset_count(dev
, ETH_SS_PRIV_FLAGS
);
238 info
.n_priv_flags
= rc
;
240 if (ops
&& ops
->get_regs_len
)
241 info
.regdump_len
= ops
->get_regs_len(dev
);
242 if (ops
&& ops
->get_eeprom_len
)
243 info
.eedump_len
= ops
->get_eeprom_len(dev
);
245 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
250 static noinline_for_stack
int ethtool_get_sset_info(struct net_device
*dev
,
251 void __user
*useraddr
)
253 struct ethtool_sset_info info
;
254 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
256 int i
, idx
= 0, n_bits
= 0, ret
, rc
;
257 u32
*info_buf
= NULL
;
259 if (!ops
->get_sset_count
)
262 if (copy_from_user(&info
, useraddr
, sizeof(info
)))
265 /* store copy of mask, because we zero struct later on */
266 sset_mask
= info
.sset_mask
;
270 /* calculate size of return buffer */
271 n_bits
= hweight64(sset_mask
);
273 memset(&info
, 0, sizeof(info
));
274 info
.cmd
= ETHTOOL_GSSET_INFO
;
276 info_buf
= kzalloc(n_bits
* sizeof(u32
), GFP_USER
);
281 * fill return buffer based on input bitmask and successful
282 * get_sset_count return
284 for (i
= 0; i
< 64; i
++) {
285 if (!(sset_mask
& (1ULL << i
)))
288 rc
= ops
->get_sset_count(dev
, i
);
290 info
.sset_mask
|= (1ULL << i
);
291 info_buf
[idx
++] = rc
;
296 if (copy_to_user(useraddr
, &info
, sizeof(info
)))
299 useraddr
+= offsetof(struct ethtool_sset_info
, data
);
300 if (copy_to_user(useraddr
, info_buf
, idx
* sizeof(u32
)))
310 static noinline_for_stack
int ethtool_set_rxnfc(struct net_device
*dev
,
311 u32 cmd
, void __user
*useraddr
)
313 struct ethtool_rxnfc info
;
314 size_t info_size
= sizeof(info
);
316 if (!dev
->ethtool_ops
->set_rxnfc
)
319 /* struct ethtool_rxnfc was originally defined for
320 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
321 * members. User-space might still be using that
323 if (cmd
== ETHTOOL_SRXFH
)
324 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
327 if (copy_from_user(&info
, useraddr
, info_size
))
330 return dev
->ethtool_ops
->set_rxnfc(dev
, &info
);
333 static noinline_for_stack
int ethtool_get_rxnfc(struct net_device
*dev
,
334 u32 cmd
, void __user
*useraddr
)
336 struct ethtool_rxnfc info
;
337 size_t info_size
= sizeof(info
);
338 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
340 void *rule_buf
= NULL
;
345 /* struct ethtool_rxnfc was originally defined for
346 * ETHTOOL_{G,S}RXFH with only the cmd, flow_type and data
347 * members. User-space might still be using that
349 if (cmd
== ETHTOOL_GRXFH
)
350 info_size
= (offsetof(struct ethtool_rxnfc
, data
) +
353 if (copy_from_user(&info
, useraddr
, info_size
))
356 if (info
.cmd
== ETHTOOL_GRXCLSRLALL
) {
357 if (info
.rule_cnt
> 0) {
358 if (info
.rule_cnt
<= KMALLOC_MAX_SIZE
/ sizeof(u32
))
359 rule_buf
= kzalloc(info
.rule_cnt
* sizeof(u32
),
366 ret
= ops
->get_rxnfc(dev
, &info
, rule_buf
);
371 if (copy_to_user(useraddr
, &info
, info_size
))
375 useraddr
+= offsetof(struct ethtool_rxnfc
, rule_locs
);
376 if (copy_to_user(useraddr
, rule_buf
,
377 info
.rule_cnt
* sizeof(u32
)))
388 static noinline_for_stack
int ethtool_get_rxfh_indir(struct net_device
*dev
,
389 void __user
*useraddr
)
391 struct ethtool_rxfh_indir
*indir
;
396 if (!dev
->ethtool_ops
->get_rxfh_indir
)
399 if (copy_from_user(&table_size
,
400 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
405 (KMALLOC_MAX_SIZE
- sizeof(*indir
)) / sizeof(*indir
->ring_index
))
407 full_size
= sizeof(*indir
) + sizeof(*indir
->ring_index
) * table_size
;
408 indir
= kzalloc(full_size
, GFP_USER
);
412 indir
->cmd
= ETHTOOL_GRXFHINDIR
;
413 indir
->size
= table_size
;
414 ret
= dev
->ethtool_ops
->get_rxfh_indir(dev
, indir
);
418 if (copy_to_user(useraddr
, indir
, full_size
))
426 static noinline_for_stack
int ethtool_set_rxfh_indir(struct net_device
*dev
,
427 void __user
*useraddr
)
429 struct ethtool_rxfh_indir
*indir
;
434 if (!dev
->ethtool_ops
->set_rxfh_indir
)
437 if (copy_from_user(&table_size
,
438 useraddr
+ offsetof(struct ethtool_rxfh_indir
, size
),
443 (KMALLOC_MAX_SIZE
- sizeof(*indir
)) / sizeof(*indir
->ring_index
))
445 full_size
= sizeof(*indir
) + sizeof(*indir
->ring_index
) * table_size
;
446 indir
= kmalloc(full_size
, GFP_USER
);
450 if (copy_from_user(indir
, useraddr
, full_size
)) {
455 ret
= dev
->ethtool_ops
->set_rxfh_indir(dev
, indir
);
462 static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list
*list
,
463 struct ethtool_rx_ntuple_flow_spec
*spec
,
464 struct ethtool_rx_ntuple_flow_spec_container
*fsc
)
467 /* don't add filters forever */
468 if (list
->count
>= ETHTOOL_MAX_NTUPLE_LIST_ENTRY
) {
469 /* free the container */
474 /* Copy the whole filter over */
475 fsc
->fs
.flow_type
= spec
->flow_type
;
476 memcpy(&fsc
->fs
.h_u
, &spec
->h_u
, sizeof(spec
->h_u
));
477 memcpy(&fsc
->fs
.m_u
, &spec
->m_u
, sizeof(spec
->m_u
));
479 fsc
->fs
.vlan_tag
= spec
->vlan_tag
;
480 fsc
->fs
.vlan_tag_mask
= spec
->vlan_tag_mask
;
481 fsc
->fs
.data
= spec
->data
;
482 fsc
->fs
.data_mask
= spec
->data_mask
;
483 fsc
->fs
.action
= spec
->action
;
485 /* add to the list */
486 list_add_tail_rcu(&fsc
->list
, &list
->list
);
491 * ethtool does not (or did not) set masks for flow parameters that are
492 * not specified, so if both value and mask are 0 then this must be
493 * treated as equivalent to a mask with all bits set. Implement that
494 * here rather than in drivers.
496 static void rx_ntuple_fix_masks(struct ethtool_rx_ntuple_flow_spec
*fs
)
498 struct ethtool_tcpip4_spec
*entry
= &fs
->h_u
.tcp_ip4_spec
;
499 struct ethtool_tcpip4_spec
*mask
= &fs
->m_u
.tcp_ip4_spec
;
501 if (fs
->flow_type
!= TCP_V4_FLOW
&&
502 fs
->flow_type
!= UDP_V4_FLOW
&&
503 fs
->flow_type
!= SCTP_V4_FLOW
)
506 if (!(entry
->ip4src
| mask
->ip4src
))
507 mask
->ip4src
= htonl(0xffffffff);
508 if (!(entry
->ip4dst
| mask
->ip4dst
))
509 mask
->ip4dst
= htonl(0xffffffff);
510 if (!(entry
->psrc
| mask
->psrc
))
511 mask
->psrc
= htons(0xffff);
512 if (!(entry
->pdst
| mask
->pdst
))
513 mask
->pdst
= htons(0xffff);
514 if (!(entry
->tos
| mask
->tos
))
516 if (!(fs
->vlan_tag
| fs
->vlan_tag_mask
))
517 fs
->vlan_tag_mask
= 0xffff;
518 if (!(fs
->data
| fs
->data_mask
))
519 fs
->data_mask
= 0xffffffffffffffffULL
;
522 static noinline_for_stack
int ethtool_set_rx_ntuple(struct net_device
*dev
,
523 void __user
*useraddr
)
525 struct ethtool_rx_ntuple cmd
;
526 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
527 struct ethtool_rx_ntuple_flow_spec_container
*fsc
= NULL
;
530 if (!(dev
->features
& NETIF_F_NTUPLE
))
533 if (copy_from_user(&cmd
, useraddr
, sizeof(cmd
)))
536 rx_ntuple_fix_masks(&cmd
.fs
);
539 * Cache filter in dev struct for GET operation only if
540 * the underlying driver doesn't have its own GET operation, and
541 * only if the filter was added successfully. First make sure we
542 * can allocate the filter, then continue if successful.
544 if (!ops
->get_rx_ntuple
) {
545 fsc
= kmalloc(sizeof(*fsc
), GFP_ATOMIC
);
550 ret
= ops
->set_rx_ntuple(dev
, &cmd
);
556 if (!ops
->get_rx_ntuple
)
557 __rx_ntuple_filter_add(&dev
->ethtool_ntuple_list
, &cmd
.fs
, fsc
);
562 static int ethtool_get_rx_ntuple(struct net_device
*dev
, void __user
*useraddr
)
564 struct ethtool_gstrings gstrings
;
565 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
566 struct ethtool_rx_ntuple_flow_spec_container
*fsc
;
569 int ret
, i
, num_strings
= 0;
571 if (!ops
->get_sset_count
)
574 if (copy_from_user(&gstrings
, useraddr
, sizeof(gstrings
)))
577 ret
= ops
->get_sset_count(dev
, gstrings
.string_set
);
583 data
= kzalloc(gstrings
.len
* ETH_GSTRING_LEN
, GFP_USER
);
587 if (ops
->get_rx_ntuple
) {
588 /* driver-specific filter grab */
589 ret
= ops
->get_rx_ntuple(dev
, gstrings
.string_set
, data
);
593 /* default ethtool filter grab */
596 list_for_each_entry(fsc
, &dev
->ethtool_ntuple_list
.list
, list
) {
597 sprintf(p
, "Filter %d:\n", i
);
598 p
+= ETH_GSTRING_LEN
;
601 switch (fsc
->fs
.flow_type
) {
603 sprintf(p
, "\tFlow Type: TCP\n");
604 p
+= ETH_GSTRING_LEN
;
608 sprintf(p
, "\tFlow Type: UDP\n");
609 p
+= ETH_GSTRING_LEN
;
613 sprintf(p
, "\tFlow Type: SCTP\n");
614 p
+= ETH_GSTRING_LEN
;
618 sprintf(p
, "\tFlow Type: AH ESP\n");
619 p
+= ETH_GSTRING_LEN
;
623 sprintf(p
, "\tFlow Type: ESP\n");
624 p
+= ETH_GSTRING_LEN
;
628 sprintf(p
, "\tFlow Type: Raw IP\n");
629 p
+= ETH_GSTRING_LEN
;
633 sprintf(p
, "\tFlow Type: IPv4\n");
634 p
+= ETH_GSTRING_LEN
;
638 sprintf(p
, "\tFlow Type: Unknown\n");
639 p
+= ETH_GSTRING_LEN
;
644 /* now the rest of the filters */
645 switch (fsc
->fs
.flow_type
) {
649 sprintf(p
, "\tSrc IP addr: 0x%x\n",
650 fsc
->fs
.h_u
.tcp_ip4_spec
.ip4src
);
651 p
+= ETH_GSTRING_LEN
;
653 sprintf(p
, "\tSrc IP mask: 0x%x\n",
654 fsc
->fs
.m_u
.tcp_ip4_spec
.ip4src
);
655 p
+= ETH_GSTRING_LEN
;
657 sprintf(p
, "\tDest IP addr: 0x%x\n",
658 fsc
->fs
.h_u
.tcp_ip4_spec
.ip4dst
);
659 p
+= ETH_GSTRING_LEN
;
661 sprintf(p
, "\tDest IP mask: 0x%x\n",
662 fsc
->fs
.m_u
.tcp_ip4_spec
.ip4dst
);
663 p
+= ETH_GSTRING_LEN
;
665 sprintf(p
, "\tSrc Port: %d, mask: 0x%x\n",
666 fsc
->fs
.h_u
.tcp_ip4_spec
.psrc
,
667 fsc
->fs
.m_u
.tcp_ip4_spec
.psrc
);
668 p
+= ETH_GSTRING_LEN
;
670 sprintf(p
, "\tDest Port: %d, mask: 0x%x\n",
671 fsc
->fs
.h_u
.tcp_ip4_spec
.pdst
,
672 fsc
->fs
.m_u
.tcp_ip4_spec
.pdst
);
673 p
+= ETH_GSTRING_LEN
;
675 sprintf(p
, "\tTOS: %d, mask: 0x%x\n",
676 fsc
->fs
.h_u
.tcp_ip4_spec
.tos
,
677 fsc
->fs
.m_u
.tcp_ip4_spec
.tos
);
678 p
+= ETH_GSTRING_LEN
;
683 sprintf(p
, "\tSrc IP addr: 0x%x\n",
684 fsc
->fs
.h_u
.ah_ip4_spec
.ip4src
);
685 p
+= ETH_GSTRING_LEN
;
687 sprintf(p
, "\tSrc IP mask: 0x%x\n",
688 fsc
->fs
.m_u
.ah_ip4_spec
.ip4src
);
689 p
+= ETH_GSTRING_LEN
;
691 sprintf(p
, "\tDest IP addr: 0x%x\n",
692 fsc
->fs
.h_u
.ah_ip4_spec
.ip4dst
);
693 p
+= ETH_GSTRING_LEN
;
695 sprintf(p
, "\tDest IP mask: 0x%x\n",
696 fsc
->fs
.m_u
.ah_ip4_spec
.ip4dst
);
697 p
+= ETH_GSTRING_LEN
;
699 sprintf(p
, "\tSPI: %d, mask: 0x%x\n",
700 fsc
->fs
.h_u
.ah_ip4_spec
.spi
,
701 fsc
->fs
.m_u
.ah_ip4_spec
.spi
);
702 p
+= ETH_GSTRING_LEN
;
704 sprintf(p
, "\tTOS: %d, mask: 0x%x\n",
705 fsc
->fs
.h_u
.ah_ip4_spec
.tos
,
706 fsc
->fs
.m_u
.ah_ip4_spec
.tos
);
707 p
+= ETH_GSTRING_LEN
;
711 sprintf(p
, "\tSrc IP addr: 0x%x\n",
712 fsc
->fs
.h_u
.usr_ip4_spec
.ip4src
);
713 p
+= ETH_GSTRING_LEN
;
715 sprintf(p
, "\tSrc IP mask: 0x%x\n",
716 fsc
->fs
.m_u
.usr_ip4_spec
.ip4src
);
717 p
+= ETH_GSTRING_LEN
;
719 sprintf(p
, "\tDest IP addr: 0x%x\n",
720 fsc
->fs
.h_u
.usr_ip4_spec
.ip4dst
);
721 p
+= ETH_GSTRING_LEN
;
723 sprintf(p
, "\tDest IP mask: 0x%x\n",
724 fsc
->fs
.m_u
.usr_ip4_spec
.ip4dst
);
725 p
+= ETH_GSTRING_LEN
;
729 sprintf(p
, "\tSrc IP addr: 0x%x\n",
730 fsc
->fs
.h_u
.usr_ip4_spec
.ip4src
);
731 p
+= ETH_GSTRING_LEN
;
733 sprintf(p
, "\tSrc IP mask: 0x%x\n",
734 fsc
->fs
.m_u
.usr_ip4_spec
.ip4src
);
735 p
+= ETH_GSTRING_LEN
;
737 sprintf(p
, "\tDest IP addr: 0x%x\n",
738 fsc
->fs
.h_u
.usr_ip4_spec
.ip4dst
);
739 p
+= ETH_GSTRING_LEN
;
741 sprintf(p
, "\tDest IP mask: 0x%x\n",
742 fsc
->fs
.m_u
.usr_ip4_spec
.ip4dst
);
743 p
+= ETH_GSTRING_LEN
;
745 sprintf(p
, "\tL4 bytes: 0x%x, mask: 0x%x\n",
746 fsc
->fs
.h_u
.usr_ip4_spec
.l4_4_bytes
,
747 fsc
->fs
.m_u
.usr_ip4_spec
.l4_4_bytes
);
748 p
+= ETH_GSTRING_LEN
;
750 sprintf(p
, "\tTOS: %d, mask: 0x%x\n",
751 fsc
->fs
.h_u
.usr_ip4_spec
.tos
,
752 fsc
->fs
.m_u
.usr_ip4_spec
.tos
);
753 p
+= ETH_GSTRING_LEN
;
755 sprintf(p
, "\tIP Version: %d, mask: 0x%x\n",
756 fsc
->fs
.h_u
.usr_ip4_spec
.ip_ver
,
757 fsc
->fs
.m_u
.usr_ip4_spec
.ip_ver
);
758 p
+= ETH_GSTRING_LEN
;
760 sprintf(p
, "\tProtocol: %d, mask: 0x%x\n",
761 fsc
->fs
.h_u
.usr_ip4_spec
.proto
,
762 fsc
->fs
.m_u
.usr_ip4_spec
.proto
);
763 p
+= ETH_GSTRING_LEN
;
767 sprintf(p
, "\tVLAN: %d, mask: 0x%x\n",
768 fsc
->fs
.vlan_tag
, fsc
->fs
.vlan_tag_mask
);
769 p
+= ETH_GSTRING_LEN
;
771 sprintf(p
, "\tUser-defined: 0x%Lx\n", fsc
->fs
.data
);
772 p
+= ETH_GSTRING_LEN
;
774 sprintf(p
, "\tUser-defined mask: 0x%Lx\n", fsc
->fs
.data_mask
);
775 p
+= ETH_GSTRING_LEN
;
777 if (fsc
->fs
.action
== ETHTOOL_RXNTUPLE_ACTION_DROP
)
778 sprintf(p
, "\tAction: Drop\n");
780 sprintf(p
, "\tAction: Direct to queue %d\n",
782 p
+= ETH_GSTRING_LEN
;
788 /* indicate to userspace how many strings we actually have */
789 gstrings
.len
= num_strings
;
791 if (copy_to_user(useraddr
, &gstrings
, sizeof(gstrings
)))
793 useraddr
+= sizeof(gstrings
);
794 if (copy_to_user(useraddr
, data
, gstrings
.len
* ETH_GSTRING_LEN
))
803 static int ethtool_get_regs(struct net_device
*dev
, char __user
*useraddr
)
805 struct ethtool_regs regs
;
806 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
810 if (!ops
->get_regs
|| !ops
->get_regs_len
)
813 if (copy_from_user(®s
, useraddr
, sizeof(regs
)))
816 reglen
= ops
->get_regs_len(dev
);
817 if (regs
.len
> reglen
)
820 regbuf
= vmalloc(reglen
);
824 ops
->get_regs(dev
, ®s
, regbuf
);
827 if (copy_to_user(useraddr
, ®s
, sizeof(regs
)))
829 useraddr
+= offsetof(struct ethtool_regs
, data
);
830 if (copy_to_user(useraddr
, regbuf
, regs
.len
))
839 static int ethtool_reset(struct net_device
*dev
, char __user
*useraddr
)
841 struct ethtool_value reset
;
844 if (!dev
->ethtool_ops
->reset
)
847 if (copy_from_user(&reset
, useraddr
, sizeof(reset
)))
850 ret
= dev
->ethtool_ops
->reset(dev
, &reset
.data
);
854 if (copy_to_user(useraddr
, &reset
, sizeof(reset
)))
859 static int ethtool_get_wol(struct net_device
*dev
, char __user
*useraddr
)
861 struct ethtool_wolinfo wol
= { .cmd
= ETHTOOL_GWOL
};
863 if (!dev
->ethtool_ops
->get_wol
)
866 dev
->ethtool_ops
->get_wol(dev
, &wol
);
868 if (copy_to_user(useraddr
, &wol
, sizeof(wol
)))
873 static int ethtool_set_wol(struct net_device
*dev
, char __user
*useraddr
)
875 struct ethtool_wolinfo wol
;
877 if (!dev
->ethtool_ops
->set_wol
)
880 if (copy_from_user(&wol
, useraddr
, sizeof(wol
)))
883 return dev
->ethtool_ops
->set_wol(dev
, &wol
);
886 static int ethtool_nway_reset(struct net_device
*dev
)
888 if (!dev
->ethtool_ops
->nway_reset
)
891 return dev
->ethtool_ops
->nway_reset(dev
);
894 static int ethtool_get_eeprom(struct net_device
*dev
, void __user
*useraddr
)
896 struct ethtool_eeprom eeprom
;
897 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
898 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
903 if (!ops
->get_eeprom
|| !ops
->get_eeprom_len
)
906 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
909 /* Check for wrap and zero */
910 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
913 /* Check for exceeding total eeprom len */
914 if (eeprom
.offset
+ eeprom
.len
> ops
->get_eeprom_len(dev
))
917 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
921 bytes_remaining
= eeprom
.len
;
922 while (bytes_remaining
> 0) {
923 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
925 ret
= ops
->get_eeprom(dev
, &eeprom
, data
);
928 if (copy_to_user(userbuf
, data
, eeprom
.len
)) {
932 userbuf
+= eeprom
.len
;
933 eeprom
.offset
+= eeprom
.len
;
934 bytes_remaining
-= eeprom
.len
;
937 eeprom
.len
= userbuf
- (useraddr
+ sizeof(eeprom
));
938 eeprom
.offset
-= eeprom
.len
;
939 if (copy_to_user(useraddr
, &eeprom
, sizeof(eeprom
)))
946 static int ethtool_set_eeprom(struct net_device
*dev
, void __user
*useraddr
)
948 struct ethtool_eeprom eeprom
;
949 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
950 void __user
*userbuf
= useraddr
+ sizeof(eeprom
);
955 if (!ops
->set_eeprom
|| !ops
->get_eeprom_len
)
958 if (copy_from_user(&eeprom
, useraddr
, sizeof(eeprom
)))
961 /* Check for wrap and zero */
962 if (eeprom
.offset
+ eeprom
.len
<= eeprom
.offset
)
965 /* Check for exceeding total eeprom len */
966 if (eeprom
.offset
+ eeprom
.len
> ops
->get_eeprom_len(dev
))
969 data
= kmalloc(PAGE_SIZE
, GFP_USER
);
973 bytes_remaining
= eeprom
.len
;
974 while (bytes_remaining
> 0) {
975 eeprom
.len
= min(bytes_remaining
, (u32
)PAGE_SIZE
);
977 if (copy_from_user(data
, userbuf
, eeprom
.len
)) {
981 ret
= ops
->set_eeprom(dev
, &eeprom
, data
);
984 userbuf
+= eeprom
.len
;
985 eeprom
.offset
+= eeprom
.len
;
986 bytes_remaining
-= eeprom
.len
;
993 static noinline_for_stack
int ethtool_get_coalesce(struct net_device
*dev
,
994 void __user
*useraddr
)
996 struct ethtool_coalesce coalesce
= { .cmd
= ETHTOOL_GCOALESCE
};
998 if (!dev
->ethtool_ops
->get_coalesce
)
1001 dev
->ethtool_ops
->get_coalesce(dev
, &coalesce
);
1003 if (copy_to_user(useraddr
, &coalesce
, sizeof(coalesce
)))
1008 static noinline_for_stack
int ethtool_set_coalesce(struct net_device
*dev
,
1009 void __user
*useraddr
)
1011 struct ethtool_coalesce coalesce
;
1013 if (!dev
->ethtool_ops
->set_coalesce
)
1016 if (copy_from_user(&coalesce
, useraddr
, sizeof(coalesce
)))
1019 return dev
->ethtool_ops
->set_coalesce(dev
, &coalesce
);
1022 static int ethtool_get_ringparam(struct net_device
*dev
, void __user
*useraddr
)
1024 struct ethtool_ringparam ringparam
= { .cmd
= ETHTOOL_GRINGPARAM
};
1026 if (!dev
->ethtool_ops
->get_ringparam
)
1029 dev
->ethtool_ops
->get_ringparam(dev
, &ringparam
);
1031 if (copy_to_user(useraddr
, &ringparam
, sizeof(ringparam
)))
1036 static int ethtool_set_ringparam(struct net_device
*dev
, void __user
*useraddr
)
1038 struct ethtool_ringparam ringparam
;
1040 if (!dev
->ethtool_ops
->set_ringparam
)
1043 if (copy_from_user(&ringparam
, useraddr
, sizeof(ringparam
)))
1046 return dev
->ethtool_ops
->set_ringparam(dev
, &ringparam
);
1049 static int ethtool_get_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1051 struct ethtool_pauseparam pauseparam
= { ETHTOOL_GPAUSEPARAM
};
1053 if (!dev
->ethtool_ops
->get_pauseparam
)
1056 dev
->ethtool_ops
->get_pauseparam(dev
, &pauseparam
);
1058 if (copy_to_user(useraddr
, &pauseparam
, sizeof(pauseparam
)))
1063 static int ethtool_set_pauseparam(struct net_device
*dev
, void __user
*useraddr
)
1065 struct ethtool_pauseparam pauseparam
;
1067 if (!dev
->ethtool_ops
->set_pauseparam
)
1070 if (copy_from_user(&pauseparam
, useraddr
, sizeof(pauseparam
)))
1073 return dev
->ethtool_ops
->set_pauseparam(dev
, &pauseparam
);
1076 static int __ethtool_set_sg(struct net_device
*dev
, u32 data
)
1080 if (!data
&& dev
->ethtool_ops
->set_tso
) {
1081 err
= dev
->ethtool_ops
->set_tso(dev
, 0);
1086 if (!data
&& dev
->ethtool_ops
->set_ufo
) {
1087 err
= dev
->ethtool_ops
->set_ufo(dev
, 0);
1091 return dev
->ethtool_ops
->set_sg(dev
, data
);
1094 static int ethtool_set_tx_csum(struct net_device
*dev
, char __user
*useraddr
)
1096 struct ethtool_value edata
;
1099 if (!dev
->ethtool_ops
->set_tx_csum
)
1102 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1105 if (!edata
.data
&& dev
->ethtool_ops
->set_sg
) {
1106 err
= __ethtool_set_sg(dev
, 0);
1111 return dev
->ethtool_ops
->set_tx_csum(dev
, edata
.data
);
1113 EXPORT_SYMBOL(ethtool_op_set_tx_csum
);
1115 static int ethtool_set_rx_csum(struct net_device
*dev
, char __user
*useraddr
)
1117 struct ethtool_value edata
;
1119 if (!dev
->ethtool_ops
->set_rx_csum
)
1122 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1125 if (!edata
.data
&& dev
->ethtool_ops
->set_sg
)
1126 dev
->features
&= ~NETIF_F_GRO
;
1128 return dev
->ethtool_ops
->set_rx_csum(dev
, edata
.data
);
1131 static int ethtool_set_sg(struct net_device
*dev
, char __user
*useraddr
)
1133 struct ethtool_value edata
;
1135 if (!dev
->ethtool_ops
->set_sg
)
1138 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1142 !(dev
->features
& NETIF_F_ALL_CSUM
))
1145 return __ethtool_set_sg(dev
, edata
.data
);
1148 static int ethtool_set_tso(struct net_device
*dev
, char __user
*useraddr
)
1150 struct ethtool_value edata
;
1152 if (!dev
->ethtool_ops
->set_tso
)
1155 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1158 if (edata
.data
&& !(dev
->features
& NETIF_F_SG
))
1161 return dev
->ethtool_ops
->set_tso(dev
, edata
.data
);
1164 static int ethtool_set_ufo(struct net_device
*dev
, char __user
*useraddr
)
1166 struct ethtool_value edata
;
1168 if (!dev
->ethtool_ops
->set_ufo
)
1170 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1172 if (edata
.data
&& !(dev
->features
& NETIF_F_SG
))
1174 if (edata
.data
&& !(dev
->features
& NETIF_F_HW_CSUM
))
1176 return dev
->ethtool_ops
->set_ufo(dev
, edata
.data
);
1179 static int ethtool_get_gso(struct net_device
*dev
, char __user
*useraddr
)
1181 struct ethtool_value edata
= { ETHTOOL_GGSO
};
1183 edata
.data
= dev
->features
& NETIF_F_GSO
;
1184 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
1189 static int ethtool_set_gso(struct net_device
*dev
, char __user
*useraddr
)
1191 struct ethtool_value edata
;
1193 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1196 dev
->features
|= NETIF_F_GSO
;
1198 dev
->features
&= ~NETIF_F_GSO
;
1202 static int ethtool_get_gro(struct net_device
*dev
, char __user
*useraddr
)
1204 struct ethtool_value edata
= { ETHTOOL_GGRO
};
1206 edata
.data
= dev
->features
& NETIF_F_GRO
;
1207 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
1212 static int ethtool_set_gro(struct net_device
*dev
, char __user
*useraddr
)
1214 struct ethtool_value edata
;
1216 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1220 u32 rxcsum
= dev
->ethtool_ops
->get_rx_csum
?
1221 dev
->ethtool_ops
->get_rx_csum(dev
) :
1222 ethtool_op_get_rx_csum(dev
);
1226 dev
->features
|= NETIF_F_GRO
;
1228 dev
->features
&= ~NETIF_F_GRO
;
1233 static int ethtool_self_test(struct net_device
*dev
, char __user
*useraddr
)
1235 struct ethtool_test test
;
1236 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1240 if (!ops
->self_test
|| !ops
->get_sset_count
)
1243 test_len
= ops
->get_sset_count(dev
, ETH_SS_TEST
);
1246 WARN_ON(test_len
== 0);
1248 if (copy_from_user(&test
, useraddr
, sizeof(test
)))
1251 test
.len
= test_len
;
1252 data
= kmalloc(test_len
* sizeof(u64
), GFP_USER
);
1256 ops
->self_test(dev
, &test
, data
);
1259 if (copy_to_user(useraddr
, &test
, sizeof(test
)))
1261 useraddr
+= sizeof(test
);
1262 if (copy_to_user(useraddr
, data
, test
.len
* sizeof(u64
)))
1271 static int ethtool_get_strings(struct net_device
*dev
, void __user
*useraddr
)
1273 struct ethtool_gstrings gstrings
;
1274 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1278 if (!ops
->get_strings
|| !ops
->get_sset_count
)
1281 if (copy_from_user(&gstrings
, useraddr
, sizeof(gstrings
)))
1284 ret
= ops
->get_sset_count(dev
, gstrings
.string_set
);
1290 data
= kmalloc(gstrings
.len
* ETH_GSTRING_LEN
, GFP_USER
);
1294 ops
->get_strings(dev
, gstrings
.string_set
, data
);
1297 if (copy_to_user(useraddr
, &gstrings
, sizeof(gstrings
)))
1299 useraddr
+= sizeof(gstrings
);
1300 if (copy_to_user(useraddr
, data
, gstrings
.len
* ETH_GSTRING_LEN
))
1309 static int ethtool_phys_id(struct net_device
*dev
, void __user
*useraddr
)
1311 struct ethtool_value id
;
1313 if (!dev
->ethtool_ops
->phys_id
)
1316 if (copy_from_user(&id
, useraddr
, sizeof(id
)))
1319 return dev
->ethtool_ops
->phys_id(dev
, id
.data
);
1322 static int ethtool_get_stats(struct net_device
*dev
, void __user
*useraddr
)
1324 struct ethtool_stats stats
;
1325 const struct ethtool_ops
*ops
= dev
->ethtool_ops
;
1329 if (!ops
->get_ethtool_stats
|| !ops
->get_sset_count
)
1332 n_stats
= ops
->get_sset_count(dev
, ETH_SS_STATS
);
1335 WARN_ON(n_stats
== 0);
1337 if (copy_from_user(&stats
, useraddr
, sizeof(stats
)))
1340 stats
.n_stats
= n_stats
;
1341 data
= kmalloc(n_stats
* sizeof(u64
), GFP_USER
);
1345 ops
->get_ethtool_stats(dev
, &stats
, data
);
1348 if (copy_to_user(useraddr
, &stats
, sizeof(stats
)))
1350 useraddr
+= sizeof(stats
);
1351 if (copy_to_user(useraddr
, data
, stats
.n_stats
* sizeof(u64
)))
1360 static int ethtool_get_perm_addr(struct net_device
*dev
, void __user
*useraddr
)
1362 struct ethtool_perm_addr epaddr
;
1364 if (copy_from_user(&epaddr
, useraddr
, sizeof(epaddr
)))
1367 if (epaddr
.size
< dev
->addr_len
)
1369 epaddr
.size
= dev
->addr_len
;
1371 if (copy_to_user(useraddr
, &epaddr
, sizeof(epaddr
)))
1373 useraddr
+= sizeof(epaddr
);
1374 if (copy_to_user(useraddr
, dev
->perm_addr
, epaddr
.size
))
1379 static int ethtool_get_value(struct net_device
*dev
, char __user
*useraddr
,
1380 u32 cmd
, u32 (*actor
)(struct net_device
*))
1382 struct ethtool_value edata
= { .cmd
= cmd
};
1387 edata
.data
= actor(dev
);
1389 if (copy_to_user(useraddr
, &edata
, sizeof(edata
)))
1394 static int ethtool_set_value_void(struct net_device
*dev
, char __user
*useraddr
,
1395 void (*actor
)(struct net_device
*, u32
))
1397 struct ethtool_value edata
;
1402 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1405 actor(dev
, edata
.data
);
1409 static int ethtool_set_value(struct net_device
*dev
, char __user
*useraddr
,
1410 int (*actor
)(struct net_device
*, u32
))
1412 struct ethtool_value edata
;
1417 if (copy_from_user(&edata
, useraddr
, sizeof(edata
)))
1420 return actor(dev
, edata
.data
);
1423 static noinline_for_stack
int ethtool_flash_device(struct net_device
*dev
,
1424 char __user
*useraddr
)
1426 struct ethtool_flash efl
;
1428 if (copy_from_user(&efl
, useraddr
, sizeof(efl
)))
1431 if (!dev
->ethtool_ops
->flash_device
)
1434 return dev
->ethtool_ops
->flash_device(dev
, &efl
);
1437 /* The main entry point in this file. Called from net/core/dev.c */
1439 int dev_ethtool(struct net
*net
, struct ifreq
*ifr
)
1441 struct net_device
*dev
= __dev_get_by_name(net
, ifr
->ifr_name
);
1442 void __user
*useraddr
= ifr
->ifr_data
;
1445 unsigned long old_features
;
1447 if (!dev
|| !netif_device_present(dev
))
1450 if (copy_from_user(ðcmd
, useraddr
, sizeof(ethcmd
)))
1453 if (!dev
->ethtool_ops
) {
1454 /* ETHTOOL_GDRVINFO does not require any driver support.
1455 * It is also unprivileged and does not change anything,
1456 * so we can take a shortcut to it. */
1457 if (ethcmd
== ETHTOOL_GDRVINFO
)
1458 return ethtool_get_drvinfo(dev
, useraddr
);
1463 /* Allow some commands to be done by anyone */
1466 case ETHTOOL_GDRVINFO
:
1467 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_GSTRINGS
:
1476 case ETHTOOL_GPERMADDR
:
1480 case ETHTOOL_GFLAGS
:
1481 case ETHTOOL_GPFLAGS
:
1483 case ETHTOOL_GRXRINGS
:
1484 case ETHTOOL_GRXCLSRLCNT
:
1485 case ETHTOOL_GRXCLSRULE
:
1486 case ETHTOOL_GRXCLSRLALL
:
1489 if (!capable(CAP_NET_ADMIN
))
1493 if (dev
->ethtool_ops
->begin
) {
1494 rc
= dev
->ethtool_ops
->begin(dev
);
1498 old_features
= dev
->features
;
1502 rc
= ethtool_get_settings(dev
, useraddr
);
1505 rc
= ethtool_set_settings(dev
, useraddr
);
1507 case ETHTOOL_GDRVINFO
:
1508 rc
= ethtool_get_drvinfo(dev
, useraddr
);
1511 rc
= ethtool_get_regs(dev
, useraddr
);
1514 rc
= ethtool_get_wol(dev
, useraddr
);
1517 rc
= ethtool_set_wol(dev
, useraddr
);
1519 case ETHTOOL_GMSGLVL
:
1520 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1521 dev
->ethtool_ops
->get_msglevel
);
1523 case ETHTOOL_SMSGLVL
:
1524 rc
= ethtool_set_value_void(dev
, useraddr
,
1525 dev
->ethtool_ops
->set_msglevel
);
1527 case ETHTOOL_NWAY_RST
:
1528 rc
= ethtool_nway_reset(dev
);
1531 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1532 dev
->ethtool_ops
->get_link
);
1534 case ETHTOOL_GEEPROM
:
1535 rc
= ethtool_get_eeprom(dev
, useraddr
);
1537 case ETHTOOL_SEEPROM
:
1538 rc
= ethtool_set_eeprom(dev
, useraddr
);
1540 case ETHTOOL_GCOALESCE
:
1541 rc
= ethtool_get_coalesce(dev
, useraddr
);
1543 case ETHTOOL_SCOALESCE
:
1544 rc
= ethtool_set_coalesce(dev
, useraddr
);
1546 case ETHTOOL_GRINGPARAM
:
1547 rc
= ethtool_get_ringparam(dev
, useraddr
);
1549 case ETHTOOL_SRINGPARAM
:
1550 rc
= ethtool_set_ringparam(dev
, useraddr
);
1552 case ETHTOOL_GPAUSEPARAM
:
1553 rc
= ethtool_get_pauseparam(dev
, useraddr
);
1555 case ETHTOOL_SPAUSEPARAM
:
1556 rc
= ethtool_set_pauseparam(dev
, useraddr
);
1558 case ETHTOOL_GRXCSUM
:
1559 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1560 (dev
->ethtool_ops
->get_rx_csum
?
1561 dev
->ethtool_ops
->get_rx_csum
:
1562 ethtool_op_get_rx_csum
));
1564 case ETHTOOL_SRXCSUM
:
1565 rc
= ethtool_set_rx_csum(dev
, useraddr
);
1567 case ETHTOOL_GTXCSUM
:
1568 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1569 (dev
->ethtool_ops
->get_tx_csum
?
1570 dev
->ethtool_ops
->get_tx_csum
:
1571 ethtool_op_get_tx_csum
));
1573 case ETHTOOL_STXCSUM
:
1574 rc
= ethtool_set_tx_csum(dev
, useraddr
);
1577 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1578 (dev
->ethtool_ops
->get_sg
?
1579 dev
->ethtool_ops
->get_sg
:
1580 ethtool_op_get_sg
));
1583 rc
= ethtool_set_sg(dev
, useraddr
);
1586 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1587 (dev
->ethtool_ops
->get_tso
?
1588 dev
->ethtool_ops
->get_tso
:
1589 ethtool_op_get_tso
));
1592 rc
= ethtool_set_tso(dev
, useraddr
);
1595 rc
= ethtool_self_test(dev
, useraddr
);
1597 case ETHTOOL_GSTRINGS
:
1598 rc
= ethtool_get_strings(dev
, useraddr
);
1600 case ETHTOOL_PHYS_ID
:
1601 rc
= ethtool_phys_id(dev
, useraddr
);
1603 case ETHTOOL_GSTATS
:
1604 rc
= ethtool_get_stats(dev
, useraddr
);
1606 case ETHTOOL_GPERMADDR
:
1607 rc
= ethtool_get_perm_addr(dev
, useraddr
);
1610 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1611 (dev
->ethtool_ops
->get_ufo
?
1612 dev
->ethtool_ops
->get_ufo
:
1613 ethtool_op_get_ufo
));
1616 rc
= ethtool_set_ufo(dev
, useraddr
);
1619 rc
= ethtool_get_gso(dev
, useraddr
);
1622 rc
= ethtool_set_gso(dev
, useraddr
);
1624 case ETHTOOL_GFLAGS
:
1625 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1626 (dev
->ethtool_ops
->get_flags
?
1627 dev
->ethtool_ops
->get_flags
:
1628 ethtool_op_get_flags
));
1630 case ETHTOOL_SFLAGS
:
1631 rc
= ethtool_set_value(dev
, useraddr
,
1632 dev
->ethtool_ops
->set_flags
);
1634 case ETHTOOL_GPFLAGS
:
1635 rc
= ethtool_get_value(dev
, useraddr
, ethcmd
,
1636 dev
->ethtool_ops
->get_priv_flags
);
1638 case ETHTOOL_SPFLAGS
:
1639 rc
= ethtool_set_value(dev
, useraddr
,
1640 dev
->ethtool_ops
->set_priv_flags
);
1643 case ETHTOOL_GRXRINGS
:
1644 case ETHTOOL_GRXCLSRLCNT
:
1645 case ETHTOOL_GRXCLSRULE
:
1646 case ETHTOOL_GRXCLSRLALL
:
1647 rc
= ethtool_get_rxnfc(dev
, ethcmd
, useraddr
);
1650 case ETHTOOL_SRXCLSRLDEL
:
1651 case ETHTOOL_SRXCLSRLINS
:
1652 rc
= ethtool_set_rxnfc(dev
, ethcmd
, useraddr
);
1655 rc
= ethtool_get_gro(dev
, useraddr
);
1658 rc
= ethtool_set_gro(dev
, useraddr
);
1660 case ETHTOOL_FLASHDEV
:
1661 rc
= ethtool_flash_device(dev
, useraddr
);
1664 rc
= ethtool_reset(dev
, useraddr
);
1666 case ETHTOOL_SRXNTUPLE
:
1667 rc
= ethtool_set_rx_ntuple(dev
, useraddr
);
1669 case ETHTOOL_GRXNTUPLE
:
1670 rc
= ethtool_get_rx_ntuple(dev
, useraddr
);
1672 case ETHTOOL_GSSET_INFO
:
1673 rc
= ethtool_get_sset_info(dev
, useraddr
);
1675 case ETHTOOL_GRXFHINDIR
:
1676 rc
= ethtool_get_rxfh_indir(dev
, useraddr
);
1678 case ETHTOOL_SRXFHINDIR
:
1679 rc
= ethtool_set_rxfh_indir(dev
, useraddr
);
1685 if (dev
->ethtool_ops
->complete
)
1686 dev
->ethtool_ops
->complete(dev
);
1688 if (old_features
!= dev
->features
)
1689 netdev_features_change(dev
);