DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Cc: "ferruh.yigit@intel.com" <ferruh.yigit@intel.com>,
	Shreyansh Jain <shreyansh.jain@nxp.com>,
	Pankaj Chauhan <pankaj.chauhan@nxp.com>,
	"M.h. Lian" <minghuan.lian@nxp.com>
Subject: [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO
Date: Thu, 27 Dec 2018 06:23:21 +0000	[thread overview]
Message-ID: <20181227062233.30781-21-hemant.agrawal@nxp.com> (raw)
In-Reply-To: <20181227062233.30781-1-hemant.agrawal@nxp.com>

From: Pankaj Chauhan <pankaj.chauhan@nxp.com>

This is required to map any accelerator memory
and PCI address to VFIO using QDMA.

Signed-off-by: Minghuan Lian <Minghuan.Lian@nxp.com>
Signed-off-by: Pankaj Chauhan <pankaj.chauhan@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c              | 42 +++++++++++++++++++++
 drivers/bus/fslmc/fslmc_vfio.h              |  1 +
 drivers/bus/fslmc/rte_bus_fslmc_version.map |  7 ++++
 3 files changed, 50 insertions(+)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..9befc8087 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -50,6 +50,7 @@ static struct fslmc_vfio_group vfio_group;
 static struct fslmc_vfio_container vfio_container;
 static int container_device_fd;
 static char *g_container;
+static int fslmc_iommu_type;
 static uint32_t *msi_intr_vaddr;
 void *(*rte_mcp_ptr_list);
 
@@ -90,6 +91,9 @@ fslmc_get_container_group(int *groupid)
 		}
 	}
 
+	fslmc_iommu_type = (rte_vfio_noiommu_is_enabled() == 1) ?
+		RTE_VFIO_NOIOMMU : VFIO_TYPE1_IOMMU;
+
 	/* get group number */
 	ret = rte_vfio_get_group_num(SYSFS_FSL_MC_DEVICES,
 				     g_container, groupid);
@@ -344,6 +348,44 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 	return ret;
 }
 
+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;
+
+	printf("PCIe vfio map 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..4e750d623 100644
--- a/drivers/bus/fslmc/fslmc_vfio.h
+++ b/drivers/bus/fslmc/fslmc_vfio.h
@@ -50,5 +50,6 @@ int fslmc_vfio_process_group(void);
 char *fslmc_get_container(void);
 int fslmc_get_container_group(int *gropuid);
 int rte_fslmc_vfio_dmamap(void);
+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 dcc4e082e..c4192d978 100644
--- a/drivers/bus/fslmc/rte_bus_fslmc_version.map
+++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map
@@ -129,3 +129,10 @@ DPDK_18.11 {
 	dpci_set_opr;
 
 } DPDK_18.05;
+
+DPDK_19.02 {
+	global:
+
+	rte_fslmc_vfio_mem_dmamap;
+
+} DPDK_18.11;
-- 
2.17.1

  parent reply	other threads:[~2018-12-27  6:23 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 01/20] bus/fslmc: fix to reset portal memory before use Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 02/20] bus/fslmc: fix the ring mode to use correct cache settings Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 03/20] bus/fslmc: fix to use correct physical core for logical core Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 04/20] net/dpaa2: fix bad check for not-null Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 05/20] bus/fslmc: fix to convert error msg to warning Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 06/20] bus/fslmc: fix parse method for bus devices Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 07/20] net/dpaa2: fix device init for secondary process Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 08/20] net/dpaa2: enable optional timestamp in mbuf Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 09/20] bus/fslmc: upgrade to latest qbman library Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 10/20] bus/fslmc: add dynamic config for memback portal mode Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 11/20] bus/fslmc: rename portal pi index to consumer index Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 12/20] bus/fslmc: make portal func static Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 13/20] net/dpaa2: add dpdmux mc flib Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 14/20] bus/fslmc: add support for scanning DPDMUX object Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 15/20] net/dpaa2: add dpdmux initialization and configuration Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 16/20] net/dpaa2: add API to support custom hash key Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 17/20] mempool/dpaa2: support saving context of buffer pool Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 18/20] net/dpaa2: change ref of device to private device Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 19/20] bus/fslmc: add support for secondary processes Hemant Agrawal
2018-12-27  6:23 ` Hemant Agrawal [this message]
2019-01-08 14:10   ` [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO Ferruh Yigit
2019-01-10  9:58     ` Shreyansh Jain
2019-01-11 11:58       ` Ferruh Yigit
2019-01-11 12:16         ` Shreyansh Jain
2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 01/20] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 02/20] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 03/20] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 04/20] net/dpaa2: fix bad check for not-null Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 05/20] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 06/20] bus/fslmc: fix parse method for bus devices Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 07/20] net/dpaa2: fix device init for secondary process Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 08/20] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 09/20] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 10/20] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 11/20] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 12/20] bus/fslmc: make portal func static Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 13/20] net/dpaa2: add dpdmux mc flib Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 14/20] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 15/20] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 16/20] net/dpaa2: add API to support custom hash key Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 17/20] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 18/20] net/dpaa2: change reference to private device Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 19/20] bus/fslmc: add support for secondary processes Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 20/20] bus/fslmc: add function to map any addr via VFIO Shreyansh Jain
2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 01/19] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 02/19] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 03/19] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 04/19] net/dpaa2: fix bad check for not-null Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 05/19] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 06/19] bus/fslmc: fix parse method for bus devices Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 07/19] net/dpaa2: fix device init for secondary process Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 08/19] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 09/19] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 10/19] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 11/19] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 12/19] bus/fslmc: make portal func static Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 13/19] net/dpaa2: add dpdmux mc flib Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 14/19] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 15/19] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 16/19] net/dpaa2: add API to support custom hash key Shreyansh Jain
2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 17/19] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 18/19] net/dpaa2: change reference to private device Shreyansh Jain
2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 19/19] bus/fslmc: add support for secondary processes Shreyansh Jain
2019-01-11 15:51     ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Ferruh Yigit
2019-01-11 16:12       ` Ferruh Yigit
2019-01-14  5:20         ` Shreyansh Jain
2019-01-14  5:19     ` Shreyansh Jain

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=20181227062233.30781-21-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=minghuan.lian@nxp.com \
    --cc=pankaj.chauhan@nxp.com \
    --cc=shreyansh.jain@nxp.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).