]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
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 | |
61a44b9c | 6 | * the information ethtool needs. |
1da177e4 | 7 | * |
61a44b9c MW |
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. | |
1da177e4 LT |
12 | */ |
13 | ||
14 | #include <linux/module.h> | |
15 | #include <linux/types.h> | |
4fc268d2 | 16 | #include <linux/capability.h> |
1da177e4 LT |
17 | #include <linux/errno.h> |
18 | #include <linux/ethtool.h> | |
19 | #include <linux/netdevice.h> | |
d17792eb | 20 | #include <linux/bitops.h> |
97f8aefb | 21 | #include <linux/uaccess.h> |
5a0e3ad6 | 22 | #include <linux/slab.h> |
1da177e4 | 23 | |
4ec93edb | 24 | /* |
1da177e4 LT |
25 | * Some useful ethtool_ops methods that're device independent. |
26 | * If we find that all drivers want to do the same thing here, | |
27 | * we can turn these into dev_() function calls. | |
28 | */ | |
29 | ||
30 | u32 ethtool_op_get_link(struct net_device *dev) | |
31 | { | |
32 | return netif_carrier_ok(dev) ? 1 : 0; | |
33 | } | |
97f8aefb | 34 | EXPORT_SYMBOL(ethtool_op_get_link); |
1da177e4 | 35 | |
1896e61f SS |
36 | u32 ethtool_op_get_rx_csum(struct net_device *dev) |
37 | { | |
38 | return (dev->features & NETIF_F_ALL_CSUM) != 0; | |
39 | } | |
8a729fce | 40 | EXPORT_SYMBOL(ethtool_op_get_rx_csum); |
1896e61f | 41 | |
1da177e4 LT |
42 | u32 ethtool_op_get_tx_csum(struct net_device *dev) |
43 | { | |
8648b305 | 44 | return (dev->features & NETIF_F_ALL_CSUM) != 0; |
1da177e4 | 45 | } |
8a729fce | 46 | EXPORT_SYMBOL(ethtool_op_get_tx_csum); |
1da177e4 LT |
47 | |
48 | int ethtool_op_set_tx_csum(struct net_device *dev, u32 data) | |
49 | { | |
50 | if (data) | |
51 | dev->features |= NETIF_F_IP_CSUM; | |
52 | else | |
53 | dev->features &= ~NETIF_F_IP_CSUM; | |
54 | ||
55 | return 0; | |
56 | } | |
57 | ||
69f6a0fa JM |
58 | int ethtool_op_set_tx_hw_csum(struct net_device *dev, u32 data) |
59 | { | |
60 | if (data) | |
61 | dev->features |= NETIF_F_HW_CSUM; | |
62 | else | |
63 | dev->features &= ~NETIF_F_HW_CSUM; | |
64 | ||
65 | return 0; | |
66 | } | |
97f8aefb | 67 | EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum); |
6460d948 MC |
68 | |
69 | int ethtool_op_set_tx_ipv6_csum(struct net_device *dev, u32 data) | |
70 | { | |
71 | if (data) | |
72 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | |
73 | else | |
74 | dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); | |
75 | ||
76 | return 0; | |
77 | } | |
97f8aefb | 78 | EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum); |
6460d948 | 79 | |
1da177e4 LT |
80 | u32 ethtool_op_get_sg(struct net_device *dev) |
81 | { | |
82 | return (dev->features & NETIF_F_SG) != 0; | |
83 | } | |
97f8aefb | 84 | EXPORT_SYMBOL(ethtool_op_get_sg); |
1da177e4 LT |
85 | |
86 | int ethtool_op_set_sg(struct net_device *dev, u32 data) | |
87 | { | |
88 | if (data) | |
89 | dev->features |= NETIF_F_SG; | |
90 | else | |
91 | dev->features &= ~NETIF_F_SG; | |
92 | ||
93 | return 0; | |
94 | } | |
97f8aefb | 95 | EXPORT_SYMBOL(ethtool_op_set_sg); |
1da177e4 LT |
96 | |
97 | u32 ethtool_op_get_tso(struct net_device *dev) | |
98 | { | |
99 | return (dev->features & NETIF_F_TSO) != 0; | |
100 | } | |
97f8aefb | 101 | EXPORT_SYMBOL(ethtool_op_get_tso); |
1da177e4 LT |
102 | |
103 | int ethtool_op_set_tso(struct net_device *dev, u32 data) | |
104 | { | |
105 | if (data) | |
106 | dev->features |= NETIF_F_TSO; | |
107 | else | |
108 | dev->features &= ~NETIF_F_TSO; | |
109 | ||
110 | return 0; | |
111 | } | |
97f8aefb | 112 | EXPORT_SYMBOL(ethtool_op_set_tso); |
1da177e4 | 113 | |
e89e9cf5 AR |
114 | u32 ethtool_op_get_ufo(struct net_device *dev) |
115 | { | |
116 | return (dev->features & NETIF_F_UFO) != 0; | |
117 | } | |
97f8aefb | 118 | EXPORT_SYMBOL(ethtool_op_get_ufo); |
e89e9cf5 AR |
119 | |
120 | int ethtool_op_set_ufo(struct net_device *dev, u32 data) | |
121 | { | |
122 | if (data) | |
123 | dev->features |= NETIF_F_UFO; | |
124 | else | |
125 | dev->features &= ~NETIF_F_UFO; | |
126 | return 0; | |
127 | } | |
97f8aefb | 128 | EXPORT_SYMBOL(ethtool_op_set_ufo); |
e89e9cf5 | 129 | |
3ae7c0b2 JG |
130 | /* the following list of flags are the same as their associated |
131 | * NETIF_F_xxx values in include/linux/netdevice.h | |
132 | */ | |
133 | static const u32 flags_dup_features = | |
b00fabb4 | 134 | (ETH_FLAG_LRO | ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH); |
3ae7c0b2 JG |
135 | |
136 | u32 ethtool_op_get_flags(struct net_device *dev) | |
137 | { | |
138 | /* in the future, this function will probably contain additional | |
139 | * handling for flags which are not so easily handled | |
140 | * by a simple masking operation | |
141 | */ | |
142 | ||
143 | return dev->features & flags_dup_features; | |
144 | } | |
97f8aefb | 145 | EXPORT_SYMBOL(ethtool_op_get_flags); |
3ae7c0b2 JG |
146 | |
147 | int ethtool_op_set_flags(struct net_device *dev, u32 data) | |
148 | { | |
0d643e1f | 149 | const struct ethtool_ops *ops = dev->ethtool_ops; |
9675478b | 150 | unsigned long features = dev->features; |
0d643e1f | 151 | |
3ae7c0b2 | 152 | if (data & ETH_FLAG_LRO) |
9675478b | 153 | features |= NETIF_F_LRO; |
3ae7c0b2 | 154 | else |
9675478b | 155 | features &= ~NETIF_F_LRO; |
3ae7c0b2 | 156 | |
0d643e1f PW |
157 | if (data & ETH_FLAG_NTUPLE) { |
158 | if (!ops->set_rx_ntuple) | |
159 | return -EOPNOTSUPP; | |
9675478b | 160 | features |= NETIF_F_NTUPLE; |
0d643e1f PW |
161 | } else { |
162 | /* safe to clear regardless */ | |
9675478b | 163 | features &= ~NETIF_F_NTUPLE; |
0d643e1f | 164 | } |
15682bc4 | 165 | |
b00fabb4 | 166 | if (data & ETH_FLAG_RXHASH) |
167 | features |= NETIF_F_RXHASH; | |
168 | else | |
169 | features &= ~NETIF_F_RXHASH; | |
170 | ||
9675478b | 171 | dev->features = features; |
3ae7c0b2 JG |
172 | return 0; |
173 | } | |
97f8aefb | 174 | EXPORT_SYMBOL(ethtool_op_set_flags); |
3ae7c0b2 | 175 | |
15682bc4 PWJ |
176 | void ethtool_ntuple_flush(struct net_device *dev) |
177 | { | |
178 | struct ethtool_rx_ntuple_flow_spec_container *fsc, *f; | |
179 | ||
180 | list_for_each_entry_safe(fsc, f, &dev->ethtool_ntuple_list.list, list) { | |
181 | list_del(&fsc->list); | |
182 | kfree(fsc); | |
183 | } | |
184 | dev->ethtool_ntuple_list.count = 0; | |
185 | } | |
186 | EXPORT_SYMBOL(ethtool_ntuple_flush); | |
187 | ||
1da177e4 LT |
188 | /* Handlers for each ethtool command */ |
189 | ||
190 | static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) | |
191 | { | |
8e557421 | 192 | struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET }; |
1da177e4 LT |
193 | int err; |
194 | ||
195 | if (!dev->ethtool_ops->get_settings) | |
196 | return -EOPNOTSUPP; | |
197 | ||
198 | err = dev->ethtool_ops->get_settings(dev, &cmd); | |
199 | if (err < 0) | |
200 | return err; | |
201 | ||
202 | if (copy_to_user(useraddr, &cmd, sizeof(cmd))) | |
203 | return -EFAULT; | |
204 | return 0; | |
205 | } | |
206 | ||
207 | static int ethtool_set_settings(struct net_device *dev, void __user *useraddr) | |
208 | { | |
209 | struct ethtool_cmd cmd; | |
210 | ||
211 | if (!dev->ethtool_ops->set_settings) | |
212 | return -EOPNOTSUPP; | |
213 | ||
214 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) | |
215 | return -EFAULT; | |
216 | ||
217 | return dev->ethtool_ops->set_settings(dev, &cmd); | |
218 | } | |
219 | ||
97f8aefb | 220 | static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, |
221 | void __user *useraddr) | |
1da177e4 LT |
222 | { |
223 | struct ethtool_drvinfo info; | |
76fd8593 | 224 | const struct ethtool_ops *ops = dev->ethtool_ops; |
1da177e4 LT |
225 | |
226 | if (!ops->get_drvinfo) | |
227 | return -EOPNOTSUPP; | |
228 | ||
229 | memset(&info, 0, sizeof(info)); | |
230 | info.cmd = ETHTOOL_GDRVINFO; | |
231 | ops->get_drvinfo(dev, &info); | |
232 | ||
723b2f57 JG |
233 | /* |
234 | * this method of obtaining string set info is deprecated; | |
d17792eb | 235 | * Use ETHTOOL_GSSET_INFO instead. |
723b2f57 | 236 | */ |
ff03d49f JG |
237 | if (ops->get_sset_count) { |
238 | int rc; | |
239 | ||
240 | rc = ops->get_sset_count(dev, ETH_SS_TEST); | |
241 | if (rc >= 0) | |
242 | info.testinfo_len = rc; | |
243 | rc = ops->get_sset_count(dev, ETH_SS_STATS); | |
244 | if (rc >= 0) | |
245 | info.n_stats = rc; | |
339bf024 JG |
246 | rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS); |
247 | if (rc >= 0) | |
248 | info.n_priv_flags = rc; | |
ff03d49f | 249 | } |
1da177e4 LT |
250 | if (ops->get_regs_len) |
251 | info.regdump_len = ops->get_regs_len(dev); | |
252 | if (ops->get_eeprom_len) | |
253 | info.eedump_len = ops->get_eeprom_len(dev); | |
254 | ||
255 | if (copy_to_user(useraddr, &info, sizeof(info))) | |
256 | return -EFAULT; | |
257 | return 0; | |
258 | } | |
259 | ||
f5c445ed | 260 | static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev, |
97f8aefb | 261 | void __user *useraddr) |
723b2f57 JG |
262 | { |
263 | struct ethtool_sset_info info; | |
264 | const struct ethtool_ops *ops = dev->ethtool_ops; | |
265 | u64 sset_mask; | |
266 | int i, idx = 0, n_bits = 0, ret, rc; | |
267 | u32 *info_buf = NULL; | |
268 | ||
269 | if (!ops->get_sset_count) | |
270 | return -EOPNOTSUPP; | |
271 | ||
272 | if (copy_from_user(&info, useraddr, sizeof(info))) | |
273 | return -EFAULT; | |
274 | ||
275 | /* store copy of mask, because we zero struct later on */ | |
276 | sset_mask = info.sset_mask; | |
277 | if (!sset_mask) | |
278 | return 0; | |
279 | ||
280 | /* calculate size of return buffer */ | |
d17792eb | 281 | n_bits = hweight64(sset_mask); |
723b2f57 JG |
282 | |
283 | memset(&info, 0, sizeof(info)); | |
284 | info.cmd = ETHTOOL_GSSET_INFO; | |
285 | ||
286 | info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER); | |
287 | if (!info_buf) | |
288 | return -ENOMEM; | |
289 | ||
290 | /* | |
291 | * fill return buffer based on input bitmask and successful | |
292 | * get_sset_count return | |
293 | */ | |
294 | for (i = 0; i < 64; i++) { | |
295 | if (!(sset_mask & (1ULL << i))) | |
296 | continue; | |
297 | ||
298 | rc = ops->get_sset_count(dev, i); | |
299 | if (rc >= 0) { | |
300 | info.sset_mask |= (1ULL << i); | |
301 | info_buf[idx++] = rc; | |
302 | } | |
303 | } | |
304 | ||
305 | ret = -EFAULT; | |
306 | if (copy_to_user(useraddr, &info, sizeof(info))) | |
307 | goto out; | |
308 | ||
309 | useraddr += offsetof(struct ethtool_sset_info, data); | |
310 | if (copy_to_user(useraddr, info_buf, idx * sizeof(u32))) | |
311 | goto out; | |
312 | ||
313 | ret = 0; | |
314 | ||
315 | out: | |
316 | kfree(info_buf); | |
317 | return ret; | |
318 | } | |
319 | ||
97f8aefb | 320 | static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev, |
321 | void __user *useraddr) | |
0853ad66 SB |
322 | { |
323 | struct ethtool_rxnfc cmd; | |
324 | ||
59089d8d | 325 | if (!dev->ethtool_ops->set_rxnfc) |
0853ad66 SB |
326 | return -EOPNOTSUPP; |
327 | ||
328 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) | |
329 | return -EFAULT; | |
330 | ||
59089d8d | 331 | return dev->ethtool_ops->set_rxnfc(dev, &cmd); |
0853ad66 SB |
332 | } |
333 | ||
97f8aefb | 334 | static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, |
335 | void __user *useraddr) | |
0853ad66 SB |
336 | { |
337 | struct ethtool_rxnfc info; | |
59089d8d SB |
338 | const struct ethtool_ops *ops = dev->ethtool_ops; |
339 | int ret; | |
340 | void *rule_buf = NULL; | |
0853ad66 | 341 | |
59089d8d | 342 | if (!ops->get_rxnfc) |
0853ad66 SB |
343 | return -EOPNOTSUPP; |
344 | ||
345 | if (copy_from_user(&info, useraddr, sizeof(info))) | |
346 | return -EFAULT; | |
347 | ||
59089d8d SB |
348 | if (info.cmd == ETHTOOL_GRXCLSRLALL) { |
349 | if (info.rule_cnt > 0) { | |
350 | rule_buf = kmalloc(info.rule_cnt * sizeof(u32), | |
351 | GFP_USER); | |
352 | if (!rule_buf) | |
353 | return -ENOMEM; | |
354 | } | |
355 | } | |
0853ad66 | 356 | |
59089d8d SB |
357 | ret = ops->get_rxnfc(dev, &info, rule_buf); |
358 | if (ret < 0) | |
359 | goto err_out; | |
360 | ||
361 | ret = -EFAULT; | |
0853ad66 | 362 | if (copy_to_user(useraddr, &info, sizeof(info))) |
59089d8d SB |
363 | goto err_out; |
364 | ||
365 | if (rule_buf) { | |
366 | useraddr += offsetof(struct ethtool_rxnfc, rule_locs); | |
367 | if (copy_to_user(useraddr, rule_buf, | |
368 | info.rule_cnt * sizeof(u32))) | |
369 | goto err_out; | |
370 | } | |
371 | ret = 0; | |
372 | ||
373 | err_out: | |
c9caceca | 374 | kfree(rule_buf); |
59089d8d SB |
375 | |
376 | return ret; | |
0853ad66 SB |
377 | } |
378 | ||
e8589118 | 379 | static void __rx_ntuple_filter_add(struct ethtool_rx_ntuple_list *list, |
97f8aefb | 380 | struct ethtool_rx_ntuple_flow_spec *spec, |
381 | struct ethtool_rx_ntuple_flow_spec_container *fsc) | |
15682bc4 | 382 | { |
15682bc4 PWJ |
383 | |
384 | /* don't add filters forever */ | |
e8589118 PW |
385 | if (list->count >= ETHTOOL_MAX_NTUPLE_LIST_ENTRY) { |
386 | /* free the container */ | |
387 | kfree(fsc); | |
388 | return; | |
389 | } | |
15682bc4 PWJ |
390 | |
391 | /* Copy the whole filter over */ | |
392 | fsc->fs.flow_type = spec->flow_type; | |
393 | memcpy(&fsc->fs.h_u, &spec->h_u, sizeof(spec->h_u)); | |
394 | memcpy(&fsc->fs.m_u, &spec->m_u, sizeof(spec->m_u)); | |
395 | ||
396 | fsc->fs.vlan_tag = spec->vlan_tag; | |
397 | fsc->fs.vlan_tag_mask = spec->vlan_tag_mask; | |
398 | fsc->fs.data = spec->data; | |
399 | fsc->fs.data_mask = spec->data_mask; | |
400 | fsc->fs.action = spec->action; | |
401 | ||
402 | /* add to the list */ | |
403 | list_add_tail_rcu(&fsc->list, &list->list); | |
404 | list->count++; | |
15682bc4 PWJ |
405 | } |
406 | ||
97f8aefb | 407 | static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev, |
408 | void __user *useraddr) | |
15682bc4 PWJ |
409 | { |
410 | struct ethtool_rx_ntuple cmd; | |
411 | const struct ethtool_ops *ops = dev->ethtool_ops; | |
e8589118 | 412 | struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL; |
15682bc4 PWJ |
413 | int ret; |
414 | ||
15682bc4 PWJ |
415 | if (!(dev->features & NETIF_F_NTUPLE)) |
416 | return -EINVAL; | |
417 | ||
418 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) | |
419 | return -EFAULT; | |
420 | ||
15682bc4 PWJ |
421 | /* |
422 | * Cache filter in dev struct for GET operation only if | |
423 | * the underlying driver doesn't have its own GET operation, and | |
e8589118 PW |
424 | * only if the filter was added successfully. First make sure we |
425 | * can allocate the filter, then continue if successful. | |
15682bc4 | 426 | */ |
e8589118 PW |
427 | if (!ops->get_rx_ntuple) { |
428 | fsc = kmalloc(sizeof(*fsc), GFP_ATOMIC); | |
429 | if (!fsc) | |
15682bc4 | 430 | return -ENOMEM; |
e8589118 PW |
431 | } |
432 | ||
433 | ret = ops->set_rx_ntuple(dev, &cmd); | |
434 | if (ret) { | |
435 | kfree(fsc); | |
436 | return ret; | |
437 | } | |
438 | ||
439 | if (!ops->get_rx_ntuple) | |
440 | __rx_ntuple_filter_add(&dev->ethtool_ntuple_list, &cmd.fs, fsc); | |
15682bc4 PWJ |
441 | |
442 | return ret; | |
443 | } | |
444 | ||
445 | static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr) | |
446 | { | |
447 | struct ethtool_gstrings gstrings; | |
448 | const struct ethtool_ops *ops = dev->ethtool_ops; | |
449 | struct ethtool_rx_ntuple_flow_spec_container *fsc; | |
450 | u8 *data; | |
451 | char *p; | |
452 | int ret, i, num_strings = 0; | |
453 | ||
454 | if (!ops->get_sset_count) | |
455 | return -EOPNOTSUPP; | |
456 | ||
457 | if (copy_from_user(&gstrings, useraddr, sizeof(gstrings))) | |
458 | return -EFAULT; | |
459 | ||
460 | ret = ops->get_sset_count(dev, gstrings.string_set); | |
461 | if (ret < 0) | |
462 | return ret; | |
463 | ||
464 | gstrings.len = ret; | |
465 | ||
466 | data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER); | |
467 | if (!data) | |
468 | return -ENOMEM; | |
469 | ||
470 | if (ops->get_rx_ntuple) { | |
471 | /* driver-specific filter grab */ | |
472 | ret = ops->get_rx_ntuple(dev, gstrings.string_set, data); | |
473 | goto copy; | |
474 | } | |
475 | ||
476 | /* default ethtool filter grab */ | |
477 | i = 0; | |
478 | p = (char *)data; | |
479 | list_for_each_entry(fsc, &dev->ethtool_ntuple_list.list, list) { | |
480 | sprintf(p, "Filter %d:\n", i); | |
481 | p += ETH_GSTRING_LEN; | |
482 | num_strings++; | |
483 | ||
484 | switch (fsc->fs.flow_type) { | |
485 | case TCP_V4_FLOW: | |
486 | sprintf(p, "\tFlow Type: TCP\n"); | |
487 | p += ETH_GSTRING_LEN; | |
488 | num_strings++; | |
489 | break; | |
490 | case UDP_V4_FLOW: | |
491 | sprintf(p, "\tFlow Type: UDP\n"); | |
492 | p += ETH_GSTRING_LEN; | |
493 | num_strings++; | |
494 | break; | |
495 | case SCTP_V4_FLOW: | |
496 | sprintf(p, "\tFlow Type: SCTP\n"); | |
497 | p += ETH_GSTRING_LEN; | |
498 | num_strings++; | |
499 | break; | |
500 | case AH_ESP_V4_FLOW: | |
501 | sprintf(p, "\tFlow Type: AH ESP\n"); | |
502 | p += ETH_GSTRING_LEN; | |
503 | num_strings++; | |
504 | break; | |
505 | case ESP_V4_FLOW: | |
506 | sprintf(p, "\tFlow Type: ESP\n"); | |
507 | p += ETH_GSTRING_LEN; | |
508 | num_strings++; | |
509 | break; | |
510 | case IP_USER_FLOW: | |
511 | sprintf(p, "\tFlow Type: Raw IP\n"); | |
512 | p += ETH_GSTRING_LEN; | |
513 | num_strings++; | |
514 | break; | |
515 | case IPV4_FLOW: | |
516 | sprintf(p, "\tFlow Type: IPv4\n"); | |
517 | p += ETH_GSTRING_LEN; | |
518 | num_strings++; | |
519 | break; | |
520 | default: | |
521 | sprintf(p, "\tFlow Type: Unknown\n"); | |
522 | p += ETH_GSTRING_LEN; | |
523 | num_strings++; | |
524 | goto unknown_filter; | |
ccbd6a5a | 525 | } |
15682bc4 PWJ |
526 | |
527 | /* now the rest of the filters */ | |
528 | switch (fsc->fs.flow_type) { | |
529 | case TCP_V4_FLOW: | |
530 | case UDP_V4_FLOW: | |
531 | case SCTP_V4_FLOW: | |
532 | sprintf(p, "\tSrc IP addr: 0x%x\n", | |
97f8aefb | 533 | fsc->fs.h_u.tcp_ip4_spec.ip4src); |
15682bc4 PWJ |
534 | p += ETH_GSTRING_LEN; |
535 | num_strings++; | |
536 | sprintf(p, "\tSrc IP mask: 0x%x\n", | |
97f8aefb | 537 | fsc->fs.m_u.tcp_ip4_spec.ip4src); |
15682bc4 PWJ |
538 | p += ETH_GSTRING_LEN; |
539 | num_strings++; | |
540 | sprintf(p, "\tDest IP addr: 0x%x\n", | |
97f8aefb | 541 | fsc->fs.h_u.tcp_ip4_spec.ip4dst); |
15682bc4 PWJ |
542 | p += ETH_GSTRING_LEN; |
543 | num_strings++; | |
544 | sprintf(p, "\tDest IP mask: 0x%x\n", | |
97f8aefb | 545 | fsc->fs.m_u.tcp_ip4_spec.ip4dst); |
15682bc4 PWJ |
546 | p += ETH_GSTRING_LEN; |
547 | num_strings++; | |
548 | sprintf(p, "\tSrc Port: %d, mask: 0x%x\n", | |
97f8aefb | 549 | fsc->fs.h_u.tcp_ip4_spec.psrc, |
550 | fsc->fs.m_u.tcp_ip4_spec.psrc); | |
15682bc4 PWJ |
551 | p += ETH_GSTRING_LEN; |
552 | num_strings++; | |
553 | sprintf(p, "\tDest Port: %d, mask: 0x%x\n", | |
97f8aefb | 554 | fsc->fs.h_u.tcp_ip4_spec.pdst, |
555 | fsc->fs.m_u.tcp_ip4_spec.pdst); | |
15682bc4 PWJ |
556 | p += ETH_GSTRING_LEN; |
557 | num_strings++; | |
558 | sprintf(p, "\tTOS: %d, mask: 0x%x\n", | |
97f8aefb | 559 | fsc->fs.h_u.tcp_ip4_spec.tos, |
560 | fsc->fs.m_u.tcp_ip4_spec.tos); | |
15682bc4 PWJ |
561 | p += ETH_GSTRING_LEN; |
562 | num_strings++; | |
563 | break; | |
564 | case AH_ESP_V4_FLOW: | |
565 | case ESP_V4_FLOW: | |
566 | sprintf(p, "\tSrc IP addr: 0x%x\n", | |
97f8aefb | 567 | fsc->fs.h_u.ah_ip4_spec.ip4src); |
15682bc4 PWJ |
568 | p += ETH_GSTRING_LEN; |
569 | num_strings++; | |
570 | sprintf(p, "\tSrc IP mask: 0x%x\n", | |
97f8aefb | 571 | fsc->fs.m_u.ah_ip4_spec.ip4src); |
15682bc4 PWJ |
572 | p += ETH_GSTRING_LEN; |
573 | num_strings++; | |
574 | sprintf(p, "\tDest IP addr: 0x%x\n", | |
97f8aefb | 575 | fsc->fs.h_u.ah_ip4_spec.ip4dst); |
15682bc4 PWJ |
576 | p += ETH_GSTRING_LEN; |
577 | num_strings++; | |
578 | sprintf(p, "\tDest IP mask: 0x%x\n", | |
97f8aefb | 579 | fsc->fs.m_u.ah_ip4_spec.ip4dst); |
15682bc4 PWJ |
580 | p += ETH_GSTRING_LEN; |
581 | num_strings++; | |
582 | sprintf(p, "\tSPI: %d, mask: 0x%x\n", | |
97f8aefb | 583 | fsc->fs.h_u.ah_ip4_spec.spi, |
584 | fsc->fs.m_u.ah_ip4_spec.spi); | |
15682bc4 PWJ |
585 | p += ETH_GSTRING_LEN; |
586 | num_strings++; | |
587 | sprintf(p, "\tTOS: %d, mask: 0x%x\n", | |
97f8aefb | 588 | fsc->fs.h_u.ah_ip4_spec.tos, |
589 | fsc->fs.m_u.ah_ip4_spec.tos); | |
15682bc4 PWJ |
590 | p += ETH_GSTRING_LEN; |
591 | num_strings++; | |
592 | break; | |
593 | case IP_USER_FLOW: | |
594 | sprintf(p, "\tSrc IP addr: 0x%x\n", | |
97f8aefb | 595 | fsc->fs.h_u.raw_ip4_spec.ip4src); |
15682bc4 PWJ |
596 | p += ETH_GSTRING_LEN; |
597 | num_strings++; | |
598 | sprintf(p, "\tSrc IP mask: 0x%x\n", | |
97f8aefb | 599 | fsc->fs.m_u.raw_ip4_spec.ip4src); |
15682bc4 PWJ |
600 | p += ETH_GSTRING_LEN; |
601 | num_strings++; | |
602 | sprintf(p, "\tDest IP addr: 0x%x\n", | |
97f8aefb | 603 | fsc->fs.h_u.raw_ip4_spec.ip4dst); |
15682bc4 PWJ |
604 | p += ETH_GSTRING_LEN; |
605 | num_strings++; | |
606 | sprintf(p, "\tDest IP mask: 0x%x\n", | |
97f8aefb | 607 | fsc->fs.m_u.raw_ip4_spec.ip4dst); |
15682bc4 PWJ |
608 | p += ETH_GSTRING_LEN; |
609 | num_strings++; | |
610 | break; | |
611 | case IPV4_FLOW: | |
612 | sprintf(p, "\tSrc IP addr: 0x%x\n", | |
97f8aefb | 613 | fsc->fs.h_u.usr_ip4_spec.ip4src); |
15682bc4 PWJ |
614 | p += ETH_GSTRING_LEN; |
615 | num_strings++; | |
616 | sprintf(p, "\tSrc IP mask: 0x%x\n", | |
97f8aefb | 617 | fsc->fs.m_u.usr_ip4_spec.ip4src); |
15682bc4 PWJ |
618 | p += ETH_GSTRING_LEN; |
619 | num_strings++; | |
620 | sprintf(p, "\tDest IP addr: 0x%x\n", | |
97f8aefb | 621 | fsc->fs.h_u.usr_ip4_spec.ip4dst); |
15682bc4 PWJ |
622 | p += ETH_GSTRING_LEN; |
623 | num_strings++; | |
624 | sprintf(p, "\tDest IP mask: 0x%x\n", | |
97f8aefb | 625 | fsc->fs.m_u.usr_ip4_spec.ip4dst); |
15682bc4 PWJ |
626 | p += ETH_GSTRING_LEN; |
627 | num_strings++; | |
628 | sprintf(p, "\tL4 bytes: 0x%x, mask: 0x%x\n", | |
97f8aefb | 629 | fsc->fs.h_u.usr_ip4_spec.l4_4_bytes, |
630 | fsc->fs.m_u.usr_ip4_spec.l4_4_bytes); | |
15682bc4 PWJ |
631 | p += ETH_GSTRING_LEN; |
632 | num_strings++; | |
633 | sprintf(p, "\tTOS: %d, mask: 0x%x\n", | |
97f8aefb | 634 | fsc->fs.h_u.usr_ip4_spec.tos, |
635 | fsc->fs.m_u.usr_ip4_spec.tos); | |
15682bc4 PWJ |
636 | p += ETH_GSTRING_LEN; |
637 | num_strings++; | |
638 | sprintf(p, "\tIP Version: %d, mask: 0x%x\n", | |
97f8aefb | 639 | fsc->fs.h_u.usr_ip4_spec.ip_ver, |
640 | fsc->fs.m_u.usr_ip4_spec.ip_ver); | |
15682bc4 PWJ |
641 | p += ETH_GSTRING_LEN; |
642 | num_strings++; | |
643 | sprintf(p, "\tProtocol: %d, mask: 0x%x\n", | |
97f8aefb | 644 | fsc->fs.h_u.usr_ip4_spec.proto, |
645 | fsc->fs.m_u.usr_ip4_spec.proto); | |
15682bc4 PWJ |
646 | p += ETH_GSTRING_LEN; |
647 | num_strings++; | |
648 | break; | |
ccbd6a5a | 649 | } |
15682bc4 | 650 | sprintf(p, "\tVLAN: %d, mask: 0x%x\n", |
97f8aefb | 651 | fsc->fs.vlan_tag, fsc->fs.vlan_tag_mask); |
15682bc4 PWJ |
652 | p += ETH_GSTRING_LEN; |
653 | num_strings++; | |
654 | sprintf(p, "\tUser-defined: 0x%Lx\n", fsc->fs.data); | |
655 | p += ETH_GSTRING_LEN; | |
656 | num_strings++; | |
657 | sprintf(p, "\tUser-defined mask: 0x%Lx\n", fsc->fs.data_mask); | |
658 | p += ETH_GSTRING_LEN; | |
659 | num_strings++; | |
660 | if (fsc->fs.action == ETHTOOL_RXNTUPLE_ACTION_DROP) | |
661 | sprintf(p, "\tAction: Drop\n"); | |
662 | else | |
663 | sprintf(p, "\tAction: Direct to queue %d\n", | |
97f8aefb | 664 | fsc->fs.action); |
15682bc4 PWJ |
665 | p += ETH_GSTRING_LEN; |
666 | num_strings++; | |
667 | unknown_filter: | |
668 | i++; | |
669 | } | |
670 | copy: | |
671 | /* indicate to userspace how many strings we actually have */ | |
672 | gstrings.len = num_strings; | |
673 | ret = -EFAULT; | |
674 | if (copy_to_user(useraddr, &gstrings, sizeof(gstrings))) | |
675 | goto out; | |
676 | useraddr += sizeof(gstrings); | |
677 | if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN)) | |
678 | goto out; | |
679 | ret = 0; | |
680 | ||
681 | out: | |
682 | kfree(data); | |
683 | return ret; | |
684 | } | |
685 | ||
1da177e4 LT |
686 | static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) |
687 | { | |
688 | struct ethtool_regs regs; | |
76fd8593 | 689 | const struct ethtool_ops *ops = dev->ethtool_ops; |
1da177e4 LT |
690 | void *regbuf; |
691 | int reglen, ret; | |
692 | ||
693 | if (!ops->get_regs || !ops->get_regs_len) | |
694 | return -EOPNOTSUPP; | |
695 | ||
696 | if (copy_from_user(®s, useraddr, sizeof(regs))) | |
697 | return -EFAULT; | |
698 | ||
699 | reglen = ops->get_regs_len(dev); | |
700 | if (regs.len > reglen) | |
701 | regs.len = reglen; | |
702 | ||
703 | regbuf = kmalloc(reglen, GFP_USER); | |
704 | if (!regbuf) | |
705 | return -ENOMEM; | |
706 | ||
707 | ops->get_regs(dev, ®s, regbuf); | |
708 | ||
709 | ret = -EFAULT; | |
710 | if (copy_to_user(useraddr, ®s, sizeof(regs))) | |
711 | goto out; | |
712 | useraddr += offsetof(struct ethtool_regs, data); | |
713 | if (copy_to_user(useraddr, regbuf, regs.len)) | |
714 | goto out; | |
715 | ret = 0; | |
716 | ||
717 | out: | |
718 | kfree(regbuf); | |
719 | return ret; | |
720 | } | |
721 | ||
d73d3a8c BH |
722 | static int ethtool_reset(struct net_device *dev, char __user *useraddr) |
723 | { | |
724 | struct ethtool_value reset; | |
725 | int ret; | |
726 | ||
727 | if (!dev->ethtool_ops->reset) | |
728 | return -EOPNOTSUPP; | |
729 | ||
730 | if (copy_from_user(&reset, useraddr, sizeof(reset))) | |
731 | return -EFAULT; | |
732 | ||
733 | ret = dev->ethtool_ops->reset(dev, &reset.data); | |
734 | if (ret) | |
735 | return ret; | |
736 | ||
737 | if (copy_to_user(useraddr, &reset, sizeof(reset))) | |
738 | return -EFAULT; | |
739 | return 0; | |
740 | } | |
741 | ||
1da177e4 LT |
742 | static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) |
743 | { | |
8e557421 | 744 | struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; |
1da177e4 LT |
745 | |
746 | if (!dev->ethtool_ops->get_wol) | |
747 | return -EOPNOTSUPP; | |
748 | ||
749 | dev->ethtool_ops->get_wol(dev, &wol); | |
750 | ||
751 | if (copy_to_user(useraddr, &wol, sizeof(wol))) | |
752 | return -EFAULT; | |
753 | return 0; | |
754 | } | |
755 | ||
756 | static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) | |
757 | { | |
758 | struct ethtool_wolinfo wol; | |
759 | ||
760 | if (!dev->ethtool_ops->set_wol) | |
761 | return -EOPNOTSUPP; | |
762 | ||
763 | if (copy_from_user(&wol, useraddr, sizeof(wol))) | |
764 | return -EFAULT; | |
765 | ||
766 | return dev->ethtool_ops->set_wol(dev, &wol); | |
767 | } | |
768 | ||
1da177e4 LT |
769 | static int ethtool_nway_reset(struct net_device *dev) |
770 | { | |
771 | if (!dev->ethtool_ops->nway_reset) | |
772 | return -EOPNOTSUPP; | |
773 | ||
774 | return dev->ethtool_ops->nway_reset(dev); | |
775 | } | |
776 | ||
1da177e4 LT |
777 | static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr) |
778 | { | |
779 | struct ethtool_eeprom eeprom; | |
76fd8593 | 780 | const struct ethtool_ops *ops = dev->ethtool_ops; |
b131dd5d MSB |
781 | void __user *userbuf = useraddr + sizeof(eeprom); |
782 | u32 bytes_remaining; | |
1da177e4 | 783 | u8 *data; |
b131dd5d | 784 | int ret = 0; |
1da177e4 LT |
785 | |
786 | if (!ops->get_eeprom || !ops->get_eeprom_len) | |
787 | return -EOPNOTSUPP; | |
788 | ||
789 | if (copy_from_user(&eeprom, useraddr, sizeof(eeprom))) | |
790 | return -EFAULT; | |
791 | ||
792 | /* Check for wrap and zero */ | |
793 | if (eeprom.offset + eeprom.len <= eeprom.offset) | |
794 | return -EINVAL; | |
795 | ||
796 | /* Check for exceeding total eeprom len */ | |
797 | if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev)) | |
798 | return -EINVAL; | |
799 | ||
b131dd5d | 800 | data = kmalloc(PAGE_SIZE, GFP_USER); |
1da177e4 LT |
801 | if (!data) |
802 | return -ENOMEM; | |
803 | ||
b131dd5d MSB |
804 | bytes_remaining = eeprom.len; |
805 | while (bytes_remaining > 0) { | |
806 | eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE); | |
807 | ||
808 | ret = ops->get_eeprom(dev, &eeprom, data); | |
809 | if (ret) | |
810 | break; | |
811 | if (copy_to_user(userbuf, data, eeprom.len)) { | |
812 | ret = -EFAULT; | |
813 | break; | |
814 | } | |
815 | userbuf += eeprom.len; | |
816 | eeprom.offset += eeprom.len; | |
817 | bytes_remaining -= eeprom.len; | |
818 | } | |
1da177e4 | 819 | |
c5835df9 MSB |
820 | eeprom.len = userbuf - (useraddr + sizeof(eeprom)); |
821 | eeprom.offset -= eeprom.len; | |
822 | if (copy_to_user(useraddr, &eeprom, sizeof(eeprom))) | |
823 | ret = -EFAULT; | |
824 | ||
1da177e4 LT |
825 | kfree(data); |
826 | return ret; | |
827 | } | |
828 | ||
829 | static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr) | |
830 | { | |
831 | struct ethtool_eeprom eeprom; | |
76fd8593 | 832 | const struct ethtool_ops *ops = dev->ethtool_ops; |
b131dd5d MSB |
833 | void __user *userbuf = useraddr + sizeof(eeprom); |
834 | u32 bytes_remaining; | |
1da177e4 | 835 | u8 *data; |
b131dd5d | 836 | int ret = 0; |
1da177e4 LT |
837 | |
838 | if (!ops->set_eeprom || !ops->get_eeprom_len) | |
839 | return -EOPNOTSUPP; | |
840 | ||
841 | if (copy_from_user(&eeprom, useraddr, sizeof(eeprom))) | |
842 | return -EFAULT; | |
843 | ||
844 | /* Check for wrap and zero */ | |
845 | if (eeprom.offset + eeprom.len <= eeprom.offset) | |
846 | return -EINVAL; | |
847 | ||
848 | /* Check for exceeding total eeprom len */ | |
849 | if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev)) | |
850 | return -EINVAL; | |
851 | ||
b131dd5d | 852 | data = kmalloc(PAGE_SIZE, GFP_USER); |
1da177e4 LT |
853 | if (!data) |
854 | return -ENOMEM; | |
855 | ||
b131dd5d MSB |
856 | bytes_remaining = eeprom.len; |
857 | while (bytes_remaining > 0) { | |
858 | eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE); | |
859 | ||
860 | if (copy_from_user(data, userbuf, eeprom.len)) { | |
861 | ret = -EFAULT; | |
862 | break; | |
863 | } | |
864 | ret = ops->set_eeprom(dev, &eeprom, data); | |
865 | if (ret) | |
866 | break; | |
867 | userbuf += eeprom.len; | |
868 | eeprom.offset += eeprom.len; | |
869 | bytes_remaining -= eeprom.len; | |
870 | } | |
1da177e4 | 871 | |
1da177e4 LT |
872 | kfree(data); |
873 | return ret; | |
874 | } | |
875 | ||
97f8aefb | 876 | static noinline_for_stack int ethtool_get_coalesce(struct net_device *dev, |
877 | void __user *useraddr) | |
1da177e4 | 878 | { |
8e557421 | 879 | struct ethtool_coalesce coalesce = { .cmd = ETHTOOL_GCOALESCE }; |
1da177e4 LT |
880 | |
881 | if (!dev->ethtool_ops->get_coalesce) | |
882 | return -EOPNOTSUPP; | |
883 | ||
884 | dev->ethtool_ops->get_coalesce(dev, &coalesce); | |
885 | ||
886 | if (copy_to_user(useraddr, &coalesce, sizeof(coalesce))) | |
887 | return -EFAULT; | |
888 | return 0; | |
889 | } | |
890 | ||
97f8aefb | 891 | static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev, |
892 | void __user *useraddr) | |
1da177e4 LT |
893 | { |
894 | struct ethtool_coalesce coalesce; | |
895 | ||
fa04ae5c | 896 | if (!dev->ethtool_ops->set_coalesce) |
1da177e4 LT |
897 | return -EOPNOTSUPP; |
898 | ||
899 | if (copy_from_user(&coalesce, useraddr, sizeof(coalesce))) | |
900 | return -EFAULT; | |
901 | ||
902 | return dev->ethtool_ops->set_coalesce(dev, &coalesce); | |
903 | } | |
904 | ||
905 | static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr) | |
906 | { | |
8e557421 | 907 | struct ethtool_ringparam ringparam = { .cmd = ETHTOOL_GRINGPARAM }; |
1da177e4 LT |
908 | |
909 | if (!dev->ethtool_ops->get_ringparam) | |
910 | return -EOPNOTSUPP; | |
911 | ||
912 | dev->ethtool_ops->get_ringparam(dev, &ringparam); | |
913 | ||
914 | if (copy_to_user(useraddr, &ringparam, sizeof(ringparam))) | |
915 | return -EFAULT; | |
916 | return 0; | |
917 | } | |
918 | ||
919 | static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) | |
920 | { | |
921 | struct ethtool_ringparam ringparam; | |
922 | ||
923 | if (!dev->ethtool_ops->set_ringparam) | |
924 | return -EOPNOTSUPP; | |
925 | ||
926 | if (copy_from_user(&ringparam, useraddr, sizeof(ringparam))) | |
927 | return -EFAULT; | |
928 | ||
929 | return dev->ethtool_ops->set_ringparam(dev, &ringparam); | |
930 | } | |
931 | ||
932 | static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr) | |
933 | { | |
934 | struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM }; | |
935 | ||
936 | if (!dev->ethtool_ops->get_pauseparam) | |
937 | return -EOPNOTSUPP; | |
938 | ||
939 | dev->ethtool_ops->get_pauseparam(dev, &pauseparam); | |
940 | ||
941 | if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam))) | |
942 | return -EFAULT; | |
943 | return 0; | |
944 | } | |
945 | ||
946 | static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr) | |
947 | { | |
948 | struct ethtool_pauseparam pauseparam; | |
949 | ||
e1b90c41 | 950 | if (!dev->ethtool_ops->set_pauseparam) |
1da177e4 LT |
951 | return -EOPNOTSUPP; |
952 | ||
953 | if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam))) | |
954 | return -EFAULT; | |
955 | ||
956 | return dev->ethtool_ops->set_pauseparam(dev, &pauseparam); | |
957 | } | |
958 | ||
1da177e4 LT |
959 | static int __ethtool_set_sg(struct net_device *dev, u32 data) |
960 | { | |
961 | int err; | |
962 | ||
963 | if (!data && dev->ethtool_ops->set_tso) { | |
964 | err = dev->ethtool_ops->set_tso(dev, 0); | |
965 | if (err) | |
966 | return err; | |
967 | } | |
968 | ||
e89e9cf5 AR |
969 | if (!data && dev->ethtool_ops->set_ufo) { |
970 | err = dev->ethtool_ops->set_ufo(dev, 0); | |
971 | if (err) | |
972 | return err; | |
973 | } | |
1da177e4 LT |
974 | return dev->ethtool_ops->set_sg(dev, data); |
975 | } | |
976 | ||
977 | static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr) | |
978 | { | |
979 | struct ethtool_value edata; | |
980 | int err; | |
981 | ||
982 | if (!dev->ethtool_ops->set_tx_csum) | |
983 | return -EOPNOTSUPP; | |
984 | ||
985 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
986 | return -EFAULT; | |
987 | ||
988 | if (!edata.data && dev->ethtool_ops->set_sg) { | |
989 | err = __ethtool_set_sg(dev, 0); | |
990 | if (err) | |
991 | return err; | |
992 | } | |
993 | ||
994 | return dev->ethtool_ops->set_tx_csum(dev, edata.data); | |
995 | } | |
97f8aefb | 996 | EXPORT_SYMBOL(ethtool_op_set_tx_csum); |
1da177e4 | 997 | |
b240a0e5 HX |
998 | static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr) |
999 | { | |
1000 | struct ethtool_value edata; | |
1001 | ||
1002 | if (!dev->ethtool_ops->set_rx_csum) | |
1003 | return -EOPNOTSUPP; | |
1004 | ||
1005 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1006 | return -EFAULT; | |
1007 | ||
1008 | if (!edata.data && dev->ethtool_ops->set_sg) | |
1009 | dev->features &= ~NETIF_F_GRO; | |
1010 | ||
1011 | return dev->ethtool_ops->set_rx_csum(dev, edata.data); | |
1012 | } | |
1013 | ||
1da177e4 LT |
1014 | static int ethtool_set_sg(struct net_device *dev, char __user *useraddr) |
1015 | { | |
1016 | struct ethtool_value edata; | |
1017 | ||
1018 | if (!dev->ethtool_ops->set_sg) | |
1019 | return -EOPNOTSUPP; | |
1020 | ||
1021 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1022 | return -EFAULT; | |
1023 | ||
4ec93edb | 1024 | if (edata.data && |
8648b305 | 1025 | !(dev->features & NETIF_F_ALL_CSUM)) |
1da177e4 LT |
1026 | return -EINVAL; |
1027 | ||
1028 | return __ethtool_set_sg(dev, edata.data); | |
1029 | } | |
1030 | ||
1da177e4 LT |
1031 | static int ethtool_set_tso(struct net_device *dev, char __user *useraddr) |
1032 | { | |
1033 | struct ethtool_value edata; | |
1034 | ||
1035 | if (!dev->ethtool_ops->set_tso) | |
1036 | return -EOPNOTSUPP; | |
1037 | ||
1038 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1039 | return -EFAULT; | |
1040 | ||
1041 | if (edata.data && !(dev->features & NETIF_F_SG)) | |
1042 | return -EINVAL; | |
1043 | ||
1044 | return dev->ethtool_ops->set_tso(dev, edata.data); | |
1045 | } | |
1046 | ||
e89e9cf5 AR |
1047 | static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr) |
1048 | { | |
1049 | struct ethtool_value edata; | |
1050 | ||
1051 | if (!dev->ethtool_ops->set_ufo) | |
1052 | return -EOPNOTSUPP; | |
1053 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1054 | return -EFAULT; | |
1055 | if (edata.data && !(dev->features & NETIF_F_SG)) | |
1056 | return -EINVAL; | |
1057 | if (edata.data && !(dev->features & NETIF_F_HW_CSUM)) | |
1058 | return -EINVAL; | |
1059 | return dev->ethtool_ops->set_ufo(dev, edata.data); | |
1060 | } | |
1061 | ||
37c3185a HX |
1062 | static int ethtool_get_gso(struct net_device *dev, char __user *useraddr) |
1063 | { | |
1064 | struct ethtool_value edata = { ETHTOOL_GGSO }; | |
1065 | ||
1066 | edata.data = dev->features & NETIF_F_GSO; | |
1067 | if (copy_to_user(useraddr, &edata, sizeof(edata))) | |
97f8aefb | 1068 | return -EFAULT; |
37c3185a HX |
1069 | return 0; |
1070 | } | |
1071 | ||
1072 | static int ethtool_set_gso(struct net_device *dev, char __user *useraddr) | |
1073 | { | |
1074 | struct ethtool_value edata; | |
1075 | ||
1076 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1077 | return -EFAULT; | |
1078 | if (edata.data) | |
1079 | dev->features |= NETIF_F_GSO; | |
1080 | else | |
1081 | dev->features &= ~NETIF_F_GSO; | |
1082 | return 0; | |
1083 | } | |
1084 | ||
b240a0e5 HX |
1085 | static int ethtool_get_gro(struct net_device *dev, char __user *useraddr) |
1086 | { | |
1087 | struct ethtool_value edata = { ETHTOOL_GGRO }; | |
1088 | ||
1089 | edata.data = dev->features & NETIF_F_GRO; | |
1090 | if (copy_to_user(useraddr, &edata, sizeof(edata))) | |
97f8aefb | 1091 | return -EFAULT; |
b240a0e5 HX |
1092 | return 0; |
1093 | } | |
1094 | ||
1095 | static int ethtool_set_gro(struct net_device *dev, char __user *useraddr) | |
1096 | { | |
1097 | struct ethtool_value edata; | |
1098 | ||
1099 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1100 | return -EFAULT; | |
1101 | ||
1102 | if (edata.data) { | |
1103 | if (!dev->ethtool_ops->get_rx_csum || | |
1104 | !dev->ethtool_ops->get_rx_csum(dev)) | |
1105 | return -EINVAL; | |
1106 | dev->features |= NETIF_F_GRO; | |
1107 | } else | |
1108 | dev->features &= ~NETIF_F_GRO; | |
1109 | ||
1110 | return 0; | |
1111 | } | |
1112 | ||
1da177e4 LT |
1113 | static int ethtool_self_test(struct net_device *dev, char __user *useraddr) |
1114 | { | |
1115 | struct ethtool_test test; | |
76fd8593 | 1116 | const struct ethtool_ops *ops = dev->ethtool_ops; |
1da177e4 | 1117 | u64 *data; |
ff03d49f | 1118 | int ret, test_len; |
1da177e4 | 1119 | |
a9828ec6 | 1120 | if (!ops->self_test || !ops->get_sset_count) |
1da177e4 LT |
1121 | return -EOPNOTSUPP; |
1122 | ||
a9828ec6 | 1123 | test_len = ops->get_sset_count(dev, ETH_SS_TEST); |
ff03d49f JG |
1124 | if (test_len < 0) |
1125 | return test_len; | |
1126 | WARN_ON(test_len == 0); | |
1127 | ||
1da177e4 LT |
1128 | if (copy_from_user(&test, useraddr, sizeof(test))) |
1129 | return -EFAULT; | |
1130 | ||
ff03d49f JG |
1131 | test.len = test_len; |
1132 | data = kmalloc(test_len * sizeof(u64), GFP_USER); | |
1da177e4 LT |
1133 | if (!data) |
1134 | return -ENOMEM; | |
1135 | ||
1136 | ops->self_test(dev, &test, data); | |
1137 | ||
1138 | ret = -EFAULT; | |
1139 | if (copy_to_user(useraddr, &test, sizeof(test))) | |
1140 | goto out; | |
1141 | useraddr += sizeof(test); | |
1142 | if (copy_to_user(useraddr, data, test.len * sizeof(u64))) | |
1143 | goto out; | |
1144 | ret = 0; | |
1145 | ||
1146 | out: | |
1147 | kfree(data); | |
1148 | return ret; | |
1149 | } | |
1150 | ||
1151 | static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) | |
1152 | { | |
1153 | struct ethtool_gstrings gstrings; | |
76fd8593 | 1154 | const struct ethtool_ops *ops = dev->ethtool_ops; |
1da177e4 LT |
1155 | u8 *data; |
1156 | int ret; | |
1157 | ||
a9828ec6 | 1158 | if (!ops->get_strings || !ops->get_sset_count) |
1da177e4 LT |
1159 | return -EOPNOTSUPP; |
1160 | ||
1161 | if (copy_from_user(&gstrings, useraddr, sizeof(gstrings))) | |
1162 | return -EFAULT; | |
1163 | ||
a9828ec6 BH |
1164 | ret = ops->get_sset_count(dev, gstrings.string_set); |
1165 | if (ret < 0) | |
1166 | return ret; | |
1167 | ||
1168 | gstrings.len = ret; | |
1da177e4 LT |
1169 | |
1170 | data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER); | |
1171 | if (!data) | |
1172 | return -ENOMEM; | |
1173 | ||
1174 | ops->get_strings(dev, gstrings.string_set, data); | |
1175 | ||
1176 | ret = -EFAULT; | |
1177 | if (copy_to_user(useraddr, &gstrings, sizeof(gstrings))) | |
1178 | goto out; | |
1179 | useraddr += sizeof(gstrings); | |
1180 | if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN)) | |
1181 | goto out; | |
1182 | ret = 0; | |
1183 | ||
1184 | out: | |
1185 | kfree(data); | |
1186 | return ret; | |
1187 | } | |
1188 | ||
1189 | static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |
1190 | { | |
1191 | struct ethtool_value id; | |
1192 | ||
1193 | if (!dev->ethtool_ops->phys_id) | |
1194 | return -EOPNOTSUPP; | |
1195 | ||
1196 | if (copy_from_user(&id, useraddr, sizeof(id))) | |
1197 | return -EFAULT; | |
1198 | ||
1199 | return dev->ethtool_ops->phys_id(dev, id.data); | |
1200 | } | |
1201 | ||
1202 | static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) | |
1203 | { | |
1204 | struct ethtool_stats stats; | |
76fd8593 | 1205 | const struct ethtool_ops *ops = dev->ethtool_ops; |
1da177e4 | 1206 | u64 *data; |
ff03d49f | 1207 | int ret, n_stats; |
1da177e4 | 1208 | |
a9828ec6 | 1209 | if (!ops->get_ethtool_stats || !ops->get_sset_count) |
1da177e4 LT |
1210 | return -EOPNOTSUPP; |
1211 | ||
a9828ec6 | 1212 | n_stats = ops->get_sset_count(dev, ETH_SS_STATS); |
ff03d49f JG |
1213 | if (n_stats < 0) |
1214 | return n_stats; | |
1215 | WARN_ON(n_stats == 0); | |
1216 | ||
1da177e4 LT |
1217 | if (copy_from_user(&stats, useraddr, sizeof(stats))) |
1218 | return -EFAULT; | |
1219 | ||
ff03d49f JG |
1220 | stats.n_stats = n_stats; |
1221 | data = kmalloc(n_stats * sizeof(u64), GFP_USER); | |
1da177e4 LT |
1222 | if (!data) |
1223 | return -ENOMEM; | |
1224 | ||
1225 | ops->get_ethtool_stats(dev, &stats, data); | |
1226 | ||
1227 | ret = -EFAULT; | |
1228 | if (copy_to_user(useraddr, &stats, sizeof(stats))) | |
1229 | goto out; | |
1230 | useraddr += sizeof(stats); | |
1231 | if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64))) | |
1232 | goto out; | |
1233 | ret = 0; | |
1234 | ||
1235 | out: | |
1236 | kfree(data); | |
1237 | return ret; | |
1238 | } | |
1239 | ||
0bf0519d | 1240 | static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr) |
a6f9a705 JW |
1241 | { |
1242 | struct ethtool_perm_addr epaddr; | |
a6f9a705 | 1243 | |
313674af | 1244 | if (copy_from_user(&epaddr, useraddr, sizeof(epaddr))) |
a6f9a705 JW |
1245 | return -EFAULT; |
1246 | ||
313674af MW |
1247 | if (epaddr.size < dev->addr_len) |
1248 | return -ETOOSMALL; | |
1249 | epaddr.size = dev->addr_len; | |
a6f9a705 | 1250 | |
a6f9a705 | 1251 | if (copy_to_user(useraddr, &epaddr, sizeof(epaddr))) |
313674af | 1252 | return -EFAULT; |
a6f9a705 | 1253 | useraddr += sizeof(epaddr); |
313674af MW |
1254 | if (copy_to_user(useraddr, dev->perm_addr, epaddr.size)) |
1255 | return -EFAULT; | |
1256 | return 0; | |
a6f9a705 JW |
1257 | } |
1258 | ||
13c99b24 JG |
1259 | static int ethtool_get_value(struct net_device *dev, char __user *useraddr, |
1260 | u32 cmd, u32 (*actor)(struct net_device *)) | |
3ae7c0b2 | 1261 | { |
8e557421 | 1262 | struct ethtool_value edata = { .cmd = cmd }; |
3ae7c0b2 | 1263 | |
13c99b24 | 1264 | if (!actor) |
3ae7c0b2 JG |
1265 | return -EOPNOTSUPP; |
1266 | ||
13c99b24 | 1267 | edata.data = actor(dev); |
3ae7c0b2 JG |
1268 | |
1269 | if (copy_to_user(useraddr, &edata, sizeof(edata))) | |
1270 | return -EFAULT; | |
1271 | return 0; | |
1272 | } | |
1273 | ||
13c99b24 JG |
1274 | static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr, |
1275 | void (*actor)(struct net_device *, u32)) | |
3ae7c0b2 JG |
1276 | { |
1277 | struct ethtool_value edata; | |
1278 | ||
13c99b24 | 1279 | if (!actor) |
3ae7c0b2 JG |
1280 | return -EOPNOTSUPP; |
1281 | ||
1282 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1283 | return -EFAULT; | |
1284 | ||
13c99b24 | 1285 | actor(dev, edata.data); |
339bf024 JG |
1286 | return 0; |
1287 | } | |
1288 | ||
13c99b24 JG |
1289 | static int ethtool_set_value(struct net_device *dev, char __user *useraddr, |
1290 | int (*actor)(struct net_device *, u32)) | |
339bf024 JG |
1291 | { |
1292 | struct ethtool_value edata; | |
1293 | ||
13c99b24 | 1294 | if (!actor) |
339bf024 JG |
1295 | return -EOPNOTSUPP; |
1296 | ||
1297 | if (copy_from_user(&edata, useraddr, sizeof(edata))) | |
1298 | return -EFAULT; | |
1299 | ||
13c99b24 | 1300 | return actor(dev, edata.data); |
339bf024 JG |
1301 | } |
1302 | ||
97f8aefb | 1303 | static noinline_for_stack int ethtool_flash_device(struct net_device *dev, |
1304 | char __user *useraddr) | |
05c6a8d7 AK |
1305 | { |
1306 | struct ethtool_flash efl; | |
1307 | ||
1308 | if (copy_from_user(&efl, useraddr, sizeof(efl))) | |
1309 | return -EFAULT; | |
1310 | ||
1311 | if (!dev->ethtool_ops->flash_device) | |
1312 | return -EOPNOTSUPP; | |
1313 | ||
1314 | return dev->ethtool_ops->flash_device(dev, &efl); | |
1315 | } | |
1316 | ||
1da177e4 LT |
1317 | /* The main entry point in this file. Called from net/core/dev.c */ |
1318 | ||
881d966b | 1319 | int dev_ethtool(struct net *net, struct ifreq *ifr) |
1da177e4 | 1320 | { |
881d966b | 1321 | struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name); |
1da177e4 LT |
1322 | void __user *useraddr = ifr->ifr_data; |
1323 | u32 ethcmd; | |
1324 | int rc; | |
81e81575 | 1325 | unsigned long old_features; |
1da177e4 | 1326 | |
1da177e4 LT |
1327 | if (!dev || !netif_device_present(dev)) |
1328 | return -ENODEV; | |
1329 | ||
1330 | if (!dev->ethtool_ops) | |
61a44b9c | 1331 | return -EOPNOTSUPP; |
1da177e4 | 1332 | |
97f8aefb | 1333 | if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd))) |
1da177e4 LT |
1334 | return -EFAULT; |
1335 | ||
75f3123c | 1336 | /* Allow some commands to be done by anyone */ |
97f8aefb | 1337 | switch (ethcmd) { |
75f3123c | 1338 | case ETHTOOL_GDRVINFO: |
75f3123c | 1339 | case ETHTOOL_GMSGLVL: |
75f3123c SH |
1340 | case ETHTOOL_GCOALESCE: |
1341 | case ETHTOOL_GRINGPARAM: | |
1342 | case ETHTOOL_GPAUSEPARAM: | |
1343 | case ETHTOOL_GRXCSUM: | |
1344 | case ETHTOOL_GTXCSUM: | |
1345 | case ETHTOOL_GSG: | |
1346 | case ETHTOOL_GSTRINGS: | |
75f3123c SH |
1347 | case ETHTOOL_GTSO: |
1348 | case ETHTOOL_GPERMADDR: | |
1349 | case ETHTOOL_GUFO: | |
1350 | case ETHTOOL_GGSO: | |
1cab819b | 1351 | case ETHTOOL_GGRO: |
339bf024 JG |
1352 | case ETHTOOL_GFLAGS: |
1353 | case ETHTOOL_GPFLAGS: | |
0853ad66 | 1354 | case ETHTOOL_GRXFH: |
59089d8d SB |
1355 | case ETHTOOL_GRXRINGS: |
1356 | case ETHTOOL_GRXCLSRLCNT: | |
1357 | case ETHTOOL_GRXCLSRULE: | |
1358 | case ETHTOOL_GRXCLSRLALL: | |
75f3123c SH |
1359 | break; |
1360 | default: | |
1361 | if (!capable(CAP_NET_ADMIN)) | |
1362 | return -EPERM; | |
1363 | } | |
1364 | ||
97f8aefb | 1365 | if (dev->ethtool_ops->begin) { |
1366 | rc = dev->ethtool_ops->begin(dev); | |
1367 | if (rc < 0) | |
1da177e4 | 1368 | return rc; |
97f8aefb | 1369 | } |
d8a33ac4 SH |
1370 | old_features = dev->features; |
1371 | ||
1da177e4 LT |
1372 | switch (ethcmd) { |
1373 | case ETHTOOL_GSET: | |
1374 | rc = ethtool_get_settings(dev, useraddr); | |
1375 | break; | |
1376 | case ETHTOOL_SSET: | |
1377 | rc = ethtool_set_settings(dev, useraddr); | |
1378 | break; | |
1379 | case ETHTOOL_GDRVINFO: | |
1380 | rc = ethtool_get_drvinfo(dev, useraddr); | |
1da177e4 LT |
1381 | break; |
1382 | case ETHTOOL_GREGS: | |
1383 | rc = ethtool_get_regs(dev, useraddr); | |
1384 | break; | |
1385 | case ETHTOOL_GWOL: | |
1386 | rc = ethtool_get_wol(dev, useraddr); | |
1387 | break; | |
1388 | case ETHTOOL_SWOL: | |
1389 | rc = ethtool_set_wol(dev, useraddr); | |
1390 | break; | |
1391 | case ETHTOOL_GMSGLVL: | |
13c99b24 JG |
1392 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
1393 | dev->ethtool_ops->get_msglevel); | |
1da177e4 LT |
1394 | break; |
1395 | case ETHTOOL_SMSGLVL: | |
13c99b24 JG |
1396 | rc = ethtool_set_value_void(dev, useraddr, |
1397 | dev->ethtool_ops->set_msglevel); | |
1da177e4 LT |
1398 | break; |
1399 | case ETHTOOL_NWAY_RST: | |
1400 | rc = ethtool_nway_reset(dev); | |
1401 | break; | |
1402 | case ETHTOOL_GLINK: | |
13c99b24 JG |
1403 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
1404 | dev->ethtool_ops->get_link); | |
1da177e4 LT |
1405 | break; |
1406 | case ETHTOOL_GEEPROM: | |
1407 | rc = ethtool_get_eeprom(dev, useraddr); | |
1408 | break; | |
1409 | case ETHTOOL_SEEPROM: | |
1410 | rc = ethtool_set_eeprom(dev, useraddr); | |
1411 | break; | |
1412 | case ETHTOOL_GCOALESCE: | |
1413 | rc = ethtool_get_coalesce(dev, useraddr); | |
1414 | break; | |
1415 | case ETHTOOL_SCOALESCE: | |
1416 | rc = ethtool_set_coalesce(dev, useraddr); | |
1417 | break; | |
1418 | case ETHTOOL_GRINGPARAM: | |
1419 | rc = ethtool_get_ringparam(dev, useraddr); | |
1420 | break; | |
1421 | case ETHTOOL_SRINGPARAM: | |
1422 | rc = ethtool_set_ringparam(dev, useraddr); | |
1423 | break; | |
1424 | case ETHTOOL_GPAUSEPARAM: | |
1425 | rc = ethtool_get_pauseparam(dev, useraddr); | |
1426 | break; | |
1427 | case ETHTOOL_SPAUSEPARAM: | |
1428 | rc = ethtool_set_pauseparam(dev, useraddr); | |
1429 | break; | |
1430 | case ETHTOOL_GRXCSUM: | |
13c99b24 | 1431 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
1896e61f SS |
1432 | (dev->ethtool_ops->get_rx_csum ? |
1433 | dev->ethtool_ops->get_rx_csum : | |
1434 | ethtool_op_get_rx_csum)); | |
1da177e4 LT |
1435 | break; |
1436 | case ETHTOOL_SRXCSUM: | |
b240a0e5 | 1437 | rc = ethtool_set_rx_csum(dev, useraddr); |
1da177e4 LT |
1438 | break; |
1439 | case ETHTOOL_GTXCSUM: | |
13c99b24 | 1440 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
88d3aafd JG |
1441 | (dev->ethtool_ops->get_tx_csum ? |
1442 | dev->ethtool_ops->get_tx_csum : | |
1443 | ethtool_op_get_tx_csum)); | |
1da177e4 LT |
1444 | break; |
1445 | case ETHTOOL_STXCSUM: | |
1446 | rc = ethtool_set_tx_csum(dev, useraddr); | |
1447 | break; | |
1448 | case ETHTOOL_GSG: | |
13c99b24 | 1449 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
88d3aafd JG |
1450 | (dev->ethtool_ops->get_sg ? |
1451 | dev->ethtool_ops->get_sg : | |
1452 | ethtool_op_get_sg)); | |
1da177e4 LT |
1453 | break; |
1454 | case ETHTOOL_SSG: | |
1455 | rc = ethtool_set_sg(dev, useraddr); | |
1456 | break; | |
1457 | case ETHTOOL_GTSO: | |
13c99b24 | 1458 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
88d3aafd JG |
1459 | (dev->ethtool_ops->get_tso ? |
1460 | dev->ethtool_ops->get_tso : | |
1461 | ethtool_op_get_tso)); | |
1da177e4 LT |
1462 | break; |
1463 | case ETHTOOL_STSO: | |
1464 | rc = ethtool_set_tso(dev, useraddr); | |
1465 | break; | |
1466 | case ETHTOOL_TEST: | |
1467 | rc = ethtool_self_test(dev, useraddr); | |
1468 | break; | |
1469 | case ETHTOOL_GSTRINGS: | |
1470 | rc = ethtool_get_strings(dev, useraddr); | |
1471 | break; | |
1472 | case ETHTOOL_PHYS_ID: | |
1473 | rc = ethtool_phys_id(dev, useraddr); | |
1474 | break; | |
1475 | case ETHTOOL_GSTATS: | |
1476 | rc = ethtool_get_stats(dev, useraddr); | |
1477 | break; | |
a6f9a705 JW |
1478 | case ETHTOOL_GPERMADDR: |
1479 | rc = ethtool_get_perm_addr(dev, useraddr); | |
1480 | break; | |
e89e9cf5 | 1481 | case ETHTOOL_GUFO: |
13c99b24 | 1482 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
88d3aafd JG |
1483 | (dev->ethtool_ops->get_ufo ? |
1484 | dev->ethtool_ops->get_ufo : | |
1485 | ethtool_op_get_ufo)); | |
e89e9cf5 AR |
1486 | break; |
1487 | case ETHTOOL_SUFO: | |
1488 | rc = ethtool_set_ufo(dev, useraddr); | |
1489 | break; | |
37c3185a HX |
1490 | case ETHTOOL_GGSO: |
1491 | rc = ethtool_get_gso(dev, useraddr); | |
1492 | break; | |
1493 | case ETHTOOL_SGSO: | |
1494 | rc = ethtool_set_gso(dev, useraddr); | |
1495 | break; | |
3ae7c0b2 | 1496 | case ETHTOOL_GFLAGS: |
13c99b24 | 1497 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
1896e61f SS |
1498 | (dev->ethtool_ops->get_flags ? |
1499 | dev->ethtool_ops->get_flags : | |
1500 | ethtool_op_get_flags)); | |
3ae7c0b2 JG |
1501 | break; |
1502 | case ETHTOOL_SFLAGS: | |
13c99b24 JG |
1503 | rc = ethtool_set_value(dev, useraddr, |
1504 | dev->ethtool_ops->set_flags); | |
3ae7c0b2 | 1505 | break; |
339bf024 | 1506 | case ETHTOOL_GPFLAGS: |
13c99b24 JG |
1507 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
1508 | dev->ethtool_ops->get_priv_flags); | |
339bf024 JG |
1509 | break; |
1510 | case ETHTOOL_SPFLAGS: | |
13c99b24 JG |
1511 | rc = ethtool_set_value(dev, useraddr, |
1512 | dev->ethtool_ops->set_priv_flags); | |
339bf024 | 1513 | break; |
0853ad66 | 1514 | case ETHTOOL_GRXFH: |
59089d8d SB |
1515 | case ETHTOOL_GRXRINGS: |
1516 | case ETHTOOL_GRXCLSRLCNT: | |
1517 | case ETHTOOL_GRXCLSRULE: | |
1518 | case ETHTOOL_GRXCLSRLALL: | |
1519 | rc = ethtool_get_rxnfc(dev, useraddr); | |
0853ad66 SB |
1520 | break; |
1521 | case ETHTOOL_SRXFH: | |
59089d8d SB |
1522 | case ETHTOOL_SRXCLSRLDEL: |
1523 | case ETHTOOL_SRXCLSRLINS: | |
1524 | rc = ethtool_set_rxnfc(dev, useraddr); | |
0853ad66 | 1525 | break; |
b240a0e5 HX |
1526 | case ETHTOOL_GGRO: |
1527 | rc = ethtool_get_gro(dev, useraddr); | |
1528 | break; | |
1529 | case ETHTOOL_SGRO: | |
1530 | rc = ethtool_set_gro(dev, useraddr); | |
1531 | break; | |
05c6a8d7 AK |
1532 | case ETHTOOL_FLASHDEV: |
1533 | rc = ethtool_flash_device(dev, useraddr); | |
1534 | break; | |
d73d3a8c BH |
1535 | case ETHTOOL_RESET: |
1536 | rc = ethtool_reset(dev, useraddr); | |
1537 | break; | |
15682bc4 PWJ |
1538 | case ETHTOOL_SRXNTUPLE: |
1539 | rc = ethtool_set_rx_ntuple(dev, useraddr); | |
1540 | break; | |
1541 | case ETHTOOL_GRXNTUPLE: | |
1542 | rc = ethtool_get_rx_ntuple(dev, useraddr); | |
1543 | break; | |
723b2f57 JG |
1544 | case ETHTOOL_GSSET_INFO: |
1545 | rc = ethtool_get_sset_info(dev, useraddr); | |
1546 | break; | |
1da177e4 | 1547 | default: |
61a44b9c | 1548 | rc = -EOPNOTSUPP; |
1da177e4 | 1549 | } |
4ec93edb | 1550 | |
e71a4783 | 1551 | if (dev->ethtool_ops->complete) |
1da177e4 | 1552 | dev->ethtool_ops->complete(dev); |
d8a33ac4 SH |
1553 | |
1554 | if (old_features != dev->features) | |
1555 | netdev_features_change(dev); | |
1556 | ||
1da177e4 | 1557 | return rc; |
1da177e4 | 1558 | } |