Skip to content

Commit

Permalink
sfc: remove phy_op indirection
Browse files Browse the repository at this point in the history
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: Edward Cree <ecree@solarflare.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Edward Cree authored and Jakub Kicinski committed Sep 7, 2020
1 parent 7dcc9d8 commit c77289b
Show file tree
Hide file tree
Showing 9 changed files with 601 additions and 712 deletions.
17 changes: 5 additions & 12 deletions drivers/net/ethernet/sfc/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "selftest.h"
#include "sriov.h"

#include "mcdi.h"
#include "mcdi_port_common.h"
#include "mcdi_pcol.h"
#include "workarounds.h"

Expand Down Expand Up @@ -149,23 +149,17 @@ static int efx_init_port(struct efx_nic *efx)

mutex_lock(&efx->mac_lock);

rc = efx->phy_op->init(efx);
if (rc)
goto fail1;

efx->port_initialized = true;

/* 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)
goto fail2;
goto fail;

mutex_unlock(&efx->mac_lock);
return 0;

fail2:
efx->phy_op->fini(efx);
fail1:
fail:
mutex_unlock(&efx->mac_lock);
return rc;
}
Expand All @@ -177,7 +171,6 @@ static void efx_fini_port(struct efx_nic *efx)
if (!efx->port_initialized)
return;

efx->phy_op->fini(efx);
efx->port_initialized = false;

efx->link_state.up = false;
Expand Down Expand Up @@ -1229,7 +1222,7 @@ static int efx_pm_thaw(struct device *dev)
goto fail;

mutex_lock(&efx->mac_lock);
efx->phy_op->reconfigure(efx);
efx_mcdi_port_reconfigure(efx);
mutex_unlock(&efx->mac_lock);

efx_start_all(efx);
Expand Down
26 changes: 4 additions & 22 deletions drivers/net/ethernet/sfc/efx_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "rx_common.h"
#include "tx_common.h"
#include "nic.h"
#include "mcdi_port_common.h"
#include "io.h"
#include "mcdi_pcol.h"

Expand Down Expand Up @@ -544,7 +545,7 @@ void efx_start_all(struct efx_nic *efx)
* to poll now because we could have missed a change
*/
mutex_lock(&efx->mac_lock);
if (efx->phy_op->poll(efx))
if (efx_mcdi_phy_poll(efx))
efx_link_status_changed(efx);
mutex_unlock(&efx->mac_lock);

Expand Down Expand Up @@ -714,9 +715,6 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method)
mutex_lock(&efx->mac_lock);
down_write(&efx->filter_sem);
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);
}

Expand Down Expand Up @@ -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 &&
method != RESET_TYPE_DATAPATH) {
rc = efx->phy_op->init(efx);
if (rc)
goto fail;
rc = efx->phy_op->reconfigure(efx);
rc = efx_mcdi_port_reconfigure(efx);
if (rc && rc != -EPERM)
netif_err(efx, drv, efx->net_dev,
"could not restore PHY settings\n");
Expand Down Expand Up @@ -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
* Needed so all function pointers are valid and do not have to be tested
Expand All @@ -972,18 +967,6 @@ int efx_port_dummy_op_int(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
Expand Down Expand Up @@ -1037,7 +1020,6 @@ int efx_init_struct(struct efx_nic *efx,
efx->rps_hash_table = kcalloc(EFX_ARFS_HASH_TABLE_SIZE,
sizeof(*efx->rps_hash_table), GFP_KERNEL);
#endif
efx->phy_op = &efx_dummy_phy_operations;
efx->mdio.dev = net_dev;
INIT_WORK(&efx->mac_work, efx_mac_work);
init_waitqueue_head(&efx->flush_wq);
Expand Down
44 changes: 15 additions & 29 deletions drivers/net/ethernet/sfc/ethtool_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "selftest.h"
#include "rx_common.h"
#include "ethtool_common.h"
#include "mcdi_port_common.h"

struct efx_sw_stat_desc {
const char *name;
Expand Down Expand Up @@ -221,7 +222,7 @@ int efx_ethtool_set_pauseparam(struct net_device *net_dev,
efx_link_set_wanted_fc(efx, wanted_fc);
if (efx->link_advertising[0] != old_adv ||
(efx->wanted_fc ^ old_fc) & EFX_FC_AUTO) {
rc = efx->phy_op->reconfigure(efx);
rc = efx_mcdi_port_reconfigure(efx);
if (rc) {
netif_err(efx, drv, efx->net_dev,
"Unable to advertise requested flow "
Expand Down Expand Up @@ -372,20 +373,15 @@ int efx_ethtool_fill_self_tests(struct efx_nic *efx,
efx_fill_test(n++, strings, data, &tests->registers,
"core", 0, "registers", NULL);

if (efx->phy_op->run_tests != NULL) {
EFX_WARN_ON_PARANOID(efx->phy_op->test_name == NULL);
for (i = 0; true; ++i) {
const char *name;

for (i = 0; true; ++i) {
const char *name;

EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
name = efx->phy_op->test_name(efx, i);
if (name == NULL)
break;
EFX_WARN_ON_PARANOID(i >= EFX_MAX_PHY_TESTS);
name = efx_mcdi_phy_test_name(efx, i);
if (name == NULL)
break;

efx_fill_test(n++, strings, data, &tests->phy_ext[i],
"phy", 0, name, NULL);
}
efx_fill_test(n++, strings, data, &tests->phy_ext[i], "phy", 0, name, NULL);
}

/* Loopback tests */
Expand Down Expand Up @@ -571,7 +567,7 @@ int efx_ethtool_get_link_ksettings(struct net_device *net_dev,
u32 supported;

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);

/* Both MACs support pause frames (bidirectional and respond-only) */
Expand Down Expand Up @@ -607,7 +603,7 @@ int efx_ethtool_set_link_ksettings(struct net_device *net_dev,
}

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);
return rc;
}
Expand All @@ -618,10 +614,8 @@ int efx_ethtool_get_fecparam(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev);
int rc;

if (!efx->phy_op || !efx->phy_op->get_fecparam)
return -EOPNOTSUPP;
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);

return rc;
Expand All @@ -633,10 +627,8 @@ int efx_ethtool_set_fecparam(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev);
int rc;

if (!efx->phy_op || !efx->phy_op->get_fecparam)
return -EOPNOTSUPP;
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);

return rc;
Expand Down Expand Up @@ -1332,11 +1324,8 @@ int efx_ethtool_get_module_eeprom(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev);
int ret;

if (!efx->phy_op || !efx->phy_op->get_module_eeprom)
return -EOPNOTSUPP;

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);

return ret;
Expand All @@ -1348,11 +1337,8 @@ int efx_ethtool_get_module_info(struct net_device *net_dev,
struct efx_nic *efx = netdev_priv(net_dev);
int ret;

if (!efx->phy_op || !efx->phy_op->get_module_info)
return -EOPNOTSUPP;

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);

return ret;
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/sfc/mcdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_reset(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_mac_start_stats(struct efx_nic *efx);
void efx_mcdi_mac_stop_stats(struct efx_nic *efx);
Expand Down
Loading

0 comments on commit c77289b

Please sign in to comment.