Received: by 10.223.185.82 with SMTP id b18csp13303wrg; Thu, 8 Mar 2018 18:06:38 -0800 (PST) X-Google-Smtp-Source: AG47ELuCPRjenCc/ug3Dl+Fc3dwN3LxzSqwyqFREuDnMR5gqdSqBUK2Usw5vBRW+R1MsNSbDVqNr X-Received: by 2002:a17:902:7883:: with SMTP id q3-v6mr25804010pll.361.1520561198033; Thu, 08 Mar 2018 18:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520561198; cv=none; d=google.com; s=arc-20160816; b=YUrMJw5N8qXWGDKxEfZW0Dr6DJtGIhP9WpzSARtylbtosHtNoPNp4hEjFpjQMKZFAh LfNYVUlH2Il8tiK7q7mh2dGrcRp+VUTX8NNnOObvrx6z9tEFSpb3ubQR6tfmJzm7ZBUt 5DP8RxzyxDOSUo4fHXoV0t5Yi8yh1Q3qz65a2Cq3jv9EKm5R2UTqQ4DygfFD6mSlYBMr EXT/rZGIuLzZT/2p5barPHMMObtEaljfgxB1GDWYX0Q2DUe0i1lvVQxl98xXNo86I6q7 rJqC4QMydOlMfQhfE/DgJdtiPNpiMWE7LC8h7nsnVf50IQOkQk7sZnKfFTewm/OsZ97w oeQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=HlXP1wMl1Q2YbqGYZvBhZolC0oNXsKv221DQKVKZhgQ=; b=WBpb8JI3Mb022+yg9ZoSZHf00bVThWArih8UmNA8236DQRcX+echv3jkcGwIgaZ9tB JLJiUcN4TFDf1nXph480gs0c4jdEC3hv6ApHY7BffNg2/3hnKuCt1ji7olVK6HstFd1p AnDoQO9JJXXeaC/uacCPj+eL7HBYiMeWNEFgfkbmgDPnhIysOm+tY+d2hrV7b19bFZA6 Q1Nl3XjitAqURgAGRsV3G0sNno6axtIwbNZyMIWlr+JSG+ms0+eVoI5aNZH0FBB2Rm9T sCBg2DZsuMu8Dxy3nz27oTSxZjh5WdR1NQzWFhM1dMsYt+5PlXVbbwexZkflIaznjigX l/Xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si16787193pfm.327.2018.03.08.18.06.23; Thu, 08 Mar 2018 18:06:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751290AbeCICFI (ORCPT + 99 others); Thu, 8 Mar 2018 21:05:08 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:38055 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750902AbeCICFC (ORCPT ); Thu, 8 Mar 2018 21:05:02 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id AB063BBA22249; Fri, 9 Mar 2018 10:04:49 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Fri, 9 Mar 2018 10:04:43 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 6/9] net: hns3: refactor the get/put_vector function Date: Fri, 9 Mar 2018 10:37:01 +0800 Message-ID: <1520563024-94811-7-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520563024-94811-1-git-send-email-lipeng321@huawei.com> References: <1520563024-94811-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin There is a get_vector function, which allocate the vectors for a client, but there is not a put_vector to free the vector. This patch introduces the put_vector function in order to fix the coalesce configuration lost problem during reset process. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 3 +++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 ++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 28 ++++++++++++++++------ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 12 +++++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index fd06bc7..a072048 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -265,6 +265,8 @@ struct hnae3_ae_dev { * Get tc size of handle * get_vector() * Get vector number and vector information + * put_vector() + * Put the vector in hdev * map_ring_to_vector() * Map rings to vector * unmap_ring_from_vector() @@ -375,6 +377,7 @@ struct hnae3_ae_ops { int (*get_vector)(struct hnae3_handle *handle, u16 vector_num, struct hnae3_vector_info *vector_info); + int (*put_vector)(struct hnae3_handle *handle, int vector_num); int (*map_ring_to_vector)(struct hnae3_handle *handle, int vector_num, struct hnae3_ring_chain_node *vr_chain); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index e0ab161..bbaa21f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2721,6 +2721,10 @@ static int hns3_nic_uninit_vector_data(struct hns3_nic_priv *priv) if (ret) return ret; + ret = h->ae_algo->ops->put_vector(h, tqp_vector->vector_irq); + if (ret) + return ret; + hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain); if (priv->tqp_vector[i].irq_init_flag == HNS3_VECTOR_INITED) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 109155d..a318773 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2969,6 +2969,24 @@ static int hclge_get_vector_index(struct hclge_dev *hdev, int vector) return -EINVAL; } +static int hclge_put_vector(struct hnae3_handle *handle, int vector) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_dev *hdev = vport->back; + int vector_id; + + vector_id = hclge_get_vector_index(hdev, vector); + if (vector_id < 0) { + dev_err(&hdev->pdev->dev, + "Get vector index fail. vector_id =%d\n", vector_id); + return vector_id; + } + + hclge_free_vector(hdev, vector_id); + + return 0; +} + static u32 hclge_get_rss_key_size(struct hnae3_handle *handle) { return HCLGE_RSS_KEY_SIZE; @@ -3523,18 +3541,13 @@ static int hclge_unmap_ring_frm_vector(struct hnae3_handle *handle, } ret = hclge_bind_ring_with_vector(vport, vector_id, false, ring_chain); - if (ret) { + if (ret) dev_err(&handle->pdev->dev, "Unmap ring from vector fail. vectorid=%d, ret =%d\n", vector_id, ret); - return ret; - } - - /* Free this MSIX or MSI vector */ - hclge_free_vector(hdev, vector_id); - return 0; + return ret; } int hclge_cmd_set_promisc_mode(struct hclge_dev *hdev, @@ -5994,6 +6007,7 @@ static const struct hnae3_ae_ops hclge_ops = { .map_ring_to_vector = hclge_map_ring_to_vector, .unmap_ring_from_vector = hclge_unmap_ring_frm_vector, .get_vector = hclge_get_vector, + .put_vector = hclge_put_vector, .set_promisc_mode = hclge_set_promisc_mode, .set_loopback = hclge_set_loopback, .start = hclge_ae_start, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index c9a916a..09a2a66 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -627,13 +627,18 @@ static int hclgevf_unmap_ring_from_vector( } ret = hclgevf_bind_ring_to_vector(handle, false, vector, ring_chain); - if (ret) { + if (ret) dev_err(&handle->pdev->dev, "Unmap ring from vector fail. vector=%d, ret =%d\n", vector_id, ret); - return ret; - } + + return ret; +} + +static int hclgevf_put_vector(struct hnae3_handle *handle, int vector) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); hclgevf_free_vector(hdev, vector); @@ -1466,6 +1471,7 @@ static const struct hnae3_ae_ops hclgevf_ops = { .map_ring_to_vector = hclgevf_map_ring_to_vector, .unmap_ring_from_vector = hclgevf_unmap_ring_from_vector, .get_vector = hclgevf_get_vector, + .put_vector = hclgevf_put_vector, .reset_queue = hclgevf_reset_tqp, .set_promisc_mode = hclgevf_set_promisc_mode, .get_mac_addr = hclgevf_get_mac_addr, -- 2.9.3