Lines Matching +full:ext +full:- +full:gen
1 // SPDX-License-Identifier: GPL-2.0
36 hw->link.status = SLI4_LINK_STATUS_MAX; in efct_hw_link_event_init()
37 hw->link.topology = SLI4_LINK_TOPO_NONE; in efct_hw_link_event_init()
38 hw->link.medium = SLI4_LINK_MEDIUM_MAX; in efct_hw_link_event_init()
39 hw->link.speed = 0; in efct_hw_link_event_init()
40 hw->link.loop_map = NULL; in efct_hw_link_event_init()
41 hw->link.fc_id = U32_MAX; in efct_hw_link_event_init()
50 struct efct *efct = hw->os; in efct_hw_read_max_dump_size()
55 if (PCI_FUNC(efct->pci->devfn) != 0) in efct_hw_read_max_dump_size()
58 if (sli_cmd_common_set_dump_location(&hw->sli, buf, 1, 0, NULL, 0)) in efct_hw_read_max_dump_size()
59 return -EIO; in efct_hw_read_max_dump_size()
66 efc_log_debug(hw->os, "set dump location cmd failed\n"); in efct_hw_read_max_dump_size()
70 hw->dump_size = in efct_hw_read_max_dump_size()
71 le32_to_cpu(rsp->buffer_length_dword) & SLI4_CMN_SET_DUMP_BUFFER_LEN; in efct_hw_read_max_dump_size()
73 efc_log_debug(hw->os, "Dump size %x\n", hw->dump_size); in efct_hw_read_max_dump_size()
85 struct efct *efct = hw->os; in __efct_read_topology_cb()
87 if (status || le16_to_cpu(read_topo->hdr.status)) { in __efct_read_topology_cb()
88 efc_log_debug(hw->os, "bad status cqe=%#x mqe=%#x\n", status, in __efct_read_topology_cb()
89 le16_to_cpu(read_topo->hdr.status)); in __efct_read_topology_cb()
90 return -EIO; in __efct_read_topology_cb()
93 switch (le32_to_cpu(read_topo->dw2_attentype) & in __efct_read_topology_cb()
96 hw->link.status = SLI4_LINK_STATUS_UP; in __efct_read_topology_cb()
99 hw->link.status = SLI4_LINK_STATUS_DOWN; in __efct_read_topology_cb()
102 hw->link.status = SLI4_LINK_STATUS_NO_ALPA; in __efct_read_topology_cb()
105 hw->link.status = SLI4_LINK_STATUS_MAX; in __efct_read_topology_cb()
109 switch (read_topo->topology) { in __efct_read_topology_cb()
111 hw->link.topology = SLI4_LINK_TOPO_NON_FC_AL; in __efct_read_topology_cb()
114 hw->link.topology = SLI4_LINK_TOPO_FC_AL; in __efct_read_topology_cb()
115 if (hw->link.status == SLI4_LINK_STATUS_UP) in __efct_read_topology_cb()
116 hw->link.loop_map = hw->loop_map.virt; in __efct_read_topology_cb()
117 hw->link.fc_id = read_topo->acquired_al_pa; in __efct_read_topology_cb()
120 hw->link.topology = SLI4_LINK_TOPO_MAX; in __efct_read_topology_cb()
124 hw->link.medium = SLI4_LINK_MEDIUM_FC; in __efct_read_topology_cb()
126 speed = (le32_to_cpu(read_topo->currlink_state) & in __efct_read_topology_cb()
130 hw->link.speed = 1 * 1000; in __efct_read_topology_cb()
133 hw->link.speed = 2 * 1000; in __efct_read_topology_cb()
136 hw->link.speed = 4 * 1000; in __efct_read_topology_cb()
139 hw->link.speed = 8 * 1000; in __efct_read_topology_cb()
142 hw->link.speed = 16 * 1000; in __efct_read_topology_cb()
145 hw->link.speed = 32 * 1000; in __efct_read_topology_cb()
148 hw->link.speed = 64 * 1000; in __efct_read_topology_cb()
151 hw->link.speed = 128 * 1000; in __efct_read_topology_cb()
155 drec.speed = hw->link.speed; in __efct_read_topology_cb()
156 drec.fc_id = hw->link.fc_id; in __efct_read_topology_cb()
158 efc_domain_cb(efct->efcport, EFC_HW_DOMAIN_FOUND, &drec); in __efct_read_topology_cb()
170 struct efct *efct = hw->os; in efct_hw_cb_link()
174 switch (event->status) { in efct_hw_cb_link()
177 hw->link = *event; in efct_hw_cb_link()
178 efct->efcport->link_status = EFC_LINK_STATUS_UP; in efct_hw_cb_link()
180 if (event->topology == SLI4_LINK_TOPO_NON_FC_AL) { in efct_hw_cb_link()
183 efc_log_info(hw->os, "Link Up, NPORT, speed is %d\n", in efct_hw_cb_link()
184 event->speed); in efct_hw_cb_link()
185 drec.speed = event->speed; in efct_hw_cb_link()
186 drec.fc_id = event->fc_id; in efct_hw_cb_link()
188 efc_domain_cb(efct->efcport, EFC_HW_DOMAIN_FOUND, in efct_hw_cb_link()
190 } else if (event->topology == SLI4_LINK_TOPO_FC_AL) { in efct_hw_cb_link()
193 efc_log_info(hw->os, "Link Up, LOOP, speed is %d\n", in efct_hw_cb_link()
194 event->speed); in efct_hw_cb_link()
196 if (!sli_cmd_read_topology(&hw->sli, buf, in efct_hw_cb_link()
197 &hw->loop_map)) { in efct_hw_cb_link()
203 efc_log_debug(hw->os, "READ_TOPOLOGY failed\n"); in efct_hw_cb_link()
205 efc_log_info(hw->os, "%s(%#x), speed is %d\n", in efct_hw_cb_link()
207 event->topology, event->speed); in efct_hw_cb_link()
211 efc_log_info(hw->os, "Link down\n"); in efct_hw_cb_link()
213 hw->link.status = event->status; in efct_hw_cb_link()
214 efct->efcport->link_status = EFC_LINK_STATUS_DOWN; in efct_hw_cb_link()
216 d = efct->efcport->domain; in efct_hw_cb_link()
218 efc_domain_cb(efct->efcport, EFC_HW_DOMAIN_LOST, d); in efct_hw_cb_link()
221 efc_log_debug(hw->os, "unhandled link status %#x\n", in efct_hw_cb_link()
222 event->status); in efct_hw_cb_link()
234 if (hw->hw_setup_called) in efct_hw_setup()
239 * needs allocation. If a structure is non-NULL, efct_hw_init() won't in efct_hw_setup()
244 hw->hw_setup_called = true; in efct_hw_setup()
246 hw->os = os; in efct_hw_setup()
248 mutex_init(&hw->bmbx_lock); in efct_hw_setup()
249 spin_lock_init(&hw->cmd_lock); in efct_hw_setup()
250 INIT_LIST_HEAD(&hw->cmd_head); in efct_hw_setup()
251 INIT_LIST_HEAD(&hw->cmd_pending); in efct_hw_setup()
252 hw->cmd_head_count = 0; in efct_hw_setup()
255 hw->cmd_ctx_pool = mempool_create_kmalloc_pool(EFCT_CMD_CTX_POOL_SZ, in efct_hw_setup()
257 if (!hw->cmd_ctx_pool) { in efct_hw_setup()
258 efc_log_err(hw->os, "failed to allocate mailbox buffer pool\n"); in efct_hw_setup()
259 return -EIO; in efct_hw_setup()
263 hw->mbox_rqst_pool = mempool_create_kmalloc_pool(EFCT_CMD_CTX_POOL_SZ, in efct_hw_setup()
265 if (!hw->mbox_rqst_pool) { in efct_hw_setup()
266 efc_log_err(hw->os, "failed to allocate mbox request pool\n"); in efct_hw_setup()
267 return -EIO; in efct_hw_setup()
270 spin_lock_init(&hw->io_lock); in efct_hw_setup()
271 INIT_LIST_HEAD(&hw->io_inuse); in efct_hw_setup()
272 INIT_LIST_HEAD(&hw->io_free); in efct_hw_setup()
273 INIT_LIST_HEAD(&hw->io_wait_free); in efct_hw_setup()
275 atomic_set(&hw->io_alloc_failed_count, 0); in efct_hw_setup()
277 hw->config.speed = SLI4_LINK_SPEED_AUTO_16_8_4; in efct_hw_setup()
278 if (sli_setup(&hw->sli, hw->os, pdev, ((struct efct *)os)->reg)) { in efct_hw_setup()
279 efc_log_err(hw->os, "SLI setup failed\n"); in efct_hw_setup()
280 return -EIO; in efct_hw_setup()
285 sli_callback(&hw->sli, SLI4_CB_LINK, efct_hw_cb_link, hw); in efct_hw_setup()
290 for (i = 0; i < ARRAY_SIZE(hw->num_qentries); i++) in efct_hw_setup()
291 hw->num_qentries[i] = hw->sli.qinfo.max_qentries[i]; in efct_hw_setup()
295 * handle multi-phase as well as aborts. in efct_hw_setup()
297 hw->num_qentries[SLI4_QTYPE_WQ] = hw->num_qentries[SLI4_QTYPE_CQ] / 2; in efct_hw_setup()
303 hw->config.rq_default_buffer_size = EFCT_HW_RQ_SIZE_PAYLOAD; in efct_hw_setup()
304 hw->config.n_io = hw->sli.ext[SLI4_RSRC_XRI].size; in efct_hw_setup()
307 hw->config.n_eq = cpus > EFCT_HW_MAX_NUM_EQ ? EFCT_HW_MAX_NUM_EQ : cpus; in efct_hw_setup()
309 max_sgl = sli_get_max_sgl(&hw->sli) - SLI4_SGE_MAX_RESERVED; in efct_hw_setup()
311 hw->config.n_sgl = max_sgl; in efct_hw_setup()
321 efc_log_info(hw->os, in efct_logfcfi()
322 "REG_FCFI: filter[%d] %08X -> RQ[%d] id=%d\n", in efct_logfcfi()
323 j, hw->config.filter_def[j], i, id); in efct_logfcfi()
330 * Set io->done to NULL, to avoid any callbacks, should in efct_hw_init_free_io()
333 io->done = NULL; in efct_hw_init_free_io()
334 io->abort_done = NULL; in efct_hw_init_free_io()
335 io->status_saved = false; in efct_hw_init_free_io()
336 io->abort_in_progress = false; in efct_hw_init_free_io()
337 io->type = 0xFFFF; in efct_hw_init_free_io()
338 io->wq = NULL; in efct_hw_init_free_io()
356 io->sgl = &io->def_sgl; in efct_hw_io_restore_sgl()
357 io->sgl_count = io->def_sgl_count; in efct_hw_io_restore_sgl()
364 struct efct_hw *hw = io->hw; in efct_hw_wq_process_io()
367 u32 ext = 0; in efct_hw_wq_process_io() local
370 if (io->xbusy && (wcqe->flags & SLI4_WCQE_XB) == 0) in efct_hw_wq_process_io()
371 io->xbusy = false; in efct_hw_wq_process_io()
374 switch (io->type) { in efct_hw_wq_process_io()
379 sli_fc_els_did(&hw->sli, cqe, &ext); in efct_hw_wq_process_io()
380 len = sli_fc_response_length(&hw->sli, cqe); in efct_hw_wq_process_io()
386 len = sli_fc_response_length(&hw->sli, cqe); in efct_hw_wq_process_io()
389 len = sli_fc_io_length(&hw->sli, cqe); in efct_hw_wq_process_io()
392 len = sli_fc_io_length(&hw->sli, cqe); in efct_hw_wq_process_io()
397 /* release the count for re-posting the buffer */ in efct_hw_wq_process_io()
401 efc_log_err(hw->os, "unhandled io type %#x for XRI 0x%x\n", in efct_hw_wq_process_io()
402 io->type, io->indicator); in efct_hw_wq_process_io()
406 ext = sli_fc_ext_status(&hw->sli, cqe); in efct_hw_wq_process_io()
411 if (efct_hw_iotype_is_originator(io->type) && in efct_hw_wq_process_io()
412 wcqe->flags & SLI4_WCQE_XB) { in efct_hw_wq_process_io()
415 efc_log_debug(hw->os, "aborting xri=%#x tag=%#x\n", in efct_hw_wq_process_io()
416 io->indicator, io->reqtag); in efct_hw_wq_process_io()
429 io->status_saved = true; in efct_hw_wq_process_io()
430 io->saved_status = status; in efct_hw_wq_process_io()
431 io->saved_ext = ext; in efct_hw_wq_process_io()
432 io->saved_len = len; in efct_hw_wq_process_io()
434 } else if (rc == -EINPROGRESS) { in efct_hw_wq_process_io()
440 efc_log_debug(hw->os, "%s%#x tag=%#x\n", in efct_hw_wq_process_io()
442 io->indicator, io->reqtag); in efct_hw_wq_process_io()
448 efc_log_debug(hw->os, "%s%#x tag=%#x rc=%d\n", in efct_hw_wq_process_io()
450 io->indicator, io->reqtag, rc); in efct_hw_wq_process_io()
455 if (io->done) { in efct_hw_wq_process_io()
456 efct_hw_done_t done = io->done; in efct_hw_wq_process_io()
458 io->done = NULL; in efct_hw_wq_process_io()
460 if (io->status_saved) { in efct_hw_wq_process_io()
462 status = io->saved_status; in efct_hw_wq_process_io()
463 len = io->saved_len; in efct_hw_wq_process_io()
464 ext = io->saved_ext; in efct_hw_wq_process_io()
465 io->status_saved = false; in efct_hw_wq_process_io()
470 done(io, len, status, ext, io->arg); in efct_hw_wq_process_io()
487 struct efct *efct = hw->os; in efct_hw_setup_io()
489 if (!hw->io) { in efct_hw_setup_io()
490 hw->io = kmalloc_array(hw->config.n_io, sizeof(io), GFP_KERNEL); in efct_hw_setup_io()
491 if (!hw->io) in efct_hw_setup_io()
492 return -ENOMEM; in efct_hw_setup_io()
494 memset(hw->io, 0, hw->config.n_io * sizeof(io)); in efct_hw_setup_io()
496 for (i = 0; i < hw->config.n_io; i++) { in efct_hw_setup_io()
497 hw->io[i] = kzalloc(sizeof(*io), GFP_KERNEL); in efct_hw_setup_io()
498 if (!hw->io[i]) in efct_hw_setup_io()
503 hw->wqe_buffs = kzalloc((hw->config.n_io * hw->sli.wqe_size), in efct_hw_setup_io()
505 if (!hw->wqe_buffs) { in efct_hw_setup_io()
506 kfree(hw->io); in efct_hw_setup_io()
507 return -ENOMEM; in efct_hw_setup_io()
511 /* re-use existing IOs, including SGLs */ in efct_hw_setup_io()
516 dma = &hw->xfer_rdy; in efct_hw_setup_io()
517 dma->size = sizeof(struct fcp_txrdy) * hw->config.n_io; in efct_hw_setup_io()
518 dma->virt = dma_alloc_coherent(&efct->pci->dev, in efct_hw_setup_io()
519 dma->size, &dma->phys, GFP_KERNEL); in efct_hw_setup_io()
520 if (!dma->virt) in efct_hw_setup_io()
521 return -ENOMEM; in efct_hw_setup_io()
523 xfer_virt = (uintptr_t)hw->xfer_rdy.virt; in efct_hw_setup_io()
524 xfer_phys = hw->xfer_rdy.phys; in efct_hw_setup_io()
527 for (i = 0; i < hw->config.n_io; i++) { in efct_hw_setup_io()
530 io = hw->io[i]; in efct_hw_setup_io()
533 io->hw = hw; in efct_hw_setup_io()
536 io->wqe.wqebuf = &hw->wqe_buffs[i * hw->sli.wqe_size]; in efct_hw_setup_io()
541 efc_log_err(hw->os, "can't allocate request tag\n"); in efct_hw_setup_io()
542 return -ENOSPC; in efct_hw_setup_io()
544 io->reqtag = wqcb->instance_index; in efct_hw_setup_io()
550 io->xbusy = 0; in efct_hw_setup_io()
552 if (sli_resource_alloc(&hw->sli, SLI4_RSRC_XRI, in efct_hw_setup_io()
553 &io->indicator, &index)) { in efct_hw_setup_io()
554 efc_log_err(hw->os, in efct_hw_setup_io()
556 return -ENOMEM; in efct_hw_setup_io()
560 dma = &io->def_sgl; in efct_hw_setup_io()
561 dma->size = hw->config.n_sgl * in efct_hw_setup_io()
563 dma->virt = dma_alloc_coherent(&efct->pci->dev, in efct_hw_setup_io()
564 dma->size, &dma->phys, in efct_hw_setup_io()
566 if (!dma->virt) { in efct_hw_setup_io()
567 efc_log_err(hw->os, "dma_alloc fail %d\n", i); in efct_hw_setup_io()
568 memset(&io->def_sgl, 0, in efct_hw_setup_io()
570 return -ENOMEM; in efct_hw_setup_io()
573 io->def_sgl_count = hw->config.n_sgl; in efct_hw_setup_io()
574 io->sgl = &io->def_sgl; in efct_hw_setup_io()
575 io->sgl_count = io->def_sgl_count; in efct_hw_setup_io()
577 if (hw->xfer_rdy.size) { in efct_hw_setup_io()
578 io->xfer_rdy.virt = (void *)xfer_virt; in efct_hw_setup_io()
579 io->xfer_rdy.phys = xfer_phys; in efct_hw_setup_io()
580 io->xfer_rdy.size = sizeof(struct fcp_txrdy); in efct_hw_setup_io()
589 for (i = 0; i < hw->config.n_io && hw->io[i]; i++) { in efct_hw_setup_io()
590 kfree(hw->io[i]); in efct_hw_setup_io()
591 hw->io[i] = NULL; in efct_hw_setup_io()
594 kfree(hw->io); in efct_hw_setup_io()
595 hw->io = NULL; in efct_hw_setup_io()
597 return -ENOMEM; in efct_hw_setup_io()
612 struct efct *efct = hw->os; in efct_hw_init_prereg_io()
616 return -ENOMEM; in efct_hw_init_prereg_io()
620 req.virt = dma_alloc_coherent(&efct->pci->dev, req.size, &req.phys, in efct_hw_init_prereg_io()
624 return -ENOMEM; in efct_hw_init_prereg_io()
627 for (n_rem = hw->config.n_io; n_rem; n_rem -= n) { in efct_hw_init_prereg_io()
636 if (hw->io[idx + n]->indicator != in efct_hw_init_prereg_io()
637 hw->io[idx + n - 1]->indicator + 1) in efct_hw_init_prereg_io()
641 sgls[n] = hw->io[idx + n]->sgl; in efct_hw_init_prereg_io()
644 if (sli_cmd_post_sgl_pages(&hw->sli, cmd, in efct_hw_init_prereg_io()
645 hw->io[idx]->indicator, n, sgls, NULL, &req)) { in efct_hw_init_prereg_io()
646 rc = -EIO; in efct_hw_init_prereg_io()
652 efc_log_err(hw->os, "SGL post failed, rc=%d\n", rc); in efct_hw_init_prereg_io()
658 io = hw->io[idx]; in efct_hw_init_prereg_io()
659 io->state = EFCT_HW_IO_STATE_FREE; in efct_hw_init_prereg_io()
660 INIT_LIST_HEAD(&io->list_entry); in efct_hw_init_prereg_io()
661 list_add_tail(&io->list_entry, &hw->io_free); in efct_hw_init_prereg_io()
665 dma_free_coherent(&efct->pci->dev, req.size, req.virt, req.phys); in efct_hw_init_prereg_io()
680 prereg = hw->sli.params.sgl_pre_registered; in efct_hw_init_io()
685 for (i = 0; i < hw->config.n_io; i++, idx++) { in efct_hw_init_io()
686 io = hw->io[idx]; in efct_hw_init_io()
687 io->state = EFCT_HW_IO_STATE_FREE; in efct_hw_init_io()
688 INIT_LIST_HEAD(&io->list_entry); in efct_hw_init_io()
689 list_add_tail(&io->list_entry, &hw->io_free); in efct_hw_init_io()
705 sli_cmd_common_set_features(&hw->sli, buf, in efct_hw_config_set_fdt_xfer_hint()
710 efc_log_warn(hw->os, "set FDT hint %d failed: %d\n", in efct_hw_config_set_fdt_xfer_hint()
713 efc_log_info(hw->os, "Set FTD transfer hint to %d\n", in efct_hw_config_set_fdt_xfer_hint()
726 efc_log_info(hw->os, "using REG_FCFI standard\n"); in efct_hw_config_rq()
734 rq_cfg[i].r_ctl_mask = (u8)hw->config.filter_def[i]; in efct_hw_config_rq()
735 rq_cfg[i].r_ctl_match = (u8)(hw->config.filter_def[i] >> 8); in efct_hw_config_rq()
736 rq_cfg[i].type_mask = (u8)(hw->config.filter_def[i] >> 16); in efct_hw_config_rq()
737 rq_cfg[i].type_match = (u8)(hw->config.filter_def[i] >> 24); in efct_hw_config_rq()
745 min_rq_count = (hw->hw_rq_count < SLI4_CMD_REG_FCFI_NUM_RQ_CFG) ? in efct_hw_config_rq()
746 hw->hw_rq_count : SLI4_CMD_REG_FCFI_NUM_RQ_CFG; in efct_hw_config_rq()
748 struct hw_rq *rq = hw->hw_rq[i]; in efct_hw_config_rq()
752 u32 mask = (rq->filter_mask != 0) ? in efct_hw_config_rq()
753 rq->filter_mask : 1; in efct_hw_config_rq()
758 rq_cfg[i].rq_id = cpu_to_le16(rq->hdr->id); in efct_hw_config_rq()
759 efct_logfcfi(hw, j, i, rq->hdr->id); in efct_hw_config_rq()
763 rc = -EIO; in efct_hw_config_rq()
764 if (!sli_cmd_reg_fcfi(&hw->sli, buf, 0, rq_cfg)) in efct_hw_config_rq()
768 efc_log_err(hw->os, "FCFI registration failed\n"); in efct_hw_config_rq()
771 hw->fcf_indicator = in efct_hw_config_rq()
772 le16_to_cpu(((struct sli4_cmd_reg_fcfi *)buf)->fcfi); in efct_hw_config_rq()
792 rq_filter[i].type_mask = (u8)hw->config.filter_def[i]; in efct_hw_config_mrq()
793 rq_filter[i].type_match = (u8)(hw->config.filter_def[i] >> 8); in efct_hw_config_mrq()
794 rq_filter[i].r_ctl_mask = (u8)(hw->config.filter_def[i] >> 16); in efct_hw_config_mrq()
795 rq_filter[i].r_ctl_match = (u8)(hw->config.filter_def[i] >> 24); in efct_hw_config_mrq()
798 rq = hw->hw_rq[0]; in efct_hw_config_mrq()
799 rq_filter[0].rq_id = cpu_to_le16(rq->hdr->id); in efct_hw_config_mrq()
800 rq_filter[1].rq_id = cpu_to_le16(rq->hdr->id); in efct_hw_config_mrq()
804 efc_log_debug(hw->os, "Issue reg_fcfi_mrq count:%d policy:%d mode:%d\n", in efct_hw_config_mrq()
805 hw->hw_rq_count, hw->config.rq_selection_policy, mode); in efct_hw_config_mrq()
807 rc = sli_cmd_reg_fcfi_mrq(&hw->sli, buf, mode, fcf_index, in efct_hw_config_mrq()
808 hw->config.rq_selection_policy, mrq_bitmask, in efct_hw_config_mrq()
809 hw->hw_mrq_count, rq_filter); in efct_hw_config_mrq()
811 efc_log_err(hw->os, "sli_cmd_reg_fcfi_mrq() failed\n"); in efct_hw_config_mrq()
812 return -EIO; in efct_hw_config_mrq()
819 if ((rc) || (le16_to_cpu(rsp->hdr.status))) { in efct_hw_config_mrq()
820 efc_log_err(hw->os, "FCFI MRQ reg failed. cmd=%x status=%x\n", in efct_hw_config_mrq()
821 rsp->hdr.command, le16_to_cpu(rsp->hdr.status)); in efct_hw_config_mrq()
822 return -EIO; in efct_hw_config_mrq()
826 hw->fcf_indicator = le16_to_cpu(rsp->fcfi); in efct_hw_config_mrq()
835 u32 hash_index = id & (EFCT_HW_Q_HASH_SIZE - 1); in efct_hw_queue_hash_add()
842 hash_index = (hash_index + 1) & (EFCT_HW_Q_HASH_SIZE - 1); in efct_hw_queue_hash_add()
869 sli_cmd_common_set_features(&hw->sli, buf, in efct_hw_config_sli_port_health_check()
874 efc_log_err(hw->os, "efct_hw_command returns %d\n", rc); in efct_hw_config_sli_port_health_check()
876 efc_log_debug(hw->os, "SLI Port Health Check is enabled\n"); in efct_hw_config_sli_port_health_check()
892 * Make sure the command lists are empty. If this is start-of-day, in efct_hw_init()
898 spin_lock_irqsave(&hw->cmd_lock, flags); in efct_hw_init()
899 if (!list_empty(&hw->cmd_head)) { in efct_hw_init()
900 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_init()
901 efc_log_err(hw->os, "command found on cmd list\n"); in efct_hw_init()
902 return -EIO; in efct_hw_init()
904 if (!list_empty(&hw->cmd_pending)) { in efct_hw_init()
905 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_init()
906 efc_log_err(hw->os, "command found on pending list\n"); in efct_hw_init()
907 return -EIO; in efct_hw_init()
909 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_init()
916 * efct_hw_init_io() function will re-add the IOs to the free list. in efct_hw_init()
925 while ((!list_empty(&hw->io_wait_free))) { in efct_hw_init()
927 temp = list_first_entry(&hw->io_wait_free, struct efct_hw_io, in efct_hw_init()
929 list_del_init(&temp->list_entry); in efct_hw_init()
932 efc_log_debug(hw->os, "rmvd %d items from io_wait_free list\n", in efct_hw_init()
936 while ((!list_empty(&hw->io_inuse))) { in efct_hw_init()
938 temp = list_first_entry(&hw->io_inuse, struct efct_hw_io, in efct_hw_init()
940 list_del_init(&temp->list_entry); in efct_hw_init()
943 efc_log_debug(hw->os, "rmvd %d items from io_inuse list\n", in efct_hw_init()
947 while ((!list_empty(&hw->io_free))) { in efct_hw_init()
949 temp = list_first_entry(&hw->io_free, struct efct_hw_io, in efct_hw_init()
951 list_del_init(&temp->list_entry); in efct_hw_init()
954 efc_log_debug(hw->os, "rmvd %d items from io_free list\n", in efct_hw_init()
958 if (hw->config.n_rq == 1) in efct_hw_init()
959 hw->sli.features &= (~SLI4_REQFEAT_MRQP); in efct_hw_init()
961 if (sli_init(&hw->sli)) { in efct_hw_init()
962 efc_log_err(hw->os, "SLI failed to initialize\n"); in efct_hw_init()
963 return -EIO; in efct_hw_init()
966 if (hw->sliport_healthcheck) { in efct_hw_init()
969 efc_log_err(hw->os, "Enable port Health check fail\n"); in efct_hw_init()
977 if (hw->sli.if_type == SLI4_INTF_IF_TYPE_2) { in efct_hw_init()
979 * Non-fatal error. In particular, we can disregard failure to in efct_hw_init()
987 memset(hw->cq_hash, 0, sizeof(hw->cq_hash)); in efct_hw_init()
988 efc_log_debug(hw->os, "Max CQs %d, hash size = %d\n", in efct_hw_init()
991 memset(hw->rq_hash, 0, sizeof(hw->rq_hash)); in efct_hw_init()
992 efc_log_debug(hw->os, "Max RQs %d, hash size = %d\n", in efct_hw_init()
995 memset(hw->wq_hash, 0, sizeof(hw->wq_hash)); in efct_hw_init()
996 efc_log_debug(hw->os, "Max WQs %d, hash size = %d\n", in efct_hw_init()
1010 efc_log_err(hw->os, "rx_allocate failed\n"); in efct_hw_init()
1016 efc_log_err(hw->os, "WARNING - error posting RQ buffers\n"); in efct_hw_init()
1020 if (hw->config.n_eq == 1) { in efct_hw_init()
1023 efc_log_err(hw->os, "config rq failed %d\n", rc); in efct_hw_init()
1029 efc_log_err(hw->os, "REG_FCFI_MRQ FCFI reg failed\n"); in efct_hw_init()
1035 efc_log_err(hw->os, "REG_FCFI_MRQ MRQ reg failed\n"); in efct_hw_init()
1045 hw->wq_reqtag_pool = efct_hw_reqtag_pool_alloc(hw); in efct_hw_init()
1046 if (!hw->wq_reqtag_pool) { in efct_hw_init()
1047 efc_log_err(hw->os, "efct_hw_reqtag_pool_alloc failed\n"); in efct_hw_init()
1048 return -ENOMEM; in efct_hw_init()
1053 efc_log_err(hw->os, "IO allocation failure\n"); in efct_hw_init()
1059 efc_log_err(hw->os, "IO initialization failure\n"); in efct_hw_init()
1063 dma = &hw->loop_map; in efct_hw_init()
1064 dma->size = SLI4_MIN_LOOP_MAP_BYTES; in efct_hw_init()
1065 dma->virt = dma_alloc_coherent(&hw->os->pci->dev, dma->size, &dma->phys, in efct_hw_init()
1067 if (!dma->virt) in efct_hw_init()
1068 return -EIO; in efct_hw_init()
1074 for (i = 0; i < hw->eq_count; i++) in efct_hw_init()
1075 sli_queue_arm(&hw->sli, &hw->eq[i], true); in efct_hw_init()
1080 for (i = 0; i < hw->rq_count; i++) in efct_hw_init()
1081 efct_hw_queue_hash_add(hw->rq_hash, hw->rq[i].id, i); in efct_hw_init()
1086 for (i = 0; i < hw->wq_count; i++) in efct_hw_init()
1087 efct_hw_queue_hash_add(hw->wq_hash, hw->wq[i].id, i); in efct_hw_init()
1092 for (i = 0; i < hw->cq_count; i++) { in efct_hw_init()
1093 efct_hw_queue_hash_add(hw->cq_hash, hw->cq[i].id, i); in efct_hw_init()
1094 sli_queue_arm(&hw->sli, &hw->cq[i], true); in efct_hw_init()
1098 for (i = 0; i < hw->hw_rq_count; i++) { in efct_hw_init()
1099 struct hw_rq *rq = hw->hw_rq[i]; in efct_hw_init()
1101 hw->cq[rq->cq->instance].proc_limit = hw->config.n_io / 2; in efct_hw_init()
1105 hw->state = EFCT_HW_STATE_ACTIVE; in efct_hw_init()
1109 hw->hw_wq[0]->send_frame_io = efct_hw_io_alloc(hw); in efct_hw_init()
1110 if (!hw->hw_wq[0]->send_frame_io) in efct_hw_init()
1111 efc_log_err(hw->os, "alloc for send_frame_io failed\n"); in efct_hw_init()
1114 atomic_set(&hw->send_frame_seq_id, 0); in efct_hw_init()
1127 for (idx = 0; idx < ARRAY_SIZE(hw->config.filter_def); idx++) in efct_hw_parse_filter()
1128 hw->config.filter_def[idx] = 0; in efct_hw_parse_filter()
1132 efc_log_err(hw->os, "p is NULL\n"); in efct_hw_parse_filter()
1133 return -ENOMEM; in efct_hw_parse_filter()
1139 if (kstrtou32(token, 0, &hw->config.filter_def[idx++])) in efct_hw_parse_filter()
1140 efc_log_err(hw->os, "kstrtoint failed\n"); in efct_hw_parse_filter()
1145 if (idx == ARRAY_SIZE(hw->config.filter_def)) in efct_hw_parse_filter()
1156 struct sli4 *sli = &hw->sli; in efct_get_wwnn()
1159 memcpy(p, sli->wwnn, sizeof(p)); in efct_get_wwnn()
1166 struct sli4 *sli = &hw->sli; in efct_get_wwpn()
1169 memcpy(p, sli->wwpn, sizeof(p)); in efct_get_wwpn()
1177 struct efct *efct = hw->os; in efct_hw_rx_buffer_alloc()
1191 prq->rqindex = rqindex; in efct_hw_rx_buffer_alloc()
1192 prq->dma.size = size; in efct_hw_rx_buffer_alloc()
1193 prq->dma.virt = dma_alloc_coherent(&efct->pci->dev, in efct_hw_rx_buffer_alloc()
1194 prq->dma.size, in efct_hw_rx_buffer_alloc()
1195 &prq->dma.phys, in efct_hw_rx_buffer_alloc()
1197 if (!prq->dma.virt) { in efct_hw_rx_buffer_alloc()
1198 efc_log_err(hw->os, "DMA allocation failed\n"); in efct_hw_rx_buffer_alloc()
1211 struct efct *efct = hw->os; in efct_hw_rx_buffer_free()
1217 dma_free_coherent(&efct->pci->dev, in efct_hw_rx_buffer_free()
1218 prq->dma.size, prq->dma.virt, in efct_hw_rx_buffer_free()
1219 prq->dma.phys); in efct_hw_rx_buffer_free()
1220 memset(&prq->dma, 0, sizeof(struct efc_dma)); in efct_hw_rx_buffer_free()
1230 struct efct *efct = hw->os; in efct_hw_rx_allocate()
1235 u32 payload_size = hw->config.rq_default_buffer_size; in efct_hw_rx_allocate()
1239 for (i = 0; i < hw->hw_rq_count; i++) { in efct_hw_rx_allocate()
1240 struct hw_rq *rq = hw->hw_rq[i]; in efct_hw_rx_allocate()
1243 rq->hdr_buf = efct_hw_rx_buffer_alloc(hw, rqindex, in efct_hw_rx_allocate()
1244 rq->entry_count, in efct_hw_rx_allocate()
1246 if (!rq->hdr_buf) { in efct_hw_rx_allocate()
1248 rc = -EIO; in efct_hw_rx_allocate()
1252 efc_log_debug(hw->os, in efct_hw_rx_allocate()
1254 i, rq->hdr->id, rq->entry_count, hdr_size); in efct_hw_rx_allocate()
1259 rq->payload_buf = efct_hw_rx_buffer_alloc(hw, rqindex, in efct_hw_rx_allocate()
1260 rq->entry_count, in efct_hw_rx_allocate()
1262 if (!rq->payload_buf) { in efct_hw_rx_allocate()
1264 rc = -EIO; in efct_hw_rx_allocate()
1267 efc_log_debug(hw->os, in efct_hw_rx_allocate()
1269 i, rq->data->id, rq->entry_count, payload_size); in efct_hw_rx_allocate()
1273 return rc ? -EIO : 0; in efct_hw_rx_allocate()
1284 if (!hw->seq_pool) { in efct_hw_rx_post()
1287 for (i = 0; i < hw->hw_rq_count; i++) in efct_hw_rx_post()
1288 count += hw->hw_rq[i]->entry_count; in efct_hw_rx_post()
1290 hw->seq_pool = kmalloc_array(count, in efct_hw_rx_post()
1292 if (!hw->seq_pool) in efct_hw_rx_post()
1293 return -ENOMEM; in efct_hw_rx_post()
1300 for (rq_idx = 0, idx = 0; rq_idx < hw->hw_rq_count; rq_idx++) { in efct_hw_rx_post()
1301 struct hw_rq *rq = hw->hw_rq[rq_idx]; in efct_hw_rx_post()
1303 for (i = 0; i < rq->entry_count - 1; i++) { in efct_hw_rx_post()
1306 seq = hw->seq_pool + idx; in efct_hw_rx_post()
1308 seq->header = &rq->hdr_buf[i]; in efct_hw_rx_post()
1309 seq->payload = &rq->payload_buf[i]; in efct_hw_rx_post()
1318 if (rc && hw->seq_pool) in efct_hw_rx_post()
1319 kfree(hw->seq_pool); in efct_hw_rx_post()
1330 for (i = 0; i < hw->hw_rq_count; i++) { in efct_hw_rx_free()
1331 struct hw_rq *rq = hw->hw_rq[i]; in efct_hw_rx_free()
1334 efct_hw_rx_buffer_free(hw, rq->hdr_buf, in efct_hw_rx_free()
1335 rq->entry_count); in efct_hw_rx_free()
1336 rq->hdr_buf = NULL; in efct_hw_rx_free()
1337 efct_hw_rx_buffer_free(hw, rq->payload_buf, in efct_hw_rx_free()
1338 rq->entry_count); in efct_hw_rx_free()
1339 rq->payload_buf = NULL; in efct_hw_rx_free()
1352 while (hw->cmd_head_count < (EFCT_HW_MQ_DEPTH - 1) && in efct_hw_cmd_submit_pending()
1353 !list_empty(&hw->cmd_pending)) { in efct_hw_cmd_submit_pending()
1356 ctx = list_first_entry(&hw->cmd_pending, in efct_hw_cmd_submit_pending()
1361 list_del_init(&ctx->list_entry); in efct_hw_cmd_submit_pending()
1363 list_add_tail(&ctx->list_entry, &hw->cmd_head); in efct_hw_cmd_submit_pending()
1364 hw->cmd_head_count++; in efct_hw_cmd_submit_pending()
1365 if (sli_mq_write(&hw->sli, hw->mq, ctx->buf) < 0) { in efct_hw_cmd_submit_pending()
1366 efc_log_debug(hw->os, in efct_hw_cmd_submit_pending()
1368 rc = -EIO; in efct_hw_cmd_submit_pending()
1378 int rc = -EIO; in efct_hw_command()
1386 if (sli_fw_error_status(&hw->sli) > 0) { in efct_hw_command()
1387 efc_log_crit(hw->os, "Chip in an error state - reset needed\n"); in efct_hw_command()
1388 efc_log_crit(hw->os, "status=%#x error1=%#x error2=%#x\n", in efct_hw_command()
1389 sli_reg_read_status(&hw->sli), in efct_hw_command()
1390 sli_reg_read_err1(&hw->sli), in efct_hw_command()
1391 sli_reg_read_err2(&hw->sli)); in efct_hw_command()
1393 return -EIO; in efct_hw_command()
1403 mutex_lock(&hw->bmbx_lock); in efct_hw_command()
1404 bmbx = hw->sli.bmbx.virt; in efct_hw_command()
1408 if (sli_bmbx_command(&hw->sli) == 0) { in efct_hw_command()
1412 mutex_unlock(&hw->bmbx_lock); in efct_hw_command()
1416 if (hw->state != EFCT_HW_STATE_ACTIVE) { in efct_hw_command()
1417 efc_log_err(hw->os, "Can't send command, HW state=%d\n", in efct_hw_command()
1418 hw->state); in efct_hw_command()
1419 return -EIO; in efct_hw_command()
1422 ctx = mempool_alloc(hw->cmd_ctx_pool, GFP_ATOMIC); in efct_hw_command()
1424 return -ENOSPC; in efct_hw_command()
1429 ctx->cb = cb; in efct_hw_command()
1430 ctx->arg = arg; in efct_hw_command()
1433 memcpy(ctx->buf, cmd, SLI4_BMBX_SIZE); in efct_hw_command()
1434 ctx->ctx = hw; in efct_hw_command()
1436 spin_lock_irqsave(&hw->cmd_lock, flags); in efct_hw_command()
1439 INIT_LIST_HEAD(&ctx->list_entry); in efct_hw_command()
1440 list_add_tail(&ctx->list_entry, &hw->cmd_pending); in efct_hw_command()
1445 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_command()
1458 spin_lock_irqsave(&hw->cmd_lock, flags); in efct_hw_command_process()
1459 if (!list_empty(&hw->cmd_head)) { in efct_hw_command_process()
1460 ctx = list_first_entry(&hw->cmd_head, in efct_hw_command_process()
1462 list_del_init(&ctx->list_entry); in efct_hw_command_process()
1465 efc_log_err(hw->os, "no command context\n"); in efct_hw_command_process()
1466 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_command_process()
1467 return -EIO; in efct_hw_command_process()
1470 hw->cmd_head_count--; in efct_hw_command_process()
1475 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_command_process()
1477 if (ctx->cb) { in efct_hw_command_process()
1478 memcpy(ctx->buf, mqe, size); in efct_hw_command_process()
1479 ctx->cb(hw, status, ctx->buf, ctx->arg); in efct_hw_command_process()
1482 mempool_free(ctx, hw->cmd_ctx_pool); in efct_hw_command_process()
1494 rc = sli_mq_read(&hw->sli, mq, mqe); in efct_hw_mq_process()
1496 rc = efct_hw_command_process(hw, status, mqe, mq->size); in efct_hw_mq_process()
1507 spin_lock_irqsave(&hw->cmd_lock, flags); in efct_hw_command_cancel()
1514 while (!list_empty(&hw->cmd_head)) { in efct_hw_command_cancel()
1518 ctx = list_first_entry(&hw->cmd_head, in efct_hw_command_cancel()
1521 efc_log_debug(hw->os, "hung command %08x\n", in efct_hw_command_cancel()
1522 !ctx ? U32_MAX : *((u32 *)ctx->buf)); in efct_hw_command_cancel()
1523 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_command_cancel()
1524 rc = efct_hw_command_process(hw, -1, mqe, SLI4_BMBX_SIZE); in efct_hw_command_cancel()
1525 spin_lock_irqsave(&hw->cmd_lock, flags); in efct_hw_command_cancel()
1528 spin_unlock_irqrestore(&hw->cmd_lock, flags); in efct_hw_command_cancel()
1539 if (ctx->callback) in efct_mbox_rsp_cb()
1540 (*ctx->callback)(hw->os->efcport, status, mqe, in efct_mbox_rsp_cb()
1541 ctx->arg); in efct_mbox_rsp_cb()
1543 mempool_free(ctx, hw->mbox_rqst_pool); in efct_mbox_rsp_cb()
1552 struct efct_hw *hw = &efct->hw; in efct_issue_mbox_rqst()
1560 ctx = mempool_alloc(hw->mbox_rqst_pool, GFP_ATOMIC); in efct_issue_mbox_rqst()
1562 return -EIO; in efct_issue_mbox_rqst()
1564 ctx->callback = cb; in efct_issue_mbox_rqst()
1565 ctx->arg = arg; in efct_issue_mbox_rqst()
1570 mempool_free(ctx, hw->mbox_rqst_pool); in efct_issue_mbox_rqst()
1571 return -EIO; in efct_issue_mbox_rqst()
1582 if (!list_empty(&hw->io_free)) { in _efct_hw_io_alloc()
1583 io = list_first_entry(&hw->io_free, struct efct_hw_io, in _efct_hw_io_alloc()
1585 list_del(&io->list_entry); in _efct_hw_io_alloc()
1588 INIT_LIST_HEAD(&io->list_entry); in _efct_hw_io_alloc()
1589 list_add_tail(&io->list_entry, &hw->io_inuse); in _efct_hw_io_alloc()
1590 io->state = EFCT_HW_IO_STATE_INUSE; in _efct_hw_io_alloc()
1591 io->abort_reqtag = U32_MAX; in _efct_hw_io_alloc()
1592 io->wq = hw->wq_cpu_array[raw_smp_processor_id()]; in _efct_hw_io_alloc()
1593 if (!io->wq) { in _efct_hw_io_alloc()
1594 efc_log_err(hw->os, "WQ not assigned for cpu:%d\n", in _efct_hw_io_alloc()
1596 io->wq = hw->hw_wq[0]; in _efct_hw_io_alloc()
1598 kref_init(&io->ref); in _efct_hw_io_alloc()
1599 io->release = efct_hw_io_free_internal; in _efct_hw_io_alloc()
1601 atomic_add(1, &hw->io_alloc_failed_count); in _efct_hw_io_alloc()
1613 spin_lock_irqsave(&hw->io_lock, flags); in efct_hw_io_alloc()
1615 spin_unlock_irqrestore(&hw->io_lock, flags); in efct_hw_io_alloc()
1628 if (io->xbusy) { in efct_hw_io_free_move_correct_list()
1633 INIT_LIST_HEAD(&io->list_entry); in efct_hw_io_free_move_correct_list()
1634 list_add_tail(&io->list_entry, &hw->io_wait_free); in efct_hw_io_free_move_correct_list()
1635 io->state = EFCT_HW_IO_STATE_WAIT_FREE; in efct_hw_io_free_move_correct_list()
1638 INIT_LIST_HEAD(&io->list_entry); in efct_hw_io_free_move_correct_list()
1639 list_add_tail(&io->list_entry, &hw->io_free); in efct_hw_io_free_move_correct_list()
1640 io->state = EFCT_HW_IO_STATE_FREE; in efct_hw_io_free_move_correct_list()
1659 struct efct_hw *hw = io->hw; in efct_hw_io_free_internal()
1664 spin_lock_irqsave(&hw->io_lock, flags); in efct_hw_io_free_internal()
1665 /* remove from in-use list */ in efct_hw_io_free_internal()
1666 if (!list_empty(&io->list_entry) && !list_empty(&hw->io_inuse)) { in efct_hw_io_free_internal()
1667 list_del_init(&io->list_entry); in efct_hw_io_free_internal()
1670 spin_unlock_irqrestore(&hw->io_lock, flags); in efct_hw_io_free_internal()
1676 return kref_put(&io->ref, io->release); in efct_hw_io_free()
1684 ioindex = xri - hw->sli.ext[SLI4_RSRC_XRI].base[0]; in efct_hw_io_lookup()
1685 return hw->io[ioindex]; in efct_hw_io_lookup()
1698 efc_log_err(hw->os, "bad parameter hw=%p io=%p\n", hw, io); in efct_hw_io_init_sges()
1699 return -EIO; in efct_hw_io_init_sges()
1702 /* Clear / reset the scatter-gather list */ in efct_hw_io_init_sges()
1703 io->sgl = &io->def_sgl; in efct_hw_io_init_sges()
1704 io->sgl_count = io->def_sgl_count; in efct_hw_io_init_sges()
1705 io->first_data_sge = 0; in efct_hw_io_init_sges()
1707 memset(io->sgl->virt, 0, 2 * sizeof(struct sli4_sge)); in efct_hw_io_init_sges()
1708 io->n_sge = 0; in efct_hw_io_init_sges()
1709 io->sge_offset = 0; in efct_hw_io_init_sges()
1711 io->type = type; in efct_hw_io_init_sges()
1713 data = io->sgl->virt; in efct_hw_io_init_sges()
1723 sge_flags = le32_to_cpu(data->dw2_flags); in efct_hw_io_init_sges()
1726 data->buffer_address_high = in efct_hw_io_init_sges()
1727 cpu_to_le32(upper_32_bits(io->xfer_rdy.phys)); in efct_hw_io_init_sges()
1728 data->buffer_address_low = in efct_hw_io_init_sges()
1729 cpu_to_le32(lower_32_bits(io->xfer_rdy.phys)); in efct_hw_io_init_sges()
1730 data->buffer_length = cpu_to_le32(io->xfer_rdy.size); in efct_hw_io_init_sges()
1731 data->dw2_flags = cpu_to_le32(sge_flags); in efct_hw_io_init_sges()
1736 io->n_sge = 1; in efct_hw_io_init_sges()
1750 efc_log_err(hw->os, "unsupported IO type %#x\n", type); in efct_hw_io_init_sges()
1751 return -EIO; in efct_hw_io_init_sges()
1758 sge_flags = le32_to_cpu(data->dw2_flags); in efct_hw_io_init_sges()
1761 data->dw2_flags = cpu_to_le32(sge_flags); in efct_hw_io_init_sges()
1765 io->n_sge += skips; in efct_hw_io_init_sges()
1770 sge_flags = le32_to_cpu(data->dw2_flags); in efct_hw_io_init_sges()
1772 data->dw2_flags = cpu_to_le32(sge_flags); in efct_hw_io_init_sges()
1785 efc_log_err(hw->os, in efct_hw_io_add_sge()
1788 return -EIO; in efct_hw_io_add_sge()
1791 if (length > hw->sli.sge_supported_length) { in efct_hw_io_add_sge()
1792 efc_log_err(hw->os, in efct_hw_io_add_sge()
1794 length, hw->sli.sge_supported_length); in efct_hw_io_add_sge()
1795 return -EIO; in efct_hw_io_add_sge()
1798 data = io->sgl->virt; in efct_hw_io_add_sge()
1799 data += io->n_sge; in efct_hw_io_add_sge()
1801 sge_flags = le32_to_cpu(data->dw2_flags); in efct_hw_io_add_sge()
1805 sge_flags |= SLI4_SGE_DATA_OFFSET_MASK & io->sge_offset; in efct_hw_io_add_sge()
1807 data->buffer_address_high = cpu_to_le32(upper_32_bits(addr)); in efct_hw_io_add_sge()
1808 data->buffer_address_low = cpu_to_le32(lower_32_bits(addr)); in efct_hw_io_add_sge()
1809 data->buffer_length = cpu_to_le32(length); in efct_hw_io_add_sge()
1817 data->dw2_flags = cpu_to_le32(sge_flags); in efct_hw_io_add_sge()
1819 if (io->n_sge) { in efct_hw_io_add_sge()
1820 sge_flags = le32_to_cpu(data[-1].dw2_flags); in efct_hw_io_add_sge()
1822 data[-1].dw2_flags = cpu_to_le32(sge_flags); in efct_hw_io_add_sge()
1826 if (io->first_data_sge == 0) in efct_hw_io_add_sge()
1827 io->first_data_sge = io->n_sge; in efct_hw_io_add_sge()
1829 io->sge_offset += length; in efct_hw_io_add_sge()
1830 io->n_sge++; in efct_hw_io_add_sge()
1842 &hw->io_inuse, list_entry) { in efct_hw_io_abort_all()
1851 struct efct_hw *hw = io->hw; in efct_hw_wq_process_abort()
1852 u32 ext = 0; in efct_hw_wq_process_abort() local
1862 ext = sli_fc_ext_status(&hw->sli, cqe); in efct_hw_wq_process_abort()
1864 ext == SLI4_FC_LOCAL_REJECT_NO_XRI && io->done) { in efct_hw_wq_process_abort()
1865 efct_hw_done_t done = io->done; in efct_hw_wq_process_abort()
1867 io->done = NULL; in efct_hw_wq_process_abort()
1873 * clobbering the len, status and ext fields. in efct_hw_wq_process_abort()
1875 status = io->saved_status; in efct_hw_wq_process_abort()
1876 len = io->saved_len; in efct_hw_wq_process_abort()
1877 ext = io->saved_ext; in efct_hw_wq_process_abort()
1878 io->status_saved = false; in efct_hw_wq_process_abort()
1879 done(io, len, status, ext, io->arg); in efct_hw_wq_process_abort()
1882 if (io->abort_done) { in efct_hw_wq_process_abort()
1883 efct_hw_done_t done = io->abort_done; in efct_hw_wq_process_abort()
1885 io->abort_done = NULL; in efct_hw_wq_process_abort()
1886 done(io, len, status, ext, io->abort_arg); in efct_hw_wq_process_abort()
1890 io->abort_in_progress = false; in efct_hw_wq_process_abort()
1893 if (io->abort_reqtag == U32_MAX) { in efct_hw_wq_process_abort()
1894 efc_log_err(hw->os, "HW IO already freed\n"); in efct_hw_wq_process_abort()
1898 wqcb = efct_hw_reqtag_get_instance(hw, io->abort_reqtag); in efct_hw_wq_process_abort()
1911 struct sli4_abort_wqe *abort = (void *)wqe->wqebuf; in efct_hw_fill_abort_wqe()
1913 memset(abort, 0, hw->sli.wqe_size); in efct_hw_fill_abort_wqe()
1915 abort->criteria = SLI4_ABORT_CRITERIA_XRI_TAG; in efct_hw_fill_abort_wqe()
1916 abort->ia_ir_byte |= wqe->send_abts ? 0 : 1; in efct_hw_fill_abort_wqe()
1919 abort->ia_ir_byte |= SLI4_ABRT_WQE_IR; in efct_hw_fill_abort_wqe()
1921 abort->t_tag = cpu_to_le32(wqe->id); in efct_hw_fill_abort_wqe()
1922 abort->command = SLI4_WQE_ABORT; in efct_hw_fill_abort_wqe()
1923 abort->request_tag = cpu_to_le16(wqe->abort_reqtag); in efct_hw_fill_abort_wqe()
1925 abort->dw10w0_flags = cpu_to_le16(SLI4_ABRT_WQE_QOSD); in efct_hw_fill_abort_wqe()
1927 abort->cq_id = cpu_to_le16(SLI4_CQ_DEFAULT); in efct_hw_fill_abort_wqe()
1938 efc_log_err(hw->os, "bad parameter hw=%p io=%p\n", in efct_hw_io_abort()
1940 return -EIO; in efct_hw_io_abort()
1943 if (hw->state != EFCT_HW_STATE_ACTIVE) { in efct_hw_io_abort()
1944 efc_log_err(hw->os, "cannot send IO abort, HW state=%d\n", in efct_hw_io_abort()
1945 hw->state); in efct_hw_io_abort()
1946 return -EIO; in efct_hw_io_abort()
1950 if (kref_get_unless_zero(&io_to_abort->ref) == 0) { in efct_hw_io_abort()
1952 efc_log_debug(hw->os, in efct_hw_io_abort()
1954 io_to_abort->indicator, io_to_abort->reqtag); in efct_hw_io_abort()
1955 return -ENOENT; in efct_hw_io_abort()
1959 if (!io_to_abort->wq) { in efct_hw_io_abort()
1960 efc_log_debug(hw->os, "io_to_abort xri=0x%x not active on WQ\n", in efct_hw_io_abort()
1961 io_to_abort->indicator); in efct_hw_io_abort()
1963 kref_put(&io_to_abort->ref, io_to_abort->release); in efct_hw_io_abort()
1964 return -ENOENT; in efct_hw_io_abort()
1971 if (cmpxchg(&io_to_abort->abort_in_progress, false, true)) { in efct_hw_io_abort()
1973 kref_put(&io_to_abort->ref, io_to_abort->release); in efct_hw_io_abort()
1974 efc_log_debug(hw->os, in efct_hw_io_abort()
1976 io_to_abort->indicator, io_to_abort->reqtag); in efct_hw_io_abort()
1977 return -EINPROGRESS; in efct_hw_io_abort()
1982 * - host owned xri in efct_hw_io_abort()
1983 * - io_to_abort->wq_index != U32_MAX in efct_hw_io_abort()
1984 * - submit ABORT_WQE to same WQ in efct_hw_io_abort()
1985 * - port owned xri: in efct_hw_io_abort()
1986 * - rxri: io_to_abort->wq_index == U32_MAX in efct_hw_io_abort()
1987 * - submit ABORT_WQE to any WQ in efct_hw_io_abort()
1988 * - non-rxri in efct_hw_io_abort()
1989 * - io_to_abort->index != U32_MAX in efct_hw_io_abort()
1990 * - submit ABORT_WQE to same WQ in efct_hw_io_abort()
1991 * - io_to_abort->index == U32_MAX in efct_hw_io_abort()
1992 * - submit ABORT_WQE to any WQ in efct_hw_io_abort()
1994 io_to_abort->abort_done = cb; in efct_hw_io_abort()
1995 io_to_abort->abort_arg = arg; in efct_hw_io_abort()
2000 efc_log_err(hw->os, "can't allocate request tag\n"); in efct_hw_io_abort()
2001 return -ENOSPC; in efct_hw_io_abort()
2004 io_to_abort->abort_reqtag = wqcb->instance_index; in efct_hw_io_abort()
2005 io_to_abort->wqe.send_abts = send_abts; in efct_hw_io_abort()
2006 io_to_abort->wqe.id = io_to_abort->indicator; in efct_hw_io_abort()
2007 io_to_abort->wqe.abort_reqtag = io_to_abort->abort_reqtag; in efct_hw_io_abort()
2013 if (io_to_abort->wq) { in efct_hw_io_abort()
2014 spin_lock_irqsave(&io_to_abort->wq->queue->lock, flags); in efct_hw_io_abort()
2015 if (io_to_abort->wqe.list_entry.next) { in efct_hw_io_abort()
2016 io_to_abort->wqe.abort_wqe_submit_needed = true; in efct_hw_io_abort()
2017 spin_unlock_irqrestore(&io_to_abort->wq->queue->lock, in efct_hw_io_abort()
2021 spin_unlock_irqrestore(&io_to_abort->wq->queue->lock, flags); in efct_hw_io_abort()
2024 efct_hw_fill_abort_wqe(hw, &io_to_abort->wqe); in efct_hw_io_abort()
2027 * therefore, keep xbusy as-is to track the exchange's state, in efct_hw_io_abort()
2030 if (efct_hw_wq_write(io_to_abort->wq, &io_to_abort->wqe)) { in efct_hw_io_abort()
2031 io_to_abort->abort_in_progress = false; in efct_hw_io_abort()
2033 kref_put(&io_to_abort->ref, io_to_abort->release); in efct_hw_io_abort()
2034 return -EIO; in efct_hw_io_abort()
2044 struct reqtag_pool *reqtag_pool = hw->wq_reqtag_pool; in efct_hw_reqtag_pool_free()
2049 wqcb = reqtag_pool->tags[i]; in efct_hw_reqtag_pool_free()
2056 hw->wq_reqtag_pool = NULL; in efct_hw_reqtag_pool_free()
2071 INIT_LIST_HEAD(&reqtag_pool->freelist); in efct_hw_reqtag_pool_alloc()
2073 spin_lock_init(&reqtag_pool->lock); in efct_hw_reqtag_pool_alloc()
2079 reqtag_pool->tags[i] = wqcb; in efct_hw_reqtag_pool_alloc()
2080 wqcb->instance_index = i; in efct_hw_reqtag_pool_alloc()
2081 wqcb->callback = NULL; in efct_hw_reqtag_pool_alloc()
2082 wqcb->arg = NULL; in efct_hw_reqtag_pool_alloc()
2083 INIT_LIST_HEAD(&wqcb->list_entry); in efct_hw_reqtag_pool_alloc()
2084 list_add_tail(&wqcb->list_entry, &reqtag_pool->freelist); in efct_hw_reqtag_pool_alloc()
2096 struct reqtag_pool *reqtag_pool = hw->wq_reqtag_pool; in efct_hw_reqtag_alloc()
2102 spin_lock_irqsave(&reqtag_pool->lock, flags); in efct_hw_reqtag_alloc()
2104 if (!list_empty(&reqtag_pool->freelist)) { in efct_hw_reqtag_alloc()
2105 wqcb = list_first_entry(&reqtag_pool->freelist, in efct_hw_reqtag_alloc()
2110 list_del_init(&wqcb->list_entry); in efct_hw_reqtag_alloc()
2111 spin_unlock_irqrestore(&reqtag_pool->lock, flags); in efct_hw_reqtag_alloc()
2112 wqcb->callback = callback; in efct_hw_reqtag_alloc()
2113 wqcb->arg = arg; in efct_hw_reqtag_alloc()
2115 spin_unlock_irqrestore(&reqtag_pool->lock, flags); in efct_hw_reqtag_alloc()
2125 struct reqtag_pool *reqtag_pool = hw->wq_reqtag_pool; in efct_hw_reqtag_free()
2127 if (!wqcb->callback) in efct_hw_reqtag_free()
2128 efc_log_err(hw->os, "WQCB is already freed\n"); in efct_hw_reqtag_free()
2130 spin_lock_irqsave(&reqtag_pool->lock, flags); in efct_hw_reqtag_free()
2131 wqcb->callback = NULL; in efct_hw_reqtag_free()
2132 wqcb->arg = NULL; in efct_hw_reqtag_free()
2133 INIT_LIST_HEAD(&wqcb->list_entry); in efct_hw_reqtag_free()
2134 list_add(&wqcb->list_entry, &hw->wq_reqtag_pool->freelist); in efct_hw_reqtag_free()
2135 spin_unlock_irqrestore(&reqtag_pool->lock, flags); in efct_hw_reqtag_free()
2143 wqcb = hw->wq_reqtag_pool->tags[instance_index]; in efct_hw_reqtag_get_instance()
2145 efc_log_err(hw->os, "wqcb for instance %d is null\n", in efct_hw_reqtag_get_instance()
2154 int index = -1; in efct_hw_queue_hash_find()
2155 int i = id & (EFCT_HW_Q_HASH_SIZE - 1); in efct_hw_queue_hash_find()
2166 i = (i + 1) & (EFCT_HW_Q_HASH_SIZE - 1); in efct_hw_queue_hash_find()
2167 } while (index == -1 && hash[i].in_use); in efct_hw_queue_hash_find()
2181 * EFCT_HW_STATE_UNINITIALIZED - No queues allocated in efct_hw_process()
2182 * EFCT_HW_STATE_QUEUES_ALLOCATED - The state after a chip reset, in efct_hw_process()
2184 * EFCT_HW_STATE_ACTIVE - Chip and queues are operational in efct_hw_process()
2185 * EFCT_HW_STATE_RESET_IN_PROGRESS - reset, we still want completions in efct_hw_process()
2186 * EFCT_HW_STATE_TEARDOWN_IN_PROGRESS - We still want mailbox in efct_hw_process()
2189 if (hw->state == EFCT_HW_STATE_UNINITIALIZED) in efct_hw_process()
2193 eq = hw->hw_eq[vector]; in efct_hw_process()
2197 eq->use_count++; in efct_hw_process()
2215 while (!done && !sli_eq_read(&hw->sli, eq->queue, eqe)) { in efct_hw_eq_process()
2219 rc = sli_eq_parse(&hw->sli, eqe, &cq_id); in efct_hw_eq_process()
2228 for (i = 0; i < hw->cq_count; i++) in efct_hw_eq_process()
2229 efct_hw_cq_process(hw, hw->hw_cq[i]); in efct_hw_eq_process()
2237 index = efct_hw_queue_hash_find(hw->cq_hash, cq_id); in efct_hw_eq_process()
2240 efct_hw_cq_process(hw, hw->hw_cq[index]); in efct_hw_eq_process()
2242 efc_log_err(hw->os, "bad CQ_ID %#06x\n", cq_id); in efct_hw_eq_process()
2245 if (eq->queue->n_posted > eq->queue->posted_limit) in efct_hw_eq_process()
2246 sli_queue_arm(&hw->sli, eq->queue, false); in efct_hw_eq_process()
2248 if (tcheck_count && (--tcheck_count == 0)) { in efct_hw_eq_process()
2250 telapsed = jiffies_to_msecs(jiffies) - tstart; in efct_hw_eq_process()
2255 sli_queue_eq_arm(&hw->sli, eq->queue, true); in efct_hw_eq_process()
2266 if (wq->wqec_count) in _efct_hw_wq_write()
2267 wq->wqec_count--; in _efct_hw_wq_write()
2269 if (wq->wqec_count == 0) { in _efct_hw_wq_write()
2270 struct sli4_generic_wqe *genwqe = (void *)wqe->wqebuf; in _efct_hw_wq_write()
2272 genwqe->cmdtype_wqec_byte |= SLI4_GEN_WQE_WQEC; in _efct_hw_wq_write()
2273 wq->wqec_count = wq->wqec_set_count; in _efct_hw_wq_write()
2277 wq->free_count--; in _efct_hw_wq_write()
2279 queue_rc = sli_wq_write(&wq->hw->sli, wq->queue, wqe->wqebuf); in _efct_hw_wq_write()
2281 return (queue_rc < 0) ? -EIO : 0; in _efct_hw_wq_write()
2290 spin_lock_irqsave(&wq->queue->lock, flags); in hw_wq_submit_pending()
2293 wq->free_count += update_free_count; in hw_wq_submit_pending()
2295 while ((wq->free_count > 0) && (!list_empty(&wq->pending_list))) { in hw_wq_submit_pending()
2296 wqe = list_first_entry(&wq->pending_list, in hw_wq_submit_pending()
2298 list_del_init(&wqe->list_entry); in hw_wq_submit_pending()
2301 if (wqe->abort_wqe_submit_needed) { in hw_wq_submit_pending()
2302 wqe->abort_wqe_submit_needed = false; in hw_wq_submit_pending()
2303 efct_hw_fill_abort_wqe(wq->hw, wqe); in hw_wq_submit_pending()
2304 INIT_LIST_HEAD(&wqe->list_entry); in hw_wq_submit_pending()
2305 list_add_tail(&wqe->list_entry, &wq->pending_list); in hw_wq_submit_pending()
2306 wq->wq_pending_count++; in hw_wq_submit_pending()
2310 spin_unlock_irqrestore(&wq->queue->lock, flags); in hw_wq_submit_pending()
2325 while (!sli_cq_read(&hw->sli, cq->queue, cqe)) { in efct_hw_cq_process()
2328 status = sli_cq_parse(&hw->sli, cq->queue, cqe, &ctype, &rid); in efct_hw_cq_process()
2351 sli_cqe_async(&hw->sli, cqe); in efct_hw_cq_process()
2358 efct_hw_mq_process(hw, status, hw->mq); in efct_hw_cq_process()
2368 index = efct_hw_queue_hash_find(hw->wq_hash, wq_id); in efct_hw_cq_process()
2371 wq = hw->hw_wq[index]; in efct_hw_cq_process()
2373 efc_log_err(hw->os, "bad WQ_ID %#06x\n", wq_id); in efct_hw_cq_process()
2377 hw_wq_submit_pending(wq, wq->wqec_set_count); in efct_hw_cq_process()
2390 efc_log_debug(hw->os, "unhandled ctype=%#x rid=%#x\n", in efct_hw_cq_process()
2396 if (n_processed == cq->queue->proc_limit) in efct_hw_cq_process()
2399 if (cq->queue->n_posted >= cq->queue->posted_limit) in efct_hw_cq_process()
2400 sli_queue_arm(&hw->sli, cq->queue, false); in efct_hw_cq_process()
2403 sli_queue_arm(&hw->sli, cq->queue, true); in efct_hw_cq_process()
2405 if (n_processed > cq->queue->max_num_processed) in efct_hw_cq_process()
2406 cq->queue->max_num_processed = n_processed; in efct_hw_cq_process()
2407 telapsed = jiffies_to_msecs(jiffies) - tstart; in efct_hw_cq_process()
2408 if (telapsed > cq->queue->max_process_time) in efct_hw_cq_process()
2409 cq->queue->max_process_time = telapsed; in efct_hw_cq_process()
2420 efc_log_err(hw->os, "reque xri failed, status = %d\n", in efct_hw_wq_process()
2427 efc_log_err(hw->os, "invalid request tag: x%x\n", rid); in efct_hw_wq_process()
2431 if (!wqcb->callback) { in efct_hw_wq_process()
2432 efc_log_err(hw->os, "wqcb callback is NULL\n"); in efct_hw_wq_process()
2436 (*wqcb->callback)(wqcb->arg, cqe, status); in efct_hw_wq_process()
2450 efc_log_err(hw->os, "xabt io lookup failed rid=%#x\n", rid); in efct_hw_xabt_process()
2454 if (!io->xbusy) in efct_hw_xabt_process()
2455 efc_log_debug(hw->os, "xabt io not busy rid=%#x\n", rid); in efct_hw_xabt_process()
2458 io->xbusy = false; in efct_hw_xabt_process()
2464 if (io->done) { in efct_hw_xabt_process()
2465 efct_hw_done_t done = io->done; in efct_hw_xabt_process()
2466 void *arg = io->arg; in efct_hw_xabt_process()
2472 int status = io->saved_status; in efct_hw_xabt_process()
2473 u32 len = io->saved_len; in efct_hw_xabt_process()
2474 u32 ext = io->saved_ext; in efct_hw_xabt_process() local
2476 io->done = NULL; in efct_hw_xabt_process()
2477 io->status_saved = false; in efct_hw_xabt_process()
2479 done(io, len, status, ext, arg); in efct_hw_xabt_process()
2482 spin_lock_irqsave(&hw->io_lock, flags); in efct_hw_xabt_process()
2483 if (io->state == EFCT_HW_IO_STATE_INUSE || in efct_hw_xabt_process()
2484 io->state == EFCT_HW_IO_STATE_WAIT_FREE) { in efct_hw_xabt_process()
2487 * if on in-use list, already marked as no longer busy; in efct_hw_xabt_process()
2490 if (io->state == EFCT_HW_IO_STATE_WAIT_FREE) { in efct_hw_xabt_process()
2491 io->state = EFCT_HW_IO_STATE_FREE; in efct_hw_xabt_process()
2492 list_del_init(&io->list_entry); in efct_hw_xabt_process()
2496 spin_unlock_irqrestore(&hw->io_lock, flags); in efct_hw_xabt_process()
2505 for (i = 0; i < hw->eq_count; i++) in efct_hw_flush()
2517 spin_lock_irqsave(&wq->queue->lock, flags); in efct_hw_wq_write()
2518 if (list_empty(&wq->pending_list)) { in efct_hw_wq_write()
2519 if (wq->free_count > 0) { in efct_hw_wq_write()
2522 INIT_LIST_HEAD(&wqe->list_entry); in efct_hw_wq_write()
2523 list_add_tail(&wqe->list_entry, &wq->pending_list); in efct_hw_wq_write()
2524 wq->wq_pending_count++; in efct_hw_wq_write()
2527 spin_unlock_irqrestore(&wq->queue->lock, flags); in efct_hw_wq_write()
2531 INIT_LIST_HEAD(&wqe->list_entry); in efct_hw_wq_write()
2532 list_add_tail(&wqe->list_entry, &wq->pending_list); in efct_hw_wq_write()
2533 wq->wq_pending_count++; in efct_hw_wq_write()
2534 while (wq->free_count > 0) { in efct_hw_wq_write()
2535 wqe = list_first_entry(&wq->pending_list, struct efct_hw_wqe, in efct_hw_wq_write()
2540 list_del_init(&wqe->list_entry); in efct_hw_wq_write()
2545 if (wqe->abort_wqe_submit_needed) { in efct_hw_wq_write()
2546 wqe->abort_wqe_submit_needed = false; in efct_hw_wq_write()
2547 efct_hw_fill_abort_wqe(wq->hw, wqe); in efct_hw_wq_write()
2549 INIT_LIST_HEAD(&wqe->list_entry); in efct_hw_wq_write()
2550 list_add_tail(&wqe->list_entry, &wq->pending_list); in efct_hw_wq_write()
2551 wq->wq_pending_count++; in efct_hw_wq_write()
2555 spin_unlock_irqrestore(&wq->queue->lock, flags); in efct_hw_wq_write()
2563 struct efct *efct = efc->base; in efct_efc_bls_send()
2572 struct efct_hw *hw = &efct->hw; in efct_hw_bls_send()
2577 if (hw->state != EFCT_HW_STATE_ACTIVE) { in efct_hw_bls_send()
2578 efc_log_err(hw->os, in efct_hw_bls_send()
2579 "cannot send BLS, HW state=%d\n", hw->state); in efct_hw_bls_send()
2580 return -EIO; in efct_hw_bls_send()
2585 efc_log_err(hw->os, "HIO allocation failed\n"); in efct_hw_bls_send()
2586 return -EIO; in efct_hw_bls_send()
2589 hio->done = cb; in efct_hw_bls_send()
2590 hio->arg = arg; in efct_hw_bls_send()
2592 bls_params->xri = hio->indicator; in efct_hw_bls_send()
2593 bls_params->tag = hio->reqtag; in efct_hw_bls_send()
2596 hio->type = EFCT_HW_BLS_ACC; in efct_hw_bls_send()
2598 memcpy(&bls.u.acc, bls_params->payload, sizeof(bls.u.acc)); in efct_hw_bls_send()
2600 hio->type = EFCT_HW_BLS_RJT; in efct_hw_bls_send()
2602 memcpy(&bls.u.rjt, bls_params->payload, sizeof(bls.u.rjt)); in efct_hw_bls_send()
2605 bls.ox_id = cpu_to_le16(bls_params->ox_id); in efct_hw_bls_send()
2606 bls.rx_id = cpu_to_le16(bls_params->rx_id); in efct_hw_bls_send()
2608 if (sli_xmit_bls_rsp64_wqe(&hw->sli, hio->wqe.wqebuf, in efct_hw_bls_send()
2610 efc_log_err(hw->os, "XMIT_BLS_RSP64 WQE error\n"); in efct_hw_bls_send()
2611 return -EIO; in efct_hw_bls_send()
2614 hio->xbusy = true; in efct_hw_bls_send()
2620 hio->wq->use_count++; in efct_hw_bls_send()
2621 rc = efct_hw_wq_write(hio->wq, &hio->wqe); in efct_hw_bls_send()
2623 /* non-negative return is success */ in efct_hw_bls_send()
2627 efc_log_err(hw->os, in efct_hw_bls_send()
2629 hio->xbusy = false; in efct_hw_bls_send()
2648 u8 *cmd = io->req.virt; in efct_fill_els_params()
2650 params->cmd = *cmd; in efct_fill_els_params()
2651 params->s_id = io->s_id; in efct_fill_els_params()
2652 params->d_id = io->d_id; in efct_fill_els_params()
2653 params->ox_id = io->iparam.els.ox_id; in efct_fill_els_params()
2654 params->rpi = io->rpi; in efct_fill_els_params()
2655 params->vpi = io->vpi; in efct_fill_els_params()
2656 params->rpi_registered = io->rpi_registered; in efct_fill_els_params()
2657 params->xmit_len = io->xmit_len; in efct_fill_els_params()
2658 params->rsp_len = io->rsp_len; in efct_fill_els_params()
2659 params->timeout = io->iparam.els.timeout; in efct_fill_els_params()
2665 params->r_ctl = io->iparam.ct.r_ctl; in efct_fill_ct_params()
2666 params->type = io->iparam.ct.type; in efct_fill_ct_params()
2667 params->df_ctl = io->iparam.ct.df_ctl; in efct_fill_ct_params()
2668 params->d_id = io->d_id; in efct_fill_ct_params()
2669 params->ox_id = io->iparam.ct.ox_id; in efct_fill_ct_params()
2670 params->rpi = io->rpi; in efct_fill_ct_params()
2671 params->vpi = io->vpi; in efct_fill_ct_params()
2672 params->rpi_registered = io->rpi_registered; in efct_fill_ct_params()
2673 params->xmit_len = io->xmit_len; in efct_fill_ct_params()
2674 params->rsp_len = io->rsp_len; in efct_fill_ct_params()
2675 params->timeout = io->iparam.ct.timeout; in efct_fill_ct_params()
2679 * efct_els_hw_srrs_send() - Send a single request and response cmd.
2685 * - Sending an ELS request.
2686 * - Sending an ELS response - To send an ELS response, the caller must provide
2688 * - Sending a FC Common Transport (FC-CT) request - To send a FC-CT request,
2697 struct efct *efct = efc->base; in efct_els_hw_srrs_send()
2699 struct efct_hw *hw = &efct->hw; in efct_els_hw_srrs_send()
2700 struct efc_dma *send = &io->req; in efct_els_hw_srrs_send()
2701 struct efc_dma *receive = &io->rsp; in efct_els_hw_srrs_send()
2704 u32 len = io->xmit_len; in efct_els_hw_srrs_send()
2711 return -EIO; in efct_els_hw_srrs_send()
2714 if (hw->state != EFCT_HW_STATE_ACTIVE) { in efct_els_hw_srrs_send()
2715 efc_log_debug(hw->os, in efct_els_hw_srrs_send()
2716 "cannot send SRRS, HW state=%d\n", hw->state); in efct_els_hw_srrs_send()
2717 return -EIO; in efct_els_hw_srrs_send()
2720 hio->done = efct_els_ssrs_send_cb; in efct_els_hw_srrs_send()
2721 hio->arg = io; in efct_els_hw_srrs_send()
2723 sge = hio->sgl->virt; in efct_els_hw_srrs_send()
2726 memset(hio->sgl->virt, 0, 2 * sizeof(struct sli4_sge)); in efct_els_hw_srrs_send()
2730 if (send->size) { in efct_els_hw_srrs_send()
2732 cpu_to_le32(upper_32_bits(send->phys)); in efct_els_hw_srrs_send()
2734 cpu_to_le32(lower_32_bits(send->phys)); in efct_els_hw_srrs_send()
2741 if (io->io_type == EFC_DISC_IO_ELS_REQ || in efct_els_hw_srrs_send()
2742 io->io_type == EFC_DISC_IO_CT_REQ) { in efct_els_hw_srrs_send()
2744 cpu_to_le32(upper_32_bits(receive->phys)); in efct_els_hw_srrs_send()
2746 cpu_to_le32(lower_32_bits(receive->phys)); in efct_els_hw_srrs_send()
2751 sge[1].buffer_length = cpu_to_le32(receive->size); in efct_els_hw_srrs_send()
2759 switch (io->io_type) { in efct_els_hw_srrs_send()
2763 hio->type = EFCT_HW_ELS_REQ; in efct_els_hw_srrs_send()
2765 els_params.xri = hio->indicator; in efct_els_hw_srrs_send()
2766 els_params.tag = hio->reqtag; in efct_els_hw_srrs_send()
2768 if (sli_els_request64_wqe(&hw->sli, hio->wqe.wqebuf, hio->sgl, in efct_els_hw_srrs_send()
2770 efc_log_err(hw->os, "REQ WQE error\n"); in efct_els_hw_srrs_send()
2771 rc = -EIO; in efct_els_hw_srrs_send()
2778 hio->type = EFCT_HW_ELS_RSP; in efct_els_hw_srrs_send()
2780 els_params.xri = hio->indicator; in efct_els_hw_srrs_send()
2781 els_params.tag = hio->reqtag; in efct_els_hw_srrs_send()
2782 if (sli_xmit_els_rsp64_wqe(&hw->sli, hio->wqe.wqebuf, send, in efct_els_hw_srrs_send()
2784 efc_log_err(hw->os, "RSP WQE error\n"); in efct_els_hw_srrs_send()
2785 rc = -EIO; in efct_els_hw_srrs_send()
2792 hio->type = EFCT_HW_FC_CT; in efct_els_hw_srrs_send()
2794 ct_params.xri = hio->indicator; in efct_els_hw_srrs_send()
2795 ct_params.tag = hio->reqtag; in efct_els_hw_srrs_send()
2796 if (sli_gen_request64_wqe(&hw->sli, hio->wqe.wqebuf, hio->sgl, in efct_els_hw_srrs_send()
2798 efc_log_err(hw->os, "GEN WQE error\n"); in efct_els_hw_srrs_send()
2799 rc = -EIO; in efct_els_hw_srrs_send()
2806 hio->type = EFCT_HW_FC_CT_RSP; in efct_els_hw_srrs_send()
2808 ct_params.xri = hio->indicator; in efct_els_hw_srrs_send()
2809 ct_params.tag = hio->reqtag; in efct_els_hw_srrs_send()
2810 if (sli_xmit_sequence64_wqe(&hw->sli, hio->wqe.wqebuf, hio->sgl, in efct_els_hw_srrs_send()
2812 efc_log_err(hw->os, "XMIT SEQ WQE error\n"); in efct_els_hw_srrs_send()
2813 rc = -EIO; in efct_els_hw_srrs_send()
2818 efc_log_err(hw->os, "bad SRRS type %#x\n", io->io_type); in efct_els_hw_srrs_send()
2819 rc = -EIO; in efct_els_hw_srrs_send()
2823 hio->xbusy = true; in efct_els_hw_srrs_send()
2829 hio->wq->use_count++; in efct_els_hw_srrs_send()
2830 rc = efct_hw_wq_write(hio->wq, &hio->wqe); in efct_els_hw_srrs_send()
2832 /* non-negative return is success */ in efct_els_hw_srrs_send()
2836 efc_log_err(hw->os, in efct_els_hw_srrs_send()
2838 hio->xbusy = false; in efct_els_hw_srrs_send()
2855 return -EIO; in efct_hw_io_send()
2858 if (hw->state != EFCT_HW_STATE_ACTIVE) { in efct_hw_io_send()
2859 efc_log_err(hw->os, "cannot send IO, HW state=%d\n", hw->state); in efct_hw_io_send()
2860 return -EIO; in efct_hw_io_send()
2866 io->type = type; in efct_hw_io_send()
2867 io->done = cb; in efct_hw_io_send()
2868 io->arg = arg; in efct_hw_io_send()
2875 u16 *flags = &iparam->fcp_tgt.flags; in efct_hw_io_send()
2876 struct fcp_txrdy *xfer = io->xfer_rdy.virt; in efct_hw_io_send()
2881 xfer->ft_data_ro = cpu_to_be32(iparam->fcp_tgt.offset); in efct_hw_io_send()
2882 xfer->ft_burst_len = cpu_to_be32(iparam->fcp_tgt.xmit_len); in efct_hw_io_send()
2884 if (io->xbusy) in efct_hw_io_send()
2888 iparam->fcp_tgt.xri = io->indicator; in efct_hw_io_send()
2889 iparam->fcp_tgt.tag = io->reqtag; in efct_hw_io_send()
2891 if (sli_fcp_treceive64_wqe(&hw->sli, io->wqe.wqebuf, in efct_hw_io_send()
2892 &io->def_sgl, io->first_data_sge, in efct_hw_io_send()
2894 0, 0, &iparam->fcp_tgt)) { in efct_hw_io_send()
2895 efc_log_err(hw->os, "TRECEIVE WQE error\n"); in efct_hw_io_send()
2896 rc = -EIO; in efct_hw_io_send()
2901 u16 *flags = &iparam->fcp_tgt.flags; in efct_hw_io_send()
2903 if (io->xbusy) in efct_hw_io_send()
2908 iparam->fcp_tgt.xri = io->indicator; in efct_hw_io_send()
2909 iparam->fcp_tgt.tag = io->reqtag; in efct_hw_io_send()
2911 if (sli_fcp_tsend64_wqe(&hw->sli, io->wqe.wqebuf, in efct_hw_io_send()
2912 &io->def_sgl, io->first_data_sge, in efct_hw_io_send()
2914 0, 0, &iparam->fcp_tgt)) { in efct_hw_io_send()
2915 efc_log_err(hw->os, "TSEND WQE error\n"); in efct_hw_io_send()
2916 rc = -EIO; in efct_hw_io_send()
2921 u16 *flags = &iparam->fcp_tgt.flags; in efct_hw_io_send()
2923 if (io->xbusy) in efct_hw_io_send()
2928 iparam->fcp_tgt.xri = io->indicator; in efct_hw_io_send()
2929 iparam->fcp_tgt.tag = io->reqtag; in efct_hw_io_send()
2931 if (sli_fcp_trsp64_wqe(&hw->sli, io->wqe.wqebuf, in efct_hw_io_send()
2932 &io->def_sgl, SLI4_CQ_DEFAULT, in efct_hw_io_send()
2933 0, &iparam->fcp_tgt)) { in efct_hw_io_send()
2934 efc_log_err(hw->os, "TRSP WQE error\n"); in efct_hw_io_send()
2935 rc = -EIO; in efct_hw_io_send()
2941 efc_log_err(hw->os, "unsupported IO type %#x\n", type); in efct_hw_io_send()
2942 rc = -EIO; in efct_hw_io_send()
2946 io->xbusy = true; in efct_hw_io_send()
2952 hw->tcmd_wq_submit[io->wq->instance]++; in efct_hw_io_send()
2953 io->wq->use_count++; in efct_hw_io_send()
2954 rc = efct_hw_wq_write(io->wq, &io->wqe); in efct_hw_io_send()
2956 /* non-negative return is success */ in efct_hw_io_send()
2960 efc_log_err(hw->os, in efct_hw_io_send()
2962 io->xbusy = false; in efct_hw_io_send()
2981 wqe = &ctx->wqe; in efct_hw_send_frame()
2984 ctx->hw = hw; in efct_hw_send_frame()
2987 ctx->wqcb = efct_hw_reqtag_alloc(hw, callback, arg); in efct_hw_send_frame()
2988 if (!ctx->wqcb) { in efct_hw_send_frame()
2989 efc_log_err(hw->os, "can't allocate request tag\n"); in efct_hw_send_frame()
2990 return -ENOSPC; in efct_hw_send_frame()
2993 wq = hw->hw_wq[0]; in efct_hw_send_frame()
2998 xri = wq->send_frame_io->indicator; in efct_hw_send_frame()
3001 rc = sli_send_frame_wqe(&hw->sli, wqe->wqebuf, in efct_hw_send_frame()
3002 sof, eof, (u32 *)hdr, payload, payload->len, in efct_hw_send_frame()
3004 ctx->wqcb->instance_index); in efct_hw_send_frame()
3006 efc_log_err(hw->os, "sli_send_frame_wqe failed: %d\n", rc); in efct_hw_send_frame()
3007 return -EIO; in efct_hw_send_frame()
3013 efc_log_err(hw->os, "efct_hw_wq_write failed: %d\n", rc); in efct_hw_send_frame()
3014 return -EIO; in efct_hw_send_frame()
3017 wq->use_count++; in efct_hw_send_frame()
3033 mbox_rsp_flags = le32_to_cpu(mbox_rsp->dw1_flags); in efct_hw_cb_link_stat()
3043 le32_to_cpu(mbox_rsp->linkfail_errcnt); in efct_hw_cb_link_stat()
3045 le32_to_cpu(mbox_rsp->losssync_errcnt); in efct_hw_cb_link_stat()
3047 le32_to_cpu(mbox_rsp->losssignal_errcnt); in efct_hw_cb_link_stat()
3049 le32_to_cpu(mbox_rsp->primseq_errcnt); in efct_hw_cb_link_stat()
3051 le32_to_cpu(mbox_rsp->inval_txword_errcnt); in efct_hw_cb_link_stat()
3053 le32_to_cpu(mbox_rsp->crc_errcnt); in efct_hw_cb_link_stat()
3055 le32_to_cpu(mbox_rsp->primseq_eventtimeout_cnt); in efct_hw_cb_link_stat()
3057 le32_to_cpu(mbox_rsp->elastic_bufoverrun_errcnt); in efct_hw_cb_link_stat()
3059 le32_to_cpu(mbox_rsp->arbit_fc_al_timeout_cnt); in efct_hw_cb_link_stat()
3061 le32_to_cpu(mbox_rsp->adv_rx_buftor_to_buf_credit); in efct_hw_cb_link_stat()
3063 le32_to_cpu(mbox_rsp->curr_rx_buf_to_buf_credit); in efct_hw_cb_link_stat()
3065 le32_to_cpu(mbox_rsp->adv_tx_buf_to_buf_credit); in efct_hw_cb_link_stat()
3067 le32_to_cpu(mbox_rsp->curr_tx_buf_to_buf_credit); in efct_hw_cb_link_stat()
3069 le32_to_cpu(mbox_rsp->rx_eofa_cnt); in efct_hw_cb_link_stat()
3071 le32_to_cpu(mbox_rsp->rx_eofdti_cnt); in efct_hw_cb_link_stat()
3073 le32_to_cpu(mbox_rsp->rx_eofni_cnt); in efct_hw_cb_link_stat()
3075 le32_to_cpu(mbox_rsp->rx_soff_cnt); in efct_hw_cb_link_stat()
3077 le32_to_cpu(mbox_rsp->rx_dropped_no_aer_cnt); in efct_hw_cb_link_stat()
3079 le32_to_cpu(mbox_rsp->rx_dropped_no_avail_rpi_rescnt); in efct_hw_cb_link_stat()
3081 le32_to_cpu(mbox_rsp->rx_dropped_no_avail_xri_rescnt); in efct_hw_cb_link_stat()
3084 if (cb_arg->cb) { in efct_hw_cb_link_stat()
3085 if (status == 0 && le16_to_cpu(mbox_rsp->hdr.status)) in efct_hw_cb_link_stat()
3086 status = le16_to_cpu(mbox_rsp->hdr.status); in efct_hw_cb_link_stat()
3087 cb_arg->cb(status, num_counters, counts, cb_arg->arg); in efct_hw_cb_link_stat()
3104 int rc = -EIO; in efct_hw_get_link_stats()
3110 return -ENOMEM; in efct_hw_get_link_stats()
3112 cb_arg->cb = cb; in efct_hw_get_link_stats()
3113 cb_arg->arg = arg; in efct_hw_get_link_stats()
3116 if (!sli_cmd_read_link_stats(&hw->sli, mbxdata, req_ext_counters, in efct_hw_get_link_stats()
3140 le32_to_cpu(mbox_rsp->trans_kbyte_cnt); in efct_hw_cb_host_stat()
3142 le32_to_cpu(mbox_rsp->recv_kbyte_cnt); in efct_hw_cb_host_stat()
3144 le32_to_cpu(mbox_rsp->trans_frame_cnt); in efct_hw_cb_host_stat()
3146 le32_to_cpu(mbox_rsp->recv_frame_cnt); in efct_hw_cb_host_stat()
3148 le32_to_cpu(mbox_rsp->trans_seq_cnt); in efct_hw_cb_host_stat()
3150 le32_to_cpu(mbox_rsp->recv_seq_cnt); in efct_hw_cb_host_stat()
3152 le32_to_cpu(mbox_rsp->tot_exchanges_orig); in efct_hw_cb_host_stat()
3154 le32_to_cpu(mbox_rsp->tot_exchanges_resp); in efct_hw_cb_host_stat()
3156 le32_to_cpu(mbox_rsp->recv_p_bsy_cnt); in efct_hw_cb_host_stat()
3158 le32_to_cpu(mbox_rsp->recv_f_bsy_cnt); in efct_hw_cb_host_stat()
3160 le32_to_cpu(mbox_rsp->no_rq_buf_dropped_frames_cnt); in efct_hw_cb_host_stat()
3162 le32_to_cpu(mbox_rsp->empty_rq_timeout_cnt); in efct_hw_cb_host_stat()
3164 le32_to_cpu(mbox_rsp->no_xri_dropped_frames_cnt); in efct_hw_cb_host_stat()
3166 le32_to_cpu(mbox_rsp->empty_xri_pool_cnt); in efct_hw_cb_host_stat()
3169 if (cb_arg->cb) { in efct_hw_cb_host_stat()
3170 if (status == 0 && le16_to_cpu(mbox_rsp->hdr.status)) in efct_hw_cb_host_stat()
3171 status = le16_to_cpu(mbox_rsp->hdr.status); in efct_hw_cb_host_stat()
3172 cb_arg->cb(status, num_counters, counts, cb_arg->arg); in efct_hw_cb_host_stat()
3188 int rc = -EIO; in efct_hw_get_host_stats()
3194 return -ENOMEM; in efct_hw_get_host_stats()
3196 cb_arg->cb = cb; in efct_hw_get_host_stats()
3197 cb_arg->arg = arg; in efct_hw_get_host_stats()
3200 if (!sli_cmd_read_status(&hw->sli, mbxdata, cc)) in efct_hw_get_host_stats()
3205 efc_log_debug(hw->os, "READ_HOST_STATS failed\n"); in efct_hw_get_host_stats()
3224 if (ctx->callback) in efct_hw_async_cb()
3225 (*ctx->callback)(hw, status, mqe, ctx->arg); in efct_hw_async_cb()
3244 return -ENOMEM; in efct_hw_async_call()
3246 ctx->callback = callback; in efct_hw_async_call()
3247 ctx->arg = arg; in efct_hw_async_call()
3250 if (sli_cmd_common_nop(&hw->sli, ctx->cmd, 0)) { in efct_hw_async_call()
3251 efc_log_err(hw->os, "COMMON_NOP format failure\n"); in efct_hw_async_call()
3253 return -EIO; in efct_hw_async_call()
3256 rc = efct_hw_command(hw, ctx->cmd, EFCT_CMD_NOWAIT, efct_hw_async_cb, in efct_hw_async_call()
3259 efc_log_err(hw->os, "COMMON_NOP command failure, rc=%d\n", rc); in efct_hw_async_call()
3261 return -EIO; in efct_hw_async_call()
3278 &mbox_rsp->payload.embed; in efct_hw_cb_fw_write()
3279 bytes_written = le32_to_cpu(wr_obj_rsp->actual_write_length); in efct_hw_cb_fw_write()
3280 mbox_status = le16_to_cpu(mbox_rsp->hdr.status); in efct_hw_cb_fw_write()
3281 change_status = (le32_to_cpu(wr_obj_rsp->change_status_dword) & in efct_hw_cb_fw_write()
3285 if (cb_arg->cb) { in efct_hw_cb_fw_write()
3288 cb_arg->cb(status, bytes_written, change_status, in efct_hw_cb_fw_write()
3289 cb_arg->arg); in efct_hw_cb_fw_write()
3305 int rc = -EIO; in efct_hw_firmware_write()
3312 return -ENOMEM; in efct_hw_firmware_write()
3314 cb_arg->cb = cb; in efct_hw_firmware_write()
3315 cb_arg->arg = arg; in efct_hw_firmware_write()
3318 if (!sli_cmd_common_write_object(&hw->sli, mbxdata, in efct_hw_firmware_write()
3325 efc_log_debug(hw->os, "COMMON_WRITE_OBJECT failed\n"); in efct_hw_firmware_write()
3345 int rc = -EIO; in efct_hw_port_control()
3352 if (!sli_cmd_config_link(&hw->sli, link)) in efct_hw_port_control()
3357 efc_log_err(hw->os, "CONFIG_LINK failed\n"); in efct_hw_port_control()
3360 speed = hw->config.speed; in efct_hw_port_control()
3363 rc = -EIO; in efct_hw_port_control()
3364 if (!sli_cmd_init_link(&hw->sli, link, speed, reset_alpa)) in efct_hw_port_control()
3369 efc_log_err(hw->os, "INIT_LINK failed\n"); in efct_hw_port_control()
3373 if (!sli_cmd_down_link(&hw->sli, link)) in efct_hw_port_control()
3378 efc_log_err(hw->os, "DOWN_LINK failed\n"); in efct_hw_port_control()
3382 efc_log_debug(hw->os, "unhandled control %#x\n", ctrl); in efct_hw_port_control()
3396 struct efct *efct = hw->os; in efct_hw_teardown()
3398 destroy_queues = (hw->state == EFCT_HW_STATE_ACTIVE); in efct_hw_teardown()
3399 free_memory = (hw->state != EFCT_HW_STATE_UNINITIALIZED); in efct_hw_teardown()
3402 if (hw->sliport_healthcheck) { in efct_hw_teardown()
3403 hw->sliport_healthcheck = 0; in efct_hw_teardown()
3407 if (hw->state != EFCT_HW_STATE_QUEUES_ALLOCATED) { in efct_hw_teardown()
3408 hw->state = EFCT_HW_STATE_TEARDOWN_IN_PROGRESS; in efct_hw_teardown()
3412 if (list_empty(&hw->cmd_head)) in efct_hw_teardown()
3413 efc_log_debug(hw->os, in efct_hw_teardown()
3416 efc_log_debug(hw->os, in efct_hw_teardown()
3422 hw->state = EFCT_HW_STATE_TEARDOWN_IN_PROGRESS; in efct_hw_teardown()
3425 dma_free_coherent(&efct->pci->dev, in efct_hw_teardown()
3426 hw->rnode_mem.size, hw->rnode_mem.virt, in efct_hw_teardown()
3427 hw->rnode_mem.phys); in efct_hw_teardown()
3428 memset(&hw->rnode_mem, 0, sizeof(struct efc_dma)); in efct_hw_teardown()
3430 if (hw->io) { in efct_hw_teardown()
3431 for (i = 0; i < hw->config.n_io; i++) { in efct_hw_teardown()
3432 if (hw->io[i] && hw->io[i]->sgl && in efct_hw_teardown()
3433 hw->io[i]->sgl->virt) { in efct_hw_teardown()
3434 dma_free_coherent(&efct->pci->dev, in efct_hw_teardown()
3435 hw->io[i]->sgl->size, in efct_hw_teardown()
3436 hw->io[i]->sgl->virt, in efct_hw_teardown()
3437 hw->io[i]->sgl->phys); in efct_hw_teardown()
3439 kfree(hw->io[i]); in efct_hw_teardown()
3440 hw->io[i] = NULL; in efct_hw_teardown()
3442 kfree(hw->io); in efct_hw_teardown()
3443 hw->io = NULL; in efct_hw_teardown()
3444 kfree(hw->wqe_buffs); in efct_hw_teardown()
3445 hw->wqe_buffs = NULL; in efct_hw_teardown()
3448 dma = &hw->xfer_rdy; in efct_hw_teardown()
3449 dma_free_coherent(&efct->pci->dev, in efct_hw_teardown()
3450 dma->size, dma->virt, dma->phys); in efct_hw_teardown()
3453 dma = &hw->loop_map; in efct_hw_teardown()
3454 dma_free_coherent(&efct->pci->dev, in efct_hw_teardown()
3455 dma->size, dma->virt, dma->phys); in efct_hw_teardown()
3458 for (i = 0; i < hw->wq_count; i++) in efct_hw_teardown()
3459 sli_queue_free(&hw->sli, &hw->wq[i], destroy_queues, in efct_hw_teardown()
3462 for (i = 0; i < hw->rq_count; i++) in efct_hw_teardown()
3463 sli_queue_free(&hw->sli, &hw->rq[i], destroy_queues, in efct_hw_teardown()
3466 for (i = 0; i < hw->mq_count; i++) in efct_hw_teardown()
3467 sli_queue_free(&hw->sli, &hw->mq[i], destroy_queues, in efct_hw_teardown()
3470 for (i = 0; i < hw->cq_count; i++) in efct_hw_teardown()
3471 sli_queue_free(&hw->sli, &hw->cq[i], destroy_queues, in efct_hw_teardown()
3474 for (i = 0; i < hw->eq_count; i++) in efct_hw_teardown()
3475 sli_queue_free(&hw->sli, &hw->eq[i], destroy_queues, in efct_hw_teardown()
3483 kfree(hw->wq_cpu_array); in efct_hw_teardown()
3485 sli_teardown(&hw->sli); in efct_hw_teardown()
3487 /* record the fact that the queues are non-functional */ in efct_hw_teardown()
3488 hw->state = EFCT_HW_STATE_UNINITIALIZED; in efct_hw_teardown()
3491 kfree(hw->seq_pool); in efct_hw_teardown()
3492 hw->seq_pool = NULL; in efct_hw_teardown()
3497 mempool_destroy(hw->cmd_ctx_pool); in efct_hw_teardown()
3498 mempool_destroy(hw->mbox_rqst_pool); in efct_hw_teardown()
3501 hw->hw_setup_called = false; in efct_hw_teardown()
3512 efc_log_debug(hw->os, "issuing function level reset\n"); in efct_hw_sli_reset()
3513 if (sli_reset(&hw->sli)) { in efct_hw_sli_reset()
3514 efc_log_err(hw->os, "sli_reset failed\n"); in efct_hw_sli_reset()
3515 rc = -EIO; in efct_hw_sli_reset()
3519 efc_log_debug(hw->os, "issuing firmware reset\n"); in efct_hw_sli_reset()
3520 if (sli_fw_reset(&hw->sli)) { in efct_hw_sli_reset()
3521 efc_log_err(hw->os, "sli_soft_reset failed\n"); in efct_hw_sli_reset()
3522 rc = -EIO; in efct_hw_sli_reset()
3525 * Because the FW reset leaves the FW in a non-running state, in efct_hw_sli_reset()
3528 efc_log_debug(hw->os, "issuing function level reset\n"); in efct_hw_sli_reset()
3529 if (sli_reset(&hw->sli)) { in efct_hw_sli_reset()
3530 efc_log_err(hw->os, "sli_reset failed\n"); in efct_hw_sli_reset()
3531 rc = -EIO; in efct_hw_sli_reset()
3535 efc_log_err(hw->os, "unknown type - no reset performed\n"); in efct_hw_sli_reset()
3536 hw->state = prev_state; in efct_hw_sli_reset()
3537 rc = -EINVAL; in efct_hw_sli_reset()
3548 enum efct_hw_state prev_state = hw->state; in efct_hw_reset()
3550 if (hw->state != EFCT_HW_STATE_ACTIVE) in efct_hw_reset()
3551 efc_log_debug(hw->os, in efct_hw_reset()
3552 "HW state %d is not active\n", hw->state); in efct_hw_reset()
3554 hw->state = EFCT_HW_STATE_RESET_IN_PROGRESS; in efct_hw_reset()
3567 if (list_empty(&hw->cmd_head)) in efct_hw_reset()
3568 efc_log_debug(hw->os, in efct_hw_reset()
3571 efc_log_err(hw->os, in efct_hw_reset()
3577 if (rc == -EINVAL) in efct_hw_reset()
3578 return -EIO; in efct_hw_reset()