[v1,2/2] app/testpmd: support dump_pkg command for ice

Message ID 20220511080247.261043-3-stevex.yang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Andrew Rybchenko
Headers
Series ICE ddp download tool |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build fail github build: failed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing fail Testing issues
ci/iol-aarch64-compile-testing fail Testing issues
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-abi-testing warning Testing issues

Commit Message

Steve Yang May 11, 2022, 8:02 a.m. UTC
  Support dump ice PF ddp package via testpmd command line.

Add command line:
    ddp dump <port_id> <profile_path>

Parameters:
    <port_id>       the PF Port ID
    <profile_path>  dumped package profile file, if not a absolute path,
                    it will be dumped to testpmd running directory.

For example:
testpmd> ddp dump 0 current.pkg

If you want to dump ice VF ddp package, you need bind other unused PF port
of the NIC first, and then dump the PF ddp package as target output.

Signed-off-by: Steve Yang <stevex.yang@intel.com>
---
 app/test-pmd/cmdline.c | 74 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
  

Comments

Qi Zhang May 18, 2022, 4:32 a.m. UTC | #1
> -----Original Message-----
> From: Yang, SteveX <stevex.yang@intel.com>
> Sent: Wednesday, May 11, 2022 4:03 PM
> To: dev@dpdk.org
> Cc: Zhang, Yuying <yuying.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>;
> mdr@ashroe.eu; Yang, SteveX <stevex.yang@intel.com>
> Subject: [PATCH v1 2/2] app/testpmd: support dump_pkg command for ice
> 
> Support dump ice PF ddp package via testpmd command line.

Dump DDP configure into a binary(package) file from ice PF port.

> 
> Add command line:
>     ddp dump <port_id> <profile_path>
> 
> Parameters:
>     <port_id>       the PF Port ID
>     <profile_path>  dumped package profile file, if not a absolute path,
>                     it will be dumped to testpmd running directory.
> 
> For example:
> testpmd> ddp dump 0 current.pkg
> 
> If you want to dump ice VF ddp package, you need bind other unused PF port of
> the NIC first, and then dump the PF ddp package as target output.
> 
> Signed-off-by: Steve Yang <stevex.yang@intel.com>


Same comment to previous patch, 
"dump DDP package" is different concept with "dump DDP runtime configure into a package file" 

Please reword.
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6ffea8e21a..f13773cd6c 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -60,6 +60,9 @@ 
 #ifdef RTE_NET_I40E
 #include <rte_pmd_i40e.h>
 #endif
+#ifdef RTE_NET_ICE
+#include <rte_pmd_ice.h>
+#endif
 #ifdef RTE_NET_BNXT
 #include <rte_pmd_bnxt.h>
 #endif
@@ -654,6 +657,9 @@  static void cmd_help_long_parsed(void *parsed_result,
 			"set link-down port (port_id)\n"
 			"	Set link down for a port.\n\n"
 
+			"ddp dump (port_id) (profile_path)\n"
+			"    Dump a profile package on a port\n\n"
+
 			"ddp add (port_id) (profile_path[,backup_profile_path])\n"
 			"    Load a profile package on a port\n\n"
 
@@ -14471,6 +14477,73 @@  cmdline_parse_inst_t cmd_strict_link_prio = {
 	},
 };
 
+/* Dump device ddp package, only for ice PF */
+struct cmd_ddp_dump_result {
+	cmdline_fixed_string_t ddp;
+	cmdline_fixed_string_t add;
+	portid_t port_id;
+	char filepath[];
+};
+
+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");
+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 =
+	TOKEN_STRING_INITIALIZER(struct cmd_ddp_dump_result, filepath, NULL);
+
+static void
+cmd_ddp_dump_parsed(
+	void *parsed_result,
+	__rte_unused struct cmdline *cl,
+	__rte_unused void *data)
+{
+	struct cmd_ddp_dump_result *res = parsed_result;
+	uint8_t *buff;
+	uint32_t size;
+	int ret = 0;
+
+#ifdef RTE_NET_ICE
+#define ICE_BUFF_SIZE	0x000c9000
+	size = ICE_BUFF_SIZE;
+	buff = (uint8_t *)malloc(ICE_BUFF_SIZE);
+	if (buff) {
+		ret = rte_pmd_ice_dump_package(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 package.\n");
+			break;
+		default:
+			fprintf(stderr, "Failed to dump package file,"
+				" error: (%s)\n", strerror(-ret));
+		}
+	}
+	free(buff);
+#endif
+}
+
+cmdline_parse_inst_t cmd_ddp_dump = {
+	.f = cmd_ddp_dump_parsed,
+	.data = NULL,
+	.help_str = "ddp dump <port_id> <profile_path>",
+	.tokens = {
+		(void *)&cmd_ddp_dump_ddp,
+		(void *)&cmd_ddp_dump_dump,
+		(void *)&cmd_ddp_dump_port_id,
+		(void *)&cmd_ddp_dump_filepath,
+		NULL,
+	},
+};
+
 /* Load dynamic device personalization*/
 struct cmd_ddp_add_result {
 	cmdline_fixed_string_t ddp;
@@ -18025,6 +18098,7 @@  cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_ddp_del,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_list,
 	(cmdline_parse_inst_t *)&cmd_ddp_get_info,
+	(cmdline_parse_inst_t *)&cmd_ddp_dump,
 	(cmdline_parse_inst_t *)&cmd_cfg_input_set,
 	(cmdline_parse_inst_t *)&cmd_clear_input_set,
 	(cmdline_parse_inst_t *)&cmd_show_vf_stats,