Commit 7f5b671d authored by Ben Walker's avatar Ben Walker Committed by Daniel Verkamp
Browse files

env: Convert some rte_mempools to spdk_mempools



This converts some, but not all, usage of rte_mempool
to spdk_mempool. The remaining rte_mempools use features
we elected not to expose through spdk_mempool such as
constructors, so that will need to be revisited.

Change-Id: I6528809a864ab466b8d19431789bf0f976b648b6
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
parent cc402a58
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@

#include <rte_config.h>
#include <rte_memzone.h>
#include <rte_mempool.h>
#include <rte_lcore.h>

#include "nvmf_tgt.h"

+11 −14
Original line number Diff line number Diff line
@@ -39,10 +39,10 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_lcore.h>
#include <rte_mempool.h>

#include "spdk/ioat.h"
#include "spdk/env.h"
#include "spdk/queue.h"
#include "spdk/string.h"

struct user_config {
@@ -70,8 +70,8 @@ struct thread_entry {
	uint64_t current_queue_depth;
	unsigned lcore_id;
	bool is_draining;
	struct rte_mempool *data_pool;
	struct rte_mempool *task_pool;
	struct spdk_mempool *data_pool;
	struct spdk_mempool *task_pool;
};

struct ioat_task {
@@ -134,9 +134,9 @@ ioat_done(void *cb_arg)
	thread_entry->current_queue_depth--;

	if (thread_entry->is_draining) {
		rte_mempool_put(thread_entry->data_pool, ioat_task->src);
		rte_mempool_put(thread_entry->data_pool, ioat_task->dst);
		rte_mempool_put(thread_entry->task_pool, ioat_task);
		spdk_mempool_put(thread_entry->data_pool, ioat_task->src);
		spdk_mempool_put(thread_entry->data_pool, ioat_task->dst);
		spdk_mempool_put(thread_entry->task_pool, ioat_task);
	} else {
		submit_single_xfer(thread_entry, ioat_task, ioat_task->dst, ioat_task->src);
	}
@@ -264,9 +264,9 @@ submit_xfers(struct thread_entry *thread_entry, uint64_t queue_depth)
		void *src = NULL, *dst = NULL;
		struct ioat_task *ioat_task = NULL;

		rte_mempool_get(thread_entry->data_pool, &src);
		rte_mempool_get(thread_entry->data_pool, &dst);
		rte_mempool_get(thread_entry->task_pool, (void **)&ioat_task);
		src = spdk_mempool_get(thread_entry->data_pool);
		dst = spdk_mempool_get(thread_entry->data_pool);
		ioat_task = spdk_mempool_get(thread_entry->task_pool);

		submit_single_xfer(thread_entry, ioat_task, dst, src);
	}
@@ -287,11 +287,8 @@ work_fn(void *arg)

	snprintf(buf_pool_name, sizeof(buf_pool_name), "buf_pool_%d", rte_lcore_id());
	snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", rte_lcore_id());
	t->data_pool = rte_mempool_create(buf_pool_name, 512, g_user_config.xfer_size_bytes, 0, 0, NULL,
					  NULL,
					  NULL, NULL, SOCKET_ID_ANY, 0);
	t->task_pool = rte_mempool_create(task_pool_name, 512, sizeof(struct ioat_task), 0, 0, NULL, NULL,
					  NULL, NULL, SOCKET_ID_ANY, 0);
	t->data_pool = spdk_mempool_create(buf_pool_name, 512, g_user_config.xfer_size_bytes, -1);
	t->task_pool = spdk_mempool_create(task_pool_name, 512, sizeof(struct ioat_task), -1);
	if (!t->data_pool || !t->task_pool) {
		fprintf(stderr, "Could not allocate buffer pool.\n");
		return 1;
+10 −13
Original line number Diff line number Diff line
@@ -39,10 +39,10 @@
#include <rte_config.h>
#include <rte_lcore.h>
#include <rte_eal.h>
#include <rte_mempool.h>

#include "spdk/ioat.h"
#include "spdk/env.h"
#include "spdk/queue.h"
#include "spdk/string.h"

#define SRC_BUFFER_SIZE (512*1024)
@@ -77,8 +77,8 @@ struct thread_entry {
	uint64_t current_queue_depth;
	unsigned lcore_id;
	bool is_draining;
	struct rte_mempool *data_pool;
	struct rte_mempool *task_pool;
	struct spdk_mempool *data_pool;
	struct spdk_mempool *task_pool;
};

struct ioat_task {
@@ -190,8 +190,8 @@ ioat_done(void *cb_arg)

	thread_entry->current_queue_depth--;
	if (thread_entry->is_draining) {
		rte_mempool_put(thread_entry->data_pool, ioat_task->buffer);
		rte_mempool_put(thread_entry->task_pool, ioat_task);
		spdk_mempool_put(thread_entry->data_pool, ioat_task->buffer);
		spdk_mempool_put(thread_entry->task_pool, ioat_task);
	} else {
		prepare_ioat_task(thread_entry, ioat_task);
		submit_single_xfer(ioat_task);
@@ -308,8 +308,8 @@ submit_xfers(struct thread_entry *thread_entry, uint64_t queue_depth)
{
	while (queue_depth-- > 0) {
		struct ioat_task *ioat_task = NULL;
		rte_mempool_get(thread_entry->task_pool, (void **)&ioat_task);
		rte_mempool_get(thread_entry->data_pool, &(ioat_task->buffer));
		ioat_task = spdk_mempool_get(thread_entry->task_pool);
		ioat_task->buffer = spdk_mempool_get(thread_entry->data_pool);

		ioat_task->type = IOAT_COPY_TYPE;
		if (spdk_ioat_get_dma_capabilities(thread_entry->chan) & SPDK_IOAT_ENGINE_FILL_SUPPORTED) {
@@ -336,12 +336,9 @@ work_fn(void *arg)

	snprintf(buf_pool_name, sizeof(buf_pool_name), "buf_pool_%d", rte_lcore_id());
	snprintf(task_pool_name, sizeof(task_pool_name), "task_pool_%d", rte_lcore_id());
	t->data_pool = rte_mempool_create(buf_pool_name, g_user_config.queue_depth, SRC_BUFFER_SIZE, 0, 0,
					  NULL, NULL,
					  NULL, NULL, SOCKET_ID_ANY, 0);
	t->task_pool = rte_mempool_create(task_pool_name, g_user_config.queue_depth,
					  sizeof(struct ioat_task), 0, 0, NULL, NULL,
					  NULL, NULL, SOCKET_ID_ANY, 0);
	t->data_pool = spdk_mempool_create(buf_pool_name, g_user_config.queue_depth, SRC_BUFFER_SIZE, -1);
	t->task_pool = spdk_mempool_create(task_pool_name, g_user_config.queue_depth,
					   sizeof(struct ioat_task), -1);
	if (!t->data_pool || !t->task_pool) {
		fprintf(stderr, "Could not allocate buffer pool.\n");
		return 1;
+0 −1
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@
#include <pthread.h>

#include "rte_config.h"
#include "rte_mempool.h"
#include "rte_eal.h"

#include "spdk/nvme.h"
+2 −1
Original line number Diff line number Diff line
@@ -32,11 +32,12 @@
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_eal.h>

#include "spdk/nvme.h"
#include "spdk/env.h"
Loading