void fsl_cpu_init(int cpu, int global, void_func sync_all) { int ret; curr_cpu_id = cpu; if (global) { ret = of_init(); if (ret) { TRACE("of_init() failed\n"); exit(EXIT_FAILURE); } ret = fman_init(); if (ret) { TRACE("fman_init() failed\n"); exit(EXIT_FAILURE); } ret = bman_global_init(); if (ret) { TRACE("bman_global_init() failed, ret=%d\n", ret); exit(EXIT_FAILURE); } ret = qman_global_init(); if (ret) { TRACE("qman_global_init() failed, ret=%d\n", ret); exit(EXIT_FAILURE); } dma_mem_generic = dma_mem_create(DMA_MAP_FLAG_ALLOC, NULL, HLP_DMA_MEM_256M); if (!dma_mem_generic) { TRACE("dma_mem_create() failed\n"); exit(EXIT_FAILURE); } } /* sync until the init done for 'fman, qman, bman, and dma' components */ if (sync_all != NULL) sync_all(); DEBUG("sync the 1st time\n"); /* Initialise bman/qman portals */ ret = bman_thread_init(); if (ret) { TRACE("bman_thread_init(%d) failed, ret=%d\n", cpu, ret); exit(EXIT_FAILURE); } ret = qman_thread_init(); if (ret) { TRACE("qman_thread_init(%d) failed, ret=%d\n", cpu, ret); exit(EXIT_FAILURE); } if (global) helper_pool_channel_init(); /* sync all cores to wait for buffer pool and FQs init done */ if (sync_all != NULL) sync_all(); /* init application tx fq, the fqid need be modified during run-time */ local_tx_fq_init(); /* dequeue rx pool channel for current thread */ qman_static_dequeue_add(helper_sdqcr); DEBUG("sync the 2nd time\n"); }
struct netcfg_info * netcfg_acquire(void) { struct fman_if *__if; int _errno, idx = 0; uint8_t num_ports = 0; uint8_t num_cfg_ports = 0; size_t size; /* Extract dpa configuration from fman driver and FMC configuration * for command-line interfaces. */ /* Open a basic socket to enable/disable shared * interfaces. */ skfd = socket(AF_PACKET, SOCK_RAW, 0); if (unlikely(skfd < 0)) { error(0, errno, "%s(): open(SOCK_RAW)", __func__); return NULL; } /* Initialise the Fman driver */ _errno = fman_init(); if (_errno) { DPAA_BUS_LOG(ERR, "FMAN driver init failed (%d)", errno); close(skfd); skfd = -1; return NULL; } /* Number of MAC ports */ list_for_each_entry(__if, fman_if_list, node) num_ports++; if (!num_ports) { DPAA_BUS_LOG(ERR, "FMAN ports not available"); return NULL; } /* Allocate space for all enabled mac ports */ size = sizeof(*netcfg) + (num_ports * sizeof(struct fm_eth_port_cfg)); netcfg = calloc(1, size); if (unlikely(netcfg == NULL)) { DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg"); goto error; } netcfg->num_ethports = num_ports; list_for_each_entry(__if, fman_if_list, node) { struct fm_eth_port_cfg *cfg = &netcfg->port_cfg[idx]; /* Hook in the fman driver interface */ cfg->fman_if = __if; cfg->rx_def = __if->fqid_rx_def; num_cfg_ports++; idx++; } if (!num_cfg_ports) { DPAA_BUS_LOG(ERR, "No FMAN ports found"); goto error; } else if (num_ports != num_cfg_ports) netcfg->num_ethports = num_cfg_ports; return netcfg; error: if (netcfg) { free(netcfg); netcfg = NULL; } return NULL; }