mempool: detect physical contiguous objects
[dpdk.git] / lib / librte_mempool / rte_mempool.c
index 92de395..146e386 100644 (file)
@@ -369,6 +369,16 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr,
 
        total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size;
 
+       /* Detect pool area has sufficient space for elements */
+       if (mp->flags & MEMPOOL_F_CAPA_PHYS_CONTIG) {
+               if (len < total_elt_sz * mp->size) {
+                       RTE_LOG(ERR, MEMPOOL,
+                               "pool area %" PRIx64 " not enough\n",
+                               (uint64_t)len);
+                       return -ENOSPC;
+               }
+       }
+
        memhdr = rte_zmalloc("MEMPOOL_MEMHDR", sizeof(*memhdr), 0);
        if (memhdr == NULL)
                return -ENOMEM;