]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: hns3: Add "FD flow table" info query function
authorliuzhongzhu <liuzhongzhu@huawei.com>
Thu, 22 Nov 2018 14:09:43 +0000 (14:09 +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
All the Flow Director rules are stored in tcam blocks.
For each bit of tcam entry, the match value
depends on two input value(x, y).

debugfs command:
echo dump fd tcam > cmd

Sample output:
root@(none)# echo dump fd tcam > cmd
hns3 0000:7d:00.0: read result tcam key x(31):
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 08000000
hns3 0000:7d:00.0: 00000600
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: read result tcam key y(31):
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: f7ff0000
hns3 0000:7d:00.0: 0000f900
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 00000000
hns3 0000:7d:00.0: 0000fff8
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>
(cherry picked from commit 3c666b586af1c6ed6e352555aec38d2f9478cd47)
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/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/Makefile
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c [new file with mode: 0644]
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

index e16e6102a396a8a899a5bb80a569e02307b08b09..70d28a24911a0a8b3a4eccb306b3890384caa2cc 100644 (file)
@@ -451,6 +451,7 @@ struct hnae3_ae_ops {
                                struct ethtool_rxnfc *cmd, u32 *rule_locs);
        int (*restore_fd_rules)(struct hnae3_handle *handle);
        void (*enable_fd)(struct hnae3_handle *handle, bool enable);
+       int (*dbg_run_cmd)(struct hnae3_handle *handle, char *cmd_buf);
        pci_ers_result_t (*process_hw_error)(struct hnae3_ae_dev *ae_dev);
        bool (*get_hw_reset_stat)(struct hnae3_handle *handle);
        bool (*ae_dev_resetting)(struct hnae3_handle *handle);
index c0685b3ef5c93be17eea3219e0e31813357f45dd..82fe7b97408f272d21085dde26d10a8310ba8375 100644 (file)
@@ -200,6 +200,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 (handle->ae_algo->ops->dbg_run_cmd)
+               ret = handle->ae_algo->ops->dbg_run_cmd(handle, cmd_buf);
 
        if (ret)
                hns3_dbg_help(handle);
index 580e81743681a24b8f1883265bcf03bc07148279..fffe8c1c45d394b2a0723443582d6427ffa6e387 100644 (file)
@@ -6,6 +6,6 @@
 ccflags-y := -Idrivers/net/ethernet/hisilicon/hns3
 
 obj-$(CONFIG_HNS3_HCLGE) += hclge.o
-hclge-objs = hclge_main.o hclge_cmd.o hclge_mdio.o hclge_tm.o hclge_mbx.o hclge_err.o
+hclge-objs = hclge_main.o hclge_cmd.o hclge_mdio.o hclge_tm.o hclge_mbx.o hclge_err.o  hclge_debugfs.o
 
 hclge-$(CONFIG_HNS3_DCB) += hclge_dcb.o
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
new file mode 100644 (file)
index 0000000..cf1355b
--- /dev/null
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* Copyright (c) 2018-2019 Hisilicon Limited. */
+
+#include <linux/device.h>
+
+#include "hclge_cmd.h"
+#include "hclge_main.h"
+#include "hnae3.h"
+
+static void hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage,
+                                  bool sel_x, u32 loc)
+{
+       struct hclge_fd_tcam_config_1_cmd *req1;
+       struct hclge_fd_tcam_config_2_cmd *req2;
+       struct hclge_fd_tcam_config_3_cmd *req3;
+       struct hclge_desc desc[3];
+       int ret, i;
+       u32 *req;
+
+       hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_FD_TCAM_OP, true);
+       desc[0].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
+       hclge_cmd_setup_basic_desc(&desc[1], HCLGE_OPC_FD_TCAM_OP, true);
+       desc[1].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT);
+       hclge_cmd_setup_basic_desc(&desc[2], HCLGE_OPC_FD_TCAM_OP, true);
+
+       req1 = (struct hclge_fd_tcam_config_1_cmd *)desc[0].data;
+       req2 = (struct hclge_fd_tcam_config_2_cmd *)desc[1].data;
+       req3 = (struct hclge_fd_tcam_config_3_cmd *)desc[2].data;
+
+       req1->stage  = stage;
+       req1->xy_sel = sel_x ? 1 : 0;
+       req1->index  = cpu_to_le32(loc);
+
+       ret = hclge_cmd_send(&hdev->hw, desc, 3);
+       if (ret)
+               return;
+
+       dev_info(&hdev->pdev->dev, " read result tcam key %s(%u):\n",
+                sel_x ? "x" : "y", loc);
+
+       req = (u32 *)req1->tcam_data;
+       for (i = 0; i < 2; i++)
+               dev_info(&hdev->pdev->dev, "%08x\n", *req++);
+
+       req = (u32 *)req2->tcam_data;
+       for (i = 0; i < 6; i++)
+               dev_info(&hdev->pdev->dev, "%08x\n", *req++);
+
+       req = (u32 *)req3->tcam_data;
+       for (i = 0; i < 5; i++)
+               dev_info(&hdev->pdev->dev, "%08x\n", *req++);
+}
+
+static void hclge_dbg_fd_tcam(struct hclge_dev *hdev)
+{
+       u32 i;
+
+       for (i = 0; i < hdev->fd_cfg.rule_num[0]; i++) {
+               hclge_dbg_fd_tcam_read(hdev, 0, true, i);
+               hclge_dbg_fd_tcam_read(hdev, 0, false, i);
+       }
+}
+
+int hclge_dbg_run_cmd(struct hnae3_handle *handle, char *cmd_buf)
+{
+       struct hclge_vport *vport = hclge_get_vport(handle);
+       struct hclge_dev *hdev = vport->back;
+
+       if (strncmp(cmd_buf, "dump fd tcam", 12) == 0) {
+               hclge_dbg_fd_tcam(hdev);
+       } else {
+               dev_info(&hdev->pdev->dev, "unknown command\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
index 12ccbaa6cbd1bbbe47b9bce64868948481c1dfbf..e1430296ce57b12e4805d8d2285a9fcd69c30bb7 100644 (file)
@@ -7828,6 +7828,7 @@ static const struct hnae3_ae_ops hclge_ops = {
        .get_fd_all_rules = hclge_get_all_rules,
        .restore_fd_rules = hclge_restore_fd_entries,
        .enable_fd = hclge_enable_fd,
+       .dbg_run_cmd = hclge_dbg_run_cmd,
        .process_hw_error = hclge_process_ras_hw_error,
        .get_hw_reset_stat = hclge_get_hw_reset_stat,
        .ae_dev_resetting = hclge_ae_dev_resetting,
index 5f24dd41d7eb292871170fa0a0bc5f294bc14147..4122ad1aab1fb6c18395a2a52291fa61b745713f 100644 (file)
@@ -814,4 +814,5 @@ int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id);
 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);
 #endif