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

Function ntb_stats_display

dpdk/examples/ntb/ntb_fwd.c:821–895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

819}
820
821static void
822ntb_stats_display(void)
823{
824 struct rte_rawdev_xstats_name *xstats_names;
825 struct rte_eth_stats stats;
826 uint64_t *values;
827 uint32_t *ids;
828 int nb_ids, i;
829
830 printf("###### statistics for NTB port %d #######\n", dev_id);
831
832 /* Get NTB dev stats and stats names */
833 nb_ids = rte_rawdev_xstats_names_get(dev_id, NULL, 0);
834 if (nb_ids <= 0) {
835 printf("Error: Cannot get count of xstats\n");
836 return;
837 }
838 xstats_names = malloc(sizeof(struct rte_rawdev_xstats_name) * nb_ids);
839 if (xstats_names == NULL) {
840 printf("Cannot allocate memory for xstats lookup\n");
841 return;
842 }
843 if (nb_ids != rte_rawdev_xstats_names_get(
844 dev_id, xstats_names, nb_ids)) {
845 printf("Error: Cannot get xstats lookup\n");
846 free(xstats_names);
847 return;
848 }
849 ids = malloc(sizeof(uint32_t) * nb_ids);
850 if (ids == NULL) {
851 printf("Cannot allocate memory for statistics IDs\n");
852 free(xstats_names);
853 return;
854 }
855 for (i = 0; i < nb_ids; i++)
856 ids[i] = i;
857 values = malloc(sizeof(uint64_t) * nb_ids);
858 if (values == NULL) {
859 printf("Cannot allocate memory to save fetching values\n");
860 free(xstats_names);
861 free(ids);
862 return;
863 }
864 if (nb_ids != rte_rawdev_xstats_get(dev_id, ids, values, nb_ids)) {
865 printf("Error: Unable to get xstats\n");
866 free(xstats_names);
867 free(values);
868 free(ids);
869 return;
870 }
871
872 /* Display NTB dev stats */
873 for (i = 0; i < nb_ids; i++)
874 printf(" %s: %"PRIu64"\n", xstats_names[i].name, values[i]);
875 ntb_calculate_throughput(0);
876
877 /* Get Ethdev stats if have any */
878 if (fwd_mode == IOFWD && eth_port_id != RTE_MAX_ETHPORTS) {

Callers 1

Calls 7

mallocFunction · 0.85
rte_rawdev_xstats_getFunction · 0.85
ntb_calculate_throughputFunction · 0.85
rte_eth_stats_getFunction · 0.85
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected