From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B427A059F; Fri, 10 Apr 2020 13:10:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7A2231C216; Fri, 10 Apr 2020 13:09:59 +0200 (CEST) Received: from mail.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 9CCF61C11E for ; Fri, 10 Apr 2020 13:09:56 +0200 (CEST) Received: from localhost.localdomain (114.119.4.74) by INCCAS002.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Fri, 10 Apr 2020 19:09:41 +0800 From: "Wei Hu (Xavier)" To: Date: Fri, 10 Apr 2020 19:09:22 +0800 Message-ID: <20200410110930.15717-2-huwei013@chinasoftinc.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200410110930.15717-1-huwei013@chinasoftinc.com> References: <20200410110930.15717-1-huwei013@chinasoftinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [114.119.4.74] Subject: [dpdk-dev] [PATCH 1/9] net/hns3: simplify process of some return values X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Lijun Ou 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 Signed-off-by: Wei Hu (Xavier) --- 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(¶m, en_uc_pmc, en_mc_pmc, en_bc_pmc, vf_id); - ret = hns3_cmd_set_promisc_mode(hw, ¶m); - if (ret) - return ret; - - return 0; + return hns3_cmd_set_promisc_mode(hw, ¶m); } 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