diff options
Diffstat (limited to 'net/core/ethtool.c')
-rw-r--r-- | net/core/ethtool.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index a8705432e4b1..3e9b2c3e30f0 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
@@ -77,6 +77,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] | |||
77 | [NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation", | 77 | [NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation", |
78 | [NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation", | 78 | [NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation", |
79 | [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation", | 79 | [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation", |
80 | [NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation", | ||
80 | 81 | ||
81 | [NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc", | 82 | [NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc", |
82 | [NETIF_F_SCTP_CSUM_BIT] = "tx-checksum-sctp", | 83 | [NETIF_F_SCTP_CSUM_BIT] = "tx-checksum-sctp", |
@@ -175,7 +176,7 @@ static int __ethtool_get_sset_count(struct net_device *dev, int sset) | |||
175 | if (sset == ETH_SS_FEATURES) | 176 | if (sset == ETH_SS_FEATURES) |
176 | return ARRAY_SIZE(netdev_features_strings); | 177 | return ARRAY_SIZE(netdev_features_strings); |
177 | 178 | ||
178 | if (ops && ops->get_sset_count && ops->get_strings) | 179 | if (ops->get_sset_count && ops->get_strings) |
179 | return ops->get_sset_count(dev, sset); | 180 | return ops->get_sset_count(dev, sset); |
180 | else | 181 | else |
181 | return -EOPNOTSUPP; | 182 | return -EOPNOTSUPP; |
@@ -311,7 +312,7 @@ int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
311 | { | 312 | { |
312 | ASSERT_RTNL(); | 313 | ASSERT_RTNL(); |
313 | 314 | ||
314 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings) | 315 | if (!dev->ethtool_ops->get_settings) |
315 | return -EOPNOTSUPP; | 316 | return -EOPNOTSUPP; |
316 | 317 | ||
317 | memset(cmd, 0, sizeof(struct ethtool_cmd)); | 318 | memset(cmd, 0, sizeof(struct ethtool_cmd)); |
@@ -355,7 +356,7 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, | |||
355 | 356 | ||
356 | memset(&info, 0, sizeof(info)); | 357 | memset(&info, 0, sizeof(info)); |
357 | info.cmd = ETHTOOL_GDRVINFO; | 358 | info.cmd = ETHTOOL_GDRVINFO; |
358 | if (ops && ops->get_drvinfo) { | 359 | if (ops->get_drvinfo) { |
359 | ops->get_drvinfo(dev, &info); | 360 | ops->get_drvinfo(dev, &info); |
360 | } else if (dev->dev.parent && dev->dev.parent->driver) { | 361 | } else if (dev->dev.parent && dev->dev.parent->driver) { |
361 | strlcpy(info.bus_info, dev_name(dev->dev.parent), | 362 | strlcpy(info.bus_info, dev_name(dev->dev.parent), |
@@ -370,7 +371,7 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, | |||
370 | * this method of obtaining string set info is deprecated; | 371 | * this method of obtaining string set info is deprecated; |
371 | * Use ETHTOOL_GSSET_INFO instead. | 372 | * Use ETHTOOL_GSSET_INFO instead. |
372 | */ | 373 | */ |
373 | if (ops && ops->get_sset_count) { | 374 | if (ops->get_sset_count) { |
374 | int rc; | 375 | int rc; |
375 | 376 | ||
376 | rc = ops->get_sset_count(dev, ETH_SS_TEST); | 377 | rc = ops->get_sset_count(dev, ETH_SS_TEST); |
@@ -383,9 +384,9 @@ static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev, | |||
383 | if (rc >= 0) | 384 | if (rc >= 0) |
384 | info.n_priv_flags = rc; | 385 | info.n_priv_flags = rc; |
385 | } | 386 | } |
386 | if (ops && ops->get_regs_len) | 387 | if (ops->get_regs_len) |
387 | info.regdump_len = ops->get_regs_len(dev); | 388 | info.regdump_len = ops->get_regs_len(dev); |
388 | if (ops && ops->get_eeprom_len) | 389 | if (ops->get_eeprom_len) |
389 | info.eedump_len = ops->get_eeprom_len(dev); | 390 | info.eedump_len = ops->get_eeprom_len(dev); |
390 | 391 | ||
391 | if (copy_to_user(useraddr, &info, sizeof(info))) | 392 | if (copy_to_user(useraddr, &info, sizeof(info))) |
@@ -590,13 +591,14 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev, | |||
590 | struct ethtool_rxnfc rx_rings; | 591 | struct ethtool_rxnfc rx_rings; |
591 | u32 user_size, dev_size, i; | 592 | u32 user_size, dev_size, i; |
592 | u32 *indir; | 593 | u32 *indir; |
594 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
593 | int ret; | 595 | int ret; |
594 | 596 | ||
595 | if (!dev->ethtool_ops->get_rxfh_indir_size || | 597 | if (!ops->get_rxfh_indir_size || !ops->set_rxfh_indir || |
596 | !dev->ethtool_ops->set_rxfh_indir || | 598 | !ops->get_rxnfc) |
597 | !dev->ethtool_ops->get_rxnfc) | ||
598 | return -EOPNOTSUPP; | 599 | return -EOPNOTSUPP; |
599 | dev_size = dev->ethtool_ops->get_rxfh_indir_size(dev); | 600 | |
601 | dev_size = ops->get_rxfh_indir_size(dev); | ||
600 | if (dev_size == 0) | 602 | if (dev_size == 0) |
601 | return -EOPNOTSUPP; | 603 | return -EOPNOTSUPP; |
602 | 604 | ||
@@ -613,7 +615,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev, | |||
613 | return -ENOMEM; | 615 | return -ENOMEM; |
614 | 616 | ||
615 | rx_rings.cmd = ETHTOOL_GRXRINGS; | 617 | rx_rings.cmd = ETHTOOL_GRXRINGS; |
616 | ret = dev->ethtool_ops->get_rxnfc(dev, &rx_rings, NULL); | 618 | ret = ops->get_rxnfc(dev, &rx_rings, NULL); |
617 | if (ret) | 619 | if (ret) |
618 | goto out; | 620 | goto out; |
619 | 621 | ||
@@ -639,7 +641,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev, | |||
639 | } | 641 | } |
640 | } | 642 | } |
641 | 643 | ||
642 | ret = dev->ethtool_ops->set_rxfh_indir(dev, indir); | 644 | ret = ops->set_rxfh_indir(dev, indir); |
643 | 645 | ||
644 | out: | 646 | out: |
645 | kfree(indir); | 647 | kfree(indir); |
@@ -1082,9 +1084,10 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |||
1082 | { | 1084 | { |
1083 | struct ethtool_value id; | 1085 | struct ethtool_value id; |
1084 | static bool busy; | 1086 | static bool busy; |
1087 | const struct ethtool_ops *ops = dev->ethtool_ops; | ||
1085 | int rc; | 1088 | int rc; |
1086 | 1089 | ||
1087 | if (!dev->ethtool_ops->set_phys_id) | 1090 | if (!ops->set_phys_id) |
1088 | return -EOPNOTSUPP; | 1091 | return -EOPNOTSUPP; |
1089 | 1092 | ||
1090 | if (busy) | 1093 | if (busy) |
@@ -1093,7 +1096,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |||
1093 | if (copy_from_user(&id, useraddr, sizeof(id))) | 1096 | if (copy_from_user(&id, useraddr, sizeof(id))) |
1094 | return -EFAULT; | 1097 | return -EFAULT; |
1095 | 1098 | ||
1096 | rc = dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE); | 1099 | rc = ops->set_phys_id(dev, ETHTOOL_ID_ACTIVE); |
1097 | if (rc < 0) | 1100 | if (rc < 0) |
1098 | return rc; | 1101 | return rc; |
1099 | 1102 | ||
@@ -1118,7 +1121,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |||
1118 | i = n; | 1121 | i = n; |
1119 | do { | 1122 | do { |
1120 | rtnl_lock(); | 1123 | rtnl_lock(); |
1121 | rc = dev->ethtool_ops->set_phys_id(dev, | 1124 | rc = ops->set_phys_id(dev, |
1122 | (i & 1) ? ETHTOOL_ID_OFF : ETHTOOL_ID_ON); | 1125 | (i & 1) ? ETHTOOL_ID_OFF : ETHTOOL_ID_ON); |
1123 | rtnl_unlock(); | 1126 | rtnl_unlock(); |
1124 | if (rc) | 1127 | if (rc) |
@@ -1133,7 +1136,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) | |||
1133 | dev_put(dev); | 1136 | dev_put(dev); |
1134 | busy = false; | 1137 | busy = false; |
1135 | 1138 | ||
1136 | (void)dev->ethtool_ops->set_phys_id(dev, ETHTOOL_ID_INACTIVE); | 1139 | (void) ops->set_phys_id(dev, ETHTOOL_ID_INACTIVE); |
1137 | return rc; | 1140 | return rc; |
1138 | } | 1141 | } |
1139 | 1142 | ||
@@ -1275,7 +1278,7 @@ static int ethtool_get_dump_flag(struct net_device *dev, | |||
1275 | struct ethtool_dump dump; | 1278 | struct ethtool_dump dump; |
1276 | const struct ethtool_ops *ops = dev->ethtool_ops; | 1279 | const struct ethtool_ops *ops = dev->ethtool_ops; |
1277 | 1280 | ||
1278 | if (!dev->ethtool_ops->get_dump_flag) | 1281 | if (!ops->get_dump_flag) |
1279 | return -EOPNOTSUPP; | 1282 | return -EOPNOTSUPP; |
1280 | 1283 | ||
1281 | if (copy_from_user(&dump, useraddr, sizeof(dump))) | 1284 | if (copy_from_user(&dump, useraddr, sizeof(dump))) |
@@ -1299,8 +1302,7 @@ static int ethtool_get_dump_data(struct net_device *dev, | |||
1299 | const struct ethtool_ops *ops = dev->ethtool_ops; | 1302 | const struct ethtool_ops *ops = dev->ethtool_ops; |
1300 | void *data = NULL; | 1303 | void *data = NULL; |
1301 | 1304 | ||
1302 | if (!dev->ethtool_ops->get_dump_data || | 1305 | if (!ops->get_dump_data || !ops->get_dump_flag) |
1303 | !dev->ethtool_ops->get_dump_flag) | ||
1304 | return -EOPNOTSUPP; | 1306 | return -EOPNOTSUPP; |
1305 | 1307 | ||
1306 | if (copy_from_user(&dump, useraddr, sizeof(dump))) | 1308 | if (copy_from_user(&dump, useraddr, sizeof(dump))) |
@@ -1346,13 +1348,9 @@ static int ethtool_get_ts_info(struct net_device *dev, void __user *useraddr) | |||
1346 | info.cmd = ETHTOOL_GET_TS_INFO; | 1348 | info.cmd = ETHTOOL_GET_TS_INFO; |
1347 | 1349 | ||
1348 | if (phydev && phydev->drv && phydev->drv->ts_info) { | 1350 | if (phydev && phydev->drv && phydev->drv->ts_info) { |
1349 | |||
1350 | err = phydev->drv->ts_info(phydev, &info); | 1351 | err = phydev->drv->ts_info(phydev, &info); |
1351 | 1352 | } else if (ops->get_ts_info) { | |
1352 | } else if (dev->ethtool_ops && dev->ethtool_ops->get_ts_info) { | ||
1353 | |||
1354 | err = ops->get_ts_info(dev, &info); | 1353 | err = ops->get_ts_info(dev, &info); |
1355 | |||
1356 | } else { | 1354 | } else { |
1357 | info.so_timestamping = | 1355 | info.so_timestamping = |
1358 | SOF_TIMESTAMPING_RX_SOFTWARE | | 1356 | SOF_TIMESTAMPING_RX_SOFTWARE | |