1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #include "opdl_evdev.h"
8 static const char * const port_xstat_str[] = {
10 "claim_pkts_requested",
19 opdl_xstats_init(struct rte_eventdev *dev)
23 struct opdl_evdev *device = opdl_pmd_priv(dev);
25 if (!device->do_validation)
28 for (i = 0; i < device->max_port_nb; i++) {
29 struct opdl_port *port = &device->ports[i];
31 for (j = 0; j < max_num_port_xstat; j++) {
32 uint32_t index = (i * max_num_port_xstat) + j;
35 sprintf(device->port_xstat[index].stat.name,
41 device->port_xstat[index].id = index;
44 device->port_xstat[index].value = &port->port_stat[j];
50 opdl_xstats_uninit(struct rte_eventdev *dev)
52 struct opdl_evdev *device = opdl_pmd_priv(dev);
54 if (!device->do_validation)
57 memset(device->port_xstat,
59 sizeof(device->port_xstat));
65 opdl_xstats_get_names(const struct rte_eventdev *dev,
66 enum rte_event_dev_xstats_mode mode,
67 uint8_t queue_port_id,
68 struct rte_event_dev_xstats_name *xstats_names,
69 unsigned int *ids, unsigned int size)
71 struct opdl_evdev *device = opdl_pmd_priv(dev);
73 if (!device->do_validation)
76 if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
77 mode == RTE_EVENT_DEV_XSTATS_QUEUE)
80 if (queue_port_id >= device->max_port_nb)
83 if (size < max_num_port_xstat)
84 return max_num_port_xstat;
86 uint32_t port_idx = queue_port_id * max_num_port_xstat;
89 for (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;
125 for (i = 0; i < n; i++) {
126 if (ids[i] < p_start || ids[i] >= p_finish)
129 values[i] = *(device->port_xstat[ids[i]].value);
136 opdl_xstats_get_by_name(const struct rte_eventdev *dev,
137 const char *name, unsigned int *id)
139 struct opdl_evdev *device = opdl_pmd_priv(dev);
141 if (!device->do_validation)
144 uint32_t max_index = device->max_port_nb * max_num_port_xstat;
147 for (i = 0; i < max_index; i++) {
150 device->port_xstat[i].stat.name,
151 RTE_EVENT_DEV_XSTATS_NAME_SIZE) == 0) {
154 if (device->port_xstat[i].value)
155 return *(device->port_xstat[i].value);
163 opdl_xstats_reset(struct rte_eventdev *dev,
164 enum rte_event_dev_xstats_mode mode,
165 int16_t queue_port_id, const uint32_t ids[],
168 struct opdl_evdev *device = opdl_pmd_priv(dev);
170 if (!device->do_validation)
175 RTE_SET_USED(queue_port_id);
177 RTE_SET_USED(nb_ids);