net: hns3: fix rss configuration lost problem when setting channel
authorYunsheng Lin <linyunsheng@huawei.com>
Tue, 22 Jan 2019 23:39:30 +0000 (07:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Jan 2019 19:13:01 +0000 (11:13 -0800)
Currently rss configuration set by user will be lost when setting
channel.

This patch fixes it by not setting rss configuration to default
if user has configured the rss.

Fixes: 09f2af6405b8 ("net: hns3: add support to modify tqps number")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index d486748d588300a224e7c9635f9d49242d5f0ca6..dc3db45361d397715ccb1879da08407e131322de 100644 (file)
@@ -433,7 +433,8 @@ struct hnae3_ae_ops {
                             struct ethtool_channels *ch);
        void (*get_tqps_and_rss_info)(struct hnae3_handle *h,
                                      u16 *alloc_tqps, u16 *max_rss_size);
-       int (*set_channels)(struct hnae3_handle *handle, u32 new_tqps_num);
+       int (*set_channels)(struct hnae3_handle *handle, u32 new_tqps_num,
+                           bool rxfh_configured);
        void (*get_flowctrl_adv)(struct hnae3_handle *handle,
                                 u32 *flowctrl_adv);
        int (*set_led_id)(struct hnae3_handle *handle,
index 1f15864fb8db73816e47f3e88e4eef0f565b5873..544f0d2f1e12253b0d6b2613774cf63eb0d3b405 100644 (file)
@@ -4163,6 +4163,7 @@ int hns3_set_channels(struct net_device *netdev,
 {
        struct hnae3_handle *h = hns3_get_handle(netdev);
        struct hnae3_knic_private_info *kinfo = &h->kinfo;
+       bool rxfh_configured = netif_is_rxfh_configured(netdev);
        u32 new_tqp_num = ch->combined_count;
        u16 org_tqp_num;
        int ret;
@@ -4190,9 +4191,10 @@ int hns3_set_channels(struct net_device *netdev,
                return ret;
 
        org_tqp_num = h->kinfo.num_tqps;
-       ret = h->ae_algo->ops->set_channels(h, new_tqp_num);
+       ret = h->ae_algo->ops->set_channels(h, new_tqp_num, rxfh_configured);
        if (ret) {
-               ret = h->ae_algo->ops->set_channels(h, org_tqp_num);
+               ret = h->ae_algo->ops->set_channels(h, org_tqp_num,
+                                                   rxfh_configured);
                if (ret) {
                        /* If revert to old tqp failed, fatal error occurred */
                        dev_err(&netdev->dev,
index bf0931c6764f8e5a8c23098a065c9854eab56c9c..3ba8de93bc3d93abdd17bed5a8cbc0f8dc0b5d54 100644 (file)
@@ -7518,7 +7518,8 @@ static void hclge_get_tqps_and_rss_info(struct hnae3_handle *handle,
        *max_rss_size = hdev->rss_size_max;
 }
 
-static int hclge_set_channels(struct hnae3_handle *handle, u32 new_tqps_num)
+static int hclge_set_channels(struct hnae3_handle *handle, u32 new_tqps_num,
+                             bool rxfh_configured)
 {
        struct hclge_vport *vport = hclge_get_vport(handle);
        struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo;
@@ -7557,6 +7558,10 @@ static int hclge_set_channels(struct hnae3_handle *handle, u32 new_tqps_num)
        if (ret)
                return ret;
 
+       /* RSS indirection table has been configuared by user */
+       if (rxfh_configured)
+               goto out;
+
        /* Reinitializes the rss indirect table according to the new RSS size */
        rss_indir = kcalloc(HCLGE_RSS_IND_TBL_SIZE, sizeof(u32), GFP_KERNEL);
        if (!rss_indir)
@@ -7572,6 +7577,7 @@ static int hclge_set_channels(struct hnae3_handle *handle, u32 new_tqps_num)
 
        kfree(rss_indir);
 
+out:
        if (!ret)
                dev_info(&hdev->pdev->dev,
                         "Channels changed, rss_size from %d to %d, tqps from %d to %d",