4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <sys/types.h>
40 #include <sys/queue.h>
45 #include <rte_common.h>
46 #include <rte_byteorder.h>
48 #include <rte_tailq.h>
49 #include <rte_memory.h>
50 #include <rte_memcpy.h>
51 #include <rte_memzone.h>
53 #include <rte_per_lcore.h>
54 #include <rte_launch.h>
55 #include <rte_atomic.h>
56 #include <rte_cycles.h>
57 #include <rte_prefetch.h>
58 #include <rte_lcore.h>
59 #include <rte_per_lcore.h>
60 #include <rte_branch_prediction.h>
61 #include <rte_interrupts.h>
63 #include <rte_random.h>
64 #include <rte_debug.h>
65 #include <rte_ether.h>
66 #include <rte_ethdev.h>
68 #include <rte_mempool.h>
70 #include <rte_malloc.h>
71 #include <rte_fbk_hash.h>
74 #define RTE_LOGTYPE_IPv4_MULTICAST RTE_LOGTYPE_USER1
78 #define MCAST_CLONE_PORTS 2
79 #define MCAST_CLONE_SEGS 2
81 #define PKT_MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
82 #define NB_PKT_MBUF 8192
84 #define HDR_MBUF_SIZE (sizeof(struct rte_mbuf) + 2 * RTE_PKTMBUF_HEADROOM)
85 #define NB_HDR_MBUF (NB_PKT_MBUF * MAX_PORTS)
87 #define CLONE_MBUF_SIZE (sizeof(struct rte_mbuf))
88 #define NB_CLONE_MBUF (NB_PKT_MBUF * MCAST_CLONE_PORTS * MCAST_CLONE_SEGS * 2)
90 /* allow max jumbo frame 9.5 KB */
91 #define JUMBO_FRAME_MAX_SIZE 0x2600
93 #define MAX_PKT_BURST 32
94 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
96 /* Configure how many packets ahead to prefetch, when reading packets */
97 #define PREFETCH_OFFSET 3
100 * Construct Ethernet multicast address from IPv4 multicast address.
101 * Citing RFC 1112, section 6.4:
102 * "An IP host group address is mapped to an Ethernet multicast address
103 * by placing the low-order 23-bits of the IP address into the low-order
104 * 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex)."
106 #define ETHER_ADDR_FOR_IPV4_MCAST(x) \
107 (rte_cpu_to_be_64(0x01005e000000ULL | ((x) & 0x7fffff)) >> 16)
110 * Configurable number of RX/TX ring descriptors
112 #define RTE_TEST_RX_DESC_DEFAULT 128
113 #define RTE_TEST_TX_DESC_DEFAULT 512
114 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
115 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
117 /* ethernet addresses of ports */
118 static struct ether_addr ports_eth_addr[MAX_PORTS];
120 /* mask of enabled ports */
121 static uint32_t enabled_port_mask = 0;
123 static uint8_t nb_ports = 0;
125 static int rx_queue_per_lcore = 1;
129 struct rte_mbuf *m_table[MAX_PKT_BURST];
132 #define MAX_RX_QUEUE_PER_LCORE 16
133 #define MAX_TX_QUEUE_PER_PORT 16
134 struct lcore_queue_conf {
137 uint8_t rx_queue_list[MAX_RX_QUEUE_PER_LCORE];
138 uint16_t tx_queue_id[MAX_PORTS];
139 struct mbuf_table tx_mbufs[MAX_PORTS];
140 } __rte_cache_aligned;
141 static struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];
143 static const struct rte_eth_conf port_conf = {
145 .max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
147 .header_split = 0, /**< Header Split disabled */
148 .hw_ip_checksum = 0, /**< IP checksum offload disabled */
149 .hw_vlan_filter = 0, /**< VLAN filtering disabled */
150 .jumbo_frame = 1, /**< Jumbo Frame Support enabled */
151 .hw_strip_crc = 0, /**< CRC stripped by hardware */
154 .mq_mode = ETH_MQ_TX_NONE,
158 static struct rte_mempool *packet_pool, *header_pool, *clone_pool;
162 static struct rte_fbk_hash_params mcast_hash_params = {
163 .name = "MCAST_HASH",
165 .entries_per_bucket = 4,
171 struct rte_fbk_hash_table *mcast_hash = NULL;
173 struct mcast_group_params {
178 static struct mcast_group_params mcast_group_table[] = {
179 {IPv4(224,0,0,101), 0x1},
180 {IPv4(224,0,0,102), 0x2},
181 {IPv4(224,0,0,103), 0x3},
182 {IPv4(224,0,0,104), 0x4},
183 {IPv4(224,0,0,105), 0x5},
184 {IPv4(224,0,0,106), 0x6},
185 {IPv4(224,0,0,107), 0x7},
186 {IPv4(224,0,0,108), 0x8},
187 {IPv4(224,0,0,109), 0x9},
188 {IPv4(224,0,0,110), 0xA},
189 {IPv4(224,0,0,111), 0xB},
190 {IPv4(224,0,0,112), 0xC},
191 {IPv4(224,0,0,113), 0xD},
192 {IPv4(224,0,0,114), 0xE},
193 {IPv4(224,0,0,115), 0xF},
196 #define N_MCAST_GROUPS \
197 (sizeof (mcast_group_table) / sizeof (mcast_group_table[0]))
200 /* Send burst of packets on an output interface */
202 send_burst(struct lcore_queue_conf *qconf, uint8_t port)
204 struct rte_mbuf **m_table;
208 queueid = qconf->tx_queue_id[port];
209 m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;
210 n = qconf->tx_mbufs[port].len;
212 ret = rte_eth_tx_burst(port, queueid, m_table, n);
213 while (unlikely (ret < n)) {
214 rte_pktmbuf_free(m_table[ret]);
218 qconf->tx_mbufs[port].len = 0;
221 /* Get number of bits set. */
222 static inline uint32_t
227 for (n = 0; v != 0; v &= v - 1, n++)
234 * Create the output multicast packet based on the given input packet.
235 * There are two approaches for creating outgoing packet, though both
236 * are based on data zero-copy idea, they differ in few details:
237 * First one creates a clone of the input packet, e.g - walk though all
238 * segments of the input packet, and for each of them create a new packet
239 * mbuf and attach that new mbuf to the segment (refer to rte_pktmbuf_clone()
240 * for more details). Then new mbuf is allocated for the packet header
241 * and is prepended to the 'clone' mbuf.
242 * Second approach doesn't make a clone, it just increment refcnt for all
243 * input packet segments. Then it allocates new mbuf for the packet header
244 * and prepends it to the input packet.
245 * Basically first approach reuses only input packet's data, but creates
246 * it's own copy of packet's metadata. Second approach reuses both input's
247 * packet data and metadata.
248 * The advantage of first approach - is that each outgoing packet has it's
249 * own copy of metadata, so we can safely modify data pointer of the
250 * input packet. That allows us to skip creation if the output packet for
251 * the last destination port, but instead modify input packet's header inplace,
252 * e.g: for N destination ports we need to invoke mcast_out_pkt (N-1) times.
253 * The advantage of second approach - less work for each outgoing packet,
254 * e.g: we skip "clone" operation completely. Though it comes with a price -
255 * input packet's metadata has to be intact. So for N destination ports we
256 * need to invoke mcast_out_pkt N times.
257 * So for small number of outgoing ports (and segments in the input packet)
258 * first approach will be faster.
259 * As number of outgoing ports (and/or input segments) will grow,
260 * second way will become more preferable.
265 * Control which of the two approaches described above should be used:
266 * - 0 - use second approach:
267 * Don't "clone" input packet.
268 * Prepend new header directly to the input packet
269 * - 1 - use first approach:
270 * Make a "clone" of input packet first.
271 * Prepend new header to the clone of the input packet
273 * - The pointer to the new outgoing packet.
274 * - NULL if operation failed.
276 static inline struct rte_mbuf *
277 mcast_out_pkt(struct rte_mbuf *pkt, int use_clone)
279 struct rte_mbuf *hdr;
281 /* Create new mbuf for the header. */
282 if (unlikely ((hdr = rte_pktmbuf_alloc(header_pool)) == NULL))
285 /* If requested, then make a new clone packet. */
286 if (use_clone != 0 &&
287 unlikely ((pkt = rte_pktmbuf_clone(pkt, clone_pool)) == NULL)) {
288 rte_pktmbuf_free(hdr);
292 /* prepend new header */
296 /* update header's fields */
297 hdr->pkt_len = (uint16_t)(hdr->data_len + pkt->pkt_len);
298 hdr->nb_segs = (uint8_t)(pkt->nb_segs + 1);
300 /* copy metadata from source packet*/
301 hdr->port = pkt->port;
302 hdr->vlan_tci = pkt->vlan_tci;
303 hdr->tx_offload = pkt->tx_offload;
304 hdr->hash = pkt->hash;
306 hdr->ol_flags = pkt->ol_flags;
308 __rte_mbuf_sanity_check(hdr, 1);
313 * Write new Ethernet header to the outgoing packet,
314 * and put it into the outgoing queue for the given port.
317 mcast_send_pkt(struct rte_mbuf *pkt, struct ether_addr *dest_addr,
318 struct lcore_queue_conf *qconf, uint8_t port)
320 struct ether_hdr *ethdr;
323 /* Construct Ethernet header. */
324 ethdr = (struct ether_hdr *)rte_pktmbuf_prepend(pkt, (uint16_t)sizeof(*ethdr));
325 RTE_MBUF_ASSERT(ethdr != NULL);
327 ether_addr_copy(dest_addr, ðdr->d_addr);
328 ether_addr_copy(&ports_eth_addr[port], ðdr->s_addr);
329 ethdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
331 /* Put new packet into the output queue */
332 len = qconf->tx_mbufs[port].len;
333 qconf->tx_mbufs[port].m_table[len] = pkt;
334 qconf->tx_mbufs[port].len = ++len;
336 /* Transmit packets */
337 if (unlikely(MAX_PKT_BURST == len))
338 send_burst(qconf, port);
341 /* Multicast forward of the input packet */
343 mcast_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf)
346 struct ipv4_hdr *iphdr;
347 uint32_t dest_addr, port_mask, port_num, use_clone;
352 struct ether_addr as_addr;
355 /* Remove the Ethernet header from the input packet */
356 iphdr = (struct ipv4_hdr *)rte_pktmbuf_adj(m, (uint16_t)sizeof(struct ether_hdr));
357 RTE_MBUF_ASSERT(iphdr != NULL);
359 dest_addr = rte_be_to_cpu_32(iphdr->dst_addr);
362 * Check that it is a valid multicast address and
363 * we have some active ports assigned to it.
365 if(!IS_IPV4_MCAST(dest_addr) ||
366 (hash = rte_fbk_hash_lookup(mcast_hash, dest_addr)) <= 0 ||
367 (port_mask = hash & enabled_port_mask) == 0) {
372 /* Calculate number of destination ports. */
373 port_num = bitcnt(port_mask);
375 /* Should we use rte_pktmbuf_clone() or not. */
376 use_clone = (port_num <= MCAST_CLONE_PORTS &&
377 m->nb_segs <= MCAST_CLONE_SEGS);
379 /* Mark all packet's segments as referenced port_num times */
381 rte_pktmbuf_refcnt_update(m, (uint16_t)port_num);
383 /* construct destination ethernet address */
384 dst_eth_addr.as_int = ETHER_ADDR_FOR_IPV4_MCAST(dest_addr);
386 for (port = 0; use_clone != port_mask; port_mask >>= 1, port++) {
388 /* Prepare output packet and send it out. */
389 if ((port_mask & 1) != 0) {
390 if (likely ((mc = mcast_out_pkt(m, use_clone)) != NULL))
391 mcast_send_pkt(mc, &dst_eth_addr.as_addr,
393 else if (use_clone == 0)
399 * If we making clone packets, then, for the last destination port,
400 * we can overwrite input packet's metadata.
403 mcast_send_pkt(m, &dst_eth_addr.as_addr, qconf, port);
408 /* Send burst of outgoing packet, if timeout expires. */
410 send_timeout_burst(struct lcore_queue_conf *qconf)
414 const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US;
416 cur_tsc = rte_rdtsc();
417 if (likely (cur_tsc < qconf->tx_tsc + drain_tsc))
420 for (portid = 0; portid < MAX_PORTS; portid++) {
421 if (qconf->tx_mbufs[portid].len != 0)
422 send_burst(qconf, portid);
424 qconf->tx_tsc = cur_tsc;
427 /* main processing loop */
429 main_loop(__rte_unused void *dummy)
431 struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
435 struct lcore_queue_conf *qconf;
437 lcore_id = rte_lcore_id();
438 qconf = &lcore_queue_conf[lcore_id];
441 if (qconf->n_rx_queue == 0) {
442 RTE_LOG(INFO, IPv4_MULTICAST, "lcore %u has nothing to do\n",
447 RTE_LOG(INFO, IPv4_MULTICAST, "entering main loop on lcore %u\n",
450 for (i = 0; i < qconf->n_rx_queue; i++) {
452 portid = qconf->rx_queue_list[i];
453 RTE_LOG(INFO, IPv4_MULTICAST, " -- lcoreid=%u portid=%d\n",
454 lcore_id, (int) portid);
460 * Read packet from RX queues
462 for (i = 0; i < qconf->n_rx_queue; i++) {
464 portid = qconf->rx_queue_list[i];
465 nb_rx = rte_eth_rx_burst(portid, 0, pkts_burst,
468 /* Prefetch first packets */
469 for (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++) {
470 rte_prefetch0(rte_pktmbuf_mtod(
471 pkts_burst[j], void *));
474 /* Prefetch and forward already prefetched packets */
475 for (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {
476 rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[
477 j + PREFETCH_OFFSET], void *));
478 mcast_forward(pkts_burst[j], qconf);
481 /* Forward remaining prefetched packets */
482 for (; j < nb_rx; j++) {
483 mcast_forward(pkts_burst[j], qconf);
487 /* Send out packets from TX queues */
488 send_timeout_burst(qconf);
494 print_usage(const char *prgname)
496 printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n"
497 " -p PORTMASK: hexadecimal bitmask of ports to configure\n"
498 " -q NQ: number of queue (=ports) per lcore (default is 1)\n",
503 parse_portmask(const char *portmask)
508 /* parse hexadecimal string */
509 pm = strtoul(portmask, &end, 16);
510 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
513 return ((uint32_t)pm);
517 parse_nqueue(const char *q_arg)
522 /* parse numerical string */
524 n = strtoul(q_arg, &end, 0);
525 if (errno != 0 || end == NULL || *end != '\0' ||
526 n == 0 || n >= MAX_RX_QUEUE_PER_LCORE)
532 /* Parse the argument given in the command line of the application */
534 parse_args(int argc, char **argv)
539 char *prgname = argv[0];
540 static struct option lgopts[] = {
546 while ((opt = getopt_long(argc, argvopt, "p:q:",
547 lgopts, &option_index)) != EOF) {
552 enabled_port_mask = parse_portmask(optarg);
553 if (enabled_port_mask == 0) {
554 printf("invalid portmask\n");
555 print_usage(prgname);
562 rx_queue_per_lcore = parse_nqueue(optarg);
563 if (rx_queue_per_lcore < 0) {
564 printf("invalid queue number\n");
565 print_usage(prgname);
571 print_usage(prgname);
577 argv[optind-1] = prgname;
580 optind = 0; /* reset getopt lib */
585 print_ethaddr(const char *name, struct ether_addr *eth_addr)
587 char buf[ETHER_ADDR_FMT_SIZE];
588 ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, eth_addr);
589 printf("%s%s", name, buf);
593 init_mcast_hash(void)
597 mcast_hash_params.socket_id = rte_socket_id();
598 mcast_hash = rte_fbk_hash_create(&mcast_hash_params);
599 if (mcast_hash == NULL){
603 for (i = 0; i < N_MCAST_GROUPS; i ++){
604 if (rte_fbk_hash_add_key(mcast_hash,
605 mcast_group_table[i].ip,
606 mcast_group_table[i].port_mask) < 0) {
614 /* Check the link status of all ports in up to 9s, and print them finally */
616 check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
618 #define CHECK_INTERVAL 100 /* 100ms */
619 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
620 uint8_t portid, count, all_ports_up, print_flag = 0;
621 struct rte_eth_link link;
623 printf("\nChecking link status");
625 for (count = 0; count <= MAX_CHECK_TIME; count++) {
627 for (portid = 0; portid < port_num; portid++) {
628 if ((port_mask & (1 << portid)) == 0)
630 memset(&link, 0, sizeof(link));
631 rte_eth_link_get_nowait(portid, &link);
632 /* print link status if flag set */
633 if (print_flag == 1) {
634 if (link.link_status)
635 printf("Port %d Link Up - speed %u "
636 "Mbps - %s\n", (uint8_t)portid,
637 (unsigned)link.link_speed,
638 (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
639 ("full-duplex") : ("half-duplex\n"));
641 printf("Port %d Link Down\n",
645 /* clear all_ports_up flag if any link down */
646 if (link.link_status == 0) {
651 /* after finally printing all link status, get out */
655 if (all_ports_up == 0) {
658 rte_delay_ms(CHECK_INTERVAL);
661 /* set the print_flag if all ports up or timeout */
662 if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
670 main(int argc, char **argv)
672 struct lcore_queue_conf *qconf;
673 struct rte_eth_dev_info dev_info;
674 struct rte_eth_txconf *txconf;
677 unsigned lcore_id = 0, rx_lcore_id = 0;
678 uint32_t n_tx_queue, nb_lcores;
682 ret = rte_eal_init(argc, argv);
684 rte_exit(EXIT_FAILURE, "Invalid EAL parameters\n");
688 /* parse application arguments (after the EAL ones) */
689 ret = parse_args(argc, argv);
691 rte_exit(EXIT_FAILURE, "Invalid IPV4_MULTICAST parameters\n");
693 /* create the mbuf pools */
694 packet_pool = rte_mempool_create("packet_pool", NB_PKT_MBUF,
695 PKT_MBUF_SIZE, 32, sizeof(struct rte_pktmbuf_pool_private),
696 rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
699 if (packet_pool == NULL)
700 rte_exit(EXIT_FAILURE, "Cannot init packet mbuf pool\n");
702 header_pool = rte_mempool_create("header_pool", NB_HDR_MBUF,
703 HDR_MBUF_SIZE, 32, 0, NULL, NULL, rte_pktmbuf_init, NULL,
706 if (header_pool == NULL)
707 rte_exit(EXIT_FAILURE, "Cannot init header mbuf pool\n");
709 clone_pool = rte_mempool_create("clone_pool", NB_CLONE_MBUF,
710 CLONE_MBUF_SIZE, 32, 0, NULL, NULL, rte_pktmbuf_init, NULL,
713 if (clone_pool == NULL)
714 rte_exit(EXIT_FAILURE, "Cannot init clone mbuf pool\n");
716 nb_ports = rte_eth_dev_count();
718 rte_exit(EXIT_FAILURE, "No physical ports!\n");
719 if (nb_ports > MAX_PORTS)
720 nb_ports = MAX_PORTS;
722 nb_lcores = rte_lcore_count();
724 /* initialize all ports */
725 for (portid = 0; portid < nb_ports; portid++) {
726 /* skip ports that are not enabled */
727 if ((enabled_port_mask & (1 << portid)) == 0) {
728 printf("Skipping disabled port %d\n", portid);
732 qconf = &lcore_queue_conf[rx_lcore_id];
734 /* get the lcore_id for this port */
735 while (rte_lcore_is_enabled(rx_lcore_id) == 0 ||
736 qconf->n_rx_queue == (unsigned)rx_queue_per_lcore) {
739 qconf = &lcore_queue_conf[rx_lcore_id];
741 if (rx_lcore_id >= RTE_MAX_LCORE)
742 rte_exit(EXIT_FAILURE, "Not enough cores\n");
744 qconf->rx_queue_list[qconf->n_rx_queue] = portid;
748 printf("Initializing port %d on lcore %u... ", portid,
752 n_tx_queue = nb_lcores;
753 if (n_tx_queue > MAX_TX_QUEUE_PER_PORT)
754 n_tx_queue = MAX_TX_QUEUE_PER_PORT;
755 ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
758 rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%d\n",
761 rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
762 print_ethaddr(" Address:", &ports_eth_addr[portid]);
765 /* init one RX queue */
767 printf("rxq=%hu ", queueid);
769 ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
770 rte_eth_dev_socket_id(portid),
774 rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, port=%d\n",
777 /* init one TX queue per couple (lcore,port) */
780 RTE_LCORE_FOREACH(lcore_id) {
781 if (rte_lcore_is_enabled(lcore_id) == 0)
783 printf("txq=%u,%hu ", lcore_id, queueid);
786 rte_eth_dev_info_get(portid, &dev_info);
787 txconf = &dev_info.default_txconf;
788 txconf->txq_flags = 0;
789 ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
790 rte_lcore_to_socket_id(lcore_id), txconf);
792 rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, "
793 "port=%d\n", ret, portid);
795 qconf = &lcore_queue_conf[lcore_id];
796 qconf->tx_queue_id[portid] = queueid;
801 ret = rte_eth_dev_start(portid);
803 rte_exit(EXIT_FAILURE, "rte_eth_dev_start: err=%d, port=%d\n",
809 check_all_ports_link_status(nb_ports, enabled_port_mask);
811 /* initialize the multicast hash */
812 int retval = init_mcast_hash();
814 rte_exit(EXIT_FAILURE, "Cannot build the multicast hash\n");
816 /* launch per-lcore init on every lcore */
817 rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
818 RTE_LCORE_FOREACH_SLAVE(lcore_id) {
819 if (rte_eal_wait_lcore(lcore_id) < 0)