Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/85494/?format=api
https://patches.dpdk.org/api/patches/85494/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20201219062806.56477-7-chenbo.xia@intel.com/", "project": { "id": 1, "url": "https://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": "<20201219062806.56477-7-chenbo.xia@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20201219062806.56477-7-chenbo.xia@intel.com", "date": "2020-12-19T06:28:04", "name": "[v2,6/8] emu/iavf: add emudev operations to fit in emudev framework", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "c8147d2cbc53ba1283a8852135f1c009d15a2978", "submitter": { "id": 1276, "url": "https://patches.dpdk.org/api/people/1276/?format=api", "name": "Chenbo Xia", "email": "chenbo.xia@intel.com" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20201219062806.56477-7-chenbo.xia@intel.com/mbox/", "series": [ { "id": 14383, "url": "https://patches.dpdk.org/api/series/14383/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=14383", "date": "2020-12-19T06:27:58", "name": "Introduce emudev library and iavf emudev driver", "version": 2, "mbox": "https://patches.dpdk.org/series/14383/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/85494/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/85494/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 84AD5A04B5;\n\tSat, 19 Dec 2020 07:45:19 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id F0942CBA2;\n\tSat, 19 Dec 2020 07:43:32 +0100 (CET)", "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by dpdk.org (Postfix) with ESMTP id 9CC4DCB97\n for <dev@dpdk.org>; Sat, 19 Dec 2020 07:43:30 +0100 (CET)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 18 Dec 2020 22:43:30 -0800", "from npg-dpdk-virtio-xiachenbo-nw.sh.intel.com ([10.67.119.123])\n by fmsmga001.fm.intel.com with ESMTP; 18 Dec 2020 22:43:28 -0800" ], "IronPort-SDR": [ "\n VCP7s5yYP3jDfkZDoIJgEdn5ZCMp4BzOzlextoIMX6pIhMScr76/8FMVuXC0Cl8TWuEEiR04Zz\n +WdFtfdDED3A==", "\n kBrNPOmv7JN6of+rHul9VKw0StdnARDexmkU4wJhougIJgWsbdOxIM3ZBJlcah+6/GyWUbmPN+\n To5db5H2VJ9g==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6000,8403,9839\"; a=\"163285196\"", "E=Sophos;i=\"5.78,432,1599548400\"; d=\"scan'208\";a=\"163285196\"", "E=Sophos;i=\"5.78,432,1599548400\"; d=\"scan'208\";a=\"454449632\"" ], "X-ExtLoop1": "1", "From": "Chenbo Xia <chenbo.xia@intel.com>", "To": "dev@dpdk.org,\n\tthomas@monjalon.net,\n\tdavid.marchand@redhat.com", "Cc": "stephen@networkplumber.org, cunming.liang@intel.com, xiuchun.lu@intel.com,\n miao.li@intel.com, jingjing.wu@intel.com", "Date": "Sat, 19 Dec 2020 14:28:04 +0800", "Message-Id": "<20201219062806.56477-7-chenbo.xia@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20201219062806.56477-1-chenbo.xia@intel.com>", "References": "<20201218074736.93999-1-chenbo.xia@intel.com>\n <20201219062806.56477-1-chenbo.xia@intel.com>", "Subject": "[dpdk-dev] [PATCH v2 6/8] emu/iavf: add emudev operations to fit in\n\temudev framework", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "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", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This patch implements emudev opertions to make emulated iavf\nfit into rte_emudev framework. Lifecycle related and device\nresource related operations are both implemented.\n\nSigned-off-by: Chenbo Xia <chenbo.xia@intel.com>\nSigned-off-by: Xiuchun Lu <xiuchun.lu@intel.com>\n---\n drivers/emu/iavf/iavf_emu.c | 218 ++++++++++++++++++++++++++++++++\n drivers/emu/iavf/rte_iavf_emu.h | 59 +++++++++\n 2 files changed, 277 insertions(+)", "diff": "diff --git a/drivers/emu/iavf/iavf_emu.c b/drivers/emu/iavf/iavf_emu.c\nindex c1a702d744..9ad371ca98 100644\n--- a/drivers/emu/iavf/iavf_emu.c\n+++ b/drivers/emu/iavf/iavf_emu.c\n@@ -2,7 +2,72 @@\n * Copyright(c) 2020 Intel Corporation\n */\n \n+#include <stdint.h>\n+#include <string.h>\n+#include <unistd.h>\n+\n+#include <rte_malloc.h>\n+#include <rte_emudev.h>\n+\n #include \"iavf_vfio_user.h\"\n+#include <iavf_type.h>\n+\n+static int iavf_emu_dev_start(struct rte_emudev *dev)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\n+\tif (iavf->ops != NULL && iavf->ops->device_start != NULL)\n+\t\tiavf->ops->device_start(dev);\n+\n+\treturn 0;\n+}\n+\n+static void iavf_emu_dev_stop(struct rte_emudev *dev)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\n+\tif (iavf->ops != NULL && iavf->ops->device_stop != NULL)\n+\t\tiavf->ops->device_stop(dev);\n+}\n+\n+static int iavf_emu_dev_configure(struct rte_emudev *dev,\n+\t\tstruct rte_emudev_info *dev_conf)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\tstruct rte_iavf_emu_config *conf =\n+\t\t(struct rte_iavf_emu_config *)dev_conf->dev_priv;\n+\n+\tif (!dev_conf->dev_priv)\n+\t\treturn -EINVAL;\n+\n+\t/* Currently emulated iavf does not support max_qp_num\n+\t * and region num configuration\n+\t */\n+\tif (dev->dev_info.max_qp_num != dev_conf->max_qp_num ||\n+\t\tdev->dev_info.region_num != dev_conf->region_num) {\n+\t\tEMU_IAVF_LOG(ERR,\n+\t\t\t\"Configure max_qp_num/region num not supported\\n\");\n+\t\treturn -ENOTSUP;\n+\t}\n+\n+\tif (conf->qp_num > RTE_MAX_QUEUES_PER_PORT ||\n+\t\tconf->qp_num > RTE_IAVF_EMU_MAX_QP_NUM) {\n+\t\tEMU_IAVF_LOG(ERR, \"Queue pair num exceeds max\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* For now, we don't support device configure when data\n+\t * path driver is attached\n+\t */\n+\tif (dev->backend_priv) {\n+\t\tEMU_IAVF_LOG(ERR, \"Configure failed because of \"\n+\t\t\t\"data path attached\\n\");\n+\t\treturn -EPERM;\n+\t}\n+\n+\tiavf->max_be_lanqp = conf->qp_num;\n+\treturn 0;\n+}\n \n static int iavf_emu_dev_close(struct rte_emudev *dev)\n {\n@@ -26,6 +91,159 @@ static int iavf_emu_dev_close(struct rte_emudev *dev)\n \treturn 0;\n }\n \n+static int iavf_emu_get_dev_info(struct rte_emudev *dev,\n+\trte_emudev_obj_t info)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\tstruct rte_iavf_emu_config *conf = (struct rte_iavf_emu_config *)info;\n+\n+\tif (!info)\n+\t\treturn -EINVAL;\n+\n+\tconf->qp_num = iavf->max_be_lanqp;\n+\treturn 0;\n+}\n+\n+static int iavf_emu_get_mem_table(struct rte_emudev *dev,\n+\trte_emudev_mem_table_t *tb)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\n+\t*tb = iavf->mem;\n+\n+\treturn 0;\n+}\n+\n+static int iavf_emu_get_queue_info(struct rte_emudev *dev, uint32_t queue,\n+\t\tstruct rte_emudev_q_info *info)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\n+\tif (queue < RTE_IAVF_EMU_ADMINQ_NUM) {\n+\t\tstruct iavf_emu_adminQ *adq = &iavf->adq[queue];\n+\t\tuint64_t base, size;\n+\n+\t\tif (adq->ring_addr_lo == NULL ||\n+\t\t adq->ring_addr_hi == NULL ||\n+\t\t adq->ring_sz == NULL)\n+\t\t\treturn -1;\n+\t\tbase = RTE_IAVF_EMU_32_TO_64(*adq->ring_addr_hi,\n+\t\t\t*adq->ring_addr_lo);\n+\t\tsize = *adq->ring_sz;\n+\t\tinfo->base = base;\n+\t\tinfo->size = size;\n+\t\tinfo->doorbell_id = queue;\n+\t\t/* RX AdminQ should have IRQ vector 0 */\n+\t\tinfo->irq_vector = queue - 1;\n+\t} else {\n+\t\tinfo->base = 0;\n+\t\tinfo->size = 0;\n+\t\tinfo->doorbell_id = queue;\n+\t\tinfo->irq_vector = -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int iavf_emu_get_irq_info(struct rte_emudev *dev, uint32_t vector,\n+\t\tstruct rte_emudev_irq_info *info)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\tstruct iavf_emu_intr *intr = iavf->intr;\n+\tstruct iavf_emu_intr_info *intr_info = &intr->info[vector];\n+\n+\tif (vector >= intr->intr_num)\n+\t\treturn -EINVAL;\n+\n+\tinfo->eventfd = intr_info->fd;\n+\tinfo->enable = intr_info->enable;\n+\tinfo->vector = vector;\n+\n+\treturn 0;\n+}\n+\n+static int iavf_emu_get_db_info(struct rte_emudev *dev, uint32_t doorbell,\n+\t\tstruct rte_emudev_db_info *info)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\n+\tif (doorbell < RTE_IAVF_EMU_ADMINQ_NUM) {\n+\t\tstruct iavf_emu_adminQ *adq = &iavf->adq[doorbell];\n+\n+\t\tinfo->data.mem.base = (uint64_t)adq->doorbell;\n+\t\tinfo->data.mem.size = adq->db_size;\n+\t} else {\n+\t\tstruct iavf_emu_lanQ *lanq =\n+\t\t\t&iavf->lanq[doorbell - RTE_IAVF_EMU_ADMINQ_NUM];\n+\n+\t\tinfo->data.mem.base = (uint64_t)lanq->doorbell;\n+\t\tinfo->data.mem.size = lanq->db_size;\n+\t}\n+\n+\tinfo->flag |= RTE_EMUDEV_DB_MEM;\n+\tinfo->id = doorbell;\n+\n+\treturn 0;\n+}\n+\n+static int iavf_emu_subs_ev(struct rte_emudev *dev,\n+\trte_emudev_event_chnl_t ev_chnl)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\n+\tiavf->ops = (struct rte_iavf_emu_notify_ops *)ev_chnl;\n+\n+\treturn 0;\n+}\n+\n+static int iavf_emu_unsubs_ev(struct rte_emudev *dev,\n+\t\trte_emudev_event_chnl_t ev_chnl)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\n+\tif ((struct rte_iavf_emu_notify_ops *)ev_chnl == iavf->ops) {\n+\t\tiavf->ops = NULL;\n+\t\treturn 0;\n+\t}\n+\n+\treturn -EINVAL;\n+}\n+\n+static int iavf_emu_get_attr(struct rte_emudev *dev, const char *attr_name,\n+\t\trte_emudev_attr_t attr)\n+{\n+\tstruct iavf_emudev *iavf = (struct iavf_emudev *)dev->priv_data;\n+\tstruct rte_vfio_user_reg_info *info;\n+\tint ret = 0;\n+\n+\tinfo = &iavf->vfio->reg->reg_info[0];\n+\n+\tif (!strcmp(attr_name, RTE_IAVF_EMU_ATTR_ASQ_HEAD))\n+\t\t*(uint64_t *)attr = (uint64_t)(uintptr_t)info->base\n+\t\t\t+ IAVF_VF_ATQH1;\n+\telse if (!strcmp(attr_name, RTE_IAVF_EMU_ATTR_ARQ_HEAD))\n+\t\t*(uint64_t *)attr = (uint64_t)(uintptr_t)info->base\n+\t\t\t+ IAVF_VF_ARQH1;\n+\telse if (!strcmp(attr_name, RTE_IAVF_EMU_ATTR_RESET))\n+\t\t*(uint64_t *)attr = (uint64_t)(uintptr_t)info->base\n+\t\t\t+ IAVF_VFGEN_RSTAT;\n+\telse\n+\t\tret = -EINVAL;\n+\n+\treturn ret;\n+}\n+\n struct rte_emudev_ops emu_iavf_ops = {\n+\t.dev_start = iavf_emu_dev_start,\n+\t.dev_stop = iavf_emu_dev_stop,\n+\t.dev_configure = iavf_emu_dev_configure,\n \t.dev_close = iavf_emu_dev_close,\n+\t.dev_info_get = iavf_emu_get_dev_info,\n+\t.get_mem_table = iavf_emu_get_mem_table,\n+\t.get_queue_info = iavf_emu_get_queue_info,\n+\t.get_irq_info = iavf_emu_get_irq_info,\n+\t.get_db_info = iavf_emu_get_db_info,\n+\t.subscribe_event = iavf_emu_subs_ev,\n+\t.unsubscribe_event = iavf_emu_unsubs_ev,\n+\t.get_attr = iavf_emu_get_attr,\n };\ndiff --git a/drivers/emu/iavf/rte_iavf_emu.h b/drivers/emu/iavf/rte_iavf_emu.h\nindex 6de0989f0b..2abcec97d4 100644\n--- a/drivers/emu/iavf/rte_iavf_emu.h\n+++ b/drivers/emu/iavf/rte_iavf_emu.h\n@@ -6,13 +6,24 @@\n #define _IAVF_EMU_H\n \n #include <stdint.h>\n+#include <stddef.h>\n+#include <limits.h>\n+#include <net/if.h>\n+#include <sys/queue.h>\n \n+#include <rte_vfio_user.h>\n #include <rte_emudev.h>\n \n #define RTE_IAVF_EMUDEV_TYPE \"iavf\"\n+#define RTE_IAVF_EMU_ATTR_ASQ_HEAD \"ASQ_H\"\n+#define RTE_IAVF_EMU_ATTR_ARQ_HEAD \"ARQ_H\"\n+#define RTE_IAVF_EMU_ATTR_RESET \"RESET\"\n+#define RTE_IAVF_EMU_RESET_IN_PROGRESS 0x00\n+#define RTE_IAVF_EMU_RESET_COMPLETED 0x01\n #define RTE_IAVF_EMU_MAX_MEM_REGIONS 256\n #define RTE_IAVF_EMU_MAX_QP_NUM 256\n #define RTE_IAVF_EMU_MAX_INTR 32\n+#define RTE_IAVF_EMU_32_TO_64(hi, lo) ((((uint64_t)(hi)) << 32) + (lo))\n \n enum {\n \tRTE_IAVF_EMU_ADMINQ_TXQ = 0,\n@@ -26,6 +37,11 @@ enum {\n \tRTE_IAVF_EMU_MAPPABLE_REG_NUM = 2,\n };\n \n+struct rte_iavf_emu_config {\n+\t/* Maximum queue pair number that data path driver can use */\n+\tuint32_t qp_num;\n+};\n+\n struct rte_iavf_emu_mem_reg {\n \tuint64_t guest_phys_addr;\n \tuint64_t host_user_addr;\n@@ -40,6 +56,49 @@ struct rte_iavf_emu_mem {\n \tstruct rte_iavf_emu_mem_reg regions[RTE_IAVF_EMU_MAX_MEM_REGIONS];\n };\n \n+/**\n+ * Helper function for data path driver to translate address\n+ * of one region\n+ *\n+ * @param mem\n+ * A pointer to DMA memory table\n+ * @param g_addr\n+ * Guest I/O virtual base address of the region\n+ * @param[in/out] len\n+ * The length of region\n+ * @return\n+ * - >0: Success, process virtual address returned\n+ * - 0: Failure on translation\n+ */\n+__rte_experimental\n+__rte_always_inline uint64_t\n+rte_iavf_emu_get_dma_vaddr(struct rte_iavf_emu_mem *mem,\n+\tuint64_t g_addr, uint64_t *len)\n+{\n+\tstruct rte_iavf_emu_mem_reg *reg;\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < mem->region_num; i++) {\n+\t\treg = &mem->regions[i];\n+\n+\t\tif (g_addr >= reg->guest_phys_addr &&\n+\t\t\tg_addr < reg->guest_phys_addr + reg->size) {\n+\n+\t\t\tif (unlikely(*len > reg->guest_phys_addr +\n+\t\t\t\t reg->size - g_addr))\n+\t\t\t\t*len = reg->guest_phys_addr +\n+\t\t\t\t\treg->size - g_addr;\n+\n+\t\t\treturn g_addr - reg->guest_phys_addr +\n+\t\t\t\treg->host_user_addr;\n+\t\t}\n+\t}\n+\n+\t*len = 0;\n+\n+\treturn 0;\n+}\n+\n struct rte_iavf_emu_notify_ops {\n \t/* Device is ready */\n \tint (*device_ready)(struct rte_emudev *dev);\n", "prefixes": [ "v2", "6/8" ] }{ "id": 85494, "url": "