Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Matthew Wilcox | 61a44b9 | 2007-07-31 14:00:02 -0700 | [diff] [blame] | 6 | * the information ethtool needs. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
Matthew Wilcox | 61a44b9 | 2007-07-31 14:00:02 -0700 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/types.h> |
Randy Dunlap | 4fc268d | 2006-01-11 12:17:47 -0800 | [diff] [blame] | 16 | #include <linux/capability.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/errno.h> |
| 18 | #include <linux/ethtool.h> |
| 19 | #include <linux/netdevice.h> |
| 20 | #include <asm/uaccess.h> |
| 21 | |
YOSHIFUJI Hideaki | 4ec93ed | 2007-02-09 23:24:36 +0900 | [diff] [blame] | 22 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Sridhar Samudrala | 1896e61 | 2009-07-22 13:38:22 +0000 | [diff] [blame] | 33 | u32 ethtool_op_get_rx_csum(struct net_device *dev) |
| 34 | { |
| 35 | return (dev->features & NETIF_F_ALL_CSUM) != 0; |
| 36 | } |
Eric Dumazet | 8a729fc | 2009-07-26 23:18:11 +0000 | [diff] [blame] | 37 | EXPORT_SYMBOL(ethtool_op_get_rx_csum); |
Sridhar Samudrala | 1896e61 | 2009-07-22 13:38:22 +0000 | [diff] [blame] | 38 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | u32 ethtool_op_get_tx_csum(struct net_device *dev) |
| 40 | { |
Herbert Xu | 8648b30 | 2006-06-17 22:06:05 -0700 | [diff] [blame] | 41 | return (dev->features & NETIF_F_ALL_CSUM) != 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | } |
Eric Dumazet | 8a729fc | 2009-07-26 23:18:11 +0000 | [diff] [blame] | 43 | EXPORT_SYMBOL(ethtool_op_get_tx_csum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Jon Mason | 69f6a0f | 2005-05-29 20:27:24 -0700 | [diff] [blame] | 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 | } |
Michael Chan | 6460d94 | 2007-07-14 19:07:52 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Ananda Raju | e89e9cf | 2005-10-18 15:46:41 -0700 | [diff] [blame] | 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 | |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 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 = |
| 123 | ETH_FLAG_LRO; |
| 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 | { |
| 137 | if (data & ETH_FLAG_LRO) |
| 138 | dev->features |= NETIF_F_LRO; |
| 139 | else |
| 140 | dev->features &= ~NETIF_F_LRO; |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | /* Handlers for each ethtool command */ |
| 146 | |
| 147 | static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) |
| 148 | { |
| 149 | struct ethtool_cmd cmd = { ETHTOOL_GSET }; |
| 150 | int err; |
| 151 | |
| 152 | if (!dev->ethtool_ops->get_settings) |
| 153 | return -EOPNOTSUPP; |
| 154 | |
| 155 | err = dev->ethtool_ops->get_settings(dev, &cmd); |
| 156 | if (err < 0) |
| 157 | return err; |
| 158 | |
| 159 | if (copy_to_user(useraddr, &cmd, sizeof(cmd))) |
| 160 | return -EFAULT; |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | static int ethtool_set_settings(struct net_device *dev, void __user *useraddr) |
| 165 | { |
| 166 | struct ethtool_cmd cmd; |
| 167 | |
| 168 | if (!dev->ethtool_ops->set_settings) |
| 169 | return -EOPNOTSUPP; |
| 170 | |
| 171 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) |
| 172 | return -EFAULT; |
| 173 | |
| 174 | return dev->ethtool_ops->set_settings(dev, &cmd); |
| 175 | } |
| 176 | |
| 177 | static int ethtool_get_drvinfo(struct net_device *dev, void __user *useraddr) |
| 178 | { |
| 179 | struct ethtool_drvinfo info; |
Stephen Hemminger | 76fd859 | 2006-09-08 11:16:13 -0700 | [diff] [blame] | 180 | const struct ethtool_ops *ops = dev->ethtool_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
| 182 | if (!ops->get_drvinfo) |
| 183 | return -EOPNOTSUPP; |
| 184 | |
| 185 | memset(&info, 0, sizeof(info)); |
| 186 | info.cmd = ETHTOOL_GDRVINFO; |
| 187 | ops->get_drvinfo(dev, &info); |
| 188 | |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 189 | if (ops->get_sset_count) { |
| 190 | int rc; |
| 191 | |
| 192 | rc = ops->get_sset_count(dev, ETH_SS_TEST); |
| 193 | if (rc >= 0) |
| 194 | info.testinfo_len = rc; |
| 195 | rc = ops->get_sset_count(dev, ETH_SS_STATS); |
| 196 | if (rc >= 0) |
| 197 | info.n_stats = rc; |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 198 | rc = ops->get_sset_count(dev, ETH_SS_PRIV_FLAGS); |
| 199 | if (rc >= 0) |
| 200 | info.n_priv_flags = rc; |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 201 | } else { |
| 202 | /* code path for obsolete hooks */ |
| 203 | |
| 204 | if (ops->self_test_count) |
| 205 | info.testinfo_len = ops->self_test_count(dev); |
| 206 | if (ops->get_stats_count) |
| 207 | info.n_stats = ops->get_stats_count(dev); |
| 208 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | if (ops->get_regs_len) |
| 210 | info.regdump_len = ops->get_regs_len(dev); |
| 211 | if (ops->get_eeprom_len) |
| 212 | info.eedump_len = ops->get_eeprom_len(dev); |
| 213 | |
| 214 | if (copy_to_user(useraddr, &info, sizeof(info))) |
| 215 | return -EFAULT; |
| 216 | return 0; |
| 217 | } |
| 218 | |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 219 | static int ethtool_set_rxnfc(struct net_device *dev, void __user *useraddr) |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 220 | { |
| 221 | struct ethtool_rxnfc cmd; |
| 222 | |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 223 | if (!dev->ethtool_ops->set_rxnfc) |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 224 | return -EOPNOTSUPP; |
| 225 | |
| 226 | if (copy_from_user(&cmd, useraddr, sizeof(cmd))) |
| 227 | return -EFAULT; |
| 228 | |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 229 | return dev->ethtool_ops->set_rxnfc(dev, &cmd); |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 232 | static int ethtool_get_rxnfc(struct net_device *dev, void __user *useraddr) |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 233 | { |
| 234 | struct ethtool_rxnfc info; |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 235 | const struct ethtool_ops *ops = dev->ethtool_ops; |
| 236 | int ret; |
| 237 | void *rule_buf = NULL; |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 238 | |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 239 | if (!ops->get_rxnfc) |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 240 | return -EOPNOTSUPP; |
| 241 | |
| 242 | if (copy_from_user(&info, useraddr, sizeof(info))) |
| 243 | return -EFAULT; |
| 244 | |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 245 | if (info.cmd == ETHTOOL_GRXCLSRLALL) { |
| 246 | if (info.rule_cnt > 0) { |
| 247 | rule_buf = kmalloc(info.rule_cnt * sizeof(u32), |
| 248 | GFP_USER); |
| 249 | if (!rule_buf) |
| 250 | return -ENOMEM; |
| 251 | } |
| 252 | } |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 253 | |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 254 | ret = ops->get_rxnfc(dev, &info, rule_buf); |
| 255 | if (ret < 0) |
| 256 | goto err_out; |
| 257 | |
| 258 | ret = -EFAULT; |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 259 | if (copy_to_user(useraddr, &info, sizeof(info))) |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 260 | goto err_out; |
| 261 | |
| 262 | if (rule_buf) { |
| 263 | useraddr += offsetof(struct ethtool_rxnfc, rule_locs); |
| 264 | if (copy_to_user(useraddr, rule_buf, |
| 265 | info.rule_cnt * sizeof(u32))) |
| 266 | goto err_out; |
| 267 | } |
| 268 | ret = 0; |
| 269 | |
| 270 | err_out: |
Wei Yongjun | c9cacec | 2009-03-31 15:06:26 -0700 | [diff] [blame] | 271 | kfree(rule_buf); |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 272 | |
| 273 | return ret; |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) |
| 277 | { |
| 278 | struct ethtool_regs regs; |
Stephen Hemminger | 76fd859 | 2006-09-08 11:16:13 -0700 | [diff] [blame] | 279 | const struct ethtool_ops *ops = dev->ethtool_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | void *regbuf; |
| 281 | int reglen, ret; |
| 282 | |
| 283 | if (!ops->get_regs || !ops->get_regs_len) |
| 284 | return -EOPNOTSUPP; |
| 285 | |
| 286 | if (copy_from_user(®s, useraddr, sizeof(regs))) |
| 287 | return -EFAULT; |
| 288 | |
| 289 | reglen = ops->get_regs_len(dev); |
| 290 | if (regs.len > reglen) |
| 291 | regs.len = reglen; |
| 292 | |
| 293 | regbuf = kmalloc(reglen, GFP_USER); |
| 294 | if (!regbuf) |
| 295 | return -ENOMEM; |
| 296 | |
| 297 | ops->get_regs(dev, ®s, regbuf); |
| 298 | |
| 299 | ret = -EFAULT; |
| 300 | if (copy_to_user(useraddr, ®s, sizeof(regs))) |
| 301 | goto out; |
| 302 | useraddr += offsetof(struct ethtool_regs, data); |
| 303 | if (copy_to_user(useraddr, regbuf, regs.len)) |
| 304 | goto out; |
| 305 | ret = 0; |
| 306 | |
| 307 | out: |
| 308 | kfree(regbuf); |
| 309 | return ret; |
| 310 | } |
| 311 | |
| 312 | static int ethtool_get_wol(struct net_device *dev, char __user *useraddr) |
| 313 | { |
| 314 | struct ethtool_wolinfo wol = { ETHTOOL_GWOL }; |
| 315 | |
| 316 | if (!dev->ethtool_ops->get_wol) |
| 317 | return -EOPNOTSUPP; |
| 318 | |
| 319 | dev->ethtool_ops->get_wol(dev, &wol); |
| 320 | |
| 321 | if (copy_to_user(useraddr, &wol, sizeof(wol))) |
| 322 | return -EFAULT; |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) |
| 327 | { |
| 328 | struct ethtool_wolinfo wol; |
| 329 | |
| 330 | if (!dev->ethtool_ops->set_wol) |
| 331 | return -EOPNOTSUPP; |
| 332 | |
| 333 | if (copy_from_user(&wol, useraddr, sizeof(wol))) |
| 334 | return -EFAULT; |
| 335 | |
| 336 | return dev->ethtool_ops->set_wol(dev, &wol); |
| 337 | } |
| 338 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | static int ethtool_nway_reset(struct net_device *dev) |
| 340 | { |
| 341 | if (!dev->ethtool_ops->nway_reset) |
| 342 | return -EOPNOTSUPP; |
| 343 | |
| 344 | return dev->ethtool_ops->nway_reset(dev); |
| 345 | } |
| 346 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr) |
| 348 | { |
| 349 | struct ethtool_eeprom eeprom; |
Stephen Hemminger | 76fd859 | 2006-09-08 11:16:13 -0700 | [diff] [blame] | 350 | const struct ethtool_ops *ops = dev->ethtool_ops; |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 351 | void __user *userbuf = useraddr + sizeof(eeprom); |
| 352 | u32 bytes_remaining; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | u8 *data; |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 354 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
| 356 | if (!ops->get_eeprom || !ops->get_eeprom_len) |
| 357 | return -EOPNOTSUPP; |
| 358 | |
| 359 | if (copy_from_user(&eeprom, useraddr, sizeof(eeprom))) |
| 360 | return -EFAULT; |
| 361 | |
| 362 | /* Check for wrap and zero */ |
| 363 | if (eeprom.offset + eeprom.len <= eeprom.offset) |
| 364 | return -EINVAL; |
| 365 | |
| 366 | /* Check for exceeding total eeprom len */ |
| 367 | if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev)) |
| 368 | return -EINVAL; |
| 369 | |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 370 | data = kmalloc(PAGE_SIZE, GFP_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | if (!data) |
| 372 | return -ENOMEM; |
| 373 | |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 374 | bytes_remaining = eeprom.len; |
| 375 | while (bytes_remaining > 0) { |
| 376 | eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 378 | ret = ops->get_eeprom(dev, &eeprom, data); |
| 379 | if (ret) |
| 380 | break; |
| 381 | if (copy_to_user(userbuf, data, eeprom.len)) { |
| 382 | ret = -EFAULT; |
| 383 | break; |
| 384 | } |
| 385 | userbuf += eeprom.len; |
| 386 | eeprom.offset += eeprom.len; |
| 387 | bytes_remaining -= eeprom.len; |
| 388 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | |
Mandeep Singh Baines | c5835df | 2008-04-24 20:55:56 -0700 | [diff] [blame] | 390 | eeprom.len = userbuf - (useraddr + sizeof(eeprom)); |
| 391 | eeprom.offset -= eeprom.len; |
| 392 | if (copy_to_user(useraddr, &eeprom, sizeof(eeprom))) |
| 393 | ret = -EFAULT; |
| 394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | kfree(data); |
| 396 | return ret; |
| 397 | } |
| 398 | |
| 399 | static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr) |
| 400 | { |
| 401 | struct ethtool_eeprom eeprom; |
Stephen Hemminger | 76fd859 | 2006-09-08 11:16:13 -0700 | [diff] [blame] | 402 | const struct ethtool_ops *ops = dev->ethtool_ops; |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 403 | void __user *userbuf = useraddr + sizeof(eeprom); |
| 404 | u32 bytes_remaining; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | u8 *data; |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 406 | int ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | |
| 408 | if (!ops->set_eeprom || !ops->get_eeprom_len) |
| 409 | return -EOPNOTSUPP; |
| 410 | |
| 411 | if (copy_from_user(&eeprom, useraddr, sizeof(eeprom))) |
| 412 | return -EFAULT; |
| 413 | |
| 414 | /* Check for wrap and zero */ |
| 415 | if (eeprom.offset + eeprom.len <= eeprom.offset) |
| 416 | return -EINVAL; |
| 417 | |
| 418 | /* Check for exceeding total eeprom len */ |
| 419 | if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev)) |
| 420 | return -EINVAL; |
| 421 | |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 422 | data = kmalloc(PAGE_SIZE, GFP_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | if (!data) |
| 424 | return -ENOMEM; |
| 425 | |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 426 | bytes_remaining = eeprom.len; |
| 427 | while (bytes_remaining > 0) { |
| 428 | eeprom.len = min(bytes_remaining, (u32)PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Mandeep Singh Baines | b131dd5 | 2008-04-15 19:24:17 -0700 | [diff] [blame] | 430 | if (copy_from_user(data, userbuf, eeprom.len)) { |
| 431 | ret = -EFAULT; |
| 432 | break; |
| 433 | } |
| 434 | ret = ops->set_eeprom(dev, &eeprom, data); |
| 435 | if (ret) |
| 436 | break; |
| 437 | userbuf += eeprom.len; |
| 438 | eeprom.offset += eeprom.len; |
| 439 | bytes_remaining -= eeprom.len; |
| 440 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | kfree(data); |
| 443 | return ret; |
| 444 | } |
| 445 | |
| 446 | static int ethtool_get_coalesce(struct net_device *dev, void __user *useraddr) |
| 447 | { |
| 448 | struct ethtool_coalesce coalesce = { ETHTOOL_GCOALESCE }; |
| 449 | |
| 450 | if (!dev->ethtool_ops->get_coalesce) |
| 451 | return -EOPNOTSUPP; |
| 452 | |
| 453 | dev->ethtool_ops->get_coalesce(dev, &coalesce); |
| 454 | |
| 455 | if (copy_to_user(useraddr, &coalesce, sizeof(coalesce))) |
| 456 | return -EFAULT; |
| 457 | return 0; |
| 458 | } |
| 459 | |
| 460 | static int ethtool_set_coalesce(struct net_device *dev, void __user *useraddr) |
| 461 | { |
| 462 | struct ethtool_coalesce coalesce; |
| 463 | |
David S. Miller | fa04ae5 | 2005-06-06 15:07:19 -0700 | [diff] [blame] | 464 | if (!dev->ethtool_ops->set_coalesce) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | return -EOPNOTSUPP; |
| 466 | |
| 467 | if (copy_from_user(&coalesce, useraddr, sizeof(coalesce))) |
| 468 | return -EFAULT; |
| 469 | |
| 470 | return dev->ethtool_ops->set_coalesce(dev, &coalesce); |
| 471 | } |
| 472 | |
| 473 | static int ethtool_get_ringparam(struct net_device *dev, void __user *useraddr) |
| 474 | { |
| 475 | struct ethtool_ringparam ringparam = { ETHTOOL_GRINGPARAM }; |
| 476 | |
| 477 | if (!dev->ethtool_ops->get_ringparam) |
| 478 | return -EOPNOTSUPP; |
| 479 | |
| 480 | dev->ethtool_ops->get_ringparam(dev, &ringparam); |
| 481 | |
| 482 | if (copy_to_user(useraddr, &ringparam, sizeof(ringparam))) |
| 483 | return -EFAULT; |
| 484 | return 0; |
| 485 | } |
| 486 | |
| 487 | static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) |
| 488 | { |
| 489 | struct ethtool_ringparam ringparam; |
| 490 | |
| 491 | if (!dev->ethtool_ops->set_ringparam) |
| 492 | return -EOPNOTSUPP; |
| 493 | |
| 494 | if (copy_from_user(&ringparam, useraddr, sizeof(ringparam))) |
| 495 | return -EFAULT; |
| 496 | |
| 497 | return dev->ethtool_ops->set_ringparam(dev, &ringparam); |
| 498 | } |
| 499 | |
| 500 | static int ethtool_get_pauseparam(struct net_device *dev, void __user *useraddr) |
| 501 | { |
| 502 | struct ethtool_pauseparam pauseparam = { ETHTOOL_GPAUSEPARAM }; |
| 503 | |
| 504 | if (!dev->ethtool_ops->get_pauseparam) |
| 505 | return -EOPNOTSUPP; |
| 506 | |
| 507 | dev->ethtool_ops->get_pauseparam(dev, &pauseparam); |
| 508 | |
| 509 | if (copy_to_user(useraddr, &pauseparam, sizeof(pauseparam))) |
| 510 | return -EFAULT; |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr) |
| 515 | { |
| 516 | struct ethtool_pauseparam pauseparam; |
| 517 | |
Jeff Garzik | e1b90c4 | 2006-07-17 12:54:40 -0400 | [diff] [blame] | 518 | if (!dev->ethtool_ops->set_pauseparam) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | return -EOPNOTSUPP; |
| 520 | |
| 521 | if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam))) |
| 522 | return -EFAULT; |
| 523 | |
| 524 | return dev->ethtool_ops->set_pauseparam(dev, &pauseparam); |
| 525 | } |
| 526 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 527 | static int __ethtool_set_sg(struct net_device *dev, u32 data) |
| 528 | { |
| 529 | int err; |
| 530 | |
| 531 | if (!data && dev->ethtool_ops->set_tso) { |
| 532 | err = dev->ethtool_ops->set_tso(dev, 0); |
| 533 | if (err) |
| 534 | return err; |
| 535 | } |
| 536 | |
Ananda Raju | e89e9cf | 2005-10-18 15:46:41 -0700 | [diff] [blame] | 537 | if (!data && dev->ethtool_ops->set_ufo) { |
| 538 | err = dev->ethtool_ops->set_ufo(dev, 0); |
| 539 | if (err) |
| 540 | return err; |
| 541 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | return dev->ethtool_ops->set_sg(dev, data); |
| 543 | } |
| 544 | |
| 545 | static int ethtool_set_tx_csum(struct net_device *dev, char __user *useraddr) |
| 546 | { |
| 547 | struct ethtool_value edata; |
| 548 | int err; |
| 549 | |
| 550 | if (!dev->ethtool_ops->set_tx_csum) |
| 551 | return -EOPNOTSUPP; |
| 552 | |
| 553 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 554 | return -EFAULT; |
| 555 | |
| 556 | if (!edata.data && dev->ethtool_ops->set_sg) { |
| 557 | err = __ethtool_set_sg(dev, 0); |
| 558 | if (err) |
| 559 | return err; |
| 560 | } |
| 561 | |
| 562 | return dev->ethtool_ops->set_tx_csum(dev, edata.data); |
| 563 | } |
| 564 | |
Herbert Xu | b240a0e | 2008-12-15 23:44:31 -0800 | [diff] [blame] | 565 | static int ethtool_set_rx_csum(struct net_device *dev, char __user *useraddr) |
| 566 | { |
| 567 | struct ethtool_value edata; |
| 568 | |
| 569 | if (!dev->ethtool_ops->set_rx_csum) |
| 570 | return -EOPNOTSUPP; |
| 571 | |
| 572 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 573 | return -EFAULT; |
| 574 | |
| 575 | if (!edata.data && dev->ethtool_ops->set_sg) |
| 576 | dev->features &= ~NETIF_F_GRO; |
| 577 | |
| 578 | return dev->ethtool_ops->set_rx_csum(dev, edata.data); |
| 579 | } |
| 580 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | static int ethtool_set_sg(struct net_device *dev, char __user *useraddr) |
| 582 | { |
| 583 | struct ethtool_value edata; |
| 584 | |
| 585 | if (!dev->ethtool_ops->set_sg) |
| 586 | return -EOPNOTSUPP; |
| 587 | |
| 588 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 589 | return -EFAULT; |
| 590 | |
YOSHIFUJI Hideaki | 4ec93ed | 2007-02-09 23:24:36 +0900 | [diff] [blame] | 591 | if (edata.data && |
Herbert Xu | 8648b30 | 2006-06-17 22:06:05 -0700 | [diff] [blame] | 592 | !(dev->features & NETIF_F_ALL_CSUM)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | return -EINVAL; |
| 594 | |
| 595 | return __ethtool_set_sg(dev, edata.data); |
| 596 | } |
| 597 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | static int ethtool_set_tso(struct net_device *dev, char __user *useraddr) |
| 599 | { |
| 600 | struct ethtool_value edata; |
| 601 | |
| 602 | if (!dev->ethtool_ops->set_tso) |
| 603 | return -EOPNOTSUPP; |
| 604 | |
| 605 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 606 | return -EFAULT; |
| 607 | |
| 608 | if (edata.data && !(dev->features & NETIF_F_SG)) |
| 609 | return -EINVAL; |
| 610 | |
| 611 | return dev->ethtool_ops->set_tso(dev, edata.data); |
| 612 | } |
| 613 | |
Ananda Raju | e89e9cf | 2005-10-18 15:46:41 -0700 | [diff] [blame] | 614 | static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr) |
| 615 | { |
| 616 | struct ethtool_value edata; |
| 617 | |
| 618 | if (!dev->ethtool_ops->set_ufo) |
| 619 | return -EOPNOTSUPP; |
| 620 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 621 | return -EFAULT; |
| 622 | if (edata.data && !(dev->features & NETIF_F_SG)) |
| 623 | return -EINVAL; |
| 624 | if (edata.data && !(dev->features & NETIF_F_HW_CSUM)) |
| 625 | return -EINVAL; |
| 626 | return dev->ethtool_ops->set_ufo(dev, edata.data); |
| 627 | } |
| 628 | |
Herbert Xu | 37c3185 | 2006-06-22 03:07:29 -0700 | [diff] [blame] | 629 | static int ethtool_get_gso(struct net_device *dev, char __user *useraddr) |
| 630 | { |
| 631 | struct ethtool_value edata = { ETHTOOL_GGSO }; |
| 632 | |
| 633 | edata.data = dev->features & NETIF_F_GSO; |
| 634 | if (copy_to_user(useraddr, &edata, sizeof(edata))) |
| 635 | return -EFAULT; |
| 636 | return 0; |
| 637 | } |
| 638 | |
| 639 | static int ethtool_set_gso(struct net_device *dev, char __user *useraddr) |
| 640 | { |
| 641 | struct ethtool_value edata; |
| 642 | |
| 643 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 644 | return -EFAULT; |
| 645 | if (edata.data) |
| 646 | dev->features |= NETIF_F_GSO; |
| 647 | else |
| 648 | dev->features &= ~NETIF_F_GSO; |
| 649 | return 0; |
| 650 | } |
| 651 | |
Herbert Xu | b240a0e | 2008-12-15 23:44:31 -0800 | [diff] [blame] | 652 | static int ethtool_get_gro(struct net_device *dev, char __user *useraddr) |
| 653 | { |
| 654 | struct ethtool_value edata = { ETHTOOL_GGRO }; |
| 655 | |
| 656 | edata.data = dev->features & NETIF_F_GRO; |
| 657 | if (copy_to_user(useraddr, &edata, sizeof(edata))) |
| 658 | return -EFAULT; |
| 659 | return 0; |
| 660 | } |
| 661 | |
| 662 | static int ethtool_set_gro(struct net_device *dev, char __user *useraddr) |
| 663 | { |
| 664 | struct ethtool_value edata; |
| 665 | |
| 666 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 667 | return -EFAULT; |
| 668 | |
| 669 | if (edata.data) { |
| 670 | if (!dev->ethtool_ops->get_rx_csum || |
| 671 | !dev->ethtool_ops->get_rx_csum(dev)) |
| 672 | return -EINVAL; |
| 673 | dev->features |= NETIF_F_GRO; |
| 674 | } else |
| 675 | dev->features &= ~NETIF_F_GRO; |
| 676 | |
| 677 | return 0; |
| 678 | } |
| 679 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | static int ethtool_self_test(struct net_device *dev, char __user *useraddr) |
| 681 | { |
| 682 | struct ethtool_test test; |
Stephen Hemminger | 76fd859 | 2006-09-08 11:16:13 -0700 | [diff] [blame] | 683 | const struct ethtool_ops *ops = dev->ethtool_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | u64 *data; |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 685 | int ret, test_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 687 | if (!ops->self_test) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | return -EOPNOTSUPP; |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 689 | if (!ops->get_sset_count && !ops->self_test_count) |
| 690 | return -EOPNOTSUPP; |
| 691 | |
| 692 | if (ops->get_sset_count) |
| 693 | test_len = ops->get_sset_count(dev, ETH_SS_TEST); |
| 694 | else |
| 695 | /* code path for obsolete hook */ |
| 696 | test_len = ops->self_test_count(dev); |
| 697 | if (test_len < 0) |
| 698 | return test_len; |
| 699 | WARN_ON(test_len == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | |
| 701 | if (copy_from_user(&test, useraddr, sizeof(test))) |
| 702 | return -EFAULT; |
| 703 | |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 704 | test.len = test_len; |
| 705 | data = kmalloc(test_len * sizeof(u64), GFP_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | if (!data) |
| 707 | return -ENOMEM; |
| 708 | |
| 709 | ops->self_test(dev, &test, data); |
| 710 | |
| 711 | ret = -EFAULT; |
| 712 | if (copy_to_user(useraddr, &test, sizeof(test))) |
| 713 | goto out; |
| 714 | useraddr += sizeof(test); |
| 715 | if (copy_to_user(useraddr, data, test.len * sizeof(u64))) |
| 716 | goto out; |
| 717 | ret = 0; |
| 718 | |
| 719 | out: |
| 720 | kfree(data); |
| 721 | return ret; |
| 722 | } |
| 723 | |
| 724 | static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) |
| 725 | { |
| 726 | struct ethtool_gstrings gstrings; |
Stephen Hemminger | 76fd859 | 2006-09-08 11:16:13 -0700 | [diff] [blame] | 727 | const struct ethtool_ops *ops = dev->ethtool_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | u8 *data; |
| 729 | int ret; |
| 730 | |
| 731 | if (!ops->get_strings) |
| 732 | return -EOPNOTSUPP; |
| 733 | |
| 734 | if (copy_from_user(&gstrings, useraddr, sizeof(gstrings))) |
| 735 | return -EFAULT; |
| 736 | |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 737 | if (ops->get_sset_count) { |
| 738 | ret = ops->get_sset_count(dev, gstrings.string_set); |
| 739 | if (ret < 0) |
| 740 | return ret; |
| 741 | |
| 742 | gstrings.len = ret; |
| 743 | } else { |
| 744 | /* code path for obsolete hooks */ |
| 745 | |
| 746 | switch (gstrings.string_set) { |
| 747 | case ETH_SS_TEST: |
| 748 | if (!ops->self_test_count) |
| 749 | return -EOPNOTSUPP; |
| 750 | gstrings.len = ops->self_test_count(dev); |
| 751 | break; |
| 752 | case ETH_SS_STATS: |
| 753 | if (!ops->get_stats_count) |
| 754 | return -EOPNOTSUPP; |
| 755 | gstrings.len = ops->get_stats_count(dev); |
| 756 | break; |
| 757 | default: |
| 758 | return -EINVAL; |
| 759 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | } |
| 761 | |
| 762 | data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER); |
| 763 | if (!data) |
| 764 | return -ENOMEM; |
| 765 | |
| 766 | ops->get_strings(dev, gstrings.string_set, data); |
| 767 | |
| 768 | ret = -EFAULT; |
| 769 | if (copy_to_user(useraddr, &gstrings, sizeof(gstrings))) |
| 770 | goto out; |
| 771 | useraddr += sizeof(gstrings); |
| 772 | if (copy_to_user(useraddr, data, gstrings.len * ETH_GSTRING_LEN)) |
| 773 | goto out; |
| 774 | ret = 0; |
| 775 | |
| 776 | out: |
| 777 | kfree(data); |
| 778 | return ret; |
| 779 | } |
| 780 | |
| 781 | static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) |
| 782 | { |
| 783 | struct ethtool_value id; |
| 784 | |
| 785 | if (!dev->ethtool_ops->phys_id) |
| 786 | return -EOPNOTSUPP; |
| 787 | |
| 788 | if (copy_from_user(&id, useraddr, sizeof(id))) |
| 789 | return -EFAULT; |
| 790 | |
| 791 | return dev->ethtool_ops->phys_id(dev, id.data); |
| 792 | } |
| 793 | |
| 794 | static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) |
| 795 | { |
| 796 | struct ethtool_stats stats; |
Stephen Hemminger | 76fd859 | 2006-09-08 11:16:13 -0700 | [diff] [blame] | 797 | const struct ethtool_ops *ops = dev->ethtool_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | u64 *data; |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 799 | int ret, n_stats; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 801 | if (!ops->get_ethtool_stats) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | return -EOPNOTSUPP; |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 803 | if (!ops->get_sset_count && !ops->get_stats_count) |
| 804 | return -EOPNOTSUPP; |
| 805 | |
| 806 | if (ops->get_sset_count) |
| 807 | n_stats = ops->get_sset_count(dev, ETH_SS_STATS); |
| 808 | else |
| 809 | /* code path for obsolete hook */ |
| 810 | n_stats = ops->get_stats_count(dev); |
| 811 | if (n_stats < 0) |
| 812 | return n_stats; |
| 813 | WARN_ON(n_stats == 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 814 | |
| 815 | if (copy_from_user(&stats, useraddr, sizeof(stats))) |
| 816 | return -EFAULT; |
| 817 | |
Jeff Garzik | ff03d49 | 2007-08-15 16:01:08 -0700 | [diff] [blame] | 818 | stats.n_stats = n_stats; |
| 819 | data = kmalloc(n_stats * sizeof(u64), GFP_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | if (!data) |
| 821 | return -ENOMEM; |
| 822 | |
| 823 | ops->get_ethtool_stats(dev, &stats, data); |
| 824 | |
| 825 | ret = -EFAULT; |
| 826 | if (copy_to_user(useraddr, &stats, sizeof(stats))) |
| 827 | goto out; |
| 828 | useraddr += sizeof(stats); |
| 829 | if (copy_to_user(useraddr, data, stats.n_stats * sizeof(u64))) |
| 830 | goto out; |
| 831 | ret = 0; |
| 832 | |
| 833 | out: |
| 834 | kfree(data); |
| 835 | return ret; |
| 836 | } |
| 837 | |
viro@ftp.linux.org.uk | 0bf0519d | 2005-09-05 03:26:18 +0100 | [diff] [blame] | 838 | static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr) |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 839 | { |
| 840 | struct ethtool_perm_addr epaddr; |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 841 | |
Matthew Wilcox | 313674a | 2007-07-31 14:00:29 -0700 | [diff] [blame] | 842 | if (copy_from_user(&epaddr, useraddr, sizeof(epaddr))) |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 843 | return -EFAULT; |
| 844 | |
Matthew Wilcox | 313674a | 2007-07-31 14:00:29 -0700 | [diff] [blame] | 845 | if (epaddr.size < dev->addr_len) |
| 846 | return -ETOOSMALL; |
| 847 | epaddr.size = dev->addr_len; |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 848 | |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 849 | if (copy_to_user(useraddr, &epaddr, sizeof(epaddr))) |
Matthew Wilcox | 313674a | 2007-07-31 14:00:29 -0700 | [diff] [blame] | 850 | return -EFAULT; |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 851 | useraddr += sizeof(epaddr); |
Matthew Wilcox | 313674a | 2007-07-31 14:00:29 -0700 | [diff] [blame] | 852 | if (copy_to_user(useraddr, dev->perm_addr, epaddr.size)) |
| 853 | return -EFAULT; |
| 854 | return 0; |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 855 | } |
| 856 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 857 | static int ethtool_get_value(struct net_device *dev, char __user *useraddr, |
| 858 | u32 cmd, u32 (*actor)(struct net_device *)) |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 859 | { |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 860 | struct ethtool_value edata = { cmd }; |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 861 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 862 | if (!actor) |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 863 | return -EOPNOTSUPP; |
| 864 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 865 | edata.data = actor(dev); |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 866 | |
| 867 | if (copy_to_user(useraddr, &edata, sizeof(edata))) |
| 868 | return -EFAULT; |
| 869 | return 0; |
| 870 | } |
| 871 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 872 | static int ethtool_set_value_void(struct net_device *dev, char __user *useraddr, |
| 873 | void (*actor)(struct net_device *, u32)) |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 874 | { |
| 875 | struct ethtool_value edata; |
| 876 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 877 | if (!actor) |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 878 | return -EOPNOTSUPP; |
| 879 | |
| 880 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 881 | return -EFAULT; |
| 882 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 883 | actor(dev, edata.data); |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 884 | return 0; |
| 885 | } |
| 886 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 887 | static int ethtool_set_value(struct net_device *dev, char __user *useraddr, |
| 888 | int (*actor)(struct net_device *, u32)) |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 889 | { |
| 890 | struct ethtool_value edata; |
| 891 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 892 | if (!actor) |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 893 | return -EOPNOTSUPP; |
| 894 | |
| 895 | if (copy_from_user(&edata, useraddr, sizeof(edata))) |
| 896 | return -EFAULT; |
| 897 | |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 898 | return actor(dev, edata.data); |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 899 | } |
| 900 | |
Ajit Khaparde | 05c6a8d | 2009-09-02 17:02:55 +0000 | [diff] [blame] | 901 | static int ethtool_flash_device(struct net_device *dev, char __user *useraddr) |
| 902 | { |
| 903 | struct ethtool_flash efl; |
| 904 | |
| 905 | if (copy_from_user(&efl, useraddr, sizeof(efl))) |
| 906 | return -EFAULT; |
| 907 | |
| 908 | if (!dev->ethtool_ops->flash_device) |
| 909 | return -EOPNOTSUPP; |
| 910 | |
| 911 | return dev->ethtool_ops->flash_device(dev, &efl); |
| 912 | } |
| 913 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | /* The main entry point in this file. Called from net/core/dev.c */ |
| 915 | |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 916 | int dev_ethtool(struct net *net, struct ifreq *ifr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | { |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 918 | struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | void __user *useraddr = ifr->ifr_data; |
| 920 | u32 ethcmd; |
| 921 | int rc; |
Stephen Hemminger | 81e8157 | 2005-05-29 14:14:35 -0700 | [diff] [blame] | 922 | unsigned long old_features; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | if (!dev || !netif_device_present(dev)) |
| 925 | return -ENODEV; |
| 926 | |
| 927 | if (!dev->ethtool_ops) |
Matthew Wilcox | 61a44b9 | 2007-07-31 14:00:02 -0700 | [diff] [blame] | 928 | return -EOPNOTSUPP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | |
| 930 | if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd))) |
| 931 | return -EFAULT; |
| 932 | |
Stephen Hemminger | 75f3123 | 2006-09-28 15:13:37 -0700 | [diff] [blame] | 933 | /* Allow some commands to be done by anyone */ |
| 934 | switch(ethcmd) { |
Stephen Hemminger | 75f3123 | 2006-09-28 15:13:37 -0700 | [diff] [blame] | 935 | case ETHTOOL_GDRVINFO: |
Stephen Hemminger | 75f3123 | 2006-09-28 15:13:37 -0700 | [diff] [blame] | 936 | case ETHTOOL_GMSGLVL: |
Stephen Hemminger | 75f3123 | 2006-09-28 15:13:37 -0700 | [diff] [blame] | 937 | case ETHTOOL_GCOALESCE: |
| 938 | case ETHTOOL_GRINGPARAM: |
| 939 | case ETHTOOL_GPAUSEPARAM: |
| 940 | case ETHTOOL_GRXCSUM: |
| 941 | case ETHTOOL_GTXCSUM: |
| 942 | case ETHTOOL_GSG: |
| 943 | case ETHTOOL_GSTRINGS: |
Stephen Hemminger | 75f3123 | 2006-09-28 15:13:37 -0700 | [diff] [blame] | 944 | case ETHTOOL_GTSO: |
| 945 | case ETHTOOL_GPERMADDR: |
| 946 | case ETHTOOL_GUFO: |
| 947 | case ETHTOOL_GGSO: |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 948 | case ETHTOOL_GFLAGS: |
| 949 | case ETHTOOL_GPFLAGS: |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 950 | case ETHTOOL_GRXFH: |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 951 | case ETHTOOL_GRXRINGS: |
| 952 | case ETHTOOL_GRXCLSRLCNT: |
| 953 | case ETHTOOL_GRXCLSRULE: |
| 954 | case ETHTOOL_GRXCLSRLALL: |
Stephen Hemminger | 75f3123 | 2006-09-28 15:13:37 -0700 | [diff] [blame] | 955 | break; |
| 956 | default: |
| 957 | if (!capable(CAP_NET_ADMIN)) |
| 958 | return -EPERM; |
| 959 | } |
| 960 | |
Stephen Hemminger | e71a478 | 2007-04-10 20:10:33 -0700 | [diff] [blame] | 961 | if (dev->ethtool_ops->begin) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | if ((rc = dev->ethtool_ops->begin(dev)) < 0) |
| 963 | return rc; |
| 964 | |
Stephen Hemminger | d8a33ac | 2005-05-29 14:13:47 -0700 | [diff] [blame] | 965 | old_features = dev->features; |
| 966 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | switch (ethcmd) { |
| 968 | case ETHTOOL_GSET: |
| 969 | rc = ethtool_get_settings(dev, useraddr); |
| 970 | break; |
| 971 | case ETHTOOL_SSET: |
| 972 | rc = ethtool_set_settings(dev, useraddr); |
| 973 | break; |
| 974 | case ETHTOOL_GDRVINFO: |
| 975 | rc = ethtool_get_drvinfo(dev, useraddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | break; |
| 977 | case ETHTOOL_GREGS: |
| 978 | rc = ethtool_get_regs(dev, useraddr); |
| 979 | break; |
| 980 | case ETHTOOL_GWOL: |
| 981 | rc = ethtool_get_wol(dev, useraddr); |
| 982 | break; |
| 983 | case ETHTOOL_SWOL: |
| 984 | rc = ethtool_set_wol(dev, useraddr); |
| 985 | break; |
| 986 | case ETHTOOL_GMSGLVL: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 987 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
| 988 | dev->ethtool_ops->get_msglevel); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | break; |
| 990 | case ETHTOOL_SMSGLVL: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 991 | rc = ethtool_set_value_void(dev, useraddr, |
| 992 | dev->ethtool_ops->set_msglevel); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | break; |
| 994 | case ETHTOOL_NWAY_RST: |
| 995 | rc = ethtool_nway_reset(dev); |
| 996 | break; |
| 997 | case ETHTOOL_GLINK: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 998 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
| 999 | dev->ethtool_ops->get_link); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | break; |
| 1001 | case ETHTOOL_GEEPROM: |
| 1002 | rc = ethtool_get_eeprom(dev, useraddr); |
| 1003 | break; |
| 1004 | case ETHTOOL_SEEPROM: |
| 1005 | rc = ethtool_set_eeprom(dev, useraddr); |
| 1006 | break; |
| 1007 | case ETHTOOL_GCOALESCE: |
| 1008 | rc = ethtool_get_coalesce(dev, useraddr); |
| 1009 | break; |
| 1010 | case ETHTOOL_SCOALESCE: |
| 1011 | rc = ethtool_set_coalesce(dev, useraddr); |
| 1012 | break; |
| 1013 | case ETHTOOL_GRINGPARAM: |
| 1014 | rc = ethtool_get_ringparam(dev, useraddr); |
| 1015 | break; |
| 1016 | case ETHTOOL_SRINGPARAM: |
| 1017 | rc = ethtool_set_ringparam(dev, useraddr); |
| 1018 | break; |
| 1019 | case ETHTOOL_GPAUSEPARAM: |
| 1020 | rc = ethtool_get_pauseparam(dev, useraddr); |
| 1021 | break; |
| 1022 | case ETHTOOL_SPAUSEPARAM: |
| 1023 | rc = ethtool_set_pauseparam(dev, useraddr); |
| 1024 | break; |
| 1025 | case ETHTOOL_GRXCSUM: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1026 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
Sridhar Samudrala | 1896e61 | 2009-07-22 13:38:22 +0000 | [diff] [blame] | 1027 | (dev->ethtool_ops->get_rx_csum ? |
| 1028 | dev->ethtool_ops->get_rx_csum : |
| 1029 | ethtool_op_get_rx_csum)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | break; |
| 1031 | case ETHTOOL_SRXCSUM: |
Herbert Xu | b240a0e | 2008-12-15 23:44:31 -0800 | [diff] [blame] | 1032 | rc = ethtool_set_rx_csum(dev, useraddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | break; |
| 1034 | case ETHTOOL_GTXCSUM: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1035 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
Jeff Garzik | 88d3aaf | 2007-09-15 14:41:06 -0700 | [diff] [blame] | 1036 | (dev->ethtool_ops->get_tx_csum ? |
| 1037 | dev->ethtool_ops->get_tx_csum : |
| 1038 | ethtool_op_get_tx_csum)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | break; |
| 1040 | case ETHTOOL_STXCSUM: |
| 1041 | rc = ethtool_set_tx_csum(dev, useraddr); |
| 1042 | break; |
| 1043 | case ETHTOOL_GSG: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1044 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
Jeff Garzik | 88d3aaf | 2007-09-15 14:41:06 -0700 | [diff] [blame] | 1045 | (dev->ethtool_ops->get_sg ? |
| 1046 | dev->ethtool_ops->get_sg : |
| 1047 | ethtool_op_get_sg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | break; |
| 1049 | case ETHTOOL_SSG: |
| 1050 | rc = ethtool_set_sg(dev, useraddr); |
| 1051 | break; |
| 1052 | case ETHTOOL_GTSO: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1053 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
Jeff Garzik | 88d3aaf | 2007-09-15 14:41:06 -0700 | [diff] [blame] | 1054 | (dev->ethtool_ops->get_tso ? |
| 1055 | dev->ethtool_ops->get_tso : |
| 1056 | ethtool_op_get_tso)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | break; |
| 1058 | case ETHTOOL_STSO: |
| 1059 | rc = ethtool_set_tso(dev, useraddr); |
| 1060 | break; |
| 1061 | case ETHTOOL_TEST: |
| 1062 | rc = ethtool_self_test(dev, useraddr); |
| 1063 | break; |
| 1064 | case ETHTOOL_GSTRINGS: |
| 1065 | rc = ethtool_get_strings(dev, useraddr); |
| 1066 | break; |
| 1067 | case ETHTOOL_PHYS_ID: |
| 1068 | rc = ethtool_phys_id(dev, useraddr); |
| 1069 | break; |
| 1070 | case ETHTOOL_GSTATS: |
| 1071 | rc = ethtool_get_stats(dev, useraddr); |
| 1072 | break; |
Jon Wetzel | a6f9a70 | 2005-08-20 17:15:54 -0700 | [diff] [blame] | 1073 | case ETHTOOL_GPERMADDR: |
| 1074 | rc = ethtool_get_perm_addr(dev, useraddr); |
| 1075 | break; |
Ananda Raju | e89e9cf | 2005-10-18 15:46:41 -0700 | [diff] [blame] | 1076 | case ETHTOOL_GUFO: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1077 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
Jeff Garzik | 88d3aaf | 2007-09-15 14:41:06 -0700 | [diff] [blame] | 1078 | (dev->ethtool_ops->get_ufo ? |
| 1079 | dev->ethtool_ops->get_ufo : |
| 1080 | ethtool_op_get_ufo)); |
Ananda Raju | e89e9cf | 2005-10-18 15:46:41 -0700 | [diff] [blame] | 1081 | break; |
| 1082 | case ETHTOOL_SUFO: |
| 1083 | rc = ethtool_set_ufo(dev, useraddr); |
| 1084 | break; |
Herbert Xu | 37c3185 | 2006-06-22 03:07:29 -0700 | [diff] [blame] | 1085 | case ETHTOOL_GGSO: |
| 1086 | rc = ethtool_get_gso(dev, useraddr); |
| 1087 | break; |
| 1088 | case ETHTOOL_SGSO: |
| 1089 | rc = ethtool_set_gso(dev, useraddr); |
| 1090 | break; |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 1091 | case ETHTOOL_GFLAGS: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1092 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
Sridhar Samudrala | 1896e61 | 2009-07-22 13:38:22 +0000 | [diff] [blame] | 1093 | (dev->ethtool_ops->get_flags ? |
| 1094 | dev->ethtool_ops->get_flags : |
| 1095 | ethtool_op_get_flags)); |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 1096 | break; |
| 1097 | case ETHTOOL_SFLAGS: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1098 | rc = ethtool_set_value(dev, useraddr, |
| 1099 | dev->ethtool_ops->set_flags); |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 1100 | break; |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 1101 | case ETHTOOL_GPFLAGS: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1102 | rc = ethtool_get_value(dev, useraddr, ethcmd, |
| 1103 | dev->ethtool_ops->get_priv_flags); |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 1104 | break; |
| 1105 | case ETHTOOL_SPFLAGS: |
Jeff Garzik | 13c99b2 | 2007-08-15 16:01:56 -0700 | [diff] [blame] | 1106 | rc = ethtool_set_value(dev, useraddr, |
| 1107 | dev->ethtool_ops->set_priv_flags); |
Jeff Garzik | 339bf02 | 2007-08-15 16:01:32 -0700 | [diff] [blame] | 1108 | break; |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 1109 | case ETHTOOL_GRXFH: |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 1110 | case ETHTOOL_GRXRINGS: |
| 1111 | case ETHTOOL_GRXCLSRLCNT: |
| 1112 | case ETHTOOL_GRXCLSRULE: |
| 1113 | case ETHTOOL_GRXCLSRLALL: |
| 1114 | rc = ethtool_get_rxnfc(dev, useraddr); |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 1115 | break; |
| 1116 | case ETHTOOL_SRXFH: |
Santwona Behera | 59089d8 | 2009-02-20 00:58:13 -0800 | [diff] [blame] | 1117 | case ETHTOOL_SRXCLSRLDEL: |
| 1118 | case ETHTOOL_SRXCLSRLINS: |
| 1119 | rc = ethtool_set_rxnfc(dev, useraddr); |
Santwona Behera | 0853ad6 | 2008-07-02 03:47:41 -0700 | [diff] [blame] | 1120 | break; |
Herbert Xu | b240a0e | 2008-12-15 23:44:31 -0800 | [diff] [blame] | 1121 | case ETHTOOL_GGRO: |
| 1122 | rc = ethtool_get_gro(dev, useraddr); |
| 1123 | break; |
| 1124 | case ETHTOOL_SGRO: |
| 1125 | rc = ethtool_set_gro(dev, useraddr); |
| 1126 | break; |
Ajit Khaparde | 05c6a8d | 2009-09-02 17:02:55 +0000 | [diff] [blame] | 1127 | case ETHTOOL_FLASHDEV: |
| 1128 | rc = ethtool_flash_device(dev, useraddr); |
| 1129 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1130 | default: |
Matthew Wilcox | 61a44b9 | 2007-07-31 14:00:02 -0700 | [diff] [blame] | 1131 | rc = -EOPNOTSUPP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1132 | } |
YOSHIFUJI Hideaki | 4ec93ed | 2007-02-09 23:24:36 +0900 | [diff] [blame] | 1133 | |
Stephen Hemminger | e71a478 | 2007-04-10 20:10:33 -0700 | [diff] [blame] | 1134 | if (dev->ethtool_ops->complete) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | dev->ethtool_ops->complete(dev); |
Stephen Hemminger | d8a33ac | 2005-05-29 14:13:47 -0700 | [diff] [blame] | 1136 | |
| 1137 | if (old_features != dev->features) |
| 1138 | netdev_features_change(dev); |
| 1139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | EXPORT_SYMBOL(ethtool_op_get_link); |
| 1144 | EXPORT_SYMBOL(ethtool_op_get_sg); |
| 1145 | EXPORT_SYMBOL(ethtool_op_get_tso); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | EXPORT_SYMBOL(ethtool_op_set_sg); |
| 1147 | EXPORT_SYMBOL(ethtool_op_set_tso); |
| 1148 | EXPORT_SYMBOL(ethtool_op_set_tx_csum); |
Jon Mason | 69f6a0f | 2005-05-29 20:27:24 -0700 | [diff] [blame] | 1149 | EXPORT_SYMBOL(ethtool_op_set_tx_hw_csum); |
Michael Chan | 6460d94 | 2007-07-14 19:07:52 -0700 | [diff] [blame] | 1150 | EXPORT_SYMBOL(ethtool_op_set_tx_ipv6_csum); |
Ananda Raju | e89e9cf | 2005-10-18 15:46:41 -0700 | [diff] [blame] | 1151 | EXPORT_SYMBOL(ethtool_op_set_ufo); |
| 1152 | EXPORT_SYMBOL(ethtool_op_get_ufo); |
Jeff Garzik | 3ae7c0b | 2007-08-15 16:00:51 -0700 | [diff] [blame] | 1153 | EXPORT_SYMBOL(ethtool_op_set_flags); |
| 1154 | EXPORT_SYMBOL(ethtool_op_get_flags); |