summaryrefslogtreecommitdiff
path: root/examples/multi_process/client_server_mp
diff options
context:
space:
mode:
authorIntel <intel.com>2012-12-20 00:00:00 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2013-07-25 15:57:45 +0200
commitd3641ae86313ac8da51faeff980022ebe18bd2bd (patch)
tree38de055bf6804fdc3e3fc7c685bb59aad2cc4ad0 /examples/multi_process/client_server_mp
parent90dc1a670c6dd26584e5fbbf03e143f61b35ffdf (diff)
downloaddpdk-d3641ae86313ac8da51faeff980022ebe18bd2bd.zip
dpdk-d3641ae86313ac8da51faeff980022ebe18bd2bd.tar.gz
dpdk-d3641ae86313ac8da51faeff980022ebe18bd2bd.tar.xz
examples: update link status checks
Signed-off-by: Intel
Diffstat (limited to 'examples/multi_process/client_server_mp')
-rw-r--r--examples/multi_process/client_server_mp/mp_server/init.c72
1 files changed, 59 insertions, 13 deletions
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 6e08a0b..9f5382c 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -65,6 +65,7 @@
#include <rte_hash_crc.h>
#include <rte_fbk_hash.h>
#include <rte_string_fns.h>
+#include <rte_cycles.h>
#include "common.h"
#include "init_drivers.h"
@@ -171,7 +172,6 @@ init_port(uint8_t port_num)
const uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
const uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
- struct rte_eth_link link;
uint16_t q;
int retval;
@@ -201,19 +201,8 @@ init_port(uint8_t port_num)
retval = rte_eth_dev_start(port_num);
if (retval < 0) return retval;
- printf( "done: ");
+ printf( "done: \n");
- /* get link status */
- rte_eth_link_get(port_num, &link);
- if (link.link_status) {
- printf(" Link Up - speed %u Mbps - %s\n",
- (uint32_t) link.link_speed,
- (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex\n"));
- }
- else{
- printf(" Link Down\n");
- }
return 0;
}
@@ -244,6 +233,61 @@ init_shm_rings(void)
return 0;
}
+/* Check the link status of all ports in up to 9s, and print them finally */
+static void
+check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
+{
+#define CHECK_INTERVAL 100 /* 100ms */
+#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
+ uint8_t portid, count, all_ports_up, print_flag = 0;
+ struct rte_eth_link link;
+
+ printf("\nChecking link status");
+ fflush(stdout);
+ 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)
+ continue;
+ memset(&link, 0, sizeof(link));
+ rte_eth_link_get_nowait(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,
+ (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);
+ continue;
+ }
+ /* clear all_ports_up flag if any link down */
+ if (link.link_status == 0) {
+ all_ports_up = 0;
+ break;
+ }
+ }
+ /* after finally printing all link status, get out */
+ if (print_flag == 1)
+ break;
+
+ if (all_ports_up == 0) {
+ printf(".");
+ fflush(stdout);
+ rte_delay_ms(CHECK_INTERVAL);
+ }
+
+ /* set the print_flag if all ports up or timeout */
+ if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
+ print_flag = 1;
+ printf("done\n");
+ }
+ }
+}
+
/**
* Main init function for the multi-process server app,
* calls subfunctions to do each stage of the initialisation.
@@ -296,6 +340,8 @@ init(int argc, char *argv[])
(unsigned)i);
}
+ check_all_ports_link_status(ports->num_ports, (~0x0));
+
/* initialise the client queues/rings for inter-eu comms */
init_shm_rings();