From patchwork Fri Aug 11 16:14:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 130169 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id E21EC43036; Fri, 11 Aug 2023 18:14:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E0DC043258; Fri, 11 Aug 2023 18:14:53 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 2725242D3F for ; Fri, 11 Aug 2023 18:14:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691770492; x=1723306492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YI7GWtTlgTWGruKxL2ZuiuUGvv7hZTwrxGqmICJJxvA=; b=n6gHvP450/Yu+qDqnMYyZzs4NOk/p3IZgxq38okg/cHNnkZxqXplysvx OJtbO9SOfrpjQgdxd/ZR3yMqKExyPS29aXG+ssGFiD34vPtNQbL0rbPrB G6osH8i7j8CLW2XoPsd38EfvmofJ2t8yReWjJLsCmRGizJs/Ou36u6be+ Z68/Q/4GbJpavkIk3ZM5XRUZ8y6vmuGIhKtf5KJV9aduy+i8c5MjK6uOy WVI16AUpa/ZFV7eG/VXAM8du8Un9IZb4bx1Mc7NAnk5sclC7ZMV71uwAL jrFaTQC3WWbIzrqBF2ypCNi+GmDsni/kQtltFgP6H5kBhQvaE0y3G4ZcH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10799"; a="351312921" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="351312921" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2023 09:14:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10799"; a="906499488" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="906499488" Received: from silpixa00401191.ir.intel.com ([10.55.128.139]) by orsmga005.jf.intel.com with ESMTP; 11 Aug 2023 09:14:49 -0700 From: Anatoly Burakov To: dev@dpdk.org, Chengwen Feng , Kevin Laatz , Bruce Richardson Cc: Vladimir Medvedkin Subject: [PATCH v1 1/3] dmadev: add inter-domain operations Date: Fri, 11 Aug 2023 16:14:44 +0000 Message-Id: <8866a5c7ea36e476b2a92e3e4cea6c2c127ab82f.1691768110.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 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 Add a flag to indicate that a specific device supports inter-domain operations, and add an API for inter-domain copy and fill. Inter-domain operation is an operation that is very similar to regular DMA operation, except either source or destination addresses can be in a different process's address space, indicated by source and destination handle values. These values are currently meant to be provided by private drivers' API's. This commit also adds a controller ID field into the DMA device API. This is an arbitrary value that may not be implemented by hardware, but it is meant to represent some kind of device hierarchy. Signed-off-by: Vladimir Medvedkin Signed-off-by: Anatoly Burakov --- doc/guides/prog_guide/dmadev.rst | 18 +++++ lib/dmadev/rte_dmadev.c | 2 + lib/dmadev/rte_dmadev.h | 133 +++++++++++++++++++++++++++++++ lib/dmadev/rte_dmadev_core.h | 12 +++ 4 files changed, 165 insertions(+) diff --git a/doc/guides/prog_guide/dmadev.rst b/doc/guides/prog_guide/dmadev.rst index 2aa26d33b8..e4e5196416 100644 --- a/doc/guides/prog_guide/dmadev.rst +++ b/doc/guides/prog_guide/dmadev.rst @@ -108,6 +108,24 @@ completed operations along with the status of each operation (filled into the completed operation's ``ring_idx`` which could help user track operations within their own application-defined rings. +.. _dmadev_inter_dom: + + +Inter-domain operations +~~~~~~~~~~~~~~~~~~~~~~~ + +For some devices, inter-domain DMA operations may be supported (indicated by +`RTE_DMA_CAPA_OPS_INTER_DOM` flag being set in DMA device capabilities flag). An +inter-domain operation (such as `rte_dma_copy_inter_dom`) is similar to regular +DMA device operation, except the user also needs to specify source and +destination handles, which the hardware will then use to get source and/or +destination PASID to perform the operation. When `src_handle` value is set, +`RTE_DMA_OP_FLAG_SRC_HANDLE` op flag must also be set. Similarly, when +`dst_handle` value is set, `RTE_DMA_OP_FLAG_DST_HANDLE` op flag must be set. + +Currently, source and destination handles are opaque values the user has to get +from private API's of those DMA device drivers that support the operation. + Querying Device Statistics ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 8c095e1f35..ff00612f84 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -425,6 +425,8 @@ rte_dma_info_get(int16_t dev_id, struct rte_dma_info *dev_info) if (*dev->dev_ops->dev_info_get == NULL) return -ENOTSUP; memset(dev_info, 0, sizeof(struct rte_dma_info)); + /* set to -1 by default, as other drivers may not implement this */ + dev_info->controller_id = -1; ret = (*dev->dev_ops->dev_info_get)(dev, dev_info, sizeof(struct rte_dma_info)); if (ret != 0) diff --git a/lib/dmadev/rte_dmadev.h b/lib/dmadev/rte_dmadev.h index e61d71959e..1cad36f0b6 100644 --- a/lib/dmadev/rte_dmadev.h +++ b/lib/dmadev/rte_dmadev.h @@ -278,6 +278,8 @@ int16_t rte_dma_next_dev(int16_t start_dev_id); #define RTE_DMA_CAPA_OPS_COPY_SG RTE_BIT64(33) /** Support fill operation. */ #define RTE_DMA_CAPA_OPS_FILL RTE_BIT64(34) +/** Support inter-domain operation. */ +#define RTE_DMA_CAPA_OPS_INTER_DOM RTE_BIT64(48) /**@}*/ /** @@ -307,6 +309,8 @@ struct rte_dma_info { int16_t numa_node; /** Number of virtual DMA channel configured. */ uint16_t nb_vchans; + /** Controller ID, -1 if unknown */ + int16_t controller_id; }; /** @@ -819,6 +823,16 @@ struct rte_dma_sge { * capability bit for this, driver should not return error if this flag was set. */ #define RTE_DMA_OP_FLAG_LLC RTE_BIT64(2) +/** Source handle is set. + * Used for inter-domain operations to indicate source handle value will be + * meaningful and can be used by hardware to learn source PASID. + */ +#define RTE_DMA_OP_FLAG_SRC_HANDLE RTE_BIT64(16) +/** Destination handle is set. + * Used for inter-domain operations to indicate destination handle value will be + * meaningful and can be used by hardware to learn destination PASID. + */ +#define RTE_DMA_OP_FLAG_DST_HANDLE RTE_BIT64(17) /**@}*/ /** @@ -1141,6 +1155,125 @@ rte_dma_burst_capacity(int16_t dev_id, uint16_t vchan) return (*obj->burst_capacity)(obj->dev_private, vchan); } +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue an inter-domain copy operation. + * + * This queues up an inter-domain copy operation to be performed by hardware, if + * the 'flags' parameter contains RTE_DMA_OP_FLAG_SUBMIT then trigger doorbell + * to begin this operation, otherwise do not trigger doorbell. + * + * The source and destination handle parameters are arbitrary opaque values, + * currently meant to be provided by private device driver API's. If the source + * handle value is meaningful, RTE_DMA_OP_FLAG_SRC_HANDLE flag must be set. + * Similarly, if the destination handle value is meaningful, + * RTE_DMA_OP_FLAG_DST_HANDLE flag must be set. Source and destination handle + * values are meant to provide information to the hardware about source and/or + * destination PASID for the inter-domain copy operation. + * + * @param dev_id + * The identifier of the device. + * @param vchan + * The identifier of virtual DMA channel. + * @param src + * The address of the source buffer (if `src_handle` is set, source address + * will be in address space of process referred to by source handle). + * @param dst + * The address of the destination buffer (if `dst_handle` is set, destination + * address will be in address space of process referred to by destination + * handle). + * @param length + * The length of the data to be copied. + * @param src_handle + * Source handle value (if used, RTE_DMA_OP_FLAG_SRC_HANDLE flag must be set). + * @param dst_handle + * Destination handle value (if used, RTE_DMA_OP_FLAG_DST_HANDLE flag must be + * set). + * @param flags + * Flags for this operation. + * @return + * - 0..UINT16_MAX: index of enqueued job. + * - -ENOSPC: if no space left to enqueue. + * - other values < 0 on failure. + */ +__rte_experimental +static inline int +rte_dma_copy_inter_dom(int16_t dev_id, uint16_t vchan, rte_iova_t src, + rte_iova_t dst, uint32_t length, uint16_t src_handle, + uint16_t dst_handle, uint64_t flags) +{ + struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; + +#ifdef RTE_DMADEV_DEBUG + if (!rte_dma_is_valid(dev_id) || length == 0) + return -EINVAL; + if (*obj->copy_inter_dom == NULL) + return -ENOTSUP; +#endif + return (*obj->copy_inter_dom)(obj->dev_private, vchan, src, dst, length, + src_handle, dst_handle, flags); +} + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enqueue an inter-domain fill operation. + * + * This queues up an inter-domain fill operation to be performed by hardware, if + * the 'flags' parameter contains RTE_DMA_OP_FLAG_SUBMIT then trigger doorbell + * to begin this operation, otherwise do not trigger doorbell. + * + * The source and destination handle parameters are arbitrary opaque values, + * currently meant to be provided by private device driver API's. If the source + * handle value is meaningful, RTE_DMA_OP_FLAG_SRC_HANDLE flag must be set. + * Similarly, if the destination handle value is meaningful, + * RTE_DMA_OP_FLAG_DST_HANDLE flag must be set. Source and destination handle + * values are meant to provide information to the hardware about source and/or + * destination PASID for the inter-domain fill operation. + * + * @param dev_id + * The identifier of the device. + * @param vchan + * The identifier of virtual DMA channel. + * @param pattern + * The pattern to populate the destination buffer with. + * @param dst + * The address of the destination buffer. + * @param length + * The length of the destination buffer. + * @param dst_handle + * Destination handle value (if used, RTE_DMA_OP_FLAG_DST_HANDLE flag must be + * set). + * @param flags + * Flags for this operation. + * @return + * - 0..UINT16_MAX: index of enqueued job. + * - -ENOSPC: if no space left to enqueue. + * - other values < 0 on failure. + */ +__rte_experimental +static inline int +rte_dma_fill_inter_dom(int16_t dev_id, uint16_t vchan, uint64_t pattern, + rte_iova_t dst, uint32_t length, uint16_t dst_handle, + uint64_t flags) +{ + struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; + +#ifdef RTE_DMADEV_DEBUG + if (!rte_dma_is_valid(dev_id) || length == 0) + return -EINVAL; + if (*obj->fill_inter_dom == NULL) + return -ENOTSUP; +#endif + + return (*obj->fill_inter_dom)(obj->dev_private, vchan, pattern, dst, + length, dst_handle, flags); +} + + #ifdef __cplusplus } #endif diff --git a/lib/dmadev/rte_dmadev_core.h b/lib/dmadev/rte_dmadev_core.h index 064785686f..b3a020f9de 100644 --- a/lib/dmadev/rte_dmadev_core.h +++ b/lib/dmadev/rte_dmadev_core.h @@ -50,6 +50,16 @@ typedef uint16_t (*rte_dma_completed_status_t)(void *dev_private, /** @internal Used to check the remaining space in descriptor ring. */ typedef uint16_t (*rte_dma_burst_capacity_t)(const void *dev_private, uint16_t vchan); +/** @internal Used to enqueue an inter-domain copy operation. */ +typedef int (*rte_dma_copy_inter_dom_t)(void *dev_private, uint16_t vchan, + rte_iova_t src, rte_iova_t dst, unsigned int length, + uint16_t src_handle, uint16_t dst_handle, uint64_t flags); +/** @internal Used to enqueue an inter-domain fill operation. */ +typedef int (*rte_dma_fill_inter_dom_t)(void *dev_private, uint16_t vchan, + uint64_t pattern, rte_iova_t dst, uint32_t length, + uint16_t dst_handle, uint64_t flags); + + /** * @internal * Fast-path dmadev functions and related data are hold in a flat array. @@ -73,6 +83,8 @@ struct rte_dma_fp_object { rte_dma_completed_t completed; rte_dma_completed_status_t completed_status; rte_dma_burst_capacity_t burst_capacity; + rte_dma_copy_inter_dom_t copy_inter_dom; + rte_dma_fill_inter_dom_t fill_inter_dom; } __rte_aligned(128); extern struct rte_dma_fp_object *rte_dma_fp_objs;