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>
Subject: [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe
Date: Tue, 26 Mar 2019 12:01:46 +0000 [thread overview]
Message-ID: <20190326115952.26278-3-hemant.agrawal@nxp.com> (raw)
Message-ID: <20190326120146.nkfHt6YsTN54RKIIgaFXwQ0GXlQiihrH9G1OYs9VbL0@z> (raw)
In-Reply-To: <20190326115952.26278-1-hemant.agrawal@nxp.com>
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 <hemant.agrawal@nxp.com>
---
drivers/bus/dpaa/base/fman/fman.c | 11 +--
drivers/bus/dpaa/base/fman/netcfg_layer.c | 6 +-
drivers/bus/dpaa/dpaa_bus.c | 83 +++++++++++++----------
drivers/bus/dpaa/rte_dpaa_bus.h | 1 +
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
5 files changed, 60 insertions(+), 43 deletions(-)
diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c
index 06762e0f4..8fa9b8cae 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 <fman.h>
#include <of.h>
+#include <rte_malloc.h>
#include <rte_dpaa_logs.h>
#include <rte_string_fns.h>
@@ -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 6b5224203..bf8c77265 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 @@ netcfg_acquire(void)
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 c7da96f8d..ac20eccd5 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 1d580a000..72fbbfce7 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 d124169c5..b1fac8fa7 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 */
--
2.17.1
next prev parent reply other threads:[~2019-03-26 12:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-26 12:01 [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` [dpdk-dev] [PATCH 2/4] mempool/dpaa: bp info dynamic allocation for multiprocess Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal [this message]
2019-03-26 12:01 ` [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe Hemant Agrawal
2019-03-26 12:01 ` [dpdk-dev] [PATCH 4/4] net/dpaa2: add support for flow table flush Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
2019-03-29 13:33 ` [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Thomas Monjalon
2019-03-29 13:33 ` 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=20190326115952.26278-3-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).