+
+error:
+ free(l_params);
+ return ret;
+}
+
+static int
+handle_rxa_get_queue_stats(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ uint8_t rx_adapter_id;
+ uint16_t rx_queue_id;
+ int eth_dev_id, ret = -1;
+ char *token, *l_params;
+ struct rte_event_eth_rx_adapter_queue_stats q_stats;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -1;
+
+ /* Get Rx adapter ID from parameter string */
+ l_params = strdup(params);
+ if (l_params == NULL)
+ return -ENOMEM;
+ token = strtok(l_params, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+ rx_adapter_id = strtoul(token, NULL, 10);
+ RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_GOTO_ERR_RET(rx_adapter_id, -EINVAL);
+
+ token = strtok(NULL, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+ /* Get device ID from parameter string */
+ eth_dev_id = strtoul(token, NULL, 10);
+ RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+ token = strtok(NULL, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+ /* Get Rx queue ID from parameter string */
+ rx_queue_id = strtoul(token, NULL, 10);
+ if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+ RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ token = strtok(NULL, "\0");
+ if (token != NULL)
+ RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+ " telemetry command, ignoring");
+ /* Parsing parameter finished */
+ free(l_params);
+
+ if (rte_event_eth_rx_adapter_queue_stats_get(rx_adapter_id, eth_dev_id,
+ rx_queue_id, &q_stats)) {
+ RTE_EDEV_LOG_ERR("Failed to get Rx adapter queue stats");
+ return -1;
+ }
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_u64(d, "rx_adapter_id", rx_adapter_id);
+ rte_tel_data_add_dict_u64(d, "eth_dev_id", eth_dev_id);
+ rte_tel_data_add_dict_u64(d, "rx_queue_id", rx_queue_id);
+ RXA_ADD_DICT(q_stats, rx_event_buf_count);
+ RXA_ADD_DICT(q_stats, rx_event_buf_size);
+ RXA_ADD_DICT(q_stats, rx_poll_count);
+ RXA_ADD_DICT(q_stats, rx_packets);
+ RXA_ADD_DICT(q_stats, rx_dropped);
+
+ return 0;
+
+error:
+ free(l_params);
+ return ret;
+}
+
+static int
+handle_rxa_queue_stats_reset(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d __rte_unused)
+{
+ uint8_t rx_adapter_id;
+ uint16_t rx_queue_id;
+ int eth_dev_id, ret = -1;
+ char *token, *l_params;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -1;
+
+ /* Get Rx adapter ID from parameter string */
+ l_params = strdup(params);
+ if (l_params == NULL)
+ return -ENOMEM;
+ token = strtok(l_params, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+ rx_adapter_id = strtoul(token, NULL, 10);
+ RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_GOTO_ERR_RET(rx_adapter_id, -EINVAL);
+
+ token = strtok(NULL, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+ /* Get device ID from parameter string */
+ eth_dev_id = strtoul(token, NULL, 10);
+ RTE_ETH_VALID_PORTID_OR_GOTO_ERR_RET(eth_dev_id, -EINVAL);
+
+ token = strtok(NULL, ",");
+ RTE_EVENT_ETH_RX_ADAPTER_TOKEN_VALID_OR_GOTO_ERR_RET(token, -1);
+
+ /* Get Rx queue ID from parameter string */
+ rx_queue_id = strtoul(token, NULL, 10);
+ if (rx_queue_id >= rte_eth_devices[eth_dev_id].data->nb_rx_queues) {
+ RTE_EDEV_LOG_ERR("Invalid rx queue_id %u", rx_queue_id);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ token = strtok(NULL, "\0");
+ if (token != NULL)
+ RTE_EDEV_LOG_ERR("Extra parameters passed to eventdev"
+ " telemetry command, ignoring");
+ /* Parsing parameter finished */
+ free(l_params);
+
+ if (rte_event_eth_rx_adapter_queue_stats_reset(rx_adapter_id,
+ eth_dev_id,
+ rx_queue_id)) {
+ RTE_EDEV_LOG_ERR("Failed to reset Rx adapter queue stats");
+ return -1;
+ }
+
+ return 0;
+
+error:
+ free(l_params);
+ return ret;