gpio-nct5104d: fix compilation with kernel 6.6
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 605-v5.18-xdp-introduce-flags-field-in-xdp_buff-xdp_frame.patch
1 From 2e88d4ff03013937028f5397268b21e10cf68713 Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Fri, 21 Jan 2022 11:09:45 +0100
4 Subject: [PATCH] xdp: introduce flags field in xdp_buff/xdp_frame
5
6 Introduce flags field in xdp_frame and xdp_buffer data structures
7 to define additional buffer features. At the moment the only
8 supported buffer feature is frags bit (XDP_FLAGS_HAS_FRAGS).
9 frags bit is used to specify if this is a linear buffer
10 (XDP_FLAGS_HAS_FRAGS not set) or a frags frame (XDP_FLAGS_HAS_FRAGS
11 set). In the latter case the driver is expected to initialize the
12 skb_shared_info structure at the end of the first buffer to link together
13 subsequent buffers belonging to the same frame.
14
15 Acked-by: Toke Hoiland-Jorgensen <toke@redhat.com>
16 Acked-by: John Fastabend <john.fastabend@gmail.com>
17 Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
18 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
19 Link: https://lore.kernel.org/r/e389f14f3a162c0a5bc6a2e1aa8dd01a90be117d.1642758637.git.lorenzo@kernel.org
20 Signed-off-by: Alexei Starovoitov <ast@kernel.org>
21 ---
22 include/net/xdp.h | 29 +++++++++++++++++++++++++++++
23 1 file changed, 29 insertions(+)
24
25 --- a/include/net/xdp.h
26 +++ b/include/net/xdp.h
27 @@ -66,6 +66,10 @@ struct xdp_txq_info {
28 struct net_device *dev;
29 };
30
31 +enum xdp_buff_flags {
32 + XDP_FLAGS_HAS_FRAGS = BIT(0), /* non-linear xdp buff */
33 +};
34 +
35 struct xdp_buff {
36 void *data;
37 void *data_end;
38 @@ -74,13 +78,30 @@ struct xdp_buff {
39 struct xdp_rxq_info *rxq;
40 struct xdp_txq_info *txq;
41 u32 frame_sz; /* frame size to deduce data_hard_end/reserved tailroom*/
42 + u32 flags; /* supported values defined in xdp_buff_flags */
43 };
44
45 +static __always_inline bool xdp_buff_has_frags(struct xdp_buff *xdp)
46 +{
47 + return !!(xdp->flags & XDP_FLAGS_HAS_FRAGS);
48 +}
49 +
50 +static __always_inline void xdp_buff_set_frags_flag(struct xdp_buff *xdp)
51 +{
52 + xdp->flags |= XDP_FLAGS_HAS_FRAGS;
53 +}
54 +
55 +static __always_inline void xdp_buff_clear_frags_flag(struct xdp_buff *xdp)
56 +{
57 + xdp->flags &= ~XDP_FLAGS_HAS_FRAGS;
58 +}
59 +
60 static __always_inline void
61 xdp_init_buff(struct xdp_buff *xdp, u32 frame_sz, struct xdp_rxq_info *rxq)
62 {
63 xdp->frame_sz = frame_sz;
64 xdp->rxq = rxq;
65 + xdp->flags = 0;
66 }
67
68 static __always_inline void
69 @@ -122,8 +143,14 @@ struct xdp_frame {
70 */
71 struct xdp_mem_info mem;
72 struct net_device *dev_rx; /* used by cpumap */
73 + u32 flags; /* supported values defined in xdp_buff_flags */
74 };
75
76 +static __always_inline bool xdp_frame_has_frags(struct xdp_frame *frame)
77 +{
78 + return !!(frame->flags & XDP_FLAGS_HAS_FRAGS);
79 +}
80 +
81 #define XDP_BULK_QUEUE_SIZE 16
82 struct xdp_frame_bulk {
83 int count;
84 @@ -180,6 +207,7 @@ void xdp_convert_frame_to_buff(struct xd
85 xdp->data_end = frame->data + frame->len;
86 xdp->data_meta = frame->data - frame->metasize;
87 xdp->frame_sz = frame->frame_sz;
88 + xdp->flags = frame->flags;
89 }
90
91 static inline
92 @@ -206,6 +234,7 @@ int xdp_update_frame_from_buff(struct xd
93 xdp_frame->headroom = headroom - sizeof(*xdp_frame);
94 xdp_frame->metasize = metasize;
95 xdp_frame->frame_sz = xdp->frame_sz;
96 + xdp_frame->flags = xdp->flags;
97
98 return 0;
99 }