提交 3fb1efb2 编写于 作者: Y Yufeng Mo 提交者: Yang Yingliang

net: hns3: support of dump mac id and loopback status in debugfs

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

The MAC id and loopback status information are obtained from
the hardware, which will be helpful for debugging. This patch
adds support for these two items in debugfs.
Signed-off-by: NYufeng Mo <moyufeng@huawei.com>
Reviewed-by: NPeng Li <lipeng321@huawei.com>
Reviewed-by: NZhong Zhaohui <zhongzhaohui@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 dbd880c2
...@@ -261,6 +261,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) ...@@ -261,6 +261,7 @@ static void hns3_dbg_help(struct hnae3_handle *h)
dev_info(&h->pdev->dev, "dump m7 info\n"); dev_info(&h->pdev->dev, "dump m7 info\n");
dev_info(&h->pdev->dev, "dump ncl_config <offset> <length>(in hex)\n"); dev_info(&h->pdev->dev, "dump ncl_config <offset> <length>(in hex)\n");
dev_info(&h->pdev->dev, "dump mac tnl status\n"); dev_info(&h->pdev->dev, "dump mac tnl status\n");
dev_info(&h->pdev->dev, "dump loopback\n");
dev_info(&h->pdev->dev, "dump uc mac list <func id>\n"); dev_info(&h->pdev->dev, "dump uc mac list <func id>\n");
dev_info(&h->pdev->dev, "dump mc mac list <func id>\n"); dev_info(&h->pdev->dev, "dump mc mac list <func id>\n");
......
...@@ -1313,6 +1313,51 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, ...@@ -1313,6 +1313,51 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev,
} }
} }
static void hclge_dbg_dump_loopback(struct hclge_dev *hdev,
const char *cmd_buf)
{
struct hclge_config_mac_mode_cmd *req_app;
struct hclge_serdes_lb_cmd *req_serdes;
struct hclge_desc desc;
u8 loopback_en;
int ret;
req_app = (struct hclge_config_mac_mode_cmd *)desc.data;
req_serdes = (struct hclge_serdes_lb_cmd *)desc.data;
dev_info(&hdev->pdev->dev, "mac id: %u\n", hdev->hw.mac.mac_id);
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CONFIG_MAC_MODE, true);
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) {
dev_err(&hdev->pdev->dev,
"failed to dump app loopback status, ret=%d\n", ret);
return;
}
loopback_en = hnae3_get_bit(le32_to_cpu(req_app->txrx_pad_fcs_loop_en),
HCLGE_MAC_APP_LP_B);
dev_info(&hdev->pdev->dev, "app loopback: %s\n",
loopback_en ? "on" : "off");
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SERDES_LOOPBACK, true);
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) {
dev_err(&hdev->pdev->dev,
"failed to dump serdes loopback status, ret=%d\n", ret);
return;
}
loopback_en = req_serdes->enable & HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B;
dev_info(&hdev->pdev->dev, "serdes serial loopback: %s\n",
loopback_en ? "on" : "off");
loopback_en = req_serdes->enable &
HCLGE_CMD_SERDES_PARALLEL_INNER_LOOP_B;
dev_info(&hdev->pdev->dev, "serdes parallel loopback: %s\n",
loopback_en ? "on" : "off");
}
/* hclge_dbg_dump_mac_tnl_status: print message about mac tnl interrupt /* hclge_dbg_dump_mac_tnl_status: print message about mac tnl interrupt
* @hdev: pointer to struct hclge_dev * @hdev: pointer to struct hclge_dev
*/ */
...@@ -1455,6 +1500,7 @@ static int hclge_dbg_dump_mac_list(struct hclge_dev *hdev, const char *cmd_buf, ...@@ -1455,6 +1500,7 @@ static int hclge_dbg_dump_mac_list(struct hclge_dev *hdev, const char *cmd_buf,
int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf)
{ {
#define DUMP_REG "dump reg" #define DUMP_REG "dump reg"
#define DUMP_LOOPBACK "dump loopback"
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
...@@ -1490,6 +1536,9 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) ...@@ -1490,6 +1536,9 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf)
&cmd_buf[sizeof("dump ncl_config")]); &cmd_buf[sizeof("dump ncl_config")]);
} else if (strncmp(cmd_buf, "dump mac tnl status", 19) == 0) { } else if (strncmp(cmd_buf, "dump mac tnl status", 19) == 0) {
hclge_dbg_dump_mac_tnl_status(hdev); hclge_dbg_dump_mac_tnl_status(hdev);
} else if (strncmp(cmd_buf, DUMP_LOOPBACK,
strlen(DUMP_LOOPBACK)) == 0) {
hclge_dbg_dump_loopback(hdev, &cmd_buf[sizeof(DUMP_LOOPBACK)]);
} else if (strncmp(cmd_buf, "dump qs shaper", 14) == 0) { } else if (strncmp(cmd_buf, "dump qs shaper", 14) == 0) {
hclge_dbg_dump_qs_shaper(hdev, hclge_dbg_dump_qs_shaper(hdev,
&cmd_buf[sizeof("dump qs shaper")]); &cmd_buf[sizeof("dump qs shaper")]);
......
...@@ -826,6 +826,8 @@ static void hclge_get_mac_stat(struct hnae3_handle *handle, ...@@ -826,6 +826,8 @@ static void hclge_get_mac_stat(struct hnae3_handle *handle,
static int hclge_parse_func_status(struct hclge_dev *hdev, static int hclge_parse_func_status(struct hclge_dev *hdev,
struct hclge_func_status_cmd *status) struct hclge_func_status_cmd *status)
{ {
#define HCLGE_MAC_ID_MASK 0xF
if (!(status->pf_state & HCLGE_PF_STATE_DONE)) if (!(status->pf_state & HCLGE_PF_STATE_DONE))
return -EINVAL; return -EINVAL;
...@@ -835,6 +837,7 @@ static int hclge_parse_func_status(struct hclge_dev *hdev, ...@@ -835,6 +837,7 @@ static int hclge_parse_func_status(struct hclge_dev *hdev,
else else
hdev->flag &= ~HCLGE_FLAG_MAIN; hdev->flag &= ~HCLGE_FLAG_MAIN;
hdev->hw.mac.mac_id = status->mac_id & HCLGE_MAC_ID_MASK;
return 0; return 0;
} }
......
...@@ -256,6 +256,7 @@ enum HCLGE_MAC_DUPLEX { ...@@ -256,6 +256,7 @@ enum HCLGE_MAC_DUPLEX {
#define QUERY_ACTIVE_SPEED 1 #define QUERY_ACTIVE_SPEED 1
struct hclge_mac { struct hclge_mac {
u8 mac_id;
u8 phy_addr; u8 phy_addr;
u8 flag; u8 flag;
u8 media_type; /* port media type, e.g. fibre/copper/backplane */ u8 media_type; /* port media type, e.g. fibre/copper/backplane */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册