Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bc71cb9 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

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: default avatarJiri 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: default avatarRalf Baechle <ralf@linux-mips.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5dac7c9
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -321,7 +321,7 @@ void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask)
static u32 tx4939_get_eth_speed(struct net_device *dev)
static u32 tx4939_get_eth_speed(struct net_device *dev)
{
{
	struct ethtool_cmd cmd;
	struct ethtool_cmd cmd;
	if (dev_ethtool_get_settings(dev, &cmd))
	if (__ethtool_get_settings(dev, &cmd))
		return 100;	/* default 100Mbps */
		return 100;	/* default 100Mbps */


	return ethtool_cmd_speed(&cmd);
	return ethtool_cmd_speed(&cmd);
+5 −8
Original line number Original line Diff line number Diff line
@@ -557,7 +557,7 @@ static int bond_set_carrier(struct bonding *bond)
static int bond_update_speed_duplex(struct slave *slave)
static int bond_update_speed_duplex(struct slave *slave)
{
{
	struct net_device *slave_dev = slave->dev;
	struct net_device *slave_dev = slave->dev;
	struct ethtool_cmd etool = { .cmd = ETHTOOL_GSET };
	struct ethtool_cmd ecmd;
	u32 slave_speed;
	u32 slave_speed;
	int res;
	int res;


@@ -565,18 +565,15 @@ static int bond_update_speed_duplex(struct slave *slave)
	slave->speed = SPEED_100;
	slave->speed = SPEED_100;
	slave->duplex = DUPLEX_FULL;
	slave->duplex = DUPLEX_FULL;


	if (!slave_dev->ethtool_ops || !slave_dev->ethtool_ops->get_settings)
	res = __ethtool_get_settings(slave_dev, &ecmd);
		return -1;

	res = slave_dev->ethtool_ops->get_settings(slave_dev, &etool);
	if (res < 0)
	if (res < 0)
		return -1;
		return -1;


	slave_speed = ethtool_cmd_speed(&etool);
	slave_speed = ethtool_cmd_speed(&ecmd);
	if (slave_speed == 0 || slave_speed == ((__u32) -1))
	if (slave_speed == 0 || slave_speed == ((__u32) -1))
		return -1;
		return -1;


	switch (etool.duplex) {
	switch (ecmd.duplex) {
	case DUPLEX_FULL:
	case DUPLEX_FULL:
	case DUPLEX_HALF:
	case DUPLEX_HALF:
		break;
		break;
@@ -585,7 +582,7 @@ static int bond_update_speed_duplex(struct slave *slave)
	}
	}


	slave->speed = slave_speed;
	slave->speed = slave_speed;
	slave->duplex = etool.duplex;
	slave->duplex = ecmd.duplex;


	return 0;
	return 0;
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -543,7 +543,8 @@ static int macvlan_ethtool_get_settings(struct net_device *dev,
					struct ethtool_cmd *cmd)
					struct ethtool_cmd *cmd)
{
{
	const struct macvlan_dev *vlan = netdev_priv(dev);
	const struct macvlan_dev *vlan = netdev_priv(dev);
	return dev_ethtool_get_settings(vlan->lowerdev, cmd);

	return __ethtool_get_settings(vlan->lowerdev, cmd);
}
}


static const struct ethtool_ops macvlan_ethtool_ops = {
static const struct ethtool_ops macvlan_ethtool_ops = {
+3 −1
Original line number Original line Diff line number Diff line
@@ -673,7 +673,7 @@ static void bnx2fc_link_speed_update(struct fc_lport *lport)
	struct net_device *netdev = interface->netdev;
	struct net_device *netdev = interface->netdev;
	struct ethtool_cmd ecmd;
	struct ethtool_cmd ecmd;


	if (!dev_ethtool_get_settings(netdev, &ecmd)) {
	if (!__ethtool_get_settings(netdev, &ecmd)) {
		lport->link_supported_speeds &=
		lport->link_supported_speeds &=
			~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
			~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
		if (ecmd.supported & (SUPPORTED_1000baseT_Half |
		if (ecmd.supported & (SUPPORTED_1000baseT_Half |
@@ -1001,9 +1001,11 @@ static int bnx2fc_vport_create(struct fc_vport *vport, bool disabled)
			"this interface\n");
			"this interface\n");
		return -EIO;
		return -EIO;
	}
	}
	rtnl_lock();
	mutex_lock(&bnx2fc_dev_lock);
	mutex_lock(&bnx2fc_dev_lock);
	vn_port = bnx2fc_if_create(interface, &vport->dev, 1);
	vn_port = bnx2fc_if_create(interface, &vport->dev, 1);
	mutex_unlock(&bnx2fc_dev_lock);
	mutex_unlock(&bnx2fc_dev_lock);
	rtnl_unlock();


	if (IS_ERR(vn_port)) {
	if (IS_ERR(vn_port)) {
		printk(KERN_ERR PFX "bnx2fc_vport_create (%s) failed\n",
		printk(KERN_ERR PFX "bnx2fc_vport_create (%s) failed\n",
+3 −1
Original line number Original line Diff line number Diff line
@@ -2043,7 +2043,7 @@ int fcoe_link_speed_update(struct fc_lport *lport)
	struct net_device *netdev = fcoe_netdev(lport);
	struct net_device *netdev = fcoe_netdev(lport);
	struct ethtool_cmd ecmd;
	struct ethtool_cmd ecmd;


	if (!dev_ethtool_get_settings(netdev, &ecmd)) {
	if (!__ethtool_get_settings(netdev, &ecmd)) {
		lport->link_supported_speeds &=
		lport->link_supported_speeds &=
			~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
			~(FC_PORTSPEED_1GBIT | FC_PORTSPEED_10GBIT);
		if (ecmd.supported & (SUPPORTED_1000baseT_Half |
		if (ecmd.supported & (SUPPORTED_1000baseT_Half |
@@ -2452,7 +2452,9 @@ static int fcoe_vport_create(struct fc_vport *vport, bool disabled)
	}
	}


	mutex_lock(&fcoe_config_mutex);
	mutex_lock(&fcoe_config_mutex);
	rtnl_lock();
	vn_port = fcoe_if_create(fcoe, &vport->dev, 1);
	vn_port = fcoe_if_create(fcoe, &vport->dev, 1);
	rtnl_unlock();
	mutex_unlock(&fcoe_config_mutex);
	mutex_unlock(&fcoe_config_mutex);


	if (IS_ERR(vn_port)) {
	if (IS_ERR(vn_port)) {
Loading