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