[dpdk-dev] [PATCH v3 4/5] app/testpmd: add command for getting loaded profiles

Beilei Xing beilei.xing at intel.com
Thu Mar 23 11:02:31 CET 2017


This patch is to add testpmd CLI for getting all loaded profiles.

Signed-off-by: Beilei Xing <beilei.xing at intel.com>
---
 app/test-pmd/cmdline.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h | 22 +++++++++++++
 2 files changed, 111 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 5d6dd73..9ed17a5 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -215,6 +215,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 
 			"read txd (port_id) (queue_id) (txd_id)\n"
 			"    Display a TX descriptor of a port TX queue.\n\n"
+
+			"get ppp list (port_id)\n"
+			"    Get ppp profile info list\n\n"
 		);
 	}
 
@@ -12474,6 +12477,91 @@ cmdline_parse_inst_t cmd_add_ppp = {
 	},
 };
 
+/* Get Pipeline Personalization Profile list*/
+#define PROFILE_INFO_SIZE 48
+#define MAX_PROFILE_NUM 16
+
+struct cmd_get_ppp_list_result {
+	cmdline_fixed_string_t get;
+	cmdline_fixed_string_t ppp;
+	cmdline_fixed_string_t list;
+	uint8_t port_id;
+};
+
+cmdline_parse_token_string_t cmd_get_ppp_list_get =
+	TOKEN_STRING_INITIALIZER(struct cmd_get_ppp_list_result, get, "get");
+cmdline_parse_token_string_t cmd_get_ppp_list_ppp =
+	TOKEN_STRING_INITIALIZER(struct cmd_get_ppp_list_result, ppp, "ppp");
+cmdline_parse_token_string_t cmd_get_ppp_list_list =
+	TOKEN_STRING_INITIALIZER(struct cmd_get_ppp_list_result, list, "list");
+cmdline_parse_token_num_t cmd_get_ppp_list_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_get_ppp_list_result, port_id, UINT8);
+
+static void
+cmd_get_ppp_list_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_get_ppp_list_result *res = parsed_result;
+	struct profile_list *p_list;
+	struct profile_info *p_info;
+	uint32_t p_num;
+	uint32_t size;
+	uint32_t i;
+	int ret = -ENOTSUP;
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4;
+	p_list = (struct profile_list *)malloc(size);
+	if (!p_list)
+		printf("%s: Failed to malloc buffer\n", __func__);
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP) {
+		ret = rte_pmd_i40e_get_ppp_list(res->port_id,
+						(uint8_t *)p_list, size);
+		if (ret < 0)
+			printf("Failed to get ppp list\n");
+	}
+#endif
+
+	if (!ret) {
+		p_num = p_list->p_count;
+		printf("Profile number is: %d\n\n", p_num);
+
+		for (i = 0; i < p_num; i++) {
+			p_info = &p_list->p_info[i];
+			printf("Profile %d:\n", i);
+			printf("Track id:     0x%x\n", p_info->track_id);
+			printf("Version:      %d.%d.%d.%d \n",
+			       p_info->version.major,
+			       p_info->version.minor,
+			       p_info->version.update,
+			       p_info->version.draft);
+			printf("Profile name: %s\n\n", p_info->name);
+		}
+	}
+
+	free(p_list);
+}
+
+cmdline_parse_inst_t cmd_get_ppp_list = {
+	.f = cmd_get_ppp_list_parsed,
+	.data = NULL,
+	.help_str = "get ppp list <port_id>",
+	.tokens = {
+		(void *)&cmd_get_ppp_list_get,
+		(void *)&cmd_get_ppp_list_ppp,
+		(void *)&cmd_get_ppp_list_list,
+		(void *)&cmd_get_ppp_list_port_id,
+		NULL,
+	},
+};
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -12650,6 +12738,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_vf_broadcast,
 	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag,
 	(cmdline_parse_inst_t *)&cmd_add_ppp,
+	(cmdline_parse_inst_t *)&cmd_get_ppp_list,
 	NULL,
 };
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 6bcd9c4..b9132fa 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -97,6 +97,28 @@ struct pkt_burst_stats {
 };
 #endif
 
+#ifdef RTE_LIBRTE_I40E_PMD
+#define PPP_NAME_SIZE 32
+struct ppp_version {
+	uint8_t major;
+	uint8_t minor;
+	uint8_t update;
+	uint8_t draft;
+};
+
+struct profile_info {
+	uint32_t track_id;
+	struct ppp_version version;
+	uint8_t reserved[8];
+	uint8_t name[PPP_NAME_SIZE];
+};
+
+struct profile_list {
+	uint32_t p_count;
+	struct profile_info p_info[1];
+};
+#endif
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
-- 
2.5.5



More information about the dev mailing list