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 "iavf_rxtx.h"
25 #define MAX_TRY_TIMES 200
26 #define ASQ_DELAY_MS 10
28 /* Read data in admin queue to get msg from pf driver */
29 static enum iavf_status
30 iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,
33 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
34 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
35 struct iavf_arq_event_info event;
36 enum virtchnl_ops opcode;
39 event.buf_len = buf_len;
41 ret = iavf_clean_arq_element(hw, &event, NULL);
42 /* Can't read any msg from adminQ */
44 PMD_DRV_LOG(DEBUG, "Can't read msg from AQ");
48 opcode = (enum virtchnl_ops)rte_le_to_cpu_32(event.desc.cookie_high);
49 vf->cmd_retval = (enum virtchnl_status_code)rte_le_to_cpu_32(
50 event.desc.cookie_low);
52 PMD_DRV_LOG(DEBUG, "AQ from pf carries opcode %u, retval %d",
53 opcode, vf->cmd_retval);
55 if (opcode != vf->pend_cmd)
56 PMD_DRV_LOG(WARNING, "command mismatch, expect %u, get %u",
57 vf->pend_cmd, opcode);
63 iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args)
65 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
66 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
71 if (_atomic_set_cmd(vf, args->ops))
74 ret = iavf_aq_send_msg_to_pf(hw, args->ops, IAVF_SUCCESS,
75 args->in_args, args->in_args_size, NULL);
77 PMD_DRV_LOG(ERR, "fail to send cmd %d", args->ops);
83 case VIRTCHNL_OP_RESET_VF:
84 /*no need to wait for response */
87 case VIRTCHNL_OP_VERSION:
88 case VIRTCHNL_OP_GET_VF_RESOURCES:
89 /* for init virtchnl ops, need to poll the response */
91 ret = iavf_read_msg_from_pf(adapter, args->out_size,
93 if (ret == IAVF_SUCCESS)
95 rte_delay_ms(ASQ_DELAY_MS);
96 } while (i++ < MAX_TRY_TIMES);
97 if (i >= MAX_TRY_TIMES ||
98 vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
100 PMD_DRV_LOG(ERR, "No response or return failure (%d)"
101 " for cmd %d", vf->cmd_retval, args->ops);
107 /* For other virtchnl ops in running time,
108 * wait for the cmd done flag.
111 if (vf->pend_cmd == VIRTCHNL_OP_UNKNOWN)
113 rte_delay_ms(ASQ_DELAY_MS);
114 /* If don't read msg or read sys event, continue */
115 } while (i++ < MAX_TRY_TIMES);
116 /* If there's no response is received, clear command */
117 if (i >= MAX_TRY_TIMES ||
118 vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {
120 PMD_DRV_LOG(ERR, "No response or return failure (%d)"
121 " for cmd %d", vf->cmd_retval, args->ops);
131 iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg,
134 struct virtchnl_pf_event *pf_msg =
135 (struct virtchnl_pf_event *)msg;
136 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
138 if (msglen < sizeof(struct virtchnl_pf_event)) {
139 PMD_DRV_LOG(DEBUG, "Error event");
142 switch (pf_msg->event) {
143 case VIRTCHNL_EVENT_RESET_IMPENDING:
144 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
145 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
148 case VIRTCHNL_EVENT_LINK_CHANGE:
149 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
150 vf->link_up = pf_msg->event_data.link_event.link_status;
151 vf->link_speed = pf_msg->event_data.link_event_adv.link_speed;
152 iavf_dev_link_update(dev, 0);
153 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
156 case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
157 PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
160 PMD_DRV_LOG(ERR, " unknown event received %u", pf_msg->event);
166 iavf_handle_virtchnl_msg(struct rte_eth_dev *dev)
168 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private);
169 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
170 struct iavf_arq_event_info info;
171 uint16_t pending, aq_opc;
172 enum virtchnl_ops msg_opc;
173 enum iavf_status msg_ret;
176 info.buf_len = IAVF_AQ_BUF_SZ;
178 PMD_DRV_LOG(ERR, "Buffer for adminq resp should not be NULL");
181 info.msg_buf = vf->aq_resp;
185 ret = iavf_clean_arq_element(hw, &info, &pending);
187 if (ret != IAVF_SUCCESS) {
188 PMD_DRV_LOG(INFO, "Failed to read msg from AdminQ,"
192 aq_opc = rte_le_to_cpu_16(info.desc.opcode);
193 /* For the message sent from pf to vf, opcode is stored in
194 * cookie_high of struct iavf_aq_desc, while return error code
195 * are stored in cookie_low, Which is done by PF driver.
197 msg_opc = (enum virtchnl_ops)rte_le_to_cpu_32(
198 info.desc.cookie_high);
199 msg_ret = (enum iavf_status)rte_le_to_cpu_32(
200 info.desc.cookie_low);
202 case iavf_aqc_opc_send_msg_to_vf:
203 if (msg_opc == VIRTCHNL_OP_EVENT) {
204 iavf_handle_pf_event_msg(dev, info.msg_buf,
207 /* read message and it's expected one */
208 if (msg_opc == vf->pend_cmd)
209 _notify_cmd(vf, msg_ret);
211 PMD_DRV_LOG(ERR, "command mismatch,"
213 vf->pend_cmd, msg_opc);
215 "adminq response is received,"
216 " opcode = %d", msg_opc);
220 PMD_DRV_LOG(ERR, "Request %u is not supported yet",
228 iavf_enable_vlan_strip(struct iavf_adapter *adapter)
230 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
231 struct iavf_cmd_info args;
234 memset(&args, 0, sizeof(args));
235 args.ops = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
237 args.in_args_size = 0;
238 args.out_buffer = vf->aq_resp;
239 args.out_size = IAVF_AQ_BUF_SZ;
240 ret = iavf_execute_vf_cmd(adapter, &args);
242 PMD_DRV_LOG(ERR, "Failed to execute command of"
243 " OP_ENABLE_VLAN_STRIPPING");
249 iavf_disable_vlan_strip(struct iavf_adapter *adapter)
251 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
252 struct iavf_cmd_info args;
255 memset(&args, 0, sizeof(args));
256 args.ops = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
258 args.in_args_size = 0;
259 args.out_buffer = vf->aq_resp;
260 args.out_size = IAVF_AQ_BUF_SZ;
261 ret = iavf_execute_vf_cmd(adapter, &args);
263 PMD_DRV_LOG(ERR, "Failed to execute command of"
264 " OP_DISABLE_VLAN_STRIPPING");
269 #define VIRTCHNL_VERSION_MAJOR_START 1
270 #define VIRTCHNL_VERSION_MINOR_START 1
272 /* Check API version with sync wait until version read from admin queue */
274 iavf_check_api_version(struct iavf_adapter *adapter)
276 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
277 struct virtchnl_version_info version, *pver;
278 struct iavf_cmd_info args;
281 version.major = VIRTCHNL_VERSION_MAJOR;
282 version.minor = VIRTCHNL_VERSION_MINOR;
284 args.ops = VIRTCHNL_OP_VERSION;
285 args.in_args = (uint8_t *)&version;
286 args.in_args_size = sizeof(version);
287 args.out_buffer = vf->aq_resp;
288 args.out_size = IAVF_AQ_BUF_SZ;
290 err = iavf_execute_vf_cmd(adapter, &args);
292 PMD_INIT_LOG(ERR, "Fail to execute command of OP_VERSION");
296 pver = (struct virtchnl_version_info *)args.out_buffer;
297 vf->virtchnl_version = *pver;
299 if (vf->virtchnl_version.major < VIRTCHNL_VERSION_MAJOR_START ||
300 (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR_START &&
301 vf->virtchnl_version.minor < VIRTCHNL_VERSION_MINOR_START)) {
302 PMD_INIT_LOG(ERR, "VIRTCHNL API version should not be lower"
303 " than (%u.%u) to support Adapative VF",
304 VIRTCHNL_VERSION_MAJOR_START,
305 VIRTCHNL_VERSION_MAJOR_START);
307 } else if (vf->virtchnl_version.major > VIRTCHNL_VERSION_MAJOR ||
308 (vf->virtchnl_version.major == VIRTCHNL_VERSION_MAJOR &&
309 vf->virtchnl_version.minor > VIRTCHNL_VERSION_MINOR)) {
310 PMD_INIT_LOG(ERR, "PF/VF API version mismatch:(%u.%u)-(%u.%u)",
311 vf->virtchnl_version.major,
312 vf->virtchnl_version.minor,
313 VIRTCHNL_VERSION_MAJOR,
314 VIRTCHNL_VERSION_MINOR);
318 PMD_DRV_LOG(DEBUG, "Peer is supported PF host");
323 iavf_get_vf_resource(struct iavf_adapter *adapter)
325 struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);
326 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
327 struct iavf_cmd_info args;
331 args.ops = VIRTCHNL_OP_GET_VF_RESOURCES;
332 args.out_buffer = vf->aq_resp;
333 args.out_size = IAVF_AQ_BUF_SZ;
335 /* TODO: basic offload capabilities, need to
336 * add advanced/optional offload capabilities
339 caps = IAVF_BASIC_OFFLOAD_CAPS | VIRTCHNL_VF_CAP_ADV_LINK_SPEED;
341 args.in_args = (uint8_t *)∩︀
342 args.in_args_size = sizeof(caps);
344 err = iavf_execute_vf_cmd(adapter, &args);
348 "Failed to execute command of OP_GET_VF_RESOURCE");
352 len = sizeof(struct virtchnl_vf_resource) +
353 IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
355 rte_memcpy(vf->vf_res, args.out_buffer,
356 RTE_MIN(args.out_size, len));
357 /* parse VF config message back from PF*/
358 iavf_vf_parse_hw_config(hw, vf->vf_res);
359 for (i = 0; i < vf->vf_res->num_vsis; i++) {
360 if (vf->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
361 vf->vsi_res = &vf->vf_res->vsi_res[i];
365 PMD_INIT_LOG(ERR, "no LAN VSI found");
369 vf->vsi.vsi_id = vf->vsi_res->vsi_id;
370 vf->vsi.nb_qps = vf->vsi_res->num_queue_pairs;
371 vf->vsi.adapter = adapter;
377 iavf_enable_queues(struct iavf_adapter *adapter)
379 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
380 struct virtchnl_queue_select queue_select;
381 struct iavf_cmd_info args;
384 memset(&queue_select, 0, sizeof(queue_select));
385 queue_select.vsi_id = vf->vsi_res->vsi_id;
387 queue_select.rx_queues = BIT(adapter->eth_dev->data->nb_rx_queues) - 1;
388 queue_select.tx_queues = BIT(adapter->eth_dev->data->nb_tx_queues) - 1;
390 args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
391 args.in_args = (u8 *)&queue_select;
392 args.in_args_size = sizeof(queue_select);
393 args.out_buffer = vf->aq_resp;
394 args.out_size = IAVF_AQ_BUF_SZ;
395 err = iavf_execute_vf_cmd(adapter, &args);
398 "Failed to execute command of OP_ENABLE_QUEUES");
405 iavf_disable_queues(struct iavf_adapter *adapter)
407 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
408 struct virtchnl_queue_select queue_select;
409 struct iavf_cmd_info args;
412 memset(&queue_select, 0, sizeof(queue_select));
413 queue_select.vsi_id = vf->vsi_res->vsi_id;
415 queue_select.rx_queues = BIT(adapter->eth_dev->data->nb_rx_queues) - 1;
416 queue_select.tx_queues = BIT(adapter->eth_dev->data->nb_tx_queues) - 1;
418 args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
419 args.in_args = (u8 *)&queue_select;
420 args.in_args_size = sizeof(queue_select);
421 args.out_buffer = vf->aq_resp;
422 args.out_size = IAVF_AQ_BUF_SZ;
423 err = iavf_execute_vf_cmd(adapter, &args);
426 "Failed to execute command of OP_DISABLE_QUEUES");
433 iavf_switch_queue(struct iavf_adapter *adapter, uint16_t qid,
436 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
437 struct virtchnl_queue_select queue_select;
438 struct iavf_cmd_info args;
441 memset(&queue_select, 0, sizeof(queue_select));
442 queue_select.vsi_id = vf->vsi_res->vsi_id;
444 queue_select.rx_queues |= 1 << qid;
446 queue_select.tx_queues |= 1 << qid;
449 args.ops = VIRTCHNL_OP_ENABLE_QUEUES;
451 args.ops = VIRTCHNL_OP_DISABLE_QUEUES;
452 args.in_args = (u8 *)&queue_select;
453 args.in_args_size = sizeof(queue_select);
454 args.out_buffer = vf->aq_resp;
455 args.out_size = IAVF_AQ_BUF_SZ;
456 err = iavf_execute_vf_cmd(adapter, &args);
458 PMD_DRV_LOG(ERR, "Failed to execute command of %s",
459 on ? "OP_ENABLE_QUEUES" : "OP_DISABLE_QUEUES");
464 iavf_configure_rss_lut(struct iavf_adapter *adapter)
466 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
467 struct virtchnl_rss_lut *rss_lut;
468 struct iavf_cmd_info args;
471 len = sizeof(*rss_lut) + vf->vf_res->rss_lut_size - 1;
472 rss_lut = rte_zmalloc("rss_lut", len, 0);
476 rss_lut->vsi_id = vf->vsi_res->vsi_id;
477 rss_lut->lut_entries = vf->vf_res->rss_lut_size;
478 rte_memcpy(rss_lut->lut, vf->rss_lut, vf->vf_res->rss_lut_size);
480 args.ops = VIRTCHNL_OP_CONFIG_RSS_LUT;
481 args.in_args = (u8 *)rss_lut;
482 args.in_args_size = len;
483 args.out_buffer = vf->aq_resp;
484 args.out_size = IAVF_AQ_BUF_SZ;
486 err = iavf_execute_vf_cmd(adapter, &args);
489 "Failed to execute command of OP_CONFIG_RSS_LUT");
496 iavf_configure_rss_key(struct iavf_adapter *adapter)
498 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
499 struct virtchnl_rss_key *rss_key;
500 struct iavf_cmd_info args;
503 len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
504 rss_key = rte_zmalloc("rss_key", len, 0);
508 rss_key->vsi_id = vf->vsi_res->vsi_id;
509 rss_key->key_len = vf->vf_res->rss_key_size;
510 rte_memcpy(rss_key->key, vf->rss_key, vf->vf_res->rss_key_size);
512 args.ops = VIRTCHNL_OP_CONFIG_RSS_KEY;
513 args.in_args = (u8 *)rss_key;
514 args.in_args_size = len;
515 args.out_buffer = vf->aq_resp;
516 args.out_size = IAVF_AQ_BUF_SZ;
518 err = iavf_execute_vf_cmd(adapter, &args);
521 "Failed to execute command of OP_CONFIG_RSS_KEY");
528 iavf_configure_queues(struct iavf_adapter *adapter)
530 struct iavf_rx_queue **rxq =
531 (struct iavf_rx_queue **)adapter->eth_dev->data->rx_queues;
532 struct iavf_tx_queue **txq =
533 (struct iavf_tx_queue **)adapter->eth_dev->data->tx_queues;
534 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
535 struct virtchnl_vsi_queue_config_info *vc_config;
536 struct virtchnl_queue_pair_info *vc_qp;
537 struct iavf_cmd_info args;
541 size = sizeof(*vc_config) +
542 sizeof(vc_config->qpair[0]) * vf->num_queue_pairs;
543 vc_config = rte_zmalloc("cfg_queue", size, 0);
547 vc_config->vsi_id = vf->vsi_res->vsi_id;
548 vc_config->num_queue_pairs = vf->num_queue_pairs;
550 for (i = 0, vc_qp = vc_config->qpair;
551 i < vf->num_queue_pairs;
553 vc_qp->txq.vsi_id = vf->vsi_res->vsi_id;
554 vc_qp->txq.queue_id = i;
555 /* Virtchnnl configure queues by pairs */
556 if (i < adapter->eth_dev->data->nb_tx_queues) {
557 vc_qp->txq.ring_len = txq[i]->nb_tx_desc;
558 vc_qp->txq.dma_ring_addr = txq[i]->tx_ring_phys_addr;
560 vc_qp->rxq.vsi_id = vf->vsi_res->vsi_id;
561 vc_qp->rxq.queue_id = i;
562 vc_qp->rxq.max_pkt_size = vf->max_pkt_len;
563 /* Virtchnnl configure queues by pairs */
564 if (i < adapter->eth_dev->data->nb_rx_queues) {
565 vc_qp->rxq.ring_len = rxq[i]->nb_rx_desc;
566 vc_qp->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;
567 vc_qp->rxq.databuffer_size = rxq[i]->rx_buf_len;
571 memset(&args, 0, sizeof(args));
572 args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
573 args.in_args = (uint8_t *)vc_config;
574 args.in_args_size = size;
575 args.out_buffer = vf->aq_resp;
576 args.out_size = IAVF_AQ_BUF_SZ;
578 err = iavf_execute_vf_cmd(adapter, &args);
580 PMD_DRV_LOG(ERR, "Failed to execute command of"
581 " VIRTCHNL_OP_CONFIG_VSI_QUEUES");
588 iavf_config_irq_map(struct iavf_adapter *adapter)
590 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
591 struct virtchnl_irq_map_info *map_info;
592 struct virtchnl_vector_map *vecmap;
593 struct iavf_cmd_info args;
596 len = sizeof(struct virtchnl_irq_map_info) +
597 sizeof(struct virtchnl_vector_map) * vf->nb_msix;
599 map_info = rte_zmalloc("map_info", len, 0);
603 map_info->num_vectors = vf->nb_msix;
604 for (i = 0; i < vf->nb_msix; i++) {
605 vecmap = &map_info->vecmap[i];
606 vecmap->vsi_id = vf->vsi_res->vsi_id;
607 vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
608 vecmap->vector_id = vf->msix_base + i;
610 vecmap->rxq_map = vf->rxq_map[vf->msix_base + i];
613 args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
614 args.in_args = (u8 *)map_info;
615 args.in_args_size = len;
616 args.out_buffer = vf->aq_resp;
617 args.out_size = IAVF_AQ_BUF_SZ;
618 err = iavf_execute_vf_cmd(adapter, &args);
620 PMD_DRV_LOG(ERR, "fail to execute command OP_CONFIG_IRQ_MAP");
627 iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)
629 struct virtchnl_ether_addr_list *list;
630 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
631 struct rte_ether_addr *addr;
632 struct iavf_cmd_info args;
639 len = sizeof(struct virtchnl_ether_addr_list);
640 for (i = begin; i < IAVF_NUM_MACADDR_MAX; i++, next_begin++) {
641 addr = &adapter->eth_dev->data->mac_addrs[i];
642 if (rte_is_zero_ether_addr(addr))
644 len += sizeof(struct virtchnl_ether_addr);
645 if (len >= IAVF_AQ_BUF_SZ) {
651 list = rte_zmalloc("iavf_del_mac_buffer", len, 0);
653 PMD_DRV_LOG(ERR, "fail to allocate memory");
657 for (i = begin; i < next_begin; i++) {
658 addr = &adapter->eth_dev->data->mac_addrs[i];
659 if (rte_is_zero_ether_addr(addr))
661 rte_memcpy(list->list[j].addr, addr->addr_bytes,
662 sizeof(addr->addr_bytes));
663 PMD_DRV_LOG(DEBUG, "add/rm mac:%x:%x:%x:%x:%x:%x",
664 addr->addr_bytes[0], addr->addr_bytes[1],
665 addr->addr_bytes[2], addr->addr_bytes[3],
666 addr->addr_bytes[4], addr->addr_bytes[5]);
669 list->vsi_id = vf->vsi_res->vsi_id;
670 list->num_elements = j;
671 args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR :
672 VIRTCHNL_OP_DEL_ETH_ADDR;
673 args.in_args = (uint8_t *)list;
674 args.in_args_size = len;
675 args.out_buffer = vf->aq_resp;
676 args.out_size = IAVF_AQ_BUF_SZ;
677 err = iavf_execute_vf_cmd(adapter, &args);
679 PMD_DRV_LOG(ERR, "fail to execute command %s",
680 add ? "OP_ADD_ETHER_ADDRESS" :
681 "OP_DEL_ETHER_ADDRESS");
684 } while (begin < IAVF_NUM_MACADDR_MAX);
688 iavf_query_stats(struct iavf_adapter *adapter,
689 struct virtchnl_eth_stats **pstats)
691 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
692 struct virtchnl_queue_select q_stats;
693 struct iavf_cmd_info args;
696 memset(&q_stats, 0, sizeof(q_stats));
697 q_stats.vsi_id = vf->vsi_res->vsi_id;
698 args.ops = VIRTCHNL_OP_GET_STATS;
699 args.in_args = (uint8_t *)&q_stats;
700 args.in_args_size = sizeof(q_stats);
701 args.out_buffer = vf->aq_resp;
702 args.out_size = IAVF_AQ_BUF_SZ;
704 err = iavf_execute_vf_cmd(adapter, &args);
706 PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS");
710 *pstats = (struct virtchnl_eth_stats *)args.out_buffer;
715 iavf_config_promisc(struct iavf_adapter *adapter,
717 bool enable_multicast)
719 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
720 struct virtchnl_promisc_info promisc;
721 struct iavf_cmd_info args;
725 promisc.vsi_id = vf->vsi_res->vsi_id;
728 promisc.flags |= FLAG_VF_UNICAST_PROMISC;
730 if (enable_multicast)
731 promisc.flags |= FLAG_VF_MULTICAST_PROMISC;
733 args.ops = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
734 args.in_args = (uint8_t *)&promisc;
735 args.in_args_size = sizeof(promisc);
736 args.out_buffer = vf->aq_resp;
737 args.out_size = IAVF_AQ_BUF_SZ;
739 err = iavf_execute_vf_cmd(adapter, &args);
743 "fail to execute command CONFIG_PROMISCUOUS_MODE");
748 iavf_add_del_eth_addr(struct iavf_adapter *adapter, struct rte_ether_addr *addr,
751 struct virtchnl_ether_addr_list *list;
752 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
753 uint8_t cmd_buffer[sizeof(struct virtchnl_ether_addr_list) +
754 sizeof(struct virtchnl_ether_addr)];
755 struct iavf_cmd_info args;
758 list = (struct virtchnl_ether_addr_list *)cmd_buffer;
759 list->vsi_id = vf->vsi_res->vsi_id;
760 list->num_elements = 1;
761 rte_memcpy(list->list[0].addr, addr->addr_bytes,
762 sizeof(addr->addr_bytes));
764 args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
765 args.in_args = cmd_buffer;
766 args.in_args_size = sizeof(cmd_buffer);
767 args.out_buffer = vf->aq_resp;
768 args.out_size = IAVF_AQ_BUF_SZ;
769 err = iavf_execute_vf_cmd(adapter, &args);
771 PMD_DRV_LOG(ERR, "fail to execute command %s",
772 add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR");
777 iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add)
779 struct virtchnl_vlan_filter_list *vlan_list;
780 struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
781 uint8_t cmd_buffer[sizeof(struct virtchnl_vlan_filter_list) +
783 struct iavf_cmd_info args;
786 vlan_list = (struct virtchnl_vlan_filter_list *)cmd_buffer;
787 vlan_list->vsi_id = vf->vsi_res->vsi_id;
788 vlan_list->num_elements = 1;
789 vlan_list->vlan_id[0] = vlanid;
791 args.ops = add ? VIRTCHNL_OP_ADD_VLAN : VIRTCHNL_OP_DEL_VLAN;
792 args.in_args = cmd_buffer;
793 args.in_args_size = sizeof(cmd_buffer);
794 args.out_buffer = vf->aq_resp;
795 args.out_size = IAVF_AQ_BUF_SZ;
796 err = iavf_execute_vf_cmd(adapter, &args);
798 PMD_DRV_LOG(ERR, "fail to execute command %s",
799 add ? "OP_ADD_VLAN" : "OP_DEL_VLAN");