Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <fcntl.h>
6 : : #include <stdio.h>
7 : : #include <errno.h>
8 : : #include <stdint.h>
9 : : #include <string.h>
10 : : #include <unistd.h>
11 : : #include <stdarg.h>
12 : : #include <inttypes.h>
13 : : #include <rte_byteorder.h>
14 : : #include <rte_common.h>
15 : : #include <rte_os_shim.h>
16 : :
17 : : #include <rte_debug.h>
18 : : #include <rte_alarm.h>
19 : : #include <rte_atomic.h>
20 : : #include <rte_eal.h>
21 : : #include <rte_ether.h>
22 : : #include <ethdev_driver.h>
23 : : #include <ethdev_pci.h>
24 : : #include <dev_driver.h>
25 : :
26 : : #include "iavf.h"
27 : : #include "iavf_rxtx.h"
28 : :
29 : : #define MAX_TRY_TIMES 2000
30 : : #define ASQ_DELAY_MS 1
31 : :
32 : : #define MAX_EVENT_PENDING 16
33 : :
34 : : struct iavf_event_element {
35 : : TAILQ_ENTRY(iavf_event_element) next;
36 : : struct rte_eth_dev *dev;
37 : : enum rte_eth_event_type event;
38 : : void *param;
39 : : size_t param_alloc_size;
40 : : uint8_t param_alloc_data[0];
41 : : };
42 : :
43 : : struct iavf_event_handler {
44 : : RTE_ATOMIC(uint32_t) ndev;
45 : : rte_thread_t tid;
46 : : int fd[2];
47 : : pthread_mutex_t lock;
48 : : TAILQ_HEAD(event_list, iavf_event_element) pending;
49 : : };
50 : :
51 : : static struct iavf_event_handler event_handler = {
52 : : .fd = {-1, -1},
53 : : };
54 : :
55 : : #ifndef TAILQ_FOREACH_SAFE
56 : : #define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
57 : : for ((var) = TAILQ_FIRST((head)); \
58 : : (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
59 : : (var) = (tvar))
60 : : #endif
61 : :
62 : : static uint32_t
63 : 0 : iavf_dev_event_handle(void *param __rte_unused)
64 : : {
65 : : struct iavf_event_handler *handler = &event_handler;
66 : : TAILQ_HEAD(event_list, iavf_event_element) pending;
67 : :
68 : 0 : while (true) {
69 : : char unused[MAX_EVENT_PENDING];
70 : 0 : ssize_t nr = read(handler->fd[0], &unused, sizeof(unused));
71 [ # # ]: 0 : if (nr <= 0)
72 : : break;
73 : :
74 : 0 : TAILQ_INIT(&pending);
75 : 0 : pthread_mutex_lock(&handler->lock);
76 [ # # ]: 0 : TAILQ_CONCAT(&pending, &handler->pending, next);
77 : 0 : pthread_mutex_unlock(&handler->lock);
78 : :
79 : : struct iavf_event_element *pos, *save_next;
80 [ # # ]: 0 : TAILQ_FOREACH_SAFE(pos, &pending, next, save_next) {
81 [ # # ]: 0 : TAILQ_REMOVE(&pending, pos, next);
82 : :
83 : 0 : struct iavf_adapter *adapter = pos->dev->data->dev_private;
84 [ # # ]: 0 : if (pos->event == RTE_ETH_EVENT_INTR_RESET &&
85 [ # # ]: 0 : adapter->devargs.auto_reset) {
86 : 0 : iavf_handle_hw_reset(pos->dev, false);
87 : 0 : rte_free(pos);
88 : 0 : continue;
89 : : }
90 : :
91 : 0 : rte_eth_dev_callback_process(pos->dev, pos->event, pos->param);
92 : 0 : rte_free(pos);
93 : : }
94 : : }
95 : :
96 : 0 : return 0;
97 : : }
98 : :
99 : : void
100 : 0 : iavf_dev_event_post(struct rte_eth_dev *dev,
101 : : enum rte_eth_event_type event,
102 : : void *param, size_t param_alloc_size)
103 : : {
104 : : struct iavf_event_handler *handler = &event_handler;
105 : 0 : char notify_byte = 0;
106 : 0 : struct iavf_event_element *elem = rte_malloc(NULL, sizeof(*elem) + param_alloc_size, 0);
107 [ # # ]: 0 : if (!elem)
108 : 0 : return;
109 : :
110 : 0 : elem->dev = dev;
111 : 0 : elem->event = event;
112 : 0 : elem->param = param;
113 : 0 : elem->param_alloc_size = param_alloc_size;
114 [ # # ]: 0 : if (param && param_alloc_size) {
115 [ # # ]: 0 : rte_memcpy(elem->param_alloc_data, param, param_alloc_size);
116 : 0 : elem->param = elem->param_alloc_data;
117 : : }
118 : :
119 : 0 : pthread_mutex_lock(&handler->lock);
120 : 0 : TAILQ_INSERT_TAIL(&handler->pending, elem, next);
121 : 0 : pthread_mutex_unlock(&handler->lock);
122 : :
123 : 0 : ssize_t nw = write(handler->fd[1], ¬ify_byte, 1);
124 : : RTE_SET_USED(nw);
125 : : }
126 : :
127 : : int
128 : 0 : iavf_dev_event_handler_init(void)
129 : : {
130 : : struct iavf_event_handler *handler = &event_handler;
131 : :
132 [ # # ]: 0 : if (rte_atomic_fetch_add_explicit(&handler->ndev, 1, rte_memory_order_relaxed) + 1 != 1)
133 : : return 0;
134 : : #if defined(RTE_EXEC_ENV_IS_WINDOWS) && RTE_EXEC_ENV_IS_WINDOWS != 0
135 : : int err = _pipe(handler->fd, MAX_EVENT_PENDING, O_BINARY);
136 : : #else
137 : 0 : int err = pipe(handler->fd);
138 : : #endif
139 [ # # ]: 0 : if (err != 0) {
140 : 0 : rte_atomic_fetch_sub_explicit(&handler->ndev, 1, rte_memory_order_relaxed);
141 : 0 : return -1;
142 : : }
143 : :
144 : 0 : TAILQ_INIT(&handler->pending);
145 : 0 : pthread_mutex_init(&handler->lock, NULL);
146 : :
147 [ # # ]: 0 : if (rte_thread_create_internal_control(&handler->tid, "iavf-event",
148 : : iavf_dev_event_handle, NULL)) {
149 : 0 : rte_atomic_fetch_sub_explicit(&handler->ndev, 1, rte_memory_order_relaxed);
150 : 0 : return -1;
151 : : }
152 : :
153 : : return 0;
154 : : }
155 : :
156 : : void
157 : 0 : iavf_dev_event_handler_fini(void)
158 : : {
159 : : struct iavf_event_handler *handler = &event_handler;
160 : :
161 [ # # ]: 0 : if (rte_atomic_fetch_sub_explicit(&handler->ndev, 1, rte_memory_order_relaxed) - 1 != 0)
162 : : return;
163 : :
164 : 0 : int unused = pthread_cancel((pthread_t)handler->tid.opaque_id);
165 : : RTE_SET_USED(unused);
166 : 0 : close(handler->fd[0]);
167 : 0 : close(handler->fd[1]);
168 : 0 : handler->fd[0] = -1;
169 : 0 : handler->fd[1] = -1;
170 : :
171 : 0 : rte_thread_join(handler->tid, NULL);
172 : 0 : pthread_mutex_destroy(&handler->lock);
173 : :
174 : : struct iavf_event_element *pos, *save_next;
175 [ # # ]: 0 : TAILQ_FOREACH_SAFE(pos, &handler->pending, next, save_next) {
176 [ # # ]: 0 : TAILQ_REMOVE(&handler->pending, pos, next);
177 : 0 : rte_free(pos);
178 : : }
179 : : }
180 : :
181 : : static uint32_t
182 : 0 : iavf_convert_link_speed(enum virtchnl_link_speed virt_link_speed)
183 : : {
184 : : uint32_t speed;
185 : :
186 [ # # # # : 0 : switch (virt_link_speed) {
# # # #
# ]
187 : : case VIRTCHNL_LINK_SPEED_100MB:
188 : : speed = 100;
189 : : break;
190 : 0 : case VIRTCHNL_LINK_SPEED_1GB:
191 : : speed = 1000;
192 : 0 : break;
193 : 0 : case VIRTCHNL_LINK_SPEED_10GB:
194 : : speed = 10000;
195 : 0 : break;
196 : 0 : case VIRTCHNL_LINK_SPEED_40GB:
197 : : speed = 40000;
198 : 0 : break;
199 : 0 : case VIRTCHNL_LINK_SPEED_20GB:
200 : : speed = 20000;
201 : 0 : break;
202 : 0 : case VIRTCHNL_LINK_SPEED_25GB:
203 : : speed = 25000;
204 : 0 : break;
205 : 0 : case VIRTCHNL_LINK_SPEED_2_5GB:
206 : : speed = 2500;
207 : 0 : break;
208 : 0 : case VIRTCHNL_LINK_SPEED_5GB:
209 : : speed = 5000;
210 : 0 : break;
211 : 0 : default:
212 : : speed = 0;
213 : 0 : break;
214 : : }
215 : :
216 : 0 : return speed;
217 : : }
218 : :
219 : : /* Read data in admin queue to get msg from pf driver */
220 : : static enum iavf_aq_result
221 : 0 : iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,
222 : : uint8_t *buf)
223 : : {
224 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
225 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
226 : : struct iavf_arq_event_info event;
227 : : enum iavf_aq_result result = IAVF_MSG_NON;
228 : : enum virtchnl_ops opcode;
229 : : int ret;
230 : :
231 : 0 : event.buf_len = buf_len;
232 : 0 : event.msg_buf = buf;
233 : 0 : ret = iavf_clean_arq_element(hw, &event, NULL);
234 : : /* Can't read any msg from adminQ */
235 [ # # ]: 0 : if (ret) {
236 : 0 : PMD_DRV_LOG(DEBUG, "Can't read msg from AQ");
237 [ # # ]: 0 : if (ret != IAVF_ERR_ADMIN_QUEUE_NO_WORK)
238 : : result = IAVF_MSG_ERR;
239 : 0 : return result;
240 : : }
241 : :
242 : 0 : opcode = (enum virtchnl_ops)rte_le_to_cpu_32(event.desc.cookie_high);
243 : 0 : vf->cmd_retval = (enum virtchnl_status_code)rte_le_to_cpu_32(
244 : : event.desc.cookie_low);
245 : :
246 : 0 : PMD_DRV_LOG(DEBUG, "AQ from pf carries opcode %u, retval %d",
247 : : opcode, vf->cmd_retval);
248 : :
249 [ # # ]: 0 : if (opcode == VIRTCHNL_OP_EVENT) {
250 : 0 : struct virtchnl_pf_event *vpe =
251 : : (struct virtchnl_pf_event *)event.msg_buf;
252 : :
253 : : result = IAVF_MSG_SYS;
254 [ # # # # ]: 0 : switch (vpe->event) {
255 : 0 : case VIRTCHNL_EVENT_LINK_CHANGE:
256 : 0 : vf->link_up =
257 : 0 : vpe->event_data.link_event.link_status;
258 [ # # ]: 0 : if (vf->vf_res != NULL &&
259 [ # # ]: 0 : vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
260 : 0 : vf->link_speed =
261 : 0 : vpe->event_data.link_event_adv.link_speed;
262 : : } else {
263 : : enum virtchnl_link_speed speed;
264 : 0 : speed = vpe->event_data.link_event.link_speed;
265 : 0 : vf->link_speed = iavf_convert_link_speed(speed);
266 : : }
267 : 0 : iavf_dev_link_update(vf->eth_dev, 0);
268 : 0 : iavf_dev_event_post(vf->eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL, 0);
269 [ # # # # ]: 0 : if (vf->link_up && !vf->vf_reset) {
270 : 0 : iavf_dev_watchdog_disable(adapter);
271 : : } else {
272 [ # # ]: 0 : if (!vf->link_up)
273 : 0 : iavf_dev_watchdog_enable(adapter);
274 : : }
275 [ # # ]: 0 : if (adapter->devargs.no_poll_on_link_down) {
276 : 0 : iavf_set_no_poll(adapter, true);
277 [ # # ]: 0 : if (adapter->no_poll)
278 : 0 : PMD_DRV_LOG(DEBUG, "VF no poll turned on");
279 : : else
280 : 0 : PMD_DRV_LOG(DEBUG, "VF no poll turned off");
281 : : }
282 [ # # ]: 0 : PMD_DRV_LOG(INFO, "Link status update:%s",
283 : : vf->link_up ? "up" : "down");
284 : 0 : break;
285 : 0 : case VIRTCHNL_EVENT_RESET_IMPENDING:
286 : 0 : vf->vf_reset = true;
287 : 0 : iavf_set_no_poll(adapter, false);
288 : 0 : PMD_DRV_LOG(INFO, "VF is resetting");
289 : 0 : break;
290 : 0 : case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
291 : 0 : vf->dev_closed = true;
292 : 0 : PMD_DRV_LOG(INFO, "PF driver closed");
293 : 0 : break;
294 : 0 : default:
295 : 0 : PMD_DRV_LOG(ERR, "%s: Unknown event %d from pf",
296 : : __func__, vpe->event);
297 : : }
298 : : } else {
299 : : /* async reply msg on command issued by vf previously */
300 : : result = IAVF_MSG_CMD;
301 [ # # ]: 0 : if (opcode != vf->pend_cmd) {
302 : 0 : PMD_DRV_LOG(WARNING, "command mismatch, expect %u, get %u",
303 : : vf->pend_cmd, opcode);
304 : : result = IAVF_MSG_ERR;
305 : : }
306 : : }
307 : :
308 : : return result;
309 : : }
310 : :
311 : : static int
312 : 0 : iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args,
313 : : int async)
314 : : {
315 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
316 : 0 : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
317 : : enum iavf_aq_result result;
318 : : enum iavf_status ret;
319 : : int err = 0;
320 : : int i = 0;
321 : :
322 [ # # ]: 0 : if (vf->vf_reset)
323 : : return -EIO;
324 : :
325 : :
326 [ # # ]: 0 : if (async) {
327 [ # # ]: 0 : if (_atomic_set_async_response_cmd(vf, args->ops))
328 : : return -1;
329 : : } else {
330 [ # # ]: 0 : if (_atomic_set_cmd(vf, args->ops))
331 : : return -1;
332 : : }
333 : :
334 : 0 : ret = iavf_aq_send_msg_to_pf(hw, args->ops, IAVF_SUCCESS,
335 : 0 : args->in_args, args->in_args_size, NULL);
336 [ # # ]: 0 : if (ret) {
337 : 0 : PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
338 : : _clear_cmd(vf);
339 : 0 : return err;
340 : : }
341 : :
342 [ # # # ]: 0 : switch (args->ops) {
343 : : case VIRTCHNL_OP_RESET_VF:
344 : : case VIRTCHNL_OP_REQUEST_QUEUES:
345 : : /*no need to wait for response */
346 : : _clear_cmd(vf);
347 : : break;
348 : 0 : case VIRTCHNL_OP_VERSION:
349 : : case VIRTCHNL_OP_GET_VF_RESOURCES:
350 : : case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
351 : : case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
352 : : /* for init virtchnl ops, need to poll the response */
353 : : do {
354 : 0 : result = iavf_read_msg_from_pf(adapter, args->out_size,
355 : : args->out_buffer);
356 [ # # ]: 0 : if (result == IAVF_MSG_CMD)
357 : : break;
358 : 0 : iavf_msec_delay(ASQ_DELAY_MS);
359 [ # # ]: 0 : } while (i++ < MAX_TRY_TIMES);
360 [ # # ]: 0 : if (i >= MAX_TRY_TIMES ||
361 [ # # ]: 0 : vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
362 : : err = -1;
363 : 0 : PMD_DRV_LOG(ERR, "No response or return failure (%d)"
364 : : " for cmd %d", vf->cmd_retval, args->ops);
365 : : }
366 : : _clear_cmd(vf);
367 : : break;
368 : 0 : default:
369 [ # # ]: 0 : if (rte_thread_is_intr()) {
370 : : /* For virtchnl ops were executed in eal_intr_thread,
371 : : * need to poll the response.
372 : : */
373 : : do {
374 : 0 : result = iavf_read_msg_from_pf(adapter, args->out_size,
375 : : args->out_buffer);
376 [ # # ]: 0 : if (result == IAVF_MSG_CMD)
377 : : break;
378 : 0 : iavf_msec_delay(ASQ_DELAY_MS);
379 [ # # ]: 0 : } while (i++ < MAX_TRY_TIMES);
380 [ # # ]: 0 : if (i >= MAX_TRY_TIMES ||
381 [ # # ]: 0 : vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
382 : : err = -1;
383 : 0 : PMD_DRV_LOG(ERR, "No response or return failure (%d)"
384 : : " for cmd %d", vf->cmd_retval, args->ops);
385 : : }
386 : : _clear_cmd(vf);
387 : : } else {
388 : : /* For other virtchnl ops in running time,
389 : : * wait for the cmd done flag.
390 : : */
391 : : do {
392 [ # # ]: 0 : if (vf->pend_cmd == VIRTCHNL_OP_UNKNOWN)
393 : : break;
394 : 0 : iavf_msec_delay(ASQ_DELAY_MS);
395 : : /* If don't read msg or read sys event, continue */
396 [ # # ]: 0 : } while (i++ < MAX_TRY_TIMES);
397 : :
398 [ # # ]: 0 : if (i >= MAX_TRY_TIMES) {
399 : 0 : PMD_DRV_LOG(ERR, "No response for cmd %d", args->ops);
400 : : _clear_cmd(vf);
401 : : err = -EIO;
402 [ # # ]: 0 : } else if (vf->cmd_retval ==
403 : : VIRTCHNL_STATUS_ERR_NOT_SUPPORTED) {
404 : 0 : PMD_DRV_LOG(ERR, "Cmd %d not supported", args->ops);
405 : : err = -ENOTSUP;
406 [ # # ]: 0 : } else if (vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
407 : 0 : PMD_DRV_LOG(ERR, "Return failure %d for cmd %d",
408 : : vf->cmd_retval, args->ops);
409 : : err = -EINVAL;
410 : : }
411 : : }
412 : : break;
413 : : }
414 : :
415 : : return err;
416 : : }
417 : :
418 : : static int
419 : 0 : iavf_execute_vf_cmd_safe(struct iavf_adapter *adapter,
420 : : struct iavf_cmd_info *args, int async)
421 : : {
422 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
423 : : int ret;
424 : 0 : int is_intr_thread = rte_thread_is_intr();
425 : :
426 [ # # ]: 0 : if (is_intr_thread) {
427 [ # # ]: 0 : if (!rte_spinlock_trylock(&vf->aq_lock))
428 : : return -EIO;
429 : : } else {
430 : 0 : rte_spinlock_lock(&vf->aq_lock);
431 : : }
432 : 0 : ret = iavf_execute_vf_cmd(adapter, args, async);
433 : 0 : rte_spinlock_unlock(&vf->aq_lock);
434 : :
435 : 0 : return ret;
436 : : }
437 : :
438 : : static void
439 : 0 : iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
440 : : uint16_t msglen)
441 : : {
442 : 0 : struct iavf_adapter *adapter =
443 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
444 : : struct iavf_info *vf = &adapter->vf;
445 : : struct virtchnl_pf_event *pf_msg =
446 : : (struct virtchnl_pf_event *)msg;
447 : :
448 [ # # ]: 0 : if (adapter->closed) {
449 : 0 : PMD_DRV_LOG(DEBUG, "Port closed");
450 : 0 : return;
451 : : }
452 : :
453 [ # # ]: 0 : if (msglen < sizeof(struct virtchnl_pf_event)) {
454 : 0 : PMD_DRV_LOG(DEBUG, "Error event");
455 : 0 : return;
456 : : }
457 [ # # # # ]: 0 : switch (pf_msg->event) {
458 : 0 : case VIRTCHNL_EVENT_RESET_IMPENDING:
459 : 0 : PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
460 : 0 : vf->link_up = false;
461 [ # # ]: 0 : if (!vf->vf_reset) {
462 : 0 : vf->vf_reset = true;
463 : 0 : iavf_set_no_poll(adapter, false);
464 : 0 : iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_RESET,
465 : : NULL, 0);
466 : : }
467 : : break;
468 : 0 : case VIRTCHNL_EVENT_LINK_CHANGE:
469 : 0 : PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
470 : 0 : vf->link_up = pf_msg->event_data.link_event.link_status;
471 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_ADV_LINK_SPEED) {
472 : 0 : vf->link_speed =
473 : 0 : pf_msg->event_data.link_event_adv.link_speed;
474 : : } else {
475 : : enum virtchnl_link_speed speed;
476 : 0 : speed = pf_msg->event_data.link_event.link_speed;
477 : 0 : vf->link_speed = iavf_convert_link_speed(speed);
478 : : }
479 : 0 : iavf_dev_link_update(dev, 0);
480 [ # # # # ]: 0 : if (vf->link_up && !vf->vf_reset) {
481 : 0 : iavf_dev_watchdog_disable(adapter);
482 : : } else {
483 [ # # ]: 0 : if (!vf->link_up)
484 : 0 : iavf_dev_watchdog_enable(adapter);
485 : : }
486 [ # # ]: 0 : if (adapter->devargs.no_poll_on_link_down) {
487 : 0 : iavf_set_no_poll(adapter, true);
488 [ # # ]: 0 : if (adapter->no_poll)
489 : 0 : PMD_DRV_LOG(DEBUG, "VF no poll turned on");
490 : : else
491 : 0 : PMD_DRV_LOG(DEBUG, "VF no poll turned off");
492 : : }
493 : 0 : iavf_dev_event_post(dev, RTE_ETH_EVENT_INTR_LSC, NULL, 0);
494 : 0 : break;
495 : 0 : case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
496 : 0 : PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
497 : 0 : break;
498 : 0 : default:
499 : 0 : PMD_DRV_LOG(ERR, " unknown event received %u", pf_msg->event);
500 : 0 : break;
501 : : }
502 : : }
503 : :
504 : : void
505 : 0 : iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
506 : : {
507 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
508 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
509 : : struct iavf_arq_event_info info;
510 : : uint16_t pending, aq_opc;
511 : : enum virtchnl_ops msg_opc;
512 : : enum iavf_status msg_ret;
513 : : int ret;
514 : :
515 : 0 : info.buf_len = IAVF_AQ_BUF_SZ;
516 [ # # ]: 0 : if (!vf->aq_resp) {
517 : 0 : PMD_DRV_LOG(ERR, "Buffer for adminq resp should not be NULL");
518 : 0 : return;
519 : : }
520 : 0 : info.msg_buf = vf->aq_resp;
521 : :
522 : 0 : pending = 1;
523 [ # # ]: 0 : while (pending) {
524 : 0 : ret = iavf_clean_arq_element(hw, &info, &pending);
525 : :
526 [ # # ]: 0 : if (ret != IAVF_SUCCESS) {
527 : 0 : PMD_DRV_LOG(INFO, "Failed to read msg from AdminQ,"
528 : : "ret: %d", ret);
529 : 0 : break;
530 : : }
531 : 0 : aq_opc = rte_le_to_cpu_16(info.desc.opcode);
532 : : /* For the message sent from pf to vf, opcode is stored in
533 : : * cookie_high of struct iavf_aq_desc, while return error code
534 : : * are stored in cookie_low, Which is done by PF driver.
535 : : */
536 : 0 : msg_opc = (enum virtchnl_ops)rte_le_to_cpu_32(
537 : : info.desc.cookie_high);
538 : 0 : msg_ret = (enum iavf_status)rte_le_to_cpu_32(
539 : : info.desc.cookie_low);
540 [ # # ]: 0 : switch (aq_opc) {
541 : 0 : case iavf_aqc_opc_send_msg_to_vf:
542 [ # # ]: 0 : if (msg_opc == VIRTCHNL_OP_EVENT) {
543 : 0 : iavf_handle_pf_event_msg(dev, info.msg_buf,
544 : 0 : info.msg_len);
545 : : } else {
546 : : /* check for unsolicited messages i.e. events */
547 [ # # ]: 0 : if (info.msg_len > 0) {
548 : : switch (msg_opc) {
549 : 0 : case VIRTCHNL_OP_INLINE_IPSEC_CRYPTO: {
550 : 0 : struct inline_ipsec_msg *imsg =
551 : : (struct inline_ipsec_msg *)info.msg_buf;
552 [ # # ]: 0 : if (imsg->ipsec_opcode
553 : 0 : == INLINE_IPSEC_OP_EVENT) {
554 : : struct rte_eth_event_ipsec_desc desc;
555 : : struct virtchnl_ipsec_event *ev =
556 : : imsg->ipsec_data.event;
557 : 0 : desc.subtype =
558 : : RTE_ETH_EVENT_IPSEC_UNKNOWN;
559 : 0 : desc.metadata =
560 : 0 : ev->ipsec_event_data;
561 : 0 : iavf_dev_event_post(dev,
562 : : RTE_ETH_EVENT_IPSEC,
563 : : &desc, sizeof(desc));
564 : : continue;
565 : : }
566 : : }
567 : : break;
568 : : default:
569 : : break;
570 : : }
571 : :
572 : : }
573 : :
574 : : /* read message and it's expected one */
575 [ # # ]: 0 : if (msg_opc == vf->pend_cmd) {
576 : : uint32_t cmd_count =
577 : 0 : rte_atomic_fetch_sub_explicit(&vf->pend_cmd_count,
578 : : 1, rte_memory_order_relaxed) - 1;
579 [ # # ]: 0 : if (cmd_count == 0)
580 : : _notify_cmd(vf, msg_ret);
581 : : } else {
582 : 0 : PMD_DRV_LOG(ERR,
583 : : "command mismatch, expect %u, get %u",
584 : : vf->pend_cmd, msg_opc);
585 : : }
586 : 0 : PMD_DRV_LOG(DEBUG,
587 : : "adminq response is received, opcode = %d",
588 : : msg_opc);
589 : : }
590 : : break;
591 : 0 : default:
592 : 0 : PMD_DRV_LOG(DEBUG, "Request %u is not supported yet",
593 : : aq_opc);
594 : 0 : break;
595 : : }
596 : : }
597 : : }
598 : :
599 : : int
600 : 0 : iavf_enable_vlan_strip(struct iavf_adapter *adapter)
601 : : {
602 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
603 : : struct iavf_cmd_info args;
604 : : int ret;
605 : :
606 : : memset(&args, 0, sizeof(args));
607 : 0 : args.ops = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
608 : : args.in_args = NULL;
609 : : args.in_args_size = 0;
610 : 0 : args.out_buffer = vf->aq_resp;
611 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
612 : 0 : ret = iavf_execute_vf_cmd_safe(adapter, &args, 0);
613 [ # # ]: 0 : if (ret)
614 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command of"
615 : : " OP_ENABLE_VLAN_STRIPPING");
616 : :
617 : 0 : return ret;
618 : : }
619 : :
620 : : int
621 : 0 : iavf_disable_vlan_strip(struct iavf_adapter *adapter)
622 : : {
623 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
624 : : struct iavf_cmd_info args;
625 : : int ret;
626 : :
627 : : memset(&args, 0, sizeof(args));
628 : 0 : args.ops = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
629 : : args.in_args = NULL;
630 : : args.in_args_size = 0;
631 : 0 : args.out_buffer = vf->aq_resp;
632 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
633 : 0 : ret = iavf_execute_vf_cmd_safe(adapter, &args, 0);
634 [ # # ]: 0 : if (ret)
635 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command of"
636 : : " OP_DISABLE_VLAN_STRIPPING");
637 : :
638 : 0 : return ret;
639 : : }
640 : :
641 : : #define VIRTCHNL_VERSION_MAJOR_START 1
642 : : #define VIRTCHNL_VERSION_MINOR_START 1
643 : :
644 : : /* Check API version with sync wait until version read from admin queue */
645 : : int
646 : 0 : iavf_check_api_version(struct iavf_adapter *adapter)
647 : : {
648 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
649 : : struct virtchnl_version_info version, *pver;
650 : : struct iavf_cmd_info args;
651 : : int err;
652 : :
653 : 0 : version.major = VIRTCHNL_VERSION_MAJOR;
654 : 0 : version.minor = VIRTCHNL_VERSION_MINOR;
655 : :
656 : 0 : args.ops = VIRTCHNL_OP_VERSION;
657 : 0 : args.in_args = (uint8_t *)&version;
658 : 0 : args.in_args_size = sizeof(version);
659 : 0 : args.out_buffer = vf->aq_resp;
660 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
661 : :
662 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
663 [ # # ]: 0 : if (err) {
664 : 0 : PMD_INIT_LOG(ERR, "Fail to execute command of OP_VERSION");
665 : 0 : return err;
666 : : }
667 : :
668 : 0 : pver = (struct virtchnl_version_info *)args.out_buffer;
669 : 0 : vf->virtchnl_version = *pver;
670 : :
671 [ # # ]: 0 : if (vf->virtchnl_version.major < VIRTCHNL_VERSION_MAJOR_START ||
672 [ # # ]: 0 : (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR_START &&
673 : : vf->virtchnl_version.minor < VIRTCHNL_VERSION_MINOR_START)) {
674 : 0 : PMD_INIT_LOG(ERR, "VIRTCHNL API version should not be lower"
675 : : " than (%u.%u) to support Adaptive VF",
676 : : VIRTCHNL_VERSION_MAJOR_START,
677 : : VIRTCHNL_VERSION_MAJOR_START);
678 : 0 : return -1;
679 [ # # ]: 0 : } else if (vf->virtchnl_version.major > VIRTCHNL_VERSION_MAJOR ||
680 : 0 : (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR &&
681 [ # # ]: 0 : vf->virtchnl_version.minor > VIRTCHNL_VERSION_MINOR)) {
682 : 0 : PMD_INIT_LOG(ERR, "PF/VF API version mismatch:(%u.%u)-(%u.%u)",
683 : : vf->virtchnl_version.major,
684 : : vf->virtchnl_version.minor,
685 : : VIRTCHNL_VERSION_MAJOR,
686 : : VIRTCHNL_VERSION_MINOR);
687 : 0 : return -1;
688 : : }
689 : :
690 : 0 : PMD_DRV_LOG(DEBUG, "Peer is supported PF host");
691 : 0 : return 0;
692 : : }
693 : :
694 : : int
695 : 0 : iavf_get_vf_resource(struct iavf_adapter *adapter)
696 : : {
697 : 0 : struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
698 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
699 : : struct iavf_cmd_info args;
700 : : uint32_t caps, len;
701 : : int err, i;
702 : :
703 : 0 : args.ops = VIRTCHNL_OP_GET_VF_RESOURCES;
704 : 0 : args.out_buffer = vf->aq_resp;
705 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
706 : :
707 : 0 : caps = IAVF_BASIC_OFFLOAD_CAPS | VIRTCHNL_VF_CAP_ADV_LINK_SPEED |
708 : : VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
709 : : VIRTCHNL_VF_OFFLOAD_FDIR_PF |
710 : : VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |
711 : : VIRTCHNL_VF_OFFLOAD_FSUB_PF |
712 : : VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
713 : : VIRTCHNL_VF_OFFLOAD_USO |
714 : : VIRTCHNL_VF_OFFLOAD_CRC |
715 : : VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
716 : : VIRTCHNL_VF_LARGE_NUM_QPAIRS |
717 : : VIRTCHNL_VF_OFFLOAD_QOS |
718 : : VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO |
719 : : VIRTCHNL_VF_CAP_PTP;
720 : :
721 : 0 : args.in_args = (uint8_t *)∩︀
722 : 0 : args.in_args_size = sizeof(caps);
723 : :
724 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
725 : :
726 [ # # ]: 0 : if (err) {
727 : 0 : PMD_DRV_LOG(ERR,
728 : : "Failed to execute command of OP_GET_VF_RESOURCE");
729 : 0 : return -1;
730 : : }
731 : :
732 : : len = sizeof(struct virtchnl_vf_resource) +
733 : : IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
734 : :
735 : 0 : rte_memcpy(vf->vf_res, args.out_buffer,
736 [ # # ]: 0 : RTE_MIN(args.out_size, len));
737 : : /* parse VF config message back from PF*/
738 : 0 : iavf_vf_parse_hw_config(hw, vf->vf_res);
739 [ # # ]: 0 : for (i = 0; i < vf->vf_res->num_vsis; i++) {
740 [ # # ]: 0 : if (vf->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
741 : 0 : vf->vsi_res = &vf->vf_res->vsi_res[i];
742 : : }
743 : :
744 [ # # ]: 0 : if (!vf->vsi_res) {
745 : 0 : PMD_INIT_LOG(ERR, "no LAN VSI found");
746 : 0 : return -1;
747 : : }
748 : :
749 : 0 : vf->vsi.vsi_id = vf->vsi_res->vsi_id;
750 : 0 : vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
751 : 0 : vf->vsi.adapter = adapter;
752 : :
753 : 0 : return 0;
754 : : }
755 : :
756 : : int
757 : 0 : iavf_get_supported_rxdid(struct iavf_adapter *adapter)
758 : : {
759 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
760 : : struct iavf_cmd_info args;
761 : : int ret;
762 : :
763 : 0 : args.ops = VIRTCHNL_OP_GET_SUPPORTED_RXDIDS;
764 : 0 : args.in_args = NULL;
765 : 0 : args.in_args_size = 0;
766 : 0 : args.out_buffer = vf->aq_resp;
767 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
768 : :
769 : 0 : ret = iavf_execute_vf_cmd_safe(adapter, &args, 0);
770 [ # # ]: 0 : if (ret) {
771 : 0 : PMD_DRV_LOG(ERR,
772 : : "Failed to execute command of OP_GET_SUPPORTED_RXDIDS");
773 : 0 : return ret;
774 : : }
775 : :
776 : 0 : vf->supported_rxdid =
777 : 0 : ((struct virtchnl_supported_rxdids *)args.out_buffer)->supported_rxdids;
778 : :
779 : 0 : return 0;
780 : : }
781 : :
782 : : int
783 : 0 : iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable)
784 : : {
785 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
786 : : struct virtchnl_vlan_supported_caps *stripping_caps;
787 : : struct virtchnl_vlan_setting vlan_strip;
788 : : struct iavf_cmd_info args;
789 : : uint32_t *ethertype;
790 : : int ret;
791 : :
792 : : stripping_caps = &vf->vlan_v2_caps.offloads.stripping_support;
793 : :
794 [ # # # # ]: 0 : if ((stripping_caps->outer & VIRTCHNL_VLAN_ETHERTYPE_8100) &&
795 : : (stripping_caps->outer & VIRTCHNL_VLAN_TOGGLE))
796 : : ethertype = &vlan_strip.outer_ethertype_setting;
797 [ # # # # ]: 0 : else if ((stripping_caps->inner & VIRTCHNL_VLAN_ETHERTYPE_8100) &&
798 : : (stripping_caps->inner & VIRTCHNL_VLAN_TOGGLE))
799 : : ethertype = &vlan_strip.inner_ethertype_setting;
800 : : else
801 : : return -ENOTSUP;
802 : :
803 : : memset(&vlan_strip, 0, sizeof(vlan_strip));
804 : 0 : vlan_strip.vport_id = vf->vsi_res->vsi_id;
805 : 0 : *ethertype = VIRTCHNL_VLAN_ETHERTYPE_8100;
806 : :
807 [ # # ]: 0 : args.ops = enable ? VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 :
808 : : VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2;
809 : 0 : args.in_args = (uint8_t *)&vlan_strip;
810 : 0 : args.in_args_size = sizeof(vlan_strip);
811 : 0 : args.out_buffer = vf->aq_resp;
812 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
813 : 0 : ret = iavf_execute_vf_cmd_safe(adapter, &args, 0);
814 [ # # ]: 0 : if (ret)
815 [ # # ]: 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
816 : : enable ? "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2" :
817 : : "VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2");
818 : :
819 : : return ret;
820 : : }
821 : :
822 : : int
823 : 0 : iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable)
824 : : {
825 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
826 : : struct virtchnl_vlan_supported_caps *insertion_caps;
827 : : struct virtchnl_vlan_setting vlan_insert;
828 : : struct iavf_cmd_info args;
829 : : uint32_t *ethertype;
830 : : int ret;
831 : :
832 : : insertion_caps = &vf->vlan_v2_caps.offloads.insertion_support;
833 : :
834 [ # # # # ]: 0 : if ((insertion_caps->outer & VIRTCHNL_VLAN_ETHERTYPE_8100) &&
835 : : (insertion_caps->outer & VIRTCHNL_VLAN_TOGGLE))
836 : : ethertype = &vlan_insert.outer_ethertype_setting;
837 [ # # # # ]: 0 : else if ((insertion_caps->inner & VIRTCHNL_VLAN_ETHERTYPE_8100) &&
838 : : (insertion_caps->inner & VIRTCHNL_VLAN_TOGGLE))
839 : : ethertype = &vlan_insert.inner_ethertype_setting;
840 : : else
841 : : return -ENOTSUP;
842 : :
843 : : memset(&vlan_insert, 0, sizeof(vlan_insert));
844 : 0 : vlan_insert.vport_id = vf->vsi_res->vsi_id;
845 : 0 : *ethertype = VIRTCHNL_VLAN_ETHERTYPE_8100;
846 : :
847 [ # # ]: 0 : args.ops = enable ? VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 :
848 : : VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2;
849 : 0 : args.in_args = (uint8_t *)&vlan_insert;
850 : 0 : args.in_args_size = sizeof(vlan_insert);
851 : 0 : args.out_buffer = vf->aq_resp;
852 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
853 : 0 : ret = iavf_execute_vf_cmd_safe(adapter, &args, 0);
854 [ # # ]: 0 : if (ret)
855 [ # # ]: 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
856 : : enable ? "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2" :
857 : : "VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2");
858 : :
859 : : return ret;
860 : : }
861 : :
862 : : int
863 : 0 : iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
864 : : {
865 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
866 : : struct virtchnl_vlan_supported_caps *supported_caps;
867 : : struct virtchnl_vlan_filter_list_v2 vlan_filter;
868 : : struct virtchnl_vlan *vlan_setting;
869 : : struct iavf_cmd_info args;
870 : : uint32_t filtering_caps;
871 : : int err;
872 : :
873 : : supported_caps = &vf->vlan_v2_caps.filtering.filtering_support;
874 [ # # ]: 0 : if (supported_caps->outer) {
875 : : filtering_caps = supported_caps->outer;
876 : : vlan_setting = &vlan_filter.filters[0].outer;
877 : : } else {
878 : 0 : filtering_caps = supported_caps->inner;
879 : : vlan_setting = &vlan_filter.filters[0].inner;
880 : : }
881 : :
882 [ # # ]: 0 : if (!(filtering_caps & VIRTCHNL_VLAN_ETHERTYPE_8100))
883 : : return -ENOTSUP;
884 : :
885 : : memset(&vlan_filter, 0, sizeof(vlan_filter));
886 : 0 : vlan_filter.vport_id = vf->vsi_res->vsi_id;
887 : 0 : vlan_filter.num_elements = 1;
888 : 0 : vlan_setting->tpid = RTE_ETHER_TYPE_VLAN;
889 : 0 : vlan_setting->tci = vlanid;
890 : :
891 [ # # ]: 0 : args.ops = add ? VIRTCHNL_OP_ADD_VLAN_V2 : VIRTCHNL_OP_DEL_VLAN_V2;
892 : 0 : args.in_args = (uint8_t *)&vlan_filter;
893 : 0 : args.in_args_size = sizeof(vlan_filter);
894 : 0 : args.out_buffer = vf->aq_resp;
895 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
896 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
897 [ # # ]: 0 : if (err)
898 [ # # ]: 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
899 : : add ? "OP_ADD_VLAN_V2" : "OP_DEL_VLAN_V2");
900 : :
901 : : return err;
902 : : }
903 : :
904 : : int
905 : 0 : iavf_get_vlan_offload_caps_v2(struct iavf_adapter *adapter)
906 : : {
907 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
908 : : struct iavf_cmd_info args;
909 : : int ret;
910 : :
911 : 0 : args.ops = VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS;
912 : 0 : args.in_args = NULL;
913 : 0 : args.in_args_size = 0;
914 : 0 : args.out_buffer = vf->aq_resp;
915 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
916 : :
917 : 0 : ret = iavf_execute_vf_cmd_safe(adapter, &args, 0);
918 [ # # ]: 0 : if (ret) {
919 : 0 : PMD_DRV_LOG(ERR,
920 : : "Failed to execute command of VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS");
921 : 0 : return ret;
922 : : }
923 : :
924 [ # # ]: 0 : rte_memcpy(&vf->vlan_v2_caps, vf->aq_resp, sizeof(vf->vlan_v2_caps));
925 : :
926 : : return 0;
927 : : }
928 : :
929 : : int
930 : 0 : iavf_enable_queues(struct iavf_adapter *adapter)
931 : : {
932 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
933 : : struct virtchnl_queue_select queue_select;
934 : : struct iavf_cmd_info args;
935 : : int err;
936 : :
937 : : memset(&queue_select, 0, sizeof(queue_select));
938 : 0 : queue_select.vsi_id = vf->vsi_res->vsi_id;
939 : :
940 : 0 : queue_select.rx_queues = BIT(adapter->dev_data->nb_rx_queues) - 1;
941 : 0 : queue_select.tx_queues = BIT(adapter->dev_data->nb_tx_queues) - 1;
942 : :
943 : 0 : args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
944 : 0 : args.in_args = (u8 *)&queue_select;
945 : 0 : args.in_args_size = sizeof(queue_select);
946 : 0 : args.out_buffer = vf->aq_resp;
947 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
948 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
949 [ # # ]: 0 : if (err) {
950 : 0 : PMD_DRV_LOG(ERR,
951 : : "Failed to execute command of OP_ENABLE_QUEUES");
952 : 0 : return err;
953 : : }
954 : : return 0;
955 : : }
956 : :
957 : : int
958 : 0 : iavf_disable_queues(struct iavf_adapter *adapter)
959 : : {
960 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
961 : : struct virtchnl_queue_select queue_select;
962 : : struct iavf_cmd_info args;
963 : : int err;
964 : :
965 : : memset(&queue_select, 0, sizeof(queue_select));
966 : 0 : queue_select.vsi_id = vf->vsi_res->vsi_id;
967 : :
968 : 0 : queue_select.rx_queues = BIT(adapter->dev_data->nb_rx_queues) - 1;
969 : 0 : queue_select.tx_queues = BIT(adapter->dev_data->nb_tx_queues) - 1;
970 : :
971 : 0 : args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
972 : 0 : args.in_args = (u8 *)&queue_select;
973 : 0 : args.in_args_size = sizeof(queue_select);
974 : 0 : args.out_buffer = vf->aq_resp;
975 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
976 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
977 [ # # ]: 0 : if (err) {
978 : 0 : PMD_DRV_LOG(ERR,
979 : : "Failed to execute command of OP_DISABLE_QUEUES");
980 : 0 : return err;
981 : : }
982 : : return 0;
983 : : }
984 : :
985 : : int
986 : 0 : iavf_switch_queue(struct iavf_adapter *adapter, uint16_t qid,
987 : : bool rx, bool on)
988 : : {
989 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
990 : : struct virtchnl_queue_select queue_select;
991 : : struct iavf_cmd_info args;
992 : : int err;
993 : :
994 [ # # ]: 0 : if (adapter->closed)
995 : : return -EIO;
996 : :
997 : : memset(&queue_select, 0, sizeof(queue_select));
998 : 0 : queue_select.vsi_id = vf->vsi_res->vsi_id;
999 [ # # ]: 0 : if (rx)
1000 : 0 : queue_select.rx_queues |= 1 << qid;
1001 : : else
1002 : 0 : queue_select.tx_queues |= 1 << qid;
1003 : :
1004 [ # # ]: 0 : if (on)
1005 : 0 : args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
1006 : : else
1007 : 0 : args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
1008 : 0 : args.in_args = (u8 *)&queue_select;
1009 : 0 : args.in_args_size = sizeof(queue_select);
1010 : 0 : args.out_buffer = vf->aq_resp;
1011 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1012 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1013 [ # # ]: 0 : if (err)
1014 [ # # ]: 0 : PMD_DRV_LOG(ERR, "Failed to execute command of %s",
1015 : : on ? "OP_ENABLE_QUEUES" : "OP_DISABLE_QUEUES");
1016 : : return err;
1017 : : }
1018 : :
1019 : : int
1020 : 0 : iavf_enable_queues_lv(struct iavf_adapter *adapter)
1021 : : {
1022 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1023 : : struct {
1024 : : struct virtchnl_del_ena_dis_queues msg;
1025 : : struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM - 1];
1026 : 0 : } queue_req = {0};
1027 : : struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg;
1028 : : struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;
1029 : : struct iavf_cmd_info args;
1030 : : int err;
1031 : :
1032 : 0 : queue_select->chunks.num_chunks = IAVF_RXTX_QUEUE_CHUNKS_NUM;
1033 : 0 : queue_select->vport_id = vf->vsi_res->vsi_id;
1034 : :
1035 : : queue_chunk[VIRTCHNL_QUEUE_TYPE_TX].type = VIRTCHNL_QUEUE_TYPE_TX;
1036 : : queue_chunk[VIRTCHNL_QUEUE_TYPE_TX].start_queue_id = 0;
1037 : 0 : queue_chunk[VIRTCHNL_QUEUE_TYPE_TX].num_queues =
1038 : 0 : adapter->dev_data->nb_tx_queues;
1039 : :
1040 : 0 : queue_chunk[VIRTCHNL_QUEUE_TYPE_RX].type = VIRTCHNL_QUEUE_TYPE_RX;
1041 : : queue_chunk[VIRTCHNL_QUEUE_TYPE_RX].start_queue_id = 0;
1042 : 0 : queue_chunk[VIRTCHNL_QUEUE_TYPE_RX].num_queues =
1043 : 0 : adapter->dev_data->nb_rx_queues;
1044 : :
1045 : 0 : args.ops = VIRTCHNL_OP_ENABLE_QUEUES_V2;
1046 : 0 : args.in_args = (u8 *)queue_select;
1047 : 0 : args.in_args_size = sizeof(queue_req);
1048 : 0 : args.out_buffer = vf->aq_resp;
1049 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1050 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1051 [ # # ]: 0 : if (err)
1052 : 0 : PMD_DRV_LOG(ERR,
1053 : : "Failed to execute command of OP_ENABLE_QUEUES_V2");
1054 : :
1055 : 0 : return err;
1056 : : }
1057 : :
1058 : : int
1059 : 0 : iavf_disable_queues_lv(struct iavf_adapter *adapter)
1060 : : {
1061 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1062 : : struct {
1063 : : struct virtchnl_del_ena_dis_queues msg;
1064 : : struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM - 1];
1065 : 0 : } queue_req = {0};
1066 : : struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg;
1067 : : struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;
1068 : : struct iavf_cmd_info args;
1069 : : int err;
1070 : :
1071 : 0 : queue_select->chunks.num_chunks = IAVF_RXTX_QUEUE_CHUNKS_NUM;
1072 : 0 : queue_select->vport_id = vf->vsi_res->vsi_id;
1073 : :
1074 : : queue_chunk[VIRTCHNL_QUEUE_TYPE_TX].type = VIRTCHNL_QUEUE_TYPE_TX;
1075 : : queue_chunk[VIRTCHNL_QUEUE_TYPE_TX].start_queue_id = 0;
1076 : 0 : queue_chunk[VIRTCHNL_QUEUE_TYPE_TX].num_queues =
1077 : 0 : adapter->dev_data->nb_tx_queues;
1078 : :
1079 : 0 : queue_chunk[VIRTCHNL_QUEUE_TYPE_RX].type = VIRTCHNL_QUEUE_TYPE_RX;
1080 : : queue_chunk[VIRTCHNL_QUEUE_TYPE_RX].start_queue_id = 0;
1081 : 0 : queue_chunk[VIRTCHNL_QUEUE_TYPE_RX].num_queues =
1082 : 0 : adapter->dev_data->nb_rx_queues;
1083 : :
1084 : 0 : args.ops = VIRTCHNL_OP_DISABLE_QUEUES_V2;
1085 : 0 : args.in_args = (u8 *)queue_select;
1086 : 0 : args.in_args_size = sizeof(queue_req);
1087 : 0 : args.out_buffer = vf->aq_resp;
1088 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1089 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1090 [ # # ]: 0 : if (err)
1091 : 0 : PMD_DRV_LOG(ERR,
1092 : : "Failed to execute command of OP_DISABLE_QUEUES_V2");
1093 : :
1094 : 0 : return err;
1095 : : }
1096 : :
1097 : : int
1098 : 0 : iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,
1099 : : bool rx, bool on)
1100 : : {
1101 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1102 : : struct {
1103 : : struct virtchnl_del_ena_dis_queues msg;
1104 : 0 : } queue_req = {0};
1105 : : struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg;
1106 : : struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;
1107 : : struct iavf_cmd_info args;
1108 : : int err;
1109 : :
1110 : 0 : queue_select->chunks.num_chunks = 1;
1111 : 0 : queue_select->vport_id = vf->vsi_res->vsi_id;
1112 : :
1113 [ # # ]: 0 : if (rx) {
1114 : 0 : queue_chunk->type = VIRTCHNL_QUEUE_TYPE_RX;
1115 : 0 : queue_chunk->start_queue_id = qid;
1116 : 0 : queue_chunk->num_queues = 1;
1117 : : } else {
1118 : : queue_chunk->type = VIRTCHNL_QUEUE_TYPE_TX;
1119 : 0 : queue_chunk->start_queue_id = qid;
1120 : 0 : queue_chunk->num_queues = 1;
1121 : : }
1122 : :
1123 [ # # ]: 0 : if (on)
1124 : 0 : args.ops = VIRTCHNL_OP_ENABLE_QUEUES_V2;
1125 : : else
1126 : 0 : args.ops = VIRTCHNL_OP_DISABLE_QUEUES_V2;
1127 : 0 : args.in_args = (u8 *)queue_select;
1128 : 0 : args.in_args_size = sizeof(queue_req);
1129 : 0 : args.out_buffer = vf->aq_resp;
1130 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1131 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1132 [ # # ]: 0 : if (err)
1133 [ # # ]: 0 : PMD_DRV_LOG(ERR, "Failed to execute command of %s",
1134 : : on ? "OP_ENABLE_QUEUES_V2" : "OP_DISABLE_QUEUES_V2");
1135 : :
1136 : 0 : return err;
1137 : : }
1138 : :
1139 : : int
1140 : 0 : iavf_configure_rss_lut(struct iavf_adapter *adapter)
1141 : : {
1142 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1143 : : struct virtchnl_rss_lut *rss_lut;
1144 : : struct iavf_cmd_info args;
1145 : : int len, err = 0;
1146 : :
1147 : 0 : len = sizeof(*rss_lut) + vf->vf_res->rss_lut_size - 1;
1148 : 0 : rss_lut = calloc(1, len);
1149 [ # # ]: 0 : if (!rss_lut)
1150 : : return -ENOMEM;
1151 : :
1152 : 0 : rss_lut->vsi_id = vf->vsi_res->vsi_id;
1153 : 0 : rss_lut->lut_entries = vf->vf_res->rss_lut_size;
1154 [ # # ]: 0 : rte_memcpy(rss_lut->lut, vf->rss_lut, vf->vf_res->rss_lut_size);
1155 : :
1156 : 0 : args.ops = VIRTCHNL_OP_CONFIG_RSS_LUT;
1157 : 0 : args.in_args = (u8 *)rss_lut;
1158 : 0 : args.in_args_size = len;
1159 : 0 : args.out_buffer = vf->aq_resp;
1160 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1161 : :
1162 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1163 [ # # ]: 0 : if (err)
1164 : 0 : PMD_DRV_LOG(ERR,
1165 : : "Failed to execute command of OP_CONFIG_RSS_LUT");
1166 : :
1167 : 0 : free(rss_lut);
1168 : 0 : return err;
1169 : : }
1170 : :
1171 : : int
1172 : 0 : iavf_configure_rss_key(struct iavf_adapter *adapter)
1173 : : {
1174 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1175 : : struct virtchnl_rss_key *rss_key;
1176 : : struct iavf_cmd_info args;
1177 : : int len, err = 0;
1178 : :
1179 : 0 : len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
1180 : 0 : rss_key = calloc(1, len);
1181 [ # # ]: 0 : if (!rss_key)
1182 : : return -ENOMEM;
1183 : :
1184 : 0 : rss_key->vsi_id = vf->vsi_res->vsi_id;
1185 : 0 : rss_key->key_len = vf->vf_res->rss_key_size;
1186 [ # # ]: 0 : rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size);
1187 : :
1188 : 0 : args.ops = VIRTCHNL_OP_CONFIG_RSS_KEY;
1189 : 0 : args.in_args = (u8 *)rss_key;
1190 : 0 : args.in_args_size = len;
1191 : 0 : args.out_buffer = vf->aq_resp;
1192 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1193 : :
1194 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1195 [ # # ]: 0 : if (err)
1196 : 0 : PMD_DRV_LOG(ERR,
1197 : : "Failed to execute command of OP_CONFIG_RSS_KEY");
1198 : :
1199 : 0 : free(rss_key);
1200 : 0 : return err;
1201 : : }
1202 : :
1203 : : static void
1204 : 0 : iavf_configure_queue_pair(struct iavf_adapter *adapter,
1205 : : struct virtchnl_queue_pair_info *vc_qp,
1206 : : uint16_t q_idx)
1207 : : {
1208 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1209 : 0 : struct ci_rx_queue **rxq = (struct ci_rx_queue **)adapter->dev_data->rx_queues;
1210 : 0 : struct ci_tx_queue **txq = (struct ci_tx_queue **)adapter->dev_data->tx_queues;
1211 : :
1212 : : /* common parts */
1213 : 0 : vc_qp->txq.vsi_id = vf->vsi_res->vsi_id;
1214 : 0 : vc_qp->txq.queue_id = q_idx;
1215 : :
1216 : 0 : vc_qp->rxq.vsi_id = vf->vsi_res->vsi_id;
1217 : 0 : vc_qp->rxq.queue_id = q_idx;
1218 : 0 : vc_qp->rxq.max_pkt_size = vf->max_pkt_len;
1219 : :
1220 : : /* is this txq active? */
1221 [ # # ]: 0 : if (q_idx < adapter->dev_data->nb_tx_queues) {
1222 : 0 : vc_qp->txq.ring_len = txq[q_idx]->nb_tx_desc;
1223 : 0 : vc_qp->txq.dma_ring_addr = txq[q_idx]->tx_ring_dma;
1224 : : }
1225 : :
1226 : : /* is this rxq active? */
1227 [ # # ]: 0 : if (q_idx >= adapter->dev_data->nb_rx_queues)
1228 : : return;
1229 : :
1230 : 0 : vc_qp->rxq.ring_len = rxq[q_idx]->nb_rx_desc;
1231 : 0 : vc_qp->rxq.dma_ring_addr = rxq[q_idx]->rx_ring_phys_addr;
1232 : 0 : vc_qp->rxq.databuffer_size = rxq[q_idx]->rx_buf_len;
1233 : 0 : vc_qp->rxq.crc_disable = rxq[q_idx]->crc_len != 0 ? 1 : 0;
1234 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC) {
1235 [ # # ]: 0 : if (vf->supported_rxdid & RTE_BIT64(rxq[q_idx]->rxdid)) {
1236 : 0 : vc_qp->rxq.rxdid = rxq[q_idx]->rxdid;
1237 : 0 : PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d]",
1238 : : vc_qp->rxq.rxdid, q_idx);
1239 : : } else {
1240 : 0 : PMD_DRV_LOG(NOTICE, "RXDID[%d] is not supported, "
1241 : : "request default RXDID[%d] in Queue[%d]",
1242 : : rxq[q_idx]->rxdid, IAVF_RXDID_LEGACY_1, q_idx);
1243 : 0 : vc_qp->rxq.rxdid = IAVF_RXDID_LEGACY_1;
1244 : : }
1245 : :
1246 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP &&
1247 [ # # ]: 0 : vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP &&
1248 [ # # ]: 0 : rxq[q_idx]->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
1249 : 0 : vc_qp->rxq.flags |= VIRTCHNL_PTP_RX_TSTAMP;
1250 : : }
1251 : : }
1252 : :
1253 : : static int
1254 : 0 : iavf_configure_queue_chunk(struct iavf_adapter *adapter,
1255 : : uint16_t chunk_sz,
1256 : : uint16_t chunk_start)
1257 : : {
1258 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1259 : : struct {
1260 : : struct virtchnl_vsi_queue_config_info config;
1261 : : struct virtchnl_queue_pair_info qp[IAVF_CFG_Q_NUM_PER_BUF];
1262 : 0 : } queue_req = {0};
1263 : 0 : struct iavf_cmd_info args = {0};
1264 : : struct virtchnl_vsi_queue_config_info *vc_config = &queue_req.config;
1265 : : struct virtchnl_queue_pair_info *vc_qp = vc_config->qpair;
1266 : 0 : uint16_t chunk_end = chunk_start + chunk_sz;
1267 : : uint16_t i;
1268 : : size_t buf_len;
1269 : : int err;
1270 : :
1271 [ # # ]: 0 : if (chunk_sz > IAVF_CFG_Q_NUM_PER_BUF)
1272 : : return -EINVAL;
1273 : :
1274 : 0 : vc_config->vsi_id = vf->vsi_res->vsi_id;
1275 : 0 : vc_config->num_queue_pairs = chunk_sz;
1276 : :
1277 [ # # ]: 0 : for (i = chunk_start; i < chunk_end; i++, vc_qp++)
1278 : 0 : iavf_configure_queue_pair(adapter, vc_qp, i);
1279 : :
1280 : : /* for some reason PF side checks for buffer being too big, so adjust it down */
1281 : 0 : buf_len = sizeof(struct virtchnl_vsi_queue_config_info) +
1282 : 0 : sizeof(struct virtchnl_queue_pair_info) * chunk_sz;
1283 : :
1284 : 0 : args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
1285 : 0 : args.in_args = (uint8_t *)vc_config;
1286 : 0 : args.in_args_size = buf_len;
1287 : 0 : args.out_buffer = vf->aq_resp;
1288 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1289 : :
1290 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1291 [ # # ]: 0 : if (err)
1292 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command VIRTCHNL_OP_CONFIG_VSI_QUEUES");
1293 : : return err;
1294 : : }
1295 : :
1296 : : int
1297 : 0 : iavf_configure_queues(struct iavf_adapter *adapter, uint16_t num_queue_pairs)
1298 : : {
1299 : : uint16_t c;
1300 : : int err;
1301 : :
1302 : : /*
1303 : : * we cannot configure all queues in one go because they won't fit into
1304 : : * adminq buffer, so we're going to chunk them instead
1305 : : */
1306 [ # # ]: 0 : for (c = 0; c < num_queue_pairs; c += IAVF_CFG_Q_NUM_PER_BUF) {
1307 : 0 : uint16_t chunk_sz = RTE_MIN(num_queue_pairs - c, IAVF_CFG_Q_NUM_PER_BUF);
1308 : 0 : err = iavf_configure_queue_chunk(adapter, chunk_sz, c);
1309 [ # # ]: 0 : if (err) {
1310 : 0 : PMD_DRV_LOG(ERR, "Failed to configure queues chunk [%u, %u)",
1311 : : c, c + chunk_sz);
1312 : 0 : return err;
1313 : : }
1314 : : }
1315 : : return 0;
1316 : : }
1317 : :
1318 : : int
1319 : 0 : iavf_config_irq_map(struct iavf_adapter *adapter)
1320 : : {
1321 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1322 : : struct {
1323 : : struct virtchnl_irq_map_info map_info;
1324 : : struct virtchnl_vector_map vecmap[IAVF_MAX_NUM_QUEUES_DFLT];
1325 : 0 : } map_req = {0};
1326 : : struct virtchnl_irq_map_info *map_info = &map_req.map_info;
1327 : 0 : struct iavf_cmd_info args = {0};
1328 : : int i, err, max_vmi = -1;
1329 : : size_t buf_len;
1330 : :
1331 [ # # ]: 0 : if (adapter->dev_data->nb_rx_queues > IAVF_MAX_NUM_QUEUES_DFLT) {
1332 : 0 : PMD_DRV_LOG(ERR, "number of queues (%u) exceeds the max supported (%u)",
1333 : : adapter->dev_data->nb_rx_queues, IAVF_MAX_NUM_QUEUES_DFLT);
1334 : 0 : return -EINVAL;
1335 : : }
1336 : :
1337 [ # # ]: 0 : for (i = 0; i < adapter->dev_data->nb_rx_queues; i++) {
1338 : : struct virtchnl_vector_map *vecmap;
1339 : : /* always 0 for 1 MSIX, never bigger than rxq for multi MSIX */
1340 : 0 : uint16_t vmi = vf->qv_map[i].vector_id - vf->msix_base;
1341 : :
1342 : : /* can't happen but avoid static analysis warnings */
1343 [ # # ]: 0 : if (vmi >= IAVF_MAX_NUM_QUEUES_DFLT) {
1344 : 0 : PMD_DRV_LOG(ERR, "vector id (%u) exceeds the max supported (%u)",
1345 : : vf->qv_map[i].vector_id,
1346 : : vf->msix_base + IAVF_MAX_NUM_QUEUES_DFLT - 1);
1347 : 0 : return -EINVAL;
1348 : : }
1349 : :
1350 : 0 : vecmap = &map_info->vecmap[vmi];
1351 : 0 : vecmap->vsi_id = vf->vsi_res->vsi_id;
1352 : 0 : vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
1353 : 0 : vecmap->vector_id = vf->qv_map[i].vector_id;
1354 : 0 : vecmap->txq_map = 0;
1355 : 0 : vecmap->rxq_map |= 1 << vf->qv_map[i].queue_id;
1356 : :
1357 : : /* MSIX vectors round robin so look for max */
1358 [ # # ]: 0 : if (vmi > max_vmi) {
1359 : 0 : map_info->num_vectors++;
1360 : : max_vmi = vmi;
1361 : : }
1362 : : }
1363 : :
1364 : : /* for some reason PF side checks for buffer being too big, so adjust it down */
1365 : 0 : buf_len = sizeof(struct virtchnl_irq_map_info) +
1366 : 0 : sizeof(struct virtchnl_vector_map) * map_info->num_vectors;
1367 : :
1368 : 0 : args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
1369 : 0 : args.in_args = (u8 *)map_info;
1370 : 0 : args.in_args_size = buf_len;
1371 : 0 : args.out_buffer = vf->aq_resp;
1372 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1373 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1374 [ # # ]: 0 : if (err)
1375 : 0 : PMD_DRV_LOG(ERR, "fail to execute command OP_CONFIG_IRQ_MAP");
1376 : :
1377 : : return err;
1378 : : }
1379 : :
1380 : : static int
1381 : 0 : iavf_config_irq_map_lv_chunk(struct iavf_adapter *adapter,
1382 : : uint16_t chunk_sz,
1383 : : uint16_t chunk_start)
1384 : : {
1385 : : struct {
1386 : : struct virtchnl_queue_vector_maps map_info;
1387 : : struct virtchnl_queue_vector qv_maps[IAVF_CFG_Q_NUM_PER_BUF];
1388 : 0 : } chunk_req = {0};
1389 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1390 : 0 : struct iavf_cmd_info args = {0};
1391 : : struct virtchnl_queue_vector_maps *map_info = &chunk_req.map_info;
1392 : : struct virtchnl_queue_vector *qv_maps = chunk_req.qv_maps;
1393 : : size_t buf_len;
1394 : : uint16_t i;
1395 : :
1396 [ # # ]: 0 : if (chunk_sz > IAVF_CFG_Q_NUM_PER_BUF)
1397 : : return -EINVAL;
1398 : :
1399 : 0 : map_info->vport_id = vf->vsi_res->vsi_id;
1400 : 0 : map_info->num_qv_maps = chunk_sz;
1401 [ # # ]: 0 : for (i = 0; i < chunk_sz; i++) {
1402 : 0 : qv_maps = &map_info->qv_maps[i];
1403 : 0 : qv_maps->itr_idx = VIRTCHNL_ITR_IDX_0;
1404 : 0 : qv_maps->queue_type = VIRTCHNL_QUEUE_TYPE_RX;
1405 : 0 : qv_maps->queue_id = vf->qv_map[chunk_start + i].queue_id;
1406 : 0 : qv_maps->vector_id = vf->qv_map[chunk_start + i].vector_id;
1407 : : }
1408 : :
1409 : : /* for some reason PF side checks for buffer being too big, so adjust it down */
1410 : 0 : buf_len = sizeof(struct virtchnl_queue_vector_maps) +
1411 : 0 : sizeof(struct virtchnl_queue_vector) * chunk_sz;
1412 : :
1413 : 0 : args.ops = VIRTCHNL_OP_MAP_QUEUE_VECTOR;
1414 : 0 : args.in_args = (u8 *)map_info;
1415 : 0 : args.in_args_size = buf_len;
1416 : 0 : args.out_buffer = vf->aq_resp;
1417 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1418 : :
1419 : 0 : return iavf_execute_vf_cmd_safe(adapter, &args, 0);
1420 : : }
1421 : :
1422 : : int
1423 : 0 : iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num)
1424 : : {
1425 : : uint16_t c;
1426 : : int err;
1427 : :
1428 [ # # ]: 0 : for (c = 0; c < num; c += IAVF_CFG_Q_NUM_PER_BUF) {
1429 : 0 : uint16_t chunk_sz = RTE_MIN(num - c, IAVF_CFG_Q_NUM_PER_BUF);
1430 : 0 : err = iavf_config_irq_map_lv_chunk(adapter, chunk_sz, c);
1431 [ # # ]: 0 : if (err) {
1432 : 0 : PMD_DRV_LOG(ERR, "Failed to configure irq map chunk [%u, %u)",
1433 : : c, c + chunk_sz);
1434 : 0 : return err;
1435 : : }
1436 : : }
1437 : : return 0;
1438 : : }
1439 : :
1440 : : void
1441 : 0 : iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)
1442 : : {
1443 : : struct {
1444 : : struct virtchnl_ether_addr_list list;
1445 : : struct virtchnl_ether_addr addr[IAVF_NUM_MACADDR_MAX];
1446 : 0 : } list_req = {0};
1447 : : struct virtchnl_ether_addr_list *list = &list_req.list;
1448 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1449 : 0 : struct iavf_cmd_info args = {0};
1450 : : int err, i;
1451 : : size_t buf_len;
1452 : :
1453 [ # # ]: 0 : for (i = 0; i < IAVF_NUM_MACADDR_MAX; i++) {
1454 : 0 : struct rte_ether_addr *addr = &adapter->dev_data->mac_addrs[i];
1455 [ # # ]: 0 : struct virtchnl_ether_addr *vc_addr = &list->list[list->num_elements];
1456 : :
1457 : : /* ignore empty addresses */
1458 [ # # ]: 0 : if (rte_is_zero_ether_addr(addr))
1459 : 0 : continue;
1460 : 0 : list->num_elements++;
1461 : :
1462 [ # # ]: 0 : memcpy(vc_addr->addr, addr->addr_bytes, sizeof(addr->addr_bytes));
1463 [ # # ]: 0 : vc_addr->type = (list->num_elements == 1) ?
1464 : : VIRTCHNL_ETHER_ADDR_PRIMARY :
1465 : : VIRTCHNL_ETHER_ADDR_EXTRA;
1466 : : }
1467 : :
1468 : : /* for some reason PF side checks for buffer being too big, so adjust it down */
1469 : 0 : buf_len = sizeof(struct virtchnl_ether_addr_list) +
1470 : 0 : sizeof(struct virtchnl_ether_addr) * list->num_elements;
1471 : :
1472 : 0 : list->vsi_id = vf->vsi_res->vsi_id;
1473 [ # # ]: 0 : args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
1474 : 0 : args.in_args = (uint8_t *)list;
1475 : 0 : args.in_args_size = buf_len;
1476 : 0 : args.out_buffer = vf->aq_resp;
1477 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1478 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1479 [ # # ]: 0 : if (err)
1480 [ # # ]: 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
1481 : : add ? "OP_ADD_ETHER_ADDRESS" : "OP_DEL_ETHER_ADDRESS");
1482 : 0 : }
1483 : :
1484 : : int
1485 : 0 : iavf_query_stats(struct iavf_adapter *adapter,
1486 : : struct virtchnl_eth_stats **pstats)
1487 : : {
1488 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1489 : : struct virtchnl_queue_select q_stats;
1490 : : struct iavf_cmd_info args;
1491 : : int err;
1492 : :
1493 [ # # ]: 0 : if (adapter->closed)
1494 : : return -EIO;
1495 : :
1496 : : memset(&q_stats, 0, sizeof(q_stats));
1497 : 0 : q_stats.vsi_id = vf->vsi_res->vsi_id;
1498 : 0 : args.ops = VIRTCHNL_OP_GET_STATS;
1499 : 0 : args.in_args = (uint8_t *)&q_stats;
1500 : 0 : args.in_args_size = sizeof(q_stats);
1501 : 0 : args.out_buffer = vf->aq_resp;
1502 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1503 : :
1504 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1505 [ # # ]: 0 : if (err) {
1506 : 0 : PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS");
1507 : 0 : *pstats = NULL;
1508 : 0 : return err;
1509 : : }
1510 : 0 : *pstats = (struct virtchnl_eth_stats *)args.out_buffer;
1511 : 0 : return 0;
1512 : : }
1513 : :
1514 : : int
1515 : 0 : iavf_config_promisc(struct iavf_adapter *adapter,
1516 : : bool enable_unicast,
1517 : : bool enable_multicast)
1518 : : {
1519 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1520 : : struct virtchnl_promisc_info promisc;
1521 : : struct iavf_cmd_info args;
1522 : : int err;
1523 : :
1524 [ # # ]: 0 : if (adapter->closed)
1525 : : return -EIO;
1526 : :
1527 : 0 : promisc.flags = 0;
1528 : 0 : promisc.vsi_id = vf->vsi_res->vsi_id;
1529 : :
1530 [ # # ]: 0 : if (enable_unicast)
1531 : 0 : promisc.flags |= FLAG_VF_UNICAST_PROMISC;
1532 : :
1533 [ # # ]: 0 : if (enable_multicast)
1534 : 0 : promisc.flags |= FLAG_VF_MULTICAST_PROMISC;
1535 : :
1536 : 0 : args.ops = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
1537 : 0 : args.in_args = (uint8_t *)&promisc;
1538 : 0 : args.in_args_size = sizeof(promisc);
1539 : 0 : args.out_buffer = vf->aq_resp;
1540 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1541 : :
1542 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1543 : :
1544 [ # # ]: 0 : if (err) {
1545 : 0 : PMD_DRV_LOG(ERR,
1546 : : "fail to execute command CONFIG_PROMISCUOUS_MODE");
1547 : :
1548 [ # # ]: 0 : if (err == -ENOTSUP)
1549 : : return err;
1550 : :
1551 : 0 : return -EAGAIN;
1552 : : }
1553 : :
1554 : 0 : vf->promisc_unicast_enabled = enable_unicast;
1555 : 0 : vf->promisc_multicast_enabled = enable_multicast;
1556 : 0 : return 0;
1557 : : }
1558 : :
1559 : : int
1560 : 0 : iavf_add_del_eth_addr(struct iavf_adapter *adapter, struct rte_ether_addr *addr,
1561 : : bool add, uint8_t type)
1562 : : {
1563 : : struct virtchnl_ether_addr_list *list;
1564 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1565 : : uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) +
1566 : : sizeof(struct virtchnl_ether_addr)];
1567 : : struct iavf_cmd_info args;
1568 : : int err;
1569 : :
1570 [ # # ]: 0 : if (adapter->closed)
1571 : : return -EIO;
1572 : :
1573 : : list = (struct virtchnl_ether_addr_list *)cmd_buffer;
1574 : 0 : list->vsi_id = vf->vsi_res->vsi_id;
1575 : 0 : list->num_elements = 1;
1576 : 0 : list->list[0].type = type;
1577 [ # # ]: 0 : rte_memcpy(list->list[0].addr, addr->addr_bytes,
1578 : : sizeof(addr->addr_bytes));
1579 : :
1580 [ # # ]: 0 : args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
1581 : 0 : args.in_args = cmd_buffer;
1582 : 0 : args.in_args_size = sizeof(cmd_buffer);
1583 : 0 : args.out_buffer = vf->aq_resp;
1584 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1585 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1586 [ # # ]: 0 : if (err)
1587 [ # # ]: 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
1588 : : add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR");
1589 : : return err;
1590 : : }
1591 : :
1592 : : int
1593 : 0 : iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
1594 : : {
1595 : : struct virtchnl_vlan_filter_list *vlan_list;
1596 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1597 : : uint8_t cmd_buffer[sizeof(struct virtchnl_vlan_filter_list) +
1598 : : sizeof(uint16_t)];
1599 : : struct iavf_cmd_info args;
1600 : : int err;
1601 : :
1602 : : vlan_list = (struct virtchnl_vlan_filter_list *)cmd_buffer;
1603 : 0 : vlan_list->vsi_id = vf->vsi_res->vsi_id;
1604 : 0 : vlan_list->num_elements = 1;
1605 : 0 : vlan_list->vlan_id[0] = vlanid;
1606 : :
1607 [ # # ]: 0 : args.ops = add ? VIRTCHNL_OP_ADD_VLAN : VIRTCHNL_OP_DEL_VLAN;
1608 : 0 : args.in_args = cmd_buffer;
1609 : 0 : args.in_args_size = sizeof(cmd_buffer);
1610 : 0 : args.out_buffer = vf->aq_resp;
1611 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1612 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1613 [ # # ]: 0 : if (err)
1614 [ # # ]: 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
1615 : : add ? "OP_ADD_VLAN" : "OP_DEL_VLAN");
1616 : :
1617 : 0 : return err;
1618 : : }
1619 : :
1620 : : int
1621 : 0 : iavf_fdir_add(struct iavf_adapter *adapter,
1622 : : struct iavf_fdir_conf *filter)
1623 : : {
1624 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1625 : : struct virtchnl_fdir_add *fdir_ret;
1626 : :
1627 : : struct iavf_cmd_info args;
1628 : : int err;
1629 : :
1630 : 0 : filter->add_fltr.vsi_id = vf->vsi_res->vsi_id;
1631 : 0 : filter->add_fltr.validate_only = 0;
1632 : :
1633 : 0 : args.ops = VIRTCHNL_OP_ADD_FDIR_FILTER;
1634 : 0 : args.in_args = (uint8_t *)(&filter->add_fltr);
1635 : 0 : args.in_args_size = sizeof(*(&filter->add_fltr));
1636 : 0 : args.out_buffer = vf->aq_resp;
1637 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1638 : :
1639 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1640 [ # # ]: 0 : if (err) {
1641 : 0 : PMD_DRV_LOG(ERR, "fail to execute command OP_ADD_FDIR_FILTER");
1642 : 0 : return err;
1643 : : }
1644 : :
1645 : 0 : fdir_ret = (struct virtchnl_fdir_add *)args.out_buffer;
1646 : 0 : filter->flow_id = fdir_ret->flow_id;
1647 : :
1648 [ # # ]: 0 : if (fdir_ret->status == VIRTCHNL_FDIR_SUCCESS) {
1649 : 0 : PMD_DRV_LOG(INFO,
1650 : : "Succeed in adding rule request by PF");
1651 : : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_NORESOURCE) {
1652 : 0 : PMD_DRV_LOG(ERR,
1653 : : "Failed to add rule request due to no hw resource");
1654 : 0 : return -1;
1655 : : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_EXIST) {
1656 : 0 : PMD_DRV_LOG(ERR,
1657 : : "Failed to add rule request due to the rule is already existed");
1658 : 0 : return -1;
1659 : : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_CONFLICT) {
1660 : 0 : PMD_DRV_LOG(ERR,
1661 : : "Failed to add rule request due to the rule is conflict with existing rule");
1662 : 0 : return -1;
1663 : : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_INVALID) {
1664 : 0 : PMD_DRV_LOG(ERR,
1665 : : "Failed to add rule request due to the hw doesn't support");
1666 : 0 : return -1;
1667 : : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT) {
1668 : 0 : PMD_DRV_LOG(ERR,
1669 : : "Failed to add rule request due to time out for programming");
1670 : 0 : return -1;
1671 : : } else {
1672 : 0 : PMD_DRV_LOG(ERR,
1673 : : "Failed to add rule request due to other reasons");
1674 : 0 : return -1;
1675 : : }
1676 : :
1677 : 0 : return 0;
1678 : : };
1679 : :
1680 : : int
1681 : 0 : iavf_fdir_del(struct iavf_adapter *adapter,
1682 : : struct iavf_fdir_conf *filter)
1683 : : {
1684 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1685 : : struct virtchnl_fdir_del *fdir_ret;
1686 : :
1687 : : struct iavf_cmd_info args;
1688 : : int err;
1689 : :
1690 : 0 : filter->del_fltr.vsi_id = vf->vsi_res->vsi_id;
1691 : 0 : filter->del_fltr.flow_id = filter->flow_id;
1692 : :
1693 : 0 : args.ops = VIRTCHNL_OP_DEL_FDIR_FILTER;
1694 : 0 : args.in_args = (uint8_t *)(&filter->del_fltr);
1695 : 0 : args.in_args_size = sizeof(filter->del_fltr);
1696 : 0 : args.out_buffer = vf->aq_resp;
1697 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1698 : :
1699 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1700 [ # # ]: 0 : if (err) {
1701 : 0 : PMD_DRV_LOG(ERR, "fail to execute command OP_DEL_FDIR_FILTER");
1702 : 0 : return err;
1703 : : }
1704 : :
1705 : 0 : fdir_ret = (struct virtchnl_fdir_del *)args.out_buffer;
1706 : :
1707 [ # # ]: 0 : if (fdir_ret->status == VIRTCHNL_FDIR_SUCCESS) {
1708 : 0 : PMD_DRV_LOG(INFO,
1709 : : "Succeed in deleting rule request by PF");
1710 [ # # ]: 0 : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST) {
1711 : 0 : PMD_DRV_LOG(ERR,
1712 : : "Failed to delete rule request due to this rule doesn't exist");
1713 : 0 : return -1;
1714 [ # # ]: 0 : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_TIMEOUT) {
1715 : 0 : PMD_DRV_LOG(ERR,
1716 : : "Failed to delete rule request due to time out for programming");
1717 : 0 : return -1;
1718 : : } else {
1719 : 0 : PMD_DRV_LOG(ERR,
1720 : : "Failed to delete rule request due to other reasons");
1721 : 0 : return -1;
1722 : : }
1723 : :
1724 : 0 : return 0;
1725 : : };
1726 : :
1727 : : int
1728 : 0 : iavf_fdir_check(struct iavf_adapter *adapter,
1729 : : struct iavf_fdir_conf *filter)
1730 : : {
1731 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1732 : : struct virtchnl_fdir_add *fdir_ret;
1733 : :
1734 : : struct iavf_cmd_info args;
1735 : : int err;
1736 : :
1737 : 0 : filter->add_fltr.vsi_id = vf->vsi_res->vsi_id;
1738 : 0 : filter->add_fltr.validate_only = 1;
1739 : :
1740 : 0 : args.ops = VIRTCHNL_OP_ADD_FDIR_FILTER;
1741 : 0 : args.in_args = (uint8_t *)(&filter->add_fltr);
1742 : 0 : args.in_args_size = sizeof(*(&filter->add_fltr));
1743 : 0 : args.out_buffer = vf->aq_resp;
1744 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1745 : :
1746 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1747 [ # # ]: 0 : if (err) {
1748 : 0 : PMD_DRV_LOG(ERR, "fail to check flow director rule");
1749 : 0 : return err;
1750 : : }
1751 : :
1752 : 0 : fdir_ret = (struct virtchnl_fdir_add *)args.out_buffer;
1753 : :
1754 [ # # ]: 0 : if (fdir_ret->status == VIRTCHNL_FDIR_SUCCESS) {
1755 : 0 : PMD_DRV_LOG(INFO,
1756 : : "Succeed in checking rule request by PF");
1757 [ # # ]: 0 : } else if (fdir_ret->status == VIRTCHNL_FDIR_FAILURE_RULE_INVALID) {
1758 : 0 : PMD_DRV_LOG(ERR,
1759 : : "Failed to check rule request due to parameters validation"
1760 : : " or HW doesn't support");
1761 : : err = -1;
1762 : : } else {
1763 : 0 : PMD_DRV_LOG(ERR,
1764 : : "Failed to check rule request due to other reasons");
1765 : : err = -1;
1766 : : }
1767 : :
1768 : : return err;
1769 : : }
1770 : :
1771 : : int
1772 : 0 : iavf_flow_sub(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter)
1773 : : {
1774 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1775 : : struct virtchnl_flow_sub *fsub_cfg;
1776 : : struct iavf_cmd_info args;
1777 : : int err;
1778 : :
1779 : 0 : filter->sub_fltr.vsi_id = vf->vsi_res->vsi_id;
1780 : 0 : filter->sub_fltr.validate_only = 0;
1781 : :
1782 : : memset(&args, 0, sizeof(args));
1783 : 0 : args.ops = VIRTCHNL_OP_FLOW_SUBSCRIBE;
1784 : 0 : args.in_args = (uint8_t *)(&filter->sub_fltr);
1785 : 0 : args.in_args_size = sizeof(*(&filter->sub_fltr));
1786 : 0 : args.out_buffer = vf->aq_resp;
1787 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1788 : :
1789 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1790 [ # # ]: 0 : if (err) {
1791 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command of "
1792 : : "OP_FLOW_SUBSCRIBE");
1793 : 0 : return err;
1794 : : }
1795 : :
1796 : 0 : fsub_cfg = (struct virtchnl_flow_sub *)args.out_buffer;
1797 : 0 : filter->flow_id = fsub_cfg->flow_id;
1798 : :
1799 [ # # ]: 0 : if (fsub_cfg->status == VIRTCHNL_FSUB_SUCCESS) {
1800 : 0 : PMD_DRV_LOG(INFO, "Succeed in adding rule request by PF");
1801 [ # # ]: 0 : } else if (fsub_cfg->status == VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE) {
1802 : 0 : PMD_DRV_LOG(ERR, "Failed to add rule request due to no hw "
1803 : : "resource");
1804 : : err = -1;
1805 [ # # ]: 0 : } else if (fsub_cfg->status == VIRTCHNL_FSUB_FAILURE_RULE_EXIST) {
1806 : 0 : PMD_DRV_LOG(ERR, "Failed to add rule request due to the rule "
1807 : : "is already existed");
1808 : : err = -1;
1809 [ # # ]: 0 : } else if (fsub_cfg->status == VIRTCHNL_FSUB_FAILURE_RULE_INVALID) {
1810 : 0 : PMD_DRV_LOG(ERR, "Failed to add rule request due to the hw "
1811 : : "doesn't support");
1812 : : err = -1;
1813 : : } else {
1814 : 0 : PMD_DRV_LOG(ERR, "Failed to add rule request due to other "
1815 : : "reasons");
1816 : : err = -1;
1817 : : }
1818 : :
1819 : : return err;
1820 : : }
1821 : :
1822 : : int
1823 : 0 : iavf_flow_unsub(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter)
1824 : : {
1825 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1826 : : struct virtchnl_flow_unsub *unsub_cfg;
1827 : : struct iavf_cmd_info args;
1828 : : int err;
1829 : :
1830 : 0 : filter->unsub_fltr.vsi_id = vf->vsi_res->vsi_id;
1831 : 0 : filter->unsub_fltr.flow_id = filter->flow_id;
1832 : :
1833 : : memset(&args, 0, sizeof(args));
1834 : 0 : args.ops = VIRTCHNL_OP_FLOW_UNSUBSCRIBE;
1835 : 0 : args.in_args = (uint8_t *)(&filter->unsub_fltr);
1836 : 0 : args.in_args_size = sizeof(filter->unsub_fltr);
1837 : 0 : args.out_buffer = vf->aq_resp;
1838 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1839 : :
1840 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1841 [ # # ]: 0 : if (err) {
1842 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command of "
1843 : : "OP_FLOW_UNSUBSCRIBE");
1844 : 0 : return err;
1845 : : }
1846 : :
1847 : 0 : unsub_cfg = (struct virtchnl_flow_unsub *)args.out_buffer;
1848 : :
1849 [ # # ]: 0 : if (unsub_cfg->status == VIRTCHNL_FSUB_SUCCESS) {
1850 : 0 : PMD_DRV_LOG(INFO, "Succeed in deleting rule request by PF");
1851 [ # # ]: 0 : } else if (unsub_cfg->status == VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST) {
1852 : 0 : PMD_DRV_LOG(ERR, "Failed to delete rule request due to this "
1853 : : "rule doesn't exist");
1854 : : err = -1;
1855 : : } else {
1856 : 0 : PMD_DRV_LOG(ERR, "Failed to delete rule request due to other "
1857 : : "reasons");
1858 : : err = -1;
1859 : : }
1860 : :
1861 : : return err;
1862 : : }
1863 : :
1864 : : int
1865 : 0 : iavf_flow_sub_check(struct iavf_adapter *adapter,
1866 : : struct iavf_fsub_conf *filter)
1867 : : {
1868 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1869 : : struct virtchnl_flow_sub *fsub_cfg;
1870 : :
1871 : : struct iavf_cmd_info args;
1872 : : int err;
1873 : :
1874 : 0 : filter->sub_fltr.vsi_id = vf->vsi_res->vsi_id;
1875 : 0 : filter->sub_fltr.validate_only = 1;
1876 : :
1877 : 0 : args.ops = VIRTCHNL_OP_FLOW_SUBSCRIBE;
1878 : 0 : args.in_args = (uint8_t *)(&filter->sub_fltr);
1879 : 0 : args.in_args_size = sizeof(*(&filter->sub_fltr));
1880 : 0 : args.out_buffer = vf->aq_resp;
1881 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1882 : :
1883 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1884 [ # # ]: 0 : if (err) {
1885 : 0 : PMD_DRV_LOG(ERR, "Failed to check flow subscription rule");
1886 : 0 : return err;
1887 : : }
1888 : :
1889 : 0 : fsub_cfg = (struct virtchnl_flow_sub *)args.out_buffer;
1890 : :
1891 [ # # ]: 0 : if (fsub_cfg->status == VIRTCHNL_FSUB_SUCCESS) {
1892 : 0 : PMD_DRV_LOG(INFO, "Succeed in checking rule request by PF");
1893 [ # # ]: 0 : } else if (fsub_cfg->status == VIRTCHNL_FSUB_FAILURE_RULE_INVALID) {
1894 : 0 : PMD_DRV_LOG(ERR, "Failed to check rule request due to "
1895 : : "parameters validation or HW doesn't "
1896 : : "support");
1897 : : err = -1;
1898 : : } else {
1899 : 0 : PMD_DRV_LOG(ERR, "Failed to check rule request due to other "
1900 : : "reasons");
1901 : : err = -1;
1902 : : }
1903 : :
1904 : : return err;
1905 : : }
1906 : :
1907 : : int
1908 [ # # ]: 0 : iavf_add_del_rss_cfg(struct iavf_adapter *adapter,
1909 : : struct virtchnl_rss_cfg *rss_cfg, bool add)
1910 : : {
1911 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1912 : : struct iavf_cmd_info args;
1913 : : int err;
1914 : :
1915 : : memset(&args, 0, sizeof(args));
1916 [ # # ]: 0 : args.ops = add ? VIRTCHNL_OP_ADD_RSS_CFG :
1917 : : VIRTCHNL_OP_DEL_RSS_CFG;
1918 : 0 : args.in_args = (u8 *)rss_cfg;
1919 : 0 : args.in_args_size = sizeof(*rss_cfg);
1920 : 0 : args.out_buffer = vf->aq_resp;
1921 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1922 : :
1923 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1924 [ # # ]: 0 : if (err)
1925 [ # # ]: 0 : PMD_DRV_LOG(ERR,
1926 : : "Failed to execute command of %s",
1927 : : add ? "OP_ADD_RSS_CFG" :
1928 : : "OP_DEL_RSS_INPUT_CFG");
1929 : :
1930 : 0 : return err;
1931 : : }
1932 : :
1933 : : int
1934 : 0 : iavf_get_hena_caps(struct iavf_adapter *adapter, uint64_t *caps)
1935 : : {
1936 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1937 : : struct iavf_cmd_info args;
1938 : : int err;
1939 : :
1940 : 0 : args.ops = VIRTCHNL_OP_GET_RSS_HENA_CAPS;
1941 : 0 : args.in_args = NULL;
1942 : 0 : args.in_args_size = 0;
1943 : 0 : args.out_buffer = vf->aq_resp;
1944 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1945 : :
1946 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1947 [ # # ]: 0 : if (err) {
1948 : 0 : PMD_DRV_LOG(ERR,
1949 : : "Failed to execute command of OP_GET_RSS_HENA_CAPS");
1950 : 0 : return err;
1951 : : }
1952 : :
1953 : 0 : *caps = ((struct virtchnl_rss_hena *)args.out_buffer)->hena;
1954 : 0 : return 0;
1955 : : }
1956 : :
1957 : : int
1958 : 0 : iavf_set_hena(struct iavf_adapter *adapter, uint64_t hena)
1959 : : {
1960 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1961 : : struct virtchnl_rss_hena vrh;
1962 : : struct iavf_cmd_info args;
1963 : : int err;
1964 : :
1965 : 0 : vrh.hena = hena;
1966 : 0 : args.ops = VIRTCHNL_OP_SET_RSS_HENA;
1967 : 0 : args.in_args = (u8 *)&vrh;
1968 : 0 : args.in_args_size = sizeof(vrh);
1969 : 0 : args.out_buffer = vf->aq_resp;
1970 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1971 : :
1972 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1973 [ # # ]: 0 : if (err)
1974 : 0 : PMD_DRV_LOG(ERR,
1975 : : "Failed to execute command of OP_SET_RSS_HENA");
1976 : :
1977 : 0 : return err;
1978 : : }
1979 : :
1980 : : int
1981 : 0 : iavf_get_qos_cap(struct iavf_adapter *adapter)
1982 : : {
1983 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
1984 : : struct iavf_cmd_info args;
1985 : : uint32_t len;
1986 : : int err;
1987 : :
1988 : 0 : args.ops = VIRTCHNL_OP_GET_QOS_CAPS;
1989 : 0 : args.in_args = NULL;
1990 : 0 : args.in_args_size = 0;
1991 : 0 : args.out_buffer = vf->aq_resp;
1992 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
1993 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
1994 : :
1995 [ # # ]: 0 : if (err) {
1996 : 0 : PMD_DRV_LOG(ERR,
1997 : : "Failed to execute command of OP_GET_VF_RESOURCE");
1998 : 0 : return -1;
1999 : : }
2000 : :
2001 : : len = sizeof(struct virtchnl_qos_cap_list) +
2002 : : IAVF_MAX_TRAFFIC_CLASS * sizeof(struct virtchnl_qos_cap_elem);
2003 : :
2004 : 0 : rte_memcpy(vf->qos_cap, args.out_buffer,
2005 [ # # ]: 0 : RTE_MIN(args.out_size, len));
2006 : :
2007 : : return 0;
2008 : : }
2009 : :
2010 : 0 : int iavf_set_q_tc_map(struct rte_eth_dev *dev,
2011 : : struct virtchnl_queue_tc_mapping *q_tc_mapping, uint16_t size)
2012 : : {
2013 : 0 : struct iavf_adapter *adapter =
2014 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2015 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
2016 : : struct iavf_cmd_info args;
2017 : : int err;
2018 : :
2019 : : memset(&args, 0, sizeof(args));
2020 : 0 : args.ops = VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP;
2021 : 0 : args.in_args = (uint8_t *)q_tc_mapping;
2022 : 0 : args.in_args_size = size;
2023 : 0 : args.out_buffer = vf->aq_resp;
2024 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2025 : :
2026 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2027 [ # # ]: 0 : if (err)
2028 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command of"
2029 : : " VIRTCHNL_OP_CONFIG_TC_MAP");
2030 : 0 : return err;
2031 : : }
2032 : :
2033 : 0 : int iavf_set_q_bw(struct rte_eth_dev *dev,
2034 : : struct virtchnl_queues_bw_cfg *q_bw, uint16_t size)
2035 : : {
2036 : 0 : struct iavf_adapter *adapter =
2037 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2038 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
2039 : : struct iavf_cmd_info args;
2040 : : int err;
2041 : :
2042 : : memset(&args, 0, sizeof(args));
2043 : 0 : args.ops = VIRTCHNL_OP_CONFIG_QUEUE_BW;
2044 : 0 : args.in_args = (uint8_t *)q_bw;
2045 : 0 : args.in_args_size = size;
2046 : 0 : args.out_buffer = vf->aq_resp;
2047 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2048 : :
2049 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2050 [ # # ]: 0 : if (err)
2051 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command of"
2052 : : " VIRTCHNL_OP_CONFIG_QUEUE_BW");
2053 : 0 : return err;
2054 : : }
2055 : :
2056 : : int
2057 : 0 : iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,
2058 : : struct rte_ether_addr *mc_addrs,
2059 : : uint32_t mc_addrs_num, bool add)
2060 : : {
2061 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
2062 : : uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) +
2063 : : (IAVF_NUM_MACADDR_MAX * sizeof(struct virtchnl_ether_addr))];
2064 : : struct virtchnl_ether_addr_list *list;
2065 : : struct iavf_cmd_info args;
2066 : : uint32_t i;
2067 : : int err;
2068 : :
2069 [ # # ]: 0 : if (mc_addrs == NULL || mc_addrs_num == 0)
2070 : : return 0;
2071 : :
2072 : : list = (struct virtchnl_ether_addr_list *)cmd_buffer;
2073 : 0 : list->vsi_id = vf->vsi_res->vsi_id;
2074 : 0 : list->num_elements = mc_addrs_num;
2075 : :
2076 [ # # ]: 0 : for (i = 0; i < mc_addrs_num; i++) {
2077 [ # # ]: 0 : if (!IAVF_IS_MULTICAST(mc_addrs[i].addr_bytes)) {
2078 : 0 : PMD_DRV_LOG(ERR, "Invalid mac:" RTE_ETHER_ADDR_PRT_FMT,
2079 : : RTE_ETHER_ADDR_BYTES(&mc_addrs[i]));
2080 : 0 : return -EINVAL;
2081 : : }
2082 : :
2083 : 0 : memcpy(list->list[i].addr, mc_addrs[i].addr_bytes,
2084 : : sizeof(list->list[i].addr));
2085 : 0 : list->list[i].type = VIRTCHNL_ETHER_ADDR_EXTRA;
2086 : : }
2087 : :
2088 [ # # ]: 0 : args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
2089 : 0 : args.in_args = cmd_buffer;
2090 : 0 : args.in_args_size = sizeof(struct virtchnl_ether_addr_list) +
2091 : 0 : i * sizeof(struct virtchnl_ether_addr);
2092 : 0 : args.out_buffer = vf->aq_resp;
2093 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2094 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2095 : :
2096 [ # # ]: 0 : if (err) {
2097 [ # # ]: 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
2098 : : add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR");
2099 : 0 : return err;
2100 : : }
2101 : :
2102 : : return 0;
2103 : : }
2104 : :
2105 : : int
2106 : 0 : iavf_request_queues(struct rte_eth_dev *dev, uint16_t num)
2107 : : {
2108 : 0 : struct iavf_adapter *adapter =
2109 : 0 : IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
2110 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
2111 : : struct virtchnl_vf_res_request vfres;
2112 : : struct iavf_cmd_info args;
2113 : : uint16_t num_queue_pairs;
2114 : : int err;
2115 : : int i = 0;
2116 : :
2117 [ # # ]: 0 : if (!(vf->vf_res->vf_cap_flags &
2118 : : VIRTCHNL_VF_OFFLOAD_REQ_QUEUES)) {
2119 : 0 : PMD_DRV_LOG(ERR, "request queues not supported");
2120 : 0 : return -1;
2121 : : }
2122 : :
2123 [ # # ]: 0 : if (num == 0) {
2124 : 0 : PMD_DRV_LOG(ERR, "queue number cannot be zero");
2125 : 0 : return -1;
2126 : : }
2127 : 0 : vfres.num_queue_pairs = num;
2128 : :
2129 : 0 : args.ops = VIRTCHNL_OP_REQUEST_QUEUES;
2130 : 0 : args.in_args = (u8 *)&vfres;
2131 : 0 : args.in_args_size = sizeof(vfres);
2132 : 0 : args.out_buffer = vf->aq_resp;
2133 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2134 : :
2135 [ # # ]: 0 : if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
2136 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2137 : : } else {
2138 : 0 : rte_eal_alarm_cancel(iavf_dev_alarm_handler, dev);
2139 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2140 : 0 : rte_eal_alarm_set(IAVF_ALARM_INTERVAL,
2141 : : iavf_dev_alarm_handler, dev);
2142 : : }
2143 : :
2144 [ # # ]: 0 : if (err) {
2145 : 0 : PMD_DRV_LOG(ERR, "fail to execute command OP_REQUEST_QUEUES");
2146 : 0 : return err;
2147 : : }
2148 : :
2149 : : /* wait for interrupt notification vf is resetting */
2150 [ # # ]: 0 : while (i++ < MAX_TRY_TIMES) {
2151 [ # # ]: 0 : if (vf->vf_reset)
2152 : : break;
2153 : 0 : iavf_msec_delay(ASQ_DELAY_MS);
2154 : : }
2155 : :
2156 : : /* request queues succeeded, vf is resetting */
2157 [ # # ]: 0 : if (vf->vf_reset) {
2158 : 0 : PMD_DRV_LOG(INFO, "vf is resetting");
2159 : 0 : return 0;
2160 : : }
2161 : :
2162 : : /* request additional queues failed, return available number */
2163 : 0 : num_queue_pairs =
2164 : 0 : ((struct virtchnl_vf_res_request *)args.out_buffer)->num_queue_pairs;
2165 : 0 : PMD_DRV_LOG(ERR, "request queues failed, only %u queues "
2166 : : "available", num_queue_pairs);
2167 : :
2168 : 0 : return -1;
2169 : : }
2170 : :
2171 : : int
2172 : 0 : iavf_get_max_rss_queue_region(struct iavf_adapter *adapter)
2173 : : {
2174 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
2175 : : struct iavf_cmd_info args;
2176 : : uint16_t qregion_width;
2177 : : int err;
2178 : :
2179 : 0 : args.ops = VIRTCHNL_OP_GET_MAX_RSS_QREGION;
2180 : 0 : args.in_args = NULL;
2181 : 0 : args.in_args_size = 0;
2182 : 0 : args.out_buffer = vf->aq_resp;
2183 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2184 : :
2185 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2186 [ # # ]: 0 : if (err) {
2187 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL_OP_GET_MAX_RSS_QREGION");
2188 : 0 : return err;
2189 : : }
2190 : :
2191 : 0 : qregion_width =
2192 : 0 : ((struct virtchnl_max_rss_qregion *)args.out_buffer)->qregion_width;
2193 : :
2194 : 0 : vf->max_rss_qregion = (uint16_t)(1 << qregion_width);
2195 : :
2196 : 0 : return 0;
2197 : : }
2198 : :
2199 : :
2200 : :
2201 : : int
2202 : 0 : iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
2203 : : uint8_t *msg, size_t msg_len,
2204 : : uint8_t *resp_msg, size_t resp_msg_len)
2205 : : {
2206 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
2207 : : struct iavf_cmd_info args;
2208 : : int err;
2209 : :
2210 : 0 : args.ops = VIRTCHNL_OP_INLINE_IPSEC_CRYPTO;
2211 : 0 : args.in_args = msg;
2212 : 0 : args.in_args_size = msg_len;
2213 : 0 : args.out_buffer = vf->aq_resp;
2214 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2215 : :
2216 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 1);
2217 [ # # ]: 0 : if (err) {
2218 : 0 : PMD_DRV_LOG(ERR, "fail to execute command %s",
2219 : : "OP_INLINE_IPSEC_CRYPTO");
2220 : 0 : return err;
2221 : : }
2222 : :
2223 : 0 : memcpy(resp_msg, args.out_buffer, resp_msg_len);
2224 : :
2225 : 0 : return 0;
2226 : : }
2227 : :
2228 : : int
2229 : 0 : iavf_set_vf_quanta_size(struct iavf_adapter *adapter, u16 start_queue_id, u16 num_queues)
2230 : : {
2231 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
2232 : : struct iavf_cmd_info args;
2233 : : struct virtchnl_quanta_cfg q_quanta;
2234 : : int err;
2235 : :
2236 [ # # ]: 0 : if (adapter->devargs.quanta_size == 0)
2237 : : return 0;
2238 : :
2239 : 0 : q_quanta.quanta_size = adapter->devargs.quanta_size;
2240 : 0 : q_quanta.queue_select.type = VIRTCHNL_QUEUE_TYPE_TX;
2241 : 0 : q_quanta.queue_select.start_queue_id = start_queue_id;
2242 : 0 : q_quanta.queue_select.num_queues = num_queues;
2243 : :
2244 : 0 : args.ops = VIRTCHNL_OP_CONFIG_QUANTA;
2245 : 0 : args.in_args = (uint8_t *)&q_quanta;
2246 : 0 : args.in_args_size = sizeof(q_quanta);
2247 : 0 : args.out_buffer = vf->aq_resp;
2248 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2249 : :
2250 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2251 [ # # ]: 0 : if (err) {
2252 : 0 : PMD_DRV_LOG(ERR, "Failed to execute command VIRTCHNL_OP_CONFIG_QUANTA");
2253 : 0 : return err;
2254 : : }
2255 : :
2256 : : return 0;
2257 : : }
2258 : :
2259 : : int
2260 : 0 : iavf_get_ptp_cap(struct iavf_adapter *adapter)
2261 : : {
2262 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
2263 : : struct virtchnl_ptp_caps ptp_caps;
2264 : : struct iavf_cmd_info args;
2265 : : int err;
2266 : :
2267 : 0 : ptp_caps.caps = VIRTCHNL_1588_PTP_CAP_RX_TSTAMP |
2268 : : VIRTCHNL_1588_PTP_CAP_READ_PHC;
2269 : :
2270 : 0 : args.ops = VIRTCHNL_OP_1588_PTP_GET_CAPS;
2271 : 0 : args.in_args = (uint8_t *)&ptp_caps;
2272 : 0 : args.in_args_size = sizeof(ptp_caps);
2273 : 0 : args.out_buffer = vf->aq_resp;
2274 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2275 : :
2276 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2277 [ # # ]: 0 : if (err) {
2278 : 0 : PMD_DRV_LOG(ERR,
2279 : : "Failed to execute command of OP_1588_PTP_GET_CAPS");
2280 : 0 : return err;
2281 : : }
2282 : :
2283 : 0 : vf->ptp_caps = ((struct virtchnl_ptp_caps *)args.out_buffer)->caps;
2284 : :
2285 : 0 : return 0;
2286 : : }
2287 : :
2288 : : int
2289 : 0 : iavf_get_phc_time(struct ci_rx_queue *rxq)
2290 : : {
2291 : 0 : struct iavf_adapter *adapter = rxq->iavf_vsi->adapter;
2292 : : struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
2293 : : struct virtchnl_phc_time phc_time;
2294 : : struct iavf_cmd_info args;
2295 : : int err = 0;
2296 : :
2297 : 0 : args.ops = VIRTCHNL_OP_1588_PTP_GET_TIME;
2298 : 0 : args.in_args = (uint8_t *)&phc_time;
2299 : 0 : args.in_args_size = sizeof(phc_time);
2300 : 0 : args.out_buffer = vf->aq_resp;
2301 : 0 : args.out_size = IAVF_AQ_BUF_SZ;
2302 : :
2303 : 0 : rte_spinlock_lock(&vf->phc_time_aq_lock);
2304 : 0 : err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
2305 [ # # ]: 0 : if (err) {
2306 : 0 : PMD_DRV_LOG(ERR,
2307 : : "Failed to execute command of VIRTCHNL_OP_1588_PTP_GET_TIME");
2308 : 0 : goto out;
2309 : : }
2310 : 0 : rxq->phc_time = ((struct virtchnl_phc_time *)args.out_buffer)->time;
2311 : :
2312 : 0 : out:
2313 : : rte_spinlock_unlock(&vf->phc_time_aq_lock);
2314 : 0 : return err;
2315 : : }
|