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()
96 ionic->num_bars = 0; in ionic_unmap_bars()
99 void __iomem *ionic_bus_map_dbpage(struct ionic *ionic, int page_num) in ionic_bus_map_dbpage() argument
101 return pci_iomap_range(ionic->pdev, in ionic_bus_map_dbpage()
102 ionic->bars[IONIC_PCI_BAR_DBELL].res_index, in ionic_bus_map_dbpage()
106 void ionic_bus_unmap_dbpage(struct ionic *ionic, void __iomem *page) in ionic_bus_unmap_dbpage() argument
111 static void ionic_vf_dealloc_locked(struct ionic *ionic) in ionic_vf_dealloc_locked() argument
117 if (!ionic->vfs) in ionic_vf_dealloc_locked()
120 for (i = ionic->num_vfs - 1; i >= 0; i--) { in ionic_vf_dealloc_locked()
121 v = &ionic->vfs[i]; in ionic_vf_dealloc_locked()
125 ionic_set_vf_config(ionic, i, &vfc); in ionic_vf_dealloc_locked()
126 dma_unmap_single(ionic->dev, v->stats_pa, in ionic_vf_dealloc_locked()
132 kfree(ionic->vfs); in ionic_vf_dealloc_locked()
133 ionic->vfs = NULL; in ionic_vf_dealloc_locked()
134 ionic->num_vfs = 0; in ionic_vf_dealloc_locked()
137 static void ionic_vf_dealloc(struct ionic *ionic) in ionic_vf_dealloc() argument
139 down_write(&ionic->vf_op_lock); in ionic_vf_dealloc()
140 ionic_vf_dealloc_locked(ionic); in ionic_vf_dealloc()
141 up_write(&ionic->vf_op_lock); in ionic_vf_dealloc()
144 static int ionic_vf_alloc(struct ionic *ionic, int num_vfs) in ionic_vf_alloc() argument
151 down_write(&ionic->vf_op_lock); in ionic_vf_alloc()
153 ionic->vfs = kcalloc(num_vfs, sizeof(struct ionic_vf), GFP_KERNEL); in ionic_vf_alloc()
154 if (!ionic->vfs) { in ionic_vf_alloc()
160 v = &ionic->vfs[i]; in ionic_vf_alloc()
161 v->stats_pa = dma_map_single(ionic->dev, &v->stats, in ionic_vf_alloc()
163 if (dma_mapping_error(ionic->dev, v->stats_pa)) { in ionic_vf_alloc()
169 ionic->num_vfs++; in ionic_vf_alloc()
173 ionic_set_vf_config(ionic, i, &vfc); in ionic_vf_alloc()
178 ionic_vf_dealloc_locked(ionic); in ionic_vf_alloc()
179 up_write(&ionic->vf_op_lock); in ionic_vf_alloc()
185 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_sriov_configure() local
186 struct device *dev = ionic->dev; in ionic_sriov_configure()
189 if (ionic->lif && in ionic_sriov_configure()
190 test_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state)) in ionic_sriov_configure()
200 ret = ionic_vf_alloc(ionic, num_vfs); in ionic_sriov_configure()
210 ionic_vf_dealloc(ionic); in ionic_sriov_configure()
217 static void ionic_clear_pci(struct ionic *ionic) in ionic_clear_pci() argument
219 if (ionic->num_bars) { in ionic_clear_pci()
220 ionic->idev.dev_info_regs = NULL; in ionic_clear_pci()
221 ionic->idev.dev_cmd_regs = NULL; in ionic_clear_pci()
222 ionic->idev.intr_status = NULL; in ionic_clear_pci()
223 ionic->idev.intr_ctrl = NULL; in ionic_clear_pci()
225 ionic_unmap_bars(ionic); in ionic_clear_pci()
226 pci_release_regions(ionic->pdev); in ionic_clear_pci()
229 if (pci_is_enabled(ionic->pdev)) in ionic_clear_pci()
230 pci_disable_device(ionic->pdev); in ionic_clear_pci()
233 static int ionic_setup_one(struct ionic *ionic) in ionic_setup_one() argument
235 struct pci_dev *pdev = ionic->pdev; in ionic_setup_one()
236 struct device *dev = ionic->dev; in ionic_setup_one()
239 ionic_debugfs_add_dev(ionic); in ionic_setup_one()
255 err = ionic_map_bars(ionic); in ionic_setup_one()
260 err = ionic_setup(ionic); in ionic_setup_one()
267 err = ionic_identify(ionic); in ionic_setup_one()
272 ionic_debugfs_add_ident(ionic); in ionic_setup_one()
274 err = ionic_init(ionic); in ionic_setup_one()
281 err = ionic_port_identify(ionic); in ionic_setup_one()
287 err = ionic_port_init(ionic); in ionic_setup_one()
296 ionic_dev_teardown(ionic); in ionic_setup_one()
298 ionic_clear_pci(ionic); in ionic_setup_one()
300 ionic_debugfs_del_dev(ionic); in ionic_setup_one()
308 struct ionic *ionic; in ionic_probe() local
312 ionic = ionic_devlink_alloc(dev); in ionic_probe()
313 if (!ionic) in ionic_probe()
316 ionic->pdev = pdev; in ionic_probe()
317 ionic->dev = dev; in ionic_probe()
318 pci_set_drvdata(pdev, ionic); in ionic_probe()
319 mutex_init(&ionic->dev_cmd_lock); in ionic_probe()
334 err = ionic_setup_one(ionic); in ionic_probe()
339 err = ionic_lif_size(ionic); in ionic_probe()
345 err = ionic_lif_alloc(ionic); in ionic_probe()
351 err = ionic_lif_init(ionic->lif); in ionic_probe()
357 init_rwsem(&ionic->vf_op_lock); in ionic_probe()
361 err = ionic_vf_alloc(ionic, num_vfs); in ionic_probe()
366 err = ionic_devlink_register(ionic); in ionic_probe()
372 err = ionic_lif_register(ionic->lif); in ionic_probe()
378 mod_timer(&ionic->watchdog_timer, in ionic_probe()
379 round_jiffies(jiffies + ionic->watchdog_period)); in ionic_probe()
380 ionic_queue_doorbell_check(ionic, IONIC_NAPI_DEADLINE); in ionic_probe()
385 ionic_devlink_unregister(ionic); in ionic_probe()
387 ionic_vf_dealloc(ionic); in ionic_probe()
388 ionic_lif_deinit(ionic->lif); in ionic_probe()
390 ionic_lif_free(ionic->lif); in ionic_probe()
391 ionic->lif = NULL; in ionic_probe()
393 ionic_bus_free_irq_vectors(ionic); in ionic_probe()
395 ionic_dev_teardown(ionic); in ionic_probe()
396 ionic_clear_pci(ionic); in ionic_probe()
397 ionic_debugfs_del_dev(ionic); in ionic_probe()
399 mutex_destroy(&ionic->dev_cmd_lock); in ionic_probe()
400 ionic_devlink_free(ionic); in ionic_probe()
407 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_remove() local
409 timer_shutdown_sync(&ionic->watchdog_timer); in ionic_remove()
411 if (ionic->lif) { in ionic_remove()
413 if (test_and_clear_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state)) in ionic_remove()
414 set_bit(IONIC_LIF_F_FW_STOPPING, ionic->lif->state); in ionic_remove()
416 if (ionic->lif->doorbell_wa) in ionic_remove()
417 cancel_delayed_work_sync(&ionic->doorbell_check_dwork); in ionic_remove()
418 ionic_lif_unregister(ionic->lif); in ionic_remove()
419 ionic_devlink_unregister(ionic); in ionic_remove()
420 ionic_lif_deinit(ionic->lif); in ionic_remove()
421 ionic_lif_free(ionic->lif); in ionic_remove()
422 ionic->lif = NULL; in ionic_remove()
423 ionic_bus_free_irq_vectors(ionic); in ionic_remove()
426 ionic_port_reset(ionic); in ionic_remove()
427 ionic_reset(ionic); in ionic_remove()
428 ionic_dev_teardown(ionic); in ionic_remove()
429 ionic_clear_pci(ionic); in ionic_remove()
430 ionic_debugfs_del_dev(ionic); in ionic_remove()
431 mutex_destroy(&ionic->dev_cmd_lock); in ionic_remove()
432 ionic_devlink_free(ionic); in ionic_remove()
437 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_reset_prepare() local
438 struct ionic_lif *lif = ionic->lif; in ionic_reset_prepare()
440 dev_dbg(ionic->dev, "%s: device stopping\n", __func__); in ionic_reset_prepare()
444 del_timer_sync(&ionic->watchdog_timer); in ionic_reset_prepare()
455 ionic_dev_teardown(ionic); in ionic_reset_prepare()
456 ionic_clear_pci(ionic); in ionic_reset_prepare()
457 ionic_debugfs_del_dev(ionic); in ionic_reset_prepare()
462 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_reset_done() local
463 struct ionic_lif *lif = ionic->lif; in ionic_reset_done()
466 err = ionic_setup_one(ionic); in ionic_reset_done()
470 ionic_debugfs_add_sizes(ionic); in ionic_reset_done()
471 ionic_debugfs_add_lif(ionic->lif); in ionic_reset_done()
477 mod_timer(&ionic->watchdog_timer, jiffies + 1); in ionic_reset_done()
480 dev_dbg(ionic->dev, "%s: device recovery %s\n", in ionic_reset_done()
497 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_pci_error_resume() local
498 struct ionic_lif *lif = ionic->lif; in ionic_pci_error_resume()