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

Function test_enqueue_copies

dpdk/app/test/test_dmadev.c:271–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271static int
272test_enqueue_copies(int16_t dev_id, uint16_t vchan)
273{
274 unsigned int i;
275
276 /* test doing a single copy */
277 if (test_single_copy(dev_id, vchan) < 0)
278 return -1;
279
280 /* test doing a multiple single copies */
281 do {
282 uint16_t id;
283 const uint16_t max_ops = 4;
284 struct rte_mbuf *src, *dst;
285 char *src_data, *dst_data;
286 uint16_t count;
287
288 src = rte_pktmbuf_alloc(pool);
289 dst = rte_pktmbuf_alloc(pool);
290 src_data = rte_pktmbuf_mtod(src, char *);
291 dst_data = rte_pktmbuf_mtod(dst, char *);
292
293 for (i = 0; i < COPY_LEN; i++)
294 src_data[i] = rte_rand() & 0xFF;
295
296 /* perform the same copy <max_ops> times */
297 for (i = 0; i < max_ops; i++)
298 if (rte_dma_copy(dev_id, vchan,
299 rte_pktmbuf_iova(src),
300 rte_pktmbuf_iova(dst),
301 COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT) != id_count++)
302 ERR_RETURN("Error with rte_dma_copy\n");
303
304 await_hw(dev_id, vchan);
305
306 count = rte_dma_completed(dev_id, vchan, max_ops * 2, &id, NULL);
307 if (count != max_ops)
308 ERR_RETURN("Error with rte_dma_completed, got %u not %u\n",
309 count, max_ops);
310
311 if (id != id_count - 1)
312 ERR_RETURN("Error, incorrect job id returned: got %u not %u\n",
313 id, id_count - 1);
314
315 for (i = 0; i < COPY_LEN; i++)
316 if (dst_data[i] != src_data[i])
317 ERR_RETURN("Data mismatch at char %u\n", i);
318
319 rte_pktmbuf_free(src);
320 rte_pktmbuf_free(dst);
321 } while (0);
322
323 /* test doing multiple copies */
324 return do_multi_copies(dev_id, vchan, 0, 0, 0) /* enqueue and complete 1 batch at a time */
325 /* enqueue 2 batches and then complete both */
326 || do_multi_copies(dev_id, vchan, 1, 0, 0)
327 /* enqueue 1 batch, then complete in two halves */
328 || do_multi_copies(dev_id, vchan, 0, 1, 0)

Callers

nothing calls this directly

Calls 8

test_single_copyFunction · 0.85
rte_pktmbuf_allocFunction · 0.85
rte_randFunction · 0.85
rte_dma_copyFunction · 0.85
await_hwFunction · 0.85
rte_dma_completedFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
do_multi_copiesFunction · 0.85

Tested by

no test coverage detected