OSDN Git Service

net: hns3: Modify hns3_get_max_available_channels
authorHuazhong Tan <tanhuazhong@huawei.com>
Wed, 26 Sep 2018 18:28:39 +0000 (19:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Sep 2018 17:37:42 +0000 (10:37 -0700)
The current hns3_get_max_available_channels returns the total number
of queues for the device, which makes ethtool -L set the number of queues
per channel queues incorrectly, so hns3_get_max_available_channels should
return the maximum available number of queues per channel, depending on
the total number of queues allocated and the hardware configurations.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@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
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

index 8581e16..dea422c 100644 (file)
@@ -403,7 +403,7 @@ struct hnae3_ae_ops {
        void (*get_channels)(struct hnae3_handle *handle,
                             struct ethtool_channels *ch);
        void (*get_tqps_and_rss_info)(struct hnae3_handle *h,
-                                     u16 *free_tqps, u16 *max_rss_size);
+                                     u16 *alloc_tqps, u16 *max_rss_size);
        int (*set_channels)(struct hnae3_handle *handle, u32 new_tqps_num);
        void (*get_flowctrl_adv)(struct hnae3_handle *handle,
                                 u32 *flowctrl_adv);
index 545777a..8273c03 100644 (file)
@@ -307,12 +307,12 @@ static int hns3_nic_set_real_num_queue(struct net_device *netdev)
 
 static u16 hns3_get_max_available_channels(struct hnae3_handle *h)
 {
-       u16 free_tqps, max_rss_size, max_tqps;
+       u16 alloc_tqps, max_rss_size, rss_size;
 
-       h->ae_algo->ops->get_tqps_and_rss_info(h, &free_tqps, &max_rss_size);
-       max_tqps = h->kinfo.num_tc * max_rss_size;
+       h->ae_algo->ops->get_tqps_and_rss_info(h, &alloc_tqps, &max_rss_size);
+       rss_size = alloc_tqps / h->kinfo.num_tc;
 
-       return min_t(u16, max_tqps, (free_tqps + h->kinfo.num_tqps));
+       return min_t(u16, rss_size, max_rss_size);
 }
 
 static int hns3_nic_net_up(struct net_device *netdev)
@@ -3164,12 +3164,14 @@ static void hns3_nic_set_priv_ops(struct net_device *netdev)
 static int hns3_client_init(struct hnae3_handle *handle)
 {
        struct pci_dev *pdev = handle->pdev;
+       u16 alloc_tqps, max_rss_size;
        struct hns3_nic_priv *priv;
        struct net_device *netdev;
        int ret;
 
-       netdev = alloc_etherdev_mq(sizeof(struct hns3_nic_priv),
-                                  hns3_get_max_available_channels(handle));
+       handle->ae_algo->ops->get_tqps_and_rss_info(handle, &alloc_tqps,
+                                                   &max_rss_size);
+       netdev = alloc_etherdev_mq(sizeof(struct hns3_nic_priv), alloc_tqps);
        if (!netdev)
                return -ENOMEM;
 
index d8b0d16..67b131d 100644 (file)
@@ -5659,18 +5659,12 @@ static void hclge_get_channels(struct hnae3_handle *handle,
 }
 
 static void hclge_get_tqps_and_rss_info(struct hnae3_handle *handle,
-                                       u16 *free_tqps, u16 *max_rss_size)
+                                       u16 *alloc_tqps, u16 *max_rss_size)
 {
        struct hclge_vport *vport = hclge_get_vport(handle);
        struct hclge_dev *hdev = vport->back;
-       u16 temp_tqps = 0;
-       int i;
 
-       for (i = 0; i < hdev->num_tqps; i++) {
-               if (!hdev->htqp[i].alloced)
-                       temp_tqps++;
-       }
-       *free_tqps = temp_tqps;
+       *alloc_tqps = vport->alloc_tqps;
        *max_rss_size = hdev->rss_size_max;
 }
 
index 9781931..8f858cb 100644 (file)
@@ -1975,11 +1975,11 @@ static void hclgevf_get_channels(struct hnae3_handle *handle,
 }
 
 static void hclgevf_get_tqps_and_rss_info(struct hnae3_handle *handle,
-                                         u16 *free_tqps, u16 *max_rss_size)
+                                         u16 *alloc_tqps, u16 *max_rss_size)
 {
        struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
 
-       *free_tqps = 0;
+       *alloc_tqps = hdev->num_tqps;
        *max_rss_size = hdev->rss_size_max;
 }