Lines Matching +full:io +full:- +full:reset

1 // SPDX-License-Identifier: GPL-2.0-only
98 u32 hash = scsi_cmd_to_rq(sc)->tag & (FNIC_IO_LOCKS - 1); in fnic_io_lock_hash()
100 return &fnic->io_req_lock[hash]; in fnic_io_lock_hash()
106 return &fnic->io_req_lock[tag & (FNIC_IO_LOCKS - 1)]; in fnic_io_lock_tag()
111 * also unmap and free the device-private scatter/gather list.
117 if (io_req->sgl_list_pa) in fnic_release_ioreq_buf()
118 dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa, in fnic_release_ioreq_buf()
119 sizeof(io_req->sgl_list[0]) * io_req->sgl_cnt, in fnic_release_ioreq_buf()
123 if (io_req->sgl_cnt) in fnic_release_ioreq_buf()
124 mempool_free(io_req->sgl_list_alloc, in fnic_release_ioreq_buf()
125 fnic->io_sgl_pool[io_req->sgl_type]); in fnic_release_ioreq_buf()
126 if (io_req->sense_buf_pa) in fnic_release_ioreq_buf()
127 dma_unmap_single(&fnic->pdev->dev, io_req->sense_buf_pa, in fnic_release_ioreq_buf()
135 if (!fnic->fw_ack_recd[0]) in free_wq_copy_descs()
142 if (wq->to_clean_index <= fnic->fw_ack_index[0]) in free_wq_copy_descs()
143 wq->ring.desc_avail += (fnic->fw_ack_index[0] in free_wq_copy_descs()
144 - wq->to_clean_index + 1); in free_wq_copy_descs()
146 wq->ring.desc_avail += (wq->ring.desc_count in free_wq_copy_descs()
147 - wq->to_clean_index in free_wq_copy_descs()
148 + fnic->fw_ack_index[0] + 1); in free_wq_copy_descs()
155 wq->to_clean_index = in free_wq_copy_descs()
156 (fnic->fw_ack_index[0] + 1) % wq->ring.desc_count; in free_wq_copy_descs()
159 fnic->fw_ack_recd[0] = 0; in free_wq_copy_descs()
175 spin_lock_irqsave(&fnic->fnic_lock, flags); in __fnic_set_state_flags()
176 spin_lock_irqsave(fnic->lport->host->host_lock, host_lock_flags); in __fnic_set_state_flags()
179 fnic->state_flags &= ~st_flags; in __fnic_set_state_flags()
181 fnic->state_flags |= st_flags; in __fnic_set_state_flags()
183 spin_unlock_irqrestore(fnic->lport->host->host_lock, host_lock_flags); in __fnic_set_state_flags()
184 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in __fnic_set_state_flags()
192 * Routine to send reset msg to fw
196 struct vnic_wq_copy *wq = &fnic->wq_copy[0]; in fnic_fw_reset_handler()
200 /* indicate fwreset to io path */ in fnic_fw_reset_handler()
203 skb_queue_purge(&fnic->frame_queue); in fnic_fw_reset_handler()
204 skb_queue_purge(&fnic->tx_queue); in fnic_fw_reset_handler()
206 /* wait for io cmpl */ in fnic_fw_reset_handler()
207 while (atomic_read(&fnic->in_flight)) in fnic_fw_reset_handler()
210 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); in fnic_fw_reset_handler()
212 if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) in fnic_fw_reset_handler()
216 ret = -EAGAIN; in fnic_fw_reset_handler()
219 atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); in fnic_fw_reset_handler()
220 if (atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs) > in fnic_fw_reset_handler()
221 atomic64_read(&fnic->fnic_stats.fw_stats.max_fw_reqs)) in fnic_fw_reset_handler()
222 atomic64_set(&fnic->fnic_stats.fw_stats.max_fw_reqs, in fnic_fw_reset_handler()
224 &fnic->fnic_stats.fw_stats.active_fw_reqs)); in fnic_fw_reset_handler()
227 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); in fnic_fw_reset_handler()
230 atomic64_inc(&fnic->fnic_stats.reset_stats.fw_resets); in fnic_fw_reset_handler()
231 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fw_reset_handler()
232 "Issued fw reset\n"); in fnic_fw_reset_handler()
235 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fw_reset_handler()
236 "Failed to issue fw reset\n"); in fnic_fw_reset_handler()
249 struct vnic_wq_copy *wq = &fnic->wq_copy[0]; in fnic_flogi_reg_handler()
251 struct fc_lport *lp = fnic->lport; in fnic_flogi_reg_handler()
256 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); in fnic_flogi_reg_handler()
258 if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) in fnic_flogi_reg_handler()
262 ret = -EAGAIN; in fnic_flogi_reg_handler()
266 if (fnic->ctlr.map_dest) { in fnic_flogi_reg_handler()
270 memcpy(gw_mac, fnic->ctlr.dest_addr, ETH_ALEN); in fnic_flogi_reg_handler()
274 if ((fnic->config.flags & VFCF_FIP_CAPABLE) && !fnic->ctlr.map_dest) { in fnic_flogi_reg_handler()
277 fnic->data_src_addr, in fnic_flogi_reg_handler()
278 lp->r_a_tov, lp->e_d_tov); in fnic_flogi_reg_handler()
279 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_flogi_reg_handler()
281 fc_id, fnic->data_src_addr, gw_mac); in fnic_flogi_reg_handler()
285 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_flogi_reg_handler()
287 fc_id, fnic->ctlr.map_dest, gw_mac); in fnic_flogi_reg_handler()
290 atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); in fnic_flogi_reg_handler()
291 if (atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs) > in fnic_flogi_reg_handler()
292 atomic64_read(&fnic->fnic_stats.fw_stats.max_fw_reqs)) in fnic_flogi_reg_handler()
293 atomic64_set(&fnic->fnic_stats.fw_stats.max_fw_reqs, in fnic_flogi_reg_handler()
294 atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs)); in fnic_flogi_reg_handler()
297 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); in fnic_flogi_reg_handler()
312 struct fc_rport *rport = starget_to_rport(scsi_target(sc->device)); in fnic_queue_wq_copy_desc()
313 struct fc_rport_libfc_priv *rp = rport->dd_data; in fnic_queue_wq_copy_desc()
315 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; in fnic_queue_wq_copy_desc()
324 desc = io_req->sgl_list; in fnic_queue_wq_copy_desc()
326 desc->addr = cpu_to_le64(sg_dma_address(sg)); in fnic_queue_wq_copy_desc()
327 desc->len = cpu_to_le32(sg_dma_len(sg)); in fnic_queue_wq_copy_desc()
328 desc->_resvd = 0; in fnic_queue_wq_copy_desc()
332 io_req->sgl_list_pa = dma_map_single(&fnic->pdev->dev, in fnic_queue_wq_copy_desc()
333 io_req->sgl_list, in fnic_queue_wq_copy_desc()
334 sizeof(io_req->sgl_list[0]) * sg_count, in fnic_queue_wq_copy_desc()
336 if (dma_mapping_error(&fnic->pdev->dev, io_req->sgl_list_pa)) { in fnic_queue_wq_copy_desc()
342 io_req->sense_buf_pa = dma_map_single(&fnic->pdev->dev, in fnic_queue_wq_copy_desc()
343 sc->sense_buffer, in fnic_queue_wq_copy_desc()
346 if (dma_mapping_error(&fnic->pdev->dev, io_req->sense_buf_pa)) { in fnic_queue_wq_copy_desc()
347 dma_unmap_single(&fnic->pdev->dev, io_req->sgl_list_pa, in fnic_queue_wq_copy_desc()
348 sizeof(io_req->sgl_list[0]) * sg_count, in fnic_queue_wq_copy_desc()
354 int_to_scsilun(sc->device->lun, &fc_lun); in fnic_queue_wq_copy_desc()
357 spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags); in fnic_queue_wq_copy_desc()
359 if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) in fnic_queue_wq_copy_desc()
363 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); in fnic_queue_wq_copy_desc()
364 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_queue_wq_copy_desc()
365 "fnic_queue_wq_copy_desc failure - no descriptors\n"); in fnic_queue_wq_copy_desc()
366 atomic64_inc(&misc_stats->io_cpwq_alloc_failures); in fnic_queue_wq_copy_desc()
371 if (sc->sc_data_direction == DMA_FROM_DEVICE) in fnic_queue_wq_copy_desc()
373 else if (sc->sc_data_direction == DMA_TO_DEVICE) in fnic_queue_wq_copy_desc()
377 if ((fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) && in fnic_queue_wq_copy_desc()
378 (rp->flags & FC_RP_FLAGS_RETRY)) in fnic_queue_wq_copy_desc()
381 fnic_queue_wq_copy_desc_icmnd_16(wq, scsi_cmd_to_rq(sc)->tag, in fnic_queue_wq_copy_desc()
382 0, exch_flags, io_req->sgl_cnt, in fnic_queue_wq_copy_desc()
384 io_req->sgl_list_pa, in fnic_queue_wq_copy_desc()
385 io_req->sense_buf_pa, in fnic_queue_wq_copy_desc()
390 sc->cmnd, sc->cmd_len, in fnic_queue_wq_copy_desc()
392 fc_lun.scsi_lun, io_req->port_id, in fnic_queue_wq_copy_desc()
393 rport->maxframe_size, rp->r_a_tov, in fnic_queue_wq_copy_desc()
394 rp->e_d_tov); in fnic_queue_wq_copy_desc()
396 atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); in fnic_queue_wq_copy_desc()
397 if (atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs) > in fnic_queue_wq_copy_desc()
398 atomic64_read(&fnic->fnic_stats.fw_stats.max_fw_reqs)) in fnic_queue_wq_copy_desc()
399 atomic64_set(&fnic->fnic_stats.fw_stats.max_fw_reqs, in fnic_queue_wq_copy_desc()
400 atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs)); in fnic_queue_wq_copy_desc()
402 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); in fnic_queue_wq_copy_desc()
414 const int tag = scsi_cmd_to_rq(sc)->tag; in fnic_queuecommand_lck()
415 struct fc_lport *lp = shost_priv(sc->device->host); in fnic_queuecommand_lck()
419 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_queuecommand_lck()
436 rport = starget_to_rport(scsi_target(sc->device)); in fnic_queuecommand_lck()
438 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_queuecommand_lck()
439 "returning DID_NO_CONNECT for IO as rport is NULL\n"); in fnic_queuecommand_lck()
440 sc->result = DID_NO_CONNECT << 16; in fnic_queuecommand_lck()
447 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_queuecommand_lck()
449 atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); in fnic_queuecommand_lck()
450 sc->result = ret; in fnic_queuecommand_lck()
455 rp = rport->dd_data; in fnic_queuecommand_lck()
456 if (!rp || rp->rp_state == RPORT_ST_DELETE) { in fnic_queuecommand_lck()
457 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_queuecommand_lck()
459 rport->port_id); in fnic_queuecommand_lck()
461 atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); in fnic_queuecommand_lck()
462 sc->result = DID_NO_CONNECT<<16; in fnic_queuecommand_lck()
467 if (rp->rp_state != RPORT_ST_READY) { in fnic_queuecommand_lck()
468 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_queuecommand_lck()
470 rport->port_id, rp->rp_state); in fnic_queuecommand_lck()
472 sc->result = DID_IMM_RETRY << 16; in fnic_queuecommand_lck()
477 if (lp->state != LPORT_ST_READY || !(lp->link_up)) in fnic_queuecommand_lck()
480 atomic_inc(&fnic->in_flight); in fnic_queuecommand_lck()
484 * Don't re-enable interrupts in case they were disabled prior to the in fnic_queuecommand_lck()
487 spin_unlock(lp->host->host_lock); in fnic_queuecommand_lck()
488 fnic_priv(sc)->state = FNIC_IOREQ_NOT_INITED; in fnic_queuecommand_lck()
489 fnic_priv(sc)->flags = FNIC_NO_FLAGS; in fnic_queuecommand_lck()
491 /* Get a new io_req for this SCSI IO */ in fnic_queuecommand_lck()
492 io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); in fnic_queuecommand_lck()
494 atomic64_inc(&fnic_stats->io_stats.alloc_failures); in fnic_queuecommand_lck()
503 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, in fnic_queuecommand_lck()
504 tag, sc, 0, sc->cmnd[0], sg_count, fnic_priv(sc)->state); in fnic_queuecommand_lck()
505 mempool_free(io_req, fnic->io_req_pool); in fnic_queuecommand_lck()
510 io_req->sgl_cnt = sg_count; in fnic_queuecommand_lck()
511 io_req->sgl_type = FNIC_SGL_CACHE_DFLT; in fnic_queuecommand_lck()
513 io_req->sgl_type = FNIC_SGL_CACHE_MAX; in fnic_queuecommand_lck()
516 io_req->sgl_list = in fnic_queuecommand_lck()
517 mempool_alloc(fnic->io_sgl_pool[io_req->sgl_type], in fnic_queuecommand_lck()
519 if (!io_req->sgl_list) { in fnic_queuecommand_lck()
520 atomic64_inc(&fnic_stats->io_stats.alloc_failures); in fnic_queuecommand_lck()
523 mempool_free(io_req, fnic->io_req_pool); in fnic_queuecommand_lck()
528 io_req->sgl_list_alloc = io_req->sgl_list; in fnic_queuecommand_lck()
529 ptr = (unsigned long) io_req->sgl_list; in fnic_queuecommand_lck()
531 io_req->sgl_list = (struct host_sg_desc *) in fnic_queuecommand_lck()
533 + FNIC_SG_DESC_ALIGN - 1) in fnic_queuecommand_lck()
534 & ~(FNIC_SG_DESC_ALIGN - 1)); in fnic_queuecommand_lck()
539 * Will acquire lock defore setting to IO initialized. in fnic_queuecommand_lck()
547 io_req->port_id = rport->port_id; in fnic_queuecommand_lck()
548 io_req->start_time = jiffies; in fnic_queuecommand_lck()
549 fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING; in fnic_queuecommand_lck()
550 fnic_priv(sc)->io_req = io_req; in fnic_queuecommand_lck()
551 fnic_priv(sc)->flags |= FNIC_IO_INITIALIZED; in fnic_queuecommand_lck()
554 wq = &fnic->wq_copy[0]; in fnic_queuecommand_lck()
561 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, in fnic_queuecommand_lck()
563 io_req = fnic_priv(sc)->io_req; in fnic_queuecommand_lck()
564 fnic_priv(sc)->io_req = NULL; in fnic_queuecommand_lck()
565 fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; in fnic_queuecommand_lck()
569 mempool_free(io_req, fnic->io_req_pool); in fnic_queuecommand_lck()
571 atomic_dec(&fnic->in_flight); in fnic_queuecommand_lck()
573 spin_lock(lp->host->host_lock); in fnic_queuecommand_lck()
576 atomic64_inc(&fnic_stats->io_stats.active_ios); in fnic_queuecommand_lck()
577 atomic64_inc(&fnic_stats->io_stats.num_ios); in fnic_queuecommand_lck()
578 if (atomic64_read(&fnic_stats->io_stats.active_ios) > in fnic_queuecommand_lck()
579 atomic64_read(&fnic_stats->io_stats.max_active_ios)) in fnic_queuecommand_lck()
580 atomic64_set(&fnic_stats->io_stats.max_active_ios, in fnic_queuecommand_lck()
581 atomic64_read(&fnic_stats->io_stats.active_ios)); in fnic_queuecommand_lck()
583 /* REVISIT: Use per IO lock in the final code */ in fnic_queuecommand_lck()
584 fnic_priv(sc)->flags |= FNIC_IO_ISSUED; in fnic_queuecommand_lck()
587 cmd_trace = ((u64)sc->cmnd[0] << 56 | (u64)sc->cmnd[7] << 40 | in fnic_queuecommand_lck()
588 (u64)sc->cmnd[8] << 32 | (u64)sc->cmnd[2] << 24 | in fnic_queuecommand_lck()
589 (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | in fnic_queuecommand_lck()
590 sc->cmnd[5]); in fnic_queuecommand_lck()
592 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, in fnic_queuecommand_lck()
596 /* if only we issued IO, will we have the io lock */ in fnic_queuecommand_lck()
600 atomic_dec(&fnic->in_flight); in fnic_queuecommand_lck()
602 spin_lock(lp->host->host_lock); in fnic_queuecommand_lck()
610 * Routine to handle fw reset completion in DEF_SCSI_QCMD()
620 struct reset_stats *reset_stats = &fnic->fnic_stats.reset_stats; in DEF_SCSI_QCMD()
622 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); in DEF_SCSI_QCMD()
624 atomic64_inc(&reset_stats->fw_reset_completions); in DEF_SCSI_QCMD()
626 /* Clean up all outstanding io requests */ in DEF_SCSI_QCMD()
629 atomic64_set(&fnic->fnic_stats.fw_stats.active_fw_reqs, 0); in DEF_SCSI_QCMD()
630 atomic64_set(&fnic->fnic_stats.io_stats.active_ios, 0); in DEF_SCSI_QCMD()
631 atomic64_set(&fnic->io_cmpl_skip, 0); in DEF_SCSI_QCMD()
633 spin_lock_irqsave(&fnic->fnic_lock, flags); in DEF_SCSI_QCMD()
636 if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) { in DEF_SCSI_QCMD()
637 /* Check status of reset completion */ in DEF_SCSI_QCMD()
639 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in DEF_SCSI_QCMD()
640 "reset cmpl success\n"); in DEF_SCSI_QCMD()
642 fnic->state = FNIC_IN_ETH_MODE; in DEF_SCSI_QCMD()
645 fnic->lport->host, in DEF_SCSI_QCMD()
653 * reset the firmware. Free the cached flogi in DEF_SCSI_QCMD()
655 fnic->state = FNIC_IN_FC_MODE; in DEF_SCSI_QCMD()
656 atomic64_inc(&reset_stats->fw_reset_failures); in DEF_SCSI_QCMD()
657 ret = -1; in DEF_SCSI_QCMD()
661 fnic->lport->host, in DEF_SCSI_QCMD()
663 " reset cmpl\n", fnic_state_to_str(fnic->state)); in DEF_SCSI_QCMD()
664 atomic64_inc(&reset_stats->fw_reset_failures); in DEF_SCSI_QCMD()
665 ret = -1; in DEF_SCSI_QCMD()
668 /* Thread removing device blocks till firmware reset is complete */ in DEF_SCSI_QCMD()
669 if (fnic->remove_wait) in DEF_SCSI_QCMD()
670 complete(fnic->remove_wait); in DEF_SCSI_QCMD()
673 * If fnic is being removed, or fw reset failed in DEF_SCSI_QCMD()
676 if (fnic->remove_wait || ret) { in DEF_SCSI_QCMD()
677 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in DEF_SCSI_QCMD()
678 skb_queue_purge(&fnic->tx_queue); in DEF_SCSI_QCMD()
682 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in DEF_SCSI_QCMD()
705 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); in fnic_fcpio_flogi_reg_cmpl_handler()
708 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_fcpio_flogi_reg_cmpl_handler()
710 if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE) { in fnic_fcpio_flogi_reg_cmpl_handler()
714 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_flogi_reg_cmpl_handler()
716 fnic->state = FNIC_IN_FC_MODE; in fnic_fcpio_flogi_reg_cmpl_handler()
719 fnic->lport->host, in fnic_fcpio_flogi_reg_cmpl_handler()
722 fnic->state = FNIC_IN_ETH_MODE; in fnic_fcpio_flogi_reg_cmpl_handler()
723 ret = -1; in fnic_fcpio_flogi_reg_cmpl_handler()
726 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_flogi_reg_cmpl_handler()
729 fnic_state_to_str(fnic->state)); in fnic_fcpio_flogi_reg_cmpl_handler()
730 ret = -1; in fnic_fcpio_flogi_reg_cmpl_handler()
734 if (fnic->stop_rx_link_events) { in fnic_fcpio_flogi_reg_cmpl_handler()
735 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_fcpio_flogi_reg_cmpl_handler()
738 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_fcpio_flogi_reg_cmpl_handler()
741 queue_work(fnic_event_queue, &fnic->frame_work); in fnic_fcpio_flogi_reg_cmpl_handler()
743 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_fcpio_flogi_reg_cmpl_handler()
753 if (wq->to_clean_index <= wq->to_use_index) { in is_ack_index_in_range()
755 if (request_out < wq->to_clean_index || in is_ack_index_in_range()
756 request_out >= wq->to_use_index) in is_ack_index_in_range()
760 if (request_out < wq->to_clean_index && in is_ack_index_in_range()
761 request_out >= wq->to_use_index) in is_ack_index_in_range()
780 u16 request_out = desc->u.ack.request_out; in fnic_fcpio_ack_handler()
785 wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count]; in fnic_fcpio_ack_handler()
786 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); in fnic_fcpio_ack_handler()
788 fnic->fnic_stats.misc_stats.last_ack_time = jiffies; in fnic_fcpio_ack_handler()
790 fnic->fw_ack_index[0] = request_out; in fnic_fcpio_ack_handler()
791 fnic->fw_ack_recd[0] = 1; in fnic_fcpio_ack_handler()
794 &fnic->fnic_stats.misc_stats.ack_index_out_of_range); in fnic_fcpio_ack_handler()
796 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); in fnic_fcpio_ack_handler()
798 fnic->lport->host->host_no, 0, 0, ox_id_tag[2], ox_id_tag[3], in fnic_fcpio_ack_handler()
817 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_fcpio_icmnd_cmpl_handler()
825 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); in fnic_fcpio_icmnd_cmpl_handler()
827 icmnd_cmpl = &desc->u.icmnd_cmpl; in fnic_fcpio_icmnd_cmpl_handler()
829 if (id >= fnic->fnic_max_tag_id) { in fnic_fcpio_icmnd_cmpl_handler()
830 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_icmnd_cmpl_handler()
836 sc = scsi_host_find_tag(fnic->lport->host, id); in fnic_fcpio_icmnd_cmpl_handler()
839 atomic64_inc(&fnic_stats->io_stats.sc_null); in fnic_fcpio_icmnd_cmpl_handler()
840 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_icmnd_cmpl_handler()
841 "icmnd_cmpl sc is null - " in fnic_fcpio_icmnd_cmpl_handler()
845 fnic->lport->host->host_no, id, in fnic_fcpio_icmnd_cmpl_handler()
846 ((u64)icmnd_cmpl->_resvd0[1] << 16 | in fnic_fcpio_icmnd_cmpl_handler()
847 (u64)icmnd_cmpl->_resvd0[0]), in fnic_fcpio_icmnd_cmpl_handler()
849 (u64)icmnd_cmpl->scsi_status << 8 | in fnic_fcpio_icmnd_cmpl_handler()
850 (u64)icmnd_cmpl->flags), desc, in fnic_fcpio_icmnd_cmpl_handler()
851 (u64)icmnd_cmpl->residual, 0); in fnic_fcpio_icmnd_cmpl_handler()
857 io_req = fnic_priv(sc)->io_req; in fnic_fcpio_icmnd_cmpl_handler()
860 atomic64_inc(&fnic_stats->io_stats.ioreq_null); in fnic_fcpio_icmnd_cmpl_handler()
861 fnic_priv(sc)->flags |= FNIC_IO_REQ_NULL; in fnic_fcpio_icmnd_cmpl_handler()
863 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_icmnd_cmpl_handler()
864 "icmnd_cmpl io_req is null - " in fnic_fcpio_icmnd_cmpl_handler()
869 start_time = io_req->start_time; in fnic_fcpio_icmnd_cmpl_handler()
871 /* firmware completed the io */ in fnic_fcpio_icmnd_cmpl_handler()
872 io_req->io_completed = 1; in fnic_fcpio_icmnd_cmpl_handler()
875 * if SCSI-ML has already issued abort on this command, in fnic_fcpio_icmnd_cmpl_handler()
876 * set completion of the IO. The abts path will clean it up in fnic_fcpio_icmnd_cmpl_handler()
878 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { in fnic_fcpio_icmnd_cmpl_handler()
884 fnic_priv(sc)->flags |= FNIC_IO_DONE; in fnic_fcpio_icmnd_cmpl_handler()
885 fnic_priv(sc)->flags |= FNIC_IO_ABTS_PENDING; in fnic_fcpio_icmnd_cmpl_handler()
888 fnic_priv(sc)->flags |= FNIC_IO_ABORTED; in fnic_fcpio_icmnd_cmpl_handler()
890 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_fcpio_icmnd_cmpl_handler()
896 icmnd_cmpl->scsi_status, in fnic_fcpio_icmnd_cmpl_handler()
897 icmnd_cmpl->residual); in fnic_fcpio_icmnd_cmpl_handler()
901 /* Mark the IO as complete */ in fnic_fcpio_icmnd_cmpl_handler()
902 fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; in fnic_fcpio_icmnd_cmpl_handler()
904 icmnd_cmpl = &desc->u.icmnd_cmpl; in fnic_fcpio_icmnd_cmpl_handler()
908 sc->result = (DID_OK << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
911 if (icmnd_cmpl->flags & FCPIO_ICMND_CMPL_RESID_UNDER) { in fnic_fcpio_icmnd_cmpl_handler()
912 xfer_len -= icmnd_cmpl->residual; in fnic_fcpio_icmnd_cmpl_handler()
913 scsi_set_resid(sc, icmnd_cmpl->residual); in fnic_fcpio_icmnd_cmpl_handler()
916 if (icmnd_cmpl->scsi_status == SAM_STAT_CHECK_CONDITION) in fnic_fcpio_icmnd_cmpl_handler()
917 atomic64_inc(&fnic_stats->misc_stats.check_condition); in fnic_fcpio_icmnd_cmpl_handler()
919 if (icmnd_cmpl->scsi_status == SAM_STAT_TASK_SET_FULL) in fnic_fcpio_icmnd_cmpl_handler()
920 atomic64_inc(&fnic_stats->misc_stats.queue_fulls); in fnic_fcpio_icmnd_cmpl_handler()
924 atomic64_inc(&fnic_stats->misc_stats.fcpio_timeout); in fnic_fcpio_icmnd_cmpl_handler()
925 sc->result = (DID_TIME_OUT << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
929 atomic64_inc(&fnic_stats->misc_stats.fcpio_aborted); in fnic_fcpio_icmnd_cmpl_handler()
930 sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
934 atomic64_inc(&fnic_stats->misc_stats.data_count_mismatch); in fnic_fcpio_icmnd_cmpl_handler()
935 scsi_set_resid(sc, icmnd_cmpl->residual); in fnic_fcpio_icmnd_cmpl_handler()
936 sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
940 atomic64_inc(&fnic_stats->fw_stats.fw_out_of_resources); in fnic_fcpio_icmnd_cmpl_handler()
941 sc->result = (DID_REQUEUE << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
945 atomic64_inc(&fnic_stats->io_stats.io_not_found); in fnic_fcpio_icmnd_cmpl_handler()
946 sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
950 atomic64_inc(&fnic_stats->misc_stats.sgl_invalid); in fnic_fcpio_icmnd_cmpl_handler()
951 sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
955 atomic64_inc(&fnic_stats->fw_stats.io_fw_errs); in fnic_fcpio_icmnd_cmpl_handler()
956 sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
960 atomic64_inc(&fnic_stats->misc_stats.mss_invalid); in fnic_fcpio_icmnd_cmpl_handler()
961 sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
968 sc->result = (DID_ERROR << 16) | icmnd_cmpl->scsi_status; in fnic_fcpio_icmnd_cmpl_handler()
973 fnic_priv(sc)->io_req = NULL; in fnic_fcpio_icmnd_cmpl_handler()
974 fnic_priv(sc)->flags |= FNIC_IO_DONE; in fnic_fcpio_icmnd_cmpl_handler()
977 atomic64_inc(&fnic_stats->io_stats.io_failures); in fnic_fcpio_icmnd_cmpl_handler()
978 shost_printk(KERN_ERR, fnic->lport->host, "hdr status = %s\n", in fnic_fcpio_icmnd_cmpl_handler()
985 (u64)icmnd_cmpl->scsi_status << 48 | in fnic_fcpio_icmnd_cmpl_handler()
986 (u64)icmnd_cmpl->flags << 40 | (u64)sc->cmnd[0] << 32 | in fnic_fcpio_icmnd_cmpl_handler()
987 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | in fnic_fcpio_icmnd_cmpl_handler()
988 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]; in fnic_fcpio_icmnd_cmpl_handler()
991 sc->device->host->host_no, id, sc, in fnic_fcpio_icmnd_cmpl_handler()
992 ((u64)icmnd_cmpl->_resvd0[1] << 56 | in fnic_fcpio_icmnd_cmpl_handler()
993 (u64)icmnd_cmpl->_resvd0[0] << 48 | in fnic_fcpio_icmnd_cmpl_handler()
994 jiffies_to_msecs(jiffies - start_time)), in fnic_fcpio_icmnd_cmpl_handler()
997 if (sc->sc_data_direction == DMA_FROM_DEVICE) { in fnic_fcpio_icmnd_cmpl_handler()
998 fnic->lport->host_stats.fcp_input_requests++; in fnic_fcpio_icmnd_cmpl_handler()
999 fnic->fcp_input_bytes += xfer_len; in fnic_fcpio_icmnd_cmpl_handler()
1000 } else if (sc->sc_data_direction == DMA_TO_DEVICE) { in fnic_fcpio_icmnd_cmpl_handler()
1001 fnic->lport->host_stats.fcp_output_requests++; in fnic_fcpio_icmnd_cmpl_handler()
1002 fnic->fcp_output_bytes += xfer_len; in fnic_fcpio_icmnd_cmpl_handler()
1004 fnic->lport->host_stats.fcp_control_requests++; in fnic_fcpio_icmnd_cmpl_handler()
1006 /* Call SCSI completion function to complete the IO */ in fnic_fcpio_icmnd_cmpl_handler()
1010 mempool_free(io_req, fnic->io_req_pool); in fnic_fcpio_icmnd_cmpl_handler()
1012 atomic64_dec(&fnic_stats->io_stats.active_ios); in fnic_fcpio_icmnd_cmpl_handler()
1013 if (atomic64_read(&fnic->io_cmpl_skip)) in fnic_fcpio_icmnd_cmpl_handler()
1014 atomic64_dec(&fnic->io_cmpl_skip); in fnic_fcpio_icmnd_cmpl_handler()
1016 atomic64_inc(&fnic_stats->io_stats.io_completions); in fnic_fcpio_icmnd_cmpl_handler()
1019 io_duration_time = jiffies_to_msecs(jiffies) - in fnic_fcpio_icmnd_cmpl_handler()
1023 atomic64_inc(&fnic_stats->io_stats.io_btw_0_to_10_msec); in fnic_fcpio_icmnd_cmpl_handler()
1025 atomic64_inc(&fnic_stats->io_stats.io_btw_10_to_100_msec); in fnic_fcpio_icmnd_cmpl_handler()
1027 atomic64_inc(&fnic_stats->io_stats.io_btw_100_to_500_msec); in fnic_fcpio_icmnd_cmpl_handler()
1029 atomic64_inc(&fnic_stats->io_stats.io_btw_500_to_5000_msec); in fnic_fcpio_icmnd_cmpl_handler()
1031 atomic64_inc(&fnic_stats->io_stats.io_btw_5000_to_10000_msec); in fnic_fcpio_icmnd_cmpl_handler()
1033 atomic64_inc(&fnic_stats->io_stats.io_btw_10000_to_30000_msec); in fnic_fcpio_icmnd_cmpl_handler()
1035 atomic64_inc(&fnic_stats->io_stats.io_greater_than_30000_msec); in fnic_fcpio_icmnd_cmpl_handler()
1037 if(io_duration_time > atomic64_read(&fnic_stats->io_stats.current_max_io_time)) in fnic_fcpio_icmnd_cmpl_handler()
1038 atomic64_set(&fnic_stats->io_stats.current_max_io_time, io_duration_time); in fnic_fcpio_icmnd_cmpl_handler()
1054 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_fcpio_itmf_cmpl_handler()
1055 struct abort_stats *abts_stats = &fnic->fnic_stats.abts_stats; in fnic_fcpio_itmf_cmpl_handler()
1056 struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; in fnic_fcpio_itmf_cmpl_handler()
1057 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; in fnic_fcpio_itmf_cmpl_handler()
1063 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &ftag); in fnic_fcpio_itmf_cmpl_handler()
1067 if (tag == fnic->fnic_max_tag_id) { in fnic_fcpio_itmf_cmpl_handler()
1069 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1074 } else if (tag > fnic->fnic_max_tag_id) { in fnic_fcpio_itmf_cmpl_handler()
1075 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1081 if ((tag == fnic->fnic_max_tag_id) && (id & FNIC_TAG_DEV_RST)) { in fnic_fcpio_itmf_cmpl_handler()
1082 sc = fnic->sgreset_sc; in fnic_fcpio_itmf_cmpl_handler()
1083 io_lock = &fnic->sgreset_lock; in fnic_fcpio_itmf_cmpl_handler()
1085 sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK); in fnic_fcpio_itmf_cmpl_handler()
1091 atomic64_inc(&fnic_stats->io_stats.sc_null); in fnic_fcpio_itmf_cmpl_handler()
1092 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1093 "itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n", in fnic_fcpio_itmf_cmpl_handler()
1099 io_req = fnic_priv(sc)->io_req; in fnic_fcpio_itmf_cmpl_handler()
1102 atomic64_inc(&fnic_stats->io_stats.ioreq_null); in fnic_fcpio_itmf_cmpl_handler()
1104 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; in fnic_fcpio_itmf_cmpl_handler()
1105 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1106 "itmf_cmpl io_req is null - " in fnic_fcpio_itmf_cmpl_handler()
1111 start_time = io_req->start_time; in fnic_fcpio_itmf_cmpl_handler()
1114 /* Abort and terminate completion of device reset req */ in fnic_fcpio_itmf_cmpl_handler()
1116 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1117 "dev reset abts cmpl recd. id %x status %s\n", in fnic_fcpio_itmf_cmpl_handler()
1119 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; in fnic_fcpio_itmf_cmpl_handler()
1120 fnic_priv(sc)->abts_status = hdr_status; in fnic_fcpio_itmf_cmpl_handler()
1121 fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; in fnic_fcpio_itmf_cmpl_handler()
1122 if (io_req->abts_done) in fnic_fcpio_itmf_cmpl_handler()
1123 complete(io_req->abts_done); in fnic_fcpio_itmf_cmpl_handler()
1131 if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED) in fnic_fcpio_itmf_cmpl_handler()
1132 atomic64_inc(&abts_stats->abort_fw_timeouts); in fnic_fcpio_itmf_cmpl_handler()
1135 &term_stats->terminate_fw_timeouts); in fnic_fcpio_itmf_cmpl_handler()
1138 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1143 if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED) in fnic_fcpio_itmf_cmpl_handler()
1144 atomic64_inc(&abts_stats->abort_io_not_found); in fnic_fcpio_itmf_cmpl_handler()
1147 &term_stats->terminate_io_not_found); in fnic_fcpio_itmf_cmpl_handler()
1150 if (fnic_priv(sc)->flags & FNIC_IO_ABTS_ISSUED) in fnic_fcpio_itmf_cmpl_handler()
1151 atomic64_inc(&abts_stats->abort_failures); in fnic_fcpio_itmf_cmpl_handler()
1154 &term_stats->terminate_failures); in fnic_fcpio_itmf_cmpl_handler()
1157 if (fnic_priv(sc)->state != FNIC_IOREQ_ABTS_PENDING) { in fnic_fcpio_itmf_cmpl_handler()
1163 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_DONE; in fnic_fcpio_itmf_cmpl_handler()
1164 fnic_priv(sc)->abts_status = hdr_status; in fnic_fcpio_itmf_cmpl_handler()
1166 /* If the status is IO not found consider it as success */ in fnic_fcpio_itmf_cmpl_handler()
1168 fnic_priv(sc)->abts_status = FCPIO_SUCCESS; in fnic_fcpio_itmf_cmpl_handler()
1170 if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) in fnic_fcpio_itmf_cmpl_handler()
1171 atomic64_inc(&misc_stats->no_icmnd_itmf_cmpls); in fnic_fcpio_itmf_cmpl_handler()
1173 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1180 * signal completion to it. IO will be cleaned in the thread in fnic_fcpio_itmf_cmpl_handler()
1183 if (io_req->abts_done) { in fnic_fcpio_itmf_cmpl_handler()
1184 complete(io_req->abts_done); in fnic_fcpio_itmf_cmpl_handler()
1187 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1188 "abts cmpl, completing IO\n"); in fnic_fcpio_itmf_cmpl_handler()
1189 fnic_priv(sc)->io_req = NULL; in fnic_fcpio_itmf_cmpl_handler()
1190 sc->result = (DID_ERROR << 16); in fnic_fcpio_itmf_cmpl_handler()
1195 mempool_free(io_req, fnic->io_req_pool); in fnic_fcpio_itmf_cmpl_handler()
1197 sc->device->host->host_no, id, in fnic_fcpio_itmf_cmpl_handler()
1199 jiffies_to_msecs(jiffies - start_time), in fnic_fcpio_itmf_cmpl_handler()
1202 (u64)sc->cmnd[0] << 32 | in fnic_fcpio_itmf_cmpl_handler()
1203 (u64)sc->cmnd[2] << 24 | in fnic_fcpio_itmf_cmpl_handler()
1204 (u64)sc->cmnd[3] << 16 | in fnic_fcpio_itmf_cmpl_handler()
1205 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), in fnic_fcpio_itmf_cmpl_handler()
1208 atomic64_dec(&fnic_stats->io_stats.active_ios); in fnic_fcpio_itmf_cmpl_handler()
1209 if (atomic64_read(&fnic->io_cmpl_skip)) in fnic_fcpio_itmf_cmpl_handler()
1210 atomic64_dec(&fnic->io_cmpl_skip); in fnic_fcpio_itmf_cmpl_handler()
1212 atomic64_inc(&fnic_stats->io_stats.io_completions); in fnic_fcpio_itmf_cmpl_handler()
1215 /* Completion of device reset */ in fnic_fcpio_itmf_cmpl_handler()
1216 fnic_priv(sc)->lr_status = hdr_status; in fnic_fcpio_itmf_cmpl_handler()
1217 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { in fnic_fcpio_itmf_cmpl_handler()
1219 fnic_priv(sc)->flags |= FNIC_DEV_RST_ABTS_PENDING; in fnic_fcpio_itmf_cmpl_handler()
1221 sc->device->host->host_no, id, sc, in fnic_fcpio_itmf_cmpl_handler()
1222 jiffies_to_msecs(jiffies - start_time), in fnic_fcpio_itmf_cmpl_handler()
1224 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1226 "dev reset cmpl recd. id %d status %s\n", in fnic_fcpio_itmf_cmpl_handler()
1231 if (fnic_priv(sc)->flags & FNIC_DEV_RST_TIMED_OUT) { in fnic_fcpio_itmf_cmpl_handler()
1235 sc->device->host->host_no, id, sc, in fnic_fcpio_itmf_cmpl_handler()
1236 jiffies_to_msecs(jiffies - start_time), in fnic_fcpio_itmf_cmpl_handler()
1238 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1239 "dev reset cmpl recd after time out. " in fnic_fcpio_itmf_cmpl_handler()
1245 fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; in fnic_fcpio_itmf_cmpl_handler()
1246 fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; in fnic_fcpio_itmf_cmpl_handler()
1247 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1248 "dev reset cmpl recd. id %d status %s\n", in fnic_fcpio_itmf_cmpl_handler()
1251 if (io_req->dr_done) in fnic_fcpio_itmf_cmpl_handler()
1252 complete(io_req->dr_done); in fnic_fcpio_itmf_cmpl_handler()
1256 shost_printk(KERN_ERR, fnic->lport->host, in fnic_fcpio_itmf_cmpl_handler()
1257 "Unexpected itmf io state %s tag %x\n", in fnic_fcpio_itmf_cmpl_handler()
1258 fnic_ioreq_state_to_str(fnic_priv(sc)->state), id); in fnic_fcpio_itmf_cmpl_handler()
1274 switch (desc->hdr.type) { in fnic_fcpio_cmpl_handler()
1276 case FCPIO_ITMF_CMPL: /* fw completed itmf (abort cmd, lun reset)*/ in fnic_fcpio_cmpl_handler()
1279 case FCPIO_RESET_CMPL: /* fw completed reset */ in fnic_fcpio_cmpl_handler()
1280 atomic64_dec(&fnic->fnic_stats.fw_stats.active_fw_reqs); in fnic_fcpio_cmpl_handler()
1286 switch (desc->hdr.type) { in fnic_fcpio_cmpl_handler()
1295 case FCPIO_ITMF_CMPL: /* fw completed itmf (abort cmd, lun reset)*/ in fnic_fcpio_cmpl_handler()
1304 case FCPIO_RESET_CMPL: /* fw completed reset */ in fnic_fcpio_cmpl_handler()
1309 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_fcpio_cmpl_handler()
1311 desc->hdr.type); in fnic_fcpio_cmpl_handler()
1327 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; in fnic_wq_copy_cmpl_handler()
1333 for (i = 0; i < fnic->wq_copy_count; i++) { in fnic_wq_copy_cmpl_handler()
1334 cq_index = i + fnic->raw_wq_count + fnic->rq_count; in fnic_wq_copy_cmpl_handler()
1337 cur_work_done = vnic_cq_copy_service(&fnic->cq[cq_index], in fnic_wq_copy_cmpl_handler()
1343 delta_jiffies = end_jiffies - start_jiffies; in fnic_wq_copy_cmpl_handler()
1345 (u64) atomic64_read(&misc_stats->max_isr_jiffies)) { in fnic_wq_copy_cmpl_handler()
1346 atomic64_set(&misc_stats->max_isr_jiffies, in fnic_wq_copy_cmpl_handler()
1349 atomic64_set(&misc_stats->max_isr_time_ms, delta_ms); in fnic_wq_copy_cmpl_handler()
1350 atomic64_set(&misc_stats->corr_work_done, in fnic_wq_copy_cmpl_handler()
1359 const int tag = scsi_cmd_to_rq(sc)->tag; in fnic_cleanup_io_iter()
1365 struct fnic_stats *fnic_stats = &fnic->fnic_stats; in fnic_cleanup_io_iter()
1370 io_req = fnic_priv(sc)->io_req; in fnic_cleanup_io_iter()
1371 if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && in fnic_cleanup_io_iter()
1372 !(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { in fnic_cleanup_io_iter()
1374 * We will be here only when FW completes reset in fnic_cleanup_io_iter()
1377 fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; in fnic_cleanup_io_iter()
1378 if (io_req && io_req->dr_done) in fnic_cleanup_io_iter()
1379 complete(io_req->dr_done); in fnic_cleanup_io_iter()
1380 else if (io_req && io_req->abts_done) in fnic_cleanup_io_iter()
1381 complete(io_req->abts_done); in fnic_cleanup_io_iter()
1384 } else if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { in fnic_cleanup_io_iter()
1393 fnic_priv(sc)->io_req = NULL; in fnic_cleanup_io_iter()
1401 start_time = io_req->start_time; in fnic_cleanup_io_iter()
1403 mempool_free(io_req, fnic->io_req_pool); in fnic_cleanup_io_iter()
1406 sc->result = DID_TRANSPORT_DISRUPTED << 16; in fnic_cleanup_io_iter()
1407 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_cleanup_io_iter()
1409 tag, sc, jiffies - start_time); in fnic_cleanup_io_iter()
1411 if (atomic64_read(&fnic->io_cmpl_skip)) in fnic_cleanup_io_iter()
1412 atomic64_dec(&fnic->io_cmpl_skip); in fnic_cleanup_io_iter()
1414 atomic64_inc(&fnic_stats->io_stats.io_completions); in fnic_cleanup_io_iter()
1417 if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) in fnic_cleanup_io_iter()
1418 shost_printk(KERN_ERR, fnic->lport->host, in fnic_cleanup_io_iter()
1419 "Calling done for IO not issued to fw: tag:0x%x sc:0x%p\n", in fnic_cleanup_io_iter()
1423 sc->device->host->host_no, tag, sc, in fnic_cleanup_io_iter()
1424 jiffies_to_msecs(jiffies - start_time), in fnic_cleanup_io_iter()
1425 0, ((u64)sc->cmnd[0] << 32 | in fnic_cleanup_io_iter()
1426 (u64)sc->cmnd[2] << 24 | in fnic_cleanup_io_iter()
1427 (u64)sc->cmnd[3] << 16 | in fnic_cleanup_io_iter()
1428 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), in fnic_cleanup_io_iter()
1438 scsi_host_busy_iter(fnic->lport->host, in fnic_cleanup_io()
1446 struct fnic *fnic = vnic_dev_priv(wq->vdev); in fnic_wq_copy_cleanup_handler()
1454 fcpio_tag_id_dec(&desc->hdr.tag, &id); in fnic_wq_copy_cleanup_handler()
1457 if (id >= fnic->fnic_max_tag_id) in fnic_wq_copy_cleanup_handler()
1460 sc = scsi_host_find_tag(fnic->lport->host, id); in fnic_wq_copy_cleanup_handler()
1467 /* Get the IO context which this desc refers to */ in fnic_wq_copy_cleanup_handler()
1468 io_req = fnic_priv(sc)->io_req; in fnic_wq_copy_cleanup_handler()
1477 fnic_priv(sc)->io_req = NULL; in fnic_wq_copy_cleanup_handler()
1481 start_time = io_req->start_time; in fnic_wq_copy_cleanup_handler()
1483 mempool_free(io_req, fnic->io_req_pool); in fnic_wq_copy_cleanup_handler()
1486 sc->result = DID_NO_CONNECT << 16; in fnic_wq_copy_cleanup_handler()
1487 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:" in fnic_wq_copy_cleanup_handler()
1491 sc->device->host->host_no, id, sc, in fnic_wq_copy_cleanup_handler()
1492 jiffies_to_msecs(jiffies - start_time), in fnic_wq_copy_cleanup_handler()
1493 0, ((u64)sc->cmnd[0] << 32 | in fnic_wq_copy_cleanup_handler()
1494 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | in fnic_wq_copy_cleanup_handler()
1495 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), in fnic_wq_copy_cleanup_handler()
1505 struct vnic_wq_copy *wq = &fnic->wq_copy[0]; in fnic_queue_abort_io_req()
1506 struct Scsi_Host *host = fnic->lport->host; in fnic_queue_abort_io_req()
1507 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; in fnic_queue_abort_io_req()
1510 spin_lock_irqsave(host->host_lock, flags); in fnic_queue_abort_io_req()
1513 spin_unlock_irqrestore(host->host_lock, flags); in fnic_queue_abort_io_req()
1516 atomic_inc(&fnic->in_flight); in fnic_queue_abort_io_req()
1517 spin_unlock_irqrestore(host->host_lock, flags); in fnic_queue_abort_io_req()
1519 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); in fnic_queue_abort_io_req()
1521 if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) in fnic_queue_abort_io_req()
1525 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); in fnic_queue_abort_io_req()
1526 atomic_dec(&fnic->in_flight); in fnic_queue_abort_io_req()
1527 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_queue_abort_io_req()
1529 atomic64_inc(&misc_stats->abts_cpwq_alloc_failures); in fnic_queue_abort_io_req()
1533 0, task_req, tag, fc_lun, io_req->port_id, in fnic_queue_abort_io_req()
1534 fnic->config.ra_tov, fnic->config.ed_tov); in fnic_queue_abort_io_req()
1536 atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); in fnic_queue_abort_io_req()
1537 if (atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs) > in fnic_queue_abort_io_req()
1538 atomic64_read(&fnic->fnic_stats.fw_stats.max_fw_reqs)) in fnic_queue_abort_io_req()
1539 atomic64_set(&fnic->fnic_stats.fw_stats.max_fw_reqs, in fnic_queue_abort_io_req()
1540 atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs)); in fnic_queue_abort_io_req()
1542 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); in fnic_queue_abort_io_req()
1543 atomic_dec(&fnic->in_flight); in fnic_queue_abort_io_req()
1557 struct fnic *fnic = iter_data->fnic; in fnic_rport_abort_io_iter()
1558 int abt_tag = scsi_cmd_to_rq(sc)->tag; in fnic_rport_abort_io_iter()
1562 struct reset_stats *reset_stats = &fnic->fnic_stats.reset_stats; in fnic_rport_abort_io_iter()
1563 struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; in fnic_rport_abort_io_iter()
1570 io_req = fnic_priv(sc)->io_req; in fnic_rport_abort_io_iter()
1572 if (!io_req || io_req->port_id != iter_data->port_id) { in fnic_rport_abort_io_iter()
1577 if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && in fnic_rport_abort_io_iter()
1578 !(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED)) { in fnic_rport_abort_io_iter()
1579 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_rport_abort_io_iter()
1587 * Found IO that is still pending with firmware and in fnic_rport_abort_io_iter()
1590 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { in fnic_rport_abort_io_iter()
1594 if (io_req->abts_done) { in fnic_rport_abort_io_iter()
1595 shost_printk(KERN_ERR, fnic->lport->host, in fnic_rport_abort_io_iter()
1596 "fnic_rport_exch_reset: io_req->abts_done is set " in fnic_rport_abort_io_iter()
1598 fnic_ioreq_state_to_str(fnic_priv(sc)->state)); in fnic_rport_abort_io_iter()
1601 if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) { in fnic_rport_abort_io_iter()
1602 shost_printk(KERN_ERR, fnic->lport->host, in fnic_rport_abort_io_iter()
1604 "IO not yet issued %p tag 0x%x flags " in fnic_rport_abort_io_iter()
1606 sc, abt_tag, fnic_priv(sc)->flags, fnic_priv(sc)->state); in fnic_rport_abort_io_iter()
1608 old_ioreq_state = fnic_priv(sc)->state; in fnic_rport_abort_io_iter()
1609 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; in fnic_rport_abort_io_iter()
1610 fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; in fnic_rport_abort_io_iter()
1611 if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { in fnic_rport_abort_io_iter()
1612 atomic64_inc(&reset_stats->device_reset_terminates); in fnic_rport_abort_io_iter()
1615 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_rport_abort_io_iter()
1617 BUG_ON(io_req->abts_done); in fnic_rport_abort_io_iter()
1619 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_rport_abort_io_iter()
1625 int_to_scsilun(sc->device->lun, &fc_lun); in fnic_rport_abort_io_iter()
1634 * lun reset in fnic_rport_abort_io_iter()
1637 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) in fnic_rport_abort_io_iter()
1638 fnic_priv(sc)->state = old_ioreq_state; in fnic_rport_abort_io_iter()
1642 if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) in fnic_rport_abort_io_iter()
1643 fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; in fnic_rport_abort_io_iter()
1645 fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED; in fnic_rport_abort_io_iter()
1647 atomic64_inc(&term_stats->terminates); in fnic_rport_abort_io_iter()
1648 iter_data->term_cnt++; in fnic_rport_abort_io_iter()
1655 struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; in fnic_rport_exch_reset()
1663 fnic->lport->host, in fnic_rport_exch_reset()
1667 if (fnic->in_remove) in fnic_rport_exch_reset()
1670 scsi_host_busy_iter(fnic->lport->host, fnic_rport_abort_io_iter, in fnic_rport_exch_reset()
1672 if (iter_data.term_cnt > atomic64_read(&term_stats->max_terminates)) in fnic_rport_exch_reset()
1673 atomic64_set(&term_stats->max_terminates, iter_data.term_cnt); in fnic_rport_exch_reset()
1687 rdata = rport->dd_data; in fnic_terminate_rport_io()
1693 lport = rdata->local_port; in fnic_terminate_rport_io()
1701 fnic->lport->host, "fnic_terminate_rport_io called" in fnic_terminate_rport_io()
1703 rport->port_name, rport->node_name, rport, in fnic_terminate_rport_io()
1704 rport->port_id); in fnic_terminate_rport_io()
1706 if (fnic->in_remove) in fnic_terminate_rport_io()
1709 fnic_rport_exch_reset(fnic, rport->port_id); in fnic_terminate_rport_io()
1714 * A SCSI IO is represented by a io_req in the driver.
1715 * The ioreq is linked to the SCSI Cmd, thus a link with the ULP's IO.
1734 const int tag = rq->tag; in fnic_abort_cmd()
1741 /* Get local-port, check ready and link up */ in fnic_abort_cmd()
1742 lp = shost_priv(sc->device->host); in fnic_abort_cmd()
1745 fnic_stats = &fnic->fnic_stats; in fnic_abort_cmd()
1746 abts_stats = &fnic->fnic_stats.abts_stats; in fnic_abort_cmd()
1747 term_stats = &fnic->fnic_stats.term_stats; in fnic_abort_cmd()
1749 rport = starget_to_rport(scsi_target(sc->device)); in fnic_abort_cmd()
1751 fnic->lport->host, in fnic_abort_cmd()
1753 rport->port_id, sc->device->lun, tag, fnic_priv(sc)->flags); in fnic_abort_cmd()
1755 fnic_priv(sc)->flags = FNIC_NO_FLAGS; in fnic_abort_cmd()
1757 if (lp->state != LPORT_ST_READY || !(lp->link_up)) { in fnic_abort_cmd()
1776 io_req = fnic_priv(sc)->io_req; in fnic_abort_cmd()
1782 io_req->abts_done = &tm_done; in fnic_abort_cmd()
1784 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { in fnic_abort_cmd()
1789 abt_issued_time = jiffies_to_msecs(jiffies) - jiffies_to_msecs(io_req->start_time); in fnic_abort_cmd()
1791 atomic64_inc(&abts_stats->abort_issued_btw_0_to_6_sec); in fnic_abort_cmd()
1793 atomic64_inc(&abts_stats->abort_issued_btw_6_to_20_sec); in fnic_abort_cmd()
1795 atomic64_inc(&abts_stats->abort_issued_btw_20_to_30_sec); in fnic_abort_cmd()
1797 atomic64_inc(&abts_stats->abort_issued_btw_30_to_40_sec); in fnic_abort_cmd()
1799 atomic64_inc(&abts_stats->abort_issued_btw_40_to_50_sec); in fnic_abort_cmd()
1801 atomic64_inc(&abts_stats->abort_issued_btw_50_to_60_sec); in fnic_abort_cmd()
1803 atomic64_inc(&abts_stats->abort_issued_greater_than_60_sec); in fnic_abort_cmd()
1805 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_abort_cmd()
1806 "CBD Opcode: %02x Abort issued time: %lu msec\n", sc->cmnd[0], abt_issued_time); in fnic_abort_cmd()
1810 * the completion wont be done till mid-layer, since abort in fnic_abort_cmd()
1813 old_ioreq_state = fnic_priv(sc)->state; in fnic_abort_cmd()
1814 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; in fnic_abort_cmd()
1815 fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; in fnic_abort_cmd()
1822 * the IO. Else, just locally terminate the IO in the firmware in fnic_abort_cmd()
1827 atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); in fnic_abort_cmd()
1832 int_to_scsilun(sc->device->lun, &fc_lun); in fnic_abort_cmd()
1837 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) in fnic_abort_cmd()
1838 fnic_priv(sc)->state = old_ioreq_state; in fnic_abort_cmd()
1839 io_req = fnic_priv(sc)->io_req; in fnic_abort_cmd()
1841 io_req->abts_done = NULL; in fnic_abort_cmd()
1847 fnic_priv(sc)->flags |= FNIC_IO_ABTS_ISSUED; in fnic_abort_cmd()
1848 atomic64_inc(&fnic_stats->abts_stats.aborts); in fnic_abort_cmd()
1850 fnic_priv(sc)->flags |= FNIC_IO_TERM_ISSUED; in fnic_abort_cmd()
1851 atomic64_inc(&fnic_stats->term_stats.terminates); in fnic_abort_cmd()
1855 * We queued an abort IO, wait for its completion. in fnic_abort_cmd()
1862 (2 * fnic->config.ra_tov + in fnic_abort_cmd()
1863 fnic->config.ed_tov)); in fnic_abort_cmd()
1868 io_req = fnic_priv(sc)->io_req; in fnic_abort_cmd()
1870 atomic64_inc(&fnic_stats->io_stats.ioreq_null); in fnic_abort_cmd()
1872 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; in fnic_abort_cmd()
1876 io_req->abts_done = NULL; in fnic_abort_cmd()
1879 if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) { in fnic_abort_cmd()
1882 atomic64_inc(&abts_stats->abort_drv_timeouts); in fnic_abort_cmd()
1884 atomic64_inc(&term_stats->terminate_drv_timeouts); in fnic_abort_cmd()
1886 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_TIMED_OUT; in fnic_abort_cmd()
1891 /* IO out of order */ in fnic_abort_cmd()
1893 if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) { in fnic_abort_cmd()
1895 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_abort_cmd()
1896 "Issuing Host reset due to out of order IO\n"); in fnic_abort_cmd()
1902 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; in fnic_abort_cmd()
1904 start_time = io_req->start_time; in fnic_abort_cmd()
1908 * Device reset will clean the I/O. in fnic_abort_cmd()
1910 if (fnic_priv(sc)->abts_status == FCPIO_SUCCESS) { in fnic_abort_cmd()
1911 fnic_priv(sc)->io_req = NULL; in fnic_abort_cmd()
1921 mempool_free(io_req, fnic->io_req_pool); in fnic_abort_cmd()
1923 /* Call SCSI completion function to complete the IO */ in fnic_abort_cmd()
1924 sc->result = DID_ABORT << 16; in fnic_abort_cmd()
1926 atomic64_dec(&fnic_stats->io_stats.active_ios); in fnic_abort_cmd()
1927 if (atomic64_read(&fnic->io_cmpl_skip)) in fnic_abort_cmd()
1928 atomic64_dec(&fnic->io_cmpl_skip); in fnic_abort_cmd()
1930 atomic64_inc(&fnic_stats->io_stats.io_completions); in fnic_abort_cmd()
1933 FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no, tag, sc, in fnic_abort_cmd()
1934 jiffies_to_msecs(jiffies - start_time), in fnic_abort_cmd()
1935 0, ((u64)sc->cmnd[0] << 32 | in fnic_abort_cmd()
1936 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | in fnic_abort_cmd()
1937 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), in fnic_abort_cmd()
1940 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_abort_cmd()
1951 struct vnic_wq_copy *wq = &fnic->wq_copy[0]; in fnic_queue_dr_io_req()
1952 struct Scsi_Host *host = fnic->lport->host; in fnic_queue_dr_io_req()
1953 struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; in fnic_queue_dr_io_req()
1957 unsigned int tag = scsi_cmd_to_rq(sc)->tag; in fnic_queue_dr_io_req()
1960 tag = io_req->tag; in fnic_queue_dr_io_req()
1962 spin_lock_irqsave(host->host_lock, intr_flags); in fnic_queue_dr_io_req()
1965 spin_unlock_irqrestore(host->host_lock, intr_flags); in fnic_queue_dr_io_req()
1968 atomic_inc(&fnic->in_flight); in fnic_queue_dr_io_req()
1969 spin_unlock_irqrestore(host->host_lock, intr_flags); in fnic_queue_dr_io_req()
1971 spin_lock_irqsave(&fnic->wq_copy_lock[0], intr_flags); in fnic_queue_dr_io_req()
1973 if (vnic_wq_copy_desc_avail(wq) <= fnic->wq_copy_desc_low[0]) in fnic_queue_dr_io_req()
1977 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_queue_dr_io_req()
1978 "queue_dr_io_req failure - no descriptors\n"); in fnic_queue_dr_io_req()
1979 atomic64_inc(&misc_stats->devrst_cpwq_alloc_failures); in fnic_queue_dr_io_req()
1980 ret = -EAGAIN; in fnic_queue_dr_io_req()
1985 int_to_scsilun(sc->device->lun, &fc_lun); in fnic_queue_dr_io_req()
1990 fc_lun.scsi_lun, io_req->port_id, in fnic_queue_dr_io_req()
1991 fnic->config.ra_tov, fnic->config.ed_tov); in fnic_queue_dr_io_req()
1993 atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); in fnic_queue_dr_io_req()
1994 if (atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs) > in fnic_queue_dr_io_req()
1995 atomic64_read(&fnic->fnic_stats.fw_stats.max_fw_reqs)) in fnic_queue_dr_io_req()
1996 atomic64_set(&fnic->fnic_stats.fw_stats.max_fw_reqs, in fnic_queue_dr_io_req()
1997 atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs)); in fnic_queue_dr_io_req()
2000 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], intr_flags); in fnic_queue_dr_io_req()
2001 atomic_dec(&fnic->in_flight); in fnic_queue_dr_io_req()
2016 struct fnic *fnic = iter_data->fnic; in fnic_pending_aborts_iter()
2017 struct scsi_device *lun_dev = iter_data->lun_dev; in fnic_pending_aborts_iter()
2018 int abt_tag = scsi_cmd_to_rq(sc)->tag; in fnic_pending_aborts_iter()
2026 if (sc == iter_data->lr_sc || sc->device != lun_dev) in fnic_pending_aborts_iter()
2031 io_req = fnic_priv(sc)->io_req; in fnic_pending_aborts_iter()
2038 * Found IO that is still pending with firmware and in fnic_pending_aborts_iter()
2041 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_pending_aborts_iter()
2042 "Found IO in %s on lun\n", in fnic_pending_aborts_iter()
2043 fnic_ioreq_state_to_str(fnic_priv(sc)->state)); in fnic_pending_aborts_iter()
2045 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) { in fnic_pending_aborts_iter()
2049 if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && in fnic_pending_aborts_iter()
2050 (!(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED))) { in fnic_pending_aborts_iter()
2051 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_pending_aborts_iter()
2058 if (io_req->abts_done) in fnic_pending_aborts_iter()
2059 shost_printk(KERN_ERR, fnic->lport->host, in fnic_pending_aborts_iter()
2060 "%s: io_req->abts_done is set state is %s\n", in fnic_pending_aborts_iter()
2061 __func__, fnic_ioreq_state_to_str(fnic_priv(sc)->state)); in fnic_pending_aborts_iter()
2062 old_ioreq_state = fnic_priv(sc)->state; in fnic_pending_aborts_iter()
2064 * Any pending IO issued prior to reset is expected to be in fnic_pending_aborts_iter()
2066 * FNIC_IOREQ_ABTS_PENDING to indicate the IO is abort pending. in fnic_pending_aborts_iter()
2067 * When IO is completed, the IO will be handed over and in fnic_pending_aborts_iter()
2070 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; in fnic_pending_aborts_iter()
2072 BUG_ON(io_req->abts_done); in fnic_pending_aborts_iter()
2074 if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { in fnic_pending_aborts_iter()
2076 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_pending_aborts_iter()
2080 fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; in fnic_pending_aborts_iter()
2081 io_req->abts_done = &tm_done; in fnic_pending_aborts_iter()
2085 int_to_scsilun(sc->device->lun, &fc_lun); in fnic_pending_aborts_iter()
2091 io_req = fnic_priv(sc)->io_req; in fnic_pending_aborts_iter()
2093 io_req->abts_done = NULL; in fnic_pending_aborts_iter()
2094 if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) in fnic_pending_aborts_iter()
2095 fnic_priv(sc)->state = old_ioreq_state; in fnic_pending_aborts_iter()
2097 iter_data->ret = FAILED; in fnic_pending_aborts_iter()
2101 if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) in fnic_pending_aborts_iter()
2102 fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; in fnic_pending_aborts_iter()
2105 fnic_priv(sc)->flags |= FNIC_IO_INTERNAL_TERM_ISSUED; in fnic_pending_aborts_iter()
2108 (fnic->config.ed_tov)); in fnic_pending_aborts_iter()
2112 io_req = fnic_priv(sc)->io_req; in fnic_pending_aborts_iter()
2115 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; in fnic_pending_aborts_iter()
2119 io_req->abts_done = NULL; in fnic_pending_aborts_iter()
2122 if (fnic_priv(sc)->abts_status == FCPIO_INVALID_CODE) { in fnic_pending_aborts_iter()
2124 fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_DONE; in fnic_pending_aborts_iter()
2125 iter_data->ret = FAILED; in fnic_pending_aborts_iter()
2128 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_COMPLETE; in fnic_pending_aborts_iter()
2130 /* original sc used for lr is handled by dev reset code */ in fnic_pending_aborts_iter()
2131 if (sc != iter_data->lr_sc) in fnic_pending_aborts_iter()
2132 fnic_priv(sc)->io_req = NULL; in fnic_pending_aborts_iter()
2135 /* original sc used for lr is handled by dev reset code */ in fnic_pending_aborts_iter()
2136 if (sc != iter_data->lr_sc) { in fnic_pending_aborts_iter()
2138 mempool_free(io_req, fnic->io_req_pool); in fnic_pending_aborts_iter()
2142 * Any IO is returned during reset, it needs to call scsi_done in fnic_pending_aborts_iter()
2146 sc->result = DID_RESET << 16; in fnic_pending_aborts_iter()
2154 * For each outstanding IO on this lun, whose abort is not completed by fw,
2166 .lun_dev = lr_sc->device, in fnic_clean_pending_aborts()
2172 scsi_host_busy_iter(fnic->lport->host, in fnic_clean_pending_aborts()
2178 schedule_timeout(msecs_to_jiffies(2 * fnic->config.ed_tov)); in fnic_clean_pending_aborts()
2185 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_clean_pending_aborts()
2191 * SCSI Eh thread issues a Lun Reset when one or more commands on a LUN
2210 int tag = rq->tag; in fnic_device_reset()
2217 /* Get local-port, check ready and link up */ in fnic_device_reset()
2218 lp = shost_priv(sc->device->host); in fnic_device_reset()
2221 fnic_stats = &fnic->fnic_stats; in fnic_device_reset()
2222 reset_stats = &fnic->fnic_stats.reset_stats; in fnic_device_reset()
2224 atomic64_inc(&reset_stats->device_resets); in fnic_device_reset()
2226 rport = starget_to_rport(scsi_target(sc->device)); in fnic_device_reset()
2227 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_device_reset()
2228 "Device reset called FCID 0x%x, LUN 0x%llx sc 0x%p\n", in fnic_device_reset()
2229 rport->port_id, sc->device->lun, sc); in fnic_device_reset()
2231 if (lp->state != LPORT_ST_READY || !(lp->link_up)) in fnic_device_reset()
2236 atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); in fnic_device_reset()
2240 fnic_priv(sc)->flags = FNIC_DEVICE_RESET; in fnic_device_reset()
2244 * For device reset issued through sg3utils, we let in fnic_device_reset()
2250 mutex_lock(&fnic->sgreset_mutex); in fnic_device_reset()
2251 tag = fnic->fnic_max_tag_id; in fnic_device_reset()
2253 fnic->sgreset_sc = sc; in fnic_device_reset()
2254 io_lock = &fnic->sgreset_lock; in fnic_device_reset()
2255 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_device_reset()
2257 rport->port_id, sc->device->lun, fnic_priv(sc)->flags, tag); in fnic_device_reset()
2262 io_req = fnic_priv(sc)->io_req; in fnic_device_reset()
2269 io_req = mempool_alloc(fnic->io_req_pool, GFP_ATOMIC); in fnic_device_reset()
2275 io_req->port_id = rport->port_id; in fnic_device_reset()
2276 io_req->tag = tag; in fnic_device_reset()
2277 io_req->sc = sc; in fnic_device_reset()
2278 fnic_priv(sc)->io_req = io_req; in fnic_device_reset()
2280 io_req->dr_done = &tm_done; in fnic_device_reset()
2281 fnic_priv(sc)->state = FNIC_IOREQ_CMD_PENDING; in fnic_device_reset()
2282 fnic_priv(sc)->lr_status = FCPIO_INVALID_CODE; in fnic_device_reset()
2285 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "TAG %x\n", tag); in fnic_device_reset()
2288 * issue the device reset, if enqueue failed, clean up the ioreq in fnic_device_reset()
2293 io_req = fnic_priv(sc)->io_req; in fnic_device_reset()
2295 io_req->dr_done = NULL; in fnic_device_reset()
2299 fnic_priv(sc)->flags |= FNIC_DEV_RST_ISSUED; in fnic_device_reset()
2303 * Wait on the local completion for LUN reset. The io_req may be in fnic_device_reset()
2310 io_req = fnic_priv(sc)->io_req; in fnic_device_reset()
2313 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_device_reset()
2317 io_req->dr_done = NULL; in fnic_device_reset()
2319 status = fnic_priv(sc)->lr_status; in fnic_device_reset()
2322 * If lun reset not completed, bail out with failed. io_req in fnic_device_reset()
2326 atomic64_inc(&reset_stats->device_reset_timeouts); in fnic_device_reset()
2327 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_device_reset()
2328 "Device reset timed out\n"); in fnic_device_reset()
2329 fnic_priv(sc)->flags |= FNIC_DEV_RST_TIMED_OUT; in fnic_device_reset()
2331 int_to_scsilun(sc->device->lun, &fc_lun); in fnic_device_reset()
2333 * Issue abort and terminate on device reset request. in fnic_device_reset()
2338 if (fnic_priv(sc)->flags & FNIC_DEV_RST_TERM_ISSUED) { in fnic_device_reset()
2351 fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; in fnic_device_reset()
2352 fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; in fnic_device_reset()
2353 io_req->abts_done = &tm_done; in fnic_device_reset()
2355 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_device_reset()
2356 "Abort and terminate issued on Device reset " in fnic_device_reset()
2363 if (!(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { in fnic_device_reset()
2369 io_req = fnic_priv(sc)->io_req; in fnic_device_reset()
2370 io_req->abts_done = NULL; in fnic_device_reset()
2382 fnic->lport->host, in fnic_device_reset()
2383 "Device reset completed - failed\n"); in fnic_device_reset()
2384 io_req = fnic_priv(sc)->io_req; in fnic_device_reset()
2390 * completed. If any of these fail, then LUN reset fails. in fnic_device_reset()
2392 * the lun reset cmd. If all cmds get cleaned, the lun reset in fnic_device_reset()
2397 io_req = fnic_priv(sc)->io_req; in fnic_device_reset()
2398 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_device_reset()
2399 "Device reset failed" in fnic_device_reset()
2404 /* Clean lun reset command */ in fnic_device_reset()
2406 io_req = fnic_priv(sc)->io_req; in fnic_device_reset()
2413 fnic_priv(sc)->io_req = NULL; in fnic_device_reset()
2418 start_time = io_req->start_time; in fnic_device_reset()
2420 mempool_free(io_req, fnic->io_req_pool); in fnic_device_reset()
2424 FNIC_TRACE(fnic_device_reset, sc->device->host->host_no, rq->tag, sc, in fnic_device_reset()
2425 jiffies_to_msecs(jiffies - start_time), in fnic_device_reset()
2426 0, ((u64)sc->cmnd[0] << 32 | in fnic_device_reset()
2427 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | in fnic_device_reset()
2428 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), in fnic_device_reset()
2432 fnic->sgreset_sc = NULL; in fnic_device_reset()
2433 mutex_unlock(&fnic->sgreset_mutex); in fnic_device_reset()
2436 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_device_reset()
2437 "Returning from device reset %s\n", in fnic_device_reset()
2442 atomic64_inc(&reset_stats->device_reset_failures); in fnic_device_reset()
2457 reset_stats = &fnic->fnic_stats.reset_stats; in fnic_reset()
2459 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_reset()
2462 atomic64_inc(&reset_stats->fnic_resets); in fnic_reset()
2465 * Reset local port, this will clean up libFC exchanges, in fnic_reset()
2466 * reset remote port sessions, and if link is up, begin flogi in fnic_reset()
2470 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_reset()
2471 "Returning from fnic reset %s\n", in fnic_reset()
2476 atomic64_inc(&reset_stats->fnic_reset_completions); in fnic_reset()
2478 atomic64_inc(&reset_stats->fnic_reset_failures); in fnic_reset()
2485 * error handling levels return FAILED. If host reset completes
2488 * Host Reset is the highest level of error recovery. If this fails, then
2496 struct Scsi_Host *shost = sc->device->host; in fnic_host_reset()
2501 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_host_reset()
2502 if (!fnic->internal_reset_inprogress) { in fnic_host_reset()
2503 fnic->internal_reset_inprogress = true; in fnic_host_reset()
2505 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_host_reset()
2506 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_host_reset()
2507 "host reset in progress skipping another host reset\n"); in fnic_host_reset()
2510 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_host_reset()
2514 * scsi-ml tries to send a TUR to every device if host reset is in fnic_host_reset()
2522 if ((lp->state == LPORT_ST_READY) && in fnic_host_reset()
2523 (lp->link_up)) { in fnic_host_reset()
2531 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_host_reset()
2532 fnic->internal_reset_inprogress = false; in fnic_host_reset()
2533 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_host_reset()
2548 /* Issue firmware reset for fnic, wait for reset to complete */ in fnic_scsi_abort_io()
2550 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_scsi_abort_io()
2551 if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) && in fnic_scsi_abort_io()
2552 fnic->link_events) { in fnic_scsi_abort_io()
2553 /* fw reset is in progress, poll for its completion */ in fnic_scsi_abort_io()
2554 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_scsi_abort_io()
2559 fnic->remove_wait = &remove_wait; in fnic_scsi_abort_io()
2560 old_state = fnic->state; in fnic_scsi_abort_io()
2561 fnic->state = FNIC_IN_FC_TRANS_ETH_MODE; in fnic_scsi_abort_io()
2562 fnic_update_mac_locked(fnic, fnic->ctlr.ctl_src_addr); in fnic_scsi_abort_io()
2563 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_scsi_abort_io()
2567 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_scsi_abort_io()
2568 if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) in fnic_scsi_abort_io()
2569 fnic->state = old_state; in fnic_scsi_abort_io()
2570 fnic->remove_wait = NULL; in fnic_scsi_abort_io()
2571 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_scsi_abort_io()
2575 /* Wait for firmware reset to complete */ in fnic_scsi_abort_io()
2579 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_scsi_abort_io()
2580 fnic->remove_wait = NULL; in fnic_scsi_abort_io()
2581 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, in fnic_scsi_abort_io()
2583 (fnic->state == FNIC_IN_ETH_MODE) ? in fnic_scsi_abort_io()
2585 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_scsi_abort_io()
2590 * This fxn called from libFC to clean up driver IO state on link down
2598 /* issue fw reset */ in fnic_scsi_cleanup()
2600 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_scsi_cleanup()
2601 if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)) { in fnic_scsi_cleanup()
2602 /* fw reset is in progress, poll for its completion */ in fnic_scsi_cleanup()
2603 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_scsi_cleanup()
2607 old_state = fnic->state; in fnic_scsi_cleanup()
2608 fnic->state = FNIC_IN_FC_TRANS_ETH_MODE; in fnic_scsi_cleanup()
2609 fnic_update_mac_locked(fnic, fnic->ctlr.ctl_src_addr); in fnic_scsi_cleanup()
2610 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_scsi_cleanup()
2613 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_scsi_cleanup()
2614 if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) in fnic_scsi_cleanup()
2615 fnic->state = old_state; in fnic_scsi_cleanup()
2616 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_scsi_cleanup()
2629 /* Non-zero sid, nothing to do */ in fnic_exch_mgr_reset()
2642 if (!fnic->in_remove) in fnic_exch_mgr_reset()
2647 /* call libFC exch mgr reset to reset its exchanges */ in fnic_exch_mgr_reset()
2656 struct fnic *fnic = iter_data->fnic; in fnic_abts_pending_iter()
2663 * ignore this lun reset cmd or cmds that do not belong to in fnic_abts_pending_iter()
2666 if (iter_data->lr_sc && sc == iter_data->lr_sc) in fnic_abts_pending_iter()
2668 if (iter_data->lun_dev && sc->device != iter_data->lun_dev) in fnic_abts_pending_iter()
2674 io_req = fnic_priv(sc)->io_req; in fnic_abts_pending_iter()
2681 * Found IO that is still pending with firmware and in fnic_abts_pending_iter()
2684 FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, in fnic_abts_pending_iter()
2685 "Found IO in %s on lun\n", in fnic_abts_pending_iter()
2686 fnic_ioreq_state_to_str(fnic_priv(sc)->state)); in fnic_abts_pending_iter()
2687 cmd_state = fnic_priv(sc)->state; in fnic_abts_pending_iter()
2690 iter_data->ret = 1; in fnic_abts_pending_iter()
2692 return iter_data->ret ? false : true; in fnic_abts_pending_iter()
2711 iter_data.lun_dev = lr_sc->device; in fnic_is_abts_pending()
2716 scsi_host_busy_iter(fnic->lport->host, in fnic_is_abts_pending()