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

Commit 8ae6daca authored by David Decotigny's avatar David Decotigny Committed by David S. Miller
Browse files

ethtool: Call ethtool's get/set_settings callbacks with cleaned data



This makes sure that when a driver calls the ethtool's
get/set_settings() callback of another driver, the data passed to it
is clean. This guarantees that speed_hi will be zeroed correctly if
the called callback doesn't explicitely set it: we are sure we don't
get a corrupted speed from the underlying driver. We also take care of
setting the cmd field appropriately (ETHTOOL_GSET/SSET).

This applies to dev_ethtool_get_settings(), which now makes sure it
sets up that ethtool command parameter correctly before passing it to
drivers. This also means that whoever calls dev_ethtool_get_settings()
does not have to clean the ethtool command parameter. This function
also becomes an exported symbol instead of an inline.

All drivers visible to make allyesconfig under x86_64 have been
updated.

Signed-off-by: default avatarDavid Decotigny <decot@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 36504605
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -318,19 +318,15 @@ void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask)
}

#if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE)
static int tx4939_get_eth_speed(struct net_device *dev)
static u32 tx4939_get_eth_speed(struct net_device *dev)
{
	struct ethtool_cmd cmd = { ETHTOOL_GSET };
	int speed = 100;	/* default 100Mbps */
	int err;
	if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings)
		return speed;
	err = dev->ethtool_ops->get_settings(dev, &cmd);
	if (err < 0)
		return speed;
	speed = cmd.speed == SPEED_100 ? 100 : 10;
	return speed;
	struct ethtool_cmd cmd;
	if (dev_ethtool_get_settings(dev, &cmd))
		return 100;	/* default 100Mbps */

	return ethtool_cmd_speed(&cmd);
}

static int tx4939_netdev_event(struct notifier_block *this,
			       unsigned long event,
			       void *ptr)
@@ -343,8 +339,7 @@ static int tx4939_netdev_event(struct notifier_block *this,
		else if (dev->irq == TXX9_IRQ_BASE + TX4939_IR_ETH(1))
			bit = TX4939_PCFG_SPEED1;
		if (bit) {
			int speed = tx4939_get_eth_speed(dev);
			if (speed == 100)
			if (tx4939_get_eth_speed(dev) == 100)
				txx9_set64(&tx4939_ccfgptr->pcfg, bit);
			else
				txx9_clear64(&tx4939_ccfgptr->pcfg, bit);
+1 −1
Original line number Diff line number Diff line
@@ -1668,7 +1668,7 @@ static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
static void e100_watchdog(unsigned long data)
{
	struct nic *nic = (struct nic *)data;
	struct ethtool_cmd cmd;
	struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };

	netif_printk(nic, timer, KERN_DEBUG, nic->netdev,
		     "right now = %ld\n", jiffies);
+3 −0
Original line number Diff line number Diff line
@@ -176,6 +176,9 @@ static u32 mdio45_get_an(const struct mdio_if_info *mdio, u16 addr)
 * @npage_adv: Modes currently advertised on next pages
 * @npage_lpa: Modes advertised by link partner on next pages
 *
 * The @ecmd parameter is expected to have been cleared before calling
 * mdio45_ethtool_gset_npage().
 *
 * Since the CSRs for auto-negotiation using next pages are not fully
 * standardised, this function does not attempt to decode them.  The
 * caller must pass them in.
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr)
 * @mii: MII interface
 * @ecmd: requested ethtool_cmd
 *
 * The @ecmd parameter is expected to have been cleared before calling
 * mii_ethtool_gset().
 *
 * Returns 0 for success, negative on error.
 */
int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
+3 −3
Original line number Diff line number Diff line
@@ -888,12 +888,12 @@ static void pch_gbe_watchdog(unsigned long data)
	struct pch_gbe_adapter *adapter = (struct pch_gbe_adapter *)data;
	struct net_device *netdev = adapter->netdev;
	struct pch_gbe_hw *hw = &adapter->hw;
	struct ethtool_cmd cmd;

	pr_debug("right now = %ld\n", jiffies);

	pch_gbe_update_stats(adapter);
	if ((mii_link_ok(&adapter->mii)) && (!netif_carrier_ok(netdev))) {
		struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
		netdev->tx_queue_len = adapter->tx_queue_len;
		/* mii library handles link maintenance tasks */
		if (mii_ethtool_gset(&adapter->mii, &cmd)) {
@@ -903,7 +903,7 @@ static void pch_gbe_watchdog(unsigned long data)
						PCH_GBE_WATCHDOG_PERIOD));
			return;
		}
		hw->mac.link_speed = cmd.speed;
		hw->mac.link_speed = ethtool_cmd_speed(&cmd);
		hw->mac.link_duplex = cmd.duplex;
		/* Set the RGMII control. */
		pch_gbe_set_rgmii_ctrl(adapter, hw->mac.link_speed,
@@ -913,7 +913,7 @@ static void pch_gbe_watchdog(unsigned long data)
				 hw->mac.link_duplex);
		netdev_dbg(netdev,
			   "Link is Up %d Mbps %s-Duplex\n",
			   cmd.speed,
			   hw->mac.link_speed,
			   cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
		netif_carrier_on(netdev);
		netif_wake_queue(netdev);
Loading