Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include "opdl_evdev.h"
6 : : #include "opdl_log.h"
7 : :
8 : : static const char * const port_xstat_str[] = {
9 : :
10 : : "claim_pkts_requested",
11 : : "claim_pkts_granted",
12 : : "claim_non_empty",
13 : : "claim_empty",
14 : : "total_cycles",
15 : : };
16 : :
17 : :
18 : : void
19 [ # # ]: 0 : opdl_xstats_init(struct rte_eventdev *dev)
20 : : {
21 : : uint32_t i, j;
22 : :
23 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
24 : :
25 [ # # ]: 0 : if (!device->do_validation)
26 : : return;
27 : :
28 [ # # ]: 0 : for (i = 0; i < device->max_port_nb; i++) {
29 : : struct opdl_port *port = &device->ports[i];
30 : :
31 [ # # ]: 0 : for (j = 0; j < max_num_port_xstat; j++) {
32 : 0 : uint32_t index = (i * max_num_port_xstat) + j;
33 : :
34 : : /* Name */
35 : 0 : snprintf(device->port_xstat[index].stat.name,
36 : : sizeof(device->port_xstat[index].stat.name),
37 : 0 : "port_%02u_%s", i, port_xstat_str[j]);
38 : :
39 : : /* ID */
40 : 0 : device->port_xstat[index].id = index;
41 : :
42 : : /* Stats ptr */
43 : 0 : device->port_xstat[index].value = &port->port_stat[j];
44 : : }
45 : : }
46 : : }
47 : :
48 : : int
49 [ # # ]: 0 : opdl_xstats_uninit(struct rte_eventdev *dev)
50 : : {
51 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
52 : :
53 [ # # ]: 0 : if (!device->do_validation)
54 : : return 0;
55 : :
56 : 0 : memset(device->port_xstat,
57 : : 0,
58 : : sizeof(device->port_xstat));
59 : :
60 : 0 : return 0;
61 : : }
62 : :
63 : : int
64 [ # # ]: 0 : 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 : : uint64_t *ids, unsigned int size)
69 : : {
70 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
71 : :
72 [ # # ]: 0 : if (!device->do_validation)
73 : : return -ENOTSUP;
74 : :
75 : 0 : if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
76 [ # # ]: 0 : mode == RTE_EVENT_DEV_XSTATS_QUEUE)
77 : : return -EINVAL;
78 : :
79 [ # # ]: 0 : if (queue_port_id >= device->max_port_nb)
80 : : return -EINVAL;
81 : :
82 [ # # ]: 0 : if (size < max_num_port_xstat)
83 : : return max_num_port_xstat;
84 : :
85 : 0 : uint32_t port_idx = queue_port_id * max_num_port_xstat;
86 : :
87 : : uint32_t j;
88 [ # # ]: 0 : for (j = 0; j < max_num_port_xstat; j++) {
89 : :
90 : 0 : strcpy(xstats_names[j].name,
91 : 0 : device->port_xstat[j + port_idx].stat.name);
92 : 0 : ids[j] = device->port_xstat[j + port_idx].id;
93 : : }
94 : :
95 : : return max_num_port_xstat;
96 : : }
97 : :
98 : : int
99 [ # # ]: 0 : opdl_xstats_get(const struct rte_eventdev *dev,
100 : : enum rte_event_dev_xstats_mode mode,
101 : : uint8_t queue_port_id,
102 : : const uint64_t ids[],
103 : : uint64_t values[], unsigned int n)
104 : : {
105 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
106 : :
107 [ # # ]: 0 : if (!device->do_validation)
108 : : return -ENOTSUP;
109 : :
110 : 0 : if (mode == RTE_EVENT_DEV_XSTATS_DEVICE ||
111 [ # # ]: 0 : mode == RTE_EVENT_DEV_XSTATS_QUEUE)
112 : : return -EINVAL;
113 : :
114 [ # # ]: 0 : if (queue_port_id >= device->max_port_nb)
115 : : return -EINVAL;
116 : :
117 [ # # ]: 0 : if (n > max_num_port_xstat)
118 : : return -EINVAL;
119 : :
120 : 0 : uint32_t p_start = queue_port_id * max_num_port_xstat;
121 : 0 : uint32_t p_finish = p_start + max_num_port_xstat;
122 : :
123 : : uint32_t i;
124 [ # # ]: 0 : for (i = 0; i < n; i++) {
125 [ # # # # ]: 0 : if (ids[i] < p_start || ids[i] >= p_finish)
126 : : return -EINVAL;
127 : :
128 : 0 : values[i] = *(device->port_xstat[ids[i]].value);
129 : : }
130 : :
131 : 0 : return n;
132 : : }
133 : :
134 : : uint64_t
135 [ # # ]: 0 : opdl_xstats_get_by_name(const struct rte_eventdev *dev,
136 : : const char *name, uint64_t *id)
137 : : {
138 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
139 : :
140 [ # # ]: 0 : if (!device->do_validation)
141 : : return -ENOTSUP;
142 : :
143 : 0 : uint32_t max_index = device->max_port_nb * max_num_port_xstat;
144 : :
145 : : uint32_t i;
146 [ # # ]: 0 : for (i = 0; i < max_index; i++) {
147 : :
148 : 0 : if (strncmp(name,
149 [ # # ]: 0 : device->port_xstat[i].stat.name,
150 : : RTE_EVENT_DEV_XSTATS_NAME_SIZE) == 0) {
151 [ # # ]: 0 : if (id != NULL)
152 : 0 : *id = i;
153 [ # # ]: 0 : if (device->port_xstat[i].value)
154 : 0 : return *(device->port_xstat[i].value);
155 : : break;
156 : : }
157 : : }
158 : : return -EINVAL;
159 : : }
160 : :
161 : : int
162 : 0 : opdl_xstats_reset(struct rte_eventdev *dev,
163 : : enum rte_event_dev_xstats_mode mode,
164 : : int16_t queue_port_id, const uint64_t ids[],
165 : : uint32_t nb_ids)
166 : : {
167 : : struct opdl_evdev *device = opdl_pmd_priv(dev);
168 : :
169 : : if (!device->do_validation)
170 : : return -ENOTSUP;
171 : :
172 : : RTE_SET_USED(dev);
173 : : RTE_SET_USED(mode);
174 : : RTE_SET_USED(queue_port_id);
175 : : RTE_SET_USED(ids);
176 : : RTE_SET_USED(nb_ids);
177 : :
178 : : return -ENOTSUP;
179 : : }
|