1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
12 #include <rte_byteorder.h>
13 #include <rte_common.h>
15 #include <rte_debug.h>
16 #include <rte_atomic.h>
18 #include <rte_ether.h>
19 #include <rte_ethdev.h>
23 #include "base/avf_prototype.h"
24 #include "base/avf_adminq_cmd.h"
25 #include "base/avf_type.h"
30 #define MAX_TRY_TIMES 200
31 #define ASQ_DELAY_MS 10
33 /* Read data in admin queue to get msg from pf driver */
34 static enum avf_status_code
35 avf_read_msg_from_pf(struct avf_adapter *adapter, uint16_t buf_len,
38 struct avf_hw *hw = AVF_DEV_PRIVATE_TO_HW(adapter);
39 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
40 struct avf_arq_event_info event;
41 enum virtchnl_ops opcode;
44 event.buf_len = buf_len;
46 ret = avf_clean_arq_element(hw, &event, NULL);
47 /* Can't read any msg from adminQ */
49 PMD_DRV_LOG(DEBUG, "Can't read msg from AQ");
53 opcode = (enum virtchnl_ops)rte_le_to_cpu_32(event.desc.cookie_high);
54 vf->cmd_retval = (enum virtchnl_status_code)rte_le_to_cpu_32(
55 event.desc.cookie_low);
57 PMD_DRV_LOG(DEBUG, "AQ from pf carries opcode %u, retval %d",
58 opcode, vf->cmd_retval);
60 if (opcode != vf->pend_cmd)
61 PMD_DRV_LOG(WARNING, "command mismatch, expect %u, get %u",
62 vf->pend_cmd, opcode);
68 avf_execute_vf_cmd(struct avf_adapter *adapter, struct avf_cmd_info *args)
70 struct avf_hw *hw = AVF_DEV_PRIVATE_TO_HW(adapter);
71 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
72 struct avf_arq_event_info event_info;
73 enum avf_status_code ret;
77 if (_atomic_set_cmd(vf, args->ops))
80 ret = avf_aq_send_msg_to_pf(hw, args->ops, AVF_SUCCESS,
81 args->in_args, args->in_args_size, NULL);
83 PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
89 case VIRTCHNL_OP_RESET_VF:
90 /*no need to wait for response */
93 case VIRTCHNL_OP_VERSION:
94 case VIRTCHNL_OP_GET_VF_RESOURCES:
95 /* for init virtchnl ops, need to poll the response */
97 ret = avf_read_msg_from_pf(adapter, args->out_size,
99 if (ret == AVF_SUCCESS)
101 rte_delay_ms(ASQ_DELAY_MS);
102 } while (i++ < MAX_TRY_TIMES);
103 if (i >= MAX_TRY_TIMES ||
104 vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
106 PMD_DRV_LOG(ERR, "No response or return failure (%d)"
107 " for cmd %d", vf->cmd_retval, args->ops);
113 /* For other virtchnl ops in running time,
114 * wait for the cmd done flag.
117 if (vf->pend_cmd == VIRTCHNL_OP_UNKNOWN)
119 rte_delay_ms(ASQ_DELAY_MS);
120 /* If don't read msg or read sys event, continue */
121 } while (i++ < MAX_TRY_TIMES);
122 /* If there's no response is received, clear command */
123 if (i >= MAX_TRY_TIMES ||
124 vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
126 PMD_DRV_LOG(ERR, "No response or return failure (%d)"
127 " for cmd %d", vf->cmd_retval, args->ops);
137 avf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
140 struct virtchnl_pf_event *pf_msg =
141 (struct virtchnl_pf_event *)msg;
142 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
144 if (msglen < sizeof(struct virtchnl_pf_event)) {
145 PMD_DRV_LOG(DEBUG, "Error event");
148 switch (pf_msg->event) {
149 case VIRTCHNL_EVENT_RESET_IMPENDING:
150 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
151 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
154 case VIRTCHNL_EVENT_LINK_CHANGE:
155 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
156 vf->link_up = pf_msg->event_data.link_event.link_status;
157 vf->link_speed = pf_msg->event_data.link_event.link_speed;
158 avf_dev_link_update(dev, 0);
159 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
162 case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
163 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
166 PMD_DRV_LOG(ERR, " unknown event received %u", pf_msg->event);
172 avf_handle_virtchnl_msg(struct rte_eth_dev *dev)
174 struct avf_hw *hw = AVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
175 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
176 struct avf_arq_event_info info;
177 uint16_t pending, aq_opc;
178 enum virtchnl_ops msg_opc;
179 enum avf_status_code msg_ret;
182 info.buf_len = AVF_AQ_BUF_SZ;
184 PMD_DRV_LOG(ERR, "Buffer for adminq resp should not be NULL");
187 info.msg_buf = vf->aq_resp;
191 ret = avf_clean_arq_element(hw, &info, &pending);
193 if (ret != AVF_SUCCESS) {
194 PMD_DRV_LOG(INFO, "Failed to read msg from AdminQ,"
198 aq_opc = rte_le_to_cpu_16(info.desc.opcode);
199 /* For the message sent from pf to vf, opcode is stored in
200 * cookie_high of struct avf_aq_desc, while return error code
201 * are stored in cookie_low, Which is done by PF driver.
203 msg_opc = (enum virtchnl_ops)rte_le_to_cpu_32(
204 info.desc.cookie_high);
205 msg_ret = (enum avf_status_code)rte_le_to_cpu_32(
206 info.desc.cookie_low);
208 case avf_aqc_opc_send_msg_to_vf:
209 if (msg_opc == VIRTCHNL_OP_EVENT) {
210 avf_handle_pf_event_msg(dev, info.msg_buf,
213 /* read message and it's expected one */
214 if (msg_opc == vf->pend_cmd) {
215 vf->cmd_retval = msg_ret;
216 /* prevent compiler reordering */
217 rte_compiler_barrier();
220 PMD_DRV_LOG(ERR, "command mismatch,"
222 vf->pend_cmd, msg_opc);
224 "adminq response is received,"
225 " opcode = %d", msg_opc);
229 PMD_DRV_LOG(ERR, "Request %u is not supported yet",
237 avf_enable_vlan_strip(struct avf_adapter *adapter)
239 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
240 struct avf_cmd_info args;
243 memset(&args, 0, sizeof(args));
244 args.ops = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
246 args.in_args_size = 0;
247 args.out_buffer = vf->aq_resp;
248 args.out_size = AVF_AQ_BUF_SZ;
249 ret = avf_execute_vf_cmd(adapter, &args);
251 PMD_DRV_LOG(ERR, "Failed to execute command of"
252 " OP_ENABLE_VLAN_STRIPPING");
258 avf_disable_vlan_strip(struct avf_adapter *adapter)
260 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
261 struct avf_cmd_info args;
264 memset(&args, 0, sizeof(args));
265 args.ops = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
267 args.in_args_size = 0;
268 args.out_buffer = vf->aq_resp;
269 args.out_size = AVF_AQ_BUF_SZ;
270 ret = avf_execute_vf_cmd(adapter, &args);
272 PMD_DRV_LOG(ERR, "Failed to execute command of"
273 " OP_DISABLE_VLAN_STRIPPING");
278 #define VIRTCHNL_VERSION_MAJOR_START 1
279 #define VIRTCHNL_VERSION_MINOR_START 1
281 /* Check API version with sync wait until version read from admin queue */
283 avf_check_api_version(struct avf_adapter *adapter)
285 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
286 struct virtchnl_version_info version, *pver;
287 struct avf_cmd_info args;
290 version.major = VIRTCHNL_VERSION_MAJOR;
291 version.minor = VIRTCHNL_VERSION_MINOR;
293 args.ops = VIRTCHNL_OP_VERSION;
294 args.in_args = (uint8_t *)&version;
295 args.in_args_size = sizeof(version);
296 args.out_buffer = vf->aq_resp;
297 args.out_size = AVF_AQ_BUF_SZ;
299 err = avf_execute_vf_cmd(adapter, &args);
301 PMD_INIT_LOG(ERR, "Fail to execute command of OP_VERSION");
305 pver = (struct virtchnl_version_info *)args.out_buffer;
306 vf->virtchnl_version = *pver;
308 if (vf->virtchnl_version.major < VIRTCHNL_VERSION_MAJOR_START ||
309 (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR_START &&
310 vf->virtchnl_version.minor < VIRTCHNL_VERSION_MINOR_START)) {
311 PMD_INIT_LOG(ERR, "VIRTCHNL API version should not be lower"
312 " than (%u.%u) to support Adapative VF",
313 VIRTCHNL_VERSION_MAJOR_START,
314 VIRTCHNL_VERSION_MAJOR_START);
316 } else if (vf->virtchnl_version.major > VIRTCHNL_VERSION_MAJOR ||
317 (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR &&
318 vf->virtchnl_version.minor > VIRTCHNL_VERSION_MINOR)) {
319 PMD_INIT_LOG(ERR, "PF/VF API version mismatch:(%u.%u)-(%u.%u)",
320 vf->virtchnl_version.major,
321 vf->virtchnl_version.minor,
322 VIRTCHNL_VERSION_MAJOR,
323 VIRTCHNL_VERSION_MINOR);
327 PMD_DRV_LOG(DEBUG, "Peer is supported PF host");
332 avf_get_vf_resource(struct avf_adapter *adapter)
334 struct avf_hw *hw = AVF_DEV_PRIVATE_TO_HW(adapter);
335 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
336 struct avf_cmd_info args;
340 args.ops = VIRTCHNL_OP_GET_VF_RESOURCES;
341 args.out_buffer = vf->aq_resp;
342 args.out_size = AVF_AQ_BUF_SZ;
344 /* TODO: basic offload capabilities, need to
345 * add advanced/optional offload capabilities
348 caps = AVF_BASIC_OFFLOAD_CAPS;
350 args.in_args = (uint8_t *)∩︀
351 args.in_args_size = sizeof(caps);
353 err = avf_execute_vf_cmd(adapter, &args);
357 "Failed to execute command of OP_GET_VF_RESOURCE");
361 len = sizeof(struct virtchnl_vf_resource) +
362 AVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
364 rte_memcpy(vf->vf_res, args.out_buffer,
365 RTE_MIN(args.out_size, len));
366 /* parse VF config message back from PF*/
367 avf_parse_hw_config(hw, vf->vf_res);
368 for (i = 0; i < vf->vf_res->num_vsis; i++) {
369 if (vf->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
370 vf->vsi_res = &vf->vf_res->vsi_res[i];
374 PMD_INIT_LOG(ERR, "no LAN VSI found");
378 vf->vsi.vsi_id = vf->vsi_res->vsi_id;
379 vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
380 vf->vsi.adapter = adapter;
386 avf_enable_queues(struct avf_adapter *adapter)
388 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
389 struct virtchnl_queue_select queue_select;
390 struct avf_cmd_info args;
393 memset(&queue_select, 0, sizeof(queue_select));
394 queue_select.vsi_id = vf->vsi_res->vsi_id;
396 queue_select.rx_queues = BIT(adapter->eth_dev->data->nb_rx_queues) - 1;
397 queue_select.tx_queues = BIT(adapter->eth_dev->data->nb_tx_queues) - 1;
399 args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
400 args.in_args = (u8 *)&queue_select;
401 args.in_args_size = sizeof(queue_select);
402 args.out_buffer = vf->aq_resp;
403 args.out_size = AVF_AQ_BUF_SZ;
404 err = avf_execute_vf_cmd(adapter, &args);
407 "Failed to execute command of OP_ENABLE_QUEUES");
414 avf_disable_queues(struct avf_adapter *adapter)
416 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
417 struct virtchnl_queue_select queue_select;
418 struct avf_cmd_info args;
421 memset(&queue_select, 0, sizeof(queue_select));
422 queue_select.vsi_id = vf->vsi_res->vsi_id;
424 queue_select.rx_queues = BIT(adapter->eth_dev->data->nb_rx_queues) - 1;
425 queue_select.tx_queues = BIT(adapter->eth_dev->data->nb_tx_queues) - 1;
427 args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
428 args.in_args = (u8 *)&queue_select;
429 args.in_args_size = sizeof(queue_select);
430 args.out_buffer = vf->aq_resp;
431 args.out_size = AVF_AQ_BUF_SZ;
432 err = avf_execute_vf_cmd(adapter, &args);
435 "Failed to execute command of OP_DISABLE_QUEUES");
442 avf_switch_queue(struct avf_adapter *adapter, uint16_t qid,
445 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
446 struct virtchnl_queue_select queue_select;
447 struct avf_cmd_info args;
450 memset(&queue_select, 0, sizeof(queue_select));
451 queue_select.vsi_id = vf->vsi_res->vsi_id;
453 queue_select.rx_queues |= 1 << qid;
455 queue_select.tx_queues |= 1 << qid;
458 args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
460 args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
461 args.in_args = (u8 *)&queue_select;
462 args.in_args_size = sizeof(queue_select);
463 args.out_buffer = vf->aq_resp;
464 args.out_size = AVF_AQ_BUF_SZ;
465 err = avf_execute_vf_cmd(adapter, &args);
467 PMD_DRV_LOG(ERR, "Failed to execute command of %s",
468 on ? "OP_ENABLE_QUEUES" : "OP_DISABLE_QUEUES");
473 avf_configure_rss_lut(struct avf_adapter *adapter)
475 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
476 struct virtchnl_rss_lut *rss_lut;
477 struct avf_cmd_info args;
480 len = sizeof(*rss_lut) + vf->vf_res->rss_lut_size - 1;
481 rss_lut = rte_zmalloc("rss_lut", len, 0);
485 rss_lut->vsi_id = vf->vsi_res->vsi_id;
486 rss_lut->lut_entries = vf->vf_res->rss_lut_size;
487 rte_memcpy(rss_lut->lut, vf->rss_lut, vf->vf_res->rss_lut_size);
489 args.ops = VIRTCHNL_OP_CONFIG_RSS_LUT;
490 args.in_args = (u8 *)rss_lut;
491 args.in_args_size = len;
492 args.out_buffer = vf->aq_resp;
493 args.out_size = AVF_AQ_BUF_SZ;
495 err = avf_execute_vf_cmd(adapter, &args);
498 "Failed to execute command of OP_CONFIG_RSS_LUT");
505 avf_configure_rss_key(struct avf_adapter *adapter)
507 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
508 struct virtchnl_rss_key *rss_key;
509 struct avf_cmd_info args;
512 len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
513 rss_key = rte_zmalloc("rss_key", len, 0);
517 rss_key->vsi_id = vf->vsi_res->vsi_id;
518 rss_key->key_len = vf->vf_res->rss_key_size;
519 rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size);
521 args.ops = VIRTCHNL_OP_CONFIG_RSS_KEY;
522 args.in_args = (u8 *)rss_key;
523 args.in_args_size = len;
524 args.out_buffer = vf->aq_resp;
525 args.out_size = AVF_AQ_BUF_SZ;
527 err = avf_execute_vf_cmd(adapter, &args);
530 "Failed to execute command of OP_CONFIG_RSS_KEY");
537 avf_configure_queues(struct avf_adapter *adapter)
539 struct avf_rx_queue **rxq =
540 (struct avf_rx_queue **)adapter->eth_dev->data->rx_queues;
541 struct avf_tx_queue **txq =
542 (struct avf_tx_queue **)adapter->eth_dev->data->tx_queues;
543 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
544 struct virtchnl_vsi_queue_config_info *vc_config;
545 struct virtchnl_queue_pair_info *vc_qp;
546 struct avf_cmd_info args;
550 size = sizeof(*vc_config) +
551 sizeof(vc_config->qpair[0]) * vf->num_queue_pairs;
552 vc_config = rte_zmalloc("cfg_queue", size, 0);
556 vc_config->vsi_id = vf->vsi_res->vsi_id;
557 vc_config->num_queue_pairs = vf->num_queue_pairs;
559 for (i = 0, vc_qp = vc_config->qpair;
560 i < vf->num_queue_pairs;
562 vc_qp->txq.vsi_id = vf->vsi_res->vsi_id;
563 vc_qp->txq.queue_id = i;
564 /* Virtchnnl configure queues by pairs */
565 if (i < adapter->eth_dev->data->nb_tx_queues) {
566 vc_qp->txq.ring_len = txq[i]->nb_tx_desc;
567 vc_qp->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
569 vc_qp->rxq.vsi_id = vf->vsi_res->vsi_id;
570 vc_qp->rxq.queue_id = i;
571 vc_qp->rxq.max_pkt_size = vf->max_pkt_len;
572 /* Virtchnnl configure queues by pairs */
573 if (i < adapter->eth_dev->data->nb_rx_queues) {
574 vc_qp->rxq.ring_len = rxq[i]->nb_rx_desc;
575 vc_qp->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;
576 vc_qp->rxq.databuffer_size = rxq[i]->rx_buf_len;
580 memset(&args, 0, sizeof(args));
581 args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
582 args.in_args = (uint8_t *)vc_config;
583 args.in_args_size = size;
584 args.out_buffer = vf->aq_resp;
585 args.out_size = AVF_AQ_BUF_SZ;
587 err = avf_execute_vf_cmd(adapter, &args);
589 PMD_DRV_LOG(ERR, "Failed to execute command of"
590 " VIRTCHNL_OP_CONFIG_VSI_QUEUES");
597 avf_config_irq_map(struct avf_adapter *adapter)
599 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
600 struct virtchnl_irq_map_info *map_info;
601 struct virtchnl_vector_map *vecmap;
602 struct avf_cmd_info args;
606 len = sizeof(struct virtchnl_irq_map_info) +
607 sizeof(struct virtchnl_vector_map) * vf->nb_msix;
609 map_info = rte_zmalloc("map_info", len, 0);
613 map_info->num_vectors = vf->nb_msix;
614 for (i = 0; i < vf->nb_msix; i++) {
615 vecmap = &map_info->vecmap[i];
616 vecmap->vsi_id = vf->vsi_res->vsi_id;
617 vecmap->rxitr_idx = AVF_ITR_INDEX_DEFAULT;
618 vecmap->vector_id = vf->msix_base + i;
620 vecmap->rxq_map = vf->rxq_map[vf->msix_base + i];
623 args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
624 args.in_args = (u8 *)map_info;
625 args.in_args_size = len;
626 args.out_buffer = vf->aq_resp;
627 args.out_size = AVF_AQ_BUF_SZ;
628 err = avf_execute_vf_cmd(adapter, &args);
630 PMD_DRV_LOG(ERR, "fail to execute command OP_CONFIG_IRQ_MAP");
637 avf_add_del_all_mac_addr(struct avf_adapter *adapter, bool add)
639 struct virtchnl_ether_addr_list *list;
640 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
641 struct ether_addr *addr;
642 struct avf_cmd_info args;
649 len = sizeof(struct virtchnl_ether_addr_list);
650 for (i = begin; i < AVF_NUM_MACADDR_MAX; i++, next_begin++) {
651 addr = &adapter->eth_dev->data->mac_addrs[i];
652 if (is_zero_ether_addr(addr))
654 len += sizeof(struct virtchnl_ether_addr);
655 if (len >= AVF_AQ_BUF_SZ) {
661 list = rte_zmalloc("avf_del_mac_buffer", len, 0);
663 PMD_DRV_LOG(ERR, "fail to allocate memory");
667 for (i = begin; i < next_begin; i++) {
668 addr = &adapter->eth_dev->data->mac_addrs[i];
669 if (is_zero_ether_addr(addr))
671 rte_memcpy(list->list[j].addr, addr->addr_bytes,
672 sizeof(addr->addr_bytes));
673 PMD_DRV_LOG(DEBUG, "add/rm mac:%x:%x:%x:%x:%x:%x",
674 addr->addr_bytes[0], addr->addr_bytes[1],
675 addr->addr_bytes[2], addr->addr_bytes[3],
676 addr->addr_bytes[4], addr->addr_bytes[5]);
679 list->vsi_id = vf->vsi_res->vsi_id;
680 list->num_elements = j;
681 args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR :
682 VIRTCHNL_OP_DEL_ETH_ADDR;
683 args.in_args = (uint8_t *)list;
684 args.in_args_size = len;
685 args.out_buffer = vf->aq_resp;
686 args.out_size = AVF_AQ_BUF_SZ;
687 err = avf_execute_vf_cmd(adapter, &args);
689 PMD_DRV_LOG(ERR, "fail to execute command %s",
690 add ? "OP_ADD_ETHER_ADDRESS" :
691 "OP_DEL_ETHER_ADDRESS");
694 } while (begin < AVF_NUM_MACADDR_MAX);
698 avf_query_stats(struct avf_adapter *adapter,
699 struct virtchnl_eth_stats **pstats)
701 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
702 struct virtchnl_queue_select q_stats;
703 struct avf_cmd_info args;
706 memset(&q_stats, 0, sizeof(q_stats));
707 q_stats.vsi_id = vf->vsi_res->vsi_id;
708 args.ops = VIRTCHNL_OP_GET_STATS;
709 args.in_args = (uint8_t *)&q_stats;
710 args.in_args_size = sizeof(q_stats);
711 args.out_buffer = vf->aq_resp;
712 args.out_size = AVF_AQ_BUF_SZ;
714 err = avf_execute_vf_cmd(adapter, &args);
716 PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS");
720 *pstats = (struct virtchnl_eth_stats *)args.out_buffer;
725 avf_config_promisc(struct avf_adapter *adapter,
727 bool enable_multicast)
729 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
730 struct virtchnl_promisc_info promisc;
731 struct avf_cmd_info args;
735 promisc.vsi_id = vf->vsi_res->vsi_id;
738 promisc.flags |= FLAG_VF_UNICAST_PROMISC;
740 if (enable_multicast)
741 promisc.flags |= FLAG_VF_MULTICAST_PROMISC;
743 args.ops = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
744 args.in_args = (uint8_t *)&promisc;
745 args.in_args_size = sizeof(promisc);
746 args.out_buffer = vf->aq_resp;
747 args.out_size = AVF_AQ_BUF_SZ;
749 err = avf_execute_vf_cmd(adapter, &args);
753 "fail to execute command CONFIG_PROMISCUOUS_MODE");
758 avf_add_del_eth_addr(struct avf_adapter *adapter, struct ether_addr *addr,
761 struct virtchnl_ether_addr_list *list;
762 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
763 uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) +
764 sizeof(struct virtchnl_ether_addr)];
765 struct avf_cmd_info args;
768 list = (struct virtchnl_ether_addr_list *)cmd_buffer;
769 list->vsi_id = vf->vsi_res->vsi_id;
770 list->num_elements = 1;
771 rte_memcpy(list->list[0].addr, addr->addr_bytes,
772 sizeof(addr->addr_bytes));
774 args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
775 args.in_args = cmd_buffer;
776 args.in_args_size = sizeof(cmd_buffer);
777 args.out_buffer = vf->aq_resp;
778 args.out_size = AVF_AQ_BUF_SZ;
779 err = avf_execute_vf_cmd(adapter, &args);
781 PMD_DRV_LOG(ERR, "fail to execute command %s",
782 add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR");
787 avf_add_del_vlan(struct avf_adapter *adapter, uint16_t vlanid, bool add)
789 struct virtchnl_vlan_filter_list *vlan_list;
790 struct avf_info *vf = AVF_DEV_PRIVATE_TO_VF(adapter);
791 uint8_t cmd_buffer[sizeof(struct virtchnl_vlan_filter_list) +
793 struct avf_cmd_info args;
796 vlan_list = (struct virtchnl_vlan_filter_list *)cmd_buffer;
797 vlan_list->vsi_id = vf->vsi_res->vsi_id;
798 vlan_list->num_elements = 1;
799 vlan_list->vlan_id[0] = vlanid;
801 args.ops = add ? VIRTCHNL_OP_ADD_VLAN : VIRTCHNL_OP_DEL_VLAN;
802 args.in_args = cmd_buffer;
803 args.in_args_size = sizeof(cmd_buffer);
804 args.out_buffer = vf->aq_resp;
805 args.out_size = AVF_AQ_BUF_SZ;
806 err = avf_execute_vf_cmd(adapter, &args);
808 PMD_DRV_LOG(ERR, "fail to execute command %s",
809 add ? "OP_ADD_VLAN" : "OP_DEL_VLAN");