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

Function print_stats

dpdk/examples/link_status_interrupt/main.c:107–167  ·  view source on GitHub ↗

Print out statistics on packets dropped */

Source from the content-addressed store, hash-verified

105
106/* Print out statistics on packets dropped */
107static void
108print_stats(void)
109{
110 struct rte_eth_link link;
111 uint64_t total_packets_dropped, total_packets_tx, total_packets_rx;
112 uint16_t portid;
113
114 total_packets_dropped = 0;
115 total_packets_tx = 0;
116 total_packets_rx = 0;
117
118 const char clr[] = { 27, '[', '2', 'J', '\0' };
119 const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' };
120 int link_get_err;
121
122 /* Clear screen and move to top left */
123 printf("%s%s", clr, topLeft);
124
125 printf("\nPort statistics ====================================");
126
127 for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
128 /* skip ports that are not enabled */
129 if ((lsi_enabled_port_mask & (1 << portid)) == 0)
130 continue;
131
132 memset(&link, 0, sizeof(link));
133 link_get_err = rte_eth_link_get_nowait(portid, &link);
134 printf("\nStatistics for port %u ------------------------------"
135 "\nLink status: %25s"
136 "\nLink speed: %26s"
137 "\nLink duplex: %25s"
138 "\nPackets sent: %24"PRIu64
139 "\nPackets received: %20"PRIu64
140 "\nPackets dropped: %21"PRIu64,
141 portid,
142 link_get_err < 0 ? "Link get failed" :
143 (link.link_status ? "Link up" : "Link down"),
144 link_get_err < 0 ? "0" :
145 rte_eth_link_speed_to_str(link.link_speed),
146 link_get_err < 0 ? "Link get failed" :
147 (link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX ?
148 "full-duplex" : "half-duplex"),
149 port_statistics[portid].tx,
150 port_statistics[portid].rx,
151 port_statistics[portid].dropped);
152
153 total_packets_dropped += port_statistics[portid].dropped;
154 total_packets_tx += port_statistics[portid].tx;
155 total_packets_rx += port_statistics[portid].rx;
156 }
157 printf("\nAggregate statistics ==============================="
158 "\nTotal packets sent: %18"PRIu64
159 "\nTotal packets received: %14"PRIu64
160 "\nTotal packets dropped: %15"PRIu64,
161 total_packets_tx,
162 total_packets_rx,
163 total_packets_dropped);
164 printf("\n====================================================\n");

Callers 1

lsi_main_loopFunction · 0.70

Calls 4

memsetFunction · 0.85
rte_eth_link_get_nowaitFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected