git: 425edb6fc2d5 - stable/13 - LinuxKPI: sk_buff: implement skb_queue_splice_tail_init()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Wed, 12 Jun 2024 19:16:42 UTC
The branch stable/13 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=425edb6fc2d5e1fcc38e8e194639980d1115b511

commit 425edb6fc2d5e1fcc38e8e194639980d1115b511
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-04-02 09:17:31 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-06-12 16:57:25 +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
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D44590
    
    (cherry picked from commit 3d3ec17825a124f0119d76c4d2523d73012fa226)
---
 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);
 }