* [dpdk-dev] [PATCH] app/testpmd: update ddp add command parameters
@ 2017-06-27 12:06 Andrey Chilikin
2017-06-27 15:12 ` Ferruh Yigit
0 siblings, 1 reply; 3+ messages in thread
From: Andrey Chilikin @ 2017-06-27 12:06 UTC (permalink / raw)
To: dev; +Cc: beilei.xing, jingjing.wu, Andrey Chilikin
This patch adds optional output file path to 'ddp add' command:
'ddp add (port) (profile_path[,output_path])'
Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
---
app/test-pmd/cmdline.c | 29 ++++++++++++++++++++++-------
app/test-pmd/config.c | 21 +++++++++++++++++++++
app/test-pmd/testpmd.h | 1 +
doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +-
4 files changed, 45 insertions(+), 8 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 632d6f03f..81d1f84fe 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -603,7 +603,7 @@ 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"
- "ddp add (port_id) (profile_path)\n"
+ "ddp add (port_id) (profile_path[,output_path])\n"
" Load a profile package on a port\n\n"
"ptype mapping get (port_id) (valid_only)\n"
@@ -12955,6 +12955,9 @@ cmd_ddp_add_parsed(
struct cmd_ddp_add_result *res = parsed_result;
uint8_t *buff;
uint32_t size;
+ char *filepath;
+ char *file_fld[2];
+ int file_num;
int ret = -ENOTSUP;
if (res->port_id > nb_ports) {
@@ -12967,9 +12970,18 @@ cmd_ddp_add_parsed(
return;
}
- buff = open_ddp_package_file(res->filepath, &size);
- if (!buff)
+ filepath = strdup(res->filepath);
+ if (filepath == NULL) {
+ printf("Failed to allocate memory\n");
return;
+ }
+ file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ',');
+
+ buff = open_ddp_package_file(file_fld[0], &size);
+ if (!buff) {
+ free((void *)filepath);
+ return;
+ }
#ifdef RTE_LIBRTE_I40E_PMD
if (ret == -ENOTSUP)
@@ -12978,18 +12990,21 @@ cmd_ddp_add_parsed(
RTE_PMD_I40E_PKG_OP_WR_ADD);
#endif
- if (ret < 0)
- printf("Failed to load profile.\n");
- else if (ret > 0)
+ if (ret == -EEXIST)
printf("Profile has already existed.\n");
+ else if (ret < 0)
+ printf("Failed to load profile.\n");
+ else if (file_num == 2)
+ save_ddp_package_file(file_fld[1], buff, size);
close_ddp_package_file(buff);
+ free((void *)filepath);
}
cmdline_parse_inst_t cmd_ddp_add = {
.f = cmd_ddp_add_parsed,
.data = NULL,
- .help_str = "ddp add <port_id> <profile_path>",
+ .help_str = "ddp add <port_id> <profile_path[,output_path]>",
.tokens = {
(void *)&cmd_ddp_add_ddp,
(void *)&cmd_ddp_add_add,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index b0b340e5c..2720bcb6d 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -3309,6 +3309,27 @@ open_ddp_package_file(const char *file_path, uint32_t *size)
}
int
+save_ddp_package_file(const char *file_path, uint8_t *buf, uint32_t size)
+{
+ FILE *fh = fopen(file_path, "wb");
+
+ if (fh == NULL) {
+ printf("%s: Failed to open %s\n", __func__, file_path);
+ return -1;
+ }
+
+ if (fwrite(buf, 1, size, fh) != size) {
+ fclose(fh);
+ printf("%s: File write operation failed\n", __func__);
+ return -1;
+ }
+
+ fclose(fh);
+
+ return 0;
+}
+
+int
close_ddp_package_file(uint8_t *buf)
{
if (buf) {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 364502d1d..0334280de 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -633,6 +633,7 @@ 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 save_ddp_package_file(const char *file_path, uint8_t *buf, uint32_t size);
int close_ddp_package_file(uint8_t *buf);
enum print_warning {
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 18ee8a3fe..e6b0b514a 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1230,7 +1230,7 @@ ddp add
Load a dynamic device personalization (DDP) package::
- testpmd> ddp add (port_id) (package_path)
+ testpmd> ddp add (port_id) (package_path[,output_path])
ptype mapping
~~~~~~~~~~~~~
--
2.13.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] app/testpmd: update ddp add command parameters
2017-06-27 12:06 [dpdk-dev] [PATCH] app/testpmd: update ddp add command parameters Andrey Chilikin
@ 2017-06-27 15:12 ` Ferruh Yigit
2017-06-27 15:14 ` Ferruh Yigit
0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2017-06-27 15:12 UTC (permalink / raw)
To: Andrey Chilikin, dev; +Cc: beilei.xing, jingjing.wu
On 6/27/2017 1:06 PM, Andrey Chilikin wrote:
> This patch adds optional output file path to 'ddp add' command:
> 'ddp add (port) (profile_path[,output_path])'
>
> Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] app/testpmd: update ddp add command parameters
2017-06-27 15:12 ` Ferruh Yigit
@ 2017-06-27 15:14 ` Ferruh Yigit
0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2017-06-27 15:14 UTC (permalink / raw)
To: Andrey Chilikin, dev; +Cc: beilei.xing, jingjing.wu
On 6/27/2017 4:12 PM, Ferruh Yigit wrote:
> On 6/27/2017 1:06 PM, Andrey Chilikin wrote:
>> This patch adds optional output file path to 'ddp add' command:
>> 'ddp add (port) (profile_path[,output_path])'
>>
>> Signed-off-by: Andrey Chilikin <andrey.chilikin@intel.com>
>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-27 15:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 12:06 [dpdk-dev] [PATCH] app/testpmd: update ddp add command parameters Andrey Chilikin
2017-06-27 15:12 ` Ferruh Yigit
2017-06-27 15:14 ` Ferruh Yigit
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).