Lines Matching refs:ionic

22 int ionic_bus_get_irq(struct ionic *ionic, unsigned int num)  in ionic_bus_get_irq()  argument
24 return pci_irq_vector(ionic->pdev, num); in ionic_bus_get_irq()
27 const char *ionic_bus_info(struct ionic *ionic) in ionic_bus_info() argument
29 return pci_name(ionic->pdev); in ionic_bus_info()
32 int ionic_bus_alloc_irq_vectors(struct ionic *ionic, unsigned int nintrs) in ionic_bus_alloc_irq_vectors() argument
34 return pci_alloc_irq_vectors(ionic->pdev, nintrs, nintrs, in ionic_bus_alloc_irq_vectors()
38 void ionic_bus_free_irq_vectors(struct ionic *ionic) in ionic_bus_free_irq_vectors() argument
40 if (!ionic->nintrs) in ionic_bus_free_irq_vectors()
43 pci_free_irq_vectors(ionic->pdev); in ionic_bus_free_irq_vectors()
46 static int ionic_map_bars(struct ionic *ionic) in ionic_map_bars() argument
48 struct pci_dev *pdev = ionic->pdev; in ionic_map_bars()
49 struct device *dev = ionic->dev; in ionic_map_bars()
53 bars = ionic->bars; in ionic_map_bars()
54 ionic->num_bars = 0; in ionic_map_bars()
76 ionic->num_bars++; in ionic_map_bars()
83 static void ionic_unmap_bars(struct ionic *ionic) in ionic_unmap_bars() argument
85 struct ionic_dev_bar *bars = ionic->bars; in ionic_unmap_bars()
98 void __iomem *ionic_bus_map_dbpage(struct ionic *ionic, int page_num) in ionic_bus_map_dbpage() argument
100 return pci_iomap_range(ionic->pdev, in ionic_bus_map_dbpage()
101 ionic->bars[IONIC_PCI_BAR_DBELL].res_index, in ionic_bus_map_dbpage()
105 void ionic_bus_unmap_dbpage(struct ionic *ionic, void __iomem *page) in ionic_bus_unmap_dbpage() argument
110 static void ionic_vf_dealloc_locked(struct ionic *ionic) in ionic_vf_dealloc_locked() argument
116 if (!ionic->vfs) in ionic_vf_dealloc_locked()
119 for (i = ionic->num_vfs - 1; i >= 0; i--) { in ionic_vf_dealloc_locked()
120 v = &ionic->vfs[i]; in ionic_vf_dealloc_locked()
124 (void)ionic_set_vf_config(ionic, i, &vfc); in ionic_vf_dealloc_locked()
125 dma_unmap_single(ionic->dev, v->stats_pa, in ionic_vf_dealloc_locked()
131 kfree(ionic->vfs); in ionic_vf_dealloc_locked()
132 ionic->vfs = NULL; in ionic_vf_dealloc_locked()
133 ionic->num_vfs = 0; in ionic_vf_dealloc_locked()
136 static void ionic_vf_dealloc(struct ionic *ionic) in ionic_vf_dealloc() argument
138 down_write(&ionic->vf_op_lock); in ionic_vf_dealloc()
139 ionic_vf_dealloc_locked(ionic); in ionic_vf_dealloc()
140 up_write(&ionic->vf_op_lock); in ionic_vf_dealloc()
143 static int ionic_vf_alloc(struct ionic *ionic, int num_vfs) in ionic_vf_alloc() argument
150 down_write(&ionic->vf_op_lock); in ionic_vf_alloc()
152 ionic->vfs = kcalloc(num_vfs, sizeof(struct ionic_vf), GFP_KERNEL); in ionic_vf_alloc()
153 if (!ionic->vfs) { in ionic_vf_alloc()
159 v = &ionic->vfs[i]; in ionic_vf_alloc()
160 v->stats_pa = dma_map_single(ionic->dev, &v->stats, in ionic_vf_alloc()
162 if (dma_mapping_error(ionic->dev, v->stats_pa)) { in ionic_vf_alloc()
168 ionic->num_vfs++; in ionic_vf_alloc()
172 (void)ionic_set_vf_config(ionic, i, &vfc); in ionic_vf_alloc()
177 ionic_vf_dealloc_locked(ionic); in ionic_vf_alloc()
178 up_write(&ionic->vf_op_lock); in ionic_vf_alloc()
184 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_sriov_configure() local
185 struct device *dev = ionic->dev; in ionic_sriov_configure()
188 if (ionic->lif && in ionic_sriov_configure()
189 test_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state)) in ionic_sriov_configure()
199 ret = ionic_vf_alloc(ionic, num_vfs); in ionic_sriov_configure()
209 ionic_vf_dealloc(ionic); in ionic_sriov_configure()
219 struct ionic *ionic; in ionic_probe() local
223 ionic = ionic_devlink_alloc(dev); in ionic_probe()
224 if (!ionic) in ionic_probe()
227 ionic->pdev = pdev; in ionic_probe()
228 ionic->dev = dev; in ionic_probe()
229 pci_set_drvdata(pdev, ionic); in ionic_probe()
230 mutex_init(&ionic->dev_cmd_lock); in ionic_probe()
240 ionic_debugfs_add_dev(ionic); in ionic_probe()
257 err = ionic_map_bars(ionic); in ionic_probe()
262 err = ionic_setup(ionic); in ionic_probe()
269 err = ionic_identify(ionic); in ionic_probe()
274 ionic_debugfs_add_ident(ionic); in ionic_probe()
276 err = ionic_init(ionic); in ionic_probe()
283 err = ionic_port_identify(ionic); in ionic_probe()
289 err = ionic_port_init(ionic); in ionic_probe()
296 err = ionic_lif_size(ionic); in ionic_probe()
302 err = ionic_lif_alloc(ionic); in ionic_probe()
308 err = ionic_lif_init(ionic->lif); in ionic_probe()
314 init_rwsem(&ionic->vf_op_lock); in ionic_probe()
318 err = ionic_vf_alloc(ionic, num_vfs); in ionic_probe()
323 err = ionic_lif_register(ionic->lif); in ionic_probe()
329 err = ionic_devlink_register(ionic); in ionic_probe()
335 mod_timer(&ionic->watchdog_timer, in ionic_probe()
336 round_jiffies(jiffies + ionic->watchdog_period)); in ionic_probe()
341 ionic_lif_unregister(ionic->lif); in ionic_probe()
343 ionic_vf_dealloc(ionic); in ionic_probe()
344 ionic_lif_deinit(ionic->lif); in ionic_probe()
346 ionic_lif_free(ionic->lif); in ionic_probe()
347 ionic->lif = NULL; in ionic_probe()
349 ionic_bus_free_irq_vectors(ionic); in ionic_probe()
351 ionic_port_reset(ionic); in ionic_probe()
353 ionic_reset(ionic); in ionic_probe()
362 ionic_unmap_bars(ionic); in ionic_probe()
368 ionic_debugfs_del_dev(ionic); in ionic_probe()
370 mutex_destroy(&ionic->dev_cmd_lock); in ionic_probe()
371 ionic_devlink_free(ionic); in ionic_probe()
378 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_remove() local
380 del_timer_sync(&ionic->watchdog_timer); in ionic_remove()
382 if (ionic->lif) { in ionic_remove()
383 ionic_devlink_unregister(ionic); in ionic_remove()
384 ionic_lif_unregister(ionic->lif); in ionic_remove()
385 ionic_lif_deinit(ionic->lif); in ionic_remove()
386 ionic_lif_free(ionic->lif); in ionic_remove()
387 ionic->lif = NULL; in ionic_remove()
388 ionic_bus_free_irq_vectors(ionic); in ionic_remove()
391 ionic_port_reset(ionic); in ionic_remove()
392 ionic_reset(ionic); in ionic_remove()
394 ionic_unmap_bars(ionic); in ionic_remove()
397 ionic_debugfs_del_dev(ionic); in ionic_remove()
398 mutex_destroy(&ionic->dev_cmd_lock); in ionic_remove()
399 ionic_devlink_free(ionic); in ionic_remove()