From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D1D2A0C54; Fri, 3 Sep 2021 12:51:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8C0A41148; Fri, 3 Sep 2021 12:50:27 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 1743141140 for ; Fri, 3 Sep 2021 12:50:25 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10095"; a="216247387" X-IronPort-AV: E=Sophos;i="5.85,265,1624345200"; d="scan'208";a="216247387" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Sep 2021 03:50:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,265,1624345200"; d="scan'208";a="521643518" Received: from silpixa00401122.ir.intel.com ([10.55.128.10]) by fmsmga004.fm.intel.com with ESMTP; 03 Sep 2021 03:50:24 -0700 From: Kevin Laatz To: dev@dpdk.org Cc: bruce.richardson@intel.com, fengchengwen@huawei.com, jerinj@marvell.com, conor.walsh@intel.com, Kevin Laatz Date: Fri, 3 Sep 2021 10:49:53 +0000 Message-Id: <20210903105001.1179328-9-kevin.laatz@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210903105001.1179328-1-kevin.laatz@intel.com> References: <20210827172048.558704-1-kevin.laatz@intel.com> <20210903105001.1179328-1-kevin.laatz@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 08/16] dma/idxd: add configure and info_get functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add functions for device configuration. The info_get function is included here since it can be useful for checking successful configuration. Signed-off-by: Bruce Richardson Signed-off-by: Kevin Laatz --- v2: - fix reconfigure bug in idxd_vchan_setup() - add literal include comment for the docs to pick up --- app/test/test_dmadev.c | 3 +- doc/guides/dmadevs/idxd.rst | 33 ++++++++++++++++ drivers/dma/idxd/idxd_bus.c | 3 ++ drivers/dma/idxd/idxd_common.c | 66 ++++++++++++++++++++++++++++++++ drivers/dma/idxd/idxd_internal.h | 5 +++ drivers/dma/idxd/idxd_pci.c | 3 ++ 6 files changed, 112 insertions(+), 1 deletion(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index c44c3ad9db..d287d480b4 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -770,6 +770,7 @@ static int test_dmadev_instance(uint16_t dev_id) { #define TEST_RINGSIZE 512 + /* Setup of the dmadev device. 8< */ struct rte_dmadev_stats stats; struct rte_dmadev_info info; const struct rte_dmadev_conf conf = { .nb_vchans = 1}; @@ -795,7 +796,7 @@ test_dmadev_instance(uint16_t dev_id) PRINT_ERR("Error with queue configuration\n"); return -1; } - + /* >8 End of setup of the dmadev device. */ rte_dmadev_info_get(dev_id, &info); if (info.nb_vchans != 1) { PRINT_ERR("Error, no configured queues reported on device id %u\n", dev_id); diff --git a/doc/guides/dmadevs/idxd.rst b/doc/guides/dmadevs/idxd.rst index ce33e2857a..66bc9fe744 100644 --- a/doc/guides/dmadevs/idxd.rst +++ b/doc/guides/dmadevs/idxd.rst @@ -120,3 +120,36 @@ use a subset of configured queues. Once probed successfully, irrespective of kernel driver, the device will appear as a ``dmadev``, that is a "DMA device type" inside DPDK, and can be accessed using APIs from the ``rte_dmadev`` library. + +Using IDXD DMAdev Devices +-------------------------- + +To use the devices from an application, the dmadev API can be used. + +Getting Device Information +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Basic information about each dmadev device can be queried using the +``rte_dmadev_info_get()`` API. This will return basic device information such as +the ``rte_device`` structure, device capabilities and other device specific values. + +Device Configuration +~~~~~~~~~~~~~~~~~~~~~ + +Configuring an IDXD dmadev device is done using the ``rte_dmadev_configure()`` and +``rte_dmadev_vchan_setup`` APIs. The configurations are passed to these APIs using +the ``rte_dmadev_conf`` and ``rte_dmadev_vchan_conf`` structures, respectively. For +example, these can be used to configure the number of ``vchans`` per device, the +ring size, etc. The ring size must be a power of two, between 64 and 4096. + +The following code shows how the device is configured in +``test_dmadev.c``: + +.. literalinclude:: ../../../app/test/test_dmadev.c + :language: c + :start-after: Setup of the dmadev device. 8< + :end-before: >8 End of setup of the dmadev device. + :dedent: 1 + +Once configured, the device can then be made ready for use by calling the +``rte_dmadev_start()`` API. diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c index dc11f829fd..ad4f076bad 100644 --- a/drivers/dma/idxd/idxd_bus.c +++ b/drivers/dma/idxd/idxd_bus.c @@ -95,6 +95,9 @@ idxd_dev_close(struct rte_dmadev *dev) static const struct rte_dmadev_ops idxd_vdev_ops = { .dev_close = idxd_dev_close, .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; static void * diff --git a/drivers/dma/idxd/idxd_common.c b/drivers/dma/idxd/idxd_common.c index 9490439fdc..6704a26357 100644 --- a/drivers/dma/idxd/idxd_common.c +++ b/drivers/dma/idxd/idxd_common.c @@ -39,6 +39,72 @@ idxd_dump(const struct rte_dmadev *dev, FILE *f) return 0; } +int +idxd_info_get(const struct rte_dmadev *dev, struct rte_dmadev_info *info, uint32_t size) +{ + struct idxd_dmadev *idxd = dev->dev_private; + + if (size < sizeof(*info)) + return -EINVAL; + + *info = (struct rte_dmadev_info) { + .device = dev->device, + .dev_capa = RTE_DMADEV_CAPA_MEM_TO_MEM | + RTE_DMADEV_CAPA_OPS_COPY | RTE_DMADEV_CAPA_OPS_FILL, + .max_vchans = 1, + .max_desc = 4096, + .min_desc = 64, + .nb_vchans = (idxd->desc_ring != NULL), /* returns 1 or 0 */ + }; + if (idxd->sva_support) + info->dev_capa |= RTE_DMADEV_CAPA_SVA; + return 0; +} + +int +idxd_configure(struct rte_dmadev *dev __rte_unused, const struct rte_dmadev_conf *dev_conf) +{ + if (dev_conf->nb_vchans != 1) + return -EINVAL; + return 0; +} + +int +idxd_vchan_setup(struct rte_dmadev *dev, uint16_t vchan __rte_unused, + const struct rte_dmadev_vchan_conf *qconf) +{ + struct idxd_dmadev *idxd = dev->dev_private; + uint16_t max_desc = qconf->nb_desc; + + idxd->qcfg = *qconf; + + if (!rte_is_power_of_2(max_desc)) + max_desc = rte_align32pow2(max_desc); + IDXD_PMD_DEBUG("DMA dev %u using %u descriptors", dev->data->dev_id, max_desc); + idxd->desc_ring_mask = max_desc - 1; + idxd->qcfg.nb_desc = max_desc; + + /* in case we are reconfiguring a device, free any existing memory */ + rte_free(idxd->desc_ring); + + /* allocate the descriptor ring at 2x size as batches can't wrap */ + idxd->desc_ring = rte_zmalloc(NULL, sizeof(*idxd->desc_ring) * max_desc * 2, 0); + if (idxd->desc_ring == NULL) + return -ENOMEM; + idxd->desc_iova = rte_mem_virt2iova(idxd->desc_ring); + + idxd->batch_idx_read = 0; + idxd->batch_idx_write = 0; + idxd->batch_start = 0; + idxd->batch_size = 0; + idxd->ids_returned = 0; + idxd->ids_avail = 0; + + memset(idxd->batch_comp_ring, 0, sizeof(*idxd->batch_comp_ring) * + (idxd->max_batches + 1)); + return 0; +} + int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd, diff --git a/drivers/dma/idxd/idxd_internal.h b/drivers/dma/idxd/idxd_internal.h index 09285b4e96..18fc65d00c 100644 --- a/drivers/dma/idxd/idxd_internal.h +++ b/drivers/dma/idxd/idxd_internal.h @@ -80,5 +80,10 @@ struct idxd_dmadev { int idxd_dmadev_create(const char *name, struct rte_device *dev, const struct idxd_dmadev *base_idxd, const struct rte_dmadev_ops *ops); int idxd_dump(const struct rte_dmadev *dev, FILE *f); +int idxd_configure(struct rte_dmadev *dev, const struct rte_dmadev_conf *dev_conf); +int idxd_vchan_setup(struct rte_dmadev *dev, uint16_t vchan, + const struct rte_dmadev_vchan_conf *qconf); +int idxd_info_get(const struct rte_dmadev *dev, struct rte_dmadev_info *dev_info, + uint32_t size); #endif /* _IDXD_INTERNAL_H_ */ diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c index 96d58c8544..569df8d04c 100644 --- a/drivers/dma/idxd/idxd_pci.c +++ b/drivers/dma/idxd/idxd_pci.c @@ -61,6 +61,9 @@ idxd_is_wq_enabled(struct idxd_dmadev *idxd) static const struct rte_dmadev_ops idxd_pci_ops = { .dev_dump = idxd_dump, + .dev_configure = idxd_configure, + .vchan_setup = idxd_vchan_setup, + .dev_info_get = idxd_info_get, }; /* each portal uses 4 x 4k pages */ -- 2.30.2