* [PATCH v1] net/ice: support ddp dump switch rule binary
@ 2022-10-18 6:13 Steve Yang
2022-10-18 6:47 ` [PATCH v2] " Steve Yang
0 siblings, 1 reply; 3+ messages in thread
From: Steve Yang @ 2022-10-18 6:13 UTC (permalink / raw)
To: dev; +Cc: qiming.yang, qi.z.zhang, Steve Yang
Dump ICE ddp runtime switch rule binary via following command:
testpmd> ddp dump switch <port_id> <output_file>
You can covert the binary file to readable texture via dpdt tool.
Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
drivers/net/ice/ice_ddp_package.c | 93 +++++++++++++++++++++++++++++++
drivers/net/ice/ice_testpmd.c | 80 +++++++++++++++++++++++++-
drivers/net/ice/rte_pmd_ice.h | 3 +
drivers/net/ice/version.map | 1 +
4 files changed, 175 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ice/ice_ddp_package.c b/drivers/net/ice/ice_ddp_package.c
index c7b5dc7ee7..db6e6e955a 100644
--- a/drivers/net/ice/ice_ddp_package.c
+++ b/drivers/net/ice/ice_ddp_package.c
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2022 Intel Corporation
*/
+#include <unistd.h>
+#include <sys/stat.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -9,6 +11,7 @@
#include "ice_ethdev.h"
#include "rte_pmd_ice.h"
+#define ICE_BLK_MAX_COUNT 512
#define ICE_BUFF_SEG_HEADER_FLAG 0x1
#define ICE_PKG_HDR_HEADR_PART1 1
#define ICE_PKG_HDR_HEADR_PART2 2
@@ -416,3 +419,93 @@ int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size)
return ice_dump_pkg(dev, buff, size);
}
+
+static uint16_t
+covert_byte_to_hex(uint8_t **outbuf, const uint8_t *inbuf, uint32_t inbuf_size)
+{
+ uint32_t i;
+ uint8_t *buffer = *outbuf;
+ for (i = 0; i < inbuf_size; ++i)
+ sprintf((char *)(buffer + i * 2), "%02X", inbuf[i]);
+
+ return inbuf_size * 2;
+}
+
+static int
+ice_dump_switch(struct rte_eth_dev *dev, uint8_t **buff2, uint32_t *size)
+{
+ struct ice_hw *hw;
+ int i = 0;
+ uint16_t tbl_id = 0;
+ uint32_t tbl_idx = 0;
+ int tbl_cnt = 0;
+ uint8_t *buffer = *buff2;
+
+ hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ /* table index string format: "0000:" */
+ #define TBL_IDX_STR_SIZE 6
+ for (i = 0; i < ICE_BLK_MAX_COUNT; i++) {
+ int res;
+ uint16_t buff_size;
+ uint8_t *buff;
+ uint32_t offset = 0;
+
+ buff = malloc(ICE_PKG_BUF_SIZE);
+ if (!buff)
+ return ICE_ERR_NO_MEMORY;
+
+ if (tbl_idx == 0) {
+ char tbl_idx_str[TBL_IDX_STR_SIZE];
+ memset(tbl_idx_str, 0, sizeof(tbl_idx_str));
+ sprintf(tbl_idx_str, "%d:", tbl_id);
+ memcpy(buffer, tbl_idx_str, strlen(tbl_idx_str));
+ offset = strlen(tbl_idx_str);
+ buffer += offset;
+ }
+
+ res = ice_aq_get_internal_data(hw,
+ ICE_AQC_DBG_DUMP_CLUSTER_ID_SW,
+ tbl_id, tbl_idx, buff,
+ ICE_PKG_BUF_SIZE,
+ &buff_size, &tbl_id, &tbl_idx, NULL);
+
+ if (res) {
+ free(buff);
+ return res;
+ }
+
+ offset = covert_byte_to_hex(&buffer, buff, buff_size);
+ buffer += offset;
+
+ free(buff);
+
+ tbl_cnt++;
+ if (tbl_idx == 0xffffffff) {
+ tbl_idx = 0;
+ tbl_cnt = 0;
+ memset(buffer, '\n', sizeof(char));
+ buffer++;
+ offset = 0;
+ }
+
+ if (tbl_id == 0xff)
+ break;
+ }
+
+ *size = buffer - *buff2;
+ return 0;
+}
+
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+ if (!is_ice_supported(dev))
+ return -ENOTSUP;
+
+ return ice_dump_switch(dev, buff, size);
+}
diff --git a/drivers/net/ice/ice_testpmd.c b/drivers/net/ice/ice_testpmd.c
index 2de9b36503..34fdc7458e 100644
--- a/drivers/net/ice/ice_testpmd.c
+++ b/drivers/net/ice/ice_testpmd.c
@@ -11,11 +11,12 @@
/* Fixed size for ICE ddp runtime configure */
#define ICE_BUFF_SIZE 0x000c9000
+#define ICE_SWITCH_BUFF_SIZE (4 * 1024 * 1024)
/* Dump device ddp package, only for ice PF */
struct cmd_ddp_dump_result {
cmdline_fixed_string_t ddp;
- cmdline_fixed_string_t add;
+ cmdline_fixed_string_t dump;
portid_t port_id;
char filepath[];
};
@@ -23,7 +24,7 @@ struct cmd_ddp_dump_result {
cmdline_parse_token_string_t cmd_ddp_dump_ddp =
TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, ddp, "ddp");
cmdline_parse_token_string_t cmd_ddp_dump_dump =
- TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, add, "dump");
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, dump, "dump");
cmdline_parse_token_num_t cmd_ddp_dump_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_result, port_id, RTE_UINT16);
cmdline_parse_token_string_t cmd_ddp_dump_filepath =
@@ -77,6 +78,75 @@ cmdline_parse_inst_t cmd_ddp_dump = {
},
};
+struct cmd_ddp_dump_switch_result {
+ cmdline_fixed_string_t ddp;
+ cmdline_fixed_string_t dump;
+ cmdline_fixed_string_t swt;
+ portid_t port_id;
+ char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_dump_swt_ddp =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_dump_swt_dump =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, dump, "dump");
+cmdline_parse_token_string_t cmd_ddp_dump_swt_switch =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, swt, "switch");
+cmdline_parse_token_num_t cmd_ddp_dump_swt_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_switch_result, port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_ddp_dump_swt_filepath =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_switch_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_ddp_dump_switch_result *res = parsed_result;
+ uint8_t *buff;
+ uint32_t size;
+ int ret = -ENOTSUP;
+
+ size = ICE_SWITCH_BUFF_SIZE;
+ buff = malloc(size);
+ if (buff) {
+ ret = rte_pmd_ice_dump_switch(res->port_id, &buff, &size);
+ switch (ret) {
+ case 0:
+ save_file(res->filepath, buff, size);
+ break;
+ case -EINVAL:
+ fprintf(stderr, "Invalid buffer size\n");
+ break;
+ case -ENOTSUP:
+ fprintf(stderr,
+ "Device doesn't support "
+ "dump DDP switch runtime configure.\n");
+ break;
+ default:
+ fprintf(stderr,
+ "Failed to dump DDP switch runtime configure,"
+ " error: (%s)\n", strerror(-ret));
+ }
+ }
+ free(buff);
+}
+
+
+cmdline_parse_inst_t cmd_ddp_dump_switch = {
+ .f = cmd_ddp_dump_switch_parsed,
+ .data = NULL,
+ .help_str = "ddp dump switch <port_id> <config_path>",
+ .tokens = {
+ (void *)&cmd_ddp_dump_swt_ddp,
+ (void *)&cmd_ddp_dump_swt_dump,
+ (void *)&cmd_ddp_dump_swt_switch,
+ (void *)&cmd_ddp_dump_swt_port_id,
+ (void *)&cmd_ddp_dump_swt_filepath,
+ NULL,
+ },
+};
+
static struct testpmd_driver_commands ice_cmds = {
.commands = {
{
@@ -84,6 +154,12 @@ static struct testpmd_driver_commands ice_cmds = {
"ddp dump (port_id) (config_path)\n"
" Dump a runtime configure on a port\n\n",
+ },
+ {
+ &cmd_ddp_dump_switch,
+ "ddp dump switch (port_id) (config_path)\n"
+ " Dump a runtime switch configure on a port\n\n",
+
},
{ NULL, NULL },
},
diff --git a/drivers/net/ice/rte_pmd_ice.h b/drivers/net/ice/rte_pmd_ice.h
index 53c81ccf4e..6a7efc6ce4 100644
--- a/drivers/net/ice/rte_pmd_ice.h
+++ b/drivers/net/ice/rte_pmd_ice.h
@@ -240,6 +240,9 @@ rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
__rte_experimental
int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
+__rte_experimental
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size);
+
#ifdef __cplusplus
}
#endif
diff --git a/drivers/net/ice/version.map b/drivers/net/ice/version.map
index 60a3f17393..e77e27c95f 100644
--- a/drivers/net/ice/version.map
+++ b/drivers/net/ice/version.map
@@ -14,4 +14,5 @@ EXPERIMENTAL {
rte_net_ice_dynflag_proto_xtr_tcp_mask;
rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
rte_pmd_ice_dump_package;
+ rte_pmd_ice_dump_switch;
};
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] net/ice: support ddp dump switch rule binary
2022-10-18 6:13 [PATCH v1] net/ice: support ddp dump switch rule binary Steve Yang
@ 2022-10-18 6:47 ` Steve Yang
2022-10-18 13:20 ` Zhang, Qi Z
0 siblings, 1 reply; 3+ messages in thread
From: Steve Yang @ 2022-10-18 6:47 UTC (permalink / raw)
To: dev; +Cc: qiming.yang, qi.z.zhang, Steve Yang
Dump ICE ddp runtime switch rule binary via following command:
testpmd> ddp dump switch <port_id> <output_file>
You can covert the binary file to readable texture via dpdt tool.
Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
drivers/net/ice/ice_ddp_package.c | 93 +++++++++++++++++++++++++++++++
drivers/net/ice/ice_ethdev.h | 2 +
drivers/net/ice/ice_testpmd.c | 80 +++++++++++++++++++++++++-
drivers/net/ice/version.map | 1 +
4 files changed, 174 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ice/ice_ddp_package.c b/drivers/net/ice/ice_ddp_package.c
index a5b42c57d9..b881fa3ded 100644
--- a/drivers/net/ice/ice_ddp_package.c
+++ b/drivers/net/ice/ice_ddp_package.c
@@ -3,6 +3,8 @@
*/
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -10,6 +12,7 @@
#include "ice_ethdev.h"
+#define ICE_BLK_MAX_COUNT 512
#define ICE_BUFF_SEG_HEADER_FLAG 0x1
#define ICE_PKG_HDR_HEADR_PART1 1
#define ICE_PKG_HDR_HEADR_PART2 2
@@ -417,3 +420,93 @@ int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size)
return ice_dump_pkg(dev, buff, size);
}
+
+static uint16_t
+covert_byte_to_hex(uint8_t **outbuf, const uint8_t *inbuf, uint32_t inbuf_size)
+{
+ uint32_t i;
+ uint8_t *buffer = *outbuf;
+ for (i = 0; i < inbuf_size; ++i)
+ sprintf((char *)(buffer + i * 2), "%02X", inbuf[i]);
+
+ return inbuf_size * 2;
+}
+
+static int
+ice_dump_switch(struct rte_eth_dev *dev, uint8_t **buff2, uint32_t *size)
+{
+ struct ice_hw *hw;
+ int i = 0;
+ uint16_t tbl_id = 0;
+ uint32_t tbl_idx = 0;
+ int tbl_cnt = 0;
+ uint8_t *buffer = *buff2;
+
+ hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ /* table index string format: "0000:" */
+ #define TBL_IDX_STR_SIZE 6
+ for (i = 0; i < ICE_BLK_MAX_COUNT; i++) {
+ int res;
+ uint16_t buff_size;
+ uint8_t *buff;
+ uint32_t offset = 0;
+
+ buff = malloc(ICE_PKG_BUF_SIZE);
+ if (!buff)
+ return ICE_ERR_NO_MEMORY;
+
+ if (tbl_idx == 0) {
+ char tbl_idx_str[TBL_IDX_STR_SIZE];
+ memset(tbl_idx_str, 0, sizeof(tbl_idx_str));
+ sprintf(tbl_idx_str, "%d:", tbl_id);
+ memcpy(buffer, tbl_idx_str, strlen(tbl_idx_str));
+ offset = strlen(tbl_idx_str);
+ buffer += offset;
+ }
+
+ res = ice_aq_get_internal_data(hw,
+ ICE_AQC_DBG_DUMP_CLUSTER_ID_SW,
+ tbl_id, tbl_idx, buff,
+ ICE_PKG_BUF_SIZE,
+ &buff_size, &tbl_id, &tbl_idx, NULL);
+
+ if (res) {
+ free(buff);
+ return res;
+ }
+
+ offset = covert_byte_to_hex(&buffer, buff, buff_size);
+ buffer += offset;
+
+ free(buff);
+
+ tbl_cnt++;
+ if (tbl_idx == 0xffffffff) {
+ tbl_idx = 0;
+ tbl_cnt = 0;
+ memset(buffer, '\n', sizeof(char));
+ buffer++;
+ offset = 0;
+ }
+
+ if (tbl_id == 0xff)
+ break;
+ }
+
+ *size = buffer - *buff2;
+ return 0;
+}
+
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size)
+{
+ struct rte_eth_dev *dev;
+
+ RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+ dev = &rte_eth_devices[port];
+ if (!is_ice_supported(dev))
+ return -ENOTSUP;
+
+ return ice_dump_switch(dev, buff, size);
+}
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index a4b8ce2956..487a331117 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -734,4 +734,6 @@ ice_align_floor(int n)
__rte_experimental
int rte_pmd_ice_dump_package(uint16_t port, uint8_t **buff, uint32_t *size);
+__rte_experimental
+int rte_pmd_ice_dump_switch(uint16_t port, uint8_t **buff, uint32_t *size);
#endif /* _ICE_ETHDEV_H_ */
diff --git a/drivers/net/ice/ice_testpmd.c b/drivers/net/ice/ice_testpmd.c
index e292b5c4df..a7a8d0c53c 100644
--- a/drivers/net/ice/ice_testpmd.c
+++ b/drivers/net/ice/ice_testpmd.c
@@ -12,11 +12,12 @@
/* Fixed size for ICE ddp runtime configure */
#define ICE_BUFF_SIZE 0x000c9000
+#define ICE_SWITCH_BUFF_SIZE (4 * 1024 * 1024)
/* Dump device ddp package, only for ice PF */
struct cmd_ddp_dump_result {
cmdline_fixed_string_t ddp;
- cmdline_fixed_string_t add;
+ cmdline_fixed_string_t dump;
portid_t port_id;
char filepath[];
};
@@ -24,7 +25,7 @@ struct cmd_ddp_dump_result {
cmdline_parse_token_string_t cmd_ddp_dump_ddp =
TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, ddp, "ddp");
cmdline_parse_token_string_t cmd_ddp_dump_dump =
- TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, add, "dump");
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, dump, "dump");
cmdline_parse_token_num_t cmd_ddp_dump_port_id =
TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_result, port_id, RTE_UINT16);
cmdline_parse_token_string_t cmd_ddp_dump_filepath =
@@ -78,6 +79,75 @@ cmdline_parse_inst_t cmd_ddp_dump = {
},
};
+struct cmd_ddp_dump_switch_result {
+ cmdline_fixed_string_t ddp;
+ cmdline_fixed_string_t dump;
+ cmdline_fixed_string_t swt;
+ portid_t port_id;
+ char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_ddp_dump_swt_ddp =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, ddp, "ddp");
+cmdline_parse_token_string_t cmd_ddp_dump_swt_dump =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, dump, "dump");
+cmdline_parse_token_string_t cmd_ddp_dump_swt_switch =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, swt, "switch");
+cmdline_parse_token_num_t cmd_ddp_dump_swt_port_id =
+ TOKEN_NUM_INITIALIZER(struct cmd_ddp_dump_switch_result, port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_ddp_dump_swt_filepath =
+ TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_switch_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_switch_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+ struct cmd_ddp_dump_switch_result *res = parsed_result;
+ uint8_t *buff;
+ uint32_t size;
+ int ret = -ENOTSUP;
+
+ size = ICE_SWITCH_BUFF_SIZE;
+ buff = malloc(size);
+ if (buff) {
+ ret = rte_pmd_ice_dump_switch(res->port_id, &buff, &size);
+ switch (ret) {
+ case 0:
+ save_file(res->filepath, buff, size);
+ break;
+ case -EINVAL:
+ fprintf(stderr, "Invalid buffer size\n");
+ break;
+ case -ENOTSUP:
+ fprintf(stderr,
+ "Device doesn't support "
+ "dump DDP switch runtime configure.\n");
+ break;
+ default:
+ fprintf(stderr,
+ "Failed to dump DDP switch runtime configure,"
+ " error: (%s)\n", strerror(-ret));
+ }
+ }
+ free(buff);
+}
+
+
+cmdline_parse_inst_t cmd_ddp_dump_switch = {
+ .f = cmd_ddp_dump_switch_parsed,
+ .data = NULL,
+ .help_str = "ddp dump switch <port_id> <config_path>",
+ .tokens = {
+ (void *)&cmd_ddp_dump_swt_ddp,
+ (void *)&cmd_ddp_dump_swt_dump,
+ (void *)&cmd_ddp_dump_swt_switch,
+ (void *)&cmd_ddp_dump_swt_port_id,
+ (void *)&cmd_ddp_dump_swt_filepath,
+ NULL,
+ },
+};
+
static struct testpmd_driver_commands ice_cmds = {
.commands = {
{
@@ -85,6 +155,12 @@ static struct testpmd_driver_commands ice_cmds = {
"ddp dump (port_id) (config_path)\n"
" Dump a runtime configure on a port\n\n",
+ },
+ {
+ &cmd_ddp_dump_switch,
+ "ddp dump switch (port_id) (config_path)\n"
+ " Dump a runtime switch configure on a port\n\n",
+
},
{ NULL, NULL },
},
diff --git a/drivers/net/ice/version.map b/drivers/net/ice/version.map
index 67b7ec6e80..d70c250e9a 100644
--- a/drivers/net/ice/version.map
+++ b/drivers/net/ice/version.map
@@ -7,4 +7,5 @@ EXPERIMENTAL {
# added in 19.11
rte_pmd_ice_dump_package;
+ rte_pmd_ice_dump_switch;
};
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH v2] net/ice: support ddp dump switch rule binary
2022-10-18 6:47 ` [PATCH v2] " Steve Yang
@ 2022-10-18 13:20 ` Zhang, Qi Z
0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Qi Z @ 2022-10-18 13:20 UTC (permalink / raw)
To: Yang, SteveX, dev; +Cc: Yang, Qiming
> -----Original Message-----
> From: Yang, SteveX <stevex.yang@intel.com>
> Sent: Tuesday, October 18, 2022 2:48 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v2] net/ice: support ddp dump switch rule binary
>
> Dump ICE ddp runtime switch rule binary via following command:
> testpmd> ddp dump switch <port_id> <output_file>
>
> You can covert the binary file to readable texture via dpdt tool.
>
> Signed-off-by: Steve Yang <stevex.yang@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
Applied to dpdk-next-net-intel.
Thanks
Qi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-18 13:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18 6:13 [PATCH v1] net/ice: support ddp dump switch rule binary Steve Yang
2022-10-18 6:47 ` [PATCH v2] " Steve Yang
2022-10-18 13:20 ` Zhang, Qi Z
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).