Lines Matching refs:SCpnt

135 static inline void nsp_inc_resid(struct scsi_cmnd *SCpnt, int residInc)
137 scsi_set_resid(SCpnt, scsi_get_resid(SCpnt) + residInc);
176 * You must be set SCpnt->result before call this function.
178 static void nsp_scsi_done(struct scsi_cmnd *SCpnt)
180 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
184 SCpnt->scsi_done(SCpnt);
187 static int nsp_queuecommand_lck(struct scsi_cmnd *SCpnt,
191 /*unsigned int host_id = SCpnt->device->host->this_id;*/
192 /*unsigned int base = SCpnt->device->host->io_port;*/
193 unsigned char target = scmd_id(SCpnt);
195 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
198 "SCpnt=0x%p target=%d lun=%llu sglist=0x%p bufflen=%d sg_count=%d",
199 SCpnt, target, SCpnt->device->lun, scsi_sglist(SCpnt),
200 scsi_bufflen(SCpnt), scsi_sg_count(SCpnt));
203 SCpnt->scsi_done = done;
207 SCpnt->result = DID_BAD_TARGET << 16;
208 nsp_scsi_done(SCpnt);
217 SCpnt->result = DID_BAD_TARGET << 16;
218 nsp_scsi_done(SCpnt);
223 show_command(SCpnt);
225 data->CurrentSC = SCpnt;
227 SCpnt->SCp.Status = CHECK_CONDITION;
228 SCpnt->SCp.Message = 0;
229 SCpnt->SCp.have_data_in = IO_UNKNOWN;
230 SCpnt->SCp.sent_command = 0;
231 SCpnt->SCp.phase = PH_UNDETERMINED;
232 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
240 if (scsi_bufflen(SCpnt)) {
241 SCpnt->SCp.buffer = scsi_sglist(SCpnt);
242 SCpnt->SCp.ptr = BUFFER_ADDR;
243 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
244 SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
246 SCpnt->SCp.ptr = NULL;
247 SCpnt->SCp.this_residual = 0;
248 SCpnt->SCp.buffer = NULL;
249 SCpnt->SCp.buffers_residual = 0;
252 if (nsphw_start_selection(SCpnt) == FALSE) {
254 SCpnt->result = DID_BUS_BUSY << 16;
255 nsp_scsi_done(SCpnt);
365 static int nsphw_start_selection(struct scsi_cmnd *SCpnt)
367 unsigned int host_id = SCpnt->device->host->this_id;
368 unsigned int base = SCpnt->device->host->io_port;
369 unsigned char target = scmd_id(SCpnt);
370 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
384 SCpnt->SCp.phase = PH_ARBSTART;
404 SCpnt->SCp.phase = PH_SELSTART;
415 nsp_start_timer(SCpnt, 1000/51);
446 static int nsp_analyze_sdtr(struct scsi_cmnd *SCpnt)
448 unsigned char target = scmd_id(SCpnt);
449 // unsigned char lun = SCpnt->device->lun;
450 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
504 static void nsp_start_timer(struct scsi_cmnd *SCpnt, int time)
506 unsigned int base = SCpnt->device->host->io_port;
507 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
509 //nsp_dbg(NSP_DEBUG_INTR, "in SCpnt=0x%p, time=%d", SCpnt, time);
517 static int nsp_negate_signal(struct scsi_cmnd *SCpnt, unsigned char mask,
520 unsigned int base = SCpnt->device->host->io_port;
545 static int nsp_expect_signal(struct scsi_cmnd *SCpnt,
549 unsigned int base = SCpnt->device->host->io_port;
580 static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase)
582 unsigned int base = SCpnt->device->host->io_port;
583 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
592 ret = nsp_expect_signal(SCpnt, phase, BUSMON_REQ);
599 if (len == 1 && SCpnt->SCp.phase == PH_MSG_OUT) {
611 nsp_negate_signal(SCpnt, BUSMON_ACK, "xfer<ack>");
620 static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt)
622 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
627 if (SCpnt->SCp.have_data_in != IO_IN) {
631 count = nsp_fifo_count(SCpnt);
642 SCpnt->SCp.phase = PH_DATA;
643 nsp_pio_read(SCpnt);
652 static int nsp_reselected(struct scsi_cmnd *SCpnt)
654 unsigned int base = SCpnt->device->host->io_port;
655 unsigned int host_id = SCpnt->device->host->this_id;
656 //nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
674 if (scmd_id(SCpnt) != target) {
678 nsp_negate_signal(SCpnt, BUSMON_SEL, "reselect<SEL>");
680 nsp_nexus(SCpnt);
691 static int nsp_fifo_count(struct scsi_cmnd *SCpnt)
693 unsigned int base = SCpnt->device->host->io_port;
718 static void nsp_pio_read(struct scsi_cmnd *SCpnt)
720 unsigned int base = SCpnt->device->host->io_port;
721 unsigned long mmio_base = SCpnt->device->host->base;
722 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
729 nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p resid=%d ocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d",
730 SCpnt, scsi_get_resid(SCpnt), ocount, SCpnt->SCp.ptr,
731 SCpnt->SCp.this_residual, SCpnt->SCp.buffer,
732 SCpnt->SCp.buffers_residual);
737 (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0 ) ) {
743 res = nsp_fifo_count(SCpnt) - ocount;
744 //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x ocount=0x%x res=0x%x", SCpnt->SCp.ptr, SCpnt->SCp.this_residual, ocount, res);
747 //nsp_dbg(NSP_DEBUG_DATA_IO, " wait for data this=%d", SCpnt->SCp.this_residual);
761 res = min(res, SCpnt->SCp.this_residual);
766 nsp_fifo32_read(base, SCpnt->SCp.ptr, res >> 2);
769 nsp_fifo8_read (base, SCpnt->SCp.ptr, res );
774 nsp_mmio_fifo32_read(mmio_base, SCpnt->SCp.ptr, res >> 2);
782 nsp_inc_resid(SCpnt, -res);
783 SCpnt->SCp.ptr += res;
784 SCpnt->SCp.this_residual -= res;
786 //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this_residual=0x%x ocount=0x%x", SCpnt->SCp.ptr, SCpnt->SCp.this_residual, ocount);
789 if (SCpnt->SCp.this_residual == 0 &&
790 SCpnt->SCp.buffers_residual != 0 ) {
792 SCpnt->SCp.buffers_residual--;
793 SCpnt->SCp.buffer++;
794 SCpnt->SCp.ptr = BUFFER_ADDR;
795 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
798 //nsp_dbg(NSP_DEBUG_DATA_IO, "page: 0x%p, off: 0x%x", SCpnt->SCp.buffer->page, SCpnt->SCp.buffer->offset);
806 scsi_get_resid(SCpnt), SCpnt->SCp.this_residual,
807 SCpnt->SCp.buffers_residual);
811 scsi_get_resid(SCpnt));
817 static void nsp_pio_write(struct scsi_cmnd *SCpnt)
819 unsigned int base = SCpnt->device->host->io_port;
820 unsigned long mmio_base = SCpnt->device->host->base;
821 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
829 data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual,
830 SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual,
831 scsi_get_resid(SCpnt));
836 (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0)) {
841 res = ocount - nsp_fifo_count(SCpnt);
845 nsp_inc_resid(SCpnt, res);
846 SCpnt->SCp.ptr -= res;
847 SCpnt->SCp.this_residual += res;
853 res = ocount - nsp_fifo_count(SCpnt);
859 res = min(SCpnt->SCp.this_residual, WFIFO_CRIT);
861 //nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x res=0x%x", SCpnt->SCp.ptr, SCpnt->SCp.this_residual, res);
865 nsp_fifo32_write(base, SCpnt->SCp.ptr, res >> 2);
868 nsp_fifo8_write (base, SCpnt->SCp.ptr, res );
873 nsp_mmio_fifo32_write(mmio_base, SCpnt->SCp.ptr, res >> 2);
881 nsp_inc_resid(SCpnt, -res);
882 SCpnt->SCp.ptr += res;
883 SCpnt->SCp.this_residual -= res;
887 if (SCpnt->SCp.this_residual == 0 &&
888 SCpnt->SCp.buffers_residual != 0 ) {
890 SCpnt->SCp.buffers_residual--;
891 SCpnt->SCp.buffer++;
892 SCpnt->SCp.ptr = BUFFER_ADDR;
893 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
902 scsi_get_resid(SCpnt));
906 scsi_get_resid(SCpnt));
914 static int nsp_nexus(struct scsi_cmnd *SCpnt)
916 unsigned int base = SCpnt->device->host->io_port;
917 unsigned char target = scmd_id(SCpnt);
918 // unsigned char lun = SCpnt->device->lun;
919 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
922 //nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p", SCpnt);
928 if (scsi_get_resid(SCpnt) % 4 != 0 ||
929 scsi_get_resid(SCpnt) <= PAGE_SIZE ) {
1456 static int nsp_eh_abort(struct scsi_cmnd *SCpnt)
1458 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1460 return nsp_eh_bus_reset(SCpnt);
1484 static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
1486 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
1488 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1493 static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt)
1495 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;