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 7E87BA0524 for ; Fri, 5 Feb 2021 12:37:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 78AE64067B; Fri, 5 Feb 2021 12:37:38 +0100 (CET) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by mails.dpdk.org (Postfix) with ESMTP id 5FEA54067B for ; Fri, 5 Feb 2021 12:37:37 +0100 (CET) Received: by mail-wr1-f41.google.com with SMTP id q7so7263453wre.13 for ; Fri, 05 Feb 2021 03:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L6HP55QJdASH643BtInqIAcOiKLRSmelVRpaJKdxY/k=; b=tpiv+xzM7NtwUyLgXbfgvLjLTPNW18J3OBO7h0iJdG8MxH+NOxnIh4eHRzQpU18dnP aSKG3z0p0MfQ0vQYkcFLxJ1ztFx2txIEK8FtKftBs8gLrO2FB770HcbURu4sb0vfm/JD eq/9pBZ+qcvRhmDScmpieXejbqi4d6X9INcu7YbQQYTaY9tAPDrWgdC03in9F1j7wsWM 76dNfRjiF3CJ49IUjUBddngivuugOg7EjEWKguRJZ47cW81Wj9+91Nf8oqWT2X4XZySH uHST/FejZTuY39JMaIvVfHmpaE9TTOyNjPVekIMHgr3dVgTd64AZNhlFj4qaMn7OUliU rtCQ== 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=L6HP55QJdASH643BtInqIAcOiKLRSmelVRpaJKdxY/k=; b=guzwA6XIDGIY9/uCuMt3rH+Zl6jScw4gpsUGkEyNVaHu4xi5hLjNvbo+U2loKXfx34 sxSe62E6itkOCoEOKJ/DJmp3HRpgPoq9kFIHFeiRD45ECNuwICpXcl6FiywwdtVf6zL3 8fmx6iDbWJtbsKrCbd5VYZ1Mi3iSBcTclLRXYu0BnaJHzUSgDQXYGhmm7ufOZIRv51tw npBjUYK1f85l5HFip/lGjHwP9o9BTXSbqNbPc+jKeH7O5e1Hk8Y1YweenO6JDOAd0mjj /ytcORyUQa2GQVTZRy3XQdvMxzWNT3qOKKJ8VU2tbBBiTWyX9MFBJSanDpbyyG3XjZoF 7F6g== X-Gm-Message-State: AOAM533cpzmUtUs45MD+L4DiAB5pp6BwTwHrA13R5//0g9qjhe8KOZIj JMyezu+QmdSwKM2HMJmTbuSGb2Q5rx/DFWw4 X-Google-Smtp-Source: ABdhPJxnD9Ftej/e8uemjFDpiqE0V9BkdMhrdJATwe5/5hnK1nunOfFXvgUdqPxyNz6BMvvKBivm9g== X-Received: by 2002:a05:6000:1249:: with SMTP id j9mr4649891wrx.307.1612525057164; Fri, 05 Feb 2021 03:37:37 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id d13sm11562869wrx.93.2021.02.05.03.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 03:37:36 -0800 (PST) From: luca.boccassi@gmail.com To: Somnath Kotur Cc: Ajit Khaparde , dpdk stable Date: Fri, 5 Feb 2021 11:18:37 +0000 Message-Id: <20210205111920.1272063-231-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210205111920.1272063-1-luca.boccassi@gmail.com> References: <20210205111920.1272063-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/bnxt: refactor init/uninit' has been queued to stable release 20.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/07/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/b3d3810bbb71f3891bfa83177d9f2ccfb01a8882 Thanks. Luca Boccassi --- >From b3d3810bbb71f3891bfa83177d9f2ccfb01a8882 Mon Sep 17 00:00:00 2001 From: Somnath Kotur Date: Wed, 13 Jan 2021 18:19:14 -0800 Subject: [PATCH] net/bnxt: refactor init/uninit [ upstream commit 3127f99274b679124658afdbfc49210730c50617 ] Move all the individual driver fields allocation routines to one routine - bnxt_drv_init(). This houses all such routines where memory needs to be allocated once during the driver's lifetime and does not need to be torn down during error recovery. Rename some function names in accordance with their functionality. bnxt_init_board() is doing nothing more than mapping the PCI bars, so rename it as such. Given that there is a bnxt_shutdown_nic that is called in dev_stop_op, rename it's counterpart - bnxt_init_chip() that is called in dev_start_op, to bnxt_start_nic. Also helps avoid confusion with some of the other bnxt_init_xxx routines. Rename bnxt_init_fw() to bnxt_get_config() as that is what that routine is doing mostly functionality wise. Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_ethdev.c | 150 +++++++++++++++++++-------------- 1 file changed, 88 insertions(+), 62 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 9a6eb19bf2..a4a31f224f 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -689,7 +689,7 @@ static int bnxt_update_phy_setting(struct bnxt *bp) return rc; } -static int bnxt_init_chip(struct bnxt *bp) +static int bnxt_start_nic(struct bnxt *bp) { struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(bp->eth_dev); struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; @@ -1395,7 +1395,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) bnxt_enable_int(bp); - rc = bnxt_init_chip(bp); + rc = bnxt_start_nic(bp); if (rc) goto error; @@ -1441,26 +1441,9 @@ bnxt_uninit_locks(struct bnxt *bp) } } -static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev) +static void bnxt_drv_uninit(struct bnxt *bp) { - struct bnxt *bp = eth_dev->data->dev_private; - int ret = 0; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - /* cancel the recovery handler before remove dev */ - rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp); - rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp); - bnxt_cancel_fc_thread(bp); - - if (eth_dev->data->dev_started) - ret = bnxt_dev_stop_op(eth_dev); - bnxt_free_switch_domain(bp); - - bnxt_uninit_resources(bp, false); - bnxt_free_leds_info(bp); bnxt_free_cos_queues(bp); bnxt_free_link_info(bp); @@ -1477,6 +1460,27 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev) rte_free(bp->grp_info); bp->grp_info = NULL; +} + +static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev) +{ + struct bnxt *bp = eth_dev->data->dev_private; + int ret = 0; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + /* cancel the recovery handler before remove dev */ + rte_eal_alarm_cancel(bnxt_dev_reset_and_resume, (void *)bp); + rte_eal_alarm_cancel(bnxt_dev_recover, (void *)bp); + bnxt_cancel_fc_thread(bp); + + if (eth_dev->data->dev_started) + ret = bnxt_dev_stop_op(eth_dev); + + bnxt_uninit_resources(bp, false); + + bnxt_drv_uninit(bp); return ret; } @@ -4045,7 +4049,7 @@ bool bnxt_stratus_device(struct bnxt *bp) } } -static int bnxt_init_board(struct rte_eth_dev *eth_dev) +static int bnxt_map_pci_bars(struct rte_eth_dev *eth_dev) { struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct bnxt *bp = eth_dev->data->dev_private; @@ -4670,7 +4674,11 @@ static int bnxt_map_hcomm_fw_status_reg(struct bnxt *bp) return 0; } -static int bnxt_init_fw(struct bnxt *bp) +/* This function gets the FW version along with the + * capabilities(MAX and current) of the function, vnic, + * error recovery, phy and other chip related info + */ +static int bnxt_get_config(struct bnxt *bp) { uint16_t mtu; int rc = 0; @@ -4755,7 +4763,7 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) { int rc = 0; - rc = bnxt_init_fw(bp); + rc = bnxt_get_config(bp); if (rc) return rc; @@ -5202,38 +5210,14 @@ static int bnxt_alloc_switch_domain(struct bnxt *bp) return rc; } -static int -bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) +/* Allocate and initialize various fields in bnxt struct that + * need to be allocated/destroyed only once in the lifetime of the driver + */ +static int bnxt_drv_init(struct rte_eth_dev *eth_dev) { struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); - static int version_printed; - struct bnxt *bp; - int rc; - - if (version_printed++ == 0) - PMD_DRV_LOG(INFO, "%s\n", bnxt_version); - - eth_dev->dev_ops = &bnxt_dev_ops; - eth_dev->rx_queue_count = bnxt_rx_queue_count_op; - eth_dev->rx_descriptor_status = bnxt_rx_descriptor_status_op; - eth_dev->tx_descriptor_status = bnxt_tx_descriptor_status_op; - eth_dev->rx_pkt_burst = &bnxt_recv_pkts; - eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; - - /* - * For secondary processes, we don't initialise any further - * as primary has already done this work. - */ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; - - rte_eth_copy_pci_info(eth_dev, pci_dev); - eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; - - bp = eth_dev->data->dev_private; - - /* Parse dev arguments passed on when starting the DPDK application. */ - bnxt_parse_dev_args(bp, pci_dev->device.devargs); + struct bnxt *bp = eth_dev->data->dev_private; + int rc = 0; bp->flags &= ~BNXT_FLAG_RX_VECTOR_PKT_MODE; @@ -5265,7 +5249,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) } } - rc = bnxt_init_board(eth_dev); + rc = bnxt_map_pci_bars(eth_dev); if (rc) { PMD_DRV_LOG(ERR, "Failed to initialize board rc: %x\n", rc); @@ -5274,31 +5258,75 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) rc = bnxt_alloc_pf_info(bp); if (rc) - goto error_free; + return rc; rc = bnxt_alloc_link_info(bp); if (rc) - goto error_free; + return rc; rc = bnxt_alloc_parent_info(bp); if (rc) - goto error_free; + return rc; rc = bnxt_alloc_hwrm_resources(bp); if (rc) { PMD_DRV_LOG(ERR, "Failed to allocate hwrm resource rc: %x\n", rc); - goto error_free; + return rc; } rc = bnxt_alloc_leds_info(bp); if (rc) - goto error_free; + return rc; rc = bnxt_alloc_cos_queues(bp); if (rc) - goto error_free; + return rc; rc = bnxt_init_locks(bp); + if (rc) + return rc; + + rc = bnxt_alloc_switch_domain(bp); + if (rc) + return rc; + + return rc; +} + +static int +bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) +{ + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); + static int version_printed; + struct bnxt *bp; + int rc; + + if (version_printed++ == 0) + PMD_DRV_LOG(INFO, "%s\n", bnxt_version); + + eth_dev->dev_ops = &bnxt_dev_ops; + eth_dev->rx_queue_count = bnxt_rx_queue_count_op; + eth_dev->rx_descriptor_status = bnxt_rx_descriptor_status_op; + eth_dev->tx_descriptor_status = bnxt_tx_descriptor_status_op; + eth_dev->rx_pkt_burst = &bnxt_recv_pkts; + eth_dev->tx_pkt_burst = &bnxt_xmit_pkts; + + /* + * For secondary processes, we don't initialise any further + * as primary has already done this work. + */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + rte_eth_copy_pci_info(eth_dev, pci_dev); + eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; + + bp = eth_dev->data->dev_private; + + /* Parse dev arguments passed on when starting the DPDK application. */ + bnxt_parse_dev_args(bp, pci_dev->device.devargs); + + rc = bnxt_drv_init(eth_dev); if (rc) goto error_free; @@ -5310,8 +5338,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) if (rc) goto error_free; - bnxt_alloc_switch_domain(bp); - PMD_DRV_LOG(INFO, DRV_MODULE_NAME "found at mem %" PRIX64 ", node addr %pM\n", pci_dev->mem_resource[0].phys_addr, -- 2.29.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-02-05 11:18:39.358556506 +0000 +++ 0231-net-bnxt-refactor-init-uninit.patch 2021-02-05 11:18:29.210698804 +0000 @@ -1 +1 @@ -From 3127f99274b679124658afdbfc49210730c50617 Mon Sep 17 00:00:00 2001 +From b3d3810bbb71f3891bfa83177d9f2ccfb01a8882 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 3127f99274b679124658afdbfc49210730c50617 ] + @@ -22,2 +23,0 @@ -Cc: stable@dpdk.org - @@ -27,2 +27,2 @@ - drivers/net/bnxt/bnxt_ethdev.c | 166 +++++++++++++++++++-------------- - 1 file changed, 96 insertions(+), 70 deletions(-) + drivers/net/bnxt/bnxt_ethdev.c | 150 +++++++++++++++++++-------------- + 1 file changed, 88 insertions(+), 62 deletions(-) @@ -31 +31 @@ -index e8a7a8ecd4..3ac3818305 100644 +index 9a6eb19bf2..a4a31f224f 100644 @@ -34 +34 @@ -@@ -679,7 +679,7 @@ static int bnxt_update_phy_setting(struct bnxt *bp) +@@ -689,7 +689,7 @@ static int bnxt_update_phy_setting(struct bnxt *bp) @@ -43 +43 @@ -@@ -1417,7 +1417,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) +@@ -1395,7 +1395,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) @@ -52 +52 @@ -@@ -1464,34 +1464,9 @@ bnxt_uninit_locks(struct bnxt *bp) +@@ -1441,26 +1441,9 @@ bnxt_uninit_locks(struct bnxt *bp) @@ -65,8 +64,0 @@ -- pthread_mutex_lock(&bp->err_recovery_lock); -- if (bp->flags & BNXT_FLAG_FW_RESET) { -- PMD_DRV_LOG(ERR, -- "Adapter recovering from error...Please retry\n"); -- return -EAGAIN; -- } -- pthread_mutex_unlock(&bp->err_recovery_lock); -- @@ -79 +71 @@ -- ret = bnxt_dev_stop(eth_dev); +- ret = bnxt_dev_stop_op(eth_dev); @@ -88 +80 @@ -@@ -1508,6 +1483,35 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev) +@@ -1477,6 +1460,27 @@ static int bnxt_dev_close_op(struct rte_eth_dev *eth_dev) @@ -102,8 +93,0 @@ -+ pthread_mutex_lock(&bp->err_recovery_lock); -+ if (bp->flags & BNXT_FLAG_FW_RESET) { -+ PMD_DRV_LOG(ERR, -+ "Adapter recovering from error...Please retry\n"); -+ return -EAGAIN; -+ } -+ pthread_mutex_unlock(&bp->err_recovery_lock); -+ @@ -116 +100 @@ -+ ret = bnxt_dev_stop(eth_dev); ++ ret = bnxt_dev_stop_op(eth_dev); @@ -124 +108 @@ -@@ -4086,7 +4090,7 @@ bool bnxt_stratus_device(struct bnxt *bp) +@@ -4045,7 +4049,7 @@ bool bnxt_stratus_device(struct bnxt *bp) @@ -133 +117 @@ -@@ -4723,7 +4727,11 @@ static int bnxt_map_hcomm_fw_status_reg(struct bnxt *bp) +@@ -4670,7 +4674,11 @@ static int bnxt_map_hcomm_fw_status_reg(struct bnxt *bp) @@ -146 +130 @@ -@@ -4819,7 +4827,7 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) +@@ -4755,7 +4763,7 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev) @@ -155 +139 @@ -@@ -5266,38 +5274,14 @@ static int bnxt_alloc_switch_domain(struct bnxt *bp) +@@ -5202,38 +5210,14 @@ static int bnxt_alloc_switch_domain(struct bnxt *bp) @@ -200 +184 @@ -@@ -5329,7 +5313,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) +@@ -5265,7 +5249,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) @@ -209 +193 @@ -@@ -5338,31 +5322,75 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) +@@ -5274,31 +5258,75 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) @@ -291 +275 @@ -@@ -5374,8 +5402,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused) +@@ -5310,8 +5338,6 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused)