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 1CBAAA04B5; Fri, 11 Sep 2020 03:58:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A615F1C193; Fri, 11 Sep 2020 03:57:09 +0200 (CEST) Received: from mail-pf1-f225.google.com (mail-pf1-f225.google.com [209.85.210.225]) by dpdk.org (Postfix) with ESMTP id 326541B9B7 for ; Fri, 11 Sep 2020 03:57:08 +0200 (CEST) Received: by mail-pf1-f225.google.com with SMTP id z19so6017608pfn.8 for ; Thu, 10 Sep 2020 18:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eHzF503ya9oXL6uGTtibh3QOaBKT3+Tt8EKdD4alB3E=; b=Q/R/e2jpcXyU/+8Q8i99OomaUlbpoL8TXiOmkqhB87n91WAj3BwEnEm5no3Qlpc0CO tzl4fE3R7Q+Yd5wSpMrG3Y1oWfoXMCR6HyhmwQJII6nm6H/xz2oSepnUKjYrdnyWC8JM IwwjXnBylJI4PfuXVQWM9QYcEKFcZ6vXqj69Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eHzF503ya9oXL6uGTtibh3QOaBKT3+Tt8EKdD4alB3E=; b=odjiFHtWyZeUlSoxIeib7a2eLft71USs0si0755qMQ4+e36X6uzS0EgSrUJytjAIqU uyz/zq1pe1yY6cp3qM9wBo6cUGqHOmz3187T7nG2ReBhXdIj2iVfFM8Y5C9Km/blQrNv FU+KLTXrnaewlPOa2Fq6MyPiv8DoxBAk0sSyATuBvLuNK7ryoR5ikizRMaQB7Xsb3lwz DfGTcS+2+0nITKZyxMsvM2wbLwjXVKaWD+12wRZjSsQYSyQZ8gIYSrfW/O6ygGoVAiDt EBGyyV0tzDduhs/EaIhRZ5jrIeSI2Tz3xb882SkYJFzYN+ZOqYv5tWEnU5FaQ3FjJu7s PW3g== X-Gm-Message-State: AOAM533wYrLqj+KXyLIrnZ4TaigyyJ7Pvn7I7MJUJBvzEXZwhQ4BKQWj UbTtBxDTtNqAUfiFSVMJhcfVRSDwveEyc/5xjopJ9iWq9nHRFn/hngabEU8r53kUefo97ZSlFy0 lcK2igk7cxk6AKbqtfwI6CSaglqLc/CLy9zRcsNNarhRAxWmEpBvqFGf2z1Dv5sFjGKdSDRxXYt 3Iew== X-Google-Smtp-Source: ABdhPJwqfi/uqqnzoPr617uoJd/q0Kx2szSvetkX+n2b1zPKXLuxsz1SJqnNv0jQy5VKMv0TJLr9ZjAD/bEx X-Received: by 2002:a63:a23:: with SMTP id 35mr5279438pgk.333.1599789427129; Thu, 10 Sep 2020 18:57:07 -0700 (PDT) Received: from localhost.localdomain ([192.19.223.252]) by smtp-relay.gmail.com with ESMTPS id cl6sm80986pjb.15.2020.09.10.18.57.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2020 18:57:07 -0700 (PDT) X-Relaying-Domain: broadcom.com From: Ajit Khaparde To: dev@dpdk.org Cc: Somnath Kotur , Venkat Duvvuru Date: Thu, 10 Sep 2020 18:55:50 -0700 Message-Id: <20200911015603.88359-13-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <20200911015603.88359-1-ajit.khaparde@broadcom.com> References: <20200911015603.88359-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 12/25] net/bnxt: fix to conditionally rollback added VF-rep ports 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: Somnath Kotur If VF-rep port add fails for some reason, code was rolling back all ports added so far. With OVS-DPDK particularly, there is no need to do that, just log failure message for the VF rep port add and continue. Also include RTE_MAX_ETH_PORTS value in the bounds check as one port will be taken by the uplink port anyway Fixes: 6dc83230b43b ("net/bnxt: support port representor data path") Signed-off-by: Somnath Kotur Reviewed-by: Venkat Duvvuru --- drivers/net/bnxt/bnxt_ethdev.c | 44 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index ea81ff149..043637db6 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -5999,7 +5999,7 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, return -EINVAL; } - if (num_rep > RTE_MAX_ETHPORTS) { + if (num_rep >= RTE_MAX_ETHPORTS) { PMD_DRV_LOG(ERR, "nb_representor_ports = %d > %d MAX ETHPORTS\n", num_rep, RTE_MAX_ETHPORTS); @@ -6042,28 +6042,36 @@ static int bnxt_rep_port_probe(struct rte_pci_device *pci_dev, NULL, NULL, bnxt_vf_representor_init, &representor); - - if (!ret) { - vf_rep_eth_dev = rte_eth_dev_allocated(name); - if (!vf_rep_eth_dev) { - PMD_DRV_LOG(ERR, "Failed to find the eth_dev" - " for VF-Rep: %s.", name); - bnxt_pci_remove_dev_with_reps(backing_eth_dev); - ret = -ENODEV; - return ret; - } - PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR pci probe\n", - backing_eth_dev->data->port_id); - backing_bp->rep_info[representor.vf_id].vfr_eth_dev = - vf_rep_eth_dev; - backing_bp->num_reps++; - } else { + if (ret) { PMD_DRV_LOG(ERR, "failed to create bnxt vf " "representor %s.", name); - bnxt_pci_remove_dev_with_reps(backing_eth_dev); + goto err; } + + vf_rep_eth_dev = rte_eth_dev_allocated(name); + if (!vf_rep_eth_dev) { + PMD_DRV_LOG(ERR, "Failed to find the eth_dev" + " for VF-Rep: %s.", name); + ret = -ENODEV; + goto err; + } + + PMD_DRV_LOG(DEBUG, "BNXT Port:%d VFR pci probe\n", + backing_eth_dev->data->port_id); + backing_bp->rep_info[representor.vf_id].vfr_eth_dev = + vf_rep_eth_dev; + backing_bp->num_reps++; } + return 0; + +err: + /* If num_rep > 1, then rollback already created + * ports, since we'll be failing the probe anyway + */ + if (num_rep > 1) + bnxt_pci_remove_dev_with_reps(backing_eth_dev); + return ret; } -- 2.21.1 (Apple Git-122.3)