All of lore.kernel.org
 help / color / mirror / Atom feed
From: Beilei Xing <beilei.xing@intel.com>
To: jingjing.wu@intel.com
Cc: helin.zhang@intel.com, dev@dpdk.org
Subject: [PATCH v8 3/6] app/testpmd: add command for loading ddp
Date: Thu, 30 Mar 2017 10:51:48 +0800	[thread overview]
Message-ID: <1490842311-96705-4-git-send-email-beilei.xing@intel.com> (raw)
In-Reply-To: <1490842311-96705-1-git-send-email-beilei.xing@intel.com>

This patch is to add testpmd CLI for loading dynamic
device personalization.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 app/test-pmd/cmdline.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  | 67 +++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/testpmd.h |  3 +++
 3 files changed, 143 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b93b096..73e29db 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -590,6 +590,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"E-tag set filter del e-tag-id (value) port (port_id)\n"
 			"    Delete an E-tag forwarding filter on a port\n\n"
 
+			"add ddp (port_id) (profile_path)\n"
+			"    Load a profile package on a port\n\n"
+
 			, list_pkt_forwarding_modes()
 		);
 	}
@@ -12739,6 +12742,75 @@ cmdline_parse_inst_t cmd_strict_link_prio = {
 	},
 };
 
+/* Load dynamic device personalization*/
+struct cmd_add_ddp_result {
+	cmdline_fixed_string_t add;
+	cmdline_fixed_string_t ddp;
+	uint8_t port_id;
+	char filepath[];
+};
+
+cmdline_parse_token_string_t cmd_add_ddp_add =
+	TOKEN_STRING_INITIALIZER(struct cmd_add_ddp_result, add, "add");
+cmdline_parse_token_string_t cmd_add_ddp_ddp =
+	TOKEN_STRING_INITIALIZER(struct cmd_add_ddp_result, ddp, "ddp");
+cmdline_parse_token_num_t cmd_add_ddp_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_add_ddp_result, port_id, UINT8);
+cmdline_parse_token_string_t cmd_add_ddp_filepath =
+	TOKEN_STRING_INITIALIZER(struct cmd_add_ddp_result, filepath, NULL);
+
+static void
+cmd_add_ddp_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_add_ddp_result *res = parsed_result;
+	uint8_t *buff;
+	uint32_t size;
+	int ret = -ENOTSUP;
+
+	if (res->port_id > nb_ports) {
+		printf("Invalid port, range is [0, %d]\n", nb_ports - 1);
+		return;
+	}
+
+	if (!all_ports_stopped()) {
+		printf("Please stop all ports first\n");
+		return;
+	}
+
+	buff = open_ddp_package_file(res->filepath, &size);
+	if (!buff)
+		return;
+
+#ifdef RTE_LIBRTE_I40E_PMD
+	if (ret == -ENOTSUP)
+		ret = rte_pmd_i40e_process_ddp_package(res->port_id,
+					       buff, size,
+					       RTE_PMD_I40E_PKG_OP_WR_ADD);
+#endif
+
+	if (ret < 0)
+		printf("Failed to load profile.\n");
+	else if (ret > 0)
+		printf("Profile has already existed.\n");
+
+	close_ddp_package_file(buff);
+}
+
+cmdline_parse_inst_t cmd_add_ddp = {
+	.f = cmd_add_ddp_parsed,
+	.data = NULL,
+	.help_str = "add/remove ddp <port_id> <profile_path>",
+	.tokens = {
+		(void *)&cmd_add_ddp_add,
+		(void *)&cmd_add_ddp_ddp,
+		(void *)&cmd_add_ddp_port_id,
+		(void *)&cmd_add_ddp_filepath,
+		NULL,
+	},
+};
 
 /* ******************************************************************************** */
 
@@ -12919,6 +12991,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_vf_tc_min_bw,
 	(cmdline_parse_inst_t *)&cmd_vf_tc_max_bw,
 	(cmdline_parse_inst_t *)&cmd_strict_link_prio,
+	(cmdline_parse_inst_t *)&cmd_add_ddp,
 	NULL,
 };
 
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 80491fc..9865bf1 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3245,3 +3245,70 @@ port_dcb_info_display(uint8_t port_id)
 		printf("\t%4d", dcb_info.tc_queue.tc_txq[0][i].nb_queue);
 	printf("\n");
 }
+
+uint8_t *
+open_ddp_package_file(const char *file_path, uint32_t *size)
+{
+	FILE *fh = fopen(file_path, "rb");
+	uint32_t pkg_size;
+	uint8_t *buf = NULL;
+	int ret = 0;
+
+	if (size)
+		*size = 0;
+
+	if (fh == NULL) {
+		printf("%s: Failed to open %s\n", __func__, file_path);
+		return buf;
+	}
+
+	ret = fseek(fh, 0, SEEK_END);
+	if (ret < 0) {
+		fclose(fh);
+		printf("%s: File operations failed\n", __func__);
+		return buf;
+	}
+
+	pkg_size = ftell(fh);
+
+	buf = (uint8_t *)malloc(pkg_size);
+	if (!buf) {
+		fclose(fh);
+		printf("%s: Failed to malloc memory\n",	__func__);
+		return buf;
+	}
+
+	ret = fseek(fh, 0, SEEK_SET);
+	if (ret < 0) {
+		fclose(fh);
+		printf("%s: File seek operation failed\n", __func__);
+		close_ddp_package_file(buf);
+		return NULL;
+	}
+
+	ret = fread(buf, 1, pkg_size, fh);
+	if (ret < 0) {
+		fclose(fh);
+		printf("%s: File read operation failed\n", __func__);
+		close_ddp_package_file(buf);
+		return NULL;
+	}
+
+	if (size)
+		*size = pkg_size;
+
+	fclose(fh);
+
+	return buf;
+}
+
+int
+close_ddp_package_file(uint8_t *buf)
+{
+	if (buf) {
+		free((void *)buf);
+		return 0;
+	}
+
+	return -1;
+}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 8cf2860..5c18151 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -622,6 +622,9 @@ void mcast_addr_add(uint8_t port_id, struct ether_addr *mc_addr);
 void mcast_addr_remove(uint8_t port_id, struct ether_addr *mc_addr);
 void port_dcb_info_display(uint8_t port_id);
 
+uint8_t *open_ddp_package_file(const char *file_path, uint32_t *size);
+int close_ddp_package_file(uint8_t *buf);
+
 enum print_warning {
 	ENABLED_WARN = 0,
 	DISABLED_WARN
-- 
2.5.5

  parent reply	other threads:[~2017-03-30  2:53 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03  7:26 [PATCH] MPSL enabling Beilei Xing
2017-03-03  7:26 ` [PATCH 1/2] net/i40e: change tunnel filter function name Beilei Xing
2017-03-03  7:26 ` [PATCH] ppp implemantation Beilei Xing
2017-03-03  9:39   ` Bruce Richardson
2017-03-03  9:41     ` Bruce Richardson
2017-03-03  7:26 ` [PATCH 2/2] net/i40e: parse NVGRE filter Beilei Xing
2017-03-03  7:26 ` [PATCH] PPP prototype Beilei Xing
2017-03-03  7:26 ` [PATCH] ppp implemantation Beilei Xing
2017-03-03  7:26 ` [PATCH 0/6] net/i40e: support pipeline personalization profile Beilei Xing
2017-03-03  7:39   ` [PATCH v2 0/5] " Beilei Xing
2017-03-03  7:39     ` [PATCH v2 1/5] " Beilei Xing
2017-03-08 12:07       ` Ferruh Yigit
2017-03-09  3:30         ` Xing, Beilei
2017-03-03  7:39     ` [PATCH v2 2/5] net/i40e: add ppp processing Beilei Xing
2017-03-08 12:07       ` Ferruh Yigit
2017-03-03  7:39     ` [PATCH v2 3/5] app/testpmd: add command for writing personalization profile Beilei Xing
2017-03-08 12:10       ` Ferruh Yigit
2017-03-03  7:39     ` [PATCH v2 4/5] net/i40e: add get all loaded profiles Beilei Xing
2017-03-03  7:39     ` [PATCH v2 5/5] app/testpmd: add command for getting " Beilei Xing
2017-03-08 11:43     ` [PATCH v2 0/5] net/i40e: support pipeline personalization profile Ferruh Yigit
2017-03-09  3:07       ` Xing, Beilei
2017-03-23 10:02     ` [PATCH v3 0/5] pipeline personalization profile support Beilei Xing
2017-03-23 10:02       ` [PATCH v3 1/5] net/i40e: add pipeline personalization profile processing Beilei Xing
2017-03-23 14:50         ` Iremonger, Bernard
2017-03-24  2:01           ` Xing, Beilei
2017-03-23 10:02       ` [PATCH v3 2/5] app/testpmd: add command for loading a profile Beilei Xing
2017-03-23 10:02       ` [PATCH v3 3/5] net/i40e: add get all loaded profiles Beilei Xing
2017-03-23 10:02       ` [PATCH v3 4/5] app/testpmd: add command for getting " Beilei Xing
2017-03-23 10:02       ` [PATCH v3 5/5] doc: add pipeline personalization profile support for i40e Beilei Xing
2017-03-24 10:19       ` [PATCH v4 0/5] pipeline personalization profile support Beilei Xing
2017-03-24 10:19         ` [PATCH v4 1/5] net/i40e: add pipeline personalization profile processing Beilei Xing
2017-03-24 14:52           ` Chilikin, Andrey
2017-03-25  4:04             ` Xing, Beilei
2017-03-25 21:03               ` Chilikin, Andrey
2017-03-27  2:09                 ` Xing, Beilei
2017-03-24 10:19         ` [PATCH v4 2/5] app/testpmd: add command for loading a profile Beilei Xing
2017-03-24 10:19         ` [PATCH v4 3/5] net/i40e: add get all loaded profiles Beilei Xing
2017-03-24 10:19         ` [PATCH v4 4/5] app/testpmd: add command for getting " Beilei Xing
2017-03-24 10:19         ` [PATCH v4 5/5] doc: add pipeline personalization profile support for i40e Beilei Xing
2017-03-24 14:31           ` Mcnamara, John
2017-03-27  6:17         ` [PATCH v5 0/5] pipeline personalization profile support Beilei Xing
2017-03-27  6:17           ` [PATCH v5 1/5] net/i40e: add pipeline personalization profile processing Beilei Xing
2017-03-27  6:17           ` [PATCH v5 2/5] app/testpmd: add command for loading a profile Beilei Xing
2017-03-27  6:17           ` [PATCH v5 3/5] net/i40e: add get all loaded profiles Beilei Xing
2017-03-27  6:17           ` [PATCH v5 4/5] app/testpmd: add command for getting " Beilei Xing
2017-03-27  6:17           ` [PATCH v5 5/5] doc: add pipeline personalization profile support for i40e Beilei Xing
2017-03-29 12:26           ` [PATCH v6 0/6] dynamic device profile support Beilei Xing
2017-03-29 12:26             ` [PATCH v6 1/6] net/i40e/base: change ppp to ddp Beilei Xing
2017-03-29 12:26             ` [PATCH v6 2/6] net/i40e: add dynamic device profile processing Beilei Xing
2017-03-29 13:17               ` Wu, Jingjing
2017-03-29 14:25                 ` Xing, Beilei
2017-03-29 12:26             ` [PATCH v6 3/6] app/testpmd: add command for loading a profile Beilei Xing
2017-03-29 12:26             ` [PATCH v6 4/6] net/i40e: add get all loaded profiles Beilei Xing
2017-03-29 12:26             ` [PATCH v6 5/6] app/testpmd: add command for getting " Beilei Xing
2017-03-29 12:26             ` [PATCH v6 6/6] doc: add dynamic device profile support for i40e Beilei Xing
2017-03-29 14:44             ` [PATCH v7 0/6] dynamic device profile support Beilei Xing
2017-03-29 14:44               ` [PATCH v7 1/6] net/i40e/base: change ppp to ddp Beilei Xing
2017-03-29 14:44               ` [PATCH v7 2/6] net/i40e: add dynamic device profile processing Beilei Xing
2017-03-29 14:44               ` [PATCH v7 3/6] app/testpmd: add command for loading a profile Beilei Xing
2017-03-29 14:44               ` [PATCH v7 4/6] net/i40e: add get all loaded profiles Beilei Xing
2017-03-29 14:44               ` [PATCH v7 5/6] app/testpmd: add command for getting " Beilei Xing
2017-03-29 14:44               ` [PATCH v7 6/6] doc: add dynamic device profile support for i40e Beilei Xing
2017-03-30  2:51               ` [PATCH v8 0/6] dynamic device personalization support Beilei Xing
2017-03-30  2:51                 ` [PATCH v8 1/6] net/i40e/base: change ppp to ddp Beilei Xing
2017-03-30 14:06                   ` Ferruh Yigit
2017-03-30  2:51                 ` [PATCH v8 2/6] net/i40e: add dynamic device personalization processing Beilei Xing
2017-03-30 14:06                   ` Ferruh Yigit
2017-03-30 14:08                   ` Ferruh Yigit
2017-03-30  2:51                 ` Beilei Xing [this message]
2017-03-30  2:51                 ` [PATCH v8 4/6] net/i40e: add get all loaded profiles Beilei Xing
2017-03-30  2:51                 ` [PATCH v8 5/6] app/testpmd: add command for getting " Beilei Xing
2017-03-30 14:07                   ` Ferruh Yigit
2017-03-30  2:51                 ` [PATCH v8 6/6] doc: add dynamic device personalization support for i40e Beilei Xing
2017-03-30  6:18                 ` [PATCH v8 0/6] dynamic device personalization support Wu, Jingjing
2017-03-30 14:05                   ` Ferruh Yigit
2017-03-03  7:52   ` [PATCH 0/6] net/i40e: support pipeline personalization profile Xing, Beilei
2017-03-03  7:26 ` [PATCH 1/6] net/i40e: fix a typo in flow Beilei Xing
2017-03-03  7:26 ` [PATCH 2/6] net/i40e: support pipeline personalization profile Beilei Xing
2017-03-03  7:26 ` [PATCH 3/6] net/i40e: add ppp processing Beilei Xing
2017-03-03  7:26 ` [PATCH 4/6] app/testpmd: add command for writing personalization profile Beilei Xing
2017-03-03  7:26 ` [PATCH 5/6] net/i40e: add get all loaded profiles Beilei Xing
2017-03-03  7:26 ` [PATCH 6/6] app/testpmd: add command for getting " Beilei Xing

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=1490842311-96705-4-git-send-email-beilei.xing@intel.com \
    --to=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=helin.zhang@intel.com \
    --cc=jingjing.wu@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.