From: Intel Date: Mon, 3 Jun 2013 00:00:00 +0000 (+0000) Subject: examples: work only on defined lcores X-Git-Tag: spdx-start~11192 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cdfd5dbb90b05e198b436f97f0ba320d7cd7d8ad;p=dpdk.git examples: work only on defined lcores Signed-off-by: Intel --- diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index 55bf58d1b1..356ec3aaed 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -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() diff --git a/examples/ipv4_frag/main.c b/examples/ipv4_frag/main.c index 145b128941..31dff5a7d3 100644 --- a/examples/ipv4_frag/main.c +++ b/examples/ipv4_frag/main.c @@ -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); diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 3b91011305..f9304d112e 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -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", diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index e825a646a5..e420b7b0c2 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -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); diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c index 22bc388b98..79c30a83bf 100644 --- a/examples/l3fwd-vf/main.c +++ b/examples/l3fwd-vf/main.c @@ -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); diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index a6c04320d6..5b1d9c1414 100755 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -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); diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index c513a1ec1d..d9a811b2b0 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -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); diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c index 2abdfc0050..b45e0201b6 100644 --- a/examples/multi_process/client_server_mp/mp_server/init.c +++ b/examples/multi_process/client_server_mp/mp_server/init.c @@ -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 */ diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c index b796e76db7..43e0ab5225 100644 --- a/examples/multi_process/client_server_mp/mp_server/main.c +++ b/examples/multi_process/client_server_mp/mp_server/main.c @@ -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; }