diff options
author | 2016-07-06 09:22:35 +0200 | |
---|---|---|
committer | 2016-07-06 16:15:13 +0200 | |
commit | 809f08006d56e7ba4ce190b0a63d44acf62d8044 (patch) | |
tree | d93fbe3244ee0cff16a6af830c7efb15c26e5ef4 /examples/performance-thread | |
parent | b8ce7c38b99df118002fb460e680fabf16944f6c (diff) |
Imported Upstream version 16.07-rc1
Change-Id: If3f757dc95532706b04053286c6b54492169f1a3
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Diffstat (limited to 'examples/performance-thread')
-rw-r--r-- | examples/performance-thread/common/lthread.c | 2 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_int.h | 12 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_mutex.c | 3 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_pool.h | 4 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_queue.h | 2 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_sched.c | 2 | ||||
-rw-r--r-- | examples/performance-thread/common/lthread_tls.c | 4 | ||||
-rw-r--r-- | examples/performance-thread/l3fwd-thread/main.c | 55 |
8 files changed, 36 insertions, 48 deletions
diff --git a/examples/performance-thread/common/lthread.c b/examples/performance-thread/common/lthread.c index 8fbff737..062275a4 100644 --- a/examples/performance-thread/common/lthread.c +++ b/examples/performance-thread/common/lthread.c @@ -143,7 +143,7 @@ struct lthread_stack *_stack_alloc(void) struct lthread_stack *s; s = _lthread_objcache_alloc((THIS_SCHED)->stack_cache); - LTHREAD_ASSERT(s != NULL); + RTE_ASSERT(s != NULL); s->root_sched = THIS_SCHED; s->stack_size = LTHREAD_MAX_STACK_SIZE; diff --git a/examples/performance-thread/common/lthread_int.h b/examples/performance-thread/common/lthread_int.h index c8357f4a..b858b55e 100644 --- a/examples/performance-thread/common/lthread_int.h +++ b/examples/performance-thread/common/lthread_int.h @@ -197,16 +197,4 @@ struct lthread { uint64_t diag_ref; /* ref to user diag data */ } __rte_cache_aligned; -/* - * Assert - */ -#if LTHREAD_DIAG -#define LTHREAD_ASSERT(expr) do { \ - if (!(expr)) \ - rte_panic("line%d\tassert \"" #expr "\" failed\n", __LINE__);\ -} while (0) -#else -#define LTHREAD_ASSERT(expr) do {} while (0) -#endif - #endif /* LTHREAD_INT_H */ diff --git a/examples/performance-thread/common/lthread_mutex.c b/examples/performance-thread/common/lthread_mutex.c index af8b82d2..c1bc6271 100644 --- a/examples/performance-thread/common/lthread_mutex.c +++ b/examples/performance-thread/common/lthread_mutex.c @@ -170,7 +170,6 @@ int lthread_mutex_lock(struct lthread_mutex *m) _suspend(); /* resumed, must loop and compete for the lock again */ } - LTHREAD_ASSERT(0); return 0; } @@ -231,7 +230,7 @@ int lthread_mutex_unlock(struct lthread_mutex *m) if (unblocked != NULL) { rte_atomic64_dec(&m->count); DIAG_EVENT(m, LT_DIAG_MUTEX_UNLOCKED, m, unblocked); - LTHREAD_ASSERT(unblocked->sched != NULL); + RTE_ASSERT(unblocked->sched != NULL); _ready_queue_insert((struct lthread_sched *) unblocked->sched, unblocked); break; diff --git a/examples/performance-thread/common/lthread_pool.h b/examples/performance-thread/common/lthread_pool.h index a5f32515..27680eab 100644 --- a/examples/performance-thread/common/lthread_pool.h +++ b/examples/performance-thread/common/lthread_pool.h @@ -138,14 +138,14 @@ _qnode_pool_create(const char *name, int prealloc_size) { RTE_CACHE_LINE_SIZE, rte_socket_id()); - LTHREAD_ASSERT(p); + RTE_ASSERT(p); p->stub = rte_malloc_socket(NULL, sizeof(struct qnode), RTE_CACHE_LINE_SIZE, rte_socket_id()); - LTHREAD_ASSERT(p->stub); + RTE_ASSERT(p->stub); if (name != NULL) strncpy(p->name, name, LT_MAX_NAME_SIZE); diff --git a/examples/performance-thread/common/lthread_queue.h b/examples/performance-thread/common/lthread_queue.h index 0c395167..2c55fcec 100644 --- a/examples/performance-thread/common/lthread_queue.h +++ b/examples/performance-thread/common/lthread_queue.h @@ -129,7 +129,7 @@ _lthread_queue_create(const char *name) /* allocated stub node */ stub = _qnode_alloc(); - LTHREAD_ASSERT(stub); + RTE_ASSERT(stub); if (name != NULL) strncpy(new_queue->name, name, sizeof(new_queue->name)); diff --git a/examples/performance-thread/common/lthread_sched.c b/examples/performance-thread/common/lthread_sched.c index 7c40bc05..c64c21ff 100644 --- a/examples/performance-thread/common/lthread_sched.c +++ b/examples/performance-thread/common/lthread_sched.c @@ -268,7 +268,7 @@ struct lthread_sched *_lthread_sched_create(size_t stack_size) struct lthread_sched *new_sched; unsigned lcoreid = rte_lcore_id(); - LTHREAD_ASSERT(stack_size <= LTHREAD_MAX_STACK_SIZE); + RTE_ASSERT(stack_size <= LTHREAD_MAX_STACK_SIZE); if (stack_size == 0) stack_size = LTHREAD_MAX_STACK_SIZE; diff --git a/examples/performance-thread/common/lthread_tls.c b/examples/performance-thread/common/lthread_tls.c index 43cda4ff..6876f831 100644 --- a/examples/performance-thread/common/lthread_tls.c +++ b/examples/performance-thread/common/lthread_tls.c @@ -94,7 +94,7 @@ void _lthread_key_pool_init(void) pool = rte_ring_create(name, LTHREAD_MAX_KEYS, 0, 0); - LTHREAD_ASSERT(pool); + RTE_ASSERT(pool); int i; @@ -240,7 +240,7 @@ void _lthread_tls_alloc(struct lthread *lt) tls = _lthread_objcache_alloc((THIS_SCHED)->tls_cache); - LTHREAD_ASSERT(tls != NULL); + RTE_ASSERT(tls != NULL); tls->root_sched = (THIS_SCHED); lt->tls = tls; diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index 15c0a4de..fdc90b28 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -996,7 +996,7 @@ simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid) const void *key_array[8] = {&key[0], &key[1], &key[2], &key[3], &key[4], &key[5], &key[6], &key[7]}; - rte_hash_lookup_multi(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, + rte_hash_lookup_bulk(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, &key_array[0], 8, ret); dst_port[0] = (uint8_t) ((ret[0] < 0) ? portid : ipv4_l3fwd_out_if[ret[0]]); dst_port[1] = (uint8_t) ((ret[1] < 0) ? portid : ipv4_l3fwd_out_if[ret[1]]); @@ -1150,7 +1150,7 @@ simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint8_t portid) const void *key_array[8] = {&key[0], &key[1], &key[2], &key[3], &key[4], &key[5], &key[6], &key[7]}; - rte_hash_lookup_multi(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct, + rte_hash_lookup_bulk(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct, &key_array[0], 4, ret); dst_port[0] = (uint8_t) ((ret[0] < 0) ? portid : ipv6_l3fwd_out_if[ret[0]]); dst_port[1] = (uint8_t) ((ret[1] < 0) ? portid : ipv6_l3fwd_out_if[ret[1]]); @@ -1307,7 +1307,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid) * to BAD_PORT value. */ static inline __attribute__((always_inline)) void -rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint32_t *dp, uint32_t ptype) +rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint16_t *dp, uint32_t ptype) { uint8_t ihl; @@ -1326,7 +1326,7 @@ rfc1812_process(struct ipv4_hdr *ipv4_hdr, uint32_t *dp, uint32_t ptype) } #else -#define rfc1812_process(mb, dp) do { } while (0) +#define rfc1812_process(mb, dp, ptype) do { } while (0) #endif /* DO_RFC_1812_CHECKS */ #endif /* APP_LOOKUP_LPM && ENABLE_MULTI_BUFFER_OPTIMIZE */ @@ -1343,28 +1343,27 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid) struct ether_hdr *eth_hdr; if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) { - if (rte_lpm_lookup(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, - dst_ipv4, &next_hop_ipv4) != 0) { - next_hop_ipv4 = portid; - return next_hop_ipv4; - } + return (uint16_t) ((rte_lpm_lookup( + RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dst_ipv4, + &next_hop_ipv4) == 0) ? next_hop_ipv4 : portid); + } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) { + eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *); ipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1); - if (rte_lpm6_lookup(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct, - ipv6_hdr->dst_addr, &next_hop_ipv6) != 0) { - next_hop_ipv6 = portid; - return next_hop_ipv6; - } - } else { - next_hop_ipv4 = portid; - return next_hop_ipv4; + + return (uint16_t) ((rte_lpm6_lookup( + RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct, + ipv6_hdr->dst_addr, &next_hop_ipv6) == 0) ? next_hop_ipv6 : + portid); + } + return portid; } static inline void -process_packet(struct rte_mbuf *pkt, uint32_t *dst_port, uint8_t portid) +process_packet(struct rte_mbuf *pkt, uint16_t *dst_port, uint8_t portid) { struct ether_hdr *eth_hdr; struct ipv4_hdr *ipv4_hdr; @@ -1431,9 +1430,9 @@ processx4_step1(struct rte_mbuf *pkt[FWDSTEP], static inline void processx4_step2(__m128i dip, uint32_t ipv4_flag, - uint32_t portid, + uint8_t portid, struct rte_mbuf *pkt[FWDSTEP], - uint32_t dprt[FWDSTEP]) + uint16_t dprt[FWDSTEP]) { rte_xmm_t dst; const __m128i bswap_mask = _mm_set_epi8(12, 13, 14, 15, 8, 9, 10, 11, @@ -1445,7 +1444,11 @@ processx4_step2(__m128i dip, /* if all 4 packets are IPV4. */ if (likely(ipv4_flag)) { rte_lpm_lookupx4(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dip, - dprt, portid); + dst.u32, portid); + + /* get rid of unused upper 16 bit for each dport. */ + dst.x = _mm_packs_epi32(dst.x, dst.x); + *(uint64_t *)dprt = dst.u64[0]; } else { dst.x = dip; dprt[0] = get_dst_port(pkt[0], dst.u32[0], portid); @@ -1460,7 +1463,7 @@ processx4_step2(__m128i dip, * Perform RFC1812 checks and updates for IPV4 packets. */ static inline void -processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint32_t dst_port[FWDSTEP]) +processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP]) { __m128i te[FWDSTEP]; __m128i ve[FWDSTEP]; @@ -1658,9 +1661,9 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, __m128i dp1, __m128i dp2) /* if dest port value has changed. */ if (v != GRPMSK) { - lp = pnum->u16 + gptbl[v].idx; - lp[0] = 1; pnum->u64 = gptbl[v].pnum; + pnum->u16[FWDSTEP] = 1; + lp = pnum->u16 + gptbl[v].idx; } return lp; @@ -1679,7 +1682,7 @@ process_burst(struct rte_mbuf *pkts_burst[MAX_PKT_BURST], int nb_rx, int32_t k; uint16_t dlp; uint16_t *lp; - uint32_t dst_port[MAX_PKT_BURST]; + uint16_t dst_port[MAX_PKT_BURST]; __m128i dip[MAX_PKT_BURST / FWDSTEP]; uint32_t ipv4_flag[MAX_PKT_BURST / FWDSTEP]; uint16_t pnum[MAX_PKT_BURST + 1]; @@ -3482,8 +3485,6 @@ main(int argc, char **argv) rte_exit(EXIT_FAILURE, "init_rx_rings failed\n"); nb_ports = rte_eth_dev_count(); - if (nb_ports > RTE_MAX_ETHPORTS) - nb_ports = RTE_MAX_ETHPORTS; if (check_port_config(nb_ports) < 0) rte_exit(EXIT_FAILURE, "check_port_config failed\n"); |