DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 1/9] net/hns3: simplify process of some return values
Date: Fri, 10 Apr 2020 19:09:22 +0800	[thread overview]
Message-ID: <20200410110930.15717-2-huwei013@chinasoftinc.com> (raw)
In-Reply-To: <20200410110930.15717-1-huwei013@chinasoftinc.com>

From: Lijun Ou <oulijun@huawei.com>

Currently, the return value processing of some functions can be combined
and the result is that some codes can be optimized.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 drivers/net/hns3/hns3_dcb.c       | 28 +++++++++-------------------
 drivers/net/hns3/hns3_ethdev.c    | 27 ++++++++-------------------
 drivers/net/hns3/hns3_ethdev_vf.c | 18 ++++++------------
 3 files changed, 23 insertions(+), 50 deletions(-)

diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index 8688de2a7..3fde222dc 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -749,12 +749,10 @@ hns3_dcb_schd_mode_cfg(struct hns3_hw *hw)
 	}
 
 	ret = hns3_dcb_lvl34_schd_mode_cfg(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "config lvl34_schd_mode failed: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -845,12 +843,10 @@ hns3_dcb_dwrr_cfg(struct hns3_hw *hw)
 	}
 
 	ret = hns3_dcb_pri_dwrr_cfg(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "config pri_dwrr failed: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -932,12 +928,10 @@ hns3_pri_q_qs_cfg(struct hns3_hw *hw)
 
 	/* Cfg q -> qs mapping */
 	ret = hns3_q_to_qs_map(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "nq_to_qs mapping fail: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -1552,12 +1546,10 @@ hns3_update_queue_map_configure(struct hns3_adapter *hns)
 
 	hns3_dcb_update_tc_queue_mapping(hw, nb_rx_q, nb_tx_q);
 	ret = hns3_q_to_qs_map(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "failed to map nq to qs! ret = %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 int
@@ -1569,10 +1561,8 @@ hns3_dcb_cfg_update(struct hns3_adapter *hns)
 
 	if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) {
 		ret = hns3_dcb_configure(hns);
-		if (ret) {
+		if (ret)
 			hns3_err(hw, "Failed to config dcb: %d", ret);
-			return ret;
-		}
 	} else {
 		/*
 		 * Update queue map without PFC configuration,
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 215e2b2c6..e55e46e38 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -312,11 +312,9 @@ hns3_restore_vlan_table(struct hns3_adapter *hns)
 	uint16_t vlan_id;
 	int ret = 0;
 
-	if (pf->port_base_vlan_cfg.state == HNS3_PORT_BASE_VLAN_ENABLE) {
-		ret = hns3_vlan_pvid_configure(hns, pf->port_base_vlan_cfg.pvid,
-					       1);
-		return ret;
-	}
+	if (pf->port_base_vlan_cfg.state == HNS3_PORT_BASE_VLAN_ENABLE)
+		return hns3_vlan_pvid_configure(hns,
+						pf->port_base_vlan_cfg.pvid, 1);
 
 	LIST_FOREACH(vlan_entry, &pf->vlan_list, next) {
 		if (vlan_entry->hd_tbl_status) {
@@ -2238,12 +2236,10 @@ hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
 	}
 
 	ret = hns3_buffer_alloc(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "Failed to allocate buffer, ret = %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -2725,12 +2721,10 @@ hns3_get_configuration(struct hns3_hw *hw)
 	}
 
 	ret = hns3_get_board_configuration(hw);
-	if (ret) {
+	if (ret)
 		PMD_INIT_LOG(ERR, "Failed to get board configuration: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -3664,7 +3658,6 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc)
 	struct hns3_promisc_param param;
 	bool en_bc_pmc = true;
 	uint8_t vf_id;
-	int ret;
 
 	/*
 	 * In current version VF is not supported when PF is driven by DPDK
@@ -3674,11 +3667,7 @@ hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc)
 	vf_id = 0;
 
 	hns3_promisc_param_init(&param, en_uc_pmc, en_mc_pmc, en_bc_pmc, vf_id);
-	ret = hns3_cmd_set_promisc_mode(hw, &param);
-	if (ret)
-		return ret;
-
-	return 0;
+	return hns3_cmd_set_promisc_mode(hw, &param);
 }
 
 static int
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 8be743d19..a1286a71e 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -283,10 +283,9 @@ hns3vf_add_mc_mac_addr(struct hns3_adapter *hns,
 				      mac_addr);
 		hns3_err(hw, "Failed to add mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
-		return ret;
 	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -306,10 +305,9 @@ hns3vf_remove_mc_mac_addr(struct hns3_adapter *hns,
 				      mac_addr);
 		hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
-		return ret;
 	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -550,13 +548,11 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id,
 	op_str = mmap ? "Map" : "Unmap";
 	ret = hns3_send_mbx_msg(hw, code, 0, (uint8_t *)&bind_msg,
 				sizeof(bind_msg), false, NULL, 0);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "%s TQP %d fail, vector_id is %d, ret is %d.",
 			 op_str, queue_id, bind_msg.vector_id, ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -1675,12 +1671,10 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
 		return ret;
 
 	ret = hns3_start_queues(hns, reset_queue);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "Failed to start queues: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
-- 
2.23.0


  reply	other threads:[~2020-04-10 11:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 11:09 [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Wei Hu (Xavier)
2020-04-10 11:09 ` Wei Hu (Xavier) [this message]
2020-04-10 11:09 ` [dpdk-dev] [PATCH 2/9] net/hns3: replace zero with macro defined in DPDK framework Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 3/9] net/hns3: fix failure when adding a MC MAC address Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 4/9] net/hns3: fix Rx interrupt after reset Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 5/9] net/hns3: fix residual flow directory rules when app restart Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 6/9] net/hns3: fix missing RSS in Rx offload capability Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 7/9] net/hns3: fix missing length of hash key when getting RSS Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 8/9] net/hns3: fix default VLAN filter configuration for PF Wei Hu (Xavier)
2020-04-10 11:09 ` [dpdk-dev] [PATCH 9/9] net/hns3: fix VLAN filter when setting promisucous mode Wei Hu (Xavier)
2020-04-14  8:31 ` [dpdk-dev] [PATCH 0/9] misc updates for hns3 PMD driver Ferruh Yigit
2020-04-17 11:09 ` oulijun

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=20200410110930.15717-2-huwei013@chinasoftinc.com \
    --to=huwei013@chinasoftinc.com \
    --cc=dev@dpdk.org \
    /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).