get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/120558/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 120558,
    "url": "http://patches.dpdk.org/api/patches/120558/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20221208075309.37852-4-beilei.xing@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20221208075309.37852-4-beilei.xing@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221208075309.37852-4-beilei.xing@intel.com",
    "date": "2022-12-08T07:52:57",
    "name": "[03/15] common/idpf: move vc functions to common module",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "ae8c1382416c1e7c954acee3bb667ca3fad725fa",
    "submitter": {
        "id": 410,
        "url": "http://patches.dpdk.org/api/people/410/?format=api",
        "name": "Xing, Beilei",
        "email": "beilei.xing@intel.com"
    },
    "delegate": {
        "id": 1540,
        "url": "http://patches.dpdk.org/api/users/1540/?format=api",
        "username": "qzhan15",
        "first_name": "Qi",
        "last_name": "Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20221208075309.37852-4-beilei.xing@intel.com/mbox/",
    "series": [
        {
            "id": 26041,
            "url": "http://patches.dpdk.org/api/series/26041/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=26041",
            "date": "2022-12-08T07:52:54",
            "name": "net/idpf: refactor idpf pmd",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/26041/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/120558/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/120558/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 24762A00C2;\n\tThu,  8 Dec 2022 08:53:46 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 461A942D35;\n\tThu,  8 Dec 2022 08:53:32 +0100 (CET)",
            "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n by mails.dpdk.org (Postfix) with ESMTP id 0E57342D21\n for <dev@dpdk.org>; Thu,  8 Dec 2022 08:53:29 +0100 (CET)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 07 Dec 2022 23:53:29 -0800",
            "from dpdk-beileix-3.sh.intel.com ([10.67.110.253])\n by fmsmga004.fm.intel.com with ESMTP; 07 Dec 2022 23:53:27 -0800"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1670486010; x=1702022010;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=oKLZPrWGCOD/ytlhLZtMQ4uc5+AzyxQ1EAL9GFW4+tA=;\n b=C850JjRrAvRSHowfy82OYygf6/3WOyhS4LRX56VvtQvPEPuYjfS0Bv20\n iqNJKe3/o0yrkY2Xe8RjVa3N+RPbxJucWhzuK5uxLNlRTVo98KNmh4CjH\n klw7CqEVGhn2QW99IUaZXa7w+p1tZrWPLhiuv/p+DoVSSxRPKJDGFJ4wU\n 36k7aHIS0wFgJ0Ma8TihC4dsVJFuPSsOJ45XDN6nLe0N6kaWF6N6Kzu1+\n eDmDscBGru4K5uUqBPv8jequ6pQPXiwyzJ2yGPC24ZZkjbTJ2ml/mEigY\n mY4tdawVhOciAvlWdLft5rTe0P8Ayw/v/dUUNmVK/IIk/0DkcGdHqodKe w==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6500,9779,10554\"; a=\"318244155\"",
            "E=Sophos;i=\"5.96,227,1665471600\"; d=\"scan'208\";a=\"318244155\"",
            "E=McAfee;i=\"6500,9779,10554\"; a=\"715499290\"",
            "E=Sophos;i=\"5.96,227,1665471600\"; d=\"scan'208\";a=\"715499290\""
        ],
        "X-ExtLoop1": "1",
        "From": "beilei.xing@intel.com",
        "To": "jingjing.wu@intel.com,\n\tqi.z.zhang@intel.com",
        "Cc": "dev@dpdk.org, Beilei Xing <beilei.xing@intel.com>,\n Wenjun Wu <wenjun1.wu@intel.com>",
        "Subject": "[PATCH 03/15] common/idpf: move vc functions to common module",
        "Date": "Thu,  8 Dec 2022 07:52:57 +0000",
        "Message-Id": "<20221208075309.37852-4-beilei.xing@intel.com>",
        "X-Mailer": "git-send-email 2.26.2",
        "In-Reply-To": "<20221208075309.37852-1-beilei.xing@intel.com>",
        "References": "<20221208075309.37852-1-beilei.xing@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "From: Beilei Xing <beilei.xing@intel.com>\n\nMove most of virtual channel functions to idpf common module.\n\nSigned-off-by: Wenjun Wu <wenjun1.wu@intel.com>\nSigned-off-by: Beilei Xing <beilei.xing@intel.com>\n---\n drivers/common/idpf/base/meson.build       |   2 +-\n drivers/common/idpf/idpf_common_device.c   |   8 +\n drivers/common/idpf/idpf_common_device.h   |  61 ++\n drivers/common/idpf/idpf_common_logs.h     |  23 +\n drivers/common/idpf/idpf_common_virtchnl.c | 815 +++++++++++++++++++++\n drivers/common/idpf/idpf_common_virtchnl.h |  48 ++\n drivers/common/idpf/meson.build            |   5 +\n drivers/common/idpf/version.map            |  16 +\n drivers/net/idpf/idpf_ethdev.c             |   9 +-\n drivers/net/idpf/idpf_ethdev.h             |  85 +--\n drivers/net/idpf/idpf_vchnl.c              | 815 +--------------------\n 11 files changed, 981 insertions(+), 906 deletions(-)\n create mode 100644 drivers/common/idpf/idpf_common_device.c\n create mode 100644 drivers/common/idpf/idpf_common_logs.h\n create mode 100644 drivers/common/idpf/idpf_common_virtchnl.c\n create mode 100644 drivers/common/idpf/idpf_common_virtchnl.h",
    "diff": "diff --git a/drivers/common/idpf/base/meson.build b/drivers/common/idpf/base/meson.build\nindex 183587b51a..dc4b93c198 100644\n--- a/drivers/common/idpf/base/meson.build\n+++ b/drivers/common/idpf/base/meson.build\n@@ -1,7 +1,7 @@\n # SPDX-License-Identifier: BSD-3-Clause\n # Copyright(c) 2022 Intel Corporation\n \n-sources = files(\n+sources += files(\n         'idpf_common.c',\n         'idpf_controlq.c',\n         'idpf_controlq_setup.c',\ndiff --git a/drivers/common/idpf/idpf_common_device.c b/drivers/common/idpf/idpf_common_device.c\nnew file mode 100644\nindex 0000000000..5062780362\n--- /dev/null\n+++ b/drivers/common/idpf/idpf_common_device.c\n@@ -0,0 +1,8 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 Intel Corporation\n+ */\n+\n+#include <rte_log.h>\n+#include <idpf_common_device.h>\n+\n+RTE_LOG_REGISTER_SUFFIX(idpf_common_logtype, common, NOTICE);\ndiff --git a/drivers/common/idpf/idpf_common_device.h b/drivers/common/idpf/idpf_common_device.h\nindex b7fff84b25..a7537281d1 100644\n--- a/drivers/common/idpf/idpf_common_device.h\n+++ b/drivers/common/idpf/idpf_common_device.h\n@@ -7,6 +7,12 @@\n \n #include <base/idpf_prototype.h>\n #include <base/virtchnl2.h>\n+#include <idpf_common_logs.h>\n+\n+#define IDPF_CTLQ_LEN\t\t64\n+#define IDPF_DFLT_MBX_BUF_SIZE\t4096\n+\n+#define IDPF_MAX_PKT_TYPE\t1024\n \n struct idpf_adapter {\n \tstruct idpf_hw hw;\n@@ -76,4 +82,59 @@ struct idpf_vport {\n \tbool stopped;\n };\n \n+/* Message type read in virtual channel from PF */\n+enum idpf_vc_result {\n+\tIDPF_MSG_ERR = -1, /* Meet error when accessing admin queue */\n+\tIDPF_MSG_NON,      /* Read nothing from admin queue */\n+\tIDPF_MSG_SYS,      /* Read system msg from admin queue */\n+\tIDPF_MSG_CMD,      /* Read async command result */\n+};\n+\n+/* structure used for sending and checking response of virtchnl ops */\n+struct idpf_cmd_info {\n+\tuint32_t ops;\n+\tuint8_t *in_args;       /* buffer for sending */\n+\tuint32_t in_args_size;  /* buffer size for sending */\n+\tuint8_t *out_buffer;    /* buffer for response */\n+\tuint32_t out_size;      /* buffer size for response */\n+};\n+\n+/* notify current command done. Only call in case execute\n+ * _atomic_set_cmd successfully.\n+ */\n+static inline void\n+notify_cmd(struct idpf_adapter *adapter, int msg_ret)\n+{\n+\tadapter->cmd_retval = msg_ret;\n+\t/* Return value may be checked in anither thread, need to ensure the coherence. */\n+\trte_wmb();\n+\tadapter->pend_cmd = VIRTCHNL2_OP_UNKNOWN;\n+}\n+\n+/* clear current command. Only call in case execute\n+ * _atomic_set_cmd successfully.\n+ */\n+static inline void\n+clear_cmd(struct idpf_adapter *adapter)\n+{\n+\t/* Return value may be checked in anither thread, need to ensure the coherence. */\n+\trte_wmb();\n+\tadapter->pend_cmd = VIRTCHNL2_OP_UNKNOWN;\n+\tadapter->cmd_retval = VIRTCHNL_STATUS_SUCCESS;\n+}\n+\n+/* Check there is pending cmd in execution. If none, set new command. */\n+static inline bool\n+atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)\n+{\n+\tuint32_t op_unk = VIRTCHNL2_OP_UNKNOWN;\n+\tbool ret = __atomic_compare_exchange(&adapter->pend_cmd, &op_unk, &ops,\n+\t\t\t\t\t    0, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);\n+\n+\tif (!ret)\n+\t\tDRV_LOG(ERR, \"There is incomplete cmd %d\", adapter->pend_cmd);\n+\n+\treturn !ret;\n+}\n+\n #endif /* _IDPF_COMMON_DEVICE_H_ */\ndiff --git a/drivers/common/idpf/idpf_common_logs.h b/drivers/common/idpf/idpf_common_logs.h\nnew file mode 100644\nindex 0000000000..fe36562769\n--- /dev/null\n+++ b/drivers/common/idpf/idpf_common_logs.h\n@@ -0,0 +1,23 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 Intel Corporation\n+ */\n+\n+#ifndef _IDPF_COMMON_LOGS_H_\n+#define _IDPF_COMMON_LOGS_H_\n+\n+#include <rte_log.h>\n+\n+extern int idpf_common_logtype;\n+\n+#define DRV_LOG_RAW(level, ...)\t\t\t\t\t\\\n+\trte_log(RTE_LOG_ ## level,\t\t\t\t\\\n+\t\tidpf_common_logtype,\t\t\t\t\\\n+\t\tRTE_FMT(\"%s(): \"\t\t\t\t\\\n+\t\t\tRTE_FMT_HEAD(__VA_ARGS__,) \"\\n\",\t\\\n+\t\t\t__func__,\t\t\t\t\\\n+\t\t\tRTE_FMT_TAIL(__VA_ARGS__,)))\n+\n+#define DRV_LOG(level, fmt, args...)\t\t\\\n+\tDRV_LOG_RAW(level, fmt \"\\n\", ## args)\n+\n+#endif /* _IDPF_COMMON_LOGS_H_ */\ndiff --git a/drivers/common/idpf/idpf_common_virtchnl.c b/drivers/common/idpf/idpf_common_virtchnl.c\nnew file mode 100644\nindex 0000000000..2e94a95876\n--- /dev/null\n+++ b/drivers/common/idpf/idpf_common_virtchnl.c\n@@ -0,0 +1,815 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 Intel Corporation\n+ */\n+\n+#include <idpf_common_virtchnl.h>\n+#include <idpf_common_logs.h>\n+\n+static int\n+idpf_vc_clean(struct idpf_adapter *adapter)\n+{\n+\tstruct idpf_ctlq_msg *q_msg[IDPF_CTLQ_LEN];\n+\tuint16_t num_q_msg = IDPF_CTLQ_LEN;\n+\tstruct idpf_dma_mem *dma_mem;\n+\tint err;\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < 10; i++) {\n+\t\terr = idpf_ctlq_clean_sq(adapter->hw.asq, &num_q_msg, q_msg);\n+\t\tmsleep(20);\n+\t\tif (num_q_msg > 0)\n+\t\t\tbreak;\n+\t}\n+\tif (err != 0)\n+\t\treturn err;\n+\n+\t/* Empty queue is not an error */\n+\tfor (i = 0; i < num_q_msg; i++) {\n+\t\tdma_mem = q_msg[i]->ctx.indirect.payload;\n+\t\tif (dma_mem != NULL) {\n+\t\t\tidpf_free_dma_mem(&adapter->hw, dma_mem);\n+\t\t\trte_free(dma_mem);\n+\t\t}\n+\t\trte_free(q_msg[i]);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+idpf_send_vc_msg(struct idpf_adapter *adapter, uint32_t op,\n+\t\t uint16_t msg_size, uint8_t *msg)\n+{\n+\tstruct idpf_ctlq_msg *ctlq_msg;\n+\tstruct idpf_dma_mem *dma_mem;\n+\tint err;\n+\n+\terr = idpf_vc_clean(adapter);\n+\tif (err != 0)\n+\t\tgoto err;\n+\n+\tctlq_msg = rte_zmalloc(NULL, sizeof(struct idpf_ctlq_msg), 0);\n+\tif (ctlq_msg == NULL) {\n+\t\terr = -ENOMEM;\n+\t\tgoto err;\n+\t}\n+\n+\tdma_mem = rte_zmalloc(NULL, sizeof(struct idpf_dma_mem), 0);\n+\tif (dma_mem == NULL) {\n+\t\terr = -ENOMEM;\n+\t\tgoto dma_mem_error;\n+\t}\n+\n+\tdma_mem->size = IDPF_DFLT_MBX_BUF_SIZE;\n+\tidpf_alloc_dma_mem(&adapter->hw, dma_mem, dma_mem->size);\n+\tif (dma_mem->va == NULL) {\n+\t\terr = -ENOMEM;\n+\t\tgoto dma_alloc_error;\n+\t}\n+\n+\tmemcpy(dma_mem->va, msg, msg_size);\n+\n+\tctlq_msg->opcode = idpf_mbq_opc_send_msg_to_pf;\n+\tctlq_msg->func_id = 0;\n+\tctlq_msg->data_len = msg_size;\n+\tctlq_msg->cookie.mbx.chnl_opcode = op;\n+\tctlq_msg->cookie.mbx.chnl_retval = VIRTCHNL_STATUS_SUCCESS;\n+\tctlq_msg->ctx.indirect.payload = dma_mem;\n+\n+\terr = idpf_ctlq_send(&adapter->hw, adapter->hw.asq, 1, ctlq_msg);\n+\tif (err != 0)\n+\t\tgoto send_error;\n+\n+\treturn 0;\n+\n+send_error:\n+\tidpf_free_dma_mem(&adapter->hw, dma_mem);\n+dma_alloc_error:\n+\trte_free(dma_mem);\n+dma_mem_error:\n+\trte_free(ctlq_msg);\n+err:\n+\treturn err;\n+}\n+\n+static enum idpf_vc_result\n+idpf_read_msg_from_cp(struct idpf_adapter *adapter, uint16_t buf_len,\n+\t\t      uint8_t *buf)\n+{\n+\tstruct idpf_hw *hw = &adapter->hw;\n+\tstruct idpf_ctlq_msg ctlq_msg;\n+\tstruct idpf_dma_mem *dma_mem = NULL;\n+\tenum idpf_vc_result result = IDPF_MSG_NON;\n+\tuint32_t opcode;\n+\tuint16_t pending = 1;\n+\tint ret;\n+\n+\tret = idpf_ctlq_recv(hw->arq, &pending, &ctlq_msg);\n+\tif (ret != 0) {\n+\t\tDRV_LOG(DEBUG, \"Can't read msg from AQ\");\n+\t\tif (ret != -ENOMSG)\n+\t\t\tresult = IDPF_MSG_ERR;\n+\t\treturn result;\n+\t}\n+\n+\trte_memcpy(buf, ctlq_msg.ctx.indirect.payload->va, buf_len);\n+\n+\topcode = rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_opcode);\n+\tadapter->cmd_retval = rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_retval);\n+\n+\tDRV_LOG(DEBUG, \"CQ from CP carries opcode %u, retval %d\",\n+\t\topcode, adapter->cmd_retval);\n+\n+\tif (opcode == VIRTCHNL2_OP_EVENT) {\n+\t\tstruct virtchnl2_event *ve = ctlq_msg.ctx.indirect.payload->va;\n+\n+\t\tresult = IDPF_MSG_SYS;\n+\t\tswitch (ve->event) {\n+\t\tcase VIRTCHNL2_EVENT_LINK_CHANGE:\n+\t\t\t/* TBD */\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tDRV_LOG(ERR, \"%s: Unknown event %d from CP\",\n+\t\t\t\t__func__, ve->event);\n+\t\t\tbreak;\n+\t\t}\n+\t} else {\n+\t\t/* async reply msg on command issued by pf previously */\n+\t\tresult = IDPF_MSG_CMD;\n+\t\tif (opcode != adapter->pend_cmd) {\n+\t\t\tDRV_LOG(WARNING, \"command mismatch, expect %u, get %u\",\n+\t\t\t\tadapter->pend_cmd, opcode);\n+\t\t\tresult = IDPF_MSG_ERR;\n+\t\t}\n+\t}\n+\n+\tif (ctlq_msg.data_len != 0)\n+\t\tdma_mem = ctlq_msg.ctx.indirect.payload;\n+\telse\n+\t\tpending = 0;\n+\n+\tret = idpf_ctlq_post_rx_buffs(hw, hw->arq, &pending, &dma_mem);\n+\tif (ret != 0 && dma_mem != NULL)\n+\t\tidpf_free_dma_mem(hw, dma_mem);\n+\n+\treturn result;\n+}\n+\n+#define MAX_TRY_TIMES 200\n+#define ASQ_DELAY_MS  10\n+\n+int\n+idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops, uint16_t buf_len,\n+\t\t  uint8_t *buf)\n+{\n+\tint err = 0;\n+\tint i = 0;\n+\tint ret;\n+\n+\tdo {\n+\t\tret = idpf_read_msg_from_cp(adapter, buf_len, buf);\n+\t\tif (ret == IDPF_MSG_CMD)\n+\t\t\tbreak;\n+\t\trte_delay_ms(ASQ_DELAY_MS);\n+\t} while (i++ < MAX_TRY_TIMES);\n+\tif (i >= MAX_TRY_TIMES ||\n+\t    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {\n+\t\terr = -EBUSY;\n+\t\tDRV_LOG(ERR, \"No response or return failure (%d) for cmd %d\",\n+\t\t\tadapter->cmd_retval, ops);\n+\t}\n+\n+\treturn err;\n+}\n+\n+int\n+idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)\n+{\n+\tint err = 0;\n+\tint i = 0;\n+\tint ret;\n+\n+\tif (atomic_set_cmd(adapter, args->ops))\n+\t\treturn -EINVAL;\n+\n+\tret = idpf_send_vc_msg(adapter, args->ops, args->in_args_size, args->in_args);\n+\tif (ret != 0) {\n+\t\tDRV_LOG(ERR, \"fail to send cmd %d\", args->ops);\n+\t\tclear_cmd(adapter);\n+\t\treturn ret;\n+\t}\n+\n+\tswitch (args->ops) {\n+\tcase VIRTCHNL_OP_VERSION:\n+\tcase VIRTCHNL2_OP_GET_CAPS:\n+\tcase VIRTCHNL2_OP_CREATE_VPORT:\n+\tcase VIRTCHNL2_OP_DESTROY_VPORT:\n+\tcase VIRTCHNL2_OP_SET_RSS_KEY:\n+\tcase VIRTCHNL2_OP_SET_RSS_LUT:\n+\tcase VIRTCHNL2_OP_SET_RSS_HASH:\n+\tcase VIRTCHNL2_OP_CONFIG_RX_QUEUES:\n+\tcase VIRTCHNL2_OP_CONFIG_TX_QUEUES:\n+\tcase VIRTCHNL2_OP_ENABLE_QUEUES:\n+\tcase VIRTCHNL2_OP_DISABLE_QUEUES:\n+\tcase VIRTCHNL2_OP_ENABLE_VPORT:\n+\tcase VIRTCHNL2_OP_DISABLE_VPORT:\n+\tcase VIRTCHNL2_OP_MAP_QUEUE_VECTOR:\n+\tcase VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR:\n+\tcase VIRTCHNL2_OP_ALLOC_VECTORS:\n+\tcase VIRTCHNL2_OP_DEALLOC_VECTORS:\n+\t\t/* for init virtchnl ops, need to poll the response */\n+\t\terr = idpf_read_one_msg(adapter, args->ops, args->out_size, args->out_buffer);\n+\t\tclear_cmd(adapter);\n+\t\tbreak;\n+\tcase VIRTCHNL2_OP_GET_PTYPE_INFO:\n+\t\t/* for multuple response message,\n+\t\t * do not handle the response here.\n+\t\t */\n+\t\tbreak;\n+\tdefault:\n+\t\t/* For other virtchnl ops in running time,\n+\t\t * wait for the cmd done flag.\n+\t\t */\n+\t\tdo {\n+\t\t\tif (adapter->pend_cmd == VIRTCHNL_OP_UNKNOWN)\n+\t\t\t\tbreak;\n+\t\t\trte_delay_ms(ASQ_DELAY_MS);\n+\t\t\t/* If don't read msg or read sys event, continue */\n+\t\t} while (i++ < MAX_TRY_TIMES);\n+\t\t/* If there's no response is received, clear command */\n+\t\tif (i >= MAX_TRY_TIMES  ||\n+\t\t    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {\n+\t\t\terr = -EBUSY;\n+\t\t\tDRV_LOG(ERR, \"No response or return failure (%d) for cmd %d\",\n+\t\t\t\tadapter->cmd_retval, args->ops);\n+\t\t\tclear_cmd(adapter);\n+\t\t}\n+\t\tbreak;\n+\t}\n+\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_check_api_version(struct idpf_adapter *adapter)\n+{\n+\tstruct virtchnl2_version_info version, *pver;\n+\tstruct idpf_cmd_info args;\n+\tint err;\n+\n+\tmemset(&version, 0, sizeof(struct virtchnl_version_info));\n+\tversion.major = VIRTCHNL2_VERSION_MAJOR_2;\n+\tversion.minor = VIRTCHNL2_VERSION_MINOR_0;\n+\n+\targs.ops = VIRTCHNL_OP_VERSION;\n+\targs.in_args = (uint8_t *)&version;\n+\targs.in_args_size = sizeof(version);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0) {\n+\t\tDRV_LOG(ERR,\n+\t\t\t\"Failed to execute command of VIRTCHNL_OP_VERSION\");\n+\t\treturn err;\n+\t}\n+\n+\tpver = (struct virtchnl2_version_info *)args.out_buffer;\n+\tadapter->virtchnl_version = *pver;\n+\n+\tif (adapter->virtchnl_version.major != VIRTCHNL2_VERSION_MAJOR_2 ||\n+\t    adapter->virtchnl_version.minor != VIRTCHNL2_VERSION_MINOR_0) {\n+\t\tDRV_LOG(ERR, \"VIRTCHNL API version mismatch:(%u.%u)-(%u.%u)\",\n+\t\t\tadapter->virtchnl_version.major,\n+\t\t\tadapter->virtchnl_version.minor,\n+\t\t\tVIRTCHNL2_VERSION_MAJOR_2,\n+\t\t\tVIRTCHNL2_VERSION_MINOR_0);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int\n+idpf_vc_get_caps(struct idpf_adapter *adapter)\n+{\n+\tstruct virtchnl2_get_capabilities caps_msg;\n+\tstruct idpf_cmd_info args;\n+\tint err;\n+\n+\tmemset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities));\n+\n+\tcaps_msg.csum_caps =\n+\t\tVIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |\n+\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |\n+\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |\n+\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |\n+\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |\n+\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |\n+\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |\n+\t\tVIRTCHNL2_CAP_TX_CSUM_GENERIC          |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |\n+\t\tVIRTCHNL2_CAP_RX_CSUM_GENERIC;\n+\n+\tcaps_msg.rss_caps =\n+\t\tVIRTCHNL2_CAP_RSS_IPV4_TCP             |\n+\t\tVIRTCHNL2_CAP_RSS_IPV4_UDP             |\n+\t\tVIRTCHNL2_CAP_RSS_IPV4_SCTP            |\n+\t\tVIRTCHNL2_CAP_RSS_IPV4_OTHER           |\n+\t\tVIRTCHNL2_CAP_RSS_IPV6_TCP             |\n+\t\tVIRTCHNL2_CAP_RSS_IPV6_UDP             |\n+\t\tVIRTCHNL2_CAP_RSS_IPV6_SCTP            |\n+\t\tVIRTCHNL2_CAP_RSS_IPV6_OTHER           |\n+\t\tVIRTCHNL2_CAP_RSS_IPV4_AH              |\n+\t\tVIRTCHNL2_CAP_RSS_IPV4_ESP             |\n+\t\tVIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |\n+\t\tVIRTCHNL2_CAP_RSS_IPV6_AH              |\n+\t\tVIRTCHNL2_CAP_RSS_IPV6_ESP             |\n+\t\tVIRTCHNL2_CAP_RSS_IPV6_AH_ESP;\n+\n+\tcaps_msg.other_caps = VIRTCHNL2_CAP_WB_ON_ITR;\n+\n+\targs.ops = VIRTCHNL2_OP_GET_CAPS;\n+\targs.in_args = (uint8_t *)&caps_msg;\n+\targs.in_args_size = sizeof(caps_msg);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0) {\n+\t\tDRV_LOG(ERR,\n+\t\t\t\"Failed to execute command of VIRTCHNL2_OP_GET_CAPS\");\n+\t\treturn err;\n+\t}\n+\n+\trte_memcpy(&adapter->caps, args.out_buffer, sizeof(caps_msg));\n+\n+\treturn 0;\n+}\n+\n+int\n+idpf_vc_create_vport(struct idpf_vport *vport,\n+\t\t     struct virtchnl2_create_vport *vport_req_info)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_create_vport vport_msg;\n+\tstruct idpf_cmd_info args;\n+\tint err = -1;\n+\n+\tmemset(&vport_msg, 0, sizeof(struct virtchnl2_create_vport));\n+\tvport_msg.vport_type = vport_req_info->vport_type;\n+\tvport_msg.txq_model = vport_req_info->txq_model;\n+\tvport_msg.rxq_model = vport_req_info->rxq_model;\n+\tvport_msg.num_tx_q = vport_req_info->num_tx_q;\n+\tvport_msg.num_tx_complq = vport_req_info->num_tx_complq;\n+\tvport_msg.num_rx_q = vport_req_info->num_rx_q;\n+\tvport_msg.num_rx_bufq = vport_req_info->num_rx_bufq;\n+\n+\tmemset(&args, 0, sizeof(args));\n+\targs.ops = VIRTCHNL2_OP_CREATE_VPORT;\n+\targs.in_args = (uint8_t *)&vport_msg;\n+\targs.in_args_size = sizeof(vport_msg);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0) {\n+\t\tDRV_LOG(ERR,\n+\t\t\t\"Failed to execute command of VIRTCHNL2_OP_CREATE_VPORT\");\n+\t\treturn err;\n+\t}\n+\n+\trte_memcpy(vport->vport_info, args.out_buffer, IDPF_DFLT_MBX_BUF_SIZE);\n+\treturn 0;\n+}\n+\n+int\n+idpf_vc_destroy_vport(struct idpf_vport *vport)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_vport vc_vport;\n+\tstruct idpf_cmd_info args;\n+\tint err;\n+\n+\tvc_vport.vport_id = vport->vport_id;\n+\n+\tmemset(&args, 0, sizeof(args));\n+\targs.ops = VIRTCHNL2_OP_DESTROY_VPORT;\n+\targs.in_args = (uint8_t *)&vc_vport;\n+\targs.in_args_size = sizeof(vc_vport);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_DESTROY_VPORT\");\n+\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_set_rss_key(struct idpf_vport *vport)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_rss_key *rss_key;\n+\tstruct idpf_cmd_info args;\n+\tint len, err;\n+\n+\tlen = sizeof(*rss_key) + sizeof(rss_key->key[0]) *\n+\t\t(vport->rss_key_size - 1);\n+\trss_key = rte_zmalloc(\"rss_key\", len, 0);\n+\tif (rss_key == NULL)\n+\t\treturn -ENOMEM;\n+\n+\trss_key->vport_id = vport->vport_id;\n+\trss_key->key_len = vport->rss_key_size;\n+\trte_memcpy(rss_key->key, vport->rss_key,\n+\t\t   sizeof(rss_key->key[0]) * vport->rss_key_size);\n+\n+\tmemset(&args, 0, sizeof(args));\n+\targs.ops = VIRTCHNL2_OP_SET_RSS_KEY;\n+\targs.in_args = (uint8_t *)rss_key;\n+\targs.in_args_size = len;\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_SET_RSS_KEY\");\n+\n+\trte_free(rss_key);\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_set_rss_lut(struct idpf_vport *vport)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_rss_lut *rss_lut;\n+\tstruct idpf_cmd_info args;\n+\tint len, err;\n+\n+\tlen = sizeof(*rss_lut) + sizeof(rss_lut->lut[0]) *\n+\t\t(vport->rss_lut_size - 1);\n+\trss_lut = rte_zmalloc(\"rss_lut\", len, 0);\n+\tif (rss_lut == NULL)\n+\t\treturn -ENOMEM;\n+\n+\trss_lut->vport_id = vport->vport_id;\n+\trss_lut->lut_entries = vport->rss_lut_size;\n+\trte_memcpy(rss_lut->lut, vport->rss_lut,\n+\t\t   sizeof(rss_lut->lut[0]) * vport->rss_lut_size);\n+\n+\tmemset(&args, 0, sizeof(args));\n+\targs.ops = VIRTCHNL2_OP_SET_RSS_LUT;\n+\targs.in_args = (uint8_t *)rss_lut;\n+\targs.in_args_size = len;\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_SET_RSS_LUT\");\n+\n+\trte_free(rss_lut);\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_set_rss_hash(struct idpf_vport *vport)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_rss_hash rss_hash;\n+\tstruct idpf_cmd_info args;\n+\tint err;\n+\n+\tmemset(&rss_hash, 0, sizeof(rss_hash));\n+\trss_hash.ptype_groups = vport->rss_hf;\n+\trss_hash.vport_id = vport->vport_id;\n+\n+\tmemset(&args, 0, sizeof(args));\n+\targs.ops = VIRTCHNL2_OP_SET_RSS_HASH;\n+\targs.in_args = (uint8_t *)&rss_hash;\n+\targs.in_args_size = sizeof(rss_hash);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of OP_SET_RSS_HASH\");\n+\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, uint16_t nb_rxq, bool map)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_queue_vector_maps *map_info;\n+\tstruct virtchnl2_queue_vector *vecmap;\n+\tstruct idpf_cmd_info args;\n+\tint len, i, err = 0;\n+\n+\tlen = sizeof(struct virtchnl2_queue_vector_maps) +\n+\t\t(nb_rxq - 1) * sizeof(struct virtchnl2_queue_vector);\n+\n+\tmap_info = rte_zmalloc(\"map_info\", len, 0);\n+\tif (map_info == NULL)\n+\t\treturn -ENOMEM;\n+\n+\tmap_info->vport_id = vport->vport_id;\n+\tmap_info->num_qv_maps = nb_rxq;\n+\tfor (i = 0; i < nb_rxq; i++) {\n+\t\tvecmap = &map_info->qv_maps[i];\n+\t\tvecmap->queue_id = vport->qv_map[i].queue_id;\n+\t\tvecmap->vector_id = vport->qv_map[i].vector_id;\n+\t\tvecmap->itr_idx = VIRTCHNL2_ITR_IDX_0;\n+\t\tvecmap->queue_type = VIRTCHNL2_QUEUE_TYPE_RX;\n+\t}\n+\n+\targs.ops = map ? VIRTCHNL2_OP_MAP_QUEUE_VECTOR :\n+\t\tVIRTCHNL2_OP_UNMAP_QUEUE_VECTOR;\n+\targs.in_args = (uint8_t *)map_info;\n+\targs.in_args_size = len;\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_QUEUE_VECTOR\",\n+\t\t\tmap ? \"MAP\" : \"UNMAP\");\n+\n+\trte_free(map_info);\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_alloc_vectors *alloc_vec;\n+\tstruct idpf_cmd_info args;\n+\tint err, len;\n+\n+\tlen = sizeof(struct virtchnl2_alloc_vectors) +\n+\t\t(num_vectors - 1) * sizeof(struct virtchnl2_vector_chunk);\n+\talloc_vec = rte_zmalloc(\"alloc_vec\", len, 0);\n+\tif (alloc_vec == NULL)\n+\t\treturn -ENOMEM;\n+\n+\talloc_vec->num_vectors = num_vectors;\n+\n+\targs.ops = VIRTCHNL2_OP_ALLOC_VECTORS;\n+\targs.in_args = (uint8_t *)alloc_vec;\n+\targs.in_args_size = sizeof(struct virtchnl2_alloc_vectors);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command VIRTCHNL2_OP_ALLOC_VECTORS\");\n+\n+\tif (vport->recv_vectors == NULL) {\n+\t\tvport->recv_vectors = rte_zmalloc(\"recv_vectors\", len, 0);\n+\t\tif (vport->recv_vectors == NULL) {\n+\t\t\trte_free(alloc_vec);\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\t}\n+\n+\trte_memcpy(vport->recv_vectors, args.out_buffer, len);\n+\trte_free(alloc_vec);\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_dealloc_vectors(struct idpf_vport *vport)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_alloc_vectors *alloc_vec;\n+\tstruct virtchnl2_vector_chunks *vcs;\n+\tstruct idpf_cmd_info args;\n+\tint err, len;\n+\n+\talloc_vec = vport->recv_vectors;\n+\tvcs = &alloc_vec->vchunks;\n+\n+\tlen = sizeof(struct virtchnl2_vector_chunks) +\n+\t\t(vcs->num_vchunks - 1) * sizeof(struct virtchnl2_vector_chunk);\n+\n+\targs.ops = VIRTCHNL2_OP_DEALLOC_VECTORS;\n+\targs.in_args = (uint8_t *)vcs;\n+\targs.in_args_size = len;\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command VIRTCHNL2_OP_DEALLOC_VECTORS\");\n+\n+\treturn err;\n+}\n+\n+static int\n+idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid,\n+\t\t\t  uint32_t type, bool on)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_del_ena_dis_queues *queue_select;\n+\tstruct virtchnl2_queue_chunk *queue_chunk;\n+\tstruct idpf_cmd_info args;\n+\tint err, len;\n+\n+\tlen = sizeof(struct virtchnl2_del_ena_dis_queues);\n+\tqueue_select = rte_zmalloc(\"queue_select\", len, 0);\n+\tif (queue_select == NULL)\n+\t\treturn -ENOMEM;\n+\n+\tqueue_chunk = queue_select->chunks.chunks;\n+\tqueue_select->chunks.num_chunks = 1;\n+\tqueue_select->vport_id = vport->vport_id;\n+\n+\tqueue_chunk->type = type;\n+\tqueue_chunk->start_queue_id = qid;\n+\tqueue_chunk->num_queues = 1;\n+\n+\targs.ops = on ? VIRTCHNL2_OP_ENABLE_QUEUES :\n+\t\tVIRTCHNL2_OP_DISABLE_QUEUES;\n+\targs.in_args = (uint8_t *)queue_select;\n+\targs.in_args_size = len;\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_QUEUES\",\n+\t\t\ton ? \"ENABLE\" : \"DISABLE\");\n+\n+\trte_free(queue_select);\n+\treturn err;\n+}\n+\n+int\n+idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,\n+\t\t  bool rx, bool on)\n+{\n+\tuint32_t type;\n+\tint err, queue_id;\n+\n+\t/* switch txq/rxq */\n+\ttype = rx ? VIRTCHNL2_QUEUE_TYPE_RX : VIRTCHNL2_QUEUE_TYPE_TX;\n+\n+\tif (type == VIRTCHNL2_QUEUE_TYPE_RX)\n+\t\tqueue_id = vport->chunks_info.rx_start_qid + qid;\n+\telse\n+\t\tqueue_id = vport->chunks_info.tx_start_qid + qid;\n+\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n+\tif (err != 0)\n+\t\treturn err;\n+\n+\t/* switch tx completion queue */\n+\tif (!rx && vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n+\t\ttype = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION;\n+\t\tqueue_id = vport->chunks_info.tx_compl_start_qid + qid;\n+\t\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n+\t\tif (err != 0)\n+\t\t\treturn err;\n+\t}\n+\n+\t/* switch rx buffer queue */\n+\tif (rx && vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n+\t\ttype = VIRTCHNL2_QUEUE_TYPE_RX_BUFFER;\n+\t\tqueue_id = vport->chunks_info.rx_buf_start_qid + 2 * qid;\n+\t\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n+\t\tif (err != 0)\n+\t\t\treturn err;\n+\t\tqueue_id++;\n+\t\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n+\t\tif (err != 0)\n+\t\t\treturn err;\n+\t}\n+\n+\treturn err;\n+}\n+\n+#define IDPF_RXTX_QUEUE_CHUNKS_NUM\t2\n+int\n+idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_del_ena_dis_queues *queue_select;\n+\tstruct virtchnl2_queue_chunk *queue_chunk;\n+\tuint32_t type;\n+\tstruct idpf_cmd_info args;\n+\tuint16_t num_chunks;\n+\tint err, len;\n+\n+\tnum_chunks = IDPF_RXTX_QUEUE_CHUNKS_NUM;\n+\tif (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)\n+\t\tnum_chunks++;\n+\tif (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)\n+\t\tnum_chunks++;\n+\n+\tlen = sizeof(struct virtchnl2_del_ena_dis_queues) +\n+\t\tsizeof(struct virtchnl2_queue_chunk) * (num_chunks - 1);\n+\tqueue_select = rte_zmalloc(\"queue_select\", len, 0);\n+\tif (queue_select == NULL)\n+\t\treturn -ENOMEM;\n+\n+\tqueue_chunk = queue_select->chunks.chunks;\n+\tqueue_select->chunks.num_chunks = num_chunks;\n+\tqueue_select->vport_id = vport->vport_id;\n+\n+\ttype = VIRTCHNL_QUEUE_TYPE_RX;\n+\tqueue_chunk[type].type = type;\n+\tqueue_chunk[type].start_queue_id = vport->chunks_info.rx_start_qid;\n+\tqueue_chunk[type].num_queues = vport->num_rx_q;\n+\n+\ttype = VIRTCHNL2_QUEUE_TYPE_TX;\n+\tqueue_chunk[type].type = type;\n+\tqueue_chunk[type].start_queue_id = vport->chunks_info.tx_start_qid;\n+\tqueue_chunk[type].num_queues = vport->num_tx_q;\n+\n+\tif (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n+\t\ttype = VIRTCHNL2_QUEUE_TYPE_RX_BUFFER;\n+\t\tqueue_chunk[type].type = type;\n+\t\tqueue_chunk[type].start_queue_id =\n+\t\t\tvport->chunks_info.rx_buf_start_qid;\n+\t\tqueue_chunk[type].num_queues = vport->num_rx_bufq;\n+\t}\n+\n+\tif (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n+\t\ttype = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION;\n+\t\tqueue_chunk[type].type = type;\n+\t\tqueue_chunk[type].start_queue_id =\n+\t\t\tvport->chunks_info.tx_compl_start_qid;\n+\t\tqueue_chunk[type].num_queues = vport->num_tx_complq;\n+\t}\n+\n+\targs.ops = enable ? VIRTCHNL2_OP_ENABLE_QUEUES :\n+\t\tVIRTCHNL2_OP_DISABLE_QUEUES;\n+\targs.in_args = (uint8_t *)queue_select;\n+\targs.in_args_size = len;\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_QUEUES\",\n+\t\t\tenable ? \"ENABLE\" : \"DISABLE\");\n+\n+\trte_free(queue_select);\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable)\n+{\n+\tstruct idpf_adapter *adapter = vport->adapter;\n+\tstruct virtchnl2_vport vc_vport;\n+\tstruct idpf_cmd_info args;\n+\tint err;\n+\n+\tvc_vport.vport_id = vport->vport_id;\n+\targs.ops = enable ? VIRTCHNL2_OP_ENABLE_VPORT :\n+\t\tVIRTCHNL2_OP_DISABLE_VPORT;\n+\targs.in_args = (uint8_t *)&vc_vport;\n+\targs.in_args_size = sizeof(vc_vport);\n+\targs.out_buffer = adapter->mbx_resp;\n+\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0) {\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_VPORT\",\n+\t\t\tenable ? \"ENABLE\" : \"DISABLE\");\n+\t}\n+\n+\treturn err;\n+}\n+\n+int\n+idpf_vc_query_ptype_info(struct idpf_adapter *adapter)\n+{\n+\tstruct virtchnl2_get_ptype_info *ptype_info;\n+\tstruct idpf_cmd_info args;\n+\tint len, err;\n+\n+\tlen = sizeof(struct virtchnl2_get_ptype_info);\n+\tptype_info = rte_zmalloc(\"ptype_info\", len, 0);\n+\tif (ptype_info == NULL)\n+\t\treturn -ENOMEM;\n+\n+\tptype_info->start_ptype_id = 0;\n+\tptype_info->num_ptypes = IDPF_MAX_PKT_TYPE;\n+\targs.ops = VIRTCHNL2_OP_GET_PTYPE_INFO;\n+\targs.in_args = (uint8_t *)ptype_info;\n+\targs.in_args_size = len;\n+\n+\terr = idpf_execute_vc_cmd(adapter, &args);\n+\tif (err != 0)\n+\t\tDRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_GET_PTYPE_INFO\");\n+\n+\trte_free(ptype_info);\n+\treturn err;\n+}\ndiff --git a/drivers/common/idpf/idpf_common_virtchnl.h b/drivers/common/idpf/idpf_common_virtchnl.h\nnew file mode 100644\nindex 0000000000..bbc66d63c4\n--- /dev/null\n+++ b/drivers/common/idpf/idpf_common_virtchnl.h\n@@ -0,0 +1,48 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2022 Intel Corporation\n+ */\n+\n+#ifndef _IDPF_COMMON_VIRTCHNL_H_\n+#define _IDPF_COMMON_VIRTCHNL_H_\n+\n+#include <idpf_common_device.h>\n+\n+__rte_internal\n+int idpf_vc_check_api_version(struct idpf_adapter *adapter);\n+__rte_internal\n+int idpf_vc_get_caps(struct idpf_adapter *adapter);\n+__rte_internal\n+int idpf_vc_create_vport(struct idpf_vport *vport,\n+\t\t\t struct virtchnl2_create_vport *vport_info);\n+__rte_internal\n+int idpf_vc_destroy_vport(struct idpf_vport *vport);\n+__rte_internal\n+int idpf_vc_set_rss_key(struct idpf_vport *vport);\n+__rte_internal\n+int idpf_vc_set_rss_lut(struct idpf_vport *vport);\n+__rte_internal\n+int idpf_vc_set_rss_hash(struct idpf_vport *vport);\n+__rte_internal\n+int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,\n+\t\t      bool rx, bool on);\n+__rte_internal\n+int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);\n+__rte_internal\n+int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);\n+__rte_internal\n+int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport,\n+\t\t\t\t uint16_t nb_rxq, bool map);\n+__rte_internal\n+int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);\n+__rte_internal\n+int idpf_vc_dealloc_vectors(struct idpf_vport *vport);\n+__rte_internal\n+int idpf_vc_query_ptype_info(struct idpf_adapter *adapter);\n+__rte_internal\n+int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops,\n+\t\t      uint16_t buf_len, uint8_t *buf);\n+__rte_internal\n+int idpf_execute_vc_cmd(struct idpf_adapter *adapter,\n+\t\t\tstruct idpf_cmd_info *args);\n+\n+#endif /* _IDPF_COMMON_VIRTCHNL_H_ */\ndiff --git a/drivers/common/idpf/meson.build b/drivers/common/idpf/meson.build\nindex 77d997b4a7..d1578641ba 100644\n--- a/drivers/common/idpf/meson.build\n+++ b/drivers/common/idpf/meson.build\n@@ -1,4 +1,9 @@\n # SPDX-License-Identifier: BSD-3-Clause\n # Copyright(c) 2022 Intel Corporation\n \n+sources = files(\n+    'idpf_common_device.c',\n+    'idpf_common_virtchnl.c',\n+)\n+\n subdir('base')\ndiff --git a/drivers/common/idpf/version.map b/drivers/common/idpf/version.map\nindex bfb246c752..3fa367aea4 100644\n--- a/drivers/common/idpf/version.map\n+++ b/drivers/common/idpf/version.map\n@@ -7,6 +7,22 @@ INTERNAL {\n \tidpf_ctlq_recv;\n \tidpf_ctlq_send;\n \tidpf_ctlq_post_rx_buffs;\n+\tidpf_vc_check_api_version;\n+\tidpf_vc_get_caps;\n+\tidpf_vc_create_vport;\n+\tidpf_vc_destroy_vport;\n+\tidpf_vc_set_rss_key;\n+\tidpf_vc_set_rss_lut;\n+\tidpf_vc_set_rss_hash;\n+\tidpf_switch_queue;\n+\tidpf_vc_ena_dis_queues;\n+\tidpf_vc_ena_dis_vport;\n+\tidpf_vc_config_irq_map_unmap;\n+\tidpf_vc_alloc_vectors;\n+\tidpf_vc_dealloc_vectors;\n+\tidpf_vc_query_ptype_info;\n+\tidpf_read_one_msg;\n+\tidpf_execute_vc_cmd;\n \n \tlocal: *;\n };\ndiff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c\nindex ad20db79f8..bd74fb57b4 100644\n--- a/drivers/net/idpf/idpf_ethdev.c\n+++ b/drivers/net/idpf/idpf_ethdev.c\n@@ -937,13 +937,6 @@ idpf_adapter_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adapt\n \t\tgoto err_api;\n \t}\n \n-\tadapter->max_rxq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -\n-\t\t\t\tsizeof(struct virtchnl2_config_rx_queues)) /\n-\t\t\t\tsizeof(struct virtchnl2_rxq_info);\n-\tadapter->max_txq_per_msg = (IDPF_DFLT_MBX_BUF_SIZE -\n-\t\t\t\tsizeof(struct virtchnl2_config_tx_queues)) /\n-\t\t\t\tsizeof(struct virtchnl2_txq_info);\n-\n \tadapter->cur_vports = 0;\n \tadapter->cur_vport_nb = 0;\n \n@@ -1070,7 +1063,7 @@ static const struct rte_pci_id pci_id_idpf_map[] = {\n \t{ .vendor_id = 0, /* sentinel */ },\n };\n \n-struct idpf_adapter_ext *\n+static struct idpf_adapter_ext *\n idpf_find_adapter_ext(struct rte_pci_device *pci_dev)\n {\n \tstruct idpf_adapter_ext *adapter;\ndiff --git a/drivers/net/idpf/idpf_ethdev.h b/drivers/net/idpf/idpf_ethdev.h\nindex aedd2278fe..10b1542ba4 100644\n--- a/drivers/net/idpf/idpf_ethdev.h\n+++ b/drivers/net/idpf/idpf_ethdev.h\n@@ -16,6 +16,7 @@\n #include \"idpf_logs.h\"\n \n #include <idpf_common_device.h>\n+#include <idpf_common_virtchnl.h>\n #include <base/idpf_prototype.h>\n #include <base/virtchnl2.h>\n \n@@ -31,8 +32,6 @@\n #define IDPF_RX_BUFQ_PER_GRP\t2\n \n #define IDPF_CTLQ_ID\t\t-1\n-#define IDPF_CTLQ_LEN\t\t64\n-#define IDPF_DFLT_MBX_BUF_SIZE\t4096\n \n #define IDPF_DFLT_Q_VEC_NUM\t1\n #define IDPF_DFLT_INTERVAL\t16\n@@ -43,8 +42,6 @@\n \n #define IDPF_NUM_MACADDR_MAX\t64\n \n-#define IDPF_MAX_PKT_TYPE\t1024\n-\n #define IDPF_VLAN_TAG_SIZE\t4\n #define IDPF_ETH_OVERHEAD \\\n \t(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IDPF_VLAN_TAG_SIZE * 2)\n@@ -65,14 +62,6 @@\n \n #define IDPF_ADAPTER_NAME_LEN\t(PCI_PRI_STR_SIZE + 1)\n \n-/* Message type read in virtual channel from PF */\n-enum idpf_vc_result {\n-\tIDPF_MSG_ERR = -1, /* Meet error when accessing admin queue */\n-\tIDPF_MSG_NON,      /* Read nothing from admin queue */\n-\tIDPF_MSG_SYS,      /* Read system msg from admin queue */\n-\tIDPF_MSG_CMD,      /* Read async command result */\n-};\n-\n struct idpf_vport_param {\n \tstruct idpf_adapter_ext *adapter;\n \tuint16_t devarg_id; /* arg id from user */\n@@ -102,10 +91,6 @@ struct idpf_adapter_ext {\n \n \tuint16_t used_vecs_num;\n \n-\t/* Max config queue number per VC message */\n-\tuint32_t max_rxq_per_msg;\n-\tuint32_t max_txq_per_msg;\n-\n \tuint32_t ptype_tbl[IDPF_MAX_PKT_TYPE] __rte_cache_min_aligned;\n \n \tbool rx_vec_allowed;\n@@ -124,74 +109,6 @@ TAILQ_HEAD(idpf_adapter_list, idpf_adapter_ext);\n #define IDPF_ADAPTER_TO_EXT(p)\t\t\t\t\t\\\n \tcontainer_of((p), struct idpf_adapter_ext, base)\n \n-/* structure used for sending and checking response of virtchnl ops */\n-struct idpf_cmd_info {\n-\tuint32_t ops;\n-\tuint8_t *in_args;       /* buffer for sending */\n-\tuint32_t in_args_size;  /* buffer size for sending */\n-\tuint8_t *out_buffer;    /* buffer for response */\n-\tuint32_t out_size;      /* buffer size for response */\n-};\n-\n-/* notify current command done. Only call in case execute\n- * _atomic_set_cmd successfully.\n- */\n-static inline void\n-notify_cmd(struct idpf_adapter *adapter, int msg_ret)\n-{\n-\tadapter->cmd_retval = msg_ret;\n-\t/* Return value may be checked in anither thread, need to ensure the coherence. */\n-\trte_wmb();\n-\tadapter->pend_cmd = VIRTCHNL2_OP_UNKNOWN;\n-}\n-\n-/* clear current command. Only call in case execute\n- * _atomic_set_cmd successfully.\n- */\n-static inline void\n-clear_cmd(struct idpf_adapter *adapter)\n-{\n-\t/* Return value may be checked in anither thread, need to ensure the coherence. */\n-\trte_wmb();\n-\tadapter->pend_cmd = VIRTCHNL2_OP_UNKNOWN;\n-\tadapter->cmd_retval = VIRTCHNL_STATUS_SUCCESS;\n-}\n-\n-/* Check there is pending cmd in execution. If none, set new command. */\n-static inline bool\n-atomic_set_cmd(struct idpf_adapter *adapter, uint32_t ops)\n-{\n-\tuint32_t op_unk = VIRTCHNL2_OP_UNKNOWN;\n-\tbool ret = __atomic_compare_exchange(&adapter->pend_cmd, &op_unk, &ops,\n-\t\t\t\t\t    0, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);\n-\n-\tif (!ret)\n-\t\tPMD_DRV_LOG(ERR, \"There is incomplete cmd %d\", adapter->pend_cmd);\n-\n-\treturn !ret;\n-}\n-\n-struct idpf_adapter_ext *idpf_find_adapter_ext(struct rte_pci_device *pci_dev);\n-void idpf_handle_virtchnl_msg(struct rte_eth_dev *dev);\n-int idpf_vc_check_api_version(struct idpf_adapter *adapter);\n int idpf_get_pkt_type(struct idpf_adapter_ext *adapter);\n-int idpf_vc_get_caps(struct idpf_adapter *adapter);\n-int idpf_vc_create_vport(struct idpf_vport *vport,\n-\t\t\t struct virtchnl2_create_vport *vport_info);\n-int idpf_vc_destroy_vport(struct idpf_vport *vport);\n-int idpf_vc_set_rss_key(struct idpf_vport *vport);\n-int idpf_vc_set_rss_lut(struct idpf_vport *vport);\n-int idpf_vc_set_rss_hash(struct idpf_vport *vport);\n-int idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,\n-\t\t      bool rx, bool on);\n-int idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable);\n-int idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable);\n-int idpf_vc_config_irq_map_unmap(struct idpf_vport *vport,\n-\t\t\t\t uint16_t nb_rxq, bool map);\n-int idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors);\n-int idpf_vc_dealloc_vectors(struct idpf_vport *vport);\n-int idpf_vc_query_ptype_info(struct idpf_adapter *adapter);\n-int idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops,\n-\t\t      uint16_t buf_len, uint8_t *buf);\n \n #endif /* _IDPF_ETHDEV_H_ */\ndiff --git a/drivers/net/idpf/idpf_vchnl.c b/drivers/net/idpf/idpf_vchnl.c\nindex 633d3295d3..576b797973 100644\n--- a/drivers/net/idpf/idpf_vchnl.c\n+++ b/drivers/net/idpf/idpf_vchnl.c\n@@ -23,293 +23,6 @@\n #include \"idpf_ethdev.h\"\n #include \"idpf_rxtx.h\"\n \n-static int\n-idpf_vc_clean(struct idpf_adapter *adapter)\n-{\n-\tstruct idpf_ctlq_msg *q_msg[IDPF_CTLQ_LEN];\n-\tuint16_t num_q_msg = IDPF_CTLQ_LEN;\n-\tstruct idpf_dma_mem *dma_mem;\n-\tint err;\n-\tuint32_t i;\n-\n-\tfor (i = 0; i < 10; i++) {\n-\t\terr = idpf_ctlq_clean_sq(adapter->hw.asq, &num_q_msg, q_msg);\n-\t\tmsleep(20);\n-\t\tif (num_q_msg > 0)\n-\t\t\tbreak;\n-\t}\n-\tif (err != 0)\n-\t\treturn err;\n-\n-\t/* Empty queue is not an error */\n-\tfor (i = 0; i < num_q_msg; i++) {\n-\t\tdma_mem = q_msg[i]->ctx.indirect.payload;\n-\t\tif (dma_mem != NULL) {\n-\t\t\tidpf_free_dma_mem(&adapter->hw, dma_mem);\n-\t\t\trte_free(dma_mem);\n-\t\t}\n-\t\trte_free(q_msg[i]);\n-\t}\n-\n-\treturn 0;\n-}\n-\n-static int\n-idpf_send_vc_msg(struct idpf_adapter *adapter, uint32_t op,\n-\t\t uint16_t msg_size, uint8_t *msg)\n-{\n-\tstruct idpf_ctlq_msg *ctlq_msg;\n-\tstruct idpf_dma_mem *dma_mem;\n-\tint err;\n-\n-\terr = idpf_vc_clean(adapter);\n-\tif (err != 0)\n-\t\tgoto err;\n-\n-\tctlq_msg = rte_zmalloc(NULL, sizeof(struct idpf_ctlq_msg), 0);\n-\tif (ctlq_msg == NULL) {\n-\t\terr = -ENOMEM;\n-\t\tgoto err;\n-\t}\n-\n-\tdma_mem = rte_zmalloc(NULL, sizeof(struct idpf_dma_mem), 0);\n-\tif (dma_mem == NULL) {\n-\t\terr = -ENOMEM;\n-\t\tgoto dma_mem_error;\n-\t}\n-\n-\tdma_mem->size = IDPF_DFLT_MBX_BUF_SIZE;\n-\tidpf_alloc_dma_mem(&adapter->hw, dma_mem, dma_mem->size);\n-\tif (dma_mem->va == NULL) {\n-\t\terr = -ENOMEM;\n-\t\tgoto dma_alloc_error;\n-\t}\n-\n-\tmemcpy(dma_mem->va, msg, msg_size);\n-\n-\tctlq_msg->opcode = idpf_mbq_opc_send_msg_to_pf;\n-\tctlq_msg->func_id = 0;\n-\tctlq_msg->data_len = msg_size;\n-\tctlq_msg->cookie.mbx.chnl_opcode = op;\n-\tctlq_msg->cookie.mbx.chnl_retval = VIRTCHNL_STATUS_SUCCESS;\n-\tctlq_msg->ctx.indirect.payload = dma_mem;\n-\n-\terr = idpf_ctlq_send(&adapter->hw, adapter->hw.asq, 1, ctlq_msg);\n-\tif (err != 0)\n-\t\tgoto send_error;\n-\n-\treturn 0;\n-\n-send_error:\n-\tidpf_free_dma_mem(&adapter->hw, dma_mem);\n-dma_alloc_error:\n-\trte_free(dma_mem);\n-dma_mem_error:\n-\trte_free(ctlq_msg);\n-err:\n-\treturn err;\n-}\n-\n-static enum idpf_vc_result\n-idpf_read_msg_from_cp(struct idpf_adapter *adapter, uint16_t buf_len,\n-\t\t      uint8_t *buf)\n-{\n-\tstruct idpf_hw *hw = &adapter->hw;\n-\tstruct idpf_ctlq_msg ctlq_msg;\n-\tstruct idpf_dma_mem *dma_mem = NULL;\n-\tenum idpf_vc_result result = IDPF_MSG_NON;\n-\tuint32_t opcode;\n-\tuint16_t pending = 1;\n-\tint ret;\n-\n-\tret = idpf_ctlq_recv(hw->arq, &pending, &ctlq_msg);\n-\tif (ret != 0) {\n-\t\tPMD_DRV_LOG(DEBUG, \"Can't read msg from AQ\");\n-\t\tif (ret != -ENOMSG)\n-\t\t\tresult = IDPF_MSG_ERR;\n-\t\treturn result;\n-\t}\n-\n-\trte_memcpy(buf, ctlq_msg.ctx.indirect.payload->va, buf_len);\n-\n-\topcode = rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_opcode);\n-\tadapter->cmd_retval =\n-\t\t(enum virtchnl_status_code)rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_retval);\n-\n-\tPMD_DRV_LOG(DEBUG, \"CQ from CP carries opcode %u, retval %d\",\n-\t\t    opcode, adapter->cmd_retval);\n-\n-\tif (opcode == VIRTCHNL2_OP_EVENT) {\n-\t\tstruct virtchnl2_event *ve =\n-\t\t\t(struct virtchnl2_event *)ctlq_msg.ctx.indirect.payload->va;\n-\n-\t\tresult = IDPF_MSG_SYS;\n-\t\tswitch (ve->event) {\n-\t\tcase VIRTCHNL2_EVENT_LINK_CHANGE:\n-\t\t\t/* TBD */\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tPMD_DRV_LOG(ERR, \"%s: Unknown event %d from CP\",\n-\t\t\t\t    __func__, ve->event);\n-\t\t\tbreak;\n-\t\t}\n-\t} else {\n-\t\t/* async reply msg on command issued by pf previously */\n-\t\tresult = IDPF_MSG_CMD;\n-\t\tif (opcode != adapter->pend_cmd) {\n-\t\t\tPMD_DRV_LOG(WARNING, \"command mismatch, expect %u, get %u\",\n-\t\t\t\t    adapter->pend_cmd, opcode);\n-\t\t\tresult = IDPF_MSG_ERR;\n-\t\t}\n-\t}\n-\n-\tif (ctlq_msg.data_len != 0)\n-\t\tdma_mem = ctlq_msg.ctx.indirect.payload;\n-\telse\n-\t\tpending = 0;\n-\n-\tret = idpf_ctlq_post_rx_buffs(hw, hw->arq, &pending, &dma_mem);\n-\tif (ret != 0 && dma_mem != NULL)\n-\t\tidpf_free_dma_mem(hw, dma_mem);\n-\n-\treturn result;\n-}\n-\n-#define MAX_TRY_TIMES 200\n-#define ASQ_DELAY_MS  10\n-\n-int\n-idpf_read_one_msg(struct idpf_adapter *adapter, uint32_t ops, uint16_t buf_len,\n-\t\t  uint8_t *buf)\n-{\n-\tint err = 0;\n-\tint i = 0;\n-\tint ret;\n-\n-\tdo {\n-\t\tret = idpf_read_msg_from_cp(adapter, buf_len, buf);\n-\t\tif (ret == IDPF_MSG_CMD)\n-\t\t\tbreak;\n-\t\trte_delay_ms(ASQ_DELAY_MS);\n-\t} while (i++ < MAX_TRY_TIMES);\n-\tif (i >= MAX_TRY_TIMES ||\n-\t    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {\n-\t\terr = -EBUSY;\n-\t\tPMD_DRV_LOG(ERR, \"No response or return failure (%d) for cmd %d\",\n-\t\t\t    adapter->cmd_retval, ops);\n-\t}\n-\n-\treturn err;\n-}\n-\n-static int\n-idpf_execute_vc_cmd(struct idpf_adapter *adapter, struct idpf_cmd_info *args)\n-{\n-\tint err = 0;\n-\tint i = 0;\n-\tint ret;\n-\n-\tif (atomic_set_cmd(adapter, args->ops))\n-\t\treturn -EINVAL;\n-\n-\tret = idpf_send_vc_msg(adapter, args->ops, args->in_args_size, args->in_args);\n-\tif (ret != 0) {\n-\t\tPMD_DRV_LOG(ERR, \"fail to send cmd %d\", args->ops);\n-\t\tclear_cmd(adapter);\n-\t\treturn ret;\n-\t}\n-\n-\tswitch (args->ops) {\n-\tcase VIRTCHNL_OP_VERSION:\n-\tcase VIRTCHNL2_OP_GET_CAPS:\n-\tcase VIRTCHNL2_OP_CREATE_VPORT:\n-\tcase VIRTCHNL2_OP_DESTROY_VPORT:\n-\tcase VIRTCHNL2_OP_SET_RSS_KEY:\n-\tcase VIRTCHNL2_OP_SET_RSS_LUT:\n-\tcase VIRTCHNL2_OP_SET_RSS_HASH:\n-\tcase VIRTCHNL2_OP_CONFIG_RX_QUEUES:\n-\tcase VIRTCHNL2_OP_CONFIG_TX_QUEUES:\n-\tcase VIRTCHNL2_OP_ENABLE_QUEUES:\n-\tcase VIRTCHNL2_OP_DISABLE_QUEUES:\n-\tcase VIRTCHNL2_OP_ENABLE_VPORT:\n-\tcase VIRTCHNL2_OP_DISABLE_VPORT:\n-\tcase VIRTCHNL2_OP_MAP_QUEUE_VECTOR:\n-\tcase VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR:\n-\tcase VIRTCHNL2_OP_ALLOC_VECTORS:\n-\tcase VIRTCHNL2_OP_DEALLOC_VECTORS:\n-\t\t/* for init virtchnl ops, need to poll the response */\n-\t\terr = idpf_read_one_msg(adapter, args->ops, args->out_size, args->out_buffer);\n-\t\tclear_cmd(adapter);\n-\t\tbreak;\n-\tcase VIRTCHNL2_OP_GET_PTYPE_INFO:\n-\t\t/* for multuple response message,\n-\t\t * do not handle the response here.\n-\t\t */\n-\t\tbreak;\n-\tdefault:\n-\t\t/* For other virtchnl ops in running time,\n-\t\t * wait for the cmd done flag.\n-\t\t */\n-\t\tdo {\n-\t\t\tif (adapter->pend_cmd == VIRTCHNL_OP_UNKNOWN)\n-\t\t\t\tbreak;\n-\t\t\trte_delay_ms(ASQ_DELAY_MS);\n-\t\t\t/* If don't read msg or read sys event, continue */\n-\t\t} while (i++ < MAX_TRY_TIMES);\n-\t\t/* If there's no response is received, clear command */\n-\t\tif (i >= MAX_TRY_TIMES  ||\n-\t\t    adapter->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {\n-\t\t\terr = -EBUSY;\n-\t\t\tPMD_DRV_LOG(ERR, \"No response or return failure (%d) for cmd %d\",\n-\t\t\t\t    adapter->cmd_retval, args->ops);\n-\t\t\tclear_cmd(adapter);\n-\t\t}\n-\t\tbreak;\n-\t}\n-\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_check_api_version(struct idpf_adapter *adapter)\n-{\n-\tstruct virtchnl2_version_info version, *pver;\n-\tstruct idpf_cmd_info args;\n-\tint err;\n-\n-\tmemset(&version, 0, sizeof(struct virtchnl_version_info));\n-\tversion.major = VIRTCHNL2_VERSION_MAJOR_2;\n-\tversion.minor = VIRTCHNL2_VERSION_MINOR_0;\n-\n-\targs.ops = VIRTCHNL_OP_VERSION;\n-\targs.in_args = (uint8_t *)&version;\n-\targs.in_args_size = sizeof(version);\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0) {\n-\t\tPMD_DRV_LOG(ERR,\n-\t\t\t    \"Failed to execute command of VIRTCHNL_OP_VERSION\");\n-\t\treturn err;\n-\t}\n-\n-\tpver = (struct virtchnl2_version_info *)args.out_buffer;\n-\tadapter->virtchnl_version = *pver;\n-\n-\tif (adapter->virtchnl_version.major != VIRTCHNL2_VERSION_MAJOR_2 ||\n-\t    adapter->virtchnl_version.minor != VIRTCHNL2_VERSION_MINOR_0) {\n-\t\tPMD_INIT_LOG(ERR, \"VIRTCHNL API version mismatch:(%u.%u)-(%u.%u)\",\n-\t\t\t     adapter->virtchnl_version.major,\n-\t\t\t     adapter->virtchnl_version.minor,\n-\t\t\t     VIRTCHNL2_VERSION_MAJOR_2,\n-\t\t\t     VIRTCHNL2_VERSION_MINOR_0);\n-\t\treturn -EINVAL;\n-\t}\n-\n-\treturn 0;\n-}\n-\n int __rte_cold\n idpf_get_pkt_type(struct idpf_adapter_ext *adapter)\n {\n@@ -333,7 +46,7 @@ idpf_get_pkt_type(struct idpf_adapter_ext *adapter)\n \n \twhile (ptype_recvd < IDPF_MAX_PKT_TYPE) {\n \t\tret = idpf_read_one_msg(base, VIRTCHNL2_OP_GET_PTYPE_INFO,\n-\t\t\t\t\tIDPF_DFLT_MBX_BUF_SIZE, (u8 *)ptype_info);\n+\t\t\t\t\tIDPF_DFLT_MBX_BUF_SIZE, (uint8_t *)ptype_info);\n \t\tif (ret != 0) {\n \t\t\tPMD_DRV_LOG(ERR, \"Fail to get packet type information\");\n \t\t\tgoto free_ptype_info;\n@@ -349,7 +62,7 @@ idpf_get_pkt_type(struct idpf_adapter_ext *adapter)\n \t\t\tuint32_t proto_hdr = 0;\n \n \t\t\tptype = (struct virtchnl2_ptype *)\n-\t\t\t\t\t((u8 *)ptype_info + ptype_offset);\n+\t\t\t\t\t((uint8_t *)ptype_info + ptype_offset);\n \t\t\tptype_offset += IDPF_GET_PTYPE_SIZE(ptype);\n \t\t\tif (ptype_offset > IDPF_DFLT_MBX_BUF_SIZE) {\n \t\t\t\tret = -EINVAL;\n@@ -523,223 +236,6 @@ idpf_get_pkt_type(struct idpf_adapter_ext *adapter)\n \treturn ret;\n }\n \n-int\n-idpf_vc_get_caps(struct idpf_adapter *adapter)\n-{\n-\tstruct virtchnl2_get_capabilities caps_msg;\n-\tstruct idpf_cmd_info args;\n-\tint err;\n-\n-\tmemset(&caps_msg, 0, sizeof(struct virtchnl2_get_capabilities));\n-\n-\tcaps_msg.csum_caps =\n-\t\tVIRTCHNL2_CAP_TX_CSUM_L3_IPV4          |\n-\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP      |\n-\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP      |\n-\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP     |\n-\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP      |\n-\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP      |\n-\t\tVIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP     |\n-\t\tVIRTCHNL2_CAP_TX_CSUM_GENERIC          |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_L3_IPV4          |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP      |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP      |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP     |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP      |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP      |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP     |\n-\t\tVIRTCHNL2_CAP_RX_CSUM_GENERIC;\n-\n-\tcaps_msg.rss_caps =\n-\t\tVIRTCHNL2_CAP_RSS_IPV4_TCP             |\n-\t\tVIRTCHNL2_CAP_RSS_IPV4_UDP             |\n-\t\tVIRTCHNL2_CAP_RSS_IPV4_SCTP            |\n-\t\tVIRTCHNL2_CAP_RSS_IPV4_OTHER           |\n-\t\tVIRTCHNL2_CAP_RSS_IPV6_TCP             |\n-\t\tVIRTCHNL2_CAP_RSS_IPV6_UDP             |\n-\t\tVIRTCHNL2_CAP_RSS_IPV6_SCTP            |\n-\t\tVIRTCHNL2_CAP_RSS_IPV6_OTHER           |\n-\t\tVIRTCHNL2_CAP_RSS_IPV4_AH              |\n-\t\tVIRTCHNL2_CAP_RSS_IPV4_ESP             |\n-\t\tVIRTCHNL2_CAP_RSS_IPV4_AH_ESP          |\n-\t\tVIRTCHNL2_CAP_RSS_IPV6_AH              |\n-\t\tVIRTCHNL2_CAP_RSS_IPV6_ESP             |\n-\t\tVIRTCHNL2_CAP_RSS_IPV6_AH_ESP;\n-\n-\tcaps_msg.other_caps = VIRTCHNL2_CAP_WB_ON_ITR;\n-\n-\targs.ops = VIRTCHNL2_OP_GET_CAPS;\n-\targs.in_args = (uint8_t *)&caps_msg;\n-\targs.in_args_size = sizeof(caps_msg);\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0) {\n-\t\tPMD_DRV_LOG(ERR,\n-\t\t\t    \"Failed to execute command of VIRTCHNL2_OP_GET_CAPS\");\n-\t\treturn err;\n-\t}\n-\n-\trte_memcpy(&adapter->caps, args.out_buffer, sizeof(caps_msg));\n-\n-\treturn 0;\n-}\n-\n-int\n-idpf_vc_create_vport(struct idpf_vport *vport,\n-\t\t     struct virtchnl2_create_vport *vport_req_info)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_create_vport vport_msg;\n-\tstruct idpf_cmd_info args;\n-\tint err = -1;\n-\n-\tmemset(&vport_msg, 0, sizeof(struct virtchnl2_create_vport));\n-\tvport_msg.vport_type = vport_req_info->vport_type;\n-\tvport_msg.txq_model = vport_req_info->txq_model;\n-\tvport_msg.rxq_model = vport_req_info->rxq_model;\n-\tvport_msg.num_tx_q = vport_req_info->num_tx_q;\n-\tvport_msg.num_tx_complq = vport_req_info->num_tx_complq;\n-\tvport_msg.num_rx_q = vport_req_info->num_rx_q;\n-\tvport_msg.num_rx_bufq = vport_req_info->num_rx_bufq;\n-\n-\tmemset(&args, 0, sizeof(args));\n-\targs.ops = VIRTCHNL2_OP_CREATE_VPORT;\n-\targs.in_args = (uint8_t *)&vport_msg;\n-\targs.in_args_size = sizeof(vport_msg);\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0) {\n-\t\tPMD_DRV_LOG(ERR,\n-\t\t\t    \"Failed to execute command of VIRTCHNL2_OP_CREATE_VPORT\");\n-\t\treturn err;\n-\t}\n-\n-\trte_memcpy(vport->vport_info, args.out_buffer, IDPF_DFLT_MBX_BUF_SIZE);\n-\treturn 0;\n-}\n-\n-int\n-idpf_vc_destroy_vport(struct idpf_vport *vport)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_vport vc_vport;\n-\tstruct idpf_cmd_info args;\n-\tint err;\n-\n-\tvc_vport.vport_id = vport->vport_id;\n-\n-\tmemset(&args, 0, sizeof(args));\n-\targs.ops = VIRTCHNL2_OP_DESTROY_VPORT;\n-\targs.in_args = (uint8_t *)&vc_vport;\n-\targs.in_args_size = sizeof(vc_vport);\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_DESTROY_VPORT\");\n-\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_set_rss_key(struct idpf_vport *vport)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_rss_key *rss_key;\n-\tstruct idpf_cmd_info args;\n-\tint len, err;\n-\n-\tlen = sizeof(*rss_key) + sizeof(rss_key->key[0]) *\n-\t\t(vport->rss_key_size - 1);\n-\trss_key = rte_zmalloc(\"rss_key\", len, 0);\n-\tif (rss_key == NULL)\n-\t\treturn -ENOMEM;\n-\n-\trss_key->vport_id = vport->vport_id;\n-\trss_key->key_len = vport->rss_key_size;\n-\trte_memcpy(rss_key->key, vport->rss_key,\n-\t\t   sizeof(rss_key->key[0]) * vport->rss_key_size);\n-\n-\tmemset(&args, 0, sizeof(args));\n-\targs.ops = VIRTCHNL2_OP_SET_RSS_KEY;\n-\targs.in_args = (uint8_t *)rss_key;\n-\targs.in_args_size = len;\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_SET_RSS_KEY\");\n-\n-\trte_free(rss_key);\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_set_rss_lut(struct idpf_vport *vport)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_rss_lut *rss_lut;\n-\tstruct idpf_cmd_info args;\n-\tint len, err;\n-\n-\tlen = sizeof(*rss_lut) + sizeof(rss_lut->lut[0]) *\n-\t\t(vport->rss_lut_size - 1);\n-\trss_lut = rte_zmalloc(\"rss_lut\", len, 0);\n-\tif (rss_lut == NULL)\n-\t\treturn -ENOMEM;\n-\n-\trss_lut->vport_id = vport->vport_id;\n-\trss_lut->lut_entries = vport->rss_lut_size;\n-\trte_memcpy(rss_lut->lut, vport->rss_lut,\n-\t\t   sizeof(rss_lut->lut[0]) * vport->rss_lut_size);\n-\n-\tmemset(&args, 0, sizeof(args));\n-\targs.ops = VIRTCHNL2_OP_SET_RSS_LUT;\n-\targs.in_args = (uint8_t *)rss_lut;\n-\targs.in_args_size = len;\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_SET_RSS_LUT\");\n-\n-\trte_free(rss_lut);\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_set_rss_hash(struct idpf_vport *vport)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_rss_hash rss_hash;\n-\tstruct idpf_cmd_info args;\n-\tint err;\n-\n-\tmemset(&rss_hash, 0, sizeof(rss_hash));\n-\trss_hash.ptype_groups = vport->rss_hf;\n-\trss_hash.vport_id = vport->vport_id;\n-\n-\tmemset(&args, 0, sizeof(args));\n-\targs.ops = VIRTCHNL2_OP_SET_RSS_HASH;\n-\targs.in_args = (uint8_t *)&rss_hash;\n-\targs.in_args_size = sizeof(rss_hash);\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of OP_SET_RSS_HASH\");\n-\n-\treturn err;\n-}\n-\n #define IDPF_RX_BUF_STRIDE\t\t64\n int\n idpf_vc_config_rxq(struct idpf_vport *vport, struct idpf_rx_queue *rxq)\n@@ -899,310 +395,3 @@ idpf_vc_config_txq(struct idpf_vport *vport, struct idpf_tx_queue *txq)\n \n \treturn err;\n }\n-\n-int\n-idpf_vc_config_irq_map_unmap(struct idpf_vport *vport, uint16_t nb_rxq, bool map)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_queue_vector_maps *map_info;\n-\tstruct virtchnl2_queue_vector *vecmap;\n-\tstruct idpf_cmd_info args;\n-\tint len, i, err = 0;\n-\n-\tlen = sizeof(struct virtchnl2_queue_vector_maps) +\n-\t\t(nb_rxq - 1) * sizeof(struct virtchnl2_queue_vector);\n-\n-\tmap_info = rte_zmalloc(\"map_info\", len, 0);\n-\tif (map_info == NULL)\n-\t\treturn -ENOMEM;\n-\n-\tmap_info->vport_id = vport->vport_id;\n-\tmap_info->num_qv_maps = nb_rxq;\n-\tfor (i = 0; i < nb_rxq; i++) {\n-\t\tvecmap = &map_info->qv_maps[i];\n-\t\tvecmap->queue_id = vport->qv_map[i].queue_id;\n-\t\tvecmap->vector_id = vport->qv_map[i].vector_id;\n-\t\tvecmap->itr_idx = VIRTCHNL2_ITR_IDX_0;\n-\t\tvecmap->queue_type = VIRTCHNL2_QUEUE_TYPE_RX;\n-\t}\n-\n-\targs.ops = map ? VIRTCHNL2_OP_MAP_QUEUE_VECTOR :\n-\t\tVIRTCHNL2_OP_UNMAP_QUEUE_VECTOR;\n-\targs.in_args = (u8 *)map_info;\n-\targs.in_args_size = len;\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_QUEUE_VECTOR\",\n-\t\t\t    map ? \"MAP\" : \"UNMAP\");\n-\n-\trte_free(map_info);\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_alloc_vectors(struct idpf_vport *vport, uint16_t num_vectors)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_alloc_vectors *alloc_vec;\n-\tstruct idpf_cmd_info args;\n-\tint err, len;\n-\n-\tlen = sizeof(struct virtchnl2_alloc_vectors) +\n-\t\t(num_vectors - 1) * sizeof(struct virtchnl2_vector_chunk);\n-\talloc_vec = rte_zmalloc(\"alloc_vec\", len, 0);\n-\tif (alloc_vec == NULL)\n-\t\treturn -ENOMEM;\n-\n-\talloc_vec->num_vectors = num_vectors;\n-\n-\targs.ops = VIRTCHNL2_OP_ALLOC_VECTORS;\n-\targs.in_args = (u8 *)alloc_vec;\n-\targs.in_args_size = sizeof(struct virtchnl2_alloc_vectors);\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command VIRTCHNL2_OP_ALLOC_VECTORS\");\n-\n-\tif (vport->recv_vectors == NULL) {\n-\t\tvport->recv_vectors = rte_zmalloc(\"recv_vectors\", len, 0);\n-\t\tif (vport->recv_vectors == NULL) {\n-\t\t\trte_free(alloc_vec);\n-\t\t\treturn -ENOMEM;\n-\t\t}\n-\t}\n-\n-\trte_memcpy(vport->recv_vectors, args.out_buffer, len);\n-\trte_free(alloc_vec);\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_dealloc_vectors(struct idpf_vport *vport)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_alloc_vectors *alloc_vec;\n-\tstruct virtchnl2_vector_chunks *vcs;\n-\tstruct idpf_cmd_info args;\n-\tint err, len;\n-\n-\talloc_vec = vport->recv_vectors;\n-\tvcs = &alloc_vec->vchunks;\n-\n-\tlen = sizeof(struct virtchnl2_vector_chunks) +\n-\t\t(vcs->num_vchunks - 1) * sizeof(struct virtchnl2_vector_chunk);\n-\n-\targs.ops = VIRTCHNL2_OP_DEALLOC_VECTORS;\n-\targs.in_args = (u8 *)vcs;\n-\targs.in_args_size = len;\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command VIRTCHNL2_OP_DEALLOC_VECTORS\");\n-\n-\treturn err;\n-}\n-\n-static int\n-idpf_vc_ena_dis_one_queue(struct idpf_vport *vport, uint16_t qid,\n-\t\t\t  uint32_t type, bool on)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_del_ena_dis_queues *queue_select;\n-\tstruct virtchnl2_queue_chunk *queue_chunk;\n-\tstruct idpf_cmd_info args;\n-\tint err, len;\n-\n-\tlen = sizeof(struct virtchnl2_del_ena_dis_queues);\n-\tqueue_select = rte_zmalloc(\"queue_select\", len, 0);\n-\tif (queue_select == NULL)\n-\t\treturn -ENOMEM;\n-\n-\tqueue_chunk = queue_select->chunks.chunks;\n-\tqueue_select->chunks.num_chunks = 1;\n-\tqueue_select->vport_id = vport->vport_id;\n-\n-\tqueue_chunk->type = type;\n-\tqueue_chunk->start_queue_id = qid;\n-\tqueue_chunk->num_queues = 1;\n-\n-\targs.ops = on ? VIRTCHNL2_OP_ENABLE_QUEUES :\n-\t\tVIRTCHNL2_OP_DISABLE_QUEUES;\n-\targs.in_args = (u8 *)queue_select;\n-\targs.in_args_size = len;\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_QUEUES\",\n-\t\t\t    on ? \"ENABLE\" : \"DISABLE\");\n-\n-\trte_free(queue_select);\n-\treturn err;\n-}\n-\n-int\n-idpf_switch_queue(struct idpf_vport *vport, uint16_t qid,\n-\t\t     bool rx, bool on)\n-{\n-\tuint32_t type;\n-\tint err, queue_id;\n-\n-\t/* switch txq/rxq */\n-\ttype = rx ? VIRTCHNL2_QUEUE_TYPE_RX : VIRTCHNL2_QUEUE_TYPE_TX;\n-\n-\tif (type == VIRTCHNL2_QUEUE_TYPE_RX)\n-\t\tqueue_id = vport->chunks_info.rx_start_qid + qid;\n-\telse\n-\t\tqueue_id = vport->chunks_info.tx_start_qid + qid;\n-\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n-\tif (err != 0)\n-\t\treturn err;\n-\n-\t/* switch tx completion queue */\n-\tif (!rx && vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n-\t\ttype = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION;\n-\t\tqueue_id = vport->chunks_info.tx_compl_start_qid + qid;\n-\t\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n-\t\tif (err != 0)\n-\t\t\treturn err;\n-\t}\n-\n-\t/* switch rx buffer queue */\n-\tif (rx && vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n-\t\ttype = VIRTCHNL2_QUEUE_TYPE_RX_BUFFER;\n-\t\tqueue_id = vport->chunks_info.rx_buf_start_qid + 2 * qid;\n-\t\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n-\t\tif (err != 0)\n-\t\t\treturn err;\n-\t\tqueue_id++;\n-\t\terr = idpf_vc_ena_dis_one_queue(vport, queue_id, type, on);\n-\t\tif (err != 0)\n-\t\t\treturn err;\n-\t}\n-\n-\treturn err;\n-}\n-\n-#define IDPF_RXTX_QUEUE_CHUNKS_NUM\t2\n-int\n-idpf_vc_ena_dis_queues(struct idpf_vport *vport, bool enable)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_del_ena_dis_queues *queue_select;\n-\tstruct virtchnl2_queue_chunk *queue_chunk;\n-\tuint32_t type;\n-\tstruct idpf_cmd_info args;\n-\tuint16_t num_chunks;\n-\tint err, len;\n-\n-\tnum_chunks = IDPF_RXTX_QUEUE_CHUNKS_NUM;\n-\tif (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)\n-\t\tnum_chunks++;\n-\tif (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT)\n-\t\tnum_chunks++;\n-\n-\tlen = sizeof(struct virtchnl2_del_ena_dis_queues) +\n-\t\tsizeof(struct virtchnl2_queue_chunk) * (num_chunks - 1);\n-\tqueue_select = rte_zmalloc(\"queue_select\", len, 0);\n-\tif (queue_select == NULL)\n-\t\treturn -ENOMEM;\n-\n-\tqueue_chunk = queue_select->chunks.chunks;\n-\tqueue_select->chunks.num_chunks = num_chunks;\n-\tqueue_select->vport_id = vport->vport_id;\n-\n-\ttype = VIRTCHNL_QUEUE_TYPE_RX;\n-\tqueue_chunk[type].type = type;\n-\tqueue_chunk[type].start_queue_id = vport->chunks_info.rx_start_qid;\n-\tqueue_chunk[type].num_queues = vport->num_rx_q;\n-\n-\ttype = VIRTCHNL2_QUEUE_TYPE_TX;\n-\tqueue_chunk[type].type = type;\n-\tqueue_chunk[type].start_queue_id = vport->chunks_info.tx_start_qid;\n-\tqueue_chunk[type].num_queues = vport->num_tx_q;\n-\n-\tif (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n-\t\ttype = VIRTCHNL2_QUEUE_TYPE_RX_BUFFER;\n-\t\tqueue_chunk[type].type = type;\n-\t\tqueue_chunk[type].start_queue_id =\n-\t\t\tvport->chunks_info.rx_buf_start_qid;\n-\t\tqueue_chunk[type].num_queues = vport->num_rx_bufq;\n-\t}\n-\n-\tif (vport->txq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) {\n-\t\ttype = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION;\n-\t\tqueue_chunk[type].type = type;\n-\t\tqueue_chunk[type].start_queue_id =\n-\t\t\tvport->chunks_info.tx_compl_start_qid;\n-\t\tqueue_chunk[type].num_queues = vport->num_tx_complq;\n-\t}\n-\n-\targs.ops = enable ? VIRTCHNL2_OP_ENABLE_QUEUES :\n-\t\tVIRTCHNL2_OP_DISABLE_QUEUES;\n-\targs.in_args = (u8 *)queue_select;\n-\targs.in_args_size = len;\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_QUEUES\",\n-\t\t\t    enable ? \"ENABLE\" : \"DISABLE\");\n-\n-\trte_free(queue_select);\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_ena_dis_vport(struct idpf_vport *vport, bool enable)\n-{\n-\tstruct idpf_adapter *adapter = vport->adapter;\n-\tstruct virtchnl2_vport vc_vport;\n-\tstruct idpf_cmd_info args;\n-\tint err;\n-\n-\tvc_vport.vport_id = vport->vport_id;\n-\targs.ops = enable ? VIRTCHNL2_OP_ENABLE_VPORT :\n-\t\t\t    VIRTCHNL2_OP_DISABLE_VPORT;\n-\targs.in_args = (uint8_t *)&vc_vport;\n-\targs.in_args_size = sizeof(vc_vport);\n-\targs.out_buffer = adapter->mbx_resp;\n-\targs.out_size = IDPF_DFLT_MBX_BUF_SIZE;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0) {\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_%s_VPORT\",\n-\t\t\t    enable ? \"ENABLE\" : \"DISABLE\");\n-\t}\n-\n-\treturn err;\n-}\n-\n-int\n-idpf_vc_query_ptype_info(struct idpf_adapter *adapter)\n-{\n-\tstruct virtchnl2_get_ptype_info *ptype_info;\n-\tstruct idpf_cmd_info args;\n-\tint len, err;\n-\n-\tlen = sizeof(struct virtchnl2_get_ptype_info);\n-\tptype_info = rte_zmalloc(\"ptype_info\", len, 0);\n-\tif (ptype_info == NULL)\n-\t\treturn -ENOMEM;\n-\n-\tptype_info->start_ptype_id = 0;\n-\tptype_info->num_ptypes = IDPF_MAX_PKT_TYPE;\n-\targs.ops = VIRTCHNL2_OP_GET_PTYPE_INFO;\n-\targs.in_args = (u8 *)ptype_info;\n-\targs.in_args_size = len;\n-\n-\terr = idpf_execute_vc_cmd(adapter, &args);\n-\tif (err != 0)\n-\t\tPMD_DRV_LOG(ERR, \"Failed to execute command of VIRTCHNL2_OP_GET_PTYPE_INFO\");\n-\n-\trte_free(ptype_info);\n-\treturn err;\n-}\n",
    "prefixes": [
        "03/15"
    ]
}