Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(C) 2021 Marvell. 3 : : */ 4 : : #include <bus_pci_driver.h> 5 : : #include <rte_pci.h> 6 : : #include <rte_rawdev.h> 7 : : #include <rte_rawdev_pmd.h> 8 : : 9 : : #include <roc_api.h> 10 : : 11 : : #include "cnxk_bphy_irq.h" 12 : : 13 : : static struct bphy_device * 14 : : cnxk_bphy_get_bphy_dev_by_dev_id(uint16_t dev_id) 15 : : { 16 : : struct rte_rawdev *rawdev; 17 : : 18 : 0 : if (!rte_rawdev_pmd_is_valid_dev(dev_id)) 19 : : return NULL; 20 : : 21 : 0 : rawdev = &rte_rawdevs[dev_id]; 22 : : 23 : 0 : return (struct bphy_device *)rawdev->dev_private; 24 : : } 25 : : 26 : : uint64_t 27 [ # # ]: 0 : cnxk_bphy_irq_max_get(uint16_t dev_id) 28 : : { 29 : : struct roc_bphy_irq_chip *irq_chip; 30 : : struct bphy_device *bphy_dev; 31 : : 32 : : bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); 33 : 0 : irq_chip = bphy_dev->irq_chip; 34 : : 35 : 0 : return roc_bphy_intr_max_get(irq_chip); 36 : : } 37 : : 38 : : int 39 [ # # ]: 0 : cnxk_bphy_intr_init(uint16_t dev_id) 40 : : { 41 : : struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); 42 : : 43 : 0 : bphy_dev->irq_chip = roc_bphy_intr_init(); 44 [ # # ]: 0 : if (bphy_dev->irq_chip == NULL) 45 : 0 : return -ENOMEM; 46 : : 47 : : return 0; 48 : : } 49 : : 50 : : void 51 [ # # ]: 0 : cnxk_bphy_intr_fini(uint16_t dev_id) 52 : : { 53 : : struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); 54 : 0 : struct roc_bphy_irq_chip *irq_chip = bphy_dev->irq_chip; 55 : : 56 : 0 : roc_bphy_intr_fini(irq_chip); 57 : 0 : bphy_dev->irq_chip = NULL; 58 : 0 : } 59 : : 60 : : int 61 : 0 : cnxk_bphy_intr_register(uint16_t dev_id, int irq_num, 62 : : cnxk_bphy_intr_handler_t handler, void *data, int cpu) 63 : : { 64 [ # # ]: 0 : struct roc_bphy_intr intr = { 65 : : .irq_num = irq_num, 66 : : .intr_handler = handler, 67 : : .isr_data = data, 68 : : .cpu = cpu 69 : : }; 70 : : 71 : : struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); 72 : 0 : struct roc_bphy_irq_chip *irq_chip = bphy_dev->irq_chip; 73 : : 74 [ # # ]: 0 : if (!irq_chip) 75 : : return -ENODEV; 76 [ # # ]: 0 : if (!handler || !data) 77 : : return -EINVAL; 78 : : 79 : 0 : return roc_bphy_intr_register(irq_chip, &intr); 80 : : } 81 : : 82 : : void 83 [ # # ]: 0 : cnxk_bphy_intr_unregister(uint16_t dev_id, int irq_num) 84 : : { 85 : : struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); 86 : : 87 [ # # ]: 0 : if (bphy_dev->irq_chip) 88 : 0 : roc_bphy_intr_clear(bphy_dev->irq_chip, irq_num); 89 : : else 90 : 0 : plt_err("Missing irq chip"); 91 : 0 : } 92 : : 93 : : struct cnxk_bphy_mem * 94 [ # # ]: 0 : cnxk_bphy_mem_get(uint16_t dev_id) 95 : : { 96 : : struct bphy_device *bphy_dev = cnxk_bphy_get_bphy_dev_by_dev_id(dev_id); 97 : : 98 : 0 : return &bphy_dev->mem; 99 : : }