* Create and initialize a cache for objects that are retrieved from and * returned to an underlying mempool. This structure is identical to the * local_cache[lcore_id] pointed to by the mempool structure. */
| 761 | * local_cache[lcore_id] pointed to by the mempool structure. |
| 762 | */ |
| 763 | struct rte_mempool_cache * |
| 764 | rte_mempool_cache_create(uint32_t size, int socket_id) |
| 765 | { |
| 766 | struct rte_mempool_cache *cache; |
| 767 | |
| 768 | if (size == 0 || size > RTE_MEMPOOL_CACHE_MAX_SIZE) { |
| 769 | rte_errno = EINVAL; |
| 770 | return NULL; |
| 771 | } |
| 772 | |
| 773 | cache = rte_zmalloc_socket("MEMPOOL_CACHE", sizeof(*cache), |
| 774 | RTE_CACHE_LINE_SIZE, socket_id); |
| 775 | if (cache == NULL) { |
| 776 | RTE_LOG(ERR, MEMPOOL, "Cannot allocate mempool cache.\n"); |
| 777 | rte_errno = ENOMEM; |
| 778 | return NULL; |
| 779 | } |
| 780 | |
| 781 | mempool_cache_init(cache, size); |
| 782 | |
| 783 | rte_mempool_trace_cache_create(size, socket_id, cache); |
| 784 | return cache; |
| 785 | } |
| 786 | |
| 787 | /* |
| 788 | * Free a cache. It's the responsibility of the user to make sure that any |