SPDK: Support configuring libpciaccess library

With CONFIG_PCIACCESS=y in CONFIG file, we can
use libpciaccess library; With CONFIG_PCIACCESS=n
in CONFIG file, we use pciaccess functions provided
in DPDK.

Change-Id: I786c5589b8e7909ba2e59d222938dd5ba45bf92d
Signed-off-by: Ziye Yang <ziye.yang@intel.com>
This commit is contained in:
Ziye Yang 2016-01-27 15:52:01 +08:00 committed by Daniel Verkamp
parent 8374a727a9
commit ff6125195c
14 changed files with 27 additions and 9 deletions

5
CONFIG
View File

@ -49,3 +49,8 @@ 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
# This item indicates using libpciaccess library or not. If enabled with y,
# libpciaccess library is used to map pci devices; else DPDK library is used to
# map pci devices.
CONFIG_PCIACCESS?=y

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/ioat/libspdk_ioat.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
all: $(APP)

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/ioat/libspdk_ioat.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
all: $(APP)

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/nvme/libspdk_nvme.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
all : $(APP)

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/nvme/libspdk_nvme.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
ifeq ($(OS),Linux)
LIBS += -laio

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/nvme/libspdk_nvme.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
all : $(APP)

View File

@ -34,6 +34,7 @@
#ifndef SPDK_PCI_H
#define SPDK_PCI_H
#ifdef USE_PCIACCESS
#define spdk_pci_device_get_domain(dev) (dev->domain)
#define spdk_pci_device_get_bus(dev) (dev->bus)
#define spdk_pci_device_get_dev(pdev) (pdev->dev)
@ -42,6 +43,7 @@
#define spdk_pci_device_get_device_id(dev) (dev->device_id)
#define spdk_pci_device_get_subvendor_id(dev) (dev->subvendor_id)
#define spdk_pci_device_get_subdevice_id(dev) (dev->subdevice_id)
#endif
#define PCI_CFG_SIZE 256
#define PCI_EXT_CAP_ID_SN 0x03

View File

@ -60,6 +60,7 @@ ioat_zmalloc(const char *tag, size_t size, unsigned align, uint64_t *phys_addr)
*/
#define ioat_printf(chan, fmt, args...) printf(fmt, ##args)
#ifdef USE_PCIACCESS
/**
*
*/
@ -83,6 +84,7 @@ ioat_pcicfg_unmap_bar(void *devhandle, uint32_t bar, void *addr)
return pci_device_unmap_range(dev, addr, dev->regions[bar].size);
}
#endif
typedef pthread_mutex_t ioat_mutex_t;

View File

@ -117,6 +117,7 @@ extern struct rte_mempool *request_mempool;
*/
#define nvme_dealloc_request(buf) rte_mempool_put(request_mempool, buf)
#ifdef USE_PCIACCESS
static inline int
nvme_pci_enumerate(int (*enum_cb)(void *enum_ctx, void *pci_dev), void *enum_ctx)
{
@ -171,6 +172,7 @@ nvme_pcicfg_unmap_bar(void *devhandle, uint32_t bar, void *addr)
return pci_device_unmap_range(dev, addr, dev->regions[bar].size);
}
#endif
typedef pthread_mutex_t nvme_mutex_t;

View File

@ -54,10 +54,11 @@
#define PCI_PRI_FMT "%04x:%02x:%02x.%1u"
#define SPDK_PCI_PATH_MAX 256
#ifdef USE_PCIACCESS
/* var should be the pointer */
#define spdk_pcicfg_read32(handle, var, offset) pci_device_cfg_read_u32(handle, var, offset)
#define spdk_pcicfg_write32(handle, var, offset) pci_device_cfg_write_u32(handle, *var, offset)
#endif
int
pci_device_get_serial_number(struct pci_device *dev, char *sn, int len)

View File

@ -84,6 +84,12 @@ LDFLAGS += --coverage
endif
endif
ifeq ($(CONFIG_PCIACCESS), y)
PCIACCESS_LIB=-lpciaccess
SPDK_PCIACCESS_CFLAGS=-DUSE_PCIACCESS
COMMON_CFLAGS += $(SPDK_PCIACCESS_CFLAGS)
endif
CFLAGS += $(COMMON_CFLAGS) -Wno-pointer-sign -std=gnu99
MAKEFLAGS += --no-print-directory

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/nvme/libspdk_nvme.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
all : $(APP)

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/nvme/libspdk_nvme.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
OBJS = $(C_SRCS:.c=.o)

View File

@ -44,7 +44,7 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/nvme/libspdk_nvme.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a \
$(SPDK_ROOT_DIR)/lib/memory/libspdk_memory.a
LIBS += $(SPDK_LIBS) -lpciaccess -lpthread $(DPDK_LIB) -lrt
LIBS += $(SPDK_LIBS) $(PCIACCESS_LIB) -lpthread $(DPDK_LIB) -lrt
all : $(APP)