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