Commit 7f58648d authored by Jedrzej Jagielski's avatar Jedrzej Jagielski Committed by Tony Nguyen
Browse files

ixgbe: apply different rules for setting FC on E610



E610 device doesn't support disabling FC autonegotiation.

Create dedicated E610 .set_pauseparam() implementation and assign
it to ixgbe_ethtool_ops_e610.

Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: default avatarJedrzej Jagielski <jedrzej.jagielski@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Tested-by: default avatarBharath R <bharath.r@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 451c6bc9
Loading
Loading
Loading
Loading
+49 −8
Original line number Diff line number Diff line
@@ -564,6 +564,22 @@ static void ixgbe_get_pauseparam(struct net_device *netdev,
	}
}

static void ixgbe_set_pauseparam_finalize(struct net_device *netdev,
					  struct ixgbe_fc_info *fc)
{
	struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
	struct ixgbe_hw *hw = &adapter->hw;

	/* If the thing changed then we'll update and use new autoneg. */
	if (memcmp(fc, &hw->fc, sizeof(*fc))) {
		hw->fc = *fc;
		if (netif_running(netdev))
			ixgbe_reinit_locked(adapter);
		else
			ixgbe_reset(adapter);
	}
}

static int ixgbe_set_pauseparam(struct net_device *netdev,
				struct ethtool_pauseparam *pause)
{
@@ -592,15 +608,40 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
	else
		fc.requested_mode = ixgbe_fc_none;

	/* if the thing changed then we'll update and use new autoneg */
	if (memcmp(&fc, &hw->fc, sizeof(struct ixgbe_fc_info))) {
		hw->fc = fc;
		if (netif_running(netdev))
			ixgbe_reinit_locked(adapter);
		else
			ixgbe_reset(adapter);
	ixgbe_set_pauseparam_finalize(netdev, &fc);

	return 0;
}

static int ixgbe_set_pauseparam_e610(struct net_device *netdev,
				     struct ethtool_pauseparam *pause)
{
	struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
	struct ixgbe_hw *hw = &adapter->hw;
	struct ixgbe_fc_info fc = hw->fc;

	if (!ixgbe_device_supports_autoneg_fc(hw))
		return -EOPNOTSUPP;

	if (pause->autoneg == AUTONEG_DISABLE) {
		netdev_info(netdev,
			    "Cannot disable autonegotiation on this device.\n");
		return -EOPNOTSUPP;
	}

	fc.disable_fc_autoneg = false;

	if (pause->rx_pause && pause->tx_pause)
		fc.requested_mode = ixgbe_fc_full;
	else if (pause->rx_pause)
		fc.requested_mode = ixgbe_fc_rx_pause;
	else if (pause->tx_pause)
		fc.requested_mode = ixgbe_fc_tx_pause;
	else
		fc.requested_mode = ixgbe_fc_none;

	ixgbe_set_pauseparam_finalize(netdev, &fc);

	return 0;
}

@@ -3710,7 +3751,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops_e610 = {
	.set_ringparam          = ixgbe_set_ringparam,
	.get_pause_stats	= ixgbe_get_pause_stats,
	.get_pauseparam         = ixgbe_get_pauseparam,
	.set_pauseparam         = ixgbe_set_pauseparam,
	.set_pauseparam         = ixgbe_set_pauseparam_e610,
	.get_msglevel           = ixgbe_get_msglevel,
	.set_msglevel           = ixgbe_set_msglevel,
	.self_test              = ixgbe_diag_test,