fnic_scsi.c (14eb5d905d16ecd33e5e3113eb44cfa2bb47e7d7) | fnic_scsi.c (4d7007b49d523d8f954ae047118d82c130f673ce) |
---|---|
1/* 2 * Copyright 2008 Cisco Systems, Inc. All rights reserved. 3 * Copyright 2007 Nuova Systems, Inc. All rights reserved. 4 * 5 * This program is free software; you may redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * --- 379 unchanged lines hidden (view full) --- 388 * fnic_queuecommand 389 * Routine to send a scsi cdb 390 * Called with host_lock held and interrupts disabled. 391 */ 392static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) 393{ 394 struct fc_lport *lp = shost_priv(sc->device->host); 395 struct fc_rport *rport; | 1/* 2 * Copyright 2008 Cisco Systems, Inc. All rights reserved. 3 * Copyright 2007 Nuova Systems, Inc. All rights reserved. 4 * 5 * This program is free software; you may redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; version 2 of the License. 8 * --- 379 unchanged lines hidden (view full) --- 388 * fnic_queuecommand 389 * Routine to send a scsi cdb 390 * Called with host_lock held and interrupts disabled. 391 */ 392static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *)) 393{ 394 struct fc_lport *lp = shost_priv(sc->device->host); 395 struct fc_rport *rport; |
396 struct fnic_io_req *io_req; | 396 struct fnic_io_req *io_req = NULL; |
397 struct fnic *fnic = lport_priv(lp); 398 struct vnic_wq_copy *wq; 399 int ret; | 397 struct fnic *fnic = lport_priv(lp); 398 struct vnic_wq_copy *wq; 399 int ret; |
400 int sg_count; | 400 u64 cmd_trace; 401 int sg_count = 0; |
401 unsigned long flags; 402 unsigned long ptr; 403 404 if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) 405 return SCSI_MLQUEUE_HOST_BUSY; 406 407 rport = starget_to_rport(scsi_target(sc->device)); 408 ret = fc_remote_port_chkready(rport); --- 23 unchanged lines hidden (view full) --- 432 ret = SCSI_MLQUEUE_HOST_BUSY; 433 goto out; 434 } 435 memset(io_req, 0, sizeof(*io_req)); 436 437 /* Map the data buffer */ 438 sg_count = scsi_dma_map(sc); 439 if (sg_count < 0) { | 402 unsigned long flags; 403 unsigned long ptr; 404 405 if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) 406 return SCSI_MLQUEUE_HOST_BUSY; 407 408 rport = starget_to_rport(scsi_target(sc->device)); 409 ret = fc_remote_port_chkready(rport); --- 23 unchanged lines hidden (view full) --- 433 ret = SCSI_MLQUEUE_HOST_BUSY; 434 goto out; 435 } 436 memset(io_req, 0, sizeof(*io_req)); 437 438 /* Map the data buffer */ 439 sg_count = scsi_dma_map(sc); 440 if (sg_count < 0) { |
441 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, 442 sc->request->tag, sc, 0, sc->cmnd[0], 443 sg_count, CMD_STATE(sc)); |
|
440 mempool_free(io_req, fnic->io_req_pool); 441 goto out; 442 } 443 444 /* Determine the type of scatter/gather list we need */ 445 io_req->sgl_cnt = sg_count; 446 io_req->sgl_type = FNIC_SGL_CACHE_DFLT; 447 if (sg_count > FNIC_DFLT_SG_DESC_CNT) --- 33 unchanged lines hidden (view full) --- 481 wq = &fnic->wq_copy[0]; 482 ret = fnic_queue_wq_copy_desc(fnic, wq, io_req, sc, sg_count); 483 if (ret) { 484 /* 485 * In case another thread cancelled the request, 486 * refetch the pointer under the lock. 487 */ 488 spinlock_t *io_lock = fnic_io_lock_hash(fnic, sc); | 444 mempool_free(io_req, fnic->io_req_pool); 445 goto out; 446 } 447 448 /* Determine the type of scatter/gather list we need */ 449 io_req->sgl_cnt = sg_count; 450 io_req->sgl_type = FNIC_SGL_CACHE_DFLT; 451 if (sg_count > FNIC_DFLT_SG_DESC_CNT) --- 33 unchanged lines hidden (view full) --- 485 wq = &fnic->wq_copy[0]; 486 ret = fnic_queue_wq_copy_desc(fnic, wq, io_req, sc, sg_count); 487 if (ret) { 488 /* 489 * In case another thread cancelled the request, 490 * refetch the pointer under the lock. 491 */ 492 spinlock_t *io_lock = fnic_io_lock_hash(fnic, sc); |
489 | 493 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, 494 sc->request->tag, sc, 0, 0, 0, 495 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); |
490 spin_lock_irqsave(io_lock, flags); 491 io_req = (struct fnic_io_req *)CMD_SP(sc); 492 CMD_SP(sc) = NULL; 493 CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; 494 spin_unlock_irqrestore(io_lock, flags); 495 if (io_req) { 496 fnic_release_ioreq_buf(fnic, io_req, sc); 497 mempool_free(io_req, fnic->io_req_pool); 498 } 499 } else { 500 /* REVISIT: Use per IO lock in the final code */ 501 CMD_FLAGS(sc) |= FNIC_IO_ISSUED; 502 } 503out: | 496 spin_lock_irqsave(io_lock, flags); 497 io_req = (struct fnic_io_req *)CMD_SP(sc); 498 CMD_SP(sc) = NULL; 499 CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; 500 spin_unlock_irqrestore(io_lock, flags); 501 if (io_req) { 502 fnic_release_ioreq_buf(fnic, io_req, sc); 503 mempool_free(io_req, fnic->io_req_pool); 504 } 505 } else { 506 /* REVISIT: Use per IO lock in the final code */ 507 CMD_FLAGS(sc) |= FNIC_IO_ISSUED; 508 } 509out: |
510 cmd_trace = ((u64)sc->cmnd[0] << 56 | (u64)sc->cmnd[7] << 40 | 511 (u64)sc->cmnd[8] << 32 | (u64)sc->cmnd[2] << 24 | 512 (u64)sc->cmnd[3] << 16 | (u64)sc->cmnd[4] << 8 | 513 sc->cmnd[5]); 514 515 FNIC_TRACE(fnic_queuecommand, sc->device->host->host_no, 516 sc->request->tag, sc, io_req, 517 sg_count, cmd_trace, 518 (((u64)CMD_FLAGS(sc) >> 32) | CMD_STATE(sc))); |
|
504 atomic_dec(&fnic->in_flight); 505 /* acquire host lock before returning to SCSI */ 506 spin_lock(lp->host->host_lock); 507 return ret; 508} 509 510DEF_SCSI_QCMD(fnic_queuecommand) 511 --- 157 unchanged lines hidden (view full) --- 669 */ 670static inline void fnic_fcpio_ack_handler(struct fnic *fnic, 671 unsigned int cq_index, 672 struct fcpio_fw_req *desc) 673{ 674 struct vnic_wq_copy *wq; 675 u16 request_out = desc->u.ack.request_out; 676 unsigned long flags; | 519 atomic_dec(&fnic->in_flight); 520 /* acquire host lock before returning to SCSI */ 521 spin_lock(lp->host->host_lock); 522 return ret; 523} 524 525DEF_SCSI_QCMD(fnic_queuecommand) 526 --- 157 unchanged lines hidden (view full) --- 684 */ 685static inline void fnic_fcpio_ack_handler(struct fnic *fnic, 686 unsigned int cq_index, 687 struct fcpio_fw_req *desc) 688{ 689 struct vnic_wq_copy *wq; 690 u16 request_out = desc->u.ack.request_out; 691 unsigned long flags; |
692 u64 *ox_id_tag = (u64 *)(void *)desc; |
|
677 678 /* mark the ack state */ 679 wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count]; 680 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); 681 682 if (is_ack_index_in_range(wq, request_out)) { 683 fnic->fw_ack_index[0] = request_out; 684 fnic->fw_ack_recd[0] = 1; 685 } 686 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); | 693 694 /* mark the ack state */ 695 wq = &fnic->wq_copy[cq_index - fnic->raw_wq_count - fnic->rq_count]; 696 spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); 697 698 if (is_ack_index_in_range(wq, request_out)) { 699 fnic->fw_ack_index[0] = request_out; 700 fnic->fw_ack_recd[0] = 1; 701 } 702 spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); |
703 FNIC_TRACE(fnic_fcpio_ack_handler, 704 fnic->lport->host->host_no, 0, 0, ox_id_tag[2], ox_id_tag[3], 705 ox_id_tag[4], ox_id_tag[5]); |
|
687} 688 689/* 690 * fnic_fcpio_icmnd_cmpl_handler 691 * Routine to handle icmnd completions 692 */ 693static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, 694 struct fcpio_fw_req *desc) 695{ 696 u8 type; 697 u8 hdr_status; 698 struct fcpio_tag tag; 699 u32 id; 700 u64 xfer_len = 0; 701 struct fcpio_icmnd_cmpl *icmnd_cmpl; 702 struct fnic_io_req *io_req; 703 struct scsi_cmnd *sc; 704 unsigned long flags; 705 spinlock_t *io_lock; | 706} 707 708/* 709 * fnic_fcpio_icmnd_cmpl_handler 710 * Routine to handle icmnd completions 711 */ 712static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, 713 struct fcpio_fw_req *desc) 714{ 715 u8 type; 716 u8 hdr_status; 717 struct fcpio_tag tag; 718 u32 id; 719 u64 xfer_len = 0; 720 struct fcpio_icmnd_cmpl *icmnd_cmpl; 721 struct fnic_io_req *io_req; 722 struct scsi_cmnd *sc; 723 unsigned long flags; 724 spinlock_t *io_lock; |
725 u64 cmd_trace; |
|
706 unsigned long start_time; 707 708 /* Decode the cmpl description to get the io_req id */ 709 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); 710 fcpio_tag_id_dec(&tag, &id); 711 icmnd_cmpl = &desc->u.icmnd_cmpl; 712 713 if (id >= FNIC_MAX_IO_REQ) { --- 5 unchanged lines hidden (view full) --- 719 720 sc = scsi_host_find_tag(fnic->lport->host, id); 721 WARN_ON_ONCE(!sc); 722 if (!sc) { 723 shost_printk(KERN_ERR, fnic->lport->host, 724 "icmnd_cmpl sc is null - " 725 "hdr status = %s tag = 0x%x desc = 0x%p\n", 726 fnic_fcpio_status_to_str(hdr_status), id, desc); | 726 unsigned long start_time; 727 728 /* Decode the cmpl description to get the io_req id */ 729 fcpio_header_dec(&desc->hdr, &type, &hdr_status, &tag); 730 fcpio_tag_id_dec(&tag, &id); 731 icmnd_cmpl = &desc->u.icmnd_cmpl; 732 733 if (id >= FNIC_MAX_IO_REQ) { --- 5 unchanged lines hidden (view full) --- 739 740 sc = scsi_host_find_tag(fnic->lport->host, id); 741 WARN_ON_ONCE(!sc); 742 if (!sc) { 743 shost_printk(KERN_ERR, fnic->lport->host, 744 "icmnd_cmpl sc is null - " 745 "hdr status = %s tag = 0x%x desc = 0x%p\n", 746 fnic_fcpio_status_to_str(hdr_status), id, desc); |
747 FNIC_TRACE(fnic_fcpio_icmnd_cmpl_handler, 748 fnic->lport->host->host_no, id, 749 ((u64)icmnd_cmpl->_resvd0[1] << 16 | 750 (u64)icmnd_cmpl->_resvd0[0]), 751 ((u64)hdr_status << 16 | 752 (u64)icmnd_cmpl->scsi_status << 8 | 753 (u64)icmnd_cmpl->flags), desc, 754 (u64)icmnd_cmpl->residual, 0); |
|
727 return; 728 } 729 730 io_lock = fnic_io_lock_hash(fnic, sc); 731 spin_lock_irqsave(io_lock, flags); 732 io_req = (struct fnic_io_req *)CMD_SP(sc); 733 WARN_ON_ONCE(!io_req); 734 if (!io_req) { --- 124 unchanged lines hidden (view full) --- 859 CMD_FLAGS(sc) |= FNIC_IO_DONE; 860 861 spin_unlock_irqrestore(io_lock, flags); 862 863 fnic_release_ioreq_buf(fnic, io_req, sc); 864 865 mempool_free(io_req, fnic->io_req_pool); 866 | 755 return; 756 } 757 758 io_lock = fnic_io_lock_hash(fnic, sc); 759 spin_lock_irqsave(io_lock, flags); 760 io_req = (struct fnic_io_req *)CMD_SP(sc); 761 WARN_ON_ONCE(!io_req); 762 if (!io_req) { --- 124 unchanged lines hidden (view full) --- 887 CMD_FLAGS(sc) |= FNIC_IO_DONE; 888 889 spin_unlock_irqrestore(io_lock, flags); 890 891 fnic_release_ioreq_buf(fnic, io_req, sc); 892 893 mempool_free(io_req, fnic->io_req_pool); 894 |
895 cmd_trace = ((u64)hdr_status << 56) | 896 (u64)icmnd_cmpl->scsi_status << 48 | 897 (u64)icmnd_cmpl->flags << 40 | (u64)sc->cmnd[0] << 32 | 898 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | 899 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]; 900 901 FNIC_TRACE(fnic_fcpio_icmnd_cmpl_handler, 902 sc->device->host->host_no, id, sc, 903 ((u64)icmnd_cmpl->_resvd0[1] << 56 | 904 (u64)icmnd_cmpl->_resvd0[0] << 48 | 905 jiffies_to_msecs(jiffies - start_time)), 906 desc, cmd_trace, 907 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); 908 |
|
867 if (sc->sc_data_direction == DMA_FROM_DEVICE) { 868 fnic->lport->host_stats.fcp_input_requests++; 869 fnic->fcp_input_bytes += xfer_len; 870 } else if (sc->sc_data_direction == DMA_TO_DEVICE) { 871 fnic->lport->host_stats.fcp_output_requests++; 872 fnic->fcp_output_bytes += xfer_len; 873 } else 874 fnic->lport->host_stats.fcp_control_requests++; 875 876 /* Call SCSI completion function to complete the IO */ 877 if (sc->scsi_done) 878 sc->scsi_done(sc); | 909 if (sc->sc_data_direction == DMA_FROM_DEVICE) { 910 fnic->lport->host_stats.fcp_input_requests++; 911 fnic->fcp_input_bytes += xfer_len; 912 } else if (sc->sc_data_direction == DMA_TO_DEVICE) { 913 fnic->lport->host_stats.fcp_output_requests++; 914 fnic->fcp_output_bytes += xfer_len; 915 } else 916 fnic->lport->host_stats.fcp_control_requests++; 917 918 /* Call SCSI completion function to complete the IO */ 919 if (sc->scsi_done) 920 sc->scsi_done(sc); |
879 | |
880} 881 882/* fnic_fcpio_itmf_cmpl_handler 883 * Routine to handle itmf completions 884 */ 885static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, 886 struct fcpio_fw_req *desc) 887{ --- 81 unchanged lines hidden (view full) --- 969 "abts cmpl, completing IO\n"); 970 CMD_SP(sc) = NULL; 971 sc->result = (DID_ERROR << 16); 972 973 spin_unlock_irqrestore(io_lock, flags); 974 975 fnic_release_ioreq_buf(fnic, io_req, sc); 976 mempool_free(io_req, fnic->io_req_pool); | 921} 922 923/* fnic_fcpio_itmf_cmpl_handler 924 * Routine to handle itmf completions 925 */ 926static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, 927 struct fcpio_fw_req *desc) 928{ --- 81 unchanged lines hidden (view full) --- 1010 "abts cmpl, completing IO\n"); 1011 CMD_SP(sc) = NULL; 1012 sc->result = (DID_ERROR << 16); 1013 1014 spin_unlock_irqrestore(io_lock, flags); 1015 1016 fnic_release_ioreq_buf(fnic, io_req, sc); 1017 mempool_free(io_req, fnic->io_req_pool); |
977 if (sc->scsi_done) | 1018 if (sc->scsi_done) { 1019 FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, 1020 sc->device->host->host_no, id, 1021 sc, 1022 jiffies_to_msecs(jiffies - start_time), 1023 desc, 1024 (((u64)hdr_status << 40) | 1025 (u64)sc->cmnd[0] << 32 | 1026 (u64)sc->cmnd[2] << 24 | 1027 (u64)sc->cmnd[3] << 16 | 1028 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), 1029 (((u64)CMD_FLAGS(sc) << 32) | 1030 CMD_STATE(sc))); |
978 sc->scsi_done(sc); | 1031 sc->scsi_done(sc); |
1032 } |
|
979 } 980 981 } else if (id & FNIC_TAG_DEV_RST) { 982 /* Completion of device reset */ 983 CMD_LR_STATUS(sc) = hdr_status; 984 if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { 985 spin_unlock_irqrestore(io_lock, flags); 986 CMD_FLAGS(sc) |= FNIC_DEV_RST_ABTS_PENDING; | 1033 } 1034 1035 } else if (id & FNIC_TAG_DEV_RST) { 1036 /* Completion of device reset */ 1037 CMD_LR_STATUS(sc) = hdr_status; 1038 if (CMD_STATE(sc) == FNIC_IOREQ_ABTS_PENDING) { 1039 spin_unlock_irqrestore(io_lock, flags); 1040 CMD_FLAGS(sc) |= FNIC_DEV_RST_ABTS_PENDING; |
1041 FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, 1042 sc->device->host->host_no, id, sc, 1043 jiffies_to_msecs(jiffies - start_time), 1044 desc, 0, 1045 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); |
|
987 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 988 "Terminate pending " 989 "dev reset cmpl recd. id %d status %s\n", 990 (int)(id & FNIC_TAG_MASK), 991 fnic_fcpio_status_to_str(hdr_status)); 992 return; 993 } 994 if (CMD_FLAGS(sc) & FNIC_DEV_RST_TIMED_OUT) { 995 /* Need to wait for terminate completion */ 996 spin_unlock_irqrestore(io_lock, flags); | 1046 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1047 "Terminate pending " 1048 "dev reset cmpl recd. id %d status %s\n", 1049 (int)(id & FNIC_TAG_MASK), 1050 fnic_fcpio_status_to_str(hdr_status)); 1051 return; 1052 } 1053 if (CMD_FLAGS(sc) & FNIC_DEV_RST_TIMED_OUT) { 1054 /* Need to wait for terminate completion */ 1055 spin_unlock_irqrestore(io_lock, flags); |
1056 FNIC_TRACE(fnic_fcpio_itmf_cmpl_handler, 1057 sc->device->host->host_no, id, sc, 1058 jiffies_to_msecs(jiffies - start_time), 1059 desc, 0, 1060 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); |
|
997 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 998 "dev reset cmpl recd after time out. " 999 "id %d status %s\n", 1000 (int)(id & FNIC_TAG_MASK), 1001 fnic_fcpio_status_to_str(hdr_status)); 1002 return; 1003 } 1004 CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; --- 132 unchanged lines hidden (view full) --- 1137 mempool_free(io_req, fnic->io_req_pool); 1138 1139cleanup_scsi_cmd: 1140 sc->result = DID_TRANSPORT_DISRUPTED << 16; 1141 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "fnic_cleanup_io:" 1142 " DID_TRANSPORT_DISRUPTED\n"); 1143 1144 /* Complete the command to SCSI */ | 1061 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1062 "dev reset cmpl recd after time out. " 1063 "id %d status %s\n", 1064 (int)(id & FNIC_TAG_MASK), 1065 fnic_fcpio_status_to_str(hdr_status)); 1066 return; 1067 } 1068 CMD_STATE(sc) = FNIC_IOREQ_CMD_COMPLETE; --- 132 unchanged lines hidden (view full) --- 1201 mempool_free(io_req, fnic->io_req_pool); 1202 1203cleanup_scsi_cmd: 1204 sc->result = DID_TRANSPORT_DISRUPTED << 16; 1205 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "fnic_cleanup_io:" 1206 " DID_TRANSPORT_DISRUPTED\n"); 1207 1208 /* Complete the command to SCSI */ |
1145 if (sc->scsi_done) | 1209 if (sc->scsi_done) { 1210 FNIC_TRACE(fnic_cleanup_io, 1211 sc->device->host->host_no, i, sc, 1212 jiffies_to_msecs(jiffies - start_time), 1213 0, ((u64)sc->cmnd[0] << 32 | 1214 (u64)sc->cmnd[2] << 24 | 1215 (u64)sc->cmnd[3] << 16 | 1216 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), 1217 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); 1218 |
1146 sc->scsi_done(sc); | 1219 sc->scsi_done(sc); |
1220 } |
|
1147 } 1148} 1149 1150void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, 1151 struct fcpio_host_req *desc) 1152{ 1153 u32 id; 1154 struct fnic *fnic = vnic_dev_priv(wq->vdev); --- 35 unchanged lines hidden (view full) --- 1190 fnic_release_ioreq_buf(fnic, io_req, sc); 1191 mempool_free(io_req, fnic->io_req_pool); 1192 1193wq_copy_cleanup_scsi_cmd: 1194 sc->result = DID_NO_CONNECT << 16; 1195 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:" 1196 " DID_NO_CONNECT\n"); 1197 | 1221 } 1222} 1223 1224void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, 1225 struct fcpio_host_req *desc) 1226{ 1227 u32 id; 1228 struct fnic *fnic = vnic_dev_priv(wq->vdev); --- 35 unchanged lines hidden (view full) --- 1264 fnic_release_ioreq_buf(fnic, io_req, sc); 1265 mempool_free(io_req, fnic->io_req_pool); 1266 1267wq_copy_cleanup_scsi_cmd: 1268 sc->result = DID_NO_CONNECT << 16; 1269 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, "wq_copy_cleanup_handler:" 1270 " DID_NO_CONNECT\n"); 1271 |
1198 if (sc->scsi_done) | 1272 if (sc->scsi_done) { 1273 FNIC_TRACE(fnic_wq_copy_cleanup_handler, 1274 sc->device->host->host_no, id, sc, 1275 jiffies_to_msecs(jiffies - start_time), 1276 0, ((u64)sc->cmnd[0] << 32 | 1277 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | 1278 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), 1279 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); 1280 |
1199 sc->scsi_done(sc); | 1281 sc->scsi_done(sc); |
1282 } |
|
1200} 1201 1202static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, 1203 u32 task_req, u8 *fc_lun, 1204 struct fnic_io_req *io_req) 1205{ 1206 struct vnic_wq_copy *wq = &fnic->wq_copy[0]; 1207 struct Scsi_Host *host = fnic->lport->host; --- 263 unchanged lines hidden (view full) --- 1471 * This function is exported to SCSI for sending abort cmnds. 1472 * A SCSI IO is represented by a io_req in the driver. 1473 * The ioreq is linked to the SCSI Cmd, thus a link with the ULP's IO. 1474 */ 1475int fnic_abort_cmd(struct scsi_cmnd *sc) 1476{ 1477 struct fc_lport *lp; 1478 struct fnic *fnic; | 1283} 1284 1285static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, 1286 u32 task_req, u8 *fc_lun, 1287 struct fnic_io_req *io_req) 1288{ 1289 struct vnic_wq_copy *wq = &fnic->wq_copy[0]; 1290 struct Scsi_Host *host = fnic->lport->host; --- 263 unchanged lines hidden (view full) --- 1554 * This function is exported to SCSI for sending abort cmnds. 1555 * A SCSI IO is represented by a io_req in the driver. 1556 * The ioreq is linked to the SCSI Cmd, thus a link with the ULP's IO. 1557 */ 1558int fnic_abort_cmd(struct scsi_cmnd *sc) 1559{ 1560 struct fc_lport *lp; 1561 struct fnic *fnic; |
1479 struct fnic_io_req *io_req; | 1562 struct fnic_io_req *io_req = NULL; |
1480 struct fc_rport *rport; 1481 spinlock_t *io_lock; 1482 unsigned long flags; 1483 unsigned long start_time = 0; 1484 int ret = SUCCESS; 1485 u32 task_req = 0; 1486 struct scsi_lun fc_lun; 1487 int tag; --- 10 unchanged lines hidden (view full) --- 1498 tag = sc->request->tag; 1499 FNIC_SCSI_DBG(KERN_DEBUG, 1500 fnic->lport->host, 1501 "Abort Cmd called FCID 0x%x, LUN 0x%x TAG %x flags %x\n", 1502 rport->port_id, sc->device->lun, tag, CMD_FLAGS(sc)); 1503 1504 CMD_FLAGS(sc) = FNIC_NO_FLAGS; 1505 | 1563 struct fc_rport *rport; 1564 spinlock_t *io_lock; 1565 unsigned long flags; 1566 unsigned long start_time = 0; 1567 int ret = SUCCESS; 1568 u32 task_req = 0; 1569 struct scsi_lun fc_lun; 1570 int tag; --- 10 unchanged lines hidden (view full) --- 1581 tag = sc->request->tag; 1582 FNIC_SCSI_DBG(KERN_DEBUG, 1583 fnic->lport->host, 1584 "Abort Cmd called FCID 0x%x, LUN 0x%x TAG %x flags %x\n", 1585 rport->port_id, sc->device->lun, tag, CMD_FLAGS(sc)); 1586 1587 CMD_FLAGS(sc) = FNIC_NO_FLAGS; 1588 |
1506 | |
1507 if (lp->state != LPORT_ST_READY || !(lp->link_up)) { 1508 ret = FAILED; 1509 goto fnic_abort_cmd_end; 1510 } 1511 1512 /* 1513 * Avoid a race between SCSI issuing the abort and the device 1514 * completing the command. --- 101 unchanged lines hidden (view full) --- 1616 1617 spin_unlock_irqrestore(io_lock, flags); 1618 1619 start_time = io_req->start_time; 1620 fnic_release_ioreq_buf(fnic, io_req, sc); 1621 mempool_free(io_req, fnic->io_req_pool); 1622 1623fnic_abort_cmd_end: | 1589 if (lp->state != LPORT_ST_READY || !(lp->link_up)) { 1590 ret = FAILED; 1591 goto fnic_abort_cmd_end; 1592 } 1593 1594 /* 1595 * Avoid a race between SCSI issuing the abort and the device 1596 * completing the command. --- 101 unchanged lines hidden (view full) --- 1698 1699 spin_unlock_irqrestore(io_lock, flags); 1700 1701 start_time = io_req->start_time; 1702 fnic_release_ioreq_buf(fnic, io_req, sc); 1703 mempool_free(io_req, fnic->io_req_pool); 1704 1705fnic_abort_cmd_end: |
1706 FNIC_TRACE(fnic_abort_cmd, sc->device->host->host_no, 1707 sc->request->tag, sc, 1708 jiffies_to_msecs(jiffies - start_time), 1709 0, ((u64)sc->cmnd[0] << 32 | 1710 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | 1711 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), 1712 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); 1713 |
|
1624 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1625 "Returning from abort cmd type %x %s\n", task_req, 1626 (ret == SUCCESS) ? 1627 "SUCCESS" : "FAILED"); 1628 return ret; 1629} 1630 1631static inline int fnic_queue_dr_io_req(struct fnic *fnic, --- 254 unchanged lines hidden (view full) --- 1886 * SCSI Eh thread issues a Lun Reset when one or more commands on a LUN 1887 * fail to get aborted. It calls driver's eh_device_reset with a SCSI command 1888 * on the LUN. 1889 */ 1890int fnic_device_reset(struct scsi_cmnd *sc) 1891{ 1892 struct fc_lport *lp; 1893 struct fnic *fnic; | 1714 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 1715 "Returning from abort cmd type %x %s\n", task_req, 1716 (ret == SUCCESS) ? 1717 "SUCCESS" : "FAILED"); 1718 return ret; 1719} 1720 1721static inline int fnic_queue_dr_io_req(struct fnic *fnic, --- 254 unchanged lines hidden (view full) --- 1976 * SCSI Eh thread issues a Lun Reset when one or more commands on a LUN 1977 * fail to get aborted. It calls driver's eh_device_reset with a SCSI command 1978 * on the LUN. 1979 */ 1980int fnic_device_reset(struct scsi_cmnd *sc) 1981{ 1982 struct fc_lport *lp; 1983 struct fnic *fnic; |
1894 struct fnic_io_req *io_req; | 1984 struct fnic_io_req *io_req = NULL; |
1895 struct fc_rport *rport; 1896 int status; 1897 int ret = FAILED; 1898 spinlock_t *io_lock; 1899 unsigned long flags; 1900 unsigned long start_time = 0; 1901 struct scsi_lun fc_lun; | 1985 struct fc_rport *rport; 1986 int status; 1987 int ret = FAILED; 1988 spinlock_t *io_lock; 1989 unsigned long flags; 1990 unsigned long start_time = 0; 1991 struct scsi_lun fc_lun; |
1902 int tag; | 1992 int tag = 0; |
1903 DECLARE_COMPLETION_ONSTACK(tm_done); 1904 int tag_gen_flag = 0; /*to track tags allocated by fnic driver*/ 1905 1906 /* Wait for rport to unblock */ 1907 fc_block_scsi_eh(sc); 1908 1909 /* Get local-port, check ready and link up */ 1910 lp = shost_priv(sc->device->host); --- 178 unchanged lines hidden (view full) --- 2089 2090 if (io_req) { 2091 start_time = io_req->start_time; 2092 fnic_release_ioreq_buf(fnic, io_req, sc); 2093 mempool_free(io_req, fnic->io_req_pool); 2094 } 2095 2096fnic_device_reset_end: | 1993 DECLARE_COMPLETION_ONSTACK(tm_done); 1994 int tag_gen_flag = 0; /*to track tags allocated by fnic driver*/ 1995 1996 /* Wait for rport to unblock */ 1997 fc_block_scsi_eh(sc); 1998 1999 /* Get local-port, check ready and link up */ 2000 lp = shost_priv(sc->device->host); --- 178 unchanged lines hidden (view full) --- 2179 2180 if (io_req) { 2181 start_time = io_req->start_time; 2182 fnic_release_ioreq_buf(fnic, io_req, sc); 2183 mempool_free(io_req, fnic->io_req_pool); 2184 } 2185 2186fnic_device_reset_end: |
2187 FNIC_TRACE(fnic_device_reset, sc->device->host->host_no, 2188 sc->request->tag, sc, 2189 jiffies_to_msecs(jiffies - start_time), 2190 0, ((u64)sc->cmnd[0] << 32 | 2191 (u64)sc->cmnd[2] << 24 | (u64)sc->cmnd[3] << 16 | 2192 (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), 2193 (((u64)CMD_FLAGS(sc) << 32) | CMD_STATE(sc))); 2194 |
|
2097 /* free tag if it is allocated */ 2098 if (unlikely(tag_gen_flag)) 2099 fnic_scsi_host_end_tag(fnic, sc); 2100 2101 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2102 "Returning from device reset %s\n", 2103 (ret == SUCCESS) ? 2104 "SUCCESS" : "FAILED"); --- 241 unchanged lines hidden --- | 2195 /* free tag if it is allocated */ 2196 if (unlikely(tag_gen_flag)) 2197 fnic_scsi_host_end_tag(fnic, sc); 2198 2199 FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, 2200 "Returning from device reset %s\n", 2201 (ret == SUCCESS) ? 2202 "SUCCESS" : "FAILED"); --- 241 unchanged lines hidden --- |