summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/sfc/efx_common.c
diff options
context:
space:
mode:
authorAlex Maftei (amaftei) <amaftei@solarflare.com>2020-01-09 18:45:29 +0300
committerDavid S. Miller <davem@davemloft.net>2020-01-09 21:58:35 +0300
commitb5775b476ef7b28a3895335a2b8533e10ba36b16 (patch)
tree0017179c2b276279b331e20258db901c2558e8aa /drivers/net/ethernet/sfc/efx_common.c
parent8da92642050df4d466cacd04bbb1d6232b070022 (diff)
downloadlinux-b5775b476ef7b28a3895335a2b8533e10ba36b16.tar.xz
sfc: conditioned some functionality
Before calling certain function pointers, check that they are non-NULL. Signed-off-by: Alexandru-Mihai Maftei <amaftei@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/sfc/efx_common.c')
-rw-r--r--drivers/net/ethernet/sfc/efx_common.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/drivers/net/ethernet/sfc/efx_common.c b/drivers/net/ethernet/sfc/efx_common.c
index fe74c66c8ec6..3add2b577503 100644
--- a/drivers/net/ethernet/sfc/efx_common.c
+++ b/drivers/net/ethernet/sfc/efx_common.c
@@ -141,9 +141,11 @@ void efx_destroy_reset_workqueue(void)
*/
void efx_mac_reconfigure(struct efx_nic *efx)
{
- down_read(&efx->filter_sem);
- efx->type->reconfigure_mac(efx);
- up_read(&efx->filter_sem);
+ if (efx->type->reconfigure_mac) {
+ down_read(&efx->filter_sem);
+ efx->type->reconfigure_mac(efx);
+ up_read(&efx->filter_sem);
+ }
}
/* Asynchronous work item for changing MAC promiscuity and multicast
@@ -296,7 +298,8 @@ static void efx_start_datapath(struct efx_nic *efx)
netdev_features_change(efx->net_dev);
/* RX filters may also have scatter-enabled flags */
- if (efx->rx_scatter != old_rx_scatter)
+ if ((efx->rx_scatter != old_rx_scatter) &&
+ efx->type->filter_update_rx_scatter)
efx->type->filter_update_rx_scatter(efx);
/* We must keep at least one descriptor in a TX ring empty.
@@ -405,11 +408,13 @@ void efx_start_all(struct efx_nic *efx)
efx_link_status_changed(efx);
mutex_unlock(&efx->mac_lock);
- efx->type->start_stats(efx);
- efx->type->pull_stats(efx);
- spin_lock_bh(&efx->stats_lock);
- efx->type->update_stats(efx, NULL, NULL);
- spin_unlock_bh(&efx->stats_lock);
+ if (efx->type->start_stats) {
+ efx->type->start_stats(efx);
+ efx->type->pull_stats(efx);
+ spin_lock_bh(&efx->stats_lock);
+ efx->type->update_stats(efx, NULL, NULL);
+ spin_unlock_bh(&efx->stats_lock);
+ }
}
/* Quiesce the hardware and software data path, and regular activity
@@ -425,14 +430,17 @@ void efx_stop_all(struct efx_nic *efx)
if (!efx->port_enabled)
return;
- /* update stats before we go down so we can accurately count
- * rx_nodesc_drops
- */
- efx->type->pull_stats(efx);
- spin_lock_bh(&efx->stats_lock);
- efx->type->update_stats(efx, NULL, NULL);
- spin_unlock_bh(&efx->stats_lock);
- efx->type->stop_stats(efx);
+ if (efx->type->update_stats) {
+ /* update stats before we go down so we can accurately count
+ * rx_nodesc_drops
+ */
+ efx->type->pull_stats(efx);
+ spin_lock_bh(&efx->stats_lock);
+ efx->type->update_stats(efx, NULL, NULL);
+ spin_unlock_bh(&efx->stats_lock);
+ efx->type->stop_stats(efx);
+ }
+
efx_stop_port(efx);
/* Stop the kernel transmit interface. This is only valid if
@@ -456,7 +464,7 @@ void efx_stop_all(struct efx_nic *efx)
int __efx_reconfigure_port(struct efx_nic *efx)
{
enum efx_phy_mode phy_mode;
- int rc;
+ int rc = 0;
WARN_ON(!mutex_is_locked(&efx->mac_lock));
@@ -467,7 +475,8 @@ int __efx_reconfigure_port(struct efx_nic *efx)
else
efx->phy_mode &= ~PHY_MODE_TX_DISABLED;
- rc = efx->type->reconfigure_port(efx);
+ if (efx->type->reconfigure_port)
+ rc = efx->type->reconfigure_port(efx);
if (rc)
efx->phy_mode = phy_mode;