Merge Linux and BSD EAL map files
cover Merge Linux and BSD EAL map files
Both Linux and BSD EALs should provide exactly the same set of functions to the user, even if in some cases the function is a stub returning ENOTSUP. Because of this we should only need a single version.map file for all of EAL - not one each for Linux and FreeBSD.
Unfortunately, there was some inconsistencies in the two EALs, specifically 4 functions were missing from the BSD interrupts files. As part of adding the needed stubs, I also discovered that there was nothing terribly Linux-specific about the Linux-specific rte_interrupts.h file, which appeared to contain a superset of the BSD contents. Therefore, this file could be made common also.
The net result is that there are now zero BSD-specific EAL headers, and only a single Linux one for KNI. The version.map file is now moved to a common location also, just inside rte_eal directory.
[While an argument could be made to put it in common, this location works best for integration with the existing meson build-sysetm work. It also allows the same version file to be used for non-posix-like environments which may not use the "common" folder as much]
Bruce Richardson (5):
eal/bsdapp: align interrupt include file with Linux version eal/bsdapp: fix missing interrupt stub functions
eal: merge bsdapp and linuxapp interrupt headers
eal: mark internal interrupts file as such to doxygen
eal: use a single version map file
lib/librte_eal/bsdapp/eal/Makefile | 4 +-
lib/librte_eal/bsdapp/eal/eal_interrupts.c | 35 +++
.../bsdapp/eal/include/exec-env/rte_interrupts.h | 137 -----------
lib/librte_eal/bsdapp/eal/rte_eal_version.map | 250 ---------------------
lib/librte_eal/common/Makefile | 3 +-
.../include/rte_eal_interrupts.h} | 24 +-
lib/librte_eal/common/include/rte_interrupts.h | 2 +-
lib/librte_eal/linuxapp/eal/Makefile | 4 +-
.../{linuxapp/eal => }/rte_eal_version.map | 0
9 files changed, 59 insertions(+), 400 deletions(-)
delete mode 100644 lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h
delete mode 100644 lib/librte_eal/bsdapp/eal/rte_eal_version.map
rename lib/librte_eal/{linuxapp/eal/include/exec-env/rte_interrupts.h => common/include/rte_eal_interrupts.h} (93%)
rename lib/librte_eal/{linuxapp/eal => }/rte_eal_version.map (100%)Signature · 1 line
2.13.6
PATCH 1/5 eal/bsdapp: align interrupt include file with Linux version
The bsdapp-specific rte_interrupts.h file does not need to be different from the linuxapp one, as there is nothing Linux specific in the APIs or data structures. This will then allow us to merge the files in a common location to avoid duplication.
--- .../bsdapp/eal/include/exec-env/rte_interrupts.h | 150 +++++++++++++++++---- 1 file changed, 127 insertions(+), 23 deletions(-)
lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h +127 -23
@@ -35,31 +35,124 @@#error "don't include this file directly, please include generic <rte_interrupts.h>"#endif -#ifndef _RTE_BSDAPP_INTERRUPTS_H_ -#define _RTE_BSDAPP_INTERRUPTS_H_ +#ifndef _RTE_EAL_INTERRUPTS_H_ +#define _RTE_EAL_INTERRUPTS_H_ +#define RTE_MAX_RXTX_INTR_VEC_ID 32#define RTE_INTR_VEC_ZERO_OFFSET 0#define RTE_INTR_VEC_RXTX_OFFSET 1 -#define RTE_MAX_RXTX_INTR_VEC_ID 32 - +/** +* The interrupt source type, e.g. UIO, VFIO, ALARM etc. +*/ enum rte_intr_handle_type { -RTE_INTR_HANDLE_UNKNOWN =0 , -RTE_INTR_HANDLE_UIO ,/**< uio device handle */ -RTE_INTR_HANDLE_ALARM ,/**< alarm handle */ -RTE_INTR_HANDLE_MAX +RTE_INTR_HANDLE_UNKNOWN =0 ,/**< generic unknown handle */ +RTE_INTR_HANDLE_UIO ,/**< uio device handle */ +RTE_INTR_HANDLE_UIO_INTX ,/**< uio generic handle */ +RTE_INTR_HANDLE_VFIO_LEGACY ,/**< vfio device handle (legacy) */ +RTE_INTR_HANDLE_VFIO_MSI ,/**< vfio device handle (MSI) */ +RTE_INTR_HANDLE_VFIO_MSIX ,/**< vfio device handle (MSIX) */ +RTE_INTR_HANDLE_ALARM ,/**< alarm handle */ +RTE_INTR_HANDLE_EXT ,/**< external handler */ +RTE_INTR_HANDLE_VDEV ,/**< virtual device */ +RTE_INTR_HANDLE_MAX /**< count of elements */ +}; + +#define RTE_INTR_EVENT_ADD 1UL +#define RTE_INTR_EVENT_DEL 2UL + +typedef void (*rte_intr_event_cb_t )(int fd,void *arg); + +struct rte_epoll_data { +uint32_t event;/**< event type */ +void *data;/**< User data */ +rte_intr_event_cb_t cb_fun;/**< IN: callback fun */ +void *cb_arg;/**< IN: callback arg */ +}; + +enum { +RTE_EPOLL_INVALID =0 , +RTE_EPOLL_VALID , +RTE_EPOLL_EXEC , +}; + +/** interrupt epoll event obj, taken by epoll_event.ptr */ +struct rte_epoll_event { +volatile uint32_t status;/**< OUT: event status */ +int fd;/**< OUT: event fd */ +int epfd;/**< OUT: epoll instance the ev associated with */ +struct rte_epoll_data epdata; };/** Handle for interrupts. */ struct rte_intr_handle { -int fd;/**< file descriptor */ -int uio_cfg_fd;/**< UIO config file descriptor */ +RTE_STD_C11 + union { + int vfio_dev_fd; /**< VFIO device file descriptor */ +int uio_cfg_fd;/**< UIO cfg file desc for uio_pci_generic */ + }; +int fd;/**< interrupt event file descriptor */ enum rte_intr_handle_type type;/**< handle type */ -int max_intr;/**< max interrupt requested */ -uint32_t nb_efd;/**< number of available efds */ -int *intr_vec;/**< intr vector number array */ +uint32_t max_intr;/**< max interrupt requested */ +uint32_t nb_efd;/**< number of available efd(event fd) */ +int efds[RTE_MAX_RXTX_INTR_VEC_ID ];/**< intr vectors/efds mapping */ +struct rte_epoll_event elist[RTE_MAX_RXTX_INTR_VEC_ID ]; +/**< intr vector epoll event */ +int *intr_vec;/**< intr vector number array */ }; +#define RTE_EPOLL_PER_THREAD -1/**< to hint using per thread epfd */ + +/** +* It waits for events on the epoll instance. +* +* @param epfd +* Epoll instance fd on which the caller wait for events. +* @param events +* Memory area contains the events that will be available for the caller. +* @param maxevents +* Up to maxevents are returned, must greater than zero. +* @param timeout +* Specifying a timeout of -1 causes a block indefinitely. +* Specifying a timeout equal to zero cause to return immediately. +* @return +* - On success, returns the number of available event. +* - On failure, a negative value. +*/ +int +rte_epoll_wait (int epfd,struct rte_epoll_event *events, +int maxevents,int timeout); + +/** +* It performs control operations on epoll instance referred by the epfd. +* It requests that the operation op be performed for the target fd. +* +* @param epfd +* Epoll instance fd on which the caller perform control operations. +* @param op +* The operation be performed for the target fd. +* @param fd +* The target fd on which the control ops perform. +* @param event +* Describes the object linked to the fd. +* Note: The caller must take care the object deletion after CTL_DEL. +* @return +* - On success, zero. +* - On failure, a negative value. +*/ +int +rte_epoll_ctl (int epfd,int op,int fd, +struct rte_epoll_event *event); + +/** +* The function returns the per thread epoll instance. +* +* @return +* epfd the epoll instance referred to. +*/ +int +rte_intr_tls_epfd (void ); +/** * @param intr_handle * Pointer to the interrupt handle.
@@ -81,9 +174,18 @@ rte_intr_rx_ctl(struct rte_intr_handle *intr_handle, int epfd, int op, unsigned int vec, void *data);/** -* It enables the fastpath event fds if it's necessary. -* It creates event fds when multi-vectors allowed, -* otherwise it multiplexes the single event fds. +* It deletes registered eventfds. +* +* @param intr_handle +* Pointer to the interrupt handle. +*/ +void +rte_intr_free_epoll_fd (struct rte_intr_handle *intr_handle); + +/** +* It enables the packet I/O interrupt event if it's necessary. +* It creates event fd for each interrupt vector when MSIX is used, +* otherwise it multiplexes a single event fd. * * @param intr_handle * Pointer to the interrupt handle.
@@ -98,7 +200,7 @@ int rte_intr_efd_enable(struct rte_intr_handle *intr_handle, uint32_t nb_efd);/** -* It disable the fastpath event fds. +* It disables the packet I/O interrupt event. * It deletes registered eventfds and closes the open fds. * * @param intr_handle
@@ -108,21 +210,23 @@ void rte_intr_efd_disable(struct rte_intr_handle *intr_handle);/** -* The fastpath interrupt is enabled or not. +* The packet I/O interrupt on datapath is enabled or not. * * @param intr_handle * Pointer to the interrupt handle. */ -int rte_intr_dp_is_en (struct rte_intr_handle *intr_handle); +int +rte_intr_dp_is_en (struct rte_intr_handle *intr_handle);/** -* The interrupt handle instance allows other cause or not. -* Other cause stands for none fastpath interrupt. +* The interrupt handle instance allows other causes or not. +* Other causes stand for any none packet I/O interrupts. * * @param intr_handle * Pointer to the interrupt handle. */ -int rte_intr_allow_others (struct rte_intr_handle *intr_handle); +int +rte_intr_allow_others (struct rte_intr_handle *intr_handle);/** * The multiple interrupt vector capability of interrupt handle instance.
@@ -134,4 +238,4 @@ int rte_intr_allow_others(struct rte_intr_handle *intr_handle);int rte_intr_cap_multiple (struct rte_intr_handle *intr_handle); -#endif /* _RTE_BSDAPP_INTERRUPTS_H_ */ +#endif /* _RTE_EAL_INTERRUPTS_H_ */
Signature · 1 line
2.13.6
PATCH 2/5 eal/bsdapp: fix missing interrupt stub functions
In reply to Bruce RichardsonA number of interrupt functions only existed on Linux. Adding in stubs for these functions corrects this omission, and allows the map files for both Linux and FreeBSD to be identical.
--- lib/librte_eal/bsdapp/eal/eal_interrupts.c | 35 +++++++++++++++++++++++++++ lib/librte_eal/bsdapp/eal/rte_eal_version.map | 6 ++++- 2 files changed, 40 insertions(+), 1 deletion(-)
lib/librte_eal/bsdapp/eal/eal_interrupts.c +35 -0
@@ -125,3 +125,38 @@ rte_intr_cap_multiple(struct rte_intr_handle *intr_handle)RTE_SET_USED (intr_handle);return 0 ; } + +int +rte_epoll_wait (int epfd,struct rte_epoll_event *events, +int maxevents,int timeout) +{ +RTE_SET_USED (epfd); +RTE_SET_USED (events); +RTE_SET_USED (maxevents); +RTE_SET_USED (timeout); + +return -ENOTSUP ; +} + +int +rte_epoll_ctl (int epfd,int op,int fd,struct rte_epoll_event *event) +{ +RTE_SET_USED (epfd); +RTE_SET_USED (op); +RTE_SET_USED (fd); +RTE_SET_USED (event); + +return -ENOTSUP ; +} + +int +rte_intr_tls_epfd (void ) +{ +return -ENOTSUP ; +} + +void +rte_intr_free_epoll_fd (struct rte_intr_handle *intr_handle) +{ +RTE_SET_USED (intr_handle); +}
lib/librte_eal/bsdapp/eal/rte_eal_version.map +5 -1
@@ -96,11 +96,14 @@ DPDK_2.0 { DPDK_2.1 { global: + rte_epoll_ctl; + rte_epoll_wait; rte_intr_allow_others; rte_intr_dp_is_en; rte_intr_efd_disable; rte_intr_efd_enable; rte_intr_rx_ctl; + rte_intr_tls_epfd; rte_memzone_free; } DPDK_2.0;
@@ -160,9 +163,10 @@ DPDK_17.05 { global: rte_cpu_is_supported; + rte_intr_free_epoll_fd; rte_log_dump; - rte_log_register; rte_log_get_global_level; + rte_log_register; rte_log_set_global_level; rte_log_set_level; rte_log_set_level_regexp;
Signature · 1 line
2.13.6
Re: [PATCH 2/5] eal/bsdapp: fix missing interrupt stub functions
Quoted 7 lines · Bruce Richardson
A number of interrupt functions only existed on Linux. Adding in stubs for these functions corrects this omission, and allows the map files for both Linux and FreeBSD to be identical.
Fixes 9efe9c6cdcac ("eal/linux: add epoll wrappers")
Apologies, I just realised that this fix patch probably can't be back-ported to stable on it's own, since it would be missing the header file updates in the previous patch. Also, not sure if this is worth taking to stable, but if it is, more patches in the set can be taken too.
Regards,
/Bruce
PATCH 3/5 eal: merge bsdapp and linuxapp interrupt headers
In reply to Bruce RichardsonThe linuxapp and bsdapp interrupt header files are now identical, so merge them into a common file in common/include.
---
lib/librte_eal/bsdapp/eal/Makefile | 2 +-
lib/librte_eal/common/Makefile | 3 +-
.../include/rte_eal_interrupts.h} | 0
lib/librte_eal/common/include/rte_interrupts.h | 2 +-
lib/librte_eal/linuxapp/eal/Makefile | 2 +-
.../linuxapp/eal/include/exec-env/rte_interrupts.h | 239 ---------------------
6 files changed, 5 insertions(+), 243 deletions(-)
rename lib/librte_eal/{bsdapp/eal/include/exec-env/rte_interrupts.h => common/include/rte_eal_interrupts.h} (100%)
delete mode 100644 lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.hlib/librte_eal/bsdapp/eal/Makefile +1 -1
@@ -126,7 +126,7 @@ CFLAGS_eal_thread.o += -Wno-return-type CFLAGS_eal_hpet.o += -Wno-return-type endif -INC := rte_interrupts.h +INC := # no bsdapp specific headers SYMLINK-$(CONFIG_RTE_EXEC_ENV_BSDAPP)-include/exec-env := \ $(addprefix include/exec-env/,$(INC))
lib/librte_eal/common/Makefile +2 -1
@@ -32,7 +32,8 @@ include $(RTE_SDK)/mk/rte.vars.mk INC := rte_branch_prediction.h rte_common.h -INC += rte_debug.h rte_eal.h rte_errno.h rte_launch.h rte_lcore.h +INC += rte_debug.h rte_eal.h rte_eal_interrupts.h +INC += rte_errno.h rte_launch.h rte_lcore.h INC += rte_log.h rte_memory.h rte_memzone.h rte_pci.h INC += rte_per_lcore.h rte_random.h INC += rte_tailq.h rte_interrupts.h rte_alarm.h
lib/librte_eal/common/include/rte_eal_interrupts.h renamed from lib/librte_eal/bsdapp/eal/include/exec-env/rte_interrupts.h +0 -0
lib/librte_eal/common/include/rte_interrupts.h +1 -1
@@ -53,7 +53,7 @@ struct rte_intr_handle;/** Function to be registered for the specific interrupt */ typedef void (*rte_intr_callback_fn )(void *cb_arg); -#include <exec-env/rte_interrupts.h> +#include "rte_eal_interrupts.h" /** * It registers the callback for the specific interrupt. Multiple
lib/librte_eal/linuxapp/eal/Makefile +1 -1
@@ -146,7 +146,7 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) CFLAGS_eal_thread.o += -Wno-return-type endif -INC := rte_interrupts.h rte_kni_common.h +INC := rte_kni_common.h SYMLINK-$(CONFIG_RTE_EXEC_ENV_LINUXAPP)-include/exec-env := \ $(addprefix include/exec-env/,$(INC))
lib/librte_eal/linuxapp/eal/include/exec-env/rte_interrupts.h deleted +0 -239
239 lines not on this page · raw message
Signature · 1 line
2.13.6
PATCH 4/5 eal: mark internal interrupts file as such to doxygen
In reply to Bruce RichardsonPut a file-level comment on rte_eal_interrupts.h to mark it as an internal only header.
--- lib/librte_eal/common/include/rte_eal_interrupts.h | 8 ++++++++ 1 file changed, 8 insertions(+)
lib/librte_eal/common/include/rte_eal_interrupts.h +8 -0
@@ -35,6 +35,14 @@#error "don't include this file directly, please include generic <rte_interrupts.h>"#endif +/** +* @file rte_eal_interrupts.h +* @internal +* +* Contains function prototypes exposed by the EAL for interrupt handling by +* drivers and other DPDK internal consumers. +*/ +#ifndef _RTE_EAL_INTERRUPTS_H_#define _RTE_EAL_INTERRUPTS_H_
Signature · 1 line
2.13.6
PATCH 5/5 eal: use a single version map file
In reply to Bruce RichardsonSince the functions exported by DPDK EAL on all OS's should be identical, we should not need separate function version files for each OS. Therefore move existing version files to the top-level EAL directory.
---
lib/librte_eal/bsdapp/eal/Makefile | 2 +-
lib/librte_eal/linuxapp/eal/Makefile | 2 +-
lib/librte_eal/linuxapp/eal/rte_eal_version.map | 254 ---------------------
.../{bsdapp/eal => }/rte_eal_version.map | 0
4 files changed, 2 insertions(+), 256 deletions(-)
delete mode 100644 lib/librte_eal/linuxapp/eal/rte_eal_version.map
rename lib/librte_eal/{bsdapp/eal => }/rte_eal_version.map (100%)lib/librte_eal/bsdapp/eal/Makefile +1 -1
@@ -46,7 +46,7 @@ LDLIBS += -lexecinfo LDLIBS += -lpthread LDLIBS += -lgcc_s -EXPORT_MAP := rte_eal_version.map +EXPORT_MAP := ../../rte_eal_version.map LIBABIVER := 6
lib/librte_eal/linuxapp/eal/Makefile +1 -1
@@ -34,7 +34,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_eal.a ARCH_DIR ?= $(RTE_ARCH) -EXPORT_MAP := rte_eal_version.map +EXPORT_MAP := ../../rte_eal_version.map VPATH += $(RTE_SDK)/lib/librte_eal/common/arch/$(ARCH_DIR) LIBABIVER := 6
lib/librte_eal/linuxapp/eal/rte_eal_version.map deleted +0 -254
254 lines not on this page · raw message
lib/librte_eal/rte_eal_version.map renamed from lib/librte_eal/bsdapp/eal/rte_eal_version.map +0 -0
Signature · 1 line
2.13.6
Re: [PATCH 5/5] eal: use a single version map file
19/10/2017 18:36, Bruce Richardson:
Quoted 6 lines
Since the functions exported by DPDK EAL on all OS's should be identical, we should not need separate function version files for each OS. Therefore move existing version files to the top-level EAL directory.
Signed-off-by Bruce Richardson <[email protected]>
This small change is missing and added when applying:
MAINTAINERS +1 -0
@@ -88,6 +88,7 @@ EAL API and common code F: lib/librte_eal/common/* F: lib/librte_eal/common/include/* F: lib/librte_eal/common/include/generic/ +F: lib/librte_eal/rte_eal_version.map F: doc/guides/prog_guide/env_abstraction_layer.rst F: test/test/test_alarm.c F: test/test/test_atomic.c
Re: [PATCH 5/5] eal: use a single version map file
Quoted 14 lines · Thomas Monjalon
19/10/2017 18:36, Bruce Richardson:
Quoted 6 lines
Since the functions exported by DPDK EAL on all OS's should be identical, we should not need separate function version files for each OS. Therefore move existing version files to the top-level EAL directory.
Signed-off-by Bruce Richardson <[email protected]>This small change is missing and added when applying:
MAINTAINERS EAL API and common code · line 94
Quoted 7 lines
MAINTAINERS +1
-0@@ -88,6 +88,7 @@ EAL API and common code F: lib/librte_eal/common/* F: lib/librte_eal/common/include/* F: lib/librte_eal/common/include/generic/ +F: lib/librte_eal/rte_eal_version.map F: doc/guides/prog_guide/env_abstraction_layer.rst F: test/test/test_alarm.c F: test/test/test_atomic.c
Thanks, good catch.
Quoted 22 lines · Bruce Richardson
Both Linux and BSD EALs should provide exactly the same set of functions to the user, even if in some cases the function is a stub returning ENOTSUP. Because of this we should only need a single version.map file for all of EAL - not one each for Linux and FreeBSD.
Unfortunately, there was some inconsistencies in the two EALs, specifically 4 functions were missing from the BSD interrupts files. As part of adding the needed stubs, I also discovered that there was nothing terribly Linux-specific about the Linux-specific
rte_interrupts.hfile, which appeared to contain a superset of the BSD contents. Therefore, this file could be made common also.The net result is that there are now zero BSD-specific EAL headers, and only a single Linux one for KNI. The version.map file is now moved to a common location also, just inside
rte_ealdirectory.[While an argument could be made to put it in common, this location works best for integration with the existing meson build-sysetm work. It also allows the same version file to be used for non-posix-like environments which may not use the "common" folder as much]
Quoted 7 lines
Bruce Richardson (5):
eal/bsdapp: align interrupt include file with Linux version eal/bsdapp: fix missing interrupt stub functions
eal: merge bsdapp and linuxapp interrupt headers
eal: mark internal interrupts file as such to doxygen
eal: use a single version map file
Compilation tested for both static and shared builds on FreeBSD 11.0 and Fedora 26.
/Bruce
Thomas Monjalon
Applied19/10/2017 18:45, Bruce Richardson:
Quoted 31 lines · Bruce Richardson
Quoted 22 lines
Both Linux and BSD EALs should provide exactly the same set of functions to the user, even if in some cases the function is a stub returning ENOTSUP. Because of this we should only need a single version.map file for all of EAL - not one each for Linux and FreeBSD.
Unfortunately, there was some inconsistencies in the two EALs, specifically 4 functions were missing from the BSD interrupts files. As part of adding the needed stubs, I also discovered that there was nothing terribly Linux-specific about the Linux-specific
rte_interrupts.hfile, which appeared to contain a superset of the BSD contents. Therefore, this file could be made common also.The net result is that there are now zero BSD-specific EAL headers, and only a single Linux one for KNI. The version.map file is now moved to a common location also, just inside
rte_ealdirectory.[While an argument could be made to put it in common, this location works best for integration with the existing meson build-sysetm work. It also allows the same version file to be used for non-posix-like environments which may not use the "common" folder as much]
Quoted 7 lines
Bruce Richardson (5):
eal/bsdapp: align interrupt include file with Linux version eal/bsdapp: fix missing interrupt stub functions
eal: merge bsdapp and linuxapp interrupt headers
eal: mark internal interrupts file as such to doxygen
eal: use a single version map file
Quoted 2 lines
Compilation tested for both static and shared builds on FreeBSD 11.0 and Fedora 26.
Applied, thanks