From: Hemant Agrawal Date: Tue, 26 Mar 2019 12:01:46 +0000 (+0000) Subject: bus/dpaa: delay fman device list to bus probe X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4762b3d419c357bd00012835e6fd430cde799dca;p=dpdk.git bus/dpaa: delay fman device list to bus probe The fman device list need to be accessed across processes. The hw device structures should be allocated with rte_calloc instead of calloc. The rte_calloc is not available at the time of bus scan, so better prepare the device list at probe. Signed-off-by: Hemant Agrawal --- diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index 06762e0f40..8fa9b8caef 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -12,6 +12,7 @@ /* This header declares the driver interface we implement */ #include #include +#include #include #include @@ -177,7 +178,7 @@ fman_if_init(const struct device_node *dpa_node) mprop = "fsl,fman-mac"; /* Allocate an object for this network interface */ - __if = malloc(sizeof(*__if)); + __if = rte_malloc(NULL, sizeof(*__if), RTE_CACHE_LINE_SIZE); if (!__if) { FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*__if)); goto err; @@ -433,7 +434,7 @@ fman_if_init(const struct device_node *dpa_node) uint64_t bpool_host[6] = {0}; const char *pname; /* Allocate an object for the pool */ - bpool = malloc(sizeof(*bpool)); + bpool = rte_malloc(NULL, sizeof(*bpool), RTE_CACHE_LINE_SIZE); if (!bpool) { FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*bpool)); goto err; @@ -443,7 +444,7 @@ fman_if_init(const struct device_node *dpa_node) if (!pool_node) { FMAN_ERR(-ENXIO, "%s: bad fsl,bman-buffer-pools\n", dname); - free(bpool); + rte_free(bpool); goto err; } pname = pool_node->full_name; @@ -451,7 +452,7 @@ fman_if_init(const struct device_node *dpa_node) prop = of_get_property(pool_node, "fsl,bpid", &proplen); if (!prop) { FMAN_ERR(-EINVAL, "%s: no fsl,bpid\n", pname); - free(bpool); + rte_free(bpool); goto err; } assert(proplen == sizeof(*prop)); @@ -574,7 +575,7 @@ fman_finish(void) -errno, strerror(errno)); printf("Tearing down %s\n", __if->node_path); list_del(&__if->__if.node); - free(__if); + rte_free(__if); } close(fman_ccsr_map_fd); diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c index 6b5224203a..bf8c77265f 100644 --- a/drivers/bus/dpaa/base/fman/netcfg_layer.c +++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c @@ -114,7 +114,7 @@ netcfg_acquire(void) size = sizeof(*netcfg) + (num_ports * sizeof(struct fm_eth_port_cfg)); - netcfg = calloc(1, size); + netcfg = rte_calloc(NULL, 1, size, 0); if (unlikely(netcfg == NULL)) { DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg"); goto error; @@ -141,7 +141,7 @@ netcfg_acquire(void) error: if (netcfg) { - free(netcfg); + rte_free(netcfg); netcfg = NULL; } @@ -151,7 +151,7 @@ error: void netcfg_release(struct netcfg_info *cfg_ptr) { - free(cfg_ptr); + rte_free(cfg_ptr); /* Close socket for shared interfaces */ if (skfd >= 0) { close(skfd); diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index c7da96f8da..ac20eccd53 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -442,40 +442,8 @@ rte_dpaa_bus_scan(void) RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n"); return 0; } - - /* Load the device-tree driver */ - ret = of_init(); - if (ret) { - DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret); - return -1; - } - - /* Get the interface configurations from device-tree */ - dpaa_netcfg = netcfg_acquire(); - if (!dpaa_netcfg) { - DPAA_BUS_LOG(ERR, "netcfg_acquire failed"); - return -EINVAL; - } - - RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n"); - - if (!dpaa_netcfg->num_ethports) { - DPAA_BUS_LOG(INFO, "no network interfaces available"); - /* This is not an error */ - return 0; - } - -#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER - dump_netcfg(dpaa_netcfg); -#endif - - DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d", - dpaa_netcfg->num_ethports); - ret = dpaa_create_device_list(); - if (ret) { - DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret); - return ret; - } + /* detected DPAA devices */ + rte_dpaa_bus.detected = 1; /* create the key, supplying a function that'll be invoked * when a portal affined thread will be deleted. @@ -533,6 +501,47 @@ rte_dpaa_device_match(struct rte_dpaa_driver *drv, return -1; } +static int +rte_dpaa_bus_dev_build(void) +{ + int ret; + + /* Load the device-tree driver */ + ret = of_init(); + if (ret) { + DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret); + return -1; + } + + /* Get the interface configurations from device-tree */ + dpaa_netcfg = netcfg_acquire(); + if (!dpaa_netcfg) { + DPAA_BUS_LOG(ERR, "netcfg_acquire failed"); + return -EINVAL; + } + + RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n"); + + if (!dpaa_netcfg->num_ethports) { + DPAA_BUS_LOG(INFO, "no network interfaces available"); + /* This is not an error */ + return 0; + } + +#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER + dump_netcfg(dpaa_netcfg); +#endif + + DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d", + dpaa_netcfg->num_ethports); + ret = dpaa_create_device_list(); + if (ret) { + DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret); + return ret; + } + return 0; +} + static int rte_dpaa_bus_probe(void) { @@ -544,6 +553,12 @@ rte_dpaa_bus_probe(void) int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST; /* If DPAA bus is not present nothing needs to be done */ + if (!rte_dpaa_bus.detected) + return 0; + + rte_dpaa_bus_dev_build(); + + /* If no device present on DPAA bus nothing needs to be done */ if (TAILQ_EMPTY(&rte_dpaa_bus.device_list)) return 0; diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 1d580a000d..72fbbfce70 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -54,6 +54,7 @@ struct rte_dpaa_bus { struct rte_dpaa_device_list device_list; struct rte_dpaa_driver_list driver_list; int device_count; + int detected; }; struct dpaa_device_id { diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index d124169c55..b1fac8fa74 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1354,7 +1354,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev) /* reset bpool list, initialize bpool dynamically */ list_for_each_entry_safe(bp, tmp_bp, &cfg->fman_if->bpool_list, node) { list_del(&bp->node); - free(bp); + rte_free(bp); } /* Populate ethdev structure */