From 40d99076dff827c10cbbda3008b5e820b98214d7 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 6 Jul 2022 17:23:40 -0400 Subject: [PATCH] openbsd_network: Move mbuf_list and mbuf_queue into mbuf-obsd.h. --- .../openbsd_network/compat/sys/mbuf-obsd.h | 44 ++++++++++++++++--- .../compat/openbsd_network/compat/sys/mbuf.h | 17 ------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/libs/compat/openbsd_network/compat/sys/mbuf-obsd.h b/src/libs/compat/openbsd_network/compat/sys/mbuf-obsd.h index 3f61fcef2c..c873019a7d 100644 --- a/src/libs/compat/openbsd_network/compat/sys/mbuf-obsd.h +++ b/src/libs/compat/openbsd_network/compat/sys/mbuf-obsd.h @@ -72,11 +72,19 @@ * Research Laboratory (NRL). */ -#define mq_len(_mq) ml_len(&(_mq)->mq_list) -#define mq_empty(_mq) ml_empty(&(_mq)->mq_list) -#define mq_full(_mq) (mq_len((_mq)) >= (_mq)->mq_maxlen) -#define mq_drops(_mq) ((_mq)->mq_drops) -#define mq_set_maxlen(_mq, _l) ((_mq)->mq_maxlen = (_l)) +struct mbuf_list { + struct mbuf *ml_head; + struct mbuf *ml_tail; + u_int ml_len; +}; + +struct mbuf_queue { + struct mutex mq_mtx; + struct mbuf_list mq_list; + u_int mq_maxlen; + u_int mq_drops; +}; + static struct mbuf * m_dup_pkt(struct mbuf *m0, unsigned int adj, int wait) @@ -129,6 +137,23 @@ m_trailingspace(struct mbuf *m) } +/* + * mbuf lists + */ + +#define MBUF_LIST_INITIALIZER() { NULL, NULL, 0 } + +#define ml_len(_ml) ((_ml)->ml_len) +#define ml_empty(_ml) ((_ml)->ml_len == 0) + +#define MBUF_LIST_FIRST(_ml) ((_ml)->ml_head) +#define MBUF_LIST_NEXT(_m) ((_m)->m_nextpkt) + +#define MBUF_LIST_FOREACH(_ml, _m) \ + for ((_m) = MBUF_LIST_FIRST(_ml); \ + (_m) != NULL; \ + (_m) = MBUF_LIST_NEXT(_m)) + static void ml_init(struct mbuf_list *ml) { @@ -230,6 +255,15 @@ ml_hdatalen(struct mbuf_list *ml) * mbuf queues */ +#define MBUF_QUEUE_INITIALIZER(_maxlen, _ipl) \ + { MUTEX_INITIALIZER(_ipl), MBUF_LIST_INITIALIZER(), (_maxlen), 0 } + +#define mq_len(_mq) ml_len(&(_mq)->mq_list) +#define mq_empty(_mq) ml_empty(&(_mq)->mq_list) +#define mq_full(_mq) (mq_len((_mq)) >= (_mq)->mq_maxlen) +#define mq_drops(_mq) ((_mq)->mq_drops) +#define mq_set_maxlen(_mq, _l) ((_mq)->mq_maxlen = (_l)) + static void mq_init(struct mbuf_queue *mq, u_int maxlen, int ipl) { diff --git a/src/libs/compat/openbsd_network/compat/sys/mbuf.h b/src/libs/compat/openbsd_network/compat/sys/mbuf.h index dd05cda566..1a8171a1d7 100644 --- a/src/libs/compat/openbsd_network/compat/sys/mbuf.h +++ b/src/libs/compat/openbsd_network/compat/sys/mbuf.h @@ -29,23 +29,6 @@ #define MCLGETL m_cljget -struct mbuf_list { - struct mbuf *ml_head; - struct mbuf *ml_tail; - u_int ml_len; -}; - -#define MBUF_LIST_INITIALIZER() { NULL, NULL, 0 } -#define ml_len(_ml) ((_ml)->ml_len) -#define ml_empty(_ml) ((_ml)->ml_len == 0) - -struct mbuf_queue { - struct mutex mq_mtx; - struct mbuf_list mq_list; - u_int mq_maxlen; - u_int mq_drops; -}; - /* FreeBSD methods not compatible with their OpenBSD counterparts */ #define m_defrag(mbuf, how) __m_defrag_unimplemented()