Lines Matching refs:cmd
267 #define NEXT(cmd) ((Scsi_Cmnd *)((cmd)->host_scribble)) argument
268 #define NEXTADDR(cmd) ((Scsi_Cmnd **)&((cmd)->host_scribble)) argument
271 #define H_NO(cmd) (cmd)->host->host_no argument
358 static int is_lun_busy( Scsi_Cmnd *cmd, int should_be_tagged ) in is_lun_busy() argument
360 SETUP_HOSTDATA(cmd->host); in is_lun_busy()
362 if (hostdata->busy[cmd->target] & (1 << cmd->lun)) in is_lun_busy()
365 !setup_use_tagged_queuing || !cmd->device->tagged_supported) in is_lun_busy()
367 if (TagAlloc[cmd->target][cmd->lun].nr_allocated >= in is_lun_busy()
368 TagAlloc[cmd->target][cmd->lun].queue_size ) { in is_lun_busy()
370 H_NO(cmd), cmd->target, cmd->lun ); in is_lun_busy()
382 static void cmd_get_tag( Scsi_Cmnd *cmd, int should_be_tagged ) in cmd_get_tag() argument
384 SETUP_HOSTDATA(cmd->host); in cmd_get_tag()
390 !setup_use_tagged_queuing || !cmd->device->tagged_supported) { in cmd_get_tag()
391 cmd->tag = TAG_NONE; in cmd_get_tag()
392 hostdata->busy[cmd->target] |= (1 << cmd->lun); in cmd_get_tag()
394 "command\n", H_NO(cmd), cmd->target, cmd->lun ); in cmd_get_tag()
397 TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; in cmd_get_tag()
399 cmd->tag = find_first_zero_bit( &ta->allocated, MAX_TAGS ); in cmd_get_tag()
400 set_bit( cmd->tag, &ta->allocated ); in cmd_get_tag()
404 H_NO(cmd), cmd->tag, cmd->target, cmd->lun, in cmd_get_tag()
414 static void cmd_free_tag( Scsi_Cmnd *cmd ) in cmd_free_tag() argument
416 SETUP_HOSTDATA(cmd->host); in cmd_free_tag()
418 if (cmd->tag == TAG_NONE) { in cmd_free_tag()
419 hostdata->busy[cmd->target] &= ~(1 << cmd->lun); in cmd_free_tag()
421 H_NO(cmd), cmd->target, cmd->lun ); in cmd_free_tag()
423 else if (cmd->tag >= MAX_TAGS) { in cmd_free_tag()
425 H_NO(cmd), cmd->tag ); in cmd_free_tag()
428 TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; in cmd_free_tag()
429 clear_bit( cmd->tag, &ta->allocated ); in cmd_free_tag()
432 H_NO(cmd), cmd->tag, cmd->target, cmd->lun ); in cmd_free_tag()
469 static void merge_contiguous_buffers( Scsi_Cmnd *cmd ) in merge_contiguous_buffers() argument
473 unsigned long oldlen = cmd->SCp.this_residual; in merge_contiguous_buffers()
477 for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; in merge_contiguous_buffers()
478 cmd->SCp.buffers_residual && in merge_contiguous_buffers()
479 virt_to_phys(cmd->SCp.buffer[1].address) == endaddr; ) { in merge_contiguous_buffers()
482 cmd->SCp.buffer[1].address, endaddr); in merge_contiguous_buffers()
486 ++cmd->SCp.buffer; in merge_contiguous_buffers()
487 --cmd->SCp.buffers_residual; in merge_contiguous_buffers()
488 cmd->SCp.this_residual += cmd->SCp.buffer->length; in merge_contiguous_buffers()
489 endaddr += cmd->SCp.buffer->length; in merge_contiguous_buffers()
492 if (oldlen != cmd->SCp.this_residual) in merge_contiguous_buffers()
494 cnt, cmd->SCp.ptr, cmd->SCp.this_residual); in merge_contiguous_buffers()
507 static __inline__ void initialize_SCp(Scsi_Cmnd *cmd) in initialize_SCp() argument
514 if (cmd->use_sg) { in initialize_SCp()
515 cmd->SCp.buffer = (struct scatterlist *) cmd->buffer; in initialize_SCp()
516 cmd->SCp.buffers_residual = cmd->use_sg - 1; in initialize_SCp()
517 cmd->SCp.ptr = (char *) cmd->SCp.buffer->address; in initialize_SCp()
518 cmd->SCp.this_residual = cmd->SCp.buffer->length; in initialize_SCp()
522 merge_contiguous_buffers( cmd ); in initialize_SCp()
524 cmd->SCp.buffer = NULL; in initialize_SCp()
525 cmd->SCp.buffers_residual = 0; in initialize_SCp()
526 cmd->SCp.ptr = (char *) cmd->request_buffer; in initialize_SCp()
527 cmd->SCp.this_residual = cmd->request_bufflen; in initialize_SCp()
755 char *lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length);
820 lprint_Scsi_Cmnd (Scsi_Cmnd *cmd, char *pos, char *buffer, int length) in lprint_Scsi_Cmnd() argument
825 H_NO(cmd), cmd->target, cmd->lun); in lprint_Scsi_Cmnd()
827 command = cmd->cmnd; in lprint_Scsi_Cmnd()
913 static int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) in NCR5380_queue_command() argument
915 SETUP_HOSTDATA(cmd->host); in NCR5380_queue_command()
921 switch (cmd->cmnd[0]) { in NCR5380_queue_command()
925 H_NO(cmd)); in NCR5380_queue_command()
926 cmd->result = (DID_ERROR << 16); in NCR5380_queue_command()
927 done(cmd); in NCR5380_queue_command()
941 if (cmd->request_bufflen > NCR5380_STAT_LIMIT) in NCR5380_queue_command()
943 switch (cmd->cmnd[0]) in NCR5380_queue_command()
948 hostdata->time_write[cmd->target] -= (jiffies - hostdata->timebase); in NCR5380_queue_command()
949 hostdata->bytes_write[cmd->target] += cmd->request_bufflen; in NCR5380_queue_command()
955 hostdata->time_read[cmd->target] -= (jiffies - hostdata->timebase); in NCR5380_queue_command()
956 hostdata->bytes_read[cmd->target] += cmd->request_bufflen; in NCR5380_queue_command()
967 NEXT(cmd) = NULL; in NCR5380_queue_command()
968 cmd->scsi_done = done; in NCR5380_queue_command()
970 cmd->result = 0; in NCR5380_queue_command()
994 if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) { in NCR5380_queue_command()
995 LIST(cmd, hostdata->issue_queue); in NCR5380_queue_command()
996 NEXT(cmd) = hostdata->issue_queue; in NCR5380_queue_command()
997 hostdata->issue_queue = cmd; in NCR5380_queue_command()
1002 LIST(cmd, tmp); in NCR5380_queue_command()
1003 NEXT(tmp) = cmd; in NCR5380_queue_command()
1008 QU_PRINTK("scsi%d: command added to %s of queue\n", H_NO(cmd), in NCR5380_queue_command()
1009 (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"); in NCR5380_queue_command()
1211 if((sun3scsi_dma_finish(hostdata->connected->request.cmd))) { in NCR5380_dma_complete()
1345 static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd* cmd) in collect_stats() argument
1348 if (cmd->request_bufflen > NCR5380_STAT_LIMIT) in collect_stats()
1350 switch (cmd->cmnd[0]) in collect_stats()
1355 hostdata->time_write[cmd->target] += (jiffies - hostdata->timebase); in collect_stats()
1362 hostdata->time_read[cmd->target] += (jiffies - hostdata->timebase); in collect_stats()
1401 static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag) in NCR5380_select() argument
1525 NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->target))); in NCR5380_select()
1578 SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->target); in NCR5380_select()
1629 if (hostdata->targets_present & (1 << cmd->target)) { in NCR5380_select()
1637 cmd->result = DID_BAD_TARGET << 16; in NCR5380_select()
1639 collect_stats(hostdata, cmd); in NCR5380_select()
1642 cmd_free_tag( cmd ); in NCR5380_select()
1644 cmd->scsi_done(cmd); in NCR5380_select()
1651 hostdata->targets_present |= (1 << cmd->target); in NCR5380_select()
1672 HOSTNO, cmd->target); in NCR5380_select()
1673 tmp[0] = IDENTIFY(1, cmd->lun); in NCR5380_select()
1676 if (cmd->tag != TAG_NONE) { in NCR5380_select()
1678 tmp[2] = cmd->tag; in NCR5380_select()
1684 cmd->tag=0; in NCR5380_select()
1693 hostdata->connected = cmd; in NCR5380_select()
1695 hostdata->busy[cmd->target] |= (1 << cmd->lun); in NCR5380_select()
1700 initialize_SCp(cmd); in NCR5380_select()
1993 Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; in NCR5380_information_transfer() local
2013 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { in NCR5380_information_transfer()
2014 count = cmd->SCp.buffer->length; in NCR5380_information_transfer()
2015 d = cmd->SCp.buffer->address; in NCR5380_information_transfer()
2017 count = cmd->SCp.this_residual; in NCR5380_information_transfer()
2018 d = cmd->SCp.ptr; in NCR5380_information_transfer()
2023 != cmd)) in NCR5380_information_transfer()
2025 if((cmd->request.cmd == 0) || (cmd->request.cmd == 1)) { in NCR5380_information_transfer()
2027 cmd->request.cmd); in NCR5380_information_transfer()
2028 sun3_dma_setup_done = cmd; in NCR5380_information_transfer()
2057 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2058 cmd->done(cmd); in NCR5380_information_transfer()
2066 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { in NCR5380_information_transfer()
2067 ++cmd->SCp.buffer; in NCR5380_information_transfer()
2068 --cmd->SCp.buffers_residual; in NCR5380_information_transfer()
2069 cmd->SCp.this_residual = cmd->SCp.buffer->length; in NCR5380_information_transfer()
2070 cmd->SCp.ptr = cmd->SCp.buffer->address; in NCR5380_information_transfer()
2077 HOSTNO, cmd->SCp.this_residual, in NCR5380_information_transfer()
2078 cmd->SCp.buffers_residual); in NCR5380_information_transfer()
2099 NCR5380_dma_xfer_len(instance,cmd,phase)) > SUN3_DMA_MINSIZE) { in NCR5380_information_transfer()
2101 cmd->SCp.phase = phase; in NCR5380_information_transfer()
2104 &len, (unsigned char **) &cmd->SCp.ptr)) { in NCR5380_information_transfer()
2111 cmd->target, cmd->lun); in NCR5380_information_transfer()
2112 cmd->device->borken = 1; in NCR5380_information_transfer()
2117 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2118 cmd->done(cmd); in NCR5380_information_transfer()
2129 cmd->SCp.this_residual -= transfersize - len; in NCR5380_information_transfer()
2135 (int *) &cmd->SCp.this_residual, (unsigned char **) in NCR5380_information_transfer()
2136 &cmd->SCp.ptr); in NCR5380_information_transfer()
2139 if(sun3_dma_setup_done == cmd) in NCR5380_information_transfer()
2149 cmd->SCp.Message = tmp; in NCR5380_information_transfer()
2169 "complete.\n", HOSTNO, cmd->target, cmd->lun); in NCR5380_information_transfer()
2179 if (!cmd->next_link) { in NCR5380_information_transfer()
2182 HOSTNO, cmd->target, cmd->lun); in NCR5380_information_transfer()
2188 initialize_SCp(cmd->next_link); in NCR5380_information_transfer()
2191 cmd->next_link->tag = cmd->tag; in NCR5380_information_transfer()
2192 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); in NCR5380_information_transfer()
2195 HOSTNO, cmd->target, cmd->lun); in NCR5380_information_transfer()
2197 collect_stats(hostdata, cmd); in NCR5380_information_transfer()
2199 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2200 cmd = hostdata->connected; in NCR5380_information_transfer()
2209 "completed\n", HOSTNO, cmd->target, cmd->lun); in NCR5380_information_transfer()
2211 cmd_free_tag( cmd ); in NCR5380_information_transfer()
2212 if (status_byte(cmd->SCp.Status) == QUEUE_FULL) { in NCR5380_information_transfer()
2221 TAG_ALLOC *ta = &TagAlloc[cmd->target][cmd->lun]; in NCR5380_information_transfer()
2224 HOSTNO, cmd->target, cmd->lun, in NCR5380_information_transfer()
2230 hostdata->busy[cmd->target] &= ~(1 << cmd->lun); in NCR5380_information_transfer()
2251 if (cmd->cmnd[0] != REQUEST_SENSE) in NCR5380_information_transfer()
2252 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); in NCR5380_information_transfer()
2253 else if (status_byte(cmd->SCp.Status) != GOOD) in NCR5380_information_transfer()
2254 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); in NCR5380_information_transfer()
2257 if ((cmd->cmnd[0] != REQUEST_SENSE) && in NCR5380_information_transfer()
2258 (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) { in NCR5380_information_transfer()
2261 cmd->cmnd[0] = REQUEST_SENSE; in NCR5380_information_transfer()
2262 cmd->cmnd[1] &= 0xe0; in NCR5380_information_transfer()
2263 cmd->cmnd[2] = 0; in NCR5380_information_transfer()
2264 cmd->cmnd[3] = 0; in NCR5380_information_transfer()
2265 cmd->cmnd[4] = sizeof(cmd->sense_buffer); in NCR5380_information_transfer()
2266 cmd->cmnd[5] = 0; in NCR5380_information_transfer()
2267 cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]); in NCR5380_information_transfer()
2269 cmd->use_sg = 0; in NCR5380_information_transfer()
2274 cmd->request_buffer = (char *) cmd->sense_buffer; in NCR5380_information_transfer()
2275 cmd->request_bufflen = sizeof(cmd->sense_buffer); in NCR5380_information_transfer()
2279 LIST(cmd,hostdata->issue_queue); in NCR5380_information_transfer()
2280 NEXT(cmd) = hostdata->issue_queue; in NCR5380_information_transfer()
2281 hostdata->issue_queue = (Scsi_Cmnd *) cmd; in NCR5380_information_transfer()
2284 "issue queue\n", H_NO(cmd)); in NCR5380_information_transfer()
2289 collect_stats(hostdata, cmd); in NCR5380_information_transfer()
2291 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2320 cmd->device->tagged_supported = 0; in NCR5380_information_transfer()
2321 hostdata->busy[cmd->target] |= (1 << cmd->lun); in NCR5380_information_transfer()
2322 cmd->tag = TAG_NONE; in NCR5380_information_transfer()
2326 HOSTNO, cmd->target, cmd->lun); in NCR5380_information_transfer()
2335 cmd->device->disconnect = 1; in NCR5380_information_transfer()
2336 LIST(cmd,hostdata->disconnected_queue); in NCR5380_information_transfer()
2337 NEXT(cmd) = hostdata->disconnected_queue; in NCR5380_information_transfer()
2339 hostdata->disconnected_queue = cmd; in NCR5380_information_transfer()
2344 cmd->target, cmd->lun); in NCR5380_information_transfer()
2446 HOSTNO, tmp, cmd->target, cmd->lun); in NCR5380_information_transfer()
2452 cmd->target, cmd->lun); in NCR5380_information_transfer()
2468 cmd_free_tag( cmd ); in NCR5380_information_transfer()
2470 hostdata->busy[cmd->target] &= ~(1 << cmd->lun); in NCR5380_information_transfer()
2473 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2475 collect_stats(hostdata, cmd); in NCR5380_information_transfer()
2477 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2484 len = cmd->cmd_len; in NCR5380_information_transfer()
2485 data = cmd->cmnd; in NCR5380_information_transfer()
2498 cmd->SCp.Status = tmp; in NCR5380_information_transfer()
2643 tmp->request.cmd); in NCR5380_reselect()
2696 static int NCR5380_abort (Scsi_Cmnd *cmd) in NCR5380_abort() argument
2698 struct Scsi_Host *instance = cmd->host; in NCR5380_abort()
2704 print_Scsi_Cmnd (cmd); in NCR5380_abort()
2722 if (hostdata->connected == cmd) { in NCR5380_abort()
2745 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2747 cmd_free_tag( cmd ); in NCR5380_abort()
2749 hostdata->busy[cmd->target] &= ~(1 << cmd->lun); in NCR5380_abort()
2752 cmd->scsi_done(cmd); in NCR5380_abort()
2769 if (cmd == tmp) { in NCR5380_abort()
2827 if (cmd == tmp) { in NCR5380_abort()
2831 if (NCR5380_select (instance, cmd, (int) cmd->tag)) in NCR5380_abort()
2843 if (cmd == tmp) { in NCR5380_abort()
2855 hostdata->busy[cmd->target] &= ~(1 << cmd->lun); in NCR5380_abort()
2890 static int NCR5380_reset( Scsi_Cmnd *cmd, unsigned int reset_flags) in NCR5380_reset() argument
2892 SETUP_HOSTDATA(cmd->host); in NCR5380_reset()
2900 NCR5380_print_status (cmd->host); in NCR5380_reset()
2948 if ((cmd = connected)) { in NCR5380_reset()
2949 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); in NCR5380_reset()
2950 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16); in NCR5380_reset()
2951 cmd->scsi_done( cmd ); in NCR5380_reset()
2954 for (i = 0; (cmd = disconnected_queue); ++i) { in NCR5380_reset()
2955 disconnected_queue = NEXT(cmd); in NCR5380_reset()
2956 NEXT(cmd) = NULL; in NCR5380_reset()
2957 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16); in NCR5380_reset()
2958 cmd->scsi_done( cmd ); in NCR5380_reset()
2995 ABRT_PRINTK("scsi%d: reset aborted issued command(s)\n", H_NO(cmd)); in NCR5380_reset()
2997 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); in NCR5380_reset()
2999 ABRT_PRINTK("scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd)); in NCR5380_reset()