DPDK patches and discussions
 help / color / mirror / Atom feed
From: Lijun Ou <oulijun@huawei.com>
To: <thomas@monjalon.net>, <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>, <linuxarm@openeuler.org>
Subject: [dpdk-dev] [PATCH 07/14] net/hns3: refactor reset event report function
Date: Fri, 22 Jan 2021 18:18:45 +0800	[thread overview]
Message-ID: <1611310732-51975-8-git-send-email-oulijun@huawei.com> (raw)
In-Reply-To: <1611310732-51975-1-git-send-email-oulijun@huawei.com>

Here encapsulate the process code of the imp reset report and
global reset report into function in order to reduce the
complexity of the hns3_check_event_cause function.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 69 +++++++++++++++++++++++++++---------------
 1 file changed, 45 insertions(+), 24 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index f3ce639..817d1dc 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -123,6 +123,47 @@ hns3_pf_enable_irq0(struct hns3_hw *hw)
 }
 
 static enum hns3_evt_cause
+hns3_proc_imp_reset_event(struct hns3_adapter *hns, bool is_delay,
+			  uint32_t *vec_val)
+{
+	struct hns3_hw *hw = &hns->hw;
+
+	rte_atomic16_set(&hw->reset.disable_cmd, 1);
+	hns3_atomic_set_bit(HNS3_IMP_RESET, &hw->reset.pending);
+	*vec_val = BIT(HNS3_VECTOR0_IMPRESET_INT_B);
+	if (!is_delay) {
+		hw->reset.stats.imp_cnt++;
+		hns3_warn(hw, "IMP reset detected, clear reset status");
+	} else {
+		hns3_schedule_delayed_reset(hns);
+		hns3_warn(hw, "IMP reset detected, don't clear reset status");
+	}
+
+	return HNS3_VECTOR0_EVENT_RST;
+}
+
+static enum hns3_evt_cause
+hns3_proc_global_reset_event(struct hns3_adapter *hns, bool is_delay,
+			     uint32_t *vec_val)
+{
+	struct hns3_hw *hw = &hns->hw;
+
+	rte_atomic16_set(&hw->reset.disable_cmd, 1);
+	hns3_atomic_set_bit(HNS3_GLOBAL_RESET, &hw->reset.pending);
+	*vec_val = BIT(HNS3_VECTOR0_GLOBALRESET_INT_B);
+	if (!is_delay) {
+		hw->reset.stats.global_cnt++;
+		hns3_warn(hw, "Global reset detected, clear reset status");
+	} else {
+		hns3_schedule_delayed_reset(hns);
+		hns3_warn(hw,
+			  "Global reset detected, don't clear reset status");
+	}
+
+	return HNS3_VECTOR0_EVENT_RST;
+}
+
+static enum hns3_evt_cause
 hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval)
 {
 	struct hns3_hw *hw = &hns->hw;
@@ -131,12 +172,14 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval)
 	uint32_t hw_err_src_reg;
 	uint32_t val;
 	enum hns3_evt_cause ret;
+	bool is_delay;
 
 	/* fetch the events from their corresponding regs */
 	vector0_int_stats = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG);
 	cmdq_src_val = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG);
 	hw_err_src_reg = hns3_read_dev(hw, HNS3_RAS_PF_OTHER_INT_STS_REG);
 
+	is_delay = clearval == NULL ? true : false;
 	/*
 	 * Assumption: If by any chance reset and mailbox events are reported
 	 * together then we will only process reset event and defer the
@@ -145,35 +188,13 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval)
 	 * from H/W just for the mailbox.
 	 */
 	if (BIT(HNS3_VECTOR0_IMPRESET_INT_B) & vector0_int_stats) { /* IMP */
-		rte_atomic16_set(&hw->reset.disable_cmd, 1);
-		hns3_atomic_set_bit(HNS3_IMP_RESET, &hw->reset.pending);
-		val = BIT(HNS3_VECTOR0_IMPRESET_INT_B);
-		if (clearval) {
-			hw->reset.stats.imp_cnt++;
-			hns3_warn(hw, "IMP reset detected, clear reset status");
-		} else {
-			hns3_schedule_delayed_reset(hns);
-			hns3_warn(hw, "IMP reset detected, don't clear reset status");
-		}
-
-		ret = HNS3_VECTOR0_EVENT_RST;
+		ret = hns3_proc_imp_reset_event(hns, is_delay, &val);
 		goto out;
 	}
 
 	/* Global reset */
 	if (BIT(HNS3_VECTOR0_GLOBALRESET_INT_B) & vector0_int_stats) {
-		rte_atomic16_set(&hw->reset.disable_cmd, 1);
-		hns3_atomic_set_bit(HNS3_GLOBAL_RESET, &hw->reset.pending);
-		val = BIT(HNS3_VECTOR0_GLOBALRESET_INT_B);
-		if (clearval) {
-			hw->reset.stats.global_cnt++;
-			hns3_warn(hw, "Global reset detected, clear reset status");
-		} else {
-			hns3_schedule_delayed_reset(hns);
-			hns3_warn(hw, "Global reset detected, don't clear reset status");
-		}
-
-		ret = HNS3_VECTOR0_EVENT_RST;
+		ret = hns3_proc_global_reset_event(hns, is_delay, &val);
 		goto out;
 	}
 
-- 
2.7.4


  parent reply	other threads:[~2021-01-22 10:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 10:18 [dpdk-dev] [PATCH 00/14] Misc updates for hns3 Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 01/14] net/hns3: encapsulate dfx stats in Rx/Tx datapatch Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 02/14] net/hns3: move queue stats to xstats Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 03/14] net/hns3: use array instead of switch-case Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 04/14] net/hns3: move judgment conditions to separated functions Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 05/14] net/hns3: reconstruct the Rx interrupt map Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 06/14] net/hns3: extract common judgments for all FDIR type Lijun Ou
2021-01-22 10:18 ` Lijun Ou [this message]
2021-01-22 10:18 ` [dpdk-dev] [PATCH 08/14] net/hns3: fix memory leak with secondary process exit Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 09/14] net/hns3: fix interrupt resources in Rx interrupt mode Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 10/14] net/hns3: rename RSS functions Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 11/14] net/hns3: adjust some comments Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 12/14] net/hns3: remove unnecessary parentheses Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 13/14] net/hns3: use %d instead of %u for enum variable Lijun Ou
2021-01-22 10:18 ` [dpdk-dev] [PATCH 14/14] net/hns3: support LSC event report Lijun Ou
2021-01-28 23:41   ` Ferruh Yigit
2021-01-29  1:49     ` oulijun
2021-02-02 12:06       ` Ferruh Yigit
2021-02-02 12:12   ` Ferruh Yigit
2021-01-28 23:58 ` [dpdk-dev] [PATCH 00/14] Misc updates for hns3 Ferruh Yigit

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=1611310732-51975-8-git-send-email-oulijun@huawei.com \
    --to=oulijun@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=linuxarm@openeuler.org \
    --cc=thomas@monjalon.net \
    /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).