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_driver.h>
23 #include "base/iavf_prototype.h"
24 #include "base/iavf_adminq_cmd.h"
25 #include "base/iavf_type.h"
28 #include "iavf_rxtx.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 iavf_status
35 iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,
38 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
39 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
40 struct iavf_arq_event_info event;
41 enum virtchnl_ops opcode;
44 event.buf_len = buf_len;
46 ret = iavf_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 iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args)
70 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
71 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
76 if (_atomic_set_cmd(vf, args->ops))
79 ret = iavf_aq_send_msg_to_pf(hw, args->ops, IAVF_SUCCESS,
80 args->in_args, args->in_args_size, NULL);
82 PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
88 case VIRTCHNL_OP_RESET_VF:
89 /*no need to wait for response */
92 case VIRTCHNL_OP_VERSION:
93 case VIRTCHNL_OP_GET_VF_RESOURCES:
94 /* for init virtchnl ops, need to poll the response */
96 ret = iavf_read_msg_from_pf(adapter, args->out_size,
98 if (ret == IAVF_SUCCESS)
100 rte_delay_ms(ASQ_DELAY_MS);
101 } while (i++ < MAX_TRY_TIMES);
102 if (i >= MAX_TRY_TIMES ||
103 vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
105 PMD_DRV_LOG(ERR, "No response or return failure (%d)"
106 " for cmd %d", vf->cmd_retval, args->ops);
112 /* For other virtchnl ops in running time,
113 * wait for the cmd done flag.
116 if (vf->pend_cmd == VIRTCHNL_OP_UNKNOWN)
118 rte_delay_ms(ASQ_DELAY_MS);
119 /* If don't read msg or read sys event, continue */
120 } while (i++ < MAX_TRY_TIMES);
121 /* If there's no response is received, clear command */
122 if (i >= MAX_TRY_TIMES ||
123 vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
125 PMD_DRV_LOG(ERR, "No response or return failure (%d)"
126 " for cmd %d", vf->cmd_retval, args->ops);
136 iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
139 struct virtchnl_pf_event *pf_msg =
140 (struct virtchnl_pf_event *)msg;
141 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
143 if (msglen < sizeof(struct virtchnl_pf_event)) {
144 PMD_DRV_LOG(DEBUG, "Error event");
147 switch (pf_msg->event) {
148 case VIRTCHNL_EVENT_RESET_IMPENDING:
149 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
150 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
153 case VIRTCHNL_EVENT_LINK_CHANGE:
154 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
155 vf->link_up = pf_msg->event_data.link_event.link_status;
156 vf->link_speed = pf_msg->event_data.link_event_adv.link_speed;
157 iavf_dev_link_update(dev, 0);
158 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
161 case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
162 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
165 PMD_DRV_LOG(ERR, " unknown event received %u", pf_msg->event);
171 iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
173 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
174 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
175 struct iavf_arq_event_info info;
176 uint16_t pending, aq_opc;
177 enum virtchnl_ops msg_opc;
178 enum iavf_status msg_ret;
181 info.buf_len = IAVF_AQ_BUF_SZ;
183 PMD_DRV_LOG(ERR, "Buffer for adminq resp should not be NULL");
186 info.msg_buf = vf->aq_resp;
190 ret = iavf_clean_arq_element(hw, &info, &pending);
192 if (ret != IAVF_SUCCESS) {
193 PMD_DRV_LOG(INFO, "Failed to read msg from AdminQ,"
197 aq_opc = rte_le_to_cpu_16(info.desc.opcode);
198 /* For the message sent from pf to vf, opcode is stored in
199 * cookie_high of struct iavf_aq_desc, while return error code
200 * are stored in cookie_low, Which is done by PF driver.
202 msg_opc = (enum virtchnl_ops)rte_le_to_cpu_32(
203 info.desc.cookie_high);
204 msg_ret = (enum iavf_status)rte_le_to_cpu_32(
205 info.desc.cookie_low);
207 case iavf_aqc_opc_send_msg_to_vf:
208 if (msg_opc == VIRTCHNL_OP_EVENT) {
209 iavf_handle_pf_event_msg(dev, info.msg_buf,
212 /* read message and it's expected one */
213 if (msg_opc == vf->pend_cmd)
214 _notify_cmd(vf, msg_ret);
216 PMD_DRV_LOG(ERR, "command mismatch,"
218 vf->pend_cmd, msg_opc);
220 "adminq response is received,"
221 " opcode = %d", msg_opc);
225 PMD_DRV_LOG(ERR, "Request %u is not supported yet",
233 iavf_enable_vlan_strip(struct iavf_adapter *adapter)
235 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
236 struct iavf_cmd_info args;
239 memset(&args, 0, sizeof(args));
240 args.ops = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
242 args.in_args_size = 0;
243 args.out_buffer = vf->aq_resp;
244 args.out_size = IAVF_AQ_BUF_SZ;
245 ret = iavf_execute_vf_cmd(adapter, &args);
247 PMD_DRV_LOG(ERR, "Failed to execute command of"
248 " OP_ENABLE_VLAN_STRIPPING");
254 iavf_disable_vlan_strip(struct iavf_adapter *adapter)
256 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
257 struct iavf_cmd_info args;
260 memset(&args, 0, sizeof(args));
261 args.ops = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
263 args.in_args_size = 0;
264 args.out_buffer = vf->aq_resp;
265 args.out_size = IAVF_AQ_BUF_SZ;
266 ret = iavf_execute_vf_cmd(adapter, &args);
268 PMD_DRV_LOG(ERR, "Failed to execute command of"
269 " OP_DISABLE_VLAN_STRIPPING");
274 #define VIRTCHNL_VERSION_MAJOR_START 1
275 #define VIRTCHNL_VERSION_MINOR_START 1
277 /* Check API version with sync wait until version read from admin queue */
279 iavf_check_api_version(struct iavf_adapter *adapter)
281 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
282 struct virtchnl_version_info version, *pver;
283 struct iavf_cmd_info args;
286 version.major = VIRTCHNL_VERSION_MAJOR;
287 version.minor = VIRTCHNL_VERSION_MINOR;
289 args.ops = VIRTCHNL_OP_VERSION;
290 args.in_args = (uint8_t *)&version;
291 args.in_args_size = sizeof(version);
292 args.out_buffer = vf->aq_resp;
293 args.out_size = IAVF_AQ_BUF_SZ;
295 err = iavf_execute_vf_cmd(adapter, &args);
297 PMD_INIT_LOG(ERR, "Fail to execute command of OP_VERSION");
301 pver = (struct virtchnl_version_info *)args.out_buffer;
302 vf->virtchnl_version = *pver;
304 if (vf->virtchnl_version.major < VIRTCHNL_VERSION_MAJOR_START ||
305 (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR_START &&
306 vf->virtchnl_version.minor < VIRTCHNL_VERSION_MINOR_START)) {
307 PMD_INIT_LOG(ERR, "VIRTCHNL API version should not be lower"
308 " than (%u.%u) to support Adapative VF",
309 VIRTCHNL_VERSION_MAJOR_START,
310 VIRTCHNL_VERSION_MAJOR_START);
312 } else if (vf->virtchnl_version.major > VIRTCHNL_VERSION_MAJOR ||
313 (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR &&
314 vf->virtchnl_version.minor > VIRTCHNL_VERSION_MINOR)) {
315 PMD_INIT_LOG(ERR, "PF/VF API version mismatch:(%u.%u)-(%u.%u)",
316 vf->virtchnl_version.major,
317 vf->virtchnl_version.minor,
318 VIRTCHNL_VERSION_MAJOR,
319 VIRTCHNL_VERSION_MINOR);
323 PMD_DRV_LOG(DEBUG, "Peer is supported PF host");
328 iavf_get_vf_resource(struct iavf_adapter *adapter)
330 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
331 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
332 struct iavf_cmd_info args;
336 args.ops = VIRTCHNL_OP_GET_VF_RESOURCES;
337 args.out_buffer = vf->aq_resp;
338 args.out_size = IAVF_AQ_BUF_SZ;
340 /* TODO: basic offload capabilities, need to
341 * add advanced/optional offload capabilities
344 caps = IAVF_BASIC_OFFLOAD_CAPS | VIRTCHNL_VF_CAP_ADV_LINK_SPEED;
346 args.in_args = (uint8_t *)∩︀
347 args.in_args_size = sizeof(caps);
349 err = iavf_execute_vf_cmd(adapter, &args);
353 "Failed to execute command of OP_GET_VF_RESOURCE");
357 len = sizeof(struct virtchnl_vf_resource) +
358 IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
360 rte_memcpy(vf->vf_res, args.out_buffer,
361 RTE_MIN(args.out_size, len));
362 /* parse VF config message back from PF*/
363 iavf_vf_parse_hw_config(hw, vf->vf_res);
364 for (i = 0; i < vf->vf_res->num_vsis; i++) {
365 if (vf->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
366 vf->vsi_res = &vf->vf_res->vsi_res[i];
370 PMD_INIT_LOG(ERR, "no LAN VSI found");
374 vf->vsi.vsi_id = vf->vsi_res->vsi_id;
375 vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
376 vf->vsi.adapter = adapter;
382 iavf_enable_queues(struct iavf_adapter *adapter)
384 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
385 struct virtchnl_queue_select queue_select;
386 struct iavf_cmd_info args;
389 memset(&queue_select, 0, sizeof(queue_select));
390 queue_select.vsi_id = vf->vsi_res->vsi_id;
392 queue_select.rx_queues = BIT(adapter->eth_dev->data->nb_rx_queues) - 1;
393 queue_select.tx_queues = BIT(adapter->eth_dev->data->nb_tx_queues) - 1;
395 args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
396 args.in_args = (u8 *)&queue_select;
397 args.in_args_size = sizeof(queue_select);
398 args.out_buffer = vf->aq_resp;
399 args.out_size = IAVF_AQ_BUF_SZ;
400 err = iavf_execute_vf_cmd(adapter, &args);
403 "Failed to execute command of OP_ENABLE_QUEUES");
410 iavf_disable_queues(struct iavf_adapter *adapter)
412 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
413 struct virtchnl_queue_select queue_select;
414 struct iavf_cmd_info args;
417 memset(&queue_select, 0, sizeof(queue_select));
418 queue_select.vsi_id = vf->vsi_res->vsi_id;
420 queue_select.rx_queues = BIT(adapter->eth_dev->data->nb_rx_queues) - 1;
421 queue_select.tx_queues = BIT(adapter->eth_dev->data->nb_tx_queues) - 1;
423 args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
424 args.in_args = (u8 *)&queue_select;
425 args.in_args_size = sizeof(queue_select);
426 args.out_buffer = vf->aq_resp;
427 args.out_size = IAVF_AQ_BUF_SZ;
428 err = iavf_execute_vf_cmd(adapter, &args);
431 "Failed to execute command of OP_DISABLE_QUEUES");
438 iavf_switch_queue(struct iavf_adapter *adapter, uint16_t qid,
441 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
442 struct virtchnl_queue_select queue_select;
443 struct iavf_cmd_info args;
446 memset(&queue_select, 0, sizeof(queue_select));
447 queue_select.vsi_id = vf->vsi_res->vsi_id;
449 queue_select.rx_queues |= 1 << qid;
451 queue_select.tx_queues |= 1 << qid;
454 args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
456 args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
457 args.in_args = (u8 *)&queue_select;
458 args.in_args_size = sizeof(queue_select);
459 args.out_buffer = vf->aq_resp;
460 args.out_size = IAVF_AQ_BUF_SZ;
461 err = iavf_execute_vf_cmd(adapter, &args);
463 PMD_DRV_LOG(ERR, "Failed to execute command of %s",
464 on ? "OP_ENABLE_QUEUES" : "OP_DISABLE_QUEUES");
469 iavf_configure_rss_lut(struct iavf_adapter *adapter)
471 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
472 struct virtchnl_rss_lut *rss_lut;
473 struct iavf_cmd_info args;
476 len = sizeof(*rss_lut) + vf->vf_res->rss_lut_size - 1;
477 rss_lut = rte_zmalloc("rss_lut", len, 0);
481 rss_lut->vsi_id = vf->vsi_res->vsi_id;
482 rss_lut->lut_entries = vf->vf_res->rss_lut_size;
483 rte_memcpy(rss_lut->lut, vf->rss_lut, vf->vf_res->rss_lut_size);
485 args.ops = VIRTCHNL_OP_CONFIG_RSS_LUT;
486 args.in_args = (u8 *)rss_lut;
487 args.in_args_size = len;
488 args.out_buffer = vf->aq_resp;
489 args.out_size = IAVF_AQ_BUF_SZ;
491 err = iavf_execute_vf_cmd(adapter, &args);
494 "Failed to execute command of OP_CONFIG_RSS_LUT");
501 iavf_configure_rss_key(struct iavf_adapter *adapter)
503 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
504 struct virtchnl_rss_key *rss_key;
505 struct iavf_cmd_info args;
508 len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
509 rss_key = rte_zmalloc("rss_key", len, 0);
513 rss_key->vsi_id = vf->vsi_res->vsi_id;
514 rss_key->key_len = vf->vf_res->rss_key_size;
515 rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size);
517 args.ops = VIRTCHNL_OP_CONFIG_RSS_KEY;
518 args.in_args = (u8 *)rss_key;
519 args.in_args_size = len;
520 args.out_buffer = vf->aq_resp;
521 args.out_size = IAVF_AQ_BUF_SZ;
523 err = iavf_execute_vf_cmd(adapter, &args);
526 "Failed to execute command of OP_CONFIG_RSS_KEY");
533 iavf_configure_queues(struct iavf_adapter *adapter)
535 struct iavf_rx_queue **rxq =
536 (struct iavf_rx_queue **)adapter->eth_dev->data->rx_queues;
537 struct iavf_tx_queue **txq =
538 (struct iavf_tx_queue **)adapter->eth_dev->data->tx_queues;
539 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
540 struct virtchnl_vsi_queue_config_info *vc_config;
541 struct virtchnl_queue_pair_info *vc_qp;
542 struct iavf_cmd_info args;
546 size = sizeof(*vc_config) +
547 sizeof(vc_config->qpair[0]) * vf->num_queue_pairs;
548 vc_config = rte_zmalloc("cfg_queue", size, 0);
552 vc_config->vsi_id = vf->vsi_res->vsi_id;
553 vc_config->num_queue_pairs = vf->num_queue_pairs;
555 for (i = 0, vc_qp = vc_config->qpair;
556 i < vf->num_queue_pairs;
558 vc_qp->txq.vsi_id = vf->vsi_res->vsi_id;
559 vc_qp->txq.queue_id = i;
560 /* Virtchnnl configure queues by pairs */
561 if (i < adapter->eth_dev->data->nb_tx_queues) {
562 vc_qp->txq.ring_len = txq[i]->nb_tx_desc;
563 vc_qp->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
565 vc_qp->rxq.vsi_id = vf->vsi_res->vsi_id;
566 vc_qp->rxq.queue_id = i;
567 vc_qp->rxq.max_pkt_size = vf->max_pkt_len;
568 /* Virtchnnl configure queues by pairs */
569 if (i < adapter->eth_dev->data->nb_rx_queues) {
570 vc_qp->rxq.ring_len = rxq[i]->nb_rx_desc;
571 vc_qp->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;
572 vc_qp->rxq.databuffer_size = rxq[i]->rx_buf_len;
576 memset(&args, 0, sizeof(args));
577 args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
578 args.in_args = (uint8_t *)vc_config;
579 args.in_args_size = size;
580 args.out_buffer = vf->aq_resp;
581 args.out_size = IAVF_AQ_BUF_SZ;
583 err = iavf_execute_vf_cmd(adapter, &args);
585 PMD_DRV_LOG(ERR, "Failed to execute command of"
586 " VIRTCHNL_OP_CONFIG_VSI_QUEUES");
593 iavf_config_irq_map(struct iavf_adapter *adapter)
595 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
596 struct virtchnl_irq_map_info *map_info;
597 struct virtchnl_vector_map *vecmap;
598 struct iavf_cmd_info args;
601 len = sizeof(struct virtchnl_irq_map_info) +
602 sizeof(struct virtchnl_vector_map) * vf->nb_msix;
604 map_info = rte_zmalloc("map_info", len, 0);
608 map_info->num_vectors = vf->nb_msix;
609 for (i = 0; i < vf->nb_msix; i++) {
610 vecmap = &map_info->vecmap[i];
611 vecmap->vsi_id = vf->vsi_res->vsi_id;
612 vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
613 vecmap->vector_id = vf->msix_base + i;
615 vecmap->rxq_map = vf->rxq_map[vf->msix_base + i];
618 args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
619 args.in_args = (u8 *)map_info;
620 args.in_args_size = len;
621 args.out_buffer = vf->aq_resp;
622 args.out_size = IAVF_AQ_BUF_SZ;
623 err = iavf_execute_vf_cmd(adapter, &args);
625 PMD_DRV_LOG(ERR, "fail to execute command OP_CONFIG_IRQ_MAP");
632 iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)
634 struct virtchnl_ether_addr_list *list;
635 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
636 struct rte_ether_addr *addr;
637 struct iavf_cmd_info args;
644 len = sizeof(struct virtchnl_ether_addr_list);
645 for (i = begin; i < IAVF_NUM_MACADDR_MAX; i++, next_begin++) {
646 addr = &adapter->eth_dev->data->mac_addrs[i];
647 if (rte_is_zero_ether_addr(addr))
649 len += sizeof(struct virtchnl_ether_addr);
650 if (len >= IAVF_AQ_BUF_SZ) {
656 list = rte_zmalloc("iavf_del_mac_buffer", len, 0);
658 PMD_DRV_LOG(ERR, "fail to allocate memory");
662 for (i = begin; i < next_begin; i++) {
663 addr = &adapter->eth_dev->data->mac_addrs[i];
664 if (rte_is_zero_ether_addr(addr))
666 rte_memcpy(list->list[j].addr, addr->addr_bytes,
667 sizeof(addr->addr_bytes));
668 PMD_DRV_LOG(DEBUG, "add/rm mac:%x:%x:%x:%x:%x:%x",
669 addr->addr_bytes[0], addr->addr_bytes[1],
670 addr->addr_bytes[2], addr->addr_bytes[3],
671 addr->addr_bytes[4], addr->addr_bytes[5]);
674 list->vsi_id = vf->vsi_res->vsi_id;
675 list->num_elements = j;
676 args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR :
677 VIRTCHNL_OP_DEL_ETH_ADDR;
678 args.in_args = (uint8_t *)list;
679 args.in_args_size = len;
680 args.out_buffer = vf->aq_resp;
681 args.out_size = IAVF_AQ_BUF_SZ;
682 err = iavf_execute_vf_cmd(adapter, &args);
684 PMD_DRV_LOG(ERR, "fail to execute command %s",
685 add ? "OP_ADD_ETHER_ADDRESS" :
686 "OP_DEL_ETHER_ADDRESS");
689 } while (begin < IAVF_NUM_MACADDR_MAX);
693 iavf_query_stats(struct iavf_adapter *adapter,
694 struct virtchnl_eth_stats **pstats)
696 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
697 struct virtchnl_queue_select q_stats;
698 struct iavf_cmd_info args;
701 memset(&q_stats, 0, sizeof(q_stats));
702 q_stats.vsi_id = vf->vsi_res->vsi_id;
703 args.ops = VIRTCHNL_OP_GET_STATS;
704 args.in_args = (uint8_t *)&q_stats;
705 args.in_args_size = sizeof(q_stats);
706 args.out_buffer = vf->aq_resp;
707 args.out_size = IAVF_AQ_BUF_SZ;
709 err = iavf_execute_vf_cmd(adapter, &args);
711 PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS");
715 *pstats = (struct virtchnl_eth_stats *)args.out_buffer;
720 iavf_config_promisc(struct iavf_adapter *adapter,
722 bool enable_multicast)
724 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
725 struct virtchnl_promisc_info promisc;
726 struct iavf_cmd_info args;
730 promisc.vsi_id = vf->vsi_res->vsi_id;
733 promisc.flags |= FLAG_VF_UNICAST_PROMISC;
735 if (enable_multicast)
736 promisc.flags |= FLAG_VF_MULTICAST_PROMISC;
738 args.ops = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
739 args.in_args = (uint8_t *)&promisc;
740 args.in_args_size = sizeof(promisc);
741 args.out_buffer = vf->aq_resp;
742 args.out_size = IAVF_AQ_BUF_SZ;
744 err = iavf_execute_vf_cmd(adapter, &args);
748 "fail to execute command CONFIG_PROMISCUOUS_MODE");
753 iavf_add_del_eth_addr(struct iavf_adapter *adapter, struct rte_ether_addr *addr,
756 struct virtchnl_ether_addr_list *list;
757 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
758 uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) +
759 sizeof(struct virtchnl_ether_addr)];
760 struct iavf_cmd_info args;
763 list = (struct virtchnl_ether_addr_list *)cmd_buffer;
764 list->vsi_id = vf->vsi_res->vsi_id;
765 list->num_elements = 1;
766 rte_memcpy(list->list[0].addr, addr->addr_bytes,
767 sizeof(addr->addr_bytes));
769 args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
770 args.in_args = cmd_buffer;
771 args.in_args_size = sizeof(cmd_buffer);
772 args.out_buffer = vf->aq_resp;
773 args.out_size = IAVF_AQ_BUF_SZ;
774 err = iavf_execute_vf_cmd(adapter, &args);
776 PMD_DRV_LOG(ERR, "fail to execute command %s",
777 add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR");
782 iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
784 struct virtchnl_vlan_filter_list *vlan_list;
785 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
786 uint8_t cmd_buffer[sizeof(struct virtchnl_vlan_filter_list) +
788 struct iavf_cmd_info args;
791 vlan_list = (struct virtchnl_vlan_filter_list *)cmd_buffer;
792 vlan_list->vsi_id = vf->vsi_res->vsi_id;
793 vlan_list->num_elements = 1;
794 vlan_list->vlan_id[0] = vlanid;
796 args.ops = add ? VIRTCHNL_OP_ADD_VLAN : VIRTCHNL_OP_DEL_VLAN;
797 args.in_args = cmd_buffer;
798 args.in_args_size = sizeof(cmd_buffer);
799 args.out_buffer = vf->aq_resp;
800 args.out_size = IAVF_AQ_BUF_SZ;
801 err = iavf_execute_vf_cmd(adapter, &args);
803 PMD_DRV_LOG(ERR, "fail to execute command %s",
804 add ? "OP_ADD_VLAN" : "OP_DEL_VLAN");