]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: hns3: Add "queue map" information query function
authorliuzhongzhu <liuzhongzhu@huawei.com>
Sat, 15 Dec 2018 15:31:57 +0000 (15:31 +0000)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 14 Jan 2019 09:28:55 +0000 (09:28 +0000)
BugLink: https://bugs.launchpad.net/bugs/1810457
This patch prints queue map information.

debugfs command:
echo dump queue map > cmd

Sample Command:
root@(none)# echo queue map > cmd
 local queue id | global queue id | vector id
          0              32             769
          1              33             770
          2              34             771
          3              35             772
          4              36             773
          5              37             774
          6              38             775
          7              39             776
          8              40             777
          9              41             778
         10              42             779
         11              43             780
         12              44             781
         13              45             782
         14              46             783
         15              47             784
root@(none)#

Signed-off-by: liuzhongzhu <liuzhongzhu@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(backported from commit 0c29d1912b81a0d8ab7eb46ce7036a8c0fb073e3)
[ dannf: trivial context fixes in hnae3.h and hclge_main.c ]
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

index 4d9cf39da48c7abc77fd7fa734770db8719d699f..691d12174902c13dd6fd9fb7a0a26fc1fa6a3273 100644 (file)
@@ -39,6 +39,7 @@ enum HCLGE_MBX_OPCODE {
        HCLGE_MBX_KEEP_ALIVE,           /* (VF -> PF) send keep alive cmd */
        HCLGE_MBX_SET_ALIVE,            /* (VF -> PF) set alive state */
        HCLGE_MBX_SET_MTU,              /* (VF -> PF) set mtu */
+       HCLGE_MBX_GET_QID_IN_PF,        /* (VF -> PF) get queue id in pf */
 };
 
 /* below are per-VF mac-vlan subcodes */
index a32c60c63c8a227736221ab81f73058c9615a464..e10ba6e1007ceefac5f94bf53c39cc4af2e6d770 100644 (file)
@@ -457,6 +457,7 @@ struct hnae3_ae_ops {
        bool (*get_hw_reset_stat)(struct hnae3_handle *handle);
        bool (*ae_dev_resetting)(struct hnae3_handle *handle);
        unsigned long (*ae_dev_reset_cnt)(struct hnae3_handle *handle);
+       u16 (*get_global_queue_id)(struct hnae3_handle *handle, u16 queue_id);
 };
 
 struct hnae3_dcb_ops {
index 005b7e77c3f3cad60b3a96489c7f3f9c0c1552d1..76c74b4b9777b77cdf1907cd8cc6e30dec76a72f 100644 (file)
@@ -125,6 +125,36 @@ static int hns3_dbg_queue_info(struct hnae3_handle *h, char *cmd_buf)
        return 0;
 }
 
+static int hns3_dbg_queue_map(struct hnae3_handle *h)
+{
+       struct hns3_nic_priv *priv = h->priv;
+       struct hns3_nic_ring_data *ring_data;
+       int i;
+
+       if (!h->ae_algo->ops->get_global_queue_id)
+               return -EOPNOTSUPP;
+
+       dev_info(&h->pdev->dev, "map info for queue id and vector id\n");
+       dev_info(&h->pdev->dev,
+                "local queue id | global queue id | vector id\n");
+       for (i = 0; i < h->kinfo.num_tqps; i++) {
+               u16 global_qid;
+
+               global_qid = h->ae_algo->ops->get_global_queue_id(h, i);
+               ring_data = &priv->ring_data[i];
+               if (!ring_data || !ring_data->ring ||
+                   !ring_data->ring->tqp_vector)
+                       continue;
+
+               dev_info(&h->pdev->dev,
+                        "      %4d            %4d            %4d\n",
+                        i, global_qid,
+                        ring_data->ring->tqp_vector->vector_irq);
+       }
+
+       return 0;
+}
+
 static int hns3_dbg_bd_info(struct hnae3_handle *h, char *cmd_buf)
 {
        struct hns3_nic_priv *priv = h->priv;
@@ -207,6 +237,7 @@ static void hns3_dbg_help(struct hnae3_handle *h)
 
        dev_info(&h->pdev->dev, "available commands\n");
        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");
        dev_info(&h->pdev->dev, "dump fd tcam\n");
        dev_info(&h->pdev->dev, "dump tc\n");
@@ -303,6 +334,8 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer,
                hns3_dbg_help(handle);
        else if (strncmp(cmd_buf, "queue info", 10) == 0)
                ret = hns3_dbg_queue_info(handle, cmd_buf);
+       else if (strncmp(cmd_buf, "queue map", 9) == 0)
+               ret = hns3_dbg_queue_map(handle);
        else if (strncmp(cmd_buf, "bd info", 7) == 0)
                ret = hns3_dbg_bd_info(handle, cmd_buf);
        else if (handle->ae_algo->ops->dbg_run_cmd)
index 88369f3fe7871ec849e2512f759d1670545621c3..4f435c8c939dfc6871d8d84bf7c23efaf5bccb66 100644 (file)
@@ -6608,8 +6608,7 @@ static int hclge_get_reset_status(struct hclge_dev *hdev, u16 queue_id)
        return hnae3_get_bit(req->ready_to_reset, HCLGE_TQP_RESET_B);
 }
 
-static u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle,
-                                         u16 queue_id)
+u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, u16 queue_id)
 {
        struct hnae3_queue *queue;
        struct hclge_tqp *tqp;
@@ -7982,6 +7981,7 @@ static const struct hnae3_ae_ops hclge_ops = {
        .get_hw_reset_stat = hclge_get_hw_reset_stat,
        .ae_dev_resetting = hclge_ae_dev_resetting,
        .ae_dev_reset_cnt = hclge_ae_dev_reset_cnt,
+       .get_global_queue_id = hclge_covert_handle_qid_global,
 };
 
 static struct hnae3_ae_algo ae_algo = {
index 9e027dbf0423665977a3e098c26f094935dceb12..af71dbce58737d8d2844634b963235f4758bc814 100644 (file)
@@ -872,4 +872,5 @@ int hclge_vport_start(struct hclge_vport *vport);
 void hclge_vport_stop(struct hclge_vport *vport);
 int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu);
 int hclge_dbg_run_cmd(struct hnae3_handle *handle, char *cmd_buf);
+u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, u16 queue_id);
 #endif
index e16a730a5f5452485c23990954d2a1097cc70831..a1de451a85dfc309e2e43c5de9b6760449c454f5 100644 (file)
@@ -413,6 +413,19 @@ static int hclge_set_vf_mtu(struct hclge_vport *vport,
        return hclge_gen_resp_to_vf(vport, mbx_req, ret, NULL, 0);
 }
 
+static int hclge_get_queue_id_in_pf(struct hclge_vport *vport,
+                                   struct hclge_mbx_vf_to_pf_cmd *mbx_req)
+{
+       u16 queue_id, qid_in_pf;
+       u8 resp_data[2];
+
+       memcpy(&queue_id, &mbx_req->msg[2], sizeof(queue_id));
+       qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id);
+       memcpy(resp_data, &qid_in_pf, sizeof(qid_in_pf));
+
+       return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data, 2);
+}
+
 static bool hclge_cmd_crq_empty(struct hclge_hw *hw)
 {
        u32 tail = hclge_read_dev(hw, HCLGE_NIC_CRQ_TAIL_REG);
@@ -533,6 +546,13 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
                                dev_err(&hdev->pdev->dev,
                                        "VF fail(%d) to set mtu\n", ret);
                        break;
+               case HCLGE_MBX_GET_QID_IN_PF:
+                       ret = hclge_get_queue_id_in_pf(vport, req);
+                       if (ret)
+                               dev_err(&hdev->pdev->dev,
+                                       "PF failed(%d) to get qid for VF\n",
+                                       ret);
+                       break;
                default:
                        dev_err(&hdev->pdev->dev,
                                "un-supported mailbox message, code = %d\n",
index 40543440cc4ef38335d9cff1a0b952f6f1ad8d6a..cf50ffc0ceef50285ff2457285ec3279c2d2a8bf 100644 (file)
@@ -256,6 +256,23 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev)
        return 0;
 }
 
+static u16 hclgevf_get_qid_global(struct hnae3_handle *handle, u16 queue_id)
+{
+       struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
+       u8 msg_data[2], resp_data[2];
+       u16 qid_in_pf = 0;
+       int ret;
+
+       memcpy(&msg_data[0], &queue_id, sizeof(queue_id));
+
+       ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_QID_IN_PF, 0, msg_data,
+                                  2, true, resp_data, 2);
+       if (!ret)
+               qid_in_pf = *(u16 *)resp_data;
+
+       return qid_in_pf;
+}
+
 static int hclgevf_alloc_tqps(struct hclgevf_dev *hdev)
 {
        struct hclgevf_tqp *tqp;
@@ -2634,6 +2651,7 @@ static const struct hnae3_ae_ops hclgevf_ops = {
        .ae_dev_resetting = hclgevf_ae_dev_resetting,
        .ae_dev_reset_cnt = hclgevf_ae_dev_reset_cnt,
        .set_mtu = hclgevf_set_mtu,
+       .get_global_queue_id = hclgevf_get_qid_global,
 };
 
 static struct hnae3_ae_algo ae_algovf = {