[dpdk-dev] [PATCH v1 1/1] example/ip_pipeline: fix memcpy issue
The cmds and thread_cmds both are the arrays of cmdline_parse_ctx_t. So the goal is to copy elements size of cmdline_parse_ctx_t not cmdline_parse_ctx_t*. Coverity issue: 120412 Fixes: b4aee0fb9c6d ("examples/ip_pipeline: reconfigure thread binding dynamically") Signed-off-by: Piotr Azarewicz --- examples/ip_pipeline/thread_fe.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ip_pipeline/thread_fe.c b/examples/ip_pipeline/thread_fe.c index 7a3bbf8..f1df05e 100644 --- a/examples/ip_pipeline/thread_fe.c +++ b/examples/ip_pipeline/thread_fe.c @@ -337,7 +337,7 @@ app_pipeline_thread_cmd_push(struct app_params *app) /* Push thread commands into the application */ memcpy(>cmds[app->n_cmds], thread_cmds, - n_cmds * sizeof(cmdline_parse_ctx_t *)); + n_cmds * sizeof(cmdline_parse_ctx_t)); for (i = 0; i < n_cmds; i++) app->cmds[app->n_cmds + i]->data = app; -- 1.7.9.5
[dpdk-dev] [PATCH v2 1/1] example/ip_pipeline: fix memcpy issue
The source and destination both are the arrays of cmdline_parse_ctx_t. So the goal is to copy elements size of cmdline_parse_ctx_t not cmdline_parse_ctx_t*. Coverity issue: 120412 Fixes: b4aee0fb9c6d ("examples/ip_pipeline: reconfigure thread binding dynamically") Fixes: ea0908c4ab89 ("examples/ip_pipeline: add master pipeline") Fixes: eb32fe7c5574 ("examples/ip_pipeline: rework initialization parameters") Signed-off-by: Piotr Azarewicz --- v2 changes: - add the same fix in two other places examples/ip_pipeline/init.c|2 +- examples/ip_pipeline/pipeline/pipeline_common_fe.c |2 +- examples/ip_pipeline/thread_fe.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 52aab53..bc6d6d9 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -1472,7 +1472,7 @@ app_pipeline_type_cmd_push(struct app_params *app, /* Push pipeline commands into the application */ memcpy(>cmds[app->n_cmds], cmds, - n_cmds * sizeof(cmdline_parse_ctx_t *)); + n_cmds * sizeof(cmdline_parse_ctx_t)); for (i = 0; i < n_cmds; i++) app->cmds[app->n_cmds + i]->data = app; diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c b/examples/ip_pipeline/pipeline/pipeline_common_fe.c index 87ec164..1e16ad6 100644 --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c @@ -1292,7 +1292,7 @@ app_pipeline_common_cmd_push(struct app_params *app) /* Push pipeline commands into the application */ memcpy(>cmds[app->n_cmds], pipeline_common_cmds, - n_cmds * sizeof(cmdline_parse_ctx_t *)); + n_cmds * sizeof(cmdline_parse_ctx_t)); for (i = 0; i < n_cmds; i++) app->cmds[app->n_cmds + i]->data = app; diff --git a/examples/ip_pipeline/thread_fe.c b/examples/ip_pipeline/thread_fe.c index 7a3bbf8..f1df05e 100644 --- a/examples/ip_pipeline/thread_fe.c +++ b/examples/ip_pipeline/thread_fe.c @@ -337,7 +337,7 @@ app_pipeline_thread_cmd_push(struct app_params *app) /* Push thread commands into the application */ memcpy(>cmds[app->n_cmds], thread_cmds, - n_cmds * sizeof(cmdline_parse_ctx_t *)); + n_cmds * sizeof(cmdline_parse_ctx_t)); for (i = 0; i < n_cmds; i++) app->cmds[app->n_cmds + i]->data = app; -- 1.7.9.5
[dpdk-dev] [PATCH v3 0/7] examples/ip_pipeline: CLI rework and improvements
Using the latest librte_cmdline improvements, the CLI implementation of the ip_pipeline application is streamlined and improved, which results in eliminating thousands of lines of code from the application, thus leading to code that is easier to maintain and extend. v3 changes: - fix the authorship in patches v2 changes: - added functions for parsing hex values - added standard error messages for CLI and file bulk - for all CLI commands: separate code paths for each flavor of each command (e.g. route add, route add default, route ls, route del, route del default, etc do not share any line of code) - for bulk commands: simplified error checking - added additional config files Acked-by: Cristian Dumitrescu Daniel Mrzyglod (1): examples/ip_pipeline: modifies firewall pipeline CLI Piotr Azarewicz (4): examples/ip_pipeline: add helper functions for parsing string examples/ip_pipeline: modifies flow action pipeline CLI examples/ip_pipeline: modifies routing pipeline CLI examples/ip_pipeline: update edge router usecase Tomasz Kulasek (2): examples/ip_pipeline: modifies common pipeline CLI examples/ip_pipeline: modifies flow classifications pipeline CLI examples/ip_pipeline/Makefile |1 + examples/ip_pipeline/config/action.cfg | 68 + examples/ip_pipeline/config/action.sh | 119 ++ examples/ip_pipeline/config/action.txt |8 + .../ip_pipeline/config/edge_router_downstream.cfg | 30 +- .../ip_pipeline/config/edge_router_downstream.sh |7 +- .../ip_pipeline/config/edge_router_upstream.cfg| 36 +- .../ip_pipeline/config/edge_router_upstream.sh | 37 +- examples/ip_pipeline/config/firewall.cfg | 68 + examples/ip_pipeline/config/firewall.sh| 13 + examples/ip_pipeline/config/firewall.txt |9 + examples/ip_pipeline/config/flow.cfg | 72 + examples/ip_pipeline/config/flow.sh| 25 + examples/ip_pipeline/config/flow.txt | 17 + examples/ip_pipeline/config/l2fwd.cfg |5 +- examples/ip_pipeline/config/l3fwd.cfg |9 +- examples/ip_pipeline/config/l3fwd.sh | 32 +- examples/ip_pipeline/config/l3fwd_arp.cfg | 70 + examples/ip_pipeline/config/l3fwd_arp.sh | 43 + examples/ip_pipeline/config_parse.c| 257 +-- examples/ip_pipeline/parser.c | 745 +++ examples/ip_pipeline/parser.h | 54 +- examples/ip_pipeline/pipeline/pipeline_common_fe.c | 452 ++--- examples/ip_pipeline/pipeline/pipeline_common_fe.h |9 + examples/ip_pipeline/pipeline/pipeline_firewall.c | 1461 +- examples/ip_pipeline/pipeline/pipeline_firewall.h | 12 + .../ip_pipeline/pipeline/pipeline_flow_actions.c | 1505 +- .../ip_pipeline/pipeline/pipeline_flow_actions.h | 11 + .../pipeline/pipeline_flow_classification.c| 2082 +--- .../pipeline/pipeline_flow_classification.h| 28 + examples/ip_pipeline/pipeline/pipeline_routing.c | 1636 --- examples/ip_pipeline/thread_fe.c | 36 +- 32 files changed, 4009 insertions(+), 4948 deletions(-) create mode 100644 examples/ip_pipeline/config/action.cfg create mode 100644 examples/ip_pipeline/config/action.sh create mode 100644 examples/ip_pipeline/config/action.txt create mode 100644 examples/ip_pipeline/config/firewall.cfg create mode 100644 examples/ip_pipeline/config/firewall.sh create mode 100644 examples/ip_pipeline/config/firewall.txt create mode 100644 examples/ip_pipeline/config/flow.cfg create mode 100644 examples/ip_pipeline/config/flow.sh create mode 100644 examples/ip_pipeline/config/flow.txt create mode 100644 examples/ip_pipeline/config/l3fwd_arp.cfg create mode 100644 examples/ip_pipeline/config/l3fwd_arp.sh create mode 100644 examples/ip_pipeline/parser.c -- 1.7.9.5
[dpdk-dev] [PATCH v3 1/7] examples/ip_pipeline: add helper functions for parsing string
Add a couple of additional functions that will allow to parse many types of input parameters, i.e.: bool, 16, 32, 64 bits, hex, etc. Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/Makefile |1 + examples/ip_pipeline/config_parse.c | 257 +--- examples/ip_pipeline/parser.c | 745 +++ examples/ip_pipeline/parser.h | 54 ++- 4 files changed, 791 insertions(+), 266 deletions(-) create mode 100644 examples/ip_pipeline/parser.c diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile index 10fe1ba..5827117 100644 --- a/examples/ip_pipeline/Makefile +++ b/examples/ip_pipeline/Makefile @@ -50,6 +50,7 @@ INC += $(wildcard *.h) $(wildcard pipeline/*.h) # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c +SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += parser.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index e5efd03..ff917f3 100644 --- a/examples/ip_pipeline/config_parse.c +++ b/examples/ip_pipeline/config_parse.c @@ -30,6 +30,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include #include #include @@ -229,13 +230,6 @@ app_print_usage(char *prgname) rte_exit(0, app_usage, prgname, app_params_default.config_file); } -#define skip_white_spaces(pos) \ -({ \ - __typeof__(pos) _p = (pos); \ - for ( ; isspace(*_p); _p++);\ - _p; \ -}) - #define PARSER_PARAM_ADD_CHECK(result, params_array, section_name) \ do { \ APP_CHECK((result != -EINVAL), \ @@ -248,44 +242,6 @@ do { \ "Parse error in section \"%s\"", section_name); \ } while (0) -int -parser_read_arg_bool(const char *p) -{ - p = skip_white_spaces(p); - int result = -EINVAL; - - if (((p[0] == 'y') && (p[1] == 'e') && (p[2] == 's')) || - ((p[0] == 'Y') && (p[1] == 'E') && (p[2] == 'S'))) { - p += 3; - result = 1; - } - - if (((p[0] == 'o') && (p[1] == 'n')) || - ((p[0] == 'O') && (p[1] == 'N'))) { - p += 2; - result = 1; - } - - if (((p[0] == 'n') && (p[1] == 'o')) || - ((p[0] == 'N') && (p[1] == 'O'))) { - p += 2; - result = 0; - } - - if (((p[0] == 'o') && (p[1] == 'f') && (p[2] == 'f')) || - ((p[0] == 'O') && (p[1] == 'F') && (p[2] == 'F'))) { - p += 3; - result = 0; - } - - p = skip_white_spaces(p); - - if (p[0] != '\0') - return -EINVAL; - - return result; -} - #define PARSE_ERROR(exp, section, entry) \ APP_CHECK(exp, "Parse error in section \"%s\": entry \"%s\"\n", section, entry) @@ -318,217 +274,6 @@ APP_CHECK(exp, "Parse error in section \"%s\": unrecognized entry \"%s\"\n",\ APP_CHECK(exp, "Parse error in section \"%s\": duplicate entry \"%s\"\n",\ section, entry) -int -parser_read_uint64(uint64_t *value, const char *p) -{ - char *next; - uint64_t val; - - p = skip_white_spaces(p); - if (!isdigit(*p)) - return -EINVAL; - - val = strtoul(p, , 10); - if (p == next) - return -EINVAL; - - p = next; - switch (*p) { - case 'T': - val *= 1024ULL; - /* fall through */ - case 'G': - val *= 1024ULL; - /* fall through */ - case 'M': - val *= 1024ULL; - /* fall through */ - case 'k': - case 'K': - val *= 1024ULL; - p++; - break; - } - - p = skip_white_spaces(p); - if (*p != '\0') - return -EINVAL; - - *value = val; - return 0; -} - -int -parser_read_uint32(uint32_t *value, const char *p) -{ - uint64_t val = 0; - int ret = parser_read_uint64(, p); - - if (ret < 0) - return ret; - - if (val > UINT32_MAX) - return -ERANGE; - - *value = val; - return 0; -
[dpdk-dev] [PATCH v3 2/7] examples/ip_pipeline: modifies common pipeline CLI
From: Tomasz KulasekAll link commands are merged into one command: cmd_link_parsed. Improve run command to allow run periodically. Adding static keyword to a lot of token declarations. Signed-off-by: Tomasz Kulasek Signed-off-by: Michal Kobylinski Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/pipeline/pipeline_common_fe.c | 452 ++-- examples/ip_pipeline/pipeline/pipeline_common_fe.h |9 + examples/ip_pipeline/thread_fe.c | 36 +- 3 files changed, 244 insertions(+), 253 deletions(-) diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c b/examples/ip_pipeline/pipeline/pipeline_common_fe.c index a691d42..dc37a5f 100644 --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,12 +42,10 @@ #include #include #include -#include -#include -#include #include #include "pipeline_common_fe.h" +#include "parser.h" int app_pipeline_ping(struct app_params *app, @@ -464,16 +462,16 @@ cmd_ping_parsed( printf("Command failed\n"); } -cmdline_parse_token_string_t cmd_ping_p_string = +static cmdline_parse_token_string_t cmd_ping_p_string = TOKEN_STRING_INITIALIZER(struct cmd_ping_result, p_string, "p"); -cmdline_parse_token_num_t cmd_ping_pipeline_id = +static cmdline_parse_token_num_t cmd_ping_pipeline_id = TOKEN_NUM_INITIALIZER(struct cmd_ping_result, pipeline_id, UINT32); -cmdline_parse_token_string_t cmd_ping_ping_string = +static cmdline_parse_token_string_t cmd_ping_ping_string = TOKEN_STRING_INITIALIZER(struct cmd_ping_result, ping_string, "ping"); -cmdline_parse_inst_t cmd_ping = { +static cmdline_parse_inst_t cmd_ping = { .f = cmd_ping_parsed, .data = NULL, .help_str = "Pipeline ping", @@ -498,6 +496,7 @@ struct cmd_stats_port_in_result { uint32_t port_in_id; }; + static void cmd_stats_port_in_parsed( void *parsed_result, @@ -531,23 +530,23 @@ cmd_stats_port_in_parsed( stats.stats.n_pkts_drop); } -cmdline_parse_token_string_t cmd_stats_port_in_p_string = +static cmdline_parse_token_string_t cmd_stats_port_in_p_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, p_string, "p"); -cmdline_parse_token_num_t cmd_stats_port_in_pipeline_id = +static cmdline_parse_token_num_t cmd_stats_port_in_pipeline_id = TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, pipeline_id, UINT32); -cmdline_parse_token_string_t cmd_stats_port_in_stats_string = +static cmdline_parse_token_string_t cmd_stats_port_in_stats_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, stats_string, "stats"); -cmdline_parse_token_string_t cmd_stats_port_in_port_string = +static cmdline_parse_token_string_t cmd_stats_port_in_port_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, port_string, "port"); -cmdline_parse_token_string_t cmd_stats_port_in_in_string = +static cmdline_parse_token_string_t cmd_stats_port_in_in_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, in_string, "in"); @@ -555,7 +554,7 @@ cmdline_parse_token_string_t cmd_stats_port_in_in_string = TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, port_in_id, UINT32); -cmdline_parse_inst_t cmd_stats_port_in = { +static cmdline_parse_inst_t cmd_stats_port_in = { .f = cmd_stats_port_in_parsed, .data = NULL, .help_str = "Pipeline input port stats", @@ -617,31 +616,31 @@ cmd_stats_port_out_parsed( stats.stats.n_pkts_drop); } -cmdline_parse_token_string_t cmd_stats_port_out_p_string = +static cmdline_parse_token_string_t cmd_stats_port_out_p_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, p_string, "p"); -cmdline_parse_token_num_t cmd_stats_port_out_pipeline_id = +static cmdline_parse_token_num_t cmd_stats_port_out_pipeline_id = TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, pipeline_id, UINT32); -cmdline_parse_token_string_t cmd_stats_port_out_stats_string = +static cmdline_parse_token_string_t cmd_stats_port_out_stats_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, stats_string, "stats"); -cmdline_parse_token_string_t cmd_stats_port_out_port_string = +static cmdline_parse_token_string_t cmd_stats_port_out_port_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, port_string, "port"); -cmdline_parse_token_string_t
[dpdk-dev] [PATCH v3 3/7] examples/ip_pipeline: modifies firewall pipeline CLI
From: Daniel MrzyglodEach command are merged into one: cmd_firewall_parsed. ADD command format is changed: p firewall add priority ipv4 port and bulk command was modified: 1. firewall add bulk File line format: priority ipv4 port (protomask is a hex value) File line example: priority 0 ipv4 1.2.3.0 24 10.20.30.40 32 0 63 64 127 6 0xF port 3 2. firewall del bulk File line format: ipv4 File line example: ipv4 1.2.3.0 24 10.20.30.40 32 0 63 64 127 6 0xF Signed-off-by: Daniel Mrzyglod Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config/firewall.cfg | 68 + examples/ip_pipeline/config/firewall.sh | 13 + examples/ip_pipeline/config/firewall.txt |9 + examples/ip_pipeline/pipeline/pipeline_firewall.c | 1461 - examples/ip_pipeline/pipeline/pipeline_firewall.h | 12 + 5 files changed, 622 insertions(+), 941 deletions(-) create mode 100644 examples/ip_pipeline/config/firewall.cfg create mode 100644 examples/ip_pipeline/config/firewall.sh create mode 100644 examples/ip_pipeline/config/firewall.txt diff --git a/examples/ip_pipeline/config/firewall.cfg b/examples/ip_pipeline/config/firewall.cfg new file mode 100644 index 000..2f5dd9f --- /dev/null +++ b/examples/ip_pipeline/config/firewall.cfg @@ -0,0 +1,68 @@ +; BSD LICENSE +; +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; * Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; * Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in +; the documentation and/or other materials provided with the +; distribution. +; * Neither the name of Intel Corporation nor the names of its +; contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +; ___ +; RXQ0.0 --->| |---> TXQ0.0 +;| | +; RXQ1.0 --->| |---> TXQ1.0 +;| Firewall| +; RXQ2.0 --->| |---> TXQ2.0 +;| | +; RXQ3.0 --->| |---> TXQ3.0 +;|___| +;| +;+---> SINK0 (default rule) +; +; Input packet: Ethernet/IPv4 +; +; Packet buffer layout: +; #Field Name Offset (Bytes) Size (Bytes) +; 0Mbuf0 128 +; 1Headroom128 128 +; 2Ethernet header 256 14 +; 3IPv4 header 270 20 + +[EAL] +log_level = 0 + +[PIPELINE0] +type = MASTER +core = 0 + +[PIPELINE1] +type = FIREWALL +core = 1 +pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 +pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 SINK0 +n_rules = 4096 +pkt_type = ipv4 +;pkt_type = vlan_ipv4 +;pkt_type = qinq_ipv4 diff --git a/examples/ip_pipeline/config/firewall.sh b/examples/ip_pipeline/config/firewall.sh new file mode 100644 index 000..c83857e --- /dev/null +++ b/examples/ip_pipeline/config/firewall.sh @@ -0,0 +1,13 @@ +# +# run ./config/firewall.sh +# + +p 1 firewall add default 4 #SINK0 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 0xF port 0 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 0xF port 1 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 0xF port 2 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 0xF port 3 + +#p 1 firewall add bulk ./config/firewall.txt + +p 1 firewall ls diff --git a/examples/ip_pipeline/config/firewall.txt b/examples/ip_pipeline/config/firewall.txt new file mode 100644 index 000..54cfffd --- /dev/null +++ b/examples/ip_pipeline/config/firewall.txt @@ -0,0 +1,9 @@ +#
[dpdk-dev] [PATCH v3 5/7] examples/ip_pipeline: modifies flow action pipeline CLI
All commands merged into one: cmd_action_parsed. modified bulk command: action flow bulk File line format: flow meter 0 meter 1 meter 2 meter 3 policer 0policer 1 policer 2policer 3 port Signed-off-by: Marcin Kerlin Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config/action.cfg | 68 + examples/ip_pipeline/config/action.sh | 119 ++ examples/ip_pipeline/config/action.txt |8 + .../ip_pipeline/pipeline/pipeline_flow_actions.c | 1505 +++- .../ip_pipeline/pipeline/pipeline_flow_actions.h | 11 + 5 files changed, 707 insertions(+), 1004 deletions(-) create mode 100644 examples/ip_pipeline/config/action.cfg create mode 100644 examples/ip_pipeline/config/action.sh create mode 100644 examples/ip_pipeline/config/action.txt diff --git a/examples/ip_pipeline/config/action.cfg b/examples/ip_pipeline/config/action.cfg new file mode 100644 index 000..994ae94 --- /dev/null +++ b/examples/ip_pipeline/config/action.cfg @@ -0,0 +1,68 @@ +; BSD LICENSE +; +; Copyright(c) 2016 Intel Corporation. All rights reserved. +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; * Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; * Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in +; the documentation and/or other materials provided with the +; distribution. +; * Neither the name of Intel Corporation nor the names of its +; contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +; +; RXQ0.0 --->||---> TXQ0.0 +;|| +; RXQ1.0 --->||---> TXQ1.0 +;| Flow | +; RXQ2.0 --->| Actions|---> TXQ2.0 +;|| +; RXQ3.0 --->||---> TXQ3.0 +;|| +; +; +; Input packet: Ethernet/IPv4 +; +; Packet buffer layout: +; #Field Name Offset (Bytes) Size (Bytes) +; 0Mbuf0 128 +; 1Headroom128 128 +; 2Ethernet header 256 14 +; 3IPv4 header 270 20 + +[EAL] +log_level = 0 + +[PIPELINE0] +type = MASTER +core = 0 + +[PIPELINE1] +type = FLOW_ACTIONS +core = 1 +pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 +pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 +n_flows = 65536 +n_meters_per_flow = 4 +flow_id_offset = 286; ipdaddr +ip_hdr_offset = 270 +color_offset = 128 diff --git a/examples/ip_pipeline/config/action.sh b/examples/ip_pipeline/config/action.sh new file mode 100644 index 000..2986ae6 --- /dev/null +++ b/examples/ip_pipeline/config/action.sh @@ -0,0 +1,119 @@ +# +# run ./config/action.sh +# + +p 1 action flow 0 meter 0 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 0 g G y Y r R +p 1 action flow 0 meter 1 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 1 g G y Y r R +p 1 action flow 0 meter 2 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 2 g G y Y r R +p 1 action flow 0 meter 3 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 3 g G y Y r R +p 1 action flow 0 port 0 + +p 1 action flow 1 meter 0 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 0 g G y Y r R +p 1 action flow 1 meter 1 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 1 g G y Y r R +p 1 action flow 1 meter 2 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 2 g G y Y r R +p 1 action flow 1 meter 3 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 3 g G y Y r R +p 1 action flow 1 port 1 + +p 1 action flow 2 m
[dpdk-dev] [PATCH v3 6/7] examples/ip_pipeline: modifies routing pipeline CLI
Several routing commands are merged into two commands: route and arp - these two commands are handled by cli library. Rest of the commands are handled internaly by the pipeline code. Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config/l2fwd.cfg|5 +- examples/ip_pipeline/config/l3fwd.cfg|9 +- examples/ip_pipeline/config/l3fwd.sh | 32 +- examples/ip_pipeline/config/l3fwd_arp.cfg| 70 + examples/ip_pipeline/config/l3fwd_arp.sh | 43 + examples/ip_pipeline/pipeline/pipeline_routing.c | 1636 ++ 6 files changed, 551 insertions(+), 1244 deletions(-) create mode 100644 examples/ip_pipeline/config/l3fwd_arp.cfg create mode 100644 examples/ip_pipeline/config/l3fwd_arp.sh diff --git a/examples/ip_pipeline/config/l2fwd.cfg b/examples/ip_pipeline/config/l2fwd.cfg index c743a14..a1df9e6 100644 --- a/examples/ip_pipeline/config/l2fwd.cfg +++ b/examples/ip_pipeline/config/l2fwd.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -44,6 +44,9 @@ ;|| ; +[EAL] +log_level = 0 + [PIPELINE0] type = MASTER core = 0 diff --git a/examples/ip_pipeline/config/l3fwd.cfg b/examples/ip_pipeline/config/l3fwd.cfg index 5449dc3..02c8f36 100644 --- a/examples/ip_pipeline/config/l3fwd.cfg +++ b/examples/ip_pipeline/config/l3fwd.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -50,6 +50,9 @@ ; 2Ethernet header 256 14 ; 3IPv4 header 270 20 +[EAL] +log_level = 0 + [PIPELINE0] type = MASTER core = 0 @@ -59,5 +62,7 @@ type = ROUTING core = 1 pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 SINK0 -encap = ethernet; encap = ethernet / ethernet_qinq / ethernet_mpls +encap = ethernet +;encap = ethernet_qinq +;encap = ethernet_mpls ip_hdr_offset = 270 diff --git a/examples/ip_pipeline/config/l3fwd.sh b/examples/ip_pipeline/config/l3fwd.sh index 2774010..47406aa 100644 --- a/examples/ip_pipeline/config/l3fwd.sh +++ b/examples/ip_pipeline/config/l3fwd.sh @@ -1,9 +1,33 @@ +# +# run ./config/l3fwd.sh +# + # Routing: encap = ethernet, arp = off p 1 route add default 4 #SINK0 -p 1 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 -p 1 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 -p 1 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 -p 1 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 +p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 +p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 +p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 +p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 p 1 route ls + + +# Routing: encap = ethernet_qinq, arp = off + +#p 1 route add default 4 #SINK0 +#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 1000 2000 +#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 1001 2001 +#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 1002 2002 +#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 1003 2003 +#p 1 route ls + + +# Routing: encap = ethernet_mpls, arp = off + +#p 1 route add default 4 #SINK0 +#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 mpls 1000:2000 +#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 mpls 1001:2001 +#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 mpls 1002:2002 +#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 mpls 1003:2003 +#p 1 route ls diff --git a/examples/ip_pipeline/config/l3fwd_arp.cfg b/examples/ip_pipeline/config/l3fwd_arp.cfg new file mode 100644 index 000..2c63c8f --- /dev/null +++ b/examples/ip_pipeline/config/l3fwd_arp.cfg @@ -0,0 +1,70 @@ +; BSD LICENSE +; +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; * Redistributions of source code
[dpdk-dev] [PATCH v3 7/7] examples/ip_pipeline: update edge router usecase
Update edge router usecase config files to use bulk commands. Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- .../ip_pipeline/config/edge_router_downstream.cfg | 30 +++- .../ip_pipeline/config/edge_router_downstream.sh |7 ++-- .../ip_pipeline/config/edge_router_upstream.cfg| 36 +-- .../ip_pipeline/config/edge_router_upstream.sh | 37 +--- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/examples/ip_pipeline/config/edge_router_downstream.cfg b/examples/ip_pipeline/config/edge_router_downstream.cfg index 85bbab8..c6b4e1f 100644 --- a/examples/ip_pipeline/config/edge_router_downstream.cfg +++ b/examples/ip_pipeline/config/edge_router_downstream.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -36,9 +36,9 @@ ; network) contains the following functional blocks: Packet RX & Routing, ; Traffic management and Packet TX. The input packets are assumed to be ; IPv4, while the output packets are Q-in-Q IPv4. - +; ; A simple implementation for this functional pipeline is presented below. - +; ; Packet Rx &Traffic Management Packet Tx ; Routing(Pass-Through) (Pass-Through) ; _ SWQ0 __ SWQ4 _ @@ -50,11 +50,23 @@ ;| | SWQ3 | | SWQ7 | | ; RXQ3.0 --->| |->| |->| |---> TXQ3.0 ;|_| |__| |_| -; | _|_ ^ _|_ ^ _|_ ^ _|_ ^ -; ||___|||___|||___|||___|| -; +--> SINK0 |___|||___|||___|||___|| -; (route miss)|__| |__| |__| |__| -; TM0 TM1 TM2 TM3 +; | | ^ | ^ | ^ | ^ +; | |__| |__| |__| |__| +; +--> SINK0 TM0 TM1 TM2 TM3 +; (Default) +; +; Input packet: Ethernet/IPv4 +; Output packet: Ethernet/QinQ/IPv4 +; +; Packet buffer layout: +; #Field Name Offset (Bytes) Size (Bytes) +; 0Mbuf0 128 +; 1Headroom128 128 +; 2Ethernet header 256 14 +; 3IPv4 header 270 20 + +[EAL] +log_level = 0 [PIPELINE0] type = MASTER @@ -67,7 +79,7 @@ pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 pktq_out = SWQ0 SWQ1 SWQ2 SWQ3 SINK0 encap = ethernet_qinq qinq_sched = test -ip_hdr_offset = 270; mbuf (128) + headroom (128) + ethernet header (14) = 270 +ip_hdr_offset = 270 [PIPELINE2] type = PASS-THROUGH diff --git a/examples/ip_pipeline/config/edge_router_downstream.sh b/examples/ip_pipeline/config/edge_router_downstream.sh index ce46beb..67c3a0d 100644 --- a/examples/ip_pipeline/config/edge_router_downstream.sh +++ b/examples/ip_pipeline/config/edge_router_downstream.sh @@ -1,3 +1,7 @@ +# +# run ./config/edge_router_downstream.sh +# + # Routing: Ether QinQ, ARP off @@ -6,5 +10,4 @@ p 1 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 256 257 p 1 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 258 259 p 1 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 260 261 p 1 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 262 263 - -p 1 route ls +#p 1 route ls diff --git a/examples/ip_pipeline/config/edge_router_upstream.cfg b/examples/ip_pipeline/config/edge_router_upstream.cfg index a08c5cc..dea42b9 100644 --- a/examples/ip_pipeline/config/edge_router_upstream.cfg +++ b/examples/ip_pipeline/config/edge_router_upstream.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -29,6 +29,7 @@ ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ; An edge router typically sits between two networks such as the provider ; core network and the provider access network. A typical packet processing ; pipeline for the upstream
[dpdk-dev] [PATCH v3 1/1] ip_pipeline: added dynamic pipeline reconfiguration
Up till now pipeline was bound to thread selected in the initial config. This patch allows binding pipeline to other threads at runtime using CLI commands. v2 changes: - deleted debug printfs v3 changes: - add timer for thread message request - fix bug that the new functionality can't work - fix leaking memory - cleaning up Signed-off-by: Maciej Gajdzica Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/Makefile |1 + examples/ip_pipeline/app.h | 12 + examples/ip_pipeline/config_parse.c|2 +- examples/ip_pipeline/init.c| 24 ++ examples/ip_pipeline/pipeline.h|6 + examples/ip_pipeline/pipeline/pipeline_common_fe.h |3 + examples/ip_pipeline/thread.c | 157 - examples/ip_pipeline/thread.h | 84 + examples/ip_pipeline/thread_fe.c | 344 examples/ip_pipeline/thread_fe.h | 95 ++ 10 files changed, 720 insertions(+), 8 deletions(-) create mode 100644 examples/ip_pipeline/thread.h create mode 100644 examples/ip_pipeline/thread_fe.c create mode 100644 examples/ip_pipeline/thread_fe.h diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile index f3ff1ec..c8e80b5 100644 --- a/examples/ip_pipeline/Makefile +++ b/examples/ip_pipeline/Makefile @@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread.c +SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread_fe.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_be.c diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..3a57956 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -220,9 +220,11 @@ struct app_pipeline_data { void *be; void *fe; uint64_t timer_period; + uint32_t enabled; }; struct app_thread_pipeline_data { + uint32_t pipeline_id; void *be; pipeline_be_op_run f_run; pipeline_be_op_timer f_timer; @@ -234,6 +236,10 @@ struct app_thread_pipeline_data { #define APP_MAX_THREAD_PIPELINES 16 #endif +#ifndef APP_THREAD_TIMER_PERIOD +#define APP_THREAD_TIMER_PERIOD 1 +#endif + struct app_thread_data { struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES]; struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES]; @@ -241,7 +247,13 @@ struct app_thread_data { uint32_t n_regular; uint32_t n_custom; + uint64_t timer_period; + uint64_t thread_req_deadline; + uint64_t deadline; + + struct rte_ring *msgq_in; + struct rte_ring *msgq_out; }; struct app_eal_params { diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index c9b78f9..d2aaadf 100644 --- a/examples/ip_pipeline/config_parse.c +++ b/examples/ip_pipeline/config_parse.c @@ -362,7 +362,7 @@ parser_read_uint32(uint32_t *value, const char *p) return 0; } -static int +int parse_pipeline_core(uint32_t *socket, uint32_t *core, uint32_t *ht, diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 3f9c68d..8c63879 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -50,6 +50,7 @@ #include "pipeline_firewall.h" #include "pipeline_flow_classification.h" #include "pipeline_routing.h" +#include "thread_fe.h" #define APP_NAME_SIZE 32 @@ -1253,6 +1254,25 @@ app_init_threads(struct app_params *app) t = >thread_data[lcore_id]; + t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) / 1000; + t->thread_req_deadline = time + t->timer_period; + + t->msgq_in = app_thread_msgq_in_get(app, + params->socket_id, + params->core_id, + params->hyper_th_id); + if (t->msgq_in == NULL) + rte_panic("Init error: Cannot find MSGQ_IN for thread %" PRId32, + lcore_id); + + t->msgq_out = app_thread_msgq_out_get(app, + params->socket_id, + params->core_id, + params->hyper_th_id); + if (t->msgq_out == NULL) + rte_panic("Init error: Cannot find MSGQ_OUT for thread %" PRId32, + lcore_id); + ptype = app_pipeline_type_find(app, params->type); if (ptype == NULL)
[dpdk-dev] [PATCH v3 0/3] ip_pipeline: add MP/MC and frag/ras support to SWQs
This patch set enhancement ip_pipeline application: - librte_port: add support for multi-producer/multi-consumer ring ports - librte_port: bug fixes for ring ports with IPv4/IPv6 reassembly support - ip_pipeline application: integrate MP/MC and fragmentation/reassembly support to SWQs v2 changes: - rte_port_ring: - fixed checkpatch errors - interlace the implementation of multi into the implementation of single - reduced the amount of code duplication v3 changes: - new functions added in the .map - add a "Fixes:" tag in commit comment Acked-by: Cristian Dumitrescu Piotr Azarewicz (3): port: add mp/mc ring ports port: fix ras ring ports examples/ip_pipeline: add mp/mc and frag/ras swq examples/ip_pipeline/app.h | 14 ++ examples/ip_pipeline/config_check.c | 45 - examples/ip_pipeline/config_parse.c | 195 +++-- examples/ip_pipeline/init.c | 165 +++--- examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 ++ lib/librte_port/rte_port_ras.c |8 +- lib/librte_port/rte_port_ring.c | 311 +++--- lib/librte_port/rte_port_ring.h | 35 +++- lib/librte_port/rte_port_version.map |9 + 10 files changed, 733 insertions(+), 71 deletions(-) -- 1.7.9.5
[dpdk-dev] [PATCH v3 1/3] port: add mp/mc ring ports
ring_multi_reader input port (on top of multi consumer rte_ring) ring_multi_writer output port (on top of multi producer rte_ring) Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_ring.c | 311 +++--- lib/librte_port/rte_port_ring.h | 35 +++- lib/librte_port/rte_port_version.map |9 + 3 files changed, 325 insertions(+), 30 deletions(-) diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c index 9461c05..755dfc1 100644 --- a/lib/librte_port/rte_port_ring.c +++ b/lib/librte_port/rte_port_ring.c @@ -63,15 +63,19 @@ struct rte_port_ring_reader { }; static void * -rte_port_ring_reader_create(void *params, int socket_id) +rte_port_ring_reader_create_internal(void *params, int socket_id, + uint32_t is_multi) { struct rte_port_ring_reader_params *conf = (struct rte_port_ring_reader_params *) params; struct rte_port_ring_reader *port; /* Check input parameters */ - if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + if ((conf == NULL) || + (conf->ring == NULL) || + (conf->ring->cons.sc_dequeue && is_multi) || + (!(conf->ring->cons.sc_dequeue) && !is_multi)) { + RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; } @@ -89,6 +93,18 @@ rte_port_ring_reader_create(void *params, int socket_id) return port; } +static void * +rte_port_ring_reader_create(void *params, int socket_id) +{ + return rte_port_ring_reader_create_internal(params, socket_id, 0); +} + +static void * +rte_port_ring_multi_reader_create(void *params, int socket_id) +{ + return rte_port_ring_reader_create_internal(params, socket_id, 1); +} + static int rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { @@ -102,6 +118,19 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) } static int +rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts, + uint32_t n_pkts) +{ + struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port; + uint32_t nb_rx; + + nb_rx = rte_ring_mc_dequeue_burst(p->ring, (void **) pkts, n_pkts); + RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); + + return nb_rx; +} + +static int rte_port_ring_reader_free(void *port) { if (port == NULL) { @@ -155,10 +184,12 @@ struct rte_port_ring_writer { uint32_t tx_burst_sz; uint32_t tx_buf_count; uint64_t bsz_mask; + uint32_t is_multi; }; static void * -rte_port_ring_writer_create(void *params, int socket_id) +rte_port_ring_writer_create_internal(void *params, int socket_id, + uint32_t is_multi) { struct rte_port_ring_writer_params *conf = (struct rte_port_ring_writer_params *) params; @@ -166,7 +197,9 @@ rte_port_ring_writer_create(void *params, int socket_id) /* Check input parameters */ if ((conf == NULL) || - (conf->ring == NULL) || + (conf->ring == NULL) || + (conf->ring->prod.sp_enqueue && is_multi) || + (!(conf->ring->prod.sp_enqueue) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; @@ -185,10 +218,23 @@ rte_port_ring_writer_create(void *params, int socket_id) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); + port->is_multi = is_multi; return port; } +static void * +rte_port_ring_writer_create(void *params, int socket_id) +{ + return rte_port_ring_writer_create_internal(params, socket_id, 0); +} + +static void * +rte_port_ring_multi_writer_create(void *params, int socket_id) +{ + return rte_port_ring_writer_create_internal(params, socket_id, 1); +} + static inline void send_burst(struct rte_port_ring_writer *p) { @@ -204,6 +250,21 @@ send_burst(struct rte_port_ring_writer *p) p->tx_buf_count = 0; } +static inline void +send_burst_mp(struct rte_port_ring_writer *p) +{ + uint32_t nb_tx; + + nb_tx = rte_ring_mp_enqueue_burst(p->ring, (void **)p->tx_buf, + p->tx_buf_count); + + RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); + for ( ; nb_tx < p->tx_buf_count; nb_tx++) + rte_pktmbuf_free(p->tx_buf[nb_tx]); + + p->tx_buf_count = 0; +} + static int rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) { @@ -218,9 +279,23 @@ rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) } static int -rt
[dpdk-dev] [PATCH v3 2/3] port: fix ras ring ports
Bug fixes for ring ports with IPv4/IPv6 reassembly support. Previous implementation can't work properly due to incorrect choosing process function. Also, assuming that, when processing ip packet, ip header is know we can set l3_len parameter here. Fixes: 50f54a84dfb7 ("port: add IPv6 reassembly port") Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_ras.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index 6bd0f8c..e45d450 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -144,7 +144,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; - port->f_ras = (is_ipv4 == 0) ? process_ipv4 : process_ipv6; + port->f_ras = (is_ipv4 == 1) ? process_ipv4 : process_ipv6; return port; } @@ -182,7 +182,7 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) /* Assume there is no ethernet header */ struct ipv4_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv4_hdr *); - /* Get "Do not fragment" flag and fragment offset */ + /* Get "More fragments" flag and fragment offset */ uint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset); uint16_t frag_offset = (uint16_t)(frag_field & IPV4_HDR_OFFSET_MASK); uint16_t frag_flag = (uint16_t)(frag_field & IPV4_HDR_MF_FLAG); @@ -195,6 +195,8 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr); + /* Process this fragment */ mo = rte_ipv4_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr); @@ -224,6 +226,8 @@ process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr) + sizeof(*frag_hdr); + /* Process this fragment */ mo = rte_ipv6_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr, frag_hdr); -- 1.7.9.5
[dpdk-dev] [PATCH v3 3/3] examples/ip_pipeline: add mp/mc and frag/ras swq
Add integrated MP/MC and fragmentation/reassembly support to SWQs Signed-off-by: Piotr Azarewicz --- examples/ip_pipeline/app.h | 14 +++ examples/ip_pipeline/config_check.c | 45 +++- examples/ip_pipeline/config_parse.c | 195 +-- examples/ip_pipeline/init.c | 165 - examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 6 files changed, 402 insertions(+), 39 deletions(-) diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..943466e 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -107,6 +107,14 @@ struct app_pktq_swq_params { uint32_t dropless; uint64_t n_retries; uint32_t cpu_socket_id; + uint32_t ipv4_frag; + uint32_t ipv6_frag; + uint32_t ipv4_ras; + uint32_t ipv6_ras; + uint32_t mtu; + uint32_t metadata_size; + uint32_t mempool_direct_id; + uint32_t mempool_indirect_id; }; #ifndef APP_FILE_NAME_SIZE @@ -405,6 +413,10 @@ struct app_params { char app_name[APP_APPNAME_SIZE]; const char *config_file; const char *script_file; + const char *parser_file; + const char *output_file; + const char *preproc; + const char *preproc_args; uint64_t port_mask; uint32_t log_level; @@ -880,6 +892,8 @@ int app_config_init(struct app_params *app); int app_config_args(struct app_params *app, int argc, char **argv); +int app_config_preproc(struct app_params *app); + int app_config_parse(struct app_params *app, const char *file_name); diff --git a/examples/ip_pipeline/config_check.c b/examples/ip_pipeline/config_check.c index 07f4c8b..8052bc4 100644 --- a/examples/ip_pipeline/config_check.c +++ b/examples/ip_pipeline/config_check.c @@ -33,6 +33,8 @@ #include +#include + #include "app.h" static void @@ -193,6 +195,7 @@ check_swqs(struct app_params *app) struct app_pktq_swq_params *p = >swq_params[i]; uint32_t n_readers = app_swq_get_readers(app, p); uint32_t n_writers = app_swq_get_writers(app, p); + uint32_t n_flags; APP_CHECK((p->size > 0), "%s size is 0\n", p->name); @@ -217,14 +220,48 @@ check_swqs(struct app_params *app) APP_CHECK((n_readers != 0), "%s has no reader\n", p->name); - APP_CHECK((n_readers == 1), - "%s has more than one reader\n", p->name); + if (n_readers > 1) + APP_LOG(app, LOW, "%s has more than one reader", p->name); APP_CHECK((n_writers != 0), "%s has no writer\n", p->name); - APP_CHECK((n_writers == 1), - "%s has more than one writer\n", p->name); + if (n_writers > 1) + APP_LOG(app, LOW, "%s has more than one writer", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((n_flags < 2), + "%s has more than one fragmentation or reassembly mode enabled\n", + p->name); + + APP_CHECK((!((n_readers > 1) && (n_flags == 1))), + "%s has more than one reader when fragmentation or reassembly" + " mode enabled\n", + p->name); + + APP_CHECK((!((n_writers > 1) && (n_flags == 1))), + "%s has more than one writer when fragmentation or reassembly" + " mode enabled\n", + p->name); + + n_flags = p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((!((p->dropless == 1) && (n_flags == 1))), + "%s has dropless when reassembly mode enabled\n", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag; + + if (n_flags == 1) { + uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) : + sizeof(struct ipv6_hdr); + + APP_CHECK((p->mtu > ip_hdr_size), + "%s mtu size is smaller than ip header\n", p->name); + + APP_CHECK((!((p->mtu - ip_hdr_size) % 8)), + "%s mtu size is incorrect\n", p->name); + } } } diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index c9b78f9..a35bd3e 100644 --- a/examples/ip_pipeline/
[dpdk-dev] [PATCH v4 0/3] ip_pipeline: add MP/MC and frag/ras support to SWQs
This patch set enhancement ip_pipeline application: - librte_port: add support for multi-producer/multi-consumer ring ports - librte_port: bug fixes for ring ports with IPv4/IPv6 reassembly support - ip_pipeline application: integrate MP/MC and fragmentation/reassembly support to SWQs v2 changes: - rte_port_ring: - fixed checkpatch errors - interlace the implementation of multi into the implementation of single - reduced the amount of code duplication v3 changes: - new functions added in the .map - add a "Fixes:" tag in commit comment v4 changes: - fix usage RTE_MBUF_METADATA_* macros Acked-by: Cristian Dumitrescu Piotr Azarewicz (3): port: add mp/mc ring ports port: fix ras/frag ring ports examples/ip_pipeline: add mp/mc and frag/ras swq examples/ip_pipeline/app.h | 14 ++ examples/ip_pipeline/config_check.c | 45 - examples/ip_pipeline/config_parse.c | 195 +++-- examples/ip_pipeline/init.c | 165 +++--- examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 ++ lib/librte_port/rte_port_frag.c |5 +- lib/librte_port/rte_port_ras.c |8 +- lib/librte_port/rte_port_ring.c | 311 +++--- lib/librte_port/rte_port_ring.h | 35 +++- lib/librte_port/rte_port_version.map |9 + 11 files changed, 736 insertions(+), 73 deletions(-) -- 1.7.9.5
[dpdk-dev] [PATCH v4 1/3] port: add mp/mc ring ports
ring_multi_reader input port (on top of multi consumer rte_ring) ring_multi_writer output port (on top of multi producer rte_ring) Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_ring.c | 311 +++--- lib/librte_port/rte_port_ring.h | 35 +++- lib/librte_port/rte_port_version.map |9 + 3 files changed, 325 insertions(+), 30 deletions(-) diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c index 9461c05..755dfc1 100644 --- a/lib/librte_port/rte_port_ring.c +++ b/lib/librte_port/rte_port_ring.c @@ -63,15 +63,19 @@ struct rte_port_ring_reader { }; static void * -rte_port_ring_reader_create(void *params, int socket_id) +rte_port_ring_reader_create_internal(void *params, int socket_id, + uint32_t is_multi) { struct rte_port_ring_reader_params *conf = (struct rte_port_ring_reader_params *) params; struct rte_port_ring_reader *port; /* Check input parameters */ - if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + if ((conf == NULL) || + (conf->ring == NULL) || + (conf->ring->cons.sc_dequeue && is_multi) || + (!(conf->ring->cons.sc_dequeue) && !is_multi)) { + RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; } @@ -89,6 +93,18 @@ rte_port_ring_reader_create(void *params, int socket_id) return port; } +static void * +rte_port_ring_reader_create(void *params, int socket_id) +{ + return rte_port_ring_reader_create_internal(params, socket_id, 0); +} + +static void * +rte_port_ring_multi_reader_create(void *params, int socket_id) +{ + return rte_port_ring_reader_create_internal(params, socket_id, 1); +} + static int rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { @@ -102,6 +118,19 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) } static int +rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts, + uint32_t n_pkts) +{ + struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port; + uint32_t nb_rx; + + nb_rx = rte_ring_mc_dequeue_burst(p->ring, (void **) pkts, n_pkts); + RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); + + return nb_rx; +} + +static int rte_port_ring_reader_free(void *port) { if (port == NULL) { @@ -155,10 +184,12 @@ struct rte_port_ring_writer { uint32_t tx_burst_sz; uint32_t tx_buf_count; uint64_t bsz_mask; + uint32_t is_multi; }; static void * -rte_port_ring_writer_create(void *params, int socket_id) +rte_port_ring_writer_create_internal(void *params, int socket_id, + uint32_t is_multi) { struct rte_port_ring_writer_params *conf = (struct rte_port_ring_writer_params *) params; @@ -166,7 +197,9 @@ rte_port_ring_writer_create(void *params, int socket_id) /* Check input parameters */ if ((conf == NULL) || - (conf->ring == NULL) || + (conf->ring == NULL) || + (conf->ring->prod.sp_enqueue && is_multi) || + (!(conf->ring->prod.sp_enqueue) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; @@ -185,10 +218,23 @@ rte_port_ring_writer_create(void *params, int socket_id) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); + port->is_multi = is_multi; return port; } +static void * +rte_port_ring_writer_create(void *params, int socket_id) +{ + return rte_port_ring_writer_create_internal(params, socket_id, 0); +} + +static void * +rte_port_ring_multi_writer_create(void *params, int socket_id) +{ + return rte_port_ring_writer_create_internal(params, socket_id, 1); +} + static inline void send_burst(struct rte_port_ring_writer *p) { @@ -204,6 +250,21 @@ send_burst(struct rte_port_ring_writer *p) p->tx_buf_count = 0; } +static inline void +send_burst_mp(struct rte_port_ring_writer *p) +{ + uint32_t nb_tx; + + nb_tx = rte_ring_mp_enqueue_burst(p->ring, (void **)p->tx_buf, + p->tx_buf_count); + + RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); + for ( ; nb_tx < p->tx_buf_count; nb_tx++) + rte_pktmbuf_free(p->tx_buf[nb_tx]); + + p->tx_buf_count = 0; +} + static int rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) { @@ -218,9 +279,23 @@ rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) } static int -rt
[dpdk-dev] [PATCH v4 2/3] port: fix ras/frag ring ports
Bug fixes for ring ports with IPv4/IPv6 reassembly support. Previous implementation can't work properly due to incorrect choosing process function. Also, assuming that, when processing ip packet, ip header is know we can set l3_len parameter here. Fix usage RTE_MBUF_METADATA_* macros due to redefinition the macros. Fixes: 50f54a84dfb7 ("port: add IPv6 reassembly port") Fixes: ba92d511ddac ("port: move metadata offset reference at mbuf head") Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_frag.c |5 +++-- lib/librte_port/rte_port_ras.c |8 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/librte_port/rte_port_frag.c b/lib/librte_port/rte_port_frag.c index 3720d5d..0fcace9 100644 --- a/lib/librte_port/rte_port_frag.c +++ b/lib/librte_port/rte_port_frag.c @@ -229,9 +229,10 @@ rte_port_ring_reader_frag_rx(void *port, /* Copy meta-data from input jumbo packet to its fragments */ for (i = 0; i < p->n_frags; i++) { - uint8_t *src = RTE_MBUF_METADATA_UINT8_PTR(pkt, 0); + uint8_t *src = + RTE_MBUF_METADATA_UINT8_PTR(pkt, sizeof(struct rte_mbuf)); uint8_t *dst = - RTE_MBUF_METADATA_UINT8_PTR(p->frags[i], 0); + RTE_MBUF_METADATA_UINT8_PTR(p->frags[i], sizeof(struct rte_mbuf)); memcpy(dst, src, p->metadata_size); } diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index 8a2e554..c4bb508 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -144,7 +144,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; - port->f_ras = (is_ipv4 == 0) ? process_ipv4 : process_ipv6; + port->f_ras = (is_ipv4 == 1) ? process_ipv4 : process_ipv6; return port; } @@ -182,7 +182,7 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) /* Assume there is no ethernet header */ struct ipv4_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv4_hdr *); - /* Get "Do not fragment" flag and fragment offset */ + /* Get "More fragments" flag and fragment offset */ uint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset); uint16_t frag_offset = (uint16_t)(frag_field & IPV4_HDR_OFFSET_MASK); uint16_t frag_flag = (uint16_t)(frag_field & IPV4_HDR_MF_FLAG); @@ -195,6 +195,8 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr); + /* Process this fragment */ mo = rte_ipv4_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr); @@ -225,6 +227,8 @@ process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr) + sizeof(*frag_hdr); + /* Process this fragment */ mo = rte_ipv6_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr, frag_hdr); -- 1.7.9.5
[dpdk-dev] [PATCH v4 3/3] examples/ip_pipeline: add mp/mc and frag/ras swq
Add integrated MP/MC and fragmentation/reassembly support to SWQs Signed-off-by: Piotr Azarewicz --- examples/ip_pipeline/app.h | 14 +++ examples/ip_pipeline/config_check.c | 45 +++- examples/ip_pipeline/config_parse.c | 195 +-- examples/ip_pipeline/init.c | 165 - examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 6 files changed, 402 insertions(+), 39 deletions(-) diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..943466e 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -107,6 +107,14 @@ struct app_pktq_swq_params { uint32_t dropless; uint64_t n_retries; uint32_t cpu_socket_id; + uint32_t ipv4_frag; + uint32_t ipv6_frag; + uint32_t ipv4_ras; + uint32_t ipv6_ras; + uint32_t mtu; + uint32_t metadata_size; + uint32_t mempool_direct_id; + uint32_t mempool_indirect_id; }; #ifndef APP_FILE_NAME_SIZE @@ -405,6 +413,10 @@ struct app_params { char app_name[APP_APPNAME_SIZE]; const char *config_file; const char *script_file; + const char *parser_file; + const char *output_file; + const char *preproc; + const char *preproc_args; uint64_t port_mask; uint32_t log_level; @@ -880,6 +892,8 @@ int app_config_init(struct app_params *app); int app_config_args(struct app_params *app, int argc, char **argv); +int app_config_preproc(struct app_params *app); + int app_config_parse(struct app_params *app, const char *file_name); diff --git a/examples/ip_pipeline/config_check.c b/examples/ip_pipeline/config_check.c index 07f4c8b..8052bc4 100644 --- a/examples/ip_pipeline/config_check.c +++ b/examples/ip_pipeline/config_check.c @@ -33,6 +33,8 @@ #include +#include + #include "app.h" static void @@ -193,6 +195,7 @@ check_swqs(struct app_params *app) struct app_pktq_swq_params *p = >swq_params[i]; uint32_t n_readers = app_swq_get_readers(app, p); uint32_t n_writers = app_swq_get_writers(app, p); + uint32_t n_flags; APP_CHECK((p->size > 0), "%s size is 0\n", p->name); @@ -217,14 +220,48 @@ check_swqs(struct app_params *app) APP_CHECK((n_readers != 0), "%s has no reader\n", p->name); - APP_CHECK((n_readers == 1), - "%s has more than one reader\n", p->name); + if (n_readers > 1) + APP_LOG(app, LOW, "%s has more than one reader", p->name); APP_CHECK((n_writers != 0), "%s has no writer\n", p->name); - APP_CHECK((n_writers == 1), - "%s has more than one writer\n", p->name); + if (n_writers > 1) + APP_LOG(app, LOW, "%s has more than one writer", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((n_flags < 2), + "%s has more than one fragmentation or reassembly mode enabled\n", + p->name); + + APP_CHECK((!((n_readers > 1) && (n_flags == 1))), + "%s has more than one reader when fragmentation or reassembly" + " mode enabled\n", + p->name); + + APP_CHECK((!((n_writers > 1) && (n_flags == 1))), + "%s has more than one writer when fragmentation or reassembly" + " mode enabled\n", + p->name); + + n_flags = p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((!((p->dropless == 1) && (n_flags == 1))), + "%s has dropless when reassembly mode enabled\n", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag; + + if (n_flags == 1) { + uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) : + sizeof(struct ipv6_hdr); + + APP_CHECK((p->mtu > ip_hdr_size), + "%s mtu size is smaller than ip header\n", p->name); + + APP_CHECK((!((p->mtu - ip_hdr_size) % 8)), + "%s mtu size is incorrect\n", p->name); + } } } diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index c9b78f9..a35bd3e 100644 --- a/examples/ip_pipeline/
[dpdk-dev] [PATCH v4 1/1] ip_pipeline: added dynamic pipeline reconfiguration
Up till now pipeline was bound to thread selected in the initial config. This patch allows binding pipeline to other threads at runtime using CLI commands. v2 changes: - deleted debug printfs v3 changes: - add timer for thread message request - fix bug that the new functionality can't work - fix leaking memory - cleaning up v4 changes: - fix compilation with gcc 5.1 - add proper checking if thread exist Signed-off-by: Maciej Gajdzica Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/Makefile |1 + examples/ip_pipeline/app.h | 12 + examples/ip_pipeline/config_parse.c|2 +- examples/ip_pipeline/init.c| 24 ++ examples/ip_pipeline/pipeline.h|6 + examples/ip_pipeline/pipeline/pipeline_common_fe.h |3 + examples/ip_pipeline/thread.c | 153 - examples/ip_pipeline/thread.h | 84 + examples/ip_pipeline/thread_fe.c | 350 examples/ip_pipeline/thread_fe.h | 95 ++ 10 files changed, 728 insertions(+), 2 deletions(-) create mode 100644 examples/ip_pipeline/thread.h create mode 100644 examples/ip_pipeline/thread_fe.c create mode 100644 examples/ip_pipeline/thread_fe.h diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile index f3ff1ec..c8e80b5 100644 --- a/examples/ip_pipeline/Makefile +++ b/examples/ip_pipeline/Makefile @@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread.c +SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread_fe.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_be.c diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..3a57956 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -220,9 +220,11 @@ struct app_pipeline_data { void *be; void *fe; uint64_t timer_period; + uint32_t enabled; }; struct app_thread_pipeline_data { + uint32_t pipeline_id; void *be; pipeline_be_op_run f_run; pipeline_be_op_timer f_timer; @@ -234,6 +236,10 @@ struct app_thread_pipeline_data { #define APP_MAX_THREAD_PIPELINES 16 #endif +#ifndef APP_THREAD_TIMER_PERIOD +#define APP_THREAD_TIMER_PERIOD 1 +#endif + struct app_thread_data { struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES]; struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES]; @@ -241,7 +247,13 @@ struct app_thread_data { uint32_t n_regular; uint32_t n_custom; + uint64_t timer_period; + uint64_t thread_req_deadline; + uint64_t deadline; + + struct rte_ring *msgq_in; + struct rte_ring *msgq_out; }; struct app_eal_params { diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index c9b78f9..d2aaadf 100644 --- a/examples/ip_pipeline/config_parse.c +++ b/examples/ip_pipeline/config_parse.c @@ -362,7 +362,7 @@ parser_read_uint32(uint32_t *value, const char *p) return 0; } -static int +int parse_pipeline_core(uint32_t *socket, uint32_t *core, uint32_t *ht, diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 3f9c68d..8c63879 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -50,6 +50,7 @@ #include "pipeline_firewall.h" #include "pipeline_flow_classification.h" #include "pipeline_routing.h" +#include "thread_fe.h" #define APP_NAME_SIZE 32 @@ -1253,6 +1254,25 @@ app_init_threads(struct app_params *app) t = >thread_data[lcore_id]; + t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) / 1000; + t->thread_req_deadline = time + t->timer_period; + + t->msgq_in = app_thread_msgq_in_get(app, + params->socket_id, + params->core_id, + params->hyper_th_id); + if (t->msgq_in == NULL) + rte_panic("Init error: Cannot find MSGQ_IN for thread %" PRId32, + lcore_id); + + t->msgq_out = app_thread_msgq_out_get(app, + params->socket_id, + params->core_id, + params->hyper_th_id); + if (t->msgq_out == NULL) + rte_panic("Init error: Cannot find MSGQ_OUT for thread %" PRId32, + lcore_id);
[dpdk-dev] [PATCH v5 1/1] ip_pipeline: added dynamic pipeline reconfiguration
Up till now pipeline was bound to thread selected in the initial config. This patch allows binding pipeline to other threads at runtime using CLI commands. v2 changes: - deleted debug printfs v3 changes: - add timer for thread message request - fix bug that the new functionality can't work - fix leaking memory - cleaning up v4 changes: - fix compilation with gcc 5.1 - add proper checking if thread exist v5 changes: - better approach about v4 changes Signed-off-by: Maciej Gajdzica Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/Makefile |1 + examples/ip_pipeline/app.h | 12 + examples/ip_pipeline/config_parse.c|2 +- examples/ip_pipeline/init.c| 24 ++ examples/ip_pipeline/pipeline.h|6 + examples/ip_pipeline/pipeline/pipeline_common_fe.h |3 + examples/ip_pipeline/thread.c | 156 - examples/ip_pipeline/thread.h | 84 + examples/ip_pipeline/thread_fe.c | 349 examples/ip_pipeline/thread_fe.h | 95 ++ 10 files changed, 728 insertions(+), 4 deletions(-) create mode 100644 examples/ip_pipeline/thread.h create mode 100644 examples/ip_pipeline/thread_fe.c create mode 100644 examples/ip_pipeline/thread_fe.h diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile index f3ff1ec..c8e80b5 100644 --- a/examples/ip_pipeline/Makefile +++ b/examples/ip_pipeline/Makefile @@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread.c +SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread_fe.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_be.c diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..3a57956 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -220,9 +220,11 @@ struct app_pipeline_data { void *be; void *fe; uint64_t timer_period; + uint32_t enabled; }; struct app_thread_pipeline_data { + uint32_t pipeline_id; void *be; pipeline_be_op_run f_run; pipeline_be_op_timer f_timer; @@ -234,6 +236,10 @@ struct app_thread_pipeline_data { #define APP_MAX_THREAD_PIPELINES 16 #endif +#ifndef APP_THREAD_TIMER_PERIOD +#define APP_THREAD_TIMER_PERIOD 1 +#endif + struct app_thread_data { struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES]; struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES]; @@ -241,7 +247,13 @@ struct app_thread_data { uint32_t n_regular; uint32_t n_custom; + uint64_t timer_period; + uint64_t thread_req_deadline; + uint64_t deadline; + + struct rte_ring *msgq_in; + struct rte_ring *msgq_out; }; struct app_eal_params { diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index c9b78f9..d2aaadf 100644 --- a/examples/ip_pipeline/config_parse.c +++ b/examples/ip_pipeline/config_parse.c @@ -362,7 +362,7 @@ parser_read_uint32(uint32_t *value, const char *p) return 0; } -static int +int parse_pipeline_core(uint32_t *socket, uint32_t *core, uint32_t *ht, diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index 3f9c68d..8c63879 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -50,6 +50,7 @@ #include "pipeline_firewall.h" #include "pipeline_flow_classification.h" #include "pipeline_routing.h" +#include "thread_fe.h" #define APP_NAME_SIZE 32 @@ -1253,6 +1254,25 @@ app_init_threads(struct app_params *app) t = >thread_data[lcore_id]; + t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) / 1000; + t->thread_req_deadline = time + t->timer_period; + + t->msgq_in = app_thread_msgq_in_get(app, + params->socket_id, + params->core_id, + params->hyper_th_id); + if (t->msgq_in == NULL) + rte_panic("Init error: Cannot find MSGQ_IN for thread %" PRId32, + lcore_id); + + t->msgq_out = app_thread_msgq_out_get(app, + params->socket_id, + params->core_id, + params->hyper_th_id); + if (t->msgq_out == NULL) + rte_panic("Init error: Cannot find MSGQ_OUT for thread %" PRId32, +
[dpdk-dev] [PATCH v2 1/1] ip_frag: fix creating ipv6 fragment extension header
Previous implementation won't work on every environment. The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined. Solution: used bytes instead of bit fields. v2 changes: - remove useless union - fix process_ipv6 function (due to remove the union above) Signed-off-by: Piotr Azarewicz --- lib/librte_ip_frag/rte_ip_frag.h| 13 ++--- lib/librte_ip_frag/rte_ipv6_fragmentation.c |6 ++ lib/librte_port/rte_port_ras.c | 10 +++--- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h index 52f44c9..f3ca566 100644 --- a/lib/librte_ip_frag/rte_ip_frag.h +++ b/lib/librte_ip_frag/rte_ip_frag.h @@ -130,17 +130,8 @@ struct rte_ip_frag_tbl { /** IPv6 fragment extension header */ struct ipv6_extension_fragment { uint8_t next_header;/**< Next header type */ - uint8_t reserved1; /**< Reserved */ - union { - struct { - uint16_t frag_offset:13; /**< Offset from the start of the packet */ - uint16_t reserved2:2; /**< Reserved */ - uint16_t more_frags:1; - /**< 1 if more fragments left, 0 if last fragment */ - }; - uint16_t frag_data; - /**< union of all fragmentation data */ - }; + uint8_t reserved; /**< Reserved */ + uint16_t frag_data; /**< All fragmentation data */ uint32_t id;/**< Packet ID */ } __attribute__((__packed__)); diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c index 0e32aa8..ab62efd 100644 --- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c +++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c @@ -65,10 +65,8 @@ __fill_ipv6hdr_frag(struct ipv6_hdr *dst, fh = (struct ipv6_extension_fragment *) ++dst; fh->next_header = src->proto; - fh->reserved1 = 0; - fh->frag_offset = rte_cpu_to_be_16(fofs); - fh->reserved2 = 0; - fh->more_frags = rte_cpu_to_be_16(mf); + fh->reserved = 0; + fh->frag_data = rte_cpu_to_be_16((fofs & ~IPV6_HDR_FO_MASK) | mf); fh->id = 0; } diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index 6bd0f8c..3dbd5be 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -205,6 +205,9 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) } } +#define MORE_FRAGS(x) ((x) & 0x0001) +#define FRAG_OFFSET(x) ((x) >> 3) + static void process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) { @@ -212,12 +215,13 @@ process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct ipv6_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv6_hdr *); struct ipv6_extension_fragment *frag_hdr; + uint16_t frag_data = 0; frag_hdr = rte_ipv6_frag_get_ipv6_fragment_header(pkt_hdr); - uint16_t frag_offset = frag_hdr->frag_offset; - uint16_t frag_flag = frag_hdr->more_frags; + if (frag_hdr != NULL) + frag_data = rte_be_to_cpu_16(frag_hdr->frag_data); /* If it is a fragmented packet, then try to reassemble */ - if ((frag_flag == 0) && (frag_offset == 0)) + if ((MORE_FRAGS(frag_data) == 0) && (FRAG_OFFSET(frag_data) == 0)) p->tx_buf[p->tx_buf_count++] = pkt; else { struct rte_mbuf *mo; -- 1.7.9.5
[dpdk-dev] [PATCH v3 1/1] ip_frag: fix creating ipv6 fragment extension header
Previous implementation won't work on every environment. The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined. Solution: used bytes instead of bit fields. v2 changes: - remove useless union - fix process_ipv6 function (due to remove the union above) v3 changes: - add macros to read/set fragment_offset and more_flags values Signed-off-by: Piotr Azarewicz --- lib/librte_ip_frag/rte_ip_frag.h| 27 --- lib/librte_ip_frag/rte_ipv6_fragmentation.c | 12 ++-- lib/librte_port/rte_port_ras.c |7 --- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h index 52f44c9..92cedf2 100644 --- a/lib/librte_ip_frag/rte_ip_frag.h +++ b/lib/librte_ip_frag/rte_ip_frag.h @@ -128,19 +128,24 @@ struct rte_ip_frag_tbl { }; /** IPv6 fragment extension header */ +#defineRTE_IPV6_EHDR_MF_SHIFT 0 +#defineRTE_IPV6_EHDR_MF_MASK 1 +#defineRTE_IPV6_EHDR_FO_SHIFT 3 +#defineRTE_IPV6_EHDR_FO_MASK (~((1 << RTE_IPV6_EHDR_FO_SHIFT) - 1)) + +#define RTE_IPV6_FRAG_USED_MASK\ + (RTE_IPV6_EHDR_MF_MASK | RTE_IPV6_EHDR_FO_MASK) + +#define RTE_IPV6_GET_MF(x) ((x) & RTE_IPV6_EHDR_MF_MASK) +#define RTE_IPV6_GET_FO(x) ((x) >> RTE_IPV6_EHDR_FO_SHIFT) + +#define RTE_IPV6_SET_FRAG_DATA(fo, mf) \ + (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) + struct ipv6_extension_fragment { uint8_t next_header;/**< Next header type */ - uint8_t reserved1; /**< Reserved */ - union { - struct { - uint16_t frag_offset:13; /**< Offset from the start of the packet */ - uint16_t reserved2:2; /**< Reserved */ - uint16_t more_frags:1; - /**< 1 if more fragments left, 0 if last fragment */ - }; - uint16_t frag_data; - /**< union of all fragmentation data */ - }; + uint8_t reserved; /**< Reserved */ + uint16_t frag_data; /**< All fragmentation data */ uint32_t id;/**< Packet ID */ } __attribute__((__packed__)); diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c index 0e32aa8..251a4b8 100644 --- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c +++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c @@ -46,12 +46,6 @@ * */ -/* Fragment Extension Header */ -#defineIPV6_HDR_MF_SHIFT 0 -#defineIPV6_HDR_FO_SHIFT 3 -#defineIPV6_HDR_MF_MASK(1 << IPV6_HDR_MF_SHIFT) -#defineIPV6_HDR_FO_MASK((1 << IPV6_HDR_FO_SHIFT) - 1) - static inline void __fill_ipv6hdr_frag(struct ipv6_hdr *dst, const struct ipv6_hdr *src, uint16_t len, uint16_t fofs, @@ -65,10 +59,8 @@ __fill_ipv6hdr_frag(struct ipv6_hdr *dst, fh = (struct ipv6_extension_fragment *) ++dst; fh->next_header = src->proto; - fh->reserved1 = 0; - fh->frag_offset = rte_cpu_to_be_16(fofs); - fh->reserved2 = 0; - fh->more_frags = rte_cpu_to_be_16(mf); + fh->reserved = 0; + fh->frag_data = rte_cpu_to_be_16(RTE_IPV6_SET_FRAG_DATA(fofs, mf)); fh->id = 0; } diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index 6bd0f8c..8a2e554 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -212,12 +212,13 @@ process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct ipv6_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv6_hdr *); struct ipv6_extension_fragment *frag_hdr; + uint16_t frag_data = 0; frag_hdr = rte_ipv6_frag_get_ipv6_fragment_header(pkt_hdr); - uint16_t frag_offset = frag_hdr->frag_offset; - uint16_t frag_flag = frag_hdr->more_frags; + if (frag_hdr != NULL) + frag_data = rte_be_to_cpu_16(frag_hdr->frag_data); /* If it is a fragmented packet, then try to reassemble */ - if ((frag_flag == 0) && (frag_offset == 0)) + if ((frag_data & RTE_IPV6_FRAG_USED_MASK) == 0) p->tx_buf[p->tx_buf_count++] = pkt; else { struct rte_mbuf *mo; -- 1.7.9.5
[dpdk-dev] [PATCH v4 1/1] ip_frag: fix creating ipv6 fragment extension header
Previous implementation won't work on every environment. The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined. Solution: used bytes instead of bit fields. v2 changes: - remove useless union - fix process_ipv6 function (due to remove the union above) v3 changes: - add macros to read/set fragment_offset and more_flags values v4 changes: - two additional fixes due to remove the union and due to changes in macros Signed-off-by: Piotr Azarewicz --- lib/librte_ip_frag/rte_ip_frag.h| 27 --- lib/librte_ip_frag/rte_ipv6_fragmentation.c | 14 +++--- lib/librte_ip_frag/rte_ipv6_reassembly.c|3 ++- lib/librte_port/rte_port_ras.c |7 --- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/lib/librte_ip_frag/rte_ip_frag.h b/lib/librte_ip_frag/rte_ip_frag.h index 52f44c9..92cedf2 100644 --- a/lib/librte_ip_frag/rte_ip_frag.h +++ b/lib/librte_ip_frag/rte_ip_frag.h @@ -128,19 +128,24 @@ struct rte_ip_frag_tbl { }; /** IPv6 fragment extension header */ +#defineRTE_IPV6_EHDR_MF_SHIFT 0 +#defineRTE_IPV6_EHDR_MF_MASK 1 +#defineRTE_IPV6_EHDR_FO_SHIFT 3 +#defineRTE_IPV6_EHDR_FO_MASK (~((1 << RTE_IPV6_EHDR_FO_SHIFT) - 1)) + +#define RTE_IPV6_FRAG_USED_MASK\ + (RTE_IPV6_EHDR_MF_MASK | RTE_IPV6_EHDR_FO_MASK) + +#define RTE_IPV6_GET_MF(x) ((x) & RTE_IPV6_EHDR_MF_MASK) +#define RTE_IPV6_GET_FO(x) ((x) >> RTE_IPV6_EHDR_FO_SHIFT) + +#define RTE_IPV6_SET_FRAG_DATA(fo, mf) \ + (((fo) & RTE_IPV6_EHDR_FO_MASK) | ((mf) & RTE_IPV6_EHDR_MF_MASK)) + struct ipv6_extension_fragment { uint8_t next_header;/**< Next header type */ - uint8_t reserved1; /**< Reserved */ - union { - struct { - uint16_t frag_offset:13; /**< Offset from the start of the packet */ - uint16_t reserved2:2; /**< Reserved */ - uint16_t more_frags:1; - /**< 1 if more fragments left, 0 if last fragment */ - }; - uint16_t frag_data; - /**< union of all fragmentation data */ - }; + uint8_t reserved; /**< Reserved */ + uint16_t frag_data; /**< All fragmentation data */ uint32_t id;/**< Packet ID */ } __attribute__((__packed__)); diff --git a/lib/librte_ip_frag/rte_ipv6_fragmentation.c b/lib/librte_ip_frag/rte_ipv6_fragmentation.c index 0e32aa8..1e30004 100644 --- a/lib/librte_ip_frag/rte_ipv6_fragmentation.c +++ b/lib/librte_ip_frag/rte_ipv6_fragmentation.c @@ -46,12 +46,6 @@ * */ -/* Fragment Extension Header */ -#defineIPV6_HDR_MF_SHIFT 0 -#defineIPV6_HDR_FO_SHIFT 3 -#defineIPV6_HDR_MF_MASK(1 << IPV6_HDR_MF_SHIFT) -#defineIPV6_HDR_FO_MASK((1 << IPV6_HDR_FO_SHIFT) - 1) - static inline void __fill_ipv6hdr_frag(struct ipv6_hdr *dst, const struct ipv6_hdr *src, uint16_t len, uint16_t fofs, @@ -65,10 +59,8 @@ __fill_ipv6hdr_frag(struct ipv6_hdr *dst, fh = (struct ipv6_extension_fragment *) ++dst; fh->next_header = src->proto; - fh->reserved1 = 0; - fh->frag_offset = rte_cpu_to_be_16(fofs); - fh->reserved2 = 0; - fh->more_frags = rte_cpu_to_be_16(mf); + fh->reserved = 0; + fh->frag_data = rte_cpu_to_be_16(RTE_IPV6_SET_FRAG_DATA(fofs, mf)); fh->id = 0; } @@ -118,7 +110,7 @@ rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in, frag_size = (uint16_t)(mtu_size - sizeof(struct ipv6_hdr)); /* Fragment size should be a multiple of 8. */ - IP_FRAG_ASSERT((frag_size & IPV6_HDR_FO_MASK) == 0); + IP_FRAG_ASSERT((frag_size & ~RTE_IPV6_EHDR_FO_MASK) == 0); /* Check that pkts_out is big enough to hold all fragments */ if (unlikely (frag_size * nb_pkts_out < diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_frag/rte_ipv6_reassembly.c index 1f1c172..8b4ef8a 100644 --- a/lib/librte_ip_frag/rte_ipv6_reassembly.c +++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c @@ -181,7 +181,8 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, " "max_entries: %u, use_entries: %u\n\n", __func__, __LINE__, - mb, tms, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs, ip_len, frag_hdr->more_frags, + mb, tms, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs,
[dpdk-dev] [PATCH v1 0/3] ip_pipeline: add MP/MC and frag/ras support to SWQs
This patch set enhancement ip_pipeline application: - librte_port: add support for multi-producer/multi-consumer ring ports - librte_port: bug fixes for ring ports with IPv4/IPv6 reassembly support - ip_pipeline application: integrate MP/MC and fragmentation/reassembly support to SWQs Piotr Azarewicz (3): port: add mp/mc ring ports port: fix ras ring ports examples/ip_pipeline: add mp/mc and frag/ras swq examples/ip_pipeline/app.h | 14 ++ examples/ip_pipeline/config_check.c | 45 +++- examples/ip_pipeline/config_parse.c | 195 - examples/ip_pipeline/init.c | 165 --- examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 ++ lib/librte_port/rte_port_ras.c |8 +- lib/librte_port/rte_port_ring.c | 399 ++- lib/librte_port/rte_port_ring.h | 34 ++- 9 files changed, 832 insertions(+), 50 deletions(-) -- 1.7.9.5
[dpdk-dev] [PATCH v1 1/3] port: add mp/mc ring ports
ring_multi_reader input port (on top of multi consumer rte_ring) ring_multi_writer output port (on top of multi producer rte_ring) Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_ring.c | 399 ++- lib/librte_port/rte_port_ring.h | 34 +++- 2 files changed, 424 insertions(+), 9 deletions(-) diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c index 9461c05..6b06466 100644 --- a/lib/librte_port/rte_port_ring.c +++ b/lib/librte_port/rte_port_ring.c @@ -70,8 +70,10 @@ rte_port_ring_reader_create(void *params, int socket_id) struct rte_port_ring_reader *port; /* Check input parameters */ - if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + if ((conf == NULL) || + (conf->ring == NULL) || + (conf->ring->cons.sc_dequeue != 1)) { + RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; } @@ -166,7 +168,8 @@ rte_port_ring_writer_create(void *params, int socket_id) /* Check input parameters */ if ((conf == NULL) || - (conf->ring == NULL) || + (conf->ring == NULL) || + (conf->ring->prod.sp_enqueue != 1) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; @@ -343,7 +346,8 @@ rte_port_ring_writer_nodrop_create(void *params, int socket_id) /* Check input parameters */ if ((conf == NULL) || - (conf->ring == NULL) || + (conf->ring == NULL) || + (conf->ring->prod.sp_enqueue != 1) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; @@ -448,6 +452,7 @@ rte_port_ring_writer_nodrop_tx_bulk(void *port, */ for (; n_pkts_ok < n_pkts; n_pkts_ok++) { struct rte_mbuf *pkt = pkts[n_pkts_ok]; + p->tx_buf[p->tx_buf_count++] = pkt; } send_burst_nodrop(p); @@ -513,6 +518,367 @@ rte_port_ring_writer_nodrop_stats_read(void *port, } /* + * Port RING Multi Reader + */ +static void * +rte_port_ring_multi_reader_create(void *params, int socket_id) +{ + struct rte_port_ring_multi_reader_params *conf = + (struct rte_port_ring_multi_reader_params *) params; + struct rte_port_ring_reader *port; + + /* Check input parameters */ + if ((conf == NULL) || + (conf->ring == NULL) || + (conf->ring->cons.sc_dequeue != 0)) { + RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + return NULL; + } + + /* Memory allocation */ + port = rte_zmalloc_socket("PORT", sizeof(*port), + RTE_CACHE_LINE_SIZE, socket_id); + if (port == NULL) { + RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__); + return NULL; + } + + /* Initialization */ + port->ring = conf->ring; + + return port; +} + +static int +rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) +{ + struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port; + uint32_t nb_rx; + + nb_rx = rte_ring_mc_dequeue_burst(p->ring, (void **) pkts, n_pkts); + RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); + + return nb_rx; +} + +static int +rte_port_ring_multi_reader_free(void *port) +{ + if (port == NULL) { + RTE_LOG(ERR, PORT, "%s: port is NULL\n", __func__); + return -EINVAL; + } + + rte_free(port); + + return 0; +} + +/* + * Port RING Multi Writer + */ +static void * +rte_port_ring_multi_writer_create(void *params, int socket_id) +{ + struct rte_port_ring_multi_writer_params *conf = + (struct rte_port_ring_multi_writer_params *) params; + struct rte_port_ring_writer *port; + + /* Check input parameters */ + if ((conf == NULL) || + (conf->ring == NULL) || + (conf->ring->prod.sp_enqueue != 0) || + (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { + RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); + return NULL; + } + + /* Memory allocation */ + port = rte_zmalloc_socket("PORT", sizeof(*port), + RTE_CACHE_LINE_SIZE, socket_id); + if (port == NULL) { + RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__
[dpdk-dev] [PATCH v1 3/3] examples/ip_pipeline: add mp/mc and frag/ras swq
Add integrated MP/MC and fragmentation/reassembly support to SWQs Signed-off-by: Piotr Azarewicz --- examples/ip_pipeline/app.h | 14 +++ examples/ip_pipeline/config_check.c | 45 +++- examples/ip_pipeline/config_parse.c | 195 +-- examples/ip_pipeline/init.c | 165 - examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 6 files changed, 402 insertions(+), 39 deletions(-) diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..943466e 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -107,6 +107,14 @@ struct app_pktq_swq_params { uint32_t dropless; uint64_t n_retries; uint32_t cpu_socket_id; + uint32_t ipv4_frag; + uint32_t ipv6_frag; + uint32_t ipv4_ras; + uint32_t ipv6_ras; + uint32_t mtu; + uint32_t metadata_size; + uint32_t mempool_direct_id; + uint32_t mempool_indirect_id; }; #ifndef APP_FILE_NAME_SIZE @@ -405,6 +413,10 @@ struct app_params { char app_name[APP_APPNAME_SIZE]; const char *config_file; const char *script_file; + const char *parser_file; + const char *output_file; + const char *preproc; + const char *preproc_args; uint64_t port_mask; uint32_t log_level; @@ -880,6 +892,8 @@ int app_config_init(struct app_params *app); int app_config_args(struct app_params *app, int argc, char **argv); +int app_config_preproc(struct app_params *app); + int app_config_parse(struct app_params *app, const char *file_name); diff --git a/examples/ip_pipeline/config_check.c b/examples/ip_pipeline/config_check.c index 07f4c8b..8052bc4 100644 --- a/examples/ip_pipeline/config_check.c +++ b/examples/ip_pipeline/config_check.c @@ -33,6 +33,8 @@ #include +#include + #include "app.h" static void @@ -193,6 +195,7 @@ check_swqs(struct app_params *app) struct app_pktq_swq_params *p = >swq_params[i]; uint32_t n_readers = app_swq_get_readers(app, p); uint32_t n_writers = app_swq_get_writers(app, p); + uint32_t n_flags; APP_CHECK((p->size > 0), "%s size is 0\n", p->name); @@ -217,14 +220,48 @@ check_swqs(struct app_params *app) APP_CHECK((n_readers != 0), "%s has no reader\n", p->name); - APP_CHECK((n_readers == 1), - "%s has more than one reader\n", p->name); + if (n_readers > 1) + APP_LOG(app, LOW, "%s has more than one reader", p->name); APP_CHECK((n_writers != 0), "%s has no writer\n", p->name); - APP_CHECK((n_writers == 1), - "%s has more than one writer\n", p->name); + if (n_writers > 1) + APP_LOG(app, LOW, "%s has more than one writer", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((n_flags < 2), + "%s has more than one fragmentation or reassembly mode enabled\n", + p->name); + + APP_CHECK((!((n_readers > 1) && (n_flags == 1))), + "%s has more than one reader when fragmentation or reassembly" + " mode enabled\n", + p->name); + + APP_CHECK((!((n_writers > 1) && (n_flags == 1))), + "%s has more than one writer when fragmentation or reassembly" + " mode enabled\n", + p->name); + + n_flags = p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((!((p->dropless == 1) && (n_flags == 1))), + "%s has dropless when reassembly mode enabled\n", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag; + + if (n_flags == 1) { + uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) : + sizeof(struct ipv6_hdr); + + APP_CHECK((p->mtu > ip_hdr_size), + "%s mtu size is smaller than ip header\n", p->name); + + APP_CHECK((!((p->mtu - ip_hdr_size) % 8)), + "%s mtu size is incorrect\n", p->name); + } } } diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index c9b78f9..a35bd3e 100644 --- a/examples/ip_pipeline/
[dpdk-dev] [PATCH v1 2/3] port: fix ras ring ports
Bug fixes for ring ports with IPv4/IPv6 reassembly support. Previous implementation can't work properly due to incorrect choosing process function. Also, assuming that, when processing ip packet, ip header is know we can set l3_len parameter here. Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_ras.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index 6bd0f8c..e45d450 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -144,7 +144,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; - port->f_ras = (is_ipv4 == 0) ? process_ipv4 : process_ipv6; + port->f_ras = (is_ipv4 == 1) ? process_ipv4 : process_ipv6; return port; } @@ -182,7 +182,7 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) /* Assume there is no ethernet header */ struct ipv4_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv4_hdr *); - /* Get "Do not fragment" flag and fragment offset */ + /* Get "More fragments" flag and fragment offset */ uint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset); uint16_t frag_offset = (uint16_t)(frag_field & IPV4_HDR_OFFSET_MASK); uint16_t frag_flag = (uint16_t)(frag_field & IPV4_HDR_MF_FLAG); @@ -195,6 +195,8 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr); + /* Process this fragment */ mo = rte_ipv4_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr); @@ -224,6 +226,8 @@ process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr) + sizeof(*frag_hdr); + /* Process this fragment */ mo = rte_ipv6_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr, frag_hdr); -- 1.7.9.5
[dpdk-dev] [PATCH v2 0/3] ip_pipeline: add MP/MC and frag/ras support to SWQs
This patch set enhancement ip_pipeline application: - librte_port: add support for multi-producer/multi-consumer ring ports - librte_port: bug fixes for ring ports with IPv4/IPv6 reassembly support - ip_pipeline application: integrate MP/MC and fragmentation/reassembly support to SWQs v2 changes: - rte_port_ring: - fixed checkpatch errors - interlace the implementation of multi into the implementation of single - reduced the amount of code duplication Piotr Azarewicz (3): port: add mp/mc ring ports port: fix ras ring ports examples/ip_pipeline: add mp/mc and frag/ras swq examples/ip_pipeline/app.h | 14 ++ examples/ip_pipeline/config_check.c | 45 - examples/ip_pipeline/config_parse.c | 195 -- examples/ip_pipeline/init.c | 165 --- examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 ++ lib/librte_port/rte_port_ras.c |8 +- lib/librte_port/rte_port_ring.c | 311 --- lib/librte_port/rte_port_ring.h | 35 +++- 9 files changed, 724 insertions(+), 71 deletions(-) -- 1.7.9.5
[dpdk-dev] [PATCH v2 1/3] port: add mp/mc ring ports
ring_multi_reader input port (on top of multi consumer rte_ring) ring_multi_writer output port (on top of multi producer rte_ring) Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_ring.c | 311 +++ lib/librte_port/rte_port_ring.h | 35 - 2 files changed, 316 insertions(+), 30 deletions(-) diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c index 9461c05..755dfc1 100644 --- a/lib/librte_port/rte_port_ring.c +++ b/lib/librte_port/rte_port_ring.c @@ -63,15 +63,19 @@ struct rte_port_ring_reader { }; static void * -rte_port_ring_reader_create(void *params, int socket_id) +rte_port_ring_reader_create_internal(void *params, int socket_id, + uint32_t is_multi) { struct rte_port_ring_reader_params *conf = (struct rte_port_ring_reader_params *) params; struct rte_port_ring_reader *port; /* Check input parameters */ - if (conf == NULL) { - RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__); + if ((conf == NULL) || + (conf->ring == NULL) || + (conf->ring->cons.sc_dequeue && is_multi) || + (!(conf->ring->cons.sc_dequeue) && !is_multi)) { + RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; } @@ -89,6 +93,18 @@ rte_port_ring_reader_create(void *params, int socket_id) return port; } +static void * +rte_port_ring_reader_create(void *params, int socket_id) +{ + return rte_port_ring_reader_create_internal(params, socket_id, 0); +} + +static void * +rte_port_ring_multi_reader_create(void *params, int socket_id) +{ + return rte_port_ring_reader_create_internal(params, socket_id, 1); +} + static int rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) { @@ -102,6 +118,19 @@ rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) } static int +rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts, + uint32_t n_pkts) +{ + struct rte_port_ring_reader *p = (struct rte_port_ring_reader *) port; + uint32_t nb_rx; + + nb_rx = rte_ring_mc_dequeue_burst(p->ring, (void **) pkts, n_pkts); + RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); + + return nb_rx; +} + +static int rte_port_ring_reader_free(void *port) { if (port == NULL) { @@ -155,10 +184,12 @@ struct rte_port_ring_writer { uint32_t tx_burst_sz; uint32_t tx_buf_count; uint64_t bsz_mask; + uint32_t is_multi; }; static void * -rte_port_ring_writer_create(void *params, int socket_id) +rte_port_ring_writer_create_internal(void *params, int socket_id, + uint32_t is_multi) { struct rte_port_ring_writer_params *conf = (struct rte_port_ring_writer_params *) params; @@ -166,7 +197,9 @@ rte_port_ring_writer_create(void *params, int socket_id) /* Check input parameters */ if ((conf == NULL) || - (conf->ring == NULL) || + (conf->ring == NULL) || + (conf->ring->prod.sp_enqueue && is_multi) || + (!(conf->ring->prod.sp_enqueue) && !is_multi) || (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__); return NULL; @@ -185,10 +218,23 @@ rte_port_ring_writer_create(void *params, int socket_id) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); + port->is_multi = is_multi; return port; } +static void * +rte_port_ring_writer_create(void *params, int socket_id) +{ + return rte_port_ring_writer_create_internal(params, socket_id, 0); +} + +static void * +rte_port_ring_multi_writer_create(void *params, int socket_id) +{ + return rte_port_ring_writer_create_internal(params, socket_id, 1); +} + static inline void send_burst(struct rte_port_ring_writer *p) { @@ -204,6 +250,21 @@ send_burst(struct rte_port_ring_writer *p) p->tx_buf_count = 0; } +static inline void +send_burst_mp(struct rte_port_ring_writer *p) +{ + uint32_t nb_tx; + + nb_tx = rte_ring_mp_enqueue_burst(p->ring, (void **)p->tx_buf, + p->tx_buf_count); + + RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); + for ( ; nb_tx < p->tx_buf_count; nb_tx++) + rte_pktmbuf_free(p->tx_buf[nb_tx]); + + p->tx_buf_count = 0; +} + static int rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) { @@ -218,9 +279,23 @@ rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) } static int -rte_port_ring_writer_tx_bulk(void *port, +rte_port_rin
[dpdk-dev] [PATCH v2 2/3] port: fix ras ring ports
Bug fixes for ring ports with IPv4/IPv6 reassembly support. Previous implementation can't work properly due to incorrect choosing process function. Also, assuming that, when processing ip packet, ip header is know we can set l3_len parameter here. Signed-off-by: Piotr Azarewicz --- lib/librte_port/rte_port_ras.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_port/rte_port_ras.c b/lib/librte_port/rte_port_ras.c index 6bd0f8c..e45d450 100644 --- a/lib/librte_port/rte_port_ras.c +++ b/lib/librte_port/rte_port_ras.c @@ -144,7 +144,7 @@ rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) port->tx_burst_sz = conf->tx_burst_sz; port->tx_buf_count = 0; - port->f_ras = (is_ipv4 == 0) ? process_ipv4 : process_ipv6; + port->f_ras = (is_ipv4 == 1) ? process_ipv4 : process_ipv6; return port; } @@ -182,7 +182,7 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) /* Assume there is no ethernet header */ struct ipv4_hdr *pkt_hdr = rte_pktmbuf_mtod(pkt, struct ipv4_hdr *); - /* Get "Do not fragment" flag and fragment offset */ + /* Get "More fragments" flag and fragment offset */ uint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset); uint16_t frag_offset = (uint16_t)(frag_field & IPV4_HDR_OFFSET_MASK); uint16_t frag_flag = (uint16_t)(frag_field & IPV4_HDR_MF_FLAG); @@ -195,6 +195,8 @@ process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr); + /* Process this fragment */ mo = rte_ipv4_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr); @@ -224,6 +226,8 @@ process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) struct rte_ip_frag_tbl *tbl = p->frag_tbl; struct rte_ip_frag_death_row *dr = >death_row; + pkt->l3_len = sizeof(*pkt_hdr) + sizeof(*frag_hdr); + /* Process this fragment */ mo = rte_ipv6_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr, frag_hdr); -- 1.7.9.5
[dpdk-dev] [PATCH v2 3/3] examples/ip_pipeline: add mp/mc and frag/ras swq
Add integrated MP/MC and fragmentation/reassembly support to SWQs Signed-off-by: Piotr Azarewicz --- examples/ip_pipeline/app.h | 14 +++ examples/ip_pipeline/config_check.c | 45 +++- examples/ip_pipeline/config_parse.c | 195 +-- examples/ip_pipeline/init.c | 165 - examples/ip_pipeline/main.c |4 +- examples/ip_pipeline/pipeline_be.h | 18 6 files changed, 402 insertions(+), 39 deletions(-) diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h index 521e3a0..943466e 100644 --- a/examples/ip_pipeline/app.h +++ b/examples/ip_pipeline/app.h @@ -107,6 +107,14 @@ struct app_pktq_swq_params { uint32_t dropless; uint64_t n_retries; uint32_t cpu_socket_id; + uint32_t ipv4_frag; + uint32_t ipv6_frag; + uint32_t ipv4_ras; + uint32_t ipv6_ras; + uint32_t mtu; + uint32_t metadata_size; + uint32_t mempool_direct_id; + uint32_t mempool_indirect_id; }; #ifndef APP_FILE_NAME_SIZE @@ -405,6 +413,10 @@ struct app_params { char app_name[APP_APPNAME_SIZE]; const char *config_file; const char *script_file; + const char *parser_file; + const char *output_file; + const char *preproc; + const char *preproc_args; uint64_t port_mask; uint32_t log_level; @@ -880,6 +892,8 @@ int app_config_init(struct app_params *app); int app_config_args(struct app_params *app, int argc, char **argv); +int app_config_preproc(struct app_params *app); + int app_config_parse(struct app_params *app, const char *file_name); diff --git a/examples/ip_pipeline/config_check.c b/examples/ip_pipeline/config_check.c index 07f4c8b..8052bc4 100644 --- a/examples/ip_pipeline/config_check.c +++ b/examples/ip_pipeline/config_check.c @@ -33,6 +33,8 @@ #include +#include + #include "app.h" static void @@ -193,6 +195,7 @@ check_swqs(struct app_params *app) struct app_pktq_swq_params *p = >swq_params[i]; uint32_t n_readers = app_swq_get_readers(app, p); uint32_t n_writers = app_swq_get_writers(app, p); + uint32_t n_flags; APP_CHECK((p->size > 0), "%s size is 0\n", p->name); @@ -217,14 +220,48 @@ check_swqs(struct app_params *app) APP_CHECK((n_readers != 0), "%s has no reader\n", p->name); - APP_CHECK((n_readers == 1), - "%s has more than one reader\n", p->name); + if (n_readers > 1) + APP_LOG(app, LOW, "%s has more than one reader", p->name); APP_CHECK((n_writers != 0), "%s has no writer\n", p->name); - APP_CHECK((n_writers == 1), - "%s has more than one writer\n", p->name); + if (n_writers > 1) + APP_LOG(app, LOW, "%s has more than one writer", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag + p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((n_flags < 2), + "%s has more than one fragmentation or reassembly mode enabled\n", + p->name); + + APP_CHECK((!((n_readers > 1) && (n_flags == 1))), + "%s has more than one reader when fragmentation or reassembly" + " mode enabled\n", + p->name); + + APP_CHECK((!((n_writers > 1) && (n_flags == 1))), + "%s has more than one writer when fragmentation or reassembly" + " mode enabled\n", + p->name); + + n_flags = p->ipv4_ras + p->ipv6_ras; + + APP_CHECK((!((p->dropless == 1) && (n_flags == 1))), + "%s has dropless when reassembly mode enabled\n", p->name); + + n_flags = p->ipv4_frag + p->ipv6_frag; + + if (n_flags == 1) { + uint16_t ip_hdr_size = (p->ipv4_frag) ? sizeof(struct ipv4_hdr) : + sizeof(struct ipv6_hdr); + + APP_CHECK((p->mtu > ip_hdr_size), + "%s mtu size is smaller than ip header\n", p->name); + + APP_CHECK((!((p->mtu - ip_hdr_size) % 8)), + "%s mtu size is incorrect\n", p->name); + } } } diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index c9b78f9..a35bd3e 100644 --- a/examples/ip_pipeline/
[dpdk-dev] [PATCH v4 1/1] examples/l3fwd: modify and modularize l3fwd code
The main problem with l3fwd is that it is too monolithic with everything being in one file, and the various options all controlled by compile time flags. This means that it's hard to read and understand, and when making any changes, you need to go to a lot of work to try and ensure you cover all the code paths, since a compile of the app will not touch large parts of the l3fwd codebase. Following changes were done to fix the issues mentioned above > Split out the various lpm and hash specific functionality into separate files, so that l3fwd code has one file for common code e.g. args processing, mempool creation, and then individual files for the various forwarding approaches. Following are new file lists main.c (Common code for args processing, memppol creation, etc) l3fwd_em.c (Hash/Exact match aka 'EM' functionality) l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code) l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality) l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code) l3fwd.h (Common include for 'EM' and 'LPM') > The choosing of the lpm/hash path should be done at runtime, not compile time, via a command-line argument. This will ensure that both code paths get compiled in a single go Following examples show runtime options provided Select 'LPM' or 'EM' based on run time selection f.e. > l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM) Options "E" and "L" are mutualy-exclusive. If none selected, "L" is default. Signed-off-by: Ravi Kerur Signed-off-by: Piotr Azarewicz Tested-by: Tomasz Kulasek Acked-by: Tomasz Kulasek Acked-by: Konstantin Ananyev --- v4 changes: fix compilation for i686 examples/l3fwd/l3fwd_em.c:437:2: error: format '%llx' expects argument of type 'long long unsigned int', but argument 2 has type 'unsigned int' solution: -printf("Hash: Adding 0x%" PRIx64 " keys\n", IPV4_L3FWD_EM_NUM_ROUTES); +printf("Hash: Adding 0x%" PRIx64 " keys\n", (uint64_t)IPV4_L3FWD_EM_NUM_ROUTES); v3 changes: add missed fix 'fix build without SSE4.1': - move l3fwd_lpm_no_opt_send_packets() to l3fwd_lpm.h - move l3fwd_em_no_opt_send_packets() to l3fwd_em.h - add #elses which provide proper headers respectively l3fwd_lpm.h/l3fwd_em.h or l3fwd_lpm_sse.h/l3fwd_em_sse.h v2 changes: rebase to latest code examples/l3fwd/Makefile| 11 +- examples/l3fwd/l3fwd.h | 211 examples/l3fwd/l3fwd_em.c | 751 ++ examples/l3fwd/l3fwd_em.h | 66 ++ examples/l3fwd/l3fwd_em_sse.h | 479 + examples/l3fwd/l3fwd_lpm.c | 305 ++ examples/l3fwd/l3fwd_lpm.h | 151 +++ examples/l3fwd/l3fwd_lpm_sse.h | 610 +++ examples/l3fwd/main.c | 2209 9 files changed, 2785 insertions(+), 2008 deletions(-) create mode 100644 examples/l3fwd/l3fwd.h create mode 100644 examples/l3fwd/l3fwd_em.c create mode 100644 examples/l3fwd/l3fwd_em.h create mode 100644 examples/l3fwd/l3fwd_em_sse.h create mode 100644 examples/l3fwd/l3fwd_lpm.c create mode 100644 examples/l3fwd/l3fwd_lpm.h create mode 100644 examples/l3fwd/l3fwd_lpm_sse.h diff --git a/examples/l3fwd/Makefile b/examples/l3fwd/Makefile index 68de8fc..5ce0ce0 100644 --- a/examples/l3fwd/Makefile +++ b/examples/l3fwd/Makefile @@ -1,6 +1,6 @@ # BSD LICENSE # -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# Copyright(c) 2010-2016 Intel Corporation. All rights reserved. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -42,15 +42,10 @@ include $(RTE_SDK)/mk/rte.vars.mk APP = l3fwd # all source are stored in SRCS-y -SRCS-y := main.c +SRCS-y := main.c l3fwd_lpm.c l3fwd_em.c +CFLAGS += -I$(SRCDIR) CFLAGS += -O3 $(USER_FLAGS) CFLAGS += $(WERROR_FLAGS) -# workaround for a gcc bug with noreturn attribute -# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603 -ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) -CFLAGS_main.o += -Wno-return-type -endif - include $(RTE_SDK)/mk/rte.extapp.mk diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h new file mode 100644 index 000..f450269 --- /dev/null +++ b/examples/l3fwd/l3fwd.h @@ -0,0 +1,211 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary
[dpdk-dev] [PATCH] app/test: fix crypto mbuf pool size
This patch fix that created pool for crypto mbufs may be too big in some environments. To avoid the issue, mbuf pool is reverted to its previous size. Moreover, here is added additional small pool with one large mbuf, what is needed in large data test scenarios. Fixes: 2070f885b76d ("app/test: added tests for libcrypto PMD") Signed-off-by: Piotr Azarewicz --- app/test/test_cryptodev.c | 28 +--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 2917454..914bb0b 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -60,6 +60,7 @@ static enum rte_cryptodev_type gbl_cryptodev_type; struct crypto_testsuite_params { struct rte_mempool *mbuf_pool; + struct rte_mempool *large_mbuf_pool; struct rte_mempool *op_mpool; struct rte_cryptodev_config conf; struct rte_cryptodev_qp_conf qp_conf; @@ -169,7 +170,7 @@ testsuite_setup(void) /* Not already created so create */ ts_params->mbuf_pool = rte_pktmbuf_pool_create( "CRYPTO_MBUFPOOL", - NUM_MBUFS, MBUF_CACHE_SIZE, 0, UINT16_MAX, + NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE, rte_socket_id()); if (ts_params->mbuf_pool == NULL) { RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n"); @@ -177,6 +178,21 @@ testsuite_setup(void) } } + ts_params->large_mbuf_pool = rte_mempool_lookup( + "CRYPTO_LARGE_MBUFPOOL"); + if (ts_params->large_mbuf_pool == NULL) { + /* Not already created so create */ + ts_params->large_mbuf_pool = rte_pktmbuf_pool_create( + "CRYPTO_LARGE_MBUFPOOL", + 1, 0, 0, UINT16_MAX, + rte_socket_id()); + if (ts_params->large_mbuf_pool == NULL) { + RTE_LOG(ERR, USER1, + "Can't create CRYPTO_LARGE_MBUFPOOL\n"); + return TEST_FAILED; + } + } + ts_params->op_mpool = rte_crypto_op_pool_create( "MBUF_CRYPTO_SYM_OP_POOL", RTE_CRYPTO_OP_TYPE_SYMMETRIC, @@ -5149,7 +5165,10 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata) if (retval < 0) return retval; - ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH) + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); + else + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); @@ -5233,7 +5252,10 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata) if (retval < 0) return retval; - ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH) + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); + else + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); -- 1.7.9.5
[dpdk-dev] [PATCH v2] app/test: fix crypto mbuf pool size
This patch fix that created pool for crypto mbufs may be too big in some environments. To avoid the issue, mbuf pool is reverted to its previous size. Moreover, here is added additional small pool with one large mbuf, what is needed in large data test scenarios. Fixes: ffbe3be0d4b5 ("app/test: add libcrypto") Signed-off-by: Piotr Azarewicz --- v2 change: - changed check if aad.len > MBUF_SIZE - added assertion check for rte_pktmbuf_alloc app/test/test_cryptodev.c | 32 +--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 2917454..7d03899 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -60,6 +60,7 @@ static enum rte_cryptodev_type gbl_cryptodev_type; struct crypto_testsuite_params { struct rte_mempool *mbuf_pool; + struct rte_mempool *large_mbuf_pool; struct rte_mempool *op_mpool; struct rte_cryptodev_config conf; struct rte_cryptodev_qp_conf qp_conf; @@ -169,7 +170,7 @@ testsuite_setup(void) /* Not already created so create */ ts_params->mbuf_pool = rte_pktmbuf_pool_create( "CRYPTO_MBUFPOOL", - NUM_MBUFS, MBUF_CACHE_SIZE, 0, UINT16_MAX, + NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE, rte_socket_id()); if (ts_params->mbuf_pool == NULL) { RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n"); @@ -177,6 +178,21 @@ testsuite_setup(void) } } + ts_params->large_mbuf_pool = rte_mempool_lookup( + "CRYPTO_LARGE_MBUFPOOL"); + if (ts_params->large_mbuf_pool == NULL) { + /* Not already created so create */ + ts_params->large_mbuf_pool = rte_pktmbuf_pool_create( + "CRYPTO_LARGE_MBUFPOOL", + 1, 0, 0, UINT16_MAX, + rte_socket_id()); + if (ts_params->large_mbuf_pool == NULL) { + RTE_LOG(ERR, USER1, + "Can't create CRYPTO_LARGE_MBUFPOOL\n"); + return TEST_FAILED; + } + } + ts_params->op_mpool = rte_crypto_op_pool_create( "MBUF_CRYPTO_SYM_OP_POOL", RTE_CRYPTO_OP_TYPE_SYMMETRIC, @@ -5149,7 +5165,12 @@ test_AES_GMAC_authentication(const struct gmac_test_data *tdata) if (retval < 0) return retval; - ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + if (tdata->aad.len > MBUF_SIZE) + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); + else + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + TEST_ASSERT_NOT_NULL(ut_params->ibuf, + "Failed to allocate input buffer in mempool"); memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); @@ -5233,7 +5254,12 @@ test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata) if (retval < 0) return retval; - ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + if (tdata->aad.len > MBUF_SIZE) + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); + else + ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); + TEST_ASSERT_NOT_NULL(ut_params->ibuf, + "Failed to allocate input buffer in mempool"); memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, rte_pktmbuf_tailroom(ut_params->ibuf)); -- 1.7.9.5
[dpdk-dev] [PATCH] examples/l2fwd-crypto: fix verify with decrypt in chain
This patch fix setting crypto operation data parameters in l2fwd-crypto application. >From now decryption in chain with auth verify work fine. How to reproduce the issue: 1. Run l2fwd_crypto with command: -c 0x3 -n 4 --vdev "crypto_aesni_mb" \ --vdev "crypto_aesni_mb" \ -- -p 0x3 --chain CIPHER_HASH \ --cipher_op ENCRYPT --cipher_algo AES_CBC \ --cipher_key 00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f \ --iv 00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:ff \ --auth_op GENERATE --auth_algo SHA1_HMAC \ --auth_key 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11 2. Send packet with payload and capture forwarded packet. Payload in forwarded packet is encrypted, what is good. 3. Run l2fwd_crypto with command: -c 0x3 -n 4 --vdev "crypto_aesni_mb" \ --vdev "crypto_aesni_mb" \ -- -p 0x3 --chain HASH_CIPHER \ --cipher_op DECRYPT --cipher_algo AES_CBC \ --cipher_key 00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f \ --iv 00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:ff \ --auth_op VERIFY --auth_algo SHA1_HMAC \ --auth_key 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11 4. Send earlier captured packet and capture forwarded packet. Payload in newly captured packet is not decrypted, what is wrong. Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application") Signed-off-by: Piotr Azarewicz --- examples/l2fwd-crypto/main.c | 23 --- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index dae45f5..43fef59 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -451,6 +451,10 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, /* Zero pad data to be crypto'd so it is block aligned */ data_len = rte_pktmbuf_data_len(m) - ipdata_offset; + + if (cparams->do_hash && cparams->hash_verify) + data_len -= cparams->digest_length; + pad_len = data_len % cparams->block_size ? cparams->block_size - (data_len % cparams->block_size) : 0; @@ -472,8 +476,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, op->sym->auth.digest.data = (uint8_t *)rte_pktmbuf_append(m, cparams->digest_length); } else { - op->sym->auth.digest.data = (uint8_t *)rte_pktmbuf_append(m, - cparams->digest_length); + op->sym->auth.digest.data = rte_pktmbuf_mtod(m, + uint8_t *) + ipdata_offset + data_len; } op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m, @@ -508,21 +512,10 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m, cparams->cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 || cparams->cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) { op->sym->cipher.data.offset = ipdata_offset << 3; - if (cparams->do_hash && cparams->hash_verify) - /* Do not cipher the hash tag */ - op->sym->cipher.data.length = (data_len - - cparams->digest_length) << 3; - else - op->sym->cipher.data.length = data_len << 3; - + op->sym->cipher.data.length = data_len << 3; } else { op->sym->cipher.data.offset = ipdata_offset; - if (cparams->do_hash && cparams->hash_verify) - /* Do not cipher the hash tag */ - op->sym->cipher.data.length = data_len - - cparams->digest_length; - else - op->sym->cipher.data.length = data_len; + op->sym->cipher.data.length = data_len; } } -- 1.7.9.5
[dpdk-dev] [PATCH v1 1/1] examples/bond: fix unchecked return value
The example is calling rte_eal_wait_lcore without checking return value. Now it is fixed by checking the value and print proper message. Coverity issue: 37789 Coverity issue: 37790 Fixes: cc7e8ae84faa ("examples/bond: add example application for link bonding mode 6") Signed-off-by: Piotr Azarewicz --- examples/bond/main.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/bond/main.c b/examples/bond/main.c index 53bd044..776fad0 100644 --- a/examples/bond/main.c +++ b/examples/bond/main.c @@ -590,10 +590,14 @@ static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, return; } global_flag_stru_p->LcoreMainIsRunning = 0; - rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore); - cmdline_printf(cl, - "lcore_main stopped on core:%d\n", - global_flag_stru_p->LcoreMainCore); + if (rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore) < 0) + cmdline_printf(cl, + "error: lcore_main can not stop on core:%d\n", + global_flag_stru_p->LcoreMainCore); + else + cmdline_printf(cl, + "lcore_main stopped on core:%d\n", + global_flag_stru_p->LcoreMainCore); rte_spinlock_unlock(_flag_stru_p->lock); } @@ -628,10 +632,14 @@ static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, return; } global_flag_stru_p->LcoreMainIsRunning = 0; - rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore); - cmdline_printf(cl, - "lcore_main stopped on core:%d\n", - global_flag_stru_p->LcoreMainCore); + if (rte_eal_wait_lcore(global_flag_stru_p->LcoreMainCore) < 0) + cmdline_printf(cl, + "error: lcore_main can not stop on core:%d\n", + global_flag_stru_p->LcoreMainCore); + else + cmdline_printf(cl, + "lcore_main stopped on core:%d\n", + global_flag_stru_p->LcoreMainCore); rte_spinlock_unlock(_flag_stru_p->lock); cmdline_quit(cl); } -- 1.7.9.5
[dpdk-dev] [PATCH v1 1/1] cmdline: add any multi string mode to token string
While parsing token string there may be several modes: - fixed single string - multi-choice single string - any single string This patch add one more mode - any multi string. Signed-off-by: Piotr Azarewicz --- app/test/test_cmdline_string.c|9 --- lib/librte_cmdline/cmdline_parse.c|8 ++ lib/librte_cmdline/cmdline_parse.h|3 +++ lib/librte_cmdline/cmdline_parse_string.c | 41 - lib/librte_cmdline/cmdline_parse_string.h |2 ++ 5 files changed, 48 insertions(+), 15 deletions(-) diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 915a7d7..96f0e20 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -97,6 +97,11 @@ struct string_parse_str string_parse_strs[] = { {"two with\rgarbage\tcharacters\n", "one#two with\rgarbage\tcharacters\n#three", "two with\rgarbage\tcharacters\n"}, + {"one two", "one", "one"}, /* fixed string */ + {"one two", TOKEN_STRING_MULTI, "one two"}, /* multi string */ + {"one two", NULL, "one"}, /* any string */ + {"one two #three", TOKEN_STRING_MULTI, "one two "}, + /* multi string with comment */ }; @@ -124,7 +129,6 @@ struct string_invalid_str string_invalid_strs[] = { "toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!" "toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!" "toolong!!!" }, -{"invalid", ""}, {"", "invalid"} }; @@ -350,8 +354,7 @@ test_parse_string_valid(void) string_parse_strs[i].str, help_str); return -1; } - if (strncmp(buf, string_parse_strs[i].result, - sizeof(string_parse_strs[i].result) - 1) != 0) { + if (strcmp(buf, string_parse_strs[i].result) != 0) { printf("Error: result mismatch!\n"); return -1; } diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 24a6ed6..b496067 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -118,6 +118,14 @@ cmdline_isendoftoken(char c) return 0; } +int +cmdline_isendofcommand(char c) +{ + if (!c || iscomment(c) || isendofline(c)) + return 1; + return 0; +} + static unsigned int nb_common_chars(const char * s1, const char * s2) { diff --git a/lib/librte_cmdline/cmdline_parse.h b/lib/librte_cmdline/cmdline_parse.h index 4b25c45..4ac05d6 100644 --- a/lib/librte_cmdline/cmdline_parse.h +++ b/lib/librte_cmdline/cmdline_parse.h @@ -184,6 +184,9 @@ int cmdline_complete(struct cmdline *cl, const char *buf, int *state, * isendofline(c)) */ int cmdline_isendoftoken(char c); +/* return true if(!c || iscomment(c) || isendofline(c)) */ +int cmdline_isendofcommand(char c); + #ifdef __cplusplus } #endif diff --git a/lib/librte_cmdline/cmdline_parse_string.c b/lib/librte_cmdline/cmdline_parse_string.c index 45883b3..274c9a3 100644 --- a/lib/librte_cmdline/cmdline_parse_string.c +++ b/lib/librte_cmdline/cmdline_parse_string.c @@ -76,9 +76,10 @@ struct cmdline_token_ops cmdline_token_string_ops = { .get_help = cmdline_get_help_string, }; -#define MULTISTRING_HELP "Mul-choice STRING" -#define ANYSTRING_HELP "Any STRING" -#define FIXEDSTRING_HELP "Fixed STRING" +#define CHOICESTRING_HELP "Mul-choice STRING" +#define ANYSTRING_HELP"Any STRING" +#define ANYSTRINGS_HELP "Any STRINGS" +#define FIXEDSTRING_HELP "Fixed STRING" static unsigned int get_token_len(const char *s) @@ -123,8 +124,8 @@ cmdline_parse_string(cmdline_parse_token_hdr_t *tk, const char *buf, void *res, sd = >string_data; - /* fixed string */ - if (sd->str) { + /* fixed string (known single token) */ + if ((sd->str != NULL) && (strcmp(sd->str, TOKEN_STRING_MULTI) != 0)) { str = sd->str; do { token_len = get_token_len(str); @@ -148,7 +149,18 @@ cmdline_parse_string(cmdline_parse_token_hdr_t *tk, const char *buf, void *res, if (!str) return -1; } - /* unspecified string */ + /* multi string */ + else if (sd->str != NULL) { + token_len = 0; + while (!cmdline_isendofcommand(buf[token_len]) && + token_len < (ressize - 1)) +
[dpdk-dev] [PATCH v2 1/1] cmdline: add any multi string mode to token string
While parsing token string there may be several modes: - fixed single string - multi-choice single string - any single string This patch add one more mode - any multi string. Signed-off-by: Piotr Azarewicz --- v2 changes: - add cmdline_multi_string_t type for the new mode app/test/test_cmdline_string.c| 15 ++ lib/librte_cmdline/cmdline_parse.c|8 ++ lib/librte_cmdline/cmdline_parse.h|3 ++ lib/librte_cmdline/cmdline_parse_string.c | 43 + lib/librte_cmdline/cmdline_parse_string.h |7 + 5 files changed, 60 insertions(+), 16 deletions(-) diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 915a7d7..c5bb9c0 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -65,9 +66,10 @@ struct string_elt_str string_elt_strs[] = { {"one#two\nwith\nnewlines#three", "two\nwith\nnewlines", 1}, }; -#if CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE +#if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \ +|| (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE) #undef CMDLINE_TEST_BUFSIZE -#define CMDLINE_TEST_BUFSIZE STR_TOKEN_SIZE +#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE) #endif struct string_nb_str { @@ -97,6 +99,11 @@ struct string_parse_str string_parse_strs[] = { {"two with\rgarbage\tcharacters\n", "one#two with\rgarbage\tcharacters\n#three", "two with\rgarbage\tcharacters\n"}, + {"one two", "one", "one"}, /* fixed string */ + {"one two", TOKEN_STRING_MULTI, "one two"}, /* multi string */ + {"one two", NULL, "one"}, /* any string */ + {"one two #three", TOKEN_STRING_MULTI, "one two "}, + /* multi string with comment */ }; @@ -124,7 +131,6 @@ struct string_invalid_str string_invalid_strs[] = { "toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!" "toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!" "toolong!!!" }, -{"invalid", ""}, {"", "invalid"} }; @@ -350,8 +356,7 @@ test_parse_string_valid(void) string_parse_strs[i].str, help_str); return -1; } - if (strncmp(buf, string_parse_strs[i].result, - sizeof(string_parse_strs[i].result) - 1) != 0) { + if (strcmp(buf, string_parse_strs[i].result) != 0) { printf("Error: result mismatch!\n"); return -1; } diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 24a6ed6..b496067 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -118,6 +118,14 @@ cmdline_isendoftoken(char c) return 0; } +int +cmdline_isendofcommand(char c) +{ + if (!c || iscomment(c) || isendofline(c)) + return 1; + return 0; +} + static unsigned int nb_common_chars(const char * s1, const char * s2) { diff --git a/lib/librte_cmdline/cmdline_parse.h b/lib/librte_cmdline/cmdline_parse.h index 4b25c45..4ac05d6 100644 --- a/lib/librte_cmdline/cmdline_parse.h +++ b/lib/librte_cmdline/cmdline_parse.h @@ -184,6 +184,9 @@ int cmdline_complete(struct cmdline *cl, const char *buf, int *state, * isendofline(c)) */ int cmdline_isendoftoken(char c); +/* return true if(!c || iscomment(c) || isendofline(c)) */ +int cmdline_isendofcommand(char c); + #ifdef __cplusplus } #endif diff --git a/lib/librte_cmdline/cmdline_parse_string.c b/lib/librte_cmdline/cmdline_parse_string.c index 45883b3..35917a7 100644 --- a/lib/librte_cmdline/cmdline_parse_string.c +++ b/lib/librte_cmdline/cmdline_parse_string.c @@ -76,9 +76,10 @@ struct cmdline_token_ops cmdline_token_string_ops = { .get_help = cmdline_get_help_string, }; -#define MULTISTRING_HELP "Mul-choice STRING" -#define ANYSTRING_HELP "Any STRING" -#define FIXEDSTRING_HELP "Fixed STRING" +#define CHOICESTRING_HELP "Mul-choice STRING" +#define ANYSTRING_HELP"Any STRING" +#define ANYSTRINGS_HELP "Any STRINGS" +#define FIXEDSTRING_HELP "Fixed STRING" static unsigned int get_token_len(const char *s) @@ -123,8 +124,8 @@ cmdline_parse_string(cmdline_parse_token_hdr_t *tk, const char *buf, void *res, sd = >string_data; - /* fixed string */ - if (sd->str) { + /* fixed string (known single token) */ +
[dpdk-dev] [PATCH v1 1/1] ixgbe: fix queue stop
It should be checked if queue enable bit is clear. CID 13215 : Wrong operator used (CONSTANT_EXPRESSION_RESULT) operator_confusion: txdctl | 33554432 is always 1/true regardless of the values of its operand. This occurs as the logical second operand of '&&'. CID 13216 : Wrong operator used (CONSTANT_EXPRESSION_RESULT) operator_confusion: rxdctl | 33554432 is always 1/true regardless of the values of its operand. This occurs as the logical second operand of '&&'. Coverity issue: 13215 Coverity issue: 13216 Fixes: 029fd06d40fa ("ixgbe: queue start and stop") Signed-off-by: Piotr Azarewicz --- drivers/net/ixgbe/ixgbe_rxtx.c |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 9fb38a6..8483e51 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -4813,12 +4813,12 @@ ixgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) rxdctl &= ~IXGBE_RXDCTL_ENABLE; IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), rxdctl); - /* Wait until RX Enable ready */ + /* Wait until RX Enable bit clear */ poll_ms = RTE_IXGBE_REGISTER_POLL_WAIT_10_MS; do { rte_delay_ms(1); rxdctl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx)); - } while (--poll_ms && (rxdctl | IXGBE_RXDCTL_ENABLE)); + } while (--poll_ms && (rxdctl & IXGBE_RXDCTL_ENABLE)); if (!poll_ms) PMD_INIT_LOG(ERR, "Could not disable Rx Queue %d", rx_queue_id); @@ -4914,14 +4914,14 @@ ixgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) txdctl &= ~IXGBE_TXDCTL_ENABLE; IXGBE_WRITE_REG(hw, IXGBE_TXDCTL(txq->reg_idx), txdctl); - /* Wait until TX Enable ready */ + /* Wait until TX Enable bit clear */ if (hw->mac.type == ixgbe_mac_82599EB) { poll_ms = RTE_IXGBE_REGISTER_POLL_WAIT_10_MS; do { rte_delay_ms(1); txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(txq->reg_idx)); - } while (--poll_ms && (txdctl | IXGBE_TXDCTL_ENABLE)); + } while (--poll_ms && (txdctl & IXGBE_TXDCTL_ENABLE)); if (!poll_ms) PMD_INIT_LOG(ERR, "Could not disable " "Tx Queue %d", tx_queue_id); -- 1.7.9.5
[dpdk-dev] [PATCH v3 1/1] cmdline: add any multi string mode to token string
While parsing token string there may be several modes: - fixed single string - multi-choice single string - any single string This patch add one more mode - any multi string. Signed-off-by: Piotr Azarewicz Acked-by: Olivier Matz --- v3 changes: - add a comment above the definiton of TOKEN_STRING_MULTI v2 changes: - add cmdline_multi_string_t type for the new mode app/test/test_cmdline_string.c| 15 ++ lib/librte_cmdline/cmdline_parse.c|8 ++ lib/librte_cmdline/cmdline_parse.h|3 ++ lib/librte_cmdline/cmdline_parse_string.c | 43 + lib/librte_cmdline/cmdline_parse_string.h | 15 ++ 5 files changed, 68 insertions(+), 16 deletions(-) diff --git a/app/test/test_cmdline_string.c b/app/test/test_cmdline_string.c index 915a7d7..c5bb9c0 100644 --- a/app/test/test_cmdline_string.c +++ b/app/test/test_cmdline_string.c @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -65,9 +66,10 @@ struct string_elt_str string_elt_strs[] = { {"one#two\nwith\nnewlines#three", "two\nwith\nnewlines", 1}, }; -#if CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE +#if (CMDLINE_TEST_BUFSIZE < STR_TOKEN_SIZE) \ +|| (CMDLINE_TEST_BUFSIZE < STR_MULTI_TOKEN_SIZE) #undef CMDLINE_TEST_BUFSIZE -#define CMDLINE_TEST_BUFSIZE STR_TOKEN_SIZE +#define CMDLINE_TEST_BUFSIZE RTE_MAX(STR_TOKEN_SIZE, STR_MULTI_TOKEN_SIZE) #endif struct string_nb_str { @@ -97,6 +99,11 @@ struct string_parse_str string_parse_strs[] = { {"two with\rgarbage\tcharacters\n", "one#two with\rgarbage\tcharacters\n#three", "two with\rgarbage\tcharacters\n"}, + {"one two", "one", "one"}, /* fixed string */ + {"one two", TOKEN_STRING_MULTI, "one two"}, /* multi string */ + {"one two", NULL, "one"}, /* any string */ + {"one two #three", TOKEN_STRING_MULTI, "one two "}, + /* multi string with comment */ }; @@ -124,7 +131,6 @@ struct string_invalid_str string_invalid_strs[] = { "toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!" "toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!toolong!!!" "toolong!!!" }, -{"invalid", ""}, {"", "invalid"} }; @@ -350,8 +356,7 @@ test_parse_string_valid(void) string_parse_strs[i].str, help_str); return -1; } - if (strncmp(buf, string_parse_strs[i].result, - sizeof(string_parse_strs[i].result) - 1) != 0) { + if (strcmp(buf, string_parse_strs[i].result) != 0) { printf("Error: result mismatch!\n"); return -1; } diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 24a6ed6..b496067 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -118,6 +118,14 @@ cmdline_isendoftoken(char c) return 0; } +int +cmdline_isendofcommand(char c) +{ + if (!c || iscomment(c) || isendofline(c)) + return 1; + return 0; +} + static unsigned int nb_common_chars(const char * s1, const char * s2) { diff --git a/lib/librte_cmdline/cmdline_parse.h b/lib/librte_cmdline/cmdline_parse.h index 4b25c45..4ac05d6 100644 --- a/lib/librte_cmdline/cmdline_parse.h +++ b/lib/librte_cmdline/cmdline_parse.h @@ -184,6 +184,9 @@ int cmdline_complete(struct cmdline *cl, const char *buf, int *state, * isendofline(c)) */ int cmdline_isendoftoken(char c); +/* return true if(!c || iscomment(c) || isendofline(c)) */ +int cmdline_isendofcommand(char c); + #ifdef __cplusplus } #endif diff --git a/lib/librte_cmdline/cmdline_parse_string.c b/lib/librte_cmdline/cmdline_parse_string.c index 45883b3..35917a7 100644 --- a/lib/librte_cmdline/cmdline_parse_string.c +++ b/lib/librte_cmdline/cmdline_parse_string.c @@ -76,9 +76,10 @@ struct cmdline_token_ops cmdline_token_string_ops = { .get_help = cmdline_get_help_string, }; -#define MULTISTRING_HELP "Mul-choice STRING" -#define ANYSTRING_HELP "Any STRING" -#define FIXEDSTRING_HELP "Fixed STRING" +#define CHOICESTRING_HELP "Mul-choice STRING" +#define ANYSTRING_HELP"Any STRING" +#define ANYSTRINGS_HELP "Any STRINGS" +#define FIXEDSTRING_HELP "Fixed STRING" static unsigned int get_token_len(const char *s) @@ -123,8 +124,8 @@ cmdline_parse_string(cmdline_parse_token_hdr_t *tk, const char *buf, void *res, sd = >string_data;
[dpdk-dev] [PATCH 0/4] New crypto software based device
From: Marcin Kerlin <marcinx.ker...@intel.com> This code provides the initial implementation of the libcrypto poll mode driver. All cryptography operations are using Openssl library crypto API. Each algorithm uses EVP_ interface from openssl API - which is recommended by Openssl maintainers. For more information about how to use this driver, go to: doc/guides/cryptodevs/libcrypto.rst Slawomir Mrozowicz (2): libcrypto_pmd: initial implementation of SW crypto device lib/cryptodev: added support to libcrypto PMD Piotr Azarewicz (1) app/test: added tests for libcrypto PMD Daniel Mrzyglod (1) examples/l2fwd-crypto: updated example for libcrypto PMD MAINTAINERS|4 + app/test/Makefile |1 + app/test/test_cryptodev.c | 1245 +++- app/test/test_cryptodev.h | 24 + app/test/test_cryptodev_aes.c | 42 +- app/test/test_cryptodev_aes_test_vectors.h | 887 +++ app/test/test_cryptodev_des_test_vectors.h | 754 ++ app/test/test_cryptodev_hash_test_vectors.h| 439 ++ app/test/test_cryptodev_kasumi_test_vectors.h | 12 +- app/test/test_cryptodev_operations.c | 1576 app/test/test_cryptodev_operations.h | 141 ++ app/test/test_cryptodev_perf.c | 699 - config/common_base |6 + doc/guides/cryptodevs/index.rst|1 + doc/guides/cryptodevs/libcrypto.rst| 109 ++ drivers/crypto/Makefile|1 + drivers/crypto/libcrypto/Makefile | 60 + drivers/crypto/libcrypto/rte_libcrypto_pmd.c | 936 drivers/crypto/libcrypto/rte_libcrypto_pmd_ops.c | 638 .../crypto/libcrypto/rte_libcrypto_pmd_private.h | 189 +++ .../crypto/libcrypto/rte_pmd_libcrypto_version.map |3 + examples/l2fwd-crypto/main.c | 11 + lib/librte_cryptodev/rte_cryptodev.h |3 + mk/rte.app.mk |3 +- 24 files changed, 7688 insertions(+), 96 deletions(-) create mode 100644 app/test/test_cryptodev_aes_test_vectors.h create mode 100644 app/test/test_cryptodev_des_test_vectors.h create mode 100644 app/test/test_cryptodev_hash_test_vectors.h create mode 100644 app/test/test_cryptodev_operations.c create mode 100644 app/test/test_cryptodev_operations.h create mode 100644 doc/guides/cryptodevs/libcrypto.rst create mode 100644 drivers/crypto/libcrypto/Makefile create mode 100644 drivers/crypto/libcrypto/rte_libcrypto_pmd.c create mode 100644 drivers/crypto/libcrypto/rte_libcrypto_pmd_ops.c create mode 100644 drivers/crypto/libcrypto/rte_libcrypto_pmd_private.h create mode 100644 drivers/crypto/libcrypto/rte_pmd_libcrypto_version.map -- 1.9.1
[dpdk-dev] [PATCH 1/4] libcrypto_pmd: initial implementation of SW crypto device
From: Marcin KerlinThis code provides the initial implementation of the libcrypto poll mode driver. All cryptography operations are using Openssl library crypto API. Each algorithm uses EVP_ interface from openssl API - which is recommended by Openssl maintainers. LibCrypto PMD has support for: Supported cipher algorithms: RTE_CRYPTO_CIPHER_3DES_CBC RTE_CRYPTO_CIPHER_AES_CBC RTE_CRYPTO_CIPHER_AES_CTR RTE_CRYPTO_CIPHER_3DES_CTR Supported authentication algorithms: RTE_CRYPTO_AUTH_AES_GMAC RTE_CRYPTO_AUTH_MD5 RTE_CRYPTO_AUTH_SHA1 RTE_CRYPTO_AUTH_SHA224 RTE_CRYPTO_AUTH_SHA256 RTE_CRYPTO_AUTH_SHA384 RTE_CRYPTO_AUTH_SHA512 RTE_CRYPTO_AUTH_MD5_HMAC RTE_CRYPTO_AUTH_SHA1_HMAC RTE_CRYPTO_AUTH_SHA224_HMAC RTE_CRYPTO_AUTH_SHA256_HMAC RTE_CRYPTO_AUTH_SHA384_HMAC RTE_CRYPTO_AUTH_SHA512_HMAC Installation To compile libcrypto PMD It has to be enabled in the config/common_base file and appropriate openssl packages have to be installed in the build environment. Signed-off-by: Slawomir Mrozowicz Signed-off-by: Michal Kobylinski Signed-off-by: Tomasz Kulasek Signed-off-by: Daniel Mrzyglod --- MAINTAINERS| 4 + config/common_base | 6 + doc/guides/cryptodevs/index.rst| 1 + doc/guides/cryptodevs/libcrypto.rst| 109 +++ drivers/crypto/Makefile| 1 + drivers/crypto/libcrypto/Makefile | 60 ++ drivers/crypto/libcrypto/rte_libcrypto_pmd.c | 936 + drivers/crypto/libcrypto/rte_libcrypto_pmd_ops.c | 638 ++ .../crypto/libcrypto/rte_libcrypto_pmd_private.h | 189 + .../crypto/libcrypto/rte_pmd_libcrypto_version.map | 3 + mk/rte.app.mk | 3 +- 11 files changed, 1949 insertions(+), 1 deletion(-) create mode 100644 doc/guides/cryptodevs/libcrypto.rst create mode 100644 drivers/crypto/libcrypto/Makefile create mode 100644 drivers/crypto/libcrypto/rte_libcrypto_pmd.c create mode 100644 drivers/crypto/libcrypto/rte_libcrypto_pmd_ops.c create mode 100644 drivers/crypto/libcrypto/rte_libcrypto_pmd_private.h create mode 100644 drivers/crypto/libcrypto/rte_pmd_libcrypto_version.map diff --git a/MAINTAINERS b/MAINTAINERS index bc9aa02..9eeb841 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -431,6 +431,10 @@ M: Declan Doherty F: drivers/crypto/null/ F: doc/guides/cryptodevs/null.rst +LibCrypto Crypto PMD +M: Declan Doherty +F: drivers/crypto/libcrypto/ +F: doc/guides/cryptodevs/libcrypto.rst Packet processing - diff --git a/config/common_base b/config/common_base index 7830535..42d28dd 100644 --- a/config/common_base +++ b/config/common_base @@ -376,6 +376,12 @@ CONFIG_RTE_LIBRTE_PMD_AESNI_MB=n CONFIG_RTE_LIBRTE_PMD_AESNI_MB_DEBUG=n # +# Compile PMD for Software backed device +# +CONFIG_RTE_LIBRTE_PMD_LIBCRYPTO=n +CONFIG_RTE_LIBRTE_PMD_LIBCRYPTO_DEBUG=n + +# # Compile PMD for AESNI GCM device # CONFIG_RTE_LIBRTE_PMD_AESNI_GCM=n diff --git a/doc/guides/cryptodevs/index.rst b/doc/guides/cryptodevs/index.rst index 9616de1..adb6e98c 100644 --- a/doc/guides/cryptodevs/index.rst +++ b/doc/guides/cryptodevs/index.rst @@ -39,6 +39,7 @@ Crypto Device Drivers aesni_mb aesni_gcm kasumi +libcrypto null snow3g qat diff --git a/doc/guides/cryptodevs/libcrypto.rst b/doc/guides/cryptodevs/libcrypto.rst new file mode 100644 index 000..1c3dd07 --- /dev/null +++ b/doc/guides/cryptodevs/libcrypto.rst @@ -0,0 +1,109 @@ +.. BSD LICENSE +Copyright(c) 2016 Intel Corporation. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the +distribution. +* Neither the name of Intel Corporation nor the names of its +contributors may be used to endorse or promote products derived +from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +
[dpdk-dev] [PATCH 2/4] lib/cryptodev: added support to libcrypto PMD
From: Marcin KerlinThis patch adds libcrypto poll mode driver support to librte_cryptodev library. Signed-off-by: Slawomir Mrozowicz --- lib/librte_cryptodev/rte_cryptodev.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index affbdec..7a87cc3 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -55,6 +55,8 @@ extern "C" { /**< AES-NI Multi buffer PMD device name */ #define CRYPTODEV_NAME_AESNI_GCM_PMD cryptodev_aesni_gcm_pmd /**< AES-NI GCM PMD device name */ +#define CRYPTODEV_NAME_LIBCRYPTO_PMD cryptodev_libcrypto_pmd +/**< Open SSL Crypto PMD device name */ #define CRYPTODEV_NAME_QAT_SYM_PMD cryptodev_qat_sym_pmd /**< Intel QAT Symmetric Crypto PMD device name */ #define CRYPTODEV_NAME_SNOW3G_PMD cryptodev_snow3g_pmd @@ -70,6 +72,7 @@ enum rte_cryptodev_type { RTE_CRYPTODEV_QAT_SYM_PMD, /**< QAT PMD Symmetric Crypto */ RTE_CRYPTODEV_SNOW3G_PMD, /**< SNOW 3G PMD */ RTE_CRYPTODEV_KASUMI_PMD, /**< KASUMI PMD */ + RTE_CRYPTODEV_LIBCRYPTO_PMD,/**< LibCrypto PMD */ }; extern const char **rte_cyptodev_names; -- 1.9.1
[dpdk-dev] [PATCH 3/4] app/test: added tests for libcrypto PMD
From: Marcin Kerlin <marcinx.ker...@intel.com> This patch containes unit tests for libcrypto PMD. User can use app/test application to check how to use this pmd and to verify crypto processing. Test name is cryptodev_libcrypto_autotest. For performance test cryptodev_libcrypto_perftest can be used. Signed-off-by: Piotr Azarewicz Signed-off-by: Daniel Mrzyglod Signed-off-by: Marcin Kerlin --- app/test/Makefile |1 + app/test/test_cryptodev.c | 1245 ++- app/test/test_cryptodev.h | 24 + app/test/test_cryptodev_aes.c | 42 +- app/test/test_cryptodev_aes_test_vectors.h| 887 ++ app/test/test_cryptodev_des_test_vectors.h| 754 app/test/test_cryptodev_hash_test_vectors.h | 439 +++ app/test/test_cryptodev_kasumi_test_vectors.h | 12 +- app/test/test_cryptodev_operations.c | 1576 + app/test/test_cryptodev_operations.h | 141 +++ app/test/test_cryptodev_perf.c| 699 ++- 11 files changed, 5725 insertions(+), 95 deletions(-) create mode 100644 app/test/test_cryptodev_aes_test_vectors.h create mode 100644 app/test/test_cryptodev_des_test_vectors.h create mode 100644 app/test/test_cryptodev_hash_test_vectors.h create mode 100644 app/test/test_cryptodev_operations.c create mode 100644 app/test/test_cryptodev_operations.h diff --git a/app/test/Makefile b/app/test/Makefile index 611d77a..0ee32a8 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -193,6 +193,7 @@ endif SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c +SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_operations.c SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_aes.c SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_perf.c SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 647787d..b7559b7 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -43,7 +43,11 @@ #include "test.h" #include "test_cryptodev.h" +#include "test_cryptodev_operations.h" #include "test_cryptodev_aes.h" +#include "test_cryptodev_hash_test_vectors.h" +#include "test_cryptodev_aes_test_vectors.h" +#include "test_cryptodev_des_test_vectors.h" #include "test_cryptodev_kasumi_test_vectors.h" #include "test_cryptodev_kasumi_hash_test_vectors.h" #include "test_cryptodev_snow3g_test_vectors.h" @@ -52,29 +56,6 @@ static enum rte_cryptodev_type gbl_cryptodev_type; -struct crypto_testsuite_params { - struct rte_mempool *mbuf_pool; - struct rte_mempool *op_mpool; - struct rte_cryptodev_config conf; - struct rte_cryptodev_qp_conf qp_conf; - - uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS]; - uint8_t valid_dev_count; -}; - -struct crypto_unittest_params { - struct rte_crypto_sym_xform cipher_xform; - struct rte_crypto_sym_xform auth_xform; - - struct rte_cryptodev_sym_session *sess; - - struct rte_crypto_op *op; - - struct rte_mbuf *obuf, *ibuf; - - uint8_t *digest; -}; - #define ALIGN_POW2_ROUNDUP(num, align) \ (((num) + (align) - 1) & ~((align) - 1)) @@ -83,12 +64,16 @@ struct crypto_unittest_params { */ static int test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( - struct crypto_unittest_params *ut_params); + struct crypto_unittest_params *ut_params, uint8_t *cipher_key, + uint8_t *hmac_key); static int test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, struct crypto_unittest_params *ut_params, - struct crypto_testsuite_params *ts_param); + struct crypto_testsuite_params *ts_param, + const uint8_t *cipher, + const uint8_t *digest, + const uint8_t *iv); static struct rte_mbuf * setup_test_string(struct rte_mempool *mpool, @@ -196,6 +181,23 @@ testsuite_setup(void) } } + /* Create 2 LIBCRYPTO devices if required */ + if (gbl_cryptodev_type == RTE_CRYPTODEV_LIBCRYPTO_PMD) { + nb_devs = rte_cryptodev_count_devtype( + RTE_CRYPTODEV_LIBCRYPTO_PMD); + if (nb_devs < 2) { + for (i = nb_devs; i < 2; i++) { + ret = rte_eal_vdev_init( + RTE_STR(CRYPTODEV_NAME_LIBCRYPTO_PMD), NULL); + + TEST_ASSERT(ret == 0, + "Failed to create instance %u of" + " pmd : %s", + i, RTE_STR(C
[dpdk-dev] [PATCH 4/4] examples/l2fwd-crypto: updated example for libcrypto PMD
From: Marcin KerlinTo verify real traffic l2fwd-crypto example can be used with this command: sudo ./build/l2fwd-crypto -c 0x3 -n 4 --vdev "cryptodev_libcrypto_pmd" --vdev "cryptodev_libcrypto_pmd" -- -p 0x3 --chain CIPHER_HASH --cipher_op ENCRYPT --cipher_algo AES_CBC --cipher_key 00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f --iv 00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:ff --auth_op GENERATE --auth_algo SHA1_HMAC --auth_key 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11:11:11:11:11: 11:11:11:11:11:11:11:11:11 Limitations --- Maximum number of sessions is 2048. Signed-off-by: Daniel Mrzyglod --- examples/l2fwd-crypto/main.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 66397a0..d912c23 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -341,18 +341,27 @@ fill_supported_algorithm_tables(void) strcpy(supported_auth_algo[i], "NOT_SUPPORTED"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_GCM], "AES_GCM"); + strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_GMAC], "AES_GMAC"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_MD5_HMAC], "MD5_HMAC"); + strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_MD5], "MD5"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_NULL], "NULL"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_XCBC_MAC], "AES_XCBC_MAC"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA1_HMAC], "SHA1_HMAC"); + strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA1], "SHA1"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA224_HMAC], "SHA224_HMAC"); + strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA224], "SHA224"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA256_HMAC], "SHA256_HMAC"); + strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA256], "SHA256"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA384_HMAC], "SHA384_HMAC"); + strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA384], "SHA384"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA512_HMAC], "SHA512_HMAC"); + strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA512], "SHA512"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SNOW3G_UIA2], "SNOW3G_UIA2"); strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_KASUMI_F9], "KASUMI_F9"); + + for (i = 0; i < RTE_CRYPTO_CIPHER_LIST_END; i++) strcpy(supported_cipher_algo[i], "NOT_SUPPORTED"); @@ -362,6 +371,8 @@ fill_supported_algorithm_tables(void) strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_NULL], "NULL"); strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_SNOW3G_UEA2], "SNOW3G_UEA2"); strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_KASUMI_F8], "KASUMI_F8"); + strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_3DES_CTR], "3DES_CTR"); + strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_3DES_CBC], "3DES_CBC"); } -- 1.9.1
[dpdk-dev] [PATCH v2 1/1] examples/l3fwd: modify and modularize l3fwd code
Many thanks to Intel team (Konstantin, Bruce and Declan) for below proposal to make changes to l3fwd code, their valuable inputs during interal review and help in performance tests. The main problem with l3fwd is that it is too monolithic with everything being in one file, and the various options all controlled by compile time flags. This means that it's hard to read and understand, and when making any changes, you need to go to a lot of work to try and ensure you cover all the code paths, since a compile of the app will not touch large parts of the l3fwd codebase. Following changes were done to fix the issues mentioned above > Split out the various lpm and hash specific functionality into separate files, so that l3fwd code has one file for common code e.g. args processing, mempool creation, and then individual files for the various forwarding approaches. Following are new file lists main.c (Common code for args processing, memppol creation, etc) l3fwd_em.c (Hash/Exact match aka 'EM' functionality) l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code) l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality) l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code) l3fwd.h (Common include for 'EM' and 'LPM') > The choosing of the lpm/hash path should be done at runtime, not compile time, via a command-line argument. This will ensure that both code paths get compiled in a single go Following examples show runtime options provided Select 'LPM' or 'EM' based on run time selection f.e. > l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM) Options "E" and "L" are mutualy-exclusive. If none selected, "L" is default. Signed-off-by: Ravi Kerur Signed-off-by: Piotr Azarewicz Tested-by: Tomasz Kulasek Acked-by: Tomasz Kulasek Acked-by: Konstantin Ananyev --- v2 changes: Rebase to latest code v1 changes: Rebase to latest code base for DPDK team review. Intel team's (Konstantin, Bruce and Declan) review comments v4<-v3: > Fix code review comments from Konstantin > Move buffer optimization code into l3fwd_lpm_sse.h and l3fwd_em_sse.h for LPM and EM respectively > Add compile time __SSE4_1__ for header file inclusion > Tested with CONFIG_RTE_MACHINE=default for non __SSE4_1__ compilation and build > Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04 v3<-v2: > Fix code review comments from Bruce > Fix multiple static definitions > Move local #defines to C files, common #defines to H file. > Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm > Pass additional parameter to send_single_packet > Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04 v2<-v1: > Fix errors in GCC 5.1 > Restore "static inline" functions, rearrange functions to take "static inline" into account > Duplicate main_loop for LPM and EM v1: > Split main.c into following 3 files > main.c, (parsing, buffer alloc, and other utilities) > l3fwd_lpm.c, (Longest Prefix Match functions) > l3fwd_em.c, (Exact Match f.e. Hash functions) > l3fwd.h, (Common defines and prototypes) > Select LPM or EM based on run time selection f.e. > l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM) > Options "E" and "L" are mutualy-exclusive. > Use function pointers during initialiation of relevant data structures. > Remove unwanted #ifdefs in the code with exception to > DO_RFC_1812_CHECKS > RTE_MACHINE_CPUFLAG_SSE4_2 > Compiled for > i686-native-linuxapp-gcc > x86_64-native-linuxapp-gcc > x86_x32-native-linuxapp-gcc > x86_64-native-bsdapp-gcc > Tested on > Ubuntu 14.04 (GCC 4.8.4) > FreeBSD 10.0 (GCC 4.8) > I217 and I218 respectively. examples/l3fwd/Makefile|9 +- examples/l3fwd/l3fwd.h | 211 examples/l3fwd/l3fwd_em.c | 776 ++ examples/l3fwd/l3fwd_em_sse.h | 479 + examples/l3fwd/l3fwd_lpm.c | 417 examples/l3fwd/l3fwd_lpm_sse.h | 610 +++ examples/l3fwd/main.c | 2207
[dpdk-dev] [PATCH v3 1/1] examples/l3fwd: modify and modularize l3fwd code
The main problem with l3fwd is that it is too monolithic with everything being in one file, and the various options all controlled by compile time flags. This means that it's hard to read and understand, and when making any changes, you need to go to a lot of work to try and ensure you cover all the code paths, since a compile of the app will not touch large parts of the l3fwd codebase. Following changes were done to fix the issues mentioned above > Split out the various lpm and hash specific functionality into separate files, so that l3fwd code has one file for common code e.g. args processing, mempool creation, and then individual files for the various forwarding approaches. Following are new file lists main.c (Common code for args processing, memppol creation, etc) l3fwd_em.c (Hash/Exact match aka 'EM' functionality) l3fwd_em_sse.h (SSE4_1 buffer optimizated 'EM' code) l3fwd_lpm.c (Longest Prefix Match aka 'LPM' functionality) l3fwd_lpm_sse.h (SSE4_1 buffer optimizated 'LPM' code) l3fwd.h (Common include for 'EM' and 'LPM') > The choosing of the lpm/hash path should be done at runtime, not compile time, via a command-line argument. This will ensure that both code paths get compiled in a single go Following examples show runtime options provided Select 'LPM' or 'EM' based on run time selection f.e. > l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (EM) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM) Options "E" and "L" are mutualy-exclusive. If none selected, "L" is default. Signed-off-by: Ravi Kerur Signed-off-by: Piotr Azarewicz Tested-by: Tomasz Kulasek Acked-by: Tomasz Kulasek Acked-by: Konstantin Ananyev --- v3 changes: add missed fix 'fix build without SSE4.1': - move l3fwd_lpm_no_opt_send_packets() to l3fwd_lpm.h - move l3fwd_em_no_opt_send_packets() to l3fwd_em.h - add #elses which provide proper headers respectively l3fwd_lpm.h/l3fwd_lpm.h or l3fwd_lpm_sse.h/l3fwd_lpm_sse.h v2 changes: Rebase to latest code v1 changes: Rebase to latest code base for DPDK team review. Intel team's (Konstantin, Bruce and Declan) review comments v4<-v3: > Fix code review comments from Konstantin > Move buffer optimization code into l3fwd_lpm_sse.h and l3fwd_em_sse.h for LPM and EM respectively > Add compile time __SSE4_1__ for header file inclusion > Tested with CONFIG_RTE_MACHINE=default for non __SSE4_1__ compilation and build > Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04 v3<-v2: > Fix code review comments from Bruce > Fix multiple static definitions > Move local #defines to C files, common #defines to H file. > Rename ipv4_l3fwd_route to ipv4_l3fwd_lpm and ipv4_l3fwd_em > Rename ipv6_l3fwd_route to ipv6_l3fwd_lpm and ipv6_l3fwd_lpm > Pass additional parameter to send_single_packet > Compiled for GCC 4.8.4 and 5.1 on Ubuntu 14.04 v2<-v1: > Fix errors in GCC 5.1 > Restore "static inline" functions, rearrange functions to take "static inline" into account > Duplicate main_loop for LPM and EM v1: > Split main.c into following 3 files > main.c, (parsing, buffer alloc, and other utilities) > l3fwd_lpm.c, (Longest Prefix Match functions) > l3fwd_em.c, (Exact Match f.e. Hash functions) > l3fwd.h, (Common defines and prototypes) > Select LPM or EM based on run time selection f.e. > l3fwd -c 0x1 -n 1 -- -p 0x1 -E ... (Exact Match) > l3fwd -c 0x1 -n 1 -- -p 0x1 -L ... (LPM) > Options "E" and "L" are mutualy-exclusive. > Use function pointers during initialiation of relevant data structures. > Remove unwanted #ifdefs in the code with exception to > DO_RFC_1812_CHECKS > RTE_MACHINE_CPUFLAG_SSE4_2 > Compiled for > i686-native-linuxapp-gcc > x86_64-native-linuxapp-gcc > x86_x32-native-linuxapp-gcc > x86_64-native-bsdapp-gcc > Tested on > Ubuntu 14.04 (GCC 4.8.4) > FreeBSD 10.0 (GCC 4.8) > I217 and I218 respectively. examples/l3fwd/Makefile| 11 +- examples/l3fwd/l3fwd.h | 211 examples/l3fwd/l3fwd_em.c | 749 ++ examples/l3fwd/l3fwd_em.h | 66 ++ examples/l3fwd/l3fwd_em_sse.h | 479 + examples/l3fwd/l3fwd_lpm.
[dpdk-dev] [PATCH v1 1/1] enic: fix local ol_flags variable
Expand local ol_flags field to 64-bits. The offload flags field (ol_flags) in rte_mbuf structure is 64-bits, so local copy of it must be 64-bits too. Moreover bit comparison between 16-bits variable and 64-bits value make no sense. CID 13218 : Operands don't affect result (CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: ol_flags & (18014398509481984ULL /* 1ULL << 54 */) is always 0 regardless of the values of its operands. This occurs as the logical operand of if. Coverity issue: 13218 Fixes: fefed3d1e62c ("enic: new driver") Signed-off-by: Piotr Azarewicz --- drivers/net/enic/enic.h|2 +- drivers/net/enic/enic_ethdev.c |2 +- drivers/net/enic/enic_main.c |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 09f3853..1bea120 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -191,7 +191,7 @@ extern unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq *wq); extern void enic_send_pkt(struct enic *enic, struct vnic_wq *wq, struct rte_mbuf *tx_pkt, unsigned short len, uint8_t sop, uint8_t eop, uint8_t cq_entry, - uint16_t ol_flags, uint16_t vlan_tag); + uint64_t ol_flags, uint16_t vlan_tag); extern void enic_post_wq_index(struct vnic_wq *wq); extern int enic_probe(struct enic *enic); diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 6bea940..29c5e1c 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -533,7 +533,7 @@ static uint16_t enicpmd_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, struct vnic_wq *wq = (struct vnic_wq *)tx_queue; struct enic *enic = vnic_dev_priv(wq->vdev); unsigned short vlan_id; - unsigned short ol_flags; + uint64_t ol_flags; uint8_t last_seg, eop; unsigned int host_tx_descs = 0; diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 60fe765..a78d0ec 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -180,7 +180,7 @@ void enic_post_wq_index(struct vnic_wq *wq) void enic_send_pkt(struct enic *enic, struct vnic_wq *wq, struct rte_mbuf *tx_pkt, unsigned short len, uint8_t sop, uint8_t eop, uint8_t cq_entry, - uint16_t ol_flags, uint16_t vlan_tag) + uint64_t ol_flags, uint16_t vlan_tag) { struct wq_enet_desc *desc = vnic_wq_next_desc(wq); uint16_t mss = 0; -- 1.7.9.5
[dpdk-dev] [PATCH v2 0/7] examples/ip_pipeline: CLI rework and improvements
Using the latest librte_cmdline improvements, the CLI implementation of the ip_pipeline application is streamlined and improved, which results in eliminating thousands of lines of code from the application, thus leading to code that is easier to maintain and extend. v2 changes: - added functions for parsing hex values - added standard error messages for CLI and file bulk - for all CLI commands: separate code paths for each flavor of each command (e.g. route add, route add default, route ls, route del, route del default, etc do not share any line of code) - for bulk commands: simplified error checking - added additional config files Acked-by: Cristian Dumitrescu Piotr Azarewicz (7): examples/ip_pipeline: add helper functions for parsing string examples/ip_pipeline: modifies common pipeline CLI examples/ip_pipeline: modifies firewall pipeline CLI examples/ip_pipeline: modifies flow classifications pipeline CLI examples/ip_pipeline: modifies flow action pipeline CLI examples/ip_pipeline: modifies routing pipeline CLI examples/ip_pipeline: update edge router usecase examples/ip_pipeline/Makefile |1 + examples/ip_pipeline/config/action.cfg | 68 + examples/ip_pipeline/config/action.sh | 119 ++ examples/ip_pipeline/config/action.txt |8 + .../ip_pipeline/config/edge_router_downstream.cfg | 30 +- .../ip_pipeline/config/edge_router_downstream.sh |7 +- .../ip_pipeline/config/edge_router_upstream.cfg| 36 +- .../ip_pipeline/config/edge_router_upstream.sh | 37 +- examples/ip_pipeline/config/firewall.cfg | 68 + examples/ip_pipeline/config/firewall.sh| 13 + examples/ip_pipeline/config/firewall.txt |9 + examples/ip_pipeline/config/flow.cfg | 72 + examples/ip_pipeline/config/flow.sh| 25 + examples/ip_pipeline/config/flow.txt | 17 + examples/ip_pipeline/config/l2fwd.cfg |5 +- examples/ip_pipeline/config/l3fwd.cfg |9 +- examples/ip_pipeline/config/l3fwd.sh | 32 +- examples/ip_pipeline/config/l3fwd_arp.cfg | 70 + examples/ip_pipeline/config/l3fwd_arp.sh | 43 + examples/ip_pipeline/config_parse.c| 257 +-- examples/ip_pipeline/parser.c | 745 +++ examples/ip_pipeline/parser.h | 54 +- examples/ip_pipeline/pipeline/pipeline_common_fe.c | 452 ++--- examples/ip_pipeline/pipeline/pipeline_common_fe.h |9 + examples/ip_pipeline/pipeline/pipeline_firewall.c | 1461 +- examples/ip_pipeline/pipeline/pipeline_firewall.h | 12 + .../ip_pipeline/pipeline/pipeline_flow_actions.c | 1505 +- .../ip_pipeline/pipeline/pipeline_flow_actions.h | 11 + .../pipeline/pipeline_flow_classification.c| 2082 +--- .../pipeline/pipeline_flow_classification.h| 28 + examples/ip_pipeline/pipeline/pipeline_routing.c | 1636 --- examples/ip_pipeline/thread_fe.c | 36 +- 32 files changed, 4009 insertions(+), 4948 deletions(-) create mode 100644 examples/ip_pipeline/config/action.cfg create mode 100644 examples/ip_pipeline/config/action.sh create mode 100644 examples/ip_pipeline/config/action.txt create mode 100644 examples/ip_pipeline/config/firewall.cfg create mode 100644 examples/ip_pipeline/config/firewall.sh create mode 100644 examples/ip_pipeline/config/firewall.txt create mode 100644 examples/ip_pipeline/config/flow.cfg create mode 100644 examples/ip_pipeline/config/flow.sh create mode 100644 examples/ip_pipeline/config/flow.txt create mode 100644 examples/ip_pipeline/config/l3fwd_arp.cfg create mode 100644 examples/ip_pipeline/config/l3fwd_arp.sh create mode 100644 examples/ip_pipeline/parser.c -- 1.7.9.5
[dpdk-dev] [PATCH v2 1/7] examples/ip_pipeline: add helper functions for parsing string
Add a couple of additional functions that will allow to parse many types of input parameters, i.e.: bool, 16, 32, 64 bits, hex, etc. Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/Makefile |1 + examples/ip_pipeline/config_parse.c | 257 +--- examples/ip_pipeline/parser.c | 745 +++ examples/ip_pipeline/parser.h | 54 ++- 4 files changed, 791 insertions(+), 266 deletions(-) create mode 100644 examples/ip_pipeline/parser.c diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile index 10fe1ba..5827117 100644 --- a/examples/ip_pipeline/Makefile +++ b/examples/ip_pipeline/Makefile @@ -50,6 +50,7 @@ INC += $(wildcard *.h) $(wildcard pipeline/*.h) # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) := main.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse.c +SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += parser.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c diff --git a/examples/ip_pipeline/config_parse.c b/examples/ip_pipeline/config_parse.c index e5efd03..ff917f3 100644 --- a/examples/ip_pipeline/config_parse.c +++ b/examples/ip_pipeline/config_parse.c @@ -30,6 +30,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include #include #include @@ -229,13 +230,6 @@ app_print_usage(char *prgname) rte_exit(0, app_usage, prgname, app_params_default.config_file); } -#define skip_white_spaces(pos) \ -({ \ - __typeof__(pos) _p = (pos); \ - for ( ; isspace(*_p); _p++);\ - _p; \ -}) - #define PARSER_PARAM_ADD_CHECK(result, params_array, section_name) \ do { \ APP_CHECK((result != -EINVAL), \ @@ -248,44 +242,6 @@ do { \ "Parse error in section \"%s\"", section_name); \ } while (0) -int -parser_read_arg_bool(const char *p) -{ - p = skip_white_spaces(p); - int result = -EINVAL; - - if (((p[0] == 'y') && (p[1] == 'e') && (p[2] == 's')) || - ((p[0] == 'Y') && (p[1] == 'E') && (p[2] == 'S'))) { - p += 3; - result = 1; - } - - if (((p[0] == 'o') && (p[1] == 'n')) || - ((p[0] == 'O') && (p[1] == 'N'))) { - p += 2; - result = 1; - } - - if (((p[0] == 'n') && (p[1] == 'o')) || - ((p[0] == 'N') && (p[1] == 'O'))) { - p += 2; - result = 0; - } - - if (((p[0] == 'o') && (p[1] == 'f') && (p[2] == 'f')) || - ((p[0] == 'O') && (p[1] == 'F') && (p[2] == 'F'))) { - p += 3; - result = 0; - } - - p = skip_white_spaces(p); - - if (p[0] != '\0') - return -EINVAL; - - return result; -} - #define PARSE_ERROR(exp, section, entry) \ APP_CHECK(exp, "Parse error in section \"%s\": entry \"%s\"\n", section, entry) @@ -318,217 +274,6 @@ APP_CHECK(exp, "Parse error in section \"%s\": unrecognized entry \"%s\"\n",\ APP_CHECK(exp, "Parse error in section \"%s\": duplicate entry \"%s\"\n",\ section, entry) -int -parser_read_uint64(uint64_t *value, const char *p) -{ - char *next; - uint64_t val; - - p = skip_white_spaces(p); - if (!isdigit(*p)) - return -EINVAL; - - val = strtoul(p, , 10); - if (p == next) - return -EINVAL; - - p = next; - switch (*p) { - case 'T': - val *= 1024ULL; - /* fall through */ - case 'G': - val *= 1024ULL; - /* fall through */ - case 'M': - val *= 1024ULL; - /* fall through */ - case 'k': - case 'K': - val *= 1024ULL; - p++; - break; - } - - p = skip_white_spaces(p); - if (*p != '\0') - return -EINVAL; - - *value = val; - return 0; -} - -int -parser_read_uint32(uint32_t *value, const char *p) -{ - uint64_t val = 0; - int ret = parser_read_uint64(, p); - - if (ret < 0) - return ret; - - if (val > UINT32_MAX) - return -ERANGE; - - *value = val; - return 0; -
[dpdk-dev] [PATCH v2 2/7] examples/ip_pipeline: modifies common pipeline CLI
All link commands are merged into one command: cmd_link_parsed. Improve run command to allow run periodically. Adding static keyword to a lot of token declarations. Signed-off-by: Tomasz Kulasek Signed-off-by: Michal Kobylinski Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/pipeline/pipeline_common_fe.c | 452 ++-- examples/ip_pipeline/pipeline/pipeline_common_fe.h |9 + examples/ip_pipeline/thread_fe.c | 36 +- 3 files changed, 244 insertions(+), 253 deletions(-) diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c b/examples/ip_pipeline/pipeline/pipeline_common_fe.c index a691d42..dc37a5f 100644 --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2016 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,12 +42,10 @@ #include #include #include -#include -#include -#include #include #include "pipeline_common_fe.h" +#include "parser.h" int app_pipeline_ping(struct app_params *app, @@ -464,16 +462,16 @@ cmd_ping_parsed( printf("Command failed\n"); } -cmdline_parse_token_string_t cmd_ping_p_string = +static cmdline_parse_token_string_t cmd_ping_p_string = TOKEN_STRING_INITIALIZER(struct cmd_ping_result, p_string, "p"); -cmdline_parse_token_num_t cmd_ping_pipeline_id = +static cmdline_parse_token_num_t cmd_ping_pipeline_id = TOKEN_NUM_INITIALIZER(struct cmd_ping_result, pipeline_id, UINT32); -cmdline_parse_token_string_t cmd_ping_ping_string = +static cmdline_parse_token_string_t cmd_ping_ping_string = TOKEN_STRING_INITIALIZER(struct cmd_ping_result, ping_string, "ping"); -cmdline_parse_inst_t cmd_ping = { +static cmdline_parse_inst_t cmd_ping = { .f = cmd_ping_parsed, .data = NULL, .help_str = "Pipeline ping", @@ -498,6 +496,7 @@ struct cmd_stats_port_in_result { uint32_t port_in_id; }; + static void cmd_stats_port_in_parsed( void *parsed_result, @@ -531,23 +530,23 @@ cmd_stats_port_in_parsed( stats.stats.n_pkts_drop); } -cmdline_parse_token_string_t cmd_stats_port_in_p_string = +static cmdline_parse_token_string_t cmd_stats_port_in_p_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, p_string, "p"); -cmdline_parse_token_num_t cmd_stats_port_in_pipeline_id = +static cmdline_parse_token_num_t cmd_stats_port_in_pipeline_id = TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, pipeline_id, UINT32); -cmdline_parse_token_string_t cmd_stats_port_in_stats_string = +static cmdline_parse_token_string_t cmd_stats_port_in_stats_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, stats_string, "stats"); -cmdline_parse_token_string_t cmd_stats_port_in_port_string = +static cmdline_parse_token_string_t cmd_stats_port_in_port_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, port_string, "port"); -cmdline_parse_token_string_t cmd_stats_port_in_in_string = +static cmdline_parse_token_string_t cmd_stats_port_in_in_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, in_string, "in"); @@ -555,7 +554,7 @@ cmdline_parse_token_string_t cmd_stats_port_in_in_string = TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, port_in_id, UINT32); -cmdline_parse_inst_t cmd_stats_port_in = { +static cmdline_parse_inst_t cmd_stats_port_in = { .f = cmd_stats_port_in_parsed, .data = NULL, .help_str = "Pipeline input port stats", @@ -617,31 +616,31 @@ cmd_stats_port_out_parsed( stats.stats.n_pkts_drop); } -cmdline_parse_token_string_t cmd_stats_port_out_p_string = +static cmdline_parse_token_string_t cmd_stats_port_out_p_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, p_string, "p"); -cmdline_parse_token_num_t cmd_stats_port_out_pipeline_id = +static cmdline_parse_token_num_t cmd_stats_port_out_pipeline_id = TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, pipeline_id, UINT32); -cmdline_parse_token_string_t cmd_stats_port_out_stats_string = +static cmdline_parse_token_string_t cmd_stats_port_out_stats_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, stats_string, "stats"); -cmdline_parse_token_string_t cmd_stats_port_out_port_string = +static cmdline_parse_token_string_t cmd_stats_port_out_port_string = TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, port_string, "port"); -cmdline_parse_token_string_t cmd_stats_port_out_out_string = +static
[dpdk-dev] [PATCH v2 3/7] examples/ip_pipeline: modifies firewall pipeline CLI
Each command are merged into one: cmd_firewall_parsed. ADD command format is changed: p firewall add priority ipv4 port and bulk command was modified: 1. firewall add bulk File line format: priority ipv4 port (protomask is a hex value) File line example: priority 0 ipv4 1.2.3.0 24 10.20.30.40 32 0 63 64 127 6 0xF port 3 2. firewall del bulk File line format: ipv4 File line example: ipv4 1.2.3.0 24 10.20.30.40 32 0 63 64 127 6 0xF Signed-off-by: Daniel Mrzyglod Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config/firewall.cfg | 68 + examples/ip_pipeline/config/firewall.sh | 13 + examples/ip_pipeline/config/firewall.txt |9 + examples/ip_pipeline/pipeline/pipeline_firewall.c | 1461 - examples/ip_pipeline/pipeline/pipeline_firewall.h | 12 + 5 files changed, 622 insertions(+), 941 deletions(-) create mode 100644 examples/ip_pipeline/config/firewall.cfg create mode 100644 examples/ip_pipeline/config/firewall.sh create mode 100644 examples/ip_pipeline/config/firewall.txt diff --git a/examples/ip_pipeline/config/firewall.cfg b/examples/ip_pipeline/config/firewall.cfg new file mode 100644 index 000..2f5dd9f --- /dev/null +++ b/examples/ip_pipeline/config/firewall.cfg @@ -0,0 +1,68 @@ +; BSD LICENSE +; +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; * Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; * Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in +; the documentation and/or other materials provided with the +; distribution. +; * Neither the name of Intel Corporation nor the names of its +; contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +; ___ +; RXQ0.0 --->| |---> TXQ0.0 +;| | +; RXQ1.0 --->| |---> TXQ1.0 +;| Firewall| +; RXQ2.0 --->| |---> TXQ2.0 +;| | +; RXQ3.0 --->| |---> TXQ3.0 +;|___| +;| +;+---> SINK0 (default rule) +; +; Input packet: Ethernet/IPv4 +; +; Packet buffer layout: +; #Field Name Offset (Bytes) Size (Bytes) +; 0Mbuf0 128 +; 1Headroom128 128 +; 2Ethernet header 256 14 +; 3IPv4 header 270 20 + +[EAL] +log_level = 0 + +[PIPELINE0] +type = MASTER +core = 0 + +[PIPELINE1] +type = FIREWALL +core = 1 +pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 +pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 SINK0 +n_rules = 4096 +pkt_type = ipv4 +;pkt_type = vlan_ipv4 +;pkt_type = qinq_ipv4 diff --git a/examples/ip_pipeline/config/firewall.sh b/examples/ip_pipeline/config/firewall.sh new file mode 100644 index 000..c83857e --- /dev/null +++ b/examples/ip_pipeline/config/firewall.sh @@ -0,0 +1,13 @@ +# +# run ./config/firewall.sh +# + +p 1 firewall add default 4 #SINK0 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.0.0.0 10 0 65535 0 65535 6 0xF port 0 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.64.0.0 10 0 65535 0 65535 6 0xF port 1 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.128.0.0 10 0 65535 0 65535 6 0xF port 2 +p 1 firewall add priority 1 ipv4 0.0.0.0 0 100.192.0.0 10 0 65535 0 65535 6 0xF port 3 + +#p 1 firewall add bulk ./config/firewall.txt + +p 1 firewall ls diff --git a/examples/ip_pipeline/config/firewall.txt b/examples/ip_pipeline/config/firewall.txt new file mode 100644 index 000..54cfffd --- /dev/null +++ b/examples/ip_pipeline/config/firewall.txt @@ -0,0 +1,9 @@ +# +# p firewall add bulk ./config/firewall.txt +# p
[dpdk-dev] [PATCH v2 5/7] examples/ip_pipeline: modifies flow action pipeline CLI
All commands merged into one: cmd_action_parsed. modified bulk command: action flow bulk File line format: flow meter 0 meter 1 meter 2 meter 3 policer 0policer 1 policer 2policer 3 port Signed-off-by: Marcin Kerlin Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config/action.cfg | 68 + examples/ip_pipeline/config/action.sh | 119 ++ examples/ip_pipeline/config/action.txt |8 + .../ip_pipeline/pipeline/pipeline_flow_actions.c | 1505 +++- .../ip_pipeline/pipeline/pipeline_flow_actions.h | 11 + 5 files changed, 707 insertions(+), 1004 deletions(-) create mode 100644 examples/ip_pipeline/config/action.cfg create mode 100644 examples/ip_pipeline/config/action.sh create mode 100644 examples/ip_pipeline/config/action.txt diff --git a/examples/ip_pipeline/config/action.cfg b/examples/ip_pipeline/config/action.cfg new file mode 100644 index 000..994ae94 --- /dev/null +++ b/examples/ip_pipeline/config/action.cfg @@ -0,0 +1,68 @@ +; BSD LICENSE +; +; Copyright(c) 2016 Intel Corporation. All rights reserved. +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; * Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; * Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in +; the documentation and/or other materials provided with the +; distribution. +; * Neither the name of Intel Corporation nor the names of its +; contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +; +; RXQ0.0 --->||---> TXQ0.0 +;|| +; RXQ1.0 --->||---> TXQ1.0 +;| Flow | +; RXQ2.0 --->| Actions|---> TXQ2.0 +;|| +; RXQ3.0 --->||---> TXQ3.0 +;|| +; +; +; Input packet: Ethernet/IPv4 +; +; Packet buffer layout: +; #Field Name Offset (Bytes) Size (Bytes) +; 0Mbuf0 128 +; 1Headroom128 128 +; 2Ethernet header 256 14 +; 3IPv4 header 270 20 + +[EAL] +log_level = 0 + +[PIPELINE0] +type = MASTER +core = 0 + +[PIPELINE1] +type = FLOW_ACTIONS +core = 1 +pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 +pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 +n_flows = 65536 +n_meters_per_flow = 4 +flow_id_offset = 286; ipdaddr +ip_hdr_offset = 270 +color_offset = 128 diff --git a/examples/ip_pipeline/config/action.sh b/examples/ip_pipeline/config/action.sh new file mode 100644 index 000..2986ae6 --- /dev/null +++ b/examples/ip_pipeline/config/action.sh @@ -0,0 +1,119 @@ +# +# run ./config/action.sh +# + +p 1 action flow 0 meter 0 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 0 g G y Y r R +p 1 action flow 0 meter 1 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 1 g G y Y r R +p 1 action flow 0 meter 2 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 2 g G y Y r R +p 1 action flow 0 meter 3 trtcm 125000 125000 100 100 +p 1 action flow 0 policer 3 g G y Y r R +p 1 action flow 0 port 0 + +p 1 action flow 1 meter 0 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 0 g G y Y r R +p 1 action flow 1 meter 1 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 1 g G y Y r R +p 1 action flow 1 meter 2 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 2 g G y Y r R +p 1 action flow 1 meter 3 trtcm 125000 125000 100 100 +p 1 action flow 1 policer 3 g G y Y r R +p 1 action flow 1 port 1 + +p 1 action flow 2 m
[dpdk-dev] [PATCH v2 4/7] examples/ip_pipeline: modifies flow classifications pipeline CLI
This patch modifies flow classifications pipeline command line interface. All commands are merged into one cmd_fc_parsed. Additionally a classification for ipv6, ipv4 and qinq can be added from configuration file. 1. flow add qinq bulk File line format: qinq port id File line example: qinq 1 2 port 3 id 0 2. flow add ipv4 bulk File line format: ipv4 port id File line example: ipv4 1.2.3.4 10.20.30.40 63 127 6 port 2 id 999 3. flow add ipv6 bulk File line format: ipv6 port id Signed-off-by: Tomasz Kulasek Signed-off-by: Marcin Kerlin Signed-off-by: Slawomir Mrozowicz Signed-off-by: Michal Kobylinski Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config/flow.cfg | 72 + examples/ip_pipeline/config/flow.sh| 25 + examples/ip_pipeline/config/flow.txt | 17 + .../pipeline/pipeline_flow_classification.c| 2082 +--- .../pipeline/pipeline_flow_classification.h| 28 + 5 files changed, 1027 insertions(+), 1197 deletions(-) create mode 100644 examples/ip_pipeline/config/flow.cfg create mode 100644 examples/ip_pipeline/config/flow.sh create mode 100644 examples/ip_pipeline/config/flow.txt diff --git a/examples/ip_pipeline/config/flow.cfg b/examples/ip_pipeline/config/flow.cfg new file mode 100644 index 000..6895d39 --- /dev/null +++ b/examples/ip_pipeline/config/flow.cfg @@ -0,0 +1,72 @@ +; BSD LICENSE +; +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; * Redistributions of source code must retain the above copyright +; notice, this list of conditions and the following disclaimer. +; * Redistributions in binary form must reproduce the above copyright +; notice, this list of conditions and the following disclaimer in +; the documentation and/or other materials provided with the +; distribution. +; * Neither the name of Intel Corporation nor the names of its +; contributors may be used to endorse or promote products derived +; from this software without specific prior written permission. +; +; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +; +; RXQ0.0 --->||---> TXQ0.0 +;|| +; RXQ1.0 --->||---> TXQ1.0 +;| Flow | +; RXQ2.0 --->| Classification |---> TXQ2.0 +;|| +; RXQ3.0 --->||---> TXQ3.0 +;|| +;| +;+---> SINK0 (flow lookup miss) +; +; Input packet: Ethernet/IPv4 +; +; Packet buffer layout: +; #Field Name Offset (Bytes) Size (Bytes) +; 0Mbuf0 128 +; 1Headroom128 128 +; 2Ethernet header 256 14 +; 3QinQ/IPv4/IPv6 header 270 8/20/40 + +[EAL] +log_level = 0 + +[PIPELINE0] +type = MASTER +core = 0 + +[PIPELINE1] +type = FLOW_CLASSIFICATION +core = 1 +pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 +pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 SINK0 +n_flows = 65536 +;key_size = 8; QinQ key size +;key_offset = 270; QinQ key offset +;key_mask = FFF0FFF0 ; QinQ key mask +key_size = 16 ; IPv4 5-tuple key size +key_offset = 278; IPv4 5-tuple key offset +key_mask = 00FF ; IPv4 5-tuple key mask +flowid_offset = 128 diff --git a/examples/ip_pipeline/config/flow.sh b/examples/ip_pipeline/config/flow.sh new file mode 100644 index 000..489c707 --- /dev/null +++ b/examples/ip_pipeline/config/flow.sh @@ -0,0 +1,25 @@ +# +# run ./config/flow.sh +# + + +# Flow classification (QinQ) + +#p 1 flow add default 4 #SINK0 +#p 1 flow add qinq 100 200 port 0 id 0 +#p 1 flow add qinq 101 201 port 1
[dpdk-dev] [PATCH v2 6/7] examples/ip_pipeline: modifies routing pipeline CLI
Several routing commands are merged into two commands: route and arp - these two commands are handled by cli library. Rest of the commands are handled internaly by the pipeline code. Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- examples/ip_pipeline/config/l2fwd.cfg|5 +- examples/ip_pipeline/config/l3fwd.cfg|9 +- examples/ip_pipeline/config/l3fwd.sh | 32 +- examples/ip_pipeline/config/l3fwd_arp.cfg| 70 + examples/ip_pipeline/config/l3fwd_arp.sh | 43 + examples/ip_pipeline/pipeline/pipeline_routing.c | 1636 ++ 6 files changed, 551 insertions(+), 1244 deletions(-) create mode 100644 examples/ip_pipeline/config/l3fwd_arp.cfg create mode 100644 examples/ip_pipeline/config/l3fwd_arp.sh diff --git a/examples/ip_pipeline/config/l2fwd.cfg b/examples/ip_pipeline/config/l2fwd.cfg index c743a14..a1df9e6 100644 --- a/examples/ip_pipeline/config/l2fwd.cfg +++ b/examples/ip_pipeline/config/l2fwd.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -44,6 +44,9 @@ ;|| ; +[EAL] +log_level = 0 + [PIPELINE0] type = MASTER core = 0 diff --git a/examples/ip_pipeline/config/l3fwd.cfg b/examples/ip_pipeline/config/l3fwd.cfg index 5449dc3..02c8f36 100644 --- a/examples/ip_pipeline/config/l3fwd.cfg +++ b/examples/ip_pipeline/config/l3fwd.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -50,6 +50,9 @@ ; 2Ethernet header 256 14 ; 3IPv4 header 270 20 +[EAL] +log_level = 0 + [PIPELINE0] type = MASTER core = 0 @@ -59,5 +62,7 @@ type = ROUTING core = 1 pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 pktq_out = TXQ0.0 TXQ1.0 TXQ2.0 TXQ3.0 SINK0 -encap = ethernet; encap = ethernet / ethernet_qinq / ethernet_mpls +encap = ethernet +;encap = ethernet_qinq +;encap = ethernet_mpls ip_hdr_offset = 270 diff --git a/examples/ip_pipeline/config/l3fwd.sh b/examples/ip_pipeline/config/l3fwd.sh index 2774010..47406aa 100644 --- a/examples/ip_pipeline/config/l3fwd.sh +++ b/examples/ip_pipeline/config/l3fwd.sh @@ -1,9 +1,33 @@ +# +# run ./config/l3fwd.sh +# + # Routing: encap = ethernet, arp = off p 1 route add default 4 #SINK0 -p 1 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 -p 1 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 -p 1 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 -p 1 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 +p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 +p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 +p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 +p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 p 1 route ls + + +# Routing: encap = ethernet_qinq, arp = off + +#p 1 route add default 4 #SINK0 +#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 1000 2000 +#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 1001 2001 +#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 1002 2002 +#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 1003 2003 +#p 1 route ls + + +# Routing: encap = ethernet_mpls, arp = off + +#p 1 route add default 4 #SINK0 +#p 1 route add 100.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 mpls 1000:2000 +#p 1 route add 100.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 mpls 1001:2001 +#p 1 route add 100.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 mpls 1002:2002 +#p 1 route add 100.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 mpls 1003:2003 +#p 1 route ls diff --git a/examples/ip_pipeline/config/l3fwd_arp.cfg b/examples/ip_pipeline/config/l3fwd_arp.cfg new file mode 100644 index 000..2c63c8f --- /dev/null +++ b/examples/ip_pipeline/config/l3fwd_arp.cfg @@ -0,0 +1,70 @@ +; BSD LICENSE +; +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. +; All rights reserved. +; +; Redistribution and use in source and binary forms, with or without +; modification, are permitted provided that the following conditions +; are met: +; +; * Redistributions of source code
[dpdk-dev] [PATCH v2 7/7] examples/ip_pipeline: update edge router usecase
Update edge router usecase config files to use bulk commands. Signed-off-by: Piotr Azarewicz Acked-by: Cristian Dumitrescu --- .../ip_pipeline/config/edge_router_downstream.cfg | 30 +++- .../ip_pipeline/config/edge_router_downstream.sh |7 ++-- .../ip_pipeline/config/edge_router_upstream.cfg| 36 +-- .../ip_pipeline/config/edge_router_upstream.sh | 37 +--- 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/examples/ip_pipeline/config/edge_router_downstream.cfg b/examples/ip_pipeline/config/edge_router_downstream.cfg index 85bbab8..c6b4e1f 100644 --- a/examples/ip_pipeline/config/edge_router_downstream.cfg +++ b/examples/ip_pipeline/config/edge_router_downstream.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -36,9 +36,9 @@ ; network) contains the following functional blocks: Packet RX & Routing, ; Traffic management and Packet TX. The input packets are assumed to be ; IPv4, while the output packets are Q-in-Q IPv4. - +; ; A simple implementation for this functional pipeline is presented below. - +; ; Packet Rx &Traffic Management Packet Tx ; Routing(Pass-Through) (Pass-Through) ; _ SWQ0 __ SWQ4 _ @@ -50,11 +50,23 @@ ;| | SWQ3 | | SWQ7 | | ; RXQ3.0 --->| |->| |->| |---> TXQ3.0 ;|_| |__| |_| -; | _|_ ^ _|_ ^ _|_ ^ _|_ ^ -; ||___|||___|||___|||___|| -; +--> SINK0 |___|||___|||___|||___|| -; (route miss)|__| |__| |__| |__| -; TM0 TM1 TM2 TM3 +; | | ^ | ^ | ^ | ^ +; | |__| |__| |__| |__| +; +--> SINK0 TM0 TM1 TM2 TM3 +; (Default) +; +; Input packet: Ethernet/IPv4 +; Output packet: Ethernet/QinQ/IPv4 +; +; Packet buffer layout: +; #Field Name Offset (Bytes) Size (Bytes) +; 0Mbuf0 128 +; 1Headroom128 128 +; 2Ethernet header 256 14 +; 3IPv4 header 270 20 + +[EAL] +log_level = 0 [PIPELINE0] type = MASTER @@ -67,7 +79,7 @@ pktq_in = RXQ0.0 RXQ1.0 RXQ2.0 RXQ3.0 pktq_out = SWQ0 SWQ1 SWQ2 SWQ3 SINK0 encap = ethernet_qinq qinq_sched = test -ip_hdr_offset = 270; mbuf (128) + headroom (128) + ethernet header (14) = 270 +ip_hdr_offset = 270 [PIPELINE2] type = PASS-THROUGH diff --git a/examples/ip_pipeline/config/edge_router_downstream.sh b/examples/ip_pipeline/config/edge_router_downstream.sh index ce46beb..67c3a0d 100644 --- a/examples/ip_pipeline/config/edge_router_downstream.sh +++ b/examples/ip_pipeline/config/edge_router_downstream.sh @@ -1,3 +1,7 @@ +# +# run ./config/edge_router_downstream.sh +# + # Routing: Ether QinQ, ARP off @@ -6,5 +10,4 @@ p 1 route add 0.0.0.0 10 port 0 ether a0:b0:c0:d0:e0:f0 qinq 256 257 p 1 route add 0.64.0.0 10 port 1 ether a1:b1:c1:d1:e1:f1 qinq 258 259 p 1 route add 0.128.0.0 10 port 2 ether a2:b2:c2:d2:e2:f2 qinq 260 261 p 1 route add 0.192.0.0 10 port 3 ether a3:b3:c3:d3:e3:f3 qinq 262 263 - -p 1 route ls +#p 1 route ls diff --git a/examples/ip_pipeline/config/edge_router_upstream.cfg b/examples/ip_pipeline/config/edge_router_upstream.cfg index a08c5cc..dea42b9 100644 --- a/examples/ip_pipeline/config/edge_router_upstream.cfg +++ b/examples/ip_pipeline/config/edge_router_upstream.cfg @@ -1,6 +1,6 @@ ; BSD LICENSE ; -; Copyright(c) 2015 Intel Corporation. All rights reserved. +; Copyright(c) 2015-2016 Intel Corporation. All rights reserved. ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without @@ -29,6 +29,7 @@ ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ; An edge router typically sits between two networks such as the provider ; core network and the provider access network. A typical packet processing ; pipeline for the upstream
[dpdk-dev] [PATCH v1 1/1] examples/quota_watermark: fix low_watermark variable placement
qw app at its init stage reserve 2*sizeof(int) memory space for quota and low_watermark shared variables, but both apps (qw and qwctl) assign wrong address for low_watermark pointer (out of reserved memzone space) due to wrong pointer arithmetic. CID 30709 : Extra sizeof expression (SIZEOF_MISMATCH) suspicious_pointer_arithmetic: Adding 4UL /* sizeof (int) */ to pointer (unsigned int *)(*qw_memzone).addr of type unsigned int * is suspicious because adding an integral value to this pointer automatically scales that value by the size, 4 bytes, of the pointed-to type, unsigned int. Most likely, sizeof (int) is extraneous and should be replaced with 1. Coverity issue: 30709 Fixes: 1d6c3ee3321a ("examples/quota_watermark: initial import") Signed-off-by: Piotr Azarewicz --- examples/quota_watermark/qw/init.c |2 +- examples/quota_watermark/qwctl/qwctl.c |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/quota_watermark/qw/init.c b/examples/quota_watermark/qw/init.c index afc1366..c208721 100644 --- a/examples/quota_watermark/qw/init.c +++ b/examples/quota_watermark/qw/init.c @@ -170,5 +170,5 @@ setup_shared_variables(void) rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); quota = qw_memzone->addr; -low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); +low_watermark = (unsigned int *) qw_memzone->addr + 1; } diff --git a/examples/quota_watermark/qwctl/qwctl.c b/examples/quota_watermark/qwctl/qwctl.c index eb2f618..4961089 100644 --- a/examples/quota_watermark/qwctl/qwctl.c +++ b/examples/quota_watermark/qwctl/qwctl.c @@ -68,7 +68,7 @@ setup_shared_variables(void) rte_exit(EXIT_FAILURE, "Couldn't find memzone\n"); quota = qw_memzone->addr; -low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); +low_watermark = (unsigned int *) qw_memzone->addr + 1; } int main(int argc, char **argv) -- 1.7.9.5
[dpdk-dev] [PATCH v1 1/1] examples/l2fwd-crypto: improve random key generator
This patch improve generate_random_key() function by replacing rand() function with reading from /dev/urandom. CID 120136 : Calling risky function (DC.WEAK_CRYPTO) dont_call: rand should not be used for security related applications, as linear congruential algorithms are too easy to break Coverity issue: 120136 Signed-off-by: Piotr Azarewicz --- examples/l2fwd-crypto/main.c | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index d18c813..e1f0a1e 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include #include @@ -581,10 +583,18 @@ l2fwd_simple_forward(struct rte_mbuf *m, unsigned portid) static void generate_random_key(uint8_t *key, unsigned length) { - unsigned i; + int fd; + int ret; + + fd = open("/dev/urandom", O_RDONLY); + if (fd < 0) + rte_exit(EXIT_FAILURE, "Failed to generate random key\n"); - for (i = 0; i < length; i++) - key[i] = rand() % 0xff; + ret = read(fd, key, length); + close(fd); + + if (ret != (signed)length) + rte_exit(EXIT_FAILURE, "Failed to generate random key\n"); } static struct rte_cryptodev_sym_session * @@ -1180,8 +1190,6 @@ l2fwd_crypto_parse_timer_period(struct l2fwd_crypto_options *options, static void l2fwd_crypto_default_options(struct l2fwd_crypto_options *options) { - srand(time(NULL)); - options->portmask = 0x; options->nb_ports_per_lcore = 1; options->refresh_period = 1; -- 1.7.9.5