MCPcopy Create free account
hub / github.com/F-Stack/f-stack / check_all_ports_link_status

Function check_all_ports_link_status

dpdk/app/graph/graph.c:32–99  ·  view source on GitHub ↗

Check the link rc of all ports in up to 9s, and print them finally */

Source from the content-addressed store, hash-verified

30
31/* Check the link rc of all ports in up to 9s, and print them finally */
32static void
33check_all_ports_link_status(uint32_t port_mask)
34{
35#define CHECK_INTERVAL 100 /* 100ms */
36#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
37 char link_rc_text[RTE_ETH_LINK_MAX_STR_LEN];
38 uint8_t count, all_ports_up, print_flag = 0;
39 struct rte_eth_link link;
40 uint16_t portid;
41 int rc;
42
43 printf("\nChecking link status...");
44 fflush(stdout);
45 for (count = 0; count <= MAX_CHECK_TIME; count++) {
46 if (force_quit)
47 return;
48
49 all_ports_up = 1;
50 RTE_ETH_FOREACH_DEV(portid)
51 {
52 if (force_quit)
53 return;
54
55 if ((port_mask & (1 << portid)) == 0)
56 continue;
57
58 memset(&link, 0, sizeof(link));
59 rc = rte_eth_link_get_nowait(portid, &link);
60 if (rc < 0) {
61 all_ports_up = 0;
62 if (print_flag == 1)
63 printf("Port %u link get failed: %s\n",
64 portid, rte_strerror(-rc));
65 continue;
66 }
67
68 /* Print link rc if flag set */
69 if (print_flag == 1) {
70 rte_eth_link_to_str(link_rc_text, sizeof(link_rc_text),
71 &link);
72 printf("Port %d %s\n", portid, link_rc_text);
73 continue;
74 }
75
76 /* Clear all_ports_up flag if any link down */
77 if (link.link_status == RTE_ETH_LINK_DOWN) {
78 all_ports_up = 0;
79 break;
80 }
81 }
82
83 /* After finally printing all link rc, get out */
84 if (print_flag == 1)
85 break;
86
87 if (all_ports_up == 0) {
88 printf(".");
89 fflush(stdout);

Callers 1

Calls 6

memsetFunction · 0.85
rte_eth_link_get_nowaitFunction · 0.85
rte_strerrorFunction · 0.85
rte_eth_link_to_strFunction · 0.85
rte_delay_msFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected