"\t -- No cache align (%c)\n"
"\t -- SP put (%c), SC get (%c)\n"
"\t -- Pool created (%c)\n"
- "\t -- No IOVA config (%c)\n",
+ "\t -- No IOVA config (%c)\n"
+ "\t -- Not used for IO (%c)\n",
ptr->name,
ptr->socket_id,
(flags & MEMPOOL_F_NO_SPREAD) ? 'y' : 'n',
(flags & MEMPOOL_F_SP_PUT) ? 'y' : 'n',
(flags & MEMPOOL_F_SC_GET) ? 'y' : 'n',
(flags & MEMPOOL_F_POOL_CREATED) ? 'y' : 'n',
- (flags & MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n');
+ (flags & MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n',
+ (flags & MEMPOOL_F_NON_IO) ? 'y' : 'n');
printf(" - Size %u Cache %u element %u\n"
" - header %u trailer %u\n"
" - private data size %u\n",
#include <sys/queue.h>
#include <rte_common.h>
+#include <rte_eal_paging.h>
#include <rte_log.h>
#include <rte_debug.h>
#include <rte_errno.h>
#pragma pop_macro("RTE_TEST_TRACE_FAILURE")
}
+#pragma push_macro("RTE_TEST_TRACE_FAILURE")
+#undef RTE_TEST_TRACE_FAILURE
+#define RTE_TEST_TRACE_FAILURE(...) do { \
+ ret = TEST_FAILED; \
+ goto exit; \
+ } while (0)
+
+static int
+test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
+{
+ struct rte_mempool *mp = NULL;
+ int ret;
+
+ mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
+ MEMPOOL_ELT_SIZE, 0, 0,
+ SOCKET_ID_ANY, MEMPOOL_F_NO_IOVA_CONTIG);
+ RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s",
+ rte_strerror(rte_errno));
+ rte_mempool_set_ops_byname(mp, rte_mbuf_best_mempool_ops(), NULL);
+ ret = rte_mempool_populate_default(mp);
+ RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
+ rte_strerror(-ret));
+ RTE_TEST_ASSERT(mp->flags & MEMPOOL_F_NON_IO,
+ "NON_IO flag is not set when NO_IOVA_CONTIG is set");
+ ret = TEST_SUCCESS;
+exit:
+ rte_mempool_free(mp);
+ return ret;
+}
+
+static int
+test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
+{
+ void *virt = NULL;
+ rte_iova_t iova;
+ size_t total_size = MEMPOOL_ELT_SIZE * MEMPOOL_SIZE;
+ size_t block_size = total_size / 3;
+ struct rte_mempool *mp = NULL;
+ int ret;
+
+ /*
+ * Since objects from the pool are never used in the test,
+ * we don't care for contiguous IOVA, on the other hand,
+ * reiuring it could cause spurious test failures.
+ */
+ virt = rte_malloc("test_mempool", total_size, rte_mem_page_size());
+ RTE_TEST_ASSERT_NOT_NULL(virt, "Cannot allocate memory");
+ iova = rte_mem_virt2iova(virt);
+ RTE_TEST_ASSERT_NOT_EQUAL(iova, RTE_BAD_IOVA, "Cannot get IOVA");
+ mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
+ MEMPOOL_ELT_SIZE, 0, 0,
+ SOCKET_ID_ANY, 0);
+ RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s",
+ rte_strerror(rte_errno));
+
+ ret = rte_mempool_populate_iova(mp, RTE_PTR_ADD(virt, 1 * block_size),
+ RTE_BAD_IOVA, block_size, NULL, NULL);
+ RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
+ rte_strerror(-ret));
+ RTE_TEST_ASSERT(mp->flags & MEMPOOL_F_NON_IO,
+ "NON_IO flag is not set when mempool is populated with only RTE_BAD_IOVA");
+
+ ret = rte_mempool_populate_iova(mp, virt, iova, block_size, NULL, NULL);
+ RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
+ rte_strerror(-ret));
+ RTE_TEST_ASSERT(!(mp->flags & MEMPOOL_F_NON_IO),
+ "NON_IO flag is not unset when mempool is populated with valid IOVA");
+
+ ret = rte_mempool_populate_iova(mp, RTE_PTR_ADD(virt, 2 * block_size),
+ RTE_BAD_IOVA, block_size, NULL, NULL);
+ RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
+ rte_strerror(-ret));
+ RTE_TEST_ASSERT(!(mp->flags & MEMPOOL_F_NON_IO),
+ "NON_IO flag is set even when some objects have valid IOVA");
+ ret = TEST_SUCCESS;
+
+exit:
+ rte_mempool_free(mp);
+ rte_free(virt);
+ return ret;
+}
+
+static int
+test_mempool_flag_non_io_unset_by_default(void)
+{
+ struct rte_mempool *mp;
+ int ret;
+
+ mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
+ MEMPOOL_ELT_SIZE, 0, 0,
+ SOCKET_ID_ANY, 0);
+ RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s",
+ rte_strerror(rte_errno));
+ ret = rte_mempool_populate_default(mp);
+ RTE_TEST_ASSERT_EQUAL(ret, (int)mp->size, "Failed to populate mempool: %s",
+ rte_strerror(-ret));
+ RTE_TEST_ASSERT(!(mp->flags & MEMPOOL_F_NON_IO),
+ "NON_IO flag is set by default");
+ ret = TEST_SUCCESS;
+exit:
+ rte_mempool_free(mp);
+ return ret;
+}
+
+#pragma pop_macro("RTE_TEST_TRACE_FAILURE")
+
static int
test_mempool(void)
{
if (test_mempool_events_safety() < 0)
GOTO_ERR(ret, err);
+ /* test NON_IO flag inference */
+ if (test_mempool_flag_non_io_unset_by_default() < 0)
+ GOTO_ERR(ret, err);
+ if (test_mempool_flag_non_io_set_when_no_iova_contig_set() < 0)
+ GOTO_ERR(ret, err);
+ if (test_mempool_flag_non_io_unset_when_populated_with_valid_iova() < 0)
+ GOTO_ERR(ret, err);
+
rte_mempool_list_dump(stdout);
ret = 0;