blob: 82cae3bca78ddc76864a3c5b536e4bf01c797112 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * net/core/ethtool.c - Ethtool ioctl handler
3 * Copyright (c) 2003 Matthew Wilcox <matthew@wil.cx>
4 *
5 * This file is where we call all the ethtool_ops commands to get
Matthew Wilcox61a44b92007-07-31 14:00:02 -07006 * the information ethtool needs.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
Matthew Wilcox61a44b92007-07-31 14:00:02 -07008 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 */
13
14#include <linux/module.h>
15#include <linux/types.h>
Randy Dunlap4fc268d2006-01-11 12:17:47 -080016#include <linux/capability.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/errno.h>
18#include <linux/ethtool.h>
19#include <linux/netdevice.h>
20#include <asm/uaccess.h>
21
YOSHIFUJI Hideaki4ec93ed2007-02-09 23:24:36 +090022/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 * Some useful ethtool_ops methods that're device independent.
24 * If we find that all drivers want to do the same thing here,
25 * we can turn these into dev_() function calls.
26 */
27
28u32 ethtool_op_get_link(struct net_device *dev)
29{
30 return netif_carrier_ok(dev) ? 1 : 0;
31}
32
Sridhar Samudrala1896e612009-07-22 13:38:22 +000033u32 ethtool_op_get_rx_csum(struct net_device *dev)
34{
35 return (dev->features & NETIF_F_ALL_CSUM) != 0;
36}
Eric Dumazet8a729fc2009-07-26 23:18:11 +000037EXPORT_SYMBOL(ethtool_op_get_rx_csum);
Sridhar Samudrala1896e612009-07-22 13:38:22 +000038
Linus Torvalds1da177e2005-04-16 15:20:36 -070039u32 ethtool_op_get_tx_csum(struct net_device *dev)
40{
Herbert Xu8648b302006-06-17 22:06:05 -070041 return (dev->features & NETIF_F_ALL_CSUM) != 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
Eric Dumazet8a729fc2009-07-26 23:18:11 +000043EXPORT_SYMBOL(ethtool_op_get_tx_csum);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
46{
47 if (data)
48 dev->features |= NETIF_F_IP_CSUM;
49 else
50 dev->features &= ~NETIF_F_IP_CSUM;
51
52 return 0;
53}
54
Jon Mason69f6a0f2005-05-29 20:27:24 -070055int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data)
56{
57 if (data)
58 dev->features |= NETIF_F_HW_CSUM;
59 else
60 dev->features &= ~NETIF_F_HW_CSUM;
61
62 return 0;
63}
Michael Chan6460d942007-07-14 19:07:52 -070064
65int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data)
66{
67 if (data)
68 dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
69 else
70 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
71
72 return 0;
73}
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075u32 ethtool_op_get_sg(struct net_device *dev)
76{
77 return (dev->features & NETIF_F_SG) != 0;
78}
79
80int ethtool_op_set_sg(struct net_device *dev, u32 data)
81{
82 if (data)
83 dev->features |= NETIF_F_SG;
84 else
85 dev->features &= ~NETIF_F_SG;
86
87 return 0;
88}
89
90u32 ethtool_op_get_tso(struct net_device *dev)
91{
92 return (dev->features & NETIF_F_TSO) != 0;
93}
94
95int ethtool_op_set_tso(struct net_device *dev, u32 data)
96{
97 if (data)
98 dev->features |= NETIF_F_TSO;
99 else
100 dev->features &= ~NETIF_F_TSO;
101
102 return 0;
103}
104
Ananda Rajue89e9cf2005-10-18 15:46:41 -0700105u32 ethtool_op_get_ufo(struct net_device *dev)
106{
107 return (dev->features & NETIF_F_UFO) != 0;
108}
109
110int ethtool_op_set_ufo(struct net_device *dev, u32 data)
111{
112 if (data)
113 dev->features |= NETIF_F_UFO;
114 else
115 dev->features &= ~NETIF_F_UFO;
116 return 0;
117}
118
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -0700119/* the following list of flags are the same as their associated
120 * NETIF_F_xxx values in include/linux/netdevice.h
121 */
122static const u32 flags_dup_features =
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800123 (ETH_FLAG_LRO | ETH_FLAG_NTUPLE);
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -0700124
125u32 ethtool_op_get_flags(struct net_device *dev)
126{
127 /* in the future, this function will probably contain additional
128 * handling for flags which are not so easily handled
129 * by a simple masking operation
130 */
131
132 return dev->features & flags_dup_features;
133}
134
135int ethtool_op_set_flags(struct net_device *dev, u32 data)
136{
Peter Waskiewicz0d643e12010-02-12 13:48:25 +0000137 const struct ethtool_ops *ops = dev->ethtool_ops;
138
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -0700139 if (data & ETH_FLAG_LRO)
140 dev->features |= NETIF_F_LRO;
141 else
142 dev->features &= ~NETIF_F_LRO;
143
Peter Waskiewicz0d643e12010-02-12 13:48:25 +0000144 if (data & ETH_FLAG_NTUPLE) {
145 if (!ops->set_rx_ntuple)
146 return -EOPNOTSUPP;
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800147 dev->features |= NETIF_F_NTUPLE;
Peter Waskiewicz0d643e12010-02-12 13:48:25 +0000148 } else {
149 /* safe to clear regardless */
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800150 dev->features &= ~NETIF_F_NTUPLE;
Peter Waskiewicz0d643e12010-02-12 13:48:25 +0000151 }
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800152
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -0700153 return 0;
154}
155
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800156void ethtool_ntuple_flush(struct net_device *dev)
157{
158 struct ethtool_rx_ntuple_flow_spec_container *fsc, *f;
159
160 list_for_each_entry_safe(fsc, f, &dev->ethtool_ntuple_list.list, list) {
161 list_del(&fsc->list);
162 kfree(fsc);
163 }
164 dev->ethtool_ntuple_list.count = 0;
165}
166EXPORT_SYMBOL(ethtool_ntuple_flush);
167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168/* Handlers for each ethtool command */
169
170static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
171{
Roland Dreier8e557422010-02-11 12:14:23 -0800172 struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 int err;
174
175 if (!dev->ethtool_ops->get_settings)
176 return -EOPNOTSUPP;
177
178 err = dev->ethtool_ops->get_settings(dev, &cmd);
179 if (err < 0)
180 return err;
181
182 if (copy_to_user(useraddr, &cmd, sizeof(cmd)))
183 return -EFAULT;
184 return 0;
185}
186
187static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
188{
189 struct ethtool_cmd cmd;
190
191 if (!dev->ethtool_ops->set_settings)
192 return -EOPNOTSUPP;
193
194 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
195 return -EFAULT;
196
197 return dev->ethtool_ops->set_settings(dev, &cmd);
198}
199
Eric Dumazet339c6e92010-02-15 21:51:33 -0800200/*
201 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
202 */
203static noinline int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204{
205 struct ethtool_drvinfo info;
Stephen Hemminger76fd8592006-09-08 11:16:13 -0700206 const struct ethtool_ops *ops = dev->ethtool_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208 if (!ops->get_drvinfo)
209 return -EOPNOTSUPP;
210
211 memset(&info, 0, sizeof(info));
212 info.cmd = ETHTOOL_GDRVINFO;
213 ops->get_drvinfo(dev, &info);
214
Jeff Garzikff03d492007-08-15 16:01:08 -0700215 if (ops->get_sset_count) {
216 int rc;
217
218 rc = ops->get_sset_count(dev, ETH_SS_TEST);
219 if (rc >= 0)
220 info.testinfo_len = rc;
221 rc = ops->get_sset_count(dev, ETH_SS_STATS);
222 if (rc >= 0)
223 info.n_stats = rc;
Jeff Garzik339bf022007-08-15 16:01:32 -0700224 rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS);
225 if (rc >= 0)
226 info.n_priv_flags = rc;
Jeff Garzikff03d492007-08-15 16:01:08 -0700227 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 if (ops->get_regs_len)
229 info.regdump_len = ops->get_regs_len(dev);
230 if (ops->get_eeprom_len)
231 info.eedump_len = ops->get_eeprom_len(dev);
232
233 if (copy_to_user(useraddr, &info, sizeof(info)))
234 return -EFAULT;
235 return 0;
236}
237
Eric Dumazet339c6e92010-02-15 21:51:33 -0800238/*
239 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
240 */
241static noinline int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr)
Santwona Behera0853ad62008-07-02 03:47:41 -0700242{
243 struct ethtool_rxnfc cmd;
244
Santwona Behera59089d82009-02-20 00:58:13 -0800245 if (!dev->ethtool_ops->set_rxnfc)
Santwona Behera0853ad62008-07-02 03:47:41 -0700246 return -EOPNOTSUPP;
247
248 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
249 return -EFAULT;
250
Santwona Behera59089d82009-02-20 00:58:13 -0800251 return dev->ethtool_ops->set_rxnfc(dev, &cmd);
Santwona Behera0853ad62008-07-02 03:47:41 -0700252}
253
Eric Dumazet339c6e92010-02-15 21:51:33 -0800254/*
255 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
256 */
257static noinline int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr)
Santwona Behera0853ad62008-07-02 03:47:41 -0700258{
259 struct ethtool_rxnfc info;
Santwona Behera59089d82009-02-20 00:58:13 -0800260 const struct ethtool_ops *ops = dev->ethtool_ops;
261 int ret;
262 void *rule_buf = NULL;
Santwona Behera0853ad62008-07-02 03:47:41 -0700263
Santwona Behera59089d82009-02-20 00:58:13 -0800264 if (!ops->get_rxnfc)
Santwona Behera0853ad62008-07-02 03:47:41 -0700265 return -EOPNOTSUPP;
266
267 if (copy_from_user(&info, useraddr, sizeof(info)))
268 return -EFAULT;
269
Santwona Behera59089d82009-02-20 00:58:13 -0800270 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
271 if (info.rule_cnt > 0) {
272 rule_buf = kmalloc(info.rule_cnt * sizeof(u32),
273 GFP_USER);
274 if (!rule_buf)
275 return -ENOMEM;
276 }
277 }
Santwona Behera0853ad62008-07-02 03:47:41 -0700278
Santwona Behera59089d82009-02-20 00:58:13 -0800279 ret = ops->get_rxnfc(dev, &info, rule_buf);
280 if (ret < 0)
281 goto err_out;
282
283 ret = -EFAULT;
Santwona Behera0853ad62008-07-02 03:47:41 -0700284 if (copy_to_user(useraddr, &info, sizeof(info)))
Santwona Behera59089d82009-02-20 00:58:13 -0800285 goto err_out;
286
287 if (rule_buf) {
288 useraddr += offsetof(struct ethtool_rxnfc, rule_locs);
289 if (copy_to_user(useraddr, rule_buf,
290 info.rule_cnt * sizeof(u32)))
291 goto err_out;
292 }
293 ret = 0;
294
295err_out:
Wei Yongjunc9cacec2009-03-31 15:06:26 -0700296 kfree(rule_buf);
Santwona Behera59089d82009-02-20 00:58:13 -0800297
298 return ret;
Santwona Behera0853ad62008-07-02 03:47:41 -0700299}
300
Peter Waskiewicze8589112010-02-12 13:48:05 +0000301static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list,
302 struct ethtool_rx_ntuple_flow_spec *spec,
303 struct ethtool_rx_ntuple_flow_spec_container *fsc)
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800304{
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800305
306 /* don't add filters forever */
Peter Waskiewicze8589112010-02-12 13:48:05 +0000307 if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY) {
308 /* free the container */
309 kfree(fsc);
310 return;
311 }
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800312
313 /* Copy the whole filter over */
314 fsc->fs.flow_type = spec->flow_type;
315 memcpy(&fsc->fs.h_u, &spec->h_u, sizeof(spec->h_u));
316 memcpy(&fsc->fs.m_u, &spec->m_u, sizeof(spec->m_u));
317
318 fsc->fs.vlan_tag = spec->vlan_tag;
319 fsc->fs.vlan_tag_mask = spec->vlan_tag_mask;
320 fsc->fs.data = spec->data;
321 fsc->fs.data_mask = spec->data_mask;
322 fsc->fs.action = spec->action;
323
324 /* add to the list */
325 list_add_tail_rcu(&fsc->list, &list->list);
326 list->count++;
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800327}
328
Eric Dumazet339c6e92010-02-15 21:51:33 -0800329/*
330 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
331 */
332static noinline int ethtool_set_rx_ntuple(struct net_device *dev, void __user *useraddr)
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800333{
334 struct ethtool_rx_ntuple cmd;
335 const struct ethtool_ops *ops = dev->ethtool_ops;
Peter Waskiewicze8589112010-02-12 13:48:05 +0000336 struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL;
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800337 int ret;
338
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800339 if (!(dev->features & NETIF_F_NTUPLE))
340 return -EINVAL;
341
342 if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
343 return -EFAULT;
344
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800345 /*
346 * Cache filter in dev struct for GET operation only if
347 * the underlying driver doesn't have its own GET operation, and
Peter Waskiewicze8589112010-02-12 13:48:05 +0000348 * only if the filter was added successfully. First make sure we
349 * can allocate the filter, then continue if successful.
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800350 */
Peter Waskiewicze8589112010-02-12 13:48:05 +0000351 if (!ops->get_rx_ntuple) {
352 fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC);
353 if (!fsc)
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800354 return -ENOMEM;
Peter Waskiewicze8589112010-02-12 13:48:05 +0000355 }
356
357 ret = ops->set_rx_ntuple(dev, &cmd);
358 if (ret) {
359 kfree(fsc);
360 return ret;
361 }
362
363 if (!ops->get_rx_ntuple)
364 __rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs, fsc);
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800365
366 return ret;
367}
368
369static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr)
370{
371 struct ethtool_gstrings gstrings;
372 const struct ethtool_ops *ops = dev->ethtool_ops;
373 struct ethtool_rx_ntuple_flow_spec_container *fsc;
374 u8 *data;
375 char *p;
376 int ret, i, num_strings = 0;
377
378 if (!ops->get_sset_count)
379 return -EOPNOTSUPP;
380
381 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
382 return -EFAULT;
383
384 ret = ops->get_sset_count(dev, gstrings.string_set);
385 if (ret < 0)
386 return ret;
387
388 gstrings.len = ret;
389
390 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
391 if (!data)
392 return -ENOMEM;
393
394 if (ops->get_rx_ntuple) {
395 /* driver-specific filter grab */
396 ret = ops->get_rx_ntuple(dev, gstrings.string_set, data);
397 goto copy;
398 }
399
400 /* default ethtool filter grab */
401 i = 0;
402 p = (char *)data;
403 list_for_each_entry(fsc, &dev->ethtool_ntuple_list.list, list) {
404 sprintf(p, "Filter %d:\n", i);
405 p += ETH_GSTRING_LEN;
406 num_strings++;
407
408 switch (fsc->fs.flow_type) {
409 case TCP_V4_FLOW:
410 sprintf(p, "\tFlow Type: TCP\n");
411 p += ETH_GSTRING_LEN;
412 num_strings++;
413 break;
414 case UDP_V4_FLOW:
415 sprintf(p, "\tFlow Type: UDP\n");
416 p += ETH_GSTRING_LEN;
417 num_strings++;
418 break;
419 case SCTP_V4_FLOW:
420 sprintf(p, "\tFlow Type: SCTP\n");
421 p += ETH_GSTRING_LEN;
422 num_strings++;
423 break;
424 case AH_ESP_V4_FLOW:
425 sprintf(p, "\tFlow Type: AH ESP\n");
426 p += ETH_GSTRING_LEN;
427 num_strings++;
428 break;
429 case ESP_V4_FLOW:
430 sprintf(p, "\tFlow Type: ESP\n");
431 p += ETH_GSTRING_LEN;
432 num_strings++;
433 break;
434 case IP_USER_FLOW:
435 sprintf(p, "\tFlow Type: Raw IP\n");
436 p += ETH_GSTRING_LEN;
437 num_strings++;
438 break;
439 case IPV4_FLOW:
440 sprintf(p, "\tFlow Type: IPv4\n");
441 p += ETH_GSTRING_LEN;
442 num_strings++;
443 break;
444 default:
445 sprintf(p, "\tFlow Type: Unknown\n");
446 p += ETH_GSTRING_LEN;
447 num_strings++;
448 goto unknown_filter;
449 };
450
451 /* now the rest of the filters */
452 switch (fsc->fs.flow_type) {
453 case TCP_V4_FLOW:
454 case UDP_V4_FLOW:
455 case SCTP_V4_FLOW:
456 sprintf(p, "\tSrc IP addr: 0x%x\n",
457 fsc->fs.h_u.tcp_ip4_spec.ip4src);
458 p += ETH_GSTRING_LEN;
459 num_strings++;
460 sprintf(p, "\tSrc IP mask: 0x%x\n",
461 fsc->fs.m_u.tcp_ip4_spec.ip4src);
462 p += ETH_GSTRING_LEN;
463 num_strings++;
464 sprintf(p, "\tDest IP addr: 0x%x\n",
465 fsc->fs.h_u.tcp_ip4_spec.ip4dst);
466 p += ETH_GSTRING_LEN;
467 num_strings++;
468 sprintf(p, "\tDest IP mask: 0x%x\n",
469 fsc->fs.m_u.tcp_ip4_spec.ip4dst);
470 p += ETH_GSTRING_LEN;
471 num_strings++;
472 sprintf(p, "\tSrc Port: %d, mask: 0x%x\n",
473 fsc->fs.h_u.tcp_ip4_spec.psrc,
474 fsc->fs.m_u.tcp_ip4_spec.psrc);
475 p += ETH_GSTRING_LEN;
476 num_strings++;
477 sprintf(p, "\tDest Port: %d, mask: 0x%x\n",
478 fsc->fs.h_u.tcp_ip4_spec.pdst,
479 fsc->fs.m_u.tcp_ip4_spec.pdst);
480 p += ETH_GSTRING_LEN;
481 num_strings++;
482 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
483 fsc->fs.h_u.tcp_ip4_spec.tos,
484 fsc->fs.m_u.tcp_ip4_spec.tos);
485 p += ETH_GSTRING_LEN;
486 num_strings++;
487 break;
488 case AH_ESP_V4_FLOW:
489 case ESP_V4_FLOW:
490 sprintf(p, "\tSrc IP addr: 0x%x\n",
491 fsc->fs.h_u.ah_ip4_spec.ip4src);
492 p += ETH_GSTRING_LEN;
493 num_strings++;
494 sprintf(p, "\tSrc IP mask: 0x%x\n",
495 fsc->fs.m_u.ah_ip4_spec.ip4src);
496 p += ETH_GSTRING_LEN;
497 num_strings++;
498 sprintf(p, "\tDest IP addr: 0x%x\n",
499 fsc->fs.h_u.ah_ip4_spec.ip4dst);
500 p += ETH_GSTRING_LEN;
501 num_strings++;
502 sprintf(p, "\tDest IP mask: 0x%x\n",
503 fsc->fs.m_u.ah_ip4_spec.ip4dst);
504 p += ETH_GSTRING_LEN;
505 num_strings++;
506 sprintf(p, "\tSPI: %d, mask: 0x%x\n",
507 fsc->fs.h_u.ah_ip4_spec.spi,
508 fsc->fs.m_u.ah_ip4_spec.spi);
509 p += ETH_GSTRING_LEN;
510 num_strings++;
511 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
512 fsc->fs.h_u.ah_ip4_spec.tos,
513 fsc->fs.m_u.ah_ip4_spec.tos);
514 p += ETH_GSTRING_LEN;
515 num_strings++;
516 break;
517 case IP_USER_FLOW:
518 sprintf(p, "\tSrc IP addr: 0x%x\n",
519 fsc->fs.h_u.raw_ip4_spec.ip4src);
520 p += ETH_GSTRING_LEN;
521 num_strings++;
522 sprintf(p, "\tSrc IP mask: 0x%x\n",
523 fsc->fs.m_u.raw_ip4_spec.ip4src);
524 p += ETH_GSTRING_LEN;
525 num_strings++;
526 sprintf(p, "\tDest IP addr: 0x%x\n",
527 fsc->fs.h_u.raw_ip4_spec.ip4dst);
528 p += ETH_GSTRING_LEN;
529 num_strings++;
530 sprintf(p, "\tDest IP mask: 0x%x\n",
531 fsc->fs.m_u.raw_ip4_spec.ip4dst);
532 p += ETH_GSTRING_LEN;
533 num_strings++;
534 break;
535 case IPV4_FLOW:
536 sprintf(p, "\tSrc IP addr: 0x%x\n",
537 fsc->fs.h_u.usr_ip4_spec.ip4src);
538 p += ETH_GSTRING_LEN;
539 num_strings++;
540 sprintf(p, "\tSrc IP mask: 0x%x\n",
541 fsc->fs.m_u.usr_ip4_spec.ip4src);
542 p += ETH_GSTRING_LEN;
543 num_strings++;
544 sprintf(p, "\tDest IP addr: 0x%x\n",
545 fsc->fs.h_u.usr_ip4_spec.ip4dst);
546 p += ETH_GSTRING_LEN;
547 num_strings++;
548 sprintf(p, "\tDest IP mask: 0x%x\n",
549 fsc->fs.m_u.usr_ip4_spec.ip4dst);
550 p += ETH_GSTRING_LEN;
551 num_strings++;
552 sprintf(p, "\tL4 bytes: 0x%x, mask: 0x%x\n",
553 fsc->fs.h_u.usr_ip4_spec.l4_4_bytes,
554 fsc->fs.m_u.usr_ip4_spec.l4_4_bytes);
555 p += ETH_GSTRING_LEN;
556 num_strings++;
557 sprintf(p, "\tTOS: %d, mask: 0x%x\n",
558 fsc->fs.h_u.usr_ip4_spec.tos,
559 fsc->fs.m_u.usr_ip4_spec.tos);
560 p += ETH_GSTRING_LEN;
561 num_strings++;
562 sprintf(p, "\tIP Version: %d, mask: 0x%x\n",
563 fsc->fs.h_u.usr_ip4_spec.ip_ver,
564 fsc->fs.m_u.usr_ip4_spec.ip_ver);
565 p += ETH_GSTRING_LEN;
566 num_strings++;
567 sprintf(p, "\tProtocol: %d, mask: 0x%x\n",
568 fsc->fs.h_u.usr_ip4_spec.proto,
569 fsc->fs.m_u.usr_ip4_spec.proto);
570 p += ETH_GSTRING_LEN;
571 num_strings++;
572 break;
573 };
574 sprintf(p, "\tVLAN: %d, mask: 0x%x\n",
575 fsc->fs.vlan_tag, fsc->fs.vlan_tag_mask);
576 p += ETH_GSTRING_LEN;
577 num_strings++;
578 sprintf(p, "\tUser-defined: 0x%Lx\n", fsc->fs.data);
579 p += ETH_GSTRING_LEN;
580 num_strings++;
581 sprintf(p, "\tUser-defined mask: 0x%Lx\n", fsc->fs.data_mask);
582 p += ETH_GSTRING_LEN;
583 num_strings++;
584 if (fsc->fs.action == ETHTOOL_RXNTUPLE_ACTION_DROP)
585 sprintf(p, "\tAction: Drop\n");
586 else
587 sprintf(p, "\tAction: Direct to queue %d\n",
588 fsc->fs.action);
589 p += ETH_GSTRING_LEN;
590 num_strings++;
591unknown_filter:
592 i++;
593 }
594copy:
595 /* indicate to userspace how many strings we actually have */
596 gstrings.len = num_strings;
597 ret = -EFAULT;
598 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
599 goto out;
600 useraddr += sizeof(gstrings);
601 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
602 goto out;
603 ret = 0;
604
605out:
606 kfree(data);
607 return ret;
608}
609
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
611{
612 struct ethtool_regs regs;
Stephen Hemminger76fd8592006-09-08 11:16:13 -0700613 const struct ethtool_ops *ops = dev->ethtool_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 void *regbuf;
615 int reglen, ret;
616
617 if (!ops->get_regs || !ops->get_regs_len)
618 return -EOPNOTSUPP;
619
620 if (copy_from_user(&regs, useraddr, sizeof(regs)))
621 return -EFAULT;
622
623 reglen = ops->get_regs_len(dev);
624 if (regs.len > reglen)
625 regs.len = reglen;
626
627 regbuf = kmalloc(reglen, GFP_USER);
628 if (!regbuf)
629 return -ENOMEM;
630
631 ops->get_regs(dev, &regs, regbuf);
632
633 ret = -EFAULT;
634 if (copy_to_user(useraddr, &regs, sizeof(regs)))
635 goto out;
636 useraddr += offsetof(struct ethtool_regs, data);
637 if (copy_to_user(useraddr, regbuf, regs.len))
638 goto out;
639 ret = 0;
640
641 out:
642 kfree(regbuf);
643 return ret;
644}
645
Ben Hutchingsd73d3a82009-10-05 10:59:58 +0000646static int ethtool_reset(struct net_device *dev, char __user *useraddr)
647{
648 struct ethtool_value reset;
649 int ret;
650
651 if (!dev->ethtool_ops->reset)
652 return -EOPNOTSUPP;
653
654 if (copy_from_user(&reset, useraddr, sizeof(reset)))
655 return -EFAULT;
656
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -0800657 /* Clear ethtool n-tuple list */
658 ethtool_ntuple_flush(dev);
659
Ben Hutchingsd73d3a82009-10-05 10:59:58 +0000660 ret = dev->ethtool_ops->reset(dev, &reset.data);
661 if (ret)
662 return ret;
663
664 if (copy_to_user(useraddr, &reset, sizeof(reset)))
665 return -EFAULT;
666 return 0;
667}
668
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
670{
Roland Dreier8e557422010-02-11 12:14:23 -0800671 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672
673 if (!dev->ethtool_ops->get_wol)
674 return -EOPNOTSUPP;
675
676 dev->ethtool_ops->get_wol(dev, &wol);
677
678 if (copy_to_user(useraddr, &wol, sizeof(wol)))
679 return -EFAULT;
680 return 0;
681}
682
683static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
684{
685 struct ethtool_wolinfo wol;
686
687 if (!dev->ethtool_ops->set_wol)
688 return -EOPNOTSUPP;
689
690 if (copy_from_user(&wol, useraddr, sizeof(wol)))
691 return -EFAULT;
692
693 return dev->ethtool_ops->set_wol(dev, &wol);
694}
695
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696static int ethtool_nway_reset(struct net_device *dev)
697{
698 if (!dev->ethtool_ops->nway_reset)
699 return -EOPNOTSUPP;
700
701 return dev->ethtool_ops->nway_reset(dev);
702}
703
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
705{
706 struct ethtool_eeprom eeprom;
Stephen Hemminger76fd8592006-09-08 11:16:13 -0700707 const struct ethtool_ops *ops = dev->ethtool_ops;
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700708 void __user *userbuf = useraddr + sizeof(eeprom);
709 u32 bytes_remaining;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 u8 *data;
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700711 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712
713 if (!ops->get_eeprom || !ops->get_eeprom_len)
714 return -EOPNOTSUPP;
715
716 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
717 return -EFAULT;
718
719 /* Check for wrap and zero */
720 if (eeprom.offset + eeprom.len <= eeprom.offset)
721 return -EINVAL;
722
723 /* Check for exceeding total eeprom len */
724 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
725 return -EINVAL;
726
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700727 data = kmalloc(PAGE_SIZE, GFP_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 if (!data)
729 return -ENOMEM;
730
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700731 bytes_remaining = eeprom.len;
732 while (bytes_remaining > 0) {
733 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700735 ret = ops->get_eeprom(dev, &eeprom, data);
736 if (ret)
737 break;
738 if (copy_to_user(userbuf, data, eeprom.len)) {
739 ret = -EFAULT;
740 break;
741 }
742 userbuf += eeprom.len;
743 eeprom.offset += eeprom.len;
744 bytes_remaining -= eeprom.len;
745 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746
Mandeep Singh Bainesc5835df2008-04-24 20:55:56 -0700747 eeprom.len = userbuf - (useraddr + sizeof(eeprom));
748 eeprom.offset -= eeprom.len;
749 if (copy_to_user(useraddr, &eeprom, sizeof(eeprom)))
750 ret = -EFAULT;
751
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 kfree(data);
753 return ret;
754}
755
756static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
757{
758 struct ethtool_eeprom eeprom;
Stephen Hemminger76fd8592006-09-08 11:16:13 -0700759 const struct ethtool_ops *ops = dev->ethtool_ops;
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700760 void __user *userbuf = useraddr + sizeof(eeprom);
761 u32 bytes_remaining;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 u8 *data;
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700763 int ret = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764
765 if (!ops->set_eeprom || !ops->get_eeprom_len)
766 return -EOPNOTSUPP;
767
768 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
769 return -EFAULT;
770
771 /* Check for wrap and zero */
772 if (eeprom.offset + eeprom.len <= eeprom.offset)
773 return -EINVAL;
774
775 /* Check for exceeding total eeprom len */
776 if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
777 return -EINVAL;
778
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700779 data = kmalloc(PAGE_SIZE, GFP_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 if (!data)
781 return -ENOMEM;
782
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700783 bytes_remaining = eeprom.len;
784 while (bytes_remaining > 0) {
785 eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786
Mandeep Singh Bainesb131dd52008-04-15 19:24:17 -0700787 if (copy_from_user(data, userbuf, eeprom.len)) {
788 ret = -EFAULT;
789 break;
790 }
791 ret = ops->set_eeprom(dev, &eeprom, data);
792 if (ret)
793 break;
794 userbuf += eeprom.len;
795 eeprom.offset += eeprom.len;
796 bytes_remaining -= eeprom.len;
797 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 kfree(data);
800 return ret;
801}
802
Eric Dumazet339c6e92010-02-15 21:51:33 -0800803/*
804 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
805 */
806static noinline int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807{
Roland Dreier8e557422010-02-11 12:14:23 -0800808 struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809
810 if (!dev->ethtool_ops->get_coalesce)
811 return -EOPNOTSUPP;
812
813 dev->ethtool_ops->get_coalesce(dev, &coalesce);
814
815 if (copy_to_user(useraddr, &coalesce, sizeof(coalesce)))
816 return -EFAULT;
817 return 0;
818}
819
Eric Dumazet339c6e92010-02-15 21:51:33 -0800820/*
821 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
822 */
823static noinline int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824{
825 struct ethtool_coalesce coalesce;
826
David S. Millerfa04ae52005-06-06 15:07:19 -0700827 if (!dev->ethtool_ops->set_coalesce)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 return -EOPNOTSUPP;
829
830 if (copy_from_user(&coalesce, useraddr, sizeof(coalesce)))
831 return -EFAULT;
832
833 return dev->ethtool_ops->set_coalesce(dev, &coalesce);
834}
835
836static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr)
837{
Roland Dreier8e557422010-02-11 12:14:23 -0800838 struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839
840 if (!dev->ethtool_ops->get_ringparam)
841 return -EOPNOTSUPP;
842
843 dev->ethtool_ops->get_ringparam(dev, &ringparam);
844
845 if (copy_to_user(useraddr, &ringparam, sizeof(ringparam)))
846 return -EFAULT;
847 return 0;
848}
849
850static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
851{
852 struct ethtool_ringparam ringparam;
853
854 if (!dev->ethtool_ops->set_ringparam)
855 return -EOPNOTSUPP;
856
857 if (copy_from_user(&ringparam, useraddr, sizeof(ringparam)))
858 return -EFAULT;
859
860 return dev->ethtool_ops->set_ringparam(dev, &ringparam);
861}
862
863static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr)
864{
865 struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM };
866
867 if (!dev->ethtool_ops->get_pauseparam)
868 return -EOPNOTSUPP;
869
870 dev->ethtool_ops->get_pauseparam(dev, &pauseparam);
871
872 if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam)))
873 return -EFAULT;
874 return 0;
875}
876
877static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
878{
879 struct ethtool_pauseparam pauseparam;
880
Jeff Garzike1b90c42006-07-17 12:54:40 -0400881 if (!dev->ethtool_ops->set_pauseparam)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 return -EOPNOTSUPP;
883
884 if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
885 return -EFAULT;
886
887 return dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
888}
889
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890static int __ethtool_set_sg(struct net_device *dev, u32 data)
891{
892 int err;
893
894 if (!data && dev->ethtool_ops->set_tso) {
895 err = dev->ethtool_ops->set_tso(dev, 0);
896 if (err)
897 return err;
898 }
899
Ananda Rajue89e9cf2005-10-18 15:46:41 -0700900 if (!data && dev->ethtool_ops->set_ufo) {
901 err = dev->ethtool_ops->set_ufo(dev, 0);
902 if (err)
903 return err;
904 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 return dev->ethtool_ops->set_sg(dev, data);
906}
907
908static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr)
909{
910 struct ethtool_value edata;
911 int err;
912
913 if (!dev->ethtool_ops->set_tx_csum)
914 return -EOPNOTSUPP;
915
916 if (copy_from_user(&edata, useraddr, sizeof(edata)))
917 return -EFAULT;
918
919 if (!edata.data && dev->ethtool_ops->set_sg) {
920 err = __ethtool_set_sg(dev, 0);
921 if (err)
922 return err;
923 }
924
925 return dev->ethtool_ops->set_tx_csum(dev, edata.data);
926}
927
Herbert Xub240a0e2008-12-15 23:44:31 -0800928static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr)
929{
930 struct ethtool_value edata;
931
932 if (!dev->ethtool_ops->set_rx_csum)
933 return -EOPNOTSUPP;
934
935 if (copy_from_user(&edata, useraddr, sizeof(edata)))
936 return -EFAULT;
937
938 if (!edata.data && dev->ethtool_ops->set_sg)
939 dev->features &= ~NETIF_F_GRO;
940
941 return dev->ethtool_ops->set_rx_csum(dev, edata.data);
942}
943
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944static int ethtool_set_sg(struct net_device *dev, char __user *useraddr)
945{
946 struct ethtool_value edata;
947
948 if (!dev->ethtool_ops->set_sg)
949 return -EOPNOTSUPP;
950
951 if (copy_from_user(&edata, useraddr, sizeof(edata)))
952 return -EFAULT;
953
YOSHIFUJI Hideaki4ec93ed2007-02-09 23:24:36 +0900954 if (edata.data &&
Herbert Xu8648b302006-06-17 22:06:05 -0700955 !(dev->features & NETIF_F_ALL_CSUM))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 return -EINVAL;
957
958 return __ethtool_set_sg(dev, edata.data);
959}
960
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961static int ethtool_set_tso(struct net_device *dev, char __user *useraddr)
962{
963 struct ethtool_value edata;
964
965 if (!dev->ethtool_ops->set_tso)
966 return -EOPNOTSUPP;
967
968 if (copy_from_user(&edata, useraddr, sizeof(edata)))
969 return -EFAULT;
970
971 if (edata.data && !(dev->features & NETIF_F_SG))
972 return -EINVAL;
973
974 return dev->ethtool_ops->set_tso(dev, edata.data);
975}
976
Ananda Rajue89e9cf2005-10-18 15:46:41 -0700977static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
978{
979 struct ethtool_value edata;
980
981 if (!dev->ethtool_ops->set_ufo)
982 return -EOPNOTSUPP;
983 if (copy_from_user(&edata, useraddr, sizeof(edata)))
984 return -EFAULT;
985 if (edata.data && !(dev->features & NETIF_F_SG))
986 return -EINVAL;
987 if (edata.data && !(dev->features & NETIF_F_HW_CSUM))
988 return -EINVAL;
989 return dev->ethtool_ops->set_ufo(dev, edata.data);
990}
991
Herbert Xu37c31852006-06-22 03:07:29 -0700992static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
993{
994 struct ethtool_value edata = { ETHTOOL_GGSO };
995
996 edata.data = dev->features & NETIF_F_GSO;
997 if (copy_to_user(useraddr, &edata, sizeof(edata)))
998 return -EFAULT;
999 return 0;
1000}
1001
1002static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
1003{
1004 struct ethtool_value edata;
1005
1006 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1007 return -EFAULT;
1008 if (edata.data)
1009 dev->features |= NETIF_F_GSO;
1010 else
1011 dev->features &= ~NETIF_F_GSO;
1012 return 0;
1013}
1014
Herbert Xub240a0e2008-12-15 23:44:31 -08001015static int ethtool_get_gro(struct net_device *dev, char __user *useraddr)
1016{
1017 struct ethtool_value edata = { ETHTOOL_GGRO };
1018
1019 edata.data = dev->features & NETIF_F_GRO;
1020 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1021 return -EFAULT;
1022 return 0;
1023}
1024
1025static int ethtool_set_gro(struct net_device *dev, char __user *useraddr)
1026{
1027 struct ethtool_value edata;
1028
1029 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1030 return -EFAULT;
1031
1032 if (edata.data) {
1033 if (!dev->ethtool_ops->get_rx_csum ||
1034 !dev->ethtool_ops->get_rx_csum(dev))
1035 return -EINVAL;
1036 dev->features |= NETIF_F_GRO;
1037 } else
1038 dev->features &= ~NETIF_F_GRO;
1039
1040 return 0;
1041}
1042
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
1044{
1045 struct ethtool_test test;
Stephen Hemminger76fd8592006-09-08 11:16:13 -07001046 const struct ethtool_ops *ops = dev->ethtool_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 u64 *data;
Jeff Garzikff03d492007-08-15 16:01:08 -07001048 int ret, test_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049
Ben Hutchingsa9828ec2009-10-01 11:33:03 +00001050 if (!ops->self_test || !ops->get_sset_count)
Jeff Garzikff03d492007-08-15 16:01:08 -07001051 return -EOPNOTSUPP;
1052
Ben Hutchingsa9828ec2009-10-01 11:33:03 +00001053 test_len = ops->get_sset_count(dev, ETH_SS_TEST);
Jeff Garzikff03d492007-08-15 16:01:08 -07001054 if (test_len < 0)
1055 return test_len;
1056 WARN_ON(test_len == 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057
1058 if (copy_from_user(&test, useraddr, sizeof(test)))
1059 return -EFAULT;
1060
Jeff Garzikff03d492007-08-15 16:01:08 -07001061 test.len = test_len;
1062 data = kmalloc(test_len * sizeof(u64), GFP_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 if (!data)
1064 return -ENOMEM;
1065
1066 ops->self_test(dev, &test, data);
1067
1068 ret = -EFAULT;
1069 if (copy_to_user(useraddr, &test, sizeof(test)))
1070 goto out;
1071 useraddr += sizeof(test);
1072 if (copy_to_user(useraddr, data, test.len * sizeof(u64)))
1073 goto out;
1074 ret = 0;
1075
1076 out:
1077 kfree(data);
1078 return ret;
1079}
1080
1081static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
1082{
1083 struct ethtool_gstrings gstrings;
Stephen Hemminger76fd8592006-09-08 11:16:13 -07001084 const struct ethtool_ops *ops = dev->ethtool_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 u8 *data;
1086 int ret;
1087
Ben Hutchingsa9828ec2009-10-01 11:33:03 +00001088 if (!ops->get_strings || !ops->get_sset_count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089 return -EOPNOTSUPP;
1090
1091 if (copy_from_user(&gstrings, useraddr, sizeof(gstrings)))
1092 return -EFAULT;
1093
Ben Hutchingsa9828ec2009-10-01 11:33:03 +00001094 ret = ops->get_sset_count(dev, gstrings.string_set);
1095 if (ret < 0)
1096 return ret;
Jeff Garzikff03d492007-08-15 16:01:08 -07001097
Ben Hutchingsa9828ec2009-10-01 11:33:03 +00001098 gstrings.len = ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099
1100 data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER);
1101 if (!data)
1102 return -ENOMEM;
1103
1104 ops->get_strings(dev, gstrings.string_set, data);
1105
1106 ret = -EFAULT;
1107 if (copy_to_user(useraddr, &gstrings, sizeof(gstrings)))
1108 goto out;
1109 useraddr += sizeof(gstrings);
1110 if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN))
1111 goto out;
1112 ret = 0;
1113
1114 out:
1115 kfree(data);
1116 return ret;
1117}
1118
1119static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
1120{
1121 struct ethtool_value id;
1122
1123 if (!dev->ethtool_ops->phys_id)
1124 return -EOPNOTSUPP;
1125
1126 if (copy_from_user(&id, useraddr, sizeof(id)))
1127 return -EFAULT;
1128
1129 return dev->ethtool_ops->phys_id(dev, id.data);
1130}
1131
1132static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
1133{
1134 struct ethtool_stats stats;
Stephen Hemminger76fd8592006-09-08 11:16:13 -07001135 const struct ethtool_ops *ops = dev->ethtool_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 u64 *data;
Jeff Garzikff03d492007-08-15 16:01:08 -07001137 int ret, n_stats;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138
Ben Hutchingsa9828ec2009-10-01 11:33:03 +00001139 if (!ops->get_ethtool_stats || !ops->get_sset_count)
Jeff Garzikff03d492007-08-15 16:01:08 -07001140 return -EOPNOTSUPP;
1141
Ben Hutchingsa9828ec2009-10-01 11:33:03 +00001142 n_stats = ops->get_sset_count(dev, ETH_SS_STATS);
Jeff Garzikff03d492007-08-15 16:01:08 -07001143 if (n_stats < 0)
1144 return n_stats;
1145 WARN_ON(n_stats == 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146
1147 if (copy_from_user(&stats, useraddr, sizeof(stats)))
1148 return -EFAULT;
1149
Jeff Garzikff03d492007-08-15 16:01:08 -07001150 stats.n_stats = n_stats;
1151 data = kmalloc(n_stats * sizeof(u64), GFP_USER);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 if (!data)
1153 return -ENOMEM;
1154
1155 ops->get_ethtool_stats(dev, &stats, data);
1156
1157 ret = -EFAULT;
1158 if (copy_to_user(useraddr, &stats, sizeof(stats)))
1159 goto out;
1160 useraddr += sizeof(stats);
1161 if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64)))
1162 goto out;
1163 ret = 0;
1164
1165 out:
1166 kfree(data);
1167 return ret;
1168}
1169
viro@ftp.linux.org.uk0bf0519d2005-09-05 03:26:18 +01001170static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
Jon Wetzela6f9a702005-08-20 17:15:54 -07001171{
1172 struct ethtool_perm_addr epaddr;
Jon Wetzela6f9a702005-08-20 17:15:54 -07001173
Matthew Wilcox313674a2007-07-31 14:00:29 -07001174 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
Jon Wetzela6f9a702005-08-20 17:15:54 -07001175 return -EFAULT;
1176
Matthew Wilcox313674a2007-07-31 14:00:29 -07001177 if (epaddr.size < dev->addr_len)
1178 return -ETOOSMALL;
1179 epaddr.size = dev->addr_len;
Jon Wetzela6f9a702005-08-20 17:15:54 -07001180
Jon Wetzela6f9a702005-08-20 17:15:54 -07001181 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
Matthew Wilcox313674a2007-07-31 14:00:29 -07001182 return -EFAULT;
Jon Wetzela6f9a702005-08-20 17:15:54 -07001183 useraddr += sizeof(epaddr);
Matthew Wilcox313674a2007-07-31 14:00:29 -07001184 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
1185 return -EFAULT;
1186 return 0;
Jon Wetzela6f9a702005-08-20 17:15:54 -07001187}
1188
Jeff Garzik13c99b22007-08-15 16:01:56 -07001189static int ethtool_get_value(struct net_device *dev, char __user *useraddr,
1190 u32 cmd, u32 (*actor)(struct net_device *))
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001191{
Roland Dreier8e557422010-02-11 12:14:23 -08001192 struct ethtool_value edata = { .cmd = cmd };
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001193
Jeff Garzik13c99b22007-08-15 16:01:56 -07001194 if (!actor)
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001195 return -EOPNOTSUPP;
1196
Jeff Garzik13c99b22007-08-15 16:01:56 -07001197 edata.data = actor(dev);
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001198
1199 if (copy_to_user(useraddr, &edata, sizeof(edata)))
1200 return -EFAULT;
1201 return 0;
1202}
1203
Jeff Garzik13c99b22007-08-15 16:01:56 -07001204static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr,
1205 void (*actor)(struct net_device *, u32))
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001206{
1207 struct ethtool_value edata;
1208
Jeff Garzik13c99b22007-08-15 16:01:56 -07001209 if (!actor)
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001210 return -EOPNOTSUPP;
1211
1212 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1213 return -EFAULT;
1214
Jeff Garzik13c99b22007-08-15 16:01:56 -07001215 actor(dev, edata.data);
Jeff Garzik339bf022007-08-15 16:01:32 -07001216 return 0;
1217}
1218
Jeff Garzik13c99b22007-08-15 16:01:56 -07001219static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
1220 int (*actor)(struct net_device *, u32))
Jeff Garzik339bf022007-08-15 16:01:32 -07001221{
1222 struct ethtool_value edata;
1223
Jeff Garzik13c99b22007-08-15 16:01:56 -07001224 if (!actor)
Jeff Garzik339bf022007-08-15 16:01:32 -07001225 return -EOPNOTSUPP;
1226
1227 if (copy_from_user(&edata, useraddr, sizeof(edata)))
1228 return -EFAULT;
1229
Jeff Garzik13c99b22007-08-15 16:01:56 -07001230 return actor(dev, edata.data);
Jeff Garzik339bf022007-08-15 16:01:32 -07001231}
1232
Eric Dumazet339c6e92010-02-15 21:51:33 -08001233/*
1234 * noinline attribute so that gcc doesnt use too much stack in dev_ethtool()
1235 */
1236static noinline int ethtool_flash_device(struct net_device *dev, char __user *useraddr)
Ajit Khaparde05c6a8d2009-09-02 17:02:55 +00001237{
1238 struct ethtool_flash efl;
1239
1240 if (copy_from_user(&efl, useraddr, sizeof(efl)))
1241 return -EFAULT;
1242
1243 if (!dev->ethtool_ops->flash_device)
1244 return -EOPNOTSUPP;
1245
1246 return dev->ethtool_ops->flash_device(dev, &efl);
1247}
1248
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249/* The main entry point in this file. Called from net/core/dev.c */
1250
Eric W. Biederman881d9662007-09-17 11:56:21 -07001251int dev_ethtool(struct net *net, struct ifreq *ifr)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252{
Eric W. Biederman881d9662007-09-17 11:56:21 -07001253 struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 void __user *useraddr = ifr->ifr_data;
1255 u32 ethcmd;
1256 int rc;
Stephen Hemminger81e81572005-05-29 14:14:35 -07001257 unsigned long old_features;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 if (!dev || !netif_device_present(dev))
1260 return -ENODEV;
1261
1262 if (!dev->ethtool_ops)
Matthew Wilcox61a44b92007-07-31 14:00:02 -07001263 return -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264
1265 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
1266 return -EFAULT;
1267
Stephen Hemminger75f31232006-09-28 15:13:37 -07001268 /* Allow some commands to be done by anyone */
1269 switch(ethcmd) {
Stephen Hemminger75f31232006-09-28 15:13:37 -07001270 case ETHTOOL_GDRVINFO:
Stephen Hemminger75f31232006-09-28 15:13:37 -07001271 case ETHTOOL_GMSGLVL:
Stephen Hemminger75f31232006-09-28 15:13:37 -07001272 case ETHTOOL_GCOALESCE:
1273 case ETHTOOL_GRINGPARAM:
1274 case ETHTOOL_GPAUSEPARAM:
1275 case ETHTOOL_GRXCSUM:
1276 case ETHTOOL_GTXCSUM:
1277 case ETHTOOL_GSG:
1278 case ETHTOOL_GSTRINGS:
Stephen Hemminger75f31232006-09-28 15:13:37 -07001279 case ETHTOOL_GTSO:
1280 case ETHTOOL_GPERMADDR:
1281 case ETHTOOL_GUFO:
1282 case ETHTOOL_GGSO:
Jeff Garzik339bf022007-08-15 16:01:32 -07001283 case ETHTOOL_GFLAGS:
1284 case ETHTOOL_GPFLAGS:
Santwona Behera0853ad62008-07-02 03:47:41 -07001285 case ETHTOOL_GRXFH:
Santwona Behera59089d82009-02-20 00:58:13 -08001286 case ETHTOOL_GRXRINGS:
1287 case ETHTOOL_GRXCLSRLCNT:
1288 case ETHTOOL_GRXCLSRULE:
1289 case ETHTOOL_GRXCLSRLALL:
Stephen Hemminger75f31232006-09-28 15:13:37 -07001290 break;
1291 default:
1292 if (!capable(CAP_NET_ADMIN))
1293 return -EPERM;
1294 }
1295
Stephen Hemmingere71a4782007-04-10 20:10:33 -07001296 if (dev->ethtool_ops->begin)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 if ((rc = dev->ethtool_ops->begin(dev)) < 0)
1298 return rc;
1299
Stephen Hemmingerd8a33ac2005-05-29 14:13:47 -07001300 old_features = dev->features;
1301
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 switch (ethcmd) {
1303 case ETHTOOL_GSET:
1304 rc = ethtool_get_settings(dev, useraddr);
1305 break;
1306 case ETHTOOL_SSET:
1307 rc = ethtool_set_settings(dev, useraddr);
1308 break;
1309 case ETHTOOL_GDRVINFO:
1310 rc = ethtool_get_drvinfo(dev, useraddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 break;
1312 case ETHTOOL_GREGS:
1313 rc = ethtool_get_regs(dev, useraddr);
1314 break;
1315 case ETHTOOL_GWOL:
1316 rc = ethtool_get_wol(dev, useraddr);
1317 break;
1318 case ETHTOOL_SWOL:
1319 rc = ethtool_set_wol(dev, useraddr);
1320 break;
1321 case ETHTOOL_GMSGLVL:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001322 rc = ethtool_get_value(dev, useraddr, ethcmd,
1323 dev->ethtool_ops->get_msglevel);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324 break;
1325 case ETHTOOL_SMSGLVL:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001326 rc = ethtool_set_value_void(dev, useraddr,
1327 dev->ethtool_ops->set_msglevel);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 break;
1329 case ETHTOOL_NWAY_RST:
1330 rc = ethtool_nway_reset(dev);
1331 break;
1332 case ETHTOOL_GLINK:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001333 rc = ethtool_get_value(dev, useraddr, ethcmd,
1334 dev->ethtool_ops->get_link);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 break;
1336 case ETHTOOL_GEEPROM:
1337 rc = ethtool_get_eeprom(dev, useraddr);
1338 break;
1339 case ETHTOOL_SEEPROM:
1340 rc = ethtool_set_eeprom(dev, useraddr);
1341 break;
1342 case ETHTOOL_GCOALESCE:
1343 rc = ethtool_get_coalesce(dev, useraddr);
1344 break;
1345 case ETHTOOL_SCOALESCE:
1346 rc = ethtool_set_coalesce(dev, useraddr);
1347 break;
1348 case ETHTOOL_GRINGPARAM:
1349 rc = ethtool_get_ringparam(dev, useraddr);
1350 break;
1351 case ETHTOOL_SRINGPARAM:
1352 rc = ethtool_set_ringparam(dev, useraddr);
1353 break;
1354 case ETHTOOL_GPAUSEPARAM:
1355 rc = ethtool_get_pauseparam(dev, useraddr);
1356 break;
1357 case ETHTOOL_SPAUSEPARAM:
1358 rc = ethtool_set_pauseparam(dev, useraddr);
1359 break;
1360 case ETHTOOL_GRXCSUM:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001361 rc = ethtool_get_value(dev, useraddr, ethcmd,
Sridhar Samudrala1896e612009-07-22 13:38:22 +00001362 (dev->ethtool_ops->get_rx_csum ?
1363 dev->ethtool_ops->get_rx_csum :
1364 ethtool_op_get_rx_csum));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 break;
1366 case ETHTOOL_SRXCSUM:
Herbert Xub240a0e2008-12-15 23:44:31 -08001367 rc = ethtool_set_rx_csum(dev, useraddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 break;
1369 case ETHTOOL_GTXCSUM:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001370 rc = ethtool_get_value(dev, useraddr, ethcmd,
Jeff Garzik88d3aaf2007-09-15 14:41:06 -07001371 (dev->ethtool_ops->get_tx_csum ?
1372 dev->ethtool_ops->get_tx_csum :
1373 ethtool_op_get_tx_csum));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 break;
1375 case ETHTOOL_STXCSUM:
1376 rc = ethtool_set_tx_csum(dev, useraddr);
1377 break;
1378 case ETHTOOL_GSG:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001379 rc = ethtool_get_value(dev, useraddr, ethcmd,
Jeff Garzik88d3aaf2007-09-15 14:41:06 -07001380 (dev->ethtool_ops->get_sg ?
1381 dev->ethtool_ops->get_sg :
1382 ethtool_op_get_sg));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 break;
1384 case ETHTOOL_SSG:
1385 rc = ethtool_set_sg(dev, useraddr);
1386 break;
1387 case ETHTOOL_GTSO:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001388 rc = ethtool_get_value(dev, useraddr, ethcmd,
Jeff Garzik88d3aaf2007-09-15 14:41:06 -07001389 (dev->ethtool_ops->get_tso ?
1390 dev->ethtool_ops->get_tso :
1391 ethtool_op_get_tso));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 break;
1393 case ETHTOOL_STSO:
1394 rc = ethtool_set_tso(dev, useraddr);
1395 break;
1396 case ETHTOOL_TEST:
1397 rc = ethtool_self_test(dev, useraddr);
1398 break;
1399 case ETHTOOL_GSTRINGS:
1400 rc = ethtool_get_strings(dev, useraddr);
1401 break;
1402 case ETHTOOL_PHYS_ID:
1403 rc = ethtool_phys_id(dev, useraddr);
1404 break;
1405 case ETHTOOL_GSTATS:
1406 rc = ethtool_get_stats(dev, useraddr);
1407 break;
Jon Wetzela6f9a702005-08-20 17:15:54 -07001408 case ETHTOOL_GPERMADDR:
1409 rc = ethtool_get_perm_addr(dev, useraddr);
1410 break;
Ananda Rajue89e9cf2005-10-18 15:46:41 -07001411 case ETHTOOL_GUFO:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001412 rc = ethtool_get_value(dev, useraddr, ethcmd,
Jeff Garzik88d3aaf2007-09-15 14:41:06 -07001413 (dev->ethtool_ops->get_ufo ?
1414 dev->ethtool_ops->get_ufo :
1415 ethtool_op_get_ufo));
Ananda Rajue89e9cf2005-10-18 15:46:41 -07001416 break;
1417 case ETHTOOL_SUFO:
1418 rc = ethtool_set_ufo(dev, useraddr);
1419 break;
Herbert Xu37c31852006-06-22 03:07:29 -07001420 case ETHTOOL_GGSO:
1421 rc = ethtool_get_gso(dev, useraddr);
1422 break;
1423 case ETHTOOL_SGSO:
1424 rc = ethtool_set_gso(dev, useraddr);
1425 break;
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001426 case ETHTOOL_GFLAGS:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001427 rc = ethtool_get_value(dev, useraddr, ethcmd,
Sridhar Samudrala1896e612009-07-22 13:38:22 +00001428 (dev->ethtool_ops->get_flags ?
1429 dev->ethtool_ops->get_flags :
1430 ethtool_op_get_flags));
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001431 break;
1432 case ETHTOOL_SFLAGS:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001433 rc = ethtool_set_value(dev, useraddr,
1434 dev->ethtool_ops->set_flags);
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001435 break;
Jeff Garzik339bf022007-08-15 16:01:32 -07001436 case ETHTOOL_GPFLAGS:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001437 rc = ethtool_get_value(dev, useraddr, ethcmd,
1438 dev->ethtool_ops->get_priv_flags);
Jeff Garzik339bf022007-08-15 16:01:32 -07001439 break;
1440 case ETHTOOL_SPFLAGS:
Jeff Garzik13c99b22007-08-15 16:01:56 -07001441 rc = ethtool_set_value(dev, useraddr,
1442 dev->ethtool_ops->set_priv_flags);
Jeff Garzik339bf022007-08-15 16:01:32 -07001443 break;
Santwona Behera0853ad62008-07-02 03:47:41 -07001444 case ETHTOOL_GRXFH:
Santwona Behera59089d82009-02-20 00:58:13 -08001445 case ETHTOOL_GRXRINGS:
1446 case ETHTOOL_GRXCLSRLCNT:
1447 case ETHTOOL_GRXCLSRULE:
1448 case ETHTOOL_GRXCLSRLALL:
1449 rc = ethtool_get_rxnfc(dev, useraddr);
Santwona Behera0853ad62008-07-02 03:47:41 -07001450 break;
1451 case ETHTOOL_SRXFH:
Santwona Behera59089d82009-02-20 00:58:13 -08001452 case ETHTOOL_SRXCLSRLDEL:
1453 case ETHTOOL_SRXCLSRLINS:
1454 rc = ethtool_set_rxnfc(dev, useraddr);
Santwona Behera0853ad62008-07-02 03:47:41 -07001455 break;
Herbert Xub240a0e2008-12-15 23:44:31 -08001456 case ETHTOOL_GGRO:
1457 rc = ethtool_get_gro(dev, useraddr);
1458 break;
1459 case ETHTOOL_SGRO:
1460 rc = ethtool_set_gro(dev, useraddr);
1461 break;
Ajit Khaparde05c6a8d2009-09-02 17:02:55 +00001462 case ETHTOOL_FLASHDEV:
1463 rc = ethtool_flash_device(dev, useraddr);
1464 break;
Ben Hutchingsd73d3a82009-10-05 10:59:58 +00001465 case ETHTOOL_RESET:
1466 rc = ethtool_reset(dev, useraddr);
1467 break;
Peter P Waskiewicz Jr15682bc2010-02-10 20:03:05 -08001468 case ETHTOOL_SRXNTUPLE:
1469 rc = ethtool_set_rx_ntuple(dev, useraddr);
1470 break;
1471 case ETHTOOL_GRXNTUPLE:
1472 rc = ethtool_get_rx_ntuple(dev, useraddr);
1473 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 default:
Matthew Wilcox61a44b92007-07-31 14:00:02 -07001475 rc = -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 }
YOSHIFUJI Hideaki4ec93ed2007-02-09 23:24:36 +09001477
Stephen Hemmingere71a4782007-04-10 20:10:33 -07001478 if (dev->ethtool_ops->complete)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 dev->ethtool_ops->complete(dev);
Stephen Hemmingerd8a33ac2005-05-29 14:13:47 -07001480
1481 if (old_features != dev->features)
1482 netdev_features_change(dev);
1483
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485}
1486
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487EXPORT_SYMBOL(ethtool_op_get_link);
1488EXPORT_SYMBOL(ethtool_op_get_sg);
1489EXPORT_SYMBOL(ethtool_op_get_tso);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490EXPORT_SYMBOL(ethtool_op_set_sg);
1491EXPORT_SYMBOL(ethtool_op_set_tso);
1492EXPORT_SYMBOL(ethtool_op_set_tx_csum);
Jon Mason69f6a0f2005-05-29 20:27:24 -07001493EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum);
Michael Chan6460d942007-07-14 19:07:52 -07001494EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum);
Ananda Rajue89e9cf2005-10-18 15:46:41 -07001495EXPORT_SYMBOL(ethtool_op_set_ufo);
1496EXPORT_SYMBOL(ethtool_op_get_ufo);
Jeff Garzik3ae7c0b2007-08-15 16:00:51 -07001497EXPORT_SYMBOL(ethtool_op_set_flags);
1498EXPORT_SYMBOL(ethtool_op_get_flags);