net/cnxk: support multicast filter

Patch adds multicast filter support for cn9k and cn10k platforms.

CGX DMAC filter table(32 entries) is divided among all LMACs
connected to it i.e. if CGX has 4 LMACs then each LMAC can have
up to 8 filters. If CGX has 1 LMAC then it can have up to 32
filters.

Above mentioned filter table is used to install unicast and multicast
DMAC address filters. Unicast filters are installed via
rte_eth_dev_mac_addr_add API while multicast filters are installed
via rte_eth_dev_set_mc_addr_list API.

So in total, supported MAC filters are equal to DMAC filters plus
mcast filters.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
This commit is contained in:
Sunil Kumar Kori 2021-06-23 10:17:01 +05:30 committed by Jerin Jacob
parent 00242a687d
commit 21cc840198
5 changed files with 73 additions and 0 deletions

View File

@ -22,6 +22,7 @@ TSO = Y
Promiscuous mode = Y
Allmulticast mode = Y
Unicast MAC filter = Y
Multicast MAC filter = Y
RSS hash = Y
RSS key update = Y
RSS reta update = Y

View File

@ -21,6 +21,7 @@ MTU update = Y
Promiscuous mode = Y
Allmulticast mode = Y
Unicast MAC filter = Y
Multicast MAC filter = Y
RSS hash = Y
RSS key update = Y
RSS reta update = Y

View File

@ -1270,6 +1270,7 @@ struct eth_dev_ops cnxk_eth_dev_ops = {
.reta_query = cnxk_nix_reta_query,
.rss_hash_update = cnxk_nix_rss_hash_update,
.rss_hash_conf_get = cnxk_nix_rss_hash_conf_get,
.set_mc_addr_list = cnxk_nix_mc_addr_list_configure,
};
static int
@ -1334,6 +1335,7 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
}
dev->max_mac_entries = max_entries;
dev->dmac_filter_count = 1;
/* Get mac address */
rc = roc_nix_npc_mac_addr_get(nix, dev->mac_addr);

View File

@ -162,6 +162,7 @@ struct cnxk_eth_dev {
uint8_t configured;
/* Max macfilter entries */
uint8_t dmac_filter_count;
uint8_t max_mac_entries;
bool dmac_filter_enable;
@ -265,6 +266,9 @@ int cnxk_nix_probe(struct rte_pci_driver *pci_drv,
struct rte_pci_device *pci_dev);
int cnxk_nix_remove(struct rte_pci_device *pci_dev);
int cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu);
int cnxk_nix_mc_addr_list_configure(struct rte_eth_dev *eth_dev,
struct rte_ether_addr *mc_addr_set,
uint32_t nb_mc_addr);
int cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev,
struct rte_ether_addr *addr, uint32_t index,
uint32_t pool);

View File

@ -359,6 +359,7 @@ cnxk_nix_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr,
roc_nix_npc_promisc_ena_dis(nix, true);
dev->dmac_filter_enable = true;
eth_dev->data->promiscuous = false;
dev->dmac_filter_count++;
return 0;
}
@ -373,6 +374,8 @@ cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index)
rc = roc_nix_mac_addr_del(nix, index);
if (rc)
plt_err("Failed to delete mac address, rc=%d", rc);
dev->dmac_filter_count--;
}
int
@ -845,3 +848,65 @@ cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
return 0;
}
int
cnxk_nix_mc_addr_list_configure(struct rte_eth_dev *eth_dev,
struct rte_ether_addr *mc_addr_set,
uint32_t nb_mc_addr)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
struct rte_eth_dev_data *data = eth_dev->data;
struct rte_ether_addr null_mac_addr;
struct roc_nix *nix = &dev->nix;
int rc, index;
uint32_t i;
memset(&null_mac_addr, 0, sizeof(null_mac_addr));
/* All configured multicast filters should be flushed first */
for (i = 0; i < dev->max_mac_entries; i++) {
if (rte_is_multicast_ether_addr(&data->mac_addrs[i])) {
rc = roc_nix_mac_addr_del(nix, i);
if (rc) {
plt_err("Failed to flush mcast address, rc=%d",
rc);
return rc;
}
dev->dmac_filter_count--;
/* Update address in NIC data structure */
rte_ether_addr_copy(&null_mac_addr,
&data->mac_addrs[i]);
}
}
if (!mc_addr_set || !nb_mc_addr)
return 0;
/* Check for available space */
if (nb_mc_addr >
((uint32_t)(dev->max_mac_entries - dev->dmac_filter_count))) {
plt_err("No space is available to add multicast filters");
return -ENOSPC;
}
/* Multicast addresses are to be installed */
for (i = 0; i < nb_mc_addr; i++) {
index = roc_nix_mac_addr_add(nix, mc_addr_set[i].addr_bytes);
if (index < 0) {
plt_err("Failed to add mcast mac address, rc=%d",
index);
return index;
}
dev->dmac_filter_count++;
/* Update address in NIC data structure */
rte_ether_addr_copy(&mc_addr_set[i], &data->mac_addrs[index]);
}
roc_nix_npc_promisc_ena_dis(nix, true);
dev->dmac_filter_enable = true;
eth_dev->data->promiscuous = false;
return 0;
}