Lines Matching refs:gc

26 	struct gdma_context *gc = pci_get_drvdata(pdev);  in mana_gd_init_pf_regs()  local
30 gc->db_page_size = mana_gd_r32(gc, GDMA_PF_REG_DB_PAGE_SIZE) & 0xFFFF; in mana_gd_init_pf_regs()
31 gc->db_page_base = gc->bar0_va + in mana_gd_init_pf_regs()
32 mana_gd_r64(gc, GDMA_PF_REG_DB_PAGE_OFF); in mana_gd_init_pf_regs()
34 sriov_base_off = mana_gd_r64(gc, GDMA_SRIOV_REG_CFG_BASE_OFF); in mana_gd_init_pf_regs()
36 sriov_base_va = gc->bar0_va + sriov_base_off; in mana_gd_init_pf_regs()
37 gc->shm_base = sriov_base_va + in mana_gd_init_pf_regs()
38 mana_gd_r64(gc, sriov_base_off + GDMA_PF_REG_SHM_OFF); in mana_gd_init_pf_regs()
43 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_init_vf_regs() local
45 gc->db_page_size = mana_gd_r32(gc, GDMA_REG_DB_PAGE_SIZE) & 0xFFFF; in mana_gd_init_vf_regs()
47 gc->db_page_base = gc->bar0_va + in mana_gd_init_vf_regs()
48 mana_gd_r64(gc, GDMA_REG_DB_PAGE_OFFSET); in mana_gd_init_vf_regs()
50 gc->phys_db_page_base = gc->bar0_pa + in mana_gd_init_vf_regs()
51 mana_gd_r64(gc, GDMA_REG_DB_PAGE_OFFSET); in mana_gd_init_vf_regs()
53 gc->shm_base = gc->bar0_va + mana_gd_r64(gc, GDMA_REG_SHM_OFFSET); in mana_gd_init_vf_regs()
58 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_init_registers() local
60 if (gc->is_pf) in mana_gd_init_registers()
68 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_query_max_resources() local
76 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_query_max_resources()
78 dev_err(gc->dev, "Failed to query resource info: %d, 0x%x\n", in mana_gd_query_max_resources()
83 if (gc->num_msix_usable > resp.max_msix) in mana_gd_query_max_resources()
84 gc->num_msix_usable = resp.max_msix; in mana_gd_query_max_resources()
86 if (gc->num_msix_usable <= 1) in mana_gd_query_max_resources()
89 gc->max_num_queues = num_online_cpus(); in mana_gd_query_max_resources()
90 if (gc->max_num_queues > MANA_MAX_NUM_QUEUES) in mana_gd_query_max_resources()
91 gc->max_num_queues = MANA_MAX_NUM_QUEUES; in mana_gd_query_max_resources()
93 if (gc->max_num_queues > resp.max_eq) in mana_gd_query_max_resources()
94 gc->max_num_queues = resp.max_eq; in mana_gd_query_max_resources()
96 if (gc->max_num_queues > resp.max_cq) in mana_gd_query_max_resources()
97 gc->max_num_queues = resp.max_cq; in mana_gd_query_max_resources()
99 if (gc->max_num_queues > resp.max_sq) in mana_gd_query_max_resources()
100 gc->max_num_queues = resp.max_sq; in mana_gd_query_max_resources()
102 if (gc->max_num_queues > resp.max_rq) in mana_gd_query_max_resources()
103 gc->max_num_queues = resp.max_rq; in mana_gd_query_max_resources()
106 if (gc->max_num_queues > gc->num_msix_usable - 1) in mana_gd_query_max_resources()
107 gc->max_num_queues = gc->num_msix_usable - 1; in mana_gd_query_max_resources()
114 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_query_hwc_timeout() local
122 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_query_hwc_timeout()
133 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_detect_devices() local
144 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_detect_devices()
146 dev_err(gc->dev, "Failed to detect devices: %d, 0x%x\n", err, in mana_gd_detect_devices()
162 gc->mana.gdma_context = gc; in mana_gd_detect_devices()
163 gc->mana.dev_id = dev; in mana_gd_detect_devices()
165 gc->mana_ib.dev_id = dev; in mana_gd_detect_devices()
166 gc->mana_ib.gdma_context = gc; in mana_gd_detect_devices()
170 return gc->mana.dev_id.type == 0 ? -ENODEV : 0; in mana_gd_detect_devices()
173 int mana_gd_send_request(struct gdma_context *gc, u32 req_len, const void *req, in mana_gd_send_request() argument
176 struct hw_channel_context *hwc = gc->hwc.driver_data; in mana_gd_send_request()
182 int mana_gd_alloc_memory(struct gdma_context *gc, unsigned int length, in mana_gd_alloc_memory() argument
191 gmi->dev = gc->dev; in mana_gd_alloc_memory()
209 static int mana_gd_create_hw_eq(struct gdma_context *gc, in mana_gd_create_hw_eq() argument
231 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_create_hw_eq()
233 dev_err(gc->dev, "Failed to create queue: %d, 0x%x\n", err, in mana_gd_create_hw_eq()
246 struct gdma_context *gc = queue->gdma_dev->gdma_context; in mana_gd_disable_queue() local
261 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_disable_queue()
263 dev_err(gc->dev, "Failed to disable queue: %d, 0x%x\n", err, in mana_gd_disable_queue()
276 static void mana_gd_ring_doorbell(struct gdma_context *gc, u32 db_index, in mana_gd_ring_doorbell() argument
280 void __iomem *addr = gc->db_page_base + gc->db_page_size * db_index; in mana_gd_ring_doorbell()
326 void mana_gd_wq_ring_doorbell(struct gdma_context *gc, struct gdma_queue *queue) in mana_gd_wq_ring_doorbell() argument
331 mana_gd_ring_doorbell(gc, queue->gdma_dev->doorbell, queue->type, in mana_gd_wq_ring_doorbell()
337 struct gdma_context *gc = cq->gdma_dev->gdma_context; in mana_gd_ring_cq() local
343 mana_gd_ring_doorbell(gc, cq->gdma_dev->doorbell, cq->type, cq->id, in mana_gd_ring_cq()
350 struct gdma_context *gc = eq->gdma_dev->gdma_context; in mana_gd_process_eqe() local
366 if (WARN_ON_ONCE(cq_id >= gc->max_num_cqs)) in mana_gd_process_eqe()
369 cq = gc->cq_table[cq_id]; in mana_gd_process_eqe()
379 gc->test_event_eq_id = eq->id; in mana_gd_process_eqe()
380 complete(&gc->eq_test_event); in mana_gd_process_eqe()
406 struct gdma_context *gc; in mana_gd_process_eq_events() local
411 gc = eq->gdma_dev->gdma_context; in mana_gd_process_eq_events()
433 dev_err(gc->dev, "EQ %d: overflow detected\n", eq->id); in mana_gd_process_eq_events()
449 mana_gd_ring_doorbell(gc, eq->gdma_dev->doorbell, eq->type, eq->id, in mana_gd_process_eq_events()
458 struct gdma_context *gc; in mana_gd_register_irq() local
464 gc = gd->gdma_context; in mana_gd_register_irq()
465 dev = gc->dev; in mana_gd_register_irq()
468 if (msi_index >= gc->num_msix_usable) { in mana_gd_register_irq()
471 err, msi_index, gc->num_msix_usable); in mana_gd_register_irq()
477 gic = &gc->irq_contexts[msi_index]; in mana_gd_register_irq()
490 struct gdma_context *gc; in mana_gd_deregiser_irq() local
495 gc = gd->gdma_context; in mana_gd_deregiser_irq()
499 if (WARN_ON(msix_index >= gc->num_msix_usable)) in mana_gd_deregiser_irq()
502 gic = &gc->irq_contexts[msix_index]; in mana_gd_deregiser_irq()
516 int mana_gd_test_eq(struct gdma_context *gc, struct gdma_queue *eq) in mana_gd_test_eq() argument
520 struct device *dev = gc->dev; in mana_gd_test_eq()
523 mutex_lock(&gc->eq_test_event_mutex); in mana_gd_test_eq()
525 init_completion(&gc->eq_test_event); in mana_gd_test_eq()
526 gc->test_event_eq_id = INVALID_QUEUE_ID; in mana_gd_test_eq()
534 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_test_eq()
547 if (!wait_for_completion_timeout(&gc->eq_test_event, 30 * HZ)) { in mana_gd_test_eq()
552 if (eq->id != gc->test_event_eq_id) { in mana_gd_test_eq()
554 gc->test_event_eq_id, eq->id); in mana_gd_test_eq()
560 mutex_unlock(&gc->eq_test_event_mutex); in mana_gd_test_eq()
564 static void mana_gd_destroy_eq(struct gdma_context *gc, bool flush_evenets, in mana_gd_destroy_eq() argument
570 err = mana_gd_test_eq(gc, queue); in mana_gd_destroy_eq()
572 dev_warn(gc->dev, "Failed to flush EQ: %d\n", err); in mana_gd_destroy_eq()
585 struct gdma_context *gc = gd->gdma_context; in mana_gd_create_eq() local
586 struct device *dev = gc->dev; in mana_gd_create_eq()
613 err = mana_gd_create_hw_eq(gc, queue); in mana_gd_create_eq()
617 err = mana_gd_test_eq(gc, queue); in mana_gd_create_eq()
625 mana_gd_destroy_eq(gc, false, queue); in mana_gd_create_eq()
640 static void mana_gd_destroy_cq(struct gdma_context *gc, in mana_gd_destroy_cq() argument
645 if (id >= gc->max_num_cqs) in mana_gd_destroy_cq()
648 if (!gc->cq_table[id]) in mana_gd_destroy_cq()
651 gc->cq_table[id] = NULL; in mana_gd_destroy_cq()
658 struct gdma_context *gc = gd->gdma_context; in mana_gd_create_hwc_queue() local
668 err = mana_gd_alloc_memory(gc, spec->queue_size, gmi); in mana_gd_create_hwc_queue()
697 int mana_gd_destroy_dma_region(struct gdma_context *gc, u64 dma_region_handle) in mana_gd_destroy_dma_region() argument
710 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_destroy_dma_region()
712 dev_err(gc->dev, "Failed to destroy DMA region: %d, 0x%x\n", in mana_gd_destroy_dma_region()
727 struct gdma_context *gc = gd->gdma_context; in mana_gd_create_dma_region() local
740 hwc = gc->hwc.driver_data; in mana_gd_create_dma_region()
760 err = mana_gd_send_request(gc, req_msg_size, req, sizeof(resp), &resp); in mana_gd_create_dma_region()
766 dev_err(gc->dev, "Failed to create DMA region: 0x%x\n", in mana_gd_create_dma_region()
782 struct gdma_context *gc = gd->gdma_context; in mana_gd_create_mana_eq() local
795 err = mana_gd_alloc_memory(gc, spec->queue_size, gmi); in mana_gd_create_mana_eq()
829 struct gdma_context *gc = gd->gdma_context; in mana_gd_create_mana_wq_cq() local
843 err = mana_gd_alloc_memory(gc, spec->queue_size, gmi); in mana_gd_create_mana_wq_cq()
871 void mana_gd_destroy_queue(struct gdma_context *gc, struct gdma_queue *queue) in mana_gd_destroy_queue() argument
877 mana_gd_destroy_eq(gc, queue->eq.disable_needed, queue); in mana_gd_destroy_queue()
881 mana_gd_destroy_cq(gc, queue); in mana_gd_destroy_queue()
891 dev_err(gc->dev, "Can't destroy unknown queue: type=%d\n", in mana_gd_destroy_queue()
896 mana_gd_destroy_dma_region(gc, gmi->dma_region_handle); in mana_gd_destroy_queue()
904 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_verify_vf_version() local
910 hwc = gc->hwc.driver_data; in mana_gd_verify_vf_version()
931 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_verify_vf_version()
933 dev_err(gc->dev, "VfVerifyVersionOutput: %d, status=0x%x\n", in mana_gd_verify_vf_version()
940 dev_err(gc->dev, "Failed to set the hwc timeout %d\n", err); in mana_gd_verify_vf_version()
943 dev_dbg(gc->dev, "set the hwc timeout to %u\n", hwc->hwc_timeout); in mana_gd_verify_vf_version()
950 struct gdma_context *gc = gd->gdma_context; in mana_gd_register_device() local
964 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_register_device()
966 dev_err(gc->dev, "gdma_register_device_resp failed: %d, 0x%x\n", in mana_gd_register_device()
981 struct gdma_context *gc = gd->gdma_context; in mana_gd_deregister_device() local
994 err = mana_gd_send_request(gc, sizeof(req), &req, sizeof(resp), &resp); in mana_gd_deregister_device()
996 dev_err(gc->dev, "Failed to deregister device: %d, 0x%x\n", in mana_gd_deregister_device()
1100 struct gdma_context *gc; in mana_gd_post_work_request() local
1131 gc = wq->gdma_dev->gdma_context; in mana_gd_post_work_request()
1132 dev_err(gc->dev, "unsuccessful flow control!\n"); in mana_gd_post_work_request()
1156 struct gdma_context *gc = queue->gdma_dev->gdma_context; in mana_gd_post_and_ring() local
1163 mana_gd_wq_ring_doorbell(gc, queue); in mana_gd_post_and_ring()
1287 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_setup_irqs() local
1317 gc->irq_contexts = kcalloc(nvec, sizeof(struct gdma_irq_context), in mana_gd_setup_irqs()
1319 if (!gc->irq_contexts) { in mana_gd_setup_irqs()
1325 gic = &gc->irq_contexts[i]; in mana_gd_setup_irqs()
1357 cpu = cpumask_local_spread(i, gc->numa_node); in mana_gd_setup_irqs()
1371 err = irq_setup(irqs, (nvec - start_irq_index), gc->numa_node); in mana_gd_setup_irqs()
1375 gc->max_num_msix = nvec; in mana_gd_setup_irqs()
1376 gc->num_msix_usable = nvec; in mana_gd_setup_irqs()
1384 gic = &gc->irq_contexts[j]; in mana_gd_setup_irqs()
1390 kfree(gc->irq_contexts); in mana_gd_setup_irqs()
1391 gc->irq_contexts = NULL; in mana_gd_setup_irqs()
1402 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_remove_irqs() local
1406 if (gc->max_num_msix < 1) in mana_gd_remove_irqs()
1409 for (i = 0; i < gc->max_num_msix; i++) { in mana_gd_remove_irqs()
1414 gic = &gc->irq_contexts[i]; in mana_gd_remove_irqs()
1423 gc->max_num_msix = 0; in mana_gd_remove_irqs()
1424 gc->num_msix_usable = 0; in mana_gd_remove_irqs()
1425 kfree(gc->irq_contexts); in mana_gd_remove_irqs()
1426 gc->irq_contexts = NULL; in mana_gd_remove_irqs()
1431 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_setup() local
1435 mana_smc_init(&gc->shm_channel, gc->dev, gc->shm_base); in mana_gd_setup()
1441 err = mana_hwc_create_channel(gc); in mana_gd_setup()
1460 mana_hwc_destroy_channel(gc); in mana_gd_setup()
1468 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_cleanup() local
1470 mana_hwc_destroy_channel(gc); in mana_gd_cleanup()
1482 struct gdma_context *gc; in mana_gd_probe() local
1507 gc = vzalloc(sizeof(*gc)); in mana_gd_probe()
1508 if (!gc) in mana_gd_probe()
1511 mutex_init(&gc->eq_test_event_mutex); in mana_gd_probe()
1512 pci_set_drvdata(pdev, gc); in mana_gd_probe()
1513 gc->bar0_pa = pci_resource_start(pdev, 0); in mana_gd_probe()
1519 gc->numa_node = dev_to_node(&pdev->dev); in mana_gd_probe()
1520 gc->is_pf = mana_is_pf(pdev->device); in mana_gd_probe()
1521 gc->bar0_va = bar0_va; in mana_gd_probe()
1522 gc->dev = &pdev->dev; in mana_gd_probe()
1524 if (gc->is_pf) in mana_gd_probe()
1525 gc->mana_pci_debugfs = debugfs_create_dir("0", mana_debugfs_root); in mana_gd_probe()
1527 gc->mana_pci_debugfs = debugfs_create_dir(pci_slot_name(pdev->slot), in mana_gd_probe()
1534 err = mana_probe(&gc->mana, false); in mana_gd_probe()
1549 debugfs_remove_recursive(gc->mana_pci_debugfs); in mana_gd_probe()
1553 vfree(gc); in mana_gd_probe()
1564 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_remove() local
1566 mana_remove(&gc->mana, false); in mana_gd_remove()
1570 debugfs_remove_recursive(gc->mana_pci_debugfs); in mana_gd_remove()
1572 pci_iounmap(pdev, gc->bar0_va); in mana_gd_remove()
1574 vfree(gc); in mana_gd_remove()
1583 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_suspend() local
1585 mana_remove(&gc->mana, true); in mana_gd_suspend()
1598 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_resume() local
1605 err = mana_probe(&gc->mana, true); in mana_gd_resume()
1615 struct gdma_context *gc = pci_get_drvdata(pdev); in mana_gd_shutdown() local
1619 mana_remove(&gc->mana, true); in mana_gd_shutdown()
1623 debugfs_remove_recursive(gc->mana_pci_debugfs); in mana_gd_shutdown()