eventdev: support telemetry with xstats info
The telemetry library is connected with eventdev xstats and port link info. The following new telemetry commands are added: /eventdev/dev_list /eventdev/port_list,DevID /eventdev/queue_list,DevID /eventdev/dev_xstats,DevID /eventdev/port_xstats,DevID,PortID /eventdev/queue_xstats,DevID,PortID /eventdev/queue_links,DevID,PortID queue_links command displays a list of queues linked with a specified eventdev port and a service priority associated with each link. Signed-off-by: Mike Ximing Chen <mike.ximing.chen@intel.com> Reviewed-by: Ciara Power <ciara.power@intel.com> Reviewed-by: Gage Eads <gage.eads@intel.com>
This commit is contained in:
parent
80d1a9aff7
commit
62303b08b7
@ -27,3 +27,4 @@ headers = files('rte_eventdev.h',
|
||||
'rte_event_crypto_adapter.h',
|
||||
'rte_event_eth_tx_adapter.h')
|
||||
deps += ['ring', 'ethdev', 'hash', 'mempool', 'mbuf', 'timer', 'cryptodev']
|
||||
deps += ['telemetry']
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <rte_ethdev.h>
|
||||
#include <rte_cryptodev.h>
|
||||
#include <rte_cryptodev_pmd.h>
|
||||
#include <rte_telemetry.h>
|
||||
|
||||
#include "rte_eventdev.h"
|
||||
#include "rte_eventdev_pmd.h"
|
||||
@ -1424,3 +1425,306 @@ rte_event_pmd_release(struct rte_eventdev *eventdev)
|
||||
eventdev->data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
handle_dev_list(const char *cmd __rte_unused,
|
||||
const char *params __rte_unused,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
uint8_t dev_id;
|
||||
int ndev = rte_event_dev_count();
|
||||
|
||||
if (ndev < 1)
|
||||
return -1;
|
||||
|
||||
rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
|
||||
for (dev_id = 0; dev_id < RTE_EVENT_MAX_DEVS; dev_id++) {
|
||||
if (rte_eventdevs[dev_id].attached ==
|
||||
RTE_EVENTDEV_ATTACHED)
|
||||
rte_tel_data_add_array_int(d, dev_id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
handle_port_list(const char *cmd __rte_unused,
|
||||
const char *params,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
int i;
|
||||
uint8_t dev_id;
|
||||
struct rte_eventdev *dev;
|
||||
char *end_param;
|
||||
|
||||
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
|
||||
return -1;
|
||||
|
||||
dev_id = strtoul(params, &end_param, 10);
|
||||
if (*end_param != '\0')
|
||||
RTE_EDEV_LOG_DEBUG(
|
||||
"Extra parameters passed to eventdev telemetry command, ignoring");
|
||||
|
||||
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
|
||||
dev = &rte_eventdevs[dev_id];
|
||||
|
||||
rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
|
||||
for (i = 0; i < dev->data->nb_ports; i++)
|
||||
rte_tel_data_add_array_int(d, i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
handle_queue_list(const char *cmd __rte_unused,
|
||||
const char *params,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
int i;
|
||||
uint8_t dev_id;
|
||||
struct rte_eventdev *dev;
|
||||
char *end_param;
|
||||
|
||||
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
|
||||
return -1;
|
||||
|
||||
dev_id = strtoul(params, &end_param, 10);
|
||||
if (*end_param != '\0')
|
||||
RTE_EDEV_LOG_DEBUG(
|
||||
"Extra parameters passed to eventdev telemetry command, ignoring");
|
||||
|
||||
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
|
||||
dev = &rte_eventdevs[dev_id];
|
||||
|
||||
rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
|
||||
for (i = 0; i < dev->data->nb_queues; i++)
|
||||
rte_tel_data_add_array_int(d, i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
handle_queue_links(const char *cmd __rte_unused,
|
||||
const char *params,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
int i, ret, port_id = 0;
|
||||
char *end_param;
|
||||
uint8_t dev_id;
|
||||
uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
|
||||
uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
|
||||
const char *p_param;
|
||||
|
||||
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
|
||||
return -1;
|
||||
|
||||
/* Get dev ID from parameter string */
|
||||
dev_id = strtoul(params, &end_param, 10);
|
||||
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
|
||||
|
||||
p_param = strtok(end_param, ",");
|
||||
if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
|
||||
return -1;
|
||||
|
||||
port_id = strtoul(p_param, &end_param, 10);
|
||||
p_param = strtok(NULL, "\0");
|
||||
if (p_param != NULL)
|
||||
RTE_EDEV_LOG_DEBUG(
|
||||
"Extra parameters passed to eventdev telemetry command, ignoring");
|
||||
|
||||
ret = rte_event_port_links_get(dev_id, port_id, queues, priorities);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
rte_tel_data_start_dict(d);
|
||||
for (i = 0; i < ret; i++) {
|
||||
char qid_name[32];
|
||||
|
||||
snprintf(qid_name, 31, "qid_%u", queues[i]);
|
||||
rte_tel_data_add_dict_u64(d, qid_name, priorities[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
eventdev_build_telemetry_data(int dev_id,
|
||||
enum rte_event_dev_xstats_mode mode,
|
||||
int port_queue_id,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
struct rte_event_dev_xstats_name *xstat_names;
|
||||
unsigned int *ids;
|
||||
uint64_t *values;
|
||||
int i, ret, num_xstats;
|
||||
|
||||
num_xstats = rte_event_dev_xstats_names_get(dev_id,
|
||||
mode,
|
||||
port_queue_id,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if (num_xstats < 0)
|
||||
return -1;
|
||||
|
||||
/* use one malloc for names */
|
||||
xstat_names = malloc((sizeof(struct rte_event_dev_xstats_name))
|
||||
* num_xstats);
|
||||
if (xstat_names == NULL)
|
||||
return -1;
|
||||
|
||||
ids = malloc((sizeof(unsigned int)) * num_xstats);
|
||||
if (ids == NULL) {
|
||||
free(xstat_names);
|
||||
return -1;
|
||||
}
|
||||
|
||||
values = malloc((sizeof(uint64_t)) * num_xstats);
|
||||
if (values == NULL) {
|
||||
free(xstat_names);
|
||||
free(ids);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = rte_event_dev_xstats_names_get(dev_id, mode, port_queue_id,
|
||||
xstat_names, ids, num_xstats);
|
||||
if (ret < 0 || ret > num_xstats) {
|
||||
free(xstat_names);
|
||||
free(ids);
|
||||
free(values);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = rte_event_dev_xstats_get(dev_id, mode, port_queue_id,
|
||||
ids, values, num_xstats);
|
||||
if (ret < 0 || ret > num_xstats) {
|
||||
free(xstat_names);
|
||||
free(ids);
|
||||
free(values);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rte_tel_data_start_dict(d);
|
||||
for (i = 0; i < num_xstats; i++)
|
||||
rte_tel_data_add_dict_u64(d, xstat_names[i].name,
|
||||
values[i]);
|
||||
|
||||
free(xstat_names);
|
||||
free(ids);
|
||||
free(values);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
handle_dev_xstats(const char *cmd __rte_unused,
|
||||
const char *params,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
int dev_id;
|
||||
enum rte_event_dev_xstats_mode mode;
|
||||
char *end_param;
|
||||
|
||||
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
|
||||
return -1;
|
||||
|
||||
/* Get dev ID from parameter string */
|
||||
dev_id = strtoul(params, &end_param, 10);
|
||||
if (*end_param != '\0')
|
||||
RTE_EDEV_LOG_DEBUG(
|
||||
"Extra parameters passed to eventdev telemetry command, ignoring");
|
||||
|
||||
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
|
||||
|
||||
mode = RTE_EVENT_DEV_XSTATS_DEVICE;
|
||||
return eventdev_build_telemetry_data(dev_id, mode, 0, d);
|
||||
}
|
||||
|
||||
static int
|
||||
handle_port_xstats(const char *cmd __rte_unused,
|
||||
const char *params,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
int dev_id;
|
||||
int port_queue_id = 0;
|
||||
enum rte_event_dev_xstats_mode mode;
|
||||
char *end_param;
|
||||
const char *p_param;
|
||||
|
||||
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
|
||||
return -1;
|
||||
|
||||
/* Get dev ID from parameter string */
|
||||
dev_id = strtoul(params, &end_param, 10);
|
||||
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
|
||||
|
||||
p_param = strtok(end_param, ",");
|
||||
mode = RTE_EVENT_DEV_XSTATS_PORT;
|
||||
|
||||
if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
|
||||
return -1;
|
||||
|
||||
port_queue_id = strtoul(p_param, &end_param, 10);
|
||||
|
||||
p_param = strtok(NULL, "\0");
|
||||
if (p_param != NULL)
|
||||
RTE_EDEV_LOG_DEBUG(
|
||||
"Extra parameters passed to eventdev telemetry command, ignoring");
|
||||
|
||||
return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d);
|
||||
}
|
||||
|
||||
static int
|
||||
handle_queue_xstats(const char *cmd __rte_unused,
|
||||
const char *params,
|
||||
struct rte_tel_data *d)
|
||||
{
|
||||
int dev_id;
|
||||
int port_queue_id = 0;
|
||||
enum rte_event_dev_xstats_mode mode;
|
||||
char *end_param;
|
||||
const char *p_param;
|
||||
|
||||
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
|
||||
return -1;
|
||||
|
||||
/* Get dev ID from parameter string */
|
||||
dev_id = strtoul(params, &end_param, 10);
|
||||
RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
|
||||
|
||||
p_param = strtok(end_param, ",");
|
||||
mode = RTE_EVENT_DEV_XSTATS_QUEUE;
|
||||
|
||||
if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
|
||||
return -1;
|
||||
|
||||
port_queue_id = strtoul(p_param, &end_param, 10);
|
||||
|
||||
p_param = strtok(NULL, "\0");
|
||||
if (p_param != NULL)
|
||||
RTE_EDEV_LOG_DEBUG(
|
||||
"Extra parameters passed to eventdev telemetry command, ignoring");
|
||||
|
||||
return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d);
|
||||
}
|
||||
|
||||
RTE_INIT(eventdev_init_telemetry)
|
||||
{
|
||||
rte_telemetry_register_cmd("/eventdev/dev_list", handle_dev_list,
|
||||
"Returns list of available eventdevs. Takes no parameters");
|
||||
rte_telemetry_register_cmd("/eventdev/port_list", handle_port_list,
|
||||
"Returns list of available ports. Parameter: DevID");
|
||||
rte_telemetry_register_cmd("/eventdev/queue_list", handle_queue_list,
|
||||
"Returns list of available queues. Parameter: DevID");
|
||||
|
||||
rte_telemetry_register_cmd("/eventdev/dev_xstats", handle_dev_xstats,
|
||||
"Returns stats for an eventdev. Parameter: DevID");
|
||||
rte_telemetry_register_cmd("/eventdev/port_xstats", handle_port_xstats,
|
||||
"Returns stats for an eventdev port. Params: DevID,PortID");
|
||||
rte_telemetry_register_cmd("/eventdev/queue_xstats",
|
||||
handle_queue_xstats,
|
||||
"Returns stats for an eventdev queue. Params: DevID,QueueID");
|
||||
rte_telemetry_register_cmd("/eventdev/queue_links", handle_queue_links,
|
||||
"Returns links for an eventdev port. Params: DevID,QueueID");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user