Skip to content

Commit

Permalink
Merge branch 'sfc-even-more-code-refactoring'
Browse files Browse the repository at this point in the history
Alex Maftei says:

====================
sfc: even more code refactoring

Splitting even more of the driver code into different files, which
will later be used in another driver for a new product.

This is a continuation to my previous patch series, and the one
before it.
There will be a stand-alone patch as well after this - after which
the refactoring will be concluded, for now.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 10, 2020
2 parents 9f120e7 + f7226e0 commit 7112f8b
Show file tree
Hide file tree
Showing 25 changed files with 1,353 additions and 1,266 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/sfc/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: GPL-2.0
sfc-y += efx.o efx_common.o efx_channels.o nic.o \
farch.o siena.o ef10.o \
tx.o tx_common.o rx.o rx_common.o \
selftest.o ethtool.o ptp.o tx_tso.o \
tx.o tx_common.o tx_tso.o rx.o rx_common.o \
selftest.o ethtool.o ethtool_common.o ptp.o \
mcdi.o mcdi_port.o mcdi_port_common.o \
mcdi_functions.o mcdi_mon.o
sfc-$(CONFIG_SFC_MTD) += mtd.o
Expand Down
69 changes: 18 additions & 51 deletions drivers/net/ethernet/sfc/ef10.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,6 @@ static bool efx_ef10_is_vf(struct efx_nic *efx)
return efx->type->is_vf;
}

static int efx_ef10_get_pf_index(struct efx_nic *efx)
{
MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_FUNCTION_INFO_OUT_LEN);
struct efx_ef10_nic_data *nic_data = efx->nic_data;
size_t outlen;
int rc;

rc = efx_mcdi_rpc(efx, MC_CMD_GET_FUNCTION_INFO, NULL, 0, outbuf,
sizeof(outbuf), &outlen);
if (rc)
return rc;
if (outlen < sizeof(outbuf))
return -EIO;

nic_data->pf_index = MCDI_DWORD(outbuf, GET_FUNCTION_INFO_OUT_PF);
return 0;
}

#ifdef CONFIG_SFC_SRIOV
static int efx_ef10_get_vf_index(struct efx_nic *efx)
{
Expand Down Expand Up @@ -277,24 +259,9 @@ static int efx_ef10_init_datapath_caps(struct efx_nic *efx)
u8 vi_window_mode = MCDI_BYTE(outbuf,
GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE);

switch (vi_window_mode) {
case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_8K:
efx->vi_stride = 8192;
break;
case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_16K:
efx->vi_stride = 16384;
break;
case MC_CMD_GET_CAPABILITIES_V3_OUT_VI_WINDOW_MODE_64K:
efx->vi_stride = 65536;
break;
default:
netif_err(efx, probe, efx->net_dev,
"Unrecognised VI window mode %d\n",
vi_window_mode);
return -EIO;
}
netif_dbg(efx, probe, efx->net_dev, "vi_stride = %u\n",
efx->vi_stride);
rc = efx_mcdi_window_mode_to_stride(efx, vi_window_mode);
if (rc)
return rc;
} else {
/* keep default VI stride */
netif_dbg(efx, probe, efx->net_dev,
Expand Down Expand Up @@ -693,7 +660,7 @@ static int efx_ef10_probe(struct efx_nic *efx)
}
nic_data->warm_boot_count = rc;

efx->rss_context.context_id = EFX_EF10_RSS_CONTEXT_INVALID;
efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID;

nic_data->vport_id = EVB_PORT_ID_ASSIGNED;

Expand Down Expand Up @@ -729,7 +696,7 @@ static int efx_ef10_probe(struct efx_nic *efx)
if (rc)
goto fail4;

rc = efx_ef10_get_pf_index(efx);
rc = efx_get_pf_index(efx, &nic_data->pf_index);
if (rc)
goto fail5;

Expand Down Expand Up @@ -1473,7 +1440,7 @@ static void efx_ef10_reset_mc_allocations(struct efx_nic *efx)
nic_data->must_restore_filters = true;
nic_data->must_restore_piobufs = true;
efx_ef10_forget_old_piobufs(efx);
efx->rss_context.context_id = EFX_EF10_RSS_CONTEXT_INVALID;
efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID;

/* Driver-created vswitches and vports must be re-created */
nic_data->must_probe_vswitching = true;
Expand Down Expand Up @@ -2631,7 +2598,7 @@ static int efx_ef10_alloc_rss_context(struct efx_nic *efx, bool exclusive,
EFX_EF10_MAX_SHARED_RSS_CONTEXT_SIZE);

if (!exclusive && rss_spread == 1) {
ctx->context_id = EFX_EF10_RSS_CONTEXT_INVALID;
ctx->context_id = EFX_MCDI_RSS_CONTEXT_INVALID;
if (context_size)
*context_size = 1;
return 0;
Expand Down Expand Up @@ -2718,11 +2685,11 @@ static void efx_ef10_rx_free_indir_table(struct efx_nic *efx)
{
int rc;

if (efx->rss_context.context_id != EFX_EF10_RSS_CONTEXT_INVALID) {
if (efx->rss_context.context_id != EFX_MCDI_RSS_CONTEXT_INVALID) {
rc = efx_ef10_free_rss_context(efx, efx->rss_context.context_id);
WARN_ON(rc != 0);
}
efx->rss_context.context_id = EFX_EF10_RSS_CONTEXT_INVALID;
efx->rss_context.context_id = EFX_MCDI_RSS_CONTEXT_INVALID;
}

static int efx_ef10_rx_push_shared_rss_config(struct efx_nic *efx,
Expand All @@ -2748,7 +2715,7 @@ static int efx_ef10_rx_push_exclusive_rss_config(struct efx_nic *efx,
struct efx_ef10_nic_data *nic_data = efx->nic_data;
int rc;

if (efx->rss_context.context_id == EFX_EF10_RSS_CONTEXT_INVALID ||
if (efx->rss_context.context_id == EFX_MCDI_RSS_CONTEXT_INVALID ||
!nic_data->rx_rss_context_exclusive) {
rc = efx_ef10_alloc_rss_context(efx, true, &efx->rss_context,
NULL);
Expand All @@ -2764,7 +2731,7 @@ static int efx_ef10_rx_push_exclusive_rss_config(struct efx_nic *efx,
goto fail2;

if (efx->rss_context.context_id != old_rx_rss_context &&
old_rx_rss_context != EFX_EF10_RSS_CONTEXT_INVALID)
old_rx_rss_context != EFX_MCDI_RSS_CONTEXT_INVALID)
WARN_ON(efx_ef10_free_rss_context(efx, old_rx_rss_context) != 0);
nic_data->rx_rss_context_exclusive = true;
if (rx_indir_table != efx->rss_context.rx_indir_table)
Expand Down Expand Up @@ -2795,7 +2762,7 @@ static int efx_ef10_rx_push_rss_context_config(struct efx_nic *efx,

WARN_ON(!mutex_is_locked(&efx->rss_lock));

if (ctx->context_id == EFX_EF10_RSS_CONTEXT_INVALID) {
if (ctx->context_id == EFX_MCDI_RSS_CONTEXT_INVALID) {
rc = efx_ef10_alloc_rss_context(efx, true, ctx, NULL);
if (rc)
return rc;
Expand Down Expand Up @@ -2830,7 +2797,7 @@ static int efx_ef10_rx_pull_rss_context_config(struct efx_nic *efx,
BUILD_BUG_ON(MC_CMD_RSS_CONTEXT_GET_TABLE_IN_LEN !=
MC_CMD_RSS_CONTEXT_GET_KEY_IN_LEN);

if (ctx->context_id == EFX_EF10_RSS_CONTEXT_INVALID)
if (ctx->context_id == EFX_MCDI_RSS_CONTEXT_INVALID)
return -ENOENT;

MCDI_SET_DWORD(inbuf, RSS_CONTEXT_GET_TABLE_IN_RSS_CONTEXT_ID,
Expand Down Expand Up @@ -2891,7 +2858,7 @@ static void efx_ef10_rx_restore_rss_contexts(struct efx_nic *efx)

list_for_each_entry(ctx, &efx->rss_context.list, list) {
/* previous NIC RSS context is gone */
ctx->context_id = EFX_EF10_RSS_CONTEXT_INVALID;
ctx->context_id = EFX_MCDI_RSS_CONTEXT_INVALID;
/* so try to allocate a new one */
rc = efx_ef10_rx_push_rss_context_config(efx, ctx,
ctx->rx_indir_table,
Expand Down Expand Up @@ -2962,7 +2929,7 @@ static int efx_ef10_vf_rx_push_rss_config(struct efx_nic *efx, bool user,
{
if (user)
return -EOPNOTSUPP;
if (efx->rss_context.context_id != EFX_EF10_RSS_CONTEXT_INVALID)
if (efx->rss_context.context_id != EFX_MCDI_RSS_CONTEXT_INVALID)
return 0;
return efx_ef10_rx_push_shared_rss_config(efx, NULL);
}
Expand Down Expand Up @@ -3883,7 +3850,7 @@ static void efx_ef10_filter_push_prep(struct efx_nic *efx,
*/
if (WARN_ON_ONCE(!ctx))
flags &= ~EFX_FILTER_FLAG_RX_RSS;
else if (WARN_ON_ONCE(ctx->context_id == EFX_EF10_RSS_CONTEXT_INVALID))
else if (WARN_ON_ONCE(ctx->context_id == EFX_MCDI_RSS_CONTEXT_INVALID))
flags &= ~EFX_FILTER_FLAG_RX_RSS;
}

Expand Down Expand Up @@ -4062,7 +4029,7 @@ static s32 efx_ef10_filter_insert_locked(struct efx_nic *efx,
rc = -ENOENT;
goto out_unlock;
}
if (ctx->context_id == EFX_EF10_RSS_CONTEXT_INVALID) {
if (ctx->context_id == EFX_MCDI_RSS_CONTEXT_INVALID) {
rc = -EOPNOTSUPP;
goto out_unlock;
}
Expand Down Expand Up @@ -4803,7 +4770,7 @@ static void efx_ef10_filter_table_restore(struct efx_nic *efx)
invalid_filters++;
goto not_restored;
}
if (ctx->context_id == EFX_EF10_RSS_CONTEXT_INVALID) {
if (ctx->context_id == EFX_MCDI_RSS_CONTEXT_INVALID) {
netif_warn(efx, drv, efx->net_dev,
"Warning: unable to restore a filter with RSS context %u as it was not created.\n",
spec->rss_context);
Expand Down
Loading

0 comments on commit 7112f8b

Please sign in to comment.