From: Jie Hai <haijie1@huawei.com>
To: <dev@dpdk.org>, Yisen Zhuang <yisen.zhuang@huawei.com>
Cc: <lihuisong@huawei.com>, <fengchengwen@huawei.com>, <haijie1@huawei.com>
Subject: [PATCH v5 6/7] net/hns3: support filter directly accessed registers
Date: Thu, 7 Mar 2024 11:02:46 +0800 [thread overview]
Message-ID: <20240307030247.599394-7-haijie1@huawei.com> (raw)
In-Reply-To: <20240307030247.599394-1-haijie1@huawei.com>
This patch supports reporting names of registers which
can be directly accessed by addresses and filtering
them by names.
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
drivers/net/hns3/hns3_regs.c | 198 +++++++++++++++++++++++++++++------
1 file changed, 167 insertions(+), 31 deletions(-)
diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c
index b7e4f78eecde..7c3bd162f067 100644
--- a/drivers/net/hns3/hns3_regs.c
+++ b/drivers/net/hns3/hns3_regs.c
@@ -837,8 +837,24 @@ hns3_get_regs_num(struct hns3_hw *hw, uint32_t *regs_num_32_bit,
return 0;
}
+static uint32_t
+hns3_get_direct_regs_cnt(const struct direct_reg_list *list,
+ uint32_t len, const char *filter)
+{
+ uint32_t i;
+ uint32_t count = 0;
+
+ for (i = 0 ; i < len; i++) {
+ if (filter != NULL && !strstr(list[i].name, filter))
+ continue;
+ count++;
+ }
+
+ return count;
+}
+
static int
-hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length)
+hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length, const char *filter)
{
struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
uint32_t cmdq_cnt, common_cnt, ring_cnt, tqp_intr_cnt;
@@ -847,13 +863,18 @@ hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length)
uint32_t len;
int ret;
- cmdq_cnt = RTE_DIM(cmdq_reg_list);
+ cmdq_cnt = hns3_get_direct_regs_cnt(cmdq_reg_list,
+ RTE_DIM(cmdq_reg_list), filter);
if (hns->is_vf)
- common_cnt = sizeof(common_vf_reg_list);
+ common_cnt = hns3_get_direct_regs_cnt(common_vf_reg_list,
+ RTE_DIM(common_vf_reg_list), filter);
else
- common_cnt = RTE_DIM(common_reg_list);
- ring_cnt = RTE_DIM(ring_reg_list);
- tqp_intr_cnt = RTE_DIM(tqp_intr_reg_list);
+ common_cnt = hns3_get_direct_regs_cnt(common_reg_list,
+ RTE_DIM(common_reg_list), filter);
+ ring_cnt = hns3_get_direct_regs_cnt(ring_reg_list,
+ RTE_DIM(ring_reg_list), filter);
+ tqp_intr_cnt = hns3_get_direct_regs_cnt(tqp_intr_reg_list,
+ RTE_DIM(tqp_intr_reg_list), filter);
len = cmdq_cnt + common_cnt + ring_cnt * hw->tqps_num +
tqp_intr_cnt * hw->intr_tqps_num;
@@ -995,47 +1016,160 @@ hns3_get_64_bit_regs(struct hns3_hw *hw, uint32_t regs_num, void *data)
return 0;
}
-static int
-hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data)
+
+static uint32_t
+hns3_direct_access_cmdq_reg(struct hns3_hw *hw,
+ struct rte_dev_reg_info *regs,
+ uint32_t count)
{
- struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
- uint32_t *origin_data_ptr = data;
- uint32_t reg_offset;
+ uint32_t *data = regs->data;
size_t reg_num;
- uint16_t j;
+ data += count;
size_t i;
- /* fetching per-PF registers values from PF PCIe register space */
reg_num = RTE_DIM(cmdq_reg_list);
- for (i = 0; i < reg_num; i++)
+ for (i = 0; i < reg_num; i++) {
+ if (regs->filter != NULL &&
+ !strstr(cmdq_reg_list[i].name, regs->filter))
+ continue;
*data++ = hns3_read_dev(hw, cmdq_reg_list[i].addr);
+ if (regs->names == NULL)
+ continue;
+ snprintf(regs->names[count++].name, RTE_ETH_REG_NAME_SIZE,
+ "%s", cmdq_reg_list[i].name);
+ }
- if (hns->is_vf)
- reg_num = RTE_DIM(common_vf_reg_list);
- else
- reg_num = RTE_DIM(common_reg_list);
- for (i = 0; i < reg_num; i++)
- if (hns->is_vf)
- *data++ = hns3_read_dev(hw, common_vf_reg_list[i].addr);
- else
- *data++ = hns3_read_dev(hw, common_reg_list[i].addr);
+ return count;
+}
+static uint32_t
+hns3_direct_access_common_reg(struct hns3_hw *hw,
+ struct rte_dev_reg_info *regs,
+ uint32_t count)
+{
+ uint32_t *data = regs->data;
+ size_t reg_num;
+ data += count;
+ size_t i;
+ reg_num = RTE_DIM(common_reg_list);
+ for (i = 0; i < reg_num; i++) {
+ if (regs->filter != NULL &&
+ !strstr(common_reg_list[i].name, regs->filter))
+ continue;
+ *data++ = hns3_read_dev(hw, common_reg_list[i].addr);
+ if (regs->names == NULL)
+ continue;
+ snprintf(regs->names[count++].name, RTE_ETH_REG_NAME_SIZE,
+ "%s", common_reg_list[i].name);
+ }
+
+ return count;
+}
+
+static uint32_t
+hns3_direct_access_vf_common_reg(struct hns3_hw *hw,
+ struct rte_dev_reg_info *regs,
+ uint32_t count)
+{
+ uint32_t *data = regs->data;
+ size_t reg_num;
+ data += count;
+ size_t i;
+
+ reg_num = RTE_DIM(common_vf_reg_list);
+ for (i = 0; i < reg_num; i++) {
+ if (regs->filter != NULL &&
+ !strstr(common_vf_reg_list[i].name, regs->filter))
+ continue;
+ *data++ = hns3_read_dev(hw, common_vf_reg_list[i].addr);
+ if (regs->names == NULL)
+ continue;
+ snprintf(regs->names[count++].name, RTE_ETH_REG_NAME_SIZE,
+ "%s", common_vf_reg_list[i].name);
+ }
+
+ return count;
+}
+
+static uint32_t
+hns3_direct_access_ring_reg(struct hns3_hw *hw,
+ struct rte_dev_reg_info *regs,
+ uint32_t count)
+{
+ uint32_t *data = regs->data;
+ uint32_t reg_offset;
+ size_t reg_num;
+ uint16_t j;
+ size_t i;
+
+ data += count;
reg_num = RTE_DIM(ring_reg_list);
for (j = 0; j < hw->tqps_num; j++) {
reg_offset = hns3_get_tqp_reg_offset(j);
- for (i = 0; i < reg_num; i++)
- *data++ = hns3_read_dev(hw,
- ring_reg_list[i].addr + reg_offset);
+ for (i = 0; i < reg_num; i++) {
+ if (regs->filter != NULL &&
+ !strstr(ring_reg_list[i].name, regs->filter))
+ continue;
+ *data++ = hns3_read_dev(hw, ring_reg_list[i].addr +
+ reg_offset);
+ if (regs->names == NULL)
+ continue;
+ snprintf(regs->names[count++].name, RTE_ETH_REG_NAME_SIZE,
+ "queue_%u_%s", j, ring_reg_list[i].name);
+ }
}
+ return count;
+}
+
+static uint32_t
+hns3_direct_access_tqp_intr_reg(struct hns3_hw *hw,
+ struct rte_dev_reg_info *regs,
+ uint32_t count)
+{
+ uint32_t *data = regs->data;
+ uint32_t reg_offset;
+ size_t reg_num;
+ uint16_t j;
+ size_t i;
+
+ data += count;
reg_num = RTE_DIM(tqp_intr_reg_list);
for (j = 0; j < hw->intr_tqps_num; j++) {
reg_offset = hns3_get_tqp_intr_reg_offset(j);
- for (i = 0; i < reg_num; i++)
+ for (i = 0; i < reg_num; i++) {
+ if (regs->filter != NULL &&
+ !strstr(tqp_intr_reg_list[i].name, regs->filter))
+ continue;
*data++ = hns3_read_dev(hw, tqp_intr_reg_list[i].addr +
reg_offset);
+ if (regs->names == NULL)
+ continue;
+ snprintf(regs->names[count++].name, RTE_ETH_REG_NAME_SIZE,
+ "queue_%u_%s", j, tqp_intr_reg_list[i].name);
+ }
}
- return data - origin_data_ptr;
+
+ return count;
+}
+
+static uint32_t
+hns3_direct_access_regs(struct hns3_hw *hw,
+ struct rte_dev_reg_info *regs,
+ uint32_t count)
+{
+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+
+ count = hns3_direct_access_cmdq_reg(hw, regs, count);
+ if (!hns->is_vf)
+ count = hns3_direct_access_common_reg(hw, regs, count);
+ else
+ count = hns3_direct_access_vf_common_reg(hw, regs, count);
+
+ count = hns3_direct_access_ring_reg(hw, regs, count);
+ count = hns3_direct_access_tqp_intr_reg(hw, regs, count);
+
+ return count;
}
static int
@@ -1177,11 +1311,12 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs)
struct hns3_hw *hw = &hns->hw;
uint32_t regs_num_32_bit;
uint32_t regs_num_64_bit;
+ uint32_t count = 0;
uint32_t length;
uint32_t *data;
int ret;
- ret = hns3_get_regs_length(hw, &length);
+ ret = hns3_get_regs_length(hw, &length, regs->filter);
if (ret)
return ret;
@@ -1193,13 +1328,14 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs)
}
/* Only full register dump is supported */
- if (regs->length && regs->length != length)
+ if ((regs->length && regs->length != length))
return -ENOTSUP;
regs->version = hw->fw_version;
/* fetching per-PF registers values from PF PCIe register space */
- data += hns3_direct_access_regs(hw, data);
+ count = hns3_direct_access_regs(hw, regs, count);
+ data += count;
if (hns->is_vf)
return 0;
--
2.30.0
next prev parent reply other threads:[~2024-03-07 3:07 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 1:56 [PATCH] ethdev: add dump regs for telemetry Jie Hai
2023-12-14 12:49 ` Ferruh Yigit
2024-01-09 2:19 ` Jie Hai
2024-01-09 2:41 ` Jie Hai
2024-01-09 18:06 ` Ferruh Yigit
2024-01-10 1:38 ` fengchengwen
2024-01-10 12:15 ` Ferruh Yigit
2024-01-10 14:09 ` Thomas Monjalon
2024-01-10 15:48 ` Ferruh Yigit
2024-01-11 1:55 ` fengchengwen
2024-01-11 11:11 ` Ferruh Yigit
2024-01-11 12:43 ` fengchengwen
2024-02-05 10:51 ` [PATCH v2 0/7] support dump reigser names and filter them Jie Hai
2024-02-05 10:51 ` [PATCH v2 1/7] ethdev: support report register names and filter Jie Hai
2024-02-07 17:00 ` Ferruh Yigit
2024-02-20 8:43 ` Jie Hai
2024-02-05 10:51 ` [PATCH v2 2/7] ethdev: add telemetry cmd for registers Jie Hai
2024-02-07 17:03 ` Ferruh Yigit
2024-02-22 9:01 ` Jie Hai
2024-02-05 10:51 ` [PATCH v2 3/7] net/hns3: fix dump counter of registers Jie Hai
2024-02-05 10:51 ` [PATCH v2 4/7] net/hns3: remove dump format " Jie Hai
2024-02-05 10:51 ` [PATCH v2 5/7] net/hns3: add names for registers Jie Hai
2024-02-05 10:51 ` [PATCH v2 6/7] net/hns3: support filter directly accessed registers Jie Hai
2024-02-05 10:51 ` [PATCH v2 7/7] net/hns3: support filter dump of registers Jie Hai
2024-02-20 10:58 ` [PATCH v3 0/7] support dump reigser names and filter them Jie Hai
2024-02-20 10:58 ` [PATCH v3 1/7] ethdev: support report register names and filter Jie Hai
2024-02-20 15:09 ` Stephen Hemminger
2024-02-26 2:33 ` Jie Hai
2024-02-20 15:13 ` Stephen Hemminger
2024-02-26 2:41 ` Jie Hai
2024-02-20 15:14 ` Stephen Hemminger
2024-02-26 2:57 ` Jie Hai
2024-02-20 15:14 ` Stephen Hemminger
2024-02-26 2:33 ` Jie Hai
2024-02-20 10:58 ` [PATCH v3 2/7] ethdev: add telemetry cmd for registers Jie Hai
2024-02-20 10:58 ` [PATCH v3 3/7] net/hns3: fix dump counter of registers Jie Hai
2024-02-20 10:58 ` [PATCH v3 4/7] net/hns3: remove dump format " Jie Hai
2024-02-20 10:58 ` [PATCH v3 5/7] net/hns3: add names for registers Jie Hai
2024-02-20 10:58 ` [PATCH v3 6/7] net/hns3: support filter directly accessed registers Jie Hai
2024-02-20 10:58 ` [PATCH v3 7/7] net/hns3: support filter dump of registers Jie Hai
2024-02-26 3:07 ` [PATCH v4 0/7] support dump reigser names and filter them Jie Hai
2024-02-26 3:07 ` [PATCH v4 1/7] ethdev: support report register names and filter Jie Hai
2024-02-26 8:01 ` fengchengwen
2024-03-06 7:22 ` Jie Hai
2024-02-29 9:52 ` Thomas Monjalon
2024-03-05 7:45 ` Jie Hai
2024-02-26 3:07 ` [PATCH v4 2/7] ethdev: add telemetry cmd for registers Jie Hai
2024-02-26 9:09 ` fengchengwen
2024-03-06 7:18 ` Jie Hai
2024-02-26 3:07 ` [PATCH v4 3/7] net/hns3: fix dump counter of registers Jie Hai
2024-02-26 3:07 ` [PATCH v4 4/7] net/hns3: remove dump format " Jie Hai
2024-02-26 3:07 ` [PATCH v4 5/7] net/hns3: add names for registers Jie Hai
2024-02-26 3:07 ` [PATCH v4 6/7] net/hns3: support filter directly accessed registers Jie Hai
2024-02-26 3:07 ` [PATCH v4 7/7] net/hns3: support filter dump of registers Jie Hai
2024-03-07 3:02 ` [PATCH v5 0/7] support dump reigser names and filter them Jie Hai
2024-03-07 3:02 ` [PATCH v5 1/7] ethdev: support report register names and filter Jie Hai
2024-03-08 8:09 ` lihuisong (C)
2024-03-07 3:02 ` [PATCH v5 2/7] ethdev: add telemetry cmd for registers Jie Hai
2024-03-08 8:48 ` lihuisong (C)
2024-03-07 3:02 ` [PATCH v5 3/7] net/hns3: fix dump counter of registers Jie Hai
2024-03-08 8:49 ` lihuisong (C)
2024-03-07 3:02 ` [PATCH v5 4/7] net/hns3: remove dump format " Jie Hai
2024-03-08 9:17 ` lihuisong (C)
2024-03-07 3:02 ` [PATCH v5 5/7] net/hns3: add names for registers Jie Hai
2024-03-08 9:41 ` lihuisong (C)
2024-03-08 10:24 ` lihuisong (C)
2024-03-07 3:02 ` Jie Hai [this message]
2024-03-08 9:41 ` [PATCH v5 6/7] net/hns3: support filter directly accessed registers lihuisong (C)
2024-03-07 3:02 ` [PATCH v5 7/7] net/hns3: support filter dump of registers Jie Hai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240307030247.599394-7-haijie1@huawei.com \
--to=haijie1@huawei.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=lihuisong@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).