From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2535A0471 for ; Thu, 18 Jul 2019 05:36:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EC3421B953; Thu, 18 Jul 2019 05:36:33 +0200 (CEST) Received: from rnd-relay.smtp.broadcom.com (rnd-relay.smtp.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 2E5DE4CE4; Thu, 18 Jul 2019 05:36:30 +0200 (CEST) Received: from nis-sj1-27.broadcom.com (nis-sj1-27.lvn.broadcom.net [10.75.144.136]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id C2BA230C38E; Wed, 17 Jul 2019 20:36:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com C2BA230C38E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1563420987; bh=/z/xOBZCSSs8Qt7FU+xtinpvUklAvGhiSYfGSzN/cgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YLIQTrzhIWouWa+d2VA0IOJn7vdbHnTIImiDQl4IR6PRluO2BGURBJkq/qKWzFzVH J9TnmTGK0Rb1MZhOAm5Js44A1E6te9YFMLJjI0WdsP8pYNgxP0kwMD11ymmtOcEOY2 L9lJUiQ/N/HGud9CSdVThs0LTSFUpB9X7vFhWVwA= Received: from C02VPB22HTD6.wifi.broadcom.net (c02vpb22htd6.wifi.broadcom.net [10.122.43.105]) by nis-sj1-27.broadcom.com (Postfix) with ESMTP id CBADFAC0761; Wed, 17 Jul 2019 20:36:26 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Kalesh AP , stable@dpdk.org, Somnath Kotur Date: Thu, 18 Jul 2019 09:05:57 +0530 Message-Id: <20190718033616.37605-4-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190718033616.37605-1-ajit.khaparde@broadcom.com> References: <20190718033616.37605-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 03/22] net/bnxt: fix failure to add a MAC address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kalesh AP HWRM command to add MAC address can fail. Driver should check the return value of HWRM command and do the house keeping properly. Fixes: 778b759ba10e45208 ("net/bnxt: add MAC address") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index a37ea93d9..0c77a8c08 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) -- 2.20.1 (Apple Git-117)