From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 5/5] mempool/dpaa2: vfio dmamap for user allocated memory
Date: Tue, 25 Jun 2019 16:14:11 +0530 [thread overview]
Message-ID: <20190625104411.19565-5-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20190625104411.19565-1-hemant.agrawal@nxp.com>
From: Sachin Saxena <sachin.saxena@nxp.com>
Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
---
drivers/bus/fslmc/fslmc_vfio.c | 39 +++++++++++++++++++++
drivers/bus/fslmc/fslmc_vfio.h | 4 ++-
drivers/bus/fslmc/rte_bus_fslmc_version.map | 6 ++++
drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 13 +++++++
4 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 711780e74..e44bd31b9 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -358,6 +358,45 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
return ret;
}
+__rte_experimental
+int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size)
+{
+ int ret;
+ struct fslmc_vfio_group *group;
+ struct vfio_iommu_type1_dma_map dma_map = {
+ .argsz = sizeof(struct vfio_iommu_type1_dma_map),
+ .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
+ };
+
+ if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) {
+ DPAA2_BUS_DEBUG("Running in NOIOMMU mode");
+ return 0;
+ }
+
+ /* SET DMA MAP for IOMMU */
+ group = &vfio_group;
+ if (!group->container) {
+ DPAA2_BUS_ERR("Container is not connected");
+ return -1;
+ }
+
+ dma_map.size = size;
+ dma_map.vaddr = vaddr;
+ dma_map.iova = iova;
+
+ DPAA2_BUS_DEBUG("VFIO dmamap 0x%llx:0x%llx, size 0x%llx\n",
+ dma_map.vaddr, dma_map.iova, dma_map.size);
+ ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA,
+ &dma_map);
+ if (ret) {
+ printf("Unable to map DMA address (errno = %d)\n",
+ errno);
+ return ret;
+ }
+
+ return 0;
+}
+
int rte_fslmc_vfio_dmamap(void)
{
int i = 0, ret;
diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h
index 9e2c4feef..e877255ea 100644
--- a/drivers/bus/fslmc/fslmc_vfio.h
+++ b/drivers/bus/fslmc/fslmc_vfio.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2016 NXP
+ * Copyright 2016,2019 NXP
*
*/
@@ -50,5 +50,7 @@ int fslmc_vfio_process_group(void);
char *fslmc_get_container(void);
int fslmc_get_container_group(int *gropuid);
int rte_fslmc_vfio_dmamap(void);
+__rte_experimental
+int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size);
#endif /* _FSLMC_VFIO_H_ */
diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map
index e86007384..4da787236 100644
--- a/drivers/bus/fslmc/rte_bus_fslmc_version.map
+++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map
@@ -141,3 +141,9 @@ DPDK_19.05 {
qbman_result_eqresp_set_rspid;
qbman_swp_enqueue_multiple_fd;
} DPDK_18.11;
+
+EXPERIMENTAL {
+ global:
+
+ rte_fslmc_vfio_mem_dmamap;
+};
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index da66577cc..f26c30b00 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -23,6 +23,7 @@
#include <rte_dev.h>
#include "rte_dpaa2_mempool.h"
+#include "fslmc_vfio.h"
#include <fslmc_logs.h>
#include <mc/fsl_dpbp.h>
#include <portal/dpaa2_hw_pvt.h>
@@ -405,6 +406,18 @@ dpaa2_populate(struct rte_mempool *mp, unsigned int max_objs,
void *vaddr, rte_iova_t paddr, size_t len,
rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg)
{
+ struct rte_memseg_list *msl;
+ /* The memsegment list exists incase the memory is not external.
+ * So, DMA-Map is required only when memory is provided by user,
+ * i.e. External.
+ */
+ msl = rte_mem_virt2memseg_list(vaddr);
+
+ if (!msl) {
+ DPAA2_MEMPOOL_DEBUG("Memsegment is External.\n");
+ rte_fslmc_vfio_mem_dmamap((size_t)vaddr,
+ (size_t)paddr, (size_t)len);
+ }
/* Insert entry into the PA->VA Table */
dpaax_iova_table_update(paddr, vaddr, len);
--
2.17.1
next prev parent reply other threads:[~2019-06-25 10:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 10:44 [dpdk-dev] [PATCH 1/5] bus/fslmc: support device iteration Hemant Agrawal
2019-06-25 10:44 ` [dpdk-dev] [PATCH 2/5] bus/fslmc: enhance error handling for dev parsing Hemant Agrawal
2019-06-25 10:44 ` [dpdk-dev] [PATCH 3/5] bus/fslmc: dynamic iommu mode detection Hemant Agrawal
2019-06-25 10:44 ` [dpdk-dev] [PATCH 4/5] bus/fslmc: use cinh read for eqcr ci on ls1088 platform Hemant Agrawal
2019-06-25 10:44 ` Hemant Agrawal [this message]
2019-06-26 21:50 ` [dpdk-dev] [PATCH 1/5] bus/fslmc: support device iteration Thomas Monjalon
2019-06-27 9:20 ` Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 0/5] FSLMC bus enchancements Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 1/5] bus/fslmc: support device iteration Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 0/5] FSLMC bus enchancements Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 1/5] bus/fslmc: support device iteration Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 2/5] bus/fslmc: enhance error handling for dev parsing Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 3/5] bus/fslmc: dynamic iommu mode detection Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 4/5] bus/fslmc: use cinh read for eqcr ci on ls1088 platform Hemant Agrawal
2019-07-15 8:44 ` [dpdk-dev] [PATCH v3 5/5] mempool/dpaa2: vfio dmamap for user allocated memory Hemant Agrawal
2019-07-15 21:53 ` [dpdk-dev] [PATCH v3 0/5] FSLMC bus enchancements Thomas Monjalon
2019-07-16 11:40 ` Ferruh Yigit
2019-07-16 13:36 ` Thomas Monjalon
2019-07-16 13:43 ` Bruce Richardson
2019-07-19 19:09 ` Ferruh Yigit
2019-07-22 6:56 ` Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 2/5] bus/fslmc: enhance error handling for dev parsing Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 3/5] bus/fslmc: dynamic iommu mode detection Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 4/5] bus/fslmc: use cinh read for eqcr ci on ls1088 platform Hemant Agrawal
2019-06-27 9:33 ` [dpdk-dev] [PATCH v2 5/5] mempool/dpaa2: vfio dmamap for user allocated memory Hemant Agrawal
2019-07-07 19:55 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190625104411.19565-5-hemant.agrawal@nxp.com \
--to=hemant.agrawal@nxp.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).