Lines Matching full:ionic
9 #include "ionic.h"
23 int ionic_bus_get_irq(struct ionic *ionic, unsigned int num) in ionic_bus_get_irq() argument
25 return pci_irq_vector(ionic->pdev, num); in ionic_bus_get_irq()
28 const char *ionic_bus_info(struct ionic *ionic) in ionic_bus_info() argument
30 return pci_name(ionic->pdev); in ionic_bus_info()
33 int ionic_bus_alloc_irq_vectors(struct ionic *ionic, unsigned int nintrs) in ionic_bus_alloc_irq_vectors() argument
35 return pci_alloc_irq_vectors(ionic->pdev, nintrs, nintrs, in ionic_bus_alloc_irq_vectors()
39 void ionic_bus_free_irq_vectors(struct ionic *ionic) in ionic_bus_free_irq_vectors() argument
41 if (!ionic->nintrs) in ionic_bus_free_irq_vectors()
44 pci_free_irq_vectors(ionic->pdev); in ionic_bus_free_irq_vectors()
47 static int ionic_map_bars(struct ionic *ionic) in ionic_map_bars() argument
49 struct pci_dev *pdev = ionic->pdev; in ionic_map_bars()
50 struct device *dev = ionic->dev; in ionic_map_bars()
54 bars = ionic->bars; in ionic_map_bars()
55 ionic->num_bars = 0; in ionic_map_bars()
77 ionic->num_bars++; in ionic_map_bars()
84 static void ionic_unmap_bars(struct ionic *ionic) in ionic_unmap_bars() argument
86 struct ionic_dev_bar *bars = ionic->bars; in ionic_unmap_bars()
97 ionic->num_bars = 0; in ionic_unmap_bars()
100 void __iomem *ionic_bus_map_dbpage(struct ionic *ionic, int page_num) in ionic_bus_map_dbpage() argument
102 return pci_iomap_range(ionic->pdev, in ionic_bus_map_dbpage()
103 ionic->bars[IONIC_PCI_BAR_DBELL].res_index, in ionic_bus_map_dbpage()
107 void ionic_bus_unmap_dbpage(struct ionic *ionic, void __iomem *page) in ionic_bus_unmap_dbpage() argument
112 static void ionic_vf_dealloc_locked(struct ionic *ionic) in ionic_vf_dealloc_locked() argument
118 if (!ionic->vfs) in ionic_vf_dealloc_locked()
121 for (i = ionic->num_vfs - 1; i >= 0; i--) { in ionic_vf_dealloc_locked()
122 v = &ionic->vfs[i]; in ionic_vf_dealloc_locked()
126 ionic_set_vf_config(ionic, i, &vfc); in ionic_vf_dealloc_locked()
127 dma_unmap_single(ionic->dev, v->stats_pa, in ionic_vf_dealloc_locked()
133 kfree(ionic->vfs); in ionic_vf_dealloc_locked()
134 ionic->vfs = NULL; in ionic_vf_dealloc_locked()
135 ionic->num_vfs = 0; in ionic_vf_dealloc_locked()
138 static void ionic_vf_dealloc(struct ionic *ionic) in ionic_vf_dealloc() argument
140 down_write(&ionic->vf_op_lock); in ionic_vf_dealloc()
141 ionic_vf_dealloc_locked(ionic); in ionic_vf_dealloc()
142 up_write(&ionic->vf_op_lock); in ionic_vf_dealloc()
145 static int ionic_vf_alloc(struct ionic *ionic, int num_vfs) in ionic_vf_alloc() argument
152 down_write(&ionic->vf_op_lock); in ionic_vf_alloc()
154 ionic->vfs = kzalloc_objs(struct ionic_vf, num_vfs); in ionic_vf_alloc()
155 if (!ionic->vfs) { in ionic_vf_alloc()
161 v = &ionic->vfs[i]; in ionic_vf_alloc()
162 v->stats_pa = dma_map_single(ionic->dev, &v->stats, in ionic_vf_alloc()
164 if (dma_mapping_error(ionic->dev, v->stats_pa)) { in ionic_vf_alloc()
170 ionic->num_vfs++; in ionic_vf_alloc()
174 ionic_set_vf_config(ionic, i, &vfc); in ionic_vf_alloc()
179 ionic_vf_dealloc_locked(ionic); in ionic_vf_alloc()
180 up_write(&ionic->vf_op_lock); in ionic_vf_alloc()
186 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_sriov_configure() local
187 struct device *dev = ionic->dev; in ionic_sriov_configure()
190 if (ionic->lif && in ionic_sriov_configure()
191 test_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state)) in ionic_sriov_configure()
201 ret = ionic_vf_alloc(ionic, num_vfs); in ionic_sriov_configure()
211 ionic_vf_dealloc(ionic); in ionic_sriov_configure()
218 static void ionic_clear_pci(struct ionic *ionic) in ionic_clear_pci() argument
220 if (ionic->num_bars) { in ionic_clear_pci()
221 ionic->idev.dev_info_regs = NULL; in ionic_clear_pci()
222 ionic->idev.dev_cmd_regs = NULL; in ionic_clear_pci()
223 ionic->idev.intr_status = NULL; in ionic_clear_pci()
224 ionic->idev.intr_ctrl = NULL; in ionic_clear_pci()
226 ionic_unmap_bars(ionic); in ionic_clear_pci()
227 pci_release_regions(ionic->pdev); in ionic_clear_pci()
230 if (pci_is_enabled(ionic->pdev)) in ionic_clear_pci()
231 pci_disable_device(ionic->pdev); in ionic_clear_pci()
234 static int ionic_setup_one(struct ionic *ionic) in ionic_setup_one() argument
236 struct pci_dev *pdev = ionic->pdev; in ionic_setup_one()
237 struct device *dev = ionic->dev; in ionic_setup_one()
240 ionic_debugfs_add_dev(ionic); in ionic_setup_one()
256 err = ionic_map_bars(ionic); in ionic_setup_one()
261 err = ionic_setup(ionic); in ionic_setup_one()
268 err = ionic_identify(ionic); in ionic_setup_one()
273 ionic_debugfs_add_ident(ionic); in ionic_setup_one()
275 ionic_map_cmb(ionic); in ionic_setup_one()
277 err = ionic_init(ionic); in ionic_setup_one()
284 err = ionic_port_identify(ionic); in ionic_setup_one()
290 err = ionic_port_init(ionic); in ionic_setup_one()
299 ionic_dev_teardown(ionic); in ionic_setup_one()
301 ionic_clear_pci(ionic); in ionic_setup_one()
303 ionic_debugfs_del_dev(ionic); in ionic_setup_one()
311 struct ionic *ionic; in ionic_probe() local
315 ionic = ionic_devlink_alloc(dev); in ionic_probe()
316 if (!ionic) in ionic_probe()
319 ionic->pdev = pdev; in ionic_probe()
320 ionic->dev = dev; in ionic_probe()
321 pci_set_drvdata(pdev, ionic); in ionic_probe()
322 mutex_init(&ionic->dev_cmd_lock); in ionic_probe()
337 err = ionic_setup_one(ionic); in ionic_probe()
342 err = ionic_lif_size(ionic); in ionic_probe()
348 err = ionic_lif_alloc(ionic); in ionic_probe()
354 err = ionic_lif_init(ionic->lif); in ionic_probe()
360 init_rwsem(&ionic->vf_op_lock); in ionic_probe()
364 err = ionic_vf_alloc(ionic, num_vfs); in ionic_probe()
369 err = ionic_devlink_register(ionic); in ionic_probe()
375 err = ionic_lif_register(ionic->lif); in ionic_probe()
381 ionic_auxbus_register(ionic->lif); in ionic_probe()
383 mod_timer(&ionic->watchdog_timer, in ionic_probe()
384 round_jiffies(jiffies + ionic->watchdog_period)); in ionic_probe()
385 ionic_queue_doorbell_check(ionic, IONIC_NAPI_DEADLINE); in ionic_probe()
390 ionic_devlink_unregister(ionic); in ionic_probe()
392 ionic_vf_dealloc(ionic); in ionic_probe()
393 ionic_lif_deinit(ionic->lif); in ionic_probe()
395 ionic_lif_free(ionic->lif); in ionic_probe()
396 ionic->lif = NULL; in ionic_probe()
398 ionic_bus_free_irq_vectors(ionic); in ionic_probe()
400 ionic_dev_teardown(ionic); in ionic_probe()
401 ionic_clear_pci(ionic); in ionic_probe()
402 ionic_debugfs_del_dev(ionic); in ionic_probe()
404 mutex_destroy(&ionic->dev_cmd_lock); in ionic_probe()
405 ionic_devlink_free(ionic); in ionic_probe()
412 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_remove() local
414 timer_shutdown_sync(&ionic->watchdog_timer); in ionic_remove()
416 if (ionic->lif) { in ionic_remove()
417 cancel_work_sync(&ionic->lif->deferred.work); in ionic_remove()
419 if (test_and_clear_bit(IONIC_LIF_F_FW_RESET, ionic->lif->state)) in ionic_remove()
420 set_bit(IONIC_LIF_F_FW_STOPPING, ionic->lif->state); in ionic_remove()
422 if (ionic->lif->doorbell_wa) in ionic_remove()
423 cancel_delayed_work_sync(&ionic->doorbell_check_dwork); in ionic_remove()
424 ionic_auxbus_unregister(ionic->lif); in ionic_remove()
425 ionic_lif_unregister(ionic->lif); in ionic_remove()
426 ionic_devlink_unregister(ionic); in ionic_remove()
427 ionic_lif_deinit(ionic->lif); in ionic_remove()
428 ionic_lif_free(ionic->lif); in ionic_remove()
429 ionic->lif = NULL; in ionic_remove()
430 ionic_bus_free_irq_vectors(ionic); in ionic_remove()
433 ionic_port_reset(ionic); in ionic_remove()
434 ionic_reset(ionic); in ionic_remove()
435 ionic_dev_teardown(ionic); in ionic_remove()
436 ionic_clear_pci(ionic); in ionic_remove()
437 ionic_debugfs_del_dev(ionic); in ionic_remove()
438 mutex_destroy(&ionic->dev_cmd_lock); in ionic_remove()
439 ionic_devlink_free(ionic); in ionic_remove()
444 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_reset_prepare() local
445 struct ionic_lif *lif = ionic->lif; in ionic_reset_prepare()
447 dev_dbg(ionic->dev, "%s: device stopping\n", __func__); in ionic_reset_prepare()
451 timer_delete_sync(&ionic->watchdog_timer); in ionic_reset_prepare()
454 ionic_auxbus_unregister(ionic->lif); in ionic_reset_prepare()
463 ionic_dev_teardown(ionic); in ionic_reset_prepare()
464 ionic_clear_pci(ionic); in ionic_reset_prepare()
465 ionic_debugfs_del_dev(ionic); in ionic_reset_prepare()
470 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_reset_done() local
471 struct ionic_lif *lif = ionic->lif; in ionic_reset_done()
474 err = ionic_setup_one(ionic); in ionic_reset_done()
478 ionic_debugfs_add_sizes(ionic); in ionic_reset_done()
479 ionic_debugfs_add_lif(ionic->lif); in ionic_reset_done()
485 mod_timer(&ionic->watchdog_timer, jiffies + 1); in ionic_reset_done()
488 dev_dbg(ionic->dev, "%s: device recovery %s\n", in ionic_reset_done()
505 struct ionic *ionic = pci_get_drvdata(pdev); in ionic_pci_error_resume() local
506 struct ionic_lif *lif = ionic->lif; in ionic_pci_error_resume()