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

Function test_m2d_auto_free

dpdk/app/test/test_dmadev.c:826–887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

824}
825
826static int
827test_m2d_auto_free(int16_t dev_id, uint16_t vchan)
828{
829#define NR_MBUF 256
830 struct rte_mempool_cache *cache;
831 struct rte_mbuf *src[NR_MBUF];
832 uint32_t buf_cnt1, buf_cnt2;
833 struct rte_mempool_ops *ops;
834 uint16_t nb_done = 0;
835 bool dma_err = false;
836 int retry = 100;
837 int i, ret = 0;
838 rte_iova_t dst;
839
840 dst = (rte_iova_t)env_test_param[TEST_PARAM_REMOTE_ADDR];
841
842 /* Capture buffer count before allocating source buffer. */
843 cache = rte_mempool_default_cache(pool, rte_lcore_id());
844 ops = rte_mempool_get_ops(pool->ops_index);
845 buf_cnt1 = ops->get_count(pool) + cache->len;
846
847 if (rte_pktmbuf_alloc_bulk(pool, src, NR_MBUF) != 0)
848 ERR_RETURN("alloc src mbufs failed.\n");
849
850 if ((buf_cnt1 - NR_MBUF) != (ops->get_count(pool) + cache->len)) {
851 printf("Buffer count check failed.\n");
852 ret = -1;
853 goto done;
854 }
855
856 for (i = 0; i < NR_MBUF; i++) {
857 ret = rte_dma_copy(dev_id, vchan, rte_mbuf_data_iova(src[i]), dst,
858 COPY_LEN, RTE_DMA_OP_FLAG_AUTO_FREE);
859
860 if (ret < 0) {
861 printf("rte_dma_copy returned error.\n");
862 goto done;
863 }
864 }
865
866 rte_dma_submit(dev_id, vchan);
867 do {
868 nb_done += rte_dma_completed(dev_id, vchan, (NR_MBUF - nb_done), NULL, &dma_err);
869 if (dma_err)
870 break;
871 /* Sleep for 1 millisecond */
872 rte_delay_us_sleep(1000);
873 } while (retry-- && (nb_done < NR_MBUF));
874
875 buf_cnt2 = ops->get_count(pool) + cache->len;
876 if ((buf_cnt1 != buf_cnt2) || dma_err) {
877 printf("Free mem to dev buffer test failed.\n");
878 ret = -1;
879 }
880
881done:
882 /* If the test passes source buffer will be freed in hardware. */
883 if (ret < 0)

Callers

nothing calls this directly

Calls 11

rte_lcore_idFunction · 0.85
rte_mempool_get_opsFunction · 0.85
rte_pktmbuf_alloc_bulkFunction · 0.85
rte_dma_copyFunction · 0.85
rte_mbuf_data_iovaFunction · 0.85
rte_dma_submitFunction · 0.85
rte_dma_completedFunction · 0.85
rte_pktmbuf_free_bulkFunction · 0.85
printfFunction · 0.50
rte_delay_us_sleepFunction · 0.50

Tested by

no test coverage detected