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

Commit 710b208d authored by Ben Hutchings's avatar Ben Hutchings
Browse files

sfc: Merge efx_mac_operations into efx_nic_type



No NICs need to switch efx_mac_operations at run-time, and the MAC
operations are fairly closely bound to NIC types.

Move efx_mac_operations::reconfigure to efx_nic_type::reconfigure_mac
and efx_mac_operations::check_fault fo efx_nic_type::check_mac_fault.
Change callers to call through efx->type or directly if the NIC type
is known.

Remove efx_mac_operations::update_stats.  The implementations for
Falcon used to fetch MAC statistics synchronously and this was used by
efx_register_netdev() to clear statistics after running self-tests.
However, it now only converts statistics that have already been
fetched (and that only for Falcon), and the call from
efx_register_netdev() has no effect.

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
parent 1cb34522
Loading
Loading
Loading
Loading
+6 −11
Original line number Original line Diff line number Diff line
@@ -900,7 +900,7 @@ static void efx_mac_work(struct work_struct *data)
	mutex_lock(&efx->mac_lock);
	mutex_lock(&efx->mac_lock);
	if (efx->port_enabled) {
	if (efx->port_enabled) {
		efx->type->push_multicast_hash(efx);
		efx->type->push_multicast_hash(efx);
		efx->mac_op->reconfigure(efx);
		efx->type->reconfigure_mac(efx);
	}
	}
	mutex_unlock(&efx->mac_lock);
	mutex_unlock(&efx->mac_lock);
}
}
@@ -941,7 +941,7 @@ static int efx_init_port(struct efx_nic *efx)


	/* Reconfigure the MAC before creating dma queues (required for
	/* Reconfigure the MAC before creating dma queues (required for
	 * Falcon/A1 where RX_INGR_EN/TX_DRAIN_EN isn't supported) */
	 * Falcon/A1 where RX_INGR_EN/TX_DRAIN_EN isn't supported) */
	efx->mac_op->reconfigure(efx);
	efx->type->reconfigure_mac(efx);


	/* Ensure the PHY advertises the correct flow control settings */
	/* Ensure the PHY advertises the correct flow control settings */
	rc = efx->phy_op->reconfigure(efx);
	rc = efx->phy_op->reconfigure(efx);
@@ -969,7 +969,7 @@ static void efx_start_port(struct efx_nic *efx)
	/* efx_mac_work() might have been scheduled after efx_stop_port(),
	/* efx_mac_work() might have been scheduled after efx_stop_port(),
	 * and then cancelled by efx_flush_all() */
	 * and then cancelled by efx_flush_all() */
	efx->type->push_multicast_hash(efx);
	efx->type->push_multicast_hash(efx);
	efx->mac_op->reconfigure(efx);
	efx->type->reconfigure_mac(efx);


	mutex_unlock(&efx->mac_lock);
	mutex_unlock(&efx->mac_lock);
}
}
@@ -1807,7 +1807,7 @@ static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
	/* Reconfigure the MAC before enabling the dma queues so that
	/* Reconfigure the MAC before enabling the dma queues so that
	 * the RX buffers don't overflow */
	 * the RX buffers don't overflow */
	net_dev->mtu = new_mtu;
	net_dev->mtu = new_mtu;
	efx->mac_op->reconfigure(efx);
	efx->type->reconfigure_mac(efx);
	mutex_unlock(&efx->mac_lock);
	mutex_unlock(&efx->mac_lock);


	efx_init_channels(efx);
	efx_init_channels(efx);
@@ -1835,7 +1835,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)


	/* Reconfigure the MAC */
	/* Reconfigure the MAC */
	mutex_lock(&efx->mac_lock);
	mutex_lock(&efx->mac_lock);
	efx->mac_op->reconfigure(efx);
	efx->type->reconfigure_mac(efx);
	mutex_unlock(&efx->mac_lock);
	mutex_unlock(&efx->mac_lock);


	return 0;
	return 0;
@@ -1949,10 +1949,6 @@ static int efx_register_netdev(struct efx_nic *efx)
	net_dev->netdev_ops = &efx_netdev_ops;
	net_dev->netdev_ops = &efx_netdev_ops;
	SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops);
	SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops);


	/* Clear MAC statistics */
	efx->mac_op->update_stats(efx);
	memset(&efx->mac_stats, 0, sizeof(efx->mac_stats));

	rtnl_lock();
	rtnl_lock();


	rc = dev_alloc_name(net_dev, net_dev->name);
	rc = dev_alloc_name(net_dev, net_dev->name);
@@ -2069,7 +2065,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
				  "could not restore PHY settings\n");
				  "could not restore PHY settings\n");
	}
	}


	efx->mac_op->reconfigure(efx);
	efx->type->reconfigure_mac(efx);


	efx_init_channels(efx);
	efx_init_channels(efx);
	efx_restore_filters(efx);
	efx_restore_filters(efx);
@@ -2274,7 +2270,6 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type,
	efx->net_dev = net_dev;
	efx->net_dev = net_dev;
	spin_lock_init(&efx->stats_lock);
	spin_lock_init(&efx->stats_lock);
	mutex_init(&efx->mac_lock);
	mutex_init(&efx->mac_lock);
	efx->mac_op = type->default_mac_ops;
	efx->phy_op = &efx_dummy_phy_operations;
	efx->phy_op = &efx_dummy_phy_operations;
	efx->mdio.dev = net_dev;
	efx->mdio.dev = net_dev;
	INIT_WORK(&efx->mac_work, efx_mac_work);
	INIT_WORK(&efx->mac_work, efx_mac_work);
+2 −2
Original line number Original line Diff line number Diff line
@@ -750,7 +750,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
			/* Recover by resetting the EM block */
			/* Recover by resetting the EM block */
			falcon_stop_nic_stats(efx);
			falcon_stop_nic_stats(efx);
			falcon_drain_tx_fifo(efx);
			falcon_drain_tx_fifo(efx);
			efx->mac_op->reconfigure(efx);
			falcon_reconfigure_xmac(efx);
			falcon_start_nic_stats(efx);
			falcon_start_nic_stats(efx);
		} else {
		} else {
			/* Schedule a reset to recover */
			/* Schedule a reset to recover */
@@ -775,7 +775,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
	/* Reconfigure the MAC. The PHY *may* generate a link state change event
	/* Reconfigure the MAC. The PHY *may* generate a link state change event
	 * if the user just changed the advertised capabilities, but there's no
	 * if the user just changed the advertised capabilities, but there's no
	 * harm doing this twice */
	 * harm doing this twice */
	efx->mac_op->reconfigure(efx);
	efx->type->reconfigure_mac(efx);


out:
out:
	mutex_unlock(&efx->mac_lock);
	mutex_unlock(&efx->mac_lock);
+8 −7
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@
#include "net_driver.h"
#include "net_driver.h"
#include "bitfield.h"
#include "bitfield.h"
#include "efx.h"
#include "efx.h"
#include "mac.h"
#include "spi.h"
#include "spi.h"
#include "nic.h"
#include "nic.h"
#include "regs.h"
#include "regs.h"
@@ -613,7 +612,7 @@ static void falcon_stats_complete(struct efx_nic *efx)
	nic_data->stats_pending = false;
	nic_data->stats_pending = false;
	if (*nic_data->stats_dma_done == FALCON_STATS_DONE) {
	if (*nic_data->stats_dma_done == FALCON_STATS_DONE) {
		rmb(); /* read the done flag before the stats */
		rmb(); /* read the done flag before the stats */
		efx->mac_op->update_stats(efx);
		falcon_update_stats_xmac(efx);
	} else {
	} else {
		netif_err(efx, hw, efx->net_dev,
		netif_err(efx, hw, efx->net_dev,
			  "timed out waiting for statistics\n");
			  "timed out waiting for statistics\n");
@@ -670,7 +669,7 @@ static int falcon_reconfigure_port(struct efx_nic *efx)
	falcon_reset_macs(efx);
	falcon_reset_macs(efx);


	efx->phy_op->reconfigure(efx);
	efx->phy_op->reconfigure(efx);
	rc = efx->mac_op->reconfigure(efx);
	rc = falcon_reconfigure_xmac(efx);
	BUG_ON(rc);
	BUG_ON(rc);


	falcon_start_nic_stats(efx);
	falcon_start_nic_stats(efx);
@@ -1218,7 +1217,7 @@ static void falcon_monitor(struct efx_nic *efx)
		falcon_deconfigure_mac_wrapper(efx);
		falcon_deconfigure_mac_wrapper(efx);


		falcon_reset_macs(efx);
		falcon_reset_macs(efx);
		rc = efx->mac_op->reconfigure(efx);
		rc = falcon_reconfigure_xmac(efx);
		BUG_ON(rc);
		BUG_ON(rc);


		falcon_start_nic_stats(efx);
		falcon_start_nic_stats(efx);
@@ -1676,7 +1675,7 @@ static void falcon_update_nic_stats(struct efx_nic *efx)
	    *nic_data->stats_dma_done == FALCON_STATS_DONE) {
	    *nic_data->stats_dma_done == FALCON_STATS_DONE) {
		nic_data->stats_pending = false;
		nic_data->stats_pending = false;
		rmb(); /* read the done flag before the stats */
		rmb(); /* read the done flag before the stats */
		efx->mac_op->update_stats(efx);
		falcon_update_stats_xmac(efx);
	}
	}
}
}


@@ -1769,11 +1768,12 @@ const struct efx_nic_type falcon_a1_nic_type = {
	.push_irq_moderation = falcon_push_irq_moderation,
	.push_irq_moderation = falcon_push_irq_moderation,
	.push_multicast_hash = falcon_push_multicast_hash,
	.push_multicast_hash = falcon_push_multicast_hash,
	.reconfigure_port = falcon_reconfigure_port,
	.reconfigure_port = falcon_reconfigure_port,
	.reconfigure_mac = falcon_reconfigure_xmac,
	.check_mac_fault = falcon_xmac_check_fault,
	.get_wol = falcon_get_wol,
	.get_wol = falcon_get_wol,
	.set_wol = falcon_set_wol,
	.set_wol = falcon_set_wol,
	.resume_wol = efx_port_dummy_op_void,
	.resume_wol = efx_port_dummy_op_void,
	.test_nvram = falcon_test_nvram,
	.test_nvram = falcon_test_nvram,
	.default_mac_ops = &falcon_xmac_operations,


	.revision = EFX_REV_FALCON_A1,
	.revision = EFX_REV_FALCON_A1,
	.mem_map_size = 0x20000,
	.mem_map_size = 0x20000,
@@ -1811,12 +1811,13 @@ const struct efx_nic_type falcon_b0_nic_type = {
	.push_irq_moderation = falcon_push_irq_moderation,
	.push_irq_moderation = falcon_push_irq_moderation,
	.push_multicast_hash = falcon_push_multicast_hash,
	.push_multicast_hash = falcon_push_multicast_hash,
	.reconfigure_port = falcon_reconfigure_port,
	.reconfigure_port = falcon_reconfigure_port,
	.reconfigure_mac = falcon_reconfigure_xmac,
	.check_mac_fault = falcon_xmac_check_fault,
	.get_wol = falcon_get_wol,
	.get_wol = falcon_get_wol,
	.set_wol = falcon_set_wol,
	.set_wol = falcon_set_wol,
	.resume_wol = efx_port_dummy_op_void,
	.resume_wol = efx_port_dummy_op_void,
	.test_registers = falcon_b0_test_registers,
	.test_registers = falcon_b0_test_registers,
	.test_nvram = falcon_test_nvram,
	.test_nvram = falcon_test_nvram,
	.default_mac_ops = &falcon_xmac_operations,


	.revision = EFX_REV_FALCON_B0,
	.revision = EFX_REV_FALCON_B0,
	/* Map everything up to and including the RSS indirection
	/* Map everything up to and including the RSS indirection
+3 −10
Original line number Original line Diff line number Diff line
@@ -14,7 +14,6 @@
#include "nic.h"
#include "nic.h"
#include "regs.h"
#include "regs.h"
#include "io.h"
#include "io.h"
#include "mac.h"
#include "mdio_10g.h"
#include "mdio_10g.h"
#include "workarounds.h"
#include "workarounds.h"


@@ -270,12 +269,12 @@ static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries)
	return mac_up;
	return mac_up;
}
}


static bool falcon_xmac_check_fault(struct efx_nic *efx)
bool falcon_xmac_check_fault(struct efx_nic *efx)
{
{
	return !falcon_xmac_link_ok_retry(efx, 5);
	return !falcon_xmac_link_ok_retry(efx, 5);
}
}


static int falcon_reconfigure_xmac(struct efx_nic *efx)
int falcon_reconfigure_xmac(struct efx_nic *efx)
{
{
	struct falcon_nic_data *nic_data = efx->nic_data;
	struct falcon_nic_data *nic_data = efx->nic_data;


@@ -290,7 +289,7 @@ static int falcon_reconfigure_xmac(struct efx_nic *efx)
	return 0;
	return 0;
}
}


static void falcon_update_stats_xmac(struct efx_nic *efx)
void falcon_update_stats_xmac(struct efx_nic *efx)
{
{
	struct efx_mac_stats *mac_stats = &efx->mac_stats;
	struct efx_mac_stats *mac_stats = &efx->mac_stats;


@@ -361,9 +360,3 @@ void falcon_poll_xmac(struct efx_nic *efx)
	nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1);
	nic_data->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1);
	falcon_ack_status_intr(efx);
	falcon_ack_status_intr(efx);
}
}

const struct efx_mac_operations falcon_xmac_operations = {
	.reconfigure	= falcon_reconfigure_xmac,
	.update_stats	= falcon_update_stats_xmac,
	.check_fault	= falcon_xmac_check_fault,
};

drivers/net/ethernet/sfc/mac.h

deleted100644 → 0
+0 −21
Original line number Original line Diff line number Diff line
/****************************************************************************
 * Driver for Solarflare Solarstorm network controllers and boards
 * Copyright 2005-2006 Fen Systems Ltd.
 * Copyright 2006-2009 Solarflare Communications Inc.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, incorporated herein by reference.
 */

#ifndef EFX_MAC_H
#define EFX_MAC_H

#include "net_driver.h"

extern const struct efx_mac_operations falcon_xmac_operations;
extern const struct efx_mac_operations efx_mcdi_mac_operations;
extern int efx_mcdi_mac_stats(struct efx_nic *efx, dma_addr_t dma_addr,
			      u32 dma_len, int enable, int clear);

#endif
Loading