ioat: Remove ioat_impl, use swappable env lib instead.

Change-Id: I377e41503b349b34c9ffc911840cb8fb9b13f322
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-08-12 09:23:44 -07:00
parent c0f04cedd0
commit e0196e8124
7 changed files with 39 additions and 88 deletions

4
CONFIG
View File

@ -57,10 +57,6 @@ CONFIG_DPDK_DIR?=/path/to/dpdk
# Defaults to depending on DPDK. # Defaults to depending on DPDK.
CONFIG_NVME_IMPL?=nvme_impl.h 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 # Build SPDK FIO plugin. Requires FIO_SOURCE_DIR set to a valid
# fio source code directory. # fio source code directory.
CONFIG_FIO_PLUGIN?=n CONFIG_FIO_PLUGIN?=n

View File

@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..) SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
CFLAGS += $(ENV_CFLAGS) -include $(CONFIG_IOAT_IMPL) CFLAGS += $(ENV_CFLAGS)
C_SRCS = ioat.c C_SRCS = ioat.c
LIBNAME = ioat LIBNAME = ioat

View File

@ -272,7 +272,7 @@ static int ioat_reset_hw(struct spdk_ioat_chan *ioat)
timeout = 20; /* in milliseconds */ timeout = 20; /* in milliseconds */
while (is_ioat_active(status) || is_ioat_idle(status)) { while (is_ioat_active(status) || is_ioat_idle(status)) {
ioat_delay_us(1000); spdk_delay_us(1000);
timeout--; timeout--;
if (timeout == 0) { if (timeout == 0) {
SPDK_ERRLOG("timed out waiting for suspend\n"); SPDK_ERRLOG("timed out waiting for suspend\n");
@ -292,7 +292,7 @@ static int ioat_reset_hw(struct spdk_ioat_chan *ioat)
timeout = 20; timeout = 20;
while (ioat_reset_pending(ioat)) { while (ioat_reset_pending(ioat)) {
ioat_delay_us(1000); spdk_delay_us(1000);
timeout--; timeout--;
if (timeout == 0) { if (timeout == 0) {
SPDK_ERRLOG("timed out waiting for reset\n"); SPDK_ERRLOG("timed out waiting for reset\n");
@ -352,11 +352,11 @@ ioat_channel_destruct(struct spdk_ioat_chan *ioat)
} }
if (ioat->hw_ring) { if (ioat->hw_ring) {
ioat_free(ioat->hw_ring); spdk_free(ioat->hw_ring);
} }
if (ioat->comp_update) { if (ioat->comp_update) {
ioat_free((void *)ioat->comp_update); spdk_free((void *)ioat->comp_update);
ioat->comp_update = NULL; ioat->comp_update = NULL;
} }
@ -402,7 +402,7 @@ ioat_channel_start(struct spdk_ioat_chan *ioat)
ioat->max_xfer_size = 1U << xfercap; 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); &comp_update_bus_addr);
if (ioat->comp_update == NULL) { if (ioat->comp_update == NULL) {
return -1; return -1;
@ -417,7 +417,7 @@ ioat_channel_start(struct spdk_ioat_chan *ioat)
return -1; 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); &ioat->hw_ring_phys_addr);
if (!ioat->hw_ring) { if (!ioat->hw_ring) {
return -1; return -1;
@ -442,7 +442,7 @@ ioat_channel_start(struct spdk_ioat_chan *ioat)
i = 100; i = 100;
while (i-- > 0) { while (i-- > 0) {
ioat_delay_us(100); spdk_delay_us(100);
status = ioat_get_chansts(ioat); status = ioat_get_chansts(ioat);
if (is_ioat_idle(status)) if (is_ioat_idle(status))
break; 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 = (uint64_t)src;
vsrc_page = _2MB_PAGE(vsrc); vsrc_page = _2MB_PAGE(vsrc);
vdst_page = _2MB_PAGE(vdst); vdst_page = _2MB_PAGE(vdst);
psrc_page = ioat_vtophys((void *)vsrc_page); psrc_page = spdk_vtophys((void *)vsrc_page);
pdst_page = ioat_vtophys((void *)vdst_page); pdst_page = spdk_vtophys((void *)vdst_page);
remaining = nbytes; 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) { if (_2MB_PAGE(vsrc) != vsrc_page) {
vsrc_page = _2MB_PAGE(vsrc); 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) { if (_2MB_PAGE(vdst) != vdst_page) {
vdst_page = _2MB_PAGE(vdst); 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 */ /* 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; remaining -= op_size;
last_desc = ioat_prep_fill(ioat, last_desc = ioat_prep_fill(ioat,
ioat_vtophys((void *)vdst), spdk_vtophys((void *)vdst),
fill_pattern, fill_pattern,
op_size); op_size);

View File

@ -1,42 +0,0 @@
#ifndef __IOAT_IMPL_H__
#define __IOAT_IMPL_H__
#include <pthread.h>
#include <stdio.h>
#include <stdbool.h>
#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__ */

View File

@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
C_SRCS = $(TEST_FILE) $(OTHER_FILES) 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 LIBS += -lcunit $(SPDK_ROOT_DIR)/lib/log/libspdk_log.a

View File

@ -1,28 +0,0 @@
/* Unit test stubbed version of ioat_impl.h */
#ifndef __IOAT_IMPL_H__
#define __IOAT_IMPL_H__
#include <assert.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
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__ */

View File

@ -33,8 +33,33 @@
#include "CUnit/Basic.h" #include "CUnit/Basic.h"
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include "ioat/ioat.c" #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 int
spdk_pci_enumerate(enum spdk_pci_device_type type, spdk_pci_enumerate(enum spdk_pci_device_type type,
spdk_pci_enum_cb enum_cb, spdk_pci_enum_cb enum_cb,