]> git.droids-corp.org - dpdk.git/commitdiff
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 55bf58d1b11d657b958b440f2d1aabf089325199..356ec3aaed89dd5c87f78068e5bb89efa5f3fcec 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 145b128941077afb32ca8c5f16801fe15a01214d..31dff5a7d354c55843e737962de0a47f937245f4 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 3b9101130599d7adc35b40877358990424dd1d92..f9304d112ef50bc5d152237a4458e39bfc34e7e4 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 e825a646a563d863222766644cab2dc167b393c2..e420b7b0c2a0831c6e82c8c853e61cc0e812cb0d 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 22bc388b985ecaf85368253ebfc418453a9aed79..79c30a83bf42046a660d2f28450a710c6982e105 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 a6c04320d69eff1e9daa94f02afe0f0012c2902c..5b1d9c1414a98afc11aaadc5892aeb6e0776d854 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 c513a1ec1dfe59f2ec7c6dbfc75cedb75500520d..d9a811b2b0b4ff3449057a0aba3d329140566cc8 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 2abdfc00503af91c1aa76568b0c923ec83a833b5..b45e0201b676b245643ecde450e8e8391bbb13fe 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 b796e76db7ba6eb2957c51369b279325f75562b0..43e0ab52259b2a8d7a01b9c8c04a71ab21f9e6fc 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;
 }