Skip to contentSkip to conversation

resolve issues with sys/queue.h

RFC In review Stephen Hemminger 9 participants 184 messages Aug 18, 2025 – Jun 10 Page 2 of 2

Subsystems (8)
lore
Share & tools
lore
#99 lore raw

PATCH v2 36/43 net/dpaa2: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 299c50dcdf..96e58b85fe 100644
@@ -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
index 1908d1e865..f956d5d5b2 100644
@@ -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
index 751e558c73..b55aa195ea 100644
@@ -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
#100 lore raw

PATCH v2 37/43 net/mvpp2: replace local definition of FOREACH_SAFE

In reply to Stephen Hemminger

There 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
index c07ac95ddc..27596b8c99 100644
@@ -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
#101 lore raw

PATCH v2 38/43 raw/ifpga: replace with TAILQ_FOREACH_SAFE

In reply to Stephen Hemminger

There 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
index 61eb6601ea..f8507fdf46 100644
@@ -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
index 57750022dd..f95bdf35b6 100644
@@ -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
index 58c884a8d8..84e0767b3a 100644
@@ -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
index d4e634c9d2..0ff2700384 100644
@@ -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
#102 lore raw

PATCH v2 39/43 drivers/vdpa: replace use of sys/queue.h

In reply to Stephen Hemminger

Use 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
index a398aa22ce..8071e1a5e0 100644
@@ -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
index eda111954f..73c75acca2 100644
@@ -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
index 2b843e563d..a240a8be25 100644
@@ -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
#103 lore raw

PATCH v2 40/43 drivers/common: remove use of sys/queue.h

In reply to Stephen Hemminger

The 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
index 7b39b61537..0c2dc04517 100644
@@ -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
index 91c84d7d97..f96c449ae8 100644
@@ -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
index cf7c685e9b..8bcc13f111 100644
@@ -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
#104 lore raw

PATCH v2 41/43 drivers/crypto: remove use of sys_queue.h

In reply to Stephen Hemminger

The 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
index 46522970d5..c66e31097e 100644
@@ -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
index 610454dd5e..7e1eafc4de 100644
@@ -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
index 5899d83bae..7069265f5d 100644
@@ -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
index 5088d8ded6..61df5b1d7e 100644
@@ -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
#105 lore raw

PATCH v2 42/43 drivers/event: remove include of sys/queue.h

In reply to Stephen Hemminger

The 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
index 87d98700c9..b085a3407d 100644
@@ -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
index 9b0c4db5ce..b6fe99fbcc 100644
@@ -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
index a2ce14051c..18ef5f13a8 100644
@@ -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
#106 lore raw

PATCH v2 43/43 eal: remove no longer used windows version of sys/queue.h

In reply to Stephen Hemminger

Superseded 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
deleted file mode 100644
index 917526531b..0000000000
@@ -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
Acked-by on v2 43/43
#107 lore raw

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.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
deleted file mode 100644
index 917526531b..0000000000
@@ -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
#108 lore raw

v3 cover Cuckoo hash cleanup and optimizations

In reply to Stephen Hemminger

Recent 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
#109 lore raw

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
index 2c92c51624..619fe0c691 100644
@@ -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
#110 lore raw

PATCH v3 2/4 hash: use static_assert

In reply to Stephen Hemminger

Now 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
index 16fe999c4c..90fda7d7e0 100644
@@ -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
#111 lore raw

PATCH v3 3/4 hash: reduce architecture special cases

In reply to Stephen Hemminger

Make 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
index a3e85635eb..2b2a37ebd2 100644
@@ -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
new file mode 100644
index 0000000000..f871a794cb
@@ -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
Acked-by on v3 3/4
#112 lore raw

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.49

Make 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 because ip_frag code poaches it.

---

LGTM now.

#113 lore raw

PATCH v3 4/4 hash: add support for common small key sizes

In reply to Stephen Hemminger

Add 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
index 5791fd7f4c..24588a4a96 100644
@@ -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
Acked-by on v3 4/4
#114 lore raw

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.49

Add new compare functions for common small key sizes.

Bugzilla ID: 1775

---

#115 lore raw

v3 cover introduce _SAFE variants of queue macros

In reply to Stephen Hemminger

This 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
#116 lore raw

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

Fixes 2caf84a71cfd ("net/nfp: add meter options")
---
 drivers/net/nfp/nfp_mtr.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/net/nfp/nfp_mtr.c +13 -6
index d4f2c4f2f0..4833ebd881 100644
@@ -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
#118 lore raw

PATCH v3 2/44 eal: add BSD version of queue.h

In reply to Stephen Hemminger

The 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
index 243a3c2959..097042dd22 100644
@@ -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
index c5ba335cfc..7bafa9ea83 100644
@@ -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
index 0a2311a342..9edf6c8121 100644
@@ -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
index 0f10c6894b..e46febefae 100644
@@ -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
index 7185de0cb9..06dfd9beb7 100644
@@ -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
index 47080d75ac..a564bf7abb 100644
@@ -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
index be041c45bb..12206764ec 100644
@@ -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
index e032dd10c9..6d4a02293c 100644
@@ -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
index 452b119c20..4d8634cb8c 100644
@@ -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
index c7ff6718f8..29d606373c 100644
@@ -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
index 13a56e490e..ee6e4df1fa 100644
@@ -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
index dfc56d4ae3..2f2f616c0f 100644
@@ -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
index 388e5a63b6..48171d732f 100644
@@ -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
index 6215245ad5..c19f0ab166 100644
@@ -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
index 5c3ab6699e..860398fae4 100644
@@ -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
index 7ed76ed796..288024ae44 100644
@@ -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
index 94b9275beb..2b1cbaa40f 100644
@@ -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
index a2517ac1d4..e630a606d5 100644
@@ -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
index aef5824e5f..906de7d0c0 100644
@@ -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
index 7631e36e82..34dda250ab 100644
@@ -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
index ed5a4675d9..e757cc306e 100644
@@ -19,6 +19,7 @@
 #include <stdio.h>
 
 #include <rte_dev.h>
+#include <rte_tailq.h>
 
 #ifdef __cplusplus
 extern "C" {
lib/eal/include/rte_tailq.h +10 -0
index e7caed6812..db69838842 100644
@@ -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 __cplusplus
 extern "C" {
 #endif
lib/eal/linux/eal_alarm.c +1 -1
index a1433eb867..46ef4a5cea 100644
@@ -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
index 9db978923a..08af2715b7 100644
@@ -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
index 20eff0409a..ef98b28024 100644
@@ -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
index 0b11d331dc..6abeb9a75e 100644
@@ -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
index 2a43cb1f9b..86161557ed 100644
@@ -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
#119 lore raw

PATCH v3 3/44 test: remove unnecessary inclusion of sys/queue.h

In reply to Stephen Hemminger

Those 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
index 497d8e9952..4ebd2cdd70 100644
@@ -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
index 8a4598baee..28a5ed1daa 100644
@@ -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
index c6d7d23313..fdc227d2ce 100644
@@ -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
index 3f26ce88d9..d98f7b1d09 100644
@@ -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
index 87c1059366..67a2d73137 100644
@@ -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
index 51e3069611..855ab15bed 100644
@@ -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
index 5791fd7f4c..f538053367 100644
@@ -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
index 70820d1f19..0d9f1dc0f6 100644
@@ -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
index 19b064771a..39541b04b0 100644
@@ -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
index ff13dbed93..0df83d94d3 100644
@@ -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
index 693b0ccd12..87924ca96a 100644
@@ -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
index 43b09704a3..a02e4b7860 100644
@@ -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
index ce8fc5dd06..c74ebaad10 100644
@@ -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
index 17be977f31..b057ae79b4 100644
@@ -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
index 8fcbc11a08..e88da6d8de 100644
@@ -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
index 63356998fd..94c72ffc06 100644
@@ -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
index e164eca788..775d61461d 100644
@@ -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
index 506725ea41..8080501a89 100644
@@ -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
index f3694530a8..72a50c92e4 100644
@@ -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
index e0674b0e70..a3e56b5c9d 100644
@@ -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
index 162049201f..5fb7f21d50 100644
@@ -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
index ba1fec1de3..1487093bc4 100644
@@ -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
index 785317621d..3bbcd8100e 100644
@@ -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
index 3c1944424e..d75054d95c 100644
@@ -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
index 34e0ef9422..5b2064ee9a 100644
@@ -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
index 2ff2877344..edb671a2be 100644
@@ -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
index 8ac2e90876..2de7cc71c0 100644
@@ -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
index 3411b7fe20..5efcc7e61d 100644
@@ -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
#120 lore raw

PATCH v3 4/44 test-pipeline: remove unnecessary use of sys/queue.h

In reply to Stephen Hemminger

Not 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
index daf838948b..61cf3a195c 100644
@@ -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
index 558f0e428d..2ca32db39d 100644
@@ -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
index 4cc098d7ac..dbc1e0d92d 100644
@@ -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
index 752f783370..e1d9f8174e 100644
@@ -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
#121 lore raw

PATCH v3 5/44 test-eventdev: use rte_bsd_queue.h

In reply to Stephen Hemminger

Use 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
index 72d6228bc3..04681e1e72 100644
@@ -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
index ad3f531dcf..30b248d5db 100644
@@ -7,7 +7,6 @@
 
 #include <string.h>
 #include <stdbool.h>
-#include <sys/queue.h>
 
 #include <rte_eal.h>
 
Signature · 1 line
2.51.0
#122 lore raw

PATCH v3 6/44 test-bbdev, test-cmdline, test-mldev: don't use sys/queue.h

In reply to Stephen Hemminger

No 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
index dc10a505d1..67a10e7a9c 100644
@@ -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
index 21b4a4278d..dd00455d30 100644
@@ -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
index f35fa8aadb..a2de5b3a31 100644
@@ -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
#123 lore raw

PATCH v3 7/44 app/testpmd: use rte_bsd_queue.h

In reply to Stephen Hemminger

Only 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
index 8e8de2557a..2671fdcd9f 100644
@@ -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
index 22afbdbad3..5296de21da 100644
@@ -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
index 3ce2a14a1b..965b4ab9f7 100644
@@ -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
index a6e872e5a4..a239434d1a 100644
@@ -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
index 53b5f24f11..dc50f8c94f 100644
@@ -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
index 5e6b37974e..35d5c06047 100644
@@ -8,7 +8,6 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#include <sys/queue.h>
 
 #include "testpmd.h"
 
app/test-pmd/icmpecho.c +0 -1
index c87b7a80df..7b51513070 100644
@@ -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
index ba06fae4a6..26dd787ca1 100644
@@ -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
index d19ace7395..5ba3549270 100644
@@ -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
index 57f77003fe..cc171aed4c 100644
@@ -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
index 81d1187cfe..edf1f62b55 100644
@@ -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
index 96973906fd..8a290a7f44 100644
@@ -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
index 315f9286cd..c73282e991 100644
@@ -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
index 2360da3a48..981a4ca9b9 100644
@@ -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
index fa46865c67..72a5d8eac1 100644
@@ -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
index bdcf6ea660..2aa8aaa4c5 100644
@@ -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
#124 lore raw

PATCH v3 8/44 apps: use rte_bsd_queue.h

In reply to Stephen Hemminger

Use 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
index e5ba36350b..506b4a5358 100644
@@ -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
index 1b9979b7c8..0826b934fc 100644
@@ -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
#125 lore raw

PATCH v3 9/44 examples: replace use of sys/queue.h

In reply to Stephen Hemminger

Where 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
index 03f15f91cc..4e788e842e 100644
@@ -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
index 9f38b63cbb..e168b6adf7 100644
@@ -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
index c04a782507..73ac631901 100644
@@ -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
index 1223ac1e8b..a7a7e586af 100644
@@ -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
index 8ea6596ed4..e1c8a9a35e 100644
@@ -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
index af509138da..630c757ba9 100644
@@ -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
index 1f84102844..ca80b4163a 100644
@@ -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
index cde17e69a3..bffea3de4c 100644
@@ -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
index d00434379e..e3759a5283 100644
@@ -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
index 34ff1149e0..d3811f5b34 100644
@@ -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
index bd46a11ca0..d665cc43e7 100644
@@ -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
index 89696480fc..bffba64ceb 100644
@@ -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
index c8440ee3cd..7bcbb58496 100644
@@ -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
index 0dce72fe3c..3faa7533db 100644
@@ -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
index 1994c55bcc..e8c0661894 100644
@@ -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
index 17ae76d4ba..3343ad4bd5 100644
@@ -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
index fe489f9a56..96bdd1a330 100644
@@ -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
index 1eed645d02..a4058d48f3 100644
@@ -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
index a441312f55..6d456daaf9 100644
@@ -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
index 8cf91b919c..3703ed3329 100644
@@ -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
index b8a755dbd5..4afbb0897f 100644
@@ -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
index bff2b99531..4e20a77e3d 100644
@@ -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
index 73e32fc197..531cf02e6b 100644
@@ -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
index c6fafdd019..dd189e16bc 100644
@@ -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
index 92cdaa1ebe..3d70718c1d 100644
@@ -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
index e27b8531b5..772675bde7 100644
@@ -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
index da9c45e3a4..f3af71adba 100644
@@ -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
index fec0aeb79c..ba23a0f32a 100644
@@ -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
index ae3b4f6439..cf6248084a 100644
@@ -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
index ac9c7f6217..21bb0cb69d 100644
@@ -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
index 087c38ef73..0d0aad5c07 100644
@@ -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
index 65713dbea8..6b06754205 100644
@@ -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
index ebfc2febc5..67371c7b9d 100644
@@ -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
index d668580784..cfdcbe7329 100644
@@ -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
index d73d1358ff..e648dfac37 100644
@@ -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
index f7d8439cd4..55ff7de5c2 100644
@@ -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
index fc2aa5ffef..4ae218ebf7 100644
@@ -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
index 9c89f6b60d..d6ded10edf 100644
@@ -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
index 75ff0ea532..367fac156c 100644
@@ -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
index 9f52082254..b1d34466d3 100644
@@ -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
index a349846c7c..e14584e764 100644
@@ -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
index c986cbc5a9..dc9388b4fe 100644
@@ -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
index 7d7efdd05a..18e4fc65c3 100644
@@ -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
index 800f733a26..a5390d5b4f 100644
@@ -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
index c141382020..cea7da9471 100644
@@ -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
index 4a3ce6884c..cab0351d72 100644
@@ -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
index 4ccc2fe4b0..3fa9f5f045 100644
@@ -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
#126 lore raw

PATCH v3 10/44 ethdev: replace use of sys/queue.h

In reply to Stephen Hemminger

Use 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
index 41a0ebe268..54b4b44052 100644
@@ -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
index c6fe0d5165..e624882dcb 100644
@@ -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
#128 lore raw

PATCH v3 11/44 lib: remove use of sys/queue.h

In reply to Stephen Hemminger

Use 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
index b2c262dee7..96e4f2908c 100644
@@ -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
index 6c98296bdb..fd4c38a497 100644
@@ -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
index 1d30ba17e2..4e911c5083 100644
@@ -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
index 01f813c56b..e3cd56f961 100644
@@ -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
index d79d561bf6..1c6292ed1c 100644
@@ -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
index f4c6f692f0..34e9b2172c 100644
@@ -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
index dde7ce2677..49ce882cdb 100644
@@ -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
index d4b3e12648..804d6b8a71 100644
@@ -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
index ebf1e0655f..38002deb8d 100644
@@ -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
index 184210f380..e3da524236 100644
@@ -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
index 93a1c7197b..b351d8cd69 100644
@@ -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
index 21912c0ae6..db74ff41d2 100644
@@ -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
index 2c92c51624..dbc0ddcf75 100644
@@ -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
index 38b15a14d1..c4027bee26 100644
@@ -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
index fcd41248b9..49d62e538e 100644
@@ -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
index 51fc9d47fb..ecf29fc02b 100644
@@ -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
index 8ad5250a13..b785156bac 100644
@@ -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
index 6dab86a05e..09d1e08263 100644
@@ -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
index e23c886766..781ec8de0b 100644
@@ -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
index 5987c9dee8..9a20033021 100644
@@ -3,7 +3,6 @@
  */
 
 #include <stdalign.h>
-#include <sys/queue.h>
 #include <stdint.h>
 #include <limits.h>
 
lib/mempool/rte_mempool.c +0 -1
index 1021ede0c2..bf8e870151 100644
@@ -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
index aedc100964..e5492a9ce0 100644
@@ -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
index 4e9bb842a1..ca44adb126 100644
@@ -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
index df864ea066..fa8dfa7d75 100644
@@ -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
index 4c7271522a..6a18563c80 100644
@@ -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
index be06530860..1c4751bee0 100644
@@ -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
index 046db131ca..bfb4c0e577 100644
@@ -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
index ec8ff68e87..5333fdd543 100644
@@ -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
index edd63aa535..b63820dcd2 100644
@@ -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
index 4c78fe4b4b..0b9223cd3f 100644
@@ -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
index eadcc6fb42..0f3f8fb430 100644
@@ -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
index 9b4f332f94..107933bfd7 100644
@@ -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
index bc2dd8d2e1..4e5fcf02be 100644
@@ -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
index e9e71c1707..16c37fc5b9 100644
@@ -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
#129 lore raw

Re: [PATCH v3 11/44] lib: remove use of sys/queue.h

Quoted 4 lines · Stephen Hemminger

Use the new rte_bsd_queue.h where needed but most files already get the needed macros from rte_tailq.h

[...]

lib/mempool/rte_mempool.c line 17

Quoted 12 lines
lib/mempool/rte_mempool.c +0 -1
index 1021ede0c2..bf8e870151 100644
@@ -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?

#130 lore raw

PATCH v3 12/44 drivers/bus: replace use of sys/queue.h

In reply to Stephen Hemminger

Prefer 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
index ac766e283e..4edc621268 100644
@@ -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
index 4604f6f4a7..bd519c1091 100644
@@ -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
index b6a6238a01..88c9ce88a9 100644
@@ -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
index 550d4e0e8d..cf6b4c6ab4 100644
@@ -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
index 2a9e519668..ac7cbd3a1f 100644
@@ -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_LCORE
 
 RTE_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
index ca9e49f548..3af95921a7 100644
@@ -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
index 3f13e1d6ac..97214ea049 100644
@@ -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
index bf5df3d94e..fd535967dd 100644
@@ -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
index 087ec38bb9..0b6d944118 100644
@@ -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
index 6f6f368cb7..1f74d81af5 100644
@@ -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
index 346b2f4c0a..d3d7e1f504 100644
@@ -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
index f6673cf181..edad25e759 100644
@@ -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
index be375f63dc..85df5f02c6 100644
@@ -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
index a787d8b18d..8a987a7d0e 100644
@@ -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
#131 lore raw

PATCH v3 13/44 net/nfp: use rte_bsd_queue.h

In reply to Stephen Hemminger

Can 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
index 4833ebd881..904d2126e7 100644
@@ -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
index 7ab0324721..c8ce03385c 100644
@@ -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
#132 lore raw

PATCH v3 14/44 net/qede: use rte_bsd_queue.h

In reply to Stephen Hemminger

The 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
index 3015c18504..87fbd07ed6 100644
@@ -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
index cecb58c997..958ab558f3 100644
@@ -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
#133 lore raw

PATCH v3 15/44 net/bnxt: remove use of sys/queue.h

In reply to Stephen Hemminger

Fix unsafe use after free by using STAILQ_FOREACH_SAFE.

Fixes e8fe0e067b68 ("net/bnxt: fix allocation of PF info struct")
---
 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
index c9fdd36d3e..e9099a3ff2 100644
@@ -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
index 7b90ba651f..0176b9f7cf 100644
@@ -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
index a2e590540b..d3da309254 100644
@@ -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
index 5a4fd4ecb7..be232df2e7 100644
@@ -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
index e0e31532fd..f8c46186fe 100644
@@ -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
index 591bde96e8..cd97bc6635 100644
@@ -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
#134 lore raw

PATCH v3 16/44 net/intel: remove use of sys/queue.h

In reply to Stephen Hemminger

For 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
index 689ed82f18..98e7678a65 100644
@@ -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
index 0907c7c259..3da4c5f4fd 100644
@@ -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
index ec3924bf6b..89f217e5d0 100644
@@ -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
index 54971fe285..b2342e3e72 100644
@@ -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
index f4e2a6442e..85549e5796 100644
@@ -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
index ea9b290e1c..c8f8bc6c0e 100644
@@ -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
index cdd7a3338f..e786a7fc18 100644
@@ -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
index b8ce79061b..b298cae5a5 100644
@@ -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
index 3fca089d6c..2caaa42a00 100644
@@ -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
index 55d18c5d4a..eb838b7746 100644
@@ -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
index f130f53ae0..5f7b69c72f 100644
@@ -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
index 3149682197..41761eb547 100644
@@ -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
index ebe1deeade..06a468d388 100644
@@ -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
index 255414dd03..f9b893aca7 100644
@@ -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
index d78582e05c..4cc41ea4ef 100644
@@ -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
index 15e49fe248..957ad69387 100644
@@ -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
index 3213464254..7b418c6604 100644
@@ -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
index eb5a3feab1..12d59fb05c 100644
@@ -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
index 6f6e95fc45..8f52b43b7c 100644
@@ -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
index 217f0500ab..212048adf9 100644
@@ -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
index a3ef13c791..cc017611b2 100644
@@ -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
index 460035d772..bd0dd48b0f 100644
@@ -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
index 21c460d007..218ae4157d 100644
@@ -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
index 38e30a4f62..5469ded014 100644
@@ -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
index 51716a4d5b..ac2f526382 100644
@@ -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
index 81da5a4656..1f27ba711e 100644
@@ -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
index 4669eba7c7..5bf61fa59a 100644
@@ -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
index 4049157eab..614b8ae280 100644
@@ -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
index aa6a21c055..b4516b1510 100644
@@ -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
index 28bc775a2c..a40eafb977 100644
@@ -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
index 47b95d0da6..bc25ec2ae4 100644
@@ -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
index 4b93d2649e..e285fa65d6 100644
@@ -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
index a2f76268b5..843f9f6747 100644
@@ -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
index bfc091c367..dade9d1699 100644
@@ -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
index 5393c81363..aba6e6d139 100644
@@ -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
index b6351bc2cf..4f65ede4fd 100644
@@ -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
index 3b68d820ca..8353c50ae1 100644
@@ -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
index 897ee2b671..74f88e3dfc 100644
@@ -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
#135 lore raw

PATCH v3 17/44 net/mlx5: remove unnecessary include of sys/queue.h

In reply to Stephen Hemminger

Already 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
index 2abc516b5e..4687e16dbe 100644
@@ -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
index 9011319a3e..6d5864ae3d 100644
@@ -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
index 07418b0922..463ce730ab 100644
@@ -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
index 673c9f3902..4fa9e444c4 100644
@@ -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
index 1de398982a..c359923c29 100644
@@ -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
index ff61706054..84aec40458 100644
@@ -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
index bcce1597e2..ba23280abc 100644
@@ -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
index 67d199ce15..aa94a9fee1 100644
@@ -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
index 7be31066a5..e88c60aa22 100644
@@ -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
index 1425886a22..cddc0da9fa 100644
@@ -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
index 3fa9245769..c999ca9052 100644
@@ -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
index 16307206e2..f320b18481 100644
@@ -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
#136 lore raw

PATCH v3 18/44 net/mlx4: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index f68eeb991a..38ed78df9f 100644
@@ -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
index b520664d95..44181c0aa3 100644
@@ -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
index 5e82df6bd6..a27317432d 100644
@@ -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
index 56dd73ff19..7fef07d6f9 100644
@@ -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
index 70f3cd8680..c68375b088 100644
@@ -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
#137 lore raw

PATCH v3 19/44 net/tap: remove unnecessary include of sys/queue.h

In reply to Stephen Hemminger

The 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
index ce4322ad04..055a9e9b23 100644
@@ -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
index 9d4ef27a8a..90fab604c2 100644
@@ -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
#138 lore raw

PATCH v3 20/44 net/axgbe: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 93e6c177b6..e882842e39 100644
@@ -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
#139 lore raw

PATCH v3 21/44 net/bnx2x: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index fa1c3ba955..3434aa0c9f 100644
@@ -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
#140 lore raw

PATCH v3 22/44 net/bonding: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 378bbba4e6..9e268d77c5 100644
@@ -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
index 5d0be5caf5..2d5b186aad 100644
@@ -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
#141 lore raw

PATCH v3 23/44 net/cxgbe: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 0c337a6cc8..f354e2638f 100644
@@ -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
index 2ed21f2d66..b3d7e1c012 100644
@@ -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
index e9d45f24c4..3fa296b1bd 100644
@@ -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
#142 lore raw

PATCH v3 24/44 net/enic: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 87f6b35fcd..163aff226f 100644
@@ -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
#143 lore raw

PATCH v3 25/44 net/failsafe: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 707e6c63b5..9f620443a4 100644
@@ -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
index babea6016e..94533a9a81 100644
@@ -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
#144 lore raw

PATCH v3 26/44 net/memif: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index b0decbb0a2..f95b64fd61 100644
@@ -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
index d4e625ab51..0154930cb7 100644
@@ -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
#145 lore raw

PATCH v3 27/44 net/ngbe: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index e575c47049..62ec1dc2e2 100644
@@ -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
index 95e2172ee4..0f9ec153cc 100644
@@ -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
#146 lore raw

PATCH v3 28/44 net/ntnic: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index f8a01dc9fc..6e1bc16036 100644
@@ -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
#147 lore raw

PATCH v3 29/44 net/sfc: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 7e2a20e4dc..66ff2ed789 100644
@@ -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
index 545f0f32bf..6f61b20a0f 100644
@@ -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
#148 lore raw

Re: [PATCH v3 29/44] net/sfc: replace use of sys/queue.h

Quoted 3 lines · Stephen Hemminger

Replace use of system sys/queue.h with DPDK rte_bsd_queue.h

[...]

drivers/net/sfc/sfc_dp.h line 14

Quoted 9 lines
drivers/net/sfc/sfc_dp.h +0 -1
index 545f0f32bf..6f61b20a0f 100644
@@ -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>
 
#149 lore raw

PATCH v3 30/44 net/softnic: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index d3975dad10..5b4361bad0 100644
@@ -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
#150 lore raw

PATCH v3 31/44 net/thunderx: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 4c7615ca99..74019818e3 100644
@@ -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
index 8421f57040..ccc6aef0fc 100644
@@ -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
index 76ed76a045..d3457aa1bc 100644
@@ -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
#151 lore raw

PATCH v3 32/44 net/txgbe: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 4be7c5d659..b7d0bf81f7 100644
@@ -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
index 0efd43b59a..c1c6e3625f 100644
@@ -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
index 31af3593ed..660f479adf 100644
@@ -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
index 167bda8019..0bbbf19791 100644
@@ -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
#152 lore raw

PATCH v3 33/44 net/vdev_netvsc: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index f4a84783ce..7d4800af6b 100644
@@ -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
#153 lore raw

PATCH v3 34/44 net/vmxnet3: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index b0c19c5c7c..df200247e0 100644
@@ -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
index 552b8a9823..daddf0a0d4 100644
@@ -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
#154 lore raw

PATCH v3 35/44 net/zxdh: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 3efcb6b591..4b9b409025 100644
@@ -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
#155 lore raw

PATCH v3 36/44 net/dpaa2: replace use of sys/queue.h

In reply to Stephen Hemminger

Replace 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
index 2e44bff766..925c65fa64 100644
@@ -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
index 9bb1bbca38..ad3a3b35e2 100644
@@ -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
index 751e558c73..b55aa195ea 100644
@@ -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
#156 lore raw

PATCH v3 37/44 net/mvpp2: replace local definition of FOREACH_SAFE

In reply to Stephen Hemminger

There 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
index c07ac95ddc..27596b8c99 100644
@@ -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
#157 lore raw

PATCH v3 38/44 raw/ifpga: replace with TAILQ_FOREACH_SAFE

In reply to Stephen Hemminger

There 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
index 61eb6601ea..f8507fdf46 100644
@@ -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
index 57750022dd..f95bdf35b6 100644
@@ -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
index 58c884a8d8..84e0767b3a 100644
@@ -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
index d4e634c9d2..0ff2700384 100644
@@ -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
#158 lore raw

PATCH v3 39/44 drivers/vdpa: replace use of sys/queue.h

In reply to Stephen Hemminger

Use 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
index a398aa22ce..8071e1a5e0 100644
@@ -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
index eda111954f..73c75acca2 100644
@@ -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
index 2b843e563d..a240a8be25 100644
@@ -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
Reviewed-by on v3 39/44
#159 lore raw

Re: [PATCH v3 39/44] drivers/vdpa: replace use of sys/queue.h

Quoted 53 lines · Stephen Hemminger

Use 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
index a398aa22ce..8071e1a5e0 100644
@@ -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
index eda111954f..73c75acca2 100644
@@ -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
index 2b843e563d..a240a8be25 100644
@@ -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

#160 lore raw

PATCH v3 40/44 drivers/common: remove use of sys/queue.h

In reply to Stephen Hemminger

The 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
index 7b39b61537..0c2dc04517 100644
@@ -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
index 91c84d7d97..f96c449ae8 100644
@@ -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
index cf7c685e9b..8bcc13f111 100644
@@ -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
#161 lore raw

PATCH v3 41/44 drivers/crypto: remove use of sys_queue.h

In reply to Stephen Hemminger

The 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
index 46522970d5..c66e31097e 100644
@@ -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
index 610454dd5e..7e1eafc4de 100644
@@ -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
index 5899d83bae..7069265f5d 100644
@@ -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
index 5088d8ded6..61df5b1d7e 100644
@@ -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
#162 lore raw

PATCH v3 42/44 drivers/event: remove include of sys/queue.h

In reply to Stephen Hemminger

The 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
index 87d98700c9..b085a3407d 100644
@@ -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
index 9b0c4db5ce..b6fe99fbcc 100644
@@ -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
index a2ce14051c..18ef5f13a8 100644
@@ -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
#163 lore raw

PATCH v3 43/44 eal: remove no longer used windows version of sys/queue.h

In reply to Stephen Hemminger

Superseded 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
deleted file mode 100644
index 917526531b..0000000000
@@ -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
#164 lore raw

PATCH v3 44/44 net/netvsc: use LIST_FOREACH_SAFE

In reply to Stephen Hemminger

Fix 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
index dc765e88f7..bc243bf229 100644
@@ -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
Reviewed-by on v3 44/44
#165 lore raw

RE: [PATCH v3 44/44] net/netvsc: use LIST_FOREACH_SAFE

Quoted 3 lines

Fix use after free in in remove_cache_list by using LIST_FOREACH_SAFE

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
index dc765e88f7..bc243bf229 100644
@@ -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

#166 lore raw
In reply to Stephen Hemminger
Quoted 327 lines · On Mon, 18 Aug 2025 16:27:11 -0700 Stephen Hemminger…

This 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.

Stephen Hemminger (47):
eal: add BSD version of queue.h
net/nfp: fix use after free
eal: use bsd_queue.h
test: remove unnecessary inclusion of sys/queue.h
testpmd: use bsd_queue.h
dumpcap: use bsd_queue.h
proc-info: remove unnecessary sys/queue.h
doc: suggest bsd_queue.h
test-pipeline: remove unnecessary use of sys/queue.h
test-eventdev: use bsd_queue.h
test-bbdev, test-cmdline, test-mldev: don't use sys/queue.h
examples: replace use of sys/queue.h
hash: do not include sys/queue.h
lpm: do not include sys/queue.h
log: replace use of sys/queue.h
ethdev: replace use of sys/queue.h
bpf: replace use of sys/queue.h
mempool: do not need sys/queue.h
lib: remove use of sys/queue.h
bus/fslmc: use rte_tailq.h
drivers/bus: replace use of sys/queue.h
net/qede: use 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/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/mlx4: 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
eal: remove no longer used windows version of queue.h net/mvpp2: replace local definition of FOREACH_SAFE drivers/raw: replace with TAILQ_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 +-
 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

#167 lore raw

v5 cover Cuckoo hash optimization for small key sizes

In reply to Stephen Hemminger

This 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
#168 lore raw

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
index 2c92c51624..619fe0c691 100644
@@ -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
#169 lore raw

PATCH v5 2/7 hash: use static_assert

In reply to Stephen Hemminger

Now 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
index 5b3c51348e..919140ac1c 100644
@@ -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
#170 lore raw

PATCH v5 3/7 hash: remove spurious warnings in CRC32 init

In reply to Stephen Hemminger

The 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
index 9fe90d6425..2e552331f5 100644
@@ -38,9 +38,6 @@ rte_hash_crc_set_alg(uint8_t alg)
 		return;
 
 #if defined RTE_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 defined RTE_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
#171 lore raw

PATCH v5 4/7 hash: simplify key comparison across architectures

In reply to Stephen Hemminger

Refactor 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
index a3e85635eb..f209aaf474 100644
@@ -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
new file mode 100644
index 0000000000..771180e97a
@@ -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
#172 lore raw

PATCH v5 5/7 hash: add support for common small key sizes

In reply to Stephen Hemminger

Add 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
index a70e2620c0..1d140ec2cc 100644
@@ -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
#173 lore raw

PATCH v5 6/7 app/test: convert hash test to use test suite runner

In reply to Stephen Hemminger

Replace 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
index 1d140ec2cc..f0825ca75d 100644
@@ -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
#174 lore raw

PATCH v5 7/7 test/hash: add test for key compare functions

In reply to Stephen Hemminger

The 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
index f0825ca75d..499b064cb7 100644
@@ -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(&params, &ut_params, sizeof(params));
+		params.name = "key_len_test";
+		params.key_len = key_len;
+
+		handle = rte_hash_create(&params);
+		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
#175 lore raw

v6 cover Cuckoo hash optimization for small key sizes

In reply to Stephen Hemminger

This 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
#176 lore raw

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
index 69dcfdfc39..9af02f2abd 100644
@@ -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
#177 lore raw

PATCH v6 2/7 hash: use static_assert

In reply to Stephen Hemminger

Now 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
index 5b3c51348e..919140ac1c 100644
@@ -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
#178 lore raw

PATCH v6 3/7 hash: remove spurious warnings in CRC32 init

In reply to Stephen Hemminger

The 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
index 523be0bf92..8b70982c4b 100644
@@ -37,9 +37,6 @@ rte_hash_crc_set_alg(uint8_t alg)
 		return;
 
 #if defined RTE_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 defined RTE_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
#179 lore raw

PATCH v6 4/7 hash: simplify key comparison across architectures

In reply to Stephen Hemminger

Refactor 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
index a3e85635eb..f209aaf474 100644
@@ -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
new file mode 100644
index 0000000000..771180e97a
@@ -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
#180 lore raw

PATCH v6 5/7 hash: add support for common small key sizes

In reply to Stephen Hemminger

Add 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
index 56a7779e09..6da69154a3 100644
@@ -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
#181 lore raw

PATCH v6 6/7 app/test: convert hash test to use test suite runner

In reply to Stephen Hemminger

Replace 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
index 6da69154a3..0ddf71ff3c 100644
@@ -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
#182 lore raw

PATCH v6 7/7 test/hash: add test for key compare functions

In reply to Stephen Hemminger

The 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
index 0ddf71ff3c..640a33e16c 100644
@@ -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(&params, &ut_params, sizeof(params));
+		params.name = "key_len_test";
+		params.key_len = key_len;
+
+		handle = rte_hash_create(&params);
+		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
#183 lore raw

Re: [PATCH v6 0/7] Cuckoo hash optimization for small key sizes

In reply to Stephen Hemminger
Quoted 8 lines

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

That's a pity we didn't have more reviews.

Applied, thanks.