Commit 6a37958b authored by Andrew Rybchenko's avatar Andrew Rybchenko Committed by David S. Miller

sfc: Forget filter ID when the filter is marked old

It is required to remove setting of filter IDs to invalid from multicast
and unicast addresses caching functions.
Add initialization to invalid when filter table is created.
Add paranoid checks to track consistency.
Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dd98708c
...@@ -3732,6 +3732,7 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx) ...@@ -3732,6 +3732,7 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx)
MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX); MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_PARSER_DISP_INFO_OUT_LENMAX);
unsigned int pd_match_pri, pd_match_count; unsigned int pd_match_pri, pd_match_count;
struct efx_ef10_filter_table *table; struct efx_ef10_filter_table *table;
unsigned int i;
size_t outlen; size_t outlen;
int rc; int rc;
...@@ -3783,6 +3784,10 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx) ...@@ -3783,6 +3784,10 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx)
goto fail; goto fail;
} }
for (i = 0; i < ARRAY_SIZE(table->dev_uc_list); i++)
table->dev_uc_list[i].id = EFX_EF10_FILTER_ID_INVALID;
for (i = 0; i < ARRAY_SIZE(table->dev_mc_list); i++)
table->dev_mc_list[i].id = EFX_EF10_FILTER_ID_INVALID;
table->ucdef_id = EFX_EF10_FILTER_ID_INVALID; table->ucdef_id = EFX_EF10_FILTER_ID_INVALID;
table->bcast_id = EFX_EF10_FILTER_ID_INVALID; table->bcast_id = EFX_EF10_FILTER_ID_INVALID;
table->mcdef_id = EFX_EF10_FILTER_ID_INVALID; table->mcdef_id = EFX_EF10_FILTER_ID_INVALID;
...@@ -3897,19 +3902,26 @@ static void efx_ef10_filter_table_remove(struct efx_nic *efx) ...@@ -3897,19 +3902,26 @@ static void efx_ef10_filter_table_remove(struct efx_nic *efx)
kfree(table); kfree(table);
} }
#define EFX_EF10_FILTER_DO_MARK_OLD(id) \ static void efx_ef10_filter_mark_one_old(struct efx_nic *efx, uint16_t *id)
if (id != EFX_EF10_FILTER_ID_INVALID) { \ {
filter_idx = efx_ef10_filter_get_unsafe_id(efx, id); \ struct efx_ef10_filter_table *table = efx->filter_state;
if (!table->entry[filter_idx].spec) \ unsigned int filter_idx;
netif_dbg(efx, drv, efx->net_dev, \
"%s: marked null spec old %04x:%04x\n", \ if (*id != EFX_EF10_FILTER_ID_INVALID) {
__func__, id, filter_idx); \ filter_idx = efx_ef10_filter_get_unsafe_id(efx, *id);
table->entry[filter_idx].spec |= EFX_EF10_FILTER_FLAG_AUTO_OLD;\ if (!table->entry[filter_idx].spec)
netif_dbg(efx, drv, efx->net_dev,
"marked null spec old %04x:%04x\n", *id,
filter_idx);
table->entry[filter_idx].spec |= EFX_EF10_FILTER_FLAG_AUTO_OLD;
*id = EFX_EF10_FILTER_ID_INVALID;
} }
}
static void efx_ef10_filter_mark_old(struct efx_nic *efx) static void efx_ef10_filter_mark_old(struct efx_nic *efx)
{ {
struct efx_ef10_filter_table *table = efx->filter_state; struct efx_ef10_filter_table *table = efx->filter_state;
unsigned int filter_idx, i; unsigned int i;
if (!table) if (!table)
return; return;
...@@ -3917,15 +3929,14 @@ static void efx_ef10_filter_mark_old(struct efx_nic *efx) ...@@ -3917,15 +3929,14 @@ static void efx_ef10_filter_mark_old(struct efx_nic *efx)
/* Mark old filters that may need to be removed */ /* Mark old filters that may need to be removed */
spin_lock_bh(&efx->filter_lock); spin_lock_bh(&efx->filter_lock);
for (i = 0; i < table->dev_uc_count; i++) for (i = 0; i < table->dev_uc_count; i++)
EFX_EF10_FILTER_DO_MARK_OLD(table->dev_uc_list[i].id); efx_ef10_filter_mark_one_old(efx, &table->dev_uc_list[i].id);
for (i = 0; i < table->dev_mc_count; i++) for (i = 0; i < table->dev_mc_count; i++)
EFX_EF10_FILTER_DO_MARK_OLD(table->dev_mc_list[i].id); efx_ef10_filter_mark_one_old(efx, &table->dev_mc_list[i].id);
EFX_EF10_FILTER_DO_MARK_OLD(table->ucdef_id); efx_ef10_filter_mark_one_old(efx, &table->ucdef_id);
EFX_EF10_FILTER_DO_MARK_OLD(table->bcast_id); efx_ef10_filter_mark_one_old(efx, &table->bcast_id);
EFX_EF10_FILTER_DO_MARK_OLD(table->mcdef_id); efx_ef10_filter_mark_one_old(efx, &table->mcdef_id);
spin_unlock_bh(&efx->filter_lock); spin_unlock_bh(&efx->filter_lock);
} }
#undef EFX_EF10_FILTER_DO_MARK_OLD
static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc) static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc)
{ {
...@@ -3935,7 +3946,6 @@ static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc) ...@@ -3935,7 +3946,6 @@ static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc)
int addr_count; int addr_count;
unsigned int i; unsigned int i;
table->ucdef_id = EFX_EF10_FILTER_ID_INVALID;
addr_count = netdev_uc_count(net_dev); addr_count = netdev_uc_count(net_dev);
if (net_dev->flags & IFF_PROMISC) if (net_dev->flags & IFF_PROMISC)
*promisc = true; *promisc = true;
...@@ -3948,7 +3958,6 @@ static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc) ...@@ -3948,7 +3958,6 @@ static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc)
break; break;
} }
ether_addr_copy(table->dev_uc_list[i].addr, uc->addr); ether_addr_copy(table->dev_uc_list[i].addr, uc->addr);
table->dev_uc_list[i].id = EFX_EF10_FILTER_ID_INVALID;
i++; i++;
} }
} }
...@@ -3960,8 +3969,6 @@ static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc) ...@@ -3960,8 +3969,6 @@ static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc)
struct netdev_hw_addr *mc; struct netdev_hw_addr *mc;
unsigned int i, addr_count; unsigned int i, addr_count;
table->mcdef_id = EFX_EF10_FILTER_ID_INVALID;
table->bcast_id = EFX_EF10_FILTER_ID_INVALID;
if (net_dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) if (net_dev->flags & (IFF_PROMISC | IFF_ALLMULTI))
*promisc = true; *promisc = true;
...@@ -3973,7 +3980,6 @@ static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc) ...@@ -3973,7 +3980,6 @@ static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc)
break; break;
} }
ether_addr_copy(table->dev_mc_list[i].addr, mc->addr); ether_addr_copy(table->dev_mc_list[i].addr, mc->addr);
table->dev_mc_list[i].id = EFX_EF10_FILTER_ID_INVALID;
i++; i++;
} }
...@@ -4051,6 +4057,8 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx, ...@@ -4051,6 +4057,8 @@ static int efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
} }
return rc; return rc;
} else { } else {
EFX_WARN_ON_PARANOID(table->bcast_id !=
EFX_EF10_FILTER_ID_INVALID);
table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc); table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc);
} }
} }
...@@ -4084,6 +4092,8 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast, ...@@ -4084,6 +4092,8 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast,
"%scast mismatch filter insert failed rc=%d\n", "%scast mismatch filter insert failed rc=%d\n",
multicast ? "Multi" : "Uni", rc); multicast ? "Multi" : "Uni", rc);
} else if (multicast) { } else if (multicast) {
EFX_WARN_ON_PARANOID(table->mcdef_id !=
EFX_EF10_FILTER_ID_INVALID);
table->mcdef_id = efx_ef10_filter_get_unsafe_id(efx, rc); table->mcdef_id = efx_ef10_filter_get_unsafe_id(efx, rc);
if (!nic_data->workaround_26807) { if (!nic_data->workaround_26807) {
/* Also need an Ethernet broadcast filter */ /* Also need an Ethernet broadcast filter */
...@@ -4106,11 +4116,14 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast, ...@@ -4106,11 +4116,14 @@ static int efx_ef10_filter_insert_def(struct efx_nic *efx, bool multicast,
return rc; return rc;
} }
} else { } else {
EFX_WARN_ON_PARANOID(table->bcast_id !=
EFX_EF10_FILTER_ID_INVALID);
table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc); table->bcast_id = efx_ef10_filter_get_unsafe_id(efx, rc);
} }
} }
rc = 0; rc = 0;
} else { } else {
EFX_WARN_ON_PARANOID(table->ucdef_id != EFX_EF10_FILTER_ID_INVALID);
table->ucdef_id = rc; table->ucdef_id = rc;
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