[dpdk-dev] [PATCH v3 2/3] port: add kni nodrop writer

2016-06-18 Thread Dumitrescu, Cristian


> -Original Message-
> From: WeiJie Zhuang [mailto:zhuangwj at gmail.com]
> Sent: Thursday, June 16, 2016 12:27 PM
> To: Dumitrescu, Cristian 
> Cc: dev at dpdk.org; Singh, Jasvinder ; Yigit,
> Ferruh ; WeiJie Zhuang 
> Subject: [PATCH v3 2/3] port: add kni nodrop writer
> 
> 1. add no drop writing operations to the kni port
> 2. support dropless kni config in the ip pipeline sample application
> 
> Signed-off-by: WeiJie Zhuang 
> ---
>  examples/ip_pipeline/app.h   |   2 +
>  examples/ip_pipeline/config_parse.c  |  31 -
>  examples/ip_pipeline/init.c  |  26 -
>  examples/ip_pipeline/pipeline_be.h   |   6 +
>  lib/librte_port/rte_port_kni.c   | 220
> +++
>  lib/librte_port/rte_port_kni.h   |  13 +++
>  lib/librte_port/rte_port_version.map |   1 +
>  7 files changed, 292 insertions(+), 7 deletions(-)
> 
> diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h
> index abbd6d4..6a6fdd9 100644
> --- a/examples/ip_pipeline/app.h
> +++ b/examples/ip_pipeline/app.h
> @@ -147,6 +147,8 @@ struct app_pktq_kni_params {
>   uint32_t mempool_id; /* Position in the app->mempool_params */
>   uint32_t burst_read;
>   uint32_t burst_write;
> + uint32_t dropless;
> + uint64_t n_retries;
>  };
> 
>  #ifndef APP_FILE_NAME_SIZE
> diff --git a/examples/ip_pipeline/config_parse.c
> b/examples/ip_pipeline/config_parse.c
> index c55be31..31a50c2 100644
> --- a/examples/ip_pipeline/config_parse.c
> +++ b/examples/ip_pipeline/config_parse.c
> @@ -199,6 +199,8 @@ struct app_pktq_kni_params default_kni_params = {
>   .mempool_id = 0,
>   .burst_read = 32,
>   .burst_write = 32,
> + .dropless = 0,
> + .n_retries = 0,
>  };
> 
>  struct app_pktq_source_params default_source_params = {
> @@ -1927,7 +1929,7 @@ parse_kni(struct app_params *app,
> 
>   if (strcmp(ent->name, "mempool") == 0) {
>   int status = validate_name(ent->value,
> -
> "MEMPOOL", 1);
> + "MEMPOOL", 1);
>   ssize_t idx;
> 
>   PARSE_ERROR((status == 0), section_name,
> @@ -1940,7 +1942,7 @@ parse_kni(struct app_params *app,
> 
>   if (strcmp(ent->name, "burst_read") == 0) {
>   int status = parser_read_uint32(
> >burst_read,
> -
>   ent->value);
> + ent->value);
> 
>   PARSE_ERROR((status == 0), section_name,
>   ent->name);
> @@ -1949,7 +1951,25 @@ parse_kni(struct app_params *app,
> 
>   if (strcmp(ent->name, "burst_write") == 0) {
>   int status = parser_read_uint32(
> >burst_write,
> -
>   ent->value);
> + ent->value);
> +
> + PARSE_ERROR((status == 0), section_name,
> + ent->name);
> + continue;
> + }
> +
> + if (strcmp(ent->name, "dropless") == 0) {
> + int status = parser_read_arg_bool(ent->value);
> +
> + PARSE_ERROR((status != -EINVAL), section_name,
> + ent->name);
> + param->dropless = status;
> + continue;
> + }
> +
> + if (strcmp(ent->name, "n_retries") == 0) {
> + int status = parser_read_uint64(>n_retries,
> + ent->value);
> 
>   PARSE_ERROR((status == 0), section_name,
>   ent->name);
> @@ -2794,6 +2814,11 @@ save_kni_params(struct app_params *app, FILE
> *f)
>   /* burst_write */
>   fprintf(f, "%s = %" PRIu32 "\n", "burst_write", p-
> >burst_write);
> 
> + /* dropless */
> + fprintf(f, "%s = %s\n",
> + "dropless",
> + p->dropless ? "yes" : "no");

Please also do not forget to save the number of retries parameter as well 
(struct app_pktq_kni_params::n_retries):

fprintf(f, "%s = %" PRIu64 "\n", "n_retries", p->n_retries);

I realize that we forgot to save n_retires in function save_txq_params(), can 
you please add it as part of your patch? We have it for save_swq_params().

> +
>   fputc('\n', f);
>   }
>  }
> diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
> index d522de4..af24f52 100644
> --- a/examples/ip_pipeline/init.c
> +++ b/examples/ip_pipeline/init.c
> @@ -1434,10 +1434,28 @@ void app_pipeline_params_get(struct
> app_params *app,
>  #ifdef RTE_LIBRTE_KNI
>   case APP_PKTQ_OUT_KNI:
>   {
> - out->type = PIPELINE_PORT_OUT_KNI_WRITER;
> - out->params.kni.kni = app->kni[in->id];
> - 

[dpdk-dev] [PATCH v3 2/3] port: add kni nodrop writer

2016-06-16 Thread WeiJie Zhuang
1. add no drop writing operations to the kni port
2. support dropless kni config in the ip pipeline sample application

Signed-off-by: WeiJie Zhuang 
---
 examples/ip_pipeline/app.h   |   2 +
 examples/ip_pipeline/config_parse.c  |  31 -
 examples/ip_pipeline/init.c  |  26 -
 examples/ip_pipeline/pipeline_be.h   |   6 +
 lib/librte_port/rte_port_kni.c   | 220 +++
 lib/librte_port/rte_port_kni.h   |  13 +++
 lib/librte_port/rte_port_version.map |   1 +
 7 files changed, 292 insertions(+), 7 deletions(-)

diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h
index abbd6d4..6a6fdd9 100644
--- a/examples/ip_pipeline/app.h
+++ b/examples/ip_pipeline/app.h
@@ -147,6 +147,8 @@ struct app_pktq_kni_params {
uint32_t mempool_id; /* Position in the app->mempool_params */
uint32_t burst_read;
uint32_t burst_write;
+   uint32_t dropless;
+   uint64_t n_retries;
 };

 #ifndef APP_FILE_NAME_SIZE
diff --git a/examples/ip_pipeline/config_parse.c 
b/examples/ip_pipeline/config_parse.c
index c55be31..31a50c2 100644
--- a/examples/ip_pipeline/config_parse.c
+++ b/examples/ip_pipeline/config_parse.c
@@ -199,6 +199,8 @@ struct app_pktq_kni_params default_kni_params = {
.mempool_id = 0,
.burst_read = 32,
.burst_write = 32,
+   .dropless = 0,
+   .n_retries = 0,
 };

 struct app_pktq_source_params default_source_params = {
@@ -1927,7 +1929,7 @@ parse_kni(struct app_params *app,

if (strcmp(ent->name, "mempool") == 0) {
int status = validate_name(ent->value,
-  
"MEMPOOL", 1);
+   "MEMPOOL", 1);
ssize_t idx;

PARSE_ERROR((status == 0), section_name,
@@ -1940,7 +1942,7 @@ parse_kni(struct app_params *app,

if (strcmp(ent->name, "burst_read") == 0) {
int status = parser_read_uint32(>burst_read,
-   
ent->value);
+   ent->value);

PARSE_ERROR((status == 0), section_name,
ent->name);
@@ -1949,7 +1951,25 @@ parse_kni(struct app_params *app,

if (strcmp(ent->name, "burst_write") == 0) {
int status = parser_read_uint32(>burst_write,
-   
ent->value);
+   ent->value);
+
+   PARSE_ERROR((status == 0), section_name,
+   ent->name);
+   continue;
+   }
+
+   if (strcmp(ent->name, "dropless") == 0) {
+   int status = parser_read_arg_bool(ent->value);
+
+   PARSE_ERROR((status != -EINVAL), section_name,
+   ent->name);
+   param->dropless = status;
+   continue;
+   }
+
+   if (strcmp(ent->name, "n_retries") == 0) {
+   int status = parser_read_uint64(>n_retries,
+   ent->value);

PARSE_ERROR((status == 0), section_name,
ent->name);
@@ -2794,6 +2814,11 @@ save_kni_params(struct app_params *app, FILE *f)
/* burst_write */
fprintf(f, "%s = %" PRIu32 "\n", "burst_write", p->burst_write);

+   /* dropless */
+   fprintf(f, "%s = %s\n",
+   "dropless",
+   p->dropless ? "yes" : "no");
+
fputc('\n', f);
}
 }
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index d522de4..af24f52 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -1434,10 +1434,28 @@ void app_pipeline_params_get(struct app_params *app,
 #ifdef RTE_LIBRTE_KNI
case APP_PKTQ_OUT_KNI:
{
-   out->type = PIPELINE_PORT_OUT_KNI_WRITER;
-   out->params.kni.kni = app->kni[in->id];
-   out->params.kni.tx_burst_sz =
-   app->kni_params[in->id].burst_write;
+   struct app_pktq_kni_params *p_kni =
+   >kni_params[in->id];
+
+   if (p_kni->dropless == 0) {
+   struct rte_port_kni_writer_params *params =
+   >params.kni;
+
+   out->type = PIPELINE_PORT_OUT_KNI_WRITER;
+   params->kni = app->kni[in->id];
+