2 * SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2010-2014 Intel Corporation
6 #include "opdl_evdev.h"
9 static const char * const port_xstat_str[] = {
11 "claim_pkts_requested",
20 opdl_xstats_init(struct rte_eventdev *dev)
24 struct opdl_evdev *device = opdl_pmd_priv(dev);
26 if (!device->do_validation)
29 for (i = 0; i < device->max_port_nb; i++) {
30 struct opdl_port *port = &device->ports[i];
32 for (j = 0; j < max_num_port_xstat; j++) {
33 uint32_t index = (i * max_num_port_xstat) + j;
36 sprintf(device->port_xstat[index].stat.name,
42 device->port_xstat[index].id = index;
45 device->port_xstat[index].value = &port->port_stat[j];
51 opdl_xstats_uninit(struct rte_eventdev *dev)
53 struct opdl_evdev *device = opdl_pmd_priv(dev);
55 if (!device->do_validation)
58 memset(device->port_xstat,
60 sizeof(device->port_xstat));
66 opdl_xstats_get_names(const struct rte_eventdev *dev,
67 enum rte_event_dev_xstats_mode mode,
68 uint8_t queue_port_id,
69 struct rte_event_dev_xstats_name *xstats_names,
70 unsigned int *ids, unsigned int size)
72 struct opdl_evdev *device = opdl_pmd_priv(dev);
74 if (!device->do_validation)
77 if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
78 mode == RTE_EVENT_DEV_XSTATS_QUEUE)
81 if (queue_port_id >= device->max_port_nb)
84 if (size < max_num_port_xstat)
85 return max_num_port_xstat;
87 uint32_t port_idx = queue_port_id * max_num_port_xstat;
89 for (uint32_t j = 0; j < max_num_port_xstat; j++) {
91 strcpy(xstats_names[j].name,
92 device->port_xstat[j + port_idx].stat.name);
93 ids[j] = device->port_xstat[j + port_idx].id;
96 return max_num_port_xstat;
100 opdl_xstats_get(const struct rte_eventdev *dev,
101 enum rte_event_dev_xstats_mode mode,
102 uint8_t queue_port_id,
103 const unsigned int ids[],
104 uint64_t values[], unsigned int n)
106 struct opdl_evdev *device = opdl_pmd_priv(dev);
108 if (!device->do_validation)
111 if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
112 mode == RTE_EVENT_DEV_XSTATS_QUEUE)
115 if (queue_port_id >= device->max_port_nb)
118 if (n > max_num_port_xstat)
121 uint32_t p_start = queue_port_id * max_num_port_xstat;
122 uint32_t p_finish = p_start + max_num_port_xstat;
124 for (uint32_t i = 0; i < n; i++) {
125 if (ids[i] < p_start || ids[i] >= p_finish)
128 values[i] = *(device->port_xstat[ids[i]].value);
135 opdl_xstats_get_by_name(const struct rte_eventdev *dev,
136 const char *name, unsigned int *id)
138 struct opdl_evdev *device = opdl_pmd_priv(dev);
140 if (!device->do_validation)
143 uint32_t max_index = device->max_port_nb * max_num_port_xstat;
145 for (uint32_t i = 0; i < max_index; i++) {
148 device->port_xstat[i].stat.name,
149 RTE_EVENT_DEV_XSTATS_NAME_SIZE) == 0) {
152 if (device->port_xstat[i].value)
153 return *(device->port_xstat[i].value);
161 opdl_xstats_reset(struct rte_eventdev *dev,
162 enum rte_event_dev_xstats_mode mode,
163 int16_t queue_port_id, const uint32_t ids[],
166 struct opdl_evdev *device = opdl_pmd_priv(dev);
168 if (!device->do_validation)
173 RTE_SET_USED(queue_port_id);
175 RTE_SET_USED(nb_ids);