bus/dpaa: support device blacklisting

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
This commit is contained in:
Hemant Agrawal 2018-04-25 18:26:58 +05:30 committed by Thomas Monjalon
parent e77fec6949
commit 6e0752205b
4 changed files with 106 additions and 20 deletions

View File

@ -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
-----------

View File

@ -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
-------------------

View File

@ -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,
},

View File

@ -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) \