2021-08-12 20:05 (UTC+0000), William Tu:
> Currently there are a couple of public header files include
Suggested subject: "eal: remove sys/queue.h from public headers".
1. The state before the patch should be described in the past tense.
2. Really ten times more than "a couple", suggesting "some" (nit).
2. "files _that_ include"?
> 'sys/queue.h', which is a POSIX functionality.
It's not POSIX, it's found on many Unix systems.
> When compiling DPDK with OVS on Windows, we encountered issues such as, found the missing
> header.
This sentence is a little hard to parse. Instead, suggesting:
This file is missing on Windows. During the build, DPDK uses a
bundled copy, but it cannot be installed because macros it exports
may conflict with the ones from application code or environment.
> In file included from ../lib/dpdk.c:27:
> C:\temp\dpdk\include\rte_log.h:24:10: fatal error: 'sys/queue.h' file
> not found
An explanation is missing why <sys/queue.h> embedded in DPDK shouldn't be
installed (see above, maybe you can come up with something better).
>
> The patch fixes it by removing the #include <sys/queue.h> from
> DPDK public headers, so programs including DPDK headers don't depend
> on POSIX sys/queue.h. For Linux/FreeBSD, DPDK public headers only need a
> handful of macros for list/tailq heads and links. Those macros should be
> provided by DPDK, with RTE_ prefix.
It is worth noting that RTE_ macros must be compatible with <sys/queue.h>
at the level of API (to use with <sys/queue.h> macros in C files) and ABI
(to avoid breaking it).
Nit: "Should" is not the right word for things done in the patch. Same below.
> For Linux and FreeBSD it will just be:
> #include <sys/queue.h>
> #define RTE_TAILQ_ENTRY(type) TAILQ_ENTRY(type)
> /* ... */
> For Windows, we copy these definitions from <sys/queue.h> to rte_os.h.
No need to describe what's inside the patch, diff already does it :)
> With this patch, all the public headers should not have
> "#include <sys/queue.h>" or "TAILQ_xxx" macros.
>
> Suggested-by: Nick Connolly <nick.connolly@mayadata.io>
> Suggested-by: Dmitry Kozliuk <Dmitry.Kozliuk@gmail.com>
> Signed-off-by: William Tu <u9012063@gmail.com>
> ---
> v2->v3:
> * follow the suggestion by Dmitry
> * run checkpatches, there are some errors but I think either
> the original file has over 80-char line due to comments,
> or some false positive about macro.
> v1->v2:
> - follow the suggestion by Nick and Dmitry
> - http://mails.dpdk.org/archives/dev/2021-August/216304.html
>
> Signed-off-by: William Tu <u9012063@gmail.com>
> ---
[...]
> diff --git a/lib/eal/freebsd/include/rte_os.h b/lib/eal/freebsd/include/rte_os.h
> index 627f0483ab..dc889e5826 100644
> --- a/lib/eal/freebsd/include/rte_os.h
> +++ b/lib/eal/freebsd/include/rte_os.h
> @@ -11,6 +11,39 @@
> */
>
> #include <pthread_np.h>
> +#include <sys/queue.h>
> +
> +/* These macros are compatible with system's sys/queue.h. */
> +#define RTE_TAILQ_INIT(head) TAILQ_INIT(head)
> +#define RTE_TAILQ_HEAD(name, type) TAILQ_HEAD(name, type)
> +#define RTE_TAILQ_LAST(head, headname) TAILQ_LAST(head, headname)
> +#define RTE_TAILQ_ENTRY(type) TAILQ_ENTRY(type)
> +#define RTE_TAILQ_FIRST(head) TAILQ_FIRST(head)
> +#define RTE_TAILQ_EMPTY(head) TAILQ_EMPTY(head)
> +#define RTE_TAILQ_NEXT(elem, field) TAILQ_NEXT(elem, field)
> +#define RTE_TAILQ_HEAD_INITIALIZER(head) TAILQ_HEAD_INITIALIZER(head)
> +#define RTE_TAILQ_FOREACH(var, head, field) TAILQ_FOREACH(var, head, field)
> +#define RTE_TAILQ_INSERT_TAIL(head, elm, field) \
> + TAILQ_INSERT_TAIL(head, elm, field)
> +#define RTE_TAILQ_REMOVE(head, elm, field) TAILQ_REMOVE(head, elm, field)
> +#define RTE_TAILQ_INSERT_BEFORE(listelm, elm, field) \
> + TAILQ_INSERT_BEFORE(listelm, elm, field)
> +#define RTE_TAILQ_INSERT_AFTER(head, listelm, elm, field) \
> + TAILQ_INSERT_AFTER(head, listelm, elm, field)
> +#define RTE_TAILQ_INSERT_HEAD(head, elm, field) \
> + TAILQ_INSERT_HEAD(head, elm, field)
> +
> +#define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type)
> +#define RTE_STAILQ_HEAD_INITIALIZER(head) STAILQ_HEAD_INITIALIZER(head)
> +#define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type)
Most of these macros are not used in public headers and are not needed.
The idea is that TAILQ_* macros from sys/queue.h can be used in C files
with variables declared with RTE_TAILQ_HEAD/ENTRY in public headers.
Needed macros:
RTE_TAILQ_HEAD
RTE_TAILQ_ENTRY
RTE_TAILQ_FOREACH
RTE_TAILQ_FIRST (for RTE_TAILQ_FOREACH_SAFE only)
RTE_TAILQ_NEXT (ditto)
RTE_STAILQ_HEAD
RTE_STAILQ_ENTRY
> +
> +/* This is not defined in sys/queue.h */
> +#ifndef TAILQ_FOREACH_SAFE
> +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
> + for ((var) = RTE_TAILQ_FIRST((head)); \
> + (var) && ((tvar) = RTE_TAILQ_NEXT((var), field), 1); \
> + (var) = (tvar))
> +#endif
Please simply change the three usages of TAILQ_FOREACH_SAFE to
RTE_TAILQ_FOREACH_SAFE and remove this one. It cannot be placed in rte_os.h,
because rte_os.h is public and it must not export non-RTE symbols.
All comments to this file obviously apply to Linux version as well.
>
> typedef cpuset_t rte_cpuset_t;
> #define RTE_HAS_CPUSET
[...]
> diff --git a/lib/eal/windows/include/rte_os.h b/lib/eal/windows/include/rte_os.h
> index 66c711d458..d0935c5003 100644
> --- a/lib/eal/windows/include/rte_os.h
> +++ b/lib/eal/windows/include/rte_os.h
> @@ -18,6 +18,144 @@
> extern "C" {
> #endif
>
> +#ifdef QUEUE_MACRO_DEBUG_TRACE
IMO we all these debugging macros should be removed from this header,
including their use in user-facing macros.
They are implementation detail for <sys/queue.h> developers.
> +/* Store the last 2 places the queue element or head was altered */
> +struct qm_trace {
> + unsigned long lastline;
> + unsigned long prevline;
> + const char *lastfile;
> + const char *prevfile;
> +};
> +
> +/**
> + * These macros are compatible with the sys/queue.h provided
> + * at DPDK source code.
> + */
[...]
> +
> +#define QMD_TAILQ_CHECK_HEAD(head, field)
> +#define QMD_TAILQ_CHECK_TAIL(head, headname)
> +#define QMD_TAILQ_CHECK_NEXT(elm, field)
> +#define QMD_TAILQ_CHECK_PREV(elm, field)
Redundant empty lines below.
> +
> +
> +#define RTE_TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
> +
> +#define RTE_TAILQ_FIRST(head) ((head)->tqh_first)
> +
> +#define RTE_TAILQ_INIT(head) do { \
I suggest removing all spaces but one before the backslash
so that you don't need to manually align.
At least please keep the lines within 80 characters.
> + RTE_TAILQ_FIRST((head)) = NULL; \
> + (head)->tqh_last = &RTE_TAILQ_FIRST((head)); \
> + QMD_TRACE_HEAD(head); \
> +} while (0)
[...]
@@ -7,6 +7,7 @@
#include <stdbool.h>
#include <stdio.h>
+#include <sys/queue.h>
#include "rte_bus_auxiliary.h"
@@ -19,7 +19,6 @@ extern "C" {
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
-#include <sys/queue.h>
#include <stdint.h>
#include <inttypes.h>
@@ -113,7 +112,7 @@ typedef int (rte_auxiliary_dma_unmap_t)(struct rte_auxiliary_device *dev,
* A structure describing an auxiliary device.
*/
struct rte_auxiliary_device {
- TAILQ_ENTRY(rte_auxiliary_device) next; /**< Next probed device. */
+ RTE_TAILQ_ENTRY(rte_auxiliary_device) next; /**< Next probed device. */
struct rte_device device; /**< Inherit core device */
char name[RTE_DEV_NAME_MAX_LEN + 1]; /**< ASCII device name */
struct rte_intr_handle intr_handle; /**< Interrupt handle */
@@ -124,7 +123,7 @@ struct rte_auxiliary_device {
* A structure describing an auxiliary driver.
*/
struct rte_auxiliary_driver {
- TAILQ_ENTRY(rte_auxiliary_driver) next; /**< Next in list. */
+ RTE_TAILQ_ENTRY(rte_auxiliary_driver) next; /**< Next in list. */
struct rte_driver driver; /**< Inherit core driver. */
struct rte_auxiliary_bus *bus; /**< Auxiliary bus reference. */
rte_auxiliary_match_t *match; /**< Device match function. */
@@ -28,9 +28,9 @@ struct rte_afu_device;
struct rte_afu_driver;
/** Double linked list of Intel FPGA AFU device. */
-TAILQ_HEAD(ifpga_afu_dev_list, rte_afu_device);
+RTE_TAILQ_HEAD(ifpga_afu_dev_list, rte_afu_device);
/** Double linked list of Intel FPGA AFU device drivers. */
-TAILQ_HEAD(ifpga_afu_drv_list, rte_afu_driver);
+RTE_TAILQ_HEAD(ifpga_afu_drv_list, rte_afu_driver);
#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
@@ -71,7 +71,7 @@ struct rte_afu_shared {
* A structure describing a AFU device.
*/
struct rte_afu_device {
- TAILQ_ENTRY(rte_afu_device) next; /**< Next in device list. */
+ RTE_TAILQ_ENTRY(rte_afu_device) next; /**< Next in device list. */
struct rte_device device; /**< Inherit core device */
struct rte_rawdev *rawdev; /**< Point Rawdev */
struct rte_afu_id id; /**< AFU id within FPGA. */
@@ -105,7 +105,7 @@ typedef int (afu_remove_t)(struct rte_afu_device *);
* A structure describing a AFU device.
*/
struct rte_afu_driver {
- TAILQ_ENTRY(rte_afu_driver) next; /**< Next afu driver. */
+ RTE_TAILQ_ENTRY(rte_afu_driver) next; /**< Next afu driver. */
struct rte_driver driver; /**< Inherit core driver. */
afu_probe_t *probe; /**< Device Probe function. */
afu_remove_t *remove; /**< Device Remove function. */
@@ -2,6 +2,8 @@
* Copyright 2018 Gaëtan Rivet
*/
+#include <sys/queue.h>
+
#include <rte_bus.h>
#include <rte_bus_pci.h>
#include <rte_dev.h>
@@ -19,7 +19,6 @@ extern "C" {
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
-#include <sys/queue.h>
#include <stdint.h>
#include <inttypes.h>
@@ -37,16 +36,16 @@ struct rte_pci_device;
struct rte_pci_driver;
/** List of PCI devices */
-TAILQ_HEAD(rte_pci_device_list, rte_pci_device);
+RTE_TAILQ_HEAD(rte_pci_device_list, rte_pci_device);
/** List of PCI drivers */
-TAILQ_HEAD(rte_pci_driver_list, rte_pci_driver);
+RTE_TAILQ_HEAD(rte_pci_driver_list, rte_pci_driver);
/* PCI Bus iterators */
#define FOREACH_DEVICE_ON_PCIBUS(p) \
- TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next)
+ RTE_TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next)
#define FOREACH_DRIVER_ON_PCIBUS(p) \
- TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next)
+ RTE_TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next)
struct rte_devargs;
@@ -64,7 +63,7 @@ enum rte_pci_kernel_driver {
* A structure describing a PCI device.
*/
struct rte_pci_device {
- TAILQ_ENTRY(rte_pci_device) next; /**< Next probed PCI device. */
+ RTE_TAILQ_ENTRY(rte_pci_device) next; /**< Next probed PCI device. */
struct rte_device device; /**< Inherit core device */
struct rte_pci_addr addr; /**< PCI location. */
struct rte_pci_id id; /**< PCI ID. */
@@ -160,7 +159,7 @@ typedef int (pci_dma_unmap_t)(struct rte_pci_device *dev, void *addr,
* A structure describing a PCI driver.
*/
struct rte_pci_driver {
- TAILQ_ENTRY(rte_pci_driver) next; /**< Next in list. */
+ RTE_TAILQ_ENTRY(rte_pci_driver) next; /**< Next in list. */
struct rte_driver driver; /**< Inherit core driver. */
struct rte_pci_bus *bus; /**< PCI bus reference. */
rte_pci_probe_t *probe; /**< Device probe function. */
@@ -1,6 +1,9 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright 2020 Mellanox Technologies, Ltd
*/
+
+#include <sys/queue.h>
+
#include <rte_windows.h>
#include <rte_errno.h>
#include <rte_log.h>
@@ -2,6 +2,8 @@
* Copyright(c) 2020 Intel Corporation.
*/
+#include <sys/queue.h>
+
#include <rte_windows.h>
#include <rte_errno.h>
#include <rte_log.h>
@@ -15,12 +15,11 @@
extern "C" {
#endif
-#include <sys/queue.h>
#include <rte_dev.h>
#include <rte_devargs.h>
struct rte_vdev_device {
- TAILQ_ENTRY(rte_vdev_device) next; /**< Next attached vdev */
+ RTE_TAILQ_ENTRY(rte_vdev_device) next; /**< Next attached vdev */
struct rte_device device; /**< Inherit core device */
};
@@ -53,7 +52,7 @@ rte_vdev_device_args(const struct rte_vdev_device *dev)
}
/** Double linked list of virtual device drivers. */
-TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
+RTE_TAILQ_HEAD(vdev_driver_list, rte_vdev_driver);
/**
* Probe function called for each virtual device driver once.
@@ -107,7 +106,7 @@ typedef int (rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void *addr,
* A virtual device driver abstraction.
*/
struct rte_vdev_driver {
- TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */
+ RTE_TAILQ_ENTRY(rte_vdev_driver) next; /**< Next in list. */
struct rte_driver driver; /**< Inherited general driver. */
rte_vdev_probe_t *probe; /**< Virtual device probe function. */
rte_vdev_remove_t *remove; /**< Virtual device remove function. */
@@ -20,7 +20,6 @@ extern "C" {
#include <limits.h>
#include <stdbool.h>
#include <errno.h>
-#include <sys/queue.h>
#include <stdint.h>
#include <inttypes.h>
@@ -38,15 +37,15 @@ struct rte_vmbus_bus;
struct vmbus_channel;
struct vmbus_mon_page;
-TAILQ_HEAD(rte_vmbus_device_list, rte_vmbus_device);
-TAILQ_HEAD(rte_vmbus_driver_list, rte_vmbus_driver);
+RTE_TAILQ_HEAD(rte_vmbus_device_list, rte_vmbus_device);
+RTE_TAILQ_HEAD(rte_vmbus_driver_list, rte_vmbus_driver);
/* VMBus iterators */
#define FOREACH_DEVICE_ON_VMBUS(p) \
- TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next)
+ RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next)
#define FOREACH_DRIVER_ON_VMBUS(p) \
- TAILQ_FOREACH(p, &(rte_vmbus_bus.driver_list), next)
+ RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.driver_list), next)
/** Maximum number of VMBUS resources. */
enum hv_uio_map {
@@ -62,7 +61,7 @@ enum hv_uio_map {
* A structure describing a VMBUS device.
*/
struct rte_vmbus_device {
- TAILQ_ENTRY(rte_vmbus_device) next; /**< Next probed VMBUS device */
+ RTE_TAILQ_ENTRY(rte_vmbus_device) next; /**< Next probed VMBUS device */
const struct rte_vmbus_driver *driver; /**< Associated driver */
struct rte_device device; /**< Inherit core device */
rte_uuid_t device_id; /**< VMBUS device id */
@@ -93,7 +92,7 @@ typedef int (vmbus_remove_t)(struct rte_vmbus_device *);
* A structure describing a VMBUS driver.
*/
struct rte_vmbus_driver {
- TAILQ_ENTRY(rte_vmbus_driver) next; /**< Next in list. */
+ RTE_TAILQ_ENTRY(rte_vmbus_driver) next; /**< Next in list. */
struct rte_driver driver;
struct rte_vmbus_bus *bus; /**< VM bus reference. */
vmbus_probe_t *probe; /**< Device Probe function. */
@@ -6,6 +6,7 @@
#define _I40E_ETHDEV_H_
#include <stdint.h>
+#include <sys/queue.h>
#include <rte_time.h>
#include <rte_kvargs.h>
@@ -4,6 +4,7 @@
#include <errno.h>
#include <stdbool.h>
+#include <sys/queue.h>
#include <sys/types.h>
#include <unistd.h>
@@ -434,7 +434,7 @@ struct rte_bbdev_callback;
struct rte_intr_handle;
/** Structure to keep track of registered callbacks */
-TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
+RTE_TAILQ_HEAD(rte_bbdev_cb_list, rte_bbdev_callback);
/**
* @internal The data structure associated with a device. Drivers can access
@@ -879,7 +879,7 @@ typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
struct rte_cryptodev_callback;
/** Structure to keep track of registered callbacks */
-TAILQ_HEAD(rte_cryptodev_cb_list, rte_cryptodev_callback);
+RTE_TAILQ_HEAD(rte_cryptodev_cb_list, rte_cryptodev_callback);
/**
* Structure used to hold information about the callbacks to be called for a
@@ -66,7 +66,7 @@ struct rte_cryptodev_global {
/* Cryptodev driver, containing the driver ID */
struct cryptodev_driver {
- TAILQ_ENTRY(cryptodev_driver) next; /**< Next in list. */
+ RTE_TAILQ_ENTRY(cryptodev_driver) next; /**< Next in list. */
const struct rte_driver *driver;
uint8_t id;
};
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
+#include <sys/queue.h>
#include <rte_bus.h>
#include <rte_class.h>
@@ -18,6 +19,7 @@
#include <rte_errno.h>
#include <rte_kvargs.h>
#include <rte_log.h>
+#include <rte_os.h>
#include <rte_tailq.h>
#include "eal_private.h"
@@ -9,6 +9,7 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <sys/queue.h>
#include <rte_common.h>
#include <rte_eal_paging.h>
@@ -10,6 +10,7 @@
#include <errno.h>
#include <regex.h>
#include <fnmatch.h>
+#include <sys/queue.h>
#include <rte_eal.h>
#include <rte_log.h>
@@ -3,6 +3,7 @@
*/
#include <string.h>
+#include <sys/queue.h>
#include <rte_errno.h>
#include <rte_lcore.h>
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <sys/queue.h>
#ifndef RTE_EXEC_ENV_WINDOWS
#include <syslog.h>
#endif
@@ -5,6 +5,8 @@
#ifndef __EAL_TRACE_H
#define __EAL_TRACE_H
+#include <sys/queue.h>
+
#include <rte_cycles.h>
#include <rte_log.h>
#include <rte_malloc.h>
@@ -11,6 +11,39 @@
*/
#include <pthread_np.h>
+#include <sys/queue.h>
+
+/* These macros are compatible with system's sys/queue.h. */
+#define RTE_TAILQ_INIT(head) TAILQ_INIT(head)
+#define RTE_TAILQ_HEAD(name, type) TAILQ_HEAD(name, type)
+#define RTE_TAILQ_LAST(head, headname) TAILQ_LAST(head, headname)
+#define RTE_TAILQ_ENTRY(type) TAILQ_ENTRY(type)
+#define RTE_TAILQ_FIRST(head) TAILQ_FIRST(head)
+#define RTE_TAILQ_EMPTY(head) TAILQ_EMPTY(head)
+#define RTE_TAILQ_NEXT(elem, field) TAILQ_NEXT(elem, field)
+#define RTE_TAILQ_HEAD_INITIALIZER(head) TAILQ_HEAD_INITIALIZER(head)
+#define RTE_TAILQ_FOREACH(var, head, field) TAILQ_FOREACH(var, head, field)
+#define RTE_TAILQ_INSERT_TAIL(head, elm, field) \
+ TAILQ_INSERT_TAIL(head, elm, field)
+#define RTE_TAILQ_REMOVE(head, elm, field) TAILQ_REMOVE(head, elm, field)
+#define RTE_TAILQ_INSERT_BEFORE(listelm, elm, field) \
+ TAILQ_INSERT_BEFORE(listelm, elm, field)
+#define RTE_TAILQ_INSERT_AFTER(head, listelm, elm, field) \
+ TAILQ_INSERT_AFTER(head, listelm, elm, field)
+#define RTE_TAILQ_INSERT_HEAD(head, elm, field) \
+ TAILQ_INSERT_HEAD(head, elm, field)
+
+#define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type)
+#define RTE_STAILQ_HEAD_INITIALIZER(head) STAILQ_HEAD_INITIALIZER(head)
+#define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type)
+
+/* This is not defined in sys/queue.h */
+#ifndef TAILQ_FOREACH_SAFE
+#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = RTE_TAILQ_FIRST((head)); \
+ (var) && ((tvar) = RTE_TAILQ_NEXT((var), field), 1); \
+ (var) = (tvar))
+#endif
typedef cpuset_t rte_cpuset_t;
#define RTE_HAS_CPUSET
@@ -19,13 +19,12 @@ extern "C" {
#endif
#include <stdio.h>
-#include <sys/queue.h>
#include <rte_log.h>
#include <rte_dev.h>
/** Double linked list of buses */
-TAILQ_HEAD(rte_bus_list, rte_bus);
+RTE_TAILQ_HEAD(rte_bus_list, rte_bus);
/**
@@ -250,7 +249,7 @@ typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void);
* A structure describing a generic bus.
*/
struct rte_bus {
- TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */
+ RTE_TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */
const char *name; /**< Name of the bus */
rte_bus_scan_t scan; /**< Scan for devices attached to bus */
rte_bus_probe_t probe; /**< Probe devices on bus */
@@ -22,18 +22,16 @@
extern "C" {
#endif
-#include <sys/queue.h>
-
#include <rte_dev.h>
/** Double linked list of classes */
-TAILQ_HEAD(rte_class_list, rte_class);
+RTE_TAILQ_HEAD(rte_class_list, rte_class);
/**
* A structure describing a generic device class.
*/
struct rte_class {
- TAILQ_ENTRY(rte_class) next; /**< Next device class in linked list */
+ RTE_TAILQ_ENTRY(rte_class) next; /**< Next device class in linked list */
const char *name; /**< Name of the class */
rte_dev_iterate_t dev_iterate; /**< Device iterator. */
};
@@ -18,7 +18,6 @@ extern "C" {
#endif
#include <stdio.h>
-#include <sys/queue.h>
#include <rte_config.h>
#include <rte_compat.h>
@@ -75,7 +74,7 @@ struct rte_mem_resource {
* A structure describing a device driver.
*/
struct rte_driver {
- TAILQ_ENTRY(rte_driver) next; /**< Next in list. */
+ RTE_TAILQ_ENTRY(rte_driver) next; /**< Next in list. */
const char *name; /**< Driver name. */
const char *alias; /**< Driver alias. */
};
@@ -90,7 +89,7 @@ struct rte_driver {
* A structure describing a generic device.
*/
struct rte_device {
- TAILQ_ENTRY(rte_device) next; /**< Next device */
+ RTE_TAILQ_ENTRY(rte_device) next; /**< Next device */
const char *name; /**< Device name */
const struct rte_driver *driver; /**< Driver assigned after probing */
const struct rte_bus *bus; /**< Bus handle assigned on scan */
@@ -21,7 +21,6 @@ extern "C" {
#endif
#include <stdio.h>
-#include <sys/queue.h>
#include <rte_compat.h>
#include <rte_bus.h>
@@ -76,7 +75,7 @@ enum rte_devtype {
*/
struct rte_devargs {
/** Next in list. */
- TAILQ_ENTRY(rte_devargs) next;
+ RTE_TAILQ_ENTRY(rte_devargs) next;
/** Type of device. */
enum rte_devtype type;
/** Device policy. */
@@ -21,7 +21,6 @@ extern "C" {
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
-#include <sys/queue.h>
#include <rte_common.h>
#include <rte_config.h>
@@ -29,7 +29,6 @@ extern "C" {
#include<stdio.h>
#include <stdint.h>
-#include <sys/queue.h>
#include <rte_config.h>
#include <rte_lcore.h>
@@ -15,17 +15,16 @@
extern "C" {
#endif
-#include <sys/queue.h>
#include <stdio.h>
#include <rte_debug.h>
/** dummy structure type used by the rte_tailq APIs */
struct rte_tailq_entry {
- TAILQ_ENTRY(rte_tailq_entry) next; /**< Pointer entries for a tailq list */
+ RTE_TAILQ_ENTRY(rte_tailq_entry) next; /**< Pointer entries for a tailq list */
void *data; /**< Pointer to the data referenced by this tailq entry */
};
/** dummy */
-TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry);
+RTE_TAILQ_HEAD(rte_tailq_entry_head, rte_tailq_entry);
#define RTE_TAILQ_NAMESIZE 32
@@ -48,7 +47,7 @@ struct rte_tailq_elem {
* rte_eal_tailqs_init()
*/
struct rte_tailq_head *head;
- TAILQ_ENTRY(rte_tailq_elem) next;
+ RTE_TAILQ_ENTRY(rte_tailq_elem) next;
const char name[RTE_TAILQ_NAMESIZE];
};
@@ -126,10 +125,10 @@ RTE_INIT(tailqinitfn_ ##t) \
}
/* This macro permits both remove and free var within the loop safely.*/
-#ifndef TAILQ_FOREACH_SAFE
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
+#ifndef RTE_TAILQ_FOREACH_SAFE
+#define RTE_TAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = RTE_TAILQ_FIRST((head)); \
+ (var) && ((tvar) = RTE_TAILQ_NEXT((var), field), 1); \
(var) = (tvar))
#endif
@@ -11,6 +11,39 @@
*/
#include <sched.h>
+#include <sys/queue.h>
+
+/* These macros are compatible with system's sys/queue.h. */
+#define RTE_TAILQ_INIT(head) TAILQ_INIT(head)
+#define RTE_TAILQ_HEAD(name, type) TAILQ_HEAD(name, type)
+#define RTE_TAILQ_LAST(head, headname) TAILQ_LAST(head, headname)
+#define RTE_TAILQ_ENTRY(type) TAILQ_ENTRY(type)
+#define RTE_TAILQ_FIRST(head) TAILQ_FIRST(head)
+#define RTE_TAILQ_EMPTY(head) TAILQ_EMPTY(head)
+#define RTE_TAILQ_NEXT(elem, field) TAILQ_NEXT(elem, field)
+#define RTE_TAILQ_HEAD_INITIALIZER(head) TAILQ_HEAD_INITIALIZER(head)
+#define RTE_TAILQ_FOREACH(var, head, field) TAILQ_FOREACH(var, head, field)
+#define RTE_TAILQ_INSERT_TAIL(head, elm, field) \
+ TAILQ_INSERT_TAIL(head, elm, field)
+#define RTE_TAILQ_REMOVE(head, elm, field) TAILQ_REMOVE(head, elm, field)
+#define RTE_TAILQ_INSERT_BEFORE(listelm, elm, field) \
+ TAILQ_INSERT_BEFORE(listelm, elm, field)
+#define RTE_TAILQ_INSERT_AFTER(head, listelm, elm, field) \
+ TAILQ_INSERT_AFTER(head, listelm, elm, field)
+#define RTE_TAILQ_INSERT_HEAD(head, elm, field) \
+ TAILQ_INSERT_HEAD(head, elm, field)
+
+#define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type)
+#define RTE_STAILQ_HEAD_INITIALIZER(head) STAILQ_HEAD_INITIALIZER(head)
+#define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type)
+
+/* This is not defined in sys/queue.h */
+#ifndef TAILQ_FOREACH_SAFE
+#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = RTE_TAILQ_FIRST((head)); \
+ (var) && ((tvar) = RTE_TAILQ_NEXT((var), field), 1); \
+ (var) = (tvar))
+#endif
#ifdef CPU_SETSIZE /* may require _GNU_SOURCE */
typedef cpu_set_t rte_cpuset_t;
@@ -4,6 +4,7 @@
#include <stdatomic.h>
#include <stdbool.h>
+#include <sys/queue.h>
#include <rte_alarm.h>
#include <rte_spinlock.h>
@@ -18,6 +18,144 @@
extern "C" {
#endif
+#ifdef QUEUE_MACRO_DEBUG_TRACE
+/* Store the last 2 places the queue element or head was altered */
+struct qm_trace {
+ unsigned long lastline;
+ unsigned long prevline;
+ const char *lastfile;
+ const char *prevfile;
+};
+
+/**
+ * These macros are compatible with the sys/queue.h provided
+ * at DPDK source code.
+ */
+#define TRACEBUF struct qm_trace trace;
+#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } ,
+
+#define QMD_TRACE_HEAD(head) do { \
+ (head)->trace.prevline = (head)->trace.lastline; \
+ (head)->trace.prevfile = (head)->trace.lastfile; \
+ (head)->trace.lastline = __LINE__; \
+ (head)->trace.lastfile = __FILE__; \
+} while (0)
+
+#define QMD_TRACE_ELEM(elem) do { \
+ (elem)->trace.prevline = (elem)->trace.lastline; \
+ (elem)->trace.prevfile = (elem)->trace.lastfile; \
+ (elem)->trace.lastline = __LINE__; \
+ (elem)->trace.lastfile = __FILE__; \
+} while (0)
+
+#else /* !QUEUE_MACRO_DEBUG_TRACE */
+#define QMD_TRACE_ELEM(elem)
+#define QMD_TRACE_HEAD(head)
+#define TRACEBUF
+#define TRACEBUF_INITIALIZER
+#endif /* QUEUE_MACRO_DEBUG_TRACE */
+
+#ifdef QUEUE_MACRO_DEBUG_TRASH
+#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
+#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
+#define QMD_IS_TRASHED(x) ((x) == (void *)(intptr_t)-1)
+#else /* !QUEUE_MACRO_DEBUG_TRASH */
+#define QMD_SAVELINK(name, link)
+#define TRASHIT(x)
+#define QMD_IS_TRASHED(x) 0
+#endif /* QUEUE_MACRO_DEBUG_TRASH */
+
+#define QMD_TAILQ_CHECK_HEAD(head, field)
+#define QMD_TAILQ_CHECK_TAIL(head, headname)
+#define QMD_TAILQ_CHECK_NEXT(elm, field)
+#define QMD_TAILQ_CHECK_PREV(elm, field)
+
+
+#define RTE_TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
+
+#define RTE_TAILQ_FIRST(head) ((head)->tqh_first)
+
+#define RTE_TAILQ_INIT(head) do { \
+ RTE_TAILQ_FIRST((head)) = NULL; \
+ (head)->tqh_last = &RTE_TAILQ_FIRST((head)); \
+ QMD_TRACE_HEAD(head); \
+} while (0)
+
+#define RTE_TAILQ_HEAD(name, type) \
+struct name { \
+ struct type *tqh_first; /* first element */ \
+ struct type **tqh_last; /* addr of last next element */ \
+ TRACEBUF \
+}
+#define RTE_TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER }
+
+#define RTE_TAILQ_ENTRY(type) \
+struct { \
+ struct type *tqe_next; /* next element */ \
+ struct type **tqe_prev; /* address of previous next element */ \
+ TRACEBUF \
+}
+
+#define RTE_TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+#define RTE_TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+
+#define RTE_TAILQ_FOREACH(var, head, field) \
+ for ((var) = RTE_TAILQ_FIRST((head)); \
+ (var); \
+ (var) = RTE_TAILQ_NEXT((var), field))
+
+#define RTE_TAILQ_INSERT_TAIL(head, elm, field) do { \
+ QMD_TAILQ_CHECK_TAIL(head, field); \
+ RTE_TAILQ_NEXT((elm), field) = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &RTE_TAILQ_NEXT((elm), field); \
+ QMD_TRACE_HEAD(head); \
+ QMD_TRACE_ELEM(&(elm)->field); \
+} while (0)
+
+#define RTE_TAILQ_REMOVE(head, elm, field) do { \
+ QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
+ QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
+ QMD_TAILQ_CHECK_NEXT(elm, field); \
+ QMD_TAILQ_CHECK_PREV(elm, field); \
+ if ((RTE_TAILQ_NEXT((elm), field)) != NULL) \
+ RTE_TAILQ_NEXT((elm), field)->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else { \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ QMD_TRACE_HEAD(head); \
+ } \
+ *(elm)->field.tqe_prev = RTE_TAILQ_NEXT((elm), field); \
+ TRASHIT(*oldnext); \
+ TRASHIT(*oldprev); \
+ QMD_TRACE_ELEM(&(elm)->field); \
+} while (0)
+
+#define RTE_TAILQ_INSERT_BEFORE(listelm, elm, field) \
+ TAILQ_INSERT_BEFORE(listelm, elm, field)
+#define RTE_TAILQ_INSERT_AFTER(head, listelm, elm, field) \
+ TAILQ_INSERT_AFTER(head, listelm, elm, field)
+#define RTE_TAILQ_INSERT_HEAD(head, elm, field) \
+ TAILQ_INSERT_HEAD(head, elm, field)
+
+
+#define RTE_STAILQ_HEAD(name, type) \
+struct name { \
+ struct type *stqh_first;/* first element */ \
+ struct type **stqh_last;/* addr of last next element */ \
+}
+#define RTE_STAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).stqh_first }
+
+#define RTE_STAILQ_ENTRY(type) \
+struct { \
+ struct type *stqe_next; /* next element */ \
+}
+
+
/* cpu_set macros implementation */
#define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2)
#define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2)
@@ -21,7 +21,7 @@
struct rte_eth_dev_callback;
/** @internal Structure to keep track of registered callbacks */
-TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
+RTE_TAILQ_HEAD(rte_eth_dev_cb_list, rte_eth_dev_callback);
struct rte_eth_dev;
@@ -17,7 +17,6 @@
#include <stdint.h>
#include <errno.h>
-#include <sys/queue.h>
#ifdef __cplusplus
extern "C" {
@@ -2,6 +2,8 @@
* Copyright(c) 2021 Intel Corporation
*/
+#include <sys/queue.h>
+
#include <rte_thash.h>
#include <rte_tailq.h>
#include <rte_random.h>
@@ -62,7 +62,7 @@ struct ip_frag_key {
* First two entries in the frags[] array are for the last and first fragments.
*/
struct ip_frag_pkt {
- TAILQ_ENTRY(ip_frag_pkt) lru; /**< LRU list */
+ RTE_TAILQ_ENTRY(ip_frag_pkt) lru; /**< LRU list */
struct ip_frag_key key; /**< fragmentation key */
uint64_t start; /**< creation timestamp */
uint32_t total_size; /**< expected reassembled size */
@@ -83,7 +83,7 @@ struct rte_ip_frag_death_row {
/**< mbufs to be freed */
};
-TAILQ_HEAD(ip_pkt_list, ip_frag_pkt); /**< @internal fragments tailq */
+RTE_TAILQ_HEAD(ip_pkt_list, ip_frag_pkt); /**< @internal fragments tailq */
/** fragmentation table statistics */
struct ip_frag_tbl_stat {
@@ -38,7 +38,6 @@
#include <stdint.h>
#include <errno.h>
#include <inttypes.h>
-#include <sys/queue.h>
#include <rte_config.h>
#include <rte_spinlock.h>
@@ -141,7 +140,7 @@ struct rte_mempool_objsz {
* double-frees.
*/
struct rte_mempool_objhdr {
- STAILQ_ENTRY(rte_mempool_objhdr) next; /**< Next in list. */
+ RTE_STAILQ_ENTRY(rte_mempool_objhdr) next; /**< Next in list. */
struct rte_mempool *mp; /**< The mempool owning the object. */
rte_iova_t iova; /**< IO address of the object. */
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
@@ -152,7 +151,7 @@ struct rte_mempool_objhdr {
/**
* A list of object headers type
*/
-STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
+RTE_STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
@@ -171,7 +170,7 @@ struct rte_mempool_objtlr {
/**
* A list of memory where objects are stored
*/
-STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
+RTE_STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
/**
* Callback used to free a memory chunk
@@ -186,7 +185,7 @@ typedef void (rte_mempool_memchunk_free_cb_t)(struct rte_mempool_memhdr *memhdr,
* and physically contiguous.
*/
struct rte_mempool_memhdr {
- STAILQ_ENTRY(rte_mempool_memhdr) next; /**< Next in list. */
+ RTE_STAILQ_ENTRY(rte_mempool_memhdr) next; /**< Next in list. */
struct rte_mempool *mp; /**< The mempool owning the chunk */
void *addr; /**< Virtual address of the chunk */
rte_iova_t iova; /**< IO address of the chunk */
@@ -18,7 +18,6 @@ extern "C" {
#include <stdio.h>
#include <limits.h>
-#include <sys/queue.h>
#include <inttypes.h>
#include <sys/types.h>
@@ -26,7 +26,6 @@ extern "C" {
#include <stdio.h>
#include <stdint.h>
#include <string.h>
-#include <sys/queue.h>
#include <errno.h>
#include <rte_common.h>
#include <rte_config.h>
@@ -16,7 +16,8 @@ extern "C" {
*/
#include <stdint.h>
-#include <sys/queue.h>
+
+#include <rte_os.h>
/** Match type. */
enum rte_swx_table_match_type {
@@ -68,7 +69,7 @@ struct rte_swx_table_entry {
/** Used to facilitate the membership of this table entry to a
* linked list.
*/
- TAILQ_ENTRY(rte_swx_table_entry) node;
+ RTE_TAILQ_ENTRY(rte_swx_table_entry) node;
/** Key value for the current entry. Array of *key_size* bytes or NULL
* if the *key_size* for the current table is 0.
@@ -111,7 +112,7 @@ struct rte_swx_table_entry {
};
/** List of table entries. */
-TAILQ_HEAD(rte_swx_table_entry_list, rte_swx_table_entry);
+RTE_TAILQ_HEAD(rte_swx_table_entry_list, rte_swx_table_entry);
/**
* Table memory footprint get
@@ -16,7 +16,6 @@ extern "C" {
*/
#include <stdint.h>
-#include <sys/queue.h>
#include <rte_compat.h>
@@ -56,7 +55,7 @@ struct rte_swx_table_selector_params {
/** Group member parameters. */
struct rte_swx_table_selector_member {
/** Linked list connectivity. */
- TAILQ_ENTRY(rte_swx_table_selector_member) node;
+ RTE_TAILQ_ENTRY(rte_swx_table_selector_member) node;
/** Member ID. */
uint32_t member_id;
@@ -66,7 +65,7 @@ struct rte_swx_table_selector_member {
};
/** List of group members. */
-TAILQ_HEAD(rte_swx_table_selector_member_list, rte_swx_table_selector_member);
+RTE_TAILQ_HEAD(rte_swx_table_selector_member_list, rte_swx_table_selector_member);
/** Group parameters. */
struct rte_swx_table_selector_group {
@@ -71,7 +71,7 @@ struct rte_vdpa_dev_ops {
* vdpa device structure includes device address and device operations.
*/
struct rte_vdpa_device {
- TAILQ_ENTRY(rte_vdpa_device) next;
+ RTE_TAILQ_ENTRY(rte_vdpa_device) next;
/** Generic device information */
struct rte_device *device;
/** vdpa device operations */