Replace DPAA_BUS_LOG(LEVEL, ...) calls with shorthand macros (DPAA_BUS_INFO, DPAA_BUS_ERR, DPAA_BUS_WARN, DPAA_BUS_DEBUG) for consistency across the driver.
Make dpaa_bus_dev_compare() a pure comparator: move the sysfs path check, dpaa_bus.detected assignment, and pthread_key_create() call back to rte_dpaa_bus_scan() where they belong. Having side effects in a comparator causes incorrect behavior when the function is called multiple times -- it returns 0 (match) for all calls after the first. Signed-off-by: Hemant Agrawal <[email protected]> --- drivers/bus/dpaa/base/fman/fman.c | 9 ++-- drivers/bus/dpaa/dpaa_bus.c | 80 +++++++++++++++---------------- 2 files changed, 42 insertions(+), 47 deletions(-) diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index 55f466d751..67f77265ca 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -119,7 +119,7 @@ _fman_init(const struct device_node *fman_node, int fd) ip_rev_1 = in_be32((uint8_t *)fman->ccsr_vir + FMAN_IP_REV_1); fman->ip_rev = ip_rev_1 >> FMAN_IP_REV_1_MAJOR_SHIFT; fman->ip_rev &= FMAN_IP_REV_1_MAJOR_MASK; - DPAA_BUS_LOG(NOTICE, "FMan version is 0x%02x", fman->ip_rev); + DPAA_BUS_INFO("FMan version is 0x%02x", fman->ip_rev); if (fman->ip_rev >= FMAN_V3) { /* @@ -795,8 +795,7 @@ fman_if_init(const struct device_node *dpa_node, int fd) fman_if_vsp_init(__if); /* Parsing of the network interface is complete, add it to the list */ - DPAA_BUS_LOG(DEBUG, "Found %s, Tx Channel = %x, FMAN = %x," - "Port ID = %x", + DPAA_BUS_DEBUG("Found %s, Tx Channel = %x, FMAN = %x, Port ID = %x", dname, __if->__if.tx_channel_id, __if->__if.fman->idx, __if->__if.mac_idx); @@ -1109,14 +1108,14 @@ fman_init(void) fd = open(FMAN_DEVICE_PATH, O_RDWR); if (unlikely(fd < 0)) { - DPAA_BUS_LOG(ERR, "Unable to open %s: %s", FMAN_DEVICE_PATH, strerror(errno)); + DPAA_BUS_ERR("Unable to open %s: %s", FMAN_DEVICE_PATH, strerror(errno)); return fd; } fman_ccsr_map_fd = fd; parent_node = of_find_compatible_node(NULL, NULL, "fsl,dpaa"); if (!parent_node) { - DPAA_BUS_LOG(ERR, "Unable to find fsl,dpaa node"); + DPAA_BUS_ERR("Unable to find fsl,dpaa node"); return -ENODEV; } diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 368c8eeb98..fe1003a1d9 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -54,6 +54,9 @@ /* At present we allow up to 4 push mode queues as default - as each of * this queue need dedicated portal and we are short of portals. */ +#define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa" +#define DPAA_DEV_PATH2 "/sys/devices/platform/fsl,dpaa" + #define DPAA_MAX_PUSH_MODE_QUEUE 8 #define DPAA_DEFAULT_PUSH_MODE_QUEUE 4 @@ -210,7 +213,7 @@ dpaa_create_device_list(void) for (i = 0; dpaa_netcfg && (i < dpaa_netcfg->num_ethports); i++) { dev = calloc(1, sizeof(struct rte_dpaa_device)); if (!dev) { - DPAA_BUS_LOG(ERR, "Failed to allocate ETH devices"); + DPAA_BUS_ERR("Failed to allocate ETH devices"); ret = -ENOMEM; goto cleanup; } @@ -221,7 +224,7 @@ dpaa_create_device_list(void) dev->intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); if (dev->intr_handle == NULL) { - DPAA_BUS_LOG(ERR, "Failed to allocate intr handle"); + DPAA_BUS_ERR("Failed to allocate intr handle"); ret = -ENOMEM; free(dev); goto cleanup; @@ -265,7 +268,7 @@ dpaa_create_device_list(void) */ if (dpaa_sec_available()) { - DPAA_BUS_LOG(INFO, "DPAA SEC devices are not available"); + DPAA_BUS_INFO("DPAA SEC devices are not available"); goto qdma_dpaa; } @@ -273,8 +276,8 @@ dpaa_create_device_list(void) for (i = 0; i < RTE_LIBRTE_DPAA_MAX_CRYPTODEV; i++) { dev = calloc(1, sizeof(struct rte_dpaa_device)); if (!dev) { - DPAA_BUS_LOG(ERR, "Failed to allocate SEC devices"); - ret = -1; + DPAA_BUS_ERR("Failed to allocate SEC devices"); + ret = -ENOMEM; goto cleanup; } @@ -282,7 +285,7 @@ dpaa_create_device_list(void) dev->intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); if (dev->intr_handle == NULL) { - DPAA_BUS_LOG(ERR, "Failed to allocate intr handle"); + DPAA_BUS_ERR("Failed to allocate intr handle"); ret = -ENOMEM; free(dev); goto cleanup; @@ -297,7 +300,7 @@ dpaa_create_device_list(void) */ memset(dev->name, 0, RTE_ETH_NAME_MAX_LEN); sprintf(dev->name, "dpaa_sec-%d", i+1); - DPAA_BUS_LOG(INFO, "%s cryptodev added", dev->name); + DPAA_BUS_INFO("%s cryptodev added", dev->name); dev->device.name = dev->name; dev->device.devargs = rte_bus_find_devargs(&rte_dpaa_bus, dev->name); if (dev->device.devargs != NULL) @@ -313,8 +316,8 @@ dpaa_create_device_list(void) for (i = 0; i < RTE_DPAA_QDMA_DEVICES; i++) { dev = calloc(1, sizeof(struct rte_dpaa_device)); if (!dev) { - DPAA_BUS_LOG(ERR, "Failed to allocate QDMA device"); - ret = -1; + DPAA_BUS_ERR("Failed to allocate QDMA device"); + ret = -ENOMEM; goto cleanup; } @@ -323,7 +326,7 @@ dpaa_create_device_list(void) memset(dev->name, 0, RTE_ETH_NAME_MAX_LEN); sprintf(dev->name, "dpaa_qdma-%d", i+1); - DPAA_BUS_LOG(INFO, "%s qdma device added", dev->name); + DPAA_BUS_INFO("%s qdma device added", dev->name); dev->device.name = dev->name; dev->device.devargs = rte_bus_find_devargs(&rte_dpaa_bus, dev->name); if (dev->device.devargs != NULL) @@ -377,37 +380,35 @@ int rte_dpaa_portal_init(void *arg) dpaa_seqn_dynfield_offset = rte_mbuf_dynfield_register(&dpaa_seqn_dynfield_desc); if (dpaa_seqn_dynfield_offset < 0) { - DPAA_BUS_LOG(ERR, "Failed to register mbuf field for dpaa sequence number"); + DPAA_BUS_ERR("Failed to register mbuf field for dpaa sequence number"); return -rte_errno; } /* Initialise bman thread portals */ ret = bman_thread_init(); if (ret) { - DPAA_BUS_LOG(ERR, "bman_thread_init failed on core %u" - " (lcore=%u) with ret: %d", cpu, lcore, ret); + DPAA_BUS_ERR("Failed(%d) to init bman thread on cpu%d/lcore%d", + ret, cpu, lcore); return ret; } - DPAA_BUS_LOG(DEBUG, "BMAN thread initialized - CPU=%d lcore=%d", - cpu, lcore); + DPAA_BUS_DEBUG("BMAN thread initialized - CPU=%d lcore=%d", cpu, lcore); /* Initialise qman thread portals */ ret = qman_thread_init(); if (ret) { - DPAA_BUS_LOG(ERR, "qman_thread_init failed on core %u" - " (lcore=%u) with ret: %d", cpu, lcore, ret); + DPAA_BUS_ERR("Failed(%d) to init qman thread on cpu%d/lcore%d", + ret, cpu, lcore); bman_thread_finish(); return ret; } - DPAA_BUS_LOG(DEBUG, "QMAN thread initialized - CPU=%d lcore=%d", - cpu, lcore); + DPAA_BUS_DEBUG("QMAN thread initialized - CPU=%d lcore=%d", cpu, lcore); DPAA_PER_LCORE_PORTAL = rte_malloc(NULL, sizeof(struct dpaa_portal), RTE_CACHE_LINE_SIZE); if (!DPAA_PER_LCORE_PORTAL) { - DPAA_BUS_LOG(ERR, "Unable to allocate memory"); + DPAA_BUS_ERR("Unable to allocate memory"); bman_thread_finish(); qman_thread_finish(); return -ENOMEM; @@ -420,15 +421,15 @@ int rte_dpaa_portal_init(void *arg) ret = pthread_setspecific(dpaa_portal_key, (void *)DPAA_PER_LCORE_PORTAL); if (ret) { - DPAA_BUS_LOG(ERR, "pthread_setspecific failed on core %u" - " (lcore=%u) with ret: %d", cpu, lcore, ret); + DPAA_BUS_ERR("Failed(%d) to set portal per thread on cpu%u/lcore%u", + ret, cpu, lcore); dpaa_portal_finish(NULL); return ret; } dpaa_portals[lcore] = DPAA_PER_LCORE_PORTAL; - DPAA_BUS_LOG(DEBUG, "QMAN thread initialized"); + DPAA_BUS_DEBUG("QMAN thread initialized"); return 0; } @@ -444,7 +445,7 @@ rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) if (unlikely(!DPAA_PER_LCORE_PORTAL)) { ret = rte_dpaa_portal_init(arg); if (ret < 0) { - DPAA_BUS_LOG(ERR, "portal initialization failure"); + DPAA_BUS_ERR("portal initialization failure"); return ret; } } @@ -452,7 +453,7 @@ rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) /* Initialise qman specific portals */ ret = fsl_qman_fq_portal_init(fq->qp); if (ret) { - DPAA_BUS_LOG(ERR, "Unable to init fq portal"); + DPAA_BUS_ERR("Unable to init fq portal"); return -1; } @@ -474,7 +475,7 @@ dpaa_portal_finish(void *arg) struct dpaa_portal *dpaa_io_portal = (struct dpaa_portal *)arg; if (!dpaa_io_portal) { - DPAA_BUS_LOG(DEBUG, "Portal already cleaned"); + DPAA_BUS_DEBUG("Portal already cleaned"); return; } @@ -612,24 +613,22 @@ rte_dpaa_bus_dev_build(void) /* Load the device-tree driver */ ret = of_init(); if (ret) { - DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret); - return -1; + DPAA_BUS_ERR("Failed(%d) to init device tree", ret); + return ret; } /* Get the interface configurations from device-tree */ dpaa_netcfg = netcfg_acquire(); if (!dpaa_netcfg) { - DPAA_BUS_LOG(ERR, - "netcfg failed: /dev/fsl_usdpaa device not available"); - DPAA_BUS_WARN( - "Check if you are using USDPAA based device tree"); + DPAA_BUS_ERR("netcfg failed: /dev/fsl_usdpaa device not available"); + DPAA_BUS_WARN("Check if you are using USDPAA based device tree"); return -EINVAL; } DPAA_BUS_LOG(NOTICE, "DPAA Bus Detected"); if (!dpaa_netcfg->num_ethports) { - DPAA_BUS_LOG(INFO, "NO DPDK mapped net interfaces available"); + DPAA_BUS_INFO("NO DPDK mapped net interfaces available"); /* This is not an error */ } @@ -637,11 +636,11 @@ rte_dpaa_bus_dev_build(void) dump_netcfg(dpaa_netcfg, stdout); #endif - DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d", - dpaa_netcfg->num_ethports); + DPAA_BUS_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); + DPAA_BUS_ERR("Unable to create device list. (%d)", ret); return ret; } return 0; @@ -667,8 +666,6 @@ static int rte_dpaa_setup_intr(struct rte_intr_handle *intr_handle) return 0; } -#define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa" -#define DPAA_DEV_PATH2 "/sys/devices/platform/fsl,dpaa" static int rte_dpaa_bus_scan(void) @@ -715,12 +712,11 @@ rte_dpaa_bus_scan(void) dpaa_bus.svr_ver = 0; } if (dpaa_bus.svr_ver == SVR_LS1046A_FAMILY) { - DPAA_BUS_LOG(INFO, "This is LS1046A family SoC."); + DPAA_BUS_INFO("This is LS1046A family SoC."); } else if (dpaa_bus.svr_ver == SVR_LS1043A_FAMILY) { - DPAA_BUS_LOG(INFO, "This is LS1043A family SoC."); + DPAA_BUS_INFO("This is LS1043A family SoC."); } else { - DPAA_BUS_LOG(WARNING, - "This is Unknown(%08x) DPAA1 family SoC.", + DPAA_BUS_WARN("This is Unknown(%08x) DPAA1 family SoC.", dpaa_bus.svr_ver); } -- 2.25.1

