Skip to content

Commit

Permalink
net/nfb: fix multicast/promiscuous mode switching
Browse files Browse the repository at this point in the history
[ upstream commit 6685343 ]

In the firmware, the promisc mode overrides the multicast mode.
So when the promisc mode is turned off, driver must check if the
multicast mode was active before and conditionally reactivate it.

Fixes: 6435f9a ("net/nfb: add new netcope driver")

Signed-off-by: Martin Spinler <spinler@cesnet.cz>
  • Loading branch information
martinspinler authored and bluca committed Feb 28, 2022
1 parent aa27fa7 commit 3a4dd26
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
4 changes: 0 additions & 4 deletions drivers/net/nfb/nfb.h
Expand Up @@ -48,10 +48,6 @@ struct pmd_internals {

char nfb_dev[PATH_MAX];
struct nfb_device *nfb;
/* Place to remember if filter was promiscuous or filtering by table,
* when disabling allmulticast
*/
enum nc_rxmac_mac_filter rx_filter_original;
};

#endif /* _NFB_H_ */
1 change: 0 additions & 1 deletion drivers/net/nfb/nfb_ethdev.c
Expand Up @@ -516,7 +516,6 @@ nfb_eth_dev_init(struct rte_eth_dev *dev)

data->promiscuous = nfb_eth_promiscuous_get(dev);
data->all_multicast = nfb_eth_allmulticast_get(dev);
internals->rx_filter_original = data->promiscuous;

dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;

Expand Down
20 changes: 8 additions & 12 deletions drivers/net/nfb/nfb_rxmode.c
Expand Up @@ -14,8 +14,6 @@ nfb_eth_promiscuous_enable(struct rte_eth_dev *dev)
dev->data->dev_private;
uint16_t i;

internals->rx_filter_original = RXMAC_MAC_FILTER_PROMISCUOUS;

for (i = 0; i < internals->max_rxmac; ++i) {
nc_rxmac_mac_filter_enable(internals->rxmac[i],
RXMAC_MAC_FILTER_PROMISCUOUS);
Expand All @@ -30,16 +28,13 @@ nfb_eth_promiscuous_disable(struct rte_eth_dev *dev)
struct pmd_internals *internals = (struct pmd_internals *)
dev->data->dev_private;
uint16_t i;
enum nc_rxmac_mac_filter filter = RXMAC_MAC_FILTER_TABLE_BCAST;

internals->rx_filter_original = RXMAC_MAC_FILTER_TABLE;

/* if promisc is not enabled, do nothing */
if (!nfb_eth_promiscuous_get(dev))
return 0;
if (dev->data->all_multicast)
filter = RXMAC_MAC_FILTER_TABLE_BCAST_MCAST;

for (i = 0; i < internals->max_rxmac; ++i) {
nc_rxmac_mac_filter_enable(internals->rxmac[i],
RXMAC_MAC_FILTER_TABLE);
nc_rxmac_mac_filter_enable(internals->rxmac[i], filter);
}

return 0;
Expand Down Expand Up @@ -67,6 +62,8 @@ nfb_eth_allmulticast_enable(struct rte_eth_dev *dev)
dev->data->dev_private;

uint16_t i;
if (dev->data->promiscuous)
return 0;
for (i = 0; i < internals->max_rxmac; ++i) {
nc_rxmac_mac_filter_enable(internals->rxmac[i],
RXMAC_MAC_FILTER_TABLE_BCAST_MCAST);
Expand All @@ -83,13 +80,12 @@ nfb_eth_allmulticast_disable(struct rte_eth_dev *dev)

uint16_t i;

/* if multicast is not enabled do nothing */
if (!nfb_eth_allmulticast_get(dev))
if (dev->data->promiscuous)
return 0;

for (i = 0; i < internals->max_rxmac; ++i) {
nc_rxmac_mac_filter_enable(internals->rxmac[i],
internals->rx_filter_original);
RXMAC_MAC_FILTER_TABLE_BCAST);
}

return 0;
Expand Down

0 comments on commit 3a4dd26

Please sign in to comment.