distributor lib performance enhancements
PATCH 1/2 distributor lib performance enhancements
This patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
Original API (and code) is kept for backward compatibility
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - 4.8x
4 workers - 2.9x
8 workers - 1.8x 12 workers - 2.1x
16 workers - 1.8x
[PATCH v1 1/2] lib: distributor performance enhancements [PATCH v1 2/2] example: distributor app modified to use burstAPI
PATCH 1/2 lib: distributor performance enhancements
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with _burst at the end of the function names.
--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 27 +- lib/librte_distributor/rte_distributor_burst.c | 617 ++++++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 255 ++++++++++ lib/librte_distributor/rte_distributor_common.h | 75 +++ 5 files changed, 950 insertions(+), 26 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_burst.c create mode 100644 lib/librte_distributor/rte_distributor_burst.h create mode 100644 lib/librte_distributor/rte_distributor_common.h
lib/librte_distributor/Makefile +2 -0
@@ -43,9 +43,11 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_burst.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_burst.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.c +1 -26
@@ -40,34 +40,9 @@#include <rte_errno.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> +#include "rte_distributor_common.h" #include "rte_distributor.h" -#define NO_FLAGS 0 -#define RTE_DISTRIB_PREFIX "DT_" - -/* we will use the bottom four bits of pointer for flags, shifting out -* the top four bits to make room (since a 64-bit pointer actually only uses -* 48 bits). An arithmetic-right-shift will then appropriately restore the -* original pointer value with proper sign extension into the top bits. */ -#define RTE_DISTRIB_FLAG_BITS 4 -#define RTE_DISTRIB_FLAGS_MASK (0x0F) -#define RTE_DISTRIB_NO_BUF 0/**< empty flags: no buffer requested */ -#define RTE_DISTRIB_GET_BUF (1)/**< worker requests a buffer, returns old */ -#define RTE_DISTRIB_RETURN_BUF (2)/**< worker returns a buffer, no request */ - -#define RTE_DISTRIB_BACKLOG_SIZE 8 -#define RTE_DISTRIB_BACKLOG_MASK (RTE_DISTRIB_BACKLOG_SIZE - 1) - -#define RTE_DISTRIB_MAX_RETURNS 128 -#define RTE_DISTRIB_RETURNS_MASK (RTE_DISTRIB_MAX_RETURNS - 1) - -/** -* Maximum number of workers allowed. -* Be aware of increasing the limit, becaus it is limited by how we track -* in-flight tags. See @in_flight_bitmask and @rte_distributor_process -*/ -#define RTE_DISTRIB_MAX_WORKERS 64 -/** * Buffer structure used to pass the pointer data between cores. This is cache * line aligned, but to improve performance and prevent adjacent cache-line
lib/librte_distributor/rte_distributor_burst.c new file +617 -0
617 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.h new file +255 -0
255 lines not on this page · raw message
lib/librte_distributor/rte_distributor_common.h new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.7.4
v2 cover distributor library performance enhancements
This patch aims to improve the throughput of the distributor library.
It adds a series of API calls similar to the original API, but with "_burst" in the function names. Usage is similar (but not identical), in that there are now bursts of mbufs sent to each worker at a time instead of a single mbuf pointer. See the header file rte_distributor_burst.h for more details on API usage.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
* Added doc updates
Notes:
Apps using the birst API must now work in bursts, as up to 8 are given to a worker at a time
For performance in matching, Flow ID's are 15-bits (non-zero) Original API (and code) is kept for backward compatibility
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - 4.8x
4 workers - 2.9x
8 workers - 1.8x 12 workers - 2.1x
16 workers - 1.8x
[PATCH v2 1/5] lib: distributor performance enhancements [PATCH v2 2/5] test: unit tests for new distributor burst api [PATCH v2 3/5] test: add distributor_perf autotest [PATCH v2 4/5] example: distributor app showing burst api [PATCH v2 5/5] doc: distributor library changes for new burst api
PATCH v2 1/5 lib: distributor performance enhancements
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with _burst at the end of the function names
--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 72 +-- lib/librte_distributor/rte_distributor_burst.c | 642 +++++++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 255 ++++++++++ lib/librte_distributor/rte_distributor_priv.h | 190 ++++++++ 5 files changed, 1090 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_burst.c create mode 100644 lib/librte_distributor/rte_distributor_burst.h create mode 100644 lib/librte_distributor/rte_distributor_priv.h
lib/librte_distributor/Makefile +2 -0
@@ -43,9 +43,11 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_burst.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_burst.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.c +1 -71
80 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.c new file +642 -0
642 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.h new file +255 -0
255 lines not on this page · raw message
lib/librte_distributor/rte_distributor_priv.h new file +190 -0
190 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v2 1/5] lib: distributor performance enhancements
Quoted 14 lines · David Hunt
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with
_burstat the end of the function namesSigned-off-by David Hunt <[email protected]>lib/librte_distributor/rte_distributor_burst.c new file +7
-0+ +int +rte_distributor_get_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **pkts, +struct rte_mbuf **oldpkt,unsigned int return_count) +{ +unsigned int count;
lib/librte_distributor/rte_distributor_burst.c line 151
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+uint64_t retries =0 ; + +rte_distributor_request_pkt_burst (d, worker_id, oldpkt, return_count); + + count =rte_distributor_poll_pkt_burst (d, worker_id, pkts); +while (count ==0 ) { +rte_pause (); + retries++; +if (retries >1000 ) { + retries =0 ;
This retries write may not have any significance as it just before the return
lib/librte_distributor/rte_distributor_burst.c line 154
Quoted 3 lines
lib/librte_distributor/rte_distributor_burst.c new file +3
-0+return 0 ; + } +uint64_t t =__rdtsc ()+100 ;
Use rte_ version of __rdtsc.
Quoted 22 lines
lib/librte_distributor/rte_distributor_burst.c new file +22
-0+ +while (__rdtsc () < t) +rte_pause (); + + count =rte_distributor_poll_pkt_burst (d, worker_id, pkts); + } +return count; +} + +int +rte_distributor_return_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **oldpkt,int num) +{ +struct rte_distributor_buffer_burst *buf = &d->bufs[worker_id]; +unsigned int i; + +for (i =0 ; i <RTE_DIST_BURST_SIZE ; i++) +/* Switch off the return bit first */ + buf->retptr64[i] &= ~RTE_DISTRIB_RETURN_BUF ; + +for (i = num; i-- >0 ; ) + buf->retptr64[i] = (((int64_t)(uintptr_t)oldpkt[i]) <<
lib/librte_distributor/rte_distributor_burst.c line 202
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+ RTE_DISTRIB_FLAG_BITS) | RTE_DISTRIB_RETURN_BUF; + +/* set the GET_BUF but even if we got no returns */ + buf->retptr64[0 ] |=RTE_DISTRIB_GET_BUF ; + +return 0 ; +} + +#if RTE_MACHINE_CPUFLAG_SSE2 +static inline void
Move SSE version of the code to separate file so that later other SIMD arch specific version like NEON can be incorporated.
Quoted 67 lines
lib/librte_distributor/rte_distributor_burst.c new file +67
-0+find_match_sse2(struct rte_distributor_burst *d, + uint16_t *data_ptr, + uint16_t *output_ptr) +{ +/* Setup */ + __m128i incoming_fids; +__m128i inflight_fids; +__m128i preflight_fids; +__m128i wkr; +__m128i mask1; +__m128i mask2; +__m128i output; +struct rte_distributor_backlog *bl; + +/* +* Function overview: +* 2. Loop through all worker ID's +* 2a. Load the current inflights for that worker into an xmm reg +* 2b. Load the current backlog for that worker into an xmm reg +* 2c. use cmpestrm to intersect flow_ids with backlog and inflights +* 2d. Add any matches to the output +* 3. Write the output xmm (matching worker ids). +*/ + + + output =_mm_set1_epi16 (0 ); + incoming_fids =_mm_load_si128 ((__m128i *)data_ptr); + +for (uint16_t i =0 ; i < d->num_workers; i++) { + bl = &d->backlog[i]; + + inflight_fids = +_mm_load_si128 ((__m128i *)&(d->in_flight_tags[i])); + preflight_fids = +_mm_load_si128 ((__m128i *)(bl->tags)); + +/* +* Any incoming_fid that exists anywhere in inflight_fids will +* have 0xffff in same position of the mask as the incoming fid +* Example (shortened to bytes for brevity): +* incoming_fids 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 +* inflight_fids 0x03 0x05 0x07 0x00 0x00 0x00 0x00 0x00 +* mask 0x00 0x00 0xff 0x00 0xff 0x00 0xff 0x00 +*/ + + mask1 =_mm_cmpestrm (inflight_fids,8 , incoming_fids,8 , + _SIDD_UWORD_OPS | + _SIDD_CMP_EQUAL_ANY | + _SIDD_UNIT_MASK); + mask2 =_mm_cmpestrm (preflight_fids,8 , incoming_fids,8 , + _SIDD_UWORD_OPS | + _SIDD_CMP_EQUAL_ANY | + _SIDD_UNIT_MASK); + + mask1 =_mm_or_si128 (mask1, mask2); +/* +* Now mask contains 0xffff where there's a match. +* Next we need to store the worker_id in the relevant position +* in the output. +*/ + + wkr =_mm_set1_epi16 (i+1 ); + mask1 =_mm_and_si128 (mask1, wkr); + output =_mm_or_si128 (mask1, output); + } + +/* process a set of packets to distribute them to workers */
lib/librte_distributor/rte_distributor_burst.c
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+int +rte_distributor_process_burst (struct rte_distributor_burst *d, +struct rte_mbuf **mbufs,unsigned int num_mbufs) +{ +unsigned int next_idx =0 ; +static unsigned int wkr; +struct rte_mbuf *next_mb =NULL ; +int64_t next_value =0 ; +uint16_t new_tag =0 ; + uint16_t flows[8] __rte_cache_aligned;
The const 8 has been used down in the function also. Please replace with macro
lib/librte_distributor/rte_distributor_burst.c line 402
Quoted 1 line
lib/librte_distributor/rte_distributor_burst.c new file +1
-0+//static int iter=0;
Please remove the test-code with // across the patch.
Quoted 19 lines
lib/librte_distributor/rte_distributor_burst.c new file +19
-0+ +if (unlikely (num_mbufs ==0 )) { +/* Flush out all non-full cache-lines to workers. */ +for (unsigned int wid =0 ; wid < d->num_workers; wid++) { +if ((d->bufs[wid].bufptr64[0 ] &RTE_DISTRIB_GET_BUF )) { +release (d, wid); +handle_returns (d, wid); + } + } +return 0 ; + } + +while (next_idx < num_mbufs) { +uint16_t matches[8 ]; +int pkts; + +if (d->bufs[wkr].bufptr64[0 ] &RTE_DISTRIB_GET_BUF ) + d->bufs[wkr].count =0 ; +
lib/librte_distributor/rte_distributor_burst.c line 431
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+for (unsigned int i =0 ; i <RTE_DIST_BURST_SIZE ; i++) { +if (mbufs[next_idx + i]) { +/* flows have to be non-zero */ + flows[i] = mbufs[next_idx + i]->hash.usr |1 ; + }else + flows[i] =0 ; + } + +switch (d->dist_match_fn) { +#ifdef RTE_MACHINE_CPUFLAG_SSE2
Is this conditional compilation flag is really required ? i.e RTE_DIST_MATCH_SSE will not enabled in non SSE case
Quoted 29 lines
lib/librte_distributor/rte_distributor_burst.c new file +29
-0+case RTE_DIST_MATCH_SSE : +find_match_sse2 (d, &flows[0 ], &matches[0 ]); +break ; +#endif +default : +find_match_scalar (d, &flows[0 ], &matches[0 ]); + } + +/* +* Matches array now contain the intended worker ID (+1) of +* the incoming packets. Any zeroes need to be assigned +* workers. +*/ + +if ((num_mbufs - next_idx) <RTE_DIST_BURST_SIZE ) + pkts = num_mbufs - next_idx; +else + pkts =RTE_DIST_BURST_SIZE ; + +for (int j =0 ; j < pkts; j++) { + + next_mb = mbufs[next_idx++]; + next_value = (((int64_t )(uintptr_t )next_mb) << +RTE_DISTRIB_FLAG_BITS ); +/* +* User is advocated to set tag vaue for each +* mbuf before calling rte_distributor_process. +* User defined tags are used to identify flows, +* or sessions.
lib/librte_distributor/rte_distributor_burst.c line 470
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+*/ +/* flows MUST be non-zero */ + new_tag = (uint16_t )(next_mb->hash.usr) |1 ; + +/* +* Using the next line will cause the find_match +* function to be optimised out, making this function +* do parallel (non-atomic) distribution +*/ +//matches[j] = 0;
test code with //
Re: [PATCH v2 1/5] lib: distributor performance enhancements
Thanks for the review, Jerin, I very much appreciate it. I'll address all the minor comments, and I've a comment or two on the remaining changes below.
Quoted 2 lines · Jerin Jacob
On Thu, Dec 22, 2016 at 04:37:04AM +0000, David Hunt wrote:
--snip--
Quoted 12 lines
lib/librte_distributor/rte_distributor_burst.c line 202
Quoted 9 lines
lib/librte_distributor/rte_distributor_burst.c new file +9
-0+ +/* set the GET_BUF but even if we got no returns */ + buf->retptr64[0 ] |=RTE_DISTRIB_GET_BUF ; + +return 0 ; +} + +#if RTE_MACHINE_CPUFLAG_SSE2 +static inline voidMove SSE version of the code to separate file so that later other SIMD arch specific version like NEON can be incorporated.
Sure. Will do. I'll model it on the i40e SIMD layout.
Quoted 4 lines
lib/librte_distributor/rte_distributor_burst.c line 431
Quoted 2 lines
lib/librte_distributor/rte_distributor_burst.c new file +2
-0+switch (d->dist_match_fn) { +#ifdef RTE_MACHINE_CPUFLAG_SSE2 Is this conditional compilation flag is really required ? i.e
RTE_DIST_MATCH_SSEwill not enabled in non SSE case
So I can always leave the call to find_match_sse2 in there, but the run-time cpu flags check will take care of whether it's called or not? OK sure.
Thanks,
Dave.
v3 cover distributor-performance-improvements
In reply to David HuntThis patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
Original API (and code) is kept for backward compatibility
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - 4.8x
4 workers - 2.9x
8 workers - 1.8x 12 workers - 2.1x
16 workers - 1.8x
[PATCH v3 1/6] lib: distributor performance enhancements [PATCH v3 2/6] lib: add distributor vector flow matching [PATCH v3 3/6] test: unit tests for new distributor burst api [PATCH v3 4/6] test: add distributor_perf autotest [PATCH v3 5/6] example: distributor app showing burst api [PATCH v3 6/6] doc: distributor library changes for new burst api
PATCH v3 1/6 lib: distributor performance enhancements
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with _burst at the end of the function names
--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 72 +--- lib/librte_distributor/rte_distributor_burst.c | 558 +++++++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 255 +++++++++++ lib/librte_distributor/rte_distributor_priv.h | 189 +++++++++ 5 files changed, 1005 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_burst.c create mode 100644 lib/librte_distributor/rte_distributor_burst.h create mode 100644 lib/librte_distributor/rte_distributor_priv.h
lib/librte_distributor/Makefile +2 -0
@@ -43,9 +43,11 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_burst.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_burst.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.c +1 -71
80 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.c new file +558 -0
558 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.h new file +255 -0
255 lines not on this page · raw message
lib/librte_distributor/rte_distributor_priv.h new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v3 2/6 lib: add distributor vector flow matching
In reply to David Hunt--- lib/librte_distributor/Makefile | 4 + lib/librte_distributor/rte_distributor_burst.c | 11 +- lib/librte_distributor/rte_distributor_match_sse.c | 113 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_priv.h | 6 ++ 4 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 lib/librte_distributor/rte_distributor_match_sse.c
lib/librte_distributor/Makefile +4 -0
@@ -44,6 +44,10 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_burst.c +ifeq ($(CONFIG_RTE_ARCH_X86),y) +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_match_sse.c +endif + # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor_burst.c +10 -1
@@ -352,6 +352,9 @@ rte_distributor_process_burst(struct rte_distributor_burst *d, }switch (d->dist_match_fn) { +case RTE_DIST_MATCH_VECTOR : +find_match_vec (d, &flows[0 ], &matches[0 ]); +break ;default :find_match_scalar (d, &flows[0 ], &matches[0 ]); }
@@ -538,7 +541,13 @@ rte_distributor_create_burst(const char *name,snprintf (d->name,sizeof (d->name),"%s" , name); d->num_workers = num_workers; - d->dist_match_fn =RTE_DIST_MATCH_SCALAR ; +#if defined(RTE_ARCH_X86 ) +if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_SSE2 )) { + d->dist_match_fn =RTE_DIST_MATCH_VECTOR ; + }else { +#endif + d->dist_match_fn =RTE_DIST_MATCH_SCALAR ; + }/* * Set up the backog tags so they're pointing at the second cache
lib/librte_distributor/rte_distributor_match_sse.c new file +113 -0
113 lines not on this page · raw message
lib/librte_distributor/rte_distributor_priv.h +6 -0
@@ -155,6 +155,7 @@ struct rte_distributor {/* All different signature compare functions */ enum rte_distributor_match_function {RTE_DIST_MATCH_SCALAR =0 , +RTE_DIST_MATCH_VECTOR ,RTE_DIST_MATCH_NUM };
@@ -182,6 +183,11 @@ struct rte_distributor_burst {enum rte_distributor_match_function dist_match_fn; }; +void +find_match_vec (struct rte_distributor_burst *d, +uint16_t *data_ptr, +uint16_t *output_ptr); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v3 3/6 test: unit tests for new distributor burst api
In reply to David Hunt--- app/test/test_distributor.c | 501 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 392 insertions(+), 109 deletions(-)
app/test/test_distributor.c +392 -109
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -40,11 +40,24 @@#include <rte_mempool.h> #include <rte_mbuf.h> #include <rte_distributor.h> +#include <rte_distributor_burst.h> #define ITER_POWER 20/* log 2 of how many iterations we do when timing. */ #define BURST 32#define BIG_BATCH 1024 +#define DIST_SINGLE 0 +#define DIST_BURST 1 +#define DIST_NUM_TYPES 2 + +struct worker_params { +struct rte_distributor *d; +struct rte_distributor_burst *db; +int dist_type; +}; + +struct worker_params worker_params; +/* statics - all zero-initialized by default */ static volatile int quit;/**< general quit variable for all threads */ static volatile int zero_quit;/**< var for when we just want thr0 to quit*/
@@ -81,17 +94,36 @@ static int handle_work(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; -unsigned count =0 ; -unsigned id =__sync_fetch_and_add (&worker_idx,1 ); - - pkt =rte_distributor_get_pkt (d, id,NULL ); -while (!quit) { + struct rte_mbuf *buf[8] __rte_cache_aligned; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db; +unsigned int count =0 , num =0 ; +unsigned int id =__sync_fetch_and_add (&worker_idx,1 ); +int i; + +if (wp->dist_type ==DIST_SINGLE ) { + pkt =rte_distributor_get_pkt (d, id,NULL ); +while (!quit) { + worker_stats[id].handled_packets++, count++; + pkt =rte_distributor_get_pkt (d, id, pkt); + } worker_stats[id].handled_packets++, count++; - pkt =rte_distributor_get_pkt (d, id, pkt); +rte_distributor_return_pkt (d, id, pkt); + }else { +for (i =0 ; i <8 ; i++) + buf[i] =NULL ; + num =rte_distributor_get_pkt_burst (db, id, buf, buf, num); +while (!quit) { + worker_stats[id].handled_packets += num; + count += num; + num =rte_distributor_get_pkt_burst (db, id, + buf, buf, num); + } + worker_stats[id].handled_packets += num; + count += num; +rte_distributor_return_pkt_burst (db, id, buf, num); } - worker_stats[id].handled_packets++, count++; -rte_distributor_return_pkt (d, id, pkt);return 0 ; }
@@ -107,12 +139,21 @@ handle_work(void *arg)* not necessarily in the same order (as different flows). */ static int -sanity_test (struct rte_distributor *d,struct rte_mempool *p) +sanity_test (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db;struct rte_mbuf *bufs[BURST ]; -unsigned i; +struct rte_mbuf *returns[BURST *2 ]; +unsigned int i; +unsigned int retries; +unsigned int count =0 ; + +if (wp->dist_type ==DIST_SINGLE ) +printf ("=== Basic distributor sanity tests (single) ===\n" ); +else +printf ("=== Basic distributor sanity tests (burst) ===\n" ); -printf ("=== Basic distributor sanity tests ===\n" );clear_packet_count ();if (rte_mempool_get_bulk (p, (void *)bufs,BURST ) !=0 ) {printf ("line %d: Error getting mbufs from pool\n" , __LINE__);
@@ -124,8 +165,21 @@ sanity_test(struct rte_distributor *d, struct rte_mempool *p)for (i =0 ; i <BURST ; i++) bufs[i]->hash.usr =0 ; -rte_distributor_process (d, bufs,BURST ); -rte_distributor_flush (d); +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_process (d, bufs,BURST ); +rte_distributor_flush (d); + }else { +rte_distributor_process_burst (db, bufs,BURST ); + count =0 ; +do { + +rte_distributor_flush_burst (db); + count +=rte_distributor_returned_pkts_burst (db, + returns,BURST *2 ); + }while (count <BURST ); + } + +if (total_packet_count () !=BURST ) { printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n",
@@ -146,8 +200,18 @@ sanity_test(struct rte_distributor *d, struct rte_mempool *p)for (i =0 ; i <BURST ; i++) bufs[i]->hash.usr = (i &1 ) <<8 ; -rte_distributor_process (d, bufs,BURST ); -rte_distributor_flush (d); +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_process (d, bufs,BURST ); +rte_distributor_flush (d); + }else { +rte_distributor_process_burst (db, bufs,BURST ); + count =0 ; +do { +rte_distributor_flush_burst (db); + count +=rte_distributor_returned_pkts_burst (db, + returns,BURST *2 ); + }while (count <BURST ); + }if (total_packet_count () !=BURST ) { printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n",
@@ -155,24 +219,32 @@ sanity_test(struct rte_distributor *d, struct rte_mempool *p)return -1 ; } +for (i =0 ; i <rte_lcore_count () -1 ; i++)printf ("Worker %u handled %u packets\n" , i, worker_stats[i].handled_packets);printf ("Sanity test with two hash values done\n" ); - -if (worker_stats[0 ].handled_packets !=16 || - worker_stats[1 ].handled_packets !=16 ) -return -1 ; }/* give a different hash value to each packet, * so load gets distributed */ clear_packet_count ();for (i =0 ; i <BURST ; i++) - bufs[i]->hash.usr = i; + bufs[i]->hash.usr = i+1 ; + +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_process (d, bufs,BURST ); +rte_distributor_flush (d); + }else { +rte_distributor_process_burst (db, bufs,BURST ); + count =0 ; +do { +rte_distributor_flush_burst (db); + count +=rte_distributor_returned_pkts_burst (db, + returns,BURST *2 ); + }while (count <BURST ); + } -rte_distributor_process (d, bufs,BURST ); -rte_distributor_flush (d);if (total_packet_count () !=BURST ) { printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n",
@@ -194,8 +266,15 @@ sanity_test(struct rte_distributor *d, struct rte_mempool *p)unsigned num_returned =0 ;/* flush out any remaining packets */ -rte_distributor_flush (d); -rte_distributor_clear_returns (d); +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_flush (d); +rte_distributor_clear_returns (d); + }else { +rte_distributor_flush_burst (db); +rte_distributor_clear_returns_burst (db); + } + +if (rte_mempool_get_bulk (p, (void *)many_bufs,BIG_BATCH ) !=0 ) {printf ("line %d: Error getting mbufs from pool\n" , __LINE__);return -1 ;
@@ -203,28 +282,59 @@ sanity_test(struct rte_distributor *d, struct rte_mempool *p)for (i =0 ; i <BIG_BATCH ; i++) many_bufs[i]->hash.usr = i <<2 ; -for (i =0 ; i <BIG_BATCH /BURST ; i++) { -rte_distributor_process (d, &many_bufs[i*BURST ],BURST ); +if (wp->dist_type ==DIST_SINGLE ) { +printf ("===testing single big burst===\n" ); +for (i =0 ; i <BIG_BATCH /BURST ; i++) { +rte_distributor_process (d, &many_bufs[i*BURST ],BURST ); + num_returned +=rte_distributor_returned_pkts (d, + &return_bufs[num_returned], +BIG_BATCH - num_returned); + } +rte_distributor_flush (d); num_returned +=rte_distributor_returned_pkts (d, &return_bufs[num_returned],BIG_BATCH - num_returned); + }else { +printf ("===testing burst big burst===\n" ); +for (i =0 ; i <BIG_BATCH /BURST ; i++) { +rte_distributor_process_burst (db, + &many_bufs[i*BURST ],BURST ); + count =rte_distributor_returned_pkts_burst (db, + &return_bufs[num_returned], +BIG_BATCH - num_returned); + num_returned += count; + } +rte_distributor_flush_burst (db); + count =rte_distributor_returned_pkts_burst (db, + &return_bufs[num_returned], +BIG_BATCH - num_returned); + num_returned += count; } -rte_distributor_flush (d); - num_returned +=rte_distributor_returned_pkts (d, - &return_bufs[num_returned],BIG_BATCH - num_returned); + retries =0 ; +do { +rte_distributor_flush_burst (db); + count =rte_distributor_returned_pkts_burst (db, + &return_bufs[num_returned], +BIG_BATCH - num_returned); + num_returned += count; + retries++; + }while ((num_returned <BIG_BATCH ) && (retries <100 )); +if (num_returned !=BIG_BATCH ) { -printf ("line %d: Number returned is not the same as " -"number sent\n" , __LINE__); +printf ("line %d: Missing packets, expected %d\n" , + __LINE__, num_returned);return -1 ; } +/* big check - make sure all packets made it back!! */ for (i =0 ; i <BIG_BATCH ; i++) {unsigned j;struct rte_mbuf *src = many_bufs[i]; -for (j =0 ; j <BIG_BATCH ; j++) +for (j =0 ; j <BIG_BATCH ; j++) {if (return_bufs[j] == src)break ; + }if (j ==BIG_BATCH ) {printf ("Error: could not find source packet #%u\n" , i);
@@ -234,7 +344,6 @@ sanity_test(struct rte_distributor *d, struct rte_mempool *p)printf ("Sanity test of returned packets done\n" );rte_mempool_put_bulk (p, (void *)many_bufs,BIG_BATCH ); -printf ("\n" );return 0 ; }
@@ -249,18 +358,40 @@ static int handle_work_with_free_mbufs(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; -unsigned count =0 ; -unsigned id =__sync_fetch_and_add (&worker_idx,1 ); - - pkt =rte_distributor_get_pkt (d, id,NULL ); -while (!quit) { + struct rte_mbuf *buf[8] __rte_cache_aligned; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db; +unsigned int count =0 ; +unsigned int i; +unsigned int num =0 ; +unsigned int id =__sync_fetch_and_add (&worker_idx,1 ); + +if (wp->dist_type ==DIST_SINGLE ) { + pkt =rte_distributor_get_pkt (d, id,NULL ); +while (!quit) { + worker_stats[id].handled_packets++, count++; +rte_pktmbuf_free (pkt); + pkt =rte_distributor_get_pkt (d, id, pkt); + } worker_stats[id].handled_packets++, count++; -rte_pktmbuf_free (pkt); - pkt =rte_distributor_get_pkt (d, id, pkt); +rte_distributor_return_pkt (d, id, pkt); + }else { +for (i =0 ; i <8 ; i++) + buf[i] =NULL ; + num =rte_distributor_get_pkt_burst (db, id, buf, buf, num); +while (!quit) { + worker_stats[id].handled_packets += num; + count += num; +for (i =0 ; i < num; i++) +rte_pktmbuf_free (buf[i]); + num =rte_distributor_get_pkt_burst (db, + id, buf, buf, num); + } + worker_stats[id].handled_packets += num; + count += num; +rte_distributor_return_pkt_burst (db, id, buf, num); } - worker_stats[id].handled_packets++, count++; -rte_distributor_return_pkt (d, id, pkt);return 0 ; }
@@ -270,26 +401,45 @@ handle_work_with_free_mbufs(void *arg)* library. */ static int -sanity_test_with_mbuf_alloc (struct rte_distributor *d,struct rte_mempool *p) +sanity_test_with_mbuf_alloc (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db;unsigned i;struct rte_mbuf *bufs[BURST ]; -printf ("=== Sanity test with mbuf alloc/free ===\n" ); +if (wp->dist_type ==DIST_SINGLE ) +printf ("=== Sanity test with mbuf alloc/free (single) ===\n" ); +else +printf ("=== Sanity test with mbuf alloc/free (burst) ===\n" ); +clear_packet_count ();for (i =0 ; i < ((1 <<ITER_POWER )); i +=BURST ) {unsigned j; -while (rte_mempool_get_bulk (p, (void *)bufs,BURST ) <0 ) -rte_distributor_process (d,NULL ,0 ); +while (rte_mempool_get_bulk (p, (void *)bufs,BURST ) <0 ) { +if (wp->dist_type ==DIST_SINGLE ) +rte_distributor_process (d,NULL ,0 ); +else +rte_distributor_process_burst (db,NULL ,0 ); + }for (j =0 ; j <BURST ; j++) { bufs[j]->hash.usr = (i+j) <<1 ;rte_mbuf_refcnt_set (bufs[j],1 ); } -rte_distributor_process (d, bufs,BURST ); +if (wp->dist_type ==DIST_SINGLE ) +rte_distributor_process (d, bufs,BURST ); +else +rte_distributor_process_burst (db, bufs,BURST ); } -rte_distributor_flush (d); +if (wp->dist_type ==DIST_SINGLE ) +rte_distributor_flush (d); +else +rte_distributor_flush_burst (db); + +rte_delay_us (10000 ); +if (total_packet_count () < (1 <<ITER_POWER )) { printf("Line %u: Packet count is incorrect, %u, expected %u\n", __LINE__, total_packet_count(),
@@ -305,20 +455,48 @@ static int handle_work_for_shutdown_test(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; -unsigned count =0 ; -const unsigned id =__sync_fetch_and_add (&worker_idx,1 ); + struct rte_mbuf *buf[8] __rte_cache_aligned; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db; +unsigned int count =0 ; +unsigned int num =0 ; +unsigned int total =0 ; +unsigned int i; +unsigned int returned =0 ; +const unsigned int id =__sync_fetch_and_add (&worker_idx,1 ); + +if (wp->dist_type ==DIST_SINGLE ) + pkt =rte_distributor_get_pkt (d, id,NULL ); +else + num =rte_distributor_get_pkt_burst (db, id, buf, buf, num); - pkt =rte_distributor_get_pkt (d, id,NULL );/* wait for quit single globally, or for worker zero, wait * for zero_quit */ while (!quit && !(id ==0 && zero_quit)) { - worker_stats[id].handled_packets++, count++; -rte_pktmbuf_free (pkt); - pkt =rte_distributor_get_pkt (d, id,NULL ); +if (wp->dist_type ==DIST_SINGLE ) { + worker_stats[id].handled_packets++, count++; +rte_pktmbuf_free (pkt); + pkt =rte_distributor_get_pkt (d, id,NULL ); + num =1 ; + total += num; + }else { + worker_stats[id].handled_packets += num; + count += num; +for (i =0 ; i < num; i++) +rte_pktmbuf_free (buf[i]); + num =rte_distributor_get_pkt_burst (db, + id, buf, buf, num); + total += num; + } + } + worker_stats[id].handled_packets += num; + count += num; +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_return_pkt (d, id, pkt); + }else { + returned =rte_distributor_return_pkt_burst (db, id, buf, num); } - worker_stats[id].handled_packets++, count++; -rte_distributor_return_pkt (d, id, pkt);if (id ==0 ) {/* for worker zero, allow it to restart to pick up last packet
@@ -326,13 +504,29 @@ handle_work_for_shutdown_test(void *arg)*/ while (zero_quit)usleep (100 ); - pkt =rte_distributor_get_pkt (d, id,NULL ); +if (wp->dist_type ==DIST_SINGLE ) { + pkt =rte_distributor_get_pkt (d, id,NULL ); + }else { + num =rte_distributor_get_pkt_burst (db, + id, buf, buf, num); + }while (!quit) { worker_stats[id].handled_packets++, count++;rte_pktmbuf_free (pkt); - pkt =rte_distributor_get_pkt (d, id,NULL ); +if (wp->dist_type ==DIST_SINGLE ) { + pkt =rte_distributor_get_pkt (d, id,NULL ); + }else { + num =rte_distributor_get_pkt_burst (db, + id, buf, buf, num); + } + } +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_return_pkt (d, id, pkt); + }else { + returned =rte_distributor_return_pkt_burst (db, + id, buf, num); +printf ("Num returned = %d\n" , returned); } -rte_distributor_return_pkt (d, id, pkt); }return 0 ; }
@@ -344,26 +538,37 @@ handle_work_for_shutdown_test(void *arg)* library. */ static int -sanity_test_with_worker_shutdown (struct rte_distributor *d, +sanity_test_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db;struct rte_mbuf *bufs[BURST ];unsigned i;printf ("=== Sanity test of worker shutdown ===\n" );clear_packet_count (); +if (rte_mempool_get_bulk (p, (void *)bufs,BURST ) !=0 ) {printf ("line %d: Error getting mbufs from pool\n" , __LINE__);return -1 ; } -/* now set all hash values in all buffers to zero, so all pkts go to the -* one worker thread */ +/* +* Now set all hash values in all buffers to same value so all +* pkts go to the one worker thread +*/ for (i =0 ; i <BURST ; i++) - bufs[i]->hash.usr =0 ; + bufs[i]->hash.usr =1 ; + +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_process (d, bufs,BURST ); + }else { +rte_distributor_process_burst (db, bufs,BURST ); +rte_distributor_flush_burst (db); + } -rte_distributor_process (d, bufs,BURST );/* at this point, we will have processed some packets and have a full * backlog for the other ones at worker 0. */
@@ -374,14 +579,25 @@ sanity_test_with_worker_shutdown(struct rte_distributor *d,return -1 ; }for (i =0 ; i <BURST ; i++) - bufs[i]->hash.usr =0 ; + bufs[i]->hash.usr =1 ;/* get worker zero to quit */ zero_quit =1 ; -rte_distributor_process (d, bufs,BURST ); +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_process (d, bufs,BURST ); +/* flush the distributor */ +rte_distributor_flush (d); + }else { +rte_distributor_process_burst (db, bufs,BURST ); +/* flush the distributor */ +rte_distributor_flush_burst (db); + } +rte_delay_us (10000 ); + +for (i =0 ; i <rte_lcore_count () -1 ; i++) +printf ("Worker %u handled %u packets\n" , i, + worker_stats[i].handled_packets); -/* flush the distributor */ -rte_distributor_flush (d);if (total_packet_count () !=BURST *2 ) { printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n",
@@ -389,10 +605,6 @@ sanity_test_with_worker_shutdown(struct rte_distributor *d,return -1 ; } -for (i =0 ; i <rte_lcore_count () -1 ; i++) -printf ("Worker %u handled %u packets\n" , i, - worker_stats[i].handled_packets); -printf ("Sanity test with worker shutdown passed\n\n" );return 0 ; }
@@ -401,13 +613,18 @@ sanity_test_with_worker_shutdown(struct rte_distributor *d,* one worker shuts down.. */ static int -test_flush_with_worker_shutdown (struct rte_distributor *d, +test_flush_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db;struct rte_mbuf *bufs[BURST ];unsigned i; -printf ("=== Test flush fn with worker shutdown ===\n" ); +if (wp->dist_type ==DIST_SINGLE ) +printf ("=== Test flush fn with worker shutdown (single) ===\n" ); +else +printf ("=== Test flush fn with worker shutdown (burst) ===\n" );clear_packet_count ();if (rte_mempool_get_bulk (p, (void *)bufs,BURST ) !=0 ) {
@@ -420,7 +637,11 @@ test_flush_with_worker_shutdown(struct rte_distributor *d,for (i =0 ; i <BURST ; i++) bufs[i]->hash.usr =0 ; -rte_distributor_process (d, bufs,BURST ); +if (wp->dist_type ==DIST_SINGLE ) +rte_distributor_process (d, bufs,BURST ); +else +rte_distributor_process_burst (db, bufs,BURST ); +/* at this point, we will have processed some packets and have a full * backlog for the other ones at worker 0. */
@@ -429,9 +650,18 @@ test_flush_with_worker_shutdown(struct rte_distributor *d, zero_quit =1 ;/* flush the distributor */ -rte_distributor_flush (d); +if (wp->dist_type ==DIST_SINGLE ) +rte_distributor_flush (d); +else +rte_distributor_flush_burst (db); + +rte_delay_us (10000 ); zero_quit =0 ; +for (i =0 ; i <rte_lcore_count () -1 ; i++) +printf ("Worker %u handled %u packets\n" , i, + worker_stats[i].handled_packets); +if (total_packet_count () !=BURST ) { printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n",
@@ -439,10 +669,6 @@ test_flush_with_worker_shutdown(struct rte_distributor *d,return -1 ; } -for (i =0 ; i <rte_lcore_count () -1 ; i++) -printf ("Worker %u handled %u packets\n" , i, - worker_stats[i].handled_packets); -printf ("Flush test with worker shutdown passed\n\n" );return 0 ; }
@@ -451,6 +677,7 @@ staticint test_error_distributor_create_name (void ) {struct rte_distributor *d =NULL ; +struct rte_distributor_burst *db =NULL ;char *name =NULL ; d = rte_distributor_create(name, rte_socket_id(),
@@ -460,6 +687,13 @@ int test_error_distributor_create_name(void)return -1 ; } + db =rte_distributor_create_burst (name,rte_socket_id (), +rte_lcore_count () -1 ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create_burst() with NULL param\n" ); +return -1 ; + } +return 0 ; }
@@ -468,20 +702,32 @@ staticint test_error_distributor_create_numworkers (void ) {struct rte_distributor *d =NULL ; +struct rte_distributor_burst *db =NULL ; + d =rte_distributor_create ("test_numworkers" ,rte_socket_id (),RTE_MAX_LCORE +10 );if (d !=NULL || rte_errno !=EINVAL ) {printf ("ERROR: No error on create() with num_workers > MAX\n" );return -1 ; } + + db =rte_distributor_create_burst ("test_numworkers" ,rte_socket_id (), +RTE_MAX_LCORE +10 ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create_burst() num_workers > MAX\n" ); +return -1 ; + } +return 0 ; }/* Useful function which ensures that all worker functions terminate */ static void -quit_workers (struct rte_distributor *d,struct rte_mempool *p) +quit_workers (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->d; +struct rte_distributor_burst *db = wp->db;const unsigned num_workers =rte_lcore_count () -1 ;unsigned i;struct rte_mbuf *bufs[RTE_MAX_LCORE ];
@@ -491,12 +737,20 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p) quit =1 ;for (i =0 ; i < num_workers; i++) bufs[i]->hash.usr = i <<1 ; -rte_distributor_process (d, bufs, num_workers); +if (wp->dist_type ==DIST_SINGLE ) +rte_distributor_process (d, bufs, num_workers); +else +rte_distributor_process_burst (db, bufs, num_workers);rte_mempool_put_bulk (p, (void *)bufs, num_workers); -rte_distributor_process (d,NULL ,0 ); -rte_distributor_flush (d); +if (wp->dist_type ==DIST_SINGLE ) { +rte_distributor_process (d,NULL ,0 ); +rte_distributor_flush (d); + }else { +rte_distributor_process_burst (db,NULL ,0 ); +rte_distributor_flush_burst (db); + }rte_eal_mp_wait_lcore (); quit =0 ; worker_idx =0 ;
@@ -506,7 +760,9 @@ static inttest_distributor (void) {static struct rte_distributor *d; +static struct rte_distributor_burst *db;static struct rte_mempool *p; +int i;if (rte_lcore_count () <2 ) {printf ("ERROR: not enough cores to test distributor\n" );
@@ -525,6 +781,19 @@ test_distributor(void)rte_distributor_clear_returns (d); } +if (db ==NULL ) { + db =rte_distributor_create_burst ("Test_dist_burst" , +rte_socket_id (), +rte_lcore_count () -1 ); +if (db ==NULL ) { +printf ("Error creating burst distributor\n" ); +return -1 ; + } + }else { +rte_distributor_flush_burst (db); +rte_distributor_clear_returns_burst (db); + } +const unsigned nb_bufs = (511 *rte_lcore_count ()) <BIG_BATCH ? (BIG_BATCH *2 ) -1 : (511 *rte_lcore_count ());if (p ==NULL ) {
@@ -536,31 +805,45 @@ test_distributor(void) } } -rte_eal_mp_remote_launch (handle_work, d,SKIP_MASTER ); -if (sanity_test (d, p) <0 ) - goto err; -quit_workers (d, p); + worker_params.d = d; + worker_params.db = db; -rte_eal_mp_remote_launch (handle_work_with_free_mbufs, d,SKIP_MASTER ); -if (sanity_test_with_mbuf_alloc (d, p) <0 ) - goto err; -quit_workers (d, p); +for (i =0 ; i <DIST_NUM_TYPES ; i++) { -if (rte_lcore_count () >2 ) { -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, -SKIP_MASTER ); -if (sanity_test_with_worker_shutdown (d, p) <0 ) - goto err; -quit_workers (d, p); + worker_params.dist_type = i; -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, -SKIP_MASTER ); -if (test_flush_with_worker_shutdown (d, p) <0 ) +rte_eal_mp_remote_launch (handle_work, + &worker_params,SKIP_MASTER ); +if (sanity_test (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); - }else { -printf ("Not enough cores to run tests for worker shutdown\n" ); +rte_eal_mp_remote_launch (handle_work_with_free_mbufs, + &worker_params,SKIP_MASTER ); +if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) + goto err; +quit_workers (&worker_params, p); + +if (rte_lcore_count () >2 ) { +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (sanity_test_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (test_flush_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + + }else { +printf ("Too few cores to run worker shutdown test\n" ); + } } if (test_error_distributor_create_numworkers() == -1 ||
@@ -572,7 +855,7 @@ test_distributor(void)return 0 ; err: -quit_workers (d, p); +quit_workers (&worker_params, p);return -1 ; }
Signature · 1 line
2.7.4
PATCH v3 4/6 test: add distributor_perf autotest
In reply to David Hunt--- app/test/test_distributor_perf.c | 148 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 11 deletions(-)
app/test/test_distributor_perf.c +137 -11
@@ -40,9 +40,11 @@#include <rte_common.h> #include <rte_mbuf.h> #include <rte_distributor.h> +#include <rte_distributor_burst.h> -#define ITER_POWER 20/* log 2 of how many iterations we do when timing. */ -#define BURST 32 +#define ITER_POWER_CL 25/* log 2 of how many iterations for Cache Line test */ +#define ITER_POWER 21/* log 2 of how many iterations we do when timing. */ +#define BURST 64#define BIG_BATCH 1024/* static vars - zero initialized by default */
@@ -54,7 +56,8 @@ struct worker_stats { } __rte_cache_aligned;struct worker_stats worker_stats[RTE_MAX_LCORE ]; -/* worker thread used for testing the time to do a round-trip of a cache +/* +* worker thread used for testing the time to do a round-trip of a cache * line between two cores and back again */ static void
@@ -69,7 +72,8 @@ flip_bit(volatile uint64_t *arg) } } -/* test case to time the number of cycles to round-trip a cache line between +/* +* test case to time the number of cycles to round-trip a cache line between * two cores and back again. */ static void
@@ -86,7 +90,7 @@ time_cache_line_switch(void)rte_pause ();const uint64_t start_time =rte_rdtsc (); -for (i =0 ; i < (1 <<ITER_POWER ); i++) { +for (i =0 ; i < (1 <<ITER_POWER_CL ); i++) {while (*pdata)rte_pause (); *pdata =1 ;
@@ -98,13 +102,14 @@ time_cache_line_switch(void) *pdata =2 ;rte_eal_wait_lcore (slaveid);printf ("==== Cache line switch test ===\n" ); -printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER ), +printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER_CL ), end_time-start_time);printf ("Ticks per iteration = %" PRIu64"\n\n" , - (end_time-start_time) >>ITER_POWER ); + (end_time-start_time) >>ITER_POWER_CL ); } -/* returns the total count of the number of packets handled by the worker +/* +* returns the total count of the number of packets handled by the worker * functions given below. */ static unsigned
@@ -123,7 +128,8 @@ clear_packet_count(void)memset (&worker_stats,0 ,sizeof (worker_stats)); } -/* this is the basic worker function for performance tests. +/* +* this is the basic worker function for performance tests. * it does nothing but return packets and count them. */ static int
@@ -144,7 +150,37 @@ handle_work(void *arg)return 0 ; } -/* this basic performance test just repeatedly sends in 32 packets at a time +/* +* this is the basic worker function for performance tests. +* it does nothing but return packets and count them. +*/ +static int +handle_work_burst (void *arg) +{ +struct rte_distributor_burst *d = arg; +unsigned int count =0 ; +unsigned int num =0 ; +int i; +unsigned int id =__sync_fetch_and_add (&worker_idx,1 ); + struct rte_mbuf *buf[8] __rte_cache_aligned; + +for (i =0 ; i <8 ; i++) + buf[i] =NULL ; + + num =rte_distributor_get_pkt_burst (d, id, buf, buf, num); +while (!quit) { + worker_stats[id].handled_packets += num; + count += num; + num =rte_distributor_get_pkt_burst (d, id, buf, buf, num); + } + worker_stats[id].handled_packets += num; + count += num; +rte_distributor_return_pkt_burst (d, id, buf, num); +return 0 ; +} + +/* +* this basic performance test just repeatedly sends in 32 packets at a time * to the distributor and verifies at the end that we got them all in the worker * threads and finally how long per packet the processing took. */
@@ -174,6 +210,8 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)rte_distributor_process (d,NULL ,0 ); }while (total_packet_count () < (BURST <<ITER_POWER )); +rte_distributor_clear_returns (d); +printf ("=== Performance test of distributor ===\n" );printf ("Time per burst: %" PRIu64"\n" , (end - start) >>ITER_POWER ); printf("Time per packet: %"PRIu64"\n\n",
@@ -190,6 +228,55 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)return 0 ; } +/* +* this basic performance test just repeatedly sends in 32 packets at a time +* to the distributor and verifies at the end that we got them all in the worker +* threads and finally how long per packet the processing took. +*/ +static inline int +perf_test_burst (struct rte_distributor_burst *d,struct rte_mempool *p) +{ +unsigned int i; +uint64_t start, end; +struct rte_mbuf *bufs[BURST ]; + +clear_packet_count (); +if (rte_mempool_get_bulk (p, (void *)bufs,BURST ) !=0 ) { +printf ("Error getting mbufs from pool\n" ); +return -1 ; + } +/* ensure we have different hash value for each pkt */ +for (i =0 ; i <BURST ; i++) + bufs[i]->hash.usr = i; + + start =rte_rdtsc (); +for (i =0 ; i < (1 <<ITER_POWER ); i++) +rte_distributor_process_burst (d, bufs,BURST ); + end =rte_rdtsc (); + +do { +usleep (100 ); +rte_distributor_process_burst (d,NULL ,0 ); + }while (total_packet_count () < (BURST <<ITER_POWER )); + +rte_distributor_clear_returns_burst (d); + +printf ("=== Performance test of burst distributor ===\n" ); +printf ("Time per burst: %" PRIu64"\n" , (end - start) >>ITER_POWER ); +printf ("Time per packet: %" PRIu64"\n\n" , + ((end - start) >>ITER_POWER )/BURST ); +rte_mempool_put_bulk (p, (void *)bufs,BURST ); + +for (i =0 ; i <rte_lcore_count () -1 ; i++) +printf ("Worker %u handled %u packets\n" , i, + worker_stats[i].handled_packets); +printf ("Total packets: %u (%x)\n" ,total_packet_count (), +total_packet_count ()); +printf ("=== Perf test done ===\n\n" ); + +return 0 ; +} +/* Useful function which ensures that all worker functions terminate */ static void quit_workers (struct rte_distributor *d,struct rte_mempool *p)
@@ -212,10 +299,34 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p) worker_idx =0 ; } +/* Useful function which ensures that all worker functions terminate */ +static void +quit_workers_burst (struct rte_distributor_burst *d,struct rte_mempool *p) +{ +const unsigned int num_workers =rte_lcore_count () -1 ; +unsigned int i; +struct rte_mbuf *bufs[RTE_MAX_LCORE ]; + +rte_mempool_get_bulk (p, (void *)bufs, num_workers); + + quit =1 ; +for (i =0 ; i < num_workers; i++) + bufs[i]->hash.usr = i <<1 ; +rte_distributor_process_burst (d, bufs, num_workers); + +rte_mempool_put_bulk (p, (void *)bufs, num_workers); + +rte_distributor_process_burst (d,NULL ,0 ); +rte_eal_mp_wait_lcore (); + quit =0 ; + worker_idx =0 ; +} +static int test_distributor_perf (void ) {static struct rte_distributor *d; +static struct rte_distributor_burst *db;static struct rte_mempool *p;if (rte_lcore_count () <2 ) {
@@ -234,10 +345,20 @@ test_distributor_perf(void)return -1 ; } }else { -rte_distributor_flush (d);rte_distributor_clear_returns (d); } +if (db ==NULL ) { + db =rte_distributor_create_burst ("Test_burst" ,rte_socket_id (), +rte_lcore_count () -1 ); +if (db ==NULL ) { +printf ("Error creating burst distributor\n" ); +return -1 ; + } + }else { +rte_distributor_clear_returns_burst (db); + } +const unsigned nb_bufs = (511 *rte_lcore_count ()) <BIG_BATCH ? (BIG_BATCH *2 ) -1 : (511 *rte_lcore_count ());if (p ==NULL ) {
@@ -254,6 +375,11 @@ test_distributor_perf(void)return -1 ;quit_workers (d, p); +rte_eal_mp_remote_launch (handle_work_burst, db,SKIP_MASTER ); +if (perf_test_burst (db, p) <0 ) +return -1 ; +quit_workers_burst (db, p); +return 0 ; }
Signature · 1 line
2.7.4
PATCH v3 5/6 example: distributor app showing burst api
In reply to David Hunt--- examples/distributor/main.c | 508 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 390 insertions(+), 118 deletions(-)
examples/distributor/main.c +390 -118
@@ -1,8 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -* All rights reserved. +* Copyright(c) 2010-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
@@ -31,6 +30,8 @@* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define BURST_API 1 +#include <stdint.h> #include <inttypes.h> #include <unistd.h>
@@ -43,39 +44,87 @@#include <rte_malloc.h> #include <rte_debug.h> #include <rte_prefetch.h> +#if BURST_API +#include <rte_distributor_burst.h> +#else #include <rte_distributor.h> +#endif -#define RX_RING_SIZE 256 -#define TX_RING_SIZE 512 +#define RX_QUEUE_SIZE 512 +#define TX_QUEUE_SIZE 512#define NUM_MBUFS ((64*1024)-1) -#define MBUF_CACHE_SIZE 250 +#define MBUF_CACHE_SIZE 128 +#if BURST_API +#define BURST_SIZE 64 +#define SCHED_RX_RING_SZ 8192 +#define SCHED_TX_RING_SZ 65536 +#else #define BURST_SIZE 32 -#define RTE_RING_SZ 1024 +#define SCHED_RX_RING_SZ 1024 +#define SCHED_TX_RING_SZ 1024 +#endif +#define BURST_SIZE_TX 32#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1 +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_RESET "\x1b[0m" +/* mask of enabled ports */ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx; +volatile uint8_t quit_signal_dist; +volatile uint8_t quit_signal_work;static volatile struct app_stats {struct {uint64_t rx_pkts;uint64_t returned_pkts;uint64_t enqueued_pkts; +uint64_t enqdrop_pkts; } rx __rte_cache_aligned; + int pad1 __rte_cache_aligned; + +struct { +uint64_t in_pkts; +uint64_t ret_pkts; +uint64_t sent_pkts; +uint64_t enqdrop_pkts; + } dist __rte_cache_aligned; + int pad2 __rte_cache_aligned;struct {uint64_t dequeue_pkts;uint64_t tx_pkts; +uint64_t enqdrop_pkts; } tx __rte_cache_aligned; + int pad3 __rte_cache_aligned; + + uint64_t worker_pkts[64] __rte_cache_aligned; + + int pad4 __rte_cache_aligned; + + uint64_t worker_bursts[64][8] __rte_cache_aligned; + + int pad5 __rte_cache_aligned; + + uint64_t port_rx_pkts[64] __rte_cache_aligned; + uint64_t port_tx_pkts[64] __rte_cache_aligned; } app_stats; +struct app_stats prev_app_stats; +static const struct rte_eth_conf port_conf_default = { .rxmode = { .mq_mode =ETH_MQ_RX_RSS , .max_rx_pkt_len =ETHER_MAX_LEN , + .split_hdr_size =0 , + .header_split =0 ,/**< Header Split disabled */ + .hw_ip_checksum =1 ,/**< IP checksum offload enabled */ + .hw_vlan_filter =0 ,/**< VLAN filtering disabled */ + .jumbo_frame =0 ,/**< Jumbo Frame Support disabled */ + .hw_strip_crc =0 ,/**< CRC stripped by hardware */ }, .txmode = { .mq_mode =ETH_MQ_TX_NONE ,
@@ -93,6 +142,8 @@ struct output_buffer {struct rte_mbuf *mbufs[BURST_SIZE ]; }; +static void print_stats (void ); +/* * Initialises a given port using global settings and with the rx buffers * coming from the mbuf_pool passed as parameter
@@ -101,9 +152,13 @@ static inline int port_init(uint8_t port, struct rte_mempool *mbuf_pool) { struct rte_eth_conf port_conf = port_conf_default; -const uint16_t rxRings =1 , txRings =rte_lcore_count () -1 ; -int retval; +const uint16_t rxRings =1 ; +uint16_t txRings =rte_lcore_count () -1 ;uint16_t q; +int retval; + +if (txRings >RTE_MAX_ETHPORTS ) + txRings =RTE_MAX_ETHPORTS ;if (port >=rte_eth_dev_count ())return -1 ;
@@ -113,7 +168,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)return retval;for (q =0 ; q < rxRings; q++) { - retval =rte_eth_rx_queue_setup (port, q,RX_RING_SIZE , + retval =rte_eth_rx_queue_setup (port, q,RX_QUEUE_SIZE ,rte_eth_dev_socket_id (port),NULL , mbuf_pool);if (retval <0 )
@@ -121,7 +176,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool) }for (q =0 ; q < txRings; q++) { - retval =rte_eth_tx_queue_setup (port, q,TX_RING_SIZE , + retval =rte_eth_tx_queue_setup (port, q,TX_QUEUE_SIZE ,rte_eth_dev_socket_id (port),NULL );if (retval <0 )
@@ -134,7 +189,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct rte_eth_link link;rte_eth_link_get_nowait (port, &link); -if (!link.link_status) { +while (!link.link_status) { +printf ("Waiting for Link up on port %" PRIu8"\n" , port);sleep (1 );rte_eth_link_get_nowait (port, &link); }
@@ -160,41 +216,52 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct lcore_params {unsigned worker_id; -struct rte_distributor *d; -struct rte_ring *r; +struct rte_distributor_burst *d; +struct rte_ring *rx_dist_ring; +struct rte_ring *dist_tx_ring;struct rte_mempool *mem_pool; }; -static int -quit_workers (struct rte_distributor *d,struct rte_mempool *p) +static inline void +flush_one_port (struct output_buffer *outbuf,uint8_t outp) { -const unsigned num_workers =rte_lcore_count () -2 ; -unsigned i; -struct rte_mbuf *bufs[num_workers]; +unsigned int nb_tx =rte_eth_tx_burst (outp,0 , + outbuf->mbufs, outbuf->count); + app_stats.tx.tx_pkts += outbuf->count; -if (rte_mempool_get_bulk (p, (void *)bufs, num_workers) !=0 ) { -printf ("line %d: Error getting mbufs from pool\n" , __LINE__); -return -1 ; +if (unlikely (nb_tx < outbuf->count)) { + app_stats.tx.enqdrop_pkts += outbuf->count - nb_tx; +do { +rte_pktmbuf_free (outbuf->mbufs[nb_tx]); + }while (++nb_tx < outbuf->count); } + outbuf->count =0 ; +} + +static inline void +flush_all_ports (struct output_buffer *tx_buffers,uint8_t nb_ports) +{ +uint8_t outp; -for (i =0 ; i < num_workers; i++) - bufs[i]->hash.rss = i <<1 ; +for (outp =0 ; outp < nb_ports; outp++) { +/* skip ports that are not enabled */ +if ((enabled_port_mask & (1 << outp)) ==0 ) +continue ; -rte_distributor_process (d, bufs, num_workers); -rte_mempool_put_bulk (p, (void *)bufs, num_workers); +if (tx_buffers[outp].count ==0 ) +continue ; -return 0 ; +flush_one_port (&tx_buffers[outp], outp); + } }static int lcore_rx (struct lcore_params *p) { -struct rte_distributor *d = p->d; -struct rte_mempool *mem_pool = p->mem_pool; -struct rte_ring *r = p->r;const uint8_t nb_ports =rte_eth_dev_count ();const int socket_id =rte_socket_id ();uint8_t port; +struct rte_mbuf *bufs[BURST_SIZE *2 ];for (port =0 ; port < nb_ports; port++) {/* skip ports that are not enabled */
@@ -210,6 +277,7 @@ lcore_rx(struct lcore_params *p)printf ("\nCore %u doing packet RX.\n" ,rte_lcore_id ()); port =0 ; +while (!quit_signal_rx) {/* skip ports that are not enabled */
@@ -218,7 +286,7 @@ lcore_rx(struct lcore_params *p) port =0 ;continue ; } -struct rte_mbuf *bufs[BURST_SIZE *2 ]; +const uint16_t nb_rx =rte_eth_rx_burst (port,0 , bufs,BURST_SIZE );if (unlikely (nb_rx ==0 )) {
@@ -228,19 +296,46 @@ lcore_rx(struct lcore_params *p) } app_stats.rx.rx_pkts += nb_rx; -rte_distributor_process (d, bufs, nb_rx); -const uint16_t nb_ret =rte_distributor_returned_pkts (d, - bufs,BURST_SIZE *2 ); +/* +* You can run the distributor on the rx core with this code. Returned +* packets are then send straight to the tx core. +*/ +#if 0 + +#if BURST_API +rte_distributor_process_burst (d, bufs, nb_rx); +const uint16_t nb_ret =rte_distributor_returned_pkts_burst (d, + bufs,BURST_SIZE *2 ); +#else +rte_distributor_process (d, bufs, nb_rx); +const uint16_t nb_ret =rte_distributor_returned_pkts (d, + bufs,BURST_SIZE *2 ); +#endif + app_stats.rx.returned_pkts += nb_ret;if (unlikely (nb_ret ==0 )) {if (++port == nb_ports) port =0 ;continue ; } - -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +struct rte_ring *tx_ring = p->dist_tx_ring; +uint16_t sent =rte_ring_enqueue_burst (tx_ring, + (void *)bufs, nb_ret); +#else +uint16_t nb_ret = nb_rx; +/* +* Swap the following two lines if you want the rx traffic +* to go directly to tx, no distribution. +*/ +struct rte_ring *out_ring = p->rx_dist_ring; +//struct rte_ring *out_ring = p->dist_tx_ring; + +uint16_t sent =rte_ring_enqueue_burst (out_ring, + (void *)bufs, nb_ret); +#endif app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { + app_stats.rx.enqdrop_pkts += nb_ret - sent;RTE_LOG_DP (DEBUG ,DISTRAPP ,"%s:Packet loss due to full ring\n" , __func__);while (sent < nb_ret)
@@ -249,56 +344,88 @@ lcore_rx(struct lcore_params *p)if (++port == nb_ports) port =0 ; } -rte_distributor_process (d,NULL ,0 ); -/* flush distributor to bring to known state */ -rte_distributor_flush (d);/* set worker & tx threads quit flag */ +printf ("\nCore %u exiting rx task.\n" ,rte_lcore_id ()); quit_signal =1 ; -/* -* worker threads may hang in get packet as -* distributor process is not running, just make sure workers -* get packets till quit_signal is actually been -* received and they gracefully shutdown -*/ -if (quit_workers (d, mem_pool) !=0 ) -return -1 ; -/* rx thread should quit at last */ return 0 ; } -static inline void -flush_one_port (struct output_buffer *outbuf,uint8_t outp) -{ -unsigned nb_tx =rte_eth_tx_burst (outp,0 , outbuf->mbufs, - outbuf->count); - app_stats.tx.tx_pkts += nb_tx; -if (unlikely (nb_tx < outbuf->count)) { -RTE_LOG_DP (DEBUG ,DISTRAPP , -"%s:Packet loss with tx_burst\n" , __func__); -do { -rte_pktmbuf_free (outbuf->mbufs[nb_tx]); - }while (++nb_tx < outbuf->count); - } - outbuf->count =0 ; -} -static inline void -flush_all_ports (struct output_buffer *tx_buffers,uint8_t nb_ports) +static int +lcore_distributor (struct lcore_params *p) { -uint8_t outp; -for (outp =0 ; outp < nb_ports; outp++) { -/* skip ports that are not enabled */ -if ((enabled_port_mask & (1 << outp)) ==0 ) -continue ; - -if (tx_buffers[outp].count ==0 ) -continue ; - -flush_one_port (&tx_buffers[outp], outp); +struct rte_ring *in_r = p->rx_dist_ring; +struct rte_ring *out_r = p->dist_tx_ring; +struct rte_mbuf *bufs[BURST_SIZE *4 ]; +struct rte_distributor_burst *d = p->d; + +printf ("\nCore %u acting as distributor core.\n" ,rte_lcore_id ()); +while (!quit_signal_dist) { +const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, + (void *)bufs,BURST_SIZE *1 ); +if (nb_rx) { + app_stats.dist.in_pkts += nb_rx; +/* +* This '#if' allows you to bypass the distributor. Incoming packets may be +* sent straight to the tx ring. +*/ +#if 1 + +#if BURST_API +/* Distribute the packets */ +rte_distributor_process_burst (d, bufs, nb_rx); +/* Handle Returns */ +const uint16_t nb_ret = +rte_distributor_returned_pkts_burst (d, + bufs,BURST_SIZE *2 ); +#else +/* Distribute the packets */ +rte_distributor_process (d, bufs, nb_rx); +/* Handle Returns */ +const uint16_t nb_ret = +rte_distributor_returned_pkts (d, + bufs,BURST_SIZE *2 ); +#endif + +#else +/* Bypass the distributor */ +const unsigned int xor_val = (rte_eth_dev_count () >1 ); +/* Touch the mbuf by xor'ing the port */ +for (unsigned int i =0 ; i < nb_rx; i++) + bufs[i]->port ^= xor_val; + +const uint16_t nb_ret = nb_rx; +#endif +if (unlikely (nb_ret ==0 )) +continue ; + app_stats.dist.ret_pkts += nb_ret; + +uint16_t sent =rte_ring_enqueue_burst (out_r, + (void *)bufs, nb_ret); + app_stats.dist.sent_pkts += sent; +if (unlikely (sent < nb_ret)) { + app_stats.dist.enqdrop_pkts += nb_ret - sent; +RTE_LOG (DEBUG ,DISTRAPP , +"%s:Packet loss due to full out ring\n" , + __func__); +while (sent < nb_ret) +rte_pktmbuf_free (bufs[sent++]); + } + } } +printf ("\nCore %u exiting distributor task.\n" ,rte_lcore_id ()); + quit_signal_work =1 ; + +#if BURST_API +/* Unblock any returns so workers can exit */ +rte_distributor_clear_returns_burst (d); +#endif + quit_signal_rx =1 ; +return 0 ; } +static int lcore_tx (struct rte_ring *in_r) {
@@ -327,9 +454,9 @@ lcore_tx(struct rte_ring *in_r)if ((enabled_port_mask & (1 << port)) ==0 )continue ; -struct rte_mbuf *bufs[BURST_SIZE ]; +struct rte_mbuf *bufs[BURST_SIZE_TX ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE_TX ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
@@ -358,11 +485,12 @@ lcore_tx(struct rte_ring *in_r) outbuf = &tx_buffers[outp]; outbuf->mbufs[outbuf->count++] = bufs[i]; -if (outbuf->count ==BURST_SIZE ) +if (outbuf->count ==BURST_SIZE_TX )flush_one_port (outbuf, outp); } } } +printf ("\nCore %u exiting tx task.\n" ,rte_lcore_id ());return 0 ; }
@@ -371,52 +499,147 @@ int_handler(int sig_num) {printf ("Exiting on signal %d\n" , sig_num);/* set quit flag for rx thread to exit */ - quit_signal_rx =1 ; + quit_signal_dist =1 ; }static void print_stats (void ) {struct rte_eth_stats eth_stats; -unsigned i; - -printf ("\nRX thread stats:\n" ); -printf (" - Received: %" PRIu64"\n" , app_stats.rx.rx_pkts); -printf (" - Processed: %" PRIu64"\n" , app_stats.rx.returned_pkts); -printf (" - Enqueued: %" PRIu64"\n" , app_stats.rx.enqueued_pkts); - -printf ("\nTX thread stats:\n" ); -printf (" - Dequeued: %" PRIu64"\n" , app_stats.tx.dequeue_pkts); -printf (" - Transmitted: %" PRIu64"\n" , app_stats.tx.tx_pkts); +unsigned int i, j; +const unsigned int num_workers =rte_lcore_count () -4 ;for (i =0 ; i <rte_eth_dev_count (); i++) {rte_eth_stats_get (i, ð_stats); -printf ("\nPort %u stats:\n" , i); -printf (" - Pkts in: %" PRIu64"\n" , eth_stats.ipackets); -printf (" - Pkts out: %" PRIu64"\n" , eth_stats.opackets); -printf (" - In Errs: %" PRIu64"\n" , eth_stats.ierrors); -printf (" - Out Errs: %" PRIu64"\n" , eth_stats.oerrors); -printf (" - Mbuf Errs: %" PRIu64"\n" , eth_stats.rx_nombuf); + app_stats.port_rx_pkts[i] = eth_stats.ipackets; + app_stats.port_tx_pkts[i] = eth_stats.opackets; + } + +printf ("\n\nRX Thread:\n" ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsin : %5.2f\n" , i, + (app_stats.port_rx_pkts[i] - + prev_app_stats.port_rx_pkts[i])/1000000.0 ); + prev_app_stats.port_rx_pkts[i] = app_stats.port_rx_pkts[i]; + } +printf (" - Received: %5.2f\n" , + (app_stats.rx.rx_pkts - + prev_app_stats.rx.rx_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.rx.returned_pkts - + prev_app_stats.rx.returned_pkts)/1000000.0 ); +printf (" - Enqueued: %5.2f\n" , + (app_stats.rx.enqueued_pkts - + prev_app_stats.rx.enqueued_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.rx.enqdrop_pkts - + prev_app_stats.rx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("Distributor thread:\n" ); +printf (" - In: %5.2f\n" , + (app_stats.dist.in_pkts - + prev_app_stats.dist.in_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.dist.ret_pkts - + prev_app_stats.dist.ret_pkts)/1000000.0 ); +printf (" - Sent: %5.2f\n" , + (app_stats.dist.sent_pkts - + prev_app_stats.dist.sent_pkts)/1000000.0 ); +printf (" - Dropped %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.dist.enqdrop_pkts - + prev_app_stats.dist.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("TX thread:\n" ); +printf (" - Dequeued: %5.2f\n" , + (app_stats.tx.dequeue_pkts - + prev_app_stats.tx.dequeue_pkts)/1000000.0 ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsout: %5.2f\n" , + i, (app_stats.port_tx_pkts[i] - + prev_app_stats.port_tx_pkts[i])/1000000.0 ); + prev_app_stats.port_tx_pkts[i] = app_stats.port_tx_pkts[i]; + } +printf (" - Transmitted: %5.2f\n" , + (app_stats.tx.tx_pkts - + prev_app_stats.tx.tx_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.tx.enqdrop_pkts - + prev_app_stats.tx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + + prev_app_stats.rx.rx_pkts = app_stats.rx.rx_pkts; + prev_app_stats.rx.returned_pkts = app_stats.rx.returned_pkts; + prev_app_stats.rx.enqueued_pkts = app_stats.rx.enqueued_pkts; + prev_app_stats.rx.enqdrop_pkts = app_stats.rx.enqdrop_pkts; + prev_app_stats.dist.in_pkts = app_stats.dist.in_pkts; + prev_app_stats.dist.ret_pkts = app_stats.dist.ret_pkts; + prev_app_stats.dist.sent_pkts = app_stats.dist.sent_pkts; + prev_app_stats.dist.enqdrop_pkts = app_stats.dist.enqdrop_pkts; + prev_app_stats.tx.dequeue_pkts = app_stats.tx.dequeue_pkts; + prev_app_stats.tx.tx_pkts = app_stats.tx.tx_pkts; + prev_app_stats.tx.enqdrop_pkts = app_stats.tx.enqdrop_pkts; + +for (i =0 ; i < num_workers; i++) { +printf ("Worker %02u Pkts: %5.2f. Bursts(1-8): " , i, + (app_stats.worker_pkts[i] - + prev_app_stats.worker_pkts[i])/1000000.0 ); +for (j =0 ; j <8 ; j++) +printf ("%ld " , app_stats.worker_bursts[i][j]); +printf ("\n" ); + prev_app_stats.worker_pkts[i] = app_stats.worker_pkts[i]; } }static int lcore_worker (struct lcore_params *p) { -struct rte_distributor *d = p->d; +struct rte_distributor_burst *d = p->d;const unsigned id = p->worker_id; +unsigned int num =0 ; +unsigned int i; +/* * for single port, xor_val will be zero so we won't modify the output * port, otherwise we send traffic from 0 to 1, 2 to 3, and vice versa */ const unsigned xor_val = (rte_eth_dev_count () >1 ); -struct rte_mbuf *buf =NULL ; + struct rte_mbuf *buf[8] __rte_cache_aligned; + +for (i =0 ; i <8 ; i++) + buf[i] =NULL ; + + app_stats.worker_pkts[p->worker_id] =1 ; +printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ()); -while (!quit_signal) { - buf =rte_distributor_get_pkt (d, id, buf); - buf->port ^= xor_val; +while (!quit_signal_work) { + +#if BURST_API + num =rte_distributor_get_pkt_burst (d, id, buf, buf, num); +/* Do a little bit of work for each packet */ +for (i =0 ; i < num; i++) { +uint64_t t =__rdtsc ()+100 ; + +while (__rdtsc () < t) +rte_pause (); + buf[i]->port ^= xor_val; + } +#else + buf[0 ] =rte_distributor_get_pkt (d, id, buf[0 ]); +uint64_t t =__rdtsc () +10 ; + +while (__rdtsc () < t) +rte_pause (); + buf[0 ]->port ^= xor_val; +#endif + + app_stats.worker_pkts[p->worker_id] += num; +if (num >0 ) + app_stats.worker_bursts[p->worker_id][num-1 ]++; } +printf ("\nCore %u exiting worker task.\n" ,rte_lcore_id ());return 0 ; }
@@ -496,12 +719,14 @@ int main(int argc, char *argv[]) { struct rte_mempool *mbuf_pool; -struct rte_distributor *d; -struct rte_ring *output_ring; +struct rte_distributor_burst *d; +struct rte_ring *dist_tx_ring; +struct rte_ring *rx_dist_ring;unsigned lcore_id, worker_id =0 ;unsigned nb_ports;uint8_t portid;uint8_t nb_ports_available; +uint64_t t, freq;/* catch ctrl-c so we can print on exit */ signal (SIGINT , int_handler);
@@ -518,10 +743,12 @@ main(int argc, char *argv[])if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid distributor parameters\n" ); -if (rte_lcore_count () <3 ) +if (rte_lcore_count () <5 )rte_exit (EXIT_FAILURE ,"Error, This application needs at " -"least 3 logical cores to run:\n" -"1 lcore for packet RX and distribution\n" +"least 5 logical cores to run:\n" +"1 lcore for stats (can be core 0)\n" +"1 lcore for packet RX\n" +"1 lcore for distribution\n" "1 lcore for packet TX\n" "and at least 1 lcore for worker threads\n" );
@@ -560,41 +787,86 @@ main(int argc, char *argv[]) "All available ports are disabled. Please set portmask.\n"); } +#if BURST_API + d =rte_distributor_create_burst ("PKT_DIST" ,rte_socket_id (), +rte_lcore_count () -4 ); +#else d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -2 ); +rte_lcore_count () -4 ); +#endif if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );/* -* scheduler ring is read only by the transmitter core, but written to -* by multiple threads +* scheduler ring is read by the transmitter core, and written to +* by scheduler core */ - output_ring =rte_ring_create ("Output_ring" ,RTE_RING_SZ , -rte_socket_id (),RING_F_SC_DEQ ); -if (output_ring ==NULL ) + dist_tx_ring =rte_ring_create ("Output_ring" ,SCHED_TX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (dist_tx_ring ==NULL ) +rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" ); + + rx_dist_ring =rte_ring_create ("Input_ring" ,SCHED_RX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (rx_dist_ring ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" );RTE_LCORE_FOREACH_SLAVE (lcore_id) { -if (worker_id ==rte_lcore_count () -2 ) +if (worker_id ==rte_lcore_count () -3 ) { +printf ("Starting distributor on lcore_id %d\n" , + lcore_id); +/* distributor core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, + rx_dist_ring, dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ( + (lcore_function_t *)lcore_distributor, + p, lcore_id); + }else if (worker_id ==rte_lcore_count () -4 ) { +printf ("Starting tx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* tx core */ rte_eal_remote_launch ((lcore_function_t *)lcore_tx, - output_ring, lcore_id); -else { + dist_tx_ring, lcore_id); + }else if (worker_id ==rte_lcore_count () -2 ) { +printf ("Starting rx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* rx core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ((lcore_function_t *)lcore_rx, + p, lcore_id); + }else { +printf ("Starting worker on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id);struct lcore_params *p =rte_malloc (NULL ,sizeof (*p),0 );if (!p)rte_panic ("malloc failure\n" ); - *p = (struct lcore_params ){worker_id, d, output_ring, mbuf_pool}; + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool};rte_eal_remote_launch ((lcore_function_t *)lcore_worker, p, lcore_id); } worker_id++; } -/* call lcore_main on master core only */ -struct lcore_params p = {0 , d, output_ring, mbuf_pool}; -if (lcore_rx (&p) !=0 ) -return -1 ; + freq =rte_get_timer_hz (); + t =__rdtsc () + freq; +while (!quit_signal_dist) { +if (t <__rdtsc ()) { +print_stats (); + t =_rdtsc () + freq; + } + }RTE_LCORE_FOREACH_SLAVE (lcore_id) {if (rte_eal_wait_lcore (lcore_id) <0 )
Signature · 1 line
2.7.4
PATCH v3 6/6 doc: distributor library changes for new burst api
In reply to David Hunt--- doc/guides/prog_guide/packet_distrib_lib.rst | 4 ++++ 1 file changed, 4 insertions(+)
doc/guides/prog_guide/packet_distrib_lib.rst +4 -0
@@ -42,6 +42,10 @@ The model of operation is shown in the diagram below. Packet Distributor mode of operation +There are two versions of the API in the distributor Library, one which sends one packet at a time to workers, +and another which sends bursts of up to 8 packets at a time to workers. The functions names of the second API +are identified by "_burst", and must not be intermixed with the single packet API. The operations described below +apply to both API's, select which API you wish to use by including the relevant header file. Distributor Core Operation --------------------------
Signature · 1 line
2.7.4
v4 cover distributor library performance enhancements
In reply to David HuntThis patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v4 changes:
* fixed issue building shared libraries
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
Original API (and code) is kept for backward compatibility
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - 4.8x
4 workers - 2.9x
8 workers - 1.8x 12 workers - 2.1x
16 workers - 1.8x
[PATCH v4 1/6] lib: distributor performance enhancements [PATCH v4 2/6] lib: add distributor vector flow matching [PATCH v4 3/6] test: unit tests for new distributor burst api [PATCH v4 4/6] test: add distributor_perf autotest [PATCH v4 5/6] example: distributor app showing burst api [PATCH v4 6/6] doc: distributor library changes for new burst api
PATCH v4 1/6 lib: distributor performance enhancements
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with _burst at the end of the function names
--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 72 +-- lib/librte_distributor/rte_distributor_burst.c | 558 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 255 ++++++++++ lib/librte_distributor/rte_distributor_priv.h | 189 +++++++ lib/librte_distributor/rte_distributor_version.map | 9 + 6 files changed, 1014 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_burst.c create mode 100644 lib/librte_distributor/rte_distributor_burst.h create mode 100644 lib/librte_distributor/rte_distributor_priv.h
lib/librte_distributor/Makefile +2 -0
@@ -43,9 +43,11 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_burst.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_burst.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.c +1 -71
80 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.c new file +558 -0
558 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.h new file +255 -0
255 lines not on this page · raw message
lib/librte_distributor/rte_distributor_priv.h new file +189 -0
189 lines not on this page · raw message
lib/librte_distributor/rte_distributor_version.map +9 -0
@@ -2,14 +2,23 @@ DPDK_2.0 { global: rte_distributor_clear_returns; + rte_distributor_clear_returns_burst; rte_distributor_create; + rte_distributor_create_burst; rte_distributor_flush; + rte_distributor_flush_burst; rte_distributor_get_pkt; + rte_distributor_get_pkt_burst; rte_distributor_poll_pkt; + rte_distributor_poll_pkt_burst; rte_distributor_process; + rte_distributor_process_burst; rte_distributor_request_pkt; + rte_distributor_request_pkt_burst; rte_distributor_return_pkt; + rte_distributor_return_pkt_burst; rte_distributor_returned_pkts; + rte_distributor_returned_pkts_burst; local: *; };
Signature · 1 line
2.7.4
Re: [PATCH v4 1/6] lib: distributor performance enhancements
Quoted 7 lines · David Hunt
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with
_burstat the end of the function namesSigned-off-by David Hunt <[email protected]>
Quoted 12 lines
--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 72 +-- lib/librte_distributor/rte_distributor_burst.c | 558 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 255 ++++++++++ lib/librte_distributor/rte_distributor_priv.h | 189 +++++++ lib/librte_distributor/rte_distributor_version.map | 9 + 6 files changed, 1014 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_burst.c create mode 100644 lib/librte_distributor/rte_distributor_burst.h create mode 100644 lib/librte_distributor/rte_distributor_priv.h
Run a documentation sanity check after this patch throws up a few warnings:
tmp/doc-check/doc.txt 2017-01-13 15:19:50.717102848 +0000 renamed from dev/null 2017-01-10 10:26:01.206201474 +0000 +1 -0
@@ -0,0 +1,6 @@ +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_burst.h:187:
warning: argument 'mbuf' of command @param is not found in the argument list of rte_distributor_return_pkt_burst(struct rte_distributor_burst *d, unsigned int worker_id, struct rte_mbuf **oldpkt, int num) +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_burst.h:199:
warning: The following parameters of rte_distributor_return_pkt_burst(struct rte_distributor_burst *d, unsigned int worker_id, struct rte_mbuf **oldpkt, int num) are not documented:
+ parameter 'oldpkt'
+ parameter 'num' +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_priv.h:73:
warning: Found unknown command `\in_flight_bitmask' +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_priv.h:73:
warning: Found unknown command `\rte_distributor_process'
Regards,
/Bruce
Re: [PATCH v4 1/6] lib: distributor performance enhancements
Quoted 42 lines · Bruce Richardson
Quoted 15 lines · David Hunt
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with
_burstat the end of the function namesSigned-off-by David Hunt <[email protected]>--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 72 +-- lib/librte_distributor/rte_distributor_burst.c | 558 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 255 ++++++++++ lib/librte_distributor/rte_distributor_priv.h | 189 +++++++ lib/librte_distributor/rte_distributor_version.map | 9 + 6 files changed, 1014 insertions(+), 71 deletions(-)Quoted 4 lines
create mode 100644
lib/librte_distributor/rte_distributor_burst.ccreate mode 100644lib/librte_distributor/rte_distributor_burst.hcreate mode 100644lib/librte_distributor/rte_distributor_priv.hRun a documentation sanity check after this patch throws up a few warnings:
tmp/doc-check/doc.txt 2017-01-13 15:19:50.717102848 +0000 renamed from dev/null 2017-01-10 10:26:01.206201474 +0000 +1
-0@@ -0,0 +1,6 @@ +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_burst.h:187:warning: argument 'mbuf' of command @param is not found in the argument list of
rte_distributor_return_pkt_burst(struct rte_distributor_burst *d, unsigned int worker_id, struct rte_mbuf **oldpkt, int num)+/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_burst.h:199:
warning: The following parameters ofrte_distributor_return_pkt_burst(struct rte_distributor_burst *d, unsigned int worker_id, struct rte_mbuf **oldpkt, int num)are not documented:tmp/doc-check/doc.txt 2017-01-13 15:19:50.717102848 +0000 renamed from dev/null 2017-01-10 10:26:01.206201474 +0000 +3
-0+ parameter 'oldpkt' + parameter 'num' +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_priv.h:73:warning: Found unknown command `\in_flight_bitmask'
+/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_priv.h:73:
warning: Found unknown command `\rte_distributor_process'
Quoted 2 lines
Regards,
/Bruce
Will be cleaned up in next revsion.
Thanks,
Dave.
Re: [PATCH v4 1/6] lib: distributor performance enhancements
In reply to David HuntQuoted 6 lines · David Hunt
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with
_burstat the end of the function names
Can you explain why this is necessary, and also how the new version works compared to the old. I know this is explained in the cover letter, but the cover letter does not make the git commit log.
Quoted 2 lines
Signed-off-by David Hunt <[email protected]>---
<snip>
lib/librte_distributor/rte_distributor_burst.c line 4
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +4
-0@@ -0,0 +1,558 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2016 Intel Corporation. All rights reserved.
Update year since we aren't in 2016 any more.
Quoted 43 lines
lib/librte_distributor/rte_distributor_burst.c new file +43
-0+* +* 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. +*/ + +#include <stdio.h> +#include <sys/queue.h> +#include <string.h> +#include <rte_mbuf.h> +#include <rte_memory.h> +#include <rte_cycles.h> +#include <rte_memzone.h> +#include <rte_errno.h> +#include <rte_string_fns.h> +#include <rte_eal_memconfig.h> +#include "rte_distributor_priv.h" +#include "rte_distributor_burst.h" + +TAILQ_HEAD (rte_dist_burst_list, rte_distributor_burst); +
lib/librte_distributor/rte_distributor_burst.c line 57
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+static struct rte_tailq_elem rte_dist_burst_tailq = { + .name ="RTE_DIST_BURST" , +}; +EAL_REGISTER_TAILQ (rte_dist_burst_tailq) + +/**** APIs called by workers ****/ + +/**** Burst Packet APIs called by workers ****/ + +/* This function should really be called return_pkt_burst() */
1) Why should it be?
2) Why isn't it called that?
Please explain the naming. :-)
Quoted 5 lines
lib/librte_distributor/rte_distributor_burst.c new file +5
-0+void +rte_distributor_request_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **oldpkt, +unsigned int count) +{
lib/librte_distributor/rte_distributor_burst.c line 72
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+struct rte_distributor_buffer_burst *buf = &(d->bufs[worker_id]); +unsigned int i; + +volatile int64_t *retptr64; + + +/* if we dont' have any packets to return, return. */ +if (count ==0 ) +return ; +
So if we don't return anything we don't get any more packets, right? What happens if we return fewer packets than we were previously given? If that is allowed, why the restriction on returning at least one?
Quoted 1 line
lib/librte_distributor/rte_distributor_burst.c new file +1
-0+ retptr64 = &(buf->retptr64[0 ]);
<snip>
Quoted 7 lines
lib/librte_distributor/rte_distributor_burst.c new file +7
-0+ +int +rte_distributor_get_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **pkts, +struct rte_mbuf **oldpkt,unsigned int return_count) +{ +unsigned int count;
lib/librte_distributor/rte_distributor_burst.c line 151
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+uint64_t retries =0 ; + +rte_distributor_request_pkt_burst (d, worker_id, oldpkt, return_count); + + count =rte_distributor_poll_pkt_burst (d, worker_id, pkts); +while (count ==0 ) { +rte_pause (); + retries++; +if (retries >1000 ) +return 0 ;
This behaviour is different to the original get_pkt() behaviour in that it has a timeout. Why the change to add the timeout, and should the timeout not be user configurable in some way?
lib/librte_distributor/rte_distributor_burst.c
Quoted 2 lines
lib/librte_distributor/rte_distributor_burst.c new file +2
-0+ +uint64_t t =rte_rdtsc ()+100 ;
need spaces around the "+"
Quoted 16 lines
lib/librte_distributor/rte_distributor_burst.c new file +16
-0+ +while (rte_rdtsc () < t) +rte_pause (); + + count =rte_distributor_poll_pkt_burst (d, worker_id, pkts); + } +return count; +} + +int +rte_distributor_return_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **oldpkt,int num) +{ +struct rte_distributor_buffer_burst *buf = &d->bufs[worker_id]; +unsigned int i; +
lib/librte_distributor/rte_distributor_burst.c line 179
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+for (i =0 ; i <RTE_DIST_BURST_SIZE ; i++) +/* Switch off the return bit first */ + buf->retptr64[i] &= ~RTE_DISTRIB_RETURN_BUF ; + +for (i = num; i-- >0 ; ) + buf->retptr64[i] = (((int64_t )(uintptr_t )oldpkt[i]) << +RTE_DISTRIB_FLAG_BITS ) |RTE_DISTRIB_RETURN_BUF ; + +/* set the GET_BUF but even if we got no returns */ + buf->retptr64[0 ] |=RTE_DISTRIB_GET_BUF ;
Does this mean we are requesting more packets here?
Quoted 6 lines
lib/librte_distributor/rte_distributor_burst.c new file +6
-0+ +return 0 ; +} + +/**** APIs called on distributor core ***/ +
<snip>
lib/librte_distributor/rte_distributor_burst.c line 279
Quoted 3 lines
lib/librte_distributor/rte_distributor_burst.c new file +3
-0+ +static unsigned int +release (struct rte_distributor_burst *d,unsigned int wkr)
I think this function needs a comment describing what it is doing, and where is it called from and why. Other functions on distributor side probably need the same thing too.
Quoted 32 lines
lib/librte_distributor/rte_distributor_burst.c new file +32
-0+{ +struct rte_distributor_buffer_burst *buf = &(d->bufs[wkr]); +unsigned int i; + +if (d->backlog[wkr].count ==0 ) +return 0 ; + +while (!(d->bufs[wkr].bufptr64[0 ] &RTE_DISTRIB_GET_BUF )) +rte_pause (); + +handle_returns (d, wkr); + + buf->count =0 ; + +for (i =0 ; i < d->backlog[wkr].count; i++) { + d->bufs[wkr].bufptr64[i] = d->backlog[wkr].pkts[i] | +RTE_DISTRIB_GET_BUF |RTE_DISTRIB_VALID_BUF ; + d->in_flight_tags[wkr][i] = d->backlog[wkr].tags[i]; + } + buf->count = i; +for ( ; i <RTE_DIST_BURST_SIZE ; i++) { + buf->bufptr64[i] =RTE_DISTRIB_GET_BUF ; + d->in_flight_tags[wkr][i] =0 ; + } + + d->backlog[wkr].count =0 ; + +/* Clear the GET bit */ + buf->bufptr64[0 ] &= ~RTE_DISTRIB_GET_BUF ; +return buf->count; + +}
<snip>
Quoted 8 lines
+/**
+ * API called by a worker to get new packets to process. Any previous packets
+ * given to the worker is assumed to have completed processing, and may be
+ * optionally returned to the distributor via the oldpkt parameter.
+ *
+ * @param d
+ * The distributor instance to be used
+ * @paramworker_id
Quoted 8 lines
+ * The worker instance number to use - must be less that
num_workerspassed
+ * at distributor creation time.
+ * @param pkts
+ * The mbufs pointer array to be filled in (up to 8 packets)
+ * @param oldpkt
+ * The previous packet, if any, being processed by the worker
+ * @param retcount
+ * The number of packets being returneda
I think you need to document that it can't be zero, if I read the above C implementation correctly.
Quoted 10 lines
+ *
+ * @return
+ * The number of packets in the pkts array
+ */lib/librte_distributor/rte_distributor_burst.c new file +6
-0+int +rte_distributor_get_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **pkts, +struct rte_mbuf **oldpkt,unsigned int retcount); + +/**
<snip>
lib/librte_distributor/rte_distributor_burst.c
Quoted 6 lines
lib/librte_distributor/rte_distributor_burst.c new file +6
-0+ +/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(__m128i) / sizeof(uint16_t))
Does this compile for non-x86 with the references to __m128i?
Quoted 1 line
+
<snip>
lib/librte_distributor/rte_distributor_burst.c
Quoted 8 lines
lib/librte_distributor/rte_distributor_burst.c new file +8
-0+ +struct rte_distributor_returned_pkts returns; +}; + +/* All different signature compare functions */ +enum rte_distributor_match_function { +RTE_DIST_MATCH_SCALAR =0 , +RTE_DIST_MATCH_NUM
I think this last entry should be "RTE_DIST_NUM_MATCH_FNS", as "NUM" is not a match function, and the define doesn't ready right.
Quoted 49 lines
lib/librte_distributor/rte_distributor_burst.c new file +31
-0+}; + +struct rte_distributor_burst { +TAILQ_ENTRY (rte_distributor_burst) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */ + +/**> +* First cache line in the this array are the tags inflight +* on the worker core. Second cache line are the backlog +* that are going to go to the worker core. +*/ + uint16_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS][RTE_DIST_BURST_SIZE*2] +__rte_cache_aligned ; + + struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] +__rte_cache_aligned ; + +struct rte_distributor_buffer_burst bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; + +enum rte_distributor_match_function dist_match_fn; +}; + +#ifdef __cplusplus +} +#endif + +#endif lib/librte_distributor/rte_distributor_version.map +5
-0@@ -2,14 +2,23 @@ DPDK_2.0 { global: rte_distributor_clear_returns; + rte_distributor_clear_returns_burst; rte_distributor_create; + rte_distributor_create_burst; rte_distributor_flush; + rte_distributor_flush_burst; rte_distributor_get_pkt; + rte_distributor_get_pkt_burst; rte_distributor_poll_pkt; + rte_distributor_poll_pkt_burst; rte_distributor_process;
lib/librte_distributor/rte_distributor_version.map DPDK_2.0 { · line 24
Quoted 10 lines
lib/librte_distributor/rte_distributor_version.map +4
-0+ rte_distributor_process_burst; rte_distributor_request_pkt; + rte_distributor_request_pkt_burst; rte_distributor_return_pkt; + rte_distributor_return_pkt_burst; rte_distributor_returned_pkts; + rte_distributor_returned_pkts_burst; local: *; };
The new functions are not present in DPDK 2.0, so you need a new node for the 17.02 release.
Regards,
/Bruce
Re: [PATCH v4 1/6] lib: distributor performance enhancements
Thanks for the comments Bruce. Addressed below.
Quoted 10 lines · Bruce Richardson
Quoted 6 lines · David Hunt
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with
_burstat the end of the function namesCan you explain why this is necessary, and also how the new version works compared to the old. I know this is explained in the cover letter, but the cover letter does not make the git commit log.
Sure. I'll add extra comments into the git comment. The main reason is to preserve the original API. This gives the user the choice to migrate to the new API should they wish to.
Quoted 75 lines
Quoted 2 lines
Signed-off-by David Hunt <[email protected]>---
<snip>
lib/librte_distributor/rte_distributor_burst.c line 4
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +4
-0@@ -0,0 +1,558 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2016 Intel Corporation. All rights reserved. Update year since we aren't in 2016 any more.
Quoted 60 lines
lib/librte_distributor/rte_distributor_burst.c new file +8
-0+* +* 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.
+ */lib/librte_distributor/rte_distributor_burst.c new file +21
-0+ +#include <stdio.h> +#include <sys/queue.h> +#include <string.h> +#include <rte_mbuf.h> +#include <rte_memory.h> +#include <rte_cycles.h> +#include <rte_memzone.h> +#include <rte_errno.h> +#include <rte_string_fns.h> +#include <rte_eal_memconfig.h> +#include "rte_distributor_priv.h" +#include "rte_distributor_burst.h" + +TAILQ_HEAD (rte_dist_burst_list, rte_distributor_burst); + +static struct rte_tailq_elem rte_dist_burst_tailq = { + .name ="RTE_DIST_BURST" , +}; +EAL_REGISTER_TAILQ (rte_dist_burst_tailq) +
Quoted 8 lines
lib/librte_distributor/rte_distributor_burst.c line 57
Quoted 5 lines
lib/librte_distributor/rte_distributor_burst.c new file +5
-0+/**** APIs called by workers ****/ + +/**** Burst Packet APIs called by workers ****/ + +/* This function should really be called return_pkt_burst() */ 1) Why should it be?
2) Why isn't it called that?
Please explain the naming.
It seemed to me that the main use of this function was to return the packets from the worker rather than requesting new packets, whilst also toggling the bit to tell the distributor to send more packets. So I guess it's OK as it is. I've removed the comment to remove this confusion.
Quoted 10 lines
Quoted 10 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+void +rte_distributor_request_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **oldpkt, +unsigned int count) +{ +struct rte_distributor_buffer_burst *buf = &(d->bufs[worker_id]); +unsigned int i; + +volatile int64_t *retptr64; +
Quoted 8 lines
lib/librte_distributor/rte_distributor_burst.c line 72
Quoted 5 lines
lib/librte_distributor/rte_distributor_burst.c new file +5
-0+ +/* if we dont' have any packets to return, return. */ +if (count ==0 ) +return ; +So if we don't return anything we don't get any more packets, right? What happens if we return fewer packets than we were previously given? If that is allowed, why the restriction on returning at least one?
You are correct. We should be able to return 0, and still flip the handshake bit to request more packets. This check will be removed.
Quoted 15 lines
Quoted 1 line
+ retptr64 = &(buf->retptr64[0]);
<snip>
Quoted 13 lines
lib/librte_distributor/rte_distributor_burst.c new file +10
-0+ +int +rte_distributor_get_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **pkts, +struct rte_mbuf **oldpkt,unsigned int return_count) +{ +unsigned int count; +uint64_t retries =0 ; + + rte_distributor_request_pkt_burst(d, worker_id, oldpkt,
return_count);lib/librte_distributor/rte_distributor_burst.c new file +2
-0+ + count =rte_distributor_poll_pkt_burst (d, worker_id, pkts);
Quoted 8 lines
lib/librte_distributor/rte_distributor_burst.c line 151
Quoted 5 lines
lib/librte_distributor/rte_distributor_burst.c new file +5
-0+while (count ==0 ) { +rte_pause (); + retries++; +if (retries >1000 ) +return 0 ;This behaviour is different to the original
get_pkt()behaviour in that it has a timeout. Why the change to add the timeout, and should the timeout not be user configurable in some way?
I had another look at this, and managed to clean up this logic. There is no longer a need for the retry.
In the old logic, the poll_pkt function returned a pointer, or NULL when the handshake bit was not ready. In the new logic, up until now, I had similar logic, but return 0 for both the case where the bit was not ready, and the bit was ready and the number of valid pointers was 0. This meant that there was no way for the loop to break out when the application was exiting or flushing. I've now introduced a -1 return when the bit is not ready, so will continue looping. But when the distributor sets the bot with no packets, the poll_pkt function will return 0, allowing the loop to exit and return to the caller.
Thanks for that comment, Bruce, it's fixed a major shortcoming in the logic.
Quoted 3 lines
lib/librte_distributor/rte_distributor_burst.c
Quoted 2 lines
lib/librte_distributor/rte_distributor_burst.c new file +2
-0+ +uint64_t t =rte_rdtsc ()+100 ;need spaces around the "+"
Done
Quoted 19 lines
Quoted 19 lines
lib/librte_distributor/rte_distributor_burst.c new file +19
-0+ +while (rte_rdtsc () < t) +rte_pause (); + + count =rte_distributor_poll_pkt_burst (d, worker_id, pkts); + } +return count; +} + +int +rte_distributor_return_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **oldpkt,int num) +{ +struct rte_distributor_buffer_burst *buf = &d->bufs[worker_id]; +unsigned int i; + +for (i =0 ; i <RTE_DIST_BURST_SIZE ; i++) +/* Switch off the return bit first */ + buf->retptr64[i] &= ~RTE_DISTRIB_RETURN_BUF ;
Quoted 8 lines
lib/librte_distributor/rte_distributor_burst.c line 179
Quoted 7 lines
lib/librte_distributor/rte_distributor_burst.c new file +7
-0+ +for (i = num; i-- >0 ; ) + buf->retptr64[i] = (((int64_t )(uintptr_t )oldpkt[i]) << +RTE_DISTRIB_FLAG_BITS ) |RTE_DISTRIB_RETURN_BUF ; + +/* set the GET_BUF but even if we got no returns */ + buf->retptr64[0 ] |=RTE_DISTRIB_GET_BUF ;Does this mean we are requesting more packets here?
No, we're setting retptr which means that the distributor will start processing the returns cacheline. The only way to request more packets is
buf->bufptr64[0] |= RTE_DISTRIB_GET_BUF;
This is usually called when you are shutting down a thread and want to return what you have, and not request any new packets from the distributor.
Quoted 8 lines
Quoted 7 lines
lib/librte_distributor/rte_distributor_burst.c new file +6
-0+ +return 0 ; +} + +/**** APIs called on distributor core ***/ +<snip>
Quoted 6 lines
lib/librte_distributor/rte_distributor_burst.c line 279
Quoted 3 lines
lib/librte_distributor/rte_distributor_burst.c new file +3
-0+ +static unsigned int +release (struct rte_distributor_burst *d,unsigned int wkr)I think this function needs a comment describing what it is doing, and where is it called from and why. Other functions on distributor side probably need the same thing too.
Done.
Quoted 52 lines
Quoted 32 lines
lib/librte_distributor/rte_distributor_burst.c new file +32
-0+{ +struct rte_distributor_buffer_burst *buf = &(d->bufs[wkr]); +unsigned int i; + +if (d->backlog[wkr].count ==0 ) +return 0 ; + +while (!(d->bufs[wkr].bufptr64[0 ] &RTE_DISTRIB_GET_BUF )) +rte_pause (); + +handle_returns (d, wkr); + + buf->count =0 ; + +for (i =0 ; i < d->backlog[wkr].count; i++) { + d->bufs[wkr].bufptr64[i] = d->backlog[wkr].pkts[i] | +RTE_DISTRIB_GET_BUF |RTE_DISTRIB_VALID_BUF ; + d->in_flight_tags[wkr][i] = d->backlog[wkr].tags[i]; + } + buf->count = i; +for ( ; i <RTE_DIST_BURST_SIZE ; i++) { + buf->bufptr64[i] =RTE_DISTRIB_GET_BUF ; + d->in_flight_tags[wkr][i] =0 ; + } + + d->backlog[wkr].count =0 ; + +/* Clear the GET bit */ + buf->bufptr64[0 ] &= ~RTE_DISTRIB_GET_BUF ; +return buf->count; + +}<snip>
Quoted 11 lines
+/**
+ * API called by a worker to get new packets to process. Any previous packets
+ * given to the worker is assumed to have completed processing, and may be
+ * optionally returned to the distributor via the oldpkt parameter.
+ *
+ * @param d
+ * The distributor instance to be used
+ * @paramworker_id
+ * The worker instance number to use - must be less thatQuoted 8 lines
num_workerspassed
+ * at distributor creation time.
+ * @param pkts
+ * The mbufs pointer array to be filled in (up to 8 packets)
+ * @param oldpkt
+ * The previous packet, if any, being processed by the worker
+ * @param retcount
+ * The number of packets being returneda
Quoted 2 lines
I think you need to document that it can't be zero, if I read the above C implementation correctly.
Can be zero now, after resolving some issues indicated above. We should be able to return zero to indicated that we've processed all in the burst but are not returning any (i.e. drop)
Quoted 11 lines
Quoted 10 lines
+ *
+ * @return
+ * The number of packets in the pkts array
+ */lib/librte_distributor/rte_distributor_burst.c new file +6
-0+int +rte_distributor_get_pkt_burst (struct rte_distributor_burst *d, +unsigned int worker_id,struct rte_mbuf **pkts, +struct rte_mbuf **oldpkt,unsigned int retcount); + +/** <snip>
Quoted 7 lines
lib/librte_distributor/rte_distributor_burst.c
Quoted 6 lines
lib/librte_distributor/rte_distributor_burst.c new file +6
-0+ +/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(__m128i) / sizeof(uint16_t))Does this compile for non-x86 with the references to
__m128i?
Changed to rte_xmm_t
Quoted 12 lines
Quoted 1 line
+
<snip>
lib/librte_distributor/rte_distributor_burst.c
Quoted 8 lines
lib/librte_distributor/rte_distributor_burst.c new file +8
-0+ +struct rte_distributor_returned_pkts returns; +}; + +/* All different signature compare functions */ +enum rte_distributor_match_function { +RTE_DIST_MATCH_SCALAR =0 , +RTE_DIST_MATCH_NUM I think this last entry should be "
RTE_DIST_NUM_MATCH_FNS", as "NUM" is not a match function, and the define doesn't ready right.
Done.
Quoted 53 lines
Quoted 53 lines
lib/librte_distributor/rte_distributor_burst.c new file +7
-0+}; + +struct rte_distributor_burst { +TAILQ_ENTRY (rte_distributor_burst) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */
lib/librte_distributor/rte_distributor_burst.c new file +7
-0+ +/**> +* First cache line in the this array are the tags inflight +* on the worker core. Second cache line are the backlog +* that are going to go to the worker core. +*/ +uint16_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS][RTE_DIST_BURST_SIZE*2]
lib/librte_distributor/rte_distributor_burst.c new file +17
-0+__rte_cache_aligned ; + + struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] + __rte_cache_aligned; + +struct rte_distributor_buffer_burst bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; + +enum rte_distributor_match_function dist_match_fn; +}; + +#ifdef __cplusplus +} +#endif + +#endif lib/librte_distributor/rte_distributor_version.map +7
-0@@ -2,14 +2,23 @@ DPDK_2.0 { global: rte_distributor_clear_returns; + rte_distributor_clear_returns_burst; rte_distributor_create; + rte_distributor_create_burst; rte_distributor_flush; + rte_distributor_flush_burst; rte_distributor_get_pkt; + rte_distributor_get_pkt_burst; rte_distributor_poll_pkt; + rte_distributor_poll_pkt_burst; rte_distributor_process; + rte_distributor_process_burst; rte_distributor_request_pkt; + rte_distributor_request_pkt_burst;
Quoted 8 lines
lib/librte_distributor/rte_distributor_version.map DPDK_2.0 { · line 24
Quoted 6 lines
lib/librte_distributor/rte_distributor_version.map +2
-0rte_distributor_return_pkt; + rte_distributor_return_pkt_burst; rte_distributor_returned_pkts; + rte_distributor_returned_pkts_burst; local: *; };The new functions are not present in DPDK 2.0, so you need a new node for the 17.02 release.
Sure.
Quoted 3 lines
Regards,
/Bruce
Thanks Bruce. I'll get a new revision up later today.
Regards,
Dave.
v5 cover distributor library performance enhancements
In reply to David HuntThis patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v4 changes:
* fixed issue building shared libraries
v5 changes:
* Removed some un-needed code around retries in worker API calls
* Cleanup due to review comments on mailing list
* Cleanup of non-x86 platform compilation, fallback to scalar match
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
Original API (and code) is kept for backward compatibility
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - 4.8x
4 workers - 2.9x
8 workers - 1.8x 12 workers - 2.1x
16 workers - 1.8x
[PATCH v5 1/6] lib: distributor performance enhancements [PATCH v5 2/6] lib: add distributor vector flow matching [PATCH v5 3/6] test: unit tests for new distributor burst API [PATCH v5 4/6] test: add distributor perf autotest [PATCH v5 5/6] examples/distributor_app: showing burst API [PATCH v5 6/6] doc: distributor library changes for new burst API
PATCH v5 1/6 lib: distributor performance enhancements
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with _burst at the end of the function names. This is to preserve the original API (and code) for backward compatibility.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 74 +-- lib/librte_distributor/rte_distributor.h | 2 +- lib/librte_distributor/rte_distributor_burst.c | 563 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 255 ++++++++++ lib/librte_distributor/rte_distributor_priv.h | 189 +++++++ lib/librte_distributor/rte_distributor_version.map | 14 + 7 files changed, 1026 insertions(+), 73 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_burst.c create mode 100644 lib/librte_distributor/rte_distributor_burst.h create mode 100644 lib/librte_distributor/rte_distributor_priv.h
lib/librte_distributor/Makefile +2 -0
@@ -43,9 +43,11 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_burst.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_burst.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.c +2 -72
88 lines not on this page · raw message
lib/librte_distributor/rte_distributor.h +1 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
lib/librte_distributor/rte_distributor_burst.c new file +563 -0
563 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.h new file +255 -0
255 lines not on this page · raw message
lib/librte_distributor/rte_distributor_priv.h new file +189 -0
189 lines not on this page · raw message
lib/librte_distributor/rte_distributor_version.map +14 -0
@@ -13,3 +13,17 @@ DPDK_2.0 { local: *; }; + +DPDK_17.02 { + global: + + rte_distributor_clear_returns_burst; + rte_distributor_create_burst; + rte_distributor_flush_burst; + rte_distributor_get_pkt_burst; + rte_distributor_poll_pkt_burst; + rte_distributor_process_burst; + rte_distributor_request_pkt_burst; + rte_distributor_return_pkt_burst; + rte_distributor_returned_pkts_burst; +} DPDK_2.0;
Signature · 1 line
2.7.4
Re: [PATCH v5 1/6] lib: distributor performance enhancements
Quoted 14 lines · David Hunt
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with
_burstat the end of the function names. This is to preserve the original API (and code) for backward compatibility.It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
Quoted 7 lines
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
Signed-off-by David Hunt <[email protected]>---
I still see some issues reported here by sanity check scripts.
/Bruce
tmp/doc-check/doc.txt 2017-01-23 12:23:01.748870247 +0000 renamed from dev/null 2017-01-10 10:26:01.206201474 +0000 +1 -0
@@ -0,0 +1,6 @@ +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_burst.h:187:
warning: argument 'mbuf' of command @param is not found in the argument list of rte_distributor_return_pkt_burst(struct rte_distributor_burst *d, unsigned int worker_id, struct rte_mbuf **oldpkt, int num) +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_burst.h:199:
warning: The following parameters of rte_distributor_return_pkt_burst(struct rte_distributor_burst *d, unsigned int worker_id, struct rte_mbuf **oldpkt, int num) are not documented:
+ parameter 'oldpkt'
+ parameter 'num' +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_priv.h:73:
warning: Found unknown command `\in_flight_bitmask' +/home/bruce/dpdk-clean/lib/librte_distributor/rte_distributor_priv.h:73:
warning: Found unknown command `\rte_distributor_process'
==== Error with doc check ====
Line too long:
makes use of the 7 free spaces in the same cache line in order to send up to
### lib: distributor performance enhancements
WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#17:
makes use of the 7 free spaces in the same cache line in order to send up to
total: 0 errors, 1 warnings, 1131 lines checked
0/1 valid patch
v6 cover distributor library performance enhancements
In reply to David HuntThis patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v4 changes:
* fixed issue building shared libraries
v5 changes:
* Removed some un-needed code around retries in worker API calls
* Cleanup due to review comments on mailing list
* Cleanup of non-x86 platform compilation, fallback to scalar match
v6 changes:
* Fixed intermittent segfault where num pkts not divisible by BURST_SIZE
* Cleanup due to review comments on mailing list
* Renamed _priv.h to _private.h.
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
Original API (and code) is kept for backward compatibility
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - 4.8x
4 workers - 2.9x
8 workers - 1.8x 12 workers - 2.1x
16 workers - 1.8x
[PATCH v6 1/6] lib: distributor performance enhancements [PATCH v6 2/6] lib: add distributor vector flow matching [PATCH v6 3/6] test: unit tests for new distributor burst API [PATCH v6 4/6] test: add distributor perf autotest [PATCH v6 5/6] examples/distributor_app: showing burst API [PATCH v6 6/6] doc: distributor library changes for new burst API
PATCH v6 1/6 lib: distributor performance enhancements
Now sends bursts of up to 8 mbufs to each worker, and tracks the in-flight flow-ids (atomic scheduling)
New file with a new api, similar to the old API except with _burst at the end of the function names. This is to preserve the original API (and code) for backward compatibility.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
--- lib/librte_distributor/Makefile | 2 + lib/librte_distributor/rte_distributor.c | 74 +-- lib/librte_distributor/rte_distributor.h | 2 +- lib/librte_distributor/rte_distributor_burst.c | 564 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_burst.h | 257 ++++++++++ lib/librte_distributor/rte_distributor_private.h | 189 +++++++ lib/librte_distributor/rte_distributor_version.map | 14 + 7 files changed, 1029 insertions(+), 73 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_burst.c create mode 100644 lib/librte_distributor/rte_distributor_burst.h create mode 100644 lib/librte_distributor/rte_distributor_private.h
lib/librte_distributor/Makefile +2 -0
@@ -43,9 +43,11 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_burst.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_burst.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.c +2 -72
88 lines not on this page · raw message
lib/librte_distributor/rte_distributor.h +1 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
lib/librte_distributor/rte_distributor_burst.c new file +564 -0
564 lines not on this page · raw message
lib/librte_distributor/rte_distributor_burst.h new file +257 -0
257 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h new file +189 -0
189 lines not on this page · raw message
lib/librte_distributor/rte_distributor_version.map +14 -0
@@ -13,3 +13,17 @@ DPDK_2.0 { local: *; }; + +DPDK_17.02 { + global: + + rte_distributor_clear_returns_burst; + rte_distributor_create_burst; + rte_distributor_flush_burst; + rte_distributor_get_pkt_burst; + rte_distributor_poll_pkt_burst; + rte_distributor_process_burst; + rte_distributor_request_pkt_burst; + rte_distributor_return_pkt_burst; + rte_distributor_returned_pkts_burst; +} DPDK_2.0;
Signature · 1 line
2.7.4
v7 cover distributor library performance enhancements
This patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v4 changes:
* fixed issue building shared libraries
v5 changes:
* Removed some un-needed code around retries in worker API calls
* Cleanup due to review comments on mailing list
* Cleanup of non-x86 platform compilation, fallback to scalar match
v6 changes:
* Fixed intermittent segfault where num pkts not divisible by BURST_SIZE
* Cleanup due to review comments on mailing list
* Renamed _priv.h to _private.h.
v7 changes:
* Reorganised patch so there's a more natural progression in the changes, and divided them down into easier to review chunks.
* Previous versions of this patch set were effectively two APIs. We now have a single API. Legacy functionality can
be used by by using the rte_distributor_create API call with the RTE_DISTRIBUTOR_SINGLE flag when creating a distributor instance.
* Added symbol versioning for old API so that ABI is preserved.
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
If 32 bits Flow IDs are required, use the packet-at-a-time (SINGLE) mode.
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - 4.8x
4 workers - 2.9x
8 workers - 1.8x 12 workers - 2.1x
16 workers - 1.8x
[01/17] lib: rename legacy distributor lib files [02/17] lib: symbol versioning of functions in distributor [03/17] lib: create rte_distributor_private.h [04/17] lib: add new burst oriented distributor structs [05/17] lib: add new distributor code
[06/17] lib: add SIMD flow matching to distributor [07/17] lib: apply symbol versioning to distibutor lib [08/17] test: change params to distributor autotest [09/17] test: switch distributor test over to burst API [10/17] test: test single and burst distributor API [11/17] test: add perf test for distributor burst mode [12/17] example: add extra stats to distributor sample [13/17] sample: distributor: wait for ports to come up [14/17] sample: switch to new distributor API [15/17] lib: make v20 header file private
[16/17] doc: distributor library changes for new burst api [17/17] maintainers: add to distributor lib maintainers
PATCH v7 1/17 lib: rename legacy distributor lib files
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
--- app/test/test_distributor.c | 2 +- app/test/test_distributor_perf.c | 2 +- examples/distributor/main.c | 2 +- lib/librte_distributor/Makefile | 4 +- lib/librte_distributor/rte_distributor.c | 487 --------------------------- lib/librte_distributor/rte_distributor.h | 247 -------------- lib/librte_distributor/rte_distributor_v20.c | 487 +++++++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.h | 247 ++++++++++++++ 8 files changed, 739 insertions(+), 739 deletions(-) delete mode 100644 lib/librte_distributor/rte_distributor.c delete mode 100644 lib/librte_distributor/rte_distributor.h create mode 100644 lib/librte_distributor/rte_distributor_v20.c create mode 100644 lib/librte_distributor/rte_distributor_v20.h
app/test/test_distributor.c +1 -1
@@ -39,7 +39,7 @@#include <rte_errno.h> #include <rte_mempool.h> #include <rte_mbuf.h> -#include <rte_distributor.h> +#include <rte_distributor_v20.h> #define ITER_POWER 20/* log 2 of how many iterations we do when timing. */ #define BURST 32
app/test/test_distributor_perf.c +1 -1
@@ -39,7 +39,7 @@#include <rte_cycles.h> #include <rte_common.h> #include <rte_mbuf.h> -#include <rte_distributor.h> +#include <rte_distributor_v20.h> #define ITER_POWER 20/* log 2 of how many iterations we do when timing. */ #define BURST 32
examples/distributor/main.c +1 -1
@@ -43,7 +43,7 @@#include <rte_malloc.h> #include <rte_debug.h> #include <rte_prefetch.h> -#include <rte_distributor.h> +#include <rte_distributor_v20.h> #define RX_RING_SIZE 256#define TX_RING_SIZE 512
lib/librte_distributor/Makefile +2 -2
@@ -42,10 +42,10 @@ EXPORT_MAP := rte_distributor_version.map LIBABIVER := 1 # all source are stored in SRCS-y -SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c # install this header file -SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.c deleted +0 -487
487 lines not on this page · raw message
lib/librte_distributor/rte_distributor.h deleted +0 -247
247 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c new file +487 -0
487 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v7 01/17] lib: rename legacy distributor lib files
Quoted 8 lines · David Hunt
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
Signed-off-by David Hunt <[email protected]>---
---snip--
Apologies, this patch should have been sent with '--find-renames', thus reducing the size of this patch significantly, and eliminating checkpatch warnings/errors.
Dave.
Re: [PATCH v7 01/17] lib: rename legacy distributor lib files
In reply to David HuntQuoted 6 lines · David Hunt
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
Signed-off-by David Hunt <[email protected]>
Quoted 9 lines
--- app/test/test_distributor.c | 2 +- app/test/test_distributor_perf.c | 2 +- examples/distributor/main.c | 2 +- lib/librte_distributor/Makefile | 4 +- lib/librte_distributor/rte_distributor.c | 487 --------------------------- lib/librte_distributor/rte_distributor.h | 247 -------------- lib/librte_distributor/rte_distributor_v20.c | 487 +++++++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.h | 247 ++++++++++++++
Rather than changing the unit tests and example applications, I think this patch would be better with a new rte_distributor.h file which simply does "#include <rte_distributor_v20.h>". Alternatively, I recently upstreamed a patch, which went into 17.02, to allow symlinks in the folder so you could create a symlink to the renamed file.
/Bruce
Re: [PATCH v7 01/17] lib: rename legacy distributor lib files
Quoted 16 lines · Bruce Richardson
Quoted 6 lines · David Hunt
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
Signed-off-by David Hunt <[email protected]>Quoted 9 lines
--- app/test/test_distributor.c | 2 +- app/test/test_distributor_perf.c | 2 +- examples/distributor/main.c | 2 +- lib/librte_distributor/Makefile | 4 +- lib/librte_distributor/rte_distributor.c | 487 --------------------------- lib/librte_distributor/rte_distributor.h | 247 -------------- lib/librte_distributor/rte_distributor_v20.c | 487 +++++++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.h | 247 ++++++++++++++
Quoted 7 lines
Rather than changing the unit tests and example applications, I think this patch would be better with a new
rte_distributor.hfile which simply does "#include <rte_distributor_v20.h>". Alternatively, I recently upstreamed a patch, which went into 17.02, to allow symlinks in the folder so you could create a symlink to the renamed file./Bruce
Thanks for the review, Bruce. I've just finished reworking the patchset on your review comments (including later emails) and will post soon.
Regards,
Dave.
v8 cover distributor library performance enhancements
In reply to David HuntThis patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v8 changes:
* Changed the patch set to have a more logical order order of the changes, but the end result is basically the same.
* Fixed broken shared library build.
* Split down the updates to example app more
* No longer changes the test app and sample app to use a temporary API.
* No longer temporarily re-names the functions in the version.map file.
v7 changes:
* Reorganised patch so there's a more natural progression in the changes, and divided them down into easier to review chunks.
* Previous versions of this patch set were effectively two APIs. We now have a single API. Legacy functionality can
be used by by using the rte_distributor_create API call with the RTE_DISTRIBUTOR_SINGLE flag when creating a distributor instance.
* Added symbol versioning for old API so that ABI is preserved.
v6 changes:
* Fixed intermittent segfault where num pkts not divisible by BURST_SIZE
* Cleanup due to review comments on mailing list
* Renamed _priv.h to _private.h.
v5 changes:
* Removed some un-needed code around retries in worker API calls
* Cleanup due to review comments on mailing list
* Cleanup of non-x86 platform compilation, fallback to scalar match
v4 changes:
* fixed issue building shared libraries
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
If 32 bits Flow IDs are required, use the packet-at-a-time (SINGLE) mode.
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - up to 4.8x
4 workers - up to 2.9x
8 workers - up to 1.8x
12 workers - up to 2.1x
16 workers - up to 1.8x
[01/18] lib: rename legacy distributor lib files [02/18] lib: create private header file
[03/18] lib: add new burst oriented distributor structs [04/18] lib: add new distributor code
[05/18] lib: add SIMD flow matching to distributor [06/18] test/distributor: extra params for autotests [07/18] lib: switch distributor over to new API [08/18] lib: make v20 header file private
[09/18] lib: add symbol versioning to distributor [10/18] test: test single and burst distributor API [11/18] test: add perf test for distributor burst mode [12/18] examples/distributor: allow for extra stats [13/18] sample: distributor: wait for ports to come up [14/18] examples/distributor: give distributor a core [15/18] examples/distributor: limit number of Tx rings [16/18] examples/distributor: give Rx thread a core [17/18] doc: distributor library changes for new burst API [18/18] maintainers: add to distributor lib maintainers
PATCH v8 1/18 lib: rename legacy distributor lib files
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
---
lib/librte_distributor/Makefile | 3 +-
lib/librte_distributor/rte_distributor.h | 210 +-----------------
.../{rte_distributor.c => rte_distributor_v20.c} | 2 +-
lib/librte_distributor/rte_distributor_v20.h | 247 +++++++++++++++++++++
4 files changed, 251 insertions(+), 211 deletions(-)
rename lib/librte_distributor/{rte_distributor.c => rte_distributor_v20.c} (99%)
create mode 100644 lib/librte_distributor/rte_distributor_v20.hlib/librte_distributor/Makefile +2 -1
@@ -42,10 +42,11 @@ EXPORT_MAP := rte_distributor_version.map LIBABIVER := 1 # all source are stored in SRCS-y -SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.h +1 -209
215 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c renamed from lib/librte_distributor/rte_distributor.c +1 -1
@@ -40,7 +40,7 @@#include <rte_errno.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> -#include "rte_distributor.h" +#include "rte_distributor_v20.h" #define NO_FLAGS 0#define RTE_DISTRIB_PREFIX "DT_"
lib/librte_distributor/rte_distributor_v20.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.7.4
v9 cover distributor lib performance enhancements
This patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v9 changes:
* fixed symbol versioning so it will compile on CentOS and RedHat
v8 changes:
* Changed the patch set to have a more logical order order of the changes, but the end result is basically the same.
* Fixed broken shared library build.
* Split down the updates to example app more
* No longer changes the test app and sample app to use a temporary API.
* No longer temporarily re-names the functions in the version.map file.
v7 changes:
* Reorganised patch so there's a more natural progression in the changes, and divided them down into easier to review chunks.
* Previous versions of this patch set were effectively two APIs. We now have a single API. Legacy functionality can
be used by by using the rte_distributor_create API call with the RTE_DISTRIBUTOR_SINGLE flag when creating a distributor instance.
* Added symbol versioning for old API so that ABI is preserved.
v6 changes:
* Fixed intermittent segfault where num pkts not divisible by BURST_SIZE
* Cleanup due to review comments on mailing list
* Renamed _priv.h to _private.h.
v5 changes:
* Removed some un-needed code around retries in worker API calls
* Cleanup due to review comments on mailing list
* Cleanup of non-x86 platform compilation, fallback to scalar match
v4 changes:
* fixed issue building shared libraries
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
If 32 bits Flow IDs are required, use the packet-at-a-time (SINGLE) mode.
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - up to 4.8x
4 workers - up to 2.9x
8 workers - up to 1.8x
12 workers - up to 2.1x
16 workers - up to 1.8x
[01/18] lib: rename legacy distributor lib files [02/18] lib: create private header file
[03/18] lib: add new burst oriented distributor structs [04/18] lib: add new distributor code
[05/18] lib: add SIMD flow matching to distributor [06/18] test/distributor: extra params for autotests [07/18] lib: switch distributor over to new API [08/18] lib: make v20 header file private
[09/18] lib: add symbol versioning to distributor [10/18] test: test single and burst distributor API [11/18] test: add perf test for distributor burst mode [12/18] examples/distributor: allow for extra stats [13/18] sample: distributor: wait for ports to come up [14/18] examples/distributor: give distributor a core [15/18] examples/distributor: limit number of Tx rings [16/18] examples/distributor: give Rx thread a core [17/18] doc: distributor library changes for new burst API [18/18] maintainers: add to distributor lib maintainers
PATCH v9 1/18 lib: rename legacy distributor lib files
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
---
lib/librte_distributor/Makefile | 3 +-
lib/librte_distributor/rte_distributor.h | 210 +-----------------
.../{rte_distributor.c => rte_distributor_v20.c} | 2 +-
lib/librte_distributor/rte_distributor_v20.h | 247 +++++++++++++++++++++
4 files changed, 251 insertions(+), 211 deletions(-)
rename lib/librte_distributor/{rte_distributor.c => rte_distributor_v20.c} (99%)
create mode 100644 lib/librte_distributor/rte_distributor_v20.hlib/librte_distributor/Makefile +2 -1
@@ -42,10 +42,11 @@ EXPORT_MAP := rte_distributor_version.map LIBABIVER := 1 # all source are stored in SRCS-y -SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.h +1 -209
215 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c renamed from lib/librte_distributor/rte_distributor.c +1 -1
@@ -40,7 +40,7 @@#include <rte_errno.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> -#include "rte_distributor.h" +#include "rte_distributor_v20.h" #define NO_FLAGS 0#define RTE_DISTRIB_PREFIX "DT_"
lib/librte_distributor/rte_distributor_v20.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.7.4
v10 cover distributor library performance enhancements
This patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v10 changes:
* Addressed all review comments from v9 (thanks, Bruce)
* Squashed the two patches containing distributor structs and code
* Renamed confusing rte_distributor_v1705.h to rte_distributor_next.h
* Added usleep in main so as to be a little more gentle with that core
* Fixed some patch titles and improved some descriptions
* Updated sample app guide documentation
* Removed un-needed code limiting Tx rings and cleaned up patch
* Inherited v9 series Ack by Bruce, except new suggested addition for example app documentation (17/18)
v9 changes:
* fixed symbol versioning so it will compile on CentOS and RedHat
v8 changes:
* Changed the patch set to have a more logical order order of the changes, but the end result is basically the same.
* Fixed broken shared library build.
* Split down the updates to example app more
* No longer changes the test app and sample app to use a temporary API.
* No longer temporarily re-names the functions in the version.map file.
v7 changes:
* Reorganised patch so there's a more natural progression in the changes, and divided them down into easier to review chunks.
* Previous versions of this patch set were effectively two APIs. We now have a single API. Legacy functionality can
be used by by using the rte_distributor_create API call with the RTE_DISTRIBUTOR_SINGLE flag when creating a distributor instance.
* Added symbol versioning for old API so that ABI is preserved.
v6 changes:
* Fixed intermittent segfault where num pkts not divisible by BURST_SIZE
* Cleanup due to review comments on mailing list
* Renamed _priv.h to _private.h.
v5 changes:
* Removed some un-needed code around retries in worker API calls
* Cleanup due to review comments on mailing list
* Cleanup of non-x86 platform compilation, fallback to scalar match
v4 changes:
* fixed issue building shared libraries
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
If 32 bits Flow IDs are required, use the packet-at-a-time (SINGLE) mode.
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - up to 4.8x
4 workers - up to 2.9x
8 workers - up to 1.8x
12 workers - up to 2.1x
16 workers - up to 1.8x
[01/18] lib: rename legacy distributor lib files [02/18] lib: create private header file
[03/18] lib: add new distributor code
[04/18] lib: add SIMD flow matching to distributor [05/18] test/distributor: extra params for autotests [06/18] lib: switch distributor over to new API [07/18] lib: make v20 header file private
[08/18] lib: add symbol versioning to distributor [09/18] test: test single and burst distributor API [10/18] test: add perf test for distributor burst mode [11/18] examples/distributor: allow for extra stats [12/18] examples/distributor: wait for ports to come up [13/18] examples/distributor: add dedicated core for dist [14/18] examples/distributor: tweaks for performance [15/18] examples/distributor: give Rx thread a core [16/18] doc: distributor library changes for new burst API [17/18] doc: distributor app changes for new burst API [18/18] maintainers: add to distributor lib maintainers
PATCH v10 1/18 lib: rename legacy distributor lib files
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
---
lib/librte_distributor/Makefile | 3 +-
lib/librte_distributor/rte_distributor.h | 210 +-----------------
.../{rte_distributor.c => rte_distributor_v20.c} | 2 +-
lib/librte_distributor/rte_distributor_v20.h | 247 +++++++++++++++++++++
4 files changed, 251 insertions(+), 211 deletions(-)
rename lib/librte_distributor/{rte_distributor.c => rte_distributor_v20.c} (99%)
create mode 100644 lib/librte_distributor/rte_distributor_v20.hlib/librte_distributor/Makefile +2 -1
@@ -42,10 +42,11 @@ EXPORT_MAP := rte_distributor_version.map LIBABIVER := 1 # all source are stored in SRCS-y -SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.h +1 -209
215 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c renamed from lib/librte_distributor/rte_distributor.c +1 -1
@@ -40,7 +40,7 @@#include <rte_errno.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> -#include "rte_distributor.h" +#include "rte_distributor_v20.h" #define NO_FLAGS 0#define RTE_DISTRIB_PREFIX "DT_"
lib/librte_distributor/rte_distributor_v20.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.7.4
v11 cover distributor lib performance enhancements
This patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v11 changes:
* Fixed RTE_DIST_BURST_SIZE so it compiles on Arm platforms
* Fixed compile issue in rte_distributor_match_generic.c on Arm plarforms
* Tweaked distributor_app docs based on review and added John's Ack
v10 changes:
* Addressed all review comments from v9 (thanks, Bruce)
* Inherited v9 series Ack by Bruce, except new suggested addition for example app documentation (17/18)
* Squashed the two patches containing distributor structs and code
* Renamed confusing rte_distributor_v1705.h to rte_distributor_next.h
* Added usleep in main so as to be a little more gentle with that core
* Fixed some patch titles and improved some descriptions
* Updated sample app guide documentation
* Removed un-needed code limiting Tx rings and cleaned up patch
v9 changes:
* fixed symbol versioning so it will compile on CentOS and RedHat
v8 changes:
* Changed the patch set to have a more logical order order of the changes, but the end result is basically the same.
* Fixed broken shared library build.
* Split down the updates to example app more
* No longer changes the test app and sample app to use a temporary API.
* No longer temporarily re-names the functions in the version.map file.
v7 changes:
* Reorganised patch so there's a more natural progression in the changes, and divided them down into easier to review chunks.
* Previous versions of this patch set were effectively two APIs. We now have a single API. Legacy functionality can
be used by by using the rte_distributor_create API call with the RTE_DISTRIBUTOR_SINGLE flag when creating a distributor instance.
* Added symbol versioning for old API so that ABI is preserved.
v6 changes:
* Fixed intermittent segfault where num pkts not divisible by BURST_SIZE
* Cleanup due to review comments on mailing list
* Renamed _priv.h to _private.h.
v5 changes:
* Removed some un-needed code around retries in worker API calls
* Cleanup due to review comments on mailing list
* Cleanup of non-x86 platform compilation, fallback to scalar match
v4 changes:
* fixed issue building shared libraries
v3 changes:
* Addressed mailing list review comments
* Test code removal
* Split out SSE match into separate file to facilitate NEON addition
* Cleaned up conditional compilation flags for SSE2
* Addressed c99 style compilation errors
* rebased on latest head (Jan 2 2017, Happy New Year to all)
v2 changes:
* Created a common distributor_priv.h header file with common definitions and structures.
* Added a scalar version so it can be built and used on machines without sse2 instruction set
* Added unit autotests
* Added perf autotest
Notes:
Apps must now work in bursts, as up to 8 are given to a worker at a time For performance in matching, Flow ID's are 15-bits
If 32 bits Flow IDs are required, use the packet-at-a-time (SINGLE) mode.
Performance Gains
2.2GHz Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz
2 x XL710 40GbE NICS to 2 x 40Gbps traffic generator channels 64b packets separate cores for rx, tx, distributor
1 worker - up to 4.8x
4 workers - up to 2.9x
8 workers - up to 1.8x
12 workers - up to 2.1x
16 workers - up to 1.8x
[01/18] lib: rename legacy distributor lib files [02/18] lib: create private header file
[03/18] lib: add new distributor code
[04/18] lib: add SIMD flow matching to distributor [05/18] test/distributor: extra params for autotests [06/18] lib: switch distributor over to new API [07/18] lib: make v20 header file private
[08/18] lib: add symbol versioning to distributor [09/18] test: test single and burst distributor API [10/18] test: add perf test for distributor burst mode [11/18] examples/distributor: allow for extra stats [12/18] examples/distributor: wait for ports to come up [13/18] examples/distributor: add dedicated core for dist [14/18] examples/distributor: tweaks for performance [15/18] examples/distributor: give Rx thread a core [16/18] doc: distributor library changes for new burst API [17/18] doc: distributor app changes for new burst API [18/18] maintainers: add to distributor lib maintainers
PATCH v11 1/18 lib: rename legacy distributor lib files
Move files out of the way so that we can replace with new versions of the distributor libtrary. Files are named in such a way as to match the symbol versioning that we will apply for backward ABI compatibility.
---
lib/librte_distributor/Makefile | 3 +-
lib/librte_distributor/rte_distributor.h | 210 +-----------------
.../{rte_distributor.c => rte_distributor_v20.c} | 2 +-
lib/librte_distributor/rte_distributor_v20.h | 247 +++++++++++++++++++++
4 files changed, 251 insertions(+), 211 deletions(-)
rename lib/librte_distributor/{rte_distributor.c => rte_distributor_v20.c} (99%)
create mode 100644 lib/librte_distributor/rte_distributor_v20.hlib/librte_distributor/Makefile +2 -1
@@ -42,10 +42,11 @@ EXPORT_MAP := rte_distributor_version.map LIBABIVER := 1 # all source are stored in SRCS-y -SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h +SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
lib/librte_distributor/rte_distributor.h +1 -209
215 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c renamed from lib/librte_distributor/rte_distributor.c +1 -1
@@ -40,7 +40,7 @@#include <rte_errno.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> -#include "rte_distributor.h" +#include "rte_distributor_v20.h" #define NO_FLAGS 0#define RTE_DISTRIB_PREFIX "DT_"
lib/librte_distributor/rte_distributor_v20.h new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v11 2/18 lib: create private header file
In reply to David HuntWe'll be adding internal implementation definitions in here that are common to both burst and legacy APIs.
--- lib/librte_distributor/rte_distributor_private.h | 136 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 72 +----------- 2 files changed, 137 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_private.h
lib/librte_distributor/rte_distributor_private.h new file +136 -0
@@ -0,0 +1,136 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 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 +* 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. +*/ + +#ifndef _RTE_DIST_PRIV_H_ +#define _RTE_DIST_PRIV_H_ + +/** +* @file +* RTE distributor +* +* The distributor is a component which is designed to pass packets +* one-at-a-time to workers, with dynamic load balancing. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NO_FLAGS 0 +#define RTE_DISTRIB_PREFIX "DT_" + +/* +* We will use the bottom four bits of pointer for flags, shifting out +* the top four bits to make room (since a 64-bit pointer actually only uses +* 48 bits). An arithmetic-right-shift will then appropriately restore the +* original pointer value with proper sign extension into the top bits. +*/ +#define RTE_DISTRIB_FLAG_BITS 4 +#define RTE_DISTRIB_FLAGS_MASK (0x0F) +#define RTE_DISTRIB_NO_BUF 0/**< empty flags: no buffer requested */ +#define RTE_DISTRIB_GET_BUF (1)/**< worker requests a buffer, returns old */ +#define RTE_DISTRIB_RETURN_BUF (2)/**< worker returns a buffer, no request */ +#define RTE_DISTRIB_VALID_BUF (4)/**< set if bufptr contains ptr */ + +#define RTE_DISTRIB_BACKLOG_SIZE 8 +#define RTE_DISTRIB_BACKLOG_MASK (RTE_DISTRIB_BACKLOG_SIZE - 1) + +#define RTE_DISTRIB_MAX_RETURNS 128 +#define RTE_DISTRIB_RETURNS_MASK (RTE_DISTRIB_MAX_RETURNS - 1) + +/** +* Maximum number of workers allowed. +* Be aware of increasing the limit, becaus it is limited by how we track +* in-flight tags. See in_flight_bitmask and rte_distributor_process +*/ +#define RTE_DISTRIB_MAX_WORKERS 64 + +#define RTE_DISTRIBUTOR_NAMESIZE 32/**< Length of name for instance */ + +/** +* Buffer structure used to pass the pointer data between cores. This is cache +* line aligned, but to improve performance and prevent adjacent cache-line +* prefetches of buffers for other workers, e.g. when worker 1's buffer is on +* the next cache line to worker 0, we pad this out to three cache lines. +* Only 64-bits of the memory is actually used though. +*/ +union rte_distributor_buffer { +volatile int64_t bufptr64; +char pad[RTE_CACHE_LINE_SIZE *3 ]; +} __rte_cache_aligned; + +/* +* Transfer up to 8 mbufs at a time to/from workers, and +* flow matching algorithm optimised for 8 flow IDs at a time +*/ +#define RTE_DIST_BURST_SIZE 8 + +struct rte_distributor_backlog { +unsigned int start; +unsigned int count; + int64_t pkts[RTE_DIST_BURST_SIZE] __rte_cache_aligned; +uint16_t *tags;/* will point to second cacheline of inflights */ +} __rte_cache_aligned; + + +struct rte_distributor_returned_pkts { +unsigned int start; +unsigned int count; +struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS ]; +}; + +struct rte_distributor { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */ + +uint32_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS ]; +/**< Tracks the tag being processed per core */ +uint64_t in_flight_bitmask; +/**< on/off bits for in-flight tags. +* Note that if RTE_DISTRIB_MAX_WORKERS is larger than 64 then +* the bitmask has to expand. +*/ + +struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS ]; + +union rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; +}; + +#ifdef __cplusplus +} +#endif + +#endif
lib/librte_distributor/rte_distributor_v20.c +1 -71
78 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v11 3/18 lib: add new distributor code
In reply to David HuntThis patch includes the code for new burst-capable distributor library.
It also includes the rte_distributor_next.h file which will be used as the public header once we add in the symbol versioning for v20 and v1705 APIs, at which stage we will rename it to rte_distributor.h.
The new distributor code contains a very similar API to the legacy code, but now sends bursts of up to 8 mbufs to each worker. Flow ID's are reduced to 15 bits for an optimal flow matching algorithm.
--- lib/librte_distributor/Makefile | 1 + lib/librte_distributor/rte_distributor.c | 628 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_next.h | 269 ++++++++++ lib/librte_distributor/rte_distributor_private.h | 61 +++ 4 files changed, 959 insertions(+) create mode 100644 lib/librte_distributor/rte_distributor.c create mode 100644 lib/librte_distributor/rte_distributor_next.h
lib/librte_distributor/Makefile +1 -0
@@ -43,6 +43,7 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor.c new file +628 -0
628 lines not on this page · raw message
lib/librte_distributor/rte_distributor_next.h new file +269 -0
269 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +61 -0
67 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v11 4/18 lib: add SIMD flow matching to distributor
In reply to David HuntAdd an optimised version of the in-flight flow matching algorithm using SIMD instructions. This should give up to 1.5x over the scalar versions performance.
Falls back to scalar version if SSE4.2 not available
--- lib/librte_distributor/Makefile | 10 ++ lib/librte_distributor/rte_distributor.c | 16 ++- .../rte_distributor_match_generic.c | 43 ++++++++ lib/librte_distributor/rte_distributor_match_sse.c | 114 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_private.h | 5 + 5 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_match_generic.c create mode 100644 lib/librte_distributor/rte_distributor_match_sse.c
lib/librte_distributor/Makefile +10 -0
@@ -44,6 +44,16 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor.c +ifeq ($(CONFIG_RTE_ARCH_X86),y) +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_match_sse.c +# distributor SIMD algo needs SSE4.2 support +ifeq ($(findstring RTE_MACHINE_CPUFLAG_SSE4_2,$(CFLAGS)),) +CFLAGS_rte_distributor_match_sse.o += -msse4.2 +endif +else +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_match_generic.c +endif + # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor.c +14 -2
@@ -391,7 +391,13 @@ rte_distributor_process_v1705(struct rte_distributor_v1705 *d,for (; i <RTE_DIST_BURST_SIZE ; i++) flows[i] =0 ; -find_match_scalar (d, &flows[0 ], &matches[0 ]); +switch (d->dist_match_fn) { +case RTE_DIST_MATCH_VECTOR : +find_match_vec (d, &flows[0 ], &matches[0 ]); +break ; +default : +find_match_scalar (d, &flows[0 ], &matches[0 ]); + }/* * Matches array now contain the intended worker ID (+1) of
@@ -607,7 +613,13 @@ rte_distributor_create_v1705(const char *name,snprintf (d->name,sizeof (d->name),"%s" , name); d->num_workers = num_workers; d->alg_type = alg_type; - d->dist_match_fn =RTE_DIST_MATCH_SCALAR ; + +#if defined(RTE_ARCH_X86 ) +if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_SSE4_2 )) + d->dist_match_fn =RTE_DIST_MATCH_VECTOR ; + else +#endif + d->dist_match_fn =RTE_DIST_MATCH_SCALAR ;/* * Set up the backog tags so they're pointing at the second cache
lib/librte_distributor/rte_distributor_match_generic.c new file +43 -0
43 lines not on this page · raw message
lib/librte_distributor/rte_distributor_match_sse.c new file +114 -0
114 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +5 -0
@@ -190,6 +190,11 @@ find_match_scalar(struct rte_distributor_v1705 *d,uint16_t *data_ptr, uint16_t *output_ptr); +void +find_match_vec (struct rte_distributor_v1705 *d, +uint16_t *data_ptr, +uint16_t *output_ptr); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v11 5/18 test/distributor: extra params for autotests
In reply to David HuntIn the next few patches, we'll want to test old and new API, so here we're allowing different parameters to be passed to the tests, instead of just a distributor struct.
--- test/test/test_distributor.c | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 21 deletions(-)
test/test/test_distributor.c +43 -21
@@ -45,6 +45,13 @@#define BURST 32#define BIG_BATCH 1024 +struct worker_params { +char name[64 ]; +struct rte_distributor *dist; +}; + +struct worker_params worker_params; +/* statics - all zero-initialized by default */ static volatile int quit;/**< general quit variable for all threads */ static volatile int zero_quit;/**< var for when we just want thr0 to quit*/
@@ -81,7 +88,9 @@ static int handle_work(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist; +unsigned count =0 ;unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -107,8 +116,9 @@ handle_work(void *arg)* not necessarily in the same order (as different flows). */ static int -sanity_test (struct rte_distributor *d,struct rte_mempool *p) +sanity_test (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -249,7 +259,8 @@ static int handle_work_with_free_mbufs(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist;unsigned count =0 ;unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -270,8 +281,9 @@ handle_work_with_free_mbufs(void *arg)* library. */ static int -sanity_test_with_mbuf_alloc (struct rte_distributor *d,struct rte_mempool *p) +sanity_test_with_mbuf_alloc (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;unsigned i;struct rte_mbuf *bufs[BURST ];
@@ -305,7 +317,8 @@ static int handle_work_for_shutdown_test(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist;unsigned count =0 ;const unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -344,9 +357,10 @@ handle_work_for_shutdown_test(void *arg)* library. */ static int -sanity_test_with_worker_shutdown (struct rte_distributor *d, +sanity_test_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -401,9 +415,10 @@ sanity_test_with_worker_shutdown(struct rte_distributor *d,* one worker shuts down.. */ static int -test_flush_with_worker_shutdown (struct rte_distributor *d, +test_flush_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -480,8 +495,9 @@ int test_error_distributor_create_numworkers(void)/* Useful function which ensures that all worker functions terminate */ static void -quit_workers (struct rte_distributor *d,struct rte_mempool *p) +quit_workers (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;const unsigned num_workers =rte_lcore_count () -1 ;unsigned i;struct rte_mbuf *bufs[RTE_MAX_LCORE ];
@@ -536,28 +552,34 @@ test_distributor(void) } } -rte_eal_mp_remote_launch (handle_work, d,SKIP_MASTER ); -if (sanity_test (d, p) <0 ) + worker_params.dist = d; +sprintf (worker_params.name,"single" ); + +rte_eal_mp_remote_launch (handle_work, &worker_params,SKIP_MASTER ); +if (sanity_test (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_with_free_mbufs, d,SKIP_MASTER ); -if (sanity_test_with_mbuf_alloc (d, p) <0 ) +rte_eal_mp_remote_launch (handle_work_with_free_mbufs, &worker_params, +SKIP_MASTER ); +if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p);if (rte_lcore_count () >2 ) { -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params,SKIP_MASTER ); -if (sanity_test_with_worker_shutdown (d, p) <0 ) +if (sanity_test_with_worker_shutdown (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params,SKIP_MASTER ); -if (test_flush_with_worker_shutdown (d, p) <0 ) +if (test_flush_with_worker_shutdown (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); }else {printf ("Not enough cores to run tests for worker shutdown\n" );
@@ -572,7 +594,7 @@ test_distributor(void)return 0 ; err: -quit_workers (d, p); +quit_workers (&worker_params, p);return -1 ; }
Signature · 1 line
2.7.4
PATCH v11 6/18 lib: switch distributor over to new API
In reply to David HuntThis is the main switch over between the legacy API and the new burst API. We rename all the functions in rte_distributor.c to remove the _v1705, and we add in _v20 in the rte_distributor_v20.c
We also rename the rte_distributor_next.h as rte_distributor.h, as this is now the public header.
At the same time, we need the autotests and sample app to compile properly, hence those changes are in this patch also.
--- examples/distributor/main.c | 22 +- lib/librte_distributor/rte_distributor.c | 76 +++--- lib/librte_distributor/rte_distributor.h | 240 +++++++++++++++++- .../rte_distributor_match_generic.c | 2 +- lib/librte_distributor/rte_distributor_match_sse.c | 2 +- lib/librte_distributor/rte_distributor_next.h | 269 --------------------- lib/librte_distributor/rte_distributor_private.h | 22 +- lib/librte_distributor/rte_distributor_v20.c | 46 ++-- lib/librte_distributor/rte_distributor_v20.h | 24 +- test/test/test_distributor.c | 235 ++++++++++++------ test/test/test_distributor_perf.c | 26 +- 11 files changed, 512 insertions(+), 452 deletions(-) delete mode 100644 lib/librte_distributor/rte_distributor_next.h
examples/distributor/main.c +18 -4
@@ -405,17 +405,30 @@ lcore_worker(struct lcore_params *p) {struct rte_distributor *d = p->d;const unsigned id = p->worker_id; +unsigned int num =0 ; +unsigned int i; +/* * for single port, xor_val will be zero so we won't modify the output * port, otherwise we send traffic from 0 to 1, 2 to 3, and vice versa */ const unsigned xor_val = (rte_eth_dev_count () >1 ); -struct rte_mbuf *buf =NULL ; + struct rte_mbuf *buf[8] __rte_cache_aligned; + +for (i =0 ; i <8 ; i++) + buf[i] =NULL ;printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ());while (!quit_signal) { - buf =rte_distributor_get_pkt (d, id, buf); - buf->port ^= xor_val; + num =rte_distributor_get_pkt (d, id, buf, buf, num); +/* Do a little bit of work for each packet */ +for (i =0 ; i < num; i++) { +uint64_t t =rte_rdtsc ()+100 ; + +while (rte_rdtsc () < t) +rte_pause (); + buf[i]->port ^= xor_val; + } }return 0 ; }
@@ -561,7 +574,8 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -2 ); +rte_lcore_count () -2 , +RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );
lib/librte_distributor/rte_distributor.c +38 -38
250 lines not on this page · raw message
lib/librte_distributor/rte_distributor.h +235 -5
252 lines not on this page · raw message
lib/librte_distributor/rte_distributor_match_generic.c +1 -1
@@ -35,7 +35,7 @@#include "rte_distributor.h" void -find_match_vec (struct rte_distributor_v1705 *d, +find_match_vec (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr) {
lib/librte_distributor/rte_distributor_match_sse.c +1 -1
@@ -38,7 +38,7 @@void -find_match_vec (struct rte_distributor_v1705 *d, +find_match_vec (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr) {
lib/librte_distributor/rte_distributor_next.h deleted +0 -269
269 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +11 -11
@@ -83,7 +83,7 @@ extern "C" {* the next cache line to worker 0, we pad this out to three cache lines. * Only 64-bits of the memory is actually used though. */ -union rte_distributor_buffer { +union rte_distributor_buffer_v20 {volatile int64_t bufptr64;char pad[RTE_CACHE_LINE_SIZE *3 ]; } __rte_cache_aligned;
@@ -108,8 +108,8 @@ struct rte_distributor_returned_pkts {struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS ]; }; -struct rte_distributor { -TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ +struct rte_distributor_v20 { +TAILQ_ENTRY (rte_distributor_v20) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -124,7 +124,7 @@ struct rte_distributor {struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS ]; -union rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ]; +union rte_distributor_buffer_v20 bufs[RTE_DISTRIB_MAX_WORKERS ];struct rte_distributor_returned_pkts returns; };
@@ -144,7 +144,7 @@ enum rte_distributor_match_function {* We can pass up to 8 mbufs at a time in one cacheline. * There is a separate cacheline for returns in the burst API. */ -struct rte_distributor_buffer_v1705 { +struct rte_distributor_buffer { volatile int64_t bufptr64[RTE_DIST_BURST_SIZE]__rte_cache_aligned ;/* <= outgoing to worker */
@@ -158,8 +158,8 @@ struct rte_distributor_buffer_v1705 { int count __rte_cache_aligned; /* <= number of current mbufs */ }; -struct rte_distributor_v1705 { -TAILQ_ENTRY (rte_distributor_v1705) next;/**< Next in list. */ +struct rte_distributor { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -176,22 +176,22 @@ struct rte_distributor_v1705 { struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] __rte_cache_aligned; -struct rte_distributor_buffer_v1705 bufs[RTE_DISTRIB_MAX_WORKERS ]; +struct rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ];struct rte_distributor_returned_pkts returns;enum rte_distributor_match_function dist_match_fn; -struct rte_distributor *d_v20; +struct rte_distributor_v20 *d_v20; };void -find_match_scalar (struct rte_distributor_v1705 *d, +find_match_scalar (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr);void -find_match_vec (struct rte_distributor_v1705 *d, +find_match_vec (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr);
lib/librte_distributor/rte_distributor_v20.c +23 -23
151 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.h +12 -12
@@ -48,7 +48,7 @@ extern "C" {#define RTE_DISTRIBUTOR_NAMESIZE 32/**< Length of name for instance */ -struct rte_distributor ; +struct rte_distributor_v20 ;struct rte_mbuf ;/**
@@ -67,8 +67,8 @@ struct rte_mbuf;* @return * The newly created distributor instance */ -struct rte_distributor * -rte_distributor_create (const char *name,unsigned int socket_id, +struct rte_distributor_v20 * +rte_distributor_create_v20 (const char *name,unsigned int socket_id,unsigned int num_workers);/* *** APIS to be called on the distributor lcore *** */
@@ -103,7 +103,7 @@ rte_distributor_create(const char *name, unsigned int socket_id,* The number of mbufs processed. */ int -rte_distributor_process (struct rte_distributor *d, +rte_distributor_process_v20 (struct rte_distributor_v20 *d,struct rte_mbuf **mbufs,unsigned int num_mbufs);/**
@@ -121,7 +121,7 @@ rte_distributor_process(struct rte_distributor *d,* The number of mbufs returned in the mbufs array. */ int -rte_distributor_returned_pkts (struct rte_distributor *d, +rte_distributor_returned_pkts_v20 (struct rte_distributor_v20 *d,struct rte_mbuf **mbufs,unsigned int max_mbufs);/**
@@ -136,7 +136,7 @@ rte_distributor_returned_pkts(struct rte_distributor *d,* The number of queued/in-flight packets that were completed by this call. */ int -rte_distributor_flush (struct rte_distributor *d); +rte_distributor_flush_v20 (struct rte_distributor_v20 *d);/** * Clears the array of returned packets used as the source for the
@@ -148,7 +148,7 @@ rte_distributor_flush(struct rte_distributor *d);* The distributor instance to be used */ void -rte_distributor_clear_returns (struct rte_distributor *d); +rte_distributor_clear_returns_v20 (struct rte_distributor_v20 *d);/* *** APIS to be called on the worker lcores *** */ /*
@@ -177,7 +177,7 @@ rte_distributor_clear_returns(struct rte_distributor *d);* A new packet to be processed by the worker thread. */ struct rte_mbuf * -rte_distributor_get_pkt (struct rte_distributor *d, +rte_distributor_get_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id,struct rte_mbuf *oldpkt);/**
@@ -193,8 +193,8 @@ rte_distributor_get_pkt(struct rte_distributor *d,* The previous packet being processed by the worker */ int -rte_distributor_return_pkt (struct rte_distributor *d,unsigned int worker_id, -struct rte_mbuf *mbuf); +rte_distributor_return_pkt_v20 (struct rte_distributor_v20 *d, +unsigned int worker_id,struct rte_mbuf *mbuf);/** * API called by a worker to request a new packet to process.
@@ -217,7 +217,7 @@ rte_distributor_return_pkt(struct rte_distributor *d, unsigned int worker_id,* The previous packet, if any, being processed by the worker */ void -rte_distributor_request_pkt (struct rte_distributor *d, +rte_distributor_request_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id,struct rte_mbuf *oldpkt);/**
@@ -237,7 +237,7 @@ rte_distributor_request_pkt(struct rte_distributor *d,* packet is yet available. */ struct rte_mbuf * -rte_distributor_poll_pkt (struct rte_distributor *d, +rte_distributor_poll_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id);#ifdef __cplusplus
test/test/test_distributor.c +156 -79
435 lines not on this page · raw message
test/test/test_distributor_perf.c +17 -9
@@ -129,18 +129,25 @@ clear_packet_count(void)static int handle_work (void *arg) { -struct rte_mbuf *pkt =NULL ;struct rte_distributor *d = arg; -unsigned count =0 ; -unsigned id =__sync_fetch_and_add (&worker_idx,1 ); +unsigned int count =0 ; +unsigned int num =0 ; +int i; +unsigned int id =__sync_fetch_and_add (&worker_idx,1 ); + struct rte_mbuf *buf[8] __rte_cache_aligned; - pkt =rte_distributor_get_pkt (d, id,NULL ); +for (i =0 ; i <8 ; i++) + buf[i] =NULL ; + + num =rte_distributor_get_pkt (d, id, buf, buf, num);while (!quit) { - worker_stats[id].handled_packets++, count++; - pkt =rte_distributor_get_pkt (d, id, pkt); + worker_stats[id].handled_packets += num; + count += num; + num =rte_distributor_get_pkt (d, id, buf, buf, num); } - worker_stats[id].handled_packets++, count++; -rte_distributor_return_pkt (d, id, pkt); + worker_stats[id].handled_packets += num; + count += num; +rte_distributor_return_pkt (d, id, buf, num);return 0 ; }
@@ -228,7 +235,8 @@ test_distributor_perf(void)if (d ==NULL ) { d =rte_distributor_create ("Test_perf" ,rte_socket_id (), -rte_lcore_count () -1 ); +rte_lcore_count () -1 , +RTE_DIST_ALG_SINGLE );if (d ==NULL ) {printf ("Error creating distributor\n" );return -1 ;
Signature · 1 line
2.7.4
PATCH v11 7/18 lib: make v20 header file private
In reply to David Hunt--- lib/librte_distributor/Makefile | 1 - 1 file changed, 1 deletion(-)
lib/librte_distributor/Makefile +0 -1
@@ -57,7 +57,6 @@ endif # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h -SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
Signature · 1 line
2.7.4
Re: [PATCH v11 07/18] lib: make v20 header file private
2017-03-20 10:08, David Hunt:
Quoted 2 lines
Signed-off-by David Hunt <[email protected]>Acked-by Bruce Richardson <[email protected]>
[...]
Quoted 2 lines
SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include :=
rte_distributor.h
-SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include +=rte_distributor_v20.h
There is no explanation for this change.
I think it would be clearer if squashed with the previous patch, switching to the new API.
Let me know, I can squash it myself :)
Re: [PATCH v11 07/18] lib: make v20 header file private
Quoted 11 lines · Thomas Monjalon
2017-03-20 10:08, David Hunt:
Quoted 2 lines
Signed-off-by David Hunt <[email protected]>Acked-by Bruce Richardson <[email protected]>[...]
Quoted 2 lines
SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include :=
rte_distributor.h
-SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include +=rte_distributor_v20.hThere is no explanation for this change.
I think it would be clearer if squashed with the previous patch, switching to the new API.Let me know, I can squash it myself :)
Sure, makes sense to squash this one. Please do. :)
Thanks,
Dave.
PATCH v11 8/18 lib: add symbol versioning to distributor
In reply to David HuntAlso bumped up the ABI version number in the Makefile
--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 10 +++ lib/librte_distributor/rte_distributor_version.map | 14 ++++ 5 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_v1705.h
lib/librte_distributor/Makefile +1 -1
@@ -39,7 +39,7 @@ CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) EXPORT_MAP := rte_distributor_version.map -LIBABIVER := 1 +LIBABIVER := 2 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c
lib/librte_distributor/rte_distributor.c +48 -9
153 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v1705.h new file +89 -0
89 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c +10 -0
@@ -38,6 +38,7 @@#include <rte_memory.h> #include <rte_memzone.h> #include <rte_errno.h> +#include <rte_compat.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> #include "rte_distributor_v20.h"
@@ -63,6 +64,7 @@ rte_distributor_request_pkt_v20(struct rte_distributor_v20 *d,rte_pause (); buf->bufptr64 = req; } +VERSION_SYMBOL (rte_distributor_request_pkt, _v20,2.0 );struct rte_mbuf * rte_distributor_poll_pkt_v20(struct rte_distributor_v20 *d,
@@ -76,6 +78,7 @@ rte_distributor_poll_pkt_v20(struct rte_distributor_v20 *d,int64_t ret = buf->bufptr64 >>RTE_DISTRIB_FLAG_BITS ;return (struct rte_mbuf *)((uintptr_t )ret); } +VERSION_SYMBOL (rte_distributor_poll_pkt, _v20,2.0 );struct rte_mbuf * rte_distributor_get_pkt_v20(struct rte_distributor_v20 *d,
@@ -87,6 +90,7 @@ rte_distributor_get_pkt_v20(struct rte_distributor_v20 *d,rte_pause ();return ret; } +VERSION_SYMBOL (rte_distributor_get_pkt, _v20,2.0 ); int rte_distributor_return_pkt_v20(struct rte_distributor_v20 *d,
@@ -98,6 +102,7 @@ rte_distributor_return_pkt_v20(struct rte_distributor_v20 *d, buf->bufptr64 = req;return 0 ; } +VERSION_SYMBOL (rte_distributor_return_pkt, _v20,2.0 );/**** APIs called on distributor core ***/
@@ -314,6 +319,7 @@ rte_distributor_process_v20(struct rte_distributor_v20 *d, d->returns.count = ret_count;return num_mbufs; } +VERSION_SYMBOL (rte_distributor_process, _v20,2.0 );/* return to the caller, packets returned from workers */ int
@@ -334,6 +340,7 @@ rte_distributor_returned_pkts_v20(struct rte_distributor_v20 *d,return retval; } +VERSION_SYMBOL (rte_distributor_returned_pkts, _v20,2.0 );/* return the number of packets in-flight in a distributor, i.e. packets * being workered on or queued up in a backlog. */
@@ -362,6 +369,7 @@ rte_distributor_flush_v20(struct rte_distributor_v20 *d)return flushed; } +VERSION_SYMBOL (rte_distributor_flush, _v20,2.0 );/* clears the internal returns array in the distributor */ void
@@ -372,6 +380,7 @@ rte_distributor_clear_returns_v20(struct rte_distributor_v20 *d)memset (d->returns.mbufs,0 ,sizeof (d->returns.mbufs));#endif } +VERSION_SYMBOL (rte_distributor_clear_returns, _v20,2.0 );/* creates a distributor instance */ struct rte_distributor_v20 *
@@ -415,3 +424,4 @@ rte_distributor_create_v20(const char *name,return d; } +VERSION_SYMBOL (rte_distributor_create, _v20,2.0 );
lib/librte_distributor/rte_distributor_version.map +14 -0
@@ -13,3 +13,17 @@ DPDK_2.0 { local: *; }; + +DPDK_17.05 { + global: + + rte_distributor_clear_returns; + rte_distributor_create; + rte_distributor_flush; + rte_distributor_get_pkt; + rte_distributor_poll_pkt; + rte_distributor_process; + rte_distributor_request_pkt; + rte_distributor_return_pkt; + rte_distributor_returned_pkts; +} DPDK_2.0;
Signature · 1 line
2.7.4
Re: [PATCH v11 08/18] lib: add symbol versioning to distributor
2017-03-20 10:08, David Hunt:
Quoted 1 line
Also bumped up the ABI version number in the
Makefile
It would be good to explain the intent of versioning here.
Quoted 16 lines
Signed-off-by David Hunt <[email protected]>Acked-by Bruce Richardson <[email protected]>--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 10 +++ lib/librte_distributor/rte_distributor_version.map | 14 ++++ 5 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_v1705.hlib/librte_distributor/Makefile +0
-0
lib/librte_distributor/Makefile CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) · line 42
Quoted 5 lines
lib/librte_distributor/Makefile +1
-1@@ -39,7 +39,7 @@ CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) EXPORT_MAP := rte_distributor_version.map -LIBABIVER := 1 +LIBABIVER := 2
Why keeping ABI compat if you bump ABIVER?
I guess you do not really want to bump now.
Re: [PATCH v11 08/18] lib: add symbol versioning to distributor
Hi Thomas,
Quoted 21 lines · Thomas Monjalon
2017-03-20 10:08, David Hunt:
Quoted 1 line
Also bumped up the ABI version number in the
MakefileIt would be good to explain the intent of versioning here.
Quoted 17 lines
Signed-off-by David Hunt <[email protected]>Acked-by Bruce Richardson <[email protected]>--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 10 +++ lib/librte_distributor/rte_distributor_version.map | 14 ++++ 5 files changed, 162 insertions(+), 10 deletions(-)create mode 100644
lib/librte_distributor/rte_distributor_v1705.hlib/librte_distributor/Makefile +0
-0@@ -39,7 +39,7 @@ CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)
Quoted 7 lines
lib/librte_distributor/Makefile CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) · line 42
Quoted 4 lines
lib/librte_distributor/Makefile +1
-1EXPORT_MAP := rte_distributor_version.map -LIBABIVER := 1 +LIBABIVER := 2Why keeping ABI compat if you bump ABIVER?
I guess you do not really want to bump now.
You are correct. The symbol versioning will ensure old binaries will work without the bump in LIBABIVER. Please do not apply this line.
Thanks,
Dave.
PATCH v11 9/18 test: test single and burst distributor API
In reply to David Hunt--- test/test/test_distributor.c | 116 ++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 34 deletions(-)
test/test/test_distributor.c +82 -34
@@ -538,17 +538,25 @@ staticint test_error_distributor_create_name (void ) {struct rte_distributor *d =NULL ; +struct rte_distributor *db =NULL ;char *name =NULL ; d =rte_distributor_create (name,rte_socket_id (),rte_lcore_count () -1 , -RTE_DIST_ALG_BURST ); - +RTE_DIST_ALG_SINGLE );if (d !=NULL || rte_errno !=EINVAL ) {printf ("ERROR: No error on create() with NULL name param\n" );return -1 ; } + db =rte_distributor_create (name,rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_BURST ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create() with NULL param\n" ); +return -1 ; + } +return 0 ; }
@@ -556,15 +564,25 @@ int test_error_distributor_create_name(void)static int test_error_distributor_create_numworkers (void ) { -struct rte_distributor *d =NULL ; +struct rte_distributor *ds =NULL ; +struct rte_distributor *db =NULL ; - d =rte_distributor_create ("test_numworkers" ,rte_socket_id (), + ds =rte_distributor_create ("test_numworkers" ,rte_socket_id (),RTE_MAX_LCORE +10 , -RTE_DIST_ALG_BURST ); -if (d !=NULL || rte_errno !=EINVAL ) { +RTE_DIST_ALG_SINGLE ); +if (ds !=NULL || rte_errno !=EINVAL ) {printf ("ERROR: No error on create() with num_workers > MAX\n" );return -1 ; } + + db =rte_distributor_create ("test_numworkers" ,rte_socket_id (), +RTE_MAX_LCORE +10 , +RTE_DIST_ALG_BURST ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create() num_workers > MAX\n" ); +return -1 ; + } +return 0 ; }
@@ -597,25 +615,42 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p)static int test_distributor (void ) { -static struct rte_distributor *d; +static struct rte_distributor *ds; +static struct rte_distributor *db; +static struct rte_distributor *dist[2 ];static struct rte_mempool *p; +int i;if (rte_lcore_count () <2 ) {printf ("ERROR: not enough cores to test distributor\n" );return -1 ; } -if (d ==NULL ) { - d =rte_distributor_create ("Test_dist_burst" ,rte_socket_id (), +if (db ==NULL ) { + db =rte_distributor_create ("Test_dist_burst" ,rte_socket_id (),rte_lcore_count () -1 ,RTE_DIST_ALG_BURST ); -if (d ==NULL ) { +if (db ==NULL ) {printf ("Error creating burst distributor\n" );return -1 ; } }else { -rte_distributor_flush (d); -rte_distributor_clear_returns (d); +rte_distributor_flush (db); +rte_distributor_clear_returns (db); + } + +if (ds ==NULL ) { + ds =rte_distributor_create ("Test_dist_single" , +rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_SINGLE ); +if (ds ==NULL ) { +printf ("Error creating single distributor\n" ); +return -1 ; + } + }else { +rte_distributor_flush (ds); +rte_distributor_clear_returns (ds); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
@@ -629,37 +664,50 @@ test_distributor(void) } } - worker_params.dist = d; -sprintf (worker_params.name,"burst" ); + dist[0 ] = ds; + dist[1 ] = db; -rte_eal_mp_remote_launch (handle_work, &worker_params,SKIP_MASTER ); -if (sanity_test (&worker_params, p) <0 ) - goto err; -quit_workers (&worker_params, p); +for (i =0 ; i <2 ; i++) { -rte_eal_mp_remote_launch (handle_work_with_free_mbufs, &worker_params, -SKIP_MASTER ); -if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) - goto err; -quit_workers (&worker_params, p); + worker_params.dist = dist[i]; +if (i) +sprintf (worker_params.name,"burst" ); +else +sprintf (worker_params.name,"single" ); -if (rte_lcore_count () >2 ) { -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, - &worker_params, -SKIP_MASTER ); -if (sanity_test_with_worker_shutdown (&worker_params, p) <0 ) +rte_eal_mp_remote_launch (handle_work, + &worker_params,SKIP_MASTER ); +if (sanity_test (&worker_params, p) <0 ) goto err;quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, - &worker_params, -SKIP_MASTER ); -if (test_flush_with_worker_shutdown (&worker_params, p) <0 ) +rte_eal_mp_remote_launch (handle_work_with_free_mbufs, + &worker_params,SKIP_MASTER ); +if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) goto err;quit_workers (&worker_params, p); - }else { -printf ("Not enough cores to run tests for worker shutdown\n" ); +if (rte_lcore_count () >2 ) { +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (sanity_test_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (test_flush_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + + }else { +printf ("Too few cores to run worker shutdown test\n" ); + } + } if (test_error_distributor_create_numworkers() == -1 ||
Signature · 1 line
2.7.4
PATCH v11 10/18 test: add perf test for distributor burst mode
In reply to David Hunt--- test/test/test_distributor_perf.c | 75 ++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 24 deletions(-)
test/test/test_distributor_perf.c +51 -24
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,9 @@#include <rte_mbuf.h> #include <rte_distributor.h> -#define ITER_POWER 20/* log 2 of how many iterations we do when timing. */ -#define BURST 32 +#define ITER_POWER_CL 25/* log 2 of how many iterations for Cache Line test */ +#define ITER_POWER 21/* log 2 of how many iterations we do when timing. */ +#define BURST 64#define BIG_BATCH 1024/* static vars - zero initialized by default */
@@ -54,7 +55,8 @@ struct worker_stats { } __rte_cache_aligned;struct worker_stats worker_stats[RTE_MAX_LCORE ]; -/* worker thread used for testing the time to do a round-trip of a cache +/* +* worker thread used for testing the time to do a round-trip of a cache * line between two cores and back again */ static void
@@ -69,7 +71,8 @@ flip_bit(volatile uint64_t *arg) } } -/* test case to time the number of cycles to round-trip a cache line between +/* +* test case to time the number of cycles to round-trip a cache line between * two cores and back again. */ static void
@@ -86,7 +89,7 @@ time_cache_line_switch(void)rte_pause ();const uint64_t start_time =rte_rdtsc (); -for (i =0 ; i < (1 <<ITER_POWER ); i++) { +for (i =0 ; i < (1 <<ITER_POWER_CL ); i++) {while (*pdata)rte_pause (); *pdata =1 ;
@@ -98,13 +101,14 @@ time_cache_line_switch(void) *pdata =2 ;rte_eal_wait_lcore (slaveid);printf ("==== Cache line switch test ===\n" ); -printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER ), +printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER_CL ), end_time-start_time);printf ("Ticks per iteration = %" PRIu64"\n\n" , - (end_time-start_time) >>ITER_POWER ); + (end_time-start_time) >>ITER_POWER_CL ); } -/* returns the total count of the number of packets handled by the worker +/* +* returns the total count of the number of packets handled by the worker * functions given below. */ static unsigned
@@ -123,7 +127,8 @@ clear_packet_count(void)memset (&worker_stats,0 ,sizeof (worker_stats)); } -/* this is the basic worker function for performance tests. +/* +* This is the basic worker function for performance tests. * it does nothing but return packets and count them. */ static int
@@ -151,14 +156,15 @@ handle_work(void *arg)return 0 ; } -/* this basic performance test just repeatedly sends in 32 packets at a time +/* +* This basic performance test just repeatedly sends in 32 packets at a time * to the distributor and verifies at the end that we got them all in the worker * threads and finally how long per packet the processing took. */ static inline int perf_test (struct rte_distributor *d,struct rte_mempool *p) { -unsigned i; +unsigned int i;uint64_t start, end;struct rte_mbuf *bufs[BURST ];
@@ -181,7 +187,8 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)rte_distributor_process (d,NULL ,0 ); }while (total_packet_count () < (BURST <<ITER_POWER )); -printf ("=== Performance test of distributor ===\n" ); +rte_distributor_clear_returns (d); +printf ("Time per burst: %" PRIu64"\n" , (end - start) >>ITER_POWER );printf ("Time per packet: %" PRIu64"\n\n" , ((end - start) >>ITER_POWER )/BURST );
@@ -201,9 +208,10 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)static void quit_workers (struct rte_distributor *d,struct rte_mempool *p) { -const unsigned num_workers =rte_lcore_count () -1 ; -unsigned i; +const unsigned int num_workers =rte_lcore_count () -1 ; +unsigned int i;struct rte_mbuf *bufs[RTE_MAX_LCORE ]; +rte_mempool_get_bulk (p, (void *)bufs, num_workers); quit =1 ;
@@ -222,7 +230,8 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)static int test_distributor_perf (void ) { -static struct rte_distributor *d; +static struct rte_distributor *ds; +static struct rte_distributor *db;static struct rte_mempool *p;if (rte_lcore_count () <2 ) {
@@ -233,17 +242,28 @@ test_distributor_perf(void)/* first time how long it takes to round-trip a cache line */ time_cache_line_switch (); -if (d ==NULL ) { - d =rte_distributor_create ("Test_perf" ,rte_socket_id (), +if (ds ==NULL ) { + ds =rte_distributor_create ("Test_perf" ,rte_socket_id (),rte_lcore_count () -1 ,RTE_DIST_ALG_SINGLE ); -if (d ==NULL ) { +if (ds ==NULL ) {printf ("Error creating distributor\n" );return -1 ; } }else { -rte_distributor_flush (d); -rte_distributor_clear_returns (d); +rte_distributor_clear_returns (ds); + } + +if (db ==NULL ) { + db =rte_distributor_create ("Test_burst" ,rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_BURST ); +if (db ==NULL ) { +printf ("Error creating burst distributor\n" ); +return -1 ; + } + }else { +rte_distributor_clear_returns (db); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
@@ -257,10 +277,17 @@ test_distributor_perf(void) } } -rte_eal_mp_remote_launch (handle_work, d,SKIP_MASTER ); -if (perf_test (d, p) <0 ) +printf ("=== Performance test of distributor (single mode) ===\n" ); +rte_eal_mp_remote_launch (handle_work, ds,SKIP_MASTER ); +if (perf_test (ds, p) <0 ) +return -1 ; +quit_workers (ds, p); + +printf ("=== Performance test of distributor (burst mode) ===\n" ); +rte_eal_mp_remote_launch (handle_work, db,SKIP_MASTER ); +if (perf_test (db, p) <0 )return -1 ; -quit_workers (d, p); +quit_workers (db, p);return 0 ; }
Signature · 1 line
2.7.4
PATCH v11 11/18 examples/distributor: allow for extra stats
In reply to David HuntThis will allow us to see what's going on at various stages throughout the sample app, with per-second visibility
--- examples/distributor/main.c | 140 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 16 deletions(-)
examples/distributor/main.c +124 -16
@@ -54,24 +54,53 @@#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1 +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_RESET "\x1b[0m" +/* mask of enabled ports */ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx; +volatile uint8_t quit_signal_dist;static volatile struct app_stats {struct {uint64_t rx_pkts;uint64_t returned_pkts;uint64_t enqueued_pkts; +uint64_t enqdrop_pkts; } rx __rte_cache_aligned; + int pad1 __rte_cache_aligned; + +struct { +uint64_t in_pkts; +uint64_t ret_pkts; +uint64_t sent_pkts; +uint64_t enqdrop_pkts; + } dist __rte_cache_aligned; + int pad2 __rte_cache_aligned;struct {uint64_t dequeue_pkts;uint64_t tx_pkts; +uint64_t enqdrop_pkts; } tx __rte_cache_aligned; + int pad3 __rte_cache_aligned; + + uint64_t worker_pkts[64] __rte_cache_aligned; + + int pad4 __rte_cache_aligned; + + uint64_t worker_bursts[64][8] __rte_cache_aligned; + + int pad5 __rte_cache_aligned; + + uint64_t port_rx_pkts[64] __rte_cache_aligned; + uint64_t port_tx_pkts[64] __rte_cache_aligned; } app_stats; +struct app_stats prev_app_stats; +static const struct rte_eth_conf port_conf_default = { .rxmode = { .mq_mode =ETH_MQ_RX_RSS ,
@@ -93,6 +122,8 @@ struct output_buffer {struct rte_mbuf *mbufs[BURST_SIZE ]; }; +static void print_stats (void ); +/* * Initialises a given port using global settings and with the rx buffers * coming from the mbuf_pool passed as parameter
@@ -378,25 +409,91 @@ static voidprint_stats (void) {struct rte_eth_stats eth_stats; -unsigned i; - -printf ("\nRX thread stats:\n" ); -printf (" - Received: %" PRIu64"\n" , app_stats.rx.rx_pkts); -printf (" - Processed: %" PRIu64"\n" , app_stats.rx.returned_pkts); -printf (" - Enqueued: %" PRIu64"\n" , app_stats.rx.enqueued_pkts); - -printf ("\nTX thread stats:\n" ); -printf (" - Dequeued: %" PRIu64"\n" , app_stats.tx.dequeue_pkts); -printf (" - Transmitted: %" PRIu64"\n" , app_stats.tx.tx_pkts); +unsigned int i, j; +const unsigned int num_workers =rte_lcore_count () -4 ;for (i =0 ; i <rte_eth_dev_count (); i++) {rte_eth_stats_get (i, ð_stats); -printf ("\nPort %u stats:\n" , i); -printf (" - Pkts in: %" PRIu64"\n" , eth_stats.ipackets); -printf (" - Pkts out: %" PRIu64"\n" , eth_stats.opackets); -printf (" - In Errs: %" PRIu64"\n" , eth_stats.ierrors); -printf (" - Out Errs: %" PRIu64"\n" , eth_stats.oerrors); -printf (" - Mbuf Errs: %" PRIu64"\n" , eth_stats.rx_nombuf); + app_stats.port_rx_pkts[i] = eth_stats.ipackets; + app_stats.port_tx_pkts[i] = eth_stats.opackets; + } + +printf ("\n\nRX Thread:\n" ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsin : %5.2f\n" , i, + (app_stats.port_rx_pkts[i] - + prev_app_stats.port_rx_pkts[i])/1000000.0 ); + prev_app_stats.port_rx_pkts[i] = app_stats.port_rx_pkts[i]; + } +printf (" - Received: %5.2f\n" , + (app_stats.rx.rx_pkts - + prev_app_stats.rx.rx_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.rx.returned_pkts - + prev_app_stats.rx.returned_pkts)/1000000.0 ); +printf (" - Enqueued: %5.2f\n" , + (app_stats.rx.enqueued_pkts - + prev_app_stats.rx.enqueued_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.rx.enqdrop_pkts - + prev_app_stats.rx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("Distributor thread:\n" ); +printf (" - In: %5.2f\n" , + (app_stats.dist.in_pkts - + prev_app_stats.dist.in_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.dist.ret_pkts - + prev_app_stats.dist.ret_pkts)/1000000.0 ); +printf (" - Sent: %5.2f\n" , + (app_stats.dist.sent_pkts - + prev_app_stats.dist.sent_pkts)/1000000.0 ); +printf (" - Dropped %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.dist.enqdrop_pkts - + prev_app_stats.dist.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("TX thread:\n" ); +printf (" - Dequeued: %5.2f\n" , + (app_stats.tx.dequeue_pkts - + prev_app_stats.tx.dequeue_pkts)/1000000.0 ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsout: %5.2f\n" , + i, (app_stats.port_tx_pkts[i] - + prev_app_stats.port_tx_pkts[i])/1000000.0 ); + prev_app_stats.port_tx_pkts[i] = app_stats.port_tx_pkts[i]; + } +printf (" - Transmitted: %5.2f\n" , + (app_stats.tx.tx_pkts - + prev_app_stats.tx.tx_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.tx.enqdrop_pkts - + prev_app_stats.tx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + + prev_app_stats.rx.rx_pkts = app_stats.rx.rx_pkts; + prev_app_stats.rx.returned_pkts = app_stats.rx.returned_pkts; + prev_app_stats.rx.enqueued_pkts = app_stats.rx.enqueued_pkts; + prev_app_stats.rx.enqdrop_pkts = app_stats.rx.enqdrop_pkts; + prev_app_stats.dist.in_pkts = app_stats.dist.in_pkts; + prev_app_stats.dist.ret_pkts = app_stats.dist.ret_pkts; + prev_app_stats.dist.sent_pkts = app_stats.dist.sent_pkts; + prev_app_stats.dist.enqdrop_pkts = app_stats.dist.enqdrop_pkts; + prev_app_stats.tx.dequeue_pkts = app_stats.tx.dequeue_pkts; + prev_app_stats.tx.tx_pkts = app_stats.tx.tx_pkts; + prev_app_stats.tx.enqdrop_pkts = app_stats.tx.enqdrop_pkts; + +for (i =0 ; i < num_workers; i++) { +printf ("Worker %02u Pkts: %5.2f. Bursts(1-8): " , i, + (app_stats.worker_pkts[i] - + prev_app_stats.worker_pkts[i])/1000000.0 ); +for (j =0 ; j <8 ; j++) { +printf ("%" PRIu64" " , app_stats.worker_bursts[i][j]); + app_stats.worker_bursts[i][j] =0 ; + } +printf ("\n" ); + prev_app_stats.worker_pkts[i] = app_stats.worker_pkts[i]; } }
@@ -515,6 +612,7 @@ main(int argc, char *argv[])unsigned nb_ports;uint8_t portid;uint8_t nb_ports_available; +uint64_t t, freq;/* catch ctrl-c so we can print on exit */ signal (SIGINT , int_handler);
@@ -610,6 +708,16 @@ main(int argc, char *argv[])if (lcore_rx (&p) !=0 )return -1 ; + freq =rte_get_timer_hz (); + t =rte_rdtsc () + freq; +while (!quit_signal_dist) { +if (t <rte_rdtsc ()) { +print_stats (); + t =rte_rdtsc () + freq; + } +usleep (1000 ); + } +RTE_LCORE_FOREACH_SLAVE (lcore_id) {if (rte_eal_wait_lcore (lcore_id) <0 )return -1 ;
Signature · 1 line
2.7.4
PATCH v11 12/18 examples/distributor: wait for ports to come up
In reply to David HuntOn some machines, ports take several seconds to come up. This patch causes the app to wait.
--- examples/distributor/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
examples/distributor/main.c +4 -3
@@ -1,8 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -* All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
@@ -62,6 +61,7 @@ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx;volatile uint8_t quit_signal_dist; +volatile uint8_t quit_signal_work; static volatile struct app_stats { struct {
@@ -165,7 +165,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct rte_eth_link link;rte_eth_link_get_nowait (port, &link); -if (!link.link_status) { +while (!link.link_status) { +printf ("Waiting for Link up on port %" PRIu8"\n" , port);sleep (1 );rte_eth_link_get_nowait (port, &link); }
Signature · 1 line
2.7.4
PATCH v11 13/18 examples/distributor: add dedicated core for dist
In reply to David HuntGive the distribution functionality it's own core for performance, otherwise it's limited by the Rx core.
--- examples/distributor/main.c | 181 ++++++++++++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 58 deletions(-)
examples/distributor/main.c +123 -58
@@ -49,6 +49,8 @@#define NUM_MBUFS ((64*1024)-1)#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +#define SCHED_RX_RING_SZ 8192 +#define SCHED_TX_RING_SZ 65536#define RTE_RING_SZ 1024#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1
@@ -193,37 +195,14 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct lcore_params {unsigned worker_id;struct rte_distributor *d; -struct rte_ring *r; +struct rte_ring *rx_dist_ring; +struct rte_ring *dist_tx_ring;struct rte_mempool *mem_pool; };static int -quit_workers (struct rte_distributor *d,struct rte_mempool *p) -{ -const unsigned num_workers =rte_lcore_count () -2 ; -unsigned i; -struct rte_mbuf *bufs[num_workers]; - -if (rte_mempool_get_bulk (p, (void *)bufs, num_workers) !=0 ) { -printf ("line %d: Error getting mbufs from pool\n" , __LINE__); -return -1 ; - } - -for (i =0 ; i < num_workers; i++) - bufs[i]->hash.rss = i <<1 ; - -rte_distributor_process (d, bufs, num_workers); -rte_mempool_put_bulk (p, (void *)bufs, num_workers); - -return 0 ; -} - -static int lcore_rx (struct lcore_params *p) { -struct rte_distributor *d = p->d; -struct rte_mempool *mem_pool = p->mem_pool; -struct rte_ring *r = p->r;const uint8_t nb_ports =rte_eth_dev_count ();const int socket_id =rte_socket_id ();uint8_t port;
@@ -260,9 +239,15 @@ lcore_rx(struct lcore_params *p) } app_stats.rx.rx_pkts += nb_rx; -rte_distributor_process (d, bufs, nb_rx); -const uint16_t nb_ret =rte_distributor_returned_pkts (d, - bufs,BURST_SIZE *2 ); +/* +* You can run the distributor on the rx core with this code. Returned +* packets are then send straight to the tx core. +*/ +#if 0 +rte_distributor_process (d, bufs, nb_rx); +const uint16_t nb_ret = rte_distributor_returned_pktsd, + bufs, BURST_SIZE*2); + app_stats.rx.returned_pkts += nb_ret;if (unlikely (nb_ret ==0 )) {if (++port == nb_ports)
@@ -270,7 +255,22 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +struct rte_ring *tx_ring = p->dist_tx_ring; +uint16_t sent =rte_ring_enqueue_burst (tx_ring, + (void *)bufs, nb_ret); +#else +uint16_t nb_ret = nb_rx; +/* +* Swap the following two lines if you want the rx traffic +* to go directly to tx, no distribution. +*/ +struct rte_ring *out_ring = p->rx_dist_ring; +/* struct rte_ring *out_ring = p->dist_tx_ring; */ + +uint16_t sent =rte_ring_enqueue_burst (out_ring, + (void *)bufs, nb_ret); +#endif + app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
@@ -281,20 +281,9 @@ lcore_rx(struct lcore_params *p)if (++port == nb_ports) port =0 ; } -rte_distributor_process (d,NULL ,0 ); -/* flush distributor to bring to known state */ -rte_distributor_flush (d);/* set worker & tx threads quit flag */ +printf ("\nCore %u exiting rx task.\n" ,rte_lcore_id ()); quit_signal =1 ; -/* -* worker threads may hang in get packet as -* distributor process is not running, just make sure workers -* get packets till quit_signal is actually been -* received and they gracefully shutdown -*/ -if (quit_workers (d, mem_pool) !=0 ) -return -1 ; -/* rx thread should quit at last */ return 0 ; }
@@ -331,6 +320,58 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports) } } + + +static int +lcore_distributor (struct lcore_params *p) +{ +struct rte_ring *in_r = p->rx_dist_ring; +struct rte_ring *out_r = p->dist_tx_ring; +struct rte_mbuf *bufs[BURST_SIZE *4 ]; +struct rte_distributor *d = p->d; + +printf ("\nCore %u acting as distributor core.\n" ,rte_lcore_id ()); +while (!quit_signal_dist) { +const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, + (void *)bufs,BURST_SIZE *1 ); +if (nb_rx) { + app_stats.dist.in_pkts += nb_rx; + +/* Distribute the packets */ +rte_distributor_process (d, bufs, nb_rx); +/* Handle Returns */ +const uint16_t nb_ret = +rte_distributor_returned_pkts (d, + bufs,BURST_SIZE *2 ); + +if (unlikely (nb_ret ==0 )) +continue ; + app_stats.dist.ret_pkts += nb_ret; + +uint16_t sent =rte_ring_enqueue_burst (out_r, + (void *)bufs, nb_ret); + app_stats.dist.sent_pkts += sent; +if (unlikely (sent < nb_ret)) { + app_stats.dist.enqdrop_pkts += nb_ret - sent; +RTE_LOG (DEBUG ,DISTRAPP , +"%s:Packet loss due to full out ring\n" , + __func__); +while (sent < nb_ret) +rte_pktmbuf_free (bufs[sent++]); + } + } + } +printf ("\nCore %u exiting distributor task.\n" ,rte_lcore_id ()); + quit_signal_work =1 ; + +rte_distributor_flush (d); +/* Unblock any returns so workers can exit */ +rte_distributor_clear_returns (d); + quit_signal_rx =1 ; +return 0 ; +} + +static int lcore_tx (struct rte_ring *in_r) {
@@ -403,7 +444,7 @@ int_handler(int sig_num) {printf ("Exiting on signal %d\n" , sig_num);/* set quit flag for rx thread to exit */ - quit_signal_rx =1 ; + quit_signal_dist =1 ; } static void
@@ -517,7 +558,7 @@ lcore_worker(struct lcore_params *p) buf[i] =NULL ;printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ()); -while (!quit_signal) { +while (!quit_signal_work) { num =rte_distributor_get_pkt (d, id, buf, buf, num);/* Do a little bit of work for each packet */ for (i =0 ; i < num; i++) {
@@ -608,7 +649,8 @@ main(int argc, char *argv[]) {struct rte_mempool *mbuf_pool;struct rte_distributor *d; -struct rte_ring *output_ring; +struct rte_ring *dist_tx_ring; +struct rte_ring *rx_dist_ring;unsigned lcore_id, worker_id =0 ;unsigned nb_ports;uint8_t portid;
@@ -630,10 +672,11 @@ main(int argc, char *argv[])if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid distributor parameters\n" ); -if (rte_lcore_count () <3 ) +if (rte_lcore_count () <4 )rte_exit (EXIT_FAILURE ,"Error, This application needs at " -"least 3 logical cores to run:\n" -"1 lcore for packet RX and distribution\n" +"least 4 logical cores to run:\n" +"1 lcore for packet RX\n" +"1 lcore for distribution\n" "1 lcore for packet TX\n" "and at least 1 lcore for worker threads\n" );
@@ -673,30 +716,52 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -2 , +rte_lcore_count () -3 ,RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );/* -* scheduler ring is read only by the transmitter core, but written to -* by multiple threads +* scheduler ring is read by the transmitter core, and written to +* by scheduler core */ - output_ring =rte_ring_create ("Output_ring" ,RTE_RING_SZ , -rte_socket_id (),RING_F_SC_DEQ ); -if (output_ring ==NULL ) + dist_tx_ring =rte_ring_create ("Output_ring" ,SCHED_TX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (dist_tx_ring ==NULL ) +rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" ); + + rx_dist_ring =rte_ring_create ("Input_ring" ,SCHED_RX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (rx_dist_ring ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" );RTE_LCORE_FOREACH_SLAVE (lcore_id) { -if (worker_id ==rte_lcore_count () -2 ) +if (worker_id ==rte_lcore_count () -3 ) { +printf ("Starting distributor on lcore_id %d\n" , + lcore_id); +/* distributor core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, + rx_dist_ring, dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ( + (lcore_function_t *)lcore_distributor, + p, lcore_id); + }else if (worker_id ==rte_lcore_count () -4 ) { +printf ("Starting tx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* tx core */ rte_eal_remote_launch ((lcore_function_t *)lcore_tx, - output_ring, lcore_id); -else { + dist_tx_ring, lcore_id); + }else {struct lcore_params *p =rte_malloc (NULL ,sizeof (*p),0 );if (!p)rte_panic ("malloc failure\n" ); - *p = (struct lcore_params ){worker_id, d, output_ring, mbuf_pool}; + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool};rte_eal_remote_launch ((lcore_function_t *)lcore_worker, p, lcore_id);
@@ -704,7 +769,7 @@ main(int argc, char *argv[]) worker_id++; }/* call lcore_main on master core only */ -struct lcore_params p = {0 , d, output_ring, mbuf_pool}; +struct lcore_params p = {0 , d, rx_dist_ring, dist_tx_ring, mbuf_pool};if (lcore_rx (&p) !=0 )return -1 ;
Signature · 1 line
2.7.4
PATCH v11 14/18 examples/distributor: tweaks for performance
In reply to David HuntApproximately 10% performance increase due to these changes.
--- examples/distributor/main.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
examples/distributor/main.c +23 -13
@@ -44,14 +44,14 @@#include <rte_prefetch.h> #include <rte_distributor.h> -#define RX_RING_SIZE 256 +#define RX_RING_SIZE 512#define TX_RING_SIZE 512#define NUM_MBUFS ((64*1024)-1) -#define MBUF_CACHE_SIZE 250 -#define BURST_SIZE 32 +#define MBUF_CACHE_SIZE 128 +#define BURST_SIZE 64#define SCHED_RX_RING_SZ 8192#define SCHED_TX_RING_SZ 65536 -#define RTE_RING_SZ 1024 +#define BURST_SIZE_TX 32#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1
@@ -206,6 +206,7 @@ lcore_rx(struct lcore_params *p)const uint8_t nb_ports =rte_eth_dev_count ();const int socket_id =rte_socket_id ();uint8_t port; +struct rte_mbuf *bufs[BURST_SIZE *2 ];for (port =0 ; port < nb_ports; port++) {/* skip ports that are not enabled */
@@ -229,7 +230,6 @@ lcore_rx(struct lcore_params *p) port =0 ;continue ; } -struct rte_mbuf *bufs[BURST_SIZE *2 ];const uint16_t nb_rx =rte_eth_rx_burst (port,0 , bufs,BURST_SIZE );if (unlikely (nb_rx ==0 )) {
@@ -273,6 +273,7 @@ lcore_rx(struct lcore_params *p) app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { + app_stats.rx.enqdrop_pkts += nb_ret - sent;RTE_LOG_DP (DEBUG ,DISTRAPP ,"%s:Packet loss due to full ring\n" , __func__);while (sent < nb_ret)
@@ -290,13 +291,12 @@ lcore_rx(struct lcore_params *p)static inline void flush_one_port (struct output_buffer *outbuf,uint8_t outp) { -unsigned nb_tx =rte_eth_tx_burst (outp,0 , outbuf->mbufs, - outbuf->count); - app_stats.tx.tx_pkts += nb_tx; +unsigned int nb_tx =rte_eth_tx_burst (outp,0 , + outbuf->mbufs, outbuf->count); + app_stats.tx.tx_pkts += outbuf->count;if (unlikely (nb_tx < outbuf->count)) { -RTE_LOG_DP (DEBUG ,DISTRAPP , -"%s:Packet loss with tx_burst\n" , __func__); + app_stats.tx.enqdrop_pkts += outbuf->count - nb_tx;do {rte_pktmbuf_free (outbuf->mbufs[nb_tx]); }while (++nb_tx < outbuf->count);
@@ -308,6 +308,7 @@ static inline void flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports) { uint8_t outp; +for (outp =0 ; outp < nb_ports; outp++) {/* skip ports that are not enabled */ if ((enabled_port_mask & (1 << outp)) ==0 )
@@ -400,9 +401,9 @@ lcore_tx(struct rte_ring *in_r)if ((enabled_port_mask & (1 << port)) ==0 )continue ; -struct rte_mbuf *bufs[BURST_SIZE ]; +struct rte_mbuf *bufs[BURST_SIZE_TX ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE_TX ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
@@ -431,11 +432,12 @@ lcore_tx(struct rte_ring *in_r) outbuf = &tx_buffers[outp]; outbuf->mbufs[outbuf->count++] = bufs[i]; -if (outbuf->count ==BURST_SIZE ) +if (outbuf->count ==BURST_SIZE_TX )flush_one_port (outbuf, outp); } } } +printf ("\nCore %u exiting tx task.\n" ,rte_lcore_id ());return 0 ; }
@@ -557,6 +559,8 @@ lcore_worker(struct lcore_params *p)for (i =0 ; i <8 ; i++) buf[i] =NULL ; + app_stats.worker_pkts[p->worker_id] =1 ; +printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ());while (!quit_signal_work) { num =rte_distributor_get_pkt (d, id, buf, buf, num);
@@ -568,6 +572,10 @@ lcore_worker(struct lcore_params *p)rte_pause (); buf[i]->port ^= xor_val; } + + app_stats.worker_pkts[p->worker_id] += num; +if (num >0 ) + app_stats.worker_bursts[p->worker_id][num-1 ]++; }return 0 ; }
@@ -756,6 +764,8 @@ main(int argc, char *argv[])rte_eal_remote_launch ((lcore_function_t *)lcore_tx, dist_tx_ring, lcore_id); }else { +printf ("Starting worker on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id);struct lcore_params *p =rte_malloc (NULL ,sizeof (*p),0 );if (!p)
Signature · 1 line
2.7.4
Re: [PATCH v11 14/18] examples/distributor: tweaks for performance
2017-03-20 10:08, David Hunt:
Quoted 1 line
Approximately 10% performance increase due to these changes.
It would have been better to explain what are the changes.
Quoted 5 lines
Signed-off-by David Hunt <[email protected]>Acked-by Bruce Richardson <[email protected]>--- examples/distributor/main.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
Re: [PATCH v11 14/18] examples/distributor: tweaks for performance
Quoted 9 lines · Thomas Monjalon
2017-03-20 10:08, David Hunt:
Quoted 1 line
Approximately 10% performance increase due to these changes.
It would have been better to explain what are the changes.
Quoted 5 lines
Signed-off-by David Hunt <[email protected]>Acked-by Bruce Richardson <[email protected]>--- examples/distributor/main.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
Hi Thomas,
Sure, how about this:
This patch tunes Rx, Tx, and rte_distributor_process() burst sizes to maximize performance. It also addresses some checkpatch issues.
The result is approximately 10% performance increase.
Regards,
Dave.
PATCH v11 15/18 examples/distributor: give Rx thread a core
In reply to David HuntNow that we're printing out a page of stats every second to the console, we should give the stats it's own core so that we don't interfere with the performance of the Rx core.
--- examples/distributor/main.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
examples/distributor/main.c +16 -8
@@ -680,9 +680,10 @@ main(int argc, char *argv[])if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid distributor parameters\n" ); -if (rte_lcore_count () <4 ) +if (rte_lcore_count () <5 )rte_exit (EXIT_FAILURE ,"Error, This application needs at " -"least 4 logical cores to run:\n" +"least 5 logical cores to run:\n" +"1 lcore for stats (can be core 0)\n" "1 lcore for packet RX\n" "1 lcore for distribution\n" "1 lcore for packet TX\n"
@@ -724,7 +725,7 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -3 , +rte_lcore_count () -4 ,RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );
@@ -763,6 +764,18 @@ main(int argc, char *argv[])/* tx core */ rte_eal_remote_launch ((lcore_function_t *)lcore_tx, dist_tx_ring, lcore_id); + }else if (worker_id ==rte_lcore_count () -2 ) { +printf ("Starting rx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* rx core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ((lcore_function_t *)lcore_rx, + p, lcore_id); }else {printf ("Starting worker on worker_id %d, lcore_id %d\n" , worker_id, lcore_id);
@@ -778,11 +791,6 @@ main(int argc, char *argv[]) } worker_id++; } -/* call lcore_main on master core only */ -struct lcore_params p = {0 , d, rx_dist_ring, dist_tx_ring, mbuf_pool}; - -if (lcore_rx (&p) !=0 ) -return -1 ; freq =rte_get_timer_hz (); t =rte_rdtsc () + freq;
Signature · 1 line
2.7.4
PATCH v11 16/18 doc: distributor library changes for new burst API
In reply to David Hunt--- doc/guides/prog_guide/packet_distrib_lib.rst | 3 +++ 1 file changed, 3 insertions(+)
doc/guides/prog_guide/packet_distrib_lib.rst +3 -0
@@ -42,6 +42,9 @@ The model of operation is shown in the diagram below. Packet Distributor mode of operation +There are two modes of operation of the API in the distributor Library, one which sends one packet at a time +to workers using 32-bits for flow_id, and an optiomised mode which sends bursts of up to 8 packets at a time +to workers, using 15 bits of flow_id. The mode is selected by the type field in the ``rte_distributor_create function``. Distributor Core Operation --------------------------
Signature · 1 line
2.7.4
Re: [PATCH v11 16/18] doc: distributor library changes for new burst API
Quoted 30 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of David Hunt
Sent: Monday, March 20, 2017 10:09 AM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; Hunt, David <[email protected]>
Subject: [dpdk-dev] [PATCH v11 16/18] doc: distributor library changes for new burst APISigned-off-by David Hunt <[email protected]>Acked-by John McNamara <[email protected]>Acked-by Bruce Richardson <[email protected]>--- doc/guides/prog_guide/packet_distrib_lib.rst | 3 +++ 1 file changed, 3 insertions(+)doc/guides/prog_guide/packet_distrib_lib.rst +3
-0@@ -42,6 +42,9 @@ The model of operation is shown in the diagram below. Packet Distributor mode of operation +There are two modes of operation of the API in the distributor Library, +one which sends one packet at a time to workers using 32-bits for +flow_id, and an optiomised mode which sends bursts of up to 8 packets at
Quoted 2 lines
a time to workers, using 15 bits of
flow_id. The mode is selected by the type field in the ``rte_distributor_create function``.
s/Library/library
s/optiomised/optimized/
s/rte_distributor_create function``/rte_distributor_create()`` function/
PATCH v11 17/18 doc: distributor app changes for new burst API
In reply to David HuntChanges in the thread layout described, with an updated diagram.
--- doc/guides/sample_app_ug/dist_app.rst | 50 +++--- doc/guides/sample_app_ug/img/dist_app.svg | 276 +++++++++++++++++------------- 2 files changed, 180 insertions(+), 146 deletions(-)
doc/guides/sample_app_ug/dist_app.rst +27 -23
@@ -104,33 +104,35 @@ Running the Application Explanation ----------- -The distributor application consists of three types of threads: a receive -thread (lcore_rx()), a set of worker threads(lcore_worker()) -and a transmit thread(lcore_tx()). How these threads work together is shown -in :numref:`figure_dist_app` below. The main() function launches threads of these three types. -Each thread has a while loop which will be doing processing and which is -terminated only upon SIGINT or ctrl+C. The receive and transmit threads -communicate using a software ring (rte_ring structure). - -The receive thread receives the packets using rte_eth_rx_burst() and gives -them to the distributor (using rte_distributor_process() API) which will -be called in context of the receive thread itself. The distributor distributes -the packets to workers threads based on the tagging of the packet - -indicated by the hash field in the mbuf. For IP traffic, this field is -automatically filled by the NIC with the "usr" hash value for the packet, -which works as a per-flow tag. +The distributor application consists of four types of threads: a receive +thread (``lcore_rx()``), a distributor thread (``lcore_dist()``), a set of +worker threads (``lcore_worker()``), and a transmit thread(``lcore_tx()``). +How these threads work together is shown in :numref:`figure_dist_app` below. +The ``main()`` function launches threads of these four types. Each thread +has a while loop which will be doing processing and which is terminated +only upon SIGINT or ctrl+C. + +The receive thread receives the packets using ``rte_eth_rx_burst()`` and will +enqueue them to an rte_ring. The distributor thread will dequeue the packets +from the ring and assign them to workers (using ``rte_distributor_process()`` API). +This assignment is based on the tag (or flow ID) of the packet - indicated by +the hash field in the mbuf. For IP traffic, this field is automatically filled +by the NIC with the "usr" hash value for the packet, which works as a per-flow +tag. The distributor thread communicates with the worker threads using a +cache-line swapping mechanism, passing up to 8 mbuf pointers at a time +(one cache line) to each worker. More than one worker thread can exist as part of the application, and these worker threads do simple packet processing by requesting packets from the distributor, doing a simple XOR operation on the input port mbuf field (to indicate the output port which will be used later for packet transmission) -and then finally returning the packets back to the distributor in the RX thread. +and then finally returning the packets back to the distributor thread. -Meanwhile, the receive thread will call the distributor api -rte_distributor_returned_pkts() to get the packets processed, and will enqueue -them to a ring for transfer to the TX thread for transmission on the output port. -The transmit thread will dequeue the packets from the ring and transmit them on -the output port specified in packet mbuf. +The distributor thread will then call the distributor api +``rte_distributor_returned_pkts()`` to get the processed packets, and will enqueue +them to another rte_ring for transfer to the TX thread for transmission on the +output port. The transmit thread will dequeue the packets from the ring and +transmit them on the output port specified in packet mbuf. Users who wish to terminate the running of the application have to press ctrl+C (or send SIGINT to the app). Upon this signal, a signal handler provided
@@ -153,8 +155,10 @@ the line "#define DEBUG" defined in start of the application in main.c to enable Statistics ---------- -Upon SIGINT (or) ctrl+C, the print_stats() function displays the count of packets -processed at the different stages in the application. +The main function will print statistics on the console every second. These +statistics include the number of packets enqueued and dequeued at each stage +in the application, and also key statistics per worker, including how many +packets of each burst size (1-8) were sent to each worker thread. Application Initialization --------------------------
doc/guides/sample_app_ug/img/dist_app.svg +153 -123
435 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v11 18/18 maintainers: add to distributor lib maintainers
In reply to David Hunt--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -492,6 +492,7 @@ F: doc/guides/sample_app_ug/ip_reassembly.rst Distributor M: Bruce Richardson <[email protected]> +M: David Hunt <[email protected]> F: lib/librte_distributor/ F: doc/guides/prog_guide/packet_distrib_lib.rst F: test/test/test_distributor*
Signature · 1 line
2.7.4
2017-03-20 10:08, David Hunt:
Quoted 1 line
This patch aims to improve the throughput of the distributor library.
The patchset compiles, have been reviewed and acked.
I have only 2 comments that can be addressed without sending a new version. Let's conclude in the commenting mails.
Thanks
2017-03-27 15:06, Thomas Monjalon:
Quoted 7 lines
2017-03-20 10:08, David Hunt:
Quoted 1 line
This patch aims to improve the throughput of the distributor library.
The patchset compiles, have been reviewed and acked.
I have only 2 comments that can be addressed without sending a new version. Let's conclude in the commenting mails.
Applied with suggested changes, thanks
PATCH v10 2/18 lib: create private header file
In reply to David HuntWe'll be adding internal implementation definitions in here that are common to both burst and legacy APIs.
--- lib/librte_distributor/rte_distributor_private.h | 136 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 72 +----------- 2 files changed, 137 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_private.h
lib/librte_distributor/rte_distributor_private.h new file +136 -0
@@ -0,0 +1,136 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 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 +* 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. +*/ + +#ifndef _RTE_DIST_PRIV_H_ +#define _RTE_DIST_PRIV_H_ + +/** +* @file +* RTE distributor +* +* The distributor is a component which is designed to pass packets +* one-at-a-time to workers, with dynamic load balancing. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NO_FLAGS 0 +#define RTE_DISTRIB_PREFIX "DT_" + +/* +* We will use the bottom four bits of pointer for flags, shifting out +* the top four bits to make room (since a 64-bit pointer actually only uses +* 48 bits). An arithmetic-right-shift will then appropriately restore the +* original pointer value with proper sign extension into the top bits. +*/ +#define RTE_DISTRIB_FLAG_BITS 4 +#define RTE_DISTRIB_FLAGS_MASK (0x0F) +#define RTE_DISTRIB_NO_BUF 0/**< empty flags: no buffer requested */ +#define RTE_DISTRIB_GET_BUF (1)/**< worker requests a buffer, returns old */ +#define RTE_DISTRIB_RETURN_BUF (2)/**< worker returns a buffer, no request */ +#define RTE_DISTRIB_VALID_BUF (4)/**< set if bufptr contains ptr */ + +#define RTE_DISTRIB_BACKLOG_SIZE 8 +#define RTE_DISTRIB_BACKLOG_MASK (RTE_DISTRIB_BACKLOG_SIZE - 1) + +#define RTE_DISTRIB_MAX_RETURNS 128 +#define RTE_DISTRIB_RETURNS_MASK (RTE_DISTRIB_MAX_RETURNS - 1) + +/** +* Maximum number of workers allowed. +* Be aware of increasing the limit, becaus it is limited by how we track +* in-flight tags. See in_flight_bitmask and rte_distributor_process +*/ +#define RTE_DISTRIB_MAX_WORKERS 64 + +#define RTE_DISTRIBUTOR_NAMESIZE 32/**< Length of name for instance */ + +/** +* Buffer structure used to pass the pointer data between cores. This is cache +* line aligned, but to improve performance and prevent adjacent cache-line +* prefetches of buffers for other workers, e.g. when worker 1's buffer is on +* the next cache line to worker 0, we pad this out to three cache lines. +* Only 64-bits of the memory is actually used though. +*/ +union rte_distributor_buffer { +volatile int64_t bufptr64; +char pad[RTE_CACHE_LINE_SIZE *3 ]; +} __rte_cache_aligned; + +/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(rte_xmm_t) / sizeof(uint16_t)) + +struct rte_distributor_backlog { +unsigned int start; +unsigned int count; + int64_t pkts[RTE_DIST_BURST_SIZE] __rte_cache_aligned; +uint16_t *tags;/* will point to second cacheline of inflights */ +} __rte_cache_aligned; + + +struct rte_distributor_returned_pkts { +unsigned int start; +unsigned int count; +struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS ]; +}; + +struct rte_distributor { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */ + +uint32_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS ]; +/**< Tracks the tag being processed per core */ +uint64_t in_flight_bitmask; +/**< on/off bits for in-flight tags. +* Note that if RTE_DISTRIB_MAX_WORKERS is larger than 64 then +* the bitmask has to expand. +*/ + +struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS ]; + +union rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; +}; + +#ifdef __cplusplus +} +#endif + +#endif
lib/librte_distributor/rte_distributor_v20.c +1 -71
78 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v10 02/18] lib: create private header file
2017-03-15 06:19, David Hunt:
lib/librte_distributor/rte_distributor_private.h line 95
Quoted 5 lines
lib/librte_distributor/rte_distributor_private.h new file +5
-0+/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(rte_xmm_t) / sizeof(uint16_t))
error: 'rte_xmm_t' undeclared here (arm compilation)
Can it be fixed by including rte_vect.h?
Ideally I would prefer we stop using XMM types in a generic code. XMM are x86-only registers. It has been translated for other arches but we should use a more generic name.
What was the intention here? SSE-optimized code or 128-bit size? Please check lib/librte_eal/common/include/generic/rte_vect.h for a generic type.
Re: [PATCH v10 02/18] lib: create private header file
Quoted 10 lines · Thomas Monjalon
2017-03-15 06:19, David Hunt:
lib/librte_distributor/rte_distributor_private.h line 95
Quoted 5 lines
lib/librte_distributor/rte_distributor_private.h new file +5
-0+/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(rte_xmm_t) / sizeof(uint16_t))error: '
rte_xmm_t' undeclared here (arm compilation)Can it be fixed by including
rte_vect.h?
Quoted 7 lines
Ideally I would prefer we stop using XMM types in a generic code. XMM are x86-only registers. It has been translated for other arches but we should use a more generic name.
What was the intention here? SSE-optimized code or 128-bit size? Please check
lib/librte_eal/common/include/generic/rte_vect.hfor a generic type.
Thomas,
Including rte_vect.h does indeed resolve the issue.
I had originally had "#define RTE_DIST_BURST_SIZE 8" but thought that latest definition would give further clarity as to why it's set to 8.
There are 2 reasons.
1. The vector instruction I use for the matching works on 8 uint16s at a time
2. The (x86) cache lines communicating with the worker cores fit 8 mbuf pointers at a time.
So there are 2 options to resolve:
1. #include <rte_vect.h> at the top of rte_distributor_private.h
2. revert back to "#define RTE_DIST_BURST_SIZE 8"
Personally, I'd probably lean towards option 2 (with additional comment) , as it removes the mention of xmm from the generic header file, as well as being valid for both reasons, whereas the xmm #define really only helps to explain one reason.
Do you have any preference? Let me know and I can push up a v11.
Regards,
Dave.
P.S. Suggested change:
/*
* Transfer up to 8 mbufs at a time to/from workers, and
* flow matching algorithm optimised for 8 flow IDs at a time */
#define RTE_DIST_BURST_SIZE 8
Re: [PATCH v10 02/18] lib: create private header file
2017-03-16 10:43, Hunt, David:
Quoted 48 lines · Thomas Monjalon
Quoted 10 lines
2017-03-15 06:19, David Hunt:
lib/librte_distributor/rte_distributor_private.h line 95
Quoted 5 lines
lib/librte_distributor/rte_distributor_private.h new file +5
-0+/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(rte_xmm_t) / sizeof(uint16_t))error: '
rte_xmm_t' undeclared here (arm compilation)Can it be fixed by including
rte_vect.h?Quoted 7 lines
Ideally I would prefer we stop using XMM types in a generic code. XMM are x86-only registers. It has been translated for other arches but we should use a more generic name.
What was the intention here? SSE-optimized code or 128-bit size? Please check
lib/librte_eal/common/include/generic/rte_vect.hfor a generic type.Thomas,
Including
rte_vect.hdoes indeed resolve the issue.I had originally had "#define
RTE_DIST_BURST_SIZE8" but thought that latest definition would give further clarity as to why it's set to 8.There are 2 reasons.
1. The vector instruction I use for the matching works on 8 uint16s at a time
2. The (x86) cache lines communicating with the worker cores fit 8 mbuf pointers at a time.So there are 2 options to resolve:
1. #include <rte_vect.h> at the top ofrte_distributor_private.h
2. revert back to "#defineRTE_DIST_BURST_SIZE8"Personally, I'd probably lean towards option 2 (with additional comment) , as it removes
the mention of xmm from the generic header file, as well as being valid for both
reasons, whereas the xmm #define really only helps to explain one reason.Do you have any preference? Let me know and I can push up a v11.
Regards,
Dave.
Quoted 7 lines
P.S. Suggested change:/*
* Transfer up to 8 mbufs at a time to/from workers, and
* flow matching algorithm optimised for 8 flow IDs at a time */
#defineRTE_DIST_BURST_SIZE8
OK for the option 2
PATCH v10 3/18 lib: add new distributor code
In reply to David HuntThis patch includes the code for new burst-capable distributor library.
It also includes the rte_distributor_next.h file which will be used as the public header once we add in the symbol versioning for v20 and v1705 APIs, at which stage we will rename it to rte_distributor.h.
The new distributor code contains a very similar API to the legacy code, but now sends bursts of up to 8 mbufs to each worker. Flow ID's are reduced to 15 bits for an optimal flow matching algorithm.
--- lib/librte_distributor/Makefile | 1 + lib/librte_distributor/rte_distributor.c | 628 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_next.h | 269 ++++++++++ lib/librte_distributor/rte_distributor_private.h | 61 +++ 4 files changed, 959 insertions(+) create mode 100644 lib/librte_distributor/rte_distributor.c create mode 100644 lib/librte_distributor/rte_distributor_next.h
lib/librte_distributor/Makefile +1 -0
@@ -43,6 +43,7 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor.c new file +628 -0
628 lines not on this page · raw message
lib/librte_distributor/rte_distributor_next.h new file +269 -0
269 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +61 -0
67 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v10 4/18 lib: add SIMD flow matching to distributor
In reply to David HuntAdd an optimised version of the in-flight flow matching algorithm using SIMD instructions. This should give up to 1.5x over the scalar versions performance.
Falls back to scalar version if SSE4.2 not available
--- lib/librte_distributor/Makefile | 10 ++ lib/librte_distributor/rte_distributor.c | 16 ++- .../rte_distributor_match_generic.c | 43 ++++++++ lib/librte_distributor/rte_distributor_match_sse.c | 114 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_private.h | 5 + 5 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_match_generic.c create mode 100644 lib/librte_distributor/rte_distributor_match_sse.c
lib/librte_distributor/Makefile +10 -0
@@ -44,6 +44,16 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor.c +ifeq ($(CONFIG_RTE_ARCH_X86),y) +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_match_sse.c +# distributor SIMD algo needs SSE4.2 support +ifeq ($(findstring RTE_MACHINE_CPUFLAG_SSE4_2,$(CFLAGS)),) +CFLAGS_rte_distributor_match_sse.o += -msse4.2 +endif +else +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_match_generic.c +endif + # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor.c +14 -2
@@ -391,7 +391,13 @@ rte_distributor_process_v1705(struct rte_distributor_v1705 *d,for (; i <RTE_DIST_BURST_SIZE ; i++) flows[i] =0 ; -find_match_scalar (d, &flows[0 ], &matches[0 ]); +switch (d->dist_match_fn) { +case RTE_DIST_MATCH_VECTOR : +find_match_vec (d, &flows[0 ], &matches[0 ]); +break ; +default : +find_match_scalar (d, &flows[0 ], &matches[0 ]); + }/* * Matches array now contain the intended worker ID (+1) of
@@ -607,7 +613,13 @@ rte_distributor_create_v1705(const char *name,snprintf (d->name,sizeof (d->name),"%s" , name); d->num_workers = num_workers; d->alg_type = alg_type; - d->dist_match_fn =RTE_DIST_MATCH_SCALAR ; + +#if defined(RTE_ARCH_X86 ) +if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_SSE4_2 )) + d->dist_match_fn =RTE_DIST_MATCH_VECTOR ; + else +#endif + d->dist_match_fn =RTE_DIST_MATCH_SCALAR ;/* * Set up the backog tags so they're pointing at the second cache
lib/librte_distributor/rte_distributor_match_generic.c new file +43 -0
43 lines not on this page · raw message
lib/librte_distributor/rte_distributor_match_sse.c new file +114 -0
114 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +5 -0
@@ -190,6 +190,11 @@ find_match_scalar(struct rte_distributor_v1705 *d,uint16_t *data_ptr, uint16_t *output_ptr); +void +find_match_vec (struct rte_distributor_v1705 *d, +uint16_t *data_ptr, +uint16_t *output_ptr); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v10 5/18 test/distributor: extra params for autotests
In reply to David HuntIn the next few patches, we'll want to test old and new API, so here we're allowing different parameters to be passed to the tests, instead of just a distributor struct.
--- test/test/test_distributor.c | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 21 deletions(-)
test/test/test_distributor.c +43 -21
@@ -45,6 +45,13 @@#define BURST 32#define BIG_BATCH 1024 +struct worker_params { +char name[64 ]; +struct rte_distributor *dist; +}; + +struct worker_params worker_params; +/* statics - all zero-initialized by default */ static volatile int quit;/**< general quit variable for all threads */ static volatile int zero_quit;/**< var for when we just want thr0 to quit*/
@@ -81,7 +88,9 @@ static int handle_work(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist; +unsigned count =0 ;unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -107,8 +116,9 @@ handle_work(void *arg)* not necessarily in the same order (as different flows). */ static int -sanity_test (struct rte_distributor *d,struct rte_mempool *p) +sanity_test (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -249,7 +259,8 @@ static int handle_work_with_free_mbufs(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist;unsigned count =0 ;unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -270,8 +281,9 @@ handle_work_with_free_mbufs(void *arg)* library. */ static int -sanity_test_with_mbuf_alloc (struct rte_distributor *d,struct rte_mempool *p) +sanity_test_with_mbuf_alloc (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;unsigned i;struct rte_mbuf *bufs[BURST ];
@@ -305,7 +317,8 @@ static int handle_work_for_shutdown_test(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist;unsigned count =0 ;const unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -344,9 +357,10 @@ handle_work_for_shutdown_test(void *arg)* library. */ static int -sanity_test_with_worker_shutdown (struct rte_distributor *d, +sanity_test_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -401,9 +415,10 @@ sanity_test_with_worker_shutdown(struct rte_distributor *d,* one worker shuts down.. */ static int -test_flush_with_worker_shutdown (struct rte_distributor *d, +test_flush_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -480,8 +495,9 @@ int test_error_distributor_create_numworkers(void)/* Useful function which ensures that all worker functions terminate */ static void -quit_workers (struct rte_distributor *d,struct rte_mempool *p) +quit_workers (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;const unsigned num_workers =rte_lcore_count () -1 ;unsigned i;struct rte_mbuf *bufs[RTE_MAX_LCORE ];
@@ -536,28 +552,34 @@ test_distributor(void) } } -rte_eal_mp_remote_launch (handle_work, d,SKIP_MASTER ); -if (sanity_test (d, p) <0 ) + worker_params.dist = d; +sprintf (worker_params.name,"single" ); + +rte_eal_mp_remote_launch (handle_work, &worker_params,SKIP_MASTER ); +if (sanity_test (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_with_free_mbufs, d,SKIP_MASTER ); -if (sanity_test_with_mbuf_alloc (d, p) <0 ) +rte_eal_mp_remote_launch (handle_work_with_free_mbufs, &worker_params, +SKIP_MASTER ); +if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p);if (rte_lcore_count () >2 ) { -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params,SKIP_MASTER ); -if (sanity_test_with_worker_shutdown (d, p) <0 ) +if (sanity_test_with_worker_shutdown (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params,SKIP_MASTER ); -if (test_flush_with_worker_shutdown (d, p) <0 ) +if (test_flush_with_worker_shutdown (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); }else {printf ("Not enough cores to run tests for worker shutdown\n" );
@@ -572,7 +594,7 @@ test_distributor(void)return 0 ; err: -quit_workers (d, p); +quit_workers (&worker_params, p);return -1 ; }
Signature · 1 line
2.7.4
PATCH v10 6/18 lib: switch distributor over to new API
In reply to David HuntThis is the main switch over between the legacy API and the new burst API. We rename all the functions in rte_distributor.c to remove the _v1705, and we add in _v20 in the rte_distributor_v20.c
We also rename the rte_distributor_next.h as rte_distributor.h, as this is now the public header.
At the same time, we need the autotests and sample app to compile properly, hence those changes are in this patch also.
--- examples/distributor/main.c | 22 +- lib/librte_distributor/rte_distributor.c | 76 +++--- lib/librte_distributor/rte_distributor.h | 240 +++++++++++++++++- lib/librte_distributor/rte_distributor_match_sse.c | 2 +- lib/librte_distributor/rte_distributor_next.h | 269 --------------------- lib/librte_distributor/rte_distributor_private.h | 22 +- lib/librte_distributor/rte_distributor_v20.c | 46 ++-- lib/librte_distributor/rte_distributor_v20.h | 24 +- test/test/test_distributor.c | 235 ++++++++++++------ test/test/test_distributor_perf.c | 26 +- 10 files changed, 511 insertions(+), 451 deletions(-) delete mode 100644 lib/librte_distributor/rte_distributor_next.h
examples/distributor/main.c +18 -4
@@ -405,17 +405,30 @@ lcore_worker(struct lcore_params *p) {struct rte_distributor *d = p->d;const unsigned id = p->worker_id; +unsigned int num =0 ; +unsigned int i; +/* * for single port, xor_val will be zero so we won't modify the output * port, otherwise we send traffic from 0 to 1, 2 to 3, and vice versa */ const unsigned xor_val = (rte_eth_dev_count () >1 ); -struct rte_mbuf *buf =NULL ; + struct rte_mbuf *buf[8] __rte_cache_aligned; + +for (i =0 ; i <8 ; i++) + buf[i] =NULL ;printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ());while (!quit_signal) { - buf =rte_distributor_get_pkt (d, id, buf); - buf->port ^= xor_val; + num =rte_distributor_get_pkt (d, id, buf, buf, num); +/* Do a little bit of work for each packet */ +for (i =0 ; i < num; i++) { +uint64_t t =rte_rdtsc ()+100 ; + +while (rte_rdtsc () < t) +rte_pause (); + buf[i]->port ^= xor_val; + } }return 0 ; }
@@ -561,7 +574,8 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -2 ); +rte_lcore_count () -2 , +RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );
lib/librte_distributor/rte_distributor.c +38 -38
250 lines not on this page · raw message
lib/librte_distributor/rte_distributor.h +235 -5
252 lines not on this page · raw message
lib/librte_distributor/rte_distributor_match_sse.c +1 -1
@@ -38,7 +38,7 @@void -find_match_vec (struct rte_distributor_v1705 *d, +find_match_vec (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr) {
lib/librte_distributor/rte_distributor_next.h deleted +0 -269
269 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +11 -11
@@ -83,7 +83,7 @@ extern "C" {* the next cache line to worker 0, we pad this out to three cache lines. * Only 64-bits of the memory is actually used though. */ -union rte_distributor_buffer { +union rte_distributor_buffer_v20 {volatile int64_t bufptr64;char pad[RTE_CACHE_LINE_SIZE *3 ]; } __rte_cache_aligned;
@@ -108,8 +108,8 @@ struct rte_distributor_returned_pkts {struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS ]; }; -struct rte_distributor { -TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ +struct rte_distributor_v20 { +TAILQ_ENTRY (rte_distributor_v20) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -124,7 +124,7 @@ struct rte_distributor {struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS ]; -union rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ]; +union rte_distributor_buffer_v20 bufs[RTE_DISTRIB_MAX_WORKERS ];struct rte_distributor_returned_pkts returns; };
@@ -144,7 +144,7 @@ enum rte_distributor_match_function {* We can pass up to 8 mbufs at a time in one cacheline. * There is a separate cacheline for returns in the burst API. */ -struct rte_distributor_buffer_v1705 { +struct rte_distributor_buffer { volatile int64_t bufptr64[RTE_DIST_BURST_SIZE]__rte_cache_aligned ;/* <= outgoing to worker */
@@ -158,8 +158,8 @@ struct rte_distributor_buffer_v1705 { int count __rte_cache_aligned; /* <= number of current mbufs */ }; -struct rte_distributor_v1705 { -TAILQ_ENTRY (rte_distributor_v1705) next;/**< Next in list. */ +struct rte_distributor { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -176,22 +176,22 @@ struct rte_distributor_v1705 { struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] __rte_cache_aligned; -struct rte_distributor_buffer_v1705 bufs[RTE_DISTRIB_MAX_WORKERS ]; +struct rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ];struct rte_distributor_returned_pkts returns;enum rte_distributor_match_function dist_match_fn; -struct rte_distributor *d_v20; +struct rte_distributor_v20 *d_v20; };void -find_match_scalar (struct rte_distributor_v1705 *d, +find_match_scalar (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr);void -find_match_vec (struct rte_distributor_v1705 *d, +find_match_vec (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr);
lib/librte_distributor/rte_distributor_v20.c +23 -23
151 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.h +12 -12
@@ -48,7 +48,7 @@ extern "C" {#define RTE_DISTRIBUTOR_NAMESIZE 32/**< Length of name for instance */ -struct rte_distributor ; +struct rte_distributor_v20 ;struct rte_mbuf ;/**
@@ -67,8 +67,8 @@ struct rte_mbuf;* @return * The newly created distributor instance */ -struct rte_distributor * -rte_distributor_create (const char *name,unsigned int socket_id, +struct rte_distributor_v20 * +rte_distributor_create_v20 (const char *name,unsigned int socket_id,unsigned int num_workers);/* *** APIS to be called on the distributor lcore *** */
@@ -103,7 +103,7 @@ rte_distributor_create(const char *name, unsigned int socket_id,* The number of mbufs processed. */ int -rte_distributor_process (struct rte_distributor *d, +rte_distributor_process_v20 (struct rte_distributor_v20 *d,struct rte_mbuf **mbufs,unsigned int num_mbufs);/**
@@ -121,7 +121,7 @@ rte_distributor_process(struct rte_distributor *d,* The number of mbufs returned in the mbufs array. */ int -rte_distributor_returned_pkts (struct rte_distributor *d, +rte_distributor_returned_pkts_v20 (struct rte_distributor_v20 *d,struct rte_mbuf **mbufs,unsigned int max_mbufs);/**
@@ -136,7 +136,7 @@ rte_distributor_returned_pkts(struct rte_distributor *d,* The number of queued/in-flight packets that were completed by this call. */ int -rte_distributor_flush (struct rte_distributor *d); +rte_distributor_flush_v20 (struct rte_distributor_v20 *d);/** * Clears the array of returned packets used as the source for the
@@ -148,7 +148,7 @@ rte_distributor_flush(struct rte_distributor *d);* The distributor instance to be used */ void -rte_distributor_clear_returns (struct rte_distributor *d); +rte_distributor_clear_returns_v20 (struct rte_distributor_v20 *d);/* *** APIS to be called on the worker lcores *** */ /*
@@ -177,7 +177,7 @@ rte_distributor_clear_returns(struct rte_distributor *d);* A new packet to be processed by the worker thread. */ struct rte_mbuf * -rte_distributor_get_pkt (struct rte_distributor *d, +rte_distributor_get_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id,struct rte_mbuf *oldpkt);/**
@@ -193,8 +193,8 @@ rte_distributor_get_pkt(struct rte_distributor *d,* The previous packet being processed by the worker */ int -rte_distributor_return_pkt (struct rte_distributor *d,unsigned int worker_id, -struct rte_mbuf *mbuf); +rte_distributor_return_pkt_v20 (struct rte_distributor_v20 *d, +unsigned int worker_id,struct rte_mbuf *mbuf);/** * API called by a worker to request a new packet to process.
@@ -217,7 +217,7 @@ rte_distributor_return_pkt(struct rte_distributor *d, unsigned int worker_id,* The previous packet, if any, being processed by the worker */ void -rte_distributor_request_pkt (struct rte_distributor *d, +rte_distributor_request_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id,struct rte_mbuf *oldpkt);/**
@@ -237,7 +237,7 @@ rte_distributor_request_pkt(struct rte_distributor *d,* packet is yet available. */ struct rte_mbuf * -rte_distributor_poll_pkt (struct rte_distributor *d, +rte_distributor_poll_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id);#ifdef __cplusplus
test/test/test_distributor.c +156 -79
435 lines not on this page · raw message
test/test/test_distributor_perf.c +17 -9
@@ -129,18 +129,25 @@ clear_packet_count(void)static int handle_work (void *arg) { -struct rte_mbuf *pkt =NULL ;struct rte_distributor *d = arg; -unsigned count =0 ; -unsigned id =__sync_fetch_and_add (&worker_idx,1 ); +unsigned int count =0 ; +unsigned int num =0 ; +int i; +unsigned int id =__sync_fetch_and_add (&worker_idx,1 ); + struct rte_mbuf *buf[8] __rte_cache_aligned; - pkt =rte_distributor_get_pkt (d, id,NULL ); +for (i =0 ; i <8 ; i++) + buf[i] =NULL ; + + num =rte_distributor_get_pkt (d, id, buf, buf, num);while (!quit) { - worker_stats[id].handled_packets++, count++; - pkt =rte_distributor_get_pkt (d, id, pkt); + worker_stats[id].handled_packets += num; + count += num; + num =rte_distributor_get_pkt (d, id, buf, buf, num); } - worker_stats[id].handled_packets++, count++; -rte_distributor_return_pkt (d, id, pkt); + worker_stats[id].handled_packets += num; + count += num; +rte_distributor_return_pkt (d, id, buf, num);return 0 ; }
@@ -228,7 +235,8 @@ test_distributor_perf(void)if (d ==NULL ) { d =rte_distributor_create ("Test_perf" ,rte_socket_id (), -rte_lcore_count () -1 ); +rte_lcore_count () -1 , +RTE_DIST_ALG_SINGLE );if (d ==NULL ) {printf ("Error creating distributor\n" );return -1 ;
Signature · 1 line
2.7.4
PATCH v10 7/18 lib: make v20 header file private
In reply to David Hunt--- lib/librte_distributor/Makefile | 1 - 1 file changed, 1 deletion(-)
lib/librte_distributor/Makefile +0 -1
@@ -57,7 +57,6 @@ endif # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h -SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
Signature · 1 line
2.7.4
PATCH v10 8/18 lib: add symbol versioning to distributor
In reply to David HuntAlso bumped up the ABI version number in the Makefile
--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 10 +++ lib/librte_distributor/rte_distributor_version.map | 14 ++++ 5 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_v1705.h
lib/librte_distributor/Makefile +1 -1
@@ -39,7 +39,7 @@ CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) EXPORT_MAP := rte_distributor_version.map -LIBABIVER := 1 +LIBABIVER := 2 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c
lib/librte_distributor/rte_distributor.c +48 -9
153 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v1705.h new file +89 -0
89 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c +10 -0
@@ -38,6 +38,7 @@#include <rte_memory.h> #include <rte_memzone.h> #include <rte_errno.h> +#include <rte_compat.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> #include "rte_distributor_v20.h"
@@ -63,6 +64,7 @@ rte_distributor_request_pkt_v20(struct rte_distributor_v20 *d,rte_pause (); buf->bufptr64 = req; } +VERSION_SYMBOL (rte_distributor_request_pkt, _v20,2.0 );struct rte_mbuf * rte_distributor_poll_pkt_v20(struct rte_distributor_v20 *d,
@@ -76,6 +78,7 @@ rte_distributor_poll_pkt_v20(struct rte_distributor_v20 *d,int64_t ret = buf->bufptr64 >>RTE_DISTRIB_FLAG_BITS ;return (struct rte_mbuf *)((uintptr_t )ret); } +VERSION_SYMBOL (rte_distributor_poll_pkt, _v20,2.0 );struct rte_mbuf * rte_distributor_get_pkt_v20(struct rte_distributor_v20 *d,
@@ -87,6 +90,7 @@ rte_distributor_get_pkt_v20(struct rte_distributor_v20 *d,rte_pause ();return ret; } +VERSION_SYMBOL (rte_distributor_get_pkt, _v20,2.0 ); int rte_distributor_return_pkt_v20(struct rte_distributor_v20 *d,
@@ -98,6 +102,7 @@ rte_distributor_return_pkt_v20(struct rte_distributor_v20 *d, buf->bufptr64 = req;return 0 ; } +VERSION_SYMBOL (rte_distributor_return_pkt, _v20,2.0 );/**** APIs called on distributor core ***/
@@ -314,6 +319,7 @@ rte_distributor_process_v20(struct rte_distributor_v20 *d, d->returns.count = ret_count;return num_mbufs; } +VERSION_SYMBOL (rte_distributor_process, _v20,2.0 );/* return to the caller, packets returned from workers */ int
@@ -334,6 +340,7 @@ rte_distributor_returned_pkts_v20(struct rte_distributor_v20 *d,return retval; } +VERSION_SYMBOL (rte_distributor_returned_pkts, _v20,2.0 );/* return the number of packets in-flight in a distributor, i.e. packets * being workered on or queued up in a backlog. */
@@ -362,6 +369,7 @@ rte_distributor_flush_v20(struct rte_distributor_v20 *d)return flushed; } +VERSION_SYMBOL (rte_distributor_flush, _v20,2.0 );/* clears the internal returns array in the distributor */ void
@@ -372,6 +380,7 @@ rte_distributor_clear_returns_v20(struct rte_distributor_v20 *d)memset (d->returns.mbufs,0 ,sizeof (d->returns.mbufs));#endif } +VERSION_SYMBOL (rte_distributor_clear_returns, _v20,2.0 );/* creates a distributor instance */ struct rte_distributor_v20 *
@@ -415,3 +424,4 @@ rte_distributor_create_v20(const char *name,return d; } +VERSION_SYMBOL (rte_distributor_create, _v20,2.0 );
lib/librte_distributor/rte_distributor_version.map +14 -0
@@ -13,3 +13,17 @@ DPDK_2.0 { local: *; }; + +DPDK_17.05 { + global: + + rte_distributor_clear_returns; + rte_distributor_create; + rte_distributor_flush; + rte_distributor_get_pkt; + rte_distributor_poll_pkt; + rte_distributor_process; + rte_distributor_request_pkt; + rte_distributor_return_pkt; + rte_distributor_returned_pkts; +} DPDK_2.0;
Signature · 1 line
2.7.4
PATCH v10 9/18 test: test single and burst distributor API
In reply to David Hunt--- test/test/test_distributor.c | 116 ++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 34 deletions(-)
test/test/test_distributor.c +82 -34
@@ -538,17 +538,25 @@ staticint test_error_distributor_create_name (void ) {struct rte_distributor *d =NULL ; +struct rte_distributor *db =NULL ;char *name =NULL ; d =rte_distributor_create (name,rte_socket_id (),rte_lcore_count () -1 , -RTE_DIST_ALG_BURST ); - +RTE_DIST_ALG_SINGLE );if (d !=NULL || rte_errno !=EINVAL ) {printf ("ERROR: No error on create() with NULL name param\n" );return -1 ; } + db =rte_distributor_create (name,rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_BURST ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create() with NULL param\n" ); +return -1 ; + } +return 0 ; }
@@ -556,15 +564,25 @@ int test_error_distributor_create_name(void)static int test_error_distributor_create_numworkers (void ) { -struct rte_distributor *d =NULL ; +struct rte_distributor *ds =NULL ; +struct rte_distributor *db =NULL ; - d =rte_distributor_create ("test_numworkers" ,rte_socket_id (), + ds =rte_distributor_create ("test_numworkers" ,rte_socket_id (),RTE_MAX_LCORE +10 , -RTE_DIST_ALG_BURST ); -if (d !=NULL || rte_errno !=EINVAL ) { +RTE_DIST_ALG_SINGLE ); +if (ds !=NULL || rte_errno !=EINVAL ) {printf ("ERROR: No error on create() with num_workers > MAX\n" );return -1 ; } + + db =rte_distributor_create ("test_numworkers" ,rte_socket_id (), +RTE_MAX_LCORE +10 , +RTE_DIST_ALG_BURST ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create() num_workers > MAX\n" ); +return -1 ; + } +return 0 ; }
@@ -597,25 +615,42 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p)static int test_distributor (void ) { -static struct rte_distributor *d; +static struct rte_distributor *ds; +static struct rte_distributor *db; +static struct rte_distributor *dist[2 ];static struct rte_mempool *p; +int i;if (rte_lcore_count () <2 ) {printf ("ERROR: not enough cores to test distributor\n" );return -1 ; } -if (d ==NULL ) { - d =rte_distributor_create ("Test_dist_burst" ,rte_socket_id (), +if (db ==NULL ) { + db =rte_distributor_create ("Test_dist_burst" ,rte_socket_id (),rte_lcore_count () -1 ,RTE_DIST_ALG_BURST ); -if (d ==NULL ) { +if (db ==NULL ) {printf ("Error creating burst distributor\n" );return -1 ; } }else { -rte_distributor_flush (d); -rte_distributor_clear_returns (d); +rte_distributor_flush (db); +rte_distributor_clear_returns (db); + } + +if (ds ==NULL ) { + ds =rte_distributor_create ("Test_dist_single" , +rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_SINGLE ); +if (ds ==NULL ) { +printf ("Error creating single distributor\n" ); +return -1 ; + } + }else { +rte_distributor_flush (ds); +rte_distributor_clear_returns (ds); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
@@ -629,37 +664,50 @@ test_distributor(void) } } - worker_params.dist = d; -sprintf (worker_params.name,"burst" ); + dist[0 ] = ds; + dist[1 ] = db; -rte_eal_mp_remote_launch (handle_work, &worker_params,SKIP_MASTER ); -if (sanity_test (&worker_params, p) <0 ) - goto err; -quit_workers (&worker_params, p); +for (i =0 ; i <2 ; i++) { -rte_eal_mp_remote_launch (handle_work_with_free_mbufs, &worker_params, -SKIP_MASTER ); -if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) - goto err; -quit_workers (&worker_params, p); + worker_params.dist = dist[i]; +if (i) +sprintf (worker_params.name,"burst" ); +else +sprintf (worker_params.name,"single" ); -if (rte_lcore_count () >2 ) { -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, - &worker_params, -SKIP_MASTER ); -if (sanity_test_with_worker_shutdown (&worker_params, p) <0 ) +rte_eal_mp_remote_launch (handle_work, + &worker_params,SKIP_MASTER ); +if (sanity_test (&worker_params, p) <0 ) goto err;quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, - &worker_params, -SKIP_MASTER ); -if (test_flush_with_worker_shutdown (&worker_params, p) <0 ) +rte_eal_mp_remote_launch (handle_work_with_free_mbufs, + &worker_params,SKIP_MASTER ); +if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) goto err;quit_workers (&worker_params, p); - }else { -printf ("Not enough cores to run tests for worker shutdown\n" ); +if (rte_lcore_count () >2 ) { +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (sanity_test_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (test_flush_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + + }else { +printf ("Too few cores to run worker shutdown test\n" ); + } + } if (test_error_distributor_create_numworkers() == -1 ||
Signature · 1 line
2.7.4
PATCH v10 10/18 test: add perf test for distributor burst mode
In reply to David Hunt--- test/test/test_distributor_perf.c | 75 ++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 24 deletions(-)
test/test/test_distributor_perf.c +51 -24
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,9 @@#include <rte_mbuf.h> #include <rte_distributor.h> -#define ITER_POWER 20/* log 2 of how many iterations we do when timing. */ -#define BURST 32 +#define ITER_POWER_CL 25/* log 2 of how many iterations for Cache Line test */ +#define ITER_POWER 21/* log 2 of how many iterations we do when timing. */ +#define BURST 64#define BIG_BATCH 1024/* static vars - zero initialized by default */
@@ -54,7 +55,8 @@ struct worker_stats { } __rte_cache_aligned;struct worker_stats worker_stats[RTE_MAX_LCORE ]; -/* worker thread used for testing the time to do a round-trip of a cache +/* +* worker thread used for testing the time to do a round-trip of a cache * line between two cores and back again */ static void
@@ -69,7 +71,8 @@ flip_bit(volatile uint64_t *arg) } } -/* test case to time the number of cycles to round-trip a cache line between +/* +* test case to time the number of cycles to round-trip a cache line between * two cores and back again. */ static void
@@ -86,7 +89,7 @@ time_cache_line_switch(void)rte_pause ();const uint64_t start_time =rte_rdtsc (); -for (i =0 ; i < (1 <<ITER_POWER ); i++) { +for (i =0 ; i < (1 <<ITER_POWER_CL ); i++) {while (*pdata)rte_pause (); *pdata =1 ;
@@ -98,13 +101,14 @@ time_cache_line_switch(void) *pdata =2 ;rte_eal_wait_lcore (slaveid);printf ("==== Cache line switch test ===\n" ); -printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER ), +printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER_CL ), end_time-start_time);printf ("Ticks per iteration = %" PRIu64"\n\n" , - (end_time-start_time) >>ITER_POWER ); + (end_time-start_time) >>ITER_POWER_CL ); } -/* returns the total count of the number of packets handled by the worker +/* +* returns the total count of the number of packets handled by the worker * functions given below. */ static unsigned
@@ -123,7 +127,8 @@ clear_packet_count(void)memset (&worker_stats,0 ,sizeof (worker_stats)); } -/* this is the basic worker function for performance tests. +/* +* This is the basic worker function for performance tests. * it does nothing but return packets and count them. */ static int
@@ -151,14 +156,15 @@ handle_work(void *arg)return 0 ; } -/* this basic performance test just repeatedly sends in 32 packets at a time +/* +* This basic performance test just repeatedly sends in 32 packets at a time * to the distributor and verifies at the end that we got them all in the worker * threads and finally how long per packet the processing took. */ static inline int perf_test (struct rte_distributor *d,struct rte_mempool *p) { -unsigned i; +unsigned int i;uint64_t start, end;struct rte_mbuf *bufs[BURST ];
@@ -181,7 +187,8 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)rte_distributor_process (d,NULL ,0 ); }while (total_packet_count () < (BURST <<ITER_POWER )); -printf ("=== Performance test of distributor ===\n" ); +rte_distributor_clear_returns (d); +printf ("Time per burst: %" PRIu64"\n" , (end - start) >>ITER_POWER );printf ("Time per packet: %" PRIu64"\n\n" , ((end - start) >>ITER_POWER )/BURST );
@@ -201,9 +208,10 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)static void quit_workers (struct rte_distributor *d,struct rte_mempool *p) { -const unsigned num_workers =rte_lcore_count () -1 ; -unsigned i; +const unsigned int num_workers =rte_lcore_count () -1 ; +unsigned int i;struct rte_mbuf *bufs[RTE_MAX_LCORE ]; +rte_mempool_get_bulk (p, (void *)bufs, num_workers); quit =1 ;
@@ -222,7 +230,8 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)static int test_distributor_perf (void ) { -static struct rte_distributor *d; +static struct rte_distributor *ds; +static struct rte_distributor *db;static struct rte_mempool *p;if (rte_lcore_count () <2 ) {
@@ -233,17 +242,28 @@ test_distributor_perf(void)/* first time how long it takes to round-trip a cache line */ time_cache_line_switch (); -if (d ==NULL ) { - d =rte_distributor_create ("Test_perf" ,rte_socket_id (), +if (ds ==NULL ) { + ds =rte_distributor_create ("Test_perf" ,rte_socket_id (),rte_lcore_count () -1 ,RTE_DIST_ALG_SINGLE ); -if (d ==NULL ) { +if (ds ==NULL ) {printf ("Error creating distributor\n" );return -1 ; } }else { -rte_distributor_flush (d); -rte_distributor_clear_returns (d); +rte_distributor_clear_returns (ds); + } + +if (db ==NULL ) { + db =rte_distributor_create ("Test_burst" ,rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_BURST ); +if (db ==NULL ) { +printf ("Error creating burst distributor\n" ); +return -1 ; + } + }else { +rte_distributor_clear_returns (db); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
@@ -257,10 +277,17 @@ test_distributor_perf(void) } } -rte_eal_mp_remote_launch (handle_work, d,SKIP_MASTER ); -if (perf_test (d, p) <0 ) +printf ("=== Performance test of distributor (single mode) ===\n" ); +rte_eal_mp_remote_launch (handle_work, ds,SKIP_MASTER ); +if (perf_test (ds, p) <0 ) +return -1 ; +quit_workers (ds, p); + +printf ("=== Performance test of distributor (burst mode) ===\n" ); +rte_eal_mp_remote_launch (handle_work, db,SKIP_MASTER ); +if (perf_test (db, p) <0 )return -1 ; -quit_workers (d, p); +quit_workers (db, p);return 0 ; }
Signature · 1 line
2.7.4
PATCH v10 11/18 examples/distributor: allow for extra stats
In reply to David HuntThis will allow us to see what's going on at various stages throughout the sample app, with per-second visibility
--- examples/distributor/main.c | 140 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 124 insertions(+), 16 deletions(-)
examples/distributor/main.c +124 -16
@@ -54,24 +54,53 @@#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1 +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_RESET "\x1b[0m" +/* mask of enabled ports */ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx; +volatile uint8_t quit_signal_dist;static volatile struct app_stats {struct {uint64_t rx_pkts;uint64_t returned_pkts;uint64_t enqueued_pkts; +uint64_t enqdrop_pkts; } rx __rte_cache_aligned; + int pad1 __rte_cache_aligned; + +struct { +uint64_t in_pkts; +uint64_t ret_pkts; +uint64_t sent_pkts; +uint64_t enqdrop_pkts; + } dist __rte_cache_aligned; + int pad2 __rte_cache_aligned;struct {uint64_t dequeue_pkts;uint64_t tx_pkts; +uint64_t enqdrop_pkts; } tx __rte_cache_aligned; + int pad3 __rte_cache_aligned; + + uint64_t worker_pkts[64] __rte_cache_aligned; + + int pad4 __rte_cache_aligned; + + uint64_t worker_bursts[64][8] __rte_cache_aligned; + + int pad5 __rte_cache_aligned; + + uint64_t port_rx_pkts[64] __rte_cache_aligned; + uint64_t port_tx_pkts[64] __rte_cache_aligned; } app_stats; +struct app_stats prev_app_stats; +static const struct rte_eth_conf port_conf_default = { .rxmode = { .mq_mode =ETH_MQ_RX_RSS ,
@@ -93,6 +122,8 @@ struct output_buffer {struct rte_mbuf *mbufs[BURST_SIZE ]; }; +static void print_stats (void ); +/* * Initialises a given port using global settings and with the rx buffers * coming from the mbuf_pool passed as parameter
@@ -378,25 +409,91 @@ static voidprint_stats (void) {struct rte_eth_stats eth_stats; -unsigned i; - -printf ("\nRX thread stats:\n" ); -printf (" - Received: %" PRIu64"\n" , app_stats.rx.rx_pkts); -printf (" - Processed: %" PRIu64"\n" , app_stats.rx.returned_pkts); -printf (" - Enqueued: %" PRIu64"\n" , app_stats.rx.enqueued_pkts); - -printf ("\nTX thread stats:\n" ); -printf (" - Dequeued: %" PRIu64"\n" , app_stats.tx.dequeue_pkts); -printf (" - Transmitted: %" PRIu64"\n" , app_stats.tx.tx_pkts); +unsigned int i, j; +const unsigned int num_workers =rte_lcore_count () -4 ;for (i =0 ; i <rte_eth_dev_count (); i++) {rte_eth_stats_get (i, ð_stats); -printf ("\nPort %u stats:\n" , i); -printf (" - Pkts in: %" PRIu64"\n" , eth_stats.ipackets); -printf (" - Pkts out: %" PRIu64"\n" , eth_stats.opackets); -printf (" - In Errs: %" PRIu64"\n" , eth_stats.ierrors); -printf (" - Out Errs: %" PRIu64"\n" , eth_stats.oerrors); -printf (" - Mbuf Errs: %" PRIu64"\n" , eth_stats.rx_nombuf); + app_stats.port_rx_pkts[i] = eth_stats.ipackets; + app_stats.port_tx_pkts[i] = eth_stats.opackets; + } + +printf ("\n\nRX Thread:\n" ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsin : %5.2f\n" , i, + (app_stats.port_rx_pkts[i] - + prev_app_stats.port_rx_pkts[i])/1000000.0 ); + prev_app_stats.port_rx_pkts[i] = app_stats.port_rx_pkts[i]; + } +printf (" - Received: %5.2f\n" , + (app_stats.rx.rx_pkts - + prev_app_stats.rx.rx_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.rx.returned_pkts - + prev_app_stats.rx.returned_pkts)/1000000.0 ); +printf (" - Enqueued: %5.2f\n" , + (app_stats.rx.enqueued_pkts - + prev_app_stats.rx.enqueued_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.rx.enqdrop_pkts - + prev_app_stats.rx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("Distributor thread:\n" ); +printf (" - In: %5.2f\n" , + (app_stats.dist.in_pkts - + prev_app_stats.dist.in_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.dist.ret_pkts - + prev_app_stats.dist.ret_pkts)/1000000.0 ); +printf (" - Sent: %5.2f\n" , + (app_stats.dist.sent_pkts - + prev_app_stats.dist.sent_pkts)/1000000.0 ); +printf (" - Dropped %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.dist.enqdrop_pkts - + prev_app_stats.dist.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("TX thread:\n" ); +printf (" - Dequeued: %5.2f\n" , + (app_stats.tx.dequeue_pkts - + prev_app_stats.tx.dequeue_pkts)/1000000.0 ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsout: %5.2f\n" , + i, (app_stats.port_tx_pkts[i] - + prev_app_stats.port_tx_pkts[i])/1000000.0 ); + prev_app_stats.port_tx_pkts[i] = app_stats.port_tx_pkts[i]; + } +printf (" - Transmitted: %5.2f\n" , + (app_stats.tx.tx_pkts - + prev_app_stats.tx.tx_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.tx.enqdrop_pkts - + prev_app_stats.tx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + + prev_app_stats.rx.rx_pkts = app_stats.rx.rx_pkts; + prev_app_stats.rx.returned_pkts = app_stats.rx.returned_pkts; + prev_app_stats.rx.enqueued_pkts = app_stats.rx.enqueued_pkts; + prev_app_stats.rx.enqdrop_pkts = app_stats.rx.enqdrop_pkts; + prev_app_stats.dist.in_pkts = app_stats.dist.in_pkts; + prev_app_stats.dist.ret_pkts = app_stats.dist.ret_pkts; + prev_app_stats.dist.sent_pkts = app_stats.dist.sent_pkts; + prev_app_stats.dist.enqdrop_pkts = app_stats.dist.enqdrop_pkts; + prev_app_stats.tx.dequeue_pkts = app_stats.tx.dequeue_pkts; + prev_app_stats.tx.tx_pkts = app_stats.tx.tx_pkts; + prev_app_stats.tx.enqdrop_pkts = app_stats.tx.enqdrop_pkts; + +for (i =0 ; i < num_workers; i++) { +printf ("Worker %02u Pkts: %5.2f. Bursts(1-8): " , i, + (app_stats.worker_pkts[i] - + prev_app_stats.worker_pkts[i])/1000000.0 ); +for (j =0 ; j <8 ; j++) { +printf ("%" PRIu64" " , app_stats.worker_bursts[i][j]); + app_stats.worker_bursts[i][j] =0 ; + } +printf ("\n" ); + prev_app_stats.worker_pkts[i] = app_stats.worker_pkts[i]; } }
@@ -515,6 +612,7 @@ main(int argc, char *argv[])unsigned nb_ports;uint8_t portid;uint8_t nb_ports_available; +uint64_t t, freq;/* catch ctrl-c so we can print on exit */ signal (SIGINT , int_handler);
@@ -610,6 +708,16 @@ main(int argc, char *argv[])if (lcore_rx (&p) !=0 )return -1 ; + freq =rte_get_timer_hz (); + t =rte_rdtsc () + freq; +while (!quit_signal_dist) { +if (t <rte_rdtsc ()) { +print_stats (); + t =rte_rdtsc () + freq; + } +usleep (1000 ); + } +RTE_LCORE_FOREACH_SLAVE (lcore_id) {if (rte_eal_wait_lcore (lcore_id) <0 )return -1 ;
Signature · 1 line
2.7.4
PATCH v10 12/18 examples/distributor: wait for ports to come up
In reply to David HuntOn some machines, ports take several seconds to come up. This patch causes the app to wait.
--- examples/distributor/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
examples/distributor/main.c +4 -3
@@ -1,8 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -* All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
@@ -62,6 +61,7 @@ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx;volatile uint8_t quit_signal_dist; +volatile uint8_t quit_signal_work; static volatile struct app_stats { struct {
@@ -165,7 +165,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct rte_eth_link link;rte_eth_link_get_nowait (port, &link); -if (!link.link_status) { +while (!link.link_status) { +printf ("Waiting for Link up on port %" PRIu8"\n" , port);sleep (1 );rte_eth_link_get_nowait (port, &link); }
Signature · 1 line
2.7.4
PATCH v10 13/18 examples/distributor: add dedicated core for dist
In reply to David HuntGive the distribution functionality it's own core for performance, otherwise it's limited by the Rx core.
--- examples/distributor/main.c | 181 ++++++++++++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 58 deletions(-)
examples/distributor/main.c +123 -58
@@ -49,6 +49,8 @@#define NUM_MBUFS ((64*1024)-1)#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +#define SCHED_RX_RING_SZ 8192 +#define SCHED_TX_RING_SZ 65536#define RTE_RING_SZ 1024#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1
@@ -193,37 +195,14 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct lcore_params {unsigned worker_id;struct rte_distributor *d; -struct rte_ring *r; +struct rte_ring *rx_dist_ring; +struct rte_ring *dist_tx_ring;struct rte_mempool *mem_pool; };static int -quit_workers (struct rte_distributor *d,struct rte_mempool *p) -{ -const unsigned num_workers =rte_lcore_count () -2 ; -unsigned i; -struct rte_mbuf *bufs[num_workers]; - -if (rte_mempool_get_bulk (p, (void *)bufs, num_workers) !=0 ) { -printf ("line %d: Error getting mbufs from pool\n" , __LINE__); -return -1 ; - } - -for (i =0 ; i < num_workers; i++) - bufs[i]->hash.rss = i <<1 ; - -rte_distributor_process (d, bufs, num_workers); -rte_mempool_put_bulk (p, (void *)bufs, num_workers); - -return 0 ; -} - -static int lcore_rx (struct lcore_params *p) { -struct rte_distributor *d = p->d; -struct rte_mempool *mem_pool = p->mem_pool; -struct rte_ring *r = p->r;const uint8_t nb_ports =rte_eth_dev_count ();const int socket_id =rte_socket_id ();uint8_t port;
@@ -260,9 +239,15 @@ lcore_rx(struct lcore_params *p) } app_stats.rx.rx_pkts += nb_rx; -rte_distributor_process (d, bufs, nb_rx); -const uint16_t nb_ret =rte_distributor_returned_pkts (d, - bufs,BURST_SIZE *2 ); +/* +* You can run the distributor on the rx core with this code. Returned +* packets are then send straight to the tx core. +*/ +#if 0 +rte_distributor_process (d, bufs, nb_rx); +const uint16_t nb_ret = rte_distributor_returned_pktsd, + bufs, BURST_SIZE*2); + app_stats.rx.returned_pkts += nb_ret;if (unlikely (nb_ret ==0 )) {if (++port == nb_ports)
@@ -270,7 +255,22 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +struct rte_ring *tx_ring = p->dist_tx_ring; +uint16_t sent =rte_ring_enqueue_burst (tx_ring, + (void *)bufs, nb_ret); +#else +uint16_t nb_ret = nb_rx; +/* +* Swap the following two lines if you want the rx traffic +* to go directly to tx, no distribution. +*/ +struct rte_ring *out_ring = p->rx_dist_ring; +/* struct rte_ring *out_ring = p->dist_tx_ring; */ + +uint16_t sent =rte_ring_enqueue_burst (out_ring, + (void *)bufs, nb_ret); +#endif + app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
@@ -281,20 +281,9 @@ lcore_rx(struct lcore_params *p)if (++port == nb_ports) port =0 ; } -rte_distributor_process (d,NULL ,0 ); -/* flush distributor to bring to known state */ -rte_distributor_flush (d);/* set worker & tx threads quit flag */ +printf ("\nCore %u exiting rx task.\n" ,rte_lcore_id ()); quit_signal =1 ; -/* -* worker threads may hang in get packet as -* distributor process is not running, just make sure workers -* get packets till quit_signal is actually been -* received and they gracefully shutdown -*/ -if (quit_workers (d, mem_pool) !=0 ) -return -1 ; -/* rx thread should quit at last */ return 0 ; }
@@ -331,6 +320,58 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports) } } + + +static int +lcore_distributor (struct lcore_params *p) +{ +struct rte_ring *in_r = p->rx_dist_ring; +struct rte_ring *out_r = p->dist_tx_ring; +struct rte_mbuf *bufs[BURST_SIZE *4 ]; +struct rte_distributor *d = p->d; + +printf ("\nCore %u acting as distributor core.\n" ,rte_lcore_id ()); +while (!quit_signal_dist) { +const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, + (void *)bufs,BURST_SIZE *1 ); +if (nb_rx) { + app_stats.dist.in_pkts += nb_rx; + +/* Distribute the packets */ +rte_distributor_process (d, bufs, nb_rx); +/* Handle Returns */ +const uint16_t nb_ret = +rte_distributor_returned_pkts (d, + bufs,BURST_SIZE *2 ); + +if (unlikely (nb_ret ==0 )) +continue ; + app_stats.dist.ret_pkts += nb_ret; + +uint16_t sent =rte_ring_enqueue_burst (out_r, + (void *)bufs, nb_ret); + app_stats.dist.sent_pkts += sent; +if (unlikely (sent < nb_ret)) { + app_stats.dist.enqdrop_pkts += nb_ret - sent; +RTE_LOG (DEBUG ,DISTRAPP , +"%s:Packet loss due to full out ring\n" , + __func__); +while (sent < nb_ret) +rte_pktmbuf_free (bufs[sent++]); + } + } + } +printf ("\nCore %u exiting distributor task.\n" ,rte_lcore_id ()); + quit_signal_work =1 ; + +rte_distributor_flush (d); +/* Unblock any returns so workers can exit */ +rte_distributor_clear_returns (d); + quit_signal_rx =1 ; +return 0 ; +} + +static int lcore_tx (struct rte_ring *in_r) {
@@ -403,7 +444,7 @@ int_handler(int sig_num) {printf ("Exiting on signal %d\n" , sig_num);/* set quit flag for rx thread to exit */ - quit_signal_rx =1 ; + quit_signal_dist =1 ; } static void
@@ -517,7 +558,7 @@ lcore_worker(struct lcore_params *p) buf[i] =NULL ;printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ()); -while (!quit_signal) { +while (!quit_signal_work) { num =rte_distributor_get_pkt (d, id, buf, buf, num);/* Do a little bit of work for each packet */ for (i =0 ; i < num; i++) {
@@ -608,7 +649,8 @@ main(int argc, char *argv[]) {struct rte_mempool *mbuf_pool;struct rte_distributor *d; -struct rte_ring *output_ring; +struct rte_ring *dist_tx_ring; +struct rte_ring *rx_dist_ring;unsigned lcore_id, worker_id =0 ;unsigned nb_ports;uint8_t portid;
@@ -630,10 +672,11 @@ main(int argc, char *argv[])if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid distributor parameters\n" ); -if (rte_lcore_count () <3 ) +if (rte_lcore_count () <4 )rte_exit (EXIT_FAILURE ,"Error, This application needs at " -"least 3 logical cores to run:\n" -"1 lcore for packet RX and distribution\n" +"least 4 logical cores to run:\n" +"1 lcore for packet RX\n" +"1 lcore for distribution\n" "1 lcore for packet TX\n" "and at least 1 lcore for worker threads\n" );
@@ -673,30 +716,52 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -2 , +rte_lcore_count () -3 ,RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );/* -* scheduler ring is read only by the transmitter core, but written to -* by multiple threads +* scheduler ring is read by the transmitter core, and written to +* by scheduler core */ - output_ring =rte_ring_create ("Output_ring" ,RTE_RING_SZ , -rte_socket_id (),RING_F_SC_DEQ ); -if (output_ring ==NULL ) + dist_tx_ring =rte_ring_create ("Output_ring" ,SCHED_TX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (dist_tx_ring ==NULL ) +rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" ); + + rx_dist_ring =rte_ring_create ("Input_ring" ,SCHED_RX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (rx_dist_ring ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" );RTE_LCORE_FOREACH_SLAVE (lcore_id) { -if (worker_id ==rte_lcore_count () -2 ) +if (worker_id ==rte_lcore_count () -3 ) { +printf ("Starting distributor on lcore_id %d\n" , + lcore_id); +/* distributor core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, + rx_dist_ring, dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ( + (lcore_function_t *)lcore_distributor, + p, lcore_id); + }else if (worker_id ==rte_lcore_count () -4 ) { +printf ("Starting tx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* tx core */ rte_eal_remote_launch ((lcore_function_t *)lcore_tx, - output_ring, lcore_id); -else { + dist_tx_ring, lcore_id); + }else {struct lcore_params *p =rte_malloc (NULL ,sizeof (*p),0 );if (!p)rte_panic ("malloc failure\n" ); - *p = (struct lcore_params ){worker_id, d, output_ring, mbuf_pool}; + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool};rte_eal_remote_launch ((lcore_function_t *)lcore_worker, p, lcore_id);
@@ -704,7 +769,7 @@ main(int argc, char *argv[]) worker_id++; }/* call lcore_main on master core only */ -struct lcore_params p = {0 , d, output_ring, mbuf_pool}; +struct lcore_params p = {0 , d, rx_dist_ring, dist_tx_ring, mbuf_pool};if (lcore_rx (&p) !=0 )return -1 ;
Signature · 1 line
2.7.4
PATCH v10 14/18 examples/distributor: tweaks for performance
In reply to David HuntApproximately 10% performance increase due to these changes.
--- examples/distributor/main.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
examples/distributor/main.c +23 -13
@@ -44,14 +44,14 @@#include <rte_prefetch.h> #include <rte_distributor.h> -#define RX_RING_SIZE 256 +#define RX_RING_SIZE 512#define TX_RING_SIZE 512#define NUM_MBUFS ((64*1024)-1) -#define MBUF_CACHE_SIZE 250 -#define BURST_SIZE 32 +#define MBUF_CACHE_SIZE 128 +#define BURST_SIZE 64#define SCHED_RX_RING_SZ 8192#define SCHED_TX_RING_SZ 65536 -#define RTE_RING_SZ 1024 +#define BURST_SIZE_TX 32#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1
@@ -206,6 +206,7 @@ lcore_rx(struct lcore_params *p)const uint8_t nb_ports =rte_eth_dev_count ();const int socket_id =rte_socket_id ();uint8_t port; +struct rte_mbuf *bufs[BURST_SIZE *2 ];for (port =0 ; port < nb_ports; port++) {/* skip ports that are not enabled */
@@ -229,7 +230,6 @@ lcore_rx(struct lcore_params *p) port =0 ;continue ; } -struct rte_mbuf *bufs[BURST_SIZE *2 ];const uint16_t nb_rx =rte_eth_rx_burst (port,0 , bufs,BURST_SIZE );if (unlikely (nb_rx ==0 )) {
@@ -273,6 +273,7 @@ lcore_rx(struct lcore_params *p) app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { + app_stats.rx.enqdrop_pkts += nb_ret - sent;RTE_LOG_DP (DEBUG ,DISTRAPP ,"%s:Packet loss due to full ring\n" , __func__);while (sent < nb_ret)
@@ -290,13 +291,12 @@ lcore_rx(struct lcore_params *p)static inline void flush_one_port (struct output_buffer *outbuf,uint8_t outp) { -unsigned nb_tx =rte_eth_tx_burst (outp,0 , outbuf->mbufs, - outbuf->count); - app_stats.tx.tx_pkts += nb_tx; +unsigned int nb_tx =rte_eth_tx_burst (outp,0 , + outbuf->mbufs, outbuf->count); + app_stats.tx.tx_pkts += outbuf->count;if (unlikely (nb_tx < outbuf->count)) { -RTE_LOG_DP (DEBUG ,DISTRAPP , -"%s:Packet loss with tx_burst\n" , __func__); + app_stats.tx.enqdrop_pkts += outbuf->count - nb_tx;do {rte_pktmbuf_free (outbuf->mbufs[nb_tx]); }while (++nb_tx < outbuf->count);
@@ -308,6 +308,7 @@ static inline void flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports) { uint8_t outp; +for (outp =0 ; outp < nb_ports; outp++) {/* skip ports that are not enabled */ if ((enabled_port_mask & (1 << outp)) ==0 )
@@ -400,9 +401,9 @@ lcore_tx(struct rte_ring *in_r)if ((enabled_port_mask & (1 << port)) ==0 )continue ; -struct rte_mbuf *bufs[BURST_SIZE ]; +struct rte_mbuf *bufs[BURST_SIZE_TX ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE_TX ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
@@ -431,11 +432,12 @@ lcore_tx(struct rte_ring *in_r) outbuf = &tx_buffers[outp]; outbuf->mbufs[outbuf->count++] = bufs[i]; -if (outbuf->count ==BURST_SIZE ) +if (outbuf->count ==BURST_SIZE_TX )flush_one_port (outbuf, outp); } } } +printf ("\nCore %u exiting tx task.\n" ,rte_lcore_id ());return 0 ; }
@@ -557,6 +559,8 @@ lcore_worker(struct lcore_params *p)for (i =0 ; i <8 ; i++) buf[i] =NULL ; + app_stats.worker_pkts[p->worker_id] =1 ; +printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ());while (!quit_signal_work) { num =rte_distributor_get_pkt (d, id, buf, buf, num);
@@ -568,6 +572,10 @@ lcore_worker(struct lcore_params *p)rte_pause (); buf[i]->port ^= xor_val; } + + app_stats.worker_pkts[p->worker_id] += num; +if (num >0 ) + app_stats.worker_bursts[p->worker_id][num-1 ]++; }return 0 ; }
@@ -756,6 +764,8 @@ main(int argc, char *argv[])rte_eal_remote_launch ((lcore_function_t *)lcore_tx, dist_tx_ring, lcore_id); }else { +printf ("Starting worker on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id);struct lcore_params *p =rte_malloc (NULL ,sizeof (*p),0 );if (!p)
Signature · 1 line
2.7.4
PATCH v10 15/18 examples/distributor: give Rx thread a core
In reply to David HuntNow that we're printing out a page of stats every second to the console, we should give the stats it's own core so that we don't interfere with the performance of the Rx core.
--- examples/distributor/main.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
examples/distributor/main.c +16 -8
@@ -680,9 +680,10 @@ main(int argc, char *argv[])if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid distributor parameters\n" ); -if (rte_lcore_count () <4 ) +if (rte_lcore_count () <5 )rte_exit (EXIT_FAILURE ,"Error, This application needs at " -"least 4 logical cores to run:\n" +"least 5 logical cores to run:\n" +"1 lcore for stats (can be core 0)\n" "1 lcore for packet RX\n" "1 lcore for distribution\n" "1 lcore for packet TX\n"
@@ -724,7 +725,7 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -3 , +rte_lcore_count () -4 ,RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );
@@ -763,6 +764,18 @@ main(int argc, char *argv[])/* tx core */ rte_eal_remote_launch ((lcore_function_t *)lcore_tx, dist_tx_ring, lcore_id); + }else if (worker_id ==rte_lcore_count () -2 ) { +printf ("Starting rx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* rx core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ((lcore_function_t *)lcore_rx, + p, lcore_id); }else {printf ("Starting worker on worker_id %d, lcore_id %d\n" , worker_id, lcore_id);
@@ -778,11 +791,6 @@ main(int argc, char *argv[]) } worker_id++; } -/* call lcore_main on master core only */ -struct lcore_params p = {0 , d, rx_dist_ring, dist_tx_ring, mbuf_pool}; - -if (lcore_rx (&p) !=0 ) -return -1 ; freq =rte_get_timer_hz (); t =rte_rdtsc () + freq;
Signature · 1 line
2.7.4
PATCH v10 16/18 doc: distributor library changes for new burst API
In reply to David Hunt--- doc/guides/prog_guide/packet_distrib_lib.rst | 3 +++ 1 file changed, 3 insertions(+)
doc/guides/prog_guide/packet_distrib_lib.rst +3 -0
@@ -42,6 +42,9 @@ The model of operation is shown in the diagram below. Packet Distributor mode of operation +There are two modes of operation of the API in the distributor Library, one which sends one packet at a time +to workers using 32-bits for flow_id, and an optiomised mode which sends bursts of up to 8 packets at a time +to workers, using 15 bits of flow_id. The mode is selected by the type field in the ``rte_distributor_create function``. Distributor Core Operation --------------------------
Signature · 1 line
2.7.4
PATCH v10 17/18 doc: distributor app changes for new burst API
In reply to David HuntChanges in the thread layout described, with an updated diagram.
--- doc/guides/sample_app_ug/dist_app.rst | 49 +++--- doc/guides/sample_app_ug/img/dist_app.svg | 276 +++++++++++++++++------------- 2 files changed, 179 insertions(+), 146 deletions(-)
doc/guides/sample_app_ug/dist_app.rst +26 -23
@@ -104,33 +104,34 @@ Running the Application Explanation ----------- -The distributor application consists of three types of threads: a receive -thread (lcore_rx()), a set of worker threads(lcore_worker()) -and a transmit thread(lcore_tx()). How these threads work together is shown -in :numref:`figure_dist_app` below. The main() function launches threads of these three types. -Each thread has a while loop which will be doing processing and which is -terminated only upon SIGINT or ctrl+C. The receive and transmit threads -communicate using a software ring (rte_ring structure). - -The receive thread receives the packets using rte_eth_rx_burst() and gives -them to the distributor (using rte_distributor_process() API) which will -be called in context of the receive thread itself. The distributor distributes -the packets to workers threads based on the tagging of the packet - -indicated by the hash field in the mbuf. For IP traffic, this field is -automatically filled by the NIC with the "usr" hash value for the packet, -which works as a per-flow tag. +The distributor application consists of four types of threads: a receive thread +(lcore_rx()), a distributor thread (lcore_dist()), a set of worker threads +(lcore_worker()), and a transmit thread(lcore_tx()). How these threads work +together is shown in :numref:`figure_dist_app` below. The main() function +launches threads of these four types. Each thread has a while loop which will +be doing processing and which is terminated only upon SIGINT or ctrl+C. + +The receive thread receives the packets using rte_eth_rx_burst() and will +enqueue them to an rte_ring. The distributor thread will dequeue the packets +from the ring and assign them to workers (using rte_distributor_process() API). +This assignment is based on the tag (or flow ID) of the packet - indicated by +the hash field in the mbuf. For IP traffic, this field is automatically filled +by the NIC with the "usr" hash value for the packet, which works as a per-flow +tag. The distributor thread communicates with the worker threads using a +cache-line swapping mechanism, passing up to 8 mbuf pointers at a time +(one cache line) to each worker. More than one worker thread can exist as part of the application, and these worker threads do simple packet processing by requesting packets from the distributor, doing a simple XOR operation on the input port mbuf field (to indicate the output port which will be used later for packet transmission) -and then finally returning the packets back to the distributor in the RX thread. +and then finally returning the packets back to the distributor thread. -Meanwhile, the receive thread will call the distributor api -rte_distributor_returned_pkts() to get the packets processed, and will enqueue -them to a ring for transfer to the TX thread for transmission on the output port. -The transmit thread will dequeue the packets from the ring and transmit them on -the output port specified in packet mbuf. +The distributor thread will then call the distributor api +rte_distributor_returned_pkts() to get the processed packets, and will enqueue +them to another rte_ring for transfer to the TX thread for transmission on the +output port. The transmit thread will dequeue the packets from the ring and +transmit them on the output port specified in packet mbuf. Users who wish to terminate the running of the application have to press ctrl+C (or send SIGINT to the app). Upon this signal, a signal handler provided
@@ -153,8 +154,10 @@ the line "#define DEBUG" defined in start of the application in main.c to enable Statistics ---------- -Upon SIGINT (or) ctrl+C, the print_stats() function displays the count of packets -processed at the different stages in the application. +The main function will print statistics on the console every second. These +statistics include the number of packets enqueued and dequeued at each stage +in the application, and also key statistics per worker, including how many +packets of each burst size (1-8) were sent to each worker thread. Application Initialization --------------------------
doc/guides/sample_app_ug/img/dist_app.svg +153 -123
435 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v10 18/18 maintainers: add to distributor lib maintainers
In reply to David Hunt--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -494,6 +494,7 @@ F: doc/guides/sample_app_ug/ip_reassembly.rst Distributor M: Bruce Richardson <[email protected]> +M: David Hunt <[email protected]> F: lib/librte_distributor/ F: doc/guides/prog_guide/packet_distrib_lib.rst F: test/test/test_distributor*
Signature · 1 line
2.7.4
PATCH v9 2/18 lib: create private header file
In reply to David HuntWe'll be adding internal implementation definitions in here that are common to both burst and legacy APIs.
--- lib/librte_distributor/rte_distributor_private.h | 136 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 72 +----------- 2 files changed, 137 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_private.h
lib/librte_distributor/rte_distributor_private.h new file +136 -0
@@ -0,0 +1,136 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 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 +* 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. +*/ + +#ifndef _RTE_DIST_PRIV_H_ +#define _RTE_DIST_PRIV_H_ + +/** +* @file +* RTE distributor +* +* The distributor is a component which is designed to pass packets +* one-at-a-time to workers, with dynamic load balancing. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NO_FLAGS 0 +#define RTE_DISTRIB_PREFIX "DT_" + +/* +* We will use the bottom four bits of pointer for flags, shifting out +* the top four bits to make room (since a 64-bit pointer actually only uses +* 48 bits). An arithmetic-right-shift will then appropriately restore the +* original pointer value with proper sign extension into the top bits. +*/ +#define RTE_DISTRIB_FLAG_BITS 4 +#define RTE_DISTRIB_FLAGS_MASK (0x0F) +#define RTE_DISTRIB_NO_BUF 0/**< empty flags: no buffer requested */ +#define RTE_DISTRIB_GET_BUF (1)/**< worker requests a buffer, returns old */ +#define RTE_DISTRIB_RETURN_BUF (2)/**< worker returns a buffer, no request */ +#define RTE_DISTRIB_VALID_BUF (4)/**< set if bufptr contains ptr */ + +#define RTE_DISTRIB_BACKLOG_SIZE 8 +#define RTE_DISTRIB_BACKLOG_MASK (RTE_DISTRIB_BACKLOG_SIZE - 1) + +#define RTE_DISTRIB_MAX_RETURNS 128 +#define RTE_DISTRIB_RETURNS_MASK (RTE_DISTRIB_MAX_RETURNS - 1) + +/** +* Maximum number of workers allowed. +* Be aware of increasing the limit, becaus it is limited by how we track +* in-flight tags. See in_flight_bitmask and rte_distributor_process +*/ +#define RTE_DISTRIB_MAX_WORKERS 64 + +#define RTE_DISTRIBUTOR_NAMESIZE 32/**< Length of name for instance */ + +/** +* Buffer structure used to pass the pointer data between cores. This is cache +* line aligned, but to improve performance and prevent adjacent cache-line +* prefetches of buffers for other workers, e.g. when worker 1's buffer is on +* the next cache line to worker 0, we pad this out to three cache lines. +* Only 64-bits of the memory is actually used though. +*/ +union rte_distributor_buffer { +volatile int64_t bufptr64; +char pad[RTE_CACHE_LINE_SIZE *3 ]; +} __rte_cache_aligned; + +/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(rte_xmm_t) / sizeof(uint16_t)) + +struct rte_distributor_backlog { +unsigned int start; +unsigned int count; + int64_t pkts[RTE_DIST_BURST_SIZE] __rte_cache_aligned; +uint16_t *tags;/* will point to second cacheline of inflights */ +} __rte_cache_aligned; + + +struct rte_distributor_returned_pkts { +unsigned int start; +unsigned int count; +struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS ]; +}; + +struct rte_distributor { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */ + +uint32_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS ]; +/**< Tracks the tag being processed per core */ +uint64_t in_flight_bitmask; +/**< on/off bits for in-flight tags. +* Note that if RTE_DISTRIB_MAX_WORKERS is larger than 64 then +* the bitmask has to expand. +*/ + +struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS ]; + +union rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; +}; + +#ifdef __cplusplus +} +#endif + +#endif
lib/librte_distributor/rte_distributor_v20.c +1 -71
78 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v9 3/18 lib: add new burst oriented distributor structs
In reply to David Hunt--- lib/librte_distributor/rte_distributor_private.h | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
lib/librte_distributor/rte_distributor_private.h +56 -0
@@ -129,6 +129,62 @@ struct rte_distributor {struct rte_distributor_returned_pkts returns; }; +/* All different signature compare functions */ +enum rte_distributor_match_function { +RTE_DIST_MATCH_SCALAR =0 , +RTE_DIST_MATCH_VECTOR , +RTE_DIST_NUM_MATCH_FNS +}; + +/** +* Buffer structure used to pass the pointer data between cores. This is cache +* line aligned, but to improve performance and prevent adjacent cache-line +* prefetches of buffers for other workers, e.g. when worker 1's buffer is on +* the next cache line to worker 0, we pad this out to two cache lines. +* We can pass up to 8 mbufs at a time in one cacheline. +* There is a separate cacheline for returns in the burst API. +*/ +struct rte_distributor_buffer_v1705 { + volatile int64_t bufptr64[RTE_DIST_BURST_SIZE] +__rte_cache_aligned ;/* <= outgoing to worker */ + + int64_t pad1 __rte_cache_aligned; /* <= one cache line */ + + volatile int64_t retptr64[RTE_DIST_BURST_SIZE] +__rte_cache_aligned ;/* <= incoming from worker */ + + int64_t pad2 __rte_cache_aligned; /* <= one cache line */ + + int count __rte_cache_aligned; /* <= number of current mbufs */ +}; + +struct rte_distributor_v1705 { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */ +unsigned int alg_type;/**< Number of alg types */ + +/**> +* First cache line in the this array are the tags inflight +* on the worker core. Second cache line are the backlog +* that are going to go to the worker core. +*/ + uint16_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS][RTE_DIST_BURST_SIZE*2] +__rte_cache_aligned ; + + struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] +__rte_cache_aligned ; + +struct rte_distributor_buffer_v1705 bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; + +enum rte_distributor_match_function dist_match_fn; + +struct rte_distributor *d_v20; +}; + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v9 4/18 lib: add new distributor code
In reply to David HuntThis patch includes public header file which will be used once we add in the symbol versioning for v20 and v1705 APIs.
Also includes v1702 header file, and code for new burst-capable distributor library. This will be re-named as rte_distributor.h later in the patch-set
The new distributor code contains a very similar API to the legacy code, but now sends bursts of up to 8 mbufs to each worker. Flow ID's are reduced to 15 bits for an optimal flow matching algorithm.
--- lib/librte_distributor/Makefile | 1 + lib/librte_distributor/rte_distributor.c | 628 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_private.h | 7 +- lib/librte_distributor/rte_distributor_v1705.h | 269 ++++++++++ 4 files changed, 904 insertions(+), 1 deletion(-) create mode 100644 lib/librte_distributor/rte_distributor.c create mode 100644 lib/librte_distributor/rte_distributor_v1705.h
lib/librte_distributor/Makefile +1 -0
@@ -43,6 +43,7 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor.c new file +628 -0
628 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +6 -1
@@ -159,7 +159,7 @@ struct rte_distributor_buffer_v1705 { };struct rte_distributor_v1705 { -TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ +TAILQ_ENTRY (rte_distributor_v1705) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -185,6 +185,11 @@ struct rte_distributor_v1705 {struct rte_distributor *d_v20; }; +void +find_match_scalar (struct rte_distributor_v1705 *d, +uint16_t *data_ptr, +uint16_t *output_ptr); + #ifdef __cplusplus }#endif
lib/librte_distributor/rte_distributor_v1705.h new file +269 -0
269 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v9 04/18] lib: add new distributor code
Quoted 4 lines · David Hunt
This patch includes public header file which will be used once we add in the symbol versioning for v20 and v1705 APIs.
Also includes v1702 header file, and code for new
Now 1705.
Quoted 8 lines
burst-capable distributor library. This will be re-named as
rte_distributor.hlater in the patch-setThe new distributor code contains a very similar API to the legacy code, but now sends bursts of up to 8 mbufs to each worker. Flow ID's are reduced to 15 bits for an optimal flow matching algorithm.
Signed-off-by David Hunt <[email protected]>
Quoted 9 lines
--- lib/librte_distributor/Makefile | 1 + lib/librte_distributor/rte_distributor.c | 628 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_private.h | 7 +- lib/librte_distributor/rte_distributor_v1705.h | 269 ++++++++++ 4 files changed, 904 insertions(+), 1 deletion(-) create mode 100644 lib/librte_distributor/rte_distributor.c create mode 100644 lib/librte_distributor/rte_distributor_v1705.h
Minor nit, I think this patch might be squashed into the previous one, to have new structures and code together.
/Bruce
Re: [PATCH v9 04/18] lib: add new distributor code
Quoted 24 lines · Bruce Richardson
Quoted 4 lines · David Hunt
This patch includes public header file which will be used once we add in the symbol versioning for v20 and v1705 APIs.
Also includes v1702 header file, and code for new
Now 1705.
Quoted 8 lines
burst-capable distributor library. This will be re-named as
rte_distributor.hlater in the patch-setThe new distributor code contains a very similar API to the legacy code, but now sends bursts of up to 8 mbufs to each worker. Flow ID's are reduced to 15 bits for an optimal flow matching algorithm.
Signed-off-by David Hunt <[email protected]>Quoted 9 lines
--- lib/librte_distributor/Makefile | 1 + lib/librte_distributor/rte_distributor.c | 628 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_private.h | 7 +- lib/librte_distributor/rte_distributor_v1705.h | 269 ++++++++++ 4 files changed, 904 insertions(+), 1 deletion(-)create mode 100644
lib/librte_distributor/rte_distributor.ccreate mode 100644lib/librte_distributor/rte_distributor_v1705.h
Quoted 4 lines
Minor nit, I think this patch might be squashed into the previous one, to have new structures and code together.
/Bruce
Done in the next version.
Dave.
PATCH v9 5/18 lib: add SIMD flow matching to distributor
In reply to David HuntAdd an optimised version of the in-flight flow matching algorithm using SIMD instructions. This should give up to 1.5x over the scalar versions performance.
Falls back to scalar version if SSE4.2 not available
--- lib/librte_distributor/Makefile | 10 ++ lib/librte_distributor/rte_distributor.c | 16 ++- .../rte_distributor_match_generic.c | 43 ++++++++ lib/librte_distributor/rte_distributor_match_sse.c | 114 +++++++++++++++++++++ lib/librte_distributor/rte_distributor_private.h | 5 + 5 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_match_generic.c create mode 100644 lib/librte_distributor/rte_distributor_match_sse.c
lib/librte_distributor/Makefile +10 -0
@@ -44,6 +44,16 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor.c +ifeq ($(CONFIG_RTE_ARCH_X86),y) +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_match_sse.c +# distributor SIMD algo needs SSE4.2 support +ifeq ($(findstring RTE_MACHINE_CPUFLAG_SSE4_2,$(CFLAGS)),) +CFLAGS_rte_distributor_match_sse.o += -msse4.2 +endif +else +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor_match_generic.c +endif + # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor.c +14 -2
@@ -391,7 +391,13 @@ rte_distributor_process_v1705(struct rte_distributor_v1705 *d,for (; i <RTE_DIST_BURST_SIZE ; i++) flows[i] =0 ; -find_match_scalar (d, &flows[0 ], &matches[0 ]); +switch (d->dist_match_fn) { +case RTE_DIST_MATCH_VECTOR : +find_match_vec (d, &flows[0 ], &matches[0 ]); +break ; +default : +find_match_scalar (d, &flows[0 ], &matches[0 ]); + }/* * Matches array now contain the intended worker ID (+1) of
@@ -607,7 +613,13 @@ rte_distributor_create_v1705(const char *name,snprintf (d->name,sizeof (d->name),"%s" , name); d->num_workers = num_workers; d->alg_type = alg_type; - d->dist_match_fn =RTE_DIST_MATCH_SCALAR ; + +#if defined(RTE_ARCH_X86 ) +if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_SSE4_2 )) + d->dist_match_fn =RTE_DIST_MATCH_VECTOR ; + else +#endif + d->dist_match_fn =RTE_DIST_MATCH_SCALAR ;/* * Set up the backog tags so they're pointing at the second cache
lib/librte_distributor/rte_distributor_match_generic.c new file +43 -0
43 lines not on this page · raw message
lib/librte_distributor/rte_distributor_match_sse.c new file +114 -0
114 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +5 -0
@@ -190,6 +190,11 @@ find_match_scalar(struct rte_distributor_v1705 *d,uint16_t *data_ptr, uint16_t *output_ptr); +void +find_match_vec (struct rte_distributor_v1705 *d, +uint16_t *data_ptr, +uint16_t *output_ptr); + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v9 6/18 test/distributor: extra params for autotests
In reply to David HuntIn the next few patches, we'll want to test old and new API, so here we're allowing different parameters to be passed to the tests, instead of just a distributor struct.
--- test/test/test_distributor.c | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 21 deletions(-)
test/test/test_distributor.c +43 -21
@@ -45,6 +45,13 @@#define BURST 32#define BIG_BATCH 1024 +struct worker_params { +char name[64 ]; +struct rte_distributor *dist; +}; + +struct worker_params worker_params; +/* statics - all zero-initialized by default */ static volatile int quit;/**< general quit variable for all threads */ static volatile int zero_quit;/**< var for when we just want thr0 to quit*/
@@ -81,7 +88,9 @@ static int handle_work(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist; +unsigned count =0 ;unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -107,8 +116,9 @@ handle_work(void *arg)* not necessarily in the same order (as different flows). */ static int -sanity_test (struct rte_distributor *d,struct rte_mempool *p) +sanity_test (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -249,7 +259,8 @@ static int handle_work_with_free_mbufs(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist;unsigned count =0 ;unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -270,8 +281,9 @@ handle_work_with_free_mbufs(void *arg)* library. */ static int -sanity_test_with_mbuf_alloc (struct rte_distributor *d,struct rte_mempool *p) +sanity_test_with_mbuf_alloc (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;unsigned i;struct rte_mbuf *bufs[BURST ];
@@ -305,7 +317,8 @@ static int handle_work_for_shutdown_test(void *arg) {struct rte_mbuf *pkt =NULL ; -struct rte_distributor *d = arg; +struct worker_params *wp = arg; +struct rte_distributor *d = wp->dist;unsigned count =0 ;const unsigned id =__sync_fetch_and_add (&worker_idx,1 );
@@ -344,9 +357,10 @@ handle_work_for_shutdown_test(void *arg)* library. */ static int -sanity_test_with_worker_shutdown (struct rte_distributor *d, +sanity_test_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -401,9 +415,10 @@ sanity_test_with_worker_shutdown(struct rte_distributor *d,* one worker shuts down.. */ static int -test_flush_with_worker_shutdown (struct rte_distributor *d, +test_flush_with_worker_shutdown (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;struct rte_mbuf *bufs[BURST ];unsigned i;
@@ -480,8 +495,9 @@ int test_error_distributor_create_numworkers(void)/* Useful function which ensures that all worker functions terminate */ static void -quit_workers (struct rte_distributor *d,struct rte_mempool *p) +quit_workers (struct worker_params *wp,struct rte_mempool *p) { +struct rte_distributor *d = wp->dist;const unsigned num_workers =rte_lcore_count () -1 ;unsigned i;struct rte_mbuf *bufs[RTE_MAX_LCORE ];
@@ -536,28 +552,34 @@ test_distributor(void) } } -rte_eal_mp_remote_launch (handle_work, d,SKIP_MASTER ); -if (sanity_test (d, p) <0 ) + worker_params.dist = d; +sprintf (worker_params.name,"single" ); + +rte_eal_mp_remote_launch (handle_work, &worker_params,SKIP_MASTER ); +if (sanity_test (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_with_free_mbufs, d,SKIP_MASTER ); -if (sanity_test_with_mbuf_alloc (d, p) <0 ) +rte_eal_mp_remote_launch (handle_work_with_free_mbufs, &worker_params, +SKIP_MASTER ); +if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p);if (rte_lcore_count () >2 ) { -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params,SKIP_MASTER ); -if (sanity_test_with_worker_shutdown (d, p) <0 ) +if (sanity_test_with_worker_shutdown (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, d, +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params,SKIP_MASTER ); -if (test_flush_with_worker_shutdown (d, p) <0 ) +if (test_flush_with_worker_shutdown (&worker_params, p) <0 ) goto err; -quit_workers (d, p); +quit_workers (&worker_params, p); }else {printf ("Not enough cores to run tests for worker shutdown\n" );
@@ -572,7 +594,7 @@ test_distributor(void)return 0 ; err: -quit_workers (d, p); +quit_workers (&worker_params, p);return -1 ; }
Signature · 1 line
2.7.4
PATCH v9 7/18 lib: switch distributor over to new API
In reply to David HuntThis is the main switch over between the legacy API and the new burst API. We rename all the functions in rte_distributor.c to remove the _v1705, and we add in _v20 in the rte_distributor_v20.c
At the same time, we need the autotests and sample app to compile properly, hence thosie changes are in there as well.
--- examples/distributor/main.c | 22 +- lib/librte_distributor/rte_distributor.c | 76 +++--- lib/librte_distributor/rte_distributor.h | 240 +++++++++++++++++- lib/librte_distributor/rte_distributor_match_sse.c | 2 +- lib/librte_distributor/rte_distributor_private.h | 22 +- lib/librte_distributor/rte_distributor_v1705.h | 269 --------------------- lib/librte_distributor/rte_distributor_v20.c | 46 ++-- lib/librte_distributor/rte_distributor_v20.h | 24 +- test/test/test_distributor.c | 235 ++++++++++++------ test/test/test_distributor_perf.c | 26 +- 10 files changed, 511 insertions(+), 451 deletions(-) delete mode 100644 lib/librte_distributor/rte_distributor_v1705.h
examples/distributor/main.c +18 -4
@@ -405,17 +405,30 @@ lcore_worker(struct lcore_params *p) {struct rte_distributor *d = p->d;const unsigned id = p->worker_id; +unsigned int num =0 ; +unsigned int i; +/* * for single port, xor_val will be zero so we won't modify the output * port, otherwise we send traffic from 0 to 1, 2 to 3, and vice versa */ const unsigned xor_val = (rte_eth_dev_count () >1 ); -struct rte_mbuf *buf =NULL ; + struct rte_mbuf *buf[8] __rte_cache_aligned; + +for (i =0 ; i <8 ; i++) + buf[i] =NULL ;printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ());while (!quit_signal) { - buf =rte_distributor_get_pkt (d, id, buf); - buf->port ^= xor_val; + num =rte_distributor_get_pkt (d, id, buf, buf, num); +/* Do a little bit of work for each packet */ +for (i =0 ; i < num; i++) { +uint64_t t =rte_rdtsc ()+100 ; + +while (rte_rdtsc () < t) +rte_pause (); + buf[i]->port ^= xor_val; + } }return 0 ; }
@@ -561,7 +574,8 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -2 ); +rte_lcore_count () -2 , +RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );
lib/librte_distributor/rte_distributor.c +38 -38
250 lines not on this page · raw message
lib/librte_distributor/rte_distributor.h +235 -5
252 lines not on this page · raw message
lib/librte_distributor/rte_distributor_match_sse.c +1 -1
@@ -38,7 +38,7 @@void -find_match_vec (struct rte_distributor_v1705 *d, +find_match_vec (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr) {
lib/librte_distributor/rte_distributor_private.h +11 -11
@@ -83,7 +83,7 @@ extern "C" {* the next cache line to worker 0, we pad this out to three cache lines. * Only 64-bits of the memory is actually used though. */ -union rte_distributor_buffer { +union rte_distributor_buffer_v20 {volatile int64_t bufptr64;char pad[RTE_CACHE_LINE_SIZE *3 ]; } __rte_cache_aligned;
@@ -108,8 +108,8 @@ struct rte_distributor_returned_pkts {struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS ]; }; -struct rte_distributor { -TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ +struct rte_distributor_v20 { +TAILQ_ENTRY (rte_distributor_v20) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -124,7 +124,7 @@ struct rte_distributor {struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS ]; -union rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ]; +union rte_distributor_buffer_v20 bufs[RTE_DISTRIB_MAX_WORKERS ];struct rte_distributor_returned_pkts returns; };
@@ -144,7 +144,7 @@ enum rte_distributor_match_function {* We can pass up to 8 mbufs at a time in one cacheline. * There is a separate cacheline for returns in the burst API. */ -struct rte_distributor_buffer_v1705 { +struct rte_distributor_buffer { volatile int64_t bufptr64[RTE_DIST_BURST_SIZE]__rte_cache_aligned ;/* <= outgoing to worker */
@@ -158,8 +158,8 @@ struct rte_distributor_buffer_v1705 { int count __rte_cache_aligned; /* <= number of current mbufs */ }; -struct rte_distributor_v1705 { -TAILQ_ENTRY (rte_distributor_v1705) next;/**< Next in list. */ +struct rte_distributor { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -176,22 +176,22 @@ struct rte_distributor_v1705 { struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] __rte_cache_aligned; -struct rte_distributor_buffer_v1705 bufs[RTE_DISTRIB_MAX_WORKERS ]; +struct rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ];struct rte_distributor_returned_pkts returns;enum rte_distributor_match_function dist_match_fn; -struct rte_distributor *d_v20; +struct rte_distributor_v20 *d_v20; };void -find_match_scalar (struct rte_distributor_v1705 *d, +find_match_scalar (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr);void -find_match_vec (struct rte_distributor_v1705 *d, +find_match_vec (struct rte_distributor *d,uint16_t *data_ptr,uint16_t *output_ptr);
lib/librte_distributor/rte_distributor_v1705.h deleted +0 -269
269 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c +23 -23
151 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.h +12 -12
@@ -48,7 +48,7 @@ extern "C" {#define RTE_DISTRIBUTOR_NAMESIZE 32/**< Length of name for instance */ -struct rte_distributor ; +struct rte_distributor_v20 ;struct rte_mbuf ;/**
@@ -67,8 +67,8 @@ struct rte_mbuf;* @return * The newly created distributor instance */ -struct rte_distributor * -rte_distributor_create (const char *name,unsigned int socket_id, +struct rte_distributor_v20 * +rte_distributor_create_v20 (const char *name,unsigned int socket_id,unsigned int num_workers);/* *** APIS to be called on the distributor lcore *** */
@@ -103,7 +103,7 @@ rte_distributor_create(const char *name, unsigned int socket_id,* The number of mbufs processed. */ int -rte_distributor_process (struct rte_distributor *d, +rte_distributor_process_v20 (struct rte_distributor_v20 *d,struct rte_mbuf **mbufs,unsigned int num_mbufs);/**
@@ -121,7 +121,7 @@ rte_distributor_process(struct rte_distributor *d,* The number of mbufs returned in the mbufs array. */ int -rte_distributor_returned_pkts (struct rte_distributor *d, +rte_distributor_returned_pkts_v20 (struct rte_distributor_v20 *d,struct rte_mbuf **mbufs,unsigned int max_mbufs);/**
@@ -136,7 +136,7 @@ rte_distributor_returned_pkts(struct rte_distributor *d,* The number of queued/in-flight packets that were completed by this call. */ int -rte_distributor_flush (struct rte_distributor *d); +rte_distributor_flush_v20 (struct rte_distributor_v20 *d);/** * Clears the array of returned packets used as the source for the
@@ -148,7 +148,7 @@ rte_distributor_flush(struct rte_distributor *d);* The distributor instance to be used */ void -rte_distributor_clear_returns (struct rte_distributor *d); +rte_distributor_clear_returns_v20 (struct rte_distributor_v20 *d);/* *** APIS to be called on the worker lcores *** */ /*
@@ -177,7 +177,7 @@ rte_distributor_clear_returns(struct rte_distributor *d);* A new packet to be processed by the worker thread. */ struct rte_mbuf * -rte_distributor_get_pkt (struct rte_distributor *d, +rte_distributor_get_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id,struct rte_mbuf *oldpkt);/**
@@ -193,8 +193,8 @@ rte_distributor_get_pkt(struct rte_distributor *d,* The previous packet being processed by the worker */ int -rte_distributor_return_pkt (struct rte_distributor *d,unsigned int worker_id, -struct rte_mbuf *mbuf); +rte_distributor_return_pkt_v20 (struct rte_distributor_v20 *d, +unsigned int worker_id,struct rte_mbuf *mbuf);/** * API called by a worker to request a new packet to process.
@@ -217,7 +217,7 @@ rte_distributor_return_pkt(struct rte_distributor *d, unsigned int worker_id,* The previous packet, if any, being processed by the worker */ void -rte_distributor_request_pkt (struct rte_distributor *d, +rte_distributor_request_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id,struct rte_mbuf *oldpkt);/**
@@ -237,7 +237,7 @@ rte_distributor_request_pkt(struct rte_distributor *d,* packet is yet available. */ struct rte_mbuf * -rte_distributor_poll_pkt (struct rte_distributor *d, +rte_distributor_poll_pkt_v20 (struct rte_distributor_v20 *d,unsigned int worker_id);#ifdef __cplusplus
test/test/test_distributor.c +156 -79
435 lines not on this page · raw message
test/test/test_distributor_perf.c +17 -9
@@ -129,18 +129,25 @@ clear_packet_count(void)static int handle_work (void *arg) { -struct rte_mbuf *pkt =NULL ;struct rte_distributor *d = arg; -unsigned count =0 ; -unsigned id =__sync_fetch_and_add (&worker_idx,1 ); +unsigned int count =0 ; +unsigned int num =0 ; +int i; +unsigned int id =__sync_fetch_and_add (&worker_idx,1 ); + struct rte_mbuf *buf[8] __rte_cache_aligned; - pkt =rte_distributor_get_pkt (d, id,NULL ); +for (i =0 ; i <8 ; i++) + buf[i] =NULL ; + + num =rte_distributor_get_pkt (d, id, buf, buf, num);while (!quit) { - worker_stats[id].handled_packets++, count++; - pkt =rte_distributor_get_pkt (d, id, pkt); + worker_stats[id].handled_packets += num; + count += num; + num =rte_distributor_get_pkt (d, id, buf, buf, num); } - worker_stats[id].handled_packets++, count++; -rte_distributor_return_pkt (d, id, pkt); + worker_stats[id].handled_packets += num; + count += num; +rte_distributor_return_pkt (d, id, buf, num);return 0 ; }
@@ -228,7 +235,8 @@ test_distributor_perf(void)if (d ==NULL ) { d =rte_distributor_create ("Test_perf" ,rte_socket_id (), -rte_lcore_count () -1 ); +rte_lcore_count () -1 , +RTE_DIST_ALG_SINGLE );if (d ==NULL ) {printf ("Error creating distributor\n" );return -1 ;
Signature · 1 line
2.7.4
PATCH v9 8/18 lib: make v20 header file private
In reply to David Hunt--- lib/librte_distributor/Makefile | 1 - 1 file changed, 1 deletion(-)
lib/librte_distributor/Makefile +0 -1
@@ -57,7 +57,6 @@ endif # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h -SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include += rte_distributor_v20.h # this lib needs eal DEPDIRS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += lib/librte_eal
Signature · 1 line
2.7.4
PATCH v9 9/18 lib: add symbol versioning to distributor
In reply to David HuntAlso bumped up the ABI version number in the Makefile
--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 10 +++ lib/librte_distributor/rte_distributor_version.map | 14 ++++ 5 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_v1705.h
lib/librte_distributor/Makefile +1 -1
@@ -39,7 +39,7 @@ CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) EXPORT_MAP := rte_distributor_version.map -LIBABIVER := 1 +LIBABIVER := 2 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c
lib/librte_distributor/rte_distributor.c +48 -9
153 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v1705.h new file +89 -0
89 lines not on this page · raw message
lib/librte_distributor/rte_distributor_v20.c +10 -0
@@ -38,6 +38,7 @@#include <rte_memory.h> #include <rte_memzone.h> #include <rte_errno.h> +#include <rte_compat.h> #include <rte_string_fns.h> #include <rte_eal_memconfig.h> #include "rte_distributor_v20.h"
@@ -63,6 +64,7 @@ rte_distributor_request_pkt_v20(struct rte_distributor_v20 *d,rte_pause (); buf->bufptr64 = req; } +VERSION_SYMBOL (rte_distributor_request_pkt, _v20,2.0 );struct rte_mbuf * rte_distributor_poll_pkt_v20(struct rte_distributor_v20 *d,
@@ -76,6 +78,7 @@ rte_distributor_poll_pkt_v20(struct rte_distributor_v20 *d,int64_t ret = buf->bufptr64 >>RTE_DISTRIB_FLAG_BITS ;return (struct rte_mbuf *)((uintptr_t )ret); } +VERSION_SYMBOL (rte_distributor_poll_pkt, _v20,2.0 );struct rte_mbuf * rte_distributor_get_pkt_v20(struct rte_distributor_v20 *d,
@@ -87,6 +90,7 @@ rte_distributor_get_pkt_v20(struct rte_distributor_v20 *d,rte_pause ();return ret; } +VERSION_SYMBOL (rte_distributor_get_pkt, _v20,2.0 ); int rte_distributor_return_pkt_v20(struct rte_distributor_v20 *d,
@@ -98,6 +102,7 @@ rte_distributor_return_pkt_v20(struct rte_distributor_v20 *d, buf->bufptr64 = req;return 0 ; } +VERSION_SYMBOL (rte_distributor_return_pkt, _v20,2.0 );/**** APIs called on distributor core ***/
@@ -314,6 +319,7 @@ rte_distributor_process_v20(struct rte_distributor_v20 *d, d->returns.count = ret_count;return num_mbufs; } +VERSION_SYMBOL (rte_distributor_process, _v20,2.0 );/* return to the caller, packets returned from workers */ int
@@ -334,6 +340,7 @@ rte_distributor_returned_pkts_v20(struct rte_distributor_v20 *d,return retval; } +VERSION_SYMBOL (rte_distributor_returned_pkts, _v20,2.0 );/* return the number of packets in-flight in a distributor, i.e. packets * being workered on or queued up in a backlog. */
@@ -362,6 +369,7 @@ rte_distributor_flush_v20(struct rte_distributor_v20 *d)return flushed; } +VERSION_SYMBOL (rte_distributor_flush, _v20,2.0 );/* clears the internal returns array in the distributor */ void
@@ -372,6 +380,7 @@ rte_distributor_clear_returns_v20(struct rte_distributor_v20 *d)memset (d->returns.mbufs,0 ,sizeof (d->returns.mbufs));#endif } +VERSION_SYMBOL (rte_distributor_clear_returns, _v20,2.0 );/* creates a distributor instance */ struct rte_distributor_v20 *
@@ -415,3 +424,4 @@ rte_distributor_create_v20(const char *name,return d; } +VERSION_SYMBOL (rte_distributor_create, _v20,2.0 );
lib/librte_distributor/rte_distributor_version.map +14 -0
@@ -13,3 +13,17 @@ DPDK_2.0 { local: *; }; + +DPDK_17.05 { + global: + + rte_distributor_clear_returns; + rte_distributor_create; + rte_distributor_flush; + rte_distributor_get_pkt; + rte_distributor_poll_pkt; + rte_distributor_process; + rte_distributor_request_pkt; + rte_distributor_return_pkt; + rte_distributor_returned_pkts; +} DPDK_2.0;
Signature · 1 line
2.7.4
Re: [PATCH v9 09/18] lib: add symbol versioning to distributor
Quoted 7 lines · David Hunt
Also bumped up the ABI version number in the
MakefileSigned-off-by David Hunt <[email protected]>--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++
A file named rte_distributor_v1705.h was added in patch 4, then deleted in patch 7, and now added again here. Seems a lot of churn.
/Bruce
Re: [PATCH v9 09/18] lib: add symbol versioning to distributor
-----Original Message-----
From: Richardson, Bruce
Sent: Friday, 10 March, 2017 4:22 PM
To: Hunt, David <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v9 09/18] lib: add symbol versioning to distributor
Quoted 7 lines · David Hunt
Also bumped up the ABI version number in the
MakefileSigned-off-by David Hunt <[email protected]>--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++
A file named rte_distributor_v1705.h was added in patch 4, then deleted in patch 7, and now added again here. Seems a lot of churn.
/Bruce
Re: [PATCH v9 09/18] lib: add symbol versioning to distributor
In reply to Bruce RichardsonQuoted 8 lines · Bruce Richardson
Quoted 7 lines · David Hunt
Also bumped up the ABI version number in the
MakefileSigned-off-by David Hunt <[email protected]>--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++
Quoted 5 lines
A file named
rte_distributor_v1705.hwas added in patch 4, then deleted in patch 7, and now added again here. Seems a lot of churn./Bruce
The first introduction of this file is what will become the public header. For successful compilation, this cannot be called rte_distributor.h until the symbol versioning patch, at which stage I will rename the file, and introduce the symbol versioned header at the same time. In the next patch I'll rename this version of the files as rte_distributor_public.h to make this clearer.
Regards,
Dave.
Re: [PATCH v9 09/18] lib: add symbol versioning to distributor
Quoted 18 lines
From: dev [mailto:[email protected]] On Behalf Of Hunt, David
Subject: Re: [dpdk-dev] [PATCH v9 09/18] lib: add symbol versioning to distributorQuoted 8 lines · Bruce Richardson
Quoted 7 lines · David Hunt
Also bumped up the ABI version number in the
MakefileSigned-off-by David Hunt <[email protected]>--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++Quoted 5 lines
A file named
rte_distributor_v1705.hwas added in patch 4, then deleted in patch 7, and now added again here. Seems a lot of churn./Bruce
Quoted 8 lines
The first introduction of this file is what will become the public header. For successful compilation,
this cannot be calledrte_distributor.huntil the symbol versioning patch, at which stage I will
rename the file, and introduce the symbol versioned header at the same time. In the next patch
I'll rename this version of the files asrte_distributor_public.hto make this clearer.
Suggestion to use rte_distributor_next.h instead of public?
Public doesn't indicate if its old or new, while next would make that clearer IMO :)
Re: [PATCH v9 09/18] lib: add symbol versioning to distributor
Quoted 26 lines · Harry
Quoted 17 lines
From: dev [mailto:[email protected]] On Behalf Of Hunt, David
Subject: Re: [dpdk-dev] [PATCH v9 09/18] lib: add symbol versioning to distributorQuoted 8 lines · Bruce Richardson
Quoted 7 lines · David Hunt
Also bumped up the ABI version number in the
MakefileSigned-off-by David Hunt <[email protected]>--- lib/librte_distributor/Makefile | 2 +- lib/librte_distributor/rte_distributor.c | 57 +++++++++++--- lib/librte_distributor/rte_distributor_v1705.h | 89 ++++++++++++++++++++++Quoted 5 lines
A file named
rte_distributor_v1705.hwas added in patch 4, then deleted in patch 7, and now added again here. Seems a lot of churn./Bruce
Quoted 8 lines
The first introduction of this file is what will become the public header. For successful compilation,
this cannot be calledrte_distributor.huntil the symbol versioning patch, at which stage I will
rename the file, and introduce the symbol versioned header at the same time. In the next patch
I'll rename this version of the files asrte_distributor_public.hto make this clearer.
Quoted 2 lines
Suggestion to use
rte_distributor_next.hinstead of public?
Public doesn't indicate if its old or new, while next would make that clearer IMO :)
Good call, will use "_next". Its clearer.
Thanks,
Dave.
PATCH v9 10/18 test: test single and burst distributor API
In reply to David Hunt--- test/test/test_distributor.c | 116 ++++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 34 deletions(-)
test/test/test_distributor.c +82 -34
@@ -538,17 +538,25 @@ staticint test_error_distributor_create_name (void ) {struct rte_distributor *d =NULL ; +struct rte_distributor *db =NULL ;char *name =NULL ; d =rte_distributor_create (name,rte_socket_id (),rte_lcore_count () -1 , -RTE_DIST_ALG_BURST ); - +RTE_DIST_ALG_SINGLE );if (d !=NULL || rte_errno !=EINVAL ) {printf ("ERROR: No error on create() with NULL name param\n" );return -1 ; } + db =rte_distributor_create (name,rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_BURST ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create() with NULL param\n" ); +return -1 ; + } +return 0 ; }
@@ -556,15 +564,25 @@ int test_error_distributor_create_name(void)static int test_error_distributor_create_numworkers (void ) { -struct rte_distributor *d =NULL ; +struct rte_distributor *ds =NULL ; +struct rte_distributor *db =NULL ; - d =rte_distributor_create ("test_numworkers" ,rte_socket_id (), + ds =rte_distributor_create ("test_numworkers" ,rte_socket_id (),RTE_MAX_LCORE +10 , -RTE_DIST_ALG_BURST ); -if (d !=NULL || rte_errno !=EINVAL ) { +RTE_DIST_ALG_SINGLE ); +if (ds !=NULL || rte_errno !=EINVAL ) {printf ("ERROR: No error on create() with num_workers > MAX\n" );return -1 ; } + + db =rte_distributor_create ("test_numworkers" ,rte_socket_id (), +RTE_MAX_LCORE +10 , +RTE_DIST_ALG_BURST ); +if (db !=NULL || rte_errno !=EINVAL ) { +printf ("ERROR: No error on create() num_workers > MAX\n" ); +return -1 ; + } +return 0 ; }
@@ -597,25 +615,42 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p)static int test_distributor (void ) { -static struct rte_distributor *d; +static struct rte_distributor *ds; +static struct rte_distributor *db; +static struct rte_distributor *dist[2 ];static struct rte_mempool *p; +int i;if (rte_lcore_count () <2 ) {printf ("ERROR: not enough cores to test distributor\n" );return -1 ; } -if (d ==NULL ) { - d =rte_distributor_create ("Test_dist_burst" ,rte_socket_id (), +if (db ==NULL ) { + db =rte_distributor_create ("Test_dist_burst" ,rte_socket_id (),rte_lcore_count () -1 ,RTE_DIST_ALG_BURST ); -if (d ==NULL ) { +if (db ==NULL ) {printf ("Error creating burst distributor\n" );return -1 ; } }else { -rte_distributor_flush (d); -rte_distributor_clear_returns (d); +rte_distributor_flush (db); +rte_distributor_clear_returns (db); + } + +if (ds ==NULL ) { + ds =rte_distributor_create ("Test_dist_single" , +rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_SINGLE ); +if (ds ==NULL ) { +printf ("Error creating single distributor\n" ); +return -1 ; + } + }else { +rte_distributor_flush (ds); +rte_distributor_clear_returns (ds); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
@@ -629,37 +664,50 @@ test_distributor(void) } } - worker_params.dist = d; -sprintf (worker_params.name,"burst" ); + dist[0 ] = ds; + dist[1 ] = db; -rte_eal_mp_remote_launch (handle_work, &worker_params,SKIP_MASTER ); -if (sanity_test (&worker_params, p) <0 ) - goto err; -quit_workers (&worker_params, p); +for (i =0 ; i <2 ; i++) { -rte_eal_mp_remote_launch (handle_work_with_free_mbufs, &worker_params, -SKIP_MASTER ); -if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) - goto err; -quit_workers (&worker_params, p); + worker_params.dist = dist[i]; +if (i) +sprintf (worker_params.name,"burst" ); +else +sprintf (worker_params.name,"single" ); -if (rte_lcore_count () >2 ) { -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, - &worker_params, -SKIP_MASTER ); -if (sanity_test_with_worker_shutdown (&worker_params, p) <0 ) +rte_eal_mp_remote_launch (handle_work, + &worker_params,SKIP_MASTER ); +if (sanity_test (&worker_params, p) <0 ) goto err;quit_workers (&worker_params, p); -rte_eal_mp_remote_launch (handle_work_for_shutdown_test, - &worker_params, -SKIP_MASTER ); -if (test_flush_with_worker_shutdown (&worker_params, p) <0 ) +rte_eal_mp_remote_launch (handle_work_with_free_mbufs, + &worker_params,SKIP_MASTER ); +if (sanity_test_with_mbuf_alloc (&worker_params, p) <0 ) goto err;quit_workers (&worker_params, p); - }else { -printf ("Not enough cores to run tests for worker shutdown\n" ); +if (rte_lcore_count () >2 ) { +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (sanity_test_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + +rte_eal_mp_remote_launch (handle_work_for_shutdown_test, + &worker_params, +SKIP_MASTER ); +if (test_flush_with_worker_shutdown (&worker_params, + p) <0 ) + goto err; +quit_workers (&worker_params, p); + + }else { +printf ("Too few cores to run worker shutdown test\n" ); + } + } if (test_error_distributor_create_numworkers() == -1 ||
Signature · 1 line
2.7.4
PATCH v9 11/18 test: add perf test for distributor burst mode
In reply to David Hunt--- test/test/test_distributor_perf.c | 75 ++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 24 deletions(-)
test/test/test_distributor_perf.c +51 -24
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,9 @@#include <rte_mbuf.h> #include <rte_distributor.h> -#define ITER_POWER 20/* log 2 of how many iterations we do when timing. */ -#define BURST 32 +#define ITER_POWER_CL 25/* log 2 of how many iterations for Cache Line test */ +#define ITER_POWER 21/* log 2 of how many iterations we do when timing. */ +#define BURST 64#define BIG_BATCH 1024/* static vars - zero initialized by default */
@@ -54,7 +55,8 @@ struct worker_stats { } __rte_cache_aligned;struct worker_stats worker_stats[RTE_MAX_LCORE ]; -/* worker thread used for testing the time to do a round-trip of a cache +/* +* worker thread used for testing the time to do a round-trip of a cache * line between two cores and back again */ static void
@@ -69,7 +71,8 @@ flip_bit(volatile uint64_t *arg) } } -/* test case to time the number of cycles to round-trip a cache line between +/* +* test case to time the number of cycles to round-trip a cache line between * two cores and back again. */ static void
@@ -86,7 +89,7 @@ time_cache_line_switch(void)rte_pause ();const uint64_t start_time =rte_rdtsc (); -for (i =0 ; i < (1 <<ITER_POWER ); i++) { +for (i =0 ; i < (1 <<ITER_POWER_CL ); i++) {while (*pdata)rte_pause (); *pdata =1 ;
@@ -98,13 +101,14 @@ time_cache_line_switch(void) *pdata =2 ;rte_eal_wait_lcore (slaveid);printf ("==== Cache line switch test ===\n" ); -printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER ), +printf ("Time for %u iterations = %" PRIu64" ticks\n" , (1 <<ITER_POWER_CL ), end_time-start_time);printf ("Ticks per iteration = %" PRIu64"\n\n" , - (end_time-start_time) >>ITER_POWER ); + (end_time-start_time) >>ITER_POWER_CL ); } -/* returns the total count of the number of packets handled by the worker +/* +* returns the total count of the number of packets handled by the worker * functions given below. */ static unsigned
@@ -123,7 +127,8 @@ clear_packet_count(void)memset (&worker_stats,0 ,sizeof (worker_stats)); } -/* this is the basic worker function for performance tests. +/* +* This is the basic worker function for performance tests. * it does nothing but return packets and count them. */ static int
@@ -151,14 +156,15 @@ handle_work(void *arg)return 0 ; } -/* this basic performance test just repeatedly sends in 32 packets at a time +/* +* This basic performance test just repeatedly sends in 32 packets at a time * to the distributor and verifies at the end that we got them all in the worker * threads and finally how long per packet the processing took. */ static inline int perf_test (struct rte_distributor *d,struct rte_mempool *p) { -unsigned i; +unsigned int i;uint64_t start, end;struct rte_mbuf *bufs[BURST ];
@@ -181,7 +187,8 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)rte_distributor_process (d,NULL ,0 ); }while (total_packet_count () < (BURST <<ITER_POWER )); -printf ("=== Performance test of distributor ===\n" ); +rte_distributor_clear_returns (d); +printf ("Time per burst: %" PRIu64"\n" , (end - start) >>ITER_POWER );printf ("Time per packet: %" PRIu64"\n\n" , ((end - start) >>ITER_POWER )/BURST );
@@ -201,9 +208,10 @@ perf_test(struct rte_distributor *d, struct rte_mempool *p)static void quit_workers (struct rte_distributor *d,struct rte_mempool *p) { -const unsigned num_workers =rte_lcore_count () -1 ; -unsigned i; +const unsigned int num_workers =rte_lcore_count () -1 ; +unsigned int i;struct rte_mbuf *bufs[RTE_MAX_LCORE ]; +rte_mempool_get_bulk (p, (void *)bufs, num_workers); quit =1 ;
@@ -222,7 +230,8 @@ quit_workers(struct rte_distributor *d, struct rte_mempool *p)static int test_distributor_perf (void ) { -static struct rte_distributor *d; +static struct rte_distributor *ds; +static struct rte_distributor *db;static struct rte_mempool *p;if (rte_lcore_count () <2 ) {
@@ -233,17 +242,28 @@ test_distributor_perf(void)/* first time how long it takes to round-trip a cache line */ time_cache_line_switch (); -if (d ==NULL ) { - d =rte_distributor_create ("Test_perf" ,rte_socket_id (), +if (ds ==NULL ) { + ds =rte_distributor_create ("Test_perf" ,rte_socket_id (),rte_lcore_count () -1 ,RTE_DIST_ALG_SINGLE ); -if (d ==NULL ) { +if (ds ==NULL ) {printf ("Error creating distributor\n" );return -1 ; } }else { -rte_distributor_flush (d); -rte_distributor_clear_returns (d); +rte_distributor_clear_returns (ds); + } + +if (db ==NULL ) { + db =rte_distributor_create ("Test_burst" ,rte_socket_id (), +rte_lcore_count () -1 , +RTE_DIST_ALG_BURST ); +if (db ==NULL ) { +printf ("Error creating burst distributor\n" ); +return -1 ; + } + }else { +rte_distributor_clear_returns (db); } const unsigned nb_bufs = (511 * rte_lcore_count()) < BIG_BATCH ?
@@ -257,10 +277,17 @@ test_distributor_perf(void) } } -rte_eal_mp_remote_launch (handle_work, d,SKIP_MASTER ); -if (perf_test (d, p) <0 ) +printf ("=== Performance test of distributor (single mode) ===\n" ); +rte_eal_mp_remote_launch (handle_work, ds,SKIP_MASTER ); +if (perf_test (ds, p) <0 ) +return -1 ; +quit_workers (ds, p); + +printf ("=== Performance test of distributor (burst mode) ===\n" ); +rte_eal_mp_remote_launch (handle_work, db,SKIP_MASTER ); +if (perf_test (db, p) <0 )return -1 ; -quit_workers (d, p); +quit_workers (db, p);return 0 ; }
Signature · 1 line
2.7.4
PATCH v9 12/18 examples/distributor: allow for extra stats
In reply to David HuntThis will allow us to see what's going on at various stages throughout the sample app, with per-second visibility
--- examples/distributor/main.c | 139 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 123 insertions(+), 16 deletions(-)
examples/distributor/main.c +123 -16
@@ -54,24 +54,53 @@#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1 +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_RESET "\x1b[0m" +/* mask of enabled ports */ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx; +volatile uint8_t quit_signal_dist;static volatile struct app_stats {struct {uint64_t rx_pkts;uint64_t returned_pkts;uint64_t enqueued_pkts; +uint64_t enqdrop_pkts; } rx __rte_cache_aligned; + int pad1 __rte_cache_aligned; + +struct { +uint64_t in_pkts; +uint64_t ret_pkts; +uint64_t sent_pkts; +uint64_t enqdrop_pkts; + } dist __rte_cache_aligned; + int pad2 __rte_cache_aligned;struct {uint64_t dequeue_pkts;uint64_t tx_pkts; +uint64_t enqdrop_pkts; } tx __rte_cache_aligned; + int pad3 __rte_cache_aligned; + + uint64_t worker_pkts[64] __rte_cache_aligned; + + int pad4 __rte_cache_aligned; + + uint64_t worker_bursts[64][8] __rte_cache_aligned; + + int pad5 __rte_cache_aligned; + + uint64_t port_rx_pkts[64] __rte_cache_aligned; + uint64_t port_tx_pkts[64] __rte_cache_aligned; } app_stats; +struct app_stats prev_app_stats; +static const struct rte_eth_conf port_conf_default = { .rxmode = { .mq_mode =ETH_MQ_RX_RSS ,
@@ -93,6 +122,8 @@ struct output_buffer {struct rte_mbuf *mbufs[BURST_SIZE ]; }; +static void print_stats (void ); +/* * Initialises a given port using global settings and with the rx buffers * coming from the mbuf_pool passed as parameter
@@ -378,25 +409,91 @@ static voidprint_stats (void) {struct rte_eth_stats eth_stats; -unsigned i; - -printf ("\nRX thread stats:\n" ); -printf (" - Received: %" PRIu64"\n" , app_stats.rx.rx_pkts); -printf (" - Processed: %" PRIu64"\n" , app_stats.rx.returned_pkts); -printf (" - Enqueued: %" PRIu64"\n" , app_stats.rx.enqueued_pkts); - -printf ("\nTX thread stats:\n" ); -printf (" - Dequeued: %" PRIu64"\n" , app_stats.tx.dequeue_pkts); -printf (" - Transmitted: %" PRIu64"\n" , app_stats.tx.tx_pkts); +unsigned int i, j; +const unsigned int num_workers =rte_lcore_count () -4 ;for (i =0 ; i <rte_eth_dev_count (); i++) {rte_eth_stats_get (i, ð_stats); -printf ("\nPort %u stats:\n" , i); -printf (" - Pkts in: %" PRIu64"\n" , eth_stats.ipackets); -printf (" - Pkts out: %" PRIu64"\n" , eth_stats.opackets); -printf (" - In Errs: %" PRIu64"\n" , eth_stats.ierrors); -printf (" - Out Errs: %" PRIu64"\n" , eth_stats.oerrors); -printf (" - Mbuf Errs: %" PRIu64"\n" , eth_stats.rx_nombuf); + app_stats.port_rx_pkts[i] = eth_stats.ipackets; + app_stats.port_tx_pkts[i] = eth_stats.opackets; + } + +printf ("\n\nRX Thread:\n" ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsin : %5.2f\n" , i, + (app_stats.port_rx_pkts[i] - + prev_app_stats.port_rx_pkts[i])/1000000.0 ); + prev_app_stats.port_rx_pkts[i] = app_stats.port_rx_pkts[i]; + } +printf (" - Received: %5.2f\n" , + (app_stats.rx.rx_pkts - + prev_app_stats.rx.rx_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.rx.returned_pkts - + prev_app_stats.rx.returned_pkts)/1000000.0 ); +printf (" - Enqueued: %5.2f\n" , + (app_stats.rx.enqueued_pkts - + prev_app_stats.rx.enqueued_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.rx.enqdrop_pkts - + prev_app_stats.rx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("Distributor thread:\n" ); +printf (" - In: %5.2f\n" , + (app_stats.dist.in_pkts - + prev_app_stats.dist.in_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.dist.ret_pkts - + prev_app_stats.dist.ret_pkts)/1000000.0 ); +printf (" - Sent: %5.2f\n" , + (app_stats.dist.sent_pkts - + prev_app_stats.dist.sent_pkts)/1000000.0 ); +printf (" - Dropped %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.dist.enqdrop_pkts - + prev_app_stats.dist.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("TX thread:\n" ); +printf (" - Dequeued: %5.2f\n" , + (app_stats.tx.dequeue_pkts - + prev_app_stats.tx.dequeue_pkts)/1000000.0 ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsout: %5.2f\n" , + i, (app_stats.port_tx_pkts[i] - + prev_app_stats.port_tx_pkts[i])/1000000.0 ); + prev_app_stats.port_tx_pkts[i] = app_stats.port_tx_pkts[i]; + } +printf (" - Transmitted: %5.2f\n" , + (app_stats.tx.tx_pkts - + prev_app_stats.tx.tx_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.tx.enqdrop_pkts - + prev_app_stats.tx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + + prev_app_stats.rx.rx_pkts = app_stats.rx.rx_pkts; + prev_app_stats.rx.returned_pkts = app_stats.rx.returned_pkts; + prev_app_stats.rx.enqueued_pkts = app_stats.rx.enqueued_pkts; + prev_app_stats.rx.enqdrop_pkts = app_stats.rx.enqdrop_pkts; + prev_app_stats.dist.in_pkts = app_stats.dist.in_pkts; + prev_app_stats.dist.ret_pkts = app_stats.dist.ret_pkts; + prev_app_stats.dist.sent_pkts = app_stats.dist.sent_pkts; + prev_app_stats.dist.enqdrop_pkts = app_stats.dist.enqdrop_pkts; + prev_app_stats.tx.dequeue_pkts = app_stats.tx.dequeue_pkts; + prev_app_stats.tx.tx_pkts = app_stats.tx.tx_pkts; + prev_app_stats.tx.enqdrop_pkts = app_stats.tx.enqdrop_pkts; + +for (i =0 ; i < num_workers; i++) { +printf ("Worker %02u Pkts: %5.2f. Bursts(1-8): " , i, + (app_stats.worker_pkts[i] - + prev_app_stats.worker_pkts[i])/1000000.0 ); +for (j =0 ; j <8 ; j++) { +printf ("%" PRIu64" " , app_stats.worker_bursts[i][j]); + app_stats.worker_bursts[i][j] =0 ; + } +printf ("\n" ); + prev_app_stats.worker_pkts[i] = app_stats.worker_pkts[i]; } }
@@ -515,6 +612,7 @@ main(int argc, char *argv[])unsigned nb_ports;uint8_t portid;uint8_t nb_ports_available; +uint64_t t, freq;/* catch ctrl-c so we can print on exit */ signal (SIGINT , int_handler);
@@ -610,6 +708,15 @@ main(int argc, char *argv[])if (lcore_rx (&p) !=0 )return -1 ; + freq =rte_get_timer_hz (); + t =rte_rdtsc () + freq; +while (!quit_signal_dist) { +if (t <rte_rdtsc ()) { +print_stats (); + t =rte_rdtsc () + freq; + } + } +RTE_LCORE_FOREACH_SLAVE (lcore_id) {if (rte_eal_wait_lcore (lcore_id) <0 )return -1 ;
Signature · 1 line
2.7.4
Re: [PATCH v9 12/18] examples/distributor: allow for extra stats
Quoted 194 lines · David Hunt
This will allow us to see what's going on at various stages throughout the sample app, with per-second visibility
Signed-off-by David Hunt <[email protected]>--- examples/distributor/main.c | 139 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 123 insertions(+), 16 deletions(-)examples/distributor/main.c +114
-16@@ -54,24 +54,53 @@#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1 +#define ANSI_COLOR_RED "\x1b[31m" +#define ANSI_COLOR_RESET "\x1b[0m" +/* mask of enabled ports */ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx; +volatile uint8_t quit_signal_dist;static volatile struct app_stats {struct {uint64_t rx_pkts;uint64_t returned_pkts;uint64_t enqueued_pkts; +uint64_t enqdrop_pkts; } rx __rte_cache_aligned; + int pad1 __rte_cache_aligned; + +struct { +uint64_t in_pkts; +uint64_t ret_pkts; +uint64_t sent_pkts; +uint64_t enqdrop_pkts; + } dist __rte_cache_aligned; + int pad2 __rte_cache_aligned;struct {uint64_t dequeue_pkts;uint64_t tx_pkts; +uint64_t enqdrop_pkts; } tx __rte_cache_aligned; + int pad3 __rte_cache_aligned; + + uint64_t worker_pkts[64] __rte_cache_aligned; + + int pad4 __rte_cache_aligned; + + uint64_t worker_bursts[64][8] __rte_cache_aligned; + + int pad5 __rte_cache_aligned; + + uint64_t port_rx_pkts[64] __rte_cache_aligned; + uint64_t port_tx_pkts[64] __rte_cache_aligned; } app_stats; +struct app_stats prev_app_stats; +static const struct rte_eth_conf port_conf_default = { .rxmode = { .mq_mode =ETH_MQ_RX_RSS ,@@ -93,6 +122,8 @@ struct output_buffer {struct rte_mbuf *mbufs[BURST_SIZE ]; }; +static void print_stats (void ); +/* * Initialises a given port using global settings and with the rx buffers * coming from the mbuf_pool passed as parameter @@ -378,25 +409,91 @@ static voidprint_stats (void) {struct rte_eth_stats eth_stats; -unsigned i; - -printf ("\nRX thread stats:\n" ); -printf (" - Received: %" PRIu64"\n" , app_stats.rx.rx_pkts); -printf (" - Processed: %" PRIu64"\n" , app_stats.rx.returned_pkts); -printf (" - Enqueued: %" PRIu64"\n" , app_stats.rx.enqueued_pkts); - -printf ("\nTX thread stats:\n" ); -printf (" - Dequeued: %" PRIu64"\n" , app_stats.tx.dequeue_pkts); -printf (" - Transmitted: %" PRIu64"\n" , app_stats.tx.tx_pkts); +unsigned int i, j; +const unsigned int num_workers =rte_lcore_count () -4 ;for (i =0 ; i <rte_eth_dev_count (); i++) {rte_eth_stats_get (i, ð_stats); -printf ("\nPort %u stats:\n" , i); -printf (" - Pkts in: %" PRIu64"\n" , eth_stats.ipackets); -printf (" - Pkts out: %" PRIu64"\n" , eth_stats.opackets); -printf (" - In Errs: %" PRIu64"\n" , eth_stats.ierrors); -printf (" - Out Errs: %" PRIu64"\n" , eth_stats.oerrors); -printf (" - Mbuf Errs: %" PRIu64"\n" , eth_stats.rx_nombuf); + app_stats.port_rx_pkts[i] = eth_stats.ipackets; + app_stats.port_tx_pkts[i] = eth_stats.opackets; + } + +printf ("\n\nRX Thread:\n" ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsin : %5.2f\n" , i, + (app_stats.port_rx_pkts[i] - + prev_app_stats.port_rx_pkts[i])/1000000.0 ); + prev_app_stats.port_rx_pkts[i] = app_stats.port_rx_pkts[i]; + } +printf (" - Received: %5.2f\n" , + (app_stats.rx.rx_pkts - + prev_app_stats.rx.rx_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.rx.returned_pkts - + prev_app_stats.rx.returned_pkts)/1000000.0 ); +printf (" - Enqueued: %5.2f\n" , + (app_stats.rx.enqueued_pkts - + prev_app_stats.rx.enqueued_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.rx.enqdrop_pkts - + prev_app_stats.rx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("Distributor thread:\n" ); +printf (" - In: %5.2f\n" , + (app_stats.dist.in_pkts - + prev_app_stats.dist.in_pkts)/1000000.0 ); +printf (" - Returned: %5.2f\n" , + (app_stats.dist.ret_pkts - + prev_app_stats.dist.ret_pkts)/1000000.0 ); +printf (" - Sent: %5.2f\n" , + (app_stats.dist.sent_pkts - + prev_app_stats.dist.sent_pkts)/1000000.0 ); +printf (" - Dropped %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.dist.enqdrop_pkts - + prev_app_stats.dist.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + +printf ("TX thread:\n" ); +printf (" - Dequeued: %5.2f\n" , + (app_stats.tx.dequeue_pkts - + prev_app_stats.tx.dequeue_pkts)/1000000.0 ); +for (i =0 ; i <rte_eth_dev_count (); i++) { +printf ("Port %u Pktsout: %5.2f\n" , + i, (app_stats.port_tx_pkts[i] - + prev_app_stats.port_tx_pkts[i])/1000000.0 ); + prev_app_stats.port_tx_pkts[i] = app_stats.port_tx_pkts[i]; + } +printf (" - Transmitted: %5.2f\n" , + (app_stats.tx.tx_pkts - + prev_app_stats.tx.tx_pkts)/1000000.0 ); +printf (" - Dropped: %s%5.2f%s\n" ,ANSI_COLOR_RED , + (app_stats.tx.enqdrop_pkts - + prev_app_stats.tx.enqdrop_pkts)/1000000.0 , +ANSI_COLOR_RESET ); + + prev_app_stats.rx.rx_pkts = app_stats.rx.rx_pkts; + prev_app_stats.rx.returned_pkts = app_stats.rx.returned_pkts; + prev_app_stats.rx.enqueued_pkts = app_stats.rx.enqueued_pkts; + prev_app_stats.rx.enqdrop_pkts = app_stats.rx.enqdrop_pkts; + prev_app_stats.dist.in_pkts = app_stats.dist.in_pkts; + prev_app_stats.dist.ret_pkts = app_stats.dist.ret_pkts; + prev_app_stats.dist.sent_pkts = app_stats.dist.sent_pkts; + prev_app_stats.dist.enqdrop_pkts = app_stats.dist.enqdrop_pkts; + prev_app_stats.tx.dequeue_pkts = app_stats.tx.dequeue_pkts; + prev_app_stats.tx.tx_pkts = app_stats.tx.tx_pkts; + prev_app_stats.tx.enqdrop_pkts = app_stats.tx.enqdrop_pkts; + +for (i =0 ; i < num_workers; i++) { +printf ("Worker %02u Pkts: %5.2f. Bursts(1-8): " , i, + (app_stats.worker_pkts[i] - + prev_app_stats.worker_pkts[i])/1000000.0 ); +for (j =0 ; j <8 ; j++) { +printf ("%" PRIu64" " , app_stats.worker_bursts[i][j]); + app_stats.worker_bursts[i][j] =0 ; + } +printf ("\n" ); + prev_app_stats.worker_pkts[i] = app_stats.worker_pkts[i]; } }@@ -515,6 +612,7 @@ main(int argc, char *argv[])unsigned nb_ports;uint8_t portid;uint8_t nb_ports_available; +uint64_t t, freq;/* catch ctrl-c so we can print on exit */ signal (SIGINT , int_handler);@@ -610,6 +708,15 @@ main(int argc, char *argv[])if (lcore_rx (&p) !=0 )return -1 ;
examples/distributor/main.c main(int argc, char *argv[]) · line 719
Quoted 10 lines
examples/distributor/main.c +9
-0+ freq =rte_get_timer_hz (); + t =rte_rdtsc () + freq; +while (!quit_signal_dist) { +if (t <rte_rdtsc ()) { +print_stats (); + t =rte_rdtsc () + freq; + } + } +
You can probably put in a usleep or nanosleep inot the while loop above. No need to burn an entire core by polling the tsc.
/Bruce
Quoted 2 lines
2.7.4
Re: [PATCH v9 12/18] examples/distributor: allow for extra stats
Quoted 13 lines · Bruce Richardson
examples/distributor/main.c main(int argc, char *argv[]) · line 719
Quoted 9 lines · David Hunt
examples/distributor/main.c +9
-0+ freq =rte_get_timer_hz (); + t =rte_rdtsc () + freq; +while (!quit_signal_dist) { +if (t <rte_rdtsc ()) { +print_stats (); + t =rte_rdtsc () + freq; + } + } +You can probably put in a usleep or nanosleep inot the while loop above. No need to burn an entire core by polling the tsc.
Quoted 1 line
/Bruce
Done in the next version.
Dave.
PATCH v9 13/18 sample: distributor: wait for ports to come up
In reply to David HuntOn some machines, ports take several seconds to come up. This patch causes the app to wait.
--- examples/distributor/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
examples/distributor/main.c +4 -3
@@ -1,8 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. -* All rights reserved. +* Copyright(c) 2010-2017 Intel Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions
@@ -62,6 +61,7 @@ static uint32_t enabled_port_mask;volatile uint8_t quit_signal;volatile uint8_t quit_signal_rx;volatile uint8_t quit_signal_dist; +volatile uint8_t quit_signal_work; static volatile struct app_stats { struct {
@@ -165,7 +165,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct rte_eth_link link;rte_eth_link_get_nowait (port, &link); -if (!link.link_status) { +while (!link.link_status) { +printf ("Waiting for Link up on port %" PRIu8"\n" , port);sleep (1 );rte_eth_link_get_nowait (port, &link); }
Signature · 1 line
2.7.4
Re: [PATCH v9 13/18] sample: distributor: wait for ports to come up
Quoted 4 lines · David Hunt
On some machines, ports take several seconds to come up. This patch causes the app to wait.
Signed-off-by David Hunt <[email protected]>
Title prefix should match other patches.
/Bruce
PATCH v9 14/18 examples/distributor: give distributor a core
In reply to David Hunt--- examples/distributor/main.c | 181 ++++++++++++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 58 deletions(-)
examples/distributor/main.c +123 -58
@@ -49,6 +49,8 @@#define NUM_MBUFS ((64*1024)-1)#define MBUF_CACHE_SIZE 250#define BURST_SIZE 32 +#define SCHED_RX_RING_SZ 8192 +#define SCHED_TX_RING_SZ 65536#define RTE_RING_SZ 1024#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1
@@ -193,37 +195,14 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)struct lcore_params {unsigned worker_id;struct rte_distributor *d; -struct rte_ring *r; +struct rte_ring *rx_dist_ring; +struct rte_ring *dist_tx_ring;struct rte_mempool *mem_pool; };static int -quit_workers (struct rte_distributor *d,struct rte_mempool *p) -{ -const unsigned num_workers =rte_lcore_count () -2 ; -unsigned i; -struct rte_mbuf *bufs[num_workers]; - -if (rte_mempool_get_bulk (p, (void *)bufs, num_workers) !=0 ) { -printf ("line %d: Error getting mbufs from pool\n" , __LINE__); -return -1 ; - } - -for (i =0 ; i < num_workers; i++) - bufs[i]->hash.rss = i <<1 ; - -rte_distributor_process (d, bufs, num_workers); -rte_mempool_put_bulk (p, (void *)bufs, num_workers); - -return 0 ; -} - -static int lcore_rx (struct lcore_params *p) { -struct rte_distributor *d = p->d; -struct rte_mempool *mem_pool = p->mem_pool; -struct rte_ring *r = p->r;const uint8_t nb_ports =rte_eth_dev_count ();const int socket_id =rte_socket_id ();uint8_t port;
@@ -260,9 +239,15 @@ lcore_rx(struct lcore_params *p) } app_stats.rx.rx_pkts += nb_rx; -rte_distributor_process (d, bufs, nb_rx); -const uint16_t nb_ret =rte_distributor_returned_pkts (d, - bufs,BURST_SIZE *2 ); +/* +* You can run the distributor on the rx core with this code. Returned +* packets are then send straight to the tx core. +*/ +#if 0 +rte_distributor_process (d, bufs, nb_rx); +const uint16_t nb_ret = rte_distributor_returned_pktsd, + bufs, BURST_SIZE*2); + app_stats.rx.returned_pkts += nb_ret;if (unlikely (nb_ret ==0 )) {if (++port == nb_ports)
@@ -270,7 +255,22 @@ lcore_rx(struct lcore_params *p)continue ; } -uint16_t sent =rte_ring_enqueue_burst (r, (void *)bufs, nb_ret); +struct rte_ring *tx_ring = p->dist_tx_ring; +uint16_t sent =rte_ring_enqueue_burst (tx_ring, + (void *)bufs, nb_ret); +#else +uint16_t nb_ret = nb_rx; +/* +* Swap the following two lines if you want the rx traffic +* to go directly to tx, no distribution. +*/ +struct rte_ring *out_ring = p->rx_dist_ring; +/* struct rte_ring *out_ring = p->dist_tx_ring; */ + +uint16_t sent =rte_ring_enqueue_burst (out_ring, + (void *)bufs, nb_ret); +#endif + app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { RTE_LOG_DP(DEBUG, DISTRAPP,
@@ -281,20 +281,9 @@ lcore_rx(struct lcore_params *p)if (++port == nb_ports) port =0 ; } -rte_distributor_process (d,NULL ,0 ); -/* flush distributor to bring to known state */ -rte_distributor_flush (d);/* set worker & tx threads quit flag */ +printf ("\nCore %u exiting rx task.\n" ,rte_lcore_id ()); quit_signal =1 ; -/* -* worker threads may hang in get packet as -* distributor process is not running, just make sure workers -* get packets till quit_signal is actually been -* received and they gracefully shutdown -*/ -if (quit_workers (d, mem_pool) !=0 ) -return -1 ; -/* rx thread should quit at last */ return 0 ; }
@@ -331,6 +320,58 @@ flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports) } } + + +static int +lcore_distributor (struct lcore_params *p) +{ +struct rte_ring *in_r = p->rx_dist_ring; +struct rte_ring *out_r = p->dist_tx_ring; +struct rte_mbuf *bufs[BURST_SIZE *4 ]; +struct rte_distributor *d = p->d; + +printf ("\nCore %u acting as distributor core.\n" ,rte_lcore_id ()); +while (!quit_signal_dist) { +const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, + (void *)bufs,BURST_SIZE *1 ); +if (nb_rx) { + app_stats.dist.in_pkts += nb_rx; + +/* Distribute the packets */ +rte_distributor_process (d, bufs, nb_rx); +/* Handle Returns */ +const uint16_t nb_ret = +rte_distributor_returned_pkts (d, + bufs,BURST_SIZE *2 ); + +if (unlikely (nb_ret ==0 )) +continue ; + app_stats.dist.ret_pkts += nb_ret; + +uint16_t sent =rte_ring_enqueue_burst (out_r, + (void *)bufs, nb_ret); + app_stats.dist.sent_pkts += sent; +if (unlikely (sent < nb_ret)) { + app_stats.dist.enqdrop_pkts += nb_ret - sent; +RTE_LOG (DEBUG ,DISTRAPP , +"%s:Packet loss due to full out ring\n" , + __func__); +while (sent < nb_ret) +rte_pktmbuf_free (bufs[sent++]); + } + } + } +printf ("\nCore %u exiting distributor task.\n" ,rte_lcore_id ()); + quit_signal_work =1 ; + +rte_distributor_flush (d); +/* Unblock any returns so workers can exit */ +rte_distributor_clear_returns (d); + quit_signal_rx =1 ; +return 0 ; +} + +static int lcore_tx (struct rte_ring *in_r) {
@@ -403,7 +444,7 @@ int_handler(int sig_num) {printf ("Exiting on signal %d\n" , sig_num);/* set quit flag for rx thread to exit */ - quit_signal_rx =1 ; + quit_signal_dist =1 ; } static void
@@ -517,7 +558,7 @@ lcore_worker(struct lcore_params *p) buf[i] =NULL ;printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ()); -while (!quit_signal) { +while (!quit_signal_work) { num =rte_distributor_get_pkt (d, id, buf, buf, num);/* Do a little bit of work for each packet */ for (i =0 ; i < num; i++) {
@@ -608,7 +649,8 @@ main(int argc, char *argv[]) {struct rte_mempool *mbuf_pool;struct rte_distributor *d; -struct rte_ring *output_ring; +struct rte_ring *dist_tx_ring; +struct rte_ring *rx_dist_ring;unsigned lcore_id, worker_id =0 ;unsigned nb_ports;uint8_t portid;
@@ -630,10 +672,11 @@ main(int argc, char *argv[])if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid distributor parameters\n" ); -if (rte_lcore_count () <3 ) +if (rte_lcore_count () <4 )rte_exit (EXIT_FAILURE ,"Error, This application needs at " -"least 3 logical cores to run:\n" -"1 lcore for packet RX and distribution\n" +"least 4 logical cores to run:\n" +"1 lcore for packet RX\n" +"1 lcore for distribution\n" "1 lcore for packet TX\n" "and at least 1 lcore for worker threads\n" );
@@ -673,30 +716,52 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -2 , +rte_lcore_count () -3 ,RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );/* -* scheduler ring is read only by the transmitter core, but written to -* by multiple threads +* scheduler ring is read by the transmitter core, and written to +* by scheduler core */ - output_ring =rte_ring_create ("Output_ring" ,RTE_RING_SZ , -rte_socket_id (),RING_F_SC_DEQ ); -if (output_ring ==NULL ) + dist_tx_ring =rte_ring_create ("Output_ring" ,SCHED_TX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (dist_tx_ring ==NULL ) +rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" ); + + rx_dist_ring =rte_ring_create ("Input_ring" ,SCHED_RX_RING_SZ , +rte_socket_id (),RING_F_SC_DEQ |RING_F_SP_ENQ ); +if (rx_dist_ring ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create output ring\n" );RTE_LCORE_FOREACH_SLAVE (lcore_id) { -if (worker_id ==rte_lcore_count () -2 ) +if (worker_id ==rte_lcore_count () -3 ) { +printf ("Starting distributor on lcore_id %d\n" , + lcore_id); +/* distributor core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, + rx_dist_ring, dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ( + (lcore_function_t *)lcore_distributor, + p, lcore_id); + }else if (worker_id ==rte_lcore_count () -4 ) { +printf ("Starting tx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* tx core */ rte_eal_remote_launch ((lcore_function_t *)lcore_tx, - output_ring, lcore_id); -else { + dist_tx_ring, lcore_id); + }else {struct lcore_params *p =rte_malloc (NULL ,sizeof (*p),0 );if (!p)rte_panic ("malloc failure\n" ); - *p = (struct lcore_params ){worker_id, d, output_ring, mbuf_pool}; + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool};rte_eal_remote_launch ((lcore_function_t *)lcore_worker, p, lcore_id);
@@ -704,7 +769,7 @@ main(int argc, char *argv[]) worker_id++; }/* call lcore_main on master core only */ -struct lcore_params p = {0 , d, output_ring, mbuf_pool}; +struct lcore_params p = {0 , d, rx_dist_ring, dist_tx_ring, mbuf_pool};if (lcore_rx (&p) !=0 )return -1 ;
Signature · 1 line
2.7.4
Re: [PATCH v9 14/18] examples/distributor: give distributor a core
Quoted 2 lines · David Hunt
Signed-off-by David Hunt <[email protected]>---
Title could do with some rewording - e.g. "make distributor API calls on dedicated core"
This also requires an explanation as to why the change is being made. Does it not also need an update to the sample app guide about how the app works?
/Bruce
Re: [PATCH v9 14/18] examples/distributor: give distributor a core
Quoted 11 lines · Bruce Richardson
Quoted 2 lines · David Hunt
Signed-off-by David Hunt <[email protected]>---
Title could do with some rewording - e.g. "make distributor API calls on dedicated core"
This also requires an explanation as to why the change is being made. Does it not also need an update to the sample app guide about how the app works?
/Bruce
Yes, sure. And I'll add some more info into the dist_app.rst file. Rgds,
Dave.
PATCH v9 15/18 examples/distributor: limit number of Tx rings
In reply to David Hunt--- examples/distributor/main.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
examples/distributor/main.c +14 -9
@@ -44,14 +44,15 @@#include <rte_prefetch.h> #include <rte_distributor.h> -#define RX_RING_SIZE 256 -#define TX_RING_SIZE 512 +#define RX_QUEUE_SIZE 512 +#define TX_QUEUE_SIZE 512 +#define NUM_MBUFS ((64*1024)-1) -#define MBUF_CACHE_SIZE 250 -#define BURST_SIZE 32 +#define MBUF_CACHE_SIZE 128 +#define BURST_SIZE 64#define SCHED_RX_RING_SZ 8192#define SCHED_TX_RING_SZ 65536 -#define RTE_RING_SZ 1024 +#define BURST_SIZE_TX 32#define RTE_LOGTYPE_DISTRAPP RTE_LOGTYPE_USER1
@@ -134,9 +135,13 @@ static inline int port_init(uint8_t port, struct rte_mempool *mbuf_pool) { struct rte_eth_conf port_conf = port_conf_default; -const uint16_t rxRings =1 , txRings =rte_lcore_count () -1 ; -int retval; +const uint16_t rxRings =1 ; +uint16_t txRings =rte_lcore_count () -1 ;uint16_t q; +int retval; + +if (txRings >RTE_MAX_ETHPORTS ) + txRings =RTE_MAX_ETHPORTS ;if (port >=rte_eth_dev_count ())return -1 ;
@@ -146,7 +151,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)return retval;for (q =0 ; q < rxRings; q++) { - retval =rte_eth_rx_queue_setup (port, q,RX_RING_SIZE , + retval =rte_eth_rx_queue_setup (port, q,RX_QUEUE_SIZE ,rte_eth_dev_socket_id (port),NULL , mbuf_pool);if (retval <0 )
@@ -154,7 +159,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool) }for (q =0 ; q < txRings; q++) { - retval =rte_eth_tx_queue_setup (port, q,TX_RING_SIZE , + retval =rte_eth_tx_queue_setup (port, q,TX_QUEUE_SIZE ,rte_eth_dev_socket_id (port),NULL );if (retval <0 )
Signature · 1 line
2.7.4
Re: [PATCH v9 15/18] examples/distributor: limit number of Tx rings
Quoted 2 lines · David Hunt
Signed-off-by David Hunt <[email protected]>---
Please explain reason for change.
/Bruce
Re: [PATCH v9 15/18] examples/distributor: limit number of Tx rings
Quoted 6 lines · Bruce Richardson
Quoted 2 lines · David Hunt
Signed-off-by David Hunt <[email protected]>---
Please explain reason for change.
/Bruce
I've re-worked this change, as it's mostly do to with performance, resulting in about 10% gain. The number of Tx rings has been removed, as it was part of an investigation for high core count operation, and is not relevant.
Rgds,
Dave.
PATCH v9 16/18 examples/distributor: give Rx thread a core
In reply to David HuntThis so that with the increased amount of stats we are counting, we don't interfere with the rx core.
--- examples/distributor/main.c | 50 ++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 16 deletions(-)
examples/distributor/main.c +34 -16
@@ -278,6 +278,7 @@ lcore_rx(struct lcore_params *p) app_stats.rx.enqueued_pkts += sent;if (unlikely (sent < nb_ret)) { + app_stats.rx.enqdrop_pkts += nb_ret - sent;RTE_LOG_DP (DEBUG ,DISTRAPP ,"%s:Packet loss due to full ring\n" , __func__);while (sent < nb_ret)
@@ -295,13 +296,12 @@ lcore_rx(struct lcore_params *p)static inline void flush_one_port (struct output_buffer *outbuf,uint8_t outp) { -unsigned nb_tx =rte_eth_tx_burst (outp,0 , outbuf->mbufs, - outbuf->count); - app_stats.tx.tx_pkts += nb_tx; +unsigned int nb_tx =rte_eth_tx_burst (outp,0 , + outbuf->mbufs, outbuf->count); + app_stats.tx.tx_pkts += outbuf->count;if (unlikely (nb_tx < outbuf->count)) { -RTE_LOG_DP (DEBUG ,DISTRAPP , -"%s:Packet loss with tx_burst\n" , __func__); + app_stats.tx.enqdrop_pkts += outbuf->count - nb_tx;do {rte_pktmbuf_free (outbuf->mbufs[nb_tx]); }while (++nb_tx < outbuf->count);
@@ -313,6 +313,7 @@ static inline void flush_all_ports(struct output_buffer *tx_buffers, uint8_t nb_ports) { uint8_t outp; +for (outp =0 ; outp < nb_ports; outp++) {/* skip ports that are not enabled */ if ((enabled_port_mask & (1 << outp)) ==0 )
@@ -405,9 +406,9 @@ lcore_tx(struct rte_ring *in_r)if ((enabled_port_mask & (1 << port)) ==0 )continue ; -struct rte_mbuf *bufs[BURST_SIZE ]; +struct rte_mbuf *bufs[BURST_SIZE_TX ];const uint16_t nb_rx =rte_ring_dequeue_burst (in_r, - (void *)bufs,BURST_SIZE ); + (void *)bufs,BURST_SIZE_TX ); app_stats.tx.dequeue_pkts += nb_rx;/* if we get no traffic, flush anything we have */
@@ -436,11 +437,12 @@ lcore_tx(struct rte_ring *in_r) outbuf = &tx_buffers[outp]; outbuf->mbufs[outbuf->count++] = bufs[i]; -if (outbuf->count ==BURST_SIZE ) +if (outbuf->count ==BURST_SIZE_TX )flush_one_port (outbuf, outp); } } } +printf ("\nCore %u exiting tx task.\n" ,rte_lcore_id ());return 0 ; }
@@ -562,6 +564,8 @@ lcore_worker(struct lcore_params *p)for (i =0 ; i <8 ; i++) buf[i] =NULL ; + app_stats.worker_pkts[p->worker_id] =1 ; +printf ("\nCore %u acting as worker core.\n" ,rte_lcore_id ());while (!quit_signal_work) { num =rte_distributor_get_pkt (d, id, buf, buf, num);
@@ -573,6 +577,10 @@ lcore_worker(struct lcore_params *p)rte_pause (); buf[i]->port ^= xor_val; } + + app_stats.worker_pkts[p->worker_id] += num; +if (num >0 ) + app_stats.worker_bursts[p->worker_id][num-1 ]++; }return 0 ; }
@@ -677,9 +685,10 @@ main(int argc, char *argv[])if (ret <0 )rte_exit (EXIT_FAILURE ,"Invalid distributor parameters\n" ); -if (rte_lcore_count () <4 ) +if (rte_lcore_count () <5 )rte_exit (EXIT_FAILURE ,"Error, This application needs at " -"least 4 logical cores to run:\n" +"least 5 logical cores to run:\n" +"1 lcore for stats (can be core 0)\n" "1 lcore for packet RX\n" "1 lcore for distribution\n" "1 lcore for packet TX\n"
@@ -721,7 +730,7 @@ main(int argc, char *argv[]) } d =rte_distributor_create ("PKT_DIST" ,rte_socket_id (), -rte_lcore_count () -3 , +rte_lcore_count () -4 ,RTE_DIST_ALG_BURST );if (d ==NULL )rte_exit (EXIT_FAILURE ,"Cannot create distributor\n" );
@@ -760,7 +769,21 @@ main(int argc, char *argv[])/* tx core */ rte_eal_remote_launch ((lcore_function_t *)lcore_tx, dist_tx_ring, lcore_id); + }else if (worker_id ==rte_lcore_count () -2 ) { +printf ("Starting rx on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id); +/* rx core */ +struct lcore_params *p = +rte_malloc (NULL ,sizeof (*p),0 ); +if (!p) +rte_panic ("malloc failure\n" ); + *p = (struct lcore_params ){worker_id, d, rx_dist_ring, + dist_tx_ring, mbuf_pool}; +rte_eal_remote_launch ((lcore_function_t *)lcore_rx, + p, lcore_id); }else { +printf ("Starting worker on worker_id %d, lcore_id %d\n" , + worker_id, lcore_id);struct lcore_params *p =rte_malloc (NULL ,sizeof (*p),0 );if (!p)
@@ -773,11 +796,6 @@ main(int argc, char *argv[]) } worker_id++; } -/* call lcore_main on master core only */ -struct lcore_params p = {0 , d, rx_dist_ring, dist_tx_ring, mbuf_pool}; - -if (lcore_rx (&p) !=0 ) -return -1 ; freq =rte_get_timer_hz (); t =rte_rdtsc () + freq;
Signature · 1 line
2.7.4
Re: [PATCH v9 16/18] examples/distributor: give Rx thread a core
Quoted 3 lines · David Hunt
This so that with the increased amount of stats we are counting, we don't interfere with the rx core.
Where are the stats being counted in the current code and how would they interfere?
/Bruce
Re: [PATCH v9 16/18] examples/distributor: give Rx thread a core
Quoted 8 lines · Bruce Richardson
Quoted 3 lines · David Hunt
This so that with the increased amount of stats we are counting, we don't interfere with the rx core.
Where are the stats being counted in the current code and how would they interfere?
/Bruce
Previous version of the distributor example did not print out several lines of statistics every second, which the new version does. I felt that it it would be better to separate this off to it's own core, so that the rx core performance would not be impacted.
I'll add an extra comment in the commit message.
Regards,
Dave.
PATCH v9 17/18 doc: distributor library changes for new burst API
In reply to David Hunt--- doc/guides/prog_guide/packet_distrib_lib.rst | 3 +++ 1 file changed, 3 insertions(+)
doc/guides/prog_guide/packet_distrib_lib.rst +3 -0
@@ -42,6 +42,9 @@ The model of operation is shown in the diagram below. Packet Distributor mode of operation +There are two modes of operation of the API in the distributor Library, one which sends one packet at a time +to workers using 32-bits for flow_id, and an optiomised mode which sends bursts of up to 8 packets at a time +to workers, using 15 bits of flow_id. The mode is selected by the type field in the ``rte_distributor_create function``. Distributor Core Operation --------------------------
Signature · 1 line
2.7.4
Re: [PATCH v9 17/18] doc: distributor library changes for new burst API
Quoted 11 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of David Hunt
Sent: Monday, March 6, 2017 9:11 AM
To: [email protected]
Cc: Richardson, Bruce <[email protected]>; Hunt, David <[email protected]>
Subject: [dpdk-dev] [PATCH v9 17/18] doc: distributor library changes for new burst API
Quoted 1 line
Signed-off-by David Hunt <[email protected]>
PATCH v9 18/18 maintainers: add to distributor lib maintainers
In reply to David Hunt--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -501,6 +501,7 @@ F: doc/guides/sample_app_ug/ip_reassembly.rst Distributor M: Bruce Richardson <[email protected]> +M: David Hunt <[email protected]> F: lib/librte_distributor/ F: doc/guides/prog_guide/packet_distrib_lib.rst F: test/test/test_distributor*
Signature · 1 line
2.7.4
Quoted 14 lines · David Hunt
This patch aims to improve the throughput of the distributor library.
It uses a similar handshake mechanism to the previous version of the library, in that bits are used to indicate when packets are ready to be sent to a worker and ready to be returned from a worker. One main difference is that instead of sending one packet in a cache line, it makes use of the 7 free spaces in the same cache line in order to send up to 8 packets at a time to/from a worker.
The flow matching algorithm has had significant re-work, and now keeps an array of inflight flows and an array of backlog flows, and matches incoming flows to the inflight/backlog flows of all workers so that flow pinning to workers can be maintained.
Quoted 9 lines
The Flow Match algorithm has both scalar and a vector versions, and a function pointer is used to select the post appropriate function at run time, depending on the presence of the SSE2 cpu flag. On non-x86 platforms, the the scalar match function is selected, which should still gives a good boost in performance over the non-burst API.
v9 changes:
* fixed symbol versioning so it will compile on CentOS and RedHat
I've flagged a number of things that could do with being cleaned up in the patchset. However, the idea itself of adding a new burst-mode to improve distributor performance - and using vector matching to further boost it - is a good improvement. Therefore
PATCH v8 2/18 lib: create private header file
In reply to David HuntWe'll be adding internal implementation definitions in here that are common to both burst and legacy APIs.
--- lib/librte_distributor/rte_distributor_private.h | 136 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_v20.c | 72 +----------- 2 files changed, 137 insertions(+), 71 deletions(-) create mode 100644 lib/librte_distributor/rte_distributor_private.h
lib/librte_distributor/rte_distributor_private.h new file +136 -0
@@ -0,0 +1,136 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 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 +* 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. +*/ + +#ifndef _RTE_DIST_PRIV_H_ +#define _RTE_DIST_PRIV_H_ + +/** +* @file +* RTE distributor +* +* The distributor is a component which is designed to pass packets +* one-at-a-time to workers, with dynamic load balancing. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#define NO_FLAGS 0 +#define RTE_DISTRIB_PREFIX "DT_" + +/* +* We will use the bottom four bits of pointer for flags, shifting out +* the top four bits to make room (since a 64-bit pointer actually only uses +* 48 bits). An arithmetic-right-shift will then appropriately restore the +* original pointer value with proper sign extension into the top bits. +*/ +#define RTE_DISTRIB_FLAG_BITS 4 +#define RTE_DISTRIB_FLAGS_MASK (0x0F) +#define RTE_DISTRIB_NO_BUF 0/**< empty flags: no buffer requested */ +#define RTE_DISTRIB_GET_BUF (1)/**< worker requests a buffer, returns old */ +#define RTE_DISTRIB_RETURN_BUF (2)/**< worker returns a buffer, no request */ +#define RTE_DISTRIB_VALID_BUF (4)/**< set if bufptr contains ptr */ + +#define RTE_DISTRIB_BACKLOG_SIZE 8 +#define RTE_DISTRIB_BACKLOG_MASK (RTE_DISTRIB_BACKLOG_SIZE - 1) + +#define RTE_DISTRIB_MAX_RETURNS 128 +#define RTE_DISTRIB_RETURNS_MASK (RTE_DISTRIB_MAX_RETURNS - 1) + +/** +* Maximum number of workers allowed. +* Be aware of increasing the limit, becaus it is limited by how we track +* in-flight tags. See in_flight_bitmask and rte_distributor_process +*/ +#define RTE_DISTRIB_MAX_WORKERS 64 + +#define RTE_DISTRIBUTOR_NAMESIZE 32/**< Length of name for instance */ + +/** +* Buffer structure used to pass the pointer data between cores. This is cache +* line aligned, but to improve performance and prevent adjacent cache-line +* prefetches of buffers for other workers, e.g. when worker 1's buffer is on +* the next cache line to worker 0, we pad this out to three cache lines. +* Only 64-bits of the memory is actually used though. +*/ +union rte_distributor_buffer { +volatile int64_t bufptr64; +char pad[RTE_CACHE_LINE_SIZE *3 ]; +} __rte_cache_aligned; + +/** +* Number of packets to deal with in bursts. Needs to be 8 so as to +* fit in one cache line. +*/ +#define RTE_DIST_BURST_SIZE (sizeof(rte_xmm_t) / sizeof(uint16_t)) + +struct rte_distributor_backlog { +unsigned int start; +unsigned int count; + int64_t pkts[RTE_DIST_BURST_SIZE] __rte_cache_aligned; +uint16_t *tags;/* will point to second cacheline of inflights */ +} __rte_cache_aligned; + + +struct rte_distributor_returned_pkts { +unsigned int start; +unsigned int count; +struct rte_mbuf *mbufs[RTE_DISTRIB_MAX_RETURNS ]; +}; + +struct rte_distributor { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */ + +uint32_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS ]; +/**< Tracks the tag being processed per core */ +uint64_t in_flight_bitmask; +/**< on/off bits for in-flight tags. +* Note that if RTE_DISTRIB_MAX_WORKERS is larger than 64 then +* the bitmask has to expand. +*/ + +struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS ]; + +union rte_distributor_buffer bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; +}; + +#ifdef __cplusplus +} +#endif + +#endif
lib/librte_distributor/rte_distributor_v20.c +1 -71
78 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v8 3/18 lib: add new burst oriented distributor structs
In reply to David Hunt--- lib/librte_distributor/rte_distributor_private.h | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
lib/librte_distributor/rte_distributor_private.h +56 -0
@@ -129,6 +129,62 @@ struct rte_distributor {struct rte_distributor_returned_pkts returns; }; +/* All different signature compare functions */ +enum rte_distributor_match_function { +RTE_DIST_MATCH_SCALAR =0 , +RTE_DIST_MATCH_VECTOR , +RTE_DIST_NUM_MATCH_FNS +}; + +/** +* Buffer structure used to pass the pointer data between cores. This is cache +* line aligned, but to improve performance and prevent adjacent cache-line +* prefetches of buffers for other workers, e.g. when worker 1's buffer is on +* the next cache line to worker 0, we pad this out to two cache lines. +* We can pass up to 8 mbufs at a time in one cacheline. +* There is a separate cacheline for returns in the burst API. +*/ +struct rte_distributor_buffer_v1705 { + volatile int64_t bufptr64[RTE_DIST_BURST_SIZE] +__rte_cache_aligned ;/* <= outgoing to worker */ + + int64_t pad1 __rte_cache_aligned; /* <= one cache line */ + + volatile int64_t retptr64[RTE_DIST_BURST_SIZE] +__rte_cache_aligned ;/* <= incoming from worker */ + + int64_t pad2 __rte_cache_aligned; /* <= one cache line */ + + int count __rte_cache_aligned; /* <= number of current mbufs */ +}; + +struct rte_distributor_v1705 { +TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ + +char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ +unsigned int num_workers;/**< Number of workers polling */ +unsigned int alg_type;/**< Number of alg types */ + +/**> +* First cache line in the this array are the tags inflight +* on the worker core. Second cache line are the backlog +* that are going to go to the worker core. +*/ + uint16_t in_flight_tags[RTE_DISTRIB_MAX_WORKERS][RTE_DIST_BURST_SIZE*2] +__rte_cache_aligned ; + + struct rte_distributor_backlog backlog[RTE_DISTRIB_MAX_WORKERS] +__rte_cache_aligned ; + +struct rte_distributor_buffer_v1705 bufs[RTE_DISTRIB_MAX_WORKERS ]; + +struct rte_distributor_returned_pkts returns; + +enum rte_distributor_match_function dist_match_fn; + +struct rte_distributor *d_v20; +}; + #ifdef __cplusplus }#endif
Signature · 1 line
2.7.4
PATCH v8 4/18 lib: add new distributor code
In reply to David HuntThis patch includes public header file which will be used once we add in the symbol versioning for v20 and v1705 APIs.
Also includes v1702 header file, and code for new burst-capable distributor library. This will be re-named as rte_distributor.h later in the patch-set
The new distributor code contains a very similar API to the legacy code, but now sends bursts of up to 8 mbufs to each worker. Flow ID's are reduced to 15 bits for an optimal flow matching algorithm.
--- lib/librte_distributor/Makefile | 1 + lib/librte_distributor/rte_distributor.c | 628 +++++++++++++++++++++++ lib/librte_distributor/rte_distributor_private.h | 7 +- lib/librte_distributor/rte_distributor_v1705.h | 269 ++++++++++ 4 files changed, 904 insertions(+), 1 deletion(-) create mode 100644 lib/librte_distributor/rte_distributor.c create mode 100644 lib/librte_distributor/rte_distributor_v1705.h
lib/librte_distributor/Makefile +1 -0
@@ -43,6 +43,7 @@ LIBABIVER := 1 # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) := rte_distributor_v20.c +SRCS-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR) += rte_distributor.c # install this header file SYMLINK-$(CONFIG_RTE_LIBRTE_DISTRIBUTOR)-include := rte_distributor.h
lib/librte_distributor/rte_distributor.c new file +628 -0
628 lines not on this page · raw message
lib/librte_distributor/rte_distributor_private.h +6 -1
@@ -159,7 +159,7 @@ struct rte_distributor_buffer_v1705 { };struct rte_distributor_v1705 { -TAILQ_ENTRY (rte_distributor) next;/**< Next in list. */ +TAILQ_ENTRY (rte_distributor_v1705) next;/**< Next in list. */ char name[RTE_DISTRIBUTOR_NAMESIZE ];/**< Name of the ring. */ unsigned int num_workers;/**< Number of workers polling */
@@ -185,6 +185,11 @@ struct rte_distributor_v1705 {struct rte_distributor *d_v20; }; +void +find_match_scalar (struct rte_distributor_v1705 *d, +uint16_t *data_ptr, +uint16_t *output_ptr); + #ifdef __cplusplus }#endif
lib/librte_distributor/rte_distributor_v1705.h new file +269 -0
269 lines not on this page · raw message
Signature · 1 line
2.7.4