From 35549703755eb6ca4ce43b180d75bb830b642ba0 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Fri, 5 Jun 2020 14:07:45 +0200 Subject: [PATCH] env_dpdk: drop DPDK 18.08 support DPDK versions 17.11 to 18.08 reached EOL. Change-Id: Icfec27b0099f53d6ab00ec3aed63e5d30d94ee4d Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2940 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Michael Haeuptle --- lib/env_dpdk/env.c | 5 ---- lib/env_dpdk/env_internal.h | 4 +-- lib/env_dpdk/init.c | 41 -------------------------- lib/env_dpdk/memory.c | 41 -------------------------- lib/env_dpdk/pci.c | 29 ------------------ lib/env_dpdk/pci_nvme.c | 2 -- lib/env_dpdk/pci_virtio.c | 2 -- lib/env_dpdk/pci_vmd.c | 2 -- test/env/mem_callbacks/mem_callbacks.c | 12 -------- 9 files changed, 2 insertions(+), 136 deletions(-) diff --git a/lib/env_dpdk/env.c b/lib/env_dpdk/env.c index b10bbb5c1..94b709de9 100644 --- a/lib/env_dpdk/env.c +++ b/lib/env_dpdk/env.c @@ -150,14 +150,9 @@ spdk_memzone_reserve_aligned(const char *name, size_t len, int socket_id, const struct rte_memzone *mz; unsigned dpdk_flags = 0; -#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0) - /* Older DPDKs do not offer such flag since their - * memzones are iova-contiguous by default. - */ if ((flags & SPDK_MEMZONE_NO_IOVA_CONTIG) == 0) { dpdk_flags |= RTE_MEMZONE_IOVA_CONTIG; } -#endif if (socket_id == SPDK_ENV_SOCKET_ID_ANY) { socket_id = SOCKET_ID_ANY; diff --git a/lib/env_dpdk/env_internal.h b/lib/env_dpdk/env_internal.h index 1d7845a98..fa2554e76 100644 --- a/lib/env_dpdk/env_internal.h +++ b/lib/env_dpdk/env_internal.h @@ -46,8 +46,8 @@ #include #include -#if RTE_VERSION < RTE_VERSION_NUM(17, 11, 0, 0) -#error RTE_VERSION is too old! Minimum 17.11 is required. +#if RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) +#error RTE_VERSION is too old! Minimum 18.11 is required. #endif /* x86-64 and ARM userspace virtual addresses use only the low 48 bits [0..47], diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 20fb05211..d4f997bb8 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -105,23 +105,6 @@ _sprintf_alloc(const char *format, ...) return NULL; } -static void -env_unlink_shared_files(void) -{ - /* Starting with DPDK 18.05, there are more files with unpredictable paths - * and filenames. The --no-shconf option prevents from creating them, but - * only for DPDK 18.08+. For DPDK 18.05 we just leave them be. - */ -#if RTE_VERSION < RTE_VERSION_NUM(18, 05, 0, 0) - char buffer[PATH_MAX]; - - snprintf(buffer, PATH_MAX, "/var/run/.spdk_pid%d_hugepage_info", getpid()); - if (unlink(buffer)) { - fprintf(stderr, "Unable to unlink shared memory file: %s. Error code: %d\n", buffer, errno); - } -#endif -} - void spdk_env_opts_init(struct spdk_env_opts *opts) { @@ -348,16 +331,6 @@ build_eal_cmdline(const struct spdk_env_opts *opts) } } -#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0) && RTE_VERSION < RTE_VERSION_NUM(18, 5, 1, 0) - /* Dynamic memory management is buggy in DPDK 18.05.0. Don't use it. */ - if (!opts->env_context || strstr(opts->env_context, "--legacy-mem") == NULL) { - args = push_arg(args, &argcount, _sprintf_alloc("--legacy-mem")); - if (args == NULL) { - return -1; - } - } -#endif - if (opts->num_pci_addr) { size_t i; char bdf[32]; @@ -375,8 +348,6 @@ build_eal_cmdline(const struct spdk_env_opts *opts) } } - /* The following log-level options are not understood by older DPDKs */ -#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0) /* Lower default EAL loglevel to RTE_LOG_NOTICE - normal, but significant messages. * This can be overridden by specifying the same option in opts->env_context */ @@ -402,7 +373,6 @@ build_eal_cmdline(const struct spdk_env_opts *opts) if (args == NULL) { return -1; } -#endif if (opts->env_context) { args = push_arg(args, &argcount, strdup(opts->env_context)); @@ -584,17 +554,6 @@ spdk_env_init(const struct spdk_env_opts *opts) return -rte_errno; } - if (opts->shm_id < 0 && !opts->hugepage_single_segments) { - /* - * Unlink hugepage and config info files after init. This will ensure they get - * deleted on app exit, even if the app crashes and does not exit normally. - * Only do this when not in multi-process mode, since for multi-process other - * apps will need to open these files. These files are not created for - * "single file segments". - */ - env_unlink_shared_files(); - } - legacy_mem = false; if (opts->env_context && strstr(opts->env_context, "--legacy-mem") != NULL) { legacy_mem = true; diff --git a/lib/env_dpdk/memory.c b/lib/env_dpdk/memory.c index 92d2b3982..4c2205a46 100644 --- a/lib/env_dpdk/memory.c +++ b/lib/env_dpdk/memory.c @@ -703,7 +703,6 @@ spdk_mem_map_translate(const struct spdk_mem_map *map, uint64_t vaddr, uint64_t return orig_translation; } -#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0) static void memory_hotplug_cb(enum rte_mem_event event_type, const void *addr, size_t len, void *arg) @@ -751,7 +750,6 @@ memory_iter_cb(const struct rte_memseg_list *msl, { return spdk_mem_register(ms->addr, len); } -#endif int mem_map_init(bool legacy_mem) @@ -768,24 +766,8 @@ mem_map_init(bool legacy_mem) * Walk all DPDK memory segments and register them * with the master memory map */ -#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0) rte_mem_event_callback_register("spdk", memory_hotplug_cb, NULL); rte_memseg_contig_walk(memory_iter_cb, NULL); -#else - struct rte_mem_config *mcfg; - size_t seg_idx; - - mcfg = rte_eal_get_configuration()->mem_config; - for (seg_idx = 0; seg_idx < RTE_MAX_MEMSEG; seg_idx++) { - struct rte_memseg *seg = &mcfg->memseg[seg_idx]; - - if (seg->addr == NULL) { - break; - } - - spdk_mem_register(seg->addr, seg->len); - } -#endif return 0; } @@ -938,7 +920,6 @@ vtophys_get_paddr_memseg(uint64_t vaddr) uintptr_t paddr; struct rte_memseg *seg; -#if RTE_VERSION >= RTE_VERSION_NUM(18, 05, 0, 0) seg = rte_mem_virt2memseg((void *)(uintptr_t)vaddr, NULL); if (seg != NULL) { paddr = seg->phys_addr; @@ -948,28 +929,6 @@ vtophys_get_paddr_memseg(uint64_t vaddr) paddr += (vaddr - (uintptr_t)seg->addr); return paddr; } -#else - struct rte_mem_config *mcfg; - uint32_t seg_idx; - - mcfg = rte_eal_get_configuration()->mem_config; - for (seg_idx = 0; seg_idx < RTE_MAX_MEMSEG; seg_idx++) { - seg = &mcfg->memseg[seg_idx]; - if (seg->addr == NULL) { - break; - } - - if (vaddr >= (uintptr_t)seg->addr && - vaddr < ((uintptr_t)seg->addr + seg->len)) { - paddr = seg->phys_addr; - if (paddr == RTE_BAD_IOVA) { - return SPDK_VTOPHYS_ERROR; - } - paddr += (vaddr - (uintptr_t)seg->addr); - return paddr; - } - } -#endif return SPDK_VTOPHYS_ERROR; } diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 1bce2010e..3b204e1ff 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -80,10 +80,6 @@ cfg_read_rte(struct spdk_pci_device *dev, void *value, uint32_t len, uint32_t of rc = rte_pci_read_config(dev->dev_handle, value, len, offset); -#if defined(__FreeBSD__) && RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) - /* Older DPDKs return 0 on success and -1 on failure */ - return rc; -#endif return (rc > 0 && (uint32_t) rc == len) ? 0 : -1; } @@ -104,7 +100,6 @@ cfg_write_rte(struct spdk_pci_device *dev, void *value, uint32_t len, uint32_t o static void remove_rte_dev(struct rte_pci_device *rte_dev) { -#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0) char bdf[32]; int i = 0, rc; @@ -112,9 +107,6 @@ remove_rte_dev(struct rte_pci_device *rte_dev) do { rc = rte_eal_hotplug_remove("pci", bdf); } while (rc == -ENOMSG && ++i <= DPDK_HOTPLUG_RETRY_COUNT); -#else - rte_eal_dev_detach(&rte_dev->device); -#endif } static void @@ -183,7 +175,6 @@ pci_driver_register(struct spdk_pci_driver *driver) TAILQ_INSERT_TAIL(&g_pci_drivers, driver, tailq); } -#if RTE_VERSION >= RTE_VERSION_NUM(18, 5, 0, 0) static void pci_device_rte_hotremove(const char *device_name, enum rte_dev_event_type event, @@ -217,7 +208,6 @@ pci_device_rte_hotremove(const char *device_name, remove_rte_dev(dev->dev_handle); } } -#endif static void cleanup_pci_devices(void) @@ -248,7 +238,6 @@ cleanup_pci_devices(void) void pci_env_init(void) { -#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0) struct spdk_pci_driver *driver; /* We need to pre-register pci drivers for the pci devices to be @@ -269,14 +258,11 @@ pci_env_init(void) driver->is_registered = true; rte_pci_register(&driver->driver); } -#endif -#if RTE_VERSION >= RTE_VERSION_NUM(18, 5, 0, 0) /* Register a single hotremove callback for all devices. */ if (spdk_process_is_primary()) { rte_dev_event_callback_register(NULL, pci_device_rte_hotremove, NULL); } -#endif } void @@ -293,11 +279,9 @@ pci_env_fini(void) } } -#if RTE_VERSION >= RTE_VERSION_NUM(18, 5, 0, 0) if (spdk_process_is_primary()) { rte_dev_event_callback_unregister(NULL, pci_device_rte_hotremove, NULL); } -#endif } int @@ -308,15 +292,6 @@ pci_device_init(struct rte_pci_driver *_drv, struct spdk_pci_device *dev; int rc; -#if RTE_VERSION < RTE_VERSION_NUM(18, 11, 0, 0) - if (!driver->cb_fn) { - /* Return a positive value to indicate that this device does - * not belong to this driver, but this isn't an error. - */ - return 1; - } -#endif - dev = calloc(1, sizeof(*dev)); if (dev == NULL) { return -1; @@ -441,7 +416,6 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver, driver->cb_fn = enum_cb; driver->cb_arg = enum_ctx; -#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0) int i = 0; do { @@ -454,9 +428,6 @@ spdk_pci_device_attach(struct spdk_pci_driver *driver, */ rc = 0; } -#else - rc = rte_eal_dev_attach(bdf, ""); -#endif driver->cb_arg = NULL; driver->cb_fn = NULL; diff --git a/lib/env_dpdk/pci_nvme.c b/lib/env_dpdk/pci_nvme.c index a21b242e7..e5122874c 100644 --- a/lib/env_dpdk/pci_nvme.c +++ b/lib/env_dpdk/pci_nvme.c @@ -49,9 +49,7 @@ static struct rte_pci_id nvme_pci_driver_id[] = { static struct spdk_pci_driver g_nvme_pci_drv = { .driver = { .drv_flags = RTE_PCI_DRV_NEED_MAPPING -#if RTE_VERSION >= RTE_VERSION_NUM(18, 8, 0, 0) | RTE_PCI_DRV_WC_ACTIVATE -#endif , .id_table = nvme_pci_driver_id, .probe = pci_device_init, diff --git a/lib/env_dpdk/pci_virtio.c b/lib/env_dpdk/pci_virtio.c index 857edb7d7..a762c4a17 100644 --- a/lib/env_dpdk/pci_virtio.c +++ b/lib/env_dpdk/pci_virtio.c @@ -46,9 +46,7 @@ static struct rte_pci_id virtio_pci_driver_id[] = { static struct spdk_pci_driver g_virtio_pci_drv = { .driver = { .drv_flags = RTE_PCI_DRV_NEED_MAPPING -#if RTE_VERSION >= RTE_VERSION_NUM(18, 8, 0, 0) | RTE_PCI_DRV_WC_ACTIVATE -#endif , .id_table = virtio_pci_driver_id, .probe = pci_device_init, diff --git a/lib/env_dpdk/pci_vmd.c b/lib/env_dpdk/pci_vmd.c index 331e24718..ae5f4b658 100644 --- a/lib/env_dpdk/pci_vmd.c +++ b/lib/env_dpdk/pci_vmd.c @@ -43,9 +43,7 @@ static struct rte_pci_id vmd_pci_driver_id[] = { static struct spdk_pci_driver g_vmd_pci_drv = { .driver = { .drv_flags = RTE_PCI_DRV_NEED_MAPPING -#if RTE_VERSION >= RTE_VERSION_NUM(18, 8, 0, 0) | RTE_PCI_DRV_WC_ACTIVATE -#endif , .id_table = vmd_pci_driver_id, .probe = pci_device_init, diff --git a/test/env/mem_callbacks/mem_callbacks.c b/test/env/mem_callbacks/mem_callbacks.c index accdedbcd..165ddb3d8 100644 --- a/test/env/mem_callbacks/mem_callbacks.c +++ b/test/env/mem_callbacks/mem_callbacks.c @@ -43,16 +43,6 @@ #include #include -#if RTE_VERSION < RTE_VERSION_NUM(18, 05, 0, 0) - -static void -test(void) -{ - printf("DPDK version %s does not support memory callbacks\n", rte_version()); -} - -#else - struct mem_allocation { uintptr_t vaddr; size_t len; @@ -183,8 +173,6 @@ test(void) rte_free(buf4); } -#endif - int main(int argc, char **argv) {