Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : *
3 : : * Copyright (c) 2017,2018 HXT-semitech Corporation.
4 : : * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
5 : : * All rights reserved.
6 : : * Derived from FreeBSD's bufring.h
7 : : * Used as BSD-3 Licensed with permission from Kip Macy.
8 : : */
9 : :
10 : : #ifndef _RTE_RING_ELEM_PVT_H_
11 : : #define _RTE_RING_ELEM_PVT_H_
12 : :
13 : : #if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
14 : : #pragma GCC diagnostic push
15 : : #pragma GCC diagnostic ignored "-Wstringop-overflow"
16 : : #pragma GCC diagnostic ignored "-Wstringop-overread"
17 : : #endif
18 : :
19 : : static __rte_always_inline void
20 : : __rte_ring_enqueue_elems_32(struct rte_ring *r, const uint32_t size,
21 : : uint32_t idx, const void *obj_table, uint32_t n)
22 : : {
23 : : unsigned int i;
24 : 179652868 : uint32_t *ring = (uint32_t *)&r[1];
25 : : const uint32_t *obj = (const uint32_t *)obj_table;
26 : 179652868 : if (likely(idx + n <= size)) {
27 [ - - + + : 126225 : for (i = 0; i < (n & ~0x7); i += 8, idx += 8) {
- + - - -
- - - - -
+ + - - -
- - - - -
- - - - -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
28 : 111618 : ring[idx] = obj[i];
29 : 111618 : ring[idx + 1] = obj[i + 1];
30 : 111618 : ring[idx + 2] = obj[i + 2];
31 : 111618 : ring[idx + 3] = obj[i + 3];
32 : 111618 : ring[idx + 4] = obj[i + 4];
33 : 111618 : ring[idx + 5] = obj[i + 5];
34 : 111618 : ring[idx + 6] = obj[i + 6];
35 : 111618 : ring[idx + 7] = obj[i + 7];
36 : : }
37 [ - - - - : 14607 : switch (n & 0x7) {
- - - - -
- + - - +
+ - - + -
- + - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - + - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- + + + +
+ + + - -
- - - - -
- + + + +
+ + + + +
+ + - + +
+ + + - +
+ + + + +
- + + + +
+ + + - +
+ - + + +
+ - - - -
- - - - +
+ + + - +
+ + + + +
- - + + +
+ - + + +
+ + + + -
+ - + + +
+ ]
38 : 13 : case 7:
39 : 13 : ring[idx++] = obj[i++]; /* fallthrough */
40 : 1059 : case 6:
41 : 1059 : ring[idx++] = obj[i++]; /* fallthrough */
42 : 5218 : case 5:
43 : 5218 : ring[idx++] = obj[i++]; /* fallthrough */
44 : 5226 : case 4:
45 : 5226 : ring[idx++] = obj[i++]; /* fallthrough */
46 : 5237 : case 3:
47 : 5237 : ring[idx++] = obj[i++]; /* fallthrough */
48 : 5319 : case 2:
49 : 5319 : ring[idx++] = obj[i++]; /* fallthrough */
50 : 9481 : case 1:
51 : 179647516 : ring[idx++] = obj[i++]; /* fallthrough */
52 : : }
53 : : } else {
54 [ - - - - : 1287263 : for (i = 0; idx < size; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
55 : 1287037 : ring[idx] = obj[i];
56 : : /* Start at the beginning */
57 [ - - - - : 1216911 : for (idx = 0; i < n; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
58 : 1216685 : ring[idx] = obj[i];
59 : : }
60 : : }
61 : :
62 : : static __rte_always_inline void
63 : : __rte_ring_enqueue_elems_64(struct rte_ring *r, uint32_t prod_head,
64 : : const void *obj_table, uint32_t n)
65 : : {
66 : : unsigned int i;
67 : 48732649 : const uint32_t size = r->size;
68 : 48732649 : uint32_t idx = prod_head & r->mask;
69 : 48732649 : uint64_t *ring = (uint64_t *)&r[1];
70 : : const unaligned_uint64_t *obj = (const unaligned_uint64_t *)obj_table;
71 [ + - + + : 48732649 : if (likely(idx + n <= size)) {
+ - + + -
- + - - -
+ + - - +
+ - - - -
- - + + -
- - - - -
+ - - - +
- - - + -
- - - - -
- + - - -
- - - - -
- - - - +
- - - - -
- - - + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
72 [ - + + + : 55680273 : for (i = 0; i < (n & ~0x3); i += 4, idx += 4) {
- + + + -
- - - - -
- - - - +
+ - - - -
- - - + -
- - - - -
- - - - -
- - - - -
- - - - +
+ - - + +
+ + + + +
+ + + - -
+ + + + +
+ + + + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + ]
73 : 7326199 : ring[idx] = obj[i];
74 : 7326199 : ring[idx + 1] = obj[i + 1];
75 : 7326199 : ring[idx + 2] = obj[i + 2];
76 : 7326199 : ring[idx + 3] = obj[i + 3];
77 : : }
78 [ - - + - : 48354074 : switch (n & 0x3) {
- + + + -
- + - + +
+ + - - -
- - - - -
- - - - -
- - - - -
- - - + +
+ - - - -
- - - - -
- - - - +
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - + + +
+ - - - -
+ + + + +
+ + + + +
+ + - + +
+ + + + +
- - - - +
+ + + - +
+ + + + +
+ + + + +
+ + + + -
- - - + +
+ + + + +
+ + + + +
- + + + +
+ + + - -
- - + + +
+ + + + +
+ + + + +
+ + + ]
79 : 30 : case 3:
80 : 30 : ring[idx++] = obj[i++]; /* fallthrough */
81 : 3368607 : case 2:
82 : 3368607 : ring[idx++] = obj[i++]; /* fallthrough */
83 : 48306043 : case 1:
84 : 48574690 : ring[idx++] = obj[i++];
85 : : }
86 : : } else {
87 [ - - + + : 1084966 : for (i = 0; idx < size; i++, idx++)
- - + + -
- - - - -
+ + - - +
+ - - - -
- - + + -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - + +
- - - - -
- - - + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
88 : 975038 : ring[idx] = obj[i];
89 : : /* Start at the beginning */
90 [ - - + + : 1096725 : for (idx = 0; i < n; i++, idx++)
- - + + -
- - - - -
+ + - - +
+ - - - -
- - + + -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - + +
- - - - -
- - - + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
91 : 986797 : ring[idx] = obj[i];
92 : : }
93 : : }
94 : :
95 : : static __rte_always_inline void
96 : : __rte_ring_enqueue_elems_128(struct rte_ring *r, uint32_t prod_head,
97 : : const void *obj_table, uint32_t n)
98 : : {
99 : : unsigned int i;
100 : 29916 : const uint32_t size = r->size;
101 : 29916 : uint32_t idx = prod_head & r->mask;
102 : 29916 : rte_int128_t *ring = (rte_int128_t *)&r[1];
103 : : const rte_int128_t *obj = (const rte_int128_t *)obj_table;
104 [ - - + - : 29916 : if (likely(idx + n <= size)) {
+ - - - -
- + - - -
+ - - - -
- - - - -
- - + + -
- - - - -
+ - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
105 [ - - + + : 106911 : for (i = 0; i < (n & ~0x1); i += 2, idx += 2)
- - - - -
- + + - -
- - - - -
- - - - -
+ + - + +
+ + + + +
+ + + + -
- + + + +
+ + + + ]
106 : 81271 : memcpy((void *)(ring + idx),
107 : 81271 : (const void *)(obj + i), 32);
108 [ - - + + : 25640 : switch (n & 0x1) {
- - - - -
- + + - -
- - - - -
- - - - -
+ + + - +
+ + + + +
+ + + + -
- + + + +
+ + + + ]
109 : 23025 : case 1:
110 : 27144 : memcpy((void *)(ring + idx),
111 : 23025 : (const void *)(obj + i), 16);
112 : : }
113 : : } else {
114 [ - - - - : 193394 : for (i = 0; idx < size; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
115 : 193278 : memcpy((void *)(ring + idx),
116 : 193278 : (const void *)(obj + i), 16);
117 : : /* Start at the beginning */
118 [ - - - - : 225192 : for (idx = 0; i < n; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
119 : 225076 : memcpy((void *)(ring + idx),
120 : 225076 : (const void *)(obj + i), 16);
121 : : }
122 : : }
123 : :
124 : : /* the actual enqueue of elements on the ring.
125 : : * Placed here since identical code needed in both
126 : : * single and multi producer enqueue functions.
127 : : */
128 : : static __rte_always_inline void
129 : : __rte_ring_enqueue_elems(struct rte_ring *r, uint32_t prod_head,
130 : : const void *obj_table, uint32_t esize, uint32_t num)
131 : : {
132 : : /* 8B and 16B copies implemented individually to retain
133 : : * the current performance.
134 : : */
135 [ - - + + : 28643 : if (esize == 8)
- + - - -
- - - - -
+ + - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
136 : : __rte_ring_enqueue_elems_64(r, prod_head, obj_table, num);
137 [ - - + + : 21755 : else if (esize == 16)
+ + - - -
- - - - -
+ + - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
138 : : __rte_ring_enqueue_elems_128(r, prod_head, obj_table, num);
139 : : else {
140 : : uint32_t idx, scale, nr_idx, nr_num, nr_size;
141 : :
142 : : /* Normalize to uint32_t */
143 : 14833 : scale = esize / sizeof(uint32_t);
144 : 5524 : nr_num = num * scale;
145 : 179652868 : idx = prod_head & r->mask;
146 : 14833 : nr_idx = idx * scale;
147 [ + - + - : 179652868 : nr_size = r->size * scale;
+ - - - +
- + - + -
+ - + - -
- - - - -
- - - + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
148 : : __rte_ring_enqueue_elems_32(r, nr_size, nr_idx,
149 : : obj_table, nr_num);
150 : : }
151 : : }
152 : :
153 : : static __rte_always_inline void
154 : : __rte_ring_dequeue_elems_32(struct rte_ring *r, const uint32_t size,
155 : : uint32_t idx, void *obj_table, uint32_t n)
156 : : {
157 : : unsigned int i;
158 : 417898 : uint32_t *ring = (uint32_t *)&r[1];
159 : : uint32_t *obj = (uint32_t *)obj_table;
160 : 417898 : if (likely(idx + n <= size)) {
161 [ + + - + : 127183 : for (i = 0; i < (n & ~0x7); i += 8, idx += 8) {
- - - - -
- - - - -
+ + - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
162 : 111674 : obj[i] = ring[idx];
163 : 111674 : obj[i + 1] = ring[idx + 1];
164 : 111674 : obj[i + 2] = ring[idx + 2];
165 : 111674 : obj[i + 3] = ring[idx + 3];
166 : 111674 : obj[i + 4] = ring[idx + 4];
167 : 111674 : obj[i + 5] = ring[idx + 5];
168 : 111674 : obj[i + 6] = ring[idx + 6];
169 : 111674 : obj[i + 7] = ring[idx + 7];
170 : : }
171 [ - + - - : 15509 : switch (n & 0x7) {
+ + - + -
- + - - -
+ - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - + - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - + - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- + + + +
+ + + - -
- - - - -
- + + + +
+ + + + +
+ + - + +
+ + + - +
+ + + + +
- + + + +
+ + + - +
+ - + + +
+ - - - -
- - - - +
+ + + - +
+ + + + +
- - + + +
+ - + + +
+ + + + -
+ - + + +
+ ]
172 : 13 : case 7:
173 : 13 : obj[i++] = ring[idx++]; /* fallthrough */
174 : 2010 : case 6:
175 : 2010 : obj[i++] = ring[idx++]; /* fallthrough */
176 : 6138 : case 5:
177 : 6138 : obj[i++] = ring[idx++]; /* fallthrough */
178 : 6146 : case 4:
179 : 6146 : obj[i++] = ring[idx++]; /* fallthrough */
180 : 6158 : case 3:
181 : 6158 : obj[i++] = ring[idx++]; /* fallthrough */
182 : 6249 : case 2:
183 : 6249 : obj[i++] = ring[idx++]; /* fallthrough */
184 : 10380 : case 1:
185 : 412543 : obj[i++] = ring[idx++]; /* fallthrough */
186 : : }
187 : : } else {
188 [ - - - - : 1287263 : for (i = 0; idx < size; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
189 : 1287037 : obj[i] = ring[idx];
190 : : /* Start at the beginning */
191 [ - - - - : 1216911 : for (idx = 0; i < n; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
192 : 1216685 : obj[i] = ring[idx];
193 : : }
194 : : }
195 : :
196 : : static __rte_always_inline void
197 : : __rte_ring_dequeue_elems_64(struct rte_ring *r, uint32_t cons_head,
198 : : void *obj_table, uint32_t n)
199 : : {
200 : : unsigned int i;
201 : 48721082 : const uint32_t size = r->size;
202 : 48721082 : uint32_t idx = cons_head & r->mask;
203 : 48721082 : uint64_t *ring = (uint64_t *)&r[1];
204 : : unaligned_uint64_t *obj = (unaligned_uint64_t *)obj_table;
205 [ + - + + : 48721082 : if (likely(idx + n <= size)) {
+ + + + -
- - - - -
+ - - - +
- - - - -
- - + + -
- - - - -
- - - - +
- - - - -
- - - - -
- + - - -
- - - - -
- - - + +
- - - - -
- - - + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
206 [ + + + + : 55681362 : for (i = 0; i < (n & ~0x3); i += 4, idx += 4) {
- + + + -
- - - - -
+ + - - -
- - - - -
- - - + -
- - - - -
- - - - +
+ - - - -
- - - - +
+ - - + +
+ + + + +
+ + + - -
+ + + + +
+ + + + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + ]
207 : 7336749 : obj[i] = ring[idx];
208 : 7336749 : obj[i + 1] = ring[idx + 1];
209 : 7336749 : obj[i + 2] = ring[idx + 2];
210 : 7336749 : obj[i + 3] = ring[idx + 3];
211 : : }
212 [ - + + - : 48344613 : switch (n & 0x3) {
- + + + -
- + - + +
+ + - - -
- - - - -
- - - - -
- - + - -
- - - - -
- - - - -
- - - - -
- - - - +
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
+ - - - -
- - - - -
- - - - -
- - + + +
+ - - - -
+ + + + +
+ + + + +
+ + - + +
+ + + + +
- - - - +
+ + + - +
+ + + + +
+ + + + +
+ + + + -
- - - + +
+ + + + +
+ + + + +
- + + + +
+ + + - -
- - + + +
+ + + + +
+ + + + +
+ + + ]
213 : 39 : case 3:
214 : 39 : obj[i++] = ring[idx++]; /* fallthrough */
215 : 3368575 : case 2:
216 : 3368575 : obj[i++] = ring[idx++]; /* fallthrough */
217 : 48306694 : case 1:
218 : 48574257 : obj[i++] = ring[idx++]; /* fallthrough */
219 : : }
220 : : } else {
221 [ - - + + : 1066876 : for (i = 0; idx < size; i++, idx++)
+ + + + -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - + +
- - - - -
- - - + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
222 : 957970 : obj[i] = ring[idx];
223 : : /* Start at the beginning */
224 [ - - + + : 1063961 : for (idx = 0; i < n; i++, idx++)
+ + + + -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - + +
- - - - -
- - - + +
- - + + +
+ + + + +
+ + - - +
+ + + + +
+ + + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
225 : 955055 : obj[i] = ring[idx];
226 : : }
227 : : }
228 : :
229 : : static __rte_always_inline void
230 : : __rte_ring_dequeue_elems_128(struct rte_ring *r, uint32_t cons_head,
231 : : void *obj_table, uint32_t n)
232 : : {
233 : : unsigned int i;
234 : 29668 : const uint32_t size = r->size;
235 : 29668 : uint32_t idx = cons_head & r->mask;
236 : 29668 : rte_int128_t *ring = (rte_int128_t *)&r[1];
237 : : rte_int128_t *obj = (rte_int128_t *)obj_table;
238 [ + - + - : 29668 : if (likely(idx + n <= size)) {
- - - - -
- + - - -
+ - - - +
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
239 [ - - + + : 106802 : for (i = 0; i < (n & ~0x1); i += 2, idx += 2)
- - - - -
- + + - -
+ + - - +
+ - - - -
+ + + + +
+ + + + +
+ + + + -
- + + + +
+ + + + ]
240 : 81392 : memcpy((void *)(obj + i), (void *)(ring + idx), 32);
241 [ - - + + : 25410 : switch (n & 0x1) {
- - - - -
- + + - -
- + - - +
+ - - - -
+ + + + +
+ + + + +
+ + + + -
- + + + +
+ + + + ]
242 : 22784 : case 1:
243 : 26926 : memcpy((void *)(obj + i), (void *)(ring + idx), 16);
244 : : }
245 : : } else {
246 [ - - - - : 193394 : for (i = 0; idx < size; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
247 : 193278 : memcpy((void *)(obj + i), (void *)(ring + idx), 16);
248 : : /* Start at the beginning */
249 [ - - - - : 225192 : for (idx = 0; i < n; i++, idx++)
- - - - -
- - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
250 : 225076 : memcpy((void *)(obj + i), (void *)(ring + idx), 16);
251 : : }
252 : : }
253 : :
254 : : /* the actual dequeue of elements from the ring.
255 : : * Placed here since identical code needed in both
256 : : * single and multi producer enqueue functions.
257 : : */
258 : : static __rte_always_inline void
259 : : __rte_ring_dequeue_elems(struct rte_ring *r, uint32_t cons_head,
260 : : void *obj_table, uint32_t esize, uint32_t num)
261 : : {
262 : : /* 8B and 16B copies implemented individually to retain
263 : : * the current performance.
264 : : */
265 [ - + + + : 29497 : if (esize == 8)
- - - - -
- - - - -
+ + - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
266 : : __rte_ring_dequeue_elems_64(r, cons_head, obj_table, num);
267 [ + + + + : 22639 : else if (esize == 16)
- - - - -
- - - - -
+ + - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ ]
268 : : __rte_ring_dequeue_elems_128(r, cons_head, obj_table, num);
269 : : else {
270 : : uint32_t idx, scale, nr_idx, nr_num, nr_size;
271 : :
272 : : /* Normalize to uint32_t */
273 : 15734 : scale = esize / sizeof(uint32_t);
274 : 7544 : nr_num = num * scale;
275 : 417898 : idx = cons_head & r->mask;
276 : 15734 : nr_idx = idx * scale;
277 [ + - + - : 417898 : nr_size = r->size * scale;
+ - + - -
- - - - -
+ - - - -
- - - - -
- - + + -
- - - - -
- - + + -
- + + + +
+ + + + +
+ - - + +
+ + + + +
+ # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
278 : : __rte_ring_dequeue_elems_32(r, nr_size, nr_idx,
279 : : obj_table, nr_num);
280 : : }
281 : : }
282 : :
283 : : /* Between load and load. there might be cpu reorder in weak model
284 : : * (powerpc/arm).
285 : : * There are 2 choices for the users
286 : : * 1.use rmb() memory barrier
287 : : * 2.use one-direction load_acquire/store_release barrier
288 : : * It depends on performance test results.
289 : : */
290 : : #ifdef RTE_USE_C11_MEM_MODEL
291 : : #include "rte_ring_c11_pvt.h"
292 : : #else
293 : : #include "rte_ring_generic_pvt.h"
294 : : #endif
295 : :
296 : : /**
297 : : * @internal Enqueue several objects on the ring
298 : : *
299 : : * @param r
300 : : * A pointer to the ring structure.
301 : : * @param obj_table
302 : : * A pointer to a table of objects.
303 : : * @param esize
304 : : * The size of ring element, in bytes. It must be a multiple of 4.
305 : : * This must be the same value used while creating the ring. Otherwise
306 : : * the results are undefined.
307 : : * @param n
308 : : * The number of objects to add in the ring from the obj_table.
309 : : * @param behavior
310 : : * RTE_RING_QUEUE_FIXED: Enqueue a fixed number of items from a ring
311 : : * RTE_RING_QUEUE_VARIABLE: Enqueue as many items as possible from ring
312 : : * @param is_sp
313 : : * Indicates whether to use single producer or multi-producer head update
314 : : * @param free_space
315 : : * returns the amount of space after the enqueue operation has finished
316 : : * @return
317 : : * Actual number of objects enqueued.
318 : : * If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.
319 : : */
320 : : static __rte_always_inline unsigned int
321 : : __rte_ring_do_enqueue_elem(struct rte_ring *r, const void *obj_table,
322 : : unsigned int esize, unsigned int n,
323 : : enum rte_ring_queue_behavior behavior, unsigned int is_sp,
324 : : unsigned int *free_space)
325 : : {
326 : : uint32_t prod_head, prod_next;
327 : : uint32_t free_entries;
328 : :
329 : : n = __rte_ring_move_prod_head(r, is_sp, n, behavior,
330 : : &prod_head, &prod_next, &free_entries);
331 [ - + - - : 44726313 : if (n == 0)
- - - - -
- - - - -
- - - - -
- - - - -
+ + + + +
+ + + + +
+ + + + +
+ ]
332 : 43 : goto end;
333 : :
334 : : __rte_ring_enqueue_elems(r, prod_head, obj_table, esize, n);
335 : :
336 : : __rte_ring_update_tail(&r->prod, prod_head, prod_next, is_sp, 1);
337 [ + - # # : 44743771 : end:
# # # # ]
338 [ - + - - : 8310 : if (free_space != NULL)
- + - + -
+ - - - +
- + - + -
- - + - +
- + - - -
+ - + ]
339 : 9297 : *free_space = free_entries - n;
340 : : return n;
341 : : }
342 : :
343 : : /**
344 : : * @internal Dequeue several objects from the ring
345 : : *
346 : : * @param r
347 : : * A pointer to the ring structure.
348 : : * @param obj_table
349 : : * A pointer to a table of objects.
350 : : * @param esize
351 : : * The size of ring element, in bytes. It must be a multiple of 4.
352 : : * This must be the same value used while creating the ring. Otherwise
353 : : * the results are undefined.
354 : : * @param n
355 : : * The number of objects to pull from the ring.
356 : : * @param behavior
357 : : * RTE_RING_QUEUE_FIXED: Dequeue a fixed number of items from a ring
358 : : * RTE_RING_QUEUE_VARIABLE: Dequeue as many items as possible from ring
359 : : * @param is_sc
360 : : * Indicates whether to use single consumer or multi-consumer head update
361 : : * @param available
362 : : * returns the number of remaining ring entries after the dequeue has finished
363 : : * @return
364 : : * - Actual number of objects dequeued.
365 : : * If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.
366 : : */
367 : : static __rte_always_inline unsigned int
368 : : __rte_ring_do_dequeue_elem(struct rte_ring *r, void *obj_table,
369 : : unsigned int esize, unsigned int n,
370 : : enum rte_ring_queue_behavior behavior, unsigned int is_sc,
371 : : unsigned int *available)
372 : : {
373 : : uint32_t cons_head, cons_next;
374 : : uint32_t entries;
375 : :
376 : : n = __rte_ring_move_cons_head(r, (int)is_sc, n, behavior,
377 : : &cons_head, &cons_next, &entries);
378 [ + + + + : 49225877 : if (n == 0)
- + - + -
- - + - -
- + - - -
+ - - - -
- - - + -
- - - - -
- + - - -
- - - - +
- - - - -
+ - - - +
- + - + -
- - + - +
- + - - -
+ - + - +
- - - + -
+ # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
379 : 16868028 : goto end;
380 : :
381 : : __rte_ring_dequeue_elems(r, cons_head, obj_table, esize, n);
382 : :
383 : : __rte_ring_update_tail(&r->cons, cons_head, cons_next, is_sc, 0);
384 : :
385 [ + + + - : 48909384 : end:
+ - + - ]
386 [ - + - - : 8280 : if (available != NULL)
- + - + -
+ - - - +
- + - + -
- - + - +
- + - - -
+ - + ]
387 : 2 : *available = entries - n;
388 : : return n;
389 : : }
390 : :
391 : : #if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
392 : : #pragma GCC diagnostic pop
393 : : #endif
394 : :
395 : : #endif /* _RTE_RING_ELEM_PVT_H_ */
|