Lines Matching refs:efct

63 	struct efct *efct = NULL;  in efct_device_alloc()  local
65 efct = kzalloc_node(sizeof(*efct), GFP_KERNEL, nid); in efct_device_alloc()
66 if (!efct) in efct_device_alloc()
67 return efct; in efct_device_alloc()
69 INIT_LIST_HEAD(&efct->list_entry); in efct_device_alloc()
70 list_add_tail(&efct->list_entry, &efct_devices); in efct_device_alloc()
72 return efct; in efct_device_alloc()
76 efct_teardown_msix(struct efct *efct) in efct_teardown_msix() argument
80 for (i = 0; i < efct->n_msix_vec; i++) { in efct_teardown_msix()
81 free_irq(pci_irq_vector(efct->pci, i), in efct_teardown_msix()
82 &efct->intr_context[i]); in efct_teardown_msix()
85 pci_free_irq_vectors(efct->pci); in efct_teardown_msix()
89 efct_efclib_config(struct efct *efct, struct libefc_function_template *tt) in efct_efclib_config() argument
99 efct->efcport = efc; in efct_efclib_config()
102 efc->base = efct; in efct_efclib_config()
103 efc->pci = efct->pci; in efct_efclib_config()
105 efc->def_wwnn = efct_get_wwnn(&efct->hw); in efct_efclib_config()
106 efc->def_wwpn = efct_get_wwpn(&efct->hw); in efct_efclib_config()
110 sli = &efct->hw.sli; in efct_efclib_config()
112 sli_get_max_sgl(&efct->hw.sli); in efct_efclib_config()
114 efc->fcfi = efct->hw.fcf_indicator; in efct_efclib_config()
123 static int efct_request_firmware_update(struct efct *efct);
136 efct_device_attach(struct efct *efct) in efct_device_attach() argument
140 if (efct->attached) { in efct_device_attach()
141 efc_log_err(efct, "Device is already attached\n"); in efct_device_attach()
145 snprintf(efct->name, sizeof(efct->name), "[%s%d] ", "fc", in efct_device_attach()
146 efct->instance_index); in efct_device_attach()
148 efct->logmask = logmask; in efct_device_attach()
149 efct->filter_def = EFCT_DEFAULT_FILTER; in efct_device_attach()
150 efct->max_isr_time_msec = EFCT_OS_MAX_ISR_TIME_MSEC; in efct_device_attach()
152 efct->model = efct_pci_model(efct->pci->device); in efct_device_attach()
154 efct->efct_req_fw_upgrade = true; in efct_device_attach()
157 efct->xport = efct_xport_alloc(efct); in efct_device_attach()
158 if (!efct->xport) { in efct_device_attach()
159 efc_log_err(efct, "failed to allocate transport object\n"); in efct_device_attach()
164 rc = efct_xport_attach(efct->xport); in efct_device_attach()
166 efc_log_err(efct, "failed to attach transport object\n"); in efct_device_attach()
170 rc = efct_xport_initialize(efct->xport); in efct_device_attach()
172 efc_log_err(efct, "failed to initialize transport object\n"); in efct_device_attach()
176 rc = efct_efclib_config(efct, &efct_libefc_templ); in efct_device_attach()
178 efc_log_err(efct, "failed to init efclib\n"); in efct_device_attach()
182 for (i = 0; i < efct->n_msix_vec; i++) { in efct_device_attach()
183 efc_log_debug(efct, "irq %d enabled\n", i); in efct_device_attach()
184 enable_irq(pci_irq_vector(efct->pci, i)); in efct_device_attach()
187 efct->attached = true; in efct_device_attach()
189 if (efct->efct_req_fw_upgrade) in efct_device_attach()
190 efct_request_firmware_update(efct); in efct_device_attach()
195 efct_xport_detach(efct->xport); in efct_device_attach()
197 efct_xport_free(efct->xport); in efct_device_attach()
198 efct->xport = NULL; in efct_device_attach()
204 efct_device_detach(struct efct *efct) in efct_device_detach() argument
208 if (!efct || !efct->attached) { in efct_device_detach()
213 if (efct_xport_control(efct->xport, EFCT_XPORT_SHUTDOWN)) in efct_device_detach()
214 efc_log_err(efct, "Transport Shutdown timed out\n"); in efct_device_detach()
216 for (i = 0; i < efct->n_msix_vec; i++) in efct_device_detach()
217 disable_irq(pci_irq_vector(efct->pci, i)); in efct_device_detach()
219 efct_xport_detach(efct->xport); in efct_device_detach()
221 efct_xport_free(efct->xport); in efct_device_detach()
222 efct->xport = NULL; in efct_device_detach()
224 efcport_destroy(efct->efcport); in efct_device_detach()
225 kfree(efct->efcport); in efct_device_detach()
227 efct->attached = false; in efct_device_detach()
246 efct_firmware_write(struct efct *efct, const u8 *buf, size_t buf_len, in efct_firmware_write() argument
263 dma.virt = dma_alloc_coherent(&efct->pci->dev, in efct_firmware_write()
279 efct_hw_firmware_write(&efct->hw, &dma, xfer_size, offset, in efct_firmware_write()
299 dma_free_coherent(&efct->pci->dev, dma.size, dma.virt, dma.phys); in efct_firmware_write()
304 efct_fw_reset(struct efct *efct) in efct_fw_reset() argument
311 if (timer_pending(&efct->xport->stats_timer)) in efct_fw_reset()
312 del_timer(&efct->xport->stats_timer); in efct_fw_reset()
314 if (efct_hw_reset(&efct->hw, EFCT_HW_RESET_FIRMWARE)) { in efct_fw_reset()
315 efc_log_info(efct, "failed to reset firmware\n"); in efct_fw_reset()
319 efc_log_info(efct, "successfully reset firmware.Now resetting port\n"); in efct_fw_reset()
321 efct_device_detach(efct); in efct_fw_reset()
322 return efct_device_attach(efct); in efct_fw_reset()
326 efct_request_firmware_update(struct efct *efct) in efct_request_firmware_update() argument
333 snprintf(file_name, 256, "%s.grp", efct->model); in efct_request_firmware_update()
335 rc = request_firmware(&fw, file_name, &efct->pci->dev); in efct_request_firmware_update()
337 efc_log_debug(efct, "Firmware file(%s) not found.\n", file_name); in efct_request_firmware_update()
343 if (!strncmp(efct->hw.sli.fw_name[0], fw_image->revision, in efct_request_firmware_update()
345 efc_log_debug(efct, in efct_request_firmware_update()
350 efc_log_info(efct, "Firmware update is initiated. %s -> %s\n", in efct_request_firmware_update()
351 efct->hw.sli.fw_name[0], fw_image->revision); in efct_request_firmware_update()
353 rc = efct_firmware_write(efct, fw->data, fw->size, &fw_change_status); in efct_request_firmware_update()
355 efc_log_err(efct, "Firmware update failed. rc = %d\n", rc); in efct_request_firmware_update()
359 efc_log_info(efct, "Firmware updated successfully\n"); in efct_request_firmware_update()
362 efc_log_info(efct, "New firmware is active.\n"); in efct_request_firmware_update()
365 efc_log_info(efct, in efct_request_firmware_update()
370 efc_log_info(efct, in efct_request_firmware_update()
372 efct_fw_reset(efct); in efct_request_firmware_update()
375 efc_log_info(efct, "Unexpected value change_status:%d\n", in efct_request_firmware_update()
387 efct_device_free(struct efct *efct) in efct_device_free() argument
389 if (efct) { in efct_device_free()
390 list_del(&efct->list_entry); in efct_device_free()
391 kfree(efct); in efct_device_free()
396 efct_device_interrupts_required(struct efct *efct) in efct_device_interrupts_required() argument
400 rc = efct_hw_setup(&efct->hw, efct, efct->pci); in efct_device_interrupts_required()
404 return efct->hw.config.n_eq; in efct_device_interrupts_required()
411 struct efct *efct = intr_ctx->efct; in efct_intr_thread() local
413 efct_hw_process(&efct->hw, intr_ctx->index, efct->max_isr_time_msec); in efct_intr_thread()
424 efct_setup_msix(struct efct *efct, u32 num_intrs) in efct_setup_msix() argument
428 if (!pci_find_capability(efct->pci, PCI_CAP_ID_MSIX)) { in efct_setup_msix()
429 dev_err(&efct->pci->dev, in efct_setup_msix()
434 efct->n_msix_vec = num_intrs; in efct_setup_msix()
436 rc = pci_alloc_irq_vectors(efct->pci, num_intrs, num_intrs, in efct_setup_msix()
440 dev_err(&efct->pci->dev, "Failed to alloc irq : %d\n", rc); in efct_setup_msix()
447 intr_ctx = &efct->intr_context[i]; in efct_setup_msix()
448 intr_ctx->efct = efct; in efct_setup_msix()
451 rc = request_threaded_irq(pci_irq_vector(efct->pci, i), in efct_setup_msix()
455 dev_err(&efct->pci->dev, in efct_setup_msix()
465 free_irq(pci_irq_vector(efct->pci, i), in efct_setup_msix()
466 &efct->intr_context[i]); in efct_setup_msix()
468 pci_free_irq_vectors(efct->pci); in efct_setup_msix()
481 struct efct *efct = NULL; in efct_pci_probe() local
515 efct = efct_device_alloc(nid); in efct_pci_probe()
516 if (!efct) { in efct_pci_probe()
522 efct->pci = pdev; in efct_pci_probe()
523 efct->numa_node = nid; in efct_pci_probe()
528 efct->reg[r] = ioremap(pci_resource_start(pdev, i), in efct_pci_probe()
542 pci_set_drvdata(pdev, efct); in efct_pci_probe()
550 num_interrupts = efct_device_interrupts_required(efct); in efct_pci_probe()
552 efc_log_err(efct, "efct_device_interrupts_required failed\n"); in efct_pci_probe()
561 rc = efct_setup_msix(efct, num_interrupts); in efct_pci_probe()
567 for (i = 0; i < efct->n_msix_vec; i++) { in efct_pci_probe()
568 efc_log_debug(efct, "irq %d disabled\n", i); in efct_pci_probe()
569 disable_irq(pci_irq_vector(efct->pci, i)); in efct_pci_probe()
572 rc = efct_device_attach(efct); in efct_pci_probe()
579 efct_teardown_msix(efct); in efct_pci_probe()
584 if (efct->reg[i]) in efct_pci_probe()
585 iounmap(efct->reg[i]); in efct_pci_probe()
587 efct_device_free(efct); in efct_pci_probe()
600 struct efct *efct = pci_get_drvdata(pdev); in efct_pci_remove() local
603 if (!efct) in efct_pci_remove()
606 efct_device_detach(efct); in efct_pci_remove()
608 efct_teardown_msix(efct); in efct_pci_remove()
611 if (efct->reg[i]) in efct_pci_remove()
612 iounmap(efct->reg[i]); in efct_pci_remove()
617 efct_device_free(efct); in efct_pci_remove()
625 efct_device_prep_for_reset(struct efct *efct, struct pci_dev *pdev) in efct_device_prep_for_reset() argument
627 if (efct) { in efct_device_prep_for_reset()
628 efc_log_debug(efct, in efct_device_prep_for_reset()
630 efct_device_detach(efct); in efct_device_prep_for_reset()
632 efct_teardown_msix(efct); in efct_device_prep_for_reset()
638 efct_device_prep_for_recover(struct efct *efct) in efct_device_prep_for_recover() argument
640 if (efct) { in efct_device_prep_for_recover()
641 efc_log_debug(efct, "PCI channel preparing for recovery\n"); in efct_device_prep_for_recover()
642 efct_hw_io_abort_all(&efct->hw); in efct_device_prep_for_recover()
664 struct efct *efct = pci_get_drvdata(pdev); in efct_pci_io_error_detected() local
669 efct_device_prep_for_recover(efct); in efct_pci_io_error_detected()
673 efct_device_prep_for_reset(efct, pdev); in efct_pci_io_error_detected()
677 efct_device_detach(efct); in efct_pci_io_error_detected()
681 efc_log_debug(efct, "Unknown PCI error state:0x%x\n", state); in efct_pci_io_error_detected()
682 efct_device_prep_for_reset(efct, pdev); in efct_pci_io_error_detected()
694 struct efct *efct = pci_get_drvdata(pdev); in efct_pci_io_slot_reset() local
698 efc_log_err(efct, "failed to enable PCI device after reset\n"); in efct_pci_io_slot_reset()
711 rc = efct_setup_msix(efct, efct->n_msix_vec); in efct_pci_io_slot_reset()
713 efc_log_err(efct, "rc %d returned, IRQ allocation failed\n", in efct_pci_io_slot_reset()
717 efct_device_detach(efct); in efct_pci_io_slot_reset()
719 efct_device_attach(efct); in efct_pci_io_slot_reset()
727 struct efct *efct = pci_get_drvdata(pdev); in efct_pci_io_resume() local
730 efct_device_detach(efct); in efct_pci_io_resume()
732 efct_device_attach(efct); in efct_pci_io_resume()