[dpdk-dev] [PATCH] app/testpmd: configure flowgen packet size though --txpkts
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> "flowgen" forwarding mode has fixed packet size (300). Let it re-use --txpkts option for specifying generated packet size. Signed-off-by: Maciej Czekaj --- app/test-pmd/config.c | 2 +- app/test-pmd/flowgen.c | 3 +-- app/test-pmd/parameters.c | 3 ++- doc/guides/testpmd_app_ug/run_app.rst | 3 ++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index bfcbff9..db682bd 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -954,7 +954,7 @@ rxtx_config_display(void) rx_mode.hw_strip_crc ? "enabled" : "disabled", nb_pkt_per_burst); - if (cur_fwd_eng == _only_engine) + if (cur_fwd_eng == _only_engine || cur_fwd_eng == _gen_engine) printf(" packet len=%u - nb packet segments=%d\n", (unsigned)tx_pkt_length, (int) tx_pkt_nb_segs); diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index a6abe91..e6b1ea2 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -74,7 +74,6 @@ /* hardcoded configuration (for now) */ static unsigned cfg_n_flows= 1024; -static unsigned cfg_pkt_size = 300; static uint32_t cfg_ip_src = IPv4(10, 254, 0, 0); static uint32_t cfg_ip_dst = IPv4(10, 253, 0, 0); static uint16_t cfg_udp_src= 1000; @@ -118,7 +117,7 @@ ip_sum(const unaligned_uint16_t *hdr, int hdr_len) static void pkt_burst_flow_gen(struct fwd_stream *fs) { - unsigned pkt_size = cfg_pkt_size - 4; /* Adjust FCS */ + unsigned pkt_size = tx_pkt_length - 4; /* Adjust FCS */ struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; struct rte_mempool *mbp; struct rte_mbuf *pkt; diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 8792c2c..c498b4b 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -191,7 +191,8 @@ usage(char* progname) "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); printf(" --no-flush-rx: Don't flush RX streams before forwarding." " Used mainly with PCAP drivers.\n"); - printf(" --txpkts=X[,Y]*: set TX segment sizes.\n"); + printf(" --txpkts=X[,Y]*: set TX segment sizes" + " or total packet length.\n"); printf(" --disable-link-check: disable check on link status when " "starting/stopping ports.\n"); } diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 7712bd2..34bf924 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -450,7 +450,8 @@ The commandline options are: * ``--txpkts=X[,Y]`` -Set TX segment sizes. +Set TX segment sizes or total packet length. Valid for ``tx-only`` +and ``flowgen`` forwarding modes. * ``--disable-link-check`` diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f87e0c2..c1868e6 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -405,7 +405,7 @@ When retry is enabled, the transmit delay time and number of retries can also be set txpkts ~~ -Set the length of each segment of the TX-ONLY packets:: +Set the length of each segment of the TX-ONLY packets or length of packet for FLOWGEN mode:: testpmd> set txpkts (x[,y]*) -- 2.7.4
[dpdk-dev] [PATCH v2 3/3] app/testpmd: support setting up txq_flags value in command line
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> "port config all txqflags " allows for specifying txq_flags value in command line. Signed-off-by: Maciej Czekaj --- app/test-pmd/cmdline.c | 69 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 2 files changed, 78 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 929d19a..1921612 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2730,6 +2730,74 @@ cmdline_parse_inst_t cmd_set_txsplit = { }, }; +/* *** CONFIG TX QUEUE FLAGS *** */ + +struct cmd_config_txqflags_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t config; + cmdline_fixed_string_t all; + cmdline_fixed_string_t what; + int32_t hexvalue; +}; + +static void cmd_config_txqflags_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_txqflags_result *res = parsed_result; + + if (!all_ports_stopped()) { + printf("Please stop all ports first\n"); + return; + } + + if (strcmp(res->what, "txqflags")) { + printf("Unknown parameter\n"); + return; + } + + if (res->hexvalue >= 0) { + txq_flags = res->hexvalue; + } else { + printf("txqflags must be >= 0\n"); + return; + } + + init_port_config(); + + cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); +} + +cmdline_parse_token_string_t cmd_config_txqflags_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port, +"port"); +cmdline_parse_token_string_t cmd_config_txqflags_config = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config, +"config"); +cmdline_parse_token_string_t cmd_config_txqflags_all = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all, +"all"); +cmdline_parse_token_string_t cmd_config_txqflags_what = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what, +"txqflags"); +cmdline_parse_token_num_t cmd_config_txqflags_value = + TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result, + hexvalue, INT32); + +cmdline_parse_inst_t cmd_config_txqflags = { + .f = cmd_config_txqflags_parsed, + .data = NULL, + .help_str = "port config all txqflags value", + .tokens = { + (void *)_config_txqflags_port, + (void *)_config_txqflags_config, + (void *)_config_txqflags_all, + (void *)_config_txqflags_what, + (void *)_config_txqflags_value, + NULL, + }, +}; + /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ struct cmd_rx_vlan_filter_all_result { cmdline_fixed_string_t rx_vlan; @@ -10487,6 +10555,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)_config_rx_mode_flag, (cmdline_parse_inst_t *)_config_rss, (cmdline_parse_inst_t *)_config_rxtx_queue, + (cmdline_parse_inst_t *)_config_txqflags, (cmdline_parse_inst_t *)_config_rss_reta, (cmdline_parse_inst_t *)_showport_reta, (cmdline_parse_inst_t *)_config_burst, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f2755cb..1545350 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1198,6 +1198,15 @@ RX scatter mode is off by default. The ``on`` option is equivalent to the ``--enable-scatter`` command-line option. +port config - TX queue flags +~~ + +Set a hexadecimal bitmap of TX queue flags for all ports:: + + testpmd> port config all txqflags value + +This command is equivalent to the ``--txqflags`` command-line option. + port config - RX Checksum ~ -- 1.9.1
[dpdk-dev] [PATCH v2 2/3] app/testpmd: extend port config with scatter parameter
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> "port config all scatter on|off" allows for controlling rxmode.enable_scatter in command line. Signed-off-by: Maciej Czekaj --- app/test-pmd/cmdline.c | 17 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index c5b9479..929d19a 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -559,10 +559,10 @@ static void cmd_help_long_parsed(void *parsed_result, "port config all max-pkt-len (value)\n" "Set the max packet length.\n\n" - "port config all (crc-strip|rx-cksum|hw-vlan|hw-vlan-filter|" + "port config all (crc-strip|scatter|rx-cksum|hw-vlan|hw-vlan-filter|" "hw-vlan-strip|hw-vlan-extend|drop-en)" " (on|off)\n" - "Set crc-strip/rx-checksum/hardware-vlan/drop_en" + "Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" " for ports.\n\n" "port config all rss (all|ip|tcp|udp|sctp|ether|none)\n" @@ -1410,6 +1410,15 @@ cmd_config_rx_mode_flag_parsed(void *parsed_result, printf("Unknown parameter\n"); return; } + } else if (!strcmp(res->name, "scatter")) { + if (!strcmp(res->value, "on")) + rx_mode.enable_scatter = 1; + else if (!strcmp(res->value, "off")) + rx_mode.enable_scatter = 0; + else { + printf("Unknown parameter\n"); + return; + } } else if (!strcmp(res->name, "rx-cksum")) { if (!strcmp(res->value, "on")) rx_mode.hw_ip_checksum = 1; @@ -1487,7 +1496,7 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, - "crc-strip#rx-cksum#hw-vlan#" + "crc-strip#scatter#rx-cksum#hw-vlan#" "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, @@ -1496,7 +1505,7 @@ cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = cmdline_parse_inst_t cmd_config_rx_mode_flag = { .f = cmd_config_rx_mode_flag_parsed, .data = NULL, - .help_str = "port config all crc-strip|rx-cksum|hw-vlan|" + .help_str = "port config all crc-strip|scatter|rx-cksum|hw-vlan|" "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", .tokens = { (void *)_config_rx_mode_flag_port, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index aed5e47..f2755cb 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1187,6 +1187,17 @@ CRC stripping is off by default. The ``on`` option is equivalent to the ``--crc-strip`` command-line option. +port config - scatter +~~~ + +Set RX scatter mode on or off for all ports:: + + testpmd> port config all scatter (on|off) + +RX scatter mode is off by default. + +The ``on`` option is equivalent to the ``--enable-scatter`` command-line option. + port config - RX Checksum ~ -- 1.9.1
[dpdk-dev] [PATCH v2 1/3] app/testpmd: add "enable-scatter" parameter
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> This parameter allows for controlling rxmode.enable_scatter which in turn allow for multi-segment packet receive tests. Signed-off-by: Maciej Czekaj --- app/test-pmd/parameters.c | 3 +++ doc/guides/testpmd_app_ug/run_app.rst | 4 2 files changed, 7 insertions(+) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 55572eb..8792c2c 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -526,6 +526,7 @@ launch_args_parse(int argc, char** argv) { "pkt-filter-drop-queue", 1, 0, 0 }, { "crc-strip", 0, 0, 0 }, { "enable-rx-cksum",0, 0, 0 }, + { "enable-scatter", 0, 0, 0 }, { "disable-hw-vlan",0, 0, 0 }, { "disable-hw-vlan-filter", 0, 0, 0 }, { "disable-hw-vlan-strip", 0, 0, 0 }, @@ -764,6 +765,8 @@ launch_args_parse(int argc, char** argv) } if (!strcmp(lgopts[opt_idx].name, "crc-strip")) rx_mode.hw_strip_crc = 1; + if (!strcmp(lgopts[opt_idx].name, "enable-scatter")) + rx_mode.enable_scatter = 1; if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) rx_mode.hw_ip_checksum = 1; diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index f605564..8fb0651 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -289,6 +289,10 @@ The commandline options are: Enable hardware RX checksum offload. +* ``--enable-scatter`` + +Enable scatter (multi-segment) RX. + * ``--disable-hw-vlan`` Disable hardware VLAN. -- 1.9.1
[dpdk-dev] [PATCH v2 0/3] testpmd: extend commands for better scatter-gather tests
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> v2: - included documentation changes - added value check for "port config all txqflags" as in --tqxflags paramater Maciej Czekaj (3): app/testpmd: add "enable-scatter" parameter app/testpmd: extend port config with scatter parameter app/testpmd: support setting up txq_flags value in command line app/test-pmd/cmdline.c | 86 +++-- app/test-pmd/parameters.c | 3 + doc/guides/testpmd_app_ug/run_app.rst | 4 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 20 +++ 4 files changed, 109 insertions(+), 4 deletions(-) -- 1.9.1
[dpdk-dev] [PATCH 3/3] app/testpmd: support setting up txq_flags value in command line
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> "port config all txqflags " allows for specifying txq_flags value in command line. Signed-off-by: Maciej Czekaj --- app/test-pmd/cmdline.c | 64 ++ 1 file changed, 64 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 929d19a..680164f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2730,6 +2730,69 @@ cmdline_parse_inst_t cmd_set_txsplit = { }, }; +/* *** CONFIG TX QUEUE FLAGS *** */ + +struct cmd_config_txqflags_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t config; + cmdline_fixed_string_t all; + cmdline_fixed_string_t what; + int32_t hexvalue; +}; + +static void cmd_config_txqflags_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_txqflags_result *res = parsed_result; + + if (!all_ports_stopped()) { + printf("Please stop all ports first\n"); + return; + } + + if (!strcmp(res->what, "txqflags")) { + txq_flags = res->hexvalue; + } else { + printf("Unknown parameter\n"); + return; + } + + init_port_config(); + + cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); +} + +cmdline_parse_token_string_t cmd_config_txqflags_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, port, +"port"); +cmdline_parse_token_string_t cmd_config_txqflags_config = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, config, +"config"); +cmdline_parse_token_string_t cmd_config_txqflags_all = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, all, +"all"); +cmdline_parse_token_string_t cmd_config_txqflags_what = + TOKEN_STRING_INITIALIZER(struct cmd_config_txqflags_result, what, +"txqflags"); +cmdline_parse_token_num_t cmd_config_txqflags_value = + TOKEN_NUM_INITIALIZER(struct cmd_config_txqflags_result, + hexvalue, INT32); + +cmdline_parse_inst_t cmd_config_txqflags = { + .f = cmd_config_txqflags_parsed, + .data = NULL, + .help_str = "port config all txqflags value", + .tokens = { + (void *)_config_txqflags_port, + (void *)_config_txqflags_config, + (void *)_config_txqflags_all, + (void *)_config_txqflags_what, + (void *)_config_txqflags_value, + NULL, + }, +}; + /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ struct cmd_rx_vlan_filter_all_result { cmdline_fixed_string_t rx_vlan; @@ -10487,6 +10550,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)_config_rx_mode_flag, (cmdline_parse_inst_t *)_config_rss, (cmdline_parse_inst_t *)_config_rxtx_queue, + (cmdline_parse_inst_t *)_config_txqflags, (cmdline_parse_inst_t *)_config_rss_reta, (cmdline_parse_inst_t *)_showport_reta, (cmdline_parse_inst_t *)_config_burst, -- 1.9.1
[dpdk-dev] [PATCH 1/3] app/testpmd: add "enable-scatter" parameter
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> This parameter allows for controlling rxmode.enable_scatter which in turn allow for multi-segment packet receive tests. Signed-off-by: Maciej Czekaj --- app/test-pmd/parameters.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 55572eb..8792c2c 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -526,6 +526,7 @@ launch_args_parse(int argc, char** argv) { "pkt-filter-drop-queue", 1, 0, 0 }, { "crc-strip", 0, 0, 0 }, { "enable-rx-cksum",0, 0, 0 }, + { "enable-scatter", 0, 0, 0 }, { "disable-hw-vlan",0, 0, 0 }, { "disable-hw-vlan-filter", 0, 0, 0 }, { "disable-hw-vlan-strip", 0, 0, 0 }, @@ -764,6 +765,8 @@ launch_args_parse(int argc, char** argv) } if (!strcmp(lgopts[opt_idx].name, "crc-strip")) rx_mode.hw_strip_crc = 1; + if (!strcmp(lgopts[opt_idx].name, "enable-scatter")) + rx_mode.enable_scatter = 1; if (!strcmp(lgopts[opt_idx].name, "enable-rx-cksum")) rx_mode.hw_ip_checksum = 1; -- 1.9.1
[dpdk-dev] [PATCH 0/3] testpmd: extend commands for better scatter-gather tests
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> This patch adds 1 parameter and 2 command line items: * --enable-scatter * port config all scatter on|off * port config all txqflags value With these, testpmd can be used for testing scatter-gather in both TX and RX. Maciej Czekaj (3): app/testpmd: add "enable-scatter" parameter app/testpmd: extend port config with scatter parameter app/testpmd: support setting up txq_flags value in command line app/test-pmd/cmdline.c| 81 --- app/test-pmd/parameters.c | 3 ++ 2 files changed, 80 insertions(+), 4 deletions(-) -- 1.9.1
[dpdk-dev] [PATCH v2] l3fwd: Fix compilation & enable exact match mode on ARM.
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> Enable NEON support in exact match mode. l3fwd example did not compile on ARM due to SSE2 instrincics used in generic part. Some instrinsins were used to initialize data structures and those were replaced by ordinary structure initalization. All SSE2 intrinsics used in forwarding, i.e. masking the IP/TCP header are moved to single inline function and made arch-specific. Signed-off-by: Maciej Czekaj --- examples/l3fwd/l3fwd.h| 4 ++- examples/l3fwd/l3fwd_em.c | 72 --- examples/l3fwd/l3fwd_em_hlm_sse.h | 32 - examples/l3fwd/main.c | 2 +- 4 files changed, 64 insertions(+), 46 deletions(-) diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index da6d369..7dcc7e5 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -34,6 +34,8 @@ #ifndef __L3_FWD_H__ #define __L3_FWD_H__ +#include + #define DO_RFC_1812_CHECKS #define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1 @@ -103,7 +105,7 @@ extern uint32_t enabled_port_mask; extern int ipv6; /**< ipv6 is false by default. */ extern uint32_t hash_entry_number; -extern __m128i val_eth[RTE_MAX_ETHPORTS]; +extern xmm_t val_eth[RTE_MAX_ETHPORTS]; extern struct lcore_conf lcore_conf[RTE_MAX_LCORE]; diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index f6a65d8..0adf8f4 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -85,7 +85,7 @@ union ipv4_5tuple_host { uint16_t port_src; uint16_t port_dst; }; - __m128i xmm; + xmm_t xmm; }; #define XMM_NUM_IN_IPV6_5TUPLE 3 @@ -109,9 +109,11 @@ union ipv6_5tuple_host { uint16_t port_dst; uint64_t reserve; }; - __m128i xmm[XMM_NUM_IN_IPV6_5TUPLE]; + xmm_t xmm[XMM_NUM_IN_IPV6_5TUPLE]; }; + + struct ipv4_l3fwd_em_route { struct ipv4_5tuple key; uint8_t if_out; @@ -236,9 +238,27 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len, static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; -static __m128i mask0; -static __m128i mask1; -static __m128i mask2; +static rte_xmm_t mask0; +static rte_xmm_t mask1; +static rte_xmm_t mask2; + +#if defined(__SSE2__) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + __m128i data = _mm_loadu_si128((__m128i *)(key)); + + return _mm_and_si128(data, mask); +} +#elif defined(__ARM_NEON) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + int32x4_t data = vld1q_s32((int32_t *)key); + + return vandq_s32(data, mask); +} +#endif static inline uint8_t em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) @@ -249,13 +269,12 @@ em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live); - __m128i data = _mm_loadu_si128((__m128i *)(ipv4_hdr)); /* * Get 5 tuple: dst port, src port, dst IP address, * src IP address and protocol. */ - key.xmm = _mm_and_si128(data, mask0); + key.xmm = em_mask_key(ipv4_hdr, mask0.x); /* Find destination port */ ret = rte_hash_lookup(ipv4_l3fwd_lookup_struct, (const void *)); @@ -271,35 +290,31 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv6_hdr = (uint8_t *)ipv6_hdr + offsetof(struct ipv6_hdr, payload_len); - __m128i data0 = - _mm_loadu_si128((__m128i *)(ipv6_hdr)); - __m128i data1 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i))); - __m128i data2 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i)+sizeof(__m128i))); + void *data0 = ipv6_hdr; + void *data1 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t); + void *data2 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t) + sizeof(xmm_t); /* Get part of 5 tuple: src IP address lower 96 bits and protocol */ - key.xmm[0] = _mm_and_si128(data0, mask1); + key.xmm[0] = em_mask_key(data0, mask1.x); /* * Get part of 5 tuple: dst IP address lower 96 bits * and src IP address higher 32 bits. */ - key.xmm[1] = data1; + key.xmm[1] = *(xmm_t *)data1; /* * Get part of 5 tuple: dst port and src port * and dst IP address higher 32 bits. */ - key.xmm[2] = _mm_and_si128(data2, mask2); + key.xmm[2] = em_mask_key(data2, mask2.x); /* Find destination port */ ret = rte_hash_lookup(ipv6_l3fwd_lookup_struct, (c
[dpdk-dev] [PATCH v2] l3fwd: Fix compilation & enable exact match mode on ARM.
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> v2: * Fixed compilation issue with HASH_MULTI_LOOKUP Maciej Czekaj (1): l3fwd: Fix compilation & enable exact match mode on ARM. examples/l3fwd/l3fwd.h| 4 ++- examples/l3fwd/l3fwd_em.c | 72 --- examples/l3fwd/l3fwd_em_hlm_sse.h | 32 - examples/l3fwd/main.c | 2 +- 4 files changed, 64 insertions(+), 46 deletions(-) -- 1.9.1
[dpdk-dev] [PATCH] l3fwd: Fix compilation & enable exact match mode on ARM.
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> Enable NEON support in exact match mode. l3fwd example did not compile on ARM due to SSE2 instrincics used in generic part. Some instrinsins were used to initialize data structures and those were replaced by ordinary structure initalization. All SSE2 intrinsics used in forwarding, i.e. masking the IP/TCP header are moved to single inline function and made arch-specific. Signed-off-by: Maciej Czekaj --- examples/l3fwd/l3fwd.h| 4 ++- examples/l3fwd/l3fwd_em.c | 72 +-- examples/l3fwd/main.c | 2 +- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index da6d369..7dcc7e5 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -34,6 +34,8 @@ #ifndef __L3_FWD_H__ #define __L3_FWD_H__ +#include + #define DO_RFC_1812_CHECKS #define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1 @@ -103,7 +105,7 @@ extern uint32_t enabled_port_mask; extern int ipv6; /**< ipv6 is false by default. */ extern uint32_t hash_entry_number; -extern __m128i val_eth[RTE_MAX_ETHPORTS]; +extern xmm_t val_eth[RTE_MAX_ETHPORTS]; extern struct lcore_conf lcore_conf[RTE_MAX_LCORE]; diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index f6a65d8..0adf8f4 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -85,7 +85,7 @@ union ipv4_5tuple_host { uint16_t port_src; uint16_t port_dst; }; - __m128i xmm; + xmm_t xmm; }; #define XMM_NUM_IN_IPV6_5TUPLE 3 @@ -109,9 +109,11 @@ union ipv6_5tuple_host { uint16_t port_dst; uint64_t reserve; }; - __m128i xmm[XMM_NUM_IN_IPV6_5TUPLE]; + xmm_t xmm[XMM_NUM_IN_IPV6_5TUPLE]; }; + + struct ipv4_l3fwd_em_route { struct ipv4_5tuple key; uint8_t if_out; @@ -236,9 +238,27 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len, static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; -static __m128i mask0; -static __m128i mask1; -static __m128i mask2; +static rte_xmm_t mask0; +static rte_xmm_t mask1; +static rte_xmm_t mask2; + +#if defined(__SSE2__) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + __m128i data = _mm_loadu_si128((__m128i *)(key)); + + return _mm_and_si128(data, mask); +} +#elif defined(__ARM_NEON) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + int32x4_t data = vld1q_s32((int32_t *)key); + + return vandq_s32(data, mask); +} +#endif static inline uint8_t em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) @@ -249,13 +269,12 @@ em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live); - __m128i data = _mm_loadu_si128((__m128i *)(ipv4_hdr)); /* * Get 5 tuple: dst port, src port, dst IP address, * src IP address and protocol. */ - key.xmm = _mm_and_si128(data, mask0); + key.xmm = em_mask_key(ipv4_hdr, mask0.x); /* Find destination port */ ret = rte_hash_lookup(ipv4_l3fwd_lookup_struct, (const void *)); @@ -271,35 +290,31 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv6_hdr = (uint8_t *)ipv6_hdr + offsetof(struct ipv6_hdr, payload_len); - __m128i data0 = - _mm_loadu_si128((__m128i *)(ipv6_hdr)); - __m128i data1 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i))); - __m128i data2 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i)+sizeof(__m128i))); + void *data0 = ipv6_hdr; + void *data1 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t); + void *data2 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t) + sizeof(xmm_t); /* Get part of 5 tuple: src IP address lower 96 bits and protocol */ - key.xmm[0] = _mm_and_si128(data0, mask1); + key.xmm[0] = em_mask_key(data0, mask1.x); /* * Get part of 5 tuple: dst IP address lower 96 bits * and src IP address higher 32 bits. */ - key.xmm[1] = data1; + key.xmm[1] = *(xmm_t *)data1; /* * Get part of 5 tuple: dst port and src port * and dst IP address higher 32 bits. */ - key.xmm[2] = _mm_and_si128(data2, mask2); + key.xmm[2] = em_mask_key(data2, mask2.x); /* Find destination port */ ret = rte_hash_lookup(ipv6_l3fwd_lookup_struct, (const void *)); return (uint8_t)((ret < 0) ? portid : ipv6_l3fw
[dpdk-dev] [PATCH] l3fwd: Fix compilation & enable exact match mode on ARM
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> This patch depends on following pending patches: lpm: add support for NEON http://dpdk.org/dev/patchwork/patch/10479/ lpm: make rte_lpm_lookupx4 API definition architecture agnostic http://dpdk.org/dev/patchwork/patch/10478/ Maciej Czekaj (1): l3fwd: Fix compilation & enable exact match mode on ARM. examples/l3fwd/l3fwd.h| 4 ++- examples/l3fwd/l3fwd_em.c | 72 +-- examples/l3fwd/main.c | 2 +- 3 files changed, 48 insertions(+), 30 deletions(-) -- 1.9.1
[dpdk-dev] [PATCH] l3fwd: Fix compilation & enable exact match mode on ARM.
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> Enable NEON support in exact match mode. l3fwd example did not compile on ARM due to SSE2 instrincics used in generic part. Some instrinsins were used to initialize data structures and those were replaced by ordinary structure initalization. All SSE2 intrinsics used in forwarding, i.e. masking the IP/TCP header are moved to single inline function and made arch-specific. Signed-off-by: Maciej Czekaj --- examples/l3fwd/l3fwd.h| 4 ++- examples/l3fwd/l3fwd_em.c | 72 +-- examples/l3fwd/main.c | 2 +- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index da6d369..7dcc7e5 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -34,6 +34,8 @@ #ifndef __L3_FWD_H__ #define __L3_FWD_H__ +#include + #define DO_RFC_1812_CHECKS #define RTE_LOGTYPE_L3FWD RTE_LOGTYPE_USER1 @@ -103,7 +105,7 @@ extern uint32_t enabled_port_mask; extern int ipv6; /**< ipv6 is false by default. */ extern uint32_t hash_entry_number; -extern __m128i val_eth[RTE_MAX_ETHPORTS]; +extern xmm_t val_eth[RTE_MAX_ETHPORTS]; extern struct lcore_conf lcore_conf[RTE_MAX_LCORE]; diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index f6a65d8..0adf8f4 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -85,7 +85,7 @@ union ipv4_5tuple_host { uint16_t port_src; uint16_t port_dst; }; - __m128i xmm; + xmm_t xmm; }; #define XMM_NUM_IN_IPV6_5TUPLE 3 @@ -109,9 +109,11 @@ union ipv6_5tuple_host { uint16_t port_dst; uint64_t reserve; }; - __m128i xmm[XMM_NUM_IN_IPV6_5TUPLE]; + xmm_t xmm[XMM_NUM_IN_IPV6_5TUPLE]; }; + + struct ipv4_l3fwd_em_route { struct ipv4_5tuple key; uint8_t if_out; @@ -236,9 +238,27 @@ ipv6_hash_crc(const void *data, __rte_unused uint32_t data_len, static uint8_t ipv4_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; static uint8_t ipv6_l3fwd_out_if[L3FWD_HASH_ENTRIES] __rte_cache_aligned; -static __m128i mask0; -static __m128i mask1; -static __m128i mask2; +static rte_xmm_t mask0; +static rte_xmm_t mask1; +static rte_xmm_t mask2; + +#if defined(__SSE2__) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + __m128i data = _mm_loadu_si128((__m128i *)(key)); + + return _mm_and_si128(data, mask); +} +#elif defined(__ARM_NEON) +static inline xmm_t +em_mask_key(void *key, xmm_t mask) +{ + int32x4_t data = vld1q_s32((int32_t *)key); + + return vandq_s32(data, mask); +} +#endif static inline uint8_t em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) @@ -249,13 +269,12 @@ em_get_ipv4_dst_port(void *ipv4_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv4_hdr = (uint8_t *)ipv4_hdr + offsetof(struct ipv4_hdr, time_to_live); - __m128i data = _mm_loadu_si128((__m128i *)(ipv4_hdr)); /* * Get 5 tuple: dst port, src port, dst IP address, * src IP address and protocol. */ - key.xmm = _mm_and_si128(data, mask0); + key.xmm = em_mask_key(ipv4_hdr, mask0.x); /* Find destination port */ ret = rte_hash_lookup(ipv4_l3fwd_lookup_struct, (const void *)); @@ -271,35 +290,31 @@ em_get_ipv6_dst_port(void *ipv6_hdr, uint8_t portid, void *lookup_struct) (struct rte_hash *)lookup_struct; ipv6_hdr = (uint8_t *)ipv6_hdr + offsetof(struct ipv6_hdr, payload_len); - __m128i data0 = - _mm_loadu_si128((__m128i *)(ipv6_hdr)); - __m128i data1 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i))); - __m128i data2 = - _mm_loadu_si128((__m128i *)(((uint8_t *)ipv6_hdr)+ - sizeof(__m128i)+sizeof(__m128i))); + void *data0 = ipv6_hdr; + void *data1 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t); + void *data2 = ((uint8_t *)ipv6_hdr) + sizeof(xmm_t) + sizeof(xmm_t); /* Get part of 5 tuple: src IP address lower 96 bits and protocol */ - key.xmm[0] = _mm_and_si128(data0, mask1); + key.xmm[0] = em_mask_key(data0, mask1.x); /* * Get part of 5 tuple: dst IP address lower 96 bits * and src IP address higher 32 bits. */ - key.xmm[1] = data1; + key.xmm[1] = *(xmm_t *)data1; /* * Get part of 5 tuple: dst port and src port * and dst IP address higher 32 bits. */ - key.xmm[2] = _mm_and_si128(data2, mask2); + key.xmm[2] = em_mask_key(data2, mask2.x); /* Find destination port */ ret = rte_hash_lookup(ipv6_l3fwd_lookup_struct, (const void *)); return (uint8_t)((ret < 0) ? portid : ipv6_l3fw
[dpdk-dev] [PATCH] l3fwd: Fix compilation & enable exact match mode on ARM
From: Maciej Czekaj <maciej.cze...@caviumnetworks.com> This patch depends on following pending patches: lpm: add support for NEON http://dpdk.org/dev/patchwork/patch/10479/ lpm: make rte_lpm_lookupx4 API definition architecture agnostic http://dpdk.org/dev/patchwork/patch/10478/ Maciej Czekaj (1): l3fwd: Fix compilation & enable exact match mode on ARM. examples/l3fwd/l3fwd.h| 4 ++- examples/l3fwd/l3fwd_em.c | 72 +-- examples/l3fwd/main.c | 2 +- 3 files changed, 48 insertions(+), 30 deletions(-) -- 1.9.1