Skip to content

Commit 482d2e9

Browse files
321lipengdavem330
authored andcommitted
net: hns3: add support to query tqps number
This patch adds the support to query tqps number for PF driver by using ehtool -l command. Signed-off-by: Peng Li <[email protected]> Signed-off-by: Mingguang Qu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 214bb1c commit 482d2e9

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ struct hnae3_ae_ops {
386386
u16 vlan, u8 qos, __be16 proto);
387387
void (*reset_event)(struct hnae3_handle *handle,
388388
enum hnae3_reset_type reset);
389+
void (*get_channels)(struct hnae3_handle *handle,
390+
struct ethtool_channels *ch);
389391
};
390392

391393
struct hnae3_dcb_ops {

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,15 @@ static int hns3_nway_reset(struct net_device *netdev)
849849
return genphy_restart_aneg(phy);
850850
}
851851

852+
void hns3_get_channels(struct net_device *netdev,
853+
struct ethtool_channels *ch)
854+
{
855+
struct hnae3_handle *h = hns3_get_handle(netdev);
856+
857+
if (h->ae_algo->ops->get_channels)
858+
h->ae_algo->ops->get_channels(h, ch);
859+
}
860+
852861
static const struct ethtool_ops hns3vf_ethtool_ops = {
853862
.get_drvinfo = hns3_get_drvinfo,
854863
.get_ringparam = hns3_get_ringparam,
@@ -883,6 +892,7 @@ static const struct ethtool_ops hns3_ethtool_ops = {
883892
.get_link_ksettings = hns3_get_link_ksettings,
884893
.set_link_ksettings = hns3_set_link_ksettings,
885894
.nway_reset = hns3_nway_reset,
895+
.get_channels = hns3_get_channels,
886896
};
887897

888898
void hns3_ethtool_set_ops(struct net_device *netdev)

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5002,6 +5002,26 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev)
50025002
ae_dev->priv = NULL;
50035003
}
50045004

5005+
static u32 hclge_get_max_channels(struct hnae3_handle *handle)
5006+
{
5007+
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
5008+
struct hclge_vport *vport = hclge_get_vport(handle);
5009+
struct hclge_dev *hdev = vport->back;
5010+
5011+
return min_t(u32, hdev->rss_size_max * kinfo->num_tc, hdev->num_tqps);
5012+
}
5013+
5014+
static void hclge_get_channels(struct hnae3_handle *handle,
5015+
struct ethtool_channels *ch)
5016+
{
5017+
struct hclge_vport *vport = hclge_get_vport(handle);
5018+
5019+
ch->max_combined = hclge_get_max_channels(handle);
5020+
ch->other_count = 1;
5021+
ch->max_other = 1;
5022+
ch->combined_count = vport->alloc_tqps;
5023+
}
5024+
50055025
static const struct hnae3_ae_ops hclge_ops = {
50065026
.init_ae_dev = hclge_init_ae_dev,
50075027
.uninit_ae_dev = hclge_uninit_ae_dev,
@@ -5046,6 +5066,7 @@ static const struct hnae3_ae_ops hclge_ops = {
50465066
.set_vlan_filter = hclge_set_port_vlan_filter,
50475067
.set_vf_vlan_filter = hclge_set_vf_vlan_filter,
50485068
.reset_event = hclge_reset_event,
5069+
.get_channels = hclge_get_channels,
50495070
};
50505071

50515072
static struct hnae3_ae_algo ae_algo = {

0 commit comments

Comments
 (0)