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