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 snprintf(device->port_xstat[index].stat.name,
36 sizeof(device->port_xstat[index].stat.name),
37 "port_%02u_%s", i, port_xstat_str[j]);
40 device->port_xstat[index].id = index;
43 device->port_xstat[index].value = &port->port_stat[j];
49 opdl_xstats_uninit(struct rte_eventdev *dev)
51 struct opdl_evdev *device = opdl_pmd_priv(dev);
53 if (!device->do_validation)
56 memset(device->port_xstat,
58 sizeof(device->port_xstat));
64 opdl_xstats_get_names(const struct rte_eventdev *dev,
65 enum rte_event_dev_xstats_mode mode,
66 uint8_t queue_port_id,
67 struct rte_event_dev_xstats_name *xstats_names,
68 unsigned int *ids, unsigned int size)
70 struct opdl_evdev *device = opdl_pmd_priv(dev);
72 if (!device->do_validation)
75 if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
76 mode == RTE_EVENT_DEV_XSTATS_QUEUE)
79 if (queue_port_id >= device->max_port_nb)
82 if (size < max_num_port_xstat)
83 return max_num_port_xstat;
85 uint32_t port_idx = queue_port_id * max_num_port_xstat;
88 for (j = 0; j < max_num_port_xstat; j++) {
90 strcpy(xstats_names[j].name,
91 device->port_xstat[j + port_idx].stat.name);
92 ids[j] = device->port_xstat[j + port_idx].id;
95 return max_num_port_xstat;
99 opdl_xstats_get(const struct rte_eventdev *dev,
100 enum rte_event_dev_xstats_mode mode,
101 uint8_t queue_port_id,
102 const unsigned int ids[],
103 uint64_t values[], unsigned int n)
105 struct opdl_evdev *device = opdl_pmd_priv(dev);
107 if (!device->do_validation)
110 if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
111 mode == RTE_EVENT_DEV_XSTATS_QUEUE)
114 if (queue_port_id >= device->max_port_nb)
117 if (n > max_num_port_xstat)
120 uint32_t p_start = queue_port_id * max_num_port_xstat;
121 uint32_t p_finish = p_start + max_num_port_xstat;
124 for (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;
146 for (i = 0; i < max_index; i++) {
149 device->port_xstat[i].stat.name,
150 RTE_EVENT_DEV_XSTATS_NAME_SIZE) == 0) {
153 if (device->port_xstat[i].value)
154 return *(device->port_xstat[i].value);
162 opdl_xstats_reset(struct rte_eventdev *dev,
163 enum rte_event_dev_xstats_mode mode,
164 int16_t queue_port_id, const uint32_t ids[],
167 struct opdl_evdev *device = opdl_pmd_priv(dev);
169 if (!device->do_validation)
174 RTE_SET_USED(queue_port_id);
176 RTE_SET_USED(nb_ids);