Commit ab8b1f7c authored by Daniel Pieczko's avatar Daniel Pieczko Committed by David S. Miller

sfc: support cascaded multicast filters

If the workaround to support cascaded multicast filters ("workaround_26807") is
enabled, the broadcast filter and individual multicast filters are not inserted
when in promiscuous or allmulti mode.

There is a race while inserting and removing filters when entering and leaving
promiscuous mode.  When changing promiscuous state with cascaded multicast
filters, the old multicast filters are removed before inserting the new filters
to avoid duplicating packets; this can lead to dropped packets until all
filters have been inserted.

The efx_nic:mc_promisc flag is added to record the presence of a multicast
promiscuous filter; this gives a simple way to tell if the promiscuous state is
changing.
Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 822b96f8
...@@ -3792,16 +3792,36 @@ static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc) ...@@ -3792,16 +3792,36 @@ static void efx_ef10_filter_uc_addr_list(struct efx_nic *efx, bool *promisc)
static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc) static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc)
{ {
struct efx_ef10_filter_table *table = efx->filter_state; struct efx_ef10_filter_table *table = efx->filter_state;
struct efx_ef10_nic_data *nic_data = efx->nic_data;
struct net_device *net_dev = efx->net_dev; struct net_device *net_dev = efx->net_dev;
struct netdev_hw_addr *mc; struct netdev_hw_addr *mc;
unsigned int i; unsigned int i, addr_count;
if (netdev_mc_count(net_dev) + 2 /* room for broadcast and promisc */ if (net_dev->flags & (IFF_PROMISC | IFF_ALLMULTI))
>= EFX_EF10_FILTER_DEV_MC_MAX) { *promisc = true;
if (nic_data->workaround_26807) {
if (*promisc) {
table->dev_mc_count = 0;
return;
}
addr_count = netdev_mc_count(net_dev);
} else {
/* Allow room for broadcast and promiscuous */
addr_count = netdev_mc_count(net_dev) + 2;
}
if (addr_count >= EFX_EF10_FILTER_DEV_MC_MAX) {
if (nic_data->workaround_26807) {
table->dev_mc_count = 0;
} else {
table->dev_mc_count = 1; table->dev_mc_count = 1;
eth_broadcast_addr(table->dev_mc_list[0].addr); eth_broadcast_addr(table->dev_mc_list[0].addr);
}
*promisc = true; *promisc = true;
} else { return;
}
table->dev_mc_count = 1 + netdev_mc_count(net_dev); table->dev_mc_count = 1 + netdev_mc_count(net_dev);
eth_broadcast_addr(table->dev_mc_list[0].addr); eth_broadcast_addr(table->dev_mc_list[0].addr);
i = 1; i = 1;
...@@ -3809,10 +3829,6 @@ static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc) ...@@ -3809,10 +3829,6 @@ static void efx_ef10_filter_mc_addr_list(struct efx_nic *efx, bool *promisc)
ether_addr_copy(table->dev_mc_list[i].addr, mc->addr); ether_addr_copy(table->dev_mc_list[i].addr, mc->addr);
i++; i++;
} }
if (net_dev->flags & (IFF_PROMISC | IFF_ALLMULTI))
*promisc = true;
}
} }
static void efx_ef10_filter_insert_addr_list(struct efx_nic *efx, static void efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
...@@ -3846,7 +3862,11 @@ static void efx_ef10_filter_insert_addr_list(struct efx_nic *efx, ...@@ -3846,7 +3862,11 @@ static void efx_ef10_filter_insert_addr_list(struct efx_nic *efx,
* filter for multicast * filter for multicast
*/ */
while (i--) { while (i--) {
if (multicast && i == 1) struct efx_ef10_nic_data *nic_data =
efx->nic_data;
if (multicast && i == 1 &&
!nic_data->workaround_26807)
break; break;
efx_ef10_filter_remove_safe( efx_ef10_filter_remove_safe(
...@@ -3974,6 +3994,7 @@ static int efx_ef10_vport_set_mac_address(struct efx_nic *efx) ...@@ -3974,6 +3994,7 @@ static int efx_ef10_vport_set_mac_address(struct efx_nic *efx)
static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx) static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
{ {
struct efx_ef10_filter_table *table = efx->filter_state; struct efx_ef10_filter_table *table = efx->filter_state;
struct efx_ef10_nic_data *nic_data = efx->nic_data;
struct net_device *net_dev = efx->net_dev; struct net_device *net_dev = efx->net_dev;
bool uc_promisc = false, mc_promisc = false; bool uc_promisc = false, mc_promisc = false;
...@@ -3995,9 +4016,16 @@ static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx) ...@@ -3995,9 +4016,16 @@ static void efx_ef10_filter_sync_rx_mode(struct efx_nic *efx)
/* Insert/renew filters */ /* Insert/renew filters */
efx_ef10_filter_insert_addr_list(efx, false, &uc_promisc); efx_ef10_filter_insert_addr_list(efx, false, &uc_promisc);
/* If changing promiscuous state with cascaded multicast filters, remove
* old filters first, so that packets are dropped rather than duplicated
*/
if (nic_data->workaround_26807 && efx->mc_promisc != mc_promisc)
efx_ef10_filter_remove_old(efx);
efx_ef10_filter_insert_addr_list(efx, true, &mc_promisc); efx_ef10_filter_insert_addr_list(efx, true, &mc_promisc);
efx_ef10_filter_remove_old(efx); efx_ef10_filter_remove_old(efx);
efx->mc_promisc = mc_promisc;
} }
static int efx_ef10_set_mac_address(struct efx_nic *efx) static int efx_ef10_set_mac_address(struct efx_nic *efx)
......
...@@ -925,6 +925,7 @@ struct vfdi_status; ...@@ -925,6 +925,7 @@ struct vfdi_status;
* @stats_lock: Statistics update lock. Must be held when calling * @stats_lock: Statistics update lock. Must be held when calling
* efx_nic_type::{update,start,stop}_stats. * efx_nic_type::{update,start,stop}_stats.
* @n_rx_noskb_drops: Count of RX packets dropped due to failure to allocate an skb * @n_rx_noskb_drops: Count of RX packets dropped due to failure to allocate an skb
* @mc_promisc: Whether in multicast promiscuous mode when last changed
* *
* This is stored in the private area of the &struct net_device. * This is stored in the private area of the &struct net_device.
*/ */
...@@ -1072,6 +1073,7 @@ struct efx_nic { ...@@ -1072,6 +1073,7 @@ struct efx_nic {
int last_irq_cpu; int last_irq_cpu;
spinlock_t stats_lock; spinlock_t stats_lock;
atomic_t n_rx_noskb_drops; atomic_t n_rx_noskb_drops;
bool mc_promisc;
}; };
static inline int efx_dev_registered(struct efx_nic *efx) static inline int efx_dev_registered(struct efx_nic *efx)
......
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