]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: hns3: refactor the hclge_get/set_rss function
authorYunsheng Lin <linyunsheng@huawei.com>
Fri, 9 Mar 2018 02:36:56 +0000 (10:36 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 6 Jun 2018 18:40:03 +0000 (14:40 -0400)
BugLink: https://bugs.launchpad.net/bugs/1768670
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 <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 89523cfaa5e316ef3eec8d2c6ca44f9b5b9458d4)
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

index f9bea150259ef74c78a6c88163ac79a40a59875e..131234dfb05ff565dd545d024a17589fe9c66e54 100644 (file)
@@ -2981,31 +2981,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)
 {
@@ -3044,7 +3019,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;
@@ -3140,12 +3115,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)
@@ -3169,8 +3143,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)
@@ -3180,6 +3152,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 */
@@ -3187,8 +3163,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)
index d99a76a9557cdfb90cdf988546389477e1374a48..7e762c4d4d81185624ce43773fdad5d4dc5ae480 100644 (file)
@@ -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;