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

Function handle_dev_xstats

dpdk/lib/rawdev/rte_rawdev.c:582–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

580}
581
582static int
583handle_dev_xstats(const char *cmd __rte_unused,
584 const char *params,
585 struct rte_tel_data *d)
586{
587 uint64_t *rawdev_xstats;
588 struct rte_rawdev_xstats_name *xstat_names;
589 int dev_id, num_xstats, i, ret;
590 unsigned int *ids;
591 char *end_param;
592
593 if (params == NULL || strlen(params) == 0 || !isdigit(*params))
594 return -1;
595
596 dev_id = strtoul(params, &end_param, 0);
597 if (*end_param != '\0')
598 RTE_RDEV_LOG(NOTICE,
599 "Extra parameters passed to rawdev telemetry command, ignoring");
600 if (!rte_rawdev_pmd_is_valid_dev(dev_id))
601 return -1;
602
603 num_xstats = xstats_get_count(dev_id);
604 if (num_xstats < 0)
605 return -1;
606
607 /* use one malloc for names, stats and ids */
608 rawdev_xstats = malloc((sizeof(uint64_t) +
609 sizeof(struct rte_rawdev_xstats_name) +
610 sizeof(unsigned int)) * num_xstats);
611 if (rawdev_xstats == NULL)
612 return -1;
613 xstat_names = (void *)&rawdev_xstats[num_xstats];
614 ids = (void *)&xstat_names[num_xstats];
615
616 ret = rte_rawdev_xstats_names_get(dev_id, xstat_names, num_xstats);
617 if (ret < 0 || ret > num_xstats) {
618 free(rawdev_xstats);
619 return -1;
620 }
621
622 for (i = 0; i < num_xstats; i++)
623 ids[i] = i;
624
625 ret = rte_rawdev_xstats_get(dev_id, ids, rawdev_xstats, num_xstats);
626 if (ret < 0 || ret > num_xstats) {
627 free(rawdev_xstats);
628 return -1;
629 }
630
631 rte_tel_data_start_dict(d);
632 for (i = 0; i < num_xstats; i++)
633 rte_tel_data_add_dict_uint(d, xstat_names[i].name,
634 rawdev_xstats[i]);
635
636 free(rawdev_xstats);
637 return 0;
638}
639

Callers

nothing calls this directly

Calls 10

isdigitFunction · 0.85
strtoulFunction · 0.85
mallocFunction · 0.85
rte_rawdev_xstats_getFunction · 0.85
rte_tel_data_start_dictFunction · 0.85
xstats_get_countFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected