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 C5B54A00C5 for ; Fri, 29 May 2020 05:59:06 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EF3651D5EC; Fri, 29 May 2020 05:59:05 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 95F0A1DBD6 for ; Fri, 29 May 2020 05:59:04 +0200 (CEST) Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 4061D4C7C33020E13D07 for ; Fri, 29 May 2020 11:59:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Fri, 29 May 2020 11:58:54 +0800 From: "Wei Hu (Xavier)" To: CC: , Date: Fri, 29 May 2020 11:57:34 +0800 Message-ID: <1590724654-23075-7-git-send-email-xavier.huwei@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590724654-23075-1-git-send-email-xavier.huwei@huawei.com> References: <1590724654-23075-1-git-send-email-xavier.huwei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-stable] [PATCH 19.11 6/6] net/hns3: fix MSI-X interrupt during initialization X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream commit 2de74dcfbd150fde59c8e0a20ae21e22ab27605e ] Currently, based on hns3 VF device error may occur during initialization. The root cause as below: When the following formula is executed during initialization, the private variable named hw->tqps_num has not been obtained from PF driver through mailbox, further causes failure when mapping interrupt and queues. hw->num_msi = (num_msi > hw->tqps_num + 1) ? hw->tqps_num + 1 : num_msi; We need to use hw->tqp_num after it is correctly assigned. On the other hand, because the private variable named hw->num_msi, which represents the number of MSI-x interrupt of hns3 PF/VF device, is used in the '.get_reg' ops implementation function to dump all interrupt related registers, it should be obtained from firmware directly and we'd better not modify it in the driver. Fixes: ef2e785c36cf ("net/hns3: fix Tx interrupt when enabling Rx interrupt") Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt") Cc: stable@dpdk.org Signed-off-by: Wei Hu (Xavier) Signed-off-by: Hao Chen Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 10 +++++----- drivers/net/hns3/hns3_ethdev_vf.c | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index c693913..3271b61 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2150,7 +2150,8 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) * Rx interrupt. */ vec = hw->num_msi - 1; /* vector 0 for misc interrupt, not for queue */ - hw->intr_tqps_num = vec - 1; /* the last interrupt is reserved */ + /* vec - 1: the last interrupt is reserved */ + hw->intr_tqps_num = vec > hw->tqps_num ? hw->tqps_num : vec - 1; for (i = 0; i < hw->intr_tqps_num; i++) { /* * Set gap limiter and rate limiter configuration of queue's @@ -2523,7 +2524,6 @@ hns3_query_pf_resource(struct hns3_hw *hw) struct hns3_pf *pf = &hns->pf; struct hns3_pf_res_cmd *req; struct hns3_cmd_desc desc; - uint16_t num_msi; int ret; hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_PF_RSRC, true); @@ -2555,9 +2555,9 @@ hns3_query_pf_resource(struct hns3_hw *hw) pf->dv_buf_size = roundup(pf->dv_buf_size, HNS3_BUF_SIZE_UNIT); - num_msi = hns3_get_field(rte_le_to_cpu_16(req->pf_intr_vector_number), - HNS3_VEC_NUM_M, HNS3_VEC_NUM_S); - hw->num_msi = (num_msi > hw->tqps_num + 1) ? hw->tqps_num + 1 : num_msi; + hw->num_msi = + hns3_get_field(rte_le_to_cpu_16(req->pf_intr_vector_number), + HNS3_VEC_NUM_M, HNS3_VEC_NUM_S); return 0; } diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 11d7dea..251d0ef 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -472,7 +472,8 @@ hns3vf_init_ring_with_vector(struct hns3_hw *hw) * Rx interrupt. */ vec = hw->num_msi - 1; /* vector 0 for misc interrupt, not for queue */ - hw->intr_tqps_num = vec - 1; /* the last interrupt is reserved */ + /* vec - 1: the last interrupt is reserved */ + hw->intr_tqps_num = vec > hw->tqps_num ? hw->tqps_num : vec - 1; for (i = 0; i < hw->intr_tqps_num; i++) { /* * Set gap limiter and rate limiter configuration of queue's @@ -1203,7 +1204,7 @@ hns3_query_vf_resource(struct hns3_hw *hw) return -EINVAL; } - hw->num_msi = (num_msi > hw->tqps_num + 1) ? hw->tqps_num + 1 : num_msi; + hw->num_msi = num_msi; return 0; } -- 2.7.4