Commit c77289b4 authored by Edward Cree's avatar Edward Cree Committed by Jakub Kicinski

sfc: remove phy_op indirection

Originally there were several implementations of PHY operations for the
 several different PHYs used on Falcon boards.  But Falcon is now in a
 separate driver, and all sfc NICs since then have had MCDI-managed PHYs.
Thus, there is no need to indirect through function pointers in
 efx->phy_op; we can simply call the efx_mcdi_phy_* functions directly.

This also hooks up these functions for EF100, which was previously using
 the dummy_phy_ops.
Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7dcc9d8a
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "selftest.h" #include "selftest.h"
#include "sriov.h" #include "sriov.h"
#include "mcdi.h" #include "mcdi_port_common.h"
#include "mcdi_pcol.h" #include "mcdi_pcol.h"
#include "workarounds.h" #include "workarounds.h"
...@@ -149,23 +149,17 @@ static int efx_init_port(struct efx_nic *efx) ...@@ -149,23 +149,17 @@ static int efx_init_port(struct efx_nic *efx)
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
rc = efx->phy_op->init(efx);
if (rc)
goto fail1;
efx->port_initialized = true; efx->port_initialized = true;
/* 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_mcdi_port_reconfigure(efx);
if (rc && rc != -EPERM) if (rc && rc != -EPERM)
goto fail2; goto fail;
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
return 0; return 0;
fail2: fail:
efx->phy_op->fini(efx);
fail1:
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
return rc; return rc;
} }
...@@ -177,7 +171,6 @@ static void efx_fini_port(struct efx_nic *efx) ...@@ -177,7 +171,6 @@ static void efx_fini_port(struct efx_nic *efx)
if (!efx->port_initialized) if (!efx->port_initialized)
return; return;
efx->phy_op->fini(efx);
efx->port_initialized = false; efx->port_initialized = false;
efx->link_state.up = false; efx->link_state.up = false;
...@@ -1229,7 +1222,7 @@ static int efx_pm_thaw(struct device *dev) ...@@ -1229,7 +1222,7 @@ static int efx_pm_thaw(struct device *dev)
goto fail; goto fail;
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
efx->phy_op->reconfigure(efx); efx_mcdi_port_reconfigure(efx);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
efx_start_all(efx); efx_start_all(efx);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "rx_common.h" #include "rx_common.h"
#include "tx_common.h" #include "tx_common.h"
#include "nic.h" #include "nic.h"
#include "mcdi_port_common.h"
#include "io.h" #include "io.h"
#include "mcdi_pcol.h" #include "mcdi_pcol.h"
...@@ -544,7 +545,7 @@ void efx_start_all(struct efx_nic *efx) ...@@ -544,7 +545,7 @@ void efx_start_all(struct efx_nic *efx)
* to poll now because we could have missed a change * to poll now because we could have missed a change
*/ */
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
if (efx->phy_op->poll(efx)) if (efx_mcdi_phy_poll(efx))
efx_link_status_changed(efx); efx_link_status_changed(efx);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
...@@ -714,9 +715,6 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method) ...@@ -714,9 +715,6 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method)
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
down_write(&efx->filter_sem); down_write(&efx->filter_sem);
mutex_lock(&efx->rss_lock); mutex_lock(&efx->rss_lock);
if (efx->port_initialized && method != RESET_TYPE_INVISIBLE &&
method != RESET_TYPE_DATAPATH)
efx->phy_op->fini(efx);
efx->type->fini(efx); efx->type->fini(efx);
} }
...@@ -759,10 +757,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) ...@@ -759,10 +757,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
if (efx->port_initialized && method != RESET_TYPE_INVISIBLE && if (efx->port_initialized && method != RESET_TYPE_INVISIBLE &&
method != RESET_TYPE_DATAPATH) { method != RESET_TYPE_DATAPATH) {
rc = efx->phy_op->init(efx); rc = efx_mcdi_port_reconfigure(efx);
if (rc)
goto fail;
rc = efx->phy_op->reconfigure(efx);
if (rc && rc != -EPERM) if (rc && rc != -EPERM)
netif_err(efx, drv, efx->net_dev, netif_err(efx, drv, efx->net_dev,
"could not restore PHY settings\n"); "could not restore PHY settings\n");
...@@ -959,7 +954,7 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type) ...@@ -959,7 +954,7 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
/************************************************************************** /**************************************************************************
* *
* Dummy PHY/MAC operations * Dummy NIC operations
* *
* Can be used for some unimplemented operations * Can be used for some unimplemented operations
* Needed so all function pointers are valid and do not have to be tested * Needed so all function pointers are valid and do not have to be tested
...@@ -972,18 +967,6 @@ int efx_port_dummy_op_int(struct efx_nic *efx) ...@@ -972,18 +967,6 @@ int efx_port_dummy_op_int(struct efx_nic *efx)
} }
void efx_port_dummy_op_void(struct efx_nic *efx) {} void efx_port_dummy_op_void(struct efx_nic *efx) {}
static bool efx_port_dummy_op_poll(struct efx_nic *efx)
{
return false;
}
static const struct efx_phy_operations efx_dummy_phy_operations = {
.init = efx_port_dummy_op_int,
.reconfigure = efx_port_dummy_op_int,
.poll = efx_port_dummy_op_poll,
.fini = efx_port_dummy_op_void,
};
/************************************************************************** /**************************************************************************
* *
* Data housekeeping * Data housekeeping
...@@ -1037,7 +1020,6 @@ int efx_init_struct(struct efx_nic *efx, ...@@ -1037,7 +1020,6 @@ int efx_init_struct(struct efx_nic *efx,
efx->rps_hash_table = kcalloc(EFX_ARFS_HASH_TABLE_SIZE, efx->rps_hash_table = kcalloc(EFX_ARFS_HASH_TABLE_SIZE,
sizeof(*efx->rps_hash_table), GFP_KERNEL); sizeof(*efx->rps_hash_table), GFP_KERNEL);
#endif #endif
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);
init_waitqueue_head(&efx->flush_wq); init_waitqueue_head(&efx->flush_wq);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "selftest.h" #include "selftest.h"
#include "rx_common.h" #include "rx_common.h"
#include "ethtool_common.h" #include "ethtool_common.h"
#include "mcdi_port_common.h"
struct efx_sw_stat_desc { struct efx_sw_stat_desc {
const char *name; const char *name;
...@@ -221,7 +222,7 @@ int efx_ethtool_set_pauseparam(struct net_device *net_dev, ...@@ -221,7 +222,7 @@ int efx_ethtool_set_pauseparam(struct net_device *net_dev,
efx_link_set_wanted_fc(efx, wanted_fc); efx_link_set_wanted_fc(efx, wanted_fc);
if (efx->link_advertising[0] != old_adv || if (efx->link_advertising[0] != old_adv ||
(efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) { (efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
rc = efx->phy_op->reconfigure(efx); rc = efx_mcdi_port_reconfigure(efx);
if (rc) { if (rc) {
netif_err(efx, drv, efx->net_dev, netif_err(efx, drv, efx->net_dev,
"Unable to advertise requested flow " "Unable to advertise requested flow "
...@@ -372,20 +373,15 @@ int efx_ethtool_fill_self_tests(struct efx_nic *efx, ...@@ -372,20 +373,15 @@ int efx_ethtool_fill_self_tests(struct efx_nic *efx,
efx_fill_test(n++, strings, data, &tests->registers, efx_fill_test(n++, strings, data, &tests->registers,
"core", 0, "registers", NULL); "core", 0, "registers", NULL);
if (efx->phy_op->run_tests != NULL) { for (i = 0; true; ++i) {
EFX_WARN_ON_PARANOID(efx->phy_op->test_name == NULL); const char *name;
for (i = 0; true; ++i) { EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
const char *name; name = efx_mcdi_phy_test_name(efx, i);
if (name == NULL)
EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS); break;
name = efx->phy_op->test_name(efx, i);
if (name == NULL)
break;
efx_fill_test(n++, strings, data, &tests->phy_ext[i], efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy", 0, name, NULL);
"phy", 0, name, NULL);
}
} }
/* Loopback tests */ /* Loopback tests */
...@@ -571,7 +567,7 @@ int efx_ethtool_get_link_ksettings(struct net_device *net_dev, ...@@ -571,7 +567,7 @@ int efx_ethtool_get_link_ksettings(struct net_device *net_dev,
u32 supported; u32 supported;
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
efx->phy_op->get_link_ksettings(efx, cmd); efx_mcdi_phy_get_link_ksettings(efx, cmd);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
/* Both MACs support pause frames (bidirectional and respond-only) */ /* Both MACs support pause frames (bidirectional and respond-only) */
...@@ -607,7 +603,7 @@ int efx_ethtool_set_link_ksettings(struct net_device *net_dev, ...@@ -607,7 +603,7 @@ int efx_ethtool_set_link_ksettings(struct net_device *net_dev,
} }
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
rc = efx->phy_op->set_link_ksettings(efx, cmd); rc = efx_mcdi_phy_set_link_ksettings(efx, cmd);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
return rc; return rc;
} }
...@@ -618,10 +614,8 @@ int efx_ethtool_get_fecparam(struct net_device *net_dev, ...@@ -618,10 +614,8 @@ int efx_ethtool_get_fecparam(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
int rc; int rc;
if (!efx->phy_op || !efx->phy_op->get_fecparam)
return -EOPNOTSUPP;
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
rc = efx->phy_op->get_fecparam(efx, fecparam); rc = efx_mcdi_phy_get_fecparam(efx, fecparam);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
return rc; return rc;
...@@ -633,10 +627,8 @@ int efx_ethtool_set_fecparam(struct net_device *net_dev, ...@@ -633,10 +627,8 @@ int efx_ethtool_set_fecparam(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
int rc; int rc;
if (!efx->phy_op || !efx->phy_op->get_fecparam)
return -EOPNOTSUPP;
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
rc = efx->phy_op->set_fecparam(efx, fecparam); rc = efx_mcdi_phy_set_fecparam(efx, fecparam);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
return rc; return rc;
...@@ -1332,11 +1324,8 @@ int efx_ethtool_get_module_eeprom(struct net_device *net_dev, ...@@ -1332,11 +1324,8 @@ int efx_ethtool_get_module_eeprom(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
int ret; int ret;
if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
return -EOPNOTSUPP;
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
ret = efx->phy_op->get_module_eeprom(efx, ee, data); ret = efx_mcdi_phy_get_module_eeprom(efx, ee, data);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
return ret; return ret;
...@@ -1348,11 +1337,8 @@ int efx_ethtool_get_module_info(struct net_device *net_dev, ...@@ -1348,11 +1337,8 @@ int efx_ethtool_get_module_info(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
int ret; int ret;
if (!efx->phy_op || !efx->phy_op->get_module_info)
return -EOPNOTSUPP;
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
ret = efx->phy_op->get_module_info(efx, modinfo); ret = efx_mcdi_phy_get_module_info(efx, modinfo);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
return ret; return ret;
......
...@@ -355,7 +355,6 @@ int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out); ...@@ -355,7 +355,6 @@ int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out);
int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id); int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id);
int efx_mcdi_wol_filter_reset(struct efx_nic *efx); int efx_mcdi_wol_filter_reset(struct efx_nic *efx);
int efx_mcdi_flush_rxqs(struct efx_nic *efx); int efx_mcdi_flush_rxqs(struct efx_nic *efx);
int efx_mcdi_port_reconfigure(struct efx_nic *efx);
void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev); void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev);
void efx_mcdi_mac_start_stats(struct efx_nic *efx); void efx_mcdi_mac_start_stats(struct efx_nic *efx);
void efx_mcdi_mac_stop_stats(struct efx_nic *efx); void efx_mcdi_mac_stop_stats(struct efx_nic *efx);
......
This diff is collapsed.
This diff is collapsed.
...@@ -45,9 +45,18 @@ u32 ethtool_fec_caps_to_mcdi(u32 ethtool_cap); ...@@ -45,9 +45,18 @@ u32 ethtool_fec_caps_to_mcdi(u32 ethtool_cap);
u32 mcdi_fec_caps_to_ethtool(u32 caps, bool is_25g); u32 mcdi_fec_caps_to_ethtool(u32 caps, bool is_25g);
void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa); void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa);
bool efx_mcdi_phy_poll(struct efx_nic *efx); bool efx_mcdi_phy_poll(struct efx_nic *efx);
int efx_mcdi_phy_get_fecparam(struct efx_nic *efx, int efx_mcdi_phy_probe(struct efx_nic *efx);
struct ethtool_fecparam *fec); void efx_mcdi_phy_remove(struct efx_nic *efx);
void efx_mcdi_phy_get_link_ksettings(struct efx_nic *efx, struct ethtool_link_ksettings *cmd);
int efx_mcdi_phy_set_link_ksettings(struct efx_nic *efx, const struct ethtool_link_ksettings *cmd);
int efx_mcdi_phy_get_fecparam(struct efx_nic *efx, struct ethtool_fecparam *fec);
int efx_mcdi_phy_set_fecparam(struct efx_nic *efx, const struct ethtool_fecparam *fec);
int efx_mcdi_phy_test_alive(struct efx_nic *efx); int efx_mcdi_phy_test_alive(struct efx_nic *efx);
int efx_mcdi_port_reconfigure(struct efx_nic *efx);
int efx_mcdi_phy_run_tests(struct efx_nic *efx, int *results, unsigned flags);
const char *efx_mcdi_phy_test_name(struct efx_nic *efx, unsigned int index);
int efx_mcdi_phy_get_module_eeprom(struct efx_nic *efx, struct ethtool_eeprom *ee, u8 *data);
int efx_mcdi_phy_get_module_info(struct efx_nic *efx, struct ethtool_modinfo *modinfo);
int efx_mcdi_set_mac(struct efx_nic *efx); int efx_mcdi_set_mac(struct efx_nic *efx);
int efx_mcdi_set_mtu(struct efx_nic *efx); int efx_mcdi_set_mtu(struct efx_nic *efx);
int efx_mcdi_mac_init_stats(struct efx_nic *efx); int efx_mcdi_mac_init_stats(struct efx_nic *efx);
......
...@@ -657,51 +657,6 @@ static inline bool efx_link_state_equal(const struct efx_link_state *left, ...@@ -657,51 +657,6 @@ static inline bool efx_link_state_equal(const struct efx_link_state *left,
left->fc == right->fc && left->speed == right->speed; left->fc == right->fc && left->speed == right->speed;
} }
/**
* struct efx_phy_operations - Efx PHY operations table
* @probe: Probe PHY and initialise efx->mdio.mode_support, efx->mdio.mmds,
* efx->loopback_modes.
* @init: Initialise PHY
* @fini: Shut down PHY
* @reconfigure: Reconfigure PHY (e.g. for new link parameters)
* @poll: Update @link_state and report whether it changed.
* 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.
* @get_fecparam: Get Forward Error Correction settings. Serialised by mac_lock.
* @set_fecparam: Set Forward Error Correction settings. Serialised by 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)
* @test_name: Get the name of a PHY-specific test/result
* @run_tests: Run tests and record results as appropriate (offline).
* Flags are the ethtool tests flags.
*/
struct efx_phy_operations {
int (*probe) (struct efx_nic *efx);
int (*init) (struct efx_nic *efx);
void (*fini) (struct efx_nic *efx);
void (*remove) (struct efx_nic *efx);
int (*reconfigure) (struct efx_nic *efx);
bool (*poll) (struct efx_nic *efx);
void (*get_link_ksettings)(struct efx_nic *efx,
struct ethtool_link_ksettings *cmd);
int (*set_link_ksettings)(struct efx_nic *efx,
const struct ethtool_link_ksettings *cmd);
int (*get_fecparam)(struct efx_nic *efx, struct ethtool_fecparam *fec);
int (*set_fecparam)(struct efx_nic *efx,
const struct ethtool_fecparam *fec);
void (*set_npage_adv) (struct efx_nic *efx, u32);
int (*test_alive) (struct efx_nic *efx);
const char *(*test_name) (struct efx_nic *efx, unsigned int index);
int (*run_tests) (struct efx_nic *efx, int *results, unsigned flags);
int (*get_module_eeprom) (struct efx_nic *efx,
struct ethtool_eeprom *ee,
u8 *data);
int (*get_module_info) (struct efx_nic *efx,
struct ethtool_modinfo *modinfo);
};
/** /**
* enum efx_phy_mode - PHY operating mode flags * enum efx_phy_mode - PHY operating mode flags
* @PHY_MODE_NORMAL: on and should pass traffic * @PHY_MODE_NORMAL: on and should pass traffic
...@@ -920,7 +875,6 @@ struct efx_async_filter_insertion { ...@@ -920,7 +875,6 @@ struct efx_async_filter_insertion {
* field of %MC_CMD_GET_CAPABILITIES_V4 response, or %MC_CMD_MAC_NSTATS) * field of %MC_CMD_GET_CAPABILITIES_V4 response, or %MC_CMD_MAC_NSTATS)
* @stats_buffer: DMA buffer for statistics * @stats_buffer: DMA buffer for statistics
* @phy_type: PHY type * @phy_type: PHY type
* @phy_op: PHY interface
* @phy_data: PHY private data (including PHY-specific stats) * @phy_data: PHY private data (including PHY-specific stats)
* @mdio: PHY MDIO interface * @mdio: PHY MDIO interface
* @mdio_bus: PHY MDIO bus ID (only used by Siena) * @mdio_bus: PHY MDIO bus ID (only used by Siena)
...@@ -1094,7 +1048,6 @@ struct efx_nic { ...@@ -1094,7 +1048,6 @@ struct efx_nic {
bool rx_nodesc_drops_prev_state; bool rx_nodesc_drops_prev_state;
unsigned int phy_type; unsigned int phy_type;
const struct efx_phy_operations *phy_op;
void *phy_data; void *phy_data;
struct mdio_if_info mdio; struct mdio_if_info mdio;
unsigned int mdio_bus; unsigned int mdio_bus;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "efx_common.h" #include "efx_common.h"
#include "efx_channels.h" #include "efx_channels.h"
#include "nic.h" #include "nic.h"
#include "mcdi_port_common.h"
#include "selftest.h" #include "selftest.h"
#include "workarounds.h" #include "workarounds.h"
...@@ -99,10 +100,8 @@ static int efx_test_phy_alive(struct efx_nic *efx, struct efx_self_tests *tests) ...@@ -99,10 +100,8 @@ static int efx_test_phy_alive(struct efx_nic *efx, struct efx_self_tests *tests)
{ {
int rc = 0; int rc = 0;
if (efx->phy_op->test_alive) { rc = efx_mcdi_phy_test_alive(efx);
rc = efx->phy_op->test_alive(efx); tests->phy_alive = rc ? -1 : 1;
tests->phy_alive = rc ? -1 : 1;
}
return rc; return rc;
} }
...@@ -257,11 +256,8 @@ static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests, ...@@ -257,11 +256,8 @@ static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests,
{ {
int rc; int rc;
if (!efx->phy_op->run_tests)
return 0;
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
rc = efx->phy_op->run_tests(efx, tests->phy_ext, flags); rc = efx_mcdi_phy_run_tests(efx, tests->phy_ext, flags);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
if (rc == -EPERM) if (rc == -EPERM)
rc = 0; rc = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment