]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: hns3: add support to query tqps number
authorPeng Li <lipeng321@huawei.com>
Fri, 22 Dec 2017 04:21:40 +0000 (12:21 +0800)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 16 Mar 2018 15:47:03 +0000 (10:47 -0500)
BugLink: http://bugs.launchpad.net/bugs/1756097
This patch adds the support to query tqps number for PF driver
by using ehtool -l command.

Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Mingguang Qu <qumingguang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 482d2e9c1cc7c0e154464e3e052db09e5e62541f)
Signed-off-by: Manoj Iyer <manoj.iyer@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index a9e2b32834c58f775475d37a419aa80db88af098..d8877215723d4862ed0201b45dd0480d356b488b 100644 (file)
@@ -386,6 +386,8 @@ struct hnae3_ae_ops {
                                  u16 vlan, u8 qos, __be16 proto);
        void (*reset_event)(struct hnae3_handle *handle,
                            enum hnae3_reset_type reset);
+       void (*get_channels)(struct hnae3_handle *handle,
+                            struct ethtool_channels *ch);
 };
 
 struct hnae3_dcb_ops {
index 65a69b4394570a666a2e62be821edc92e5964aa1..23af36c2156881feaaa2366401a5d58ac0d42cd9 100644 (file)
@@ -849,6 +849,15 @@ static int hns3_nway_reset(struct net_device *netdev)
        return genphy_restart_aneg(phy);
 }
 
+void hns3_get_channels(struct net_device *netdev,
+                      struct ethtool_channels *ch)
+{
+       struct hnae3_handle *h = hns3_get_handle(netdev);
+
+       if (h->ae_algo->ops->get_channels)
+               h->ae_algo->ops->get_channels(h, ch);
+}
+
 static const struct ethtool_ops hns3vf_ethtool_ops = {
        .get_drvinfo = hns3_get_drvinfo,
        .get_ringparam = hns3_get_ringparam,
@@ -883,6 +892,7 @@ static const struct ethtool_ops hns3_ethtool_ops = {
        .get_link_ksettings = hns3_get_link_ksettings,
        .set_link_ksettings = hns3_set_link_ksettings,
        .nway_reset = hns3_nway_reset,
+       .get_channels = hns3_get_channels,
 };
 
 void hns3_ethtool_set_ops(struct net_device *netdev)
index e97fd6654e5e46ae9ca25c8e7a10de2a2f22f3f6..a3101bcc33dd017351f9a20ae10a49295647040a 100644 (file)
@@ -5002,6 +5002,26 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
        ae_dev->priv = NULL;
 }
 
+static u32 hclge_get_max_channels(struct hnae3_handle *handle)
+{
+       struct hnae3_knic_private_info *kinfo = &handle->kinfo;
+       struct hclge_vport *vport = hclge_get_vport(handle);
+       struct hclge_dev *hdev = vport->back;
+
+       return min_t(u32, hdev->rss_size_max * kinfo->num_tc, hdev->num_tqps);
+}
+
+static void hclge_get_channels(struct hnae3_handle *handle,
+                              struct ethtool_channels *ch)
+{
+       struct hclge_vport *vport = hclge_get_vport(handle);
+
+       ch->max_combined = hclge_get_max_channels(handle);
+       ch->other_count = 1;
+       ch->max_other = 1;
+       ch->combined_count = vport->alloc_tqps;
+}
+
 static const struct hnae3_ae_ops hclge_ops = {
        .init_ae_dev = hclge_init_ae_dev,
        .uninit_ae_dev = hclge_uninit_ae_dev,
@@ -5046,6 +5066,7 @@ static const struct hnae3_ae_ops hclge_ops = {
        .set_vlan_filter = hclge_set_port_vlan_filter,
        .set_vf_vlan_filter = hclge_set_vf_vlan_filter,
        .reset_event = hclge_reset_event,
+       .get_channels = hclge_get_channels,
 };
 
 static struct hnae3_ae_algo ae_algo = {