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

Function nic_xstats_display_periodic

dpdk/app/test-pmd/config.c:217–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217static void
218nic_xstats_display_periodic(portid_t port_id)
219{
220 struct xstat_display_info *xstats_info;
221 uint64_t *prev_values, *curr_values;
222 uint64_t diff_value, value_rate;
223 struct timespec cur_time;
224 uint64_t *ids_supp;
225 size_t ids_supp_sz;
226 uint64_t diff_ns;
227 unsigned int i;
228 int rc;
229
230 xstats_info = &ports[port_id].xstats_info;
231
232 ids_supp_sz = xstats_info->ids_supp_sz;
233 if (ids_supp_sz == 0)
234 return;
235
236 printf("\n");
237
238 ids_supp = xstats_info->ids_supp;
239 prev_values = xstats_info->prev_values;
240 curr_values = xstats_info->curr_values;
241
242 rc = rte_eth_xstats_get_by_id(port_id, ids_supp, curr_values,
243 ids_supp_sz);
244 if (rc != (int)ids_supp_sz) {
245 fprintf(stderr,
246 "Failed to get values of %zu xstats for port %u - return code %d\n",
247 ids_supp_sz, port_id, rc);
248 return;
249 }
250
251 diff_ns = 0;
252 if (clock_gettime(CLOCK_TYPE_ID, &cur_time) == 0) {
253 uint64_t ns;
254
255 ns = cur_time.tv_sec * NS_PER_SEC;
256 ns += cur_time.tv_nsec;
257
258 if (xstats_info->prev_ns != 0)
259 diff_ns = ns - xstats_info->prev_ns;
260 xstats_info->prev_ns = ns;
261 }
262
263 printf("%-31s%-17s%s\n", " ", "Value", "Rate (since last show)");
264 for (i = 0; i < ids_supp_sz; i++) {
265 diff_value = (curr_values[i] > prev_values[i]) ?
266 (curr_values[i] - prev_values[i]) : 0;
267 prev_values[i] = curr_values[i];
268 value_rate = diff_ns > 0 ?
269 (double)diff_value / diff_ns * NS_PER_SEC : 0;
270
271 printf(" %-25s%12"PRIu64" %15"PRIu64"\n",
272 xstats_display[i].name, curr_values[i], value_rate);
273 }
274}

Callers 1

nic_stats_displayFunction · 0.85

Calls 2

rte_eth_xstats_get_by_idFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected