mpt_cam.c (256826) | mpt_cam.c (257381) |
---|---|
1/*- 2 * FreeBSD/CAM specific routines for LSI '909 FC adapters. 3 * FreeBSD Version. 4 * 5 * Copyright (c) 2000, 2001 by Greg Ansley 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 80 unchanged lines hidden (view full) --- 89 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 90 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 91 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 92 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 93 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 94 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 95 */ 96#include <sys/cdefs.h> | 1/*- 2 * FreeBSD/CAM specific routines for LSI '909 FC adapters. 3 * FreeBSD Version. 4 * 5 * Copyright (c) 2000, 2001 by Greg Ansley 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 80 unchanged lines hidden (view full) --- 89 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 90 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 91 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 92 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 93 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT 94 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 95 */ 96#include <sys/cdefs.h> |
97__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_cam.c 256826 2013-10-21 06:04:39Z mav $"); | 97__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_cam.c 257381 2013-10-30 14:04:47Z nwhitehorn $"); |
98 99#include <dev/mpt/mpt.h> 100#include <dev/mpt/mpt_cam.h> 101#include <dev/mpt/mpt_raid.h> 102 103#include "dev/mpt/mpilib/mpi_ioc.h" /* XXX Fix Event Handling!!! */ 104#include "dev/mpt/mpilib/mpi_init.h" 105#include "dev/mpt/mpilib/mpi_targ.h" --- 2092 unchanged lines hidden (view full) --- 2198 "SCSI_IO_REQUEST" : "SCSI_IO_PASSTHRU", mpt_req->CDB[0]); 2199 df = mpt_req->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK; 2200 if (df != MPI_SCSIIO_CONTROL_NODATATRANSFER) { 2201 mpt_prtc(mpt, "(%s %u byte%s ", 2202 (df == MPI_SCSIIO_CONTROL_READ)? 2203 "read" : "write", csio->dxfer_len, 2204 (csio->dxfer_len == 1)? ")" : "s)"); 2205 } | 98 99#include <dev/mpt/mpt.h> 100#include <dev/mpt/mpt_cam.h> 101#include <dev/mpt/mpt_raid.h> 102 103#include "dev/mpt/mpilib/mpi_ioc.h" /* XXX Fix Event Handling!!! */ 104#include "dev/mpt/mpilib/mpi_init.h" 105#include "dev/mpt/mpilib/mpi_targ.h" --- 2092 unchanged lines hidden (view full) --- 2198 "SCSI_IO_REQUEST" : "SCSI_IO_PASSTHRU", mpt_req->CDB[0]); 2199 df = mpt_req->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK; 2200 if (df != MPI_SCSIIO_CONTROL_NODATATRANSFER) { 2201 mpt_prtc(mpt, "(%s %u byte%s ", 2202 (df == MPI_SCSIIO_CONTROL_READ)? 2203 "read" : "write", csio->dxfer_len, 2204 (csio->dxfer_len == 1)? ")" : "s)"); 2205 } |
2206 mpt_prtc(mpt, "tgt %u lun %u req %p:%u\n", tgt, 2207 ccb->ccb_h.target_lun, req, req->serno); | 2206 mpt_prtc(mpt, "tgt %u lun %jx req %p:%u\n", tgt, 2207 (uintmax_t)ccb->ccb_h.target_lun, req, req->serno); |
2208 } 2209 2210 error = bus_dmamap_load_ccb(mpt->buffer_dmat, req->dmap, ccb, cb, 2211 req, 0); 2212 if (error == EINPROGRESS) { 2213 /* 2214 * So as to maintain ordering, freeze the controller queue 2215 * until our mapping is returned. --- 757 unchanged lines hidden (view full) --- 2973 "RX_ID received=0x%x; RX_ID in cmd=0x%x\n", 2974 rx_id, ct_id); 2975 goto skip; 2976 } 2977 2978 ccb = tgt->ccb; 2979 if (ccb) { 2980 mpt_prt(mpt, | 2208 } 2209 2210 error = bus_dmamap_load_ccb(mpt->buffer_dmat, req->dmap, ccb, cb, 2211 req, 0); 2212 if (error == EINPROGRESS) { 2213 /* 2214 * So as to maintain ordering, freeze the controller queue 2215 * until our mapping is returned. --- 757 unchanged lines hidden (view full) --- 2973 "RX_ID received=0x%x; RX_ID in cmd=0x%x\n", 2974 rx_id, ct_id); 2975 goto skip; 2976 } 2977 2978 ccb = tgt->ccb; 2979 if (ccb) { 2980 mpt_prt(mpt, |
2981 "CCB (%p): lun %u flags %x status %x\n", 2982 ccb, ccb->ccb_h.target_lun, | 2981 "CCB (%p): lun %jx flags %x status %x\n", 2982 ccb, (uintmax_t)ccb->ccb_h.target_lun, |
2983 ccb->ccb_h.flags, ccb->ccb_h.status); 2984 } 2985 mpt_prt(mpt, "target state 0x%x resid %u xfrd %u rpwrd " 2986 "%x nxfers %x\n", tgt->state, 2987 tgt->resid, tgt->bytes_xfered, tgt->reply_desc, 2988 tgt->nxfers); 2989 skip: 2990 if (mpt_abort_target_cmd(mpt, tgt_req)) { --- 702 unchanged lines hidden (view full) --- 3693 } else if (lun >= MPT_MAX_LUNS) { 3694 mpt_set_ccb_status(ccb, CAM_REQ_INVALID); 3695 break; 3696 } else { 3697 trtp = &mpt->trt[lun]; 3698 } 3699 if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { 3700 mpt_lprt(mpt, MPT_PRT_DEBUG1, | 2983 ccb->ccb_h.flags, ccb->ccb_h.status); 2984 } 2985 mpt_prt(mpt, "target state 0x%x resid %u xfrd %u rpwrd " 2986 "%x nxfers %x\n", tgt->state, 2987 tgt->resid, tgt->bytes_xfered, tgt->reply_desc, 2988 tgt->nxfers); 2989 skip: 2990 if (mpt_abort_target_cmd(mpt, tgt_req)) { --- 702 unchanged lines hidden (view full) --- 3693 } else if (lun >= MPT_MAX_LUNS) { 3694 mpt_set_ccb_status(ccb, CAM_REQ_INVALID); 3695 break; 3696 } else { 3697 trtp = &mpt->trt[lun]; 3698 } 3699 if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { 3700 mpt_lprt(mpt, MPT_PRT_DEBUG1, |
3701 "Put FREE ATIO %p lun %d\n", ccb, lun); | 3701 "Put FREE ATIO %p lun %jx\n", ccb, (uintmax_t)lun); |
3702 STAILQ_INSERT_TAIL(&trtp->atios, &ccb->ccb_h, 3703 sim_links.stqe); 3704 } else if (ccb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { 3705 mpt_lprt(mpt, MPT_PRT_DEBUG1, | 3702 STAILQ_INSERT_TAIL(&trtp->atios, &ccb->ccb_h, 3703 sim_links.stqe); 3704 } else if (ccb->ccb_h.func_code == XPT_IMMEDIATE_NOTIFY) { 3705 mpt_lprt(mpt, MPT_PRT_DEBUG1, |
3706 "Put FREE INOT lun %d\n", lun); | 3706 "Put FREE INOT lun %jx\n", (uintmax_t)lun); |
3707 STAILQ_INSERT_TAIL(&trtp->inots, &ccb->ccb_h, 3708 sim_links.stqe); 3709 } else { 3710 mpt_lprt(mpt, MPT_PRT_ALWAYS, "Got Notify ACK\n"); 3711 } 3712 mpt_set_ccb_status(ccb, CAM_REQ_INPROG); 3713 return; 3714 } --- 1146 unchanged lines hidden (view full) --- 4861 inot = (struct ccb_immediate_notify *) STAILQ_FIRST(&trtp->inots); 4862 if (inot == NULL) { 4863 mpt_lprt(mpt, MPT_PRT_WARN, "no INOTSs- sending back BSY\n"); 4864 mpt_scsi_tgt_status(mpt, NULL, req, SCSI_STATUS_BUSY, NULL); 4865 return; 4866 } 4867 STAILQ_REMOVE_HEAD(&trtp->inots, sim_links.stqe); 4868 mpt_lprt(mpt, MPT_PRT_DEBUG1, | 3707 STAILQ_INSERT_TAIL(&trtp->inots, &ccb->ccb_h, 3708 sim_links.stqe); 3709 } else { 3710 mpt_lprt(mpt, MPT_PRT_ALWAYS, "Got Notify ACK\n"); 3711 } 3712 mpt_set_ccb_status(ccb, CAM_REQ_INPROG); 3713 return; 3714 } --- 1146 unchanged lines hidden (view full) --- 4861 inot = (struct ccb_immediate_notify *) STAILQ_FIRST(&trtp->inots); 4862 if (inot == NULL) { 4863 mpt_lprt(mpt, MPT_PRT_WARN, "no INOTSs- sending back BSY\n"); 4864 mpt_scsi_tgt_status(mpt, NULL, req, SCSI_STATUS_BUSY, NULL); 4865 return; 4866 } 4867 STAILQ_REMOVE_HEAD(&trtp->inots, sim_links.stqe); 4868 mpt_lprt(mpt, MPT_PRT_DEBUG1, |
4869 "Get FREE INOT %p lun %d\n", inot, inot->ccb_h.target_lun); | 4869 "Get FREE INOT %p lun %jx\n", inot, 4870 (uintmax_t)inot->ccb_h.target_lun); |
4870 4871 inot->initiator_id = init_id; /* XXX */ 4872 /* 4873 * This is a somewhat grotesque attempt to map from task management 4874 * to old style SCSI messages. God help us all. 4875 */ 4876 switch (fc) { 4877 case MPT_ABORT_TASK_SET: --- 210 unchanged lines hidden (view full) --- 5088 return; 5089 } 5090 case REPORT_LUNS: 5091 mpt_lprt(mpt, MPT_PRT_DEBUG, "REPORT LUNS\n"); 5092 buf[12] = 0x26; 5093 return; 5094 default: 5095 mpt_lprt(mpt, MPT_PRT_DEBUG, | 4871 4872 inot->initiator_id = init_id; /* XXX */ 4873 /* 4874 * This is a somewhat grotesque attempt to map from task management 4875 * to old style SCSI messages. God help us all. 4876 */ 4877 switch (fc) { 4878 case MPT_ABORT_TASK_SET: --- 210 unchanged lines hidden (view full) --- 5089 return; 5090 } 5091 case REPORT_LUNS: 5092 mpt_lprt(mpt, MPT_PRT_DEBUG, "REPORT LUNS\n"); 5093 buf[12] = 0x26; 5094 return; 5095 default: 5096 mpt_lprt(mpt, MPT_PRT_DEBUG, |
5096 "CMD 0x%x to unmanaged lun %u\n", 5097 cdbp[0], lun); | 5097 "CMD 0x%x to unmanaged lun %jx\n", 5098 cdbp[0], (uintmax_t)lun); |
5098 buf[12] = 0x25; 5099 break; 5100 } 5101 mpt_scsi_tgt_status(mpt, NULL, req, cond, sp); 5102 return; 5103 } 5104 /* otherwise, leave trtp NULL */ 5105 } else { --- 15 unchanged lines hidden (view full) --- 5121 } 5122 return; 5123 } 5124 5125 5126 atiop = (struct ccb_accept_tio *) STAILQ_FIRST(&trtp->atios); 5127 if (atiop == NULL) { 5128 mpt_lprt(mpt, MPT_PRT_WARN, | 5099 buf[12] = 0x25; 5100 break; 5101 } 5102 mpt_scsi_tgt_status(mpt, NULL, req, cond, sp); 5103 return; 5104 } 5105 /* otherwise, leave trtp NULL */ 5106 } else { --- 15 unchanged lines hidden (view full) --- 5122 } 5123 return; 5124 } 5125 5126 5127 atiop = (struct ccb_accept_tio *) STAILQ_FIRST(&trtp->atios); 5128 if (atiop == NULL) { 5129 mpt_lprt(mpt, MPT_PRT_WARN, |
5129 "no ATIOs for lun %u- sending back %s\n", lun, | 5130 "no ATIOs for lun %jx- sending back %s\n", (uintmax_t)lun, |
5130 mpt->tenabled? "QUEUE FULL" : "BUSY"); 5131 mpt_scsi_tgt_status(mpt, NULL, req, 5132 mpt->tenabled? SCSI_STATUS_QUEUE_FULL : SCSI_STATUS_BUSY, 5133 NULL); 5134 return; 5135 } 5136 STAILQ_REMOVE_HEAD(&trtp->atios, sim_links.stqe); 5137 mpt_lprt(mpt, MPT_PRT_DEBUG1, | 5131 mpt->tenabled? "QUEUE FULL" : "BUSY"); 5132 mpt_scsi_tgt_status(mpt, NULL, req, 5133 mpt->tenabled? SCSI_STATUS_QUEUE_FULL : SCSI_STATUS_BUSY, 5134 NULL); 5135 return; 5136 } 5137 STAILQ_REMOVE_HEAD(&trtp->atios, sim_links.stqe); 5138 mpt_lprt(mpt, MPT_PRT_DEBUG1, |
5138 "Get FREE ATIO %p lun %d\n", atiop, atiop->ccb_h.target_lun); | 5139 "Get FREE ATIO %p lun %jx\n", atiop, 5140 (uintmax_t)atiop->ccb_h.target_lun); |
5139 atiop->ccb_h.ccb_mpt_ptr = mpt; 5140 atiop->ccb_h.status = CAM_CDB_RECVD; 5141 atiop->ccb_h.target_lun = lun; 5142 atiop->sense_len = 0; 5143 atiop->init_id = GET_INITIATOR_INDEX(reply_desc); 5144 atiop->cdb_len = mpt_cdblen(cdbp[0], 16); 5145 memcpy(atiop->cdb_io.cdb_bytes, cdbp, atiop->cdb_len); 5146 --- 7 unchanged lines hidden (view full) --- 5154 atiop->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); 5155 tgt->tag_id = atiop->tag_id; 5156 if (tag_action) { 5157 atiop->tag_action = tag_action; 5158 atiop->ccb_h.flags |= CAM_TAG_ACTION_VALID; 5159 } 5160 if (mpt->verbose >= MPT_PRT_DEBUG) { 5161 int i; | 5141 atiop->ccb_h.ccb_mpt_ptr = mpt; 5142 atiop->ccb_h.status = CAM_CDB_RECVD; 5143 atiop->ccb_h.target_lun = lun; 5144 atiop->sense_len = 0; 5145 atiop->init_id = GET_INITIATOR_INDEX(reply_desc); 5146 atiop->cdb_len = mpt_cdblen(cdbp[0], 16); 5147 memcpy(atiop->cdb_io.cdb_bytes, cdbp, atiop->cdb_len); 5148 --- 7 unchanged lines hidden (view full) --- 5156 atiop->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); 5157 tgt->tag_id = atiop->tag_id; 5158 if (tag_action) { 5159 atiop->tag_action = tag_action; 5160 atiop->ccb_h.flags |= CAM_TAG_ACTION_VALID; 5161 } 5162 if (mpt->verbose >= MPT_PRT_DEBUG) { 5163 int i; |
5162 mpt_prt(mpt, "START_CCB %p for lun %u CDB=<", atiop, 5163 atiop->ccb_h.target_lun); | 5164 mpt_prt(mpt, "START_CCB %p for lun %jx CDB=<", atiop, 5165 (uintmax_t)atiop->ccb_h.target_lun); |
5164 for (i = 0; i < atiop->cdb_len; i++) { 5165 mpt_prtc(mpt, "%02x%c", cdbp[i] & 0xff, 5166 (i == (atiop->cdb_len - 1))? '>' : ' '); 5167 } 5168 mpt_prtc(mpt, " itag %x tag %x rdesc %x dl=%u\n", 5169 itag, atiop->tag_id, tgt->reply_desc, tgt->resid); 5170 } 5171 --- 276 unchanged lines hidden --- | 5166 for (i = 0; i < atiop->cdb_len; i++) { 5167 mpt_prtc(mpt, "%02x%c", cdbp[i] & 0xff, 5168 (i == (atiop->cdb_len - 1))? '>' : ' '); 5169 } 5170 mpt_prtc(mpt, " itag %x tag %x rdesc %x dl=%u\n", 5171 itag, atiop->tag_id, tgt->reply_desc, tgt->resid); 5172 } 5173 --- 276 unchanged lines hidden --- |