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

Function print_link_info

dpdk/examples/ip_pipeline/cli.c:243–296  ·  view source on GitHub ↗

Print the link stats and info */

Source from the content-addressed store, hash-verified

241
242/* Print the link stats and info */
243static void
244print_link_info(struct link *link, char *out, size_t out_size)
245{
246 struct rte_eth_stats stats;
247 struct rte_ether_addr mac_addr;
248 struct rte_eth_link eth_link;
249 uint16_t mtu;
250 int ret;
251
252 memset(&stats, 0, sizeof(stats));
253 rte_eth_stats_get(link->port_id, &stats);
254
255 ret = rte_eth_macaddr_get(link->port_id, &mac_addr);
256 if (ret != 0) {
257 snprintf(out, out_size, "\n%s: MAC address get failed: %s",
258 link->name, rte_strerror(-ret));
259 return;
260 }
261
262 ret = rte_eth_link_get(link->port_id, &eth_link);
263 if (ret < 0) {
264 snprintf(out, out_size, "\n%s: link get failed: %s",
265 link->name, rte_strerror(-ret));
266 return;
267 }
268
269 rte_eth_dev_get_mtu(link->port_id, &mtu);
270
271 snprintf(out, out_size,
272 "\n"
273 "%s: flags=<%s> mtu %u\n"
274 "\tether " RTE_ETHER_ADDR_PRT_FMT " rxqueues %u txqueues %u\n"
275 "\tport# %u speed %s\n"
276 "\tRX packets %" PRIu64" bytes %" PRIu64"\n"
277 "\tRX errors %" PRIu64" missed %" PRIu64" no-mbuf %" PRIu64"\n"
278 "\tTX packets %" PRIu64" bytes %" PRIu64"\n"
279 "\tTX errors %" PRIu64"\n",
280 link->name,
281 eth_link.link_status == 0 ? "DOWN" : "UP",
282 mtu,
283 RTE_ETHER_ADDR_BYTES(&mac_addr),
284 link->n_rxq,
285 link->n_txq,
286 link->port_id,
287 rte_eth_link_speed_to_str(eth_link.link_speed),
288 stats.ipackets,
289 stats.ibytes,
290 stats.ierrors,
291 stats.imissed,
292 stats.rx_nombuf,
293 stats.opackets,
294 stats.obytes,
295 stats.oerrors);
296}
297
298/*
299 * link show [<link_name>]

Callers 1

cmd_link_showFunction · 0.70

Calls 8

memsetFunction · 0.85
rte_eth_stats_getFunction · 0.85
rte_eth_macaddr_getFunction · 0.85
snprintfFunction · 0.85
rte_strerrorFunction · 0.85
rte_eth_link_getFunction · 0.85
rte_eth_dev_get_mtuFunction · 0.85

Tested by

no test coverage detected