218 lines
7.2 KiB
Diff
218 lines
7.2 KiB
Diff
From 2a1e73290fad59f6de2535591b2aa6ef6218a9f0 Mon Sep 17 00:00:00 2001
|
|
From: Huazhong Tan <tanhuazhong@huawei.com>
|
|
Date: Thu, 18 Nov 2021 20:44:40 +0800
|
|
Subject: [PATCH 253/283] net: hns3: add debugfs support for interrupt coalesce
|
|
|
|
mainline inclusion
|
|
from mainline-v5.16-rc1
|
|
commit c99fead7cb07979f5db38035ccb5f02ad2c7106a
|
|
category: feature
|
|
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8EN49
|
|
CVE: NA
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c99fead7cb07979f5db38035ccb5f02ad2c7106a
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Since user may need to check the current configuration of the
|
|
interrupt coalesce, so add debugfs support for query this info.
|
|
|
|
Create a single file "coalesce_info" for it, and query it by
|
|
"cat coalesce_info", return the result to userspace.
|
|
|
|
For device whose version is above V3(include V3), the GL's register
|
|
contains usecs and 1us unit configuration. When get the usecs
|
|
configuration from this register, it will include the confusing unit
|
|
configuration, so add a GL mask to get the correct value, and add
|
|
a QL mask for the frames configuration as well.
|
|
|
|
The display style is below:
|
|
$ cat coalesce_info
|
|
tx interrupt coalesce info:
|
|
VEC_ID ALGO_STATE PROFILE_ID CQE_MODE TUNE_STATE STEPS_LEFT...
|
|
0 IN_PROG 4 EQE ON_TOP 0...
|
|
1 START 3 EQE LEFT 1...
|
|
|
|
rx interrupt coalesce info:
|
|
VEC_ID ALGO_STATE PROFILE_ID CQE_MODE TUNE_STATE STEPS_LEFT...
|
|
0 IN_PROG 3 EQE LEFT 1...
|
|
1 IN_PROG 0 EQE ON_TOP 0...
|
|
|
|
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
|
|
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
Reviewed-by: Yongxin Li <liyongxin1@huawei.com>
|
|
Signed-off-by: Junxin Chen <chenjunxin1@huawei.com>
|
|
Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com>
|
|
Signed-off-by: Xiaodong Li <lixiaodong67@huawei.com>
|
|
|
|
Conflicts:
|
|
drivers/net/ethernet/hisilicon/hns3/hnae3.h
|
|
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
|
|
---
|
|
.../ethernet/hisilicon/hns3/hns3_debugfs.c | 108 ++++++++++++++++++
|
|
.../net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +
|
|
2 files changed, 110 insertions(+)
|
|
|
|
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
|
|
index 5e4be179cf99..e96d44e3e716 100644
|
|
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
|
|
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
|
|
@@ -322,6 +322,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] = {
|
|
.buf_len = HNS3_DBG_READ_LEN,
|
|
.init = hns3_dbg_common_file_init,
|
|
},
|
|
+ {
|
|
+ .name = "coalesce_info",
|
|
+ .cmd = HNAE3_DBG_CMD_COAL_INFO,
|
|
+ .dentry = HNS3_DBG_DENTRY_COMMON,
|
|
+ .buf_len = HNS3_DBG_READ_LEN_1MB,
|
|
+ .init = hns3_dbg_common_file_init,
|
|
+ },
|
|
};
|
|
|
|
static struct hns3_dbg_cap_info hns3_dbg_cap[] = {
|
|
@@ -379,6 +386,26 @@ static struct hns3_dbg_cap_info hns3_dbg_cap[] = {
|
|
}
|
|
};
|
|
|
|
+static const struct hns3_dbg_item coal_info_items[] = {
|
|
+ { "VEC_ID", 2 },
|
|
+ { "ALGO_STATE", 2 },
|
|
+ { "PROFILE_ID", 2 },
|
|
+ { "CQE_MODE", 2 },
|
|
+ { "TUNE_STATE", 2 },
|
|
+ { "STEPS_LEFT", 2 },
|
|
+ { "STEPS_RIGHT", 2 },
|
|
+ { "TIRED", 2 },
|
|
+ { "SW_GL", 2 },
|
|
+ { "SW_QL", 2 },
|
|
+ { "HW_GL", 2 },
|
|
+ { "HW_QL", 2 },
|
|
+};
|
|
+
|
|
+static const char * const dim_cqe_mode_str[] = { "EQE", "CQE" };
|
|
+static const char * const dim_state_str[] = { "START", "IN_PROG", "APPLY" };
|
|
+static const char * const
|
|
+dim_tune_stat_str[] = { "ON_TOP", "TIRED", "RIGHT", "LEFT" };
|
|
+
|
|
static void hns3_dbg_fill_content(char *content, u16 len,
|
|
const struct hns3_dbg_item *items,
|
|
const char **result, u16 size)
|
|
@@ -417,6 +444,83 @@ static void hns3_dbg_fill_content(char *content, u16 len,
|
|
*pos++ = '\0';
|
|
}
|
|
|
|
+static void hns3_get_coal_info(struct hns3_enet_tqp_vector *tqp_vector,
|
|
+ char **result, int i, bool is_tx)
|
|
+{
|
|
+ unsigned int gl_offset, ql_offset;
|
|
+ struct hns3_enet_coalesce *coal;
|
|
+ unsigned int reg_val;
|
|
+ unsigned int j = 0;
|
|
+ bool ql_enable;
|
|
+
|
|
+ if (is_tx) {
|
|
+ coal = &tqp_vector->tx_group.coal;
|
|
+ gl_offset = HNS3_VECTOR_GL1_OFFSET;
|
|
+ ql_offset = HNS3_VECTOR_TX_QL_OFFSET;
|
|
+ ql_enable = tqp_vector->tx_group.coal.ql_enable;
|
|
+ } else {
|
|
+ coal = &tqp_vector->rx_group.coal;
|
|
+ gl_offset = HNS3_VECTOR_GL0_OFFSET;
|
|
+ ql_offset = HNS3_VECTOR_RX_QL_OFFSET;
|
|
+ ql_enable = tqp_vector->rx_group.coal.ql_enable;
|
|
+ }
|
|
+
|
|
+ sprintf(result[j++], "%d", i);
|
|
+ sprintf(result[j++], "%u", coal->int_gl);
|
|
+ sprintf(result[j++], "%u", coal->int_ql);
|
|
+ reg_val = readl(tqp_vector->mask_addr + gl_offset) &
|
|
+ HNS3_VECTOR_GL_MASK;
|
|
+ sprintf(result[j++], "%u", reg_val);
|
|
+ if (ql_enable) {
|
|
+ reg_val = readl(tqp_vector->mask_addr + ql_offset) &
|
|
+ HNS3_VECTOR_QL_MASK;
|
|
+ sprintf(result[j++], "%u", reg_val);
|
|
+ } else {
|
|
+ sprintf(result[j++], "NA");
|
|
+ }
|
|
+}
|
|
+
|
|
+static void hns3_dump_coal_info(struct hnae3_handle *h, char *buf, int len,
|
|
+ int *pos, bool is_tx)
|
|
+{
|
|
+ char data_str[ARRAY_SIZE(coal_info_items)][HNS3_DBG_DATA_STR_LEN];
|
|
+ char *result[ARRAY_SIZE(coal_info_items)];
|
|
+ struct hns3_enet_tqp_vector *tqp_vector;
|
|
+ struct hns3_nic_priv *priv = h->priv;
|
|
+ char content[HNS3_DBG_INFO_LEN];
|
|
+ unsigned int i;
|
|
+
|
|
+ for (i = 0; i < ARRAY_SIZE(coal_info_items); i++)
|
|
+ result[i] = &data_str[i][0];
|
|
+
|
|
+ *pos += scnprintf(buf + *pos, len - *pos,
|
|
+ "%s interrupt coalesce info:\n",
|
|
+ is_tx ? "tx" : "rx");
|
|
+ hns3_dbg_fill_content(content, sizeof(content), coal_info_items,
|
|
+ NULL, ARRAY_SIZE(coal_info_items));
|
|
+ *pos += scnprintf(buf + *pos, len - *pos, "%s", content);
|
|
+
|
|
+ for (i = 0; i < priv->vector_num; i++) {
|
|
+ tqp_vector = &priv->tqp_vector[i];
|
|
+ hns3_get_coal_info(tqp_vector, result, i, is_tx);
|
|
+ hns3_dbg_fill_content(content, sizeof(content), coal_info_items,
|
|
+ (const char **)result,
|
|
+ ARRAY_SIZE(coal_info_items));
|
|
+ *pos += scnprintf(buf + *pos, len - *pos, "%s", content);
|
|
+ }
|
|
+}
|
|
+
|
|
+static int hns3_dbg_coal_info(struct hnae3_handle *h, char *buf, int len)
|
|
+{
|
|
+ int pos = 0;
|
|
+
|
|
+ hns3_dump_coal_info(h, buf, len, &pos, true);
|
|
+ pos += scnprintf(buf + pos, len - pos, "\n");
|
|
+ hns3_dump_coal_info(h, buf, len, &pos, false);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static const struct hns3_dbg_item tx_spare_info_items[] = {
|
|
{ "QUEUE_ID", 2 },
|
|
{ "COPYBREAK", 2 },
|
|
@@ -976,6 +1080,10 @@ static const struct hns3_dbg_func hns3_dbg_cmd_func[] = {
|
|
.cmd = HNAE3_DBG_CMD_DEV_INFO,
|
|
.dbg_dump = hns3_dbg_dev_info,
|
|
},
|
|
+ {
|
|
+ .cmd = HNAE3_DBG_CMD_COAL_INFO,
|
|
+ .dbg_dump = hns3_dbg_coal_info,
|
|
+ },
|
|
};
|
|
|
|
static int hns3_dbg_read_cmd(struct hns3_dbg_data *dbg_data,
|
|
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
|
|
index 163f7cdadd54..36342762f85d 100644
|
|
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
|
|
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
|
|
@@ -200,11 +200,13 @@ enum hns3_nic_state {
|
|
#define HNS3_MAX_NON_TSO_SIZE 9728U
|
|
#define HNS3_MAX_BD_SIZE_OFFSET 16
|
|
|
|
+#define HNS3_VECTOR_GL_MASK GENMASK(11, 0)
|
|
#define HNS3_VECTOR_GL0_OFFSET 0x100
|
|
#define HNS3_VECTOR_GL1_OFFSET 0x200
|
|
#define HNS3_VECTOR_GL2_OFFSET 0x300
|
|
#define HNS3_VECTOR_RL_OFFSET 0x900
|
|
#define HNS3_VECTOR_RL_EN_B 6
|
|
+#define HNS3_VECTOR_QL_MASK GENMASK(9, 0)
|
|
#define HNS3_VECTOR_TX_QL_OFFSET 0xe00
|
|
#define HNS3_VECTOR_RX_QL_OFFSET 0xf00
|
|
|
|
--
|
|
2.34.1
|
|
|