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

Function dma_afu_buf_alloc

dpdk/drivers/raw/ifpga/afu_pmd_n3000.c:236–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236static int dma_afu_buf_alloc(struct dma_afu_ctx *ctx,
237 struct rte_pmd_afu_dma_cfg *cfg)
238{
239 size_t page_sz = sysconf(_SC_PAGE_SIZE);
240 int i, ret = 0;
241
242 if (!ctx || !cfg)
243 return -EINVAL;
244
245 for (i = 0; i < NUM_DMA_BUF; i++) {
246 ctx->dma_buf[i] = (uint64_t *)rte_zmalloc(NULL, cfg->size,
247 TEST_MEM_ALIGN);
248 if (!ctx->dma_buf[i]) {
249 ret = -ENOMEM;
250 goto free_dma_buf;
251 }
252 ctx->dma_iova[i] = rte_malloc_virt2iova(ctx->dma_buf[i]);
253 if (ctx->dma_iova[i] == RTE_BAD_IOVA) {
254 ret = -ENOMEM;
255 goto free_dma_buf;
256 }
257 }
258
259 ctx->data_buf = rte_malloc(NULL, cfg->length, page_sz);
260 if (!ctx->data_buf) {
261 ret = -ENOMEM;
262 goto free_dma_buf;
263 }
264
265 ctx->ref_buf = rte_malloc(NULL, cfg->length, page_sz);
266 if (!ctx->ref_buf) {
267 ret = -ENOMEM;
268 goto free_data_buf;
269 }
270
271 return 0;
272
273free_data_buf:
274 rte_free(ctx->data_buf);
275 ctx->data_buf = NULL;
276free_dma_buf:
277 for (i = 0; i < NUM_DMA_BUF; i++) {
278 rte_free(ctx->dma_buf[i]);
279 ctx->dma_buf[i] = NULL;
280 }
281 return ret;
282}
283
284static void dma_afu_buf_init(struct dma_afu_ctx *ctx, size_t size)
285{

Callers 1

dma_afu_testFunction · 0.85

Calls 4

rte_zmallocFunction · 0.85
rte_malloc_virt2iovaFunction · 0.85
rte_mallocFunction · 0.85
rte_freeFunction · 0.85

Tested by

no test coverage detected