Lines Matching +full:timeout +full:- +full:ulp +full:- +full:ms
4 * Copyright (c) 2008-2013 Broadcom Corporation
5 * Copyright (c) 2014-2016 QLogic Corporation
6 * Copyright (c) 2016-2017 Cavium Inc.
32 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_cmd_timer_set()
34 if (queue_delayed_work(interface->timer_work_queue, in bnx2fc_cmd_timer_set()
35 &io_req->timeout_work, in bnx2fc_cmd_timer_set()
37 kref_get(&io_req->refcount); in bnx2fc_cmd_timer_set()
44 u8 cmd_type = io_req->cmd_type; in bnx2fc_cmd_timeout()
45 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_cmd_timeout()
49 "req_flags = %lx\n", cmd_type, io_req->req_flags); in bnx2fc_cmd_timeout()
51 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_cmd_timeout()
52 if (test_and_clear_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
53 clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_cmd_timeout()
56 * and release io_req from timeout hold. in bnx2fc_cmd_timeout()
58 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_cmd_timeout()
62 if (test_and_clear_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
70 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
71 /* Handle eh_abort timeout */ in bnx2fc_cmd_timeout()
73 complete(&io_req->abts_done); in bnx2fc_cmd_timeout()
75 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
76 /* Handle internally generated ABTS timeout */ in bnx2fc_cmd_timeout()
78 kref_read(&io_req->refcount)); in bnx2fc_cmd_timeout()
80 &io_req->req_flags))) { in bnx2fc_cmd_timeout()
83 * mid-layer. in bnx2fc_cmd_timeout()
86 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
87 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_cmd_timeout()
92 /* Hanlde IO timeout */ in bnx2fc_cmd_timeout()
95 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
102 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
107 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
108 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_cmd_timeout()
119 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_cmd_timeout()
123 &io_req->req_flags)) { in bnx2fc_cmd_timeout()
124 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
125 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_cmd_timeout()
131 * Handle ELS timeout. in bnx2fc_cmd_timeout()
132 * tgt_lock is used to sync compl path and timeout in bnx2fc_cmd_timeout()
138 &io_req->req_flags)) in bnx2fc_cmd_timeout()
142 set_bit(BNX2FC_FLAG_ELS_TIMEOUT, &io_req->req_flags); in bnx2fc_cmd_timeout()
144 if ((io_req->cb_func) && (io_req->cb_arg)) { in bnx2fc_cmd_timeout()
145 io_req->cb_func(io_req->cb_arg); in bnx2fc_cmd_timeout()
146 io_req->cb_arg = NULL; in bnx2fc_cmd_timeout()
158 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_cmd_timeout()
159 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_cmd_timeout()
165 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_scsi_done()
172 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_scsi_done()
176 if (test_bit(BNX2FC_FLAG_CMD_LOST, &io_req->req_flags)) { in bnx2fc_scsi_done()
182 io_req->sc_cmd = NULL; in bnx2fc_scsi_done()
184 /* Sanity checks before returning command to mid-layer */ in bnx2fc_scsi_done()
186 printk(KERN_ERR PFX "scsi_done - sc_cmd NULL. " in bnx2fc_scsi_done()
188 io_req->xid); in bnx2fc_scsi_done()
191 if (!sc_cmd->device) { in bnx2fc_scsi_done()
192 pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid); in bnx2fc_scsi_done()
195 if (!sc_cmd->device->host) { in bnx2fc_scsi_done()
196 pr_err(PFX "0x%x: sc_cmd->device->host is NULL.\n", in bnx2fc_scsi_done()
197 io_req->xid); in bnx2fc_scsi_done()
201 sc_cmd->result = err_code << 16; in bnx2fc_scsi_done()
204 sc_cmd, host_byte(sc_cmd->result), sc_cmd->retries, in bnx2fc_scsi_done()
205 sc_cmd->allowed); in bnx2fc_scsi_done()
207 bnx2fc_priv(sc_cmd)->io_req = NULL; in bnx2fc_scsi_done()
224 u16 max_xid = hba->max_xid; in bnx2fc_cmd_mgr_alloc()
233 num_ios = max_xid - min_xid + 1; in bnx2fc_cmd_mgr_alloc()
243 cmgr->hba = hba; in bnx2fc_cmd_mgr_alloc()
244 cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list), in bnx2fc_cmd_mgr_alloc()
246 if (!cmgr->free_list) { in bnx2fc_cmd_mgr_alloc()
251 cmgr->free_list_lock = kcalloc(arr_sz, sizeof(*cmgr->free_list_lock), in bnx2fc_cmd_mgr_alloc()
253 if (!cmgr->free_list_lock) { in bnx2fc_cmd_mgr_alloc()
255 kfree(cmgr->free_list); in bnx2fc_cmd_mgr_alloc()
256 cmgr->free_list = NULL; in bnx2fc_cmd_mgr_alloc()
260 cmgr->cmds = (struct bnx2fc_cmd **)(cmgr + 1); in bnx2fc_cmd_mgr_alloc()
263 INIT_LIST_HEAD(&cmgr->free_list[i]); in bnx2fc_cmd_mgr_alloc()
264 spin_lock_init(&cmgr->free_list_lock[i]); in bnx2fc_cmd_mgr_alloc()
268 * Pre-allocated pool of bnx2fc_cmds. in bnx2fc_cmd_mgr_alloc()
273 num_pri_ios = num_ios - hba->elstm_xids; in bnx2fc_cmd_mgr_alloc()
282 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_mgr_alloc()
283 INIT_DELAYED_WORK(&io_req->timeout_work, bnx2fc_cmd_timeout); in bnx2fc_cmd_mgr_alloc()
285 io_req->xid = xid++; in bnx2fc_cmd_mgr_alloc()
287 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
288 &cmgr->free_list[io_req->xid % in bnx2fc_cmd_mgr_alloc()
291 list_add_tail(&io_req->link, in bnx2fc_cmd_mgr_alloc()
292 &cmgr->free_list[num_possible_cpus()]); in bnx2fc_cmd_mgr_alloc()
296 /* Allocate pool of io_bdts - one for each bnx2fc_cmd */ in bnx2fc_cmd_mgr_alloc()
298 cmgr->io_bdt_pool = kzalloc(mem_size, GFP_KERNEL); in bnx2fc_cmd_mgr_alloc()
299 if (!cmgr->io_bdt_pool) { in bnx2fc_cmd_mgr_alloc()
306 cmgr->io_bdt_pool[i] = kmalloc(mem_size, GFP_KERNEL); in bnx2fc_cmd_mgr_alloc()
307 if (!cmgr->io_bdt_pool[i]) { in bnx2fc_cmd_mgr_alloc()
317 bdt_info = cmgr->io_bdt_pool[i]; in bnx2fc_cmd_mgr_alloc()
318 bdt_info->bd_tbl = dma_alloc_coherent(&hba->pcidev->dev, in bnx2fc_cmd_mgr_alloc()
320 &bdt_info->bd_tbl_dma, in bnx2fc_cmd_mgr_alloc()
322 if (!bdt_info->bd_tbl) { in bnx2fc_cmd_mgr_alloc()
339 struct bnx2fc_hba *hba = cmgr->hba; in bnx2fc_cmd_mgr_free()
342 u16 max_xid = hba->max_xid; in bnx2fc_cmd_mgr_free()
346 num_ios = max_xid - min_xid + 1; in bnx2fc_cmd_mgr_free()
349 if (!cmgr->io_bdt_pool) in bnx2fc_cmd_mgr_free()
354 bdt_info = cmgr->io_bdt_pool[i]; in bnx2fc_cmd_mgr_free()
355 if (bdt_info->bd_tbl) { in bnx2fc_cmd_mgr_free()
356 dma_free_coherent(&hba->pcidev->dev, bd_tbl_sz, in bnx2fc_cmd_mgr_free()
357 bdt_info->bd_tbl, in bnx2fc_cmd_mgr_free()
358 bdt_info->bd_tbl_dma); in bnx2fc_cmd_mgr_free()
359 bdt_info->bd_tbl = NULL; in bnx2fc_cmd_mgr_free()
365 kfree(cmgr->io_bdt_pool[i]); in bnx2fc_cmd_mgr_free()
366 cmgr->io_bdt_pool[i] = NULL; in bnx2fc_cmd_mgr_free()
369 kfree(cmgr->io_bdt_pool); in bnx2fc_cmd_mgr_free()
370 cmgr->io_bdt_pool = NULL; in bnx2fc_cmd_mgr_free()
373 kfree(cmgr->free_list_lock); in bnx2fc_cmd_mgr_free()
376 if (!cmgr->free_list) in bnx2fc_cmd_mgr_free()
383 &cmgr->free_list[i], link) { in bnx2fc_cmd_mgr_free()
384 list_del(&io_req->link); in bnx2fc_cmd_mgr_free()
388 kfree(cmgr->free_list); in bnx2fc_cmd_mgr_free()
396 struct fcoe_port *port = tgt->port; in bnx2fc_elstm_alloc()
397 struct bnx2fc_interface *interface = port->priv; in bnx2fc_elstm_alloc()
398 struct bnx2fc_cmd_mgr *cmd_mgr = interface->hba->cmd_mgr; in bnx2fc_elstm_alloc()
407 max_sqes = tgt->max_sqes; in bnx2fc_elstm_alloc()
423 spin_lock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_elstm_alloc()
424 free_sqes = atomic_read(&tgt->free_sqes); in bnx2fc_elstm_alloc()
425 if ((list_empty(&(cmd_mgr->free_list[index]))) || in bnx2fc_elstm_alloc()
426 (tgt->num_active_ios.counter >= max_sqes) || in bnx2fc_elstm_alloc()
430 tgt->num_active_ios.counter, tgt->max_sqes); in bnx2fc_elstm_alloc()
431 if (list_empty(&(cmd_mgr->free_list[index]))) in bnx2fc_elstm_alloc()
433 spin_unlock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_elstm_alloc()
438 cmd_mgr->free_list[index].next; in bnx2fc_elstm_alloc()
441 xid = io_req->xid; in bnx2fc_elstm_alloc()
442 cmd_mgr->cmds[xid] = io_req; in bnx2fc_elstm_alloc()
443 atomic_inc(&tgt->num_active_ios); in bnx2fc_elstm_alloc()
444 atomic_dec(&tgt->free_sqes); in bnx2fc_elstm_alloc()
445 spin_unlock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_elstm_alloc()
447 INIT_LIST_HEAD(&io_req->link); in bnx2fc_elstm_alloc()
449 io_req->port = port; in bnx2fc_elstm_alloc()
450 io_req->cmd_mgr = cmd_mgr; in bnx2fc_elstm_alloc()
451 io_req->req_flags = 0; in bnx2fc_elstm_alloc()
452 io_req->cmd_type = type; in bnx2fc_elstm_alloc()
456 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_elstm_alloc()
457 bd_tbl->io_req = io_req; in bnx2fc_elstm_alloc()
460 kref_init(&io_req->refcount); in bnx2fc_elstm_alloc()
466 struct fcoe_port *port = tgt->port; in bnx2fc_cmd_alloc()
467 struct bnx2fc_interface *interface = port->priv; in bnx2fc_cmd_alloc()
468 struct bnx2fc_cmd_mgr *cmd_mgr = interface->hba->cmd_mgr; in bnx2fc_cmd_alloc()
482 spin_lock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_cmd_alloc()
483 free_sqes = atomic_read(&tgt->free_sqes); in bnx2fc_cmd_alloc()
484 if ((list_empty(&cmd_mgr->free_list[index])) || in bnx2fc_cmd_alloc()
485 (tgt->num_active_ios.counter >= max_sqes) || in bnx2fc_cmd_alloc()
487 spin_unlock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_cmd_alloc()
492 cmd_mgr->free_list[index].next; in bnx2fc_cmd_alloc()
495 xid = io_req->xid; in bnx2fc_cmd_alloc()
496 cmd_mgr->cmds[xid] = io_req; in bnx2fc_cmd_alloc()
497 atomic_inc(&tgt->num_active_ios); in bnx2fc_cmd_alloc()
498 atomic_dec(&tgt->free_sqes); in bnx2fc_cmd_alloc()
499 spin_unlock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_cmd_alloc()
501 INIT_LIST_HEAD(&io_req->link); in bnx2fc_cmd_alloc()
503 io_req->port = port; in bnx2fc_cmd_alloc()
504 io_req->cmd_mgr = cmd_mgr; in bnx2fc_cmd_alloc()
505 io_req->req_flags = 0; in bnx2fc_cmd_alloc()
509 bd_tbl = io_req->bd_tbl = cmd_mgr->io_bdt_pool[xid]; in bnx2fc_cmd_alloc()
510 bd_tbl->io_req = io_req; in bnx2fc_cmd_alloc()
513 kref_init(&io_req->refcount); in bnx2fc_cmd_alloc()
521 struct bnx2fc_cmd_mgr *cmd_mgr = io_req->cmd_mgr; in bnx2fc_cmd_release()
524 if (io_req->cmd_type == BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
525 index = io_req->xid % num_possible_cpus(); in bnx2fc_cmd_release()
530 spin_lock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_cmd_release()
531 if (io_req->cmd_type != BNX2FC_SCSI_CMD) in bnx2fc_cmd_release()
533 cmd_mgr->cmds[io_req->xid] = NULL; in bnx2fc_cmd_release()
535 list_del_init(&io_req->link); in bnx2fc_cmd_release()
537 list_add(&io_req->link, in bnx2fc_cmd_release()
538 &cmd_mgr->free_list[index]); in bnx2fc_cmd_release()
539 atomic_dec(&io_req->tgt->num_active_ios); in bnx2fc_cmd_release()
540 spin_unlock_bh(&cmd_mgr->free_list_lock[index]); in bnx2fc_cmd_release()
546 struct bnx2fc_mp_req *mp_req = &(io_req->mp_req); in bnx2fc_free_mp_resc()
547 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_free_mp_resc()
548 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_free_mp_resc()
552 mp_req->tm_flags = 0; in bnx2fc_free_mp_resc()
553 if (mp_req->mp_req_bd) { in bnx2fc_free_mp_resc()
554 dma_free_coherent(&hba->pcidev->dev, sz, in bnx2fc_free_mp_resc()
555 mp_req->mp_req_bd, in bnx2fc_free_mp_resc()
556 mp_req->mp_req_bd_dma); in bnx2fc_free_mp_resc()
557 mp_req->mp_req_bd = NULL; in bnx2fc_free_mp_resc()
559 if (mp_req->mp_resp_bd) { in bnx2fc_free_mp_resc()
560 dma_free_coherent(&hba->pcidev->dev, sz, in bnx2fc_free_mp_resc()
561 mp_req->mp_resp_bd, in bnx2fc_free_mp_resc()
562 mp_req->mp_resp_bd_dma); in bnx2fc_free_mp_resc()
563 mp_req->mp_resp_bd = NULL; in bnx2fc_free_mp_resc()
565 if (mp_req->req_buf) { in bnx2fc_free_mp_resc()
566 dma_free_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE, in bnx2fc_free_mp_resc()
567 mp_req->req_buf, in bnx2fc_free_mp_resc()
568 mp_req->req_buf_dma); in bnx2fc_free_mp_resc()
569 mp_req->req_buf = NULL; in bnx2fc_free_mp_resc()
571 if (mp_req->resp_buf) { in bnx2fc_free_mp_resc()
572 dma_free_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE, in bnx2fc_free_mp_resc()
573 mp_req->resp_buf, in bnx2fc_free_mp_resc()
574 mp_req->resp_buf_dma); in bnx2fc_free_mp_resc()
575 mp_req->resp_buf = NULL; in bnx2fc_free_mp_resc()
584 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_init_mp_req()
585 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_init_mp_req()
589 mp_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_init_mp_req()
592 if (io_req->cmd_type != BNX2FC_ELS) { in bnx2fc_init_mp_req()
593 mp_req->req_len = sizeof(struct fcp_cmnd); in bnx2fc_init_mp_req()
594 io_req->data_xfer_len = mp_req->req_len; in bnx2fc_init_mp_req()
596 mp_req->req_len = io_req->data_xfer_len; in bnx2fc_init_mp_req()
598 mp_req->req_buf = dma_alloc_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE, in bnx2fc_init_mp_req()
599 &mp_req->req_buf_dma, in bnx2fc_init_mp_req()
601 if (!mp_req->req_buf) { in bnx2fc_init_mp_req()
607 mp_req->resp_buf = dma_alloc_coherent(&hba->pcidev->dev, CNIC_PAGE_SIZE, in bnx2fc_init_mp_req()
608 &mp_req->resp_buf_dma, in bnx2fc_init_mp_req()
610 if (!mp_req->resp_buf) { in bnx2fc_init_mp_req()
615 memset(mp_req->req_buf, 0, CNIC_PAGE_SIZE); in bnx2fc_init_mp_req()
616 memset(mp_req->resp_buf, 0, CNIC_PAGE_SIZE); in bnx2fc_init_mp_req()
620 mp_req->mp_req_bd = dma_alloc_coherent(&hba->pcidev->dev, sz, in bnx2fc_init_mp_req()
621 &mp_req->mp_req_bd_dma, in bnx2fc_init_mp_req()
623 if (!mp_req->mp_req_bd) { in bnx2fc_init_mp_req()
628 mp_req->mp_resp_bd = dma_alloc_coherent(&hba->pcidev->dev, sz, in bnx2fc_init_mp_req()
629 &mp_req->mp_resp_bd_dma, in bnx2fc_init_mp_req()
631 if (!mp_req->mp_resp_bd) { in bnx2fc_init_mp_req()
637 addr = mp_req->req_buf_dma; in bnx2fc_init_mp_req()
638 mp_req_bd = mp_req->mp_req_bd; in bnx2fc_init_mp_req()
639 mp_req_bd->buf_addr_lo = (u32)addr & 0xffffffff; in bnx2fc_init_mp_req()
640 mp_req_bd->buf_addr_hi = (u32)((u64)addr >> 32); in bnx2fc_init_mp_req()
641 mp_req_bd->buf_len = CNIC_PAGE_SIZE; in bnx2fc_init_mp_req()
642 mp_req_bd->flags = 0; in bnx2fc_init_mp_req()
649 mp_resp_bd = mp_req->mp_resp_bd; in bnx2fc_init_mp_req()
650 addr = mp_req->resp_buf_dma; in bnx2fc_init_mp_req()
651 mp_resp_bd->buf_addr_lo = (u32)addr & 0xffffffff; in bnx2fc_init_mp_req()
652 mp_resp_bd->buf_addr_hi = (u32)((u64)addr >> 32); in bnx2fc_init_mp_req()
653 mp_resp_bd->buf_len = CNIC_PAGE_SIZE; in bnx2fc_init_mp_req()
654 mp_resp_bd->flags = 0; in bnx2fc_init_mp_req()
679 interface = port->priv; in bnx2fc_initiate_tmf()
686 rp = rport->dd_data; in bnx2fc_initiate_tmf()
692 if (lport->state != LPORT_ST_READY || !(lport->link_up)) { in bnx2fc_initiate_tmf()
697 /* rport and tgt are allocated together, so tgt should be non-NULL */ in bnx2fc_initiate_tmf()
700 if (!(test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags))) { in bnx2fc_initiate_tmf()
717 io_req->sc_cmd = NULL; in bnx2fc_initiate_tmf()
718 io_req->port = port; in bnx2fc_initiate_tmf()
719 io_req->tgt = tgt; in bnx2fc_initiate_tmf()
721 tm_req = (struct bnx2fc_mp_req *)&(io_req->mp_req); in bnx2fc_initiate_tmf()
726 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
727 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
728 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
733 io_req->io_req_flags = 0; in bnx2fc_initiate_tmf()
734 tm_req->tm_flags = tm_flags; in bnx2fc_initiate_tmf()
735 tm_req->tm_lun = tm_lun; in bnx2fc_initiate_tmf()
738 bnx2fc_build_fcp_cmnd(io_req, (struct fcp_cmnd *)tm_req->req_buf); in bnx2fc_initiate_tmf()
739 fcp_cmnd = (struct fcp_cmnd *)tm_req->req_buf; in bnx2fc_initiate_tmf()
740 int_to_scsilun(tm_lun, &fcp_cmnd->fc_lun); in bnx2fc_initiate_tmf()
741 memset(fcp_cmnd->fc_cdb, 0, BNX2FC_MAX_CMD_LEN); in bnx2fc_initiate_tmf()
742 fcp_cmnd->fc_dl = 0; in bnx2fc_initiate_tmf()
745 fc_hdr = &(tm_req->req_fc_hdr); in bnx2fc_initiate_tmf()
746 sid = tgt->sid; in bnx2fc_initiate_tmf()
747 did = rport->port_id; in bnx2fc_initiate_tmf()
752 xid = io_req->xid; in bnx2fc_initiate_tmf()
754 BNX2FC_TGT_DBG(tgt, "Initiate TMF - xid = 0x%x\n", xid); in bnx2fc_initiate_tmf()
760 interface->hba->task_ctx[task_idx]; in bnx2fc_initiate_tmf()
765 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
769 io_req->on_tmf_queue = 1; in bnx2fc_initiate_tmf()
770 list_add_tail(&io_req->link, &tgt->active_tm_queue); in bnx2fc_initiate_tmf()
772 init_completion(&io_req->abts_done); in bnx2fc_initiate_tmf()
773 io_req->wait_for_abts_comp = 1; in bnx2fc_initiate_tmf()
777 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
779 rc = wait_for_completion_timeout(&io_req->abts_done, in bnx2fc_initiate_tmf()
780 interface->tm_timeout * HZ); in bnx2fc_initiate_tmf()
781 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
783 io_req->wait_for_abts_comp = 0; in bnx2fc_initiate_tmf()
784 if (!(test_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags))) { in bnx2fc_initiate_tmf()
785 set_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags); in bnx2fc_initiate_tmf()
786 if (io_req->on_tmf_queue) { in bnx2fc_initiate_tmf()
787 list_del_init(&io_req->link); in bnx2fc_initiate_tmf()
788 io_req->on_tmf_queue = 0; in bnx2fc_initiate_tmf()
790 io_req->wait_for_cleanup_comp = 1; in bnx2fc_initiate_tmf()
791 init_completion(&io_req->cleanup_done); in bnx2fc_initiate_tmf()
793 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
794 rc = wait_for_completion_timeout(&io_req->cleanup_done, in bnx2fc_initiate_tmf()
796 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
797 io_req->wait_for_cleanup_comp = 0; in bnx2fc_initiate_tmf()
799 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_initiate_tmf()
802 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_initiate_tmf()
818 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_abts()
819 struct fc_rport *rport = tgt->rport; in bnx2fc_initiate_abts()
820 struct fc_rport_priv *rdata = tgt->rdata; in bnx2fc_initiate_abts()
832 u32 r_a_tov = rdata->r_a_tov; in bnx2fc_initiate_abts()
837 port = io_req->port; in bnx2fc_initiate_abts()
838 interface = port->priv; in bnx2fc_initiate_abts()
839 lport = port->lport; in bnx2fc_initiate_abts()
841 if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) { in bnx2fc_initiate_abts()
853 if (lport->state != LPORT_ST_READY || !(lport->link_up)) { in bnx2fc_initiate_abts()
867 abts_io_req->sc_cmd = NULL; in bnx2fc_initiate_abts()
868 abts_io_req->port = port; in bnx2fc_initiate_abts()
869 abts_io_req->tgt = tgt; in bnx2fc_initiate_abts()
870 abts_io_req->data_xfer_len = 0; /* No data transfer for ABTS */ in bnx2fc_initiate_abts()
872 abts_req = (struct bnx2fc_mp_req *)&(abts_io_req->mp_req); in bnx2fc_initiate_abts()
876 fc_hdr = &(abts_req->req_fc_hdr); in bnx2fc_initiate_abts()
879 fc_hdr->fh_ox_id = htons(io_req->xid); in bnx2fc_initiate_abts()
880 fc_hdr->fh_rx_id = htons(io_req->task->rxwr_txrd.var_ctx.rx_id); in bnx2fc_initiate_abts()
882 sid = tgt->sid; in bnx2fc_initiate_abts()
883 did = rport->port_id; in bnx2fc_initiate_abts()
889 xid = abts_io_req->xid; in bnx2fc_initiate_abts()
896 interface->hba->task_ctx[task_idx]; in bnx2fc_initiate_abts()
907 * TM request. For the ABTS issued as part of ULP timeout, in bnx2fc_initiate_abts()
908 * scsi-ml maintains the timers. in bnx2fc_initiate_abts()
911 /* if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags))*/ in bnx2fc_initiate_abts()
927 struct bnx2fc_rport *tgt = orig_io_req->tgt; in bnx2fc_initiate_seq_cleanup()
939 orig_io_req->xid); in bnx2fc_initiate_seq_cleanup()
940 kref_get(&orig_io_req->refcount); in bnx2fc_initiate_seq_cleanup()
942 port = orig_io_req->port; in bnx2fc_initiate_seq_cleanup()
943 interface = port->priv; in bnx2fc_initiate_seq_cleanup()
948 rc = -ENOMEM; in bnx2fc_initiate_seq_cleanup()
955 rc = -ENOMEM; in bnx2fc_initiate_seq_cleanup()
960 seq_clnp_req->sc_cmd = NULL; in bnx2fc_initiate_seq_cleanup()
961 seq_clnp_req->port = port; in bnx2fc_initiate_seq_cleanup()
962 seq_clnp_req->tgt = tgt; in bnx2fc_initiate_seq_cleanup()
963 seq_clnp_req->data_xfer_len = 0; /* No data transfer for cleanup */ in bnx2fc_initiate_seq_cleanup()
965 xid = seq_clnp_req->xid; in bnx2fc_initiate_seq_cleanup()
972 interface->hba->task_ctx[task_idx]; in bnx2fc_initiate_seq_cleanup()
974 cb_arg->aborted_io_req = orig_io_req; in bnx2fc_initiate_seq_cleanup()
975 cb_arg->io_req = seq_clnp_req; in bnx2fc_initiate_seq_cleanup()
976 cb_arg->r_ctl = r_ctl; in bnx2fc_initiate_seq_cleanup()
977 cb_arg->offset = offset; in bnx2fc_initiate_seq_cleanup()
978 seq_clnp_req->cb_arg = cb_arg; in bnx2fc_initiate_seq_cleanup()
994 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_initiate_cleanup()
1007 port = io_req->port; in bnx2fc_initiate_cleanup()
1008 interface = port->priv; in bnx2fc_initiate_cleanup()
1013 rc = -1; in bnx2fc_initiate_cleanup()
1018 cleanup_io_req->sc_cmd = NULL; in bnx2fc_initiate_cleanup()
1019 cleanup_io_req->port = port; in bnx2fc_initiate_cleanup()
1020 cleanup_io_req->tgt = tgt; in bnx2fc_initiate_cleanup()
1021 cleanup_io_req->data_xfer_len = 0; /* No data transfer for cleanup */ in bnx2fc_initiate_cleanup()
1023 xid = cleanup_io_req->xid; in bnx2fc_initiate_cleanup()
1030 interface->hba->task_ctx[task_idx]; in bnx2fc_initiate_cleanup()
1032 orig_xid = io_req->xid; in bnx2fc_initiate_cleanup()
1042 set_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags); in bnx2fc_initiate_cleanup()
1061 struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); in bnx2fc_eh_target_reset()
1068 * bnx2fc_eh_device_reset - Reset a single LUN
1077 struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); in bnx2fc_eh_device_reset()
1080 return bnx2fc_initiate_tmf(lport, rport, sc_cmd->device->lun, in bnx2fc_eh_device_reset()
1085 __must_hold(&tgt->tgt_lock) in bnx2fc_abts_cleanup()
1087 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_abts_cleanup()
1090 init_completion(&io_req->cleanup_done); in bnx2fc_abts_cleanup()
1091 io_req->wait_for_cleanup_comp = 1; in bnx2fc_abts_cleanup()
1094 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_abts_cleanup()
1100 time_left = wait_for_completion_timeout(&io_req->cleanup_done, in bnx2fc_abts_cleanup()
1110 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_abts_cleanup()
1113 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_abts_cleanup()
1114 io_req->wait_for_cleanup_comp = 0; in bnx2fc_abts_cleanup()
1119 * bnx2fc_eh_abort - eh_abort_handler api to abort an outstanding
1128 struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); in bnx2fc_eh_abort()
1129 struct fc_rport_libfc_priv *rp = rport->dd_data; in bnx2fc_eh_abort()
1140 lport = shost_priv(sc_cmd->device->host); in bnx2fc_eh_abort()
1141 if ((lport->state != LPORT_ST_READY) || !(lport->link_up)) { in bnx2fc_eh_abort()
1150 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1151 io_req = bnx2fc_priv(sc_cmd)->io_req; in bnx2fc_eh_abort()
1155 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1158 BNX2FC_IO_DBG(io_req, "eh_abort - refcnt = %d\n", in bnx2fc_eh_abort()
1159 kref_read(&io_req->refcount)); in bnx2fc_eh_abort()
1162 kref_get(&io_req->refcount); in bnx2fc_eh_abort()
1164 BUG_ON(tgt != io_req->tgt); in bnx2fc_eh_abort()
1172 if (tgt->flush_in_prog) { in bnx2fc_eh_abort()
1174 "flush in progress\n", io_req->xid); in bnx2fc_eh_abort()
1175 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1176 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1180 if (io_req->on_active_queue == 0) { in bnx2fc_eh_abort()
1182 "not on active_q\n", io_req->xid); in bnx2fc_eh_abort()
1185 * Return failure and let SCSI-ml retry eh_abort. in bnx2fc_eh_abort()
1187 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1198 list_del_init(&io_req->link); in bnx2fc_eh_abort()
1199 io_req->on_active_queue = 0; in bnx2fc_eh_abort()
1201 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_eh_abort()
1203 init_completion(&io_req->abts_done); in bnx2fc_eh_abort()
1204 init_completion(&io_req->cleanup_done); in bnx2fc_eh_abort()
1206 if (test_and_set_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) { in bnx2fc_eh_abort()
1208 "already in abts processing\n", io_req->xid); in bnx2fc_eh_abort()
1209 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1210 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1223 set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags); in bnx2fc_eh_abort()
1229 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_eh_abort()
1230 kref_put(&io_req->refcount, in bnx2fc_eh_abort()
1232 set_bit(BNX2FC_FLAG_EH_ABORT, &io_req->req_flags); in bnx2fc_eh_abort()
1233 io_req->wait_for_abts_comp = 1; in bnx2fc_eh_abort()
1236 io_req->wait_for_cleanup_comp = 1; in bnx2fc_eh_abort()
1238 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1239 wait_for_completion(&io_req->cleanup_done); in bnx2fc_eh_abort()
1240 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1241 io_req->wait_for_cleanup_comp = 0; in bnx2fc_eh_abort()
1244 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1246 /* Wait 2 * RA_TOV + 1 to be sure timeout function hasn't fired */ in bnx2fc_eh_abort()
1247 time_left = wait_for_completion_timeout(&io_req->abts_done, in bnx2fc_eh_abort()
1248 msecs_to_jiffies(2 * rp->r_a_tov + 1)); in bnx2fc_eh_abort()
1253 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1254 io_req->wait_for_abts_comp = 0; in bnx2fc_eh_abort()
1255 if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_eh_abort()
1259 &io_req->req_flags))) { in bnx2fc_eh_abort()
1260 /* Let the scsi-ml try to recover this command */ in bnx2fc_eh_abort()
1262 io_req->xid); in bnx2fc_eh_abort()
1272 * between timeout and abts completion, and abts in bnx2fc_eh_abort()
1278 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1282 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_eh_abort()
1283 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_eh_abort()
1291 struct bnx2fc_els_cb_arg *cb_arg = seq_clnp_req->cb_arg; in bnx2fc_process_seq_cleanup_compl()
1292 struct bnx2fc_cmd *orig_io_req = cb_arg->aborted_io_req; in bnx2fc_process_seq_cleanup_compl()
1293 u32 offset = cb_arg->offset; in bnx2fc_process_seq_cleanup_compl()
1294 enum fc_rctl r_ctl = cb_arg->r_ctl; in bnx2fc_process_seq_cleanup_compl()
1296 struct bnx2fc_rport *tgt = orig_io_req->tgt; in bnx2fc_process_seq_cleanup_compl()
1300 seq_clnp_req->xid, seq_clnp_req->cmd_type); in bnx2fc_process_seq_cleanup_compl()
1303 printk(KERN_ERR PFX "seq cleanup ignored - xid = 0x%x\n", in bnx2fc_process_seq_cleanup_compl()
1304 seq_clnp_req->xid); in bnx2fc_process_seq_cleanup_compl()
1308 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_process_seq_cleanup_compl()
1310 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_process_seq_cleanup_compl()
1315 seq_clnp_req->cb_arg = NULL; in bnx2fc_process_seq_cleanup_compl()
1316 kref_put(&orig_io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_seq_cleanup_compl()
1328 kref_read(&io_req->refcount), io_req->cmd_type); in bnx2fc_process_cleanup_compl()
1334 &io_req->req_flags)) in bnx2fc_process_cleanup_compl()
1341 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags) && in bnx2fc_process_cleanup_compl()
1342 !test_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags)) { in bnx2fc_process_cleanup_compl()
1343 set_bit(BNX2FC_FLAG_ABTS_DONE, &io_req->req_flags); in bnx2fc_process_cleanup_compl()
1344 if (io_req->wait_for_abts_comp) in bnx2fc_process_cleanup_compl()
1345 complete(&io_req->abts_done); in bnx2fc_process_cleanup_compl()
1349 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_cleanup_compl()
1350 if (io_req->wait_for_cleanup_comp) in bnx2fc_process_cleanup_compl()
1351 complete(&io_req->cleanup_done); in bnx2fc_process_cleanup_compl()
1361 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_abts_compl()
1365 io_req->xid, in bnx2fc_process_abts_compl()
1366 kref_read(&io_req->refcount), io_req->cmd_type); in bnx2fc_process_abts_compl()
1369 &io_req->req_flags)) { in bnx2fc_process_abts_compl()
1379 if (test_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags)) { in bnx2fc_process_abts_compl()
1380 clear_bit(BNX2FC_FLAG_ISSUE_CLEANUP_REQ, &io_req->req_flags); in bnx2fc_process_abts_compl()
1381 if (io_req->wait_for_cleanup_comp) in bnx2fc_process_abts_compl()
1382 complete(&io_req->cleanup_done); in bnx2fc_process_abts_compl()
1387 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1391 * For ABTS issued due to SCSI eh_abort_handler, timeout in bnx2fc_process_abts_compl()
1392 * values are maintained by scsi-ml itself. Cancel timeout in bnx2fc_process_abts_compl()
1396 if (test_bit(BNX2FC_FLAG_ISSUE_ABTS, &io_req->req_flags)) in bnx2fc_process_abts_compl()
1397 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_abts_compl()
1398 kref_put(&io_req->refcount, in bnx2fc_process_abts_compl()
1401 r_ctl = (u8)task->rxwr_only.union_ctx.comp_info.abts_rsp.r_ctl; in bnx2fc_process_abts_compl()
1409 BNX2FC_IO_DBG(io_req, "ABTS response - ACC Send RRQ\n"); in bnx2fc_process_abts_compl()
1414 BNX2FC_IO_DBG(io_req, "ABTS response - RJT\n"); in bnx2fc_process_abts_compl()
1423 set_bit(BNX2FC_FLAG_ISSUE_RRQ, &io_req->req_flags); in bnx2fc_process_abts_compl()
1425 set_bit(BNX2FC_FLAG_RETIRE_OXID, &io_req->req_flags); in bnx2fc_process_abts_compl()
1429 if (io_req->wait_for_abts_comp) { in bnx2fc_process_abts_compl()
1431 &io_req->req_flags)) in bnx2fc_process_abts_compl()
1432 complete(&io_req->abts_done); in bnx2fc_process_abts_compl()
1443 if (io_req->on_active_queue) { in bnx2fc_process_abts_compl()
1444 list_del_init(&io_req->link); in bnx2fc_process_abts_compl()
1445 io_req->on_active_queue = 0; in bnx2fc_process_abts_compl()
1447 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_abts_compl()
1450 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_abts_compl()
1456 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_lun_reset_cmpl()
1458 struct bnx2fc_mp_req *tm_req = &io_req->mp_req; in bnx2fc_lun_reset_cmpl()
1468 list_for_each_entry_safe(cmd, tmp, &tgt->active_cmd_queue, link) { in bnx2fc_lun_reset_cmpl()
1470 if (!cmd->sc_cmd) in bnx2fc_lun_reset_cmpl()
1472 lun = cmd->sc_cmd->device->lun; in bnx2fc_lun_reset_cmpl()
1473 if (lun == tm_req->tm_lun) { in bnx2fc_lun_reset_cmpl()
1476 &cmd->req_flags)) { in bnx2fc_lun_reset_cmpl()
1477 /* cancel the IO timeout */ in bnx2fc_lun_reset_cmpl()
1478 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_lun_reset_cmpl()
1479 kref_put(&io_req->refcount, in bnx2fc_lun_reset_cmpl()
1488 cmd->xid); in bnx2fc_lun_reset_cmpl()
1495 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_tgt_reset_cmpl()
1505 list_for_each_entry_safe(cmd, tmp, &tgt->active_cmd_queue, link) { in bnx2fc_tgt_reset_cmpl()
1509 &cmd->req_flags)) { in bnx2fc_tgt_reset_cmpl()
1510 /* cancel the IO timeout */ in bnx2fc_tgt_reset_cmpl()
1511 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_tgt_reset_cmpl()
1512 kref_put(&io_req->refcount, in bnx2fc_tgt_reset_cmpl()
1520 " for this IO 0x%x\n", cmd->xid); in bnx2fc_tgt_reset_cmpl()
1530 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1538 if (!(test_bit(BNX2FC_FLAG_TM_TIMEOUT, &io_req->req_flags))) in bnx2fc_process_tm_compl()
1539 set_bit(BNX2FC_FLAG_TM_COMPL, &io_req->req_flags); in bnx2fc_process_tm_compl()
1548 tm_req = &(io_req->mp_req); in bnx2fc_process_tm_compl()
1549 fc_hdr = &(tm_req->resp_fc_hdr); in bnx2fc_process_tm_compl()
1552 &task->rxwr_only.union_ctx.comp_info.mp_rsp.fc_hdr; in bnx2fc_process_tm_compl()
1557 tm_req->resp_len = in bnx2fc_process_tm_compl()
1558 task->rxwr_only.union_ctx.comp_info.mp_rsp.mp_payload_len; in bnx2fc_process_tm_compl()
1560 rsp_buf = tm_req->resp_buf; in bnx2fc_process_tm_compl()
1562 if (fc_hdr->fh_r_ctl == FC_RCTL_DD_CMD_STATUS) { in bnx2fc_process_tm_compl()
1566 if (io_req->fcp_rsp_code == 0) { in bnx2fc_process_tm_compl()
1568 if (tm_req->tm_flags & FCP_TMF_LUN_RESET) in bnx2fc_process_tm_compl()
1570 else if (tm_req->tm_flags & FCP_TMF_TGT_RESET) in bnx2fc_process_tm_compl()
1575 fc_hdr->fh_r_ctl); in bnx2fc_process_tm_compl()
1578 if (!bnx2fc_priv(sc_cmd)->io_req) { in bnx2fc_process_tm_compl()
1582 switch (io_req->fcp_status) { in bnx2fc_process_tm_compl()
1584 if (io_req->cdb_status == 0) { in bnx2fc_process_tm_compl()
1586 sc_cmd->result = DID_OK << 16; in bnx2fc_process_tm_compl()
1589 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_tm_compl()
1591 if (io_req->fcp_resid) in bnx2fc_process_tm_compl()
1592 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_tm_compl()
1597 io_req->fcp_status); in bnx2fc_process_tm_compl()
1601 sc_cmd = io_req->sc_cmd; in bnx2fc_process_tm_compl()
1602 io_req->sc_cmd = NULL; in bnx2fc_process_tm_compl()
1604 bnx2fc_priv(sc_cmd)->io_req = NULL; in bnx2fc_process_tm_compl()
1609 if (io_req->on_tmf_queue) { in bnx2fc_process_tm_compl()
1611 list_del_init(&io_req->link); in bnx2fc_process_tm_compl()
1612 io_req->on_tmf_queue = 0; in bnx2fc_process_tm_compl()
1619 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_tm_compl()
1620 if (io_req->wait_for_abts_comp) { in bnx2fc_process_tm_compl()
1621 BNX2FC_IO_DBG(io_req, "tm_compl - wake up the waiter\n"); in bnx2fc_process_tm_compl()
1622 complete(&io_req->abts_done); in bnx2fc_process_tm_compl()
1629 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_split_bd()
1645 sg_len -= frag_size; in bnx2fc_split_bd()
1653 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_map_sg()
1654 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_map_sg()
1655 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_map_sg()
1656 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_map_sg()
1671 sg_count = dma_map_sg(&hba->pcidev->dev, scsi_sglist(sc), in bnx2fc_map_sg()
1672 scsi_sg_count(sc), sc->sc_data_direction); in bnx2fc_map_sg()
1693 io_req->xid); in bnx2fc_map_sg()
1699 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_build_bd_list_from_sg()
1700 struct fcoe_bd_ctx *bd = io_req->bd_tbl->bd_tbl; in bnx2fc_build_bd_list_from_sg()
1706 return -ENOMEM; in bnx2fc_build_bd_list_from_sg()
1712 io_req->bd_tbl->bd_valid = bd_count; in bnx2fc_build_bd_list_from_sg()
1720 bd_count, io_req->xid); in bnx2fc_build_bd_list_from_sg()
1721 return -ENOMEM; in bnx2fc_build_bd_list_from_sg()
1729 struct scsi_cmnd *sc = io_req->sc_cmd; in bnx2fc_unmap_sg_list()
1730 struct bnx2fc_interface *interface = io_req->port->priv; in bnx2fc_unmap_sg_list()
1731 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_unmap_sg_list()
1737 if (io_req->bd_tbl->bd_valid && sc && scsi_sg_count(sc)) { in bnx2fc_unmap_sg_list()
1738 dma_unmap_sg(&hba->pcidev->dev, scsi_sglist(sc), in bnx2fc_unmap_sg_list()
1739 scsi_sg_count(sc), sc->sc_data_direction); in bnx2fc_unmap_sg_list()
1740 io_req->bd_tbl->bd_valid = 0; in bnx2fc_unmap_sg_list()
1749 fcp_cmnd->fc_dl = htonl(io_req->data_xfer_len); in bnx2fc_build_fcp_cmnd()
1750 fcp_cmnd->fc_cmdref = 0; in bnx2fc_build_fcp_cmnd()
1751 fcp_cmnd->fc_pri_ta = 0; in bnx2fc_build_fcp_cmnd()
1752 fcp_cmnd->fc_tm_flags = io_req->mp_req.tm_flags; in bnx2fc_build_fcp_cmnd()
1753 fcp_cmnd->fc_flags = io_req->io_req_flags; in bnx2fc_build_fcp_cmnd()
1754 fcp_cmnd->fc_pri_ta = FCP_PTA_SIMPLE; in bnx2fc_build_fcp_cmnd()
1761 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_parse_fcp_rsp()
1762 u8 rsp_flags = fcp_rsp->fcp_flags.flags; in bnx2fc_parse_fcp_rsp()
1767 io_req->fcp_status = FC_GOOD; in bnx2fc_parse_fcp_rsp()
1768 io_req->fcp_resid = 0; in bnx2fc_parse_fcp_rsp()
1771 io_req->fcp_resid = fcp_rsp->fcp_resid; in bnx2fc_parse_fcp_rsp()
1773 io_req->scsi_comp_flags = rsp_flags; in bnx2fc_parse_fcp_rsp()
1774 io_req->cdb_status = fcp_rsp->scsi_status_code; in bnx2fc_parse_fcp_rsp()
1788 = fcp_rsp->fcp_rsp_len; in bnx2fc_parse_fcp_rsp()
1793 fcp_sns_len = fcp_rsp->fcp_sns_len; in bnx2fc_parse_fcp_rsp()
1794 rq_buff_len += fcp_rsp->fcp_sns_len; in bnx2fc_parse_fcp_rsp()
1797 io_req->fcp_rsp_len = fcp_rsp_len; in bnx2fc_parse_fcp_rsp()
1798 io_req->fcp_sns_len = fcp_sns_len; in bnx2fc_parse_fcp_rsp()
1811 io_req->fcp_rsp_code = rq_data[3]; in bnx2fc_parse_fcp_rsp()
1813 io_req->fcp_rsp_code); in bnx2fc_parse_fcp_rsp()
1824 memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in bnx2fc_parse_fcp_rsp()
1826 memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len); in bnx2fc_parse_fcp_rsp()
1832 * bnx2fc_queuecommand - Queuecommand function of the scsi template
1837 * This is the IO strategy routine, called by SCSI-ML
1843 struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device)); in bnx2fc_queuecommand()
1844 struct fc_rport_libfc_priv *rp = rport->dd_data; in bnx2fc_queuecommand()
1852 sc_cmd->result = rval; in bnx2fc_queuecommand()
1857 if ((lport->state != LPORT_ST_READY) || !(lport->link_up)) { in bnx2fc_queuecommand()
1862 /* rport and tgt are allocated together, so tgt should be non-NULL */ in bnx2fc_queuecommand()
1865 if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) { in bnx2fc_queuecommand()
1867 * Session is not offloaded yet. Let SCSI-ml retry in bnx2fc_queuecommand()
1873 if (tgt->retry_delay_timestamp) { in bnx2fc_queuecommand()
1874 if (time_after(jiffies, tgt->retry_delay_timestamp)) { in bnx2fc_queuecommand()
1875 tgt->retry_delay_timestamp = 0; in bnx2fc_queuecommand()
1883 spin_lock_bh(&tgt->tgt_lock); in bnx2fc_queuecommand()
1890 io_req->sc_cmd = sc_cmd; in bnx2fc_queuecommand()
1899 spin_unlock_bh(&tgt->tgt_lock); in bnx2fc_queuecommand()
1909 struct bnx2fc_rport *tgt = io_req->tgt; in bnx2fc_process_scsi_cmd_compl()
1915 if (test_and_set_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { in bnx2fc_process_scsi_cmd_compl()
1920 &io_req->req_flags)) { in bnx2fc_process_scsi_cmd_compl()
1929 if (cancel_delayed_work(&io_req->timeout_work)) in bnx2fc_process_scsi_cmd_compl()
1930 kref_put(&io_req->refcount, in bnx2fc_process_scsi_cmd_compl()
1933 sc_cmd = io_req->sc_cmd; in bnx2fc_process_scsi_cmd_compl()
1935 printk(KERN_ERR PFX "scsi_cmd_compl - sc_cmd is NULL\n"); in bnx2fc_process_scsi_cmd_compl()
1941 &(task->rxwr_only.union_ctx.comp_info.fcp_rsp.payload); in bnx2fc_process_scsi_cmd_compl()
1946 if (!bnx2fc_priv(sc_cmd)->io_req) { in bnx2fc_process_scsi_cmd_compl()
1951 if (io_req->on_active_queue) { in bnx2fc_process_scsi_cmd_compl()
1952 list_del_init(&io_req->link); in bnx2fc_process_scsi_cmd_compl()
1953 io_req->on_active_queue = 0; in bnx2fc_process_scsi_cmd_compl()
1955 list_add_tail(&io_req->link, &tgt->io_retire_queue); in bnx2fc_process_scsi_cmd_compl()
1962 if (io_req->wait_for_abts_comp) in bnx2fc_process_scsi_cmd_compl()
1964 &io_req->req_flags)) in bnx2fc_process_scsi_cmd_compl()
1965 complete(&io_req->abts_done); in bnx2fc_process_scsi_cmd_compl()
1969 io_req->sc_cmd = NULL; in bnx2fc_process_scsi_cmd_compl()
1971 switch (io_req->fcp_status) { in bnx2fc_process_scsi_cmd_compl()
1973 if (io_req->cdb_status == 0) { in bnx2fc_process_scsi_cmd_compl()
1975 sc_cmd->result = DID_OK << 16; in bnx2fc_process_scsi_cmd_compl()
1980 io_req->cdb_status, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
1981 sc_cmd->result = (DID_OK << 16) | io_req->cdb_status; in bnx2fc_process_scsi_cmd_compl()
1983 if (io_req->cdb_status == SAM_STAT_TASK_SET_FULL || in bnx2fc_process_scsi_cmd_compl()
1984 io_req->cdb_status == SAM_STAT_BUSY) { in bnx2fc_process_scsi_cmd_compl()
1991 if (fcp_rsp->retry_delay_timer) { in bnx2fc_process_scsi_cmd_compl()
1993 scope = fcp_rsp->retry_delay_timer in bnx2fc_process_scsi_cmd_compl()
1996 qualifier = fcp_rsp->retry_delay_timer in bnx2fc_process_scsi_cmd_compl()
2002 * retry_delay_timer * 100ms in bnx2fc_process_scsi_cmd_compl()
2005 tgt->retry_delay_timestamp = jiffies + in bnx2fc_process_scsi_cmd_compl()
2010 if (io_req->fcp_resid) in bnx2fc_process_scsi_cmd_compl()
2011 scsi_set_resid(sc_cmd, io_req->fcp_resid); in bnx2fc_process_scsi_cmd_compl()
2015 io_req->fcp_status); in bnx2fc_process_scsi_cmd_compl()
2018 bnx2fc_priv(sc_cmd)->io_req = NULL; in bnx2fc_process_scsi_cmd_compl()
2020 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_process_scsi_cmd_compl()
2028 struct scsi_cmnd *sc_cmd = io_req->sc_cmd; in bnx2fc_post_io_req()
2029 struct fcoe_port *port = tgt->port; in bnx2fc_post_io_req()
2030 struct bnx2fc_interface *interface = port->priv; in bnx2fc_post_io_req()
2031 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_post_io_req()
2032 struct fc_lport *lport = port->lport; in bnx2fc_post_io_req()
2039 io_req->cmd_type = BNX2FC_SCSI_CMD; in bnx2fc_post_io_req()
2040 io_req->port = port; in bnx2fc_post_io_req()
2041 io_req->tgt = tgt; in bnx2fc_post_io_req()
2042 io_req->data_xfer_len = scsi_bufflen(sc_cmd); in bnx2fc_post_io_req()
2043 bnx2fc_priv(sc_cmd)->io_req = io_req; in bnx2fc_post_io_req()
2045 if (sc_cmd->sc_data_direction == DMA_FROM_DEVICE) { in bnx2fc_post_io_req()
2046 io_req->io_req_flags = BNX2FC_READ; in bnx2fc_post_io_req()
2047 this_cpu_inc(lport->stats->InputRequests); in bnx2fc_post_io_req()
2048 this_cpu_add(lport->stats->InputBytes, io_req->data_xfer_len); in bnx2fc_post_io_req()
2049 } else if (sc_cmd->sc_data_direction == DMA_TO_DEVICE) { in bnx2fc_post_io_req()
2050 io_req->io_req_flags = BNX2FC_WRITE; in bnx2fc_post_io_req()
2051 this_cpu_inc(lport->stats->OutputRequests); in bnx2fc_post_io_req()
2052 this_cpu_add(lport->stats->OutputBytes, io_req->data_xfer_len); in bnx2fc_post_io_req()
2054 io_req->io_req_flags = 0; in bnx2fc_post_io_req()
2055 this_cpu_inc(lport->stats->ControlRequests); in bnx2fc_post_io_req()
2058 xid = io_req->xid; in bnx2fc_post_io_req()
2063 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2064 return -EAGAIN; in bnx2fc_post_io_req()
2071 task_page = (struct fcoe_task_ctx_entry *) hba->task_ctx[task_idx]; in bnx2fc_post_io_req()
2075 if (tgt->flush_in_prog) { in bnx2fc_post_io_req()
2077 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2078 return -EAGAIN; in bnx2fc_post_io_req()
2081 if (!test_bit(BNX2FC_FLAG_SESSION_READY, &tgt->flags)) { in bnx2fc_post_io_req()
2083 kref_put(&io_req->refcount, bnx2fc_cmd_release); in bnx2fc_post_io_req()
2084 return -EAGAIN; in bnx2fc_post_io_req()
2088 if (tgt->io_timeout) in bnx2fc_post_io_req()
2095 io_req->on_active_queue = 1; in bnx2fc_post_io_req()
2097 list_add_tail(&io_req->link, &tgt->active_cmd_queue); in bnx2fc_post_io_req()