diff options
author | Stuart Hodgson <smhodgson@solarflare.com> | 2012-04-19 04:44:42 -0400 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2012-05-09 21:22:17 -0400 |
commit | 41c3cb6d20f0252308e9796fa4f3dacb4960de91 (patch) | |
tree | cc816536a6cc0b5c6e971a2b8b0828e1ee9f43b9 /net/core/ethtool.c | |
parent | 081d094eaab894ae5a517fde56179dfe67773ff0 (diff) |
ethtool: Extend the ethtool API to obtain plugin module eeprom data
ETHTOOL_GMODULEINFO returns a new struct ethtool_modinfo that will return the
type and size of plug-in module eeprom (such as SFP+) for parsing
by userland program.
ETHTOOL_GMODULEEEPROM returns the raw eeprom information
using the existing ethtool_eeprom structture to return the data
Signed-off-by: Stuart Hodgson <smhodgson@solarflare.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'net/core/ethtool.c')
-rw-r--r-- | net/core/ethtool.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index ca7698fd24d4..9c2afb480270 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -1335,6 +1335,47 @@ static int ethtool_get_ts_info(struct net_device *dev, void __user *useraddr) | |||
1335 | return err; | 1335 | return err; |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | static int ethtool_get_module_info(struct net_device *dev, | ||
1339 | void __user *useraddr) | ||
1340 | { | ||
1341 | int ret; | ||
1342 | struct ethtool_modinfo modinfo; | ||
1343 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
1344 | |||
1345 | if (!ops->get_module_info) | ||
1346 | return -EOPNOTSUPP; | ||
1347 | |||
1348 | if (copy_from_user(&modinfo, useraddr, sizeof(modinfo))) | ||
1349 | return -EFAULT; | ||
1350 | |||
1351 | ret = ops->get_module_info(dev, &modinfo); | ||
1352 | if (ret) | ||
1353 | return ret; | ||
1354 | |||
1355 | if (copy_to_user(useraddr, &modinfo, sizeof(modinfo))) | ||
1356 | return -EFAULT; | ||
1357 | |||
1358 | return 0; | ||
1359 | } | ||
1360 | |||
1361 | static int ethtool_get_module_eeprom(struct net_device *dev, | ||
1362 | void __user *useraddr) | ||
1363 | { | ||
1364 | int ret; | ||
1365 | struct ethtool_modinfo modinfo; | ||
1366 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
1367 | |||
1368 | if (!ops->get_module_info || !ops->get_module_eeprom) | ||
1369 | return -EOPNOTSUPP; | ||
1370 | |||
1371 | ret = ops->get_module_info(dev, &modinfo); | ||
1372 | if (ret) | ||
1373 | return ret; | ||
1374 | |||
1375 | return ethtool_get_any_eeprom(dev, useraddr, ops->get_module_eeprom, | ||
1376 | modinfo.eeprom_len); | ||
1377 | } | ||
1378 | |||
1338 | /* The main entry point in this file. Called from net/core/dev.c */ | 1379 | /* The main entry point in this file. Called from net/core/dev.c */ |
1339 | 1380 | ||
1340 | int dev_ethtool(struct net *net, struct ifreq *ifr) | 1381 | int dev_ethtool(struct net *net, struct ifreq *ifr) |
@@ -1559,6 +1600,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) | |||
1559 | case ETHTOOL_GET_TS_INFO: | 1600 | case ETHTOOL_GET_TS_INFO: |
1560 | rc = ethtool_get_ts_info(dev, useraddr); | 1601 | rc = ethtool_get_ts_info(dev, useraddr); |
1561 | break; | 1602 | break; |
1603 | case ETHTOOL_GMODULEINFO: | ||
1604 | rc = ethtool_get_module_info(dev, useraddr); | ||
1605 | break; | ||
1606 | case ETHTOOL_GMODULEEEPROM: | ||
1607 | rc = ethtool_get_module_eeprom(dev, useraddr); | ||
1608 | break; | ||
1562 | default: | 1609 | default: |
1563 | rc = -EOPNOTSUPP; | 1610 | rc = -EOPNOTSUPP; |
1564 | } | 1611 | } |