Skip to content

Commit

Permalink
net/bnxt: fix multicast address set
Browse files Browse the repository at this point in the history
[ upstream commit 4dc9409 ]

Fix bnxt_dev_set_mc_addr_list_op.
Fix to cache the multicast mac addresses added to the port
to the driver private structure memory. Use this cached mc list
to program the FW.

This fixes an issue where multicast packets reception is
successful only if the multicast mac address of the packets
is the first one in the multicast address list of the port.

This is in preparation for another fix in the series.

Fixes: d69851d ("net/bnxt: support multicast filter and set MAC addr")

Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
  • Loading branch information
Kalesh AP authored and bluca committed Feb 14, 2022
1 parent e2c9b99 commit 5ee9622
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
5 changes: 5 additions & 0 deletions drivers/net/bnxt/bnxt.h
Expand Up @@ -854,6 +854,11 @@ struct bnxt {
uint16_t tx_cfa_action;
struct bnxt_ring_stats *prev_rx_ring_stats;
struct bnxt_ring_stats *prev_tx_ring_stats;

#define BNXT_MAX_MC_ADDRS 16
struct rte_ether_addr *mcast_addr_list;
rte_iova_t mc_list_dma_addr;
uint32_t nb_mc_addr;
};

static
Expand Down
34 changes: 25 additions & 9 deletions drivers/net/bnxt/bnxt_ethdev.c
Expand Up @@ -2771,9 +2771,8 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev,
uint32_t nb_mc_addr)
{
struct bnxt *bp = eth_dev->data->dev_private;
char *mc_addr_list = (char *)mc_addr_set;
struct bnxt_vnic_info *vnic;
uint32_t off = 0, i = 0;
uint32_t i = 0;
int rc;

rc = is_bnxt_in_error(bp);
Expand All @@ -2782,21 +2781,19 @@ bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev,

vnic = BNXT_GET_DEFAULT_VNIC(bp);

bp->nb_mc_addr = nb_mc_addr;

if (nb_mc_addr > BNXT_MAX_MC_ADDRS) {
vnic->flags |= BNXT_VNIC_INFO_ALLMULTI;
goto allmulti;
}

/* TODO Check for Duplicate mcast addresses */
vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI;
for (i = 0; i < nb_mc_addr; i++) {
memcpy(vnic->mc_list + off, &mc_addr_list[i],
RTE_ETHER_ADDR_LEN);
off += RTE_ETHER_ADDR_LEN;
}
for (i = 0; i < nb_mc_addr; i++)
rte_ether_addr_copy(&mc_addr_set[i], &bp->mcast_addr_list[i]);

vnic->mc_addr_cnt = i;
if (vnic->mc_addr_cnt)
if (bp->nb_mc_addr)
vnic->flags |= BNXT_VNIC_INFO_MCAST;
else
vnic->flags &= ~BNXT_VNIC_INFO_MCAST;
Expand Down Expand Up @@ -4780,6 +4777,23 @@ static int bnxt_setup_mac_addr(struct rte_eth_dev *eth_dev)
/* Copy the permanent MAC from the FUNC_QCAPS response */
memcpy(&eth_dev->data->mac_addrs[0], bp->mac_addr, RTE_ETHER_ADDR_LEN);

/*
* Allocate memory to hold multicast mac addresses added.
* Used to restore them during reset recovery
*/
bp->mcast_addr_list = rte_zmalloc("bnxt_mcast_addr_tbl",
sizeof(struct rte_ether_addr) *
BNXT_MAX_MC_ADDRS, 0);
if (bp->mcast_addr_list == NULL) {
PMD_DRV_LOG(ERR, "Failed to allocate multicast addr table\n");
return -ENOMEM;
}
bp->mc_list_dma_addr = rte_malloc_virt2iova(bp->mcast_addr_list);
if (bp->mc_list_dma_addr == RTE_BAD_IOVA) {
PMD_DRV_LOG(ERR, "Fail to map mcast_addr_list to physical memory\n");
return -ENOMEM;
}

return rc;
}

Expand Down Expand Up @@ -5818,6 +5832,8 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
if (!reconfig_dev) {
bnxt_free_hwrm_resources(bp);
bnxt_free_error_recovery_info(bp);
rte_free(bp->mcast_addr_list);
bp->mcast_addr_list = NULL;
}

bnxt_uninit_ctx_mem(bp);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/bnxt/bnxt_hwrm.c
Expand Up @@ -391,8 +391,8 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
} else if (vnic->flags & BNXT_VNIC_INFO_MCAST) {
mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST;
req.num_mc_entries = rte_cpu_to_le_32(vnic->mc_addr_cnt);
req.mc_tbl_addr = rte_cpu_to_le_64(vnic->mc_list_dma_addr);
req.num_mc_entries = rte_cpu_to_le_32(bp->nb_mc_addr);
req.mc_tbl_addr = rte_cpu_to_le_64(bp->mc_list_dma_addr);
}
if (vlan_table) {
if (!(mask & HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_VLAN_NONVLAN))
Expand Down
7 changes: 1 addition & 6 deletions drivers/net/bnxt/bnxt_vnic.c
Expand Up @@ -126,8 +126,7 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp)
int i;
rte_iova_t mz_phys_addr;

entry_length = HW_HASH_KEY_SIZE +
BNXT_MAX_MC_ADDRS * RTE_ETHER_ADDR_LEN;
entry_length = HW_HASH_KEY_SIZE;

if (BNXT_CHIP_THOR(bp))
rss_table_size = BNXT_RSS_TBL_SIZE_THOR *
Expand Down Expand Up @@ -169,10 +168,6 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp)

vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr +
rss_table_size;
vnic->mc_list = (void *)((char *)vnic->rss_hash_key +
HW_HASH_KEY_SIZE);
vnic->mc_list_dma_addr = vnic->rss_hash_key_dma_addr +
HW_HASH_KEY_SIZE;
bnxt_prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE);
}

Expand Down
4 changes: 0 additions & 4 deletions drivers/net/bnxt/bnxt_vnic.h
Expand Up @@ -32,10 +32,6 @@ struct bnxt_vnic_info {
uint16_t *rss_table;
rte_iova_t rss_hash_key_dma_addr;
void *rss_hash_key;
rte_iova_t mc_list_dma_addr;
char *mc_list;
uint32_t mc_addr_cnt;
#define BNXT_MAX_MC_ADDRS 16
uint32_t flags;
#define BNXT_VNIC_INFO_PROMISC (1 << 0)
#define BNXT_VNIC_INFO_ALLMULTI (1 << 1)
Expand Down

0 comments on commit 5ee9622

Please sign in to comment.