DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shreyansh Jain <shreyansh.jain@nxp.com>
To: <dev@dpdk.org>
Cc: <hemant.agrawal@nxp.com>, <thomas@monjalon.net>,
	Shreyansh Jain <shreyansh.jain@nxp.com>
Subject: [dpdk-dev] [PATCH 1/6] bus/fslmc: support only single group and container
Date: Fri, 18 Aug 2017 18:21:22 +0530	[thread overview]
Message-ID: <20170818125127.22346-2-shreyansh.jain@nxp.com> (raw)
In-Reply-To: <20170818125127.22346-1-shreyansh.jain@nxp.com>

Currently DPAA2 code doesn't support multiple groups and containers.
Remove such provision in code to simplify code.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 70 +++++++++++++++---------------------------
 drivers/bus/fslmc/fslmc_vfio.h |  3 +-
 2 files changed, 26 insertions(+), 47 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 45e5927..3423b57 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -62,8 +62,6 @@
 #include "portal/dpaa2_hw_pvt.h"
 #include "portal/dpaa2_hw_dpio.h"
 
-#define VFIO_MAX_CONTAINERS	1
-
 #define FSLMC_VFIO_LOG(level, fmt, args...) \
 	RTE_LOG(level, EAL, "%s(): " fmt "\n", __func__, ##args)
 
@@ -71,8 +69,8 @@
 #define SYSFS_FSL_MC_DEVICES "/sys/bus/fsl-mc/devices"
 
 /* Number of VFIO containers & groups with in */
-static struct fslmc_vfio_group vfio_groups[VFIO_MAX_GRP];
-static struct fslmc_vfio_container vfio_containers[VFIO_MAX_CONTAINERS];
+static struct fslmc_vfio_group vfio_group;
+static struct fslmc_vfio_container vfio_container;
 static int container_device_fd;
 static uint32_t *msi_intr_vaddr;
 void *(*rte_mcp_ptr_list);
@@ -90,22 +88,18 @@ rte_fslmc_object_register(struct rte_dpaa2_object *object)
 	TAILQ_INSERT_TAIL(&fslmc_obj_list, object, next);
 }
 
-static int vfio_connect_container(struct fslmc_vfio_group *vfio_group)
+static int vfio_connect_container(void)
 {
-	struct fslmc_vfio_container *container;
-	int i, fd, ret;
+	int fd, ret;
 
 	/* Try connecting to vfio container if already created */
-	for (i = 0; i < VFIO_MAX_CONTAINERS; i++) {
-		container = &vfio_containers[i];
-		if (!ioctl(vfio_group->fd, VFIO_GROUP_SET_CONTAINER,
-			   &container->fd)) {
-			FSLMC_VFIO_LOG(INFO,
-			    "Container pre-exists with FD[0x%x] for this group",
-			    container->fd);
-			vfio_group->container = container;
-			return 0;
-		}
+	if (!ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER,
+		&vfio_container.fd)) {
+		FSLMC_VFIO_LOG(INFO,
+		    "Container pre-exists with FD[0x%x] for this group",
+		    vfio_container.fd);
+		vfio_group.container = &vfio_container;
+		return 0;
 	}
 
 	/* Opens main vfio file descriptor which represents the "container" */
@@ -118,7 +112,7 @@ static int vfio_connect_container(struct fslmc_vfio_group *vfio_group)
 	/* Check whether support for SMMU type IOMMU present or not */
 	if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
 		/* Connect group to container */
-		ret = ioctl(vfio_group->fd, VFIO_GROUP_SET_CONTAINER, &fd);
+		ret = ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER, &fd);
 		if (ret) {
 			FSLMC_VFIO_LOG(ERR, "Failed to setup group container");
 			close(fd);
@@ -137,23 +131,11 @@ static int vfio_connect_container(struct fslmc_vfio_group *vfio_group)
 		return -EINVAL;
 	}
 
-	container = NULL;
-	for (i = 0; i < VFIO_MAX_CONTAINERS; i++) {
-		if (vfio_containers[i].used)
-			continue;
-		container = &vfio_containers[i];
-	}
-	if (!container) {
-		FSLMC_VFIO_LOG(ERR, "No free container found");
-		close(fd);
-		return -ENOMEM;
-	}
+	vfio_container.used = 1;
+	vfio_container.fd = fd;
+	vfio_container.group = &vfio_group;
+	vfio_group.container = &vfio_container;
 
-	container->used = 1;
-	container->fd = fd;
-	container->group_list[container->index] = vfio_group;
-	vfio_group->container = container;
-	container->index++;
 	return 0;
 }
 
@@ -222,7 +204,7 @@ int rte_fslmc_vfio_dmamap(void)
 #endif
 
 		/* SET DMA MAP for IOMMU */
-		group = &vfio_groups[0];
+		group = &vfio_group;
 
 		if (!group->container) {
 			FSLMC_VFIO_LOG(ERR, "Container is not connected ");
@@ -392,7 +374,7 @@ int fslmc_vfio_process_group(void)
 	char path[PATH_MAX];
 	int64_t v_addr;
 	int ndev_count;
-	struct fslmc_vfio_group *group = &vfio_groups[0];
+	struct fslmc_vfio_group *group = &vfio_group;
 	static int process_once;
 
 	/* if already done once */
@@ -569,7 +551,7 @@ int fslmc_vfio_setup_group(void)
 {
 	struct fslmc_vfio_group *group = NULL;
 	int groupid;
-	int ret, i;
+	int ret;
 	char *container;
 	struct vfio_group_status status = { .argsz = sizeof(status) };
 
@@ -599,13 +581,11 @@ int fslmc_vfio_setup_group(void)
 	FSLMC_VFIO_LOG(DEBUG, "VFIO iommu group id = %d", groupid);
 
 	/* Check if group already exists */
-	for (i = 0; i < VFIO_MAX_GRP; i++) {
-		group = &vfio_groups[i];
-		if (group->groupid == groupid) {
-			FSLMC_VFIO_LOG(ERR, "groupid already exists %d",
-				       groupid);
-			return 0;
-		}
+	group = &vfio_group;
+	if (group->groupid == groupid) {
+		FSLMC_VFIO_LOG(ERR, "groupid already exists %d",
+			       groupid);
+		return 0;
 	}
 
 	/* get the actual group fd */
@@ -637,7 +617,7 @@ int fslmc_vfio_setup_group(void)
 	/* check if group does not have a container yet */
 	if (!(status.flags & VFIO_GROUP_FLAGS_CONTAINER_SET)) {
 		/* Now connect this IOMMU group to given container */
-		ret = vfio_connect_container(group);
+		ret = vfio_connect_container();
 		if (ret) {
 			FSLMC_VFIO_LOG(ERR, "VFIO error connecting container"
 				       " with groupid %d", groupid);
diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h
index 0aff9b1..942a33c 100644
--- a/drivers/bus/fslmc/fslmc_vfio.h
+++ b/drivers/bus/fslmc/fslmc_vfio.h
@@ -44,7 +44,6 @@
 #define DPAA2_MC_DPBP_DEVID	10
 #define DPAA2_MC_DPCI_DEVID	11
 
-#define VFIO_MAX_GRP 1
 
 typedef struct fslmc_vfio_device {
 	int fd; /* fslmc root container device ?? */
@@ -64,7 +63,7 @@ typedef struct fslmc_vfio_container {
 	int fd; /* /dev/vfio/vfio */
 	int used;
 	int index; /* index in group list */
-	struct fslmc_vfio_group *group_list[VFIO_MAX_GRP];
+	struct fslmc_vfio_group *group;
 } fslmc_vfio_container;
 
 struct rte_dpaa2_object;
-- 
2.9.3

  reply	other threads:[~2017-08-18 12:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18 12:51 [dpdk-dev] [PATCH 0/6] NXP DPAA2: Refactor bus scan/probe code Shreyansh Jain
2017-08-18 12:51 ` Shreyansh Jain [this message]
2017-08-18 12:51 ` [dpdk-dev] [PATCH 2/6] bus/fslmc: introduce new device type enumerator Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 3/6] net/dpaa2: update driver type field Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 4/6] crypto/dpaa2_sec: " Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 5/6] drivers: refactor DPAA2 object definition Shreyansh Jain
2017-08-18 12:51 ` [dpdk-dev] [PATCH 6/6] bus/fslmc: refactor scan and probe functions Shreyansh Jain
2017-08-25 10:19 ` [dpdk-dev] [PATCH v2 0/6] NXP DPAA2: Refactor bus scan/probe code Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 1/6] bus/fslmc: support only single group and container Shreyansh Jain
2017-09-18 11:15     ` santosh
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 2/6] bus/fslmc: introduce new device type enumerator Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 3/6] crypto/dpaa2_sec: update driver type field Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 4/6] net/dpaa2: " Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 5/6] drivers: refactor DPAA2 object definition Shreyansh Jain
2017-08-25 10:19   ` [dpdk-dev] [PATCH v2 6/6] bus/fslmc: refactor scan and probe functions Shreyansh Jain
2017-09-11 14:06   ` [dpdk-dev] [PATCH v2 0/6] NXP DPAA2: Refactor bus scan/probe code Ferruh Yigit
2017-09-11 14:25     ` Shreyansh Jain
2017-09-25  7:07       ` Hemant Agrawal
2017-09-18 14:36     ` santosh
2017-10-05 23:09     ` 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=20170818125127.22346-2-shreyansh.jain@nxp.com \
    --to=shreyansh.jain@nxp.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=thomas@monjalon.net \
    /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).