diff options
| author | Jiri Pirko <jpirko@redhat.com> | 2011-09-02 23:34:30 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-09-15 17:32:26 -0400 |
| commit | 4bc71cb983fd2844e603bf633df2bb53385182d2 (patch) | |
| tree | 067b6df32fda6c554b2b9263a94a585c2e5a832d | |
| parent | c5dac7c9984d8a034eb7ae149cedf23ec9259f98 (diff) | |
net: consolidate and fix ethtool_ops->get_settings calling
This patch does several things:
- introduces __ethtool_get_settings which is called from ethtool code and
from drivers as well. Put ASSERT_RTNL there.
- dev_ethtool_get_settings() is replaced by __ethtool_get_settings()
- changes calling in drivers so rtnl locking is respected. In
iboe_get_rate was previously ->get_settings() called unlocked. This
fixes it. Also prb_calc_retire_blk_tmo() in af_packet.c had the same
problem. Also fixed by calling __dev_get_by_index() instead of
dev_get_by_index() and holding rtnl_lock for both calls.
- introduces rtnl_lock in bnx2fc_vport_create() and fcoe_vport_create()
so bnx2fc_if_create() and fcoe_if_create() are called locked as they
are from other places.
- use __ethtool_get_settings() in bonding code
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
v2->v3:
-removed dev_ethtool_get_settings()
-added ASSERT_RTNL into __ethtool_get_settings()
-prb_calc_retire_blk_tmo - use __dev_get_by_index() and lock
around it and __ethtool_get_settings() call
v1->v2:
add missing export_symbol
Reviewed-by: Ben Hutchings <bhutchings@solarflare.com> [except FCoE bits]
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | arch/mips/txx9/generic/setup_tx4939.c | 2 | ||||
| -rw-r--r-- | drivers/net/bonding/bond_main.c | 13 | ||||
| -rw-r--r-- | drivers/net/macvlan.c | 3 | ||||
| -rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 4 | ||||
| -rw-r--r-- | drivers/scsi/fcoe/fcoe.c | 4 | ||||
| -rw-r--r-- | include/linux/ethtool.h | 3 | ||||
| -rw-r--r-- | include/linux/netdevice.h | 3 | ||||
| -rw-r--r-- | include/rdma/ib_addr.h | 6 | ||||
| -rw-r--r-- | net/8021q/vlan_dev.c | 3 | ||||
| -rw-r--r-- | net/bridge/br_if.c | 2 | ||||
| -rw-r--r-- | net/core/dev.c | 24 | ||||
| -rw-r--r-- | net/core/ethtool.c | 20 | ||||
| -rw-r--r-- | net/core/net-sysfs.c | 4 | ||||
| -rw-r--r-- | net/packet/af_packet.c | 52 |
14 files changed, 69 insertions, 74 deletions
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic/setup_tx4939.c index e9f95dcde379..ba3cec3155df 100644 --- a/arch/mips/txx9/generic/setup_tx4939.c +++ b/arch/mips/txx9/generic/setup_tx4939.c | |||
| @@ -321,7 +321,7 @@ void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask) | |||
| 321 | static u32 tx4939_get_eth_speed(struct net_device *dev) | 321 | static u32 tx4939_get_eth_speed(struct net_device *dev) |
| 322 | { | 322 | { |
| 323 | struct ethtool_cmd cmd; | 323 | struct ethtool_cmd cmd; |
| 324 | if (dev_ethtool_get_settings(dev, &cmd)) | 324 | if (__ethtool_get_settings(dev, &cmd)) |
| 325 | return 100; /* default 100Mbps */ | 325 | return 100; /* default 100Mbps */ |
| 326 | 326 | ||
| 327 | return ethtool_cmd_speed(&cmd); | 327 | return ethtool_cmd_speed(&cmd); |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 8cb75a6efec3..1dcb07ce5263 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
| @@ -557,7 +557,7 @@ down: | |||
| 557 | static int bond_update_speed_duplex(struct slave *slave) | 557 | static int bond_update_speed_duplex(struct slave *slave) |
| 558 | { | 558 | { |
| 559 | struct net_device *slave_dev = slave->dev; | 559 | struct net_device *slave_dev = slave->dev; |
| 560 | struct ethtool_cmd etool = { .cmd = ETHTOOL_GSET }; | 560 | struct ethtool_cmd ecmd; |
| 561 | u32 slave_speed; | 561 | u32 slave_speed; |
| 562 | int res; | 562 | int res; |
| 563 | 563 | ||
| @@ -565,18 +565,15 @@ static int bond_update_speed_duplex(struct slave *slave) | |||
| 565 | slave->speed = SPEED_100; | 565 | slave->speed = SPEED_100; |
| 566 | slave->duplex = DUPLEX_FULL; | 566 | slave->duplex = DUPLEX_FULL; |
| 567 | 567 | ||
| 568 | if (!slave_dev->ethtool_ops || !slave_dev->ethtool_ops->get_settings) | 568 | res = __ethtool_get_settings(slave_dev, &ecmd); |
| 569 | return -1; | ||
| 570 | |||
| 571 | res = slave_dev->ethtool_ops->get_settings(slave_dev, &etool); | ||
| 572 | if (res < 0) | 569 | if (res < 0) |
| 573 | return -1; | 570 | return -1; |
| 574 | 571 | ||
| 575 | slave_speed = ethtool_cmd_speed(&etool); | 572 | slave_speed = ethtool_cmd_speed(&ecmd); |
| 576 | if (slave_speed == 0 || slave_speed == ((__u32) -1)) | 573 | if (slave_speed == 0 || slave_speed == ((__u32) -1)) |
| 577 | return -1; | 574 | return -1; |
| 578 | 575 | ||
| 579 | switch (etool.duplex) { | 576 | switch (ecmd.duplex) { |
| 580 | case DUPLEX_FULL: | 577 | case DUPLEX_FULL: |
| 581 | case DUPLEX_HALF: | 578 | case DUPLEX_HALF: |
| 582 | break; | 579 | break; |
| @@ -585,7 +582,7 @@ static int bond_update_speed_duplex(struct slave *slave) | |||
| 585 | } | 582 | } |
| 586 | 583 | ||
| 587 | slave->speed = slave_speed; | 584 | slave->speed = slave_speed; |
| 588 | slave->duplex = etool.duplex; | 585 | slave->duplex = ecmd.duplex; |
| 589 | 586 | ||
| 590 | return 0; | 587 | return 0; |
| 591 | } | 588 | } |
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 836e13fcb3ec..b100c90e8507 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
| @@ -543,7 +543,8 @@ static int macvlan_ethtool_get_settings(struct net_device *dev, | |||
| 543 | struct ethtool_cmd *cmd) | 543 | struct ethtool_cmd *cmd) |
| 544 | { | 544 | { |
| 545 | const struct macvlan_dev *vlan = netdev_priv(dev); | 545 | const struct macvlan_dev *vlan = netdev_priv(dev); |
| 546 | return dev_ethtool_get_settings(vlan->lowerdev, cmd); | 546 | |
| 547 | return __ethtool_get_settings(vlan->lowerdev, cmd); | ||
| 547 | } | 548 | } |
| 548 | 549 | ||
| 549 | static const struct ethtool_ops macvlan_ethtool_ops = { | 550 | static const struct ethtool_ops macvlan_ethtool_ops = { |
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 2c780a78fcbd..820a1840c3f7 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c | |||
| @@ -673,7 +673,7 @@ static void bnx2fc_link_speed_update(struct fc_lport *lport) | |||
| 673 | struct net_device *netdev = interface->netdev; | 673 | struct net_device *netdev = interface->netdev; |
| 674 | struct ethtool_cmd ecmd; | 674 | struct ethtool_cmd ecmd; |
| 675 | 675 | ||
| 676 | if (!dev_ethtool_get_settings(netdev, &ecmd)) { | 676 | if (!__ethtool_get_settings(netdev, &ecmd)) { |
| 677 | lport->link_supported_speeds &= | 677 | lport->link_supported_speeds &= |
| 678 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); | 678 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); |
| 679 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | | 679 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | |
| @@ -1001,9 +1001,11 @@ static int bnx2fc_vport_create(struct fc_vport *vport, bool disabled) | |||
| 1001 | "this interface\n"); | 1001 | "this interface\n"); |
| 1002 | return -EIO; | 1002 | return -EIO; |
| 1003 | } | 1003 | } |
| 1004 | rtnl_lock(); | ||
| 1004 | mutex_lock(&bnx2fc_dev_lock); | 1005 | mutex_lock(&bnx2fc_dev_lock); |
| 1005 | vn_port = bnx2fc_if_create(interface, &vport->dev, 1); | 1006 | vn_port = bnx2fc_if_create(interface, &vport->dev, 1); |
| 1006 | mutex_unlock(&bnx2fc_dev_lock); | 1007 | mutex_unlock(&bnx2fc_dev_lock); |
| 1008 | rtnl_unlock(); | ||
| 1007 | 1009 | ||
| 1008 | if (IS_ERR(vn_port)) { | 1010 | if (IS_ERR(vn_port)) { |
| 1009 | printk(KERN_ERR PFX "bnx2fc_vport_create (%s) failed\n", | 1011 | printk(KERN_ERR PFX "bnx2fc_vport_create (%s) failed\n", |
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 3416ab673814..83aa3ac52c40 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c | |||
| @@ -2043,7 +2043,7 @@ int fcoe_link_speed_update(struct fc_lport *lport) | |||
| 2043 | struct net_device *netdev = fcoe_netdev(lport); | 2043 | struct net_device *netdev = fcoe_netdev(lport); |
| 2044 | struct ethtool_cmd ecmd; | 2044 | struct ethtool_cmd ecmd; |
| 2045 | 2045 | ||
| 2046 | if (!dev_ethtool_get_settings(netdev, &ecmd)) { | 2046 | if (!__ethtool_get_settings(netdev, &ecmd)) { |
| 2047 | lport->link_supported_speeds &= | 2047 | lport->link_supported_speeds &= |
| 2048 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); | 2048 | ~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT); |
| 2049 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | | 2049 | if (ecmd.supported & (SUPPORTED_1000baseT_Half | |
| @@ -2452,7 +2452,9 @@ static int fcoe_vport_create(struct fc_vport *vport, bool disabled) | |||
| 2452 | } | 2452 | } |
| 2453 | 2453 | ||
| 2454 | mutex_lock(&fcoe_config_mutex); | 2454 | mutex_lock(&fcoe_config_mutex); |
| 2455 | rtnl_lock(); | ||
| 2455 | vn_port = fcoe_if_create(fcoe, &vport->dev, 1); | 2456 | vn_port = fcoe_if_create(fcoe, &vport->dev, 1); |
| 2457 | rtnl_unlock(); | ||
| 2456 | mutex_unlock(&fcoe_config_mutex); | 2458 | mutex_unlock(&fcoe_config_mutex); |
| 2457 | 2459 | ||
| 2458 | if (IS_ERR(vn_port)) { | 2460 | if (IS_ERR(vn_port)) { |
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 3829712ccc05..8571f18c38a6 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h | |||
| @@ -728,6 +728,9 @@ enum ethtool_sfeatures_retval_bits { | |||
| 728 | /* needed by dev_disable_lro() */ | 728 | /* needed by dev_disable_lro() */ |
| 729 | extern int __ethtool_set_flags(struct net_device *dev, u32 flags); | 729 | extern int __ethtool_set_flags(struct net_device *dev, u32 flags); |
| 730 | 730 | ||
| 731 | extern int __ethtool_get_settings(struct net_device *dev, | ||
| 732 | struct ethtool_cmd *cmd); | ||
| 733 | |||
| 731 | /** | 734 | /** |
| 732 | * enum ethtool_phys_id_state - indicator state for physical identification | 735 | * enum ethtool_phys_id_state - indicator state for physical identification |
| 733 | * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated | 736 | * @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 0a7f619f284e..43b32983ba10 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -2589,9 +2589,6 @@ static inline int netif_is_bond_slave(struct net_device *dev) | |||
| 2589 | 2589 | ||
| 2590 | extern struct pernet_operations __net_initdata loopback_net_ops; | 2590 | extern struct pernet_operations __net_initdata loopback_net_ops; |
| 2591 | 2591 | ||
| 2592 | int dev_ethtool_get_settings(struct net_device *dev, | ||
| 2593 | struct ethtool_cmd *cmd); | ||
| 2594 | |||
| 2595 | static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev) | 2592 | static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev) |
| 2596 | { | 2593 | { |
| 2597 | if (dev->features & NETIF_F_RXCSUM) | 2594 | if (dev->features & NETIF_F_RXCSUM) |
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index ae8c68f30f1b..639a4491fc0d 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h | |||
| @@ -218,8 +218,12 @@ static inline int iboe_get_rate(struct net_device *dev) | |||
| 218 | { | 218 | { |
| 219 | struct ethtool_cmd cmd; | 219 | struct ethtool_cmd cmd; |
| 220 | u32 speed; | 220 | u32 speed; |
| 221 | int err; | ||
| 221 | 222 | ||
| 222 | if (dev_ethtool_get_settings(dev, &cmd)) | 223 | rtnl_lock(); |
| 224 | err = __ethtool_get_settings(dev, &cmd); | ||
| 225 | rtnl_unlock(); | ||
| 226 | if (err) | ||
| 223 | return IB_RATE_PORT_CURRENT; | 227 | return IB_RATE_PORT_CURRENT; |
| 224 | 228 | ||
| 225 | speed = ethtool_cmd_speed(&cmd); | 229 | speed = ethtool_cmd_speed(&cmd); |
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index eba705b92d6f..c8cf9391417e 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
| @@ -610,7 +610,8 @@ static int vlan_ethtool_get_settings(struct net_device *dev, | |||
| 610 | struct ethtool_cmd *cmd) | 610 | struct ethtool_cmd *cmd) |
| 611 | { | 611 | { |
| 612 | const struct vlan_dev_info *vlan = vlan_dev_info(dev); | 612 | const struct vlan_dev_info *vlan = vlan_dev_info(dev); |
| 613 | return dev_ethtool_get_settings(vlan->real_dev, cmd); | 613 | |
| 614 | return __ethtool_get_settings(vlan->real_dev, cmd); | ||
| 614 | } | 615 | } |
| 615 | 616 | ||
| 616 | static void vlan_ethtool_get_drvinfo(struct net_device *dev, | 617 | static void vlan_ethtool_get_drvinfo(struct net_device *dev, |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index b365bba84d19..043a5eb8cafc 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
| @@ -35,7 +35,7 @@ static int port_cost(struct net_device *dev) | |||
| 35 | { | 35 | { |
| 36 | struct ethtool_cmd ecmd; | 36 | struct ethtool_cmd ecmd; |
| 37 | 37 | ||
| 38 | if (!dev_ethtool_get_settings(dev, &ecmd)) { | 38 | if (!__ethtool_get_settings(dev, &ecmd)) { |
| 39 | switch (ethtool_cmd_speed(&ecmd)) { | 39 | switch (ethtool_cmd_speed(&ecmd)) { |
| 40 | case SPEED_10000: | 40 | case SPEED_10000: |
| 41 | return 2; | 41 | return 2; |
diff --git a/net/core/dev.c b/net/core/dev.c index b2e262ed3963..4b9981caf06f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -4566,30 +4566,6 @@ void dev_set_rx_mode(struct net_device *dev) | |||
| 4566 | } | 4566 | } |
| 4567 | 4567 | ||
| 4568 | /** | 4568 | /** |
| 4569 | * dev_ethtool_get_settings - call device's ethtool_ops::get_settings() | ||
| 4570 | * @dev: device | ||
| 4571 | * @cmd: memory area for ethtool_ops::get_settings() result | ||
| 4572 | * | ||
| 4573 | * The cmd arg is initialized properly (cleared and | ||
| 4574 | * ethtool_cmd::cmd field set to ETHTOOL_GSET). | ||
| 4575 | * | ||
| 4576 | * Return device's ethtool_ops::get_settings() result value or | ||
| 4577 | * -EOPNOTSUPP when device doesn't expose | ||
| 4578 | * ethtool_ops::get_settings() operation. | ||
| 4579 | */ | ||
| 4580 | int dev_ethtool_get_settings(struct net_device *dev, | ||
| 4581 | struct ethtool_cmd *cmd) | ||
| 4582 | { | ||
| 4583 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings) | ||
| 4584 | return -EOPNOTSUPP; | ||
| 4585 | |||
| 4586 | memset(cmd, 0, sizeof(struct ethtool_cmd)); | ||
| 4587 | cmd->cmd = ETHTOOL_GSET; | ||
| 4588 | return dev->ethtool_ops->get_settings(dev, cmd); | ||
| 4589 | } | ||
| 4590 | EXPORT_SYMBOL(dev_ethtool_get_settings); | ||
| 4591 | |||
| 4592 | /** | ||
| 4593 | * dev_get_flags - get flags reported to userspace | 4569 | * dev_get_flags - get flags reported to userspace |
| 4594 | * @dev: device | 4570 | * @dev: device |
| 4595 | * | 4571 | * |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 6cdba5fc2bed..f44481707124 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
| @@ -569,15 +569,25 @@ int __ethtool_set_flags(struct net_device *dev, u32 data) | |||
| 569 | return 0; | 569 | return 0; |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) | 572 | int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
| 573 | { | 573 | { |
| 574 | struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET }; | 574 | ASSERT_RTNL(); |
| 575 | int err; | ||
| 576 | 575 | ||
| 577 | if (!dev->ethtool_ops->get_settings) | 576 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings) |
| 578 | return -EOPNOTSUPP; | 577 | return -EOPNOTSUPP; |
| 579 | 578 | ||
| 580 | err = dev->ethtool_ops->get_settings(dev, &cmd); | 579 | memset(cmd, 0, sizeof(struct ethtool_cmd)); |
| 580 | cmd->cmd = ETHTOOL_GSET; | ||
| 581 | return dev->ethtool_ops->get_settings(dev, cmd); | ||
| 582 | } | ||
| 583 | EXPORT_SYMBOL(__ethtool_get_settings); | ||
| 584 | |||
| 585 | static int ethtool_get_settings(struct net_device *dev, void __user *useraddr) | ||
| 586 | { | ||
| 587 | int err; | ||
| 588 | struct ethtool_cmd cmd; | ||
| 589 | |||
| 590 | err = __ethtool_get_settings(dev, &cmd); | ||
| 581 | if (err < 0) | 591 | if (err < 0) |
| 582 | return err; | 592 | return err; |
| 583 | 593 | ||
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 56e42ab7cbc6..7604a635376b 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
| @@ -147,7 +147,7 @@ static ssize_t show_speed(struct device *dev, | |||
| 147 | 147 | ||
| 148 | if (netif_running(netdev)) { | 148 | if (netif_running(netdev)) { |
| 149 | struct ethtool_cmd cmd; | 149 | struct ethtool_cmd cmd; |
| 150 | if (!dev_ethtool_get_settings(netdev, &cmd)) | 150 | if (!__ethtool_get_settings(netdev, &cmd)) |
| 151 | ret = sprintf(buf, fmt_udec, ethtool_cmd_speed(&cmd)); | 151 | ret = sprintf(buf, fmt_udec, ethtool_cmd_speed(&cmd)); |
| 152 | } | 152 | } |
| 153 | rtnl_unlock(); | 153 | rtnl_unlock(); |
| @@ -165,7 +165,7 @@ static ssize_t show_duplex(struct device *dev, | |||
| 165 | 165 | ||
| 166 | if (netif_running(netdev)) { | 166 | if (netif_running(netdev)) { |
| 167 | struct ethtool_cmd cmd; | 167 | struct ethtool_cmd cmd; |
| 168 | if (!dev_ethtool_get_settings(netdev, &cmd)) | 168 | if (!__ethtool_get_settings(netdev, &cmd)) |
| 169 | ret = sprintf(buf, "%s\n", | 169 | ret = sprintf(buf, "%s\n", |
| 170 | cmd.duplex ? "full" : "half"); | 170 | cmd.duplex ? "full" : "half"); |
| 171 | } | 171 | } |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 2ea3d63e1d4c..25e68f56b4ba 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
| @@ -530,33 +530,35 @@ static int prb_calc_retire_blk_tmo(struct packet_sock *po, | |||
| 530 | { | 530 | { |
| 531 | struct net_device *dev; | 531 | struct net_device *dev; |
| 532 | unsigned int mbits = 0, msec = 0, div = 0, tmo = 0; | 532 | unsigned int mbits = 0, msec = 0, div = 0, tmo = 0; |
| 533 | struct ethtool_cmd ecmd; | ||
| 534 | int err; | ||
| 533 | 535 | ||
| 534 | dev = dev_get_by_index(sock_net(&po->sk), po->ifindex); | 536 | rtnl_lock(); |
| 535 | if (unlikely(dev == NULL)) | 537 | dev = __dev_get_by_index(sock_net(&po->sk), po->ifindex); |
| 538 | if (unlikely(!dev)) { | ||
| 539 | rtnl_unlock(); | ||
| 536 | return DEFAULT_PRB_RETIRE_TOV; | 540 | return DEFAULT_PRB_RETIRE_TOV; |
| 537 | 541 | } | |
| 538 | if (dev->ethtool_ops && dev->ethtool_ops->get_settings) { | 542 | err = __ethtool_get_settings(dev, &ecmd); |
| 539 | struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET, }; | 543 | rtnl_unlock(); |
| 540 | 544 | if (!err) { | |
| 541 | if (!dev->ethtool_ops->get_settings(dev, &ecmd)) { | 545 | switch (ecmd.speed) { |
| 542 | switch (ecmd.speed) { | 546 | case SPEED_10000: |
| 543 | case SPEED_10000: | 547 | msec = 1; |
| 544 | msec = 1; | 548 | div = 10000/1000; |
| 545 | div = 10000/1000; | 549 | break; |
| 546 | break; | 550 | case SPEED_1000: |
| 547 | case SPEED_1000: | 551 | msec = 1; |
| 548 | msec = 1; | 552 | div = 1000/1000; |
| 549 | div = 1000/1000; | 553 | break; |
| 550 | break; | 554 | /* |
| 551 | /* | 555 | * If the link speed is so slow you don't really |
| 552 | * If the link speed is so slow you don't really | 556 | * need to worry about perf anyways |
| 553 | * need to worry about perf anyways | 557 | */ |
| 554 | */ | 558 | case SPEED_100: |
| 555 | case SPEED_100: | 559 | case SPEED_10: |
| 556 | case SPEED_10: | 560 | default: |
| 557 | default: | 561 | return DEFAULT_PRB_RETIRE_TOV; |
| 558 | return DEFAULT_PRB_RETIRE_TOV; | ||
| 559 | } | ||
| 560 | } | 562 | } |
| 561 | } | 563 | } |
| 562 | 564 | ||
