git: 3d3ec17825a1 - main - LinuxKPI: sk_buff: implement skb_queue_splice_tail_init()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Mon, 15 Apr 2024 16:07:16 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=3d3ec17825a124f0119d76c4d2523d73012fa226

commit 3d3ec17825a124f0119d76c4d2523d73012fa226
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-04-02 09:17:31 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-04-15 16:06:11 +0000

    LinuxKPI: sk_buff: implement skb_queue_splice_tail_init()
    
    Implement skb_queue_splice_tail_init() and SKB_DATA_ALIGN() as
    needed by the mt76 wireless driver.
    
    Sponsord by:    The FreeBD Foundation
    MFC after:      3 days
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D44590
---
 sys/compat/linuxkpi/common/include/linux/skbuff.h | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/skbuff.h b/sys/compat/linuxkpi/common/include/linux/skbuff.h
index 02190a29e241..ee3f427aa6e9 100644
--- a/sys/compat/linuxkpi/common/include/linux/skbuff.h
+++ b/sys/compat/linuxkpi/common/include/linux/skbuff.h
@@ -89,6 +89,7 @@ struct skb_shared_hwtstamps {
 };
 
 #define	NET_SKB_PAD		max(CACHE_LINE_SIZE, 32)
+#define	SKB_DATA_ALIGN(_x)	roundup2(_x, CACHE_LINE_SIZE)
 
 struct sk_buff_head {
 		/* XXX TODO */
@@ -824,7 +825,7 @@ skb_mark_not_on_list(struct sk_buff *skb)
 }
 
 static inline void
-___skb_queue_splice_init(const struct sk_buff_head *from,
+___skb_queue_splice(const struct sk_buff_head *from,
     struct sk_buff *p, struct sk_buff *n)
 {
 	struct sk_buff *b, *e;
@@ -847,7 +848,21 @@ skb_queue_splice_init(struct sk_buff_head *from, struct sk_buff_head *to)
 	if (skb_queue_empty(from))
 		return;
 
-	___skb_queue_splice_init(from, (struct sk_buff *)to, to->next);
+	___skb_queue_splice(from, (struct sk_buff *)to, to->next);
+	to->qlen += from->qlen;
+	__skb_queue_head_init(from);
+}
+
+static inline void
+skb_queue_splice_tail_init(struct sk_buff_head *from, struct sk_buff_head *to)
+{
+
+	SKB_TRACE2(from, to);
+
+	if (skb_queue_empty(from))
+		return;
+
+	___skb_queue_splice(from, to->prev, (struct sk_buff *)to);
 	to->qlen += from->qlen;
 	__skb_queue_head_init(from);
 }