MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_mempool_create_empty

Function rte_mempool_create_empty

dpdk/lib/mempool/rte_mempool.c:800–965  ·  view source on GitHub ↗

create an empty mempool */

Source from the content-addressed store, hash-verified

798
799/* create an empty mempool */
800struct rte_mempool *
801rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
802 unsigned cache_size, unsigned private_data_size,
803 int socket_id, unsigned flags)
804{
805 char mz_name[RTE_MEMZONE_NAMESIZE];
806 struct rte_mempool_list *mempool_list;
807 struct rte_mempool *mp = NULL;
808 struct rte_tailq_entry *te = NULL;
809 const struct rte_memzone *mz = NULL;
810 size_t mempool_size;
811 unsigned int mz_flags = RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY;
812 struct rte_mempool_objsz objsz;
813 unsigned lcore_id;
814 int ret;
815
816 /* compilation-time checks */
817 RTE_BUILD_BUG_ON((sizeof(struct rte_mempool) &
818 RTE_CACHE_LINE_MASK) != 0);
819 RTE_BUILD_BUG_ON((sizeof(struct rte_mempool_cache) &
820 RTE_CACHE_LINE_MASK) != 0);
821#ifdef RTE_LIBRTE_MEMPOOL_STATS
822 RTE_BUILD_BUG_ON((sizeof(struct rte_mempool_debug_stats) &
823 RTE_CACHE_LINE_MASK) != 0);
824 RTE_BUILD_BUG_ON((offsetof(struct rte_mempool, stats) &
825 RTE_CACHE_LINE_MASK) != 0);
826#endif
827
828 mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
829
830 /* asked for zero items */
831 if (n == 0) {
832 rte_errno = EINVAL;
833 return NULL;
834 }
835
836 /* asked cache too big */
837 if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE ||
838 CALC_CACHE_FLUSHTHRESH(cache_size) > n) {
839 rte_errno = EINVAL;
840 return NULL;
841 }
842
843 /* enforce only user flags are passed by the application */
844 if ((flags & ~RTE_MEMPOOL_VALID_USER_FLAGS) != 0) {
845 rte_errno = EINVAL;
846 return NULL;
847 }
848
849 /*
850 * No objects in the pool can be used for IO until it's populated
851 * with at least some objects with valid IOVA.
852 */
853 flags |= RTE_MEMPOOL_F_NON_IO;
854
855 /* "no cache align" imply "no spread" */
856 if (flags & RTE_MEMPOOL_F_NO_CACHE_ALIGN)
857 flags |= RTE_MEMPOOL_F_NO_SPREAD;

Calls 14

rte_zmallocFunction · 0.85
snprintfFunction · 0.85
rte_memzone_reserveFunction · 0.85
memsetFunction · 0.85
mempool_cache_initFunction · 0.85
rte_freeFunction · 0.85