Lines Matching refs:func_to_io

60 static void __iomem *get_db_area(struct hinic_func_to_io *func_to_io)  in get_db_area()  argument
62 struct hinic_free_db_area *free_db_area = &func_to_io->free_db_area; in get_db_area()
84 return func_to_io->db_base + idx * HINIC_DB_PAGE_SIZE; in get_db_area()
87 static void return_db_area(struct hinic_func_to_io *func_to_io, in return_db_area() argument
90 struct hinic_free_db_area *free_db_area = &func_to_io->free_db_area; in return_db_area()
91 int pos, idx = DB_IDX(db_base, func_to_io->db_base); in return_db_area()
105 static int write_sq_ctxts(struct hinic_func_to_io *func_to_io, u16 base_qpn, in write_sq_ctxts() argument
108 struct hinic_hwif *hwif = func_to_io->hwif; in write_sq_ctxts()
117 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmdq_buf); in write_sq_ctxts()
127 num_sqs, func_to_io->max_qps); in write_sq_ctxts()
129 qp = &func_to_io->qps[i]; in write_sq_ctxts()
137 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC, in write_sq_ctxts()
145 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmdq_buf); in write_sq_ctxts()
149 static int write_rq_ctxts(struct hinic_func_to_io *func_to_io, u16 base_qpn, in write_rq_ctxts() argument
152 struct hinic_hwif *hwif = func_to_io->hwif; in write_rq_ctxts()
161 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmdq_buf); in write_rq_ctxts()
171 num_rqs, func_to_io->max_qps); in write_rq_ctxts()
173 qp = &func_to_io->qps[i]; in write_rq_ctxts()
181 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC, in write_rq_ctxts()
189 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmdq_buf); in write_rq_ctxts()
201 static int write_qp_ctxts(struct hinic_func_to_io *func_to_io, u16 base_qpn, in write_qp_ctxts() argument
204 return (write_sq_ctxts(func_to_io, base_qpn, num_qps) || in write_qp_ctxts()
205 write_rq_ctxts(func_to_io, base_qpn, num_qps)); in write_qp_ctxts()
208 static int hinic_clean_queue_offload_ctxt(struct hinic_func_to_io *func_to_io, in hinic_clean_queue_offload_ctxt() argument
211 struct hinic_hwif *hwif = func_to_io->hwif; in hinic_clean_queue_offload_ctxt()
218 err = hinic_alloc_cmdq_buf(&func_to_io->cmdqs, &cmdq_buf); in hinic_clean_queue_offload_ctxt()
225 ctxt_block->cmdq_hdr.num_queues = func_to_io->max_qps; in hinic_clean_queue_offload_ctxt()
236 err = hinic_cmdq_direct_resp(&func_to_io->cmdqs, HINIC_MOD_L2NIC, in hinic_clean_queue_offload_ctxt()
247 hinic_free_cmdq_buf(&func_to_io->cmdqs, &cmdq_buf); in hinic_clean_queue_offload_ctxt()
252 static int hinic_clean_qp_offload_ctxt(struct hinic_func_to_io *func_to_io) in hinic_clean_qp_offload_ctxt() argument
255 return (hinic_clean_queue_offload_ctxt(func_to_io, in hinic_clean_qp_offload_ctxt()
257 hinic_clean_queue_offload_ctxt(func_to_io, in hinic_clean_qp_offload_ctxt()
271 static int init_qp(struct hinic_func_to_io *func_to_io, in init_qp() argument
276 struct hinic_hwif *hwif = func_to_io->hwif; in init_qp()
283 err = hinic_wq_allocate(&func_to_io->wqs, &func_to_io->sq_wq[q_id], in init_qp()
285 func_to_io->sq_depth, HINIC_SQ_WQE_MAX_SIZE); in init_qp()
291 err = hinic_wq_allocate(&func_to_io->wqs, &func_to_io->rq_wq[q_id], in init_qp()
293 func_to_io->rq_depth, HINIC_RQ_WQE_SIZE); in init_qp()
299 db_base = get_db_area(func_to_io); in init_qp()
306 func_to_io->sq_db[q_id] = db_base; in init_qp()
309 err = hinic_init_sq(&qp->sq, hwif, &func_to_io->sq_wq[q_id], in init_qp()
311 CI_ADDR(func_to_io->ci_addr_base, q_id), in init_qp()
312 CI_ADDR(func_to_io->ci_dma_base, q_id), db_base); in init_qp()
319 err = hinic_init_rq(&qp->rq, hwif, &func_to_io->rq_wq[q_id], in init_qp()
332 return_db_area(func_to_io, db_base); in init_qp()
335 hinic_wq_free(&func_to_io->wqs, &func_to_io->rq_wq[q_id]); in init_qp()
338 hinic_wq_free(&func_to_io->wqs, &func_to_io->sq_wq[q_id]); in init_qp()
347 static void destroy_qp(struct hinic_func_to_io *func_to_io, in destroy_qp() argument
355 return_db_area(func_to_io, func_to_io->sq_db[q_id]); in destroy_qp()
357 hinic_wq_free(&func_to_io->wqs, &func_to_io->rq_wq[q_id]); in destroy_qp()
358 hinic_wq_free(&func_to_io->wqs, &func_to_io->sq_wq[q_id]); in destroy_qp()
371 int hinic_io_create_qps(struct hinic_func_to_io *func_to_io, in hinic_io_create_qps() argument
376 struct hinic_hwif *hwif = func_to_io->hwif; in hinic_io_create_qps()
381 func_to_io->qps = devm_kcalloc(&pdev->dev, num_qps, in hinic_io_create_qps()
382 sizeof(*func_to_io->qps), GFP_KERNEL); in hinic_io_create_qps()
383 if (!func_to_io->qps) in hinic_io_create_qps()
386 func_to_io->sq_wq = devm_kcalloc(&pdev->dev, num_qps, in hinic_io_create_qps()
387 sizeof(*func_to_io->sq_wq), GFP_KERNEL); in hinic_io_create_qps()
388 if (!func_to_io->sq_wq) { in hinic_io_create_qps()
393 func_to_io->rq_wq = devm_kcalloc(&pdev->dev, num_qps, in hinic_io_create_qps()
394 sizeof(*func_to_io->rq_wq), GFP_KERNEL); in hinic_io_create_qps()
395 if (!func_to_io->rq_wq) { in hinic_io_create_qps()
400 func_to_io->sq_db = devm_kcalloc(&pdev->dev, num_qps, in hinic_io_create_qps()
401 sizeof(*func_to_io->sq_db), GFP_KERNEL); in hinic_io_create_qps()
402 if (!func_to_io->sq_db) { in hinic_io_create_qps()
408 &func_to_io->ci_dma_base, in hinic_io_create_qps()
416 func_to_io->ci_addr_base = ci_addr_base; in hinic_io_create_qps()
419 err = init_qp(func_to_io, &func_to_io->qps[i], i, in hinic_io_create_qps()
427 err = write_qp_ctxts(func_to_io, base_qpn, num_qps); in hinic_io_create_qps()
433 err = hinic_clean_qp_offload_ctxt(func_to_io); in hinic_io_create_qps()
444 destroy_qp(func_to_io, &func_to_io->qps[j]); in hinic_io_create_qps()
447 func_to_io->ci_addr_base, func_to_io->ci_dma_base); in hinic_io_create_qps()
450 devm_kfree(&pdev->dev, func_to_io->sq_db); in hinic_io_create_qps()
453 devm_kfree(&pdev->dev, func_to_io->rq_wq); in hinic_io_create_qps()
456 devm_kfree(&pdev->dev, func_to_io->sq_wq); in hinic_io_create_qps()
459 devm_kfree(&pdev->dev, func_to_io->qps); in hinic_io_create_qps()
468 void hinic_io_destroy_qps(struct hinic_func_to_io *func_to_io, int num_qps) in hinic_io_destroy_qps() argument
470 struct hinic_hwif *hwif = func_to_io->hwif; in hinic_io_destroy_qps()
478 destroy_qp(func_to_io, &func_to_io->qps[i]); in hinic_io_destroy_qps()
480 dma_free_coherent(&pdev->dev, ci_table_size, func_to_io->ci_addr_base, in hinic_io_destroy_qps()
481 func_to_io->ci_dma_base); in hinic_io_destroy_qps()
483 devm_kfree(&pdev->dev, func_to_io->sq_db); in hinic_io_destroy_qps()
485 devm_kfree(&pdev->dev, func_to_io->rq_wq); in hinic_io_destroy_qps()
486 devm_kfree(&pdev->dev, func_to_io->sq_wq); in hinic_io_destroy_qps()
488 devm_kfree(&pdev->dev, func_to_io->qps); in hinic_io_destroy_qps()
528 int hinic_io_init(struct hinic_func_to_io *func_to_io, in hinic_io_init() argument
537 func_to_io->hwif = hwif; in hinic_io_init()
538 func_to_io->qps = NULL; in hinic_io_init()
539 func_to_io->max_qps = max_qps; in hinic_io_init()
540 func_to_io->ceqs.hwdev = func_to_io->hwdev; in hinic_io_init()
542 err = hinic_ceqs_init(&func_to_io->ceqs, hwif, num_ceqs, in hinic_io_init()
550 err = hinic_wqs_alloc(&func_to_io->wqs, 2 * max_qps, hwif); in hinic_io_init()
556 func_to_io->db_base = pci_ioremap_bar(pdev, HINIC_PCI_DB_BAR); in hinic_io_init()
557 if (!func_to_io->db_base) { in hinic_io_init()
563 init_db_area_idx(&func_to_io->free_db_area); in hinic_io_init()
566 db_area = get_db_area(func_to_io); in hinic_io_init()
573 func_to_io->cmdq_db_area[cmdq] = db_area; in hinic_io_init()
576 err = hinic_set_wq_page_size(func_to_io->hwdev, in hinic_io_init()
580 dev_err(&func_to_io->hwif->pdev->dev, "Failed to set wq page size\n"); in hinic_io_init()
584 err = hinic_init_cmdqs(&func_to_io->cmdqs, hwif, in hinic_io_init()
585 func_to_io->cmdq_db_area); in hinic_io_init()
594 if (!HINIC_IS_VF(func_to_io->hwif)) in hinic_io_init()
595 hinic_set_wq_page_size(func_to_io->hwdev, in hinic_io_init()
601 return_db_area(func_to_io, func_to_io->cmdq_db_area[type]); in hinic_io_init()
603 iounmap(func_to_io->db_base); in hinic_io_init()
606 hinic_wqs_free(&func_to_io->wqs); in hinic_io_init()
609 hinic_ceqs_free(&func_to_io->ceqs); in hinic_io_init()
617 void hinic_io_free(struct hinic_func_to_io *func_to_io) in hinic_io_free() argument
621 hinic_free_cmdqs(&func_to_io->cmdqs); in hinic_io_free()
623 if (!HINIC_IS_VF(func_to_io->hwif)) in hinic_io_free()
624 hinic_set_wq_page_size(func_to_io->hwdev, in hinic_io_free()
625 HINIC_HWIF_FUNC_IDX(func_to_io->hwif), in hinic_io_free()
629 return_db_area(func_to_io, func_to_io->cmdq_db_area[cmdq]); in hinic_io_free()
631 iounmap(func_to_io->db_base); in hinic_io_free()
632 hinic_wqs_free(&func_to_io->wqs); in hinic_io_free()
633 hinic_ceqs_free(&func_to_io->ceqs); in hinic_io_free()