From e0196e8124ad640f5b949ae86c667649bd7ba413 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Fri, 12 Aug 2016 09:23:44 -0700 Subject: [PATCH] ioat: Remove ioat_impl, use swappable env lib instead. Change-Id: I377e41503b349b34c9ffc911840cb8fb9b13f322 Signed-off-by: Ben Walker --- CONFIG | 4 ---- lib/ioat/Makefile | 2 +- lib/ioat/ioat.c | 24 +++++++++---------- lib/ioat/ioat_impl.h | 42 ---------------------------------- mk/ioat.unittest.mk | 2 +- test/lib/ioat/unit/ioat_impl.h | 28 ----------------------- test/lib/ioat/unit/ioat_ut.c | 25 ++++++++++++++++++++ 7 files changed, 39 insertions(+), 88 deletions(-) delete mode 100644 lib/ioat/ioat_impl.h delete mode 100644 test/lib/ioat/unit/ioat_impl.h diff --git a/CONFIG b/CONFIG index d3ac75bca..5e54681ce 100644 --- a/CONFIG +++ b/CONFIG @@ -57,10 +57,6 @@ CONFIG_DPDK_DIR?=/path/to/dpdk # Defaults to depending on DPDK. CONFIG_NVME_IMPL?=nvme_impl.h -# Header file to use for IOAT implementation specific functions. -# Defaults to depending on DPDK. -CONFIG_IOAT_IMPL?=ioat_impl.h - # Build SPDK FIO plugin. Requires FIO_SOURCE_DIR set to a valid # fio source code directory. CONFIG_FIO_PLUGIN?=n diff --git a/lib/ioat/Makefile b/lib/ioat/Makefile index 2219e7246..aa835a2f8 100644 --- a/lib/ioat/Makefile +++ b/lib/ioat/Makefile @@ -34,7 +34,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) include $(SPDK_ROOT_DIR)/mk/spdk.common.mk -CFLAGS += $(ENV_CFLAGS) -include $(CONFIG_IOAT_IMPL) +CFLAGS += $(ENV_CFLAGS) C_SRCS = ioat.c LIBNAME = ioat diff --git a/lib/ioat/ioat.c b/lib/ioat/ioat.c index e0c23244e..75e66e8d7 100644 --- a/lib/ioat/ioat.c +++ b/lib/ioat/ioat.c @@ -272,7 +272,7 @@ static int ioat_reset_hw(struct spdk_ioat_chan *ioat) timeout = 20; /* in milliseconds */ while (is_ioat_active(status) || is_ioat_idle(status)) { - ioat_delay_us(1000); + spdk_delay_us(1000); timeout--; if (timeout == 0) { SPDK_ERRLOG("timed out waiting for suspend\n"); @@ -292,7 +292,7 @@ static int ioat_reset_hw(struct spdk_ioat_chan *ioat) timeout = 20; while (ioat_reset_pending(ioat)) { - ioat_delay_us(1000); + spdk_delay_us(1000); timeout--; if (timeout == 0) { SPDK_ERRLOG("timed out waiting for reset\n"); @@ -352,11 +352,11 @@ ioat_channel_destruct(struct spdk_ioat_chan *ioat) } if (ioat->hw_ring) { - ioat_free(ioat->hw_ring); + spdk_free(ioat->hw_ring); } if (ioat->comp_update) { - ioat_free((void *)ioat->comp_update); + spdk_free((void *)ioat->comp_update); ioat->comp_update = NULL; } @@ -402,7 +402,7 @@ ioat_channel_start(struct spdk_ioat_chan *ioat) ioat->max_xfer_size = 1U << xfercap; } - ioat->comp_update = ioat_zmalloc(sizeof(*ioat->comp_update), SPDK_IOAT_CHANCMP_ALIGN, + ioat->comp_update = spdk_zmalloc(sizeof(*ioat->comp_update), SPDK_IOAT_CHANCMP_ALIGN, &comp_update_bus_addr); if (ioat->comp_update == NULL) { return -1; @@ -417,7 +417,7 @@ ioat_channel_start(struct spdk_ioat_chan *ioat) return -1; } - ioat->hw_ring = ioat_zmalloc(num_descriptors * sizeof(union spdk_ioat_hw_desc), 64, + ioat->hw_ring = spdk_zmalloc(num_descriptors * sizeof(union spdk_ioat_hw_desc), 64, &ioat->hw_ring_phys_addr); if (!ioat->hw_ring) { return -1; @@ -442,7 +442,7 @@ ioat_channel_start(struct spdk_ioat_chan *ioat) i = 100; while (i-- > 0) { - ioat_delay_us(100); + spdk_delay_us(100); status = ioat_get_chansts(ioat); if (is_ioat_idle(status)) break; @@ -594,8 +594,8 @@ spdk_ioat_submit_copy(struct spdk_ioat_chan *ioat, void *cb_arg, spdk_ioat_req_c vsrc = (uint64_t)src; vsrc_page = _2MB_PAGE(vsrc); vdst_page = _2MB_PAGE(vdst); - psrc_page = ioat_vtophys((void *)vsrc_page); - pdst_page = ioat_vtophys((void *)vdst_page); + psrc_page = spdk_vtophys((void *)vsrc_page); + pdst_page = spdk_vtophys((void *)vdst_page); remaining = nbytes; @@ -620,12 +620,12 @@ spdk_ioat_submit_copy(struct spdk_ioat_chan *ioat, void *cb_arg, spdk_ioat_req_c if (_2MB_PAGE(vsrc) != vsrc_page) { vsrc_page = _2MB_PAGE(vsrc); - psrc_page = ioat_vtophys((void *)vsrc_page); + psrc_page = spdk_vtophys((void *)vsrc_page); } if (_2MB_PAGE(vdst) != vdst_page) { vdst_page = _2MB_PAGE(vdst); - pdst_page = ioat_vtophys((void *)vdst_page); + pdst_page = spdk_vtophys((void *)vdst_page); } } /* Issue null descriptor for null transfer */ @@ -678,7 +678,7 @@ spdk_ioat_submit_fill(struct spdk_ioat_chan *ioat, void *cb_arg, spdk_ioat_req_c remaining -= op_size; last_desc = ioat_prep_fill(ioat, - ioat_vtophys((void *)vdst), + spdk_vtophys((void *)vdst), fill_pattern, op_size); diff --git a/lib/ioat/ioat_impl.h b/lib/ioat/ioat_impl.h deleted file mode 100644 index dfceb2a9b..000000000 --- a/lib/ioat/ioat_impl.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __IOAT_IMPL_H__ -#define __IOAT_IMPL_H__ - -#include -#include -#include - -#include "spdk/assert.h" -#include "spdk/env.h" - -/** - * \file - * - * This file describes the functions required to integrate - * the userspace IOAT driver for a specific implementation. This - * implementation is specific for DPDK. Users would revise it as - * necessary for their own particular environment if not using it - * within the SPDK framework. - */ - -/** - * Allocate a pinned, physically contiguous memory buffer with the - * given size and alignment. - */ -#define ioat_zmalloc spdk_zmalloc - -/** - * Free a memory buffer previously allocated with ioat_zmalloc. - */ -#define ioat_free spdk_free - -/** - * Return the physical address for the specified virtual address. - */ -#define ioat_vtophys(buf) spdk_vtophys(buf) - -/** - * Delay us. - */ -#define ioat_delay_us spdk_delay_us - -#endif /* __IOAT_IMPL_H__ */ diff --git a/mk/ioat.unittest.mk b/mk/ioat.unittest.mk index 1f97af210..b5e630f8e 100644 --- a/mk/ioat.unittest.mk +++ b/mk/ioat.unittest.mk @@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk C_SRCS = $(TEST_FILE) $(OTHER_FILES) -CFLAGS += -I$(SPDK_ROOT_DIR)/lib -include $(SPDK_ROOT_DIR)/test/lib/ioat/unit/ioat_impl.h +CFLAGS += -I$(SPDK_ROOT_DIR)/lib LIBS += -lcunit $(SPDK_ROOT_DIR)/lib/log/libspdk_log.a diff --git a/test/lib/ioat/unit/ioat_impl.h b/test/lib/ioat/unit/ioat_impl.h deleted file mode 100644 index f5e777b4f..000000000 --- a/test/lib/ioat/unit/ioat_impl.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Unit test stubbed version of ioat_impl.h */ - -#ifndef __IOAT_IMPL_H__ -#define __IOAT_IMPL_H__ - -#include -#include -#include -#include -#include - -struct spdk_pci_device; - -static inline void * -ioat_zmalloc(size_t size, unsigned align, uint64_t *phys_addr) -{ - return calloc(1, size); -} - -#define ioat_noop() do { } while (0) - -#define ioat_calloc(tag, num, size, align) calloc(num, size) -#define ioat_malloc(tag, size, align) malloc(size) -#define ioat_free(buf) free(buf) -#define ioat_vtophys(buf) (uint64_t)(buf) -#define ioat_delay_us(us) ioat_noop() - -#endif /* __IOAT_IMPL_H__ */ diff --git a/test/lib/ioat/unit/ioat_ut.c b/test/lib/ioat/unit/ioat_ut.c index 0425a4cc7..70d5a6983 100644 --- a/test/lib/ioat/unit/ioat_ut.c +++ b/test/lib/ioat/unit/ioat_ut.c @@ -33,8 +33,33 @@ #include "CUnit/Basic.h" +#include +#include +#include + #include "ioat/ioat.c" +void * +spdk_zmalloc(size_t size, size_t align, uint64_t *phys_addr) +{ + return calloc(1, size); +} + +void spdk_free(void *buf) +{ + free(buf); +} + +uint64_t spdk_vtophys(void *buf) +{ + return (uint64_t)buf; +} + +void spdk_delay_us(unsigned int us) +{ + +} + int spdk_pci_enumerate(enum spdk_pci_device_type type, spdk_pci_enum_cb enum_cb,