Lines Matching full:pbl
1190 static int pbl_chunk_list_create(struct efa_dev *dev, struct pbl_context *pbl) in pbl_chunk_list_create() argument
1192 struct pbl_chunk_list *chunk_list = &pbl->phys.indirect.chunk_list; in pbl_chunk_list_create()
1193 int page_cnt = pbl->phys.indirect.pbl_buf_size_in_pages; in pbl_chunk_list_create()
1194 struct scatterlist *pages_sgl = pbl->phys.indirect.sgl; in pbl_chunk_list_create()
1196 int sg_dma_cnt = pbl->phys.indirect.sg_dma_cnt; in pbl_chunk_list_create()
1290 static void pbl_chunk_list_destroy(struct efa_dev *dev, struct pbl_context *pbl) in pbl_chunk_list_destroy() argument
1292 struct pbl_chunk_list *chunk_list = &pbl->phys.indirect.chunk_list; in pbl_chunk_list_destroy()
1304 /* initialize pbl continuous mode: map pbl buffer to a dma address. */
1306 struct pbl_context *pbl) in pbl_continuous_initialize() argument
1310 dma_addr = dma_map_single(&dev->pdev->dev, pbl->pbl_buf, in pbl_continuous_initialize()
1311 pbl->pbl_buf_size_in_bytes, DMA_TO_DEVICE); in pbl_continuous_initialize()
1313 ibdev_err(&dev->ibdev, "Unable to map pbl to DMA address\n"); in pbl_continuous_initialize()
1317 pbl->phys.continuous.dma_addr = dma_addr; in pbl_continuous_initialize()
1319 "pbl continuous - dma_addr = %pad, size[%u]\n", in pbl_continuous_initialize()
1320 &dma_addr, pbl->pbl_buf_size_in_bytes); in pbl_continuous_initialize()
1326 * initialize pbl indirect mode:
1328 * pbl buffer.
1330 static int pbl_indirect_initialize(struct efa_dev *dev, struct pbl_context *pbl) in pbl_indirect_initialize() argument
1332 u32 size_in_pages = DIV_ROUND_UP(pbl->pbl_buf_size_in_bytes, PAGE_SIZE); in pbl_indirect_initialize()
1337 sgl = efa_vmalloc_buf_to_sg(pbl->pbl_buf, size_in_pages); in pbl_indirect_initialize()
1347 pbl->phys.indirect.pbl_buf_size_in_pages = size_in_pages; in pbl_indirect_initialize()
1348 pbl->phys.indirect.sgl = sgl; in pbl_indirect_initialize()
1349 pbl->phys.indirect.sg_dma_cnt = sg_dma_cnt; in pbl_indirect_initialize()
1350 err = pbl_chunk_list_create(dev, pbl); in pbl_indirect_initialize()
1358 "pbl indirect - size[%u], chunks[%u]\n", in pbl_indirect_initialize()
1359 pbl->pbl_buf_size_in_bytes, in pbl_indirect_initialize()
1360 pbl->phys.indirect.chunk_list.size); in pbl_indirect_initialize()
1371 static void pbl_indirect_terminate(struct efa_dev *dev, struct pbl_context *pbl) in pbl_indirect_terminate() argument
1373 pbl_chunk_list_destroy(dev, pbl); in pbl_indirect_terminate()
1374 dma_unmap_sg(&dev->pdev->dev, pbl->phys.indirect.sgl, in pbl_indirect_terminate()
1375 pbl->phys.indirect.pbl_buf_size_in_pages, DMA_TO_DEVICE); in pbl_indirect_terminate()
1376 kfree(pbl->phys.indirect.sgl); in pbl_indirect_terminate()
1381 struct pbl_context *pbl, in pbl_create() argument
1388 pbl->pbl_buf_size_in_bytes = hp_cnt * EFA_CHUNK_PAYLOAD_PTR_SIZE; in pbl_create()
1389 pbl->pbl_buf = kvzalloc(pbl->pbl_buf_size_in_bytes, GFP_KERNEL); in pbl_create()
1390 if (!pbl->pbl_buf) in pbl_create()
1393 if (is_vmalloc_addr(pbl->pbl_buf)) { in pbl_create()
1394 pbl->physically_continuous = 0; in pbl_create()
1395 err = umem_to_page_list(dev, umem, pbl->pbl_buf, hp_cnt, in pbl_create()
1400 err = pbl_indirect_initialize(dev, pbl); in pbl_create()
1404 pbl->physically_continuous = 1; in pbl_create()
1405 err = umem_to_page_list(dev, umem, pbl->pbl_buf, hp_cnt, in pbl_create()
1410 err = pbl_continuous_initialize(dev, pbl); in pbl_create()
1417 hp_cnt, pbl->physically_continuous); in pbl_create()
1422 kvfree(pbl->pbl_buf); in pbl_create()
1426 static void pbl_destroy(struct efa_dev *dev, struct pbl_context *pbl) in pbl_destroy() argument
1428 if (pbl->physically_continuous) in pbl_destroy()
1429 dma_unmap_single(&dev->pdev->dev, pbl->phys.continuous.dma_addr, in pbl_destroy()
1430 pbl->pbl_buf_size_in_bytes, DMA_TO_DEVICE); in pbl_destroy()
1432 pbl_indirect_terminate(dev, pbl); in pbl_destroy()
1434 kvfree(pbl->pbl_buf); in pbl_destroy()
1443 err = umem_to_page_list(dev, mr->umem, params->pbl.inline_pbl_array, in efa_create_inline_pbl()
1455 struct pbl_context *pbl, in efa_create_pbl() argument
1461 err = pbl_create(dev, pbl, mr->umem, params->page_num, in efa_create_pbl()
1464 ibdev_dbg(&dev->ibdev, "Failed to create pbl[%d]\n", err); in efa_create_pbl()
1469 params->indirect = !pbl->physically_continuous; in efa_create_pbl()
1470 if (pbl->physically_continuous) { in efa_create_pbl()
1471 params->pbl.pbl.length = pbl->pbl_buf_size_in_bytes; in efa_create_pbl()
1473 efa_com_set_dma_addr(pbl->phys.continuous.dma_addr, in efa_create_pbl()
1474 ¶ms->pbl.pbl.address.mem_addr_high, in efa_create_pbl()
1475 ¶ms->pbl.pbl.address.mem_addr_low); in efa_create_pbl()
1477 params->pbl.pbl.length = in efa_create_pbl()
1478 pbl->phys.indirect.chunk_list.chunks[0].length; in efa_create_pbl()
1480 efa_com_set_dma_addr(pbl->phys.indirect.chunk_list.chunks[0].dma_addr, in efa_create_pbl()
1481 ¶ms->pbl.pbl.address.mem_addr_high, in efa_create_pbl()
1482 ¶ms->pbl.pbl.address.mem_addr_low); in efa_create_pbl()
1495 struct pbl_context pbl; in efa_reg_mr() local
1559 inline_size = ARRAY_SIZE(params.pbl.inline_pbl_array); in efa_reg_mr()
1569 err = efa_create_pbl(dev, &pbl, mr, ¶ms); in efa_reg_mr()
1574 pbl_destroy(dev, &pbl); in efa_reg_mr()