From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0ED80A0548; Wed, 15 Jun 2022 16:57:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0675842B86; Wed, 15 Jun 2022 16:57:46 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (lpdvsmtp11.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 81A9642B7A for ; Wed, 15 Jun 2022 16:57:44 +0200 (CEST) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id BC6FDC0000E6; Wed, 15 Jun 2022 07:57:42 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com BC6FDC0000E6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1655305063; bh=LtVCwMJ9BVOLDS1kAXv21uiJNrBlbeumonAdxkjoCuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JruA0iuNv4glJGLinrYir7alvWoGHnac607AUdqA4XgppHCWPq3No4yj0UBSUHNcz RBhuUcEoZ61F8cTyBgb8sqDLCeUWVoYPjLqgu2/dtpilDnxgzB5u8WmDdpU90w3/Ie JBNRAIIAeSeXt7Hwi1XRVkR9kk7qjEotcyTjcuus= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@xilinx.com, ajit.khaparde@broadcom.com Subject: [dpdk-dev] [PATCH 2/8] net/bnxt: fix switch domain allocation Date: Wed, 15 Jun 2022 20:26:57 +0530 Message-Id: <20220615145703.6613-3-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20220615145703.6613-1-kalesh-anakkur.purayil@broadcom.com> References: <20220615145703.6613-1-kalesh-anakkur.purayil@broadcom.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ajit Khaparde Allocate switch domain after the trusted VF capability is queried from the FW. Currently we are calling the function earlier. Since the switch domain is allocated only for PFs or trusted VF, the current location of code fails to allocate the domain during init. But during cleanup we try to free the domain incorrectly. Fix the behavior by changing the sequence of function calls. Fixes: 3127f99274b67 ("net/bnxt: refactor init/uninit") Cc: stable@dpdk.org Signed-off-by: Ajit Khaparde Reviewed-by: Somnath Kotur Reviewed-by: Kalesh AP Reviewed-by: Andy Gospodarek --- drivers/net/bnxt/bnxt_ethdev.c | 45 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 0f0f40b..34f2149 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -5287,6 +5287,25 @@ bnxt_init_locks(struct bnxt *bp) return err; } +/* This should be called after we have queried trusted VF cap */ +static int bnxt_alloc_switch_domain(struct bnxt *bp) +{ + int rc = 0; + + if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) { + rc = rte_eth_switch_domain_alloc(&bp->switch_domain_id); + if (rc) + PMD_DRV_LOG(ERR, + "Failed to alloc switch domain: %d\n", rc); + else + PMD_DRV_LOG(INFO, + "Switch domain allocated %d\n", + bp->switch_domain_id); + } + + return rc; +} + static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) { int rc = 0; @@ -5295,6 +5314,10 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) if (rc) return rc; + rc = bnxt_alloc_switch_domain(bp); + if (rc) + return rc; + if (!reconfig_dev) { rc = bnxt_setup_mac_addr(bp->eth_dev); if (rc) @@ -5734,24 +5757,6 @@ bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs) return ret; } -static int bnxt_alloc_switch_domain(struct bnxt *bp) -{ - int rc = 0; - - if (BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp)) { - rc = rte_eth_switch_domain_alloc(&bp->switch_domain_id); - if (rc) - PMD_DRV_LOG(ERR, - "Failed to alloc switch domain: %d\n", rc); - else - PMD_DRV_LOG(INFO, - "Switch domain allocated %d\n", - bp->switch_domain_id); - } - - return rc; -} - /* Allocate and initialize various fields in bnxt struct that * need to be allocated/destroyed only once in the lifetime of the driver */ @@ -5828,10 +5833,6 @@ static int bnxt_drv_init(struct rte_eth_dev *eth_dev) if (rc) return rc; - rc = bnxt_alloc_switch_domain(bp); - if (rc) - return rc; - return rc; } -- 2.10.1