DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hemant Agrawal <hemant.agrawal@nxp.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, shreyansh.jain@nxp.com
Subject: [dpdk-dev] [PATCH 1/5] bus/dpaa: support device blacklisting
Date: Wed, 25 Apr 2018 18:26:58 +0530	[thread overview]
Message-ID: <1524661022-21484-1-git-send-email-hemant.agrawal@nxp.com> (raw)

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 doc/guides/cryptodevs/dpaa_sec.rst |  13 +++++
 doc/guides/nics/dpaa.rst           |  10 ++++
 drivers/bus/dpaa/dpaa_bus.c        | 101 ++++++++++++++++++++++++++++++-------
 drivers/bus/dpaa/rte_dpaa_bus.h    |   2 -
 4 files changed, 106 insertions(+), 20 deletions(-)

diff --git a/doc/guides/cryptodevs/dpaa_sec.rst b/doc/guides/cryptodevs/dpaa_sec.rst
index 2964e83..9988ee1 100644
--- a/doc/guides/cryptodevs/dpaa_sec.rst
+++ b/doc/guides/cryptodevs/dpaa_sec.rst
@@ -78,6 +78,19 @@ Supported DPAA SoCs
 * LS1046A/LS1026A
 * LS1043A/LS1023A
 
+Whitelisting & Blacklisting
+---------------------------
+
+For blacklisting a DPAA device, following commands can be used.
+
+ .. code-block:: console
+
+    <dpdk app> <EAL args> -b "dpaa_bus:dpaa-secX" -- ...
+    e.g. "dpaa_bus:dpaa-sec0"
+
+    or to disable all 4 SEC devices
+    -b "dpaa_sec:dpaa-sec0"  -b "dpaa_sec:dpaa-sec1" -b "dpaa_sec:dpaa-sec2" -b "dpaa_sec:dpaa-sec3"
+
 Limitations
 -----------
 
diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index 0a13996..620c045 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -162,6 +162,16 @@ Manager.
   this pool.
 
 
+Whitelisting & Blacklisting
+---------------------------
+
+For blacklisting a DPAA device, following commands can be used.
+
+ .. code-block:: console
+
+    <dpdk app> <EAL args> -b "dpaa_bus:fmX-macY" -- ...
+    e.g. "dpaa_bus:fm1-mac4"
+
 Supported DPAA SoCs
 -------------------
 
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index ffc90a7..2b85c9e 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -54,6 +54,8 @@ pthread_key_t dpaa_portal_key;
 
 unsigned int dpaa_svr_family;
 
+#define FSL_DPAA_BUS_NAME	dpaa_bus
+
 RTE_DEFINE_PER_LCORE(bool, dpaa_io);
 RTE_DEFINE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs);
 
@@ -129,6 +131,22 @@ dpaa_sec_available(void)
 
 static void dpaa_clean_device_list(void);
 
+static struct rte_devargs *
+dpaa_devargs_lookup(struct rte_dpaa_device *dev)
+{
+	struct rte_devargs *devargs;
+	char dev_name[32];
+
+	RTE_EAL_DEVARGS_FOREACH("dpaa_bus", devargs) {
+		devargs->bus->parse(devargs->name, &dev_name);
+		if (strcmp(dev_name, dev->device.name) == 0) {
+			DPAA_BUS_INFO("**Devargs matched %s", dev_name);
+			return devargs;
+		}
+	}
+	return NULL;
+}
+
 static int
 dpaa_create_device_list(void)
 {
@@ -162,6 +180,7 @@ dpaa_create_device_list(void)
 			fman_intf->mac_idx);
 		DPAA_BUS_LOG(DEBUG, "Device added: %s", dev->name);
 		dev->device.name = dev->name;
+		dev->device.devargs = dpaa_devargs_lookup(dev);
 
 		dpaa_add_to_device_list(dev);
 	}
@@ -198,6 +217,8 @@ dpaa_create_device_list(void)
 		memset(dev->name, 0, RTE_ETH_NAME_MAX_LEN);
 		sprintf(dev->name, "dpaa-sec%d", i);
 		DPAA_BUS_LOG(DEBUG, "Device added: %s", dev->name);
+		dev->device.name = dev->name;
+		dev->device.devargs = dpaa_devargs_lookup(dev);
 
 		dpaa_add_to_device_list(dev);
 	}
@@ -357,6 +378,51 @@ dpaa_portal_finish(void *arg)
 	RTE_PER_LCORE(dpaa_io) = false;
 }
 
+static int
+rte_dpaa_bus_parse(const char *name, void *out_name)
+{
+	int i, j;
+	int max_fman = 2, max_macs = 16;
+	char *sep = strchr(name, ':');
+
+	if (strncmp(name, RTE_STR(FSL_DPAA_BUS_NAME),
+		strlen(RTE_STR(FSL_DPAA_BUS_NAME)))) {
+		return -EINVAL;
+	}
+
+	if (!sep) {
+		DPAA_BUS_ERR("Incorrect device name observed");
+		return -EINVAL;
+	}
+
+	sep = (char *) (sep + 1);
+
+	for (i = 0; i < max_fman; i++) {
+		for (j = 0; j < max_macs; j++) {
+			char fm_name[16];
+			snprintf(fm_name, 16, "fm%d-mac%d", i, j);
+			if (strcmp(fm_name, sep) == 0) {
+				if (out_name)
+					strcpy(out_name, sep);
+				return 0;
+			}
+		}
+	}
+
+	for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) {
+		char sec_name[16];
+
+		snprintf(sec_name, 16, "dpaa-sec%d", i);
+		if (strcmp(sec_name, sep) == 0) {
+			if (out_name)
+				strcpy(out_name, sep);
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+
 #define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa"
 #define DPAA_DEV_PATH2 "/sys/devices/platform/fsl,dpaa"
 
@@ -458,22 +524,15 @@ static int
 rte_dpaa_device_match(struct rte_dpaa_driver *drv,
 		      struct rte_dpaa_device *dev)
 {
-	int ret = -1;
-
-	BUS_INIT_FUNC_TRACE();
-
 	if (!drv || !dev) {
 		DPAA_BUS_DEBUG("Invalid drv or dev received.");
-		return ret;
+		return -1;
 	}
 
-	if (drv->drv_type == dev->device_type) {
-		DPAA_BUS_INFO("Device: %s matches for driver: %s",
-			      dev->name, drv->driver.name);
-		ret = 0; /* Found a match */
-	}
+	if (drv->drv_type == dev->device_type)
+		return 0;
 
-	return ret;
+	return -1;
 }
 
 static int
@@ -484,8 +543,7 @@ rte_dpaa_bus_probe(void)
 	struct rte_dpaa_driver *drv;
 	FILE *svr_file = NULL;
 	unsigned int svr_ver;
-
-	BUS_INIT_FUNC_TRACE();
+	int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST;
 
 	/* For each registered driver, and device, call the driver->probe */
 	TAILQ_FOREACH(dev, &rte_dpaa_bus.device_list, next) {
@@ -494,13 +552,19 @@ rte_dpaa_bus_probe(void)
 			if (ret)
 				continue;
 
-			if (!drv->probe)
+			if (!drv->probe ||
+			    (dev->device.devargs &&
+			    dev->device.devargs->policy == RTE_DEV_BLACKLISTED))
 				continue;
 
-			ret = drv->probe(drv, dev);
-			if (ret)
-				DPAA_BUS_ERR("Unable to probe.\n");
-
+			if (probe_all ||
+			    (dev->device.devargs &&
+			    dev->device.devargs->policy ==
+			    RTE_DEV_WHITELISTED)) {
+				ret = drv->probe(drv, dev);
+				if (ret)
+					DPAA_BUS_ERR("Unable to probe.\n");
+			}
 			break;
 		}
 	}
@@ -557,6 +621,7 @@ struct rte_dpaa_bus rte_dpaa_bus = {
 	.bus = {
 		.scan = rte_dpaa_bus_scan,
 		.probe = rte_dpaa_bus_probe,
+		.parse = rte_dpaa_bus_parse,
 		.find_device = rte_dpaa_find_device,
 		.get_iommu_class = rte_dpaa_get_iommu_class,
 	},
diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h
index 89aeac2..8f7e18c 100644
--- a/drivers/bus/dpaa/rte_dpaa_bus.h
+++ b/drivers/bus/dpaa/rte_dpaa_bus.h
@@ -15,8 +15,6 @@
 #include <of.h>
 #include <netcfg.h>
 
-#define FSL_DPAA_BUS_NAME	"FSL_DPAA_BUS"
-
 #define DPAA_MEMPOOL_OPS_NAME	"dpaa"
 
 #define DEV_TO_DPAA_DEVICE(ptr)	\
-- 
2.7.4

             reply	other threads:[~2018-04-25 12:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25 12:56 Hemant Agrawal [this message]
2018-04-25 12:56 ` [dpdk-dev] [PATCH 2/5] bus/fslmc: " Hemant Agrawal
2018-04-25 12:57 ` [dpdk-dev] [PATCH 3/5] bus/fslmc: minor improvements in debug logging Hemant Agrawal
2018-04-25 12:57 ` [dpdk-dev] [PATCH 4/5] net/dpaa: fix the xstats implementation Hemant Agrawal
2018-04-25 12:57 ` [dpdk-dev] [PATCH 5/5] bus/dpaa: improve the dynamic logging Hemant Agrawal
2018-05-09  5:41 ` [dpdk-dev] [PATCH 1/5] bus/dpaa: support device blacklisting Shreyansh Jain
2018-05-13 22:38   ` 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=1524661022-21484-1-git-send-email-hemant.agrawal@nxp.com \
    --to=hemant.agrawal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.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).