#include "fra_bpool.h" #include <usdpaa/conf.h> #include <assert.h> #include <stdio.h> struct bpool_node bpool_array[POOL_MAX]; #ifdef BPOOL_DEPLETION static void bp_depletion(struct bman_portal *bm __always_unused, struct bman_pool *p, void *cb_ctx __maybe_unused, int depleted) { uint8_t bpid = bman_get_params(p)->bpid; BUG_ON(p != *(typeof(&p))cb_ctx); error(0, 0, "%s: BP%u -> %s", __func__, bpid, depleted ? "entry" : "exit"); } #endif static int bpool_init(uint8_t bpid) { struct bman_pool_params params = { .bpid = bpid, #ifdef BPOOL_DEPLETION .flags = BMAN_POOL_FLAG_DEPLETION, .cb = bp_depletion, .cb_ctx = &(bpool_array[bpid].pool),
static int dpaa_mbuf_create_pool(struct rte_mempool *mp) { struct bman_pool *bp; struct bm_buffer bufs[8]; struct dpaa_bp_info *bp_info; uint8_t bpid; int num_bufs = 0, ret = 0; struct bman_pool_params params = { .flags = BMAN_POOL_FLAG_DYNAMIC_BPID }; MEMPOOL_INIT_FUNC_TRACE(); bp = bman_new_pool(¶ms); if (!bp) { DPAA_MEMPOOL_ERR("bman_new_pool() failed"); return -ENODEV; } bpid = bman_get_params(bp)->bpid; /* Drain the pool of anything already in it. */ do { /* Acquire is all-or-nothing, so we drain in 8s, * then in 1s for the remainder. */ if (ret != 1) ret = bman_acquire(bp, bufs, 8, 0); if (ret < 8) ret = bman_acquire(bp, bufs, 1, 0); if (ret > 0) num_bufs += ret; } while (ret > 0); if (num_bufs) DPAA_MEMPOOL_WARN("drained %u bufs from BPID %d", num_bufs, bpid); rte_dpaa_bpid_info[bpid].mp = mp; rte_dpaa_bpid_info[bpid].bpid = bpid; rte_dpaa_bpid_info[bpid].size = mp->elt_size; rte_dpaa_bpid_info[bpid].bp = bp; rte_dpaa_bpid_info[bpid].meta_data_size = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mp); rte_dpaa_bpid_info[bpid].dpaa_ops_index = mp->ops_index; rte_dpaa_bpid_info[bpid].ptov_off = 0; rte_dpaa_bpid_info[bpid].flags = 0; bp_info = rte_malloc(NULL, sizeof(struct dpaa_bp_info), RTE_CACHE_LINE_SIZE); if (!bp_info) { DPAA_MEMPOOL_WARN("Memory allocation failed for bp_info"); bman_free_pool(bp); return -ENOMEM; } rte_memcpy(bp_info, (void *)&rte_dpaa_bpid_info[bpid], sizeof(struct dpaa_bp_info)); mp->pool_data = (void *)bp_info; DPAA_MEMPOOL_INFO("BMAN pool created for bpid =%d", bpid); return 0; }