4 * Copyright(c) 2010-2012 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.
39 #include <sys/types.h>
41 #include <sys/queue.h>
46 #include <rte_common.h>
47 #include <rte_byteorder.h>
49 #include <rte_tailq.h>
50 #include <rte_memory.h>
51 #include <rte_memcpy.h>
52 #include <rte_memzone.h>
54 #include <rte_per_lcore.h>
55 #include <rte_launch.h>
56 #include <rte_atomic.h>
57 #include <rte_cycles.h>
58 #include <rte_prefetch.h>
59 #include <rte_lcore.h>
60 #include <rte_per_lcore.h>
61 #include <rte_branch_prediction.h>
62 #include <rte_interrupts.h>
64 #include <rte_random.h>
65 #include <rte_debug.h>
66 #include <rte_ether.h>
67 #include <rte_ethdev.h>
69 #include <rte_mempool.h>
71 #include <rte_malloc.h>
72 #include <rte_hash_crc.h>
73 #include <rte_fbk_hash.h>
78 #define RTE_LOGTYPE_IPv4_MULTICAST RTE_LOGTYPE_USER1
82 #define MCAST_CLONE_PORTS 2
83 #define MCAST_CLONE_SEGS 2
85 #define PKT_MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
86 #define NB_PKT_MBUF 8192
88 #define HDR_MBUF_SIZE (sizeof(struct rte_mbuf) + 2 * RTE_PKTMBUF_HEADROOM)
89 #define NB_HDR_MBUF (NB_PKT_MBUF * MAX_PORTS)
91 #define CLONE_MBUF_SIZE (sizeof(struct rte_mbuf))
92 #define NB_CLONE_MBUF (NB_PKT_MBUF * MCAST_CLONE_PORTS * MCAST_CLONE_SEGS * 2)
94 /* allow max jumbo frame 9.5 KB */
95 #define JUMBO_FRAME_MAX_SIZE 0x2600
98 * RX and TX Prefetch, Host, and Write-back threshold values should be
99 * carefully set for optimal performance. Consult the network
100 * controller's datasheet and supporting DPDK documentation for guidance
101 * on how these parameters should be set.
103 #define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */
104 #define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */
105 #define RX_WTHRESH 4 /**< Default values of RX write-back threshold reg. */
108 * These default values are optimized for use with the Intel(R) 82599 10 GbE
109 * Controller and the DPDK ixgbe PMD. Consider using other values for other
110 * network controllers and/or network drivers.
112 #define TX_PTHRESH 36 /**< Default values of TX prefetch threshold reg. */
113 #define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */
114 #define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */
116 #define MAX_PKT_BURST 32
117 #define BURST_TX_DRAIN 200000ULL /* around 100us at 2 Ghz */
121 /* Configure how many packets ahead to prefetch, when reading packets */
122 #define PREFETCH_OFFSET 3
125 * Construct Ethernet multicast address from IPv4 multicast address.
126 * Citing RFC 1112, section 6.4:
127 * "An IP host group address is mapped to an Ethernet multicast address
128 * by placing the low-order 23-bits of the IP address into the low-order
129 * 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex)."
131 #define ETHER_ADDR_FOR_IPV4_MCAST(x) \
132 (rte_cpu_to_be_64(0x01005e000000ULL | ((x) & 0x7fffff)) >> 16)
135 * Configurable number of RX/TX ring descriptors
137 #define RTE_TEST_RX_DESC_DEFAULT 128
138 #define RTE_TEST_TX_DESC_DEFAULT 512
139 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
140 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
142 /* ethernet addresses of ports */
143 static struct ether_addr ports_eth_addr[MAX_PORTS];
145 /* mask of enabled ports */
146 static uint32_t enabled_port_mask = 0;
148 static uint8_t nb_ports = 0;
150 static int rx_queue_per_lcore = 1;
154 struct rte_mbuf *m_table[MAX_PKT_BURST];
157 #define MAX_RX_QUEUE_PER_LCORE 16
158 #define MAX_TX_QUEUE_PER_PORT 16
159 struct lcore_queue_conf {
162 uint8_t rx_queue_list[MAX_RX_QUEUE_PER_LCORE];
163 uint16_t tx_queue_id[MAX_PORTS];
164 struct mbuf_table tx_mbufs[MAX_PORTS];
165 } __rte_cache_aligned;
166 static struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];
168 static const struct rte_eth_conf port_conf = {
170 .max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
172 .header_split = 0, /**< Header Split disabled */
173 .hw_ip_checksum = 0, /**< IP checksum offload disabled */
174 .hw_vlan_filter = 0, /**< VLAN filtering disabled */
175 .jumbo_frame = 1, /**< Jumbo Frame Support enabled */
176 .hw_strip_crc = 0, /**< CRC stripped by hardware */
182 static const struct rte_eth_rxconf rx_conf = {
184 .pthresh = RX_PTHRESH,
185 .hthresh = RX_HTHRESH,
186 .wthresh = RX_WTHRESH,
190 static const struct rte_eth_txconf tx_conf = {
192 .pthresh = TX_PTHRESH,
193 .hthresh = TX_HTHRESH,
194 .wthresh = TX_WTHRESH,
196 .tx_free_thresh = 0, /* Use PMD default values */
197 .tx_rs_thresh = 0, /* Use PMD default values */
200 static struct rte_mempool *packet_pool, *header_pool, *clone_pool;
204 static struct rte_fbk_hash_params mcast_hash_params = {
205 .name = "MCAST_HASH",
207 .entries_per_bucket = 4,
208 .socket_id = SOCKET0,
213 struct rte_fbk_hash_table *mcast_hash = NULL;
215 struct mcast_group_params {
220 static struct mcast_group_params mcast_group_table[] = {
221 {IPv4(224,0,0,101), 0x1},
222 {IPv4(224,0,0,102), 0x2},
223 {IPv4(224,0,0,103), 0x3},
224 {IPv4(224,0,0,104), 0x4},
225 {IPv4(224,0,0,105), 0x5},
226 {IPv4(224,0,0,106), 0x6},
227 {IPv4(224,0,0,107), 0x7},
228 {IPv4(224,0,0,108), 0x8},
229 {IPv4(224,0,0,109), 0x9},
230 {IPv4(224,0,0,110), 0xA},
231 {IPv4(224,0,0,111), 0xB},
232 {IPv4(224,0,0,112), 0xC},
233 {IPv4(224,0,0,113), 0xD},
234 {IPv4(224,0,0,114), 0xE},
235 {IPv4(224,0,0,115), 0xF},
238 #define N_MCAST_GROUPS \
239 (sizeof (mcast_group_table) / sizeof (mcast_group_table[0]))
242 /* Send burst of packets on an output interface */
244 send_burst(struct lcore_queue_conf *qconf, uint8_t port)
246 struct rte_mbuf **m_table;
250 queueid = qconf->tx_queue_id[port];
251 m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;
252 n = qconf->tx_mbufs[port].len;
254 ret = rte_eth_tx_burst(port, queueid, m_table, n);
255 while (unlikely (ret < n)) {
256 rte_pktmbuf_free(m_table[ret]);
260 qconf->tx_mbufs[port].len = 0;
263 /* Get number of bits set. */
264 static inline uint32_t
269 for (n = 0; v != 0; v &= v - 1, n++)
276 * Create the output multicast packet based on the given input packet.
277 * There are two approaches for creating outgoing packet, though both
278 * are based on data zero-copy idea, they differ in few details:
279 * First one creates a clone of the input packet, e.g - walk though all
280 * segments of the input packet, and for each of them create a new packet
281 * mbuf and attach that new mbuf to the segment (refer to rte_pktmbuf_clone()
282 * for more details). Then new mbuf is allocated for the packet header
283 * and is prepended to the 'clone' mbuf.
284 * Second approach doesn't make a clone, it just increment refcnt for all
285 * input packet segments. Then it allocates new mbuf for the packet header
286 * and prepends it to the input packet.
287 * Basically first approach reuses only input packet's data, but creates
288 * it's own copy of packet's metadata. Second approach reuses both input's
289 * packet data and metadata.
290 * The advantage of first approach - is that each outgoing packet has it's
291 * own copy of metadata, so we can safely modify data pointer of the
292 * input packet. That allows us to skip creation if the output packet for
293 * the last destination port, but instead modify input packet's header inplace,
294 * e.g: for N destination ports we need to invoke mcast_out_pkt (N-1) times.
295 * The advantage of second approach - less work for each outgoing packet,
296 * e.g: we skip "clone" operation completely. Though it comes with a price -
297 * input packet's metadata has to be intact. So for N destination ports we
298 * need to invoke mcast_out_pkt N times.
299 * So for small number of outgoing ports (and segments in the input packet)
300 * first approach will be faster.
301 * As number of outgoing ports (and/or input segments) will grow,
302 * second way will become more preferable.
307 * Control which of the two approaches described above should be used:
308 * - 0 - use second approach:
309 * Don't "clone" input packet.
310 * Prepend new header directly to the input packet
311 * - 1 - use first approach:
312 * Make a "clone" of input packet first.
313 * Prepend new header to the clone of the input packet
315 * - The pointer to the new outgoing packet.
316 * - NULL if operation failed.
318 static inline struct rte_mbuf *
319 mcast_out_pkt(struct rte_mbuf *pkt, int use_clone)
321 struct rte_mbuf *hdr;
323 /* Create new mbuf for the header. */
324 if (unlikely ((hdr = rte_pktmbuf_alloc(header_pool)) == NULL))
327 /* If requested, then make a new clone packet. */
328 if (use_clone != 0 &&
329 unlikely ((pkt = rte_pktmbuf_clone(pkt, clone_pool)) == NULL)) {
330 rte_pktmbuf_free(hdr);
334 /* prepend new header */
338 /* update header's fields */
339 hdr->pkt.pkt_len = (uint16_t)(hdr->pkt.data_len + pkt->pkt.pkt_len);
340 hdr->pkt.nb_segs = (uint8_t)(pkt->pkt.nb_segs + 1);
342 /* copy metadata from source packet*/
343 hdr->pkt.in_port = pkt->pkt.in_port;
344 hdr->pkt.vlan_tci = pkt->pkt.vlan_tci;
345 hdr->pkt.l2_len = pkt->pkt.l2_len;
346 hdr->pkt.l3_len = pkt->pkt.l3_len;
347 hdr->pkt.hash = pkt->pkt.hash;
349 hdr->ol_flags = pkt->ol_flags;
351 __rte_mbuf_sanity_check(hdr, RTE_MBUF_PKT, 1);
356 * Write new Ethernet header to the outgoing packet,
357 * and put it into the outgoing queue for the given port.
360 mcast_send_pkt(struct rte_mbuf *pkt, struct ether_addr *dest_addr,
361 struct lcore_queue_conf *qconf, uint8_t port)
363 struct ether_hdr *ethdr;
366 /* Construct Ethernet header. */
367 ethdr = (struct ether_hdr *)rte_pktmbuf_prepend(pkt, (uint16_t)sizeof(*ethdr));
368 RTE_MBUF_ASSERT(ethdr != NULL);
370 ether_addr_copy(dest_addr, ðdr->d_addr);
371 ether_addr_copy(&ports_eth_addr[port], ðdr->s_addr);
372 ethdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
374 /* Put new packet into the output queue */
375 len = qconf->tx_mbufs[port].len;
376 qconf->tx_mbufs[port].m_table[len] = pkt;
377 qconf->tx_mbufs[port].len = ++len;
379 /* Transmit packets */
380 if (unlikely(MAX_PKT_BURST == len))
381 send_burst(qconf, port);
384 /* Multicast forward of the input packet */
386 mcast_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf)
389 struct ipv4_hdr *iphdr;
390 uint32_t dest_addr, port_mask, port_num, use_clone;
395 struct ether_addr as_addr;
398 /* Remove the Ethernet header from the input packet */
399 iphdr = (struct ipv4_hdr *)rte_pktmbuf_adj(m, (uint16_t)sizeof(struct ether_hdr));
400 RTE_MBUF_ASSERT(iphdr != NULL);
402 dest_addr = rte_be_to_cpu_32(iphdr->dst_addr);
405 * Check that it is a valid multicast address and
406 * we have some active ports assigned to it.
408 if(!IS_IPV4_MCAST(dest_addr) ||
409 (hash = rte_fbk_hash_lookup(mcast_hash, dest_addr)) <= 0 ||
410 (port_mask = hash & enabled_port_mask) == 0) {
415 /* Calculate number of destination ports. */
416 port_num = bitcnt(port_mask);
418 /* Should we use rte_pktmbuf_clone() or not. */
419 use_clone = (port_num <= MCAST_CLONE_PORTS &&
420 m->pkt.nb_segs <= MCAST_CLONE_SEGS);
422 /* Mark all packet's segments as referenced port_num times */
424 rte_pktmbuf_refcnt_update(m, (uint16_t)port_num);
426 /* construct destination ethernet address */
427 dst_eth_addr.as_int = ETHER_ADDR_FOR_IPV4_MCAST(dest_addr);
429 for (port = 0; use_clone != port_mask; port_mask >>= 1, port++) {
431 /* Prepare output packet and send it out. */
432 if ((port_mask & 1) != 0) {
433 if (likely ((mc = mcast_out_pkt(m, use_clone)) != NULL))
434 mcast_send_pkt(mc, &dst_eth_addr.as_addr,
436 else if (use_clone == 0)
442 * If we making clone packets, then, for the last destination port,
443 * we can overwrite input packet's metadata.
446 mcast_send_pkt(m, &dst_eth_addr.as_addr, qconf, port);
451 /* Send burst of outgoing packet, if timeout expires. */
453 send_timeout_burst(struct lcore_queue_conf *qconf)
458 cur_tsc = rte_rdtsc();
459 if (likely (cur_tsc < qconf->tx_tsc + BURST_TX_DRAIN))
462 for (portid = 0; portid < MAX_PORTS; portid++) {
463 if (qconf->tx_mbufs[portid].len != 0)
464 send_burst(qconf, portid);
466 qconf->tx_tsc = cur_tsc;
469 /* main processing loop */
470 static __attribute__((noreturn)) int
471 main_loop(__rte_unused void *dummy)
473 struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
477 struct lcore_queue_conf *qconf;
479 lcore_id = rte_lcore_id();
480 qconf = &lcore_queue_conf[lcore_id];
483 if (qconf->n_rx_queue == 0) {
484 RTE_LOG(INFO, IPv4_MULTICAST, "lcore %u has nothing to do\n",
489 RTE_LOG(INFO, IPv4_MULTICAST, "entering main loop on lcore %u\n",
492 for (i = 0; i < qconf->n_rx_queue; i++) {
494 portid = qconf->rx_queue_list[i];
495 RTE_LOG(INFO, IPv4_MULTICAST, " -- lcoreid=%u portid=%d\n",
496 lcore_id, (int) portid);
502 * Read packet from RX queues
504 for (i = 0; i < qconf->n_rx_queue; i++) {
506 portid = qconf->rx_queue_list[i];
507 nb_rx = rte_eth_rx_burst(portid, 0, pkts_burst,
510 /* Prefetch first packets */
511 for (j = 0; j < PREFETCH_OFFSET && j < nb_rx; j++) {
512 rte_prefetch0(rte_pktmbuf_mtod(
513 pkts_burst[j], void *));
516 /* Prefetch and forward already prefetched packets */
517 for (j = 0; j < (nb_rx - PREFETCH_OFFSET); j++) {
518 rte_prefetch0(rte_pktmbuf_mtod(pkts_burst[
519 j + PREFETCH_OFFSET], void *));
520 mcast_forward(pkts_burst[j], qconf);
523 /* Forward remaining prefetched packets */
524 for (; j < nb_rx; j++) {
525 mcast_forward(pkts_burst[j], qconf);
529 /* Send out packets from TX queues */
530 send_timeout_burst(qconf);
536 print_usage(const char *prgname)
538 printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n"
539 " -p PORTMASK: hexadecimal bitmask of ports to configure\n"
540 " -q NQ: number of queue (=ports) per lcore (default is 1)\n",
545 parse_portmask(const char *portmask)
550 /* parse hexadecimal string */
551 pm = strtoul(portmask, &end, 16);
552 if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
555 return ((uint32_t)pm);
559 parse_nqueue(const char *q_arg)
564 /* parse numerical string */
566 n = strtoul(q_arg, &end, 0);
567 if (errno != 0 || end == NULL || *end != '\0' ||
568 n == 0 || n >= MAX_RX_QUEUE_PER_LCORE)
574 /* Parse the argument given in the command line of the application */
576 parse_args(int argc, char **argv)
581 char *prgname = argv[0];
582 static struct option lgopts[] = {
588 while ((opt = getopt_long(argc, argvopt, "p:q:",
589 lgopts, &option_index)) != EOF) {
594 enabled_port_mask = parse_portmask(optarg);
595 if (enabled_port_mask == 0) {
596 printf("invalid portmask\n");
597 print_usage(prgname);
604 rx_queue_per_lcore = parse_nqueue(optarg);
605 if (rx_queue_per_lcore < 0) {
606 printf("invalid queue number\n");
607 print_usage(prgname);
613 print_usage(prgname);
619 argv[optind-1] = prgname;
622 optind = 0; /* reset getopt lib */
627 print_ethaddr(const char *name, struct ether_addr *eth_addr)
629 printf("%s%02X:%02X:%02X:%02X:%02X:%02X", name,
630 eth_addr->addr_bytes[0],
631 eth_addr->addr_bytes[1],
632 eth_addr->addr_bytes[2],
633 eth_addr->addr_bytes[3],
634 eth_addr->addr_bytes[4],
635 eth_addr->addr_bytes[5]);
639 init_mcast_hash(void)
643 mcast_hash = rte_fbk_hash_create(&mcast_hash_params);
644 if (mcast_hash == NULL){
648 for (i = 0; i < N_MCAST_GROUPS; i ++){
649 if (rte_fbk_hash_add_key(mcast_hash,
650 mcast_group_table[i].ip,
651 mcast_group_table[i].port_mask) < 0) {
660 MAIN(int argc, char **argv)
662 struct lcore_queue_conf *qconf;
663 struct rte_eth_link link;
666 unsigned lcore_id = 0, rx_lcore_id = 0;;
667 uint32_t n_tx_queue, nb_lcores;
671 ret = rte_eal_init(argc, argv);
673 rte_exit(EXIT_FAILURE, "Invalid EAL parameters\n");
677 /* parse application arguments (after the EAL ones) */
678 ret = parse_args(argc, argv);
680 rte_exit(EXIT_FAILURE, "Invalid IPV4_MULTICAST parameters\n");
682 /* create the mbuf pools */
683 packet_pool = rte_mempool_create("packet_pool", NB_PKT_MBUF,
684 PKT_MBUF_SIZE, 32, sizeof(struct rte_pktmbuf_pool_private),
685 rte_pktmbuf_pool_init, NULL, rte_pktmbuf_init, NULL,
688 if (packet_pool == NULL)
689 rte_exit(EXIT_FAILURE, "Cannot init packet mbuf pool\n");
691 header_pool = rte_mempool_create("header_pool", NB_HDR_MBUF,
692 HDR_MBUF_SIZE, 32, 0, NULL, NULL, rte_pktmbuf_init, NULL,
695 if (header_pool == NULL)
696 rte_exit(EXIT_FAILURE, "Cannot init header mbuf pool\n");
698 clone_pool = rte_mempool_create("clone_pool", NB_CLONE_MBUF,
699 CLONE_MBUF_SIZE, 32, 0, NULL, NULL, rte_pktmbuf_init, NULL,
702 if (clone_pool == NULL)
703 rte_exit(EXIT_FAILURE, "Cannot init clone mbuf pool\n");
706 #ifdef RTE_LIBRTE_IGB_PMD
707 if (rte_igb_pmd_init() < 0)
708 rte_exit(EXIT_FAILURE, "Cannot init igb pmd\n");
710 #ifdef RTE_LIBRTE_IXGBE_PMD
711 if (rte_ixgbe_pmd_init() < 0)
712 rte_exit(EXIT_FAILURE, "Cannot init ixgbe pmd\n");
715 if (rte_eal_pci_probe() < 0)
716 rte_exit(EXIT_FAILURE, "Cannot probe PCI\n");
718 nb_ports = rte_eth_dev_count();
720 rte_exit(EXIT_FAILURE, "No physical ports!\n");
721 if (nb_ports > MAX_PORTS)
722 nb_ports = MAX_PORTS;
724 nb_lcores = rte_lcore_count();
726 /* initialize all ports */
727 for (portid = 0; portid < nb_ports; portid++) {
728 /* skip ports that are not enabled */
729 if ((enabled_port_mask & (1 << portid)) == 0) {
730 printf("Skipping disabled port %d\n", portid);
734 qconf = &lcore_queue_conf[rx_lcore_id];
736 /* get the lcore_id for this port */
737 while (rte_lcore_is_enabled(rx_lcore_id) == 0 ||
738 qconf->n_rx_queue == (unsigned)rx_queue_per_lcore) {
741 qconf = &lcore_queue_conf[rx_lcore_id];
743 if (rx_lcore_id >= RTE_MAX_LCORE)
744 rte_exit(EXIT_FAILURE, "Not enough cores\n");
746 qconf->rx_queue_list[qconf->n_rx_queue] = portid;
750 printf("Initializing port %d on lcore %u... ", portid,
754 n_tx_queue = nb_lcores;
755 if (n_tx_queue > MAX_TX_QUEUE_PER_PORT)
756 n_tx_queue = MAX_TX_QUEUE_PER_PORT;
757 ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
760 rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%d\n",
763 rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
764 print_ethaddr(" Address:", &ports_eth_addr[portid]);
767 /* init one RX queue */
769 printf("rxq=%hu ", queueid);
771 ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
775 rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, port=%d\n",
778 /* init one TX queue per couple (lcore,port) */
781 RTE_LCORE_FOREACH(lcore_id) {
782 if (rte_lcore_is_enabled(lcore_id) == 0)
784 printf("txq=%u,%hu ", lcore_id, queueid);
786 ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
789 rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, "
790 "port=%d\n", ret, portid);
792 qconf = &lcore_queue_conf[lcore_id];
793 qconf->tx_queue_id[portid] = queueid;
798 ret = rte_eth_dev_start(portid);
800 rte_exit(EXIT_FAILURE, "rte_eth_dev_start: err=%d, port=%d\n",
805 /* get link status */
806 rte_eth_link_get(portid, &link);
807 if (link.link_status) {
808 printf(" Link Up - speed %u Mbps - %s\n",
809 (uint32_t) link.link_speed,
810 (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
811 ("full-duplex") : ("half-duplex\n"));
812 rte_eth_promiscuous_enable(portid);
813 rte_eth_allmulticast_enable(portid);
815 printf(" Link Down\n");
820 /* initialize the multicast hash */
821 int retval = init_mcast_hash();
823 rte_exit(EXIT_FAILURE, "Cannot build the multicast hash\n");
825 /* launch per-lcore init on every lcore */
826 rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
827 RTE_LCORE_FOREACH_SLAVE(lcore_id) {
828 if (rte_eal_wait_lcore(lcore_id) < 0)