| 973 | #define ADD_DICT_STAT(s) rte_tel_data_add_dict_uint(d, #s, dma_stats.s) |
| 974 | |
| 975 | static int |
| 976 | dmadev_handle_dev_stats(const char *cmd __rte_unused, |
| 977 | const char *params, |
| 978 | struct rte_tel_data *d) |
| 979 | { |
| 980 | struct rte_dma_info dma_info; |
| 981 | struct rte_dma_stats dma_stats; |
| 982 | int dev_id, ret, vchan_id; |
| 983 | char *end_param; |
| 984 | const char *vchan_param; |
| 985 | |
| 986 | if (params == NULL || strlen(params) == 0 || !isdigit(*params)) |
| 987 | return -EINVAL; |
| 988 | |
| 989 | dev_id = strtoul(params, &end_param, 0); |
| 990 | |
| 991 | /* Function info_get validates dev_id so we don't need to. */ |
| 992 | ret = rte_dma_info_get(dev_id, &dma_info); |
| 993 | if (ret < 0) |
| 994 | return -EINVAL; |
| 995 | |
| 996 | /* If the device has one vchan the user does not need to supply the |
| 997 | * vchan id and only the device id is needed, no extra parameters. |
| 998 | */ |
| 999 | if (dma_info.nb_vchans == 1 && *end_param == '\0') |
| 1000 | vchan_id = 0; |
| 1001 | else { |
| 1002 | vchan_param = strtok(end_param, ","); |
| 1003 | if (!vchan_param || strlen(vchan_param) == 0 || !isdigit(*vchan_param)) |
| 1004 | return -EINVAL; |
| 1005 | |
| 1006 | vchan_id = strtoul(vchan_param, &end_param, 0); |
| 1007 | } |
| 1008 | if (*end_param != '\0') |
| 1009 | RTE_DMA_LOG(WARNING, "Extra parameters passed to dmadev telemetry command, ignoring"); |
| 1010 | |
| 1011 | ret = rte_dma_stats_get(dev_id, vchan_id, &dma_stats); |
| 1012 | if (ret < 0) |
| 1013 | return -EINVAL; |
| 1014 | |
| 1015 | rte_tel_data_start_dict(d); |
| 1016 | ADD_DICT_STAT(submitted); |
| 1017 | ADD_DICT_STAT(completed); |
| 1018 | ADD_DICT_STAT(errors); |
| 1019 | |
| 1020 | return 0; |
| 1021 | } |
| 1022 | |
| 1023 | #ifndef RTE_EXEC_ENV_WINDOWS |
| 1024 | static int |
nothing calls this directly
no test coverage detected