OSDN Git Service

net: hns3: add function type check for debugfs help information
authorYufeng Mo <moyufeng@huawei.com>
Fri, 19 Apr 2019 03:05:47 +0000 (11:05 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 20 Apr 2019 01:43:16 +0000 (18:43 -0700)
PF supports all debugfs command, but VF only supports part of
debugfs command. So VF should not show unsupported help information.

This patch adds a check for PF and PF to show the supportable help
information.

Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h

index 1532906..fc4917a 100644 (file)
@@ -239,6 +239,10 @@ static void hns3_dbg_help(struct hnae3_handle *h)
        dev_info(&h->pdev->dev, "queue info [number]\n");
        dev_info(&h->pdev->dev, "queue map\n");
        dev_info(&h->pdev->dev, "bd info [q_num] <bd index>\n");
+
+       if (!hns3_is_phys_func(h->pdev))
+               return;
+
        dev_info(&h->pdev->dev, "dump fd tcam\n");
        dev_info(&h->pdev->dev, "dump tc\n");
        dev_info(&h->pdev->dev, "dump tm map [q_num]\n");
@@ -344,6 +348,8 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer,
                ret = hns3_dbg_bd_info(handle, cmd_buf);
        else if (handle->ae_algo->ops->dbg_run_cmd)
                ret = handle->ae_algo->ops->dbg_run_cmd(handle, cmd_buf);
+       else
+               ret = -EOPNOTSUPP;
 
        if (ret)
                hns3_dbg_help(handle);
index 142fe6e..176d4b9 100644 (file)
@@ -1764,7 +1764,7 @@ static const struct net_device_ops hns3_nic_netdev_ops = {
        .ndo_set_vf_vlan        = hns3_ndo_set_vf_vlan,
 };
 
-static bool hns3_is_phys_func(struct pci_dev *pdev)
+bool hns3_is_phys_func(struct pci_dev *pdev)
 {
        u32 dev_id = pdev->device;
 
index f433c6d..cec56a5 100644 (file)
@@ -663,6 +663,7 @@ int hns3_init_all_ring(struct hns3_nic_priv *priv);
 int hns3_uninit_all_ring(struct hns3_nic_priv *priv);
 int hns3_nic_reset_all_ring(struct hnae3_handle *h);
 netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev);
+bool hns3_is_phys_func(struct pci_dev *pdev);
 int hns3_clean_rx_ring(
                struct hns3_enet_ring *ring, int budget,
                void (*rx_fn)(struct hns3_enet_ring *, struct sk_buff *));