examples: work only on defined lcores
authorIntel <intel.com>
Mon, 3 Jun 2013 00:00:00 +0000 (00:00 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 17 Sep 2013 12:16:09 +0000 (14:16 +0200)
Signed-off-by: Intel
examples/exception_path/main.c
examples/ipv4_frag/main.c
examples/ipv4_multicast/main.c
examples/l2fwd/main.c
examples/l3fwd-vf/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/multi_process/client_server_mp/mp_server/init.c
examples/multi_process/client_server_mp/mp_server/main.c

index 55bf58d..356ec3a 100644 (file)
@@ -245,21 +245,21 @@ static int tap_create(char *name)
 }
 
 /* Main processing loop */
-static  __attribute__((noreturn)) int
+static int
 main_loop(__attribute__((unused)) void *arg)
 {
        const unsigned lcore_id = rte_lcore_id();
        char tap_name[IFNAMSIZ];
        int tap_fd;
 
-       /* Create new tap interface */
-       rte_snprintf(tap_name, IFNAMSIZ, "tap_dpdk_%.2u", lcore_id);
-       tap_fd = tap_create(tap_name);
-       if (tap_fd < 0)
-               FATAL_ERROR("Could not create tap interface \"%s\" (%d)",
-                           tap_name, tap_fd);
-
        if ((1 << lcore_id) & input_cores_mask) {
+               /* Create new tap interface */
+               rte_snprintf(tap_name, IFNAMSIZ, "tap_dpdk_%.2u", lcore_id);
+               tap_fd = tap_create(tap_name);
+               if (tap_fd < 0)
+                       FATAL_ERROR("Could not create tap interface \"%s\" (%d)",
+                                       tap_name, tap_fd);
+
                PRINT_INFO("Lcore %u is reading from port %u and writing to %s",
                           lcore_id, (unsigned)port_ids[lcore_id], tap_name);
                fflush(stdout);
@@ -286,6 +286,13 @@ main_loop(__attribute__((unused)) void *arg)
                }
        }
        else if ((1 << lcore_id) & output_cores_mask) {
+               /* Create new tap interface */
+               rte_snprintf(tap_name, IFNAMSIZ, "tap_dpdk_%.2u", lcore_id);
+               tap_fd = tap_create(tap_name);
+               if (tap_fd < 0)
+                       FATAL_ERROR("Could not create tap interface \"%s\" (%d)",
+                                       tap_name, tap_fd);
+
                PRINT_INFO("Lcore %u is reading from %s and writing to port %u",
                           lcore_id, tap_name, (unsigned)port_ids[lcore_id]);
                fflush(stdout);
@@ -318,8 +325,7 @@ main_loop(__attribute__((unused)) void *arg)
        }
        else {
                PRINT_INFO("Lcore %u has nothing to do", lcore_id);
-               for (;;)
-                       ; /* loop doing nothing */
+               return 0;
        }
        /*
         * Tap file is closed automatically when program exits. Putting close()
index 145b128..31dff5a 100644 (file)
@@ -304,7 +304,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t port_in)
 }
 
 /* main processing loop */
-static __attribute__((noreturn)) int
+static int
 main_loop(__attribute__((unused)) void *dummy)
 {
        struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -322,7 +322,7 @@ main_loop(__attribute__((unused)) void *dummy)
 
        if (qconf->n_rx_queue == 0) {
                RTE_LOG(INFO, L3FWD, "lcore %u has nothing to do\n", lcore_id);
-               while(1);
+               return 0;
        }
 
        RTE_LOG(INFO, L3FWD, "entering main loop on lcore %u\n", lcore_id);
index 3b91011..f9304d1 100644 (file)
@@ -464,7 +464,7 @@ send_timeout_burst(struct lcore_queue_conf *qconf)
 }
 
 /* main processing loop */
-static __attribute__((noreturn)) int
+static int
 main_loop(__rte_unused void *dummy)
 {
        struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -480,7 +480,7 @@ main_loop(__rte_unused void *dummy)
        if (qconf->n_rx_queue == 0) {
                RTE_LOG(INFO, IPv4_MULTICAST, "lcore %u has nothing to do\n",
                    lcore_id);
-               while(1);
+               return 0;
        }
 
        RTE_LOG(INFO, IPv4_MULTICAST, "entering main loop on lcore %u\n",
index e825a64..e420b7b 100644 (file)
@@ -313,7 +313,7 @@ l2fwd_main_loop(void)
 
        if (qconf->n_rx_port == 0) {
                RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id);
-               while(1);
+               return;
        }
 
        RTE_LOG(INFO, L2FWD, "entering main loop on lcore %u\n", lcore_id);
index 22bc388..79c30a8 100644 (file)
@@ -495,7 +495,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, lookup_struct_t * l3fwd
 }
 
 /* main processing loop */
-static __attribute__((noreturn)) int
+static int
 main_loop(__attribute__((unused)) void *dummy)
 {
        struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -513,7 +513,7 @@ main_loop(__attribute__((unused)) void *dummy)
 
        if (qconf->n_rx_queue == 0) {
                RTE_LOG(INFO, L3FWD, "lcore %u has nothing to do\n", lcore_id);
-               while(1);
+               return 0;
        }
 
        RTE_LOG(INFO, L3FWD, "entering main loop on lcore %u\n", lcore_id);
index a6c0432..5b1d9c1 100755 (executable)
@@ -645,7 +645,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t portid, struct lcore_conf *qcon
 }
 
 /* main processing loop */
-static __attribute__((noreturn)) int
+static int
 main_loop(__attribute__((unused)) void *dummy)
 {
        struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
@@ -663,7 +663,7 @@ main_loop(__attribute__((unused)) void *dummy)
 
        if (qconf->n_rx_queue == 0) {
                RTE_LOG(INFO, L3FWD, "lcore %u has nothing to do\n", lcore_id);
-               while(1);
+               return 0;
        }
 
        RTE_LOG(INFO, L3FWD, "entering main loop on lcore %u\n", lcore_id);
index c513a1e..d9a811b 100644 (file)
@@ -330,7 +330,7 @@ lsi_main_loop(void)
 
        if (qconf->n_rx_port == 0) {
                RTE_LOG(INFO, LSI, "lcore %u has nothing to do\n", lcore_id);
-               while(1);
+               return;
        }
 
        RTE_LOG(INFO, LSI, "entering main loop on lcore %u\n", lcore_id);
index 2abdfc0..b45e020 100644 (file)
@@ -250,21 +250,21 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
                for (portid = 0; portid < port_num; portid++) {
-                       if ((port_mask & (1 << portid)) == 0)
+                       if ((port_mask & (1 << ports->id[portid])) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       rte_eth_link_get_nowait(ports->id[portid], &link);
                        /* print link status if flag set */
                        if (print_flag == 1) {
                                if (link.link_status)
                                        printf("Port %d Link Up - speed %u "
-                                               "Mbps - %s\n", (uint8_t)portid,
+                                               "Mbps - %s\n", ports->id[portid],
                                                (unsigned)link.link_speed,
                                (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
                                        ("full-duplex") : ("half-duplex\n"));
                                else
                                        printf("Port %d Link Down\n",
-                                               (uint8_t)portid);
+                                               (uint8_t)ports->id[portid]);
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
index b796e76..43e0ab5 100644 (file)
@@ -138,8 +138,8 @@ do_stats_display(void)
                const volatile struct tx_stats *tx = &ports->tx_stats[i];
                for (j = 0; j < ports->num_ports; j++){
                        /* assign to local variables here, save re-reading volatile vars */
-                       const uint64_t tx_val = tx->tx[j];
-                       const uint64_t drop_val = tx->tx_drop[j];
+                       const uint64_t tx_val = tx->tx[ports->id[j]];
+                       const uint64_t drop_val = tx->tx_drop[ports->id[j]];
                        port_tx[j] += tx_val;
                        port_tx_drop[j] += drop_val;
                        client_tx[i] += tx_val;
@@ -200,12 +200,6 @@ sleep_lcore(__attribute__((unused)) void *dummy)
                while (sleep(sleeptime) <= sleeptime)
                        do_stats_display();
        }
-       else {
-               const unsigned sleeptime = 100;
-               printf("Putting core %u to sleep\n", rte_lcore_id());
-               while (sleep(sleeptime) <= sleeptime)
-                       ; /* loop doing nothing */
-       }
        return 0;
 }