AC_SUBST(XIO_LIBS)
fi
+#
+# DPDK
+#
+
+AC_ARG_WITH(dpdk,
+ [AC_HELP_STRING([--with-dpdk], [build Ceph DPDK Support])], [], [with_dpdk=no])
+
+AM_CONDITIONAL(WITH_DPDK, [test "x$with_dpdk" != "xno"])
+
+if test "x$with_dpdk" != x"no"; then
+ CPPFLAGS="$CPPFLAGS -I$with_dpdk/include"
+ LDFLAGS="$LDFLAGS -I$with_dpdk/lib"
+ AC_CHECK_HEADER([rte_config.h], [], AC_MSG_ERROR([Cannot find header 'rte_config.h'.]))
+ AC_CHECK_LIB([rte_eal], [rte_eal_init], [], AC_MSG_FAILURE([DPDK rte_eal_init not found]))
+
+ AC_DEFINE([HAVE_DPDK], [1], [DPDK conditional compilation])
+fi
+
#
# SPDK
#
if test "x$with_spdk" != x"no"; then
CPPFLAGS="$CPPFLAGS -I$with_spdk/include"
+ LDFLAGS="$LDFLAGS -I$with_dpdk/lib"
AC_CHECK_HEADER([spdk/nvme.h], [], AC_MSG_ERROR([Cannot find header 'spdk/nvme.h'.]))
AC_CHECK_LIB([spdk_nvme], [nvme_attach], [], AC_MSG_FAILURE([SPDK nvme_attach not found]))
#include <fcntl.h>
#include <unistd.h>
+#include <rte_config.h>
+#include <rte_cycles.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_lcore.h>
+
#include "include/types.h"
#include "include/compat.h"
#include "common/errno.h"
zeros.zero();
}
+static char *ealargs[] = {
+ "perf",
+ "-c 0x1", /* This must be the second parameter. It is overwritten by index in main(). */
+ "-n 4",
+};
+
int NVMEDevice::open(string p)
{
int r = 0;
pci_device *pci_dev;
+ r = rte_eal_init(sizeof(ealargs) / sizeof(ealargs[0]), (char **)(void *)(uintptr_t)ealargs);
+ if (r < 0) {
+ derr << __func__ << " init dpdk failed" << dendl;
+ return r;
+ }
+
+ if (request_mempool == NULL) {
+ derr << __func__ << " could not initialize request mempool" << dendl;
+ return -1;
+ }
+
pci_system_init();
// Search for matching devices
string sn_tag = g_conf->bdev_nvme_serial_number;
if (sn_tag.empty()) {
- int r = -ENOENT;
+ r = -ENOENT;
derr << __func__ << " empty serial number: " << cpp_strerror(r) << dendl;
return r;
}
- unbindfromkernel = g_conf->bdev_nvme_unbind_from_kernel;
-
char serial_number[128];
while ((pci_dev = pci_device_next(iter)) != NULL) {
dout(10) << __func__ << " found device at "<< pci_dev->bus << ":" << pci_dev->dev << ":"
if (pci_device_has_kernel_driver(pci_dev)) {
if (!pci_device_has_uio_driver(pci_dev)) {
/*NVMe kernel driver case*/
- if (unbindfromkernel) {
+ if (g_conf->bdev_nvme_unbind_from_kernel) {
r = pci_device_switch_to_uio_driver(pci_dev);
if (r < 0) {
derr << __func__ << " device " << pci_device_get_device_name(pci_dev) << " " << pci_dev->bus
if (num_ns > 1) {
dout(0) << __func__ << " namespace count larger than 1, currently only use the first namespace" << dendl;
}
- nvme_namespace *ns = nvme_ctrlr_get_ns(ctrlr, 0);
+ ns = nvme_ctrlr_get_ns(ctrlr, 1);
+ if (!ns) {
+ derr << __func__ << " failed to get namespace at 1" << dendl;
+ return -1;
+ }
block_size = nvme_ns_get_sector_size(ns);
size = block_size * nvme_ns_get_num_sectors(ns);
dout(1) << __func__ << " successfully attach nvme device at" << pci_device_get_device_name(pci_dev)
<< " " << pci_dev->bus << ":" << pci_dev->dev << ":" << pci_dev->func << dendl;
break;
}
+ if (pci_dev == NULL) {
+ derr << __func__ << " failed to found nvme serial number " << sn_tag << dend;
+ return -ENOENT;
+ }
pci_iterator_destroy(iter);