From patchwork Tue Jun 9 08:44:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70995 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D7847A04FA; Tue, 9 Jun 2020 10:46:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1E9052C57; Tue, 9 Jun 2020 10:46:03 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id B44FB2BE9 for ; Tue, 9 Jun 2020 10:45:57 +0200 (CEST) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7700BBD0EDE036826EA2 for ; Tue, 9 Jun 2020 16:45:55 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 9 Jun 2020 16:45:45 +0800 From: "Wei Hu (Xavier)" To: CC: , Date: Tue, 9 Jun 2020 16:44:14 +0800 Message-ID: <1591692257-55884-2-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> References: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 1/4] net/hns3: fix passing negative parameter to strerror 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" There is a coverity defect related "Argument cannot be negative". This patch fixes it by passing '-ret' to the function strerror() when ret is negative. Coverity issue: 349933 Fixes: fcba820d9b9e ("net/hns3: support flow director") Cc: stable@dpdk.org Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_fdir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c index 4c5928f..7bc5bf8 100644 --- a/drivers/net/hns3/hns3_fdir.c +++ b/drivers/net/hns3/hns3_fdir.c @@ -893,7 +893,7 @@ static int hns3_insert_fdir_filter(struct hns3_hw *hw, if (ret < 0) { rte_spinlock_unlock(&fdir_info->flows_lock); hns3_err(hw, "Hash table full? err:%d(%s)!", ret, - strerror(ret)); + strerror(-ret)); return ret; } From patchwork Tue Jun 9 08:44:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70993 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31169A04FA; Tue, 9 Jun 2020 10:46:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A61BD2BF7; Tue, 9 Jun 2020 10:46:00 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 801D529D6 for ; Tue, 9 Jun 2020 10:45:57 +0200 (CEST) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8663DF5BF3E8C82DD536 for ; Tue, 9 Jun 2020 16:45:55 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 9 Jun 2020 16:45:46 +0800 From: "Wei Hu (Xavier)" To: CC: , Date: Tue, 9 Jun 2020 16:44:15 +0800 Message-ID: <1591692257-55884-3-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> References: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 2/4] net/hns3: avoid unchecked return value in reset err process 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: Hongbo Zheng There is a coverity defect related "Unchecked return value". The internal static hns3_reset_err_handle function is reset error process of hns3 PMD driver. If failure in reset process, it does not mean that the network port is completely unavailable. so the command interface between driver and firmware still needs to be initialized. Regardless of whether the execution of the function named hns3_cmd_init is successful or not, the next process after execution must be continued, so there is no need to check the return value. If hns3_cmd_init fails to execute, there will be corresponding log information inside hns3_cmd_init. This patch adds '(void)' Type conversion to avoid coverity warnning. Coverity issue: 349934 Fixes: 2790c6464725 ("net/hns3: support device reset") Cc: stable@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_intr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c index 9953a1d..46d617c 100644 --- a/drivers/net/hns3/hns3_intr.c +++ b/drivers/net/hns3/hns3_intr.c @@ -882,8 +882,14 @@ hns3_reset_err_handle(struct hns3_adapter *hns) return true; } + /* + * Failure to reset does not mean that the network port is + * completely unavailable, so cmd still needs to be initialized. + * Regardless of whether the execution is successful or not, the + * flow after execution must be continued. + */ if (rte_atomic16_read(&hw->reset.disable_cmd)) - hns3_cmd_init(hw); + (void)hns3_cmd_init(hw); reset_fail: hw->reset.attempts = 0; hw->reset.stats.fail_cnt++; From patchwork Tue Jun 9 08:44:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70996 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 732F2A04FA; Tue, 9 Jun 2020 10:46:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2480A2D13; Tue, 9 Jun 2020 10:46:04 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id AF6972A62 for ; Tue, 9 Jun 2020 10:45:57 +0200 (CEST) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7DDABDFF77A314212BA8 for ; Tue, 9 Jun 2020 16:45:55 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 9 Jun 2020 16:45:46 +0800 From: "Wei Hu (Xavier)" To: CC: , Date: Tue, 9 Jun 2020 16:44:16 +0800 Message-ID: <1591692257-55884-4-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> References: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 3/4] net/hns3: fix unintended sign extension in fd operation 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" Currently, there are coverity defects warning as below: CID 349937 (#1 of 1): Unintended sign extension (SIGN_EXTENSION) sign_extension: Suspicious implicit sign extension: port_number with type uint16_t (16 bits, unsigned) is promoted in port_number << cur_pos to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If port_number << cur_pos is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. CID 349893 (#1 of 1): Unintended sign extension (SIGN_EXTENSION) sign_extension: Suspicious implicit sign extension: vlan_tag with type uint8_t (8 bits, unsigned) is promoted in vlan_tag << cur_pos to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If vlan_tag << cur_pos is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. This patch fixes them by replacing the data type of port_number and vlan_tag with uint32_t in the inner static function named hns3_fd_convert_meta_data of hns3 PMD driver. Coverity issue: 349937, 349893 Fixes: fcba820d9b9e ("net/hns3: support flow director") Cc: stable@dpdk.org Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_fdir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c index 7bc5bf8..6ab439d 100644 --- a/drivers/net/hns3/hns3_fdir.c +++ b/drivers/net/hns3/hns3_fdir.c @@ -619,7 +619,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg, uint8_t *key_x, uint8_t *key_y) { uint16_t meta_data = 0; - uint16_t port_number; + uint32_t port_number; uint8_t cur_pos = 0; uint8_t tuple_size; uint8_t shift_bits; @@ -637,7 +637,7 @@ static void hns3_fd_convert_meta_data(struct hns3_fd_key_cfg *cfg, rule->key_conf.spec.tunnel_type ? 1 : 0); cur_pos += tuple_size; } else if (i == VLAN_NUMBER) { - uint8_t vlan_tag; + uint32_t vlan_tag; uint8_t vlan_num; if (rule->key_conf.spec.tunnel_type == 0) vlan_num = rule->key_conf.vlan_num; From patchwork Tue Jun 9 08:44:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wei Hu (Xavier)" X-Patchwork-Id: 70994 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9CCB9A04FA; Tue, 9 Jun 2020 10:46:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D7C442C28; Tue, 9 Jun 2020 10:46:01 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id B29692BAB for ; Tue, 9 Jun 2020 10:45:57 +0200 (CEST) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7333B970BA08DD0369A3 for ; Tue, 9 Jun 2020 16:45:55 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 9 Jun 2020 16:45:46 +0800 From: "Wei Hu (Xavier)" To: CC: , Date: Tue, 9 Jun 2020 16:44:17 +0800 Message-ID: <1591692257-55884-5-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> References: <1591692257-55884-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH 4/4] net/hns3: fix unintended sign extension in dump operation 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: Hongbo Zheng There are coverity defects related "Unintended sign extension" in the internal static function named hns3_get_regs_length used for dumping reg operation. This patch fixes them by replacing the data type of cmdq_lines, common_lines, ring_lines and tqp_intr_lines with uint32_t in the inner static function named hns3_get_regs_length of hns3 PMD driver. Coverity issue: 349917, 349914 Fixes: 936eda25e8da ("net/hns3: support dump register") Cc: stable@dpdk.org Signed-off-by: Hongbo Zheng Signed-off-by: Wei Hu (Xavier) --- drivers/net/hns3/hns3_regs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c index a3f2a51..63c8602 100644 --- a/drivers/net/hns3/hns3_regs.c +++ b/drivers/net/hns3/hns3_regs.c @@ -116,7 +116,7 @@ static int hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length) { struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - int cmdq_lines, common_lines, ring_lines, tqp_intr_lines; + uint32_t cmdq_lines, common_lines, ring_lines, tqp_intr_lines; uint32_t regs_num_32_bit, regs_num_64_bit; uint32_t len; int ret;