Commit 6f48bf7c authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Ben Walker
Browse files

env/dpdk: drop support for DPDK < 17.11



DPDK 17.11 is the oldest version still supported by DPDK,
so drop support for DPDKs older than that in SPDK. This
lets us remove a huge amount of ifdefs.

Change-Id: I500987648e388cd5418a25845b6cccf4b55a4e5b
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447674


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 62e37db4
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -57,6 +57,10 @@ Default size is 4096.
The `phys_addr` parameter in spdk_malloc() and spdk_zmalloc() has been deprecated.
For retrieving physical addresses, spdk_vtophys() should be used instead.

### DPDK

Dropped support for DPDK 17.07 and earlier, which SPDK won't even compile with right now.

## v19.01:

### ocf bdev
+1 −23
Original line number Diff line number Diff line
@@ -47,17 +47,10 @@ virt_to_phys(void *vaddr)
{
	uint64_t ret;

#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
	ret = rte_malloc_virt2iova(vaddr);
	if (ret != RTE_BAD_IOVA) {
		return ret;
	}
#else
	ret = rte_malloc_virt2phy(vaddr);
	if (ret != RTE_BAD_PHYS_ADDR) {
		return ret;
	}
#endif

	return spdk_vtophys(vaddr, NULL);
}
@@ -402,26 +395,11 @@ spdk_ring_count(struct spdk_ring *ring)
size_t
spdk_ring_enqueue(struct spdk_ring *ring, void **objs, size_t count)
{
	int rc;
#if RTE_VERSION < RTE_VERSION_NUM(17, 5, 0, 0)
	rc = rte_ring_enqueue_bulk((struct rte_ring *)ring, objs, count);
	if (rc == 0) {
		return count;
	}

	return 0;
#else
	rc = rte_ring_enqueue_bulk((struct rte_ring *)ring, objs, count, NULL);
	return rc;
#endif
	return rte_ring_enqueue_bulk((struct rte_ring *)ring, objs, count, NULL);
}

size_t
spdk_ring_dequeue(struct spdk_ring *ring, void **objs, size_t count)
{
#if RTE_VERSION < RTE_VERSION_NUM(17, 5, 0, 0)
	return rte_ring_dequeue_burst((struct rte_ring *)ring, objs, count);
#else
	return rte_ring_dequeue_burst((struct rte_ring *)ring, objs, count, NULL);
#endif
}
+2 −6
Original line number Diff line number Diff line
@@ -41,17 +41,13 @@
#include <rte_config.h>
#include <rte_version.h>
#include <rte_eal.h>
#if RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 0)
#include <rte_bus.h>
#endif
#include <rte_pci.h>
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 1)
#include <rte_bus_pci.h>
#endif
#include <rte_dev.h>

#if RTE_VERSION < RTE_VERSION_NUM(16, 11, 0, 0)
#error RTE_VERSION is too old! Minimum 16.11 is required.
#if RTE_VERSION < RTE_VERSION_NUM(17, 11, 0, 0)
#error RTE_VERSION is too old! Minimum 17.11 is required.
#endif

/* x86-64 and ARM userspace virtual addresses use only the low 48 bits [0..47],
+5 −43
Original line number Diff line number Diff line
@@ -51,23 +51,10 @@
#define SPDK_VFIO_ENABLED 0
#else
#include <linux/version.h>
/*
 * DPDK versions before 17.11 don't provide a way to get VFIO information in the public API,
 * and we can't link to internal symbols when built against shared library DPDK,
 * so disable VFIO entirely in that case.
 */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) && \
    (RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3) || !defined(RTE_BUILD_SHARED_LIB))

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
#define SPDK_VFIO_ENABLED 1
#include <linux/vfio.h>

#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
#include <rte_vfio.h>
#else
/* Internal DPDK function forward declaration */
int pci_vfio_is_enabled(void);
#endif

struct spdk_vfio_dma_map {
	struct vfio_iommu_type1_dma_map map;
@@ -929,11 +916,7 @@ vtophys_get_paddr_memseg(uint64_t vaddr)
		if (vaddr >= (uintptr_t)seg->addr &&
		    vaddr < ((uintptr_t)seg->addr + seg->len)) {
			paddr = seg->phys_addr;
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
			if (paddr == RTE_BAD_IOVA) {
#else
			if (paddr == RTE_BAD_PHYS_ADDR) {
#endif
				return SPDK_VTOPHYS_ERROR;
			}
			paddr += (vaddr - (uintptr_t)seg->addr);
@@ -951,38 +934,21 @@ vtophys_get_paddr_pagemap(uint64_t vaddr)
{
	uintptr_t paddr;

#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
#define BAD_ADDR RTE_BAD_IOVA
#define VTOPHYS rte_mem_virt2iova
#else
#define BAD_ADDR RTE_BAD_PHYS_ADDR
#define VTOPHYS rte_mem_virt2phy
#endif

	/*
	 * Note: the virt2phy/virt2iova functions have changed over time, such
	 * that older versions may return 0 while recent versions will never
	 * return 0 but RTE_BAD_PHYS_ADDR/IOVA instead.  To support older and
	 * newer versions, check for both return values.
	 */
	paddr = VTOPHYS((void *)vaddr);
	if (paddr == 0 || paddr == BAD_ADDR) {
	paddr = rte_mem_virt2iova((void *)vaddr);
	if (paddr == RTE_BAD_IOVA) {
		/*
		 * The vaddr may be valid but doesn't have a backing page
		 * assigned yet.  Touch the page to ensure a backing page
		 * gets assigned, then try to translate again.
		 */
		rte_atomic64_read((rte_atomic64_t *)vaddr);
		paddr = VTOPHYS((void *)vaddr);
		paddr = rte_mem_virt2iova((void *)vaddr);
	}
	if (paddr == 0 || paddr == BAD_ADDR) {
	if (paddr == RTE_BAD_IOVA) {
		/* Unable to get to the physical address. */
		return SPDK_VTOPHYS_ERROR;
	}

#undef BAD_ADDR
#undef VTOPHYS

	return paddr;
}

@@ -1122,11 +1088,7 @@ spdk_vtophys_notify(void *cb_ctx, struct spdk_mem_map *map,
static bool
spdk_vfio_enabled(void)
{
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
	return rte_vfio_is_enabled("vfio_pci");
#else
	return pci_vfio_is_enabled();
#endif
}

/* Check if IOMMU is enabled on the system */
+2 −45
Original line number Diff line number Diff line
@@ -73,11 +73,7 @@ spdk_cfg_read_rte(struct spdk_pci_device *dev, void *value, uint32_t len, uint32
{
	int rc;

#if RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
	rc = rte_pci_read_config(dev->dev_handle, value, len, offset);
#else
	rc = rte_eal_pci_read_config(dev->dev_handle, value, len, offset);
#endif

#if defined(__FreeBSD__) && RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0)
	/* Older DPDKs return 0 on success and -1 on failure */
@@ -91,11 +87,7 @@ spdk_cfg_write_rte(struct spdk_pci_device *dev, void *value, uint32_t len, uint3
{
	int rc;

#if RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
	rc = rte_pci_write_config(dev->dev_handle, value, len, offset);
#else
	rc = rte_eal_pci_write_config(dev->dev_handle, value, len, offset);
#endif

#ifdef __FreeBSD__
	/* DPDK returns 0 on success and -1 on failure */
@@ -117,13 +109,8 @@ spdk_detach_rte(struct spdk_pci_device *dev)
	do {
		rc = rte_eal_hotplug_remove("pci", bdf);
	} while (rc == -ENOMSG && ++i <= DPDK_HOTPLUG_RETRY_COUNT);
#elif RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
	rte_eal_dev_detach(&rte_dev->device);
#elif RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
	rte_pci_detach(&rte_dev->addr);
#else
	rte_eal_device_remove(&rte_dev->device);
	rte_eal_pci_detach(&rte_dev->addr);
	rte_eal_dev_detach(&rte_dev->device);
#endif
}

@@ -170,9 +157,6 @@ spdk_pci_device_init(struct rte_pci_driver *_drv,

#if RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0)
	if (!driver->cb_fn) {
#if RTE_VERSION < RTE_VERSION_NUM(17, 02, 0, 1)
		rte_eal_pci_unmap_device(_dev);
#endif
		/* Return a positive value to indicate that this device does
		 * not belong to this driver, but this isn't an error.
		 */
@@ -257,18 +241,9 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver,
{
	struct spdk_pci_device *dev;
	int rc;
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
	char bdf[32];

	spdk_pci_addr_fmt(bdf, sizeof(bdf), pci_address);
#else
	struct rte_pci_addr addr;

	addr.domain = pci_address->domain;
	addr.bus = pci_address->bus;
	addr.devid = pci_address->dev;
	addr.function = pci_address->func;
#endif

	pthread_mutex_lock(&g_pci_mutex);

@@ -294,11 +269,7 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver,

	if (!driver->is_registered) {
		driver->is_registered = true;
#if RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
		rte_pci_register(&driver->driver);
#else
		rte_eal_pci_register(&driver->driver);
#endif
	}

	driver->cb_fn = enum_cb;
@@ -317,12 +288,8 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver,
		 */
		rc = 0;
	}
#elif RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
	rc = rte_eal_dev_attach(bdf, "");
#elif RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
	rc = rte_pci_probe_one(&addr);
#else
	rc = rte_eal_pci_probe_one(&addr);
	rc = rte_eal_dev_attach(bdf, "");
#endif

	driver->cb_arg = NULL;
@@ -362,23 +329,13 @@ spdk_pci_enumerate(struct spdk_pci_driver *driver,

	if (!driver->is_registered) {
		driver->is_registered = true;
#if RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
		rte_pci_register(&driver->driver);
#else
		rte_eal_pci_register(&driver->driver);
#endif
	}

	driver->cb_fn = enum_cb;
	driver->cb_arg = enum_ctx;

#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
	if (rte_bus_scan() != 0 || rte_bus_probe() != 0) {
#elif RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
	if (rte_pci_scan() != 0 || rte_pci_probe() != 0) {
#else
	if (rte_eal_pci_scan() != 0 || rte_eal_pci_probe() != 0) {
#endif
		driver->cb_arg = NULL;
		driver->cb_fn = NULL;
		pthread_mutex_unlock(&g_pci_mutex);