X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fperformance-thread%2Fl3fwd-thread%2Fmain.c;h=46275e79a203a007c0ae6ceb113ded4b8dc1645b;hb=35b2d13fd6fdcbd191f2a30d74648faeb1186c65;hp=e78b6578cdd07c8c37ab5a40a7648d1e1fc19d8d;hpb=373149c631fec7beb768bbe418183860c90d0e10;p=dpdk.git diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index e78b6578cd..46275e79a2 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -2,8 +2,6 @@ * Copyright(c) 2010-2016 Intel Corporation */ -#define _GNU_SOURCE - #include #include #include @@ -94,15 +92,15 @@ check_ptype(int portid) static inline void parse_ptype(struct rte_mbuf *m) { - struct ether_hdr *eth_hdr; + struct rte_ether_hdr *eth_hdr; uint32_t packet_type = RTE_PTYPE_UNKNOWN; uint16_t ether_type; - eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); ether_type = eth_hdr->ether_type; - if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) + if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPv4)) packet_type |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; - else if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv6)) + else if (ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPv6)) packet_type |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; m->packet_type = packet_type; @@ -181,14 +179,14 @@ cb_parse_ptype(__rte_unused uint16_t port, __rte_unused uint16_t queue, /* * Configurable number of RX/TX ring descriptors */ -#define RTE_TEST_RX_DESC_DEFAULT 128 -#define RTE_TEST_TX_DESC_DEFAULT 128 +#define RTE_TEST_RX_DESC_DEFAULT 1024 +#define RTE_TEST_TX_DESC_DEFAULT 1024 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT; static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; /* ethernet addresses of ports */ static uint64_t dest_eth_addr[RTE_MAX_ETHPORTS]; -static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; +static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; static xmm_t val_eth[RTE_MAX_ETHPORTS]; @@ -304,11 +302,9 @@ static uint16_t nb_tx_thread_params = RTE_DIM(tx_thread_params_array_default); static struct rte_eth_conf port_conf = { .rxmode = { .mq_mode = ETH_MQ_RX_RSS, - .max_rx_pkt_len = ETHER_MAX_LEN, + .max_rx_pkt_len = RTE_ETHER_MAX_LEN, .split_hdr_size = 0, - .ignore_offload_bitfield = 1, - .offloads = (DEV_RX_OFFLOAD_CHECKSUM | - DEV_RX_OFFLOAD_CRC_STRIP), + .offloads = DEV_RX_OFFLOAD_CHECKSUM, }, .rx_adv_conf = { .rss_conf = { @@ -888,39 +884,39 @@ static inline void l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid) static inline void simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint16_t portid) { - struct ether_hdr *eth_hdr[8]; + struct rte_ether_hdr *eth_hdr[8]; struct ipv4_hdr *ipv4_hdr[8]; uint16_t dst_port[8]; int32_t ret[8]; union ipv4_5tuple_host key[8]; __m128i data[8]; - eth_hdr[0] = rte_pktmbuf_mtod(m[0], struct ether_hdr *); - eth_hdr[1] = rte_pktmbuf_mtod(m[1], struct ether_hdr *); - eth_hdr[2] = rte_pktmbuf_mtod(m[2], struct ether_hdr *); - eth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *); - eth_hdr[4] = rte_pktmbuf_mtod(m[4], struct ether_hdr *); - eth_hdr[5] = rte_pktmbuf_mtod(m[5], struct ether_hdr *); - eth_hdr[6] = rte_pktmbuf_mtod(m[6], struct ether_hdr *); - eth_hdr[7] = rte_pktmbuf_mtod(m[7], struct ether_hdr *); + eth_hdr[0] = rte_pktmbuf_mtod(m[0], struct rte_ether_hdr *); + eth_hdr[1] = rte_pktmbuf_mtod(m[1], struct rte_ether_hdr *); + eth_hdr[2] = rte_pktmbuf_mtod(m[2], struct rte_ether_hdr *); + eth_hdr[3] = rte_pktmbuf_mtod(m[3], struct rte_ether_hdr *); + eth_hdr[4] = rte_pktmbuf_mtod(m[4], struct rte_ether_hdr *); + eth_hdr[5] = rte_pktmbuf_mtod(m[5], struct rte_ether_hdr *); + eth_hdr[6] = rte_pktmbuf_mtod(m[6], struct rte_ether_hdr *); + eth_hdr[7] = rte_pktmbuf_mtod(m[7], struct rte_ether_hdr *); /* Handle IPv4 headers.*/ ipv4_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv4_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv4_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv4_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv4_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv4_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv4_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv4_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); #ifdef DO_RFC_1812_CHECKS /* Check to make sure the packet is valid (RFC1812) */ @@ -971,28 +967,28 @@ simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint16_t portid) #endif /* End of #ifdef DO_RFC_1812_CHECKS */ data[0] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[0], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); data[1] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[1], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); data[2] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[2], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); data[3] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[3], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); data[4] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[4], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); data[5] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[5], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); data[6] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[6], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); data[7] = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m[7], __m128i *, - sizeof(struct ether_hdr) + + sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, time_to_live))); key[0].xmm = _mm_and_si128(data[0], mask0); @@ -1074,14 +1070,14 @@ simple_ipv4_fwd_8pkts(struct rte_mbuf *m[8], uint16_t portid) *(uint64_t *)ð_hdr[7]->d_addr = dest_eth_addr[dst_port[7]]; /* src addr */ - ether_addr_copy(&ports_eth_addr[dst_port[0]], ð_hdr[0]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[1]], ð_hdr[1]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[2]], ð_hdr[2]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[3]], ð_hdr[3]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[4]], ð_hdr[4]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[5]], ð_hdr[5]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[6]], ð_hdr[6]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[7]], ð_hdr[7]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[0]], ð_hdr[0]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[1]], ð_hdr[1]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[2]], ð_hdr[2]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[3]], ð_hdr[3]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[4]], ð_hdr[4]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[5]], ð_hdr[5]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[6]], ð_hdr[6]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[7]], ð_hdr[7]->s_addr); send_single_packet(m[0], (uint8_t)dst_port[0]); send_single_packet(m[1], (uint8_t)dst_port[1]); @@ -1098,13 +1094,13 @@ static inline void get_ipv6_5tuple(struct rte_mbuf *m0, __m128i mask0, __m128i mask1, union ipv6_5tuple_host *key) { __m128i tmpdata0 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, - __m128i *, sizeof(struct ether_hdr) + + __m128i *, sizeof(struct rte_ether_hdr) + offsetof(struct ipv6_hdr, payload_len))); __m128i tmpdata1 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, - __m128i *, sizeof(struct ether_hdr) + + __m128i *, sizeof(struct rte_ether_hdr) + offsetof(struct ipv6_hdr, payload_len) + sizeof(__m128i))); __m128i tmpdata2 = _mm_loadu_si128(rte_pktmbuf_mtod_offset(m0, - __m128i *, sizeof(struct ether_hdr) + + __m128i *, sizeof(struct rte_ether_hdr) + offsetof(struct ipv6_hdr, payload_len) + sizeof(__m128i) + sizeof(__m128i))); key->xmm[0] = _mm_and_si128(tmpdata0, mask0); @@ -1117,37 +1113,37 @@ simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint16_t portid) { int32_t ret[8]; uint16_t dst_port[8]; - struct ether_hdr *eth_hdr[8]; + struct rte_ether_hdr *eth_hdr[8]; union ipv6_5tuple_host key[8]; __attribute__((unused)) struct ipv6_hdr *ipv6_hdr[8]; - eth_hdr[0] = rte_pktmbuf_mtod(m[0], struct ether_hdr *); - eth_hdr[1] = rte_pktmbuf_mtod(m[1], struct ether_hdr *); - eth_hdr[2] = rte_pktmbuf_mtod(m[2], struct ether_hdr *); - eth_hdr[3] = rte_pktmbuf_mtod(m[3], struct ether_hdr *); - eth_hdr[4] = rte_pktmbuf_mtod(m[4], struct ether_hdr *); - eth_hdr[5] = rte_pktmbuf_mtod(m[5], struct ether_hdr *); - eth_hdr[6] = rte_pktmbuf_mtod(m[6], struct ether_hdr *); - eth_hdr[7] = rte_pktmbuf_mtod(m[7], struct ether_hdr *); + eth_hdr[0] = rte_pktmbuf_mtod(m[0], struct rte_ether_hdr *); + eth_hdr[1] = rte_pktmbuf_mtod(m[1], struct rte_ether_hdr *); + eth_hdr[2] = rte_pktmbuf_mtod(m[2], struct rte_ether_hdr *); + eth_hdr[3] = rte_pktmbuf_mtod(m[3], struct rte_ether_hdr *); + eth_hdr[4] = rte_pktmbuf_mtod(m[4], struct rte_ether_hdr *); + eth_hdr[5] = rte_pktmbuf_mtod(m[5], struct rte_ether_hdr *); + eth_hdr[6] = rte_pktmbuf_mtod(m[6], struct rte_ether_hdr *); + eth_hdr[7] = rte_pktmbuf_mtod(m[7], struct rte_ether_hdr *); /* Handle IPv6 headers.*/ ipv6_hdr[0] = rte_pktmbuf_mtod_offset(m[0], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv6_hdr[1] = rte_pktmbuf_mtod_offset(m[1], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv6_hdr[2] = rte_pktmbuf_mtod_offset(m[2], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv6_hdr[3] = rte_pktmbuf_mtod_offset(m[3], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv6_hdr[4] = rte_pktmbuf_mtod_offset(m[4], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv6_hdr[5] = rte_pktmbuf_mtod_offset(m[5], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv6_hdr[6] = rte_pktmbuf_mtod_offset(m[6], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); ipv6_hdr[7] = rte_pktmbuf_mtod_offset(m[7], struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); get_ipv6_5tuple(m[0], mask1, mask2, &key[0]); get_ipv6_5tuple(m[1], mask1, mask2, &key[1]); @@ -1208,14 +1204,14 @@ simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint16_t portid) *(uint64_t *)ð_hdr[7]->d_addr = dest_eth_addr[dst_port[7]]; /* src addr */ - ether_addr_copy(&ports_eth_addr[dst_port[0]], ð_hdr[0]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[1]], ð_hdr[1]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[2]], ð_hdr[2]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[3]], ð_hdr[3]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[4]], ð_hdr[4]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[5]], ð_hdr[5]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[6]], ð_hdr[6]->s_addr); - ether_addr_copy(&ports_eth_addr[dst_port[7]], ð_hdr[7]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[0]], ð_hdr[0]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[1]], ð_hdr[1]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[2]], ð_hdr[2]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[3]], ð_hdr[3]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[4]], ð_hdr[4]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[5]], ð_hdr[5]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[6]], ð_hdr[6]->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port[7]], ð_hdr[7]->s_addr); send_single_packet(m[0], dst_port[0]); send_single_packet(m[1], dst_port[1]); @@ -1232,16 +1228,16 @@ simple_ipv6_fwd_8pkts(struct rte_mbuf *m[8], uint16_t portid) static __rte_always_inline void l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid) { - struct ether_hdr *eth_hdr; + struct rte_ether_hdr *eth_hdr; struct ipv4_hdr *ipv4_hdr; uint16_t dst_port; - eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) { /* Handle IPv4 headers.*/ ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); #ifdef DO_RFC_1812_CHECKS /* Check to make sure the packet is valid (RFC1812) */ @@ -1266,7 +1262,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid) *(uint64_t *)ð_hdr->d_addr = dest_eth_addr[dst_port]; /* src addr */ - ether_addr_copy(&ports_eth_addr[dst_port], ð_hdr->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port], + ð_hdr->s_addr); send_single_packet(m, dst_port); } else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) { @@ -1274,7 +1271,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid) struct ipv6_hdr *ipv6_hdr; ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, - sizeof(struct ether_hdr)); + sizeof(struct rte_ether_hdr)); dst_port = get_ipv6_dst_port(ipv6_hdr, portid, RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct); @@ -1287,7 +1284,8 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint16_t portid) *(uint64_t *)ð_hdr->d_addr = dest_eth_addr[dst_port]; /* src addr */ - ether_addr_copy(&ports_eth_addr[dst_port], ð_hdr->s_addr); + rte_ether_addr_copy(&ports_eth_addr[dst_port], + ð_hdr->s_addr); send_single_packet(m, dst_port); } else @@ -1350,7 +1348,7 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint16_t portid) { uint32_t next_hop; struct ipv6_hdr *ipv6_hdr; - struct ether_hdr *eth_hdr; + struct rte_ether_hdr *eth_hdr; if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) { return (uint16_t) ((rte_lpm_lookup( @@ -1359,7 +1357,7 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint16_t portid) } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) { - eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); ipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1); return (uint16_t) ((rte_lpm6_lookup( @@ -1375,13 +1373,13 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint16_t portid) static inline void process_packet(struct rte_mbuf *pkt, uint16_t *dst_port, uint16_t portid) { - struct ether_hdr *eth_hdr; + struct rte_ether_hdr *eth_hdr; struct ipv4_hdr *ipv4_hdr; uint32_t dst_ipv4; uint16_t dp; __m128i te, ve; - eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1); dst_ipv4 = ipv4_hdr->dst_addr; @@ -1407,25 +1405,25 @@ processx4_step1(struct rte_mbuf *pkt[FWDSTEP], uint32_t *ipv4_flag) { struct ipv4_hdr *ipv4_hdr; - struct ether_hdr *eth_hdr; + struct rte_ether_hdr *eth_hdr; uint32_t x0, x1, x2, x3; - eth_hdr = rte_pktmbuf_mtod(pkt[0], struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(pkt[0], struct rte_ether_hdr *); ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1); x0 = ipv4_hdr->dst_addr; ipv4_flag[0] = pkt[0]->packet_type & RTE_PTYPE_L3_IPV4; - eth_hdr = rte_pktmbuf_mtod(pkt[1], struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(pkt[1], struct rte_ether_hdr *); ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1); x1 = ipv4_hdr->dst_addr; ipv4_flag[0] &= pkt[1]->packet_type; - eth_hdr = rte_pktmbuf_mtod(pkt[2], struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(pkt[2], struct rte_ether_hdr *); ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1); x2 = ipv4_hdr->dst_addr; ipv4_flag[0] &= pkt[2]->packet_type; - eth_hdr = rte_pktmbuf_mtod(pkt[3], struct ether_hdr *); + eth_hdr = rte_pktmbuf_mtod(pkt[3], struct rte_ether_hdr *); ipv4_hdr = (struct ipv4_hdr *)(eth_hdr + 1); x3 = ipv4_hdr->dst_addr; ipv4_flag[0] &= pkt[3]->packet_type; @@ -1507,13 +1505,13 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP]) _mm_store_si128(p[2], te[2]); _mm_store_si128(p[3], te[3]); - rfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[0] + 1), + rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[0] + 1), &dst_port[0], pkt[0]->packet_type); - rfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[1] + 1), + rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[1] + 1), &dst_port[1], pkt[1]->packet_type); - rfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[2] + 1), + rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[2] + 1), &dst_port[2], pkt[2]->packet_type); - rfc1812_process((struct ipv4_hdr *)((struct ether_hdr *)p[3] + 1), + rfc1812_process((struct ipv4_hdr *)((struct rte_ether_hdr *)p[3] + 1), &dst_port[3], pkt[3]->packet_type); } @@ -1990,17 +1988,18 @@ cpu_load_collector(__rte_unused void *arg) { * * This loop is used to start empty scheduler on lcore. */ -static void +static void * lthread_null(__rte_unused void *args) { int lcore_id = rte_lcore_id(); RTE_LOG(INFO, L3FWD, "Starting scheduler on lcore %d.\n", lcore_id); lthread_exit(NULL); + return NULL; } /* main processing loop */ -static void +static void * lthread_tx_per_ring(void *dummy) { int nb_rx; @@ -2045,6 +2044,7 @@ lthread_tx_per_ring(void *dummy) lthread_cond_wait(ready, 0); } + return NULL; } /* @@ -2053,7 +2053,7 @@ lthread_tx_per_ring(void *dummy) * This lthread is used to spawn one new lthread per ring from producers. * */ -static void +static void * lthread_tx(void *args) { struct lthread *lt; @@ -2098,9 +2098,10 @@ lthread_tx(void *args) } } + return NULL; } -static void +static void * lthread_rx(void *dummy) { int ret; @@ -2124,7 +2125,7 @@ lthread_rx(void *dummy) if (rx_conf->n_rx_queue == 0) { RTE_LOG(INFO, L3FWD, "lcore %u has nothing to do\n", rte_lcore_id()); - return; + return NULL; } RTE_LOG(INFO, L3FWD, "Entering main Rx loop on lcore %u\n", rte_lcore_id()); @@ -2196,6 +2197,7 @@ lthread_rx(void *dummy) lthread_yield(); } } + return NULL; } /* @@ -2204,8 +2206,9 @@ lthread_rx(void *dummy) * This lthread loop spawns all rx and tx lthreads on master lcore */ -static void -lthread_spawner(__rte_unused void *arg) { +static void * +lthread_spawner(__rte_unused void *arg) +{ struct lthread *lt[MAX_THREAD]; int i; int n_thread = 0; @@ -2246,6 +2249,7 @@ lthread_spawner(__rte_unused void *arg) { for (i = 0; i < n_thread; i++) lthread_join(lt[i], NULL); + return NULL; } /* @@ -2491,7 +2495,7 @@ check_lcore_params(void) } static int -check_port_config(const unsigned nb_ports) +check_port_config(void) { unsigned portid; uint16_t i; @@ -2502,7 +2506,7 @@ check_port_config(const unsigned nb_ports) printf("port %u is not enabled in port mask\n", portid); return -1; } - if (portid >= nb_ports) { + if (!rte_eth_dev_is_valid_port(portid)) { printf("port %u is not present on the board\n", portid); return -1; } @@ -2973,7 +2977,9 @@ parse_args(int argc, char **argv) port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS; - /* if no max-pkt-len set, use the default value ETHER_MAX_LEN */ + /* if no max-pkt-len set, use the default value + * RTE_ETHER_MAX_LEN + */ if (0 == getopt_long(argc, argvopt, "", &lenopts, &option_index)) { @@ -3018,11 +3024,11 @@ parse_args(int argc, char **argv) } static void -print_ethaddr(const char *name, const struct ether_addr *eth_addr) +print_ethaddr(const char *name, const struct rte_ether_addr *eth_addr) { - char buf[ETHER_ADDR_FMT_SIZE]; + char buf[RTE_ETHER_ADDR_FMT_SIZE]; - ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr); + rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, eth_addr); printf("%s%s", name, buf); } @@ -3411,7 +3417,7 @@ init_mem(unsigned nb_mbuf) /* Check the link status of all ports in up to 9s, and print them finally */ static void -check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) +check_all_ports_link_status(uint32_t port_mask) { #define CHECK_INTERVAL 100 /* 100ms */ #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */ @@ -3423,7 +3429,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) fflush(stdout); for (count = 0; count <= MAX_CHECK_TIME; count++) { all_ports_up = 1; - for (portid = 0; portid < port_num; portid++) { + RTE_ETH_FOREACH_DEV(portid) { if ((port_mask & (1 << portid)) == 0) continue; memset(&link, 0, sizeof(link)); @@ -3486,7 +3492,7 @@ main(int argc, char **argv) /* pre-init dst MACs for all ports to 02:00:00:00:00:xx */ for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) { - dest_eth_addr[portid] = ETHER_LOCAL_ADMIN_ADDR + + dest_eth_addr[portid] = RTE_ETHER_LOCAL_ADMIN_ADDR + ((uint64_t)portid << 40); *(uint64_t *)(val_eth + portid) = dest_eth_addr[portid]; } @@ -3514,15 +3520,15 @@ main(int argc, char **argv) if (ret < 0) rte_exit(EXIT_FAILURE, "init_rx_rings failed\n"); - nb_ports = rte_eth_dev_count(); + nb_ports = rte_eth_dev_count_avail(); - if (check_port_config(nb_ports) < 0) + if (check_port_config() < 0) rte_exit(EXIT_FAILURE, "check_port_config failed\n"); nb_lcores = rte_lcore_count(); /* initialize all ports */ - for (portid = 0; portid < nb_ports; portid++) { + RTE_ETH_FOREACH_DEV(portid) { struct rte_eth_conf local_port_conf = port_conf; /* skip ports that are not enabled */ @@ -3545,6 +3551,18 @@ main(int argc, char **argv) if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; + + local_port_conf.rx_adv_conf.rss_conf.rss_hf &= + dev_info.flow_type_rss_offloads; + if (local_port_conf.rx_adv_conf.rss_conf.rss_hf != + port_conf.rx_adv_conf.rss_conf.rss_hf) { + printf("Port %u modified RSS hash function based on hardware support," + "requested:%#"PRIx64" configured:%#"PRIx64"\n", + portid, + port_conf.rx_adv_conf.rss_conf.rss_hf, + local_port_conf.rx_adv_conf.rss_conf.rss_hf); + } + ret = rte_eth_dev_configure(portid, nb_rx_queue, (uint16_t)n_tx_queue, &local_port_conf); if (ret < 0) @@ -3562,14 +3580,14 @@ main(int argc, char **argv) print_ethaddr(" Address:", &ports_eth_addr[portid]); printf(", "); print_ethaddr("Destination:", - (const struct ether_addr *)&dest_eth_addr[portid]); + (const struct rte_ether_addr *)&dest_eth_addr[portid]); printf(", "); /* * prepare src MACs for each port. */ - ether_addr_copy(&ports_eth_addr[portid], - (struct ether_addr *)(val_eth + portid) + 1); + rte_ether_addr_copy(&ports_eth_addr[portid], + (struct rte_ether_addr *)(val_eth + portid) + 1); /* init memory */ ret = init_mem(NB_MBUF); @@ -3591,7 +3609,6 @@ main(int argc, char **argv) fflush(stdout); txconf = &dev_info.default_txconf; - txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE; txconf->offloads = local_port_conf.txmode.offloads; ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd, socketid, txconf); @@ -3654,7 +3671,7 @@ main(int argc, char **argv) printf("\n"); /* start ports */ - for (portid = 0; portid < nb_ports; portid++) { + RTE_ETH_FOREACH_DEV(portid) { if ((enabled_port_mask & (1 << portid)) == 0) continue; @@ -3699,7 +3716,7 @@ main(int argc, char **argv) } } - check_all_ports_link_status((uint8_t)nb_ports, enabled_port_mask); + check_all_ports_link_status(enabled_port_mask); if (lthreads_on) { printf("Starting L-Threading Model\n");