From: Thinh Tran <thinhtr@linux.vnet.ibm.com>
To: kuba@kernel.org
Cc: netdev@vger.kernel.org, aelior@marvell.com, davem@davemloft.net,
manishc@marvell.com, pabeni@redhat.com, skalluru@marvell.com,
simon.horman@corigine.com, edumazet@google.com,
VENKATA.SAI.DUGGI@ibm.com, drc@linux.vnet.ibm.com,
abdhalee@in.ibm.com, thinhtr@linux.vnet.ibm.com
Subject: [PATCH v7 2/2] net/bnx2x: refactor common code to bnx2x_stop_nic()
Date: Thu, 1 Feb 2024 11:48:22 -0600 [thread overview]
Message-ID: <1149c0efc9b000bf6c28807b3f1d173079e807bd.1706804455.git.thinhtr@linux.vnet.ibm.com> (raw)
In-Reply-To: <cover.1706804455.git.thinhtr@linux.vnet.ibm.com>
Refactor common code which disables and releases HW interrupts, deletes
NAPI objects, into a new bnx2x_stop_nic() function.
Signed-off-by: Thinh Tran <thinhtr@linux.vnet.ibm.com>
---
.../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 28 +++++++++++--------
.../net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 1 +
.../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 25 +++--------------
.../net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 12 ++------
4 files changed, 24 insertions(+), 42 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index e9c1e1bb5580..e34aff5fb782 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -3097,17 +3097,8 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
if (!CHIP_IS_E1x(bp))
bnx2x_pf_disable(bp);
- if (!bp->nic_stopped) {
- /* Disable HW interrupts, NAPI */
- bnx2x_netif_stop(bp, 1);
- /* Delete all NAPI objects */
- bnx2x_del_all_napi(bp);
- if (CNIC_LOADED(bp))
- bnx2x_del_all_napi_cnic(bp);
- /* Release IRQs */
- bnx2x_free_irq(bp);
- bp->nic_stopped = true;
- }
+ /* Disable HW interrupts, delete NAPIs, Release IRQs */
+ bnx2x_stop_nic(bp, 1);
/* Report UNLOAD_DONE to MCP */
bnx2x_send_unload_done(bp, false);
@@ -5139,3 +5130,18 @@ void bnx2x_schedule_sp_rtnl(struct bnx2x *bp, enum sp_rtnl_flag flag,
flag);
schedule_delayed_work(&bp->sp_rtnl_task, 0);
}
+
+void bnx2x_stop_nic(struct bnx2x *bp, int disable_hw)
+{
+ if (!bp->nic_stopped) {
+ /* Disable HW interrupts, NAPI */
+ bnx2x_netif_stop(bp, disable_hw);
+ /* Delete all NAPI objects */
+ bnx2x_del_all_napi(bp);
+ if (CNIC_LOADED(bp))
+ bnx2x_del_all_napi_cnic(bp);
+ /* Release IRQs */
+ bnx2x_free_irq(bp);
+ bp->nic_stopped = true;
+ }
+}
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 0bc1367fd649..a35a02299b33 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -553,6 +553,7 @@ void bnx2x_free_skbs(struct bnx2x *bp);
void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw);
void bnx2x_netif_start(struct bnx2x *bp);
int bnx2x_load_cnic(struct bnx2x *bp);
+void bnx2x_stop_nic(struct bnx2x *bp, int disable_hw);
/**
* bnx2x_enable_msix - set msix configuration.
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 0d8e61c63c7c..ff75c883cffe 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -9474,18 +9474,8 @@ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link)
}
}
- if (!bp->nic_stopped) {
- /* Disable HW interrupts, NAPI */
- bnx2x_netif_stop(bp, 1);
- /* Delete all NAPI objects */
- bnx2x_del_all_napi(bp);
- if (CNIC_LOADED(bp))
- bnx2x_del_all_napi_cnic(bp);
-
- /* Release IRQs */
- bnx2x_free_irq(bp);
- bp->nic_stopped = true;
- }
+ /* Disable HW interrupts, delete NAPIs, Release IRQs */
+ bnx2x_stop_nic(bp, 1);
/* Reset the chip, unless PCI function is offline. If we reach this
* point following a PCI error handling, it means device is really
@@ -14241,16 +14231,9 @@ static pci_ers_result_t bnx2x_io_slot_reset(struct pci_dev *pdev)
}
bnx2x_drain_tx_queues(bp);
bnx2x_send_unload_req(bp, UNLOAD_RECOVERY);
- if (!bp->nic_stopped) {
- bnx2x_netif_stop(bp, 1);
- bnx2x_del_all_napi(bp);
- if (CNIC_LOADED(bp))
- bnx2x_del_all_napi_cnic(bp);
-
- bnx2x_free_irq(bp);
- bp->nic_stopped = true;
- }
+ /* Disable HW interrupts, delete NAPIs, Release IRQs */
+ bnx2x_stop_nic(bp, 1);
/* Report UNLOAD_DONE to MCP */
bnx2x_send_unload_done(bp, true);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
index 8946a931e87e..e92e82423096 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
@@ -529,16 +529,8 @@ void bnx2x_vfpf_close_vf(struct bnx2x *bp)
bnx2x_vfpf_finalize(bp, &req->first_tlv);
free_irq:
- if (!bp->nic_stopped) {
- /* Disable HW interrupts, NAPI */
- bnx2x_netif_stop(bp, 0);
- /* Delete all NAPI objects */
- bnx2x_del_all_napi(bp);
-
- /* Release IRQs */
- bnx2x_free_irq(bp);
- bp->nic_stopped = true;
- }
+ /* Disable HW interrupts, delete NAPIs, Release IRQs */
+ bnx2x_stop_nic(bp, 0);
}
static void bnx2x_leading_vfq_init(struct bnx2x *bp, struct bnx2x_virtf *vf,
--
2.25.1
next prev parent reply other threads:[~2024-02-01 17:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 17:48 [PATCH v7 0/2] bnx2x: Fix error recovering in switch configuration Thinh Tran
2024-02-01 17:48 ` [PATCH v7 1/2] net/bnx2x: Prevent access to a freed page in page_pool Thinh Tran
2024-02-08 2:37 ` Jakub Kicinski
2024-02-01 17:48 ` Thinh Tran [this message]
2024-02-08 18:55 ` [PATCH v8 0/2] bnx2x: Fix error recovering in switch configuration Thinh Tran
2024-02-08 18:55 ` [PATCH v8 1/2] net/bnx2x: Prevent access to a freed page in page_pool Thinh Tran
2024-02-08 19:14 ` Thinh Tran
2024-02-08 19:18 ` Thinh Tran
2024-02-09 1:29 ` Jakub Kicinski
2024-02-12 20:47 ` Thinh Tran
2024-02-12 20:47 ` [PATCH v9 " Thinh Tran
2024-02-08 18:55 ` [PATCH v8 2/2] net/bnx2x: refactor common code to bnx2x_stop_nic() Thinh Tran
2024-02-12 20:47 ` [PATCH v9 " Thinh Tran
2024-02-12 20:47 ` [PATCH v9 0/2] bnx2x: Fix error recovering in switch configuration Thinh Tran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1149c0efc9b000bf6c28807b3f1d173079e807bd.1706804455.git.thinhtr@linux.vnet.ibm.com \
--to=thinhtr@linux.vnet.ibm.com \
--cc=VENKATA.SAI.DUGGI@ibm.com \
--cc=abdhalee@in.ibm.com \
--cc=aelior@marvell.com \
--cc=davem@davemloft.net \
--cc=drc@linux.vnet.ibm.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=manishc@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=simon.horman@corigine.com \
--cc=skalluru@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).