diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2016-06-13 16:54:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-06-15 16:58:27 -0400 |
commit | 7d7072e3bad5569f636d3c54a36da40976bfd505 (patch) | |
tree | ae127906844437808567a4bfccd6d465810c3db3 | |
parent | 5d49de532002f02755decd1758aac53063a68625 (diff) |
skb_array: resize support
Update skb_array after ptr_ring API changes.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Tested-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/skb_array.h | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/include/linux/skb_array.h b/include/linux/skb_array.h index c4c090223333..678bfbf78ac4 100644 --- a/include/linux/skb_array.h +++ b/include/linux/skb_array.h | |||
@@ -63,9 +63,9 @@ static inline int skb_array_produce_any(struct skb_array *a, struct sk_buff *skb | |||
63 | return ptr_ring_produce_any(&a->ring, skb); | 63 | return ptr_ring_produce_any(&a->ring, skb); |
64 | } | 64 | } |
65 | 65 | ||
66 | /* Might be slightly faster than skb_array_empty below, but callers invoking | 66 | /* Might be slightly faster than skb_array_empty below, but only safe if the |
67 | * this in a loop must take care to use a compiler barrier, for example | 67 | * array is never resized. Also, callers invoking this in a loop must take care |
68 | * cpu_relax(). | 68 | * to use a compiler barrier, for example cpu_relax(). |
69 | */ | 69 | */ |
70 | static inline bool __skb_array_empty(struct skb_array *a) | 70 | static inline bool __skb_array_empty(struct skb_array *a) |
71 | { | 71 | { |
@@ -77,6 +77,21 @@ static inline bool skb_array_empty(struct skb_array *a) | |||
77 | return ptr_ring_empty(&a->ring); | 77 | return ptr_ring_empty(&a->ring); |
78 | } | 78 | } |
79 | 79 | ||
80 | static inline bool skb_array_empty_bh(struct skb_array *a) | ||
81 | { | ||
82 | return ptr_ring_empty_bh(&a->ring); | ||
83 | } | ||
84 | |||
85 | static inline bool skb_array_empty_irq(struct skb_array *a) | ||
86 | { | ||
87 | return ptr_ring_empty_irq(&a->ring); | ||
88 | } | ||
89 | |||
90 | static inline bool skb_array_empty_any(struct skb_array *a) | ||
91 | { | ||
92 | return ptr_ring_empty_any(&a->ring); | ||
93 | } | ||
94 | |||
80 | static inline struct sk_buff *skb_array_consume(struct skb_array *a) | 95 | static inline struct sk_buff *skb_array_consume(struct skb_array *a) |
81 | { | 96 | { |
82 | return ptr_ring_consume(&a->ring); | 97 | return ptr_ring_consume(&a->ring); |
@@ -136,9 +151,19 @@ static inline int skb_array_init(struct skb_array *a, int size, gfp_t gfp) | |||
136 | return ptr_ring_init(&a->ring, size, gfp); | 151 | return ptr_ring_init(&a->ring, size, gfp); |
137 | } | 152 | } |
138 | 153 | ||
154 | void __skb_array_destroy_skb(void *ptr) | ||
155 | { | ||
156 | kfree_skb(ptr); | ||
157 | } | ||
158 | |||
159 | int skb_array_resize(struct skb_array *a, int size, gfp_t gfp) | ||
160 | { | ||
161 | return ptr_ring_resize(&a->ring, size, gfp, __skb_array_destroy_skb); | ||
162 | } | ||
163 | |||
139 | static inline void skb_array_cleanup(struct skb_array *a) | 164 | static inline void skb_array_cleanup(struct skb_array *a) |
140 | { | 165 | { |
141 | ptr_ring_cleanup(&a->ring); | 166 | ptr_ring_cleanup(&a->ring, __skb_array_destroy_skb); |
142 | } | 167 | } |
143 | 168 | ||
144 | #endif /* _LINUX_SKB_ARRAY_H */ | 169 | #endif /* _LINUX_SKB_ARRAY_H */ |