MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_reorder_insert

Function test_reorder_insert

dpdk/app/test/test_reorder.c:130–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130static int
131test_reorder_insert(void)
132{
133 struct rte_reorder_buffer *b = NULL;
134 struct rte_mempool *p = test_params->p;
135 const unsigned int size = 4;
136 const unsigned int num_bufs = 7;
137 struct rte_mbuf *bufs[num_bufs];
138 int ret = 0;
139 unsigned i;
140
141 /* This would create a reorder buffer instance consisting of:
142 * reorder_seq = 0
143 * ready_buf: RB[size] = {NULL, NULL, NULL, NULL}
144 * order_buf: OB[size] = {NULL, NULL, NULL, NULL}
145 */
146 b = rte_reorder_create("test_insert", rte_socket_id(), size);
147 TEST_ASSERT_NOT_NULL(b, "Failed to create reorder buffer");
148
149 for (i = 0; i < num_bufs; i++) {
150 bufs[i] = rte_pktmbuf_alloc(p);
151 TEST_ASSERT_NOT_NULL(bufs[i], "Packet allocation failed\n");
152 *rte_reorder_seqn(bufs[i]) = i;
153 }
154
155 /* This should fill up order buffer:
156 * reorder_seq = 0
157 * RB[] = {NULL, NULL, NULL, NULL}
158 * OB[] = {0, 1, 2, 3}
159 */
160 for (i = 0; i < size; i++) {
161 ret = rte_reorder_insert(b, bufs[i]);
162 if (ret != 0) {
163 printf("%s:%d: Error inserting packet with seqn less than size\n",
164 __func__, __LINE__);
165 ret = -1;
166 goto exit;
167 }
168 bufs[i] = NULL;
169 }
170
171 /* early packet - should move mbufs to ready buf and move sequence window
172 * reorder_seq = 4
173 * RB[] = {0, 1, 2, 3}
174 * OB[] = {4, NULL, NULL, NULL}
175 */
176 ret = rte_reorder_insert(b, bufs[4]);
177 if (ret != 0) {
178 printf("%s:%d: Error inserting early packet with seqn: size\n",
179 __func__, __LINE__);
180 ret = -1;
181 goto exit;
182 }
183 bufs[4] = NULL;
184
185 /* early packet from current sequence window - full ready buffer */
186 *rte_reorder_seqn(bufs[5]) = 2 * size;
187 ret = rte_reorder_insert(b, bufs[5]);

Callers

nothing calls this directly

Calls 7

rte_reorder_createFunction · 0.85
rte_socket_idFunction · 0.85
rte_pktmbuf_allocFunction · 0.85
rte_reorder_insertFunction · 0.85
rte_reorder_freeFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected