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;
90 for (j = 0; j < max_num_port_xstat; j++) {
92 strcpy(xstats_names[j].name,
93 device->port_xstat[j + port_idx].stat.name);
94 ids[j] = device->port_xstat[j + port_idx].id;
97 return max_num_port_xstat;
101 opdl_xstats_get(const struct rte_eventdev *dev,
102 enum rte_event_dev_xstats_mode mode,
103 uint8_t queue_port_id,
104 const unsigned int ids[],
105 uint64_t values[], unsigned int n)
107 struct opdl_evdev *device = opdl_pmd_priv(dev);
109 if (!device->do_validation)
112 if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
113 mode == RTE_EVENT_DEV_XSTATS_QUEUE)
116 if (queue_port_id >= device->max_port_nb)
119 if (n > max_num_port_xstat)
122 uint32_t p_start = queue_port_id * max_num_port_xstat;
123 uint32_t p_finish = p_start + max_num_port_xstat;
126 for (i = 0; i < n; i++) {
127 if (ids[i] < p_start || ids[i] >= p_finish)
130 values[i] = *(device->port_xstat[ids[i]].value);
137 opdl_xstats_get_by_name(const struct rte_eventdev *dev,
138 const char *name, unsigned int *id)
140 struct opdl_evdev *device = opdl_pmd_priv(dev);
142 if (!device->do_validation)
145 uint32_t max_index = device->max_port_nb * max_num_port_xstat;
148 for (i = 0; i < max_index; i++) {
151 device->port_xstat[i].stat.name,
152 RTE_EVENT_DEV_XSTATS_NAME_SIZE) == 0) {
155 if (device->port_xstat[i].value)
156 return *(device->port_xstat[i].value);
164 opdl_xstats_reset(struct rte_eventdev *dev,
165 enum rte_event_dev_xstats_mode mode,
166 int16_t queue_port_id, const uint32_t ids[],
169 struct opdl_evdev *device = opdl_pmd_priv(dev);
171 if (!device->do_validation)
176 RTE_SET_USED(queue_port_id);
178 RTE_SET_USED(nb_ids);