void cmd_ringinfo(uint8_t lcore_id, uint8_t task_id) { struct lcore_cfg *lconf; struct rte_ring *ring; struct task_args* targ; uint32_t count; if (!dppd_core_active(lcore_id, 0)) { plog_info("lcore %u is not active\n", lcore_id); return; } lconf = &lcore_cfg[lcore_id]; if (task_id >= lconf->nb_tasks) { plog_warn("Invalid task index %u: lcore %u has %u tasks\n", task_id, lcore_id, lconf->nb_tasks); return; } targ = &lconf->targs[task_id]; plog_info("Core %u task %u: %u rings\n", lcore_id, task_id, targ->nb_rxrings); for (uint8_t i = 0; i < targ->nb_rxrings; ++i) { ring = targ->rx_rings[i]; count = ring->prod.mask + 1; plog_info("\tRing %u:\n", i); plog_info("\t\tFlags: %s,%s\n", ring->flags & RING_F_SP_ENQ? "sp":"mp", ring->flags & RING_F_SC_DEQ? "sc":"mc"); plog_info("\t\tMemory size: %zu bytes\n", rte_ring_get_memsize(count)); plog_info("\t\tOccupied: %u/%u\n", rte_ring_count(ring), count); } }
/* create the ring */ struct rte_ring * rte_ring_create(const char *name, unsigned count, int socket_id, unsigned flags) { char mz_name[RTE_MEMZONE_NAMESIZE]; struct rte_ring *r; struct rte_tailq_entry *te; const struct rte_memzone *mz; ssize_t ring_size; int mz_flags = 0; struct rte_ring_list* ring_list = NULL; ring_list = RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list); ring_size = rte_ring_get_memsize(count); if (ring_size < 0) { rte_errno = ring_size; return NULL; } te = rte_zmalloc("RING_TAILQ_ENTRY", sizeof(*te), 0); if (te == NULL) { RTE_LOG(ERR, RING, "Cannot reserve memory for tailq\n"); rte_errno = ENOMEM; return NULL; } snprintf(mz_name, sizeof(mz_name), "%s%s", RTE_RING_MZ_PREFIX, name); rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK); /* reserve a memory zone for this ring. If we can't get rte_config or * we are secondary process, the memzone_reserve function will set * rte_errno for us appropriately - hence no check in this this function */ mz = rte_memzone_reserve(mz_name, ring_size, socket_id, mz_flags); if (mz != NULL) { r = mz->addr; /* no need to check return value here, we already checked the * arguments above */ rte_ring_init(r, name, count, flags); te->data = (void *) r; TAILQ_INSERT_TAIL(ring_list, te, next); } else { r = NULL; RTE_LOG(ERR, RING, "Cannot reserve memory\n"); rte_free(te); } rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); return r; }