Received: by 10.223.185.82 with SMTP id b18csp15367wrg; Thu, 8 Mar 2018 18:09:40 -0800 (PST) X-Google-Smtp-Source: AG47ELvXtcTmmvaqXVUVTlvUaXevgvWpwtehGBP1x2z2sKPuu6gbB9nuE2QRk5ERjEBJjmz8vS08 X-Received: by 10.101.89.6 with SMTP id f6mr22924002pgu.22.1520561380859; Thu, 08 Mar 2018 18:09:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520561380; cv=none; d=google.com; s=arc-20160816; b=hnXG8DOKHpnrtwCuxpxzMI9ScrnrRN/vnVsrz+o1l2FhjUXzYbzRF4wzHaSX/JKhNY qbG6JZ21Y/IFGPDhvLXkCFpnHL0lIJcNjci6b1HcvUH6RuepD3BUME9rDxxsFSR4cuYm c4rPpA1rrk1PUXmEyCpCZPMx8KfY8r1bK2+dgUZiCUVIclu/55MvRKKy5NccuZ5bQiWm b65CvqNb662d4+a2RjvrAwL34SDXLDkXiC9/VM3UNMPsjark3LhJhhKcn93eZln+ihjk u5CGaLT9NYADrpY2YpcjwozTCbkNIjhn0CnZQ1UOUHrLroe/OnR0vq9XMO6+M8hcCt/M zR2Q== 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=lPLFahZsYNE7j34owJxky19QrpVeepTHv2ADrsa8nQo=; b=RahF5C9vJHUw4pYazfrftw3HA6ZS7zBIFFVSIC0S2ZEclFqOGq6DbCNcbOTgIssFfL 09NLJAKM4rVkI6vaxoE4lwrUUZIYlBr63N5jWWrRvgECUAQ3V0In0QtEedkfp5R9wMrX rnXBMlgnt/Zx45K/z0IqfTuHT50mrdJxbUjJ7NRCHN7sIcWY9CYD1LMEoY2s6lzXTN9t v2Myp2rEuizVK1x8Lkz54Jh71uZ7wfOQxIvTUwH5wTp2wGg4rSIwYhcIU5FaI35uWWAu qbFsB9xN2P5n3PNXwzmhDwThNnr73i5UqERc74UbNxLBa7A/hm7Ycvtx72ud5VVuXr6v ZepA== 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 v7si16595873pfi.403.2018.03.08.18.09.26; Thu, 08 Mar 2018 18:09:40 -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 S1752034AbeCICHh (ORCPT + 99 others); Thu, 8 Mar 2018 21:07:37 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:38063 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751008AbeCICFE (ORCPT ); Thu, 8 Mar 2018 21:05:04 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id F2B37F57392FE; 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:42 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 1/9] net: hns3: refactor the hclge_get/set_rss function Date: Fri, 9 Mar 2018 10:36:56 +0800 Message-ID: <1520563024-94811-2-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 This patch refactors the hclge_get/set_rss function in order to fix the rss configuration loss problem during reset process. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 39 ++++------------------ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 ++ 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 39bc0e6..cd5b040 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2979,31 +2979,6 @@ static u32 hclge_get_rss_indir_size(struct hnae3_handle *handle) return HCLGE_RSS_IND_TBL_SIZE; } -static int hclge_get_rss_algo(struct hclge_dev *hdev) -{ - struct hclge_rss_config_cmd *req; - struct hclge_desc desc; - int rss_hash_algo; - int ret; - - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_RSS_GENERIC_CONFIG, true); - - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, - "Get link status error, status =%d\n", ret); - return ret; - } - - req = (struct hclge_rss_config_cmd *)desc.data; - rss_hash_algo = (req->hash_config & HCLGE_RSS_HASH_ALGO_MASK); - - if (rss_hash_algo == HCLGE_RSS_HASH_ALGO_TOEPLITZ) - return ETH_RSS_HASH_TOP; - - return -EINVAL; -} - static int hclge_set_rss_algo_key(struct hclge_dev *hdev, const u8 hfunc, const u8 *key) { @@ -3042,7 +3017,7 @@ static int hclge_set_rss_algo_key(struct hclge_dev *hdev, return 0; } -static int hclge_set_rss_indir_table(struct hclge_dev *hdev, const u32 *indir) +static int hclge_set_rss_indir_table(struct hclge_dev *hdev, const u8 *indir) { struct hclge_rss_indirection_table_cmd *req; struct hclge_desc desc; @@ -3138,12 +3113,11 @@ static int hclge_get_rss(struct hnae3_handle *handle, u32 *indir, u8 *key, u8 *hfunc) { struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; int i; /* Get hash algorithm */ if (hfunc) - *hfunc = hclge_get_rss_algo(hdev); + *hfunc = vport->rss_algo; /* Get the RSS Key required by the user */ if (key) @@ -3167,8 +3141,6 @@ static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir, /* Set the RSS Hash Key if specififed by the user */ if (key) { - /* Update the shadow RSS key with user specified qids */ - memcpy(vport->rss_hash_key, key, HCLGE_RSS_KEY_SIZE); if (hfunc == ETH_RSS_HASH_TOP || hfunc == ETH_RSS_HASH_NO_CHANGE) @@ -3178,6 +3150,10 @@ static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir, ret = hclge_set_rss_algo_key(hdev, hash_algo, key); if (ret) return ret; + + /* Update the shadow RSS key with user specified qids */ + memcpy(vport->rss_hash_key, key, HCLGE_RSS_KEY_SIZE); + vport->rss_algo = hash_algo; } /* Update the shadow RSS table with user specified qids */ @@ -3185,8 +3161,7 @@ static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir, vport->rss_indirection_tbl[i] = indir[i]; /* Update the hardware */ - ret = hclge_set_rss_indir_table(hdev, indir); - return ret; + return hclge_set_rss_indir_table(hdev, vport->rss_indirection_tbl); } static u8 hclge_get_rss_hash_bits(struct ethtool_rxnfc *nfc) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index d99a76a..7e762c4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -579,6 +579,8 @@ struct hclge_vport { u8 rss_hash_key[HCLGE_RSS_KEY_SIZE]; /* User configured hash keys */ /* User configured lookup table entries */ u8 rss_indirection_tbl[HCLGE_RSS_IND_TBL_SIZE]; + int rss_algo; /* User configured hash algorithm */ + u16 alloc_rss_size; u16 qs_offset; -- 2.9.3