From: Kalesh AP Date: Thu, 18 Jul 2019 03:35:57 +0000 (+0530) Subject: net/bnxt: fix adding MAC address X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=d8b3bc78d804467ebf75e04beede0d941af91195;p=dpdk.git net/bnxt: fix adding MAC address HWRM command to add MAC address can fail. Driver should check the return value of HWRM command and do the house keeping properly. Fixes: 778b759ba10e ("net/bnxt: add MAC address") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 306d627721..15048de3f1 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -915,6 +915,7 @@ static int bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev, struct bnxt *bp = eth_dev->data->dev_private; struct bnxt_vnic_info *vnic = &bp->vnic_info[pool]; struct bnxt_filter_info *filter; + int rc = 0; if (BNXT_VF(bp) & !BNXT_VF_IS_TRUSTED(bp)) { PMD_DRV_LOG(ERR, "Cannot add MAC address to a VF interface\n"); @@ -938,10 +939,20 @@ static int bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev, PMD_DRV_LOG(ERR, "L2 filter alloc failed\n"); return -ENODEV; } - STAILQ_INSERT_TAIL(&vnic->filter, filter, next); + filter->mac_index = index; memcpy(filter->l2_addr, mac_addr, RTE_ETHER_ADDR_LEN); - return bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter); + + rc = bnxt_hwrm_set_l2_filter(bp, vnic->fw_vnic_id, filter); + if (!rc) { + STAILQ_INSERT_TAIL(&vnic->filter, filter, next); + } else { + filter->mac_index = INVALID_MAC_INDEX; + memset(&filter->l2_addr, 0, RTE_ETHER_ADDR_LEN); + bnxt_free_filter(bp, filter); + } + + return rc; } int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete)