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

Commit e938ed15 authored by Philippe Reynes's avatar Philippe Reynes Committed by David S. Miller
Browse files

net: sfc: falcon: use new api ethtool_{get|set}_link_ksettings



The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

Signed-off-by: default avatarPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8e4881aa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -986,7 +986,7 @@ void ef4_mac_reconfigure(struct ef4_nic *efx)

/* Push loopback/power/transmit disable settings to the PHY, and reconfigure
 * the MAC appropriately. All other PHY configuration changes are pushed
 * through phy_op->set_settings(), and pushed asynchronously to the MAC
 * through phy_op->set_link_ksettings(), and pushed asynchronously to the MAC
 * through ef4_monitor().
 *
 * Callers must hold the mac_lock
+16 −13
Original line number Diff line number Diff line
@@ -115,44 +115,47 @@ static int ef4_ethtool_phys_id(struct net_device *net_dev,
}

/* This must be called with rtnl_lock held. */
static int ef4_ethtool_get_settings(struct net_device *net_dev,
				    struct ethtool_cmd *ecmd)
static int
ef4_ethtool_get_link_ksettings(struct net_device *net_dev,
			       struct ethtool_link_ksettings *cmd)
{
	struct ef4_nic *efx = netdev_priv(net_dev);
	struct ef4_link_state *link_state = &efx->link_state;

	mutex_lock(&efx->mac_lock);
	efx->phy_op->get_settings(efx, ecmd);
	efx->phy_op->get_link_ksettings(efx, cmd);
	mutex_unlock(&efx->mac_lock);

	/* Both MACs support pause frames (bidirectional and respond-only) */
	ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
	ethtool_link_ksettings_add_link_mode(cmd, supported, Pause);
	ethtool_link_ksettings_add_link_mode(cmd, supported, Asym_Pause);

	if (LOOPBACK_INTERNAL(efx)) {
		ethtool_cmd_speed_set(ecmd, link_state->speed);
		ecmd->duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
		cmd->base.speed = link_state->speed;
		cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
	}

	return 0;
}

/* This must be called with rtnl_lock held. */
static int ef4_ethtool_set_settings(struct net_device *net_dev,
				    struct ethtool_cmd *ecmd)
static int
ef4_ethtool_set_link_ksettings(struct net_device *net_dev,
			       const struct ethtool_link_ksettings *cmd)
{
	struct ef4_nic *efx = netdev_priv(net_dev);
	int rc;

	/* GMAC does not support 1000Mbps HD */
	if ((ethtool_cmd_speed(ecmd) == SPEED_1000) &&
	    (ecmd->duplex != DUPLEX_FULL)) {
	if ((cmd->base.speed == SPEED_1000) &&
	    (cmd->base.duplex != DUPLEX_FULL)) {
		netif_dbg(efx, drv, efx->net_dev,
			  "rejecting unsupported 1000Mbps HD setting\n");
		return -EINVAL;
	}

	mutex_lock(&efx->mac_lock);
	rc = efx->phy_op->set_settings(efx, ecmd);
	rc = efx->phy_op->set_link_ksettings(efx, cmd);
	mutex_unlock(&efx->mac_lock);
	return rc;
}
@@ -1310,8 +1313,6 @@ static int ef4_ethtool_get_module_info(struct net_device *net_dev,
}

const struct ethtool_ops ef4_ethtool_ops = {
	.get_settings		= ef4_ethtool_get_settings,
	.set_settings		= ef4_ethtool_set_settings,
	.get_drvinfo		= ef4_ethtool_get_drvinfo,
	.get_regs_len		= ef4_ethtool_get_regs_len,
	.get_regs		= ef4_ethtool_get_regs,
@@ -1340,4 +1341,6 @@ const struct ethtool_ops ef4_ethtool_ops = {
	.set_rxfh		= ef4_ethtool_set_rxfh,
	.get_module_info	= ef4_ethtool_get_module_info,
	.get_module_eeprom	= ef4_ethtool_get_module_eeprom,
	.get_link_ksettings	= ef4_ethtool_get_link_ksettings,
	.set_link_ksettings	= ef4_ethtool_set_link_ksettings,
};
+28 −16
Original line number Diff line number Diff line
@@ -226,33 +226,45 @@ void ef4_mdio_set_mmds_lpower(struct ef4_nic *efx,
}

/**
 * ef4_mdio_set_settings - Set (some of) the PHY settings over MDIO.
 * ef4_mdio_set_link_ksettings - Set (some of) the PHY settings over MDIO.
 * @efx:		Efx NIC
 * @ecmd:		New settings
 * @cmd:		New settings
 */
int ef4_mdio_set_settings(struct ef4_nic *efx, struct ethtool_cmd *ecmd)
int ef4_mdio_set_link_ksettings(struct ef4_nic *efx,
				const struct ethtool_link_ksettings *cmd)
{
	struct ethtool_cmd prev = { .cmd = ETHTOOL_GSET };

	efx->phy_op->get_settings(efx, &prev);

	if (ecmd->advertising == prev.advertising &&
	    ethtool_cmd_speed(ecmd) == ethtool_cmd_speed(&prev) &&
	    ecmd->duplex == prev.duplex &&
	    ecmd->port == prev.port &&
	    ecmd->autoneg == prev.autoneg)
	struct ethtool_link_ksettings prev = {
		.base.cmd = ETHTOOL_GLINKSETTINGS
	};
	u32 prev_advertising, advertising;
	u32 prev_supported;

	efx->phy_op->get_link_ksettings(efx, &prev);

	ethtool_convert_link_mode_to_legacy_u32(&advertising,
						cmd->link_modes.advertising);
	ethtool_convert_link_mode_to_legacy_u32(&prev_advertising,
						prev.link_modes.advertising);
	ethtool_convert_link_mode_to_legacy_u32(&prev_supported,
						prev.link_modes.supported);

	if (advertising == prev_advertising &&
	    cmd->base.speed == prev.base.speed &&
	    cmd->base.duplex == prev.base.duplex &&
	    cmd->base.port == prev.base.port &&
	    cmd->base.autoneg == prev.base.autoneg)
		return 0;

	/* We can only change these settings for -T PHYs */
	if (prev.port != PORT_TP || ecmd->port != PORT_TP)
	if (prev.base.port != PORT_TP || cmd->base.port != PORT_TP)
		return -EINVAL;

	/* Check that PHY supports these settings */
	if (!ecmd->autoneg ||
	    (ecmd->advertising | SUPPORTED_Autoneg) & ~prev.supported)
	if (!cmd->base.autoneg ||
	    (advertising | SUPPORTED_Autoneg) & ~prev_supported)
		return -EINVAL;

	ef4_link_set_advertising(efx, ecmd->advertising | ADVERTISED_Autoneg);
	ef4_link_set_advertising(efx, advertising | ADVERTISED_Autoneg);
	ef4_mdio_an_reconfigure(efx);
	return 0;
}
+2 −1
Original line number Diff line number Diff line
@@ -83,7 +83,8 @@ void ef4_mdio_set_mmds_lpower(struct ef4_nic *efx, int low_power,
			      unsigned int mmd_mask);

/* Set (some of) the PHY settings over MDIO */
int ef4_mdio_set_settings(struct ef4_nic *efx, struct ethtool_cmd *ecmd);
int ef4_mdio_set_link_ksettings(struct ef4_nic *efx,
				const struct ethtool_link_ksettings *cmd);

/* Push advertising flags and restart autonegotiation */
void ef4_mdio_an_reconfigure(struct ef4_nic *efx);
+6 −6
Original line number Diff line number Diff line
@@ -684,8 +684,8 @@ static inline bool ef4_link_state_equal(const struct ef4_link_state *left,
 * @reconfigure: Reconfigure PHY (e.g. for new link parameters)
 * @poll: Update @link_state and report whether it changed.
 *	Serialised by the mac_lock.
 * @get_settings: Get ethtool settings. Serialised by the mac_lock.
 * @set_settings: Set ethtool settings. Serialised by the mac_lock.
 * @get_link_ksettings: Get ethtool settings. Serialised by the mac_lock.
 * @set_link_ksettings: Set ethtool settings. Serialised by the mac_lock.
 * @set_npage_adv: Set abilities advertised in (Extended) Next Page
 *	(only needed where AN bit is set in mmds)
 * @test_alive: Test that PHY is 'alive' (online)
@@ -700,10 +700,10 @@ struct ef4_phy_operations {
	void (*remove) (struct ef4_nic *efx);
	int (*reconfigure) (struct ef4_nic *efx);
	bool (*poll) (struct ef4_nic *efx);
	void (*get_settings) (struct ef4_nic *efx,
			      struct ethtool_cmd *ecmd);
	int (*set_settings) (struct ef4_nic *efx,
			     struct ethtool_cmd *ecmd);
	void (*get_link_ksettings)(struct ef4_nic *efx,
				   struct ethtool_link_ksettings *cmd);
	int (*set_link_ksettings)(struct ef4_nic *efx,
				  const struct ethtool_link_ksettings *cmd);
	void (*set_npage_adv) (struct ef4_nic *efx, u32);
	int (*test_alive) (struct ef4_nic *efx);
	const char *(*test_name) (struct ef4_nic *efx, unsigned int index);
Loading