diff options
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 | } |