resolve issues with sys/queue.h
Subsystems (8)
PATCH v2 36/43 net/dpaa2: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/dpaa2/dpaa2_flow.c | 1 - drivers/net/dpaa2/dpaa2_mux.c | 1 - drivers/net/dpaa2/dpaa2_ptp.c | 1 - 3 files changed, 3 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +0 -1
@@ -2,7 +2,6 @@* Copyright 2018-2022 NXP */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/dpaa2/dpaa2_mux.c +0 -1
@@ -2,7 +2,6 @@* Copyright 2018-2021,2023 NXP */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/dpaa2/dpaa2_ptp.c +0 -1
@@ -2,7 +2,6 @@* Copyright 2019, 2023 NXP */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
Signature · 1 line
2.47.2
PATCH v2 37/43 net/mvpp2: replace local definition of FOREACH_SAFE
In reply to Stephen HemmingerThere is now a standard macro for this.
--- drivers/net/mvpp2/mrvl_mtr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/mvpp2/mrvl_mtr.c +2 -6
@@ -505,13 +505,9 @@ mrvl_mtr_deinit(struct rte_eth_dev *dev)struct mrvl_mtr_profile *profile, *tmp_profile;struct mrvl_mtr *mtr, *tmp_mtr; -for (mtr =LIST_FIRST (&priv->mtrs); - mtr && (tmp_mtr =LIST_NEXT (mtr, next),1 ); - mtr = tmp_mtr) + LIST_FOREACH_SAFE(mtr, &priv->mtrs, next, tmp_mtr)mrvl_destroy (dev, mtr->mtr_id,NULL ); -for (profile =LIST_FIRST (&priv->profiles); - profile && (tmp_profile =LIST_NEXT (profile, next),1 ); - profile = tmp_profile) + LIST_FOREACH_SAFE(profile, &priv_profiles, next, tmp_profile)mrvl_meter_profile_delete (dev, profile->profile_id,NULL ); }
Signature · 1 line
2.47.2
PATCH v2 38/43 raw/ifpga: replace with TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerThere is now a standard macro to safely walk tailq.
--- drivers/raw/ifpga/base/ifpga_enumerate.c | 6 +++--- drivers/raw/ifpga/base/opae_hw_api.h | 1 - drivers/raw/ifpga/base/opae_intel_max10.c | 8 +------- drivers/raw/ifpga/base/osdep_rte/osdep_generic.h | 1 + 4 files changed, 5 insertions(+), 11 deletions(-)
drivers/raw/ifpga/base/ifpga_enumerate.c +3 -3
@@ -6,6 +6,8 @@#include <inttypes.h> #include <unistd.h> +#include <rte_bsd_queue.h> +#include "opae_hw_api.h" #include "ifpga_api.h"
@@ -725,9 +727,7 @@ static void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info)return ;/* remove all device feature lists in the list. */ -for (dfl =TAILQ_FIRST (&info->dfls); - dfl && (tmp =TAILQ_NEXT (dfl, node),1 ); - dfl = tmp) { + TAILQ_FOREACH_SAFE(dfl, &info->dfls, node, tmp) {TAILQ_REMOVE (&info->dfls, dfl, node);opae_free (dfl); }
drivers/raw/ifpga/base/opae_hw_api.h +0 -1
@@ -8,7 +8,6 @@#include <stdint.h> #include <stdlib.h> #include <stdio.h> -#include <sys/queue.h> #include "opae_osdep.h" #include "opae_intel_max10.h"
drivers/raw/ifpga/base/opae_intel_max10.c +1 -7
@@ -4,14 +4,8 @@#include "opae_intel_max10.h" #include <libfdt.h> -#include "opae_osdep.h" -#ifndef TAILQ_FOREACH_SAFE -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif +#include "opae_osdep.h" int max10_sys_read (struct intel_max10_device *dev,unsigned int offset,unsigned int *val)
drivers/raw/ifpga/base/osdep_rte/osdep_generic.h +1 -0
@@ -8,6 +8,7 @@#include <stdlib.h> #include <rte_common.h> +#include <rte_bsd_queue.h> #include <rte_cycles.h> #include <rte_spinlock.h> #include <rte_log.h>
Signature · 1 line
2.47.2
PATCH v2 39/43 drivers/vdpa: replace use of sys/queue.h
In reply to Stephen HemmingerUse rte_bsd_queue.h instead.
--- drivers/vdpa/mlx5/mlx5_vdpa.h | 3 ++- drivers/vdpa/sfc/sfc_vdpa.c | 2 +- drivers/vdpa/sfc/sfc_vdpa.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa.h +2 -1
@@ -6,7 +6,8 @@#define RTE_PMD_MLX5_VDPA_H_ #include <linux/virtio_net.h> -#include <sys/queue.h> + +#include <rte_bsd_queue.h> #ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"
drivers/vdpa/sfc/sfc_vdpa.c +1 -1
@@ -5,8 +5,8 @@#include <stdbool.h> #include <stdint.h> #include <pthread.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_devargs.h> #include <rte_errno.h>
drivers/vdpa/sfc/sfc_vdpa.h +1 -1
@@ -6,8 +6,8 @@#define _SFC_VDPA_H#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <bus_pci_driver.h> #include "sfc_efx.h"
Signature · 1 line
2.47.2
PATCH v2 40/43 drivers/common: remove use of sys/queue.h
In reply to Stephen HemmingerThe system version of queue.h should not be used.
--- drivers/common/cnxk/roc_bphy_irq.c | 3 ++- drivers/common/cnxk/roc_npc.h | 2 -- drivers/common/mlx5/mlx5_common_mr.h | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/common/cnxk/roc_bphy_irq.c +2 -1
@@ -5,9 +5,10 @@#include <pthread.h> #include <sys/ioctl.h> #include <sys/mman.h> -#include <sys/queue.h> #include <unistd.h> +#include <rte_bsd_queue.h> +#include "roc_api.h" #include "roc_bphy_irq.h"
drivers/common/cnxk/roc_npc.h +0 -2
@@ -5,8 +5,6 @@#ifndef _ROC_NPC_H_#define _ROC_NPC_H_ -#include <sys/queue.h> -enum roc_npc_item_type {ROC_NPC_ITEM_TYPE_VOID , ROC_NPC_ITEM_TYPE_ANY,
drivers/common/mlx5/mlx5_common_mr.h +1 -2
@@ -8,10 +8,9 @@#include <stddef.h> #include <stdint.h> -#include <sys/queue.h> -#include <rte_compat.h> +#include <rte_bsd_queue.h> #include <rte_rwlock.h> #include <rte_bitmap.h> #include <rte_mbuf.h>
Signature · 1 line
2.47.2
PATCH v2 41/43 drivers/crypto: remove use of sys_queue.h
In reply to Stephen HemmingerThe system version of queue.h should not be used.
If necessary use rte_bsd_queue.h
--- drivers/crypto/bcmfs/bcmfs_device.c | 2 +- drivers/crypto/bcmfs/bcmfs_device.h | 2 -- drivers/crypto/ccp/ccp_crypto.c | 1 - drivers/crypto/ccp/ccp_dev.c | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/bcmfs/bcmfs_device.c +1 -1
@@ -6,8 +6,8 @@#include <dirent.h> #include <stdbool.h> #include <stdlib.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_malloc.h> #include <rte_string_fns.h>
drivers/crypto/bcmfs/bcmfs_device.h +0 -2
@@ -6,8 +6,6 @@#ifndef _BCMFS_DEVICE_H_#define _BCMFS_DEVICE_H_ -#include <sys/queue.h> -#include <rte_spinlock.h> #include <bus_vdev_driver.h>
drivers/crypto/ccp/ccp_crypto.c +0 -1
@@ -9,7 +9,6 @@#include <stdio.h> #include <string.h> #include <sys/mman.h> -#include <sys/queue.h> #include <sys/types.h> #include <unistd.h> #include <openssl/sha.h>
drivers/crypto/ccp/ccp_dev.c +1 -1
@@ -7,11 +7,11 @@#include <stdio.h> #include <string.h> #include <sys/mman.h> -#include <sys/queue.h> #include <sys/types.h> #include <sys/file.h> #include <unistd.h> +#include <rte_bsd_queue.h> #include <rte_hexdump.h> #include <rte_memzone.h> #include <rte_malloc.h>
Signature · 1 line
2.47.2
PATCH v2 42/43 drivers/event: remove include of sys/queue.h
In reply to Stephen HemmingerThe system version of queue.h is no longer used.
--- drivers/event/dlb2/dlb2_selftest.c | 1 - drivers/event/opdl/opdl_test.c | 1 - drivers/event/sw/sw_evdev_selftest.c | 1 - 3 files changed, 3 deletions(-)
drivers/event/dlb2/dlb2_selftest.c +0 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <errno.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_memzone.h>
drivers/event/opdl/opdl_test.c +0 -1
@@ -8,7 +8,6 @@#include <stdlib.h> #include <errno.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_memzone.h>
drivers/event/sw/sw_evdev_selftest.c +0 -1
@@ -9,7 +9,6 @@#include <stdlib.h> #include <errno.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_launch.h>
Signature · 1 line
2.47.2
PATCH v2 43/43 eal: remove no longer used windows version of sys/queue.h
In reply to Stephen HemmingerSuperseded by common rte_bsd_queue.h
--- lib/eal/windows/include/sys/queue.h | 840 ---------------------------- 1 file changed, 840 deletions(-) delete mode 100644 lib/eal/windows/include/sys/queue.h
lib/eal/windows/include/sys/queue.h deleted +0 -840
@@ -1,840 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause -* -* Copyright (c) 1991, 1993 -* The Regents of the University of California. All rights reserved. -*/ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -/* -* This file defines four types of data structures: singly-linked lists, -* singly-linked tail queues, lists and tail queues. -* -* A singly-linked list is headed by a single forward pointer. The elements -* are singly linked for minimum space and pointer manipulation overhead at -* the expense of O(n) removal for arbitrary elements. New elements can be -* added to the list after an existing element or at the head of the list. -* Elements being removed from the head of the list should use the explicit -* macro for this purpose for optimum efficiency. A singly-linked list may -* only be traversed in the forward direction. Singly-linked lists are ideal -* for applications with large datasets and few or no removals or for -* implementing a LIFO queue. -* -* A singly-linked tail queue is headed by a pair of pointers, one to the -* head of the list and the other to the tail of the list. The elements are -* singly linked for minimum space and pointer manipulation overhead at the -* expense of O(n) removal for arbitrary elements. New elements can be added -* to the list after an existing element, at the head of the list, or at the -* end of the list. Elements being removed from the head of the tail queue -* should use the explicit macro for this purpose for optimum efficiency. -* A singly-linked tail queue may only be traversed in the forward direction. -* Singly-linked tail queues are ideal for applications with large datasets -* and few or no removals or for implementing a FIFO queue. -* -* A list is headed by a single forward pointer (or an array of forward -* pointers for a hash table header). The elements are doubly linked -* so that an arbitrary element can be removed without a need to -* traverse the list. New elements can be added to the list before -* or after an existing element or at the head of the list. A list -* may be traversed in either direction. -* -* A tail queue is headed by a pair of pointers, one to the head of the -* list and the other to the tail of the list. The elements are doubly -* linked so that an arbitrary element can be removed without a need to -* traverse the list. New elements can be added to the list before or -* after an existing element, at the head of the list, or at the end of -* the list. A tail queue may be traversed in either direction. -* -* For details on the use of these macros, see the queue(3) manual page. -* -* Below is a summary of implemented functions where: -* + means the macro is available -* - means the macro is not available -* s means the macro is available but is slow (runs in O(n) time) -* -* SLIST LIST STAILQ TAILQ -* _HEAD + + + + -* _CLASS_HEAD + + + + -* _HEAD_INITIALIZER + + + + -* _ENTRY + + + + -* _CLASS_ENTRY + + + + -* _INIT + + + + -* _EMPTY + + + + -* _FIRST + + + + -* _NEXT + + + + -* _PREV - + - + -* _LAST - - + + -* _LAST_FAST - - - + -* _FOREACH + + + + -* _FOREACH_FROM + + + + -* _FOREACH_SAFE + + + + -* _FOREACH_FROM_SAFE + + + + -* _FOREACH_REVERSE - - - + -* _FOREACH_REVERSE_FROM - - - + -* _FOREACH_REVERSE_SAFE - - - + -* _FOREACH_REVERSE_FROM_SAFE - - - + -* _INSERT_HEAD + + + + -* _INSERT_BEFORE - + - + -* _INSERT_AFTER + + + + -* _INSERT_TAIL - - + + -* _CONCAT s s + + -* _REMOVE_AFTER + - + - -* _REMOVE_HEAD + - + - -* _REMOVE s + s + -* _SWAP + + + + -*/ -#ifdef QUEUE_MACRO_DEBUG -#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH -#define QUEUE_MACRO_DEBUG_TRACE -#define QUEUE_MACRO_DEBUG_TRASH -#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; -}; - -#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 */ - -#ifdef __cplusplus -/* -* In C++ there can be structure lists and class lists: -*/ -#define QUEUE_TYPEOF (type) type -#else -#define QUEUE_TYPEOF (type) struct type -#endif - -/* -* Singly-linked List declarations. -*/ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_CLASS_HEAD(name, type) \ -struct name { \ - class type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER (head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -#define SLIST_CLASS_ENTRY(type) \ -struct { \ - class type *sle_next; /* next element */ \ -} - -/* -* Singly-linked List functions. -*/ -#if (defined(_KERNEL) && defined(INVARIANTS )) -#define QMD_SLIST_CHECK_PREVPTR (prevp, elm) do { \ - if (*(prevp) != (elm)) \ - panic("Bad prevptr *(%p) == %p != %p", \ - (prevp), *(prevp), (elm)); \ -} while (0) -#else -#define QMD_SLIST_CHECK_PREVPTR (prevp, elm) -#endif - -#define SLIST_CONCAT (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ - if (curelm == NULL) { \ - if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \ - SLIST_INIT(head2); \ - } else if (SLIST_FIRST(head2) != NULL) { \ - while (SLIST_NEXT(curelm, field) != NULL) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ - SLIST_INIT(head2); \ - } \ -} while (0) - -#define SLIST_EMPTY (head) ((head)->slh_first == NULL) - -#define SLIST_FIRST (head) ((head)->slh_first) - -#define SLIST_FOREACH (var, head, field) \ - for ((var) = SLIST_FIRST((head)); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_PREVPTR (var, varp, head, field) \ - for ((varp) = &SLIST_FIRST((head)); \ - ((var) = *(varp)) != NULL; \ - (varp) = &SLIST_NEXT((var), field)) - -#define SLIST_INIT (head) do { \ - SLIST_FIRST((head)) = NULL; \ -} while (0) - -#define SLIST_INSERT_AFTER (slistelm, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ - SLIST_NEXT((slistelm), field) = (elm); \ -} while (0) - -#define SLIST_INSERT_HEAD (head, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ - SLIST_FIRST((head)) = (elm); \ -} while (0) - -#define SLIST_NEXT (elm, field) ((elm)->field.sle_next) - -#define SLIST_REMOVE (head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ - if (SLIST_FIRST((head)) == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \ - while (SLIST_NEXT(curelm, field) != (elm)) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_REMOVE_AFTER(curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define SLIST_REMOVE_AFTER (elm, field) do { \ - SLIST_NEXT(elm, field) = \ - SLIST_NEXT(SLIST_NEXT(elm, field), field); \ -} while (0) - -#define SLIST_REMOVE_HEAD (head, field) do { \ - SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ -} while (0) - -#define SLIST_REMOVE_PREVPTR (prevp, elm, field) do { \ - QMD_SLIST_CHECK_PREVPTR(prevp, elm); \ - *(prevp) = SLIST_NEXT(elm, field); \ - TRASHIT((elm)->field.sle_next); \ -} while (0) - -#define SLIST_SWAP (head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \ - SLIST_FIRST(head1) = SLIST_FIRST(head2); \ - SLIST_FIRST(head2) = swap_first; \ -} while (0) - -/* -* Singly-linked Tail queue declarations. -*/ -#define STAILQ_HEAD (name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ -struct type **stqh_last;/* addr of last next element */ \ -} - -#define STAILQ_CLASS_HEAD(name, type) \ -struct name { \ - class type *stqh_first; /* first element */ \ - class type **stqh_last; /* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -#define STAILQ_CLASS_ENTRY(type) \ -struct { \ - class type *stqe_next; /* next element */ \ -} - -/* -* Singly-linked Tail queue functions. -*/ -#define STAILQ_CONCAT (head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (0) - -#define STAILQ_EMPTY (head) ((head)->stqh_first == NULL) - -#define STAILQ_FIRST (head) ((head)->stqh_first) - -#define STAILQ_FOREACH (var, head, field) \ - for((var) = STAILQ_FIRST((head)); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_INIT (head) do { \ - STAILQ_FIRST((head)) = NULL; \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_INSERT_AFTER (head, tqelm, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_NEXT((tqelm), field) = (elm); \ -} while (0) - -#define STAILQ_INSERT_HEAD (head, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_FIRST((head)) = (elm); \ -} while (0) - -#define STAILQ_INSERT_TAIL (head, elm, field) do { \ - STAILQ_NEXT((elm), field) = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_LAST (head, type, field) \ - (STAILQ_EMPTY((head)) ? NULL : \ - __containerof((head)->stqh_last, \ - QUEUE_TYPEOF(type), field.stqe_next)) - -#define STAILQ_NEXT (elm, field) ((elm)->field.stqe_next) - -#define STAILQ_REMOVE (head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ - if (STAILQ_FIRST((head)) == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } \ - else { \ - QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \ - while (STAILQ_NEXT(curelm, field) != (elm)) \ - curelm = STAILQ_NEXT(curelm, field); \ - STAILQ_REMOVE_AFTER(head, curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define STAILQ_REMOVE_AFTER (head, elm, field) do { \ - if ((STAILQ_NEXT(elm, field) = \ - STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_REMOVE_HEAD (head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_SWAP (head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \ - QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \ - STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_FIRST(head2) = swap_first; \ - (head2)->stqh_last = swap_last; \ - if (STAILQ_EMPTY(head1)) \ - (head1)->stqh_last = &STAILQ_FIRST(head1); \ - if (STAILQ_EMPTY(head2)) \ - (head2)->stqh_last = &STAILQ_FIRST(head2); \ -} while (0) - - -/* -* List declarations. -*/ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_CLASS_HEAD(name, type) \ -struct name { \ - class type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER (head) \ - { NULL } - -#define LIST_ENTRY (type) \ -struct { \ - struct type *le_next;/* next element */ \ -struct type **le_prev;/* address of previous next element */ \ -} - -#define LIST_CLASS_ENTRY(type) \ -struct { \ - class type *le_next; /* next element */ \ - class type **le_prev; /* address of previous next element */ \ -} - -/* -* List functions. -*/ - -#if (defined(_KERNEL) && defined(INVARIANTS )) -/* -* QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME) -* -* If the list is non-empty, validates that the first element of the list -* points back at 'head.' -*/ -#define QMD_LIST_CHECK_HEAD (head, field) do { \ - if (LIST_FIRST((head)) != NULL && \ - LIST_FIRST((head))->field.le_prev != \ - &LIST_FIRST((head))) \ - panic("Bad list head %p first->prev != head", (head)); \ -} while (0) - -/* -* QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME) -* -* If an element follows 'elm' in the list, validates that the next element -* points back at 'elm.' -*/ -#define QMD_LIST_CHECK_NEXT (elm, field) do { \ - if (LIST_NEXT((elm), field) != NULL && \ - LIST_NEXT((elm), field)->field.le_prev != \ - &((elm)->field.le_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -/* -* QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME) -* -* Validates that the previous element (or head of the list) points to 'elm.' -*/ -#define QMD_LIST_CHECK_PREV (elm, field) do { \ - if (*(elm)->field.le_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#define QMD_LIST_CHECK_HEAD (head, field) -#define QMD_LIST_CHECK_NEXT (elm, field) -#define QMD_LIST_CHECK_PREV (elm, field) -#endif /* (_KERNEL && INVARIANTS) */ - -#define LIST_CONCAT (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \ - if (curelm == NULL) { \ - if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \ - LIST_FIRST(head2)->field.le_prev = \ - &LIST_FIRST((head1)); \ - LIST_INIT(head2); \ - } \ - } else if (LIST_FIRST(head2) != NULL) { \ - while (LIST_NEXT(curelm, field) != NULL) \ - curelm = LIST_NEXT(curelm, field); \ - LIST_NEXT(curelm, field) = LIST_FIRST(head2); \ - LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \ - LIST_INIT(head2); \ - } \ -} while (0) - -#define LIST_EMPTY (head) ((head)->lh_first == NULL) - -#define LIST_FIRST (head) ((head)->lh_first) - -#define LIST_FOREACH (var, head, field) \ - for ((var) = LIST_FIRST((head)); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_INIT (head) do { \ - LIST_FIRST((head)) = NULL; \ -} while (0) - -#define LIST_INSERT_AFTER (listelm, elm, field) do { \ - QMD_LIST_CHECK_NEXT(listelm, field); \ - if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ - LIST_NEXT((listelm), field)->field.le_prev = \ - &LIST_NEXT((elm), field); \ - LIST_NEXT((listelm), field) = (elm); \ - (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ -} while (0) - -#define LIST_INSERT_BEFORE (listelm, elm, field) do { \ - QMD_LIST_CHECK_PREV(listelm, field); \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - LIST_NEXT((elm), field) = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ -} while (0) - -#define LIST_INSERT_HEAD (head, elm, field) do { \ - QMD_LIST_CHECK_HEAD((head), field); \ - if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ - LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ - LIST_FIRST((head)) = (elm); \ - (elm)->field.le_prev = &LIST_FIRST((head)); \ -} while (0) - -#define LIST_NEXT (elm, field) ((elm)->field.le_next) - -#define LIST_PREV (elm, head, type, field) \ - ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ - __containerof((elm)->field.le_prev, \ - QUEUE_TYPEOF(type), field.le_next)) - -#define LIST_REMOVE (elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.le_next); \ - QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ - QMD_LIST_CHECK_NEXT(elm, field); \ - QMD_LIST_CHECK_PREV(elm, field); \ - if (LIST_NEXT((elm), field) != NULL) \ - LIST_NEXT((elm), field)->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = LIST_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ -} while (0) - -#define LIST_SWAP (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \ - LIST_FIRST((head1)) = LIST_FIRST((head2)); \ - LIST_FIRST((head2)) = swap_tmp; \ - if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ - if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ -} while (0) - -/* -* Tail queue declarations. -*/ -#define TAILQ_HEAD (name, type) \ -struct name { \ - struct type *tqh_first;/* first element */ \ -struct type **tqh_last;/* addr of last next element */ \ - TRACEBUF \ -} - -#define TAILQ_CLASS_HEAD(name, type) \ -struct name { \ - class type *tqh_first; /* first element */ \ - class type **tqh_last; /* addr of last next element */ \ -TRACEBUF \ -} - -#define TAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } - -#define TAILQ_ENTRY (type) \ -struct { \ - struct type *tqe_next;/* next element */ \ -struct type **tqe_prev;/* address of previous next element */ \ - TRACEBUF \ -} - -#define TAILQ_CLASS_ENTRY(type) \ -struct { \ - class type *tqe_next; /* next element */ \ - class type **tqe_prev; /* address of previous next element */ \ -TRACEBUF \ -} - -/* -* Tail queue functions. -*/ -#if (defined(_KERNEL) && defined(INVARIANTS )) -/* -* QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME) -* -* If the tailq is non-empty, validates that the first element of the tailq -* points back at 'head.' -*/ -#define QMD_TAILQ_CHECK_HEAD (head, field) do { \ - if (!TAILQ_EMPTY(head) && \ - TAILQ_FIRST((head))->field.tqe_prev != \ - &TAILQ_FIRST((head))) \ - panic("Bad tailq head %p first->prev != head", (head)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME) -* -* Validates that the tail of the tailq is a pointer to pointer to NULL. -*/ -#define QMD_TAILQ_CHECK_TAIL (head, field) do { \ - if (*(head)->tqh_last != NULL) \ - panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME) -* -* If an element follows 'elm' in the tailq, validates that the next element -* points back at 'elm.' -*/ -#define QMD_TAILQ_CHECK_NEXT (elm, field) do { \ - if (TAILQ_NEXT((elm), field) != NULL && \ - TAILQ_NEXT((elm), field)->field.tqe_prev != \ - &((elm)->field.tqe_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME) -* -* Validates that the previous element (or head of the tailq) points to 'elm.' -*/ -#define QMD_TAILQ_CHECK_PREV (elm, field) do { \ - if (*(elm)->field.tqe_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#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) -#endif /* (_KERNEL && INVARIANTS) */ - -#define TAILQ_CONCAT (head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - QMD_TRACE_HEAD(head1); \ - QMD_TRACE_HEAD(head2); \ - } \ -} while (0) - -#define TAILQ_EMPTY (head) ((head)->tqh_first == NULL) - -#define TAILQ_FIRST (head) ((head)->tqh_first) - -#define TAILQ_FOREACH (var, head, field) \ - for ((var) = TAILQ_FIRST((head)); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE (var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_FROM (var, head, headname, field) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE (var, head, headname, field, tvar) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE_FROM_SAFE (var, head, headname, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_INIT (head) do { \ - TAILQ_FIRST((head)) = NULL; \ - (head)->tqh_last = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ -} while (0) - -#define TAILQ_INSERT_AFTER (head, listelm, elm, field) do { \ - QMD_TAILQ_CHECK_NEXT(listelm, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else { \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - } \ - TAILQ_NEXT((listelm), field) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&(listelm)->field); \ -} while (0) - -#define TAILQ_INSERT_BEFORE (listelm, elm, field) do { \ - QMD_TAILQ_CHECK_PREV(listelm, field); \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - TAILQ_NEXT((elm), field) = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&(listelm)->field); \ -} while (0) - -#define TAILQ_INSERT_HEAD (head, elm, field) do { \ - QMD_TAILQ_CHECK_HEAD(head, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ - TAILQ_FIRST((head))->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - TAILQ_FIRST((head)) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_INSERT_TAIL (head, elm, field) do { \ - QMD_TAILQ_CHECK_TAIL(head, field); \ - TAILQ_NEXT((elm), field) = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_LAST (head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) - -/* -* The FAST function is fast in that it causes no data access other -* then the access to the head. The standard LAST function above -* will cause a data access of both the element you want and -* the previous element. FAST is very useful for instances when -* you may want to prefetch the last data element. -*/ -#define TAILQ_LAST_FAST (head, type, field) \ - (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next)) - -#define TAILQ_NEXT (elm, field) ((elm)->field.tqe_next) - -#define TAILQ_PREV (elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#define TAILQ_PREV_FAST (elm, head, type, field) \ - ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ - __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) - -#define 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 ((TAILQ_NEXT((elm), field)) != NULL) \ - 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 = TAILQ_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_SWAP (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \ - QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \ - (head1)->tqh_first = (head2)->tqh_first; \ - (head1)->tqh_last = (head2)->tqh_last; \ - (head2)->tqh_first = swap_first; \ - (head2)->tqh_last = swap_last; \ - if ((swap_first = (head1)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head1)->tqh_first; \ - else \ - (head1)->tqh_last = &(head1)->tqh_first; \ - if ((swap_first = (head2)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head2)->tqh_first; \ - else \ - (head2)->tqh_last = &(head2)->tqh_first; \ -} while (0) - -#endif /* !_SYS_QUEUE_H_ */
Signature · 1 line
2.47.2
Re: [PATCH v2 43/43] eal: remove no longer used windows version of sys/queue.h
Quoted 856 lines · Stephen Hemminger
Superseded by common
rte_bsd_queue.hSigned-off-by Stephen Hemminger <[email protected]>--- lib/eal/windows/include/sys/queue.h | 840 ---------------------------- 1 file changed, 840 deletions(-) delete mode 100644 lib/eal/windows/include/sys/queue.hlib/eal/windows/include/sys/queue.h deleted +0
-840@@ -1,840 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause -* -* Copyright (c) 1991, 1993 -* The Regents of the University of California. All rights reserved. -*/ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -/* -* This file defines four types of data structures: singly-linked lists, -* singly-linked tail queues, lists and tail queues. -* -* A singly-linked list is headed by a single forward pointer. The elements -* are singly linked for minimum space and pointer manipulation overhead at -* the expense of O(n) removal for arbitrary elements. New elements can be -* added to the list after an existing element or at the head of the list. -* Elements being removed from the head of the list should use the explicit -* macro for this purpose for optimum efficiency. A singly-linked list may -* only be traversed in the forward direction. Singly-linked lists are ideal -* for applications with large datasets and few or no removals or for -* implementing a LIFO queue. -* -* A singly-linked tail queue is headed by a pair of pointers, one to the -* head of the list and the other to the tail of the list. The elements are -* singly linked for minimum space and pointer manipulation overhead at the -* expense of O(n) removal for arbitrary elements. New elements can be added -* to the list after an existing element, at the head of the list, or at the -* end of the list. Elements being removed from the head of the tail queue -* should use the explicit macro for this purpose for optimum efficiency. -* A singly-linked tail queue may only be traversed in the forward direction. -* Singly-linked tail queues are ideal for applications with large datasets -* and few or no removals or for implementing a FIFO queue. -* -* A list is headed by a single forward pointer (or an array of forward -* pointers for a hash table header). The elements are doubly linked -* so that an arbitrary element can be removed without a need to -* traverse the list. New elements can be added to the list before -* or after an existing element or at the head of the list. A list -* may be traversed in either direction. -* -* A tail queue is headed by a pair of pointers, one to the head of the -* list and the other to the tail of the list. The elements are doubly -* linked so that an arbitrary element can be removed without a need to -* traverse the list. New elements can be added to the list before or -* after an existing element, at the head of the list, or at the end of -* the list. A tail queue may be traversed in either direction. -* -* For details on the use of these macros, see the queue(3) manual page. -* -* Below is a summary of implemented functions where: -* + means the macro is available -* - means the macro is not available -* s means the macro is available but is slow (runs in O(n) time) -* -* SLIST LIST STAILQ TAILQ -* _HEAD + + + + -* _CLASS_HEAD + + + + -* _HEAD_INITIALIZER + + + + -* _ENTRY + + + + -* _CLASS_ENTRY + + + + -* _INIT + + + + -* _EMPTY + + + + -* _FIRST + + + + -* _NEXT + + + + -* _PREV - + - + -* _LAST - - + + -* _LAST_FAST - - - + -* _FOREACH + + + + -* _FOREACH_FROM + + + + -* _FOREACH_SAFE + + + + -* _FOREACH_FROM_SAFE + + + + -* _FOREACH_REVERSE - - - + -* _FOREACH_REVERSE_FROM - - - + -* _FOREACH_REVERSE_SAFE - - - + -* _FOREACH_REVERSE_FROM_SAFE - - - + -* _INSERT_HEAD + + + + -* _INSERT_BEFORE - + - + -* _INSERT_AFTER + + + + -* _INSERT_TAIL - - + + -* _CONCAT s s + + -* _REMOVE_AFTER + - + - -* _REMOVE_HEAD + - + - -* _REMOVE s + s + -* _SWAP + + + + -*/ -#ifdef QUEUE_MACRO_DEBUG -#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH -#define QUEUE_MACRO_DEBUG_TRACE -#define QUEUE_MACRO_DEBUG_TRASH -#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; -}; - -#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 */ - -#ifdef __cplusplus -/* -* In C++ there can be structure lists and class lists: -*/ -#define QUEUE_TYPEOF (type) type -#else -#define QUEUE_TYPEOF (type) struct type -#endif - -/* -* Singly-linked List declarations. -*/ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_CLASS_HEAD(name, type) \ -struct name { \ - class type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER (head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -#define SLIST_CLASS_ENTRY(type) \ -struct { \ - class type *sle_next; /* next element */ \ -} - -/* -* Singly-linked List functions. -*/ -#if (defined(_KERNEL) && defined(INVARIANTS )) -#define QMD_SLIST_CHECK_PREVPTR (prevp, elm) do { \ - if (*(prevp) != (elm)) \ - panic("Bad prevptr *(%p) == %p != %p", \ - (prevp), *(prevp), (elm)); \ -} while (0) -#else -#define QMD_SLIST_CHECK_PREVPTR (prevp, elm) -#endif - -#define SLIST_CONCAT (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ - if (curelm == NULL) { \ - if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \ - SLIST_INIT(head2); \ - } else if (SLIST_FIRST(head2) != NULL) { \ - while (SLIST_NEXT(curelm, field) != NULL) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ - SLIST_INIT(head2); \ - } \ -} while (0) - -#define SLIST_EMPTY (head) ((head)->slh_first == NULL) - -#define SLIST_FIRST (head) ((head)->slh_first) - -#define SLIST_FOREACH (var, head, field) \ - for ((var) = SLIST_FIRST((head)); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_PREVPTR (var, varp, head, field) \ - for ((varp) = &SLIST_FIRST((head)); \ - ((var) = *(varp)) != NULL; \ - (varp) = &SLIST_NEXT((var), field)) - -#define SLIST_INIT (head) do { \ - SLIST_FIRST((head)) = NULL; \ -} while (0) - -#define SLIST_INSERT_AFTER (slistelm, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ - SLIST_NEXT((slistelm), field) = (elm); \ -} while (0) - -#define SLIST_INSERT_HEAD (head, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ - SLIST_FIRST((head)) = (elm); \ -} while (0) - -#define SLIST_NEXT (elm, field) ((elm)->field.sle_next) - -#define SLIST_REMOVE (head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ - if (SLIST_FIRST((head)) == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \ - while (SLIST_NEXT(curelm, field) != (elm)) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_REMOVE_AFTER(curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define SLIST_REMOVE_AFTER (elm, field) do { \ - SLIST_NEXT(elm, field) = \ - SLIST_NEXT(SLIST_NEXT(elm, field), field); \ -} while (0) - -#define SLIST_REMOVE_HEAD (head, field) do { \ - SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ -} while (0) - -#define SLIST_REMOVE_PREVPTR (prevp, elm, field) do { \ - QMD_SLIST_CHECK_PREVPTR(prevp, elm); \ - *(prevp) = SLIST_NEXT(elm, field); \ - TRASHIT((elm)->field.sle_next); \ -} while (0) - -#define SLIST_SWAP (head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \ - SLIST_FIRST(head1) = SLIST_FIRST(head2); \ - SLIST_FIRST(head2) = swap_first; \ -} while (0) - -/* -* Singly-linked Tail queue declarations. -*/ -#define STAILQ_HEAD (name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ -struct type **stqh_last;/* addr of last next element */ \ -} - -#define STAILQ_CLASS_HEAD(name, type) \ -struct name { \ - class type *stqh_first; /* first element */ \ - class type **stqh_last; /* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -#define STAILQ_CLASS_ENTRY(type) \ -struct { \ - class type *stqe_next; /* next element */ \ -} - -/* -* Singly-linked Tail queue functions. -*/ -#define STAILQ_CONCAT (head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (0) - -#define STAILQ_EMPTY (head) ((head)->stqh_first == NULL) - -#define STAILQ_FIRST (head) ((head)->stqh_first) - -#define STAILQ_FOREACH (var, head, field) \ - for((var) = STAILQ_FIRST((head)); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_INIT (head) do { \ - STAILQ_FIRST((head)) = NULL; \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_INSERT_AFTER (head, tqelm, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_NEXT((tqelm), field) = (elm); \ -} while (0) - -#define STAILQ_INSERT_HEAD (head, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_FIRST((head)) = (elm); \ -} while (0) - -#define STAILQ_INSERT_TAIL (head, elm, field) do { \ - STAILQ_NEXT((elm), field) = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_LAST (head, type, field) \ - (STAILQ_EMPTY((head)) ? NULL : \ - __containerof((head)->stqh_last, \ - QUEUE_TYPEOF(type), field.stqe_next)) - -#define STAILQ_NEXT (elm, field) ((elm)->field.stqe_next) - -#define STAILQ_REMOVE (head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ - if (STAILQ_FIRST((head)) == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } \ - else { \ - QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \ - while (STAILQ_NEXT(curelm, field) != (elm)) \ - curelm = STAILQ_NEXT(curelm, field); \ - STAILQ_REMOVE_AFTER(head, curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define STAILQ_REMOVE_AFTER (head, elm, field) do { \ - if ((STAILQ_NEXT(elm, field) = \ - STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_REMOVE_HEAD (head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_SWAP (head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \ - QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \ - STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_FIRST(head2) = swap_first; \ - (head2)->stqh_last = swap_last; \ - if (STAILQ_EMPTY(head1)) \ - (head1)->stqh_last = &STAILQ_FIRST(head1); \ - if (STAILQ_EMPTY(head2)) \ - (head2)->stqh_last = &STAILQ_FIRST(head2); \ -} while (0) - - -/* -* List declarations. -*/ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_CLASS_HEAD(name, type) \ -struct name { \ - class type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER (head) \ - { NULL } - -#define LIST_ENTRY (type) \ -struct { \ - struct type *le_next;/* next element */ \ -struct type **le_prev;/* address of previous next element */ \ -} - -#define LIST_CLASS_ENTRY(type) \ -struct { \ - class type *le_next; /* next element */ \ - class type **le_prev; /* address of previous next element */ \ -} - -/* -* List functions. -*/ - -#if (defined(_KERNEL) && defined(INVARIANTS )) -/* -* QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME) -* -* If the list is non-empty, validates that the first element of the list -* points back at 'head.' -*/ -#define QMD_LIST_CHECK_HEAD (head, field) do { \ - if (LIST_FIRST((head)) != NULL && \ - LIST_FIRST((head))->field.le_prev != \ - &LIST_FIRST((head))) \ - panic("Bad list head %p first->prev != head", (head)); \ -} while (0) - -/* -* QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME) -* -* If an element follows 'elm' in the list, validates that the next element -* points back at 'elm.' -*/ -#define QMD_LIST_CHECK_NEXT (elm, field) do { \ - if (LIST_NEXT((elm), field) != NULL && \ - LIST_NEXT((elm), field)->field.le_prev != \ - &((elm)->field.le_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -/* -* QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME) -* -* Validates that the previous element (or head of the list) points to 'elm.' -*/ -#define QMD_LIST_CHECK_PREV (elm, field) do { \ - if (*(elm)->field.le_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#define QMD_LIST_CHECK_HEAD (head, field) -#define QMD_LIST_CHECK_NEXT (elm, field) -#define QMD_LIST_CHECK_PREV (elm, field) -#endif /* (_KERNEL && INVARIANTS) */ - -#define LIST_CONCAT (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \ - if (curelm == NULL) { \ - if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \ - LIST_FIRST(head2)->field.le_prev = \ - &LIST_FIRST((head1)); \ - LIST_INIT(head2); \ - } \ - } else if (LIST_FIRST(head2) != NULL) { \ - while (LIST_NEXT(curelm, field) != NULL) \ - curelm = LIST_NEXT(curelm, field); \ - LIST_NEXT(curelm, field) = LIST_FIRST(head2); \ - LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \ - LIST_INIT(head2); \ - } \ -} while (0) - -#define LIST_EMPTY (head) ((head)->lh_first == NULL) - -#define LIST_FIRST (head) ((head)->lh_first) - -#define LIST_FOREACH (var, head, field) \ - for ((var) = LIST_FIRST((head)); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_INIT (head) do { \ - LIST_FIRST((head)) = NULL; \ -} while (0) - -#define LIST_INSERT_AFTER (listelm, elm, field) do { \ - QMD_LIST_CHECK_NEXT(listelm, field); \ - if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ - LIST_NEXT((listelm), field)->field.le_prev = \ - &LIST_NEXT((elm), field); \ - LIST_NEXT((listelm), field) = (elm); \ - (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ -} while (0) - -#define LIST_INSERT_BEFORE (listelm, elm, field) do { \ - QMD_LIST_CHECK_PREV(listelm, field); \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - LIST_NEXT((elm), field) = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ -} while (0) - -#define LIST_INSERT_HEAD (head, elm, field) do { \ - QMD_LIST_CHECK_HEAD((head), field); \ - if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ - LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ - LIST_FIRST((head)) = (elm); \ - (elm)->field.le_prev = &LIST_FIRST((head)); \ -} while (0) - -#define LIST_NEXT (elm, field) ((elm)->field.le_next) - -#define LIST_PREV (elm, head, type, field) \ - ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ - __containerof((elm)->field.le_prev, \ - QUEUE_TYPEOF(type), field.le_next)) - -#define LIST_REMOVE (elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.le_next); \ - QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ - QMD_LIST_CHECK_NEXT(elm, field); \ - QMD_LIST_CHECK_PREV(elm, field); \ - if (LIST_NEXT((elm), field) != NULL) \ - LIST_NEXT((elm), field)->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = LIST_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ -} while (0) - -#define LIST_SWAP (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \ - LIST_FIRST((head1)) = LIST_FIRST((head2)); \ - LIST_FIRST((head2)) = swap_tmp; \ - if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ - if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ -} while (0) - -/* -* Tail queue declarations. -*/ -#define TAILQ_HEAD (name, type) \ -struct name { \ - struct type *tqh_first;/* first element */ \ -struct type **tqh_last;/* addr of last next element */ \ - TRACEBUF \ -} - -#define TAILQ_CLASS_HEAD(name, type) \ -struct name { \ - class type *tqh_first; /* first element */ \ - class type **tqh_last; /* addr of last next element */ \ -TRACEBUF \ -} - -#define TAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } - -#define TAILQ_ENTRY (type) \ -struct { \ - struct type *tqe_next;/* next element */ \ -struct type **tqe_prev;/* address of previous next element */ \ - TRACEBUF \ -} - -#define TAILQ_CLASS_ENTRY(type) \ -struct { \ - class type *tqe_next; /* next element */ \ - class type **tqe_prev; /* address of previous next element */ \ -TRACEBUF \ -} - -/* -* Tail queue functions. -*/ -#if (defined(_KERNEL) && defined(INVARIANTS )) -/* -* QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME) -* -* If the tailq is non-empty, validates that the first element of the tailq -* points back at 'head.' -*/ -#define QMD_TAILQ_CHECK_HEAD (head, field) do { \ - if (!TAILQ_EMPTY(head) && \ - TAILQ_FIRST((head))->field.tqe_prev != \ - &TAILQ_FIRST((head))) \ - panic("Bad tailq head %p first->prev != head", (head)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME) -* -* Validates that the tail of the tailq is a pointer to pointer to NULL. -*/ -#define QMD_TAILQ_CHECK_TAIL (head, field) do { \ - if (*(head)->tqh_last != NULL) \ - panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME) -* -* If an element follows 'elm' in the tailq, validates that the next element -* points back at 'elm.' -*/ -#define QMD_TAILQ_CHECK_NEXT (elm, field) do { \ - if (TAILQ_NEXT((elm), field) != NULL && \ - TAILQ_NEXT((elm), field)->field.tqe_prev != \ - &((elm)->field.tqe_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME) -* -* Validates that the previous element (or head of the tailq) points to 'elm.' -*/ -#define QMD_TAILQ_CHECK_PREV (elm, field) do { \ - if (*(elm)->field.tqe_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#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) -#endif /* (_KERNEL && INVARIANTS) */ - -#define TAILQ_CONCAT (head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - QMD_TRACE_HEAD(head1); \ - QMD_TRACE_HEAD(head2); \ - } \ -} while (0) - -#define TAILQ_EMPTY (head) ((head)->tqh_first == NULL) - -#define TAILQ_FIRST (head) ((head)->tqh_first) - -#define TAILQ_FOREACH (var, head, field) \ - for ((var) = TAILQ_FIRST((head)); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE (var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_FROM (var, head, headname, field) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE (var, head, headname, field, tvar) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE_FROM_SAFE (var, head, headname, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_INIT (head) do { \ - TAILQ_FIRST((head)) = NULL; \ - (head)->tqh_last = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ -} while (0) - -#define TAILQ_INSERT_AFTER (head, listelm, elm, field) do { \ - QMD_TAILQ_CHECK_NEXT(listelm, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else { \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - } \ - TAILQ_NEXT((listelm), field) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&(listelm)->field); \ -} while (0) - -#define TAILQ_INSERT_BEFORE (listelm, elm, field) do { \ - QMD_TAILQ_CHECK_PREV(listelm, field); \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - TAILQ_NEXT((elm), field) = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&(listelm)->field); \ -} while (0) - -#define TAILQ_INSERT_HEAD (head, elm, field) do { \ - QMD_TAILQ_CHECK_HEAD(head, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ - TAILQ_FIRST((head))->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - TAILQ_FIRST((head)) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_INSERT_TAIL (head, elm, field) do { \ - QMD_TAILQ_CHECK_TAIL(head, field); \ - TAILQ_NEXT((elm), field) = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_LAST (head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) - -/* -* The FAST function is fast in that it causes no data access other -* then the access to the head. The standard LAST function above -* will cause a data access of both the element you want and -* the previous element. FAST is very useful for instances when -* you may want to prefetch the last data element. -*/ -#define TAILQ_LAST_FAST (head, type, field) \ - (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next)) - -#define TAILQ_NEXT (elm, field) ((elm)->field.tqe_next) - -#define TAILQ_PREV (elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#define TAILQ_PREV_FAST (elm, head, type, field) \ - ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ - __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) - -#define 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 ((TAILQ_NEXT((elm), field)) != NULL) \ - 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 = TAILQ_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_SWAP (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \ - QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \ - (head1)->tqh_first = (head2)->tqh_first; \ - (head1)->tqh_last = (head2)->tqh_last; \ - (head2)->tqh_first = swap_first; \ - (head2)->tqh_last = swap_last; \ - if ((swap_first = (head1)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head1)->tqh_first; \ - else \ - (head1)->tqh_last = &(head1)->tqh_first; \ - if ((swap_first = (head2)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head2)->tqh_first; \ - else \ - (head2)->tqh_last = &(head2)->tqh_first; \ -} while (0) - -#endif /* !_SYS_QUEUE_H_ */ Signature · 1 line
2.47.2
v3 cover Cuckoo hash cleanup and optimizations
In reply to Stephen HemmingerRecent discussion around handling small keys motivated furthur examination of the compare logic.
Stephen Hemminger (4):
hash: move table of hash compare functions out of header
hash: use static_assert
hash: reduce architecture special cases
hash: add support for common small key sizes
v3 - review feedback
app/test/test_hash.c | 4 +- lib/hash/rte_cmp_arm64.h | 56 +-------- lib/hash/rte_cmp_generic.h | 35 ++++++ lib/hash/rte_cmp_x86.h | 60 +--------- lib/hash/rte_cuckoo_hash.c | 238 +++++++++++++++++++++++++++++++++++-- lib/hash/rte_cuckoo_hash.h | 84 +------------ 6 files changed, 275 insertions(+), 202 deletions(-) create mode 100644 lib/hash/rte_cmp_generic.h
Signature · 1 line
2.47.2
PATCH v3 1/4 hash: move table of hash compare functions out of header
Remove the definition of the compare jump table from the header file so the internal details are not exposed. Prevents future ABI breakage if new sizes are added.
Make other macros local if possible, header should only contain exposed API.
--- lib/hash/rte_cuckoo_hash.c | 74 ++++++++++++++++++++++++++++++----- lib/hash/rte_cuckoo_hash.h | 79 +------------------------------------- 2 files changed, 65 insertions(+), 88 deletions(-)
lib/hash/rte_cuckoo_hash.c +64 -10
@@ -25,14 +25,51 @@#include <rte_tailq.h> #include "rte_hash.h" +#include "rte_cuckoo_hash.h" -/* needs to be before rte_cuckoo_hash.h */ RTE_LOG_REGISTER_DEFAULT (hash_logtype,INFO );#define RTE_LOGTYPE_HASH hash_logtype#define HASH_LOG (level, ...) \ RTE_LOG_LINE(level, HASH, "" __VA_ARGS__) -#include "rte_cuckoo_hash.h" +/* Macro to enable/disable run-time checking of function parameters */ +#if defined(RTE_LIBRTE_HASH_DEBUG ) +#define RETURN_IF_TRUE (cond, retval) do { \ + if (cond) \ + return retval; \ +} while (0) +#else +#define RETURN_IF_TRUE (cond, retval) +#endif + +#if defined(RTE_ARCH_X86 ) +#include "rte_cmp_x86.h" +#endif + +#if defined(RTE_ARCH_ARM64 ) +#include "rte_cmp_arm64.h" +#endif + +/* +* All different options to select a key compare function, +* based on the key size and custom function. +* Not in rte_cuckoo_hash.h to avoid ABI issues. +*/ +enum cmp_jump_table_case { +KEY_CUSTOM =0 , +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +KEY_16_BYTES , +KEY_32_BYTES , +KEY_48_BYTES , +KEY_64_BYTES , +KEY_80_BYTES , +KEY_96_BYTES , +KEY_112_BYTES , +KEY_128_BYTES , +#endif +KEY_OTHER_BYTES , +NUM_KEY_CMP_CASES , +};/* Enum used to select the implementation of the signature comparison function to use * eg: a system supporting SVE might want to use a NEON or scalar implementation.
@@ -117,6 +154,25 @@ void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func) h->rte_hash_custom_cmp_eq = func; } +/* +* Table storing all different key compare functions +* (multi-process supported) +*/ +static const rte_hash_cmp_eq_t cmp_jump_table[NUM_KEY_CMP_CASES ] = { + [KEY_CUSTOM ] =NULL , +#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64) + [KEY_16_BYTES ] = rte_hash_k16_cmp_eq, + [KEY_32_BYTES ] = rte_hash_k32_cmp_eq, + [KEY_48_BYTES ] = rte_hash_k48_cmp_eq, + [KEY_64_BYTES ] = rte_hash_k64_cmp_eq, + [KEY_80_BYTES ] = rte_hash_k80_cmp_eq, + [KEY_96_BYTES ] = rte_hash_k96_cmp_eq, + [KEY_112_BYTES ] = rte_hash_k112_cmp_eq, + [KEY_128_BYTES ] = rte_hash_k128_cmp_eq, +#endif + [KEY_OTHER_BYTES ] = memcmp, +}; +static inline int rte_hash_cmp_eq (const void *key1,const void *key2,const struct rte_hash *h) {
@@ -390,13 +446,13 @@ rte_hash_create(const struct rte_hash_parameters *params) goto err_unlock; } -/* -* If x86 architecture is used, select appropriate compare function, -* which may use x86 intrinsics, otherwise use memcmp -*/ -#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 )/* Select function to compare keys */ switch (params->key_len) { +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +/* +* If x86 architecture is used, select appropriate compare function, +* which may use x86 intrinsics, otherwise use memcmp +*/ case 16 : h->cmp_jump_table_idx =KEY_16_BYTES ;break ;
@@ -421,13 +477,11 @@ rte_hash_create(const struct rte_hash_parameters *params)case 128 : h->cmp_jump_table_idx =KEY_128_BYTES ;break ; +#endif default :/* If key is not multiple of 16, use generic memcmp */ h->cmp_jump_table_idx =KEY_OTHER_BYTES ; } -#else - h->cmp_jump_table_idx =KEY_OTHER_BYTES ; -#endif if (use_local_cache) { local_free_slots = rte_zmalloc_socket(NULL,
lib/hash/rte_cuckoo_hash.h +1 -78
94 lines not on this page · raw message
Signature · 1 line
2.47.2
PATCH v3 2/4 hash: use static_assert
In reply to Stephen HemmingerNow that static_assert is available, better than pre-processor use of #if condition.
--- lib/hash/rte_cuckoo_hash.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/hash/rte_cuckoo_hash.h +2 -3
@@ -24,9 +24,8 @@*/ #define RTE_HASH_BUCKET_ENTRIES 8 -#if !RTE_IS_POWER_OF_2 (RTE_HASH_BUCKET_ENTRIES ) -#error RTE_HASH_BUCKET_ENTRIES must be a power of 2 -#endif +static_assert (RTE_IS_POWER_OF_2 (RTE_HASH_BUCKET_ENTRIES ), +"RTE_HASH_BUCKET_ENTRIES must be a power of 2" );#define NULL_SIGNATURE 0
Signature · 1 line
2.47.2
PATCH v3 3/4 hash: reduce architecture special cases
In reply to Stephen HemmingerMake comparison of sizes compatible across platforms. Keep the special case code for 16 bytes for x86 and arm64 but also add simple xor for others.
Need to keep rte_hash_k32_cmp_eq() exposed because ip_frag code poaches it.
--- lib/hash/rte_cmp_arm64.h | 56 +------------------------ lib/hash/rte_cmp_generic.h | 35 ++++++++++++++++ lib/hash/rte_cmp_x86.h | 60 ++------------------------ lib/hash/rte_cuckoo_hash.c | 86 +++++++++++++++++++++++++++++++++----- 4 files changed, 116 insertions(+), 121 deletions(-) create mode 100644 lib/hash/rte_cmp_generic.h
lib/hash/rte_cmp_arm64.h +2 -54
@@ -2,7 +2,7 @@* Copyright(c) 2015 Cavium, Inc */ -/* Functions to compare multiple of 16 byte keys (up to 128 bytes) */ +/* Functions to compare multiple of 16 byte keys */ static inline int rte_hash_k16_cmp_eq (const void *key1,const void *key2, size_t key_len __rte_unused)
@@ -27,59 +27,7 @@ rte_hash_k16_cmp_eq(const void *key1, const void *key2,static inline int rte_hash_k32_cmp_eq (const void *key1,const void *key2,size_t key_len) { -return rte_hash_k16_cmp_eq (key1, key2, key_len) || +return rte_hash_k16_cmp_eq (key1, key2, key_len) |rte_hash_k16_cmp_eq ((const char *) key1 +16 , (const char *) key2 +16 , key_len); } - -static inline int -rte_hash_k48_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k16_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +16 , - (const char *) key2 +16 , key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +32 , - (const char *) key2 +32 , key_len); -} - -static inline int -rte_hash_k64_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k32_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +32 , - (const char *) key2 +32 , key_len); -} - -static inline int -rte_hash_k80_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); -} - -static inline int -rte_hash_k96_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); -} - -static inline int -rte_hash_k112_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +96 , - (const char *) key2 +96 , key_len); -} - -static inline int -rte_hash_k128_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k64_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); -}
lib/hash/rte_cmp_generic.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2025 Stephen Hemminger +*/ + +#ifndef _RTE_CMP_GENERIC_H_ +#define _RTE_CMP_GENERIC_H_ + +/* Function to compare 16 byte keys */ +static inline int +rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused) +{ +#ifdef RTE_ARCH_64 +const unaligned_uint64_t *k1 = key1; +const unaligned_uint64_t *k2 = key2; + +return ((k1[0 ] ^ k2[0 ]) | (k1[1 ] ^ k2[1 ])) !=0 ; +#else +const unaligned_uint32_t *k1 = key1; +const unaligned_uint32_t *k2 = key2; + +return (k1[0 ] ^ k2[0 ]) | (k1[1 ] ^ k2[1 ]) | + (k1[2 ] ^ k2[2 ]) | (k1[3 ] ^ k2[3 ]); +#endif +} + +/* Function to compare 32 byte keys */ +static inline int +rte_hash_k32_cmp_eq (const void *key1,const void *key2,size_t key_len) +{ +return rte_hash_k16_cmp_eq (key1, key2, key_len) | +rte_hash_k16_cmp_eq ((const uint8_t *) key1 +16 , + (const uint8_t *) key2 +16 , key_len); +} + +#endif
lib/hash/rte_cmp_x86.h +4 -56
70 lines not on this page · raw message
lib/hash/rte_cuckoo_hash.c +75 -11
120 lines not on this page · raw message
Signature · 1 line
2.47.2
RE: [PATCH v3 3/4] hash: reduce architecture special cases
Quoted 7 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, 26 August 2025 16.49Make comparison of sizes compatible across platforms. Keep the special case code for 16 bytes for x86 and arm64 but also add simple xor for others.
Quoted 5 lines
Need to keep
rte_hash_k32_cmp_eq()exposed becauseip_fragcode poaches it.Signed-off-by Stephen Hemminger <[email protected]>---
LGTM now.
PATCH v3 4/4 hash: add support for common small key sizes
In reply to Stephen HemmingerAdd new compare functions for common small key sizes.
Bugzilla ID: 1775
--- app/test/test_hash.c | 4 +- lib/hash/rte_cuckoo_hash.c | 100 +++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-)
app/test/test_hash.c +3 -1
@@ -35,7 +35,9 @@*/ static rte_hash_function hashtest_funcs[] = {rte_jhash, rte_hash_crc};static uint32_t hashtest_initvals[] = {0 }; -static uint32_t hashtest_key_lens[] = {0 ,2 ,4 ,5 ,6 ,7 ,8 ,10 ,11 ,15 ,16 ,21 ,31 ,32 ,33 ,63 ,64 }; +static uint32_t hashtest_key_lens[] = { +0 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,10 ,11 ,12 ,14 ,15 ,16 ,21 ,31 ,32 ,33 ,63 ,64 +};#define MAX_KEYSIZE 64/******************************************************************************/ #define LOCAL_FBK_HASH_ENTRIES_MAX (1 << 15)
lib/hash/rte_cuckoo_hash.c +100 -0
118 lines not on this page · raw message
Signature · 1 line
2.47.2
RE: [PATCH v3 4/4] hash: add support for common small key sizes
Quoted 11 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, 26 August 2025 16.49Add new compare functions for common small key sizes.
Bugzilla ID: 1775
Suggested-by Morten Brørup <[email protected]>Reported-by Mattias Rönnblom <[email protected]>Signed-off-by Stephen Hemminger <[email protected]>---
v3 cover introduce _SAFE variants of queue macros
In reply to Stephen HemmingerThis patchset cleans up the queue.h macro problems in DPDK. The root cause is that sys/queue.h in Linux is an old version from early BSD; my best guess is that it is a BSD GPL license issue that it never got updated. The Linux version is missing several useful macros which leads to redefiniton, bugs, etc.
The patch starts out by introducing a version of the current FreeBSD queue.h named as bsd_queue.h, then uses it across all of DPDK. The file sys/queue.h is no longer used. Ends up doing one line change on lots of files.
The patch fixes a couple of use after free cases in existing drivers. May require some manual effort to backport but not that hard.
v3 - rebase
- fix netvsc
Stephen Hemminger (44):
net/nfp: fix use after free
eal: add BSD version of queue.h
test: remove unnecessary inclusion of sys/queue.h
test-pipeline: remove unnecessary use of sys/queue.h
test-eventdev: use rte_bsd_queue.h
test-bbdev, test-cmdline, test-mldev: don't use sys/queue.h app/testpmd: use rte_bsd_queue.h
apps: use rte_bsd_queue.h
examples: replace use of sys/queue.h
ethdev: replace use of sys/queue.h
lib: remove use of sys/queue.h
drivers/bus: replace use of sys/queue.h
net/nfp: use rte_bsd_queue.h
net/qede: use rte_bsd_queue.h
net/bnxt: remove use of sys/queue.h
net/intel: remove use of sys/queue.h
net/mlx5: remove unnecessary include of sys/queue.h net/mlx4: replace use of sys/queue.h
net/tap: remove unnecessary include of sys/queue.h net/axgbe: replace use of sys/queue.h
net/bnx2x: replace use of sys/queue.h net/bonding: replace use of sys/queue.h net/cxgbe: replace use of sys/queue.h
net/enic: replace use of sys/queue.h net/failsafe: replace use of sys/queue.h net/memif: replace use of sys/queue.h
net/ngbe: replace use of sys/queue.h
net/ntnic: replace use of sys/queue.h
net/sfc: replace use of sys/queue.h
net/softnic: replace use of sys/queue.h net/thunderx: replace use of sys/queue.h net/txgbe: replace use of sys/queue.h net/vdev_netvsc: replace use of sys/queue.h net/vmxnet3: replace use of sys/queue.h
net/zxdh: replace use of sys/queue.h
net/dpaa2: replace use of sys/queue.h
net/mvpp2: replace local definition of FOREACH_SAFE raw/ifpga: replace with TAILQ_FOREACH_SAFE drivers/vdpa: replace use of sys/queue.h drivers/common: remove use of sys/queue.h drivers/crypto: remove use of sys_queue.h drivers/event: remove include of sys/queue.h
eal: remove no longer used windows version of sys/queue.h net/netvsc: use LIST_FOREACH_SAFE
app/dumpcap/main.c | 2 +-
app/proc-info/main.c | 1 -
app/test-bbdev/main.h | 1 -
app/test-cmdline/cmdline_test.c | 1 -
app/test-eventdev/evt_test.c | 2 +-
app/test-eventdev/evt_test.h | 1 -
app/test-mldev/ml_test.h | 1 -
app/test-pipeline/config.c | 1 -
app/test-pipeline/init.c | 1 -
app/test-pipeline/main.c | 1 -
app/test-pipeline/runtime.c | 1 -
app/test-pmd/5tswap.c | 2 -
app/test-pmd/cmdline.c | 2 +-
app/test-pmd/config.c | 2 +-
app/test-pmd/csumonly.c | 1 -
app/test-pmd/flowgen.c | 1 -
app/test-pmd/hairpin.c | 1 -
app/test-pmd/icmpecho.c | 1 -
app/test-pmd/iofwd.c | 1 -
app/test-pmd/macfwd.c | 1 -
app/test-pmd/macswap.c | 1 -
app/test-pmd/noisy_vnf.c | 1 -
app/test-pmd/parameters.c | 1 -
app/test-pmd/rxonly.c | 1 -
app/test-pmd/testpmd.c | 1 -
app/test-pmd/testpmd.h | 2 +-
app/test-pmd/txonly.c | 1 -
app/test/commands.c | 2 +-
app/test/test.c | 1 -
app/test/test.h | 2 +-
app/test/test_atomic.c | 1 -
app/test/test_cmdline_lib.c | 1 -
app/test/test_func_reentrancy.c | 1 -
app/test/test_hash.c | 1 -
app/test/test_hash_functions.c | 1 -
app/test/test_link_bonding.c | 1 -
app/test/test_link_bonding_mode4.c | 1 -
app/test/test_link_bonding_rssconf.c | 1 -
app/test/test_logs.c | 1 -
app/test/test_malloc.c | 1 -
app/test/test_mbuf.c | 1 -
app/test/test_mcslock.c | 1 -
app/test/test_mempool.c | 1 -
app/test/test_mempool_perf.c | 1 -
app/test/test_memzone.c | 1 -
app/test/test_mp_secondary.c | 1 -
app/test/test_per_lcore.c | 1 -
app/test/test_pflock.c | 1 -
app/test/test_ring.c | 1 -
app/test/test_rwlock.c | 1 -
app/test/test_soring.c | 1 -
app/test/test_spinlock.c | 1 -
app/test/test_tailq.c | 1 -
app/test/test_ticketlock.c | 1 -
app/test/test_timer.c | 1 -
doc/guides/contributing/coding_style.rst | 4 +-
doc/guides/rel_notes/release_25_11.rst | 3 +
drivers/bus/auxiliary/auxiliary_common.c | 2 +-
drivers/bus/auxiliary/private.h | 2 +-
drivers/bus/fslmc/bus_fslmc_driver.h | 1 -
drivers/bus/fslmc/fslmc_vfio.c | 1 +
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 11 +-
drivers/bus/ifpga/ifpga_bus.c | 2 +-
drivers/bus/pci/bsd/pci.c | 2 +-
drivers/bus/pci/pci_common.c | 1 -
drivers/bus/pci/pci_params.c | 2 -
drivers/bus/pci/windows/pci.c | 3 +-
drivers/bus/pci/windows/pci_netuio.c | 2 -
drivers/bus/platform/platform.c | 2 +-
drivers/bus/vdev/vdev.c | 1 -
drivers/bus/vmbus/vmbus_common.c | 1 -
drivers/common/cnxk/roc_bphy_irq.c | 3 +-
drivers/common/cnxk/roc_npc.h | 2 -
drivers/common/mlx5/mlx5_common_mr.h | 3 +-
drivers/crypto/bcmfs/bcmfs_device.c | 2 +-
drivers/crypto/bcmfs/bcmfs_device.h | 2 -
drivers/crypto/ccp/ccp_crypto.c | 1 -
drivers/crypto/ccp/ccp_dev.c | 2 +-
drivers/event/dlb2/dlb2_selftest.c | 1 -
drivers/event/opdl/opdl_test.c | 1 -
drivers/event/sw/sw_evdev_selftest.c | 1 -
drivers/net/axgbe/axgbe_common.h | 1 -
drivers/net/bnx2x/bnx2x_ethdev.h | 1 -
drivers/net/bnxt/bnxt.h | 1 -
drivers/net/bnxt/bnxt_filter.c | 7 +-
drivers/net/bnxt/bnxt_flow.c | 1 -
drivers/net/bnxt/bnxt_vnic.h | 1 -
drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 1 -
drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c | 1 -
drivers/net/bonding/eth_bond_private.h | 1 -
drivers/net/bonding/rte_eth_bond_flow.c | 1 -
drivers/net/cxgbe/cxgbe_ethdev.c | 2 +-
drivers/net/cxgbe/cxgbe_main.c | 1 -
drivers/net/cxgbe/sge.c | 1 -
drivers/net/dpaa2/dpaa2_flow.c | 1 -
drivers/net/dpaa2/dpaa2_mux.c | 1 -
drivers/net/dpaa2/dpaa2_ptp.c | 1 -
drivers/net/enic/enic.h | 1 -
drivers/net/failsafe/failsafe_flow.c | 1 -
drivers/net/failsafe/failsafe_private.h | 2 +-
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c | 1 -
drivers/net/intel/e1000/e1000_ethdev.h | 1 -
drivers/net/intel/e1000/em_ethdev.c | 1 -
drivers/net/intel/e1000/em_rxtx.c | 1 -
drivers/net/intel/e1000/igb_ethdev.c | 2 +-
drivers/net/intel/e1000/igb_flow.c | 2 +-
drivers/net/intel/e1000/igb_rxtx.c | 1 -
drivers/net/intel/i40e/i40e_ethdev.c | 9 +-
drivers/net/intel/i40e/i40e_ethdev.h | 1 -
drivers/net/intel/i40e/i40e_fdir.c | 2 +-
drivers/net/intel/i40e/i40e_flow.c | 1 -
drivers/net/intel/i40e/i40e_hash.c | 1 -
drivers/net/intel/i40e/i40e_pf.c | 1 -
drivers/net/intel/i40e/i40e_rxtx.c | 1 -
drivers/net/intel/iavf/iavf.h | 1 -
drivers/net/intel/iavf/iavf_ethdev.c | 1 -
drivers/net/intel/iavf/iavf_fdir.c | 1 -
drivers/net/intel/iavf/iavf_fsub.c | 1 -
drivers/net/intel/iavf/iavf_generic_flow.c | 1 -
drivers/net/intel/iavf/iavf_hash.c | 1 -
drivers/net/intel/iavf/iavf_rxtx.c | 1 -
drivers/net/intel/iavf/iavf_vchnl.c | 7 -
drivers/net/intel/ice/base/ice_osdep.h | 2 +-
drivers/net/intel/ice/ice_acl_filter.c | 1 -
drivers/net/intel/ice/ice_dcf.c | 2 +-
drivers/net/intel/ice/ice_dcf_ethdev.c | 1 -
drivers/net/intel/ice/ice_ethdev.c | 8 +-
drivers/net/intel/ice/ice_generic_flow.c | 1 -
drivers/net/intel/ice/ice_hash.c | 1 -
drivers/net/intel/ice/ice_switch_filter.c | 1 -
drivers/net/intel/idpf/base/idpf_osdep.h | 9 +-
drivers/net/intel/ipn3ke/ipn3ke_ethdev.h | 1 -
drivers/net/intel/ipn3ke/ipn3ke_flow.c | 1 -
drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +-
drivers/net/intel/ixgbe/ixgbe_ethdev.h | 1 -
drivers/net/intel/ixgbe/ixgbe_fdir.c | 2 +-
drivers/net/intel/ixgbe/ixgbe_flow.c | 2 +-
drivers/net/intel/ixgbe/ixgbe_rxtx.c | 1 -
drivers/net/memif/memif_socket.h | 1 -
drivers/net/memif/rte_eth_memif.h | 1 -
drivers/net/mlx4/mlx4.h | 1 -
drivers/net/mlx4/mlx4_flow.c | 2 +-
drivers/net/mlx4/mlx4_flow.h | 1 -
drivers/net/mlx4/mlx4_mr.h | 1 -
drivers/net/mlx4/mlx4_rxtx.h | 1 -
drivers/net/mlx5/hws/mlx5dr_internal.h | 1 -
drivers/net/mlx5/linux/mlx5_verbs.c | 1 -
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_devx.c | 1 -
drivers/net/mlx5/mlx5_flow.c | 2 +-
drivers/net/mlx5/mlx5_flow.h | 2 +-
drivers/net/mlx5/mlx5_flow_dv.c | 1 -
drivers/net/mlx5/mlx5_flow_verbs.c | 2 +-
drivers/net/mlx5/mlx5_rx.h | 1 -
drivers/net/mlx5/mlx5_rxq.c | 2 +-
drivers/net/mlx5/mlx5_rxtx.h | 1 -
drivers/net/mlx5/mlx5_tx.h | 1 -
drivers/net/mvpp2/mrvl_mtr.c | 8 +-
drivers/net/netvsc/hn_ethdev.c | 4 +-
drivers/net/nfp/nfp_mtr.c | 12 +-
drivers/net/nfp/nfp_mtr.h | 1 +
drivers/net/ngbe/ngbe_ethdev_vf.c | 1 -
drivers/net/ngbe/ngbe_rxtx.c | 1 -
drivers/net/ntnic/ntnic_ethdev.c | 2 -
drivers/net/qede/qede_ethdev.h | 3 +-
drivers/net/qede/qede_filter.c | 6 -
drivers/net/sfc/sfc_dp.c | 2 +-
drivers/net/sfc/sfc_dp.h | 1 -
.../net/softnic/rte_eth_softnic_internals.h | 1 -
drivers/net/tap/rte_eth_tap.h | 1 -
drivers/net/tap/tap_flow.c | 1 -
drivers/net/thunderx/base/nicvf_bsvf.h | 2 +-
drivers/net/thunderx/base/nicvf_plat.h | 1 +
drivers/net/thunderx/nicvf_ethdev.c | 1 -
drivers/net/txgbe/txgbe_ethdev_vf.c | 1 -
drivers/net/txgbe/txgbe_fdir.c | 2 +-
drivers/net/txgbe/txgbe_flow.c | 2 +-
drivers/net/txgbe/txgbe_rxtx.c | 1 -
drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +-
drivers/net/vmxnet3/vmxnet3_ethdev.c | 1 -
drivers/net/vmxnet3/vmxnet3_rxtx.c | 1 -
drivers/net/zxdh/zxdh_mtr.h | 1 -
drivers/raw/ifpga/base/ifpga_enumerate.c | 6 +-
drivers/raw/ifpga/base/opae_hw_api.h | 1 -
drivers/raw/ifpga/base/opae_intel_max10.c | 8 +-
.../raw/ifpga/base/osdep_rte/osdep_generic.h | 1 +
drivers/vdpa/mlx5/mlx5_vdpa.h | 3 +-
drivers/vdpa/sfc/sfc_vdpa.c | 2 +-
drivers/vdpa/sfc/sfc_vdpa.h | 2 +-
examples/bbdev_app/main.c | 2 +-
examples/bond/main.c | 2 +-
examples/cmdline/main.c | 1 -
examples/cmdline/parse_obj_list.h | 2 +-
examples/flow_filtering/main.c | 1 -
examples/helloworld/main.c | 2 +-
examples/ip_fragmentation/main.c | 2 +-
examples/ip_pipeline/action.h | 2 +-
examples/ip_pipeline/cryptodev.h | 2 +-
examples/ip_pipeline/link.h | 2 +-
examples/ip_pipeline/mempool.h | 2 +-
examples/ip_pipeline/pipeline.h | 2 +-
examples/ip_pipeline/swq.h | 2 +-
examples/ip_pipeline/tap.h | 2 +-
examples/ip_pipeline/tmgr.h | 2 +-
examples/ip_reassembly/main.c | 2 +-
examples/ipsec-secgw/ipsec-secgw.c | 2 +-
examples/ipv4_multicast/main.c | 2 +-
examples/l2fwd-crypto/main.c | 2 +-
examples/l2fwd-event/l2fwd_common.h | 1 -
examples/l2fwd-keepalive/ka-agent/main.c | 1 -
examples/l2fwd-keepalive/main.c | 2 +-
examples/l2fwd-macsec/main.c | 2 +-
examples/l2fwd/main.c | 2 +-
examples/l3fwd-graph/main.c | 2 +-
examples/l3fwd-power/main.c | 2 +-
examples/l3fwd/l3fwd_em.c | 1 -
examples/l3fwd/l3fwd_lpm.c | 1 -
examples/l3fwd/main.c | 2 +-
examples/link_status_interrupt/main.c | 2 +-
.../client_server_mp/mp_client/client.c | 1 -
.../client_server_mp/mp_server/init.c | 1 -
.../client_server_mp/mp_server/main.c | 2 +-
examples/multi_process/hotplug_mp/main.c | 1 -
examples/multi_process/simple_mp/main.c | 2 +-
examples/multi_process/symmetric_mp/main.c | 2 +-
examples/server_node_efd/efd_node/node.c | 1 -
examples/server_node_efd/efd_server/init.c | 1 -
examples/server_node_efd/efd_server/main.c | 1 -
examples/service_cores/main.c | 1 -
examples/timer/main.c | 2 +-
examples/vhost/main.h | 2 +-
examples/vm_power_manager/channel_manager.c | 2 +-
examples/vm_power_manager/channel_monitor.c | 2 +-
examples/vm_power_manager/main.c | 2 +-
examples/vmdq/main.c | 2 +-
examples/vmdq_dcb/main.c | 2 +-
lib/acl/rte_acl_osdep.h | 1 -
lib/bbdev/rte_bbdev.c | 2 +-
lib/bpf/bpf_load_elf.c | 1 -
lib/bpf/bpf_pkt.c | 3 +-
lib/cryptodev/cryptodev_pmd.c | 1 -
lib/cryptodev/rte_cryptodev.c | 1 -
lib/distributor/rte_distributor.c | 2 +-
lib/distributor/rte_distributor_single.c | 2 +-
lib/eal/common/eal_common_bus.c | 2 +-
lib/eal/common/eal_common_class.c | 2 +-
lib/eal/common/eal_common_dev.c | 2 +-
lib/eal/common/eal_common_tailqs.c | 2 +-
lib/eal/common/eal_common_trace.c | 2 +-
lib/eal/common/eal_private.h | 2 +-
lib/eal/common/malloc_elem.c | 2 +-
lib/eal/common/malloc_elem.h | 1 +
lib/eal/common/malloc_heap.c | 2 +-
lib/eal/common/malloc_heap.h | 2 +-
lib/eal/common/rte_malloc.c | 2 +-
lib/eal/freebsd/eal.c | 2 +-
lib/eal/freebsd/eal_interrupts.c | 2 +-
lib/eal/freebsd/eal_thread.c | 2 +-
lib/eal/freebsd/include/rte_os.h | 10 -
lib/eal/include/dev_driver.h | 1 +
lib/eal/include/meson.build | 1 +
.../sys/queue.h => include/rte_bsd_queue.h} | 670 ++++++++++++------
lib/eal/include/rte_class.h | 1 +
lib/eal/include/rte_devargs.h | 1 +
lib/eal/include/rte_tailq.h | 10 +
lib/eal/linux/eal_alarm.c | 2 +-
lib/eal/linux/eal_interrupts.c | 2 +-
lib/eal/linux/include/rte_os.h | 3 +-
lib/eal/windows/eal_alarm.c | 2 +-
lib/eal/windows/include/rte_os.h | 27 -
lib/efd/rte_efd.c | 1 -
lib/ethdev/ethdev_private.h | 3 +-
lib/ethdev/rte_ethdev.c | 2 +-
lib/fib/rte_fib.c | 1 -
lib/fib/rte_fib6.c | 1 -
lib/graph/graph_private.h | 1 -
lib/hash/rte_cuckoo_hash.c | 1 -
lib/hash/rte_fbk_hash.c | 1 -
lib/hash/rte_thash.c | 1 -
lib/ip_frag/ip_frag_common.h | 3 +-
lib/log/log.c | 2 +-
lib/lpm/rte_lpm.c | 1 -
lib/lpm/rte_lpm6.c | 1 -
lib/mbuf/rte_mbuf_dyn.c | 1 -
lib/mempool/rte_mempool.c | 1 -
lib/mempool/rte_mempool.h | 1 +
lib/pipeline/rte_swx_ctl.c | 1 -
lib/pipeline/rte_swx_pipeline_internal.h | 3 +-
lib/pmu/pmu.c | 1 -
lib/reorder/rte_reorder.c | 1 -
lib/rib/rte_rib.c | 1 -
lib/rib/rte_rib6.c | 1 -
lib/ring/rte_ring.c | 1 -
lib/stack/rte_stack.c | 1 -
lib/vhost/fd_man.h | 1 -
lib/vhost/socket.c | 2 +-
lib/vhost/vdpa.c | 2 -
lib/vhost/vhost.h | 2 +-
298 files changed, 604 insertions(+), 616 deletions(-)
rename lib/eal/{windows/include/sys/queue.h => include/rte_bsd_queue.h} (52%)Signature · 1 line
2.51.0
PATCH v3 1/44 net/nfp: fix use after free
The code to cleanup metering was using the objects after calling rte_free(). Fix by using LISTFOREACH_SAFE
--- drivers/net/nfp/nfp_mtr.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/net/nfp/nfp_mtr.c +13 -6
@@ -12,6 +12,13 @@#include "flower/nfp_flower_representor.h" #include "nfp_logs.h" +#ifndef LIST_FOREACH_SAFE +#define LIST_FOREACH_SAFE (var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); \ + (var) && ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif +#define NFP_MAX_POLICY_CNT NFP_MAX_MTR_CNT#define NFP_MAX_PROFILE_CNT NFP_MAX_MTR_CNT
@@ -1124,10 +1131,10 @@ nfp_mtr_priv_init(struct nfp_pf_dev *pf_dev)void nfp_mtr_priv_uninit (struct nfp_pf_dev *pf_dev) { -struct nfp_mtr *mtr; +struct nfp_mtr *mtr, *tmp_mtr;struct nfp_mtr_priv *priv; -struct nfp_mtr_policy *mtr_policy; -struct nfp_mtr_profile *mtr_profile; +struct nfp_mtr_policy *mtr_policy, *tmp_policy; +struct nfp_mtr_profile *mtr_profile, *tmp_profile;struct nfp_app_fw_flower *app_fw_flower; app_fw_flower =NFP_PRIV_TO_APP_FW_FLOWER (pf_dev->app_fw_priv);
@@ -1135,17 +1142,17 @@ nfp_mtr_priv_uninit(struct nfp_pf_dev *pf_dev)rte_eal_alarm_cancel (nfp_mtr_stats_request, (void *)app_fw_flower); - LIST_FOREACH(mtr, &priv->mtrs, next) { + LIST_FOREACH_SAFE(mtr, &priv->mtrs, next, tmp_mtr) {LIST_REMOVE (mtr, next);rte_free (mtr); } - LIST_FOREACH(mtr_profile, &priv->profiles, next) { + LIST_FOREACH_SAFE(mtr_profile, &priv->profiles, next, tmp_profile) {LIST_REMOVE (mtr_profile, next);rte_free (mtr_profile); } - LIST_FOREACH(mtr_policy, &priv->policies, next) { + LIST_FOREACH_SAFE(mtr_policy, &priv->policies, next, tmp_policy) {LIST_REMOVE (mtr_policy, next);rte_free (mtr_policy); }
Signature · 1 line
2.51.0
Stephen Hemminger
AppliedRe: [PATCH v3 01/44] net/nfp: fix use after free
Quoted 8 lines · On Mon, 3 Nov 2025 08:47:06 -0800 Stephen Hemminger…
The code to cleanup metering was using the objects after calling
rte_free(). Fix by usingLISTFOREACH_SAFESigned-off-by Stephen Hemminger <[email protected]>
Queued to next-net
PATCH v3 2/44 eal: add BSD version of queue.h
In reply to Stephen HemmingerThe version of sys/queue.h on Linux from glibc was derived from an older version of BSD and is missing several key macros such as LIST_FOREACH_SAFE. This leads to drivers re-implementing the macros (sometimes badly) and other bugs.
Introduce a version of queue.h derived from the current FreeBSD.
--- doc/guides/contributing/coding_style.rst | 4 +- doc/guides/rel_notes/release_25_11.rst | 3 + lib/eal/common/eal_common_bus.c | 2 +- lib/eal/common/eal_common_class.c | 2 +- lib/eal/common/eal_common_dev.c | 2 +- lib/eal/common/eal_common_tailqs.c | 2 +- lib/eal/common/eal_common_trace.c | 2 +- lib/eal/common/eal_private.h | 2 +- lib/eal/common/malloc_elem.c | 2 +- lib/eal/common/malloc_elem.h | 1 + lib/eal/common/malloc_heap.c | 2 +- lib/eal/common/malloc_heap.h | 2 +- lib/eal/common/rte_malloc.c | 2 +- lib/eal/freebsd/eal.c | 2 +- lib/eal/freebsd/eal_interrupts.c | 2 +- lib/eal/freebsd/eal_thread.c | 2 +- lib/eal/freebsd/include/rte_os.h | 10 - lib/eal/include/dev_driver.h | 1 + lib/eal/include/meson.build | 1 + lib/eal/include/rte_bsd_queue.h | 1062 ++++++++++++++++++++++ lib/eal/include/rte_class.h | 1 + lib/eal/include/rte_devargs.h | 1 + lib/eal/include/rte_tailq.h | 10 + lib/eal/linux/eal_alarm.c | 2 +- lib/eal/linux/eal_interrupts.c | 2 +- lib/eal/linux/include/rte_os.h | 3 +- lib/eal/windows/eal_alarm.c | 2 +- lib/eal/windows/include/rte_os.h | 27 - 28 files changed, 1100 insertions(+), 56 deletions(-) create mode 100644 lib/eal/include/rte_bsd_queue.h
doc/guides/contributing/coding_style.rst +2 -2
@@ -324,12 +324,12 @@ Structure Declarations Queues ~~~~~~ -Use queue(3) macros rather than rolling your own lists, whenever possible. +Use queue(3) macros defined in <rte_queue.h> rather than rolling your own lists. Thus, the previous example would be better written: .. code-block:: c - #include <sys/queue.h> + #include <rte_queue.h> struct foo { LIST_ENTRY(foo) link; /* Use queue macros for foo lists. */
doc/guides/rel_notes/release_25_11.rst +3 -0
@@ -220,6 +220,9 @@ API Changes The link type was previously hardcoded to the Ethernet link type in the API. This argument is added to ``rte_pcapng_add_interface``. +* eal: Added ``rte_queue.h`` which is clone of BSD queue.h header that is + portable across all OS's. + ABI Changes -----------
lib/eal/common/eal_common_bus.c +1 -1
@@ -4,8 +4,8 @@#include <stdio.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <bus_driver.h> #include <rte_debug.h> #include <rte_string_fns.h>
lib/eal/common/eal_common_class.c +1 -1
@@ -4,8 +4,8 @@#include <stdio.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_class.h> #include <rte_debug.h>
lib/eal/common/eal_common_dev.c +1 -1
@@ -6,8 +6,8 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <bus_driver.h> #include <rte_class.h> #include <dev_driver.h>
lib/eal/common/eal_common_tailqs.c +1 -1
@@ -2,10 +2,10 @@* Copyright(c) 2010-2014 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <string.h> +#include <rte_bsd_queue.h> #include <rte_eal.h> #include <rte_eal_memconfig.h> #include <rte_log.h>
lib/eal/common/eal_common_trace.c +1 -1
@@ -5,9 +5,9 @@#include <stdlib.h> #include <fnmatch.h> #include <pthread.h> -#include <sys/queue.h> #include <regex.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_errno.h> #include <rte_lcore.h>
lib/eal/common/eal_private.h +1 -1
@@ -8,12 +8,12 @@#include <stdbool.h> #include <stdint.h> #include <stdio.h> -#include <sys/queue.h> #include <dev_driver.h> #include <rte_lcore.h> #include <rte_log.h> #include <rte_memory.h> +#include <rte_tailq.h> #include "eal_internal_cfg.h"
lib/eal/common/malloc_elem.c +1 -1
@@ -6,8 +6,8 @@#include <stddef.h> #include <stdio.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_memory.h> #include <rte_eal.h> #include <rte_common.h>
lib/eal/common/malloc_elem.h +1 -0
@@ -8,6 +8,7 @@#include <stdbool.h> #include <rte_common.h> +#include <rte_bsd_queue.h> #define MIN_DATA_SIZE (RTE_CACHE_LINE_SIZE)
lib/eal/common/malloc_heap.c +1 -1
@@ -6,8 +6,8 @@#include <stdlib.h> #include <stdio.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_memory.h> #include <rte_errno.h> #include <rte_eal.h>
lib/eal/common/malloc_heap.h +1 -1
@@ -6,8 +6,8 @@#define MALLOC_HEAP_H_ #include <stdbool.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_malloc.h> #include <rte_spinlock.h>
lib/eal/common/rte_malloc.c +1 -1
@@ -6,8 +6,8 @@#include <stddef.h> #include <stdio.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_errno.h> #include <rte_memcpy.h> #include <rte_memory.h>
lib/eal/freebsd/eal.c +1 -1
@@ -17,9 +17,9 @@#include <errno.h> #include <limits.h> #include <sys/mman.h> -#include <sys/queue.h> #include <sys/stat.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_debug.h> #include <rte_memory.h>
lib/eal/freebsd/eal_interrupts.c +1 -1
@@ -5,9 +5,9 @@#include <string.h> #include <sys/types.h> #include <sys/event.h> -#include <sys/queue.h> #include <unistd.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <eal_trace_internal.h> #include <rte_errno.h>
lib/eal/freebsd/eal_thread.c +1 -1
@@ -9,9 +9,9 @@#include <unistd.h> #include <sched.h> #include <pthread_np.h> -#include <sys/queue.h> #include <sys/thr.h> +#include <rte_bsd_queue.h> #include <rte_debug.h> #include <rte_atomic.h> #include <rte_launch.h>
lib/eal/freebsd/include/rte_os.h +0 -10
@@ -12,16 +12,6 @@#include <pthread_np.h> #include <stdlib.h> /* Declares alloca() */ -#include <sys/queue.h> - -/* These macros are compatible with system's sys/queue.h. */ -#define RTE_TAILQ_HEAD (name, type) TAILQ_HEAD(name, type) -#define RTE_TAILQ_ENTRY (type) TAILQ_ENTRY(type) -#define RTE_TAILQ_FOREACH (var, head, field) TAILQ_FOREACH(var, head, field) -#define RTE_TAILQ_FIRST (head) TAILQ_FIRST(head) -#define RTE_TAILQ_NEXT (elem, field) TAILQ_NEXT(elem, field) -#define RTE_STAILQ_HEAD (name, type) STAILQ_HEAD(name, type) -#define RTE_STAILQ_ENTRY (type) STAILQ_ENTRY(type)typedef cpuset_t rte_cpuset_t ;#define RTE_HAS_CPUSET
lib/eal/include/dev_driver.h +1 -0
@@ -7,6 +7,7 @@#include <rte_common.h> #include <rte_dev.h> +#include <rte_tailq.h> /** * A structure describing a device driver.
lib/eal/include/meson.build +1 -0
@@ -38,6 +38,7 @@ headers += files( 'rte_pci_dev_features.h', 'rte_per_lcore.h', 'rte_pflock.h', + 'rte_bsd_queue.h', 'rte_random.h', 'rte_reciprocal.h', 'rte_seqcount.h',
lib/eal/include/rte_bsd_queue.h new file +1062 -0
1,062 lines not on this page · raw message
lib/eal/include/rte_class.h +1 -0
@@ -18,6 +18,7 @@* cryptographic co-processor (crypto), etc. */ +#include <rte_tailq.h> #include <rte_dev.h> #ifdef __cplusplus
lib/eal/include/rte_devargs.h +1 -0
@@ -19,6 +19,7 @@#include <stdio.h> #include <rte_dev.h> +#include <rte_tailq.h> #ifdef __cplusplusextern "C" {
lib/eal/include/rte_tailq.h +10 -0
@@ -13,6 +13,16 @@#include <stdio.h> #include <rte_debug.h> +#include <rte_bsd_queue.h> + +#define RTE_TAILQ_HEAD (name, type) TAILQ_HEAD(name, type) +#define RTE_TAILQ_ENTRY (type) TAILQ_ENTRY(type) +#define RTE_TAILQ_FOREACH (var, head, field) TAILQ_FOREACH(var, head, field) +#define RTE_TAILQ_FIRST (head) TAILQ_FIRST(head) +#define RTE_TAILQ_NEXT (elem, field) TAILQ_NEXT(elem, field) +#define RTE_STAILQ_HEAD (name, type) STAILQ_HEAD(name, type) +#define RTE_STAILQ_ENTRY (type) STAILQ_ENTRY(type) +#ifdef __cplusplusextern "C" {#endif
lib/eal/linux/eal_alarm.c +1 -1
@@ -6,10 +6,10 @@#include <stdlib.h> #include <errno.h> #include <pthread.h> -#include <sys/queue.h> #include <sys/time.h> #include <sys/timerfd.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <eal_trace_internal.h> #include <rte_interrupts.h>
lib/eal/linux/eal_interrupts.c +1 -1
@@ -7,7 +7,6 @@#include <stdio.h> #include <stdint.h> #include <stdlib.h> -#include <sys/queue.h> #include <unistd.h> #include <string.h> #include <errno.h>
@@ -17,6 +16,7 @@#include <assert.h> #include <stdbool.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <eal_trace_internal.h> #include <rte_common.h>
lib/eal/linux/include/rte_os.h +2 -1
@@ -12,7 +12,8 @@#include <alloca.h> #include <sched.h> -#include <sys/queue.h> + +#include <rte_bsd_queue.h> /* These macros are compatible with system's sys/queue.h. */ #define RTE_TAILQ_HEAD (name, type) TAILQ_HEAD(name, type)
lib/eal/windows/eal_alarm.c +1 -1
@@ -4,8 +4,8 @@#include <stdatomic.h> #include <stdbool.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <rte_alarm.h> #include <rte_spinlock.h>
lib/eal/windows/include/rte_os.h +0 -27
@@ -17,33 +17,6 @@#include <sched.h> -/* These macros are compatible with bundled sys/queue.h. */ -#define RTE_TAILQ_HEAD (name, type) \ -struct name { \ - struct type *tqh_first; \ - struct type **tqh_last; \ -} -#define RTE_TAILQ_ENTRY (type) \ -struct { \ - struct type *tqe_next; \ - struct type **tqe_prev; \ -} -#define RTE_TAILQ_FOREACH (var, head, field) \ - for ((var) = RTE_TAILQ_FIRST((head)); \ - (var); \ - (var) = RTE_TAILQ_NEXT((var), field)) -#define RTE_TAILQ_FIRST (head) ((head)->tqh_first) -#define RTE_TAILQ_NEXT (elm, field) ((elm)->field.tqe_next) -#define RTE_STAILQ_HEAD (name, type) \ -struct name { \ - struct type *stqh_first; \ - struct type **stqh_last; \ -} -#define RTE_STAILQ_ENTRY (type) \ -struct { \ - struct type *stqe_next; \ -} -/* 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)
Signature · 1 line
2.51.0
PATCH v3 3/44 test: remove unnecessary inclusion of sys/queue.h
In reply to Stephen HemmingerThose macros are not directly in most of the test code. Replace with rte_bsd_queue.h
--- app/test/commands.c | 2 +- app/test/test.c | 1 - app/test/test.h | 2 +- app/test/test_atomic.c | 1 - app/test/test_cmdline_lib.c | 1 - app/test/test_func_reentrancy.c | 1 - app/test/test_hash.c | 1 - app/test/test_hash_functions.c | 1 - app/test/test_link_bonding.c | 1 - app/test/test_link_bonding_mode4.c | 1 - app/test/test_link_bonding_rssconf.c | 1 - app/test/test_logs.c | 1 - app/test/test_malloc.c | 1 - app/test/test_mbuf.c | 1 - app/test/test_mcslock.c | 1 - app/test/test_mempool.c | 1 - app/test/test_mempool_perf.c | 1 - app/test/test_memzone.c | 1 - app/test/test_mp_secondary.c | 1 - app/test/test_per_lcore.c | 1 - app/test/test_pflock.c | 1 - app/test/test_ring.c | 1 - app/test/test_rwlock.c | 1 - app/test/test_soring.c | 1 - app/test/test_spinlock.c | 1 - app/test/test_tailq.c | 1 - app/test/test_ticketlock.c | 1 - app/test/test_timer.c | 1 - 28 files changed, 2 insertions(+), 28 deletions(-)
app/test/commands.c +1 -1
@@ -10,8 +10,8 @@#include <stdlib.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_log.h> #include <rte_debug.h>
app/test/test.c +0 -1
@@ -9,7 +9,6 @@#include <stdlib.h> #include <errno.h> #include <ctype.h> -#include <sys/queue.h> #include <cmdline_rdline.h> #include <cmdline_parse.h>
app/test/test.h +1 -1
@@ -8,8 +8,8 @@#include <errno.h> #include <stddef.h> #include <stdlib.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_hexdump.h> #include <rte_common.h> #include <rte_os_shim.h>
app/test/test_atomic.c +0 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_per_lcore.h>
app/test/test_cmdline_lib.c +0 -1
@@ -9,7 +9,6 @@#include <stdlib.h> #include <errno.h> #include <ctype.h> -#include <sys/queue.h> #include <rte_common.h>
app/test/test_func_reentrancy.c +0 -1
@@ -9,7 +9,6 @@#include <inttypes.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_log.h>
app/test/test_hash.c +0 -1
@@ -8,7 +8,6 @@#include <stdlib.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_malloc.h>
app/test/test_hash_functions.c +0 -1
@@ -8,7 +8,6 @@#include <stdlib.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> #include <rte_cycles.h> #include <rte_random.h>
app/test/test_link_bonding.c +0 -1
@@ -11,7 +11,6 @@#include <inttypes.h> #include <errno.h> #include <pthread.h> -#include <sys/queue.h> #include <sys/time.h> #include <rte_cycles.h>
app/test/test_link_bonding_mode4.c +0 -1
@@ -10,7 +10,6 @@#include <inttypes.h> #include <errno.h> #include <rte_cycles.h> -#include <sys/queue.h> #include <rte_byteorder.h> #include <rte_common.h>
app/test/test_link_bonding_rssconf.c +0 -1
@@ -10,7 +10,6 @@#include <inttypes.h> #include <errno.h> #include <rte_cycles.h> -#include <sys/queue.h> #include <rte_byteorder.h> #include <rte_common.h>
app/test/test_logs.c +0 -1
@@ -5,7 +5,6 @@#include <stdio.h> #include <stdint.h> #include <stdarg.h> -#include <sys/queue.h> #include <rte_log.h> #include <rte_memory.h>
app/test/test_malloc.c +0 -1
@@ -13,7 +13,6 @@#ifndef RTE_EXEC_ENV_WINDOWS #include <sys/mman.h> #endif -#include <sys/queue.h> #include <unistd.h> #include <rte_common.h>
app/test/test_mbuf.c +0 -1
@@ -12,7 +12,6 @@#include <stdint.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_errno.h>
app/test/test_mcslock.c +0 -1
@@ -7,7 +7,6 @@#include <inttypes.h> #include <string.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_memory.h>
app/test/test_mempool.c +0 -1
@@ -9,7 +9,6 @@#include <inttypes.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_eal_paging.h>
app/test/test_mempool_perf.c +0 -1
@@ -10,7 +10,6 @@#include <inttypes.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_log.h>
app/test/test_memzone.c +0 -1
@@ -6,7 +6,6 @@#include <stdint.h> #include <string.h> #include <inttypes.h> -#include <sys/queue.h> #include <rte_random.h> #include <rte_cycles.h>
app/test/test_mp_secondary.c +0 -1
@@ -10,7 +10,6 @@#include <stdlib.h> #include <stdarg.h> #include <inttypes.h> -#include <sys/queue.h> #include <errno.h> #include <string.h> #include <unistd.h>
app/test/test_per_lcore.c +0 -1
@@ -4,7 +4,6 @@#include <stdio.h> #include <stdint.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_memory.h>
app/test/test_pflock.c +0 -1
@@ -6,7 +6,6 @@#include <stdint.h> #include <inttypes.h> #include <unistd.h> -#include <sys/queue.h> #include <string.h> #include <rte_common.h>
app/test/test_ring.c +0 -1
@@ -10,7 +10,6 @@#include <stdint.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_log.h>
app/test/test_rwlock.c +0 -1
@@ -6,7 +6,6 @@#include <stdint.h> #include <inttypes.h> #include <unistd.h> -#include <sys/queue.h> #include <string.h> #include <rte_common.h>
app/test/test_soring.c +0 -1
@@ -9,7 +9,6 @@#include <stdint.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_log.h>
app/test/test_spinlock.c +0 -1
@@ -7,7 +7,6 @@#include <inttypes.h> #include <string.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_memory.h>
app/test/test_tailq.c +0 -1
@@ -7,7 +7,6 @@#include <stdarg.h> #include <string.h> #include <errno.h> -#include <sys/queue.h> #include <rte_eal.h> #include <rte_string_fns.h>
app/test/test_ticketlock.c +0 -1
@@ -6,7 +6,6 @@#include <stdint.h> #include <stdio.h> #include <string.h> -#include <sys/queue.h> #include <unistd.h> #include <rte_common.h>
app/test/test_timer.c +0 -1
@@ -91,7 +91,6 @@#include <stdlib.h> #include <stdint.h> #include <inttypes.h> -#include <sys/queue.h> #include <math.h> #include <rte_common.h>
Signature · 1 line
2.51.0
PATCH v3 4/44 test-pipeline: remove unnecessary use of sys/queue.h
In reply to Stephen HemmingerNot used directly here
--- app/test-pipeline/config.c | 1 - app/test-pipeline/init.c | 1 - app/test-pipeline/main.c | 1 - app/test-pipeline/runtime.c | 1 - 4 files changed, 4 deletions(-)
app/test-pipeline/config.c +0 -1
@@ -8,7 +8,6 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
app/test-pipeline/init.c +0 -1
@@ -8,7 +8,6 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
app/test-pipeline/main.c +0 -1
@@ -8,7 +8,6 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> #include <stdarg.h> #include <signal.h> #include <errno.h>
app/test-pipeline/runtime.c +0 -1
@@ -8,7 +8,6 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
Signature · 1 line
2.51.0
PATCH v3 5/44 test-eventdev: use rte_bsd_queue.h
In reply to Stephen HemmingerUse the replacement rte_bsd_queue.h header instead
--- app/test-eventdev/evt_test.c | 2 +- app/test-eventdev/evt_test.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
app/test-eventdev/evt_test.c +1 -1
@@ -4,8 +4,8 @@#include <stdio.h> #include <unistd.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include "evt_test.h" static STAILQ_HEAD(, evt_test_entry) head = STAILQ_HEAD_INITIALIZER(head);
app/test-eventdev/evt_test.h +0 -1
@@ -7,7 +7,6 @@#include <string.h> #include <stdbool.h> -#include <sys/queue.h> #include <rte_eal.h>
Signature · 1 line
2.51.0
PATCH v3 6/44 test-bbdev, test-cmdline, test-mldev: don't use sys/queue.h
In reply to Stephen HemmingerNo need for direct inclusion here.
--- app/test-bbdev/main.h | 1 - app/test-cmdline/cmdline_test.c | 1 - app/test-mldev/ml_test.h | 1 - 3 files changed, 3 deletions(-)
app/test-bbdev/main.h +0 -1
@@ -6,7 +6,6 @@#define _MAIN_H_#include <stddef.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_hexdump.h>
app/test-cmdline/cmdline_test.c +0 -1
@@ -9,7 +9,6 @@#include <stdlib.h> #include <errno.h> #include <ctype.h> -#include <sys/queue.h> #include <rte_common.h>
app/test-mldev/ml_test.h +0 -1
@@ -8,7 +8,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/queue.h> #include <rte_common.h>
Signature · 1 line
2.51.0
PATCH v3 7/44 app/testpmd: use rte_bsd_queue.h
In reply to Stephen HemmingerOnly include the definition of LIST, TAILQ, etc where needed.
--- app/test-pmd/5tswap.c | 2 -- app/test-pmd/cmdline.c | 2 +- app/test-pmd/config.c | 2 +- app/test-pmd/csumonly.c | 1 - app/test-pmd/flowgen.c | 1 - app/test-pmd/hairpin.c | 1 - app/test-pmd/icmpecho.c | 1 - app/test-pmd/iofwd.c | 1 - app/test-pmd/macfwd.c | 1 - app/test-pmd/macswap.c | 1 - app/test-pmd/noisy_vnf.c | 1 - app/test-pmd/parameters.c | 1 - app/test-pmd/rxonly.c | 1 - app/test-pmd/testpmd.c | 1 - app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 1 - 16 files changed, 3 insertions(+), 17 deletions(-)
app/test-pmd/5tswap.c +0 -2
@@ -7,8 +7,6 @@#include <stdint.h> #include <unistd.h> #include <inttypes.h> - -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/cmdline.c +1 -1
@@ -13,8 +13,8 @@#include <string.h> #include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_byteorder.h> #include <rte_log.h>
app/test-pmd/config.c +1 -1
@@ -13,7 +13,7 @@#include <stdint.h> #include <inttypes.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>
app/test-pmd/csumonly.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/flowgen.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/hairpin.c +0 -1
@@ -8,7 +8,6 @@#include <stdbool.h> #include <stdint.h> -#include <sys/queue.h> #include "testpmd.h"
app/test-pmd/icmpecho.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/iofwd.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/macfwd.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/macswap.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/noisy_vnf.c +0 -1
@@ -12,7 +12,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/parameters.c +0 -1
@@ -13,7 +13,6 @@#include <fcntl.h> #include <sys/types.h> -#include <sys/queue.h> #include <sys/stat.h> #include <stdint.h>
app/test-pmd/rxonly.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
app/test-pmd/testpmd.c +0 -1
@@ -16,7 +16,6 @@#include <errno.h> #include <stdbool.h> -#include <sys/queue.h> #include <sys/stat.h> #include <stdint.h>
app/test-pmd/testpmd.h +1 -1
@@ -21,7 +21,7 @@#include <cmdline.h> #include <cmdline_parse.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #ifdef RTE_HAS_JANSSON #include <jansson.h> #endif
app/test-pmd/txonly.c +0 -1
@@ -10,7 +10,6 @@#include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <sys/stat.h> #include <rte_common.h>
Signature · 1 line
2.51.0
PATCH v3 8/44 apps: use rte_bsd_queue.h
In reply to Stephen HemmingerUse DPDK not system version.
Not really a requirement but better to avoid any possible conflict.
--- app/dumpcap/main.c | 2 +- app/proc-info/main.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
app/dumpcap/main.c +1 -1
@@ -17,12 +17,12 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/queue.h> #include <sys/types.h> #include <sys/utsname.h> #include <time.h> #include <unistd.h> +#include <rte_bsd_queue.h> #include <rte_alarm.h> #include <rte_bitops.h> #include <rte_bpf.h>
app/proc-info/main.c +0 -1
@@ -9,7 +9,6 @@#include <errno.h> #include <stdarg.h> #include <inttypes.h> -#include <sys/queue.h> #include <stdlib.h> #include <getopt.h> #include <unistd.h>
Signature · 1 line
2.51.0
PATCH v3 9/44 examples: replace use of sys/queue.h
In reply to Stephen HemmingerWhere macros are actually used directly include rte_bsd_queue.h. Most places were just copying some other file and doing unnecessary include of sys/queue.h
--- examples/bbdev_app/main.c | 2 +- examples/bond/main.c | 2 +- examples/cmdline/main.c | 1 - examples/cmdline/parse_obj_list.h | 2 +- examples/flow_filtering/main.c | 1 - examples/helloworld/main.c | 2 +- examples/ip_fragmentation/main.c | 2 +- examples/ip_pipeline/action.h | 2 +- examples/ip_pipeline/cryptodev.h | 2 +- examples/ip_pipeline/link.h | 2 +- examples/ip_pipeline/mempool.h | 2 +- examples/ip_pipeline/pipeline.h | 2 +- examples/ip_pipeline/swq.h | 2 +- examples/ip_pipeline/tap.h | 2 +- examples/ip_pipeline/tmgr.h | 2 +- examples/ip_reassembly/main.c | 2 +- examples/ipsec-secgw/ipsec-secgw.c | 2 +- examples/ipv4_multicast/main.c | 2 +- examples/l2fwd-crypto/main.c | 2 +- examples/l2fwd-event/l2fwd_common.h | 1 - examples/l2fwd-keepalive/ka-agent/main.c | 1 - examples/l2fwd-keepalive/main.c | 2 +- examples/l2fwd-macsec/main.c | 2 +- examples/l2fwd/main.c | 2 +- examples/l3fwd-graph/main.c | 2 +- examples/l3fwd-power/main.c | 2 +- examples/l3fwd/l3fwd_em.c | 1 - examples/l3fwd/l3fwd_lpm.c | 1 - examples/l3fwd/main.c | 2 +- examples/link_status_interrupt/main.c | 2 +- examples/multi_process/client_server_mp/mp_client/client.c | 1 - examples/multi_process/client_server_mp/mp_server/init.c | 1 - examples/multi_process/client_server_mp/mp_server/main.c | 2 +- examples/multi_process/hotplug_mp/main.c | 1 - examples/multi_process/simple_mp/main.c | 2 +- examples/multi_process/symmetric_mp/main.c | 2 +- examples/server_node_efd/efd_node/node.c | 1 - examples/server_node_efd/efd_server/init.c | 1 - examples/server_node_efd/efd_server/main.c | 1 - examples/service_cores/main.c | 1 - examples/timer/main.c | 2 +- examples/vhost/main.h | 2 +- examples/vm_power_manager/channel_manager.c | 2 +- examples/vm_power_manager/channel_monitor.c | 2 +- examples/vm_power_manager/main.c | 2 +- examples/vmdq/main.c | 2 +- examples/vmdq_dcb/main.c | 2 +- 47 files changed, 34 insertions(+), 47 deletions(-)
examples/bbdev_app/main.c +1 -1
@@ -10,7 +10,7 @@#include <inttypes.h> #include <sys/types.h> #include <unistd.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdarg.h> #include <ctype.h> #include <errno.h>
examples/bond/main.c +1 -1
@@ -3,7 +3,7 @@*/ #include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <sys/socket.h> #include <stdlib.h> #include <string.h>
examples/cmdline/main.c +0 -1
@@ -8,7 +8,6 @@#include <string.h> #include <stdint.h> #include <errno.h> -#include <sys/queue.h> #include <cmdline_rdline.h> #include <cmdline_parse.h>
examples/cmdline/parse_obj_list.h +1 -1
@@ -10,7 +10,7 @@/* This file is an example of extension of libcmdline. It provides an * example of objects stored in a list. */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <cmdline_parse.h> #include <cmdline_parse_string.h>
examples/flow_filtering/main.c +0 -1
@@ -8,7 +8,6 @@#include <stdint.h> #include <inttypes.h> #include <sys/types.h> -#include <sys/queue.h> #include <setjmp.h> #include <stdarg.h> #include <ctype.h>
examples/helloworld/main.c +1 -1
@@ -6,7 +6,7 @@#include <string.h> #include <stdint.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_memory.h> #include <rte_launch.h>
examples/ip_fragmentation/main.c +1 -1
@@ -9,7 +9,7 @@#include <sys/types.h> #include <sys/param.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
examples/ip_pipeline/action.h +1 -1
@@ -5,7 +5,7 @@#ifndef _INCLUDE_ACTION_H_#define _INCLUDE_ACTION_H_ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_port_in_action.h> #include <rte_table_action.h>
examples/ip_pipeline/cryptodev.h +1 -1
@@ -6,7 +6,7 @@#define _INCLUDE_SYM_C_H_#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_cryptodev.h>
examples/ip_pipeline/link.h +1 -1
@@ -6,7 +6,7 @@#define _INCLUDE_LINK_H_#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include "common.h"
examples/ip_pipeline/mempool.h +1 -1
@@ -6,7 +6,7 @@#define _INCLUDE_MEMPOOL_H_#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_mempool.h>
examples/ip_pipeline/pipeline.h +1 -1
@@ -6,7 +6,7 @@#define _INCLUDE_PIPELINE_H_#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_pipeline.h> #include <rte_table_action.h>
examples/ip_pipeline/swq.h +1 -1
@@ -6,7 +6,7 @@#define _INCLUDE_SWQ_H_#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_ring.h>
examples/ip_pipeline/tap.h +1 -1
@@ -5,7 +5,7 @@#ifndef _INCLUDE_TAP_H_#define _INCLUDE_TAP_H_ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include "common.h"
examples/ip_pipeline/tmgr.h +1 -1
@@ -6,7 +6,7 @@#define _INCLUDE_TMGR_H_#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_sched.h> #include <rte_red.h>
examples/ip_reassembly/main.c +1 -1
@@ -8,7 +8,7 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
examples/ipsec-secgw/ipsec-secgw.c +1 -1
@@ -12,7 +12,7 @@#include <netinet/ip.h> #include <netinet/ip6.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdarg.h> #include <errno.h> #include <signal.h>
examples/ipv4_multicast/main.c +1 -1
@@ -8,7 +8,7 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
examples/l2fwd-crypto/main.c +1 -1
@@ -9,7 +9,7 @@#include <stdint.h> #include <inttypes.h> #include <sys/types.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <netinet/in.h> #include <setjmp.h> #include <stdarg.h>
examples/l2fwd-event/l2fwd_common.h +0 -1
@@ -11,7 +11,6 @@#include <stdint.h> #include <inttypes.h> #include <sys/types.h> -#include <sys/queue.h> #include <netinet/in.h> #include <setjmp.h> #include <stdarg.h>
examples/l2fwd-keepalive/ka-agent/main.c +0 -1
@@ -9,7 +9,6 @@#include <unistd.h> #include <fcntl.h> #include <sys/wait.h> -#include <sys/queue.h> #include <sys/mman.h> #include <sys/stat.h> #include <time.h>
examples/l2fwd-keepalive/main.c +1 -1
@@ -8,7 +8,7 @@#include <stdint.h> #include <inttypes.h> #include <sys/types.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <netinet/in.h> #include <setjmp.h> #include <stdarg.h>
examples/l2fwd-macsec/main.c +1 -1
@@ -8,7 +8,7 @@#include <stdint.h> #include <inttypes.h> #include <sys/types.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <setjmp.h> #include <stdarg.h> #include <ctype.h>
examples/l2fwd/main.c +1 -1
@@ -8,7 +8,7 @@#include <stdint.h> #include <inttypes.h> #include <sys/types.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <setjmp.h> #include <stdarg.h> #include <ctype.h>
examples/l3fwd-graph/main.c +1 -1
@@ -15,7 +15,7 @@#include <string.h> #include <sys/socket.h> #include <sys/types.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <unistd.h> #include <rte_branch_prediction.h>
examples/l3fwd-power/main.c +1 -1
@@ -8,7 +8,7 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
examples/l3fwd/l3fwd_em.c +0 -1
@@ -8,7 +8,6 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
examples/l3fwd/l3fwd_lpm.c +0 -1
@@ -8,7 +8,6 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
examples/l3fwd/main.c +1 -1
@@ -8,7 +8,7 @@#include <inttypes.h> #include <sys/types.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdarg.h> #include <errno.h> #include <getopt.h>
examples/link_status_interrupt/main.c +1 -1
@@ -8,7 +8,7 @@#include <stdint.h> #include <inttypes.h> #include <sys/types.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <setjmp.h> #include <stdarg.h> #include <ctype.h>
examples/multi_process/client_server_mp/mp_client/client.c +0 -1
@@ -7,7 +7,6 @@#include <inttypes.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> #include <stdlib.h> #include <getopt.h> #include <string.h>
examples/multi_process/client_server_mp/mp_server/init.c +0 -1
@@ -6,7 +6,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/queue.h> #include <errno.h> #include <stdarg.h> #include <inttypes.h>
examples/multi_process/client_server_mp/mp_server/main.c +1 -1
@@ -9,7 +9,7 @@#include <stdint.h> #include <stdarg.h> #include <inttypes.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <errno.h> #include <signal.h>
examples/multi_process/hotplug_mp/main.c +0 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <errno.h> #include <termios.h> -#include <sys/queue.h> #include <cmdline_rdline.h> #include <cmdline_parse.h>
examples/multi_process/simple_mp/main.c +1 -1
@@ -22,7 +22,7 @@#include <errno.h> #include <unistd.h> #include <termios.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_memory.h>
examples/multi_process/symmetric_mp/main.c +1 -1
@@ -19,7 +19,7 @@#include <stdlib.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <getopt.h> #include <signal.h> #include <inttypes.h>
examples/server_node_efd/efd_node/node.c +0 -1
@@ -7,7 +7,6 @@#include <inttypes.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> #include <stdlib.h> #include <getopt.h> #include <string.h>
examples/server_node_efd/efd_server/init.c +0 -1
@@ -6,7 +6,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/queue.h> #include <errno.h> #include <stdarg.h> #include <inttypes.h>
examples/server_node_efd/efd_server/main.c +0 -1
@@ -9,7 +9,6 @@#include <stdint.h> #include <stdarg.h> #include <inttypes.h> -#include <sys/queue.h> #include <errno.h> #include <sys/types.h> #include <netinet/in.h>
examples/service_cores/main.c +0 -1
@@ -7,7 +7,6 @@#include <string.h> #include <stdint.h> #include <errno.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_launch.h>
examples/timer/main.c +1 -1
@@ -6,7 +6,7 @@#include <string.h> #include <stdint.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_memory.h>
examples/vhost/main.h +1 -1
@@ -5,7 +5,7 @@#ifndef _MAIN_H_#define _MAIN_H_ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_ether.h> #include <rte_pci.h>
examples/vm_power_manager/channel_manager.c +1 -1
@@ -10,7 +10,7 @@#include <dirent.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h>
examples/vm_power_manager/channel_monitor.c +1 -1
@@ -13,7 +13,7 @@#include <fcntl.h> #include <sys/types.h> #include <sys/epoll.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/select.h>
examples/vm_power_manager/main.c +1 -1
@@ -12,7 +12,7 @@#include <signal.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_eal.h>
examples/vmdq/main.c +1 -1
@@ -3,7 +3,7 @@*/ #include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdlib.h> #include <string.h> #include <stdio.h>
examples/vmdq_dcb/main.c +1 -1
@@ -3,7 +3,7 @@*/ #include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdlib.h> #include <string.h> #include <stdio.h>
Signature · 1 line
2.51.0
PATCH v3 10/44 ethdev: replace use of sys/queue.h
In reply to Stephen HemmingerUse rte_bsd_queue.h instead.
--- lib/ethdev/ethdev_private.h | 3 +-- lib/ethdev/rte_ethdev.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
lib/ethdev/ethdev_private.h +1 -2
@@ -5,8 +5,7 @@#ifndef _ETH_PRIVATE_H_#define _ETH_PRIVATE_H_ -#include <sys/queue.h> - +#include <rte_bsd_queue.h> #include <rte_eal_memconfig.h> #include <rte_malloc.h> #include <rte_os_shim.h>
lib/ethdev/rte_ethdev.c +1 -1
@@ -9,8 +9,8 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <bus_driver.h> #include <eal_export.h> #include <rte_log.h>
Signature · 1 line
2.51.0
Re: [PATCH v3 10/44] ethdev: replace use of sys/queue.h
Quoted 3 lines · Stephen Hemminger
Use
rte_bsd_queue.hinstead.Signed-off-by Stephen Hemminger <[email protected]>
PATCH v3 11/44 lib: remove use of sys/queue.h
In reply to Stephen HemmingerUse the new rte_bsd_queue.h where needed but most files already get the needed macros from rte_tailq.h
--- lib/acl/rte_acl_osdep.h | 1 - lib/bbdev/rte_bbdev.c | 2 +- lib/bpf/bpf_load_elf.c | 1 - lib/bpf/bpf_pkt.c | 3 +-- lib/cryptodev/cryptodev_pmd.c | 1 - lib/cryptodev/rte_cryptodev.c | 1 - lib/distributor/rte_distributor.c | 2 +- lib/distributor/rte_distributor_single.c | 2 +- lib/efd/rte_efd.c | 1 - lib/fib/rte_fib.c | 1 - lib/fib/rte_fib6.c | 1 - lib/graph/graph_private.h | 1 - lib/hash/rte_cuckoo_hash.c | 1 - lib/hash/rte_fbk_hash.c | 1 - lib/hash/rte_thash.c | 1 - lib/ip_frag/ip_frag_common.h | 3 +-- lib/log/log.c | 2 +- lib/lpm/rte_lpm.c | 1 - lib/lpm/rte_lpm6.c | 1 - lib/mbuf/rte_mbuf_dyn.c | 1 - lib/mempool/rte_mempool.c | 1 - lib/mempool/rte_mempool.h | 1 + lib/pipeline/rte_swx_ctl.c | 1 - lib/pipeline/rte_swx_pipeline_internal.h | 3 ++- lib/pmu/pmu.c | 1 - lib/reorder/rte_reorder.c | 1 - lib/rib/rte_rib.c | 1 - lib/rib/rte_rib6.c | 1 - lib/ring/rte_ring.c | 1 - lib/stack/rte_stack.c | 1 - lib/vhost/fd_man.h | 1 - lib/vhost/socket.c | 2 +- lib/vhost/vdpa.c | 2 -- lib/vhost/vhost.h | 2 +- 34 files changed, 11 insertions(+), 36 deletions(-)
lib/acl/rte_acl_osdep.h +0 -1
@@ -21,7 +21,6 @@#include <stdio.h> #include <stdarg.h> #include <stdlib.h> -#include <sys/queue.h> /* * Common defines.
lib/bbdev/rte_bbdev.c +1 -1
@@ -5,8 +5,8 @@#include <stdint.h> #include <string.h> #include <stdbool.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <rte_common.h> #include <rte_errno.h>
lib/bpf/bpf_load_elf.c +0 -1
@@ -12,7 +12,6 @@#include <sys/types.h> #include <sys/stat.h> -#include <sys/queue.h> #include <fcntl.h> #include <libelf.h>
lib/bpf/bpf_pkt.c +1 -2
@@ -7,8 +7,7 @@#include <errno.h> #include <stdint.h> -#include <sys/queue.h> - +#include <rte_bsd_queue.h> #include <eal_export.h> #include <rte_common.h> #include <rte_malloc.h>
lib/cryptodev/cryptodev_pmd.c +0 -1
@@ -3,7 +3,6 @@*/ #include <stdlib.h> -#include <sys/queue.h> #include <dev_driver.h> #include <eal_export.h>
lib/cryptodev/rte_cryptodev.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2015-2020 Intel Corporation */ -#include <sys/queue.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h>
lib/distributor/rte_distributor.c +1 -1
@@ -5,8 +5,8 @@#include <stdalign.h> #include <stdio.h> #include <stdlib.h> -#include <sys/queue.h> #include <string.h> +#include <eal_export.h> #include <rte_mbuf.h> #include <rte_cycles.h>
lib/distributor/rte_distributor_single.c +1 -1
@@ -3,7 +3,7 @@*/ #include <stdio.h> -#include <sys/queue.h> +#include <rte_mbuf.h> #include <rte_memzone.h> #include <rte_errno.h>
lib/efd/rte_efd.c +0 -1
@@ -7,7 +7,6 @@#include <stdlib.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_cpuflags.h>
lib/fib/rte_fib.c +0 -1
@@ -5,7 +5,6 @@#include <stdint.h> #include <string.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_eal_memconfig.h>
lib/fib/rte_fib6.c +0 -1
@@ -5,7 +5,6 @@#include <stdint.h> #include <string.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_eal_memconfig.h>
lib/graph/graph_private.h +0 -1
@@ -6,7 +6,6 @@#define _RTE_GRAPH_PRIVATE_H_#include <inttypes.h> -#include <sys/queue.h> #include <rte_common.h> #include <rte_eal.h>
lib/hash/rte_cuckoo_hash.c +0 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <errno.h> #include <stdio.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_common.h>
lib/hash/rte_fbk_hash.c +0 -1
@@ -6,7 +6,6 @@#include <stdio.h> #include <string.h> #include <errno.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_cpuflags.h>
lib/hash/rte_thash.c +0 -1
@@ -3,7 +3,6 @@*/ #include <stdalign.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_thash.h>
lib/ip_frag/ip_frag_common.h +1 -2
@@ -5,8 +5,7 @@#ifndef _IP_FRAG_COMMON_H_#define _IP_FRAG_COMMON_H_ -#include <sys/queue.h> - +#include <rte_bsd_queue.h> #include <rte_common.h> #if defined(RTE_ARCH_ARM64 )
lib/log/log.c +1 -1
@@ -11,9 +11,9 @@#include <errno.h> #include <regex.h> #include <fnmatch.h> -#include <sys/queue.h> #include <unistd.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <rte_common.h> #include <rte_log.h>
lib/lpm/rte_lpm.c +0 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <errno.h> #include <stdio.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_log.h>
lib/lpm/rte_lpm6.c +0 -1
@@ -6,7 +6,6 @@#include <stdint.h> #include <errno.h> #include <stdio.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_log.h>
lib/mbuf/rte_mbuf_dyn.c +0 -1
@@ -3,7 +3,6 @@*/ #include <stdalign.h> -#include <sys/queue.h> #include <stdint.h> #include <limits.h>
lib/mempool/rte_mempool.c +0 -1
@@ -12,7 +12,6 @@#include <unistd.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_common.h>
lib/mempool/rte_mempool.h +1 -0
@@ -49,6 +49,7 @@#include <rte_ring.h> #include <rte_memcpy.h> #include <rte_common.h> +#include <rte_tailq.h> #include "rte_mempool_trace_fp.h"
lib/pipeline/rte_swx_ctl.c +0 -1
@@ -5,7 +5,6 @@#include <stdlib.h> #include <string.h> #include <stdio.h> -#include <sys/queue.h> #include <unistd.h> #include <eal_export.h>
lib/pipeline/rte_swx_pipeline_internal.h +2 -1
@@ -6,7 +6,7 @@#include <inttypes.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bitops.h> #include <rte_byteorder.h>
@@ -14,6 +14,7 @@#include <rte_cycles.h> #include <rte_prefetch.h> #include <rte_meter.h> +#include <rte_tailq.h> #include <rte_swx_table_selector.h> #include <rte_swx_table_learner.h>
lib/pmu/pmu.c +0 -1
@@ -8,7 +8,6 @@#include <stdlib.h> #include <unistd.h> #include <sys/mman.h> -#include <sys/queue.h> #include <sys/ioctl.h> #include <sys/syscall.h>
lib/reorder/rte_reorder.c +0 -1
@@ -4,7 +4,6 @@#include <stdalign.h> #include <string.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_string_fns.h>
lib/rib/rte_rib.c +0 -1
@@ -5,7 +5,6 @@#include <stdbool.h> #include <stdint.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_eal_memconfig.h>
lib/rib/rte_rib6.c +0 -1
@@ -5,7 +5,6 @@#include <stdbool.h> #include <stdint.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_eal_memconfig.h>
lib/ring/rte_ring.c +0 -1
@@ -13,7 +13,6 @@#include <stdint.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_common.h>
lib/stack/rte_stack.c +0 -1
@@ -4,7 +4,6 @@#include <stdalign.h> #include <string.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_string_fns.h>
lib/vhost/fd_man.h +0 -1
@@ -6,7 +6,6 @@#define _FD_MAN_H_#include <pthread.h> #include <poll.h> -#include <sys/queue.h> struct fdset ;
lib/vhost/socket.c +1 -1
@@ -10,13 +10,13 @@#include <string.h> #include <sys/socket.h> #include <sys/un.h> -#include <sys/queue.h> #include <errno.h> #include <fcntl.h> #include <eal_export.h> #include <rte_thread.h> #include <rte_log.h> +#include <rte_tailq.h> #include "fd_man.h" #include "vduse.h"
lib/vhost/vdpa.c +0 -2
@@ -8,8 +8,6 @@* Device specific vhost lib */ -#include <sys/queue.h> -#include <dev_driver.h> #include <eal_export.h> #include <rte_class.h>
lib/vhost/vhost.h +1 -1
@@ -8,7 +8,6 @@#include <stdio.h> #include <stdbool.h> #include <stdlib.h> -#include <sys/queue.h> #include <unistd.h> #include <linux/virtio_net.h> #include <sys/socket.h>
@@ -19,6 +18,7 @@#include <rte_ether.h> #include <rte_malloc.h> #include <rte_dmadev.h> +#include <rte_tailq.h> #include "rte_vhost.h" #include "vdpa_driver.h"
Signature · 1 line
2.51.0
Re: [PATCH v3 11/44] lib: remove use of sys/queue.h
Quoted 4 lines · Stephen Hemminger
Use the new
rte_bsd_queue.hwhere needed but most files already get the needed macros fromrte_tailq.hSigned-off-by Stephen Hemminger <[email protected]>
[...]
lib/mempool/rte_mempool.c line 17
Quoted 12 lines
lib/mempool/rte_mempool.c +0
-1@@ -12,7 +12,6 @@#include <unistd.h> #include <inttypes.h> #include <errno.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_common.h>
I'm wondering why rte_bsd_queue.h is not added here instead of sys/queue.h since the code definitely uses corresponding macros. Is it OK to rely on indirect include via other headers?
PATCH v3 12/44 drivers/bus: replace use of sys/queue.h
In reply to Stephen HemmingerPrefer just using rte_tailq.h when TAILQ macro's are used. Other places eliminate sys/queue.h if possible.
--- drivers/bus/auxiliary/auxiliary_common.c | 2 +- drivers/bus/auxiliary/private.h | 2 +- drivers/bus/fslmc/bus_fslmc_driver.h | 1 - drivers/bus/fslmc/fslmc_vfio.c | 1 + drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 11 ++--------- drivers/bus/ifpga/ifpga_bus.c | 2 +- drivers/bus/pci/bsd/pci.c | 2 +- drivers/bus/pci/pci_common.c | 1 - drivers/bus/pci/pci_params.c | 2 -- drivers/bus/pci/windows/pci.c | 3 +-- drivers/bus/pci/windows/pci_netuio.c | 2 -- drivers/bus/platform/platform.c | 2 +- drivers/bus/vdev/vdev.c | 1 - drivers/bus/vmbus/vmbus_common.c | 1 - 14 files changed, 9 insertions(+), 24 deletions(-)
drivers/bus/auxiliary/auxiliary_common.c +1 -1
@@ -8,7 +8,7 @@#include <stdbool.h> #include <stdlib.h> #include <stdio.h> -#include <sys/queue.h> +#include <eal_export.h> #include <rte_errno.h> #include <rte_interrupts.h>
drivers/bus/auxiliary/private.h +1 -1
@@ -7,9 +7,9 @@#include <stdbool.h> #include <stdio.h> -#include <sys/queue.h> #include <bus_driver.h> +#include <rte_bsd_queue.h> #include "bus_auxiliary_driver.h"
drivers/bus/fslmc/bus_fslmc_driver.h +0 -1
@@ -17,7 +17,6 @@#include <stdlib.h> #include <limits.h> #include <errno.h> -#include <sys/queue.h> #include <stdint.h> #include <inttypes.h>
drivers/bus/fslmc/fslmc_vfio.c +1 -0
@@ -23,6 +23,7 @@#include <sys/eventfd.h> #include <ctype.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <eal_filesystem.h> #include <rte_mbuf.h>
drivers/bus/fslmc/portal/dpaa2_hw_dpio.c +2 -9
@@ -17,7 +17,6 @@#include <signal.h> #include <pthread.h> #include <sys/types.h> -#include <sys/queue.h> #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/mman.h>
@@ -34,6 +33,7 @@#include <rte_cycles.h> #include <rte_kvargs.h> #include <dev_driver.h> +#include <rte_tailq.h> #include <fslmc_logs.h> #include <bus_fslmc_driver.h>
@@ -41,13 +41,6 @@#include "dpaa2_hw_dpio.h" #include <mc/fsl_dpmng.h> -#ifndef TAILQ_FOREACH_SAFE -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif -#define NUM_HOST_CPUS RTE_MAX_LCORERTE_EXPORT_INTERNAL_SYMBOL (dpaa2_io_portal)
@@ -107,7 +100,7 @@ static struct dpaa2_dpio_dev *get_dpio_dev_from_id(int32_t dpio_id)struct dpaa2_dpio_dev *dpio_dev =NULL ;/* Get DPIO dev handle from list using index */ - TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) { + RTE_TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {if (dpio_dev->hw_id == dpio_id)break ; }
drivers/bus/ifpga/ifpga_bus.c +1 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <stdlib.h> #include <stdio.h> -#include <sys/queue.h> #include <sys/mman.h> #include <sys/types.h> #include <unistd.h>
@@ -26,6 +25,7 @@#include <rte_alarm.h> #include <rte_string_fns.h> #include <rte_debug.h> +#include <rte_tailq.h> #include "rte_rawdev.h" #include "rte_rawdev_pmd.h"
drivers/bus/pci/bsd/pci.c +1 -1
@@ -15,7 +15,6 @@#include <errno.h> #include <dirent.h> #include <limits.h> -#include <sys/queue.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <sys/pciio.h>
@@ -38,6 +37,7 @@#include <rte_string_fns.h> #include <rte_debug.h> #include <rte_devargs.h> +#include <rte_tailq.h> #include <eal_export.h> #include "eal_filesystem.h"
drivers/bus/pci/pci_common.c +0 -1
@@ -9,7 +9,6 @@#include <stdbool.h> #include <stdlib.h> #include <stdio.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_errno.h> #include <rte_interrupts.h>
drivers/bus/pci/pci_params.c +0 -2
@@ -2,8 +2,6 @@* Copyright 2018 Gaëtan Rivet */ -#include <sys/queue.h> -#include <bus_driver.h> #include <rte_bus_pci.h> #include <dev_driver.h>
drivers/bus/pci/windows/pci.c +1 -2
@@ -2,8 +2,6 @@* Copyright 2020 Mellanox Technologies, Ltd */ -#include <sys/queue.h> -#include <eal_export.h> #include <rte_windows.h> #include <rte_errno.h>
@@ -11,6 +9,7 @@#include <rte_eal.h> #include <rte_memory.h> #include <rte_bus_pci.h> +#include <rte_tailq.h> /* DEVPKEY_Device_Numa_Node should be defined in devpkey.h */ #include <devpkey.h>
drivers/bus/pci/windows/pci_netuio.c +0 -2
@@ -2,8 +2,6 @@* Copyright(c) 2020 Intel Corporation. */ -#include <sys/queue.h> -#include <rte_windows.h> #include <rte_errno.h> #include <rte_log.h>
drivers/bus/platform/platform.c +1 -1
@@ -10,7 +10,6 @@#include <string.h> #include <sys/ioctl.h> #include <sys/mman.h> -#include <sys/queue.h> #include <unistd.h> #include <bus_driver.h>
@@ -23,6 +22,7 @@#include <rte_log.h> #include <rte_memory.h> #include <rte_string_fns.h> +#include <rte_tailq.h> #include <rte_vfio.h> #include "private.h"
drivers/bus/vdev/vdev.c +0 -1
@@ -8,7 +8,6 @@#include <stdlib.h> #include <stdint.h> #include <stdbool.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_eal.h>
drivers/bus/vmbus/vmbus_common.c +0 -1
@@ -7,7 +7,6 @@#include <unistd.h> #include <dirent.h> #include <fcntl.h> -#include <sys/queue.h> #include <sys/mman.h> #include <eal_export.h>
Signature · 1 line
2.51.0
PATCH v3 13/44 net/nfp: use rte_bsd_queue.h
In reply to Stephen HemmingerCan use common macro.
--- drivers/net/nfp/nfp_mtr.c | 7 ------- drivers/net/nfp/nfp_mtr.h | 1 + 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/net/nfp/nfp_mtr.c +0 -7
@@ -12,13 +12,6 @@#include "flower/nfp_flower_representor.h" #include "nfp_logs.h" -#ifndef LIST_FOREACH_SAFE -#define LIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif -#define NFP_MAX_POLICY_CNT NFP_MAX_MTR_CNT#define NFP_MAX_PROFILE_CNT NFP_MAX_MTR_CNT
drivers/net/nfp/nfp_mtr.h +1 -0
@@ -7,6 +7,7 @@#define __NFP_MTR_H__#include <rte_mtr.h> +#include <rte_bsd_queue.h> #include "flower/nfp_flower_cmsg.h"
Signature · 1 line
2.51.0
PATCH v3 14/44 net/qede: use rte_bsd_queue.h
In reply to Stephen HemmingerThe BSD version has the needed SLIST_FOREACH_SAFE already.
--- drivers/net/qede/qede_ethdev.h | 3 +-- drivers/net/qede/qede_filter.c | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/net/qede/qede_ethdev.h +1 -2
@@ -8,8 +8,7 @@#ifndef _QEDE_ETHDEV_H_#define _QEDE_ETHDEV_H_ -#include <sys/queue.h> - +#include <rte_bsd_queue.h> #include <rte_ether.h> #include <ethdev_driver.h> #include <ethdev_pci.h>
drivers/net/qede/qede_filter.c +0 -6
@@ -12,12 +12,6 @@#include "qede_ethdev.h" -#ifndef SLIST_FOREACH_SAFE -#define SLIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif /* VXLAN tunnel classification mapping */ const struct _qede_udp_tunn_types {
Signature · 1 line
2.51.0
PATCH v3 15/44 net/bnxt: remove use of sys/queue.h
In reply to Stephen HemmingerFix unsafe use after free by using STAILQ_FOREACH_SAFE.
--- drivers/net/bnxt/bnxt.h | 1 - drivers/net/bnxt/bnxt_filter.c | 7 +++---- drivers/net/bnxt/bnxt_flow.c | 1 - drivers/net/bnxt/bnxt_vnic.h | 1 - drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 1 - drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c | 1 - 6 files changed, 3 insertions(+), 9 deletions(-)
drivers/net/bnxt/bnxt.h +0 -1
@@ -9,7 +9,6 @@#include <inttypes.h> #include <stdbool.h> #include <pthread.h> -#include <sys/queue.h> #include <rte_pci.h> #include <bus_pci_driver.h>
drivers/net/bnxt/bnxt_filter.c +3 -4
@@ -3,8 +3,7 @@* All rights reserved. */ -#include <sys/queue.h> - +#include <rte_bsd_queue.h> #include <rte_byteorder.h> #include <rte_log.h> #include <rte_malloc.h>
@@ -110,7 +109,7 @@ void bnxt_free_all_filters(struct bnxt *bp)void bnxt_free_filter_mem (struct bnxt *bp) { -struct bnxt_filter_info *filter; +struct bnxt_filter_info *filter, *tmp;uint16_t max_filters, i;int rc =0 ;
@@ -151,7 +150,7 @@ void bnxt_free_filter_mem(struct bnxt *bp) bp->filter_info =NULL ;for (i =0 ; i < bp->pf->max_vfs; i++) { - STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) { + STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next, tmp) {rte_free (filter);STAILQ_REMOVE (&bp->pf->vf_info[i].filter, filter, bnxt_filter_info, next);
drivers/net/bnxt/bnxt_flow.c +0 -1
@@ -3,7 +3,6 @@* All rights reserved. */ -#include <sys/queue.h> #include <rte_log.h> #include <rte_malloc.h>
drivers/net/bnxt/bnxt_vnic.h +0 -1
@@ -6,7 +6,6 @@#ifndef _BNXT_VNIC_H_#define _BNXT_VNIC_H_ -#include <sys/queue.h> #include <stdbool.h> #include <rte_hash.h>
drivers/net/bnxt/tf_ulp/bnxt_ulp.h +0 -1
@@ -8,7 +8,6 @@#include <inttypes.h> #include <stdbool.h> -#include <sys/queue.h> #include "rte_version.h" #include "rte_ethdev.h"
drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c +0 -1
@@ -4,7 +4,6 @@*/ #include <math.h> -#include <sys/queue.h> #include <rte_log.h> #include <rte_malloc.h>
Signature · 1 line
2.51.0
PATCH v3 16/44 net/intel: remove use of sys/queue.h
In reply to Stephen HemmingerFor all the drivers, remove use of sys/queue.h if not necessary. Remove locally defined FOREACH_SAFE macros.
Use rte_bsd_queue.h instead.
--- drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c | 1 - drivers/net/intel/e1000/e1000_ethdev.h | 1 - drivers/net/intel/e1000/em_ethdev.c | 1 - drivers/net/intel/e1000/em_rxtx.c | 1 - drivers/net/intel/e1000/igb_ethdev.c | 2 +- drivers/net/intel/e1000/igb_flow.c | 2 +- drivers/net/intel/e1000/igb_rxtx.c | 1 - drivers/net/intel/i40e/i40e_ethdev.c | 9 +++------ drivers/net/intel/i40e/i40e_ethdev.h | 1 - drivers/net/intel/i40e/i40e_fdir.c | 2 +- drivers/net/intel/i40e/i40e_flow.c | 1 - drivers/net/intel/i40e/i40e_hash.c | 1 - drivers/net/intel/i40e/i40e_pf.c | 1 - drivers/net/intel/i40e/i40e_rxtx.c | 1 - drivers/net/intel/iavf/iavf.h | 1 - drivers/net/intel/iavf/iavf_ethdev.c | 1 - drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.c | 1 - drivers/net/intel/iavf/iavf_hash.c | 1 - drivers/net/intel/iavf/iavf_rxtx.c | 1 - drivers/net/intel/iavf/iavf_vchnl.c | 7 ------- drivers/net/intel/ice/base/ice_osdep.h | 2 +- drivers/net/intel/ice/ice_acl_filter.c | 1 - drivers/net/intel/ice/ice_dcf.c | 2 +- drivers/net/intel/ice/ice_dcf_ethdev.c | 1 - drivers/net/intel/ice/ice_ethdev.c | 8 ++------ drivers/net/intel/ice/ice_generic_flow.c | 1 - drivers/net/intel/ice/ice_hash.c | 1 - drivers/net/intel/ice/ice_switch_filter.c | 1 - drivers/net/intel/idpf/base/idpf_osdep.h | 9 +-------- drivers/net/intel/ipn3ke/ipn3ke_ethdev.h | 1 - drivers/net/intel/ipn3ke/ipn3ke_flow.c | 1 - drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 1 - drivers/net/intel/ixgbe/ixgbe_fdir.c | 2 +- drivers/net/intel/ixgbe/ixgbe_flow.c | 2 +- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 1 - 38 files changed, 14 insertions(+), 61 deletions(-)
drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2022 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/e1000/e1000_ethdev.h +0 -1
@@ -6,7 +6,6 @@#define _E1000_ETHDEV_H_#include <stdint.h> -#include <sys/queue.h> #include <rte_flow.h> #include <rte_time.h>
drivers/net/intel/e1000/em_ethdev.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2010-2016 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/e1000/em_rxtx.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2010-2016 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <stdlib.h>
drivers/net/intel/e1000/igb_ethdev.c +1 -1
@@ -2,7 +2,7 @@* Copyright(c) 2010-2016 Intel Corporation */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/e1000/igb_flow.c +1 -1
@@ -2,7 +2,7 @@* Copyright(c) 2010-2016 Intel Corporation */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/e1000/igb_rxtx.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2010-2016 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <stdlib.h>
drivers/net/intel/i40e/i40e_ethdev.c +3 -6
@@ -12,6 +12,7 @@#include <inttypes.h> #include <assert.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_eal.h> #include <rte_string_fns.h>
@@ -5098,16 +5099,12 @@ i40e_res_pool_destroy(struct i40e_res_pool_info *pool)if (pool ==NULL )return ; -for (entry =LIST_FIRST (&pool->alloc_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->alloc_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); } -for (entry =LIST_FIRST (&pool->free_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->free_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); }
drivers/net/intel/i40e/i40e_ethdev.h +0 -1
@@ -6,7 +6,6 @@#define _I40E_ETHDEV_H_#include <stdint.h> -#include <sys/queue.h> #include <rte_time.h> #include <rte_kvargs.h>
drivers/net/intel/i40e/i40e_fdir.c +1 -1
@@ -2,7 +2,7 @@* Copyright(c) 2010-2015 Intel Corporation */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/i40e/i40e_flow.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2016-2017 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/i40e/i40e_hash.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2020 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/i40e/i40e_pf.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2010-2017 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/i40e/i40e_rxtx.c +0 -1
@@ -10,7 +10,6 @@#include <stdarg.h> #include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <rte_string_fns.h> #include <rte_memzone.h>
drivers/net/intel/iavf/iavf.h +0 -1
@@ -5,7 +5,6 @@#ifndef _IAVF_ETHDEV_H_#define _IAVF_ETHDEV_H_ -#include <sys/queue.h> #include <rte_kvargs.h> #include <rte_tm_driver.h>
drivers/net/intel/iavf/iavf_ethdev.c +0 -1
@@ -3,7 +3,6 @@*/ #include <ctype.h> -#include <sys/queue.h> #include <stdalign.h> #include <stdio.h> #include <errno.h>
drivers/net/intel/iavf/iavf_fdir.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2020 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/iavf/iavf_fsub.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2022 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/iavf/iavf_generic_flow.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2019 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/iavf/iavf_hash.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2020 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/iavf/iavf_rxtx.c +0 -1
@@ -10,7 +10,6 @@#include <stdarg.h> #include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include <eal_export.h> #include <rte_string_fns.h>
drivers/net/intel/iavf/iavf_vchnl.c +0 -7
@@ -52,13 +52,6 @@ static struct iavf_event_handler event_handler = { .fd = {-1, -1}, }; -#ifndef TAILQ_FOREACH_SAFE -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif -static uint32_t iavf_dev_event_handle(void *param __rte_unused) {
drivers/net/intel/ice/base/ice_osdep.h +1 -1
@@ -10,9 +10,9 @@#include <stdio.h> #include <stdarg.h> #include <inttypes.h> -#include <sys/queue.h> #include <stdbool.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_memcpy.h> #include <rte_malloc.h>
drivers/net/intel/ice/ice_acl_filter.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2020 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/ice/ice_dcf.c +1 -1
@@ -2,7 +2,7 @@* Copyright(c) 2020 Intel Corporation */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/ice/ice_dcf_ethdev.c +0 -1
@@ -4,7 +4,6 @@#include <errno.h> #include <stdbool.h> -#include <sys/queue.h> #include <sys/types.h> #include <unistd.h>
drivers/net/intel/ice/ice_ethdev.c +2 -6
@@ -941,16 +941,12 @@ ice_res_pool_destroy(struct ice_res_pool_info *pool)if (!pool)return ; -for (entry =LIST_FIRST (&pool->alloc_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->alloc_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); } -for (entry =LIST_FIRST (&pool->free_list); - entry && (next_entry =LIST_NEXT (entry, next),1 ); - entry = next_entry) { + LIST_FOREACH_SAFE(entry, &pool->free_list, next, next_entry) {LIST_REMOVE (entry, next);rte_free (entry); }
drivers/net/intel/ice/ice_generic_flow.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2019 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/ice/ice_hash.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2019 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/ice/ice_switch_filter.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2019 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/idpf/base/idpf_osdep.h +1 -8
@@ -10,7 +10,7 @@#include <stdio.h> #include <stdarg.h> #include <inttypes.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdbool.h> #include <rte_common.h>
@@ -343,13 +343,6 @@ idpf_hweight32(u32 num)#define LIST_ENTRY_TYPE (type) LIST_ENTRY(type)#endif -#ifndef LIST_FOREACH_SAFE -#define LIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif -#ifndef LIST_FOR_EACH_ENTRY_SAFE #define LIST_FOR_EACH_ENTRY_SAFE (pos, temp, head, entry_type, list) \ LIST_FOREACH_SAFE(pos, head, list, temp)
drivers/net/intel/ipn3ke/ipn3ke_ethdev.h +0 -1
@@ -11,7 +11,6 @@#include <limits.h> #include <net/if.h> #include <netinet/in.h> -#include <sys/queue.h> #include <rte_mbuf.h> #include <rte_flow_driver.h>
drivers/net/intel/ipn3ke/ipn3ke_flow.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2019 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/ixgbe/ixgbe_ethdev.c +1 -1
@@ -2,7 +2,7 @@* Copyright(c) 2010-2017 Intel Corporation */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/ixgbe/ixgbe_ethdev.h +0 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <stdbool.h> -#include <sys/queue.h> #include "base/ixgbe_type.h" #include "base/ixgbe_dcb.h"
drivers/net/intel/ixgbe/ixgbe_fdir.c +1 -1
@@ -6,7 +6,7 @@#include <stdint.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_interrupts.h> #include <rte_log.h>
drivers/net/intel/ixgbe/ixgbe_flow.c +1 -1
@@ -2,7 +2,7 @@* Copyright(c) 2010-2016 Intel Corporation */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/intel/ixgbe/ixgbe_rxtx.c +0 -1
@@ -3,7 +3,6 @@* Copyright 2014 6WIND S.A. */ -#include <sys/queue.h> #include <stdio.h> #include <stdlib.h>
Signature · 1 line
2.51.0
PATCH v3 17/44 net/mlx5: remove unnecessary include of sys/queue.h
In reply to Stephen HemmingerAlready handled by rte_tailq.h in most places.
--- drivers/net/mlx5/hws/mlx5dr_internal.h | 1 - drivers/net/mlx5/linux/mlx5_verbs.c | 1 - drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_devx.c | 1 - drivers/net/mlx5/mlx5_flow.c | 2 +- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 1 - drivers/net/mlx5/mlx5_flow_verbs.c | 2 +- drivers/net/mlx5/mlx5_rx.h | 1 - drivers/net/mlx5/mlx5_rxq.c | 2 +- drivers/net/mlx5/mlx5_rxtx.h | 1 - drivers/net/mlx5/mlx5_tx.h | 1 - 12 files changed, 5 insertions(+), 12 deletions(-)
drivers/net/mlx5/hws/mlx5dr_internal.h +0 -1
@@ -6,7 +6,6 @@#define MLX5DR_INTERNAL_H_ #include <stdint.h> -#include <sys/queue.h> /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"
drivers/net/mlx5/linux/mlx5_verbs.c +0 -1
@@ -8,7 +8,6 @@#include <stdint.h> #include <unistd.h> #include <inttypes.h> -#include <sys/queue.h> #include "mlx5_autoconf.h"
drivers/net/mlx5/mlx5.h +1 -1
@@ -10,7 +10,7 @@#include <stdbool.h> #include <stdint.h> #include <limits.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_pci.h> #include <rte_ether.h>
drivers/net/mlx5/mlx5_devx.c +0 -1
@@ -7,7 +7,6 @@#include <stdbool.h> #include <string.h> #include <stdint.h> -#include <sys/queue.h> #include <rte_malloc.h> #include <rte_common.h>
drivers/net/mlx5/mlx5_flow.c +1 -1
@@ -7,7 +7,7 @@#include <stdint.h> #include <string.h> #include <stdbool.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <rte_common.h>
drivers/net/mlx5/mlx5_flow.h +1 -1
@@ -8,7 +8,7 @@#include <stdalign.h> #include <stdint.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_alarm.h> #include <rte_mtr.h>
drivers/net/mlx5/mlx5_flow_dv.c +0 -1
@@ -2,7 +2,6 @@* Copyright 2018 Mellanox Technologies, Ltd */ -#include <sys/queue.h> #include <stdalign.h> #include <stdint.h> #include <string.h>
drivers/net/mlx5/mlx5_flow_verbs.c +1 -1
@@ -3,7 +3,7 @@*/ #include <netinet/in.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdalign.h> #include <stdint.h> #include <string.h>
drivers/net/mlx5/mlx5_rx.h +0 -1
@@ -7,7 +7,6 @@#define RTE_PMD_MLX5_RX_H_ #include <stdint.h> -#include <sys/queue.h> #include <rte_mbuf.h> #include <rte_mempool.h>
drivers/net/mlx5/mlx5_rxq.c +1 -1
@@ -8,7 +8,7 @@#include <string.h> #include <stdint.h> #include <fcntl.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <eal_export.h> #include <rte_mbuf.h>
drivers/net/mlx5/mlx5_rxtx.h +0 -1
@@ -8,7 +8,6 @@#include <stddef.h> #include <stdint.h> -#include <sys/queue.h> #include <rte_mbuf.h> #include <rte_mempool.h>
drivers/net/mlx5/mlx5_tx.h +0 -1
@@ -7,7 +7,6 @@#define RTE_PMD_MLX5_TX_H_ #include <stdint.h> -#include <sys/queue.h> #include <rte_mbuf.h> #include <rte_mempool.h>
Signature · 1 line
2.51.0
PATCH v3 18/44 net/mlx4: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/mlx4/mlx4.h | 1 - drivers/net/mlx4/mlx4_flow.c | 2 +- drivers/net/mlx4/mlx4_flow.h | 1 - drivers/net/mlx4/mlx4_mr.h | 1 - drivers/net/mlx4/mlx4_rxtx.h | 1 - 5 files changed, 1 insertion(+), 5 deletions(-)
drivers/net/mlx4/mlx4.h +0 -1
@@ -8,7 +8,6 @@#include <net/if.h> #include <stdint.h> -#include <sys/queue.h> /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC
drivers/net/mlx4/mlx4_flow.c +1 -1
@@ -14,7 +14,7 @@#include <stddef.h> #include <stdint.h> #include <string.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC
drivers/net/mlx4/mlx4_flow.h +0 -1
@@ -7,7 +7,6 @@#define RTE_PMD_MLX4_FLOW_H_ #include <stdint.h> -#include <sys/queue.h> /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC
drivers/net/mlx4/mlx4_mr.h +0 -1
@@ -8,7 +8,6 @@#include <stddef.h> #include <stdint.h> -#include <sys/queue.h> /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC
drivers/net/mlx4/mlx4_rxtx.h +0 -1
@@ -7,7 +7,6 @@#define MLX4_RXTX_H_ #include <stdint.h> -#include <sys/queue.h> /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC
Signature · 1 line
2.51.0
PATCH v3 19/44 net/tap: remove unnecessary include of sys/queue.h
In reply to Stephen HemmingerThe macros in sys/queue.h are not used here.
--- drivers/net/tap/rte_eth_tap.h | 1 - drivers/net/tap/tap_flow.c | 1 - 2 files changed, 2 deletions(-)
drivers/net/tap/rte_eth_tap.h +0 -1
@@ -6,7 +6,6 @@#ifndef _RTE_ETH_TAP_H_#define _RTE_ETH_TAP_H_ -#include <sys/queue.h> #include <sys/uio.h> #include <inttypes.h> #include <net/if.h>
drivers/net/tap/tap_flow.c +0 -1
@@ -6,7 +6,6 @@#include <errno.h> #include <string.h> #include <unistd.h> -#include <sys/queue.h> #include <sys/resource.h> #include <rte_byteorder.h>
Signature · 1 line
2.51.0
PATCH v3 20/44 net/axgbe: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/axgbe/axgbe_common.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/axgbe/axgbe_common.h +0 -1
@@ -10,7 +10,6 @@#include <stdbool.h> #include <limits.h> -#include <sys/queue.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
Signature · 1 line
2.51.0
PATCH v3 21/44 net/bnx2x: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/bnx2x/bnx2x_ethdev.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/bnx2x/bnx2x_ethdev.h +0 -1
@@ -8,7 +8,6 @@#ifndef PMD_BNX2X_ETHDEV_H #define PMD_BNX2X_ETHDEV_H -#include <sys/queue.h> #include <sys/param.h> #include <sys/user.h> #include <sys/stat.h>
Signature · 1 line
2.51.0
PATCH v3 22/44 net/bonding: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/bonding/eth_bond_private.h | 1 - drivers/net/bonding/rte_eth_bond_flow.c | 1 - 2 files changed, 2 deletions(-)
drivers/net/bonding/eth_bond_private.h +0 -1
@@ -6,7 +6,6 @@#define _ETH_BOND_PRIVATE_H_#include <stdint.h> -#include <sys/queue.h> #include <ethdev_driver.h> #include <rte_flow.h>
drivers/net/bonding/rte_eth_bond_flow.c +0 -1
@@ -4,7 +4,6 @@#include <stddef.h> #include <string.h> -#include <sys/queue.h> #include <rte_errno.h> #include <rte_malloc.h>
Signature · 1 line
2.51.0
PATCH v3 23/44 net/cxgbe: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/cxgbe/cxgbe_ethdev.c | 2 +- drivers/net/cxgbe/cxgbe_main.c | 1 - drivers/net/cxgbe/sge.c | 1 - 3 files changed, 1 insertion(+), 3 deletions(-)
drivers/net/cxgbe/cxgbe_ethdev.c +1 -1
@@ -3,7 +3,7 @@* All rights reserved. */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/cxgbe/cxgbe_main.c +0 -1
@@ -3,7 +3,6 @@* All rights reserved. */ -#include <sys/queue.h> #include <sys/stat.h> #include <stdio.h> #include <errno.h>
drivers/net/cxgbe/sge.c +0 -1
@@ -3,7 +3,6 @@* All rights reserved. */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
Signature · 1 line
2.51.0
PATCH v3 24/44 net/enic: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/enic/enic.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/enic/enic.h +0 -1
@@ -21,7 +21,6 @@#include "enic_res.h" #include "cq_enet_desc.h" #include <stdbool.h> -#include <sys/queue.h> #include <rte_spinlock.h> #define DRV_NAME "enic_pmd"
Signature · 1 line
2.51.0
PATCH v3 25/44 net/failsafe: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/failsafe/failsafe_flow.c | 1 - drivers/net/failsafe/failsafe_private.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/failsafe/failsafe_flow.c +0 -1
@@ -5,7 +5,6 @@#include <stddef.h> #include <string.h> -#include <sys/queue.h> #include <rte_errno.h> #include <rte_malloc.h>
drivers/net/failsafe/failsafe_private.h +1 -1
@@ -7,7 +7,7 @@#define _ETH_FAILSAFE_PRIVATE_H_#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <pthread.h> #include <rte_atomic.h>
Signature · 1 line
2.51.0
PATCH v3 26/44 net/memif: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/memif/memif_socket.h | 1 - drivers/net/memif/rte_eth_memif.h | 1 - 2 files changed, 2 deletions(-)
drivers/net/memif/memif_socket.h +0 -1
@@ -5,7 +5,6 @@#ifndef _MEMIF_SOCKET_H_#define _MEMIF_SOCKET_H_ -#include <sys/queue.h> #include <sys/un.h> /**
drivers/net/memif/rte_eth_memif.h +0 -1
@@ -5,7 +5,6 @@#ifndef _RTE_ETH_MEMIF_H_#define _RTE_ETH_MEMIF_H_ -#include <sys/queue.h> #include <ethdev_driver.h> #include <rte_ether.h>
Signature · 1 line
2.51.0
PATCH v3 27/44 net/ngbe: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/ngbe/ngbe_ethdev_vf.c | 1 - drivers/net/ngbe/ngbe_rxtx.c | 1 - 2 files changed, 2 deletions(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +0 -1
@@ -3,7 +3,6 @@* Copyright(c) 2010-2017 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/ngbe/ngbe_rxtx.c +0 -1
@@ -3,7 +3,6 @@* Copyright(c) 2010-2017 Intel Corporation */ -#include <sys/queue.h> #include <stdint.h> #include <rte_ethdev.h>
Signature · 1 line
2.51.0
PATCH v3 28/44 net/ntnic: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/ntnic/ntnic_ethdev.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ntnic/ntnic_ethdev.c +0 -2
@@ -14,8 +14,6 @@#include <ethdev_pci.h> #include <rte_kvargs.h> -#include <sys/queue.h> -#include "rte_spinlock.h" #include "ntlog.h" #include "ntdrv_4ga.h"
Signature · 1 line
2.51.0
PATCH v3 29/44 net/sfc: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/sfc/sfc_dp.c | 2 +- drivers/net/sfc/sfc_dp.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/sfc/sfc_dp.c +1 -1
@@ -7,7 +7,7 @@* for Solarflare) and Solarflare Communications, Inc. */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <stdalign.h> #include <string.h> #include <errno.h>
drivers/net/sfc/sfc_dp.h +0 -1
@@ -11,7 +11,6 @@#define _SFC_DP_H#include <stdbool.h> -#include <sys/queue.h> #include <rte_pci.h>
Signature · 1 line
2.51.0
Re: [PATCH v3 29/44] net/sfc: replace use of sys/queue.h
Quoted 3 lines · Stephen Hemminger
Replace use of system
sys/queue.hwith DPDKrte_bsd_queue.hSigned-off-by Stephen Hemminger <[email protected]>
[...]
drivers/net/sfc/sfc_dp.h line 14
Quoted 9 lines
drivers/net/sfc/sfc_dp.h +0
-1@@ -11,7 +11,6 @@#define _SFC_DP_H#include <stdbool.h> -#include <sys/queue.h>
rte_bsd_queue.h should be added instead, since the header uses TAILQ_ENTRY/HEAD macros.
Quoted 3 lines
drivers/net/sfc/sfc_dp.h +0
-0#include <rte_pci.h>
PATCH v3 30/44 net/softnic: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/softnic/rte_eth_softnic_internals.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/softnic/rte_eth_softnic_internals.h +0 -1
@@ -7,7 +7,6 @@#include <stddef.h> #include <stdint.h> -#include <sys/queue.h> #include <rte_mempool.h> #include <rte_mbuf.h>
Signature · 1 line
2.51.0
PATCH v3 31/44 net/thunderx: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/thunderx/base/nicvf_bsvf.h | 2 +- drivers/net/thunderx/base/nicvf_plat.h | 1 + drivers/net/thunderx/nicvf_ethdev.c | 1 - 3 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/thunderx/base/nicvf_bsvf.h +1 -1
@@ -5,7 +5,7 @@#ifndef __THUNDERX_NICVF_BSVF_H__#define __THUNDERX_NICVF_BSVF_H__ -#include <sys/queue.h> +#include <rte_bsd_queue.h> struct nicvf ;
drivers/net/thunderx/base/nicvf_plat.h +1 -0
@@ -6,6 +6,7 @@#define _THUNDERX_NICVF_H/* Platform/OS/arch specific abstractions */ +#include <rte_bsd_queue.h> /* log */ #include <rte_log.h>
drivers/net/thunderx/nicvf_ethdev.c +0 -1
@@ -12,7 +12,6 @@#include <stdarg.h> #include <inttypes.h> #include <netinet/in.h> -#include <sys/queue.h> #include <rte_alarm.h> #include <rte_branch_prediction.h>
Signature · 1 line
2.51.0
PATCH v3 32/44 net/txgbe: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/txgbe/txgbe_ethdev_vf.c | 1 - drivers/net/txgbe/txgbe_fdir.c | 2 +- drivers/net/txgbe/txgbe_flow.c | 2 +- drivers/net/txgbe/txgbe_rxtx.c | 1 - 4 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/txgbe/txgbe_ethdev_vf.c +0 -1
@@ -3,7 +3,6 @@* Copyright(c) 2010-2017 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/txgbe/txgbe_fdir.c +1 -1
@@ -7,7 +7,7 @@#include <stdint.h> #include <stdarg.h> #include <errno.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_malloc.h> #include "txgbe_logs.h"
drivers/net/txgbe/txgbe_flow.c +1 -1
@@ -3,7 +3,7 @@* Copyright(c) 2010-2017 Intel Corporation */ -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <bus_pci_driver.h> #include <rte_malloc.h> #include <rte_flow.h>
drivers/net/txgbe/txgbe_rxtx.c +0 -1
@@ -3,7 +3,6 @@* Copyright(c) 2010-2017 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <stdlib.h>
Signature · 1 line
2.51.0
PATCH v3 33/44 net/vdev_netvsc: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vdev_netvsc/vdev_netvsc.c +1 -1
@@ -19,7 +19,7 @@#include <stdio.h> #include <string.h> #include <sys/ioctl.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <sys/socket.h> #include <unistd.h>
Signature · 1 line
2.51.0
PATCH v3 34/44 net/vmxnet3: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/vmxnet3/vmxnet3_ethdev.c | 1 - drivers/net/vmxnet3/vmxnet3_rxtx.c | 1 - 2 files changed, 2 deletions(-)
drivers/net/vmxnet3/vmxnet3_ethdev.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2010-2015 Intel Corporation */ -#include <sys/queue.h> #include <stdalign.h> #include <stdio.h> #include <errno.h>
drivers/net/vmxnet3/vmxnet3_rxtx.c +0 -1
@@ -2,7 +2,6 @@* Copyright(c) 2010-2015 Intel Corporation */ -#include <sys/queue.h> #include <stdio.h> #include <stdlib.h>
Signature · 1 line
2.51.0
PATCH v3 35/44 net/zxdh: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/zxdh/zxdh_mtr.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/zxdh/zxdh_mtr.h +0 -1
@@ -7,7 +7,6 @@#include <stddef.h> #include <stdint.h> -#include <sys/queue.h> #include <rte_mtr.h> #include "zxdh_np.h"
Signature · 1 line
2.51.0
PATCH v3 36/44 net/dpaa2: replace use of sys/queue.h
In reply to Stephen HemmingerReplace use of system sys/queue.h with DPDK rte_bsd_queue.h
--- drivers/net/dpaa2/dpaa2_flow.c | 1 - drivers/net/dpaa2/dpaa2_mux.c | 1 - drivers/net/dpaa2/dpaa2_ptp.c | 1 - 3 files changed, 3 deletions(-)
drivers/net/dpaa2/dpaa2_flow.c +0 -1
@@ -2,7 +2,6 @@* Copyright 2018-2022 NXP */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/dpaa2/dpaa2_mux.c +0 -1
@@ -2,7 +2,6 @@* Copyright 2018-2021,2023 NXP */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
drivers/net/dpaa2/dpaa2_ptp.c +0 -1
@@ -2,7 +2,6 @@* Copyright 2019, 2023 NXP */ -#include <sys/queue.h> #include <stdio.h> #include <errno.h> #include <stdint.h>
Signature · 1 line
2.51.0
PATCH v3 37/44 net/mvpp2: replace local definition of FOREACH_SAFE
In reply to Stephen HemmingerThere is now a standard macro for this.
--- drivers/net/mvpp2/mrvl_mtr.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/mvpp2/mrvl_mtr.c +2 -6
@@ -505,13 +505,9 @@ mrvl_mtr_deinit(struct rte_eth_dev *dev)struct mrvl_mtr_profile *profile, *tmp_profile;struct mrvl_mtr *mtr, *tmp_mtr; -for (mtr =LIST_FIRST (&priv->mtrs); - mtr && (tmp_mtr =LIST_NEXT (mtr, next),1 ); - mtr = tmp_mtr) + LIST_FOREACH_SAFE(mtr, &priv->mtrs, next, tmp_mtr)mrvl_destroy (dev, mtr->mtr_id,NULL ); -for (profile =LIST_FIRST (&priv->profiles); - profile && (tmp_profile =LIST_NEXT (profile, next),1 ); - profile = tmp_profile) + LIST_FOREACH_SAFE(profile, &priv_profiles, next, tmp_profile)mrvl_meter_profile_delete (dev, profile->profile_id,NULL ); }
Signature · 1 line
2.51.0
PATCH v3 38/44 raw/ifpga: replace with TAILQ_FOREACH_SAFE
In reply to Stephen HemmingerThere is now a standard macro to safely walk tailq.
--- drivers/raw/ifpga/base/ifpga_enumerate.c | 6 +++--- drivers/raw/ifpga/base/opae_hw_api.h | 1 - drivers/raw/ifpga/base/opae_intel_max10.c | 8 +------- drivers/raw/ifpga/base/osdep_rte/osdep_generic.h | 1 + 4 files changed, 5 insertions(+), 11 deletions(-)
drivers/raw/ifpga/base/ifpga_enumerate.c +3 -3
@@ -6,6 +6,8 @@#include <inttypes.h> #include <unistd.h> +#include <rte_bsd_queue.h> +#include "opae_hw_api.h" #include "ifpga_api.h"
@@ -725,9 +727,7 @@ static void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info)return ;/* remove all device feature lists in the list. */ -for (dfl =TAILQ_FIRST (&info->dfls); - dfl && (tmp =TAILQ_NEXT (dfl, node),1 ); - dfl = tmp) { + TAILQ_FOREACH_SAFE(dfl, &info->dfls, node, tmp) {TAILQ_REMOVE (&info->dfls, dfl, node);opae_free (dfl); }
drivers/raw/ifpga/base/opae_hw_api.h +0 -1
@@ -8,7 +8,6 @@#include <stdint.h> #include <stdlib.h> #include <stdio.h> -#include <sys/queue.h> #include "opae_osdep.h" #include "opae_intel_max10.h"
drivers/raw/ifpga/base/opae_intel_max10.c +1 -7
@@ -4,14 +4,8 @@#include "opae_intel_max10.h" #include <libfdt.h> -#include "opae_osdep.h" -#ifndef TAILQ_FOREACH_SAFE -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) -#endif +#include "opae_osdep.h" int max10_sys_read (struct intel_max10_device *dev,unsigned int offset,unsigned int *val)
drivers/raw/ifpga/base/osdep_rte/osdep_generic.h +1 -0
@@ -8,6 +8,7 @@#include <stdlib.h> #include <rte_common.h> +#include <rte_bsd_queue.h> #include <rte_cycles.h> #include <rte_spinlock.h> #include <rte_log.h>
Signature · 1 line
2.51.0
PATCH v3 39/44 drivers/vdpa: replace use of sys/queue.h
In reply to Stephen HemmingerUse rte_bsd_queue.h instead.
--- drivers/vdpa/mlx5/mlx5_vdpa.h | 3 ++- drivers/vdpa/sfc/sfc_vdpa.c | 2 +- drivers/vdpa/sfc/sfc_vdpa.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/vdpa/mlx5/mlx5_vdpa.h +2 -1
@@ -6,7 +6,8 @@#define RTE_PMD_MLX5_VDPA_H_ #include <linux/virtio_net.h> -#include <sys/queue.h> + +#include <rte_bsd_queue.h> #ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"
drivers/vdpa/sfc/sfc_vdpa.c +1 -1
@@ -5,8 +5,8 @@#include <stdbool.h> #include <stdint.h> #include <pthread.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_devargs.h> #include <rte_errno.h>
drivers/vdpa/sfc/sfc_vdpa.h +1 -1
@@ -6,8 +6,8 @@#define _SFC_VDPA_H#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <bus_pci_driver.h> #include "sfc_efx.h"
Signature · 1 line
2.51.0
Re: [PATCH v3 39/44] drivers/vdpa: replace use of sys/queue.h
Quoted 53 lines · Stephen Hemminger
Use
rte_bsd_queue.hinstead.Signed-off-by Stephen Hemminger <[email protected]>--- drivers/vdpa/mlx5/mlx5_vdpa.h | 3 ++- drivers/vdpa/sfc/sfc_vdpa.c | 2 +- drivers/vdpa/sfc/sfc_vdpa.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)drivers/vdpa/mlx5/mlx5_vdpa.h +2
-1@@ -6,7 +6,8 @@#define RTE_PMD_MLX5_VDPA_H_ #include <linux/virtio_net.h> -#include <sys/queue.h> + +#include <rte_bsd_queue.h> #ifdef PEDANTIC #pragma GCC diagnostic ignored "-Wpedantic"drivers/vdpa/sfc/sfc_vdpa.c +1
-1@@ -5,8 +5,8 @@#include <stdbool.h> #include <stdint.h> #include <pthread.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_common.h> #include <rte_devargs.h> #include <rte_errno.h> drivers/vdpa/sfc/sfc_vdpa.h +1
-2@@ -6,8 +6,8 @@#define _SFC_VDPA_H#include <stdint.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <bus_pci_driver.h> #include "sfc_efx.h" --
Quoted 2 lines
2.51.0
Thanks,
Maxime
PATCH v3 40/44 drivers/common: remove use of sys/queue.h
In reply to Stephen HemmingerThe system version of queue.h should not be used.
--- drivers/common/cnxk/roc_bphy_irq.c | 3 ++- drivers/common/cnxk/roc_npc.h | 2 -- drivers/common/mlx5/mlx5_common_mr.h | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/common/cnxk/roc_bphy_irq.c +2 -1
@@ -5,9 +5,10 @@#include <pthread.h> #include <sys/ioctl.h> #include <sys/mman.h> -#include <sys/queue.h> #include <unistd.h> +#include <rte_bsd_queue.h> +#include "roc_api.h" #include "roc_bphy_irq.h"
drivers/common/cnxk/roc_npc.h +0 -2
@@ -5,8 +5,6 @@#ifndef _ROC_NPC_H_#define _ROC_NPC_H_ -#include <sys/queue.h> -enum roc_npc_item_type {ROC_NPC_ITEM_TYPE_VOID , ROC_NPC_ITEM_TYPE_ANY,
drivers/common/mlx5/mlx5_common_mr.h +1 -2
@@ -8,10 +8,9 @@#include <stddef.h> #include <stdint.h> -#include <sys/queue.h> -#include <rte_compat.h> +#include <rte_bsd_queue.h> #include <rte_rwlock.h> #include <rte_bitmap.h> #include <rte_mbuf.h>
Signature · 1 line
2.51.0
PATCH v3 41/44 drivers/crypto: remove use of sys_queue.h
In reply to Stephen HemmingerThe system version of queue.h should not be used.
If necessary use rte_bsd_queue.h
--- drivers/crypto/bcmfs/bcmfs_device.c | 2 +- drivers/crypto/bcmfs/bcmfs_device.h | 2 -- drivers/crypto/ccp/ccp_crypto.c | 1 - drivers/crypto/ccp/ccp_dev.c | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-)
drivers/crypto/bcmfs/bcmfs_device.c +1 -1
@@ -6,8 +6,8 @@#include <dirent.h> #include <stdbool.h> #include <stdlib.h> -#include <sys/queue.h> +#include <rte_bsd_queue.h> #include <rte_malloc.h> #include <rte_string_fns.h>
drivers/crypto/bcmfs/bcmfs_device.h +0 -2
@@ -6,8 +6,6 @@#ifndef _BCMFS_DEVICE_H_#define _BCMFS_DEVICE_H_ -#include <sys/queue.h> -#include <rte_spinlock.h> #include <bus_vdev_driver.h>
drivers/crypto/ccp/ccp_crypto.c +0 -1
@@ -9,7 +9,6 @@#include <stdio.h> #include <string.h> #include <sys/mman.h> -#include <sys/queue.h> #include <sys/types.h> #include <unistd.h> #include <openssl/sha.h>
drivers/crypto/ccp/ccp_dev.c +1 -1
@@ -7,11 +7,11 @@#include <stdio.h> #include <string.h> #include <sys/mman.h> -#include <sys/queue.h> #include <sys/types.h> #include <sys/file.h> #include <unistd.h> +#include <rte_bsd_queue.h> #include <rte_hexdump.h> #include <rte_memzone.h> #include <rte_malloc.h>
Signature · 1 line
2.51.0
PATCH v3 42/44 drivers/event: remove include of sys/queue.h
In reply to Stephen HemmingerThe system version of queue.h is no longer used.
--- drivers/event/dlb2/dlb2_selftest.c | 1 - drivers/event/opdl/opdl_test.c | 1 - drivers/event/sw/sw_evdev_selftest.c | 1 - 3 files changed, 3 deletions(-)
drivers/event/dlb2/dlb2_selftest.c +0 -1
@@ -7,7 +7,6 @@#include <stdint.h> #include <errno.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_memzone.h>
drivers/event/opdl/opdl_test.c +0 -1
@@ -8,7 +8,6 @@#include <stdlib.h> #include <errno.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_memzone.h>
drivers/event/sw/sw_evdev_selftest.c +0 -1
@@ -9,7 +9,6 @@#include <stdlib.h> #include <errno.h> #include <unistd.h> -#include <sys/queue.h> #include <rte_memory.h> #include <rte_launch.h>
Signature · 1 line
2.51.0
PATCH v3 43/44 eal: remove no longer used windows version of sys/queue.h
In reply to Stephen HemmingerSuperseded by common rte_bsd_queue.h
--- lib/eal/windows/include/sys/queue.h | 840 ---------------------------- 1 file changed, 840 deletions(-) delete mode 100644 lib/eal/windows/include/sys/queue.h
lib/eal/windows/include/sys/queue.h deleted +0 -840
@@ -1,840 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause -* -* Copyright (c) 1991, 1993 -* The Regents of the University of California. All rights reserved. -*/ - -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ - -/* -* This file defines four types of data structures: singly-linked lists, -* singly-linked tail queues, lists and tail queues. -* -* A singly-linked list is headed by a single forward pointer. The elements -* are singly linked for minimum space and pointer manipulation overhead at -* the expense of O(n) removal for arbitrary elements. New elements can be -* added to the list after an existing element or at the head of the list. -* Elements being removed from the head of the list should use the explicit -* macro for this purpose for optimum efficiency. A singly-linked list may -* only be traversed in the forward direction. Singly-linked lists are ideal -* for applications with large datasets and few or no removals or for -* implementing a LIFO queue. -* -* A singly-linked tail queue is headed by a pair of pointers, one to the -* head of the list and the other to the tail of the list. The elements are -* singly linked for minimum space and pointer manipulation overhead at the -* expense of O(n) removal for arbitrary elements. New elements can be added -* to the list after an existing element, at the head of the list, or at the -* end of the list. Elements being removed from the head of the tail queue -* should use the explicit macro for this purpose for optimum efficiency. -* A singly-linked tail queue may only be traversed in the forward direction. -* Singly-linked tail queues are ideal for applications with large datasets -* and few or no removals or for implementing a FIFO queue. -* -* A list is headed by a single forward pointer (or an array of forward -* pointers for a hash table header). The elements are doubly linked -* so that an arbitrary element can be removed without a need to -* traverse the list. New elements can be added to the list before -* or after an existing element or at the head of the list. A list -* may be traversed in either direction. -* -* A tail queue is headed by a pair of pointers, one to the head of the -* list and the other to the tail of the list. The elements are doubly -* linked so that an arbitrary element can be removed without a need to -* traverse the list. New elements can be added to the list before or -* after an existing element, at the head of the list, or at the end of -* the list. A tail queue may be traversed in either direction. -* -* For details on the use of these macros, see the queue(3) manual page. -* -* Below is a summary of implemented functions where: -* + means the macro is available -* - means the macro is not available -* s means the macro is available but is slow (runs in O(n) time) -* -* SLIST LIST STAILQ TAILQ -* _HEAD + + + + -* _CLASS_HEAD + + + + -* _HEAD_INITIALIZER + + + + -* _ENTRY + + + + -* _CLASS_ENTRY + + + + -* _INIT + + + + -* _EMPTY + + + + -* _FIRST + + + + -* _NEXT + + + + -* _PREV - + - + -* _LAST - - + + -* _LAST_FAST - - - + -* _FOREACH + + + + -* _FOREACH_FROM + + + + -* _FOREACH_SAFE + + + + -* _FOREACH_FROM_SAFE + + + + -* _FOREACH_REVERSE - - - + -* _FOREACH_REVERSE_FROM - - - + -* _FOREACH_REVERSE_SAFE - - - + -* _FOREACH_REVERSE_FROM_SAFE - - - + -* _INSERT_HEAD + + + + -* _INSERT_BEFORE - + - + -* _INSERT_AFTER + + + + -* _INSERT_TAIL - - + + -* _CONCAT s s + + -* _REMOVE_AFTER + - + - -* _REMOVE_HEAD + - + - -* _REMOVE s + s + -* _SWAP + + + + -*/ -#ifdef QUEUE_MACRO_DEBUG -#warn Use QUEUE_MACRO_DEBUG_TRACE and/or QUEUE_MACRO_DEBUG_TRASH -#define QUEUE_MACRO_DEBUG_TRACE -#define QUEUE_MACRO_DEBUG_TRASH -#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; -}; - -#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 */ - -#ifdef __cplusplus -/* -* In C++ there can be structure lists and class lists: -*/ -#define QUEUE_TYPEOF (type) type -#else -#define QUEUE_TYPEOF (type) struct type -#endif - -/* -* Singly-linked List declarations. -*/ -#define SLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define SLIST_CLASS_HEAD(name, type) \ -struct name { \ - class type *slh_first; /* first element */ \ -} - -#define SLIST_HEAD_INITIALIZER (head) \ - { NULL } - -#define SLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -#define SLIST_CLASS_ENTRY(type) \ -struct { \ - class type *sle_next; /* next element */ \ -} - -/* -* Singly-linked List functions. -*/ -#if (defined(_KERNEL) && defined(INVARIANTS )) -#define QMD_SLIST_CHECK_PREVPTR (prevp, elm) do { \ - if (*(prevp) != (elm)) \ - panic("Bad prevptr *(%p) == %p != %p", \ - (prevp), *(prevp), (elm)); \ -} while (0) -#else -#define QMD_SLIST_CHECK_PREVPTR (prevp, elm) -#endif - -#define SLIST_CONCAT (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head1); \ - if (curelm == NULL) { \ - if ((SLIST_FIRST(head1) = SLIST_FIRST(head2)) != NULL) \ - SLIST_INIT(head2); \ - } else if (SLIST_FIRST(head2) != NULL) { \ - while (SLIST_NEXT(curelm, field) != NULL) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_NEXT(curelm, field) = SLIST_FIRST(head2); \ - SLIST_INIT(head2); \ - } \ -} while (0) - -#define SLIST_EMPTY (head) ((head)->slh_first == NULL) - -#define SLIST_FIRST (head) ((head)->slh_first) - -#define SLIST_FOREACH (var, head, field) \ - for ((var) = SLIST_FIRST((head)); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var); \ - (var) = SLIST_NEXT((var), field)) - -#define SLIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = SLIST_FIRST((head)); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ - (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define SLIST_FOREACH_PREVPTR (var, varp, head, field) \ - for ((varp) = &SLIST_FIRST((head)); \ - ((var) = *(varp)) != NULL; \ - (varp) = &SLIST_NEXT((var), field)) - -#define SLIST_INIT (head) do { \ - SLIST_FIRST((head)) = NULL; \ -} while (0) - -#define SLIST_INSERT_AFTER (slistelm, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ - SLIST_NEXT((slistelm), field) = (elm); \ -} while (0) - -#define SLIST_INSERT_HEAD (head, elm, field) do { \ - SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ - SLIST_FIRST((head)) = (elm); \ -} while (0) - -#define SLIST_NEXT (elm, field) ((elm)->field.sle_next) - -#define SLIST_REMOVE (head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ - if (SLIST_FIRST((head)) == (elm)) { \ - SLIST_REMOVE_HEAD((head), field); \ - } \ - else { \ - QUEUE_TYPEOF(type) *curelm = SLIST_FIRST(head); \ - while (SLIST_NEXT(curelm, field) != (elm)) \ - curelm = SLIST_NEXT(curelm, field); \ - SLIST_REMOVE_AFTER(curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define SLIST_REMOVE_AFTER (elm, field) do { \ - SLIST_NEXT(elm, field) = \ - SLIST_NEXT(SLIST_NEXT(elm, field), field); \ -} while (0) - -#define SLIST_REMOVE_HEAD (head, field) do { \ - SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ -} while (0) - -#define SLIST_REMOVE_PREVPTR (prevp, elm, field) do { \ - QMD_SLIST_CHECK_PREVPTR(prevp, elm); \ - *(prevp) = SLIST_NEXT(elm, field); \ - TRASHIT((elm)->field.sle_next); \ -} while (0) - -#define SLIST_SWAP (head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = SLIST_FIRST(head1); \ - SLIST_FIRST(head1) = SLIST_FIRST(head2); \ - SLIST_FIRST(head2) = swap_first; \ -} while (0) - -/* -* Singly-linked Tail queue declarations. -*/ -#define STAILQ_HEAD (name, type) \ -struct name { \ - struct type *stqh_first;/* first element */ \ -struct type **stqh_last;/* addr of last next element */ \ -} - -#define STAILQ_CLASS_HEAD(name, type) \ -struct name { \ - class type *stqh_first; /* first element */ \ - class type **stqh_last; /* addr of last next element */ \ -} - -#define STAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).stqh_first } - -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} - -#define STAILQ_CLASS_ENTRY(type) \ -struct { \ - class type *stqe_next; /* next element */ \ -} - -/* -* Singly-linked Tail queue functions. -*/ -#define STAILQ_CONCAT (head1, head2) do { \ - if (!STAILQ_EMPTY((head2))) { \ - *(head1)->stqh_last = (head2)->stqh_first; \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_INIT((head2)); \ - } \ -} while (0) - -#define STAILQ_EMPTY (head) ((head)->stqh_first == NULL) - -#define STAILQ_FIRST (head) ((head)->stqh_first) - -#define STAILQ_FOREACH (var, head, field) \ - for((var) = STAILQ_FIRST((head)); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var); \ - (var) = STAILQ_NEXT((var), field)) - -#define STAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = STAILQ_FIRST((head)); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ - (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define STAILQ_INIT (head) do { \ - STAILQ_FIRST((head)) = NULL; \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_INSERT_AFTER (head, tqelm, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_NEXT((tqelm), field) = (elm); \ -} while (0) - -#define STAILQ_INSERT_HEAD (head, elm, field) do { \ - if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ - STAILQ_FIRST((head)) = (elm); \ -} while (0) - -#define STAILQ_INSERT_TAIL (head, elm, field) do { \ - STAILQ_NEXT((elm), field) = NULL; \ - *(head)->stqh_last = (elm); \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_LAST (head, type, field) \ - (STAILQ_EMPTY((head)) ? NULL : \ - __containerof((head)->stqh_last, \ - QUEUE_TYPEOF(type), field.stqe_next)) - -#define STAILQ_NEXT (elm, field) ((elm)->field.stqe_next) - -#define STAILQ_REMOVE (head, elm, type, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ - if (STAILQ_FIRST((head)) == (elm)) { \ - STAILQ_REMOVE_HEAD((head), field); \ - } \ - else { \ - QUEUE_TYPEOF(type) *curelm = STAILQ_FIRST(head); \ - while (STAILQ_NEXT(curelm, field) != (elm)) \ - curelm = STAILQ_NEXT(curelm, field); \ - STAILQ_REMOVE_AFTER(head, curelm, field); \ - } \ - TRASHIT(*oldnext); \ -} while (0) - -#define STAILQ_REMOVE_AFTER (head, elm, field) do { \ - if ((STAILQ_NEXT(elm, field) = \ - STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ - (head)->stqh_last = &STAILQ_NEXT((elm), field); \ -} while (0) - -#define STAILQ_REMOVE_HEAD (head, field) do { \ - if ((STAILQ_FIRST((head)) = \ - STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ - (head)->stqh_last = &STAILQ_FIRST((head)); \ -} while (0) - -#define STAILQ_SWAP (head1, head2, type) do { \ - QUEUE_TYPEOF(type) *swap_first = STAILQ_FIRST(head1); \ - QUEUE_TYPEOF(type) **swap_last = (head1)->stqh_last; \ - STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ - (head1)->stqh_last = (head2)->stqh_last; \ - STAILQ_FIRST(head2) = swap_first; \ - (head2)->stqh_last = swap_last; \ - if (STAILQ_EMPTY(head1)) \ - (head1)->stqh_last = &STAILQ_FIRST(head1); \ - if (STAILQ_EMPTY(head2)) \ - (head2)->stqh_last = &STAILQ_FIRST(head2); \ -} while (0) - - -/* -* List declarations. -*/ -#define LIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define LIST_CLASS_HEAD(name, type) \ -struct name { \ - class type *lh_first; /* first element */ \ -} - -#define LIST_HEAD_INITIALIZER (head) \ - { NULL } - -#define LIST_ENTRY (type) \ -struct { \ - struct type *le_next;/* next element */ \ -struct type **le_prev;/* address of previous next element */ \ -} - -#define LIST_CLASS_ENTRY(type) \ -struct { \ - class type *le_next; /* next element */ \ - class type **le_prev; /* address of previous next element */ \ -} - -/* -* List functions. -*/ - -#if (defined(_KERNEL) && defined(INVARIANTS )) -/* -* QMD_LIST_CHECK_HEAD(LIST_HEAD *head, LIST_ENTRY NAME) -* -* If the list is non-empty, validates that the first element of the list -* points back at 'head.' -*/ -#define QMD_LIST_CHECK_HEAD (head, field) do { \ - if (LIST_FIRST((head)) != NULL && \ - LIST_FIRST((head))->field.le_prev != \ - &LIST_FIRST((head))) \ - panic("Bad list head %p first->prev != head", (head)); \ -} while (0) - -/* -* QMD_LIST_CHECK_NEXT(TYPE *elm, LIST_ENTRY NAME) -* -* If an element follows 'elm' in the list, validates that the next element -* points back at 'elm.' -*/ -#define QMD_LIST_CHECK_NEXT (elm, field) do { \ - if (LIST_NEXT((elm), field) != NULL && \ - LIST_NEXT((elm), field)->field.le_prev != \ - &((elm)->field.le_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -/* -* QMD_LIST_CHECK_PREV(TYPE *elm, LIST_ENTRY NAME) -* -* Validates that the previous element (or head of the list) points to 'elm.' -*/ -#define QMD_LIST_CHECK_PREV (elm, field) do { \ - if (*(elm)->field.le_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#define QMD_LIST_CHECK_HEAD (head, field) -#define QMD_LIST_CHECK_NEXT (elm, field) -#define QMD_LIST_CHECK_PREV (elm, field) -#endif /* (_KERNEL && INVARIANTS) */ - -#define LIST_CONCAT (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *curelm = LIST_FIRST(head1); \ - if (curelm == NULL) { \ - if ((LIST_FIRST(head1) = LIST_FIRST(head2)) != NULL) { \ - LIST_FIRST(head2)->field.le_prev = \ - &LIST_FIRST((head1)); \ - LIST_INIT(head2); \ - } \ - } else if (LIST_FIRST(head2) != NULL) { \ - while (LIST_NEXT(curelm, field) != NULL) \ - curelm = LIST_NEXT(curelm, field); \ - LIST_NEXT(curelm, field) = LIST_FIRST(head2); \ - LIST_FIRST(head2)->field.le_prev = &LIST_NEXT(curelm, field); \ - LIST_INIT(head2); \ - } \ -} while (0) - -#define LIST_EMPTY (head) ((head)->lh_first == NULL) - -#define LIST_FIRST (head) ((head)->lh_first) - -#define LIST_FOREACH (var, head, field) \ - for ((var) = LIST_FIRST((head)); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var); \ - (var) = LIST_NEXT((var), field)) - -#define LIST_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = LIST_FIRST((head)); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ - (var) && ((tvar) = LIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define LIST_INIT (head) do { \ - LIST_FIRST((head)) = NULL; \ -} while (0) - -#define LIST_INSERT_AFTER (listelm, elm, field) do { \ - QMD_LIST_CHECK_NEXT(listelm, field); \ - if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ - LIST_NEXT((listelm), field)->field.le_prev = \ - &LIST_NEXT((elm), field); \ - LIST_NEXT((listelm), field) = (elm); \ - (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ -} while (0) - -#define LIST_INSERT_BEFORE (listelm, elm, field) do { \ - QMD_LIST_CHECK_PREV(listelm, field); \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - LIST_NEXT((elm), field) = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ -} while (0) - -#define LIST_INSERT_HEAD (head, elm, field) do { \ - QMD_LIST_CHECK_HEAD((head), field); \ - if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ - LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ - LIST_FIRST((head)) = (elm); \ - (elm)->field.le_prev = &LIST_FIRST((head)); \ -} while (0) - -#define LIST_NEXT (elm, field) ((elm)->field.le_next) - -#define LIST_PREV (elm, head, type, field) \ - ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ - __containerof((elm)->field.le_prev, \ - QUEUE_TYPEOF(type), field.le_next)) - -#define LIST_REMOVE (elm, field) do { \ - QMD_SAVELINK(oldnext, (elm)->field.le_next); \ - QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ - QMD_LIST_CHECK_NEXT(elm, field); \ - QMD_LIST_CHECK_PREV(elm, field); \ - if (LIST_NEXT((elm), field) != NULL) \ - LIST_NEXT((elm), field)->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = LIST_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ -} while (0) - -#define LIST_SWAP (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *swap_tmp = LIST_FIRST(head1); \ - LIST_FIRST((head1)) = LIST_FIRST((head2)); \ - LIST_FIRST((head2)) = swap_tmp; \ - if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ - if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ - swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ -} while (0) - -/* -* Tail queue declarations. -*/ -#define TAILQ_HEAD (name, type) \ -struct name { \ - struct type *tqh_first;/* first element */ \ -struct type **tqh_last;/* addr of last next element */ \ - TRACEBUF \ -} - -#define TAILQ_CLASS_HEAD(name, type) \ -struct name { \ - class type *tqh_first; /* first element */ \ - class type **tqh_last; /* addr of last next element */ \ -TRACEBUF \ -} - -#define TAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } - -#define TAILQ_ENTRY (type) \ -struct { \ - struct type *tqe_next;/* next element */ \ -struct type **tqe_prev;/* address of previous next element */ \ - TRACEBUF \ -} - -#define TAILQ_CLASS_ENTRY(type) \ -struct { \ - class type *tqe_next; /* next element */ \ - class type **tqe_prev; /* address of previous next element */ \ -TRACEBUF \ -} - -/* -* Tail queue functions. -*/ -#if (defined(_KERNEL) && defined(INVARIANTS )) -/* -* QMD_TAILQ_CHECK_HEAD(TAILQ_HEAD *head, TAILQ_ENTRY NAME) -* -* If the tailq is non-empty, validates that the first element of the tailq -* points back at 'head.' -*/ -#define QMD_TAILQ_CHECK_HEAD (head, field) do { \ - if (!TAILQ_EMPTY(head) && \ - TAILQ_FIRST((head))->field.tqe_prev != \ - &TAILQ_FIRST((head))) \ - panic("Bad tailq head %p first->prev != head", (head)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_TAIL(TAILQ_HEAD *head, TAILQ_ENTRY NAME) -* -* Validates that the tail of the tailq is a pointer to pointer to NULL. -*/ -#define QMD_TAILQ_CHECK_TAIL (head, field) do { \ - if (*(head)->tqh_last != NULL) \ - panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_NEXT(TYPE *elm, TAILQ_ENTRY NAME) -* -* If an element follows 'elm' in the tailq, validates that the next element -* points back at 'elm.' -*/ -#define QMD_TAILQ_CHECK_NEXT (elm, field) do { \ - if (TAILQ_NEXT((elm), field) != NULL && \ - TAILQ_NEXT((elm), field)->field.tqe_prev != \ - &((elm)->field.tqe_next)) \ - panic("Bad link elm %p next->prev != elm", (elm)); \ -} while (0) - -/* -* QMD_TAILQ_CHECK_PREV(TYPE *elm, TAILQ_ENTRY NAME) -* -* Validates that the previous element (or head of the tailq) points to 'elm.' -*/ -#define QMD_TAILQ_CHECK_PREV (elm, field) do { \ - if (*(elm)->field.tqe_prev != (elm)) \ - panic("Bad link elm %p prev->next != elm", (elm)); \ -} while (0) -#else -#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) -#endif /* (_KERNEL && INVARIANTS) */ - -#define TAILQ_CONCAT (head1, head2, field) do { \ - if (!TAILQ_EMPTY(head2)) { \ - *(head1)->tqh_last = (head2)->tqh_first; \ - (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ - (head1)->tqh_last = (head2)->tqh_last; \ - TAILQ_INIT((head2)); \ - QMD_TRACE_HEAD(head1); \ - QMD_TRACE_HEAD(head2); \ - } \ -} while (0) - -#define TAILQ_EMPTY (head) ((head)->tqh_first == NULL) - -#define TAILQ_FIRST (head) ((head)->tqh_first) - -#define TAILQ_FOREACH (var, head, field) \ - for ((var) = TAILQ_FIRST((head)); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_FROM (var, head, field) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var); \ - (var) = TAILQ_NEXT((var), field)) - -#define TAILQ_FOREACH_SAFE (var, head, field, tvar) \ - for ((var) = TAILQ_FIRST((head)); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_FROM_SAFE (var, head, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ - (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE (var, head, headname, field) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_FROM (var, head, headname, field) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var); \ - (var) = TAILQ_PREV((var), headname, field)) - -#define TAILQ_FOREACH_REVERSE_SAFE (var, head, headname, field, tvar) \ - for ((var) = TAILQ_LAST((head), headname); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_FOREACH_REVERSE_FROM_SAFE (var, head, headname, field, tvar) \ - for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ - (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ - (var) = (tvar)) - -#define TAILQ_INIT (head) do { \ - TAILQ_FIRST((head)) = NULL; \ - (head)->tqh_last = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ -} while (0) - -#define TAILQ_INSERT_AFTER (head, listelm, elm, field) do { \ - QMD_TAILQ_CHECK_NEXT(listelm, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ - TAILQ_NEXT((elm), field)->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else { \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - } \ - TAILQ_NEXT((listelm), field) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&(listelm)->field); \ -} while (0) - -#define TAILQ_INSERT_BEFORE (listelm, elm, field) do { \ - QMD_TAILQ_CHECK_PREV(listelm, field); \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - TAILQ_NEXT((elm), field) = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_ELEM(&(elm)->field); \ - QMD_TRACE_ELEM(&(listelm)->field); \ -} while (0) - -#define TAILQ_INSERT_HEAD (head, elm, field) do { \ - QMD_TAILQ_CHECK_HEAD(head, field); \ - if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ - TAILQ_FIRST((head))->field.tqe_prev = \ - &TAILQ_NEXT((elm), field); \ - else \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - TAILQ_FIRST((head)) = (elm); \ - (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_INSERT_TAIL (head, elm, field) do { \ - QMD_TAILQ_CHECK_TAIL(head, field); \ - TAILQ_NEXT((elm), field) = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &TAILQ_NEXT((elm), field); \ - QMD_TRACE_HEAD(head); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_LAST (head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) - -/* -* The FAST function is fast in that it causes no data access other -* then the access to the head. The standard LAST function above -* will cause a data access of both the element you want and -* the previous element. FAST is very useful for instances when -* you may want to prefetch the last data element. -*/ -#define TAILQ_LAST_FAST (head, type, field) \ - (TAILQ_EMPTY(head) ? NULL : __containerof((head)->tqh_last, QUEUE_TYPEOF(type), field.tqe_next)) - -#define TAILQ_NEXT (elm, field) ((elm)->field.tqe_next) - -#define TAILQ_PREV (elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#define TAILQ_PREV_FAST (elm, head, type, field) \ - ((elm)->field.tqe_prev == &(head)->tqh_first ? NULL : \ - __containerof((elm)->field.tqe_prev, QUEUE_TYPEOF(type), field.tqe_next)) - -#define 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 ((TAILQ_NEXT((elm), field)) != NULL) \ - 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 = TAILQ_NEXT((elm), field); \ - TRASHIT(*oldnext); \ - TRASHIT(*oldprev); \ - QMD_TRACE_ELEM(&(elm)->field); \ -} while (0) - -#define TAILQ_SWAP (head1, head2, type, field) do { \ - QUEUE_TYPEOF(type) *swap_first = (head1)->tqh_first; \ - QUEUE_TYPEOF(type) **swap_last = (head1)->tqh_last; \ - (head1)->tqh_first = (head2)->tqh_first; \ - (head1)->tqh_last = (head2)->tqh_last; \ - (head2)->tqh_first = swap_first; \ - (head2)->tqh_last = swap_last; \ - if ((swap_first = (head1)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head1)->tqh_first; \ - else \ - (head1)->tqh_last = &(head1)->tqh_first; \ - if ((swap_first = (head2)->tqh_first) != NULL) \ - swap_first->field.tqe_prev = &(head2)->tqh_first; \ - else \ - (head2)->tqh_last = &(head2)->tqh_first; \ -} while (0) - -#endif /* !_SYS_QUEUE_H_ */
Signature · 1 line
2.51.0
PATCH v3 44/44 net/netvsc: use LIST_FOREACH_SAFE
In reply to Stephen HemmingerFix use after free in in remove_cache_list by using LIST_FOREACH_SAFE
--- drivers/net/netvsc/hn_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/netvsc/hn_ethdev.c +2 -2
@@ -1479,14 +1479,14 @@ static int populate_cache_list(void)static void remove_cache_list (void ) { -struct da_cache *cache; +struct da_cache *cache, *tmp;rte_spinlock_lock (&netvsc_lock); da_cache_usage--;if (da_cache_usage) goto out; - LIST_FOREACH(cache, &da_cache_list, list) { + LIST_FOREACH_SAFE(cache, &da_cache_list, list, tmp) {LIST_REMOVE (cache, list);free (cache); }
Signature · 1 line
2.51.0
RE: [PATCH v3 44/44] net/netvsc: use LIST_FOREACH_SAFE
Quoted 3 lines
Fix use after free in in
remove_cache_listby usingLIST_FOREACH_SAFESigned-off-by Stephen Hemminger <[email protected]>
Thank you.
Quoted 27 lines
--- drivers/net/netvsc/hn_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/netvsc/hn_ethdev.c +2
-3@@ -1479,14 +1479,14 @@ static int populate_cache_list(void)static void remove_cache_list (void ) { -struct da_cache *cache; +struct da_cache *cache, *tmp;rte_spinlock_lock (&netvsc_lock); da_cache_usage--;if (da_cache_usage) goto out; - LIST_FOREACH(cache, &da_cache_list, list) { + LIST_FOREACH_SAFE(cache, &da_cache_list, list, tmp) {LIST_REMOVE (cache, list);free (cache); } --2.51.0
Quoted 327 lines · On Mon, 18 Aug 2025 16:27:11 -0700 Stephen Hemminger…
This patchset cleans up the
queue.hmacro problems in DPDK. The root cause is thatsys/queue.hin Linux is an old version from early BSD; my best guess is that it is a BSD GPL license issue that it never got updated. The Linux version is missing several useful macros which leads to redefiniton, bugs, etc.The patch starts out by introducing a version of the current FreeBSD
queue.hnamed asbsd_queue.h, then uses it across all of DPDK. The filesys/queue.his no longer used. Ends up doing one line change on lots of files.Stephen Hemminger (47):
eal: add BSD version ofqueue.h
net/nfp: fix use after free
eal: usebsd_queue.h
test: remove unnecessary inclusion ofsys/queue.h
testpmd: usebsd_queue.h
dumpcap: usebsd_queue.h
proc-info: remove unnecessarysys/queue.h
doc: suggestbsd_queue.h
test-pipeline: remove unnecessary use ofsys/queue.h
test-eventdev: usebsd_queue.h
test-bbdev, test-cmdline, test-mldev: don't usesys/queue.h
examples: replace use ofsys/queue.h
hash: do not includesys/queue.h
lpm: do not includesys/queue.h
log: replace use ofsys/queue.h
ethdev: replace use ofsys/queue.h
bpf: replace use ofsys/queue.h
mempool: do not needsys/queue.h
lib: remove use ofsys/queue.h
bus/fslmc: userte_tailq.h
drivers/bus: replace use ofsys/queue.h
net/qede: usebsd_queue.h
net/bnxt: remove use ofsys/queue.h
net/intel: remove use ofsys/queue.h
net/mlx5: remove unnecessary include ofsys/queue.hnet/tap: remove unnecessary include ofsys/queue.hnet/axgbe: replace use ofsys/queue.h
net/bnx2x: replace use ofsys/queue.hnet/bonding: replace use ofsys/queue.hnet/cxgbe: replace use ofsys/queue.h
net/enic: replace use ofsys/queue.hnet/failsafe: replace use ofsys/queue.hnet/memif: replace use ofsys/queue.h
net/mlx4: replace use ofsys/queue.h
net/ngbe: replace use ofsys/queue.h
net/ntnic: replace use ofsys/queue.h
net/sfc: replace use ofsys/queue.h
net/softnic: replace use ofsys/queue.hnet/thunderx: replace use ofsys/queue.hnet/txgbe: replace use ofsys/queue.hnet/vdev_netvsc: replace use ofsys/queue.hnet/vmxnet3: replace use ofsys/queue.h
net/zxdh: replace use ofsys/queue.h
net/dpaa2: replace use ofsys/queue.h
eal: remove no longer used windows version ofqueue.hnet/mvpp2: replace local definition ofFOREACH_SAFEdrivers/raw: replace withTAILQ_FOREACH_SAFEapp/dumpcap/main.c | 2 +- app/proc-info/main.c | 1 - app/test-bbdev/main.h | 1 - app/test-cmdline/cmdline_test.c | 1 - app/test-eventdev/evt_test.c | 2 +- app/test-eventdev/evt_test.h | 1 - app/test-mldev/ml_test.h | 1 - app/test-pipeline/config.c | 1 - app/test-pipeline/init.c | 1 - app/test-pipeline/main.c | 1 - app/test-pipeline/runtime.c | 1 - app/test-pmd/5tswap.c | 2 - app/test-pmd/cmdline.c | 2 +- app/test-pmd/config.c | 2 +- app/test-pmd/csumonly.c | 1 - app/test-pmd/flowgen.c | 1 - app/test-pmd/hairpin.c | 1 - app/test-pmd/icmpecho.c | 1 - app/test-pmd/iofwd.c | 1 - app/test-pmd/macfwd.c | 1 - app/test-pmd/macswap.c | 1 - app/test-pmd/noisy_vnf.c | 1 - app/test-pmd/parameters.c | 1 - app/test-pmd/rxonly.c | 1 - app/test-pmd/testpmd.c | 1 - app/test-pmd/testpmd.h | 2 +- app/test-pmd/txonly.c | 1 - app/test/commands.c | 2 +- app/test/test.c | 1 - app/test/test.h | 2 +- app/test/test_atomic.c | 1 - app/test/test_cmdline_lib.c | 1 - app/test/test_func_reentrancy.c | 1 - app/test/test_hash.c | 1 - app/test/test_hash_functions.c | 1 - app/test/test_link_bonding.c | 1 - app/test/test_link_bonding_mode4.c | 1 - app/test/test_link_bonding_rssconf.c | 1 - app/test/test_logs.c | 1 - app/test/test_malloc.c | 1 - app/test/test_mbuf.c | 1 - app/test/test_mcslock.c | 1 - app/test/test_mempool.c | 1 - app/test/test_mempool_perf.c | 1 - app/test/test_memzone.c | 1 - app/test/test_mp_secondary.c | 1 - app/test/test_per_lcore.c | 1 - app/test/test_pflock.c | 1 - app/test/test_ring.c | 1 - app/test/test_rwlock.c | 1 - app/test/test_soring.c | 1 - app/test/test_spinlock.c | 1 - app/test/test_tailq.c | 1 - app/test/test_ticketlock.c | 1 - app/test/test_timer.c | 1 - doc/guides/contributing/coding_style.rst | 4 +- drivers/bus/auxiliary/auxiliary_common.c | 2 +- drivers/bus/auxiliary/private.h | 2 +- drivers/bus/fslmc/bus_fslmc_driver.h | 1 - drivers/bus/fslmc/fslmc_vfio.c | 1 + drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 11 +- drivers/bus/ifpga/ifpga_bus.c | 2 +- drivers/bus/pci/bsd/pci.c | 2 +- drivers/bus/pci/pci_common.c | 1 - drivers/bus/pci/pci_params.c | 2 - drivers/bus/pci/windows/pci.c | 3 +- drivers/bus/pci/windows/pci_netuio.c | 2 - drivers/bus/platform/platform.c | 2 +- drivers/bus/vdev/vdev.c | 1 - drivers/bus/vmbus/vmbus_common.c | 1 - drivers/net/axgbe/axgbe_common.h | 1 - drivers/net/bnx2x/bnx2x_ethdev.h | 1 - drivers/net/bnxt/bnxt.h | 1 - drivers/net/bnxt/bnxt_filter.c | 7 +- drivers/net/bnxt/bnxt_flow.c | 1 - drivers/net/bnxt/bnxt_vnic.h | 1 - drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 1 - drivers/net/bnxt/tf_ulp/bnxt_ulp_meter.c | 1 - drivers/net/bonding/eth_bond_private.h | 1 - drivers/net/bonding/rte_eth_bond_flow.c | 1 - drivers/net/cxgbe/cxgbe_ethdev.c | 2 +- drivers/net/cxgbe/cxgbe_main.c | 1 - drivers/net/cxgbe/sge.c | 1 - drivers/net/dpaa2/dpaa2_flow.c | 1 - drivers/net/dpaa2/dpaa2_mux.c | 1 - drivers/net/dpaa2/dpaa2_ptp.c | 1 - drivers/net/enic/enic.h | 1 - drivers/net/failsafe/failsafe_flow.c | 1 - drivers/net/failsafe/failsafe_private.h | 2 +- drivers/net/intel/cpfl/cpfl_flow_engine_fxp.c | 1 - drivers/net/intel/e1000/e1000_ethdev.h | 1 - drivers/net/intel/e1000/em_ethdev.c | 1 - drivers/net/intel/e1000/em_rxtx.c | 1 - drivers/net/intel/e1000/igb_ethdev.c | 2 +- drivers/net/intel/e1000/igb_flow.c | 2 +- drivers/net/intel/e1000/igb_rxtx.c | 1 - drivers/net/intel/i40e/i40e_ethdev.c | 9 +- drivers/net/intel/i40e/i40e_ethdev.h | 1 - drivers/net/intel/i40e/i40e_fdir.c | 2 +- drivers/net/intel/i40e/i40e_flow.c | 1 - drivers/net/intel/i40e/i40e_hash.c | 1 - drivers/net/intel/i40e/i40e_pf.c | 1 - drivers/net/intel/i40e/i40e_rxtx.c | 1 - drivers/net/intel/iavf/iavf.h | 1 - drivers/net/intel/iavf/iavf_ethdev.c | 1 - drivers/net/intel/iavf/iavf_fdir.c | 1 - drivers/net/intel/iavf/iavf_fsub.c | 1 - drivers/net/intel/iavf/iavf_generic_flow.c | 1 - drivers/net/intel/iavf/iavf_hash.c | 1 - drivers/net/intel/iavf/iavf_rxtx.c | 1 - drivers/net/intel/iavf/iavf_vchnl.c | 7 - drivers/net/intel/ice/base/ice_osdep.h | 2 +- drivers/net/intel/ice/ice_acl_filter.c | 1 - drivers/net/intel/ice/ice_dcf.c | 2 +- drivers/net/intel/ice/ice_dcf_ethdev.c | 1 - drivers/net/intel/ice/ice_ethdev.c | 8 +- drivers/net/intel/ice/ice_generic_flow.c | 1 - drivers/net/intel/ice/ice_hash.c | 1 - drivers/net/intel/ice/ice_switch_filter.c | 1 - drivers/net/intel/idpf/base/idpf_osdep.h | 9 +- drivers/net/intel/ipn3ke/ipn3ke_ethdev.h | 1 - drivers/net/intel/ipn3ke/ipn3ke_flow.c | 1 - drivers/net/intel/ixgbe/ixgbe_ethdev.c | 2 +- drivers/net/intel/ixgbe/ixgbe_ethdev.h | 1 - drivers/net/intel/ixgbe/ixgbe_fdir.c | 2 +- drivers/net/intel/ixgbe/ixgbe_flow.c | 2 +- drivers/net/intel/ixgbe/ixgbe_rxtx.c | 1 - drivers/net/memif/memif_socket.h | 1 - drivers/net/memif/rte_eth_memif.h | 1 - drivers/net/mlx4/mlx4.h | 1 - drivers/net/mlx4/mlx4_flow.c | 2 +- drivers/net/mlx4/mlx4_flow.h | 1 - drivers/net/mlx4/mlx4_mr.h | 1 - drivers/net/mlx4/mlx4_rxtx.h | 1 - drivers/net/mlx5/hws/mlx5dr_internal.h | 1 - drivers/net/mlx5/linux/mlx5_verbs.c | 1 - drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_devx.c | 1 - drivers/net/mlx5/mlx5_flow.c | 2 +- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 1 - drivers/net/mlx5/mlx5_flow_verbs.c | 2 +- drivers/net/mlx5/mlx5_rx.h | 1 - drivers/net/mlx5/mlx5_rxq.c | 2 +- drivers/net/mlx5/mlx5_rxtx.h | 1 - drivers/net/mlx5/mlx5_tx.h | 1 - drivers/net/mvpp2/mrvl_mtr.c | 8 +- drivers/net/nfp/nfp_mtr.c | 12 +- drivers/net/ngbe/ngbe_ethdev_vf.c | 1 - drivers/net/ngbe/ngbe_rxtx.c | 1 - drivers/net/ntnic/ntnic_ethdev.c | 1 - drivers/net/qede/qede_ethdev.h | 3 +- drivers/net/qede/qede_filter.c | 6 - drivers/net/sfc/sfc_dp.c | 2 +- drivers/net/sfc/sfc_dp.h | 1 - .../net/softnic/rte_eth_softnic_internals.h | 1 - drivers/net/tap/rte_eth_tap.h | 1 - drivers/net/tap/tap_flow.c | 1 - drivers/net/thunderx/base/nicvf_bsvf.h | 2 +- drivers/net/thunderx/base/nicvf_plat.h | 1 + drivers/net/thunderx/nicvf_ethdev.c | 1 - drivers/net/txgbe/txgbe_ethdev_vf.c | 1 - drivers/net/txgbe/txgbe_fdir.c | 2 +- drivers/net/txgbe/txgbe_flow.c | 2 +- drivers/net/txgbe/txgbe_rxtx.c | 1 - drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +- drivers/net/vmxnet3/vmxnet3_ethdev.c | 1 - drivers/net/vmxnet3/vmxnet3_rxtx.c | 1 - drivers/net/zxdh/zxdh_mtr.h | 1 - drivers/raw/ifpga/base/ifpga_enumerate.c | 6 +- drivers/raw/ifpga/base/opae_intel_max10.c | 8 +- examples/bbdev_app/main.c | 2 +- examples/bond/main.c | 2 +- examples/cmdline/main.c | 1 - examples/cmdline/parse_obj_list.h | 2 +- examples/flow_filtering/main.c | 1 - examples/helloworld/main.c | 2 +- examples/ip_fragmentation/main.c | 2 +- examples/ip_pipeline/action.h | 2 +- examples/ip_pipeline/cryptodev.h | 2 +- examples/ip_pipeline/link.h | 2 +- examples/ip_pipeline/mempool.h | 2 +- examples/ip_pipeline/pipeline.h | 2 +- examples/ip_pipeline/swq.h | 2 +- examples/ip_pipeline/tap.h | 2 +- examples/ip_pipeline/tmgr.h | 2 +- examples/ip_reassembly/main.c | 2 +- examples/ipsec-secgw/ipsec-secgw.c | 2 +- examples/ipv4_multicast/main.c | 2 +- examples/l2fwd-crypto/main.c | 2 +- examples/l2fwd-event/l2fwd_common.h | 1 - examples/l2fwd-keepalive/ka-agent/main.c | 1 - examples/l2fwd-keepalive/main.c | 2 +- examples/l2fwd-macsec/main.c | 2 +- examples/l2fwd/main.c | 2 +- examples/l3fwd-graph/main.c | 2 +- examples/l3fwd-power/main.c | 2 +- examples/l3fwd/l3fwd_em.c | 1 - examples/l3fwd/l3fwd_lpm.c | 1 - examples/l3fwd/main.c | 2 +- examples/link_status_interrupt/main.c | 2 +- .../client_server_mp/mp_client/client.c | 1 - .../client_server_mp/mp_server/init.c | 1 - .../client_server_mp/mp_server/main.c | 2 +- examples/multi_process/hotplug_mp/main.c | 1 - examples/multi_process/simple_mp/main.c | 2 +- examples/multi_process/symmetric_mp/main.c | 2 +- examples/server_node_efd/efd_node/node.c | 1 - examples/server_node_efd/efd_server/init.c | 1 - examples/server_node_efd/efd_server/main.c | 1 - examples/service_cores/main.c | 1 - examples/timer/main.c | 2 +- examples/vhost/main.h | 2 +- examples/vm_power_manager/channel_manager.c | 2 +- examples/vm_power_manager/channel_monitor.c | 2 +- examples/vm_power_manager/main.c | 2 +- examples/vmdq/main.c | 2 +- examples/vmdq_dcb/main.c | 2 +- lib/acl/rte_acl_osdep.h | 1 - lib/bbdev/rte_bbdev.c | 2 +- lib/bpf/bpf_load_elf.c | 1 - lib/bpf/bpf_pkt.c | 3 +- lib/cryptodev/cryptodev_pmd.c | 1 - lib/cryptodev/rte_cryptodev.c | 1 - lib/distributor/rte_distributor.c | 2 +- lib/distributor/rte_distributor_single.c | 2 +- lib/eal/common/eal_common_bus.c | 2 +- lib/eal/common/eal_common_class.c | 2 +- lib/eal/common/eal_common_dev.c | 2 +- lib/eal/common/eal_common_tailqs.c | 2 +- lib/eal/common/eal_common_trace.c | 2 +- lib/eal/common/eal_private.h | 2 +- lib/eal/common/malloc_elem.c | 2 +- lib/eal/common/malloc_heap.c | 2 +- lib/eal/common/malloc_heap.h | 2 +- lib/eal/common/rte_malloc.c | 2 +- lib/eal/freebsd/eal.c | 2 +- lib/eal/freebsd/eal_interrupts.c | 2 +- lib/eal/freebsd/eal_thread.c | 2 +- lib/eal/freebsd/include/rte_os.h | 6 +- .../sys/queue.h => include/bsd_queue.h} | 683 ++++++++++++------ lib/eal/linux/eal_alarm.c | 2 +- lib/eal/linux/eal_interrupts.c | 2 +- lib/eal/linux/include/rte_os.h | 3 +- lib/eal/windows/eal_alarm.c | 2 +- lib/efd/rte_efd.c | 1 - lib/ethdev/ethdev_private.h | 3 +- lib/ethdev/rte_ethdev.c | 2 +- lib/fib/rte_fib.c | 1 - lib/fib/rte_fib6.c | 1 - lib/gpudev/gpudev_driver.h | 1 - lib/graph/graph_private.h | 1 - lib/hash/rte_cuckoo_hash.c | 1 - lib/hash/rte_fbk_hash.c | 1 - lib/hash/rte_thash.c | 1 - lib/ip_frag/ip_frag_common.h | 3 +- lib/log/log.c | 2 +- lib/lpm/rte_lpm.c | 1 - lib/lpm/rte_lpm6.c | 1 - lib/mbuf/rte_mbuf_dyn.c | 1 - lib/mempool/rte_mempool.c | 1 - lib/pipeline/rte_swx_ctl.c | 1 - lib/pipeline/rte_swx_pipeline_internal.h | 3 +- lib/pmu/pmu.c | 1 - lib/reorder/rte_reorder.c | 1 - lib/rib/rte_rib.c | 1 - lib/rib/rte_rib6.c | 1 -
Quoted 8 lines
lib/ring/rte_ring.c | 1 -
lib/stack/rte_stack.c | 1 -
lib/vhost/fd_man.h | 1 -
lib/vhost/socket.c | 2 +-
lib/vhost/vdpa.c | 2 -
lib/vhost/vhost.h | 2 +-
273 files changed, 589 insertions(+), 562 deletions(-)
rename lib/eal/{windows/include/sys/queue.h => include/bsd_queue.h} (52%)Still not convinced that having a DPDK clone of BSD queue.h is the best solution. It creates lots of foot guns if wrong include is used.
Marking my own patch back to RFC
v5 cover Cuckoo hash optimization for small key sizes
In reply to Stephen HemmingerThis series improves the hash library's key comparison performance and portability. The main goals are:
- Hide internal implementation details to prevent future ABI breakage
- Enable optimized key comparisons on all architectures (not just x86 and ARM64)
- Add specialized compare functions for common small key sizes (2-20 bytes) to avoid memcmp overhead
- Improve test coverage and code quality
Changes in v5:
- Rebase onto latest main
- New patch: remove spurious warnings in CRC32 algorithm selection that fired even when the requested algorithm was successfully used
- Improved commit message for patch 4 (was patch 3)
- New patch: convert hash unit tests to use test suite runner framework for structured output with per-test pass/fail status
- New patch: add dedicated test for key compare functions that exercises all sizes in cmp_jump_table
- Use table lookup instead of switch statement for key size selection
- Add static_assert to verify table consistency
- Fix minor return value issues in small key compare functions
Changes in v4:
- Add test for more key sizes
- Add a few more special case sizes
Stephen Hemminger (7):
hash: move table of hash compare functions out of header
hash: use static_assert
hash: remove spurious warnings in CRC32 init
hash: simplify key comparison across architectures
hash: add support for common small key sizes app/test: convert hash test to use test suite runner test/hash: add test for key compare functions
app/test/test_hash.c | 249 +++++++++++++++++++++--------- lib/hash/rte_cmp_arm64.h | 62 +------- lib/hash/rte_cmp_generic.h | 35 +++++ lib/hash/rte_cmp_x86.h | 62 +------- lib/hash/rte_cuckoo_hash.c | 301 ++++++++++++++++++++++++++++++++----- lib/hash/rte_cuckoo_hash.h | 84 +---------- lib/hash/rte_hash_crc.c | 8 +- 7 files changed, 490 insertions(+), 311 deletions(-) create mode 100644 lib/hash/rte_cmp_generic.h
Signature · 1 line
2.51.0
PATCH v5 1/7 hash: move table of hash compare functions out of header
Remove the definition of the compare jump table from the header file so the internal details are not exposed. Prevents future ABI breakage if new sizes are added.
Make other macros local if possible, header should only contain exposed API.
--- lib/hash/rte_cuckoo_hash.c | 74 ++++++++++++++++++++++++++++++----- lib/hash/rte_cuckoo_hash.h | 79 +------------------------------------- 2 files changed, 65 insertions(+), 88 deletions(-)
lib/hash/rte_cuckoo_hash.c +64 -10
@@ -25,14 +25,51 @@#include <rte_tailq.h> #include "rte_hash.h" +#include "rte_cuckoo_hash.h" -/* needs to be before rte_cuckoo_hash.h */ RTE_LOG_REGISTER_DEFAULT (hash_logtype,INFO );#define RTE_LOGTYPE_HASH hash_logtype#define HASH_LOG (level, ...) \ RTE_LOG_LINE(level, HASH, "" __VA_ARGS__) -#include "rte_cuckoo_hash.h" +/* Macro to enable/disable run-time checking of function parameters */ +#if defined(RTE_LIBRTE_HASH_DEBUG ) +#define RETURN_IF_TRUE (cond, retval) do { \ + if (cond) \ + return retval; \ +} while (0) +#else +#define RETURN_IF_TRUE (cond, retval) +#endif + +#if defined(RTE_ARCH_X86 ) +#include "rte_cmp_x86.h" +#endif + +#if defined(RTE_ARCH_ARM64 ) +#include "rte_cmp_arm64.h" +#endif + +/* +* All different options to select a key compare function, +* based on the key size and custom function. +* Not in rte_cuckoo_hash.h to avoid ABI issues. +*/ +enum cmp_jump_table_case { +KEY_CUSTOM =0 , +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +KEY_16_BYTES , +KEY_32_BYTES , +KEY_48_BYTES , +KEY_64_BYTES , +KEY_80_BYTES , +KEY_96_BYTES , +KEY_112_BYTES , +KEY_128_BYTES , +#endif +KEY_OTHER_BYTES , +NUM_KEY_CMP_CASES , +};/* Enum used to select the implementation of the signature comparison function to use * eg: a system supporting SVE might want to use a NEON or scalar implementation.
@@ -117,6 +154,25 @@ void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func) h->rte_hash_custom_cmp_eq = func; } +/* +* Table storing all different key compare functions +* (multi-process supported) +*/ +static const rte_hash_cmp_eq_t cmp_jump_table[NUM_KEY_CMP_CASES ] = { + [KEY_CUSTOM ] =NULL , +#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64) + [KEY_16_BYTES ] = rte_hash_k16_cmp_eq, + [KEY_32_BYTES ] = rte_hash_k32_cmp_eq, + [KEY_48_BYTES ] = rte_hash_k48_cmp_eq, + [KEY_64_BYTES ] = rte_hash_k64_cmp_eq, + [KEY_80_BYTES ] = rte_hash_k80_cmp_eq, + [KEY_96_BYTES ] = rte_hash_k96_cmp_eq, + [KEY_112_BYTES ] = rte_hash_k112_cmp_eq, + [KEY_128_BYTES ] = rte_hash_k128_cmp_eq, +#endif + [KEY_OTHER_BYTES ] = memcmp, +}; +static inline int rte_hash_cmp_eq (const void *key1,const void *key2,const struct rte_hash *h) {
@@ -390,13 +446,13 @@ rte_hash_create(const struct rte_hash_parameters *params) goto err_unlock; } -/* -* If x86 architecture is used, select appropriate compare function, -* which may use x86 intrinsics, otherwise use memcmp -*/ -#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 )/* Select function to compare keys */ switch (params->key_len) { +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +/* +* If x86 architecture is used, select appropriate compare function, +* which may use x86 intrinsics, otherwise use memcmp +*/ case 16 : h->cmp_jump_table_idx =KEY_16_BYTES ;break ;
@@ -421,13 +477,11 @@ rte_hash_create(const struct rte_hash_parameters *params)case 128 : h->cmp_jump_table_idx =KEY_128_BYTES ;break ; +#endif default :/* If key is not multiple of 16, use generic memcmp */ h->cmp_jump_table_idx =KEY_OTHER_BYTES ; } -#else - h->cmp_jump_table_idx =KEY_OTHER_BYTES ; -#endif if (use_local_cache) { local_free_slots = rte_zmalloc_socket(NULL,
lib/hash/rte_cuckoo_hash.h +1 -78
94 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v5 2/7 hash: use static_assert
In reply to Stephen HemmingerNow that static_assert is available, better than pre-processor use of #if condition.
--- lib/hash/rte_cuckoo_hash.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/hash/rte_cuckoo_hash.h +2 -3
@@ -24,9 +24,8 @@*/ #define RTE_HASH_BUCKET_ENTRIES 8 -#if !RTE_IS_POWER_OF_2 (RTE_HASH_BUCKET_ENTRIES ) -#error RTE_HASH_BUCKET_ENTRIES must be a power of 2 -#endif +static_assert (RTE_IS_POWER_OF_2 (RTE_HASH_BUCKET_ENTRIES ), +"RTE_HASH_BUCKET_ENTRIES must be a power of 2" );#define NULL_SIGNATURE 0
Signature · 1 line
2.51.0
PATCH v5 3/7 hash: remove spurious warnings in CRC32 init
In reply to Stephen HemmingerThe warnings in rte_hash_crc_set_alg() were misleading - they fired when requesting a valid algorithm that would actually be used. For example, requesting CRC32_SSE42 would trigger a warning even though SSE4.2 instructions would be used successfully.
Remove the spurious warnings and only warn when the requested algorithm is truly unavailable and falling back to software CRC.
--- lib/hash/rte_hash_crc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
lib/hash/rte_hash_crc.c +1 -7
@@ -38,9 +38,6 @@ rte_hash_crc_set_alg(uint8_t alg)return ;#if definedRTE_ARCH_X86 -if (!(alg & CRC32_SSE42_x64)) -HASH_CRC_LOG (WARNING , -"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42" );if (!rte_cpu_get_flag_enabled (RTE_CPUFLAG_EM64T ) || alg ==CRC32_SSE42 ) rte_hash_crc32_alg =CRC32_SSE42 ;else
@@ -48,16 +45,13 @@ rte_hash_crc_set_alg(uint8_t alg)#endif #if definedRTE_ARCH_ARM64 -if (!(alg &CRC32_ARM64 )) -HASH_CRC_LOG (WARNING , -"Unsupported CRC32 algorithm requested using CRC32_ARM64" );if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_CRC32 )) rte_hash_crc32_alg =CRC32_ARM64 ;#endif if (rte_hash_crc32_alg ==CRC32_SW )HASH_CRC_LOG (WARNING , -"Unsupported CRC32 algorithm requested using CRC32_SW" ); +"Unsupported CRC32 algorithm requested, using CRC32_SW" ); }/* Setting the best available algorithm */
Signature · 1 line
2.51.0
PATCH v5 4/7 hash: simplify key comparison across architectures
In reply to Stephen HemmingerRefactor hash key comparison functions to reduce code duplication and improve portability:
- Keep optimized 16-byte and 32-byte comparisons for x86 (SSE) and ARM64 (NEON), but remove the larger size-specific functions (48, 64, 80, 96, 112, 128 bytes) from the architecture headers
- Add generic implementation using XOR for platforms without SIMD
- Move larger key comparison functions into rte_cuckoo_hash.c where they build upon the 16-byte primitives
- Enable optimized key comparisons on all architectures, not just x86 and ARM64
The rte_hash_k32_cmp_eq() function remains exposed because it is used internally by the IP fragmentation library.
--- lib/hash/rte_cmp_arm64.h | 62 +++------------------------ lib/hash/rte_cmp_generic.h | 35 ++++++++++++++++ lib/hash/rte_cmp_x86.h | 62 +++------------------------ lib/hash/rte_cuckoo_hash.c | 86 +++++++++++++++++++++++++++++++++----- 4 files changed, 120 insertions(+), 125 deletions(-) create mode 100644 lib/hash/rte_cmp_generic.h
lib/hash/rte_cmp_arm64.h +5 -57
@@ -2,7 +2,7 @@* Copyright(c) 2015 Cavium, Inc */ -/* Functions to compare multiple of 16 byte keys (up to 128 bytes) */ +/* Functions to compare multiple of 16 byte keys */ static inline int rte_hash_k16_cmp_eq (const void *key1,const void *key2, size_t key_len __rte_unused)
@@ -25,61 +25,9 @@ rte_hash_k16_cmp_eq(const void *key1, const void *key2, }static inline int -rte_hash_k32_cmp_eq (const void *key1,const void *key2,size_t key_len) +rte_hash_k32_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused) { -return rte_hash_k16_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +16 , - (const char *) key2 +16 , key_len); -} - -static inline int -rte_hash_k48_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k16_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +16 , - (const char *) key2 +16 , key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +32 , - (const char *) key2 +32 , key_len); -} - -static inline int -rte_hash_k64_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k32_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +32 , - (const char *) key2 +32 , key_len); -} - -static inline int -rte_hash_k80_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); -} - -static inline int -rte_hash_k96_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); -} - -static inline int -rte_hash_k112_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +96 , - (const char *) key2 +96 , key_len); -} - -static inline int -rte_hash_k128_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k64_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); +return rte_hash_k16_cmp_eq (key1, key2,16 ) | +rte_hash_k16_cmp_eq ((const uint8_t *)key1 +16 , + (const uint8_t *)key2 +16 ,16 ); }
lib/hash/rte_cmp_generic.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 Stephen Hemminger +*/ + +#ifndef _RTE_CMP_GENERIC_H_ +#define _RTE_CMP_GENERIC_H_ + +/* Function to compare 16 byte keys */ +static inline int +rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused) +{ +#ifdef RTE_ARCH_64 +const unaligned_uint64_t *k1 = key1; +const unaligned_uint64_t *k2 = key2; + +return !!((k1[0 ] ^ k2[0 ]) | (k1[1 ] ^ k2[1 ])); +#else +const unaligned_uint32_t *k1 = key1; +const unaligned_uint32_t *k2 = key2; + +return !!((k1[0 ] ^ k2[0 ]) | (k1[1 ] ^ k2[1 ]) | + (k1[2 ] ^ k2[2 ]) | (k1[3 ] ^ k2[3 ])); +#endif +} + +/* Function to compare 32 byte keys */ +static inline int +rte_hash_k32_cmp_eq (const void *key1,const void *key2,size_t key_len) +{ +return rte_hash_k16_cmp_eq (key1, key2, key_len) | +rte_hash_k16_cmp_eq ((const uint8_t *) key1 +16 , + (const uint8_t *) key2 +16 , key_len); +} + +#endif /* _RTE_CMP_GENERIC_H_ */
lib/hash/rte_cmp_x86.h +5 -57
73 lines not on this page · raw message
lib/hash/rte_cuckoo_hash.c +75 -11
120 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v5 5/7 hash: add support for common small key sizes
In reply to Stephen HemmingerAdd new compare functions for common small key sizes.
Fill in more key sizes to ensure more complete coverage of special cases.
Bugzilla ID: 1775
--- app/test/test_hash.c | 12 +- lib/hash/rte_cuckoo_hash.c | 233 +++++++++++++++++++++++++++---------- 2 files changed, 179 insertions(+), 66 deletions(-)
app/test/test_hash.c +10 -2
@@ -35,8 +35,16 @@*/ static rte_hash_function hashtest_funcs[] = {rte_jhash, rte_hash_crc};static uint32_t hashtest_initvals[] = {0 }; -static uint32_t hashtest_key_lens[] = {0 ,2 ,4 ,5 ,6 ,7 ,8 ,10 ,11 ,15 ,16 ,21 ,31 ,32 ,33 ,63 ,64 }; -#define MAX_KEYSIZE 64 + +/* +* Test common hash key lengths. Make sure and cover all the special cases +* in the cmp_jump_table. +*/ +static uint32_t hashtest_key_lens[] = { +0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,10 ,11 ,12 ,14 ,15 ,16 ,18 ,20 , +21 ,31 ,32 ,33 ,36 ,48 ,63 ,64 ,80 ,96 ,112 ,128 ,254 +}; +#define MAX_KEYSIZE 256/******************************************************************************/ #define LOCAL_FBK_HASH_ENTRIES_MAX (1 << 15)
lib/hash/rte_cuckoo_hash.c +169 -64
289 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v5 6/7 app/test: convert hash test to use test suite runner
In reply to Stephen HemmingerReplace the manual sequence of if/return checks with the unit_test_suite_runner framework. This provides structured test output with per-test pass/fail status and summary counts.
--- app/test/test_hash.c | 159 +++++++++++++++++++++++++------------------ 1 file changed, 91 insertions(+), 68 deletions(-)
app/test/test_hash.c +91 -68
@@ -2330,87 +2330,110 @@ test_hash_rcu_qsbr_dq_reclaim(void) }/* -* Do all unit and performance tests. +* Wrapper functions for tests that take parameters. */ static int -test_hash (void ) +test_average_table_utilization_no_ext (void ) { -RTE_BUILD_BUG_ON (sizeof (struct flow_key ) %sizeof (uint32_t ) !=0 ); - -if (test_add_delete () <0 ) -return -1 ; -if (test_hash_add_delete_jhash2 () <0 ) -return -1 ; -if (test_hash_add_delete_2_jhash2 () <0 ) -return -1 ; -if (test_hash_add_delete_jhash_1word () <0 ) -return -1 ; -if (test_hash_add_delete_jhash_2word () <0 ) -return -1 ; -if (test_hash_add_delete_jhash_3word () <0 ) -return -1 ; -if (test_hash_get_key_with_position () <0 ) -return -1 ; -if (test_hash_find_existing () <0 ) -return -1 ; -if (test_add_update_delete () <0 ) -return -1 ; -if (test_add_update_delete_free () <0 ) -return -1 ; -if (test_add_delete_free_lf () <0 ) -return -1 ; -if (test_five_keys () <0 ) -return -1 ; -if (test_full_bucket () <0 ) -return -1 ; -if (test_extendable_bucket () <0 ) -return -1 ; - -if (test_fbk_hash_find_existing () <0 ) -return -1 ; -if (fbk_hash_unit_test () <0 ) -return -1 ; -if (test_hash_creation_with_bad_parameters () <0 ) -return -1 ; -if (test_hash_creation_with_good_parameters () <0 ) -return -1 ; - -/* ext table disabled */ -if (test_average_table_utilization (0 ) <0 ) -return -1 ; -if (test_hash_iteration (0 ) <0 ) -return -1 ; +return test_average_table_utilization (0 ); +} -/* ext table enabled */ -if (test_average_table_utilization (1 ) <0 ) -return -1 ; -if (test_hash_iteration (1 ) <0 ) -return -1 ; +static int +test_average_table_utilization_ext (void ) +{ +return test_average_table_utilization (1 ); +} -run_hash_func_tests (); +static int +test_hash_iteration_no_ext (void ) +{ +return test_hash_iteration (0 ); +} -if (test_crc32_hash_alg_equiv () <0 ) -return -1 ; +static int +test_hash_iteration_ext (void ) +{ +return test_hash_iteration (1 ); +} -if (test_hash_rcu_qsbr_add () <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_dq_mode_no_ext (void ) +{ +return test_hash_rcu_qsbr_dq_mode (0 ); +} -if (test_hash_rcu_qsbr_dq_mode (0 ) <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_dq_mode_ext (void ) +{ +return test_hash_rcu_qsbr_dq_mode (1 ); +} -if (test_hash_rcu_qsbr_dq_mode (1 ) <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_sync_mode_no_ext (void ) +{ +return test_hash_rcu_qsbr_sync_mode (0 ); +} -if (test_hash_rcu_qsbr_sync_mode (0 ) <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_sync_mode_ext (void ) +{ +return test_hash_rcu_qsbr_sync_mode (1 ); +} -if (test_hash_rcu_qsbr_sync_mode (1 ) <0 ) -return -1 ; +static int +test_hash_func_tests (void ) +{ +run_hash_func_tests (); +return TEST_SUCCESS ; +} -if (test_hash_rcu_qsbr_dq_reclaim () <0 ) -return -1 ; +static_assert (sizeof (struct flow_key ) %sizeof (uint32_t ) ==0 , +"flow_key size must be a multiple of 4 bytes" ); + +static struct unit_test_suite hash_test_suite = { + .suite_name ="Hash Unit Test Suite" , + .unit_test_cases = { +TEST_CASE (test_add_delete), +TEST_CASE (test_hash_add_delete_jhash2), +TEST_CASE (test_hash_add_delete_2_jhash2), +TEST_CASE (test_hash_add_delete_jhash_1word), +TEST_CASE (test_hash_add_delete_jhash_2word), +TEST_CASE (test_hash_add_delete_jhash_3word), +TEST_CASE (test_hash_get_key_with_position), +TEST_CASE (test_hash_find_existing), +TEST_CASE (test_add_update_delete), +TEST_CASE (test_add_update_delete_free), +TEST_CASE (test_add_delete_free_lf), +TEST_CASE (test_five_keys), +TEST_CASE (test_full_bucket), +TEST_CASE (test_extendable_bucket), +TEST_CASE (test_fbk_hash_find_existing), +TEST_CASE (fbk_hash_unit_test), +TEST_CASE (test_hash_creation_with_bad_parameters), +TEST_CASE (test_hash_creation_with_good_parameters), +TEST_CASE (test_average_table_utilization_no_ext), +TEST_CASE (test_hash_iteration_no_ext), +TEST_CASE (test_average_table_utilization_ext), +TEST_CASE (test_hash_iteration_ext), +TEST_CASE (test_hash_func_tests), +TEST_CASE (test_crc32_hash_alg_equiv), +TEST_CASE (test_hash_rcu_qsbr_add), +TEST_CASE (test_hash_rcu_qsbr_dq_mode_no_ext), +TEST_CASE (test_hash_rcu_qsbr_dq_mode_ext), +TEST_CASE (test_hash_rcu_qsbr_sync_mode_no_ext), +TEST_CASE (test_hash_rcu_qsbr_sync_mode_ext), +TEST_CASE (test_hash_rcu_qsbr_dq_reclaim), +TEST_CASES_END () + } +}; -return 0 ; +/* +* Do all unit and performance tests. +*/ +static int +test_hash (void ) +{ +return unit_test_suite_runner (&hash_test_suite); }REGISTER_FAST_TEST (hash_autotest,NOHUGE_OK ,ASAN_OK , test_hash);
Signature · 1 line
2.51.0
PATCH v5 7/7 test/hash: add test for key compare functions
In reply to Stephen HemmingerThe hash library has optimized key compare functions for various key lengths (in rte_cmp_jump_table). Add a test that creates hash tables with each length in hashtest_key_lens[] and verifies that add, lookup, and delete work correctly. The test also verifies that the compare function properly detects when a key differs by modifying the last byte and confirming lookup fails.
--- app/test/test_hash.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
app/test/test_hash.c +78 -0
@@ -1494,6 +1494,83 @@ test_hash_creation_with_good_parameters(void)return 0 ; } +/* +* Test hash creation and key operations with various key lengths. +* This exercises the key compare functions for different sizes. +*/ +static int +test_hash_creation_with_key_lengths (void ) +{ +struct rte_hash *handle; +struct rte_hash_parameters params; +uint8_t key[MAX_KEYSIZE ]; +unsigned int i, j; +int pos, expected_pos; + +for (i =0 ; i <RTE_DIM (hashtest_key_lens); i++) { +uint32_t key_len = hashtest_key_lens[i]; + +/* key_len of 0 is invalid */ +if (key_len ==0 ) +continue ; + +memcpy (¶ms, &ut_params,sizeof (params)); + params.name ="key_len_test" ; + params.key_len = key_len; + + handle =rte_hash_create (¶ms); +if (handle ==NULL ) { +printf ("Creating hash with key_len %u failed\n" , key_len); +return -1 ; + } + +/* initialize key with pattern */ +for (j =0 ; j < key_len; j++) + key[j] = (uint8_t )j; + +/* add the key */ + pos =rte_hash_add_key (handle, key); +if (pos <0 ) { +printf ("Adding key with key_len %u failed\n" , key_len); +rte_hash_free (handle); +return -1 ; + } + expected_pos = pos; + +/* lookup should find same key */ + pos =rte_hash_lookup (handle, key); +if (pos != expected_pos) { +printf ("Lookup key with key_len %u failed: expected %d got %d\n" , + key_len, expected_pos, pos); +rte_hash_free (handle); +return -1 ; + } + +/* modify one byte and lookup should fail */ + key[key_len -1 ] ^=0xff ; + pos =rte_hash_lookup (handle, key); +if (pos != -ENOENT ) { +printf ("Lookup modified key with key_len %u should have failed\n" , + key_len); +rte_hash_free (handle); +return -1 ; + } + +/* restore key and delete */ + key[key_len -1 ] ^=0xff ; + pos =rte_hash_del_key (handle, key); +if (pos != expected_pos) { +printf ("Delete key with key_len %u failed\n" , key_len); +rte_hash_free (handle); +return -1 ; + } + +rte_hash_free (handle); + } + +return 0 ; +} +#define ITERATIONS 3/* * Test to see the average table utilization (entries added/max entries)
@@ -2411,6 +2488,7 @@ static struct unit_test_suite hash_test_suite = {TEST_CASE (fbk_hash_unit_test),TEST_CASE (test_hash_creation_with_bad_parameters),TEST_CASE (test_hash_creation_with_good_parameters), +TEST_CASE (test_hash_creation_with_key_lengths),TEST_CASE (test_average_table_utilization_no_ext),TEST_CASE (test_hash_iteration_no_ext), TEST_CASE(test_average_table_utilization_ext),
Signature · 1 line
2.51.0
v6 cover Cuckoo hash optimization for small key sizes
In reply to Stephen HemmingerThis series improves the hash library's key comparison performance and portability. The main goals are:
- Hide internal implementation details to prevent future ABI breakage
- Enable optimized key comparisons on all architectures (not just x86 and ARM64)
- Add specialized compare functions for common small key sizes (2-20 bytes) to avoid memcmp overhead
- Improve test coverage and code quality
v6 - rebase to main integrate the recent rcu test
Stephen Hemminger (7):
hash: move table of hash compare functions out of header
hash: use static_assert
hash: remove spurious warnings in CRC32 init
hash: simplify key comparison across architectures
hash: add support for common small key sizes app/test: convert hash test to use test suite runner test/hash: add test for key compare functions
app/test/test_hash.c | 253 ++++++++++++++++++++++--------- lib/hash/rte_cmp_arm64.h | 62 +------- lib/hash/rte_cmp_generic.h | 35 +++++ lib/hash/rte_cmp_x86.h | 62 +------- lib/hash/rte_cuckoo_hash.c | 301 ++++++++++++++++++++++++++++++++----- lib/hash/rte_cuckoo_hash.h | 84 +---------- lib/hash/rte_hash_crc.c | 8 +- 7 files changed, 491 insertions(+), 314 deletions(-) create mode 100644 lib/hash/rte_cmp_generic.h
Signature · 1 line
2.53.0
PATCH v6 1/7 hash: move table of hash compare functions out of header
Remove the definition of the compare jump table from the header file so the internal details are not exposed. Prevents future ABI breakage if new sizes are added.
Make other macros local if possible, header should only contain exposed API.
--- lib/hash/rte_cuckoo_hash.c | 74 ++++++++++++++++++++++++++++++----- lib/hash/rte_cuckoo_hash.h | 79 +------------------------------------- 2 files changed, 65 insertions(+), 88 deletions(-)
lib/hash/rte_cuckoo_hash.c +64 -10
@@ -25,14 +25,51 @@#include <rte_tailq.h> #include "rte_hash.h" +#include "rte_cuckoo_hash.h" -/* needs to be before rte_cuckoo_hash.h */ RTE_LOG_REGISTER_DEFAULT (hash_logtype,INFO );#define RTE_LOGTYPE_HASH hash_logtype#define HASH_LOG (level, ...) \ RTE_LOG_LINE(level, HASH, "" __VA_ARGS__) -#include "rte_cuckoo_hash.h" +/* Macro to enable/disable run-time checking of function parameters */ +#if defined(RTE_LIBRTE_HASH_DEBUG ) +#define RETURN_IF_TRUE (cond, retval) do { \ + if (cond) \ + return retval; \ +} while (0) +#else +#define RETURN_IF_TRUE (cond, retval) +#endif + +#if defined(RTE_ARCH_X86 ) +#include "rte_cmp_x86.h" +#endif + +#if defined(RTE_ARCH_ARM64 ) +#include "rte_cmp_arm64.h" +#endif + +/* +* All different options to select a key compare function, +* based on the key size and custom function. +* Not in rte_cuckoo_hash.h to avoid ABI issues. +*/ +enum cmp_jump_table_case { +KEY_CUSTOM =0 , +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +KEY_16_BYTES , +KEY_32_BYTES , +KEY_48_BYTES , +KEY_64_BYTES , +KEY_80_BYTES , +KEY_96_BYTES , +KEY_112_BYTES , +KEY_128_BYTES , +#endif +KEY_OTHER_BYTES , +NUM_KEY_CMP_CASES , +};/* Enum used to select the implementation of the signature comparison function to use * eg: a system supporting SVE might want to use a NEON or scalar implementation.
@@ -118,6 +155,25 @@ void rte_hash_set_cmp_func(struct rte_hash *h, rte_hash_cmp_eq_t func) h->rte_hash_custom_cmp_eq = func; } +/* +* Table storing all different key compare functions +* (multi-process supported) +*/ +static const rte_hash_cmp_eq_t cmp_jump_table[NUM_KEY_CMP_CASES ] = { + [KEY_CUSTOM ] =NULL , +#if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64) + [KEY_16_BYTES ] = rte_hash_k16_cmp_eq, + [KEY_32_BYTES ] = rte_hash_k32_cmp_eq, + [KEY_48_BYTES ] = rte_hash_k48_cmp_eq, + [KEY_64_BYTES ] = rte_hash_k64_cmp_eq, + [KEY_80_BYTES ] = rte_hash_k80_cmp_eq, + [KEY_96_BYTES ] = rte_hash_k96_cmp_eq, + [KEY_112_BYTES ] = rte_hash_k112_cmp_eq, + [KEY_128_BYTES ] = rte_hash_k128_cmp_eq, +#endif + [KEY_OTHER_BYTES ] = memcmp, +}; +static inline int rte_hash_cmp_eq (const void *key1,const void *key2,const struct rte_hash *h) {
@@ -406,13 +462,13 @@ rte_hash_create(const struct rte_hash_parameters *params) goto err_unlock; } -/* -* If x86 architecture is used, select appropriate compare function, -* which may use x86 intrinsics, otherwise use memcmp -*/ -#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 )/* Select function to compare keys */ switch (params->key_len) { +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM64 ) +/* +* If x86 architecture is used, select appropriate compare function, +* which may use x86 intrinsics, otherwise use memcmp +*/ case 16 : h->cmp_jump_table_idx =KEY_16_BYTES ;break ;
@@ -437,13 +493,11 @@ rte_hash_create(const struct rte_hash_parameters *params)case 128 : h->cmp_jump_table_idx =KEY_128_BYTES ;break ; +#endif default :/* If key is not multiple of 16, use generic memcmp */ h->cmp_jump_table_idx =KEY_OTHER_BYTES ; } -#else - h->cmp_jump_table_idx =KEY_OTHER_BYTES ; -#endif if (use_local_cache) { local_free_slots = rte_zmalloc_socket(NULL,
lib/hash/rte_cuckoo_hash.h +1 -78
94 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v6 2/7 hash: use static_assert
In reply to Stephen HemmingerNow that static_assert is available, better than pre-processor use of #if condition.
--- lib/hash/rte_cuckoo_hash.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
lib/hash/rte_cuckoo_hash.h +2 -3
@@ -24,9 +24,8 @@*/ #define RTE_HASH_BUCKET_ENTRIES 8 -#if !RTE_IS_POWER_OF_2 (RTE_HASH_BUCKET_ENTRIES ) -#error RTE_HASH_BUCKET_ENTRIES must be a power of 2 -#endif +static_assert (RTE_IS_POWER_OF_2 (RTE_HASH_BUCKET_ENTRIES ), +"RTE_HASH_BUCKET_ENTRIES must be a power of 2" );#define NULL_SIGNATURE 0
Signature · 1 line
2.53.0
PATCH v6 3/7 hash: remove spurious warnings in CRC32 init
In reply to Stephen HemmingerThe warnings in rte_hash_crc_set_alg() were misleading - they fired when requesting a valid algorithm that would actually be used. For example, requesting CRC32_SSE42 would trigger a warning even though SSE4.2 instructions would be used successfully.
Remove the spurious warnings and only warn when the requested algorithm is truly unavailable and falling back to software CRC.
--- lib/hash/rte_hash_crc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
lib/hash/rte_hash_crc.c +1 -7
@@ -37,9 +37,6 @@ rte_hash_crc_set_alg(uint8_t alg)return ;#if definedRTE_ARCH_X86 -if (!(alg & CRC32_SSE42_x64)) -HASH_CRC_LOG (WARNING , -"Unsupported CRC32 algorithm requested using CRC32_x64/CRC32_SSE42" );if (!rte_cpu_get_flag_enabled (RTE_CPUFLAG_EM64T ) || alg ==CRC32_SSE42 ) rte_hash_crc32_alg =CRC32_SSE42 ;else
@@ -47,16 +44,13 @@ rte_hash_crc_set_alg(uint8_t alg)#endif #if definedRTE_ARCH_ARM64 -if (!(alg &CRC32_ARM64 )) -HASH_CRC_LOG (WARNING , -"Unsupported CRC32 algorithm requested using CRC32_ARM64" );if (rte_cpu_get_flag_enabled (RTE_CPUFLAG_CRC32 )) rte_hash_crc32_alg =CRC32_ARM64 ;#endif if (rte_hash_crc32_alg ==CRC32_SW )HASH_CRC_LOG (WARNING , -"Unsupported CRC32 algorithm requested using CRC32_SW" ); +"Unsupported CRC32 algorithm requested, using CRC32_SW" ); }/* Setting the best available algorithm */
Signature · 1 line
2.53.0
PATCH v6 4/7 hash: simplify key comparison across architectures
In reply to Stephen HemmingerRefactor hash key comparison functions to reduce code duplication and improve portability:
- Keep optimized 16-byte and 32-byte comparisons for x86 (SSE) and ARM64 (NEON), but remove the larger size-specific functions (48, 64, 80, 96, 112, 128 bytes) from the architecture headers
- Add generic implementation using XOR for platforms without SIMD
- Move larger key comparison functions into rte_cuckoo_hash.c where they build upon the 16-byte primitives
- Enable optimized key comparisons on all architectures, not just x86 and ARM64
The rte_hash_k32_cmp_eq() function remains exposed because it is used internally by the IP fragmentation library.
--- lib/hash/rte_cmp_arm64.h | 62 +++------------------------ lib/hash/rte_cmp_generic.h | 35 ++++++++++++++++ lib/hash/rte_cmp_x86.h | 62 +++------------------------ lib/hash/rte_cuckoo_hash.c | 86 +++++++++++++++++++++++++++++++++----- 4 files changed, 120 insertions(+), 125 deletions(-) create mode 100644 lib/hash/rte_cmp_generic.h
lib/hash/rte_cmp_arm64.h +5 -57
@@ -2,7 +2,7 @@* Copyright(c) 2015 Cavium, Inc */ -/* Functions to compare multiple of 16 byte keys (up to 128 bytes) */ +/* Functions to compare multiple of 16 byte keys */ static inline int rte_hash_k16_cmp_eq (const void *key1,const void *key2, size_t key_len __rte_unused)
@@ -25,61 +25,9 @@ rte_hash_k16_cmp_eq(const void *key1, const void *key2, }static inline int -rte_hash_k32_cmp_eq (const void *key1,const void *key2,size_t key_len) +rte_hash_k32_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused) { -return rte_hash_k16_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +16 , - (const char *) key2 +16 , key_len); -} - -static inline int -rte_hash_k48_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k16_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +16 , - (const char *) key2 +16 , key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +32 , - (const char *) key2 +32 , key_len); -} - -static inline int -rte_hash_k64_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k32_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +32 , - (const char *) key2 +32 , key_len); -} - -static inline int -rte_hash_k80_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); -} - -static inline int -rte_hash_k96_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); -} - -static inline int -rte_hash_k112_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k32_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len) || -rte_hash_k16_cmp_eq ((const char *) key1 +96 , - (const char *) key2 +96 , key_len); -} - -static inline int -rte_hash_k128_cmp_eq (const void *key1,const void *key2,size_t key_len) -{ -return rte_hash_k64_cmp_eq (key1, key2, key_len) || -rte_hash_k64_cmp_eq ((const char *) key1 +64 , - (const char *) key2 +64 , key_len); +return rte_hash_k16_cmp_eq (key1, key2,16 ) | +rte_hash_k16_cmp_eq ((const uint8_t *)key1 +16 , + (const uint8_t *)key2 +16 ,16 ); }
lib/hash/rte_cmp_generic.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2026 Stephen Hemminger +*/ + +#ifndef _RTE_CMP_GENERIC_H_ +#define _RTE_CMP_GENERIC_H_ + +/* Function to compare 16 byte keys */ +static inline int +rte_hash_k16_cmp_eq(const void *key1, const void *key2, size_t key_len __rte_unused) +{ +#ifdef RTE_ARCH_64 +const unaligned_uint64_t *k1 = key1; +const unaligned_uint64_t *k2 = key2; + +return !!((k1[0 ] ^ k2[0 ]) | (k1[1 ] ^ k2[1 ])); +#else +const unaligned_uint32_t *k1 = key1; +const unaligned_uint32_t *k2 = key2; + +return !!((k1[0 ] ^ k2[0 ]) | (k1[1 ] ^ k2[1 ]) | + (k1[2 ] ^ k2[2 ]) | (k1[3 ] ^ k2[3 ])); +#endif +} + +/* Function to compare 32 byte keys */ +static inline int +rte_hash_k32_cmp_eq (const void *key1,const void *key2,size_t key_len) +{ +return rte_hash_k16_cmp_eq (key1, key2, key_len) | +rte_hash_k16_cmp_eq ((const uint8_t *) key1 +16 , + (const uint8_t *) key2 +16 , key_len); +} + +#endif /* _RTE_CMP_GENERIC_H_ */
lib/hash/rte_cmp_x86.h +5 -57
73 lines not on this page · raw message
lib/hash/rte_cuckoo_hash.c +75 -11
120 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v6 5/7 hash: add support for common small key sizes
In reply to Stephen HemmingerAdd new compare functions for common small key sizes.
Fill in more key sizes to ensure more complete coverage of special cases.
Bugzilla ID: 1775
--- app/test/test_hash.c | 12 +- lib/hash/rte_cuckoo_hash.c | 233 +++++++++++++++++++++++++++---------- 2 files changed, 179 insertions(+), 66 deletions(-)
app/test/test_hash.c +10 -2
@@ -35,8 +35,16 @@*/ static rte_hash_function hashtest_funcs[] = {rte_jhash, rte_hash_crc};static uint32_t hashtest_initvals[] = {0 }; -static uint32_t hashtest_key_lens[] = {0 ,2 ,4 ,5 ,6 ,7 ,8 ,10 ,11 ,15 ,16 ,21 ,31 ,32 ,33 ,63 ,64 }; -#define MAX_KEYSIZE 64 + +/* +* Test common hash key lengths. Make sure and cover all the special cases +* in the cmp_jump_table. +*/ +static uint32_t hashtest_key_lens[] = { +0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,10 ,11 ,12 ,14 ,15 ,16 ,18 ,20 , +21 ,31 ,32 ,33 ,36 ,48 ,63 ,64 ,80 ,96 ,112 ,128 ,254 +}; +#define MAX_KEYSIZE 256/******************************************************************************/ #define LOCAL_FBK_HASH_ENTRIES_MAX (1 << 15)
lib/hash/rte_cuckoo_hash.c +169 -64
289 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v6 6/7 app/test: convert hash test to use test suite runner
In reply to Stephen HemmingerReplace the manual sequence of if/return checks with the unit_test_suite_runner framework. This provides structured test output with per-test pass/fail status and summary counts.
--- app/test/test_hash.c | 163 ++++++++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 71 deletions(-)
app/test/test_hash.c +92 -71
@@ -2482,90 +2482,111 @@ test_hash_rcu_qsbr_replace_auto_free(void) }/* -* Do all unit and performance tests. +* Wrapper functions for tests that take parameters. */ static int -test_hash (void ) +test_average_table_utilization_no_ext (void ) { -RTE_BUILD_BUG_ON (sizeof (struct flow_key ) %sizeof (uint32_t ) !=0 ); - -if (test_add_delete () <0 ) -return -1 ; -if (test_hash_add_delete_jhash2 () <0 ) -return -1 ; -if (test_hash_add_delete_2_jhash2 () <0 ) -return -1 ; -if (test_hash_add_delete_jhash_1word () <0 ) -return -1 ; -if (test_hash_add_delete_jhash_2word () <0 ) -return -1 ; -if (test_hash_add_delete_jhash_3word () <0 ) -return -1 ; -if (test_hash_get_key_with_position () <0 ) -return -1 ; -if (test_hash_find_existing () <0 ) -return -1 ; -if (test_add_update_delete () <0 ) -return -1 ; -if (test_add_update_delete_free () <0 ) -return -1 ; -if (test_add_delete_free_lf () <0 ) -return -1 ; -if (test_five_keys () <0 ) -return -1 ; -if (test_full_bucket () <0 ) -return -1 ; -if (test_extendable_bucket () <0 ) -return -1 ; - -if (test_fbk_hash_find_existing () <0 ) -return -1 ; -if (fbk_hash_unit_test () <0 ) -return -1 ; -if (test_hash_creation_with_bad_parameters () <0 ) -return -1 ; -if (test_hash_creation_with_good_parameters () <0 ) -return -1 ; - -/* ext table disabled */ -if (test_average_table_utilization (0 ) <0 ) -return -1 ; -if (test_hash_iteration (0 ) <0 ) -return -1 ; - -/* ext table enabled */ -if (test_average_table_utilization (1 ) <0 ) -return -1 ; -if (test_hash_iteration (1 ) <0 ) -return -1 ; +return test_average_table_utilization (0 ); +} -run_hash_func_tests (); +static int +test_average_table_utilization_ext (void ) +{ +return test_average_table_utilization (1 ); +} -if (test_crc32_hash_alg_equiv () <0 ) -return -1 ; +static int +test_hash_iteration_no_ext (void ) +{ +return test_hash_iteration (0 ); +} -if (test_hash_rcu_qsbr_add () <0 ) -return -1 ; +static int +test_hash_iteration_ext (void ) +{ +return test_hash_iteration (1 ); +} -if (test_hash_rcu_qsbr_dq_mode (0 ) <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_dq_mode_no_ext (void ) +{ +return test_hash_rcu_qsbr_dq_mode (0 ); +} -if (test_hash_rcu_qsbr_dq_mode (1 ) <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_dq_mode_ext (void ) +{ +return test_hash_rcu_qsbr_dq_mode (1 ); +} -if (test_hash_rcu_qsbr_sync_mode (0 ) <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_sync_mode_no_ext (void ) +{ +return test_hash_rcu_qsbr_sync_mode (0 ); +} -if (test_hash_rcu_qsbr_sync_mode (1 ) <0 ) -return -1 ; +static int +test_hash_rcu_qsbr_sync_mode_ext (void ) +{ +return test_hash_rcu_qsbr_sync_mode (1 ); +} -if (test_hash_rcu_qsbr_dq_reclaim () <0 ) -return -1 ; +static int +test_hash_func_tests (void ) +{ +run_hash_func_tests (); +return TEST_SUCCESS ; +} -if (test_hash_rcu_qsbr_replace_auto_free () <0 ) -return -1 ; +static_assert (sizeof (struct flow_key ) %sizeof (uint32_t ) ==0 , +"flow_key size must be a multiple of 4 bytes" ); + +static struct unit_test_suite hash_test_suite = { + .suite_name ="Hash Unit Test Suite" , + .unit_test_cases = { +TEST_CASE (test_add_delete), +TEST_CASE (test_hash_add_delete_jhash2), +TEST_CASE (test_hash_add_delete_2_jhash2), +TEST_CASE (test_hash_add_delete_jhash_1word), +TEST_CASE (test_hash_add_delete_jhash_2word), +TEST_CASE (test_hash_add_delete_jhash_3word), +TEST_CASE (test_hash_get_key_with_position), +TEST_CASE (test_hash_find_existing), +TEST_CASE (test_add_update_delete), +TEST_CASE (test_add_update_delete_free), +TEST_CASE (test_add_delete_free_lf), +TEST_CASE (test_five_keys), +TEST_CASE (test_full_bucket), +TEST_CASE (test_extendable_bucket), +TEST_CASE (test_fbk_hash_find_existing), +TEST_CASE (fbk_hash_unit_test), +TEST_CASE (test_hash_creation_with_bad_parameters), +TEST_CASE (test_hash_creation_with_good_parameters), +TEST_CASE (test_average_table_utilization_no_ext), +TEST_CASE (test_hash_iteration_no_ext), +TEST_CASE (test_average_table_utilization_ext), +TEST_CASE (test_hash_iteration_ext), +TEST_CASE (test_hash_func_tests), +TEST_CASE (test_crc32_hash_alg_equiv), +TEST_CASE (test_hash_rcu_qsbr_add), +TEST_CASE (test_hash_rcu_qsbr_dq_mode_no_ext), +TEST_CASE (test_hash_rcu_qsbr_dq_mode_ext), +TEST_CASE (test_hash_rcu_qsbr_sync_mode_no_ext), +TEST_CASE (test_hash_rcu_qsbr_sync_mode_ext), +TEST_CASE (test_hash_rcu_qsbr_dq_reclaim), +TEST_CASE (test_hash_rcu_qsbr_replace_auto_free), +TEST_CASES_END () + } +}; -return 0 ; +/* +* Do all unit and performance tests. +*/ +static int +test_hash (void ) +{ +return unit_test_suite_runner (&hash_test_suite); }REGISTER_FAST_TEST (hash_autotest,NOHUGE_OK ,ASAN_OK , test_hash);
Signature · 1 line
2.53.0
PATCH v6 7/7 test/hash: add test for key compare functions
In reply to Stephen HemmingerThe hash library has optimized key compare functions for various key lengths (in rte_cmp_jump_table). Add a test that creates hash tables with each length in hashtest_key_lens[] and verifies that add, lookup, and delete work correctly. The test also verifies that the compare function properly detects when a key differs by modifying the last byte and confirming lookup fails.
--- app/test/test_hash.c | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
app/test/test_hash.c +78 -0
@@ -1515,6 +1515,83 @@ test_hash_creation_with_good_parameters(void)return 0 ; } +/* +* Test hash creation and key operations with various key lengths. +* This exercises the key compare functions for different sizes. +*/ +static int +test_hash_creation_with_key_lengths (void ) +{ +struct rte_hash *handle; +struct rte_hash_parameters params; +uint8_t key[MAX_KEYSIZE ]; +unsigned int i, j; +int pos, expected_pos; + +for (i =0 ; i <RTE_DIM (hashtest_key_lens); i++) { +uint32_t key_len = hashtest_key_lens[i]; + +/* key_len of 0 is invalid */ +if (key_len ==0 ) +continue ; + +memcpy (¶ms, &ut_params,sizeof (params)); + params.name ="key_len_test" ; + params.key_len = key_len; + + handle =rte_hash_create (¶ms); +if (handle ==NULL ) { +printf ("Creating hash with key_len %u failed\n" , key_len); +return -1 ; + } + +/* initialize key with pattern */ +for (j =0 ; j < key_len; j++) + key[j] = (uint8_t )j; + +/* add the key */ + pos =rte_hash_add_key (handle, key); +if (pos <0 ) { +printf ("Adding key with key_len %u failed\n" , key_len); +rte_hash_free (handle); +return -1 ; + } + expected_pos = pos; + +/* lookup should find same key */ + pos =rte_hash_lookup (handle, key); +if (pos != expected_pos) { +printf ("Lookup key with key_len %u failed: expected %d got %d\n" , + key_len, expected_pos, pos); +rte_hash_free (handle); +return -1 ; + } + +/* modify one byte and lookup should fail */ + key[key_len -1 ] ^=0xff ; + pos =rte_hash_lookup (handle, key); +if (pos != -ENOENT ) { +printf ("Lookup modified key with key_len %u should have failed\n" , + key_len); +rte_hash_free (handle); +return -1 ; + } + +/* restore key and delete */ + key[key_len -1 ] ^=0xff ; + pos =rte_hash_del_key (handle, key); +if (pos != expected_pos) { +printf ("Delete key with key_len %u failed\n" , key_len); +rte_hash_free (handle); +return -1 ; + } + +rte_hash_free (handle); + } + +return 0 ; +} +#define ITERATIONS 3/* * Test to see the average table utilization (entries added/max entries)
@@ -2563,6 +2640,7 @@ static struct unit_test_suite hash_test_suite = {TEST_CASE (fbk_hash_unit_test),TEST_CASE (test_hash_creation_with_bad_parameters),TEST_CASE (test_hash_creation_with_good_parameters), +TEST_CASE (test_hash_creation_with_key_lengths),TEST_CASE (test_average_table_utilization_no_ext),TEST_CASE (test_hash_iteration_no_ext), TEST_CASE(test_average_table_utilization_ext),
Signature · 1 line
2.53.0
Thomas Monjalon
AppliedRe: [PATCH v6 0/7] Cuckoo hash optimization for small key sizes
In reply to Stephen HemmingerQuoted 8 lines
Stephen Hemminger (7):
hash: move table of hash compare functions out of header
hash: usestatic_assert
hash: remove spurious warnings in CRC32 init
hash: simplify key comparison across architectures
hash: add support for common small key sizes app/test: convert hash test to use test suite runner test/hash: add test for key compare functions
That's a pity we didn't have more reviews.
Applied, thanks.