net/sfc/base: fix error code usage in common code
[dpdk.git] / examples / distributor / main.c
index 53c7b38..8071f91 100644 (file)
@@ -257,7 +257,7 @@ lcore_rx(struct lcore_params *p)
 
                struct rte_ring *tx_ring = p->dist_tx_ring;
                uint16_t sent = rte_ring_enqueue_burst(tx_ring,
 
                struct rte_ring *tx_ring = p->dist_tx_ring;
                uint16_t sent = rte_ring_enqueue_burst(tx_ring,
-                               (void *)bufs, nb_ret);
+                               (void *)bufs, nb_ret, NULL);
 #else
                uint16_t nb_ret = nb_rx;
                /*
 #else
                uint16_t nb_ret = nb_rx;
                /*
@@ -268,7 +268,7 @@ lcore_rx(struct lcore_params *p)
                /* struct rte_ring *out_ring = p->dist_tx_ring; */
 
                uint16_t sent = rte_ring_enqueue_burst(out_ring,
                /* struct rte_ring *out_ring = p->dist_tx_ring; */
 
                uint16_t sent = rte_ring_enqueue_burst(out_ring,
-                               (void *)bufs, nb_ret);
+                               (void *)bufs, nb_ret, NULL);
 #endif
 
                app_stats.rx.enqueued_pkts += sent;
 #endif
 
                app_stats.rx.enqueued_pkts += sent;
@@ -334,7 +334,7 @@ lcore_distributor(struct lcore_params *p)
        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,
        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);
+                               (void *)bufs, BURST_SIZE*1, NULL);
                if (nb_rx) {
                        app_stats.dist.in_pkts += nb_rx;
 
                if (nb_rx) {
                        app_stats.dist.in_pkts += nb_rx;
 
@@ -350,7 +350,7 @@ lcore_distributor(struct lcore_params *p)
                        app_stats.dist.ret_pkts += nb_ret;
 
                        uint16_t sent = rte_ring_enqueue_burst(out_r,
                        app_stats.dist.ret_pkts += nb_ret;
 
                        uint16_t sent = rte_ring_enqueue_burst(out_r,
-                                       (void *)bufs, nb_ret);
+                                       (void *)bufs, nb_ret, NULL);
                        app_stats.dist.sent_pkts += sent;
                        if (unlikely(sent < nb_ret)) {
                                app_stats.dist.enqdrop_pkts += nb_ret - sent;
                        app_stats.dist.sent_pkts += sent;
                        if (unlikely(sent < nb_ret)) {
                                app_stats.dist.enqdrop_pkts += nb_ret - sent;
@@ -403,7 +403,7 @@ lcore_tx(struct rte_ring *in_r)
 
                        struct rte_mbuf *bufs[BURST_SIZE_TX];
                        const uint16_t nb_rx = rte_ring_dequeue_burst(in_r,
 
                        struct rte_mbuf *bufs[BURST_SIZE_TX];
                        const uint16_t nb_rx = rte_ring_dequeue_burst(in_r,
-                                       (void *)bufs, BURST_SIZE_TX);
+                                       (void *)bufs, BURST_SIZE_TX, NULL);
                        app_stats.tx.dequeue_pkts += nb_rx;
 
                        /* if we get no traffic, flush anything we have */
                        app_stats.tx.dequeue_pkts += nb_rx;
 
                        /* if we get no traffic, flush anything we have */
@@ -680,9 +680,10 @@ main(int argc, char *argv[])
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Invalid distributor parameters\n");
 
        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 "
                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"
                                "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(),
        }
 
        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");
                        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);
                        /* 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);
                } 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++;
        }
                }
                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;
 
        freq = rte_get_timer_hz();
        t = rte_rdtsc() + freq;