X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fbus%2Fdpaa%2Fdpaa_bus.c;h=ffc90a7025f3b10bfe76fac26feeb84049f9c68d;hb=964b2f3bfb07ae95fcf4570269a6bc0e1c0affec;hp=f5840de77860527a7030aaa0e6684c0544107a8c;hpb=2bd0d5b951a92ce1be828f6614a27197b30e1e07;p=dpdk.git diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index f5840de778..ffc90a7025 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -55,19 +54,61 @@ pthread_key_t dpaa_portal_key; unsigned int dpaa_svr_family; -RTE_DEFINE_PER_LCORE(bool, _dpaa_io); +RTE_DEFINE_PER_LCORE(bool, dpaa_io); RTE_DEFINE_PER_LCORE(struct dpaa_portal_dqrr, held_bufs); -static inline void -dpaa_add_to_device_list(struct rte_dpaa_device *dev) +static int +compare_dpaa_devices(struct rte_dpaa_device *dev1, + struct rte_dpaa_device *dev2) { - TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next); + int comp = 0; + + /* Segragating ETH from SEC devices */ + if (dev1->device_type > dev2->device_type) + comp = 1; + else if (dev1->device_type < dev2->device_type) + comp = -1; + else + comp = 0; + + if ((comp != 0) || (dev1->device_type != FSL_DPAA_ETH)) + return comp; + + if (dev1->id.fman_id > dev2->id.fman_id) { + comp = 1; + } else if (dev1->id.fman_id < dev2->id.fman_id) { + comp = -1; + } else { + /* FMAN ids match, check for mac_id */ + if (dev1->id.mac_id > dev2->id.mac_id) + comp = 1; + else if (dev1->id.mac_id < dev2->id.mac_id) + comp = -1; + else + comp = 0; + } + + return comp; } static inline void -dpaa_remove_from_device_list(struct rte_dpaa_device *dev) +dpaa_add_to_device_list(struct rte_dpaa_device *newdev) { - TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, dev, next); + int comp, inserted = 0; + struct rte_dpaa_device *dev = NULL; + struct rte_dpaa_device *tdev = NULL; + + TAILQ_FOREACH_SAFE(dev, &rte_dpaa_bus.device_list, next, tdev) { + comp = compare_dpaa_devices(newdev, dev); + if (comp < 0) { + TAILQ_INSERT_BEFORE(dev, newdev, next); + inserted = 1; + break; + } + } + + if (!inserted) + TAILQ_INSERT_TAIL(&rte_dpaa_bus.device_list, newdev, next); } /* @@ -183,9 +224,7 @@ dpaa_clean_device_list(void) } } -/** XXX move this function into a separate file */ -static int -_dpaa_portal_init(void *arg) +int rte_dpaa_portal_init(void *arg) { cpu_set_t cpuset; pthread_t id; @@ -195,7 +234,7 @@ _dpaa_portal_init(void *arg) BUS_INIT_FUNC_TRACE(); - if ((uint64_t)arg == 1 || cpu == LCORE_ID_ANY) + if ((size_t)arg == 1 || cpu == LCORE_ID_ANY) cpu = rte_get_master_lcore(); /* if the core id is not supported */ else @@ -256,34 +295,28 @@ _dpaa_portal_init(void *arg) return ret; } - RTE_PER_LCORE(_dpaa_io) = true; + RTE_PER_LCORE(dpaa_io) = true; DPAA_BUS_LOG(DEBUG, "QMAN thread initialized"); return 0; } -/* - * rte_dpaa_portal_init - Wrapper over _dpaa_portal_init with thread level check - * XXX Complete this - */ -int rte_dpaa_portal_init(void *arg) -{ - if (unlikely(!RTE_PER_LCORE(_dpaa_io))) - return _dpaa_portal_init(arg); - - return 0; -} - int rte_dpaa_portal_fq_init(void *arg, struct qman_fq *fq) { /* Affine above created portal with channel*/ u32 sdqcr; struct qman_portal *qp; + int ret; - if (unlikely(!RTE_PER_LCORE(_dpaa_io))) - _dpaa_portal_init(arg); + if (unlikely(!RTE_PER_LCORE(dpaa_io))) { + ret = rte_dpaa_portal_init(arg); + if (ret < 0) { + DPAA_BUS_LOG(ERR, "portal initialization failure"); + return ret; + } + } /* Initialise qman specific portals */ qp = fsl_qman_portal_create(); @@ -321,7 +354,7 @@ dpaa_portal_finish(void *arg) rte_free(dpaa_io_portal); dpaa_io_portal = NULL; - RTE_PER_LCORE(_dpaa_io) = false; + RTE_PER_LCORE(dpaa_io) = false; } #define DPAA_DEV_PATH1 "/sys/devices/platform/soc/soc:fsl,dpaa" @@ -467,10 +500,16 @@ rte_dpaa_bus_probe(void) ret = drv->probe(drv, dev); if (ret) DPAA_BUS_ERR("Unable to probe.\n"); + break; } } - rte_mbuf_set_platform_mempool_ops(DPAA_MEMPOOL_OPS_NAME); + + /* Register DPAA mempool ops only if any DPAA device has + * been detected. + */ + if (!TAILQ_EMPTY(&rte_dpaa_bus.device_list)) + rte_mbuf_set_platform_mempool_ops(DPAA_MEMPOOL_OPS_NAME); svr_file = fopen(DPAA_SOC_ID_FILE, "r"); if (svr_file) { @@ -507,6 +546,10 @@ rte_dpaa_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, static enum rte_iova_mode rte_dpaa_get_iommu_class(void) { + if ((access(DPAA_DEV_PATH1, F_OK) != 0) && + (access(DPAA_DEV_PATH2, F_OK) != 0)) { + return RTE_IOVA_DC; + } return RTE_IOVA_PA; }