Lines Matching refs:cmd
275 #define NEXT(cmd) ((Scsi_Cmnd *)(cmd)->host_scribble) argument
276 #define SET_NEXT(cmd,next) ((cmd)->host_scribble = (void *)(next)) argument
277 #define NEXTADDR(cmd) ((Scsi_Cmnd **)&(cmd)->host_scribble) argument
280 #define H_NO(cmd) (cmd)->device->host->host_no argument
362 static int is_lun_busy(Scsi_Cmnd *cmd, int should_be_tagged) in is_lun_busy() argument
364 SETUP_HOSTDATA(cmd->device->host); in is_lun_busy()
366 if (hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)) in is_lun_busy()
369 !setup_use_tagged_queuing || !cmd->device->tagged_supported) in is_lun_busy()
371 if (TagAlloc[cmd->device->id][cmd->device->lun].nr_allocated >= in is_lun_busy()
372 TagAlloc[cmd->device->id][cmd->device->lun].queue_size) { in is_lun_busy()
374 H_NO(cmd), cmd->device->id, cmd->device->lun); in is_lun_busy()
386 static void cmd_get_tag(Scsi_Cmnd *cmd, int should_be_tagged) in cmd_get_tag() argument
388 SETUP_HOSTDATA(cmd->device->host); in cmd_get_tag()
394 !setup_use_tagged_queuing || !cmd->device->tagged_supported) { in cmd_get_tag()
395 cmd->tag = TAG_NONE; in cmd_get_tag()
396 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); in cmd_get_tag()
398 "command\n", H_NO(cmd), cmd->device->id, cmd->device->lun); in cmd_get_tag()
400 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; in cmd_get_tag()
402 cmd->tag = find_first_zero_bit(ta->allocated, MAX_TAGS); in cmd_get_tag()
403 set_bit(cmd->tag, ta->allocated); in cmd_get_tag()
407 H_NO(cmd), cmd->tag, cmd->device->id, in cmd_get_tag()
408 cmd->device->lun, ta->nr_allocated); in cmd_get_tag()
417 static void cmd_free_tag(Scsi_Cmnd *cmd) in cmd_free_tag() argument
419 SETUP_HOSTDATA(cmd->device->host); in cmd_free_tag()
421 if (cmd->tag == TAG_NONE) { in cmd_free_tag()
422 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in cmd_free_tag()
424 H_NO(cmd), cmd->device->id, cmd->device->lun); in cmd_free_tag()
425 } else if (cmd->tag >= MAX_TAGS) { in cmd_free_tag()
427 H_NO(cmd), cmd->tag); in cmd_free_tag()
429 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; in cmd_free_tag()
430 clear_bit(cmd->tag, ta->allocated); in cmd_free_tag()
433 H_NO(cmd), cmd->tag, cmd->device->id, cmd->device->lun); in cmd_free_tag()
470 static void merge_contiguous_buffers(Scsi_Cmnd *cmd) in merge_contiguous_buffers() argument
474 unsigned long oldlen = cmd->SCp.this_residual; in merge_contiguous_buffers()
478 for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; in merge_contiguous_buffers()
479 cmd->SCp.buffers_residual && in merge_contiguous_buffers()
480 virt_to_phys(sg_virt(&cmd->SCp.buffer[1])) == endaddr;) { in merge_contiguous_buffers()
482 page_address(sg_page(&cmd->SCp.buffer[1])), 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 (scsi_bufflen(cmd)) { in initialize_SCp()
515 cmd->SCp.buffer = scsi_sglist(cmd); in initialize_SCp()
516 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; in initialize_SCp()
517 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); 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 = NULL; in initialize_SCp()
527 cmd->SCp.this_residual = 0; in initialize_SCp()
763 static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length);
820 static char *lprint_Scsi_Cmnd(Scsi_Cmnd *cmd, char *pos, char *buffer, int length) in lprint_Scsi_Cmnd() argument
825 H_NO(cmd), cmd->device->id, cmd->device->lun); in lprint_Scsi_Cmnd()
827 command = cmd->cmnd; in lprint_Scsi_Cmnd()
913 static int NCR5380_queue_command_lck(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) in NCR5380_queue_command_lck() argument
915 SETUP_HOSTDATA(cmd->device->host); in NCR5380_queue_command_lck()
921 switch (cmd->cmnd[0]) { in NCR5380_queue_command_lck()
925 H_NO(cmd)); in NCR5380_queue_command_lck()
926 cmd->result = (DID_ERROR << 16); in NCR5380_queue_command_lck()
927 done(cmd); in NCR5380_queue_command_lck()
940 if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT) in NCR5380_queue_command_lck()
942 switch (cmd->cmnd[0]) { in NCR5380_queue_command_lck()
946 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase); in NCR5380_queue_command_lck()
947 hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd); in NCR5380_queue_command_lck()
953 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase); in NCR5380_queue_command_lck()
954 hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd); in NCR5380_queue_command_lck()
965 SET_NEXT(cmd, NULL); in NCR5380_queue_command_lck()
966 cmd->scsi_done = done; in NCR5380_queue_command_lck()
968 cmd->result = 0; in NCR5380_queue_command_lck()
995 if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) { in NCR5380_queue_command_lck()
996 LIST(cmd, hostdata->issue_queue); in NCR5380_queue_command_lck()
997 SET_NEXT(cmd, hostdata->issue_queue); in NCR5380_queue_command_lck()
998 hostdata->issue_queue = cmd; in NCR5380_queue_command_lck()
1003 LIST(cmd, tmp); in NCR5380_queue_command_lck()
1004 SET_NEXT(tmp, cmd); in NCR5380_queue_command_lck()
1008 QU_PRINTK("scsi%d: command added to %s of queue\n", H_NO(cmd), in NCR5380_queue_command_lck()
1009 (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"); in NCR5380_queue_command_lck()
1355 static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd *cmd) in collect_stats() argument
1358 if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT) in collect_stats()
1360 switch (cmd->cmnd[0]) { in collect_stats()
1364 hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase); in collect_stats()
1371 hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase); in collect_stats()
1410 static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag) in NCR5380_select() argument
1532 NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id))); in NCR5380_select()
1585 SEL_PRINTK("scsi%d: selecting target %d\n", HOSTNO, cmd->device->id); in NCR5380_select()
1637 if (hostdata->targets_present & (1 << cmd->device->id)) { in NCR5380_select()
1645 cmd->result = DID_BAD_TARGET << 16; in NCR5380_select()
1647 collect_stats(hostdata, cmd); in NCR5380_select()
1650 cmd_free_tag(cmd); in NCR5380_select()
1652 cmd->scsi_done(cmd); in NCR5380_select()
1659 hostdata->targets_present |= (1 << cmd->device->id); in NCR5380_select()
1681 HOSTNO, cmd->device->id); in NCR5380_select()
1682 tmp[0] = IDENTIFY(1, cmd->device->lun); in NCR5380_select()
1685 if (cmd->tag != TAG_NONE) { in NCR5380_select()
1687 tmp[2] = cmd->tag; in NCR5380_select()
1693 cmd->tag = 0; in NCR5380_select()
1702 hostdata->connected = cmd; in NCR5380_select()
1704 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); in NCR5380_select()
1707 initialize_SCp(cmd); in NCR5380_select()
2012 Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; in NCR5380_information_transfer() local
2044 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2045 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2054 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { in NCR5380_information_transfer()
2055 ++cmd->SCp.buffer; in NCR5380_information_transfer()
2056 --cmd->SCp.buffers_residual; in NCR5380_information_transfer()
2057 cmd->SCp.this_residual = cmd->SCp.buffer->length; in NCR5380_information_transfer()
2058 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); in NCR5380_information_transfer()
2062 merge_contiguous_buffers(cmd); in NCR5380_information_transfer()
2064 HOSTNO, cmd->SCp.this_residual, in NCR5380_information_transfer()
2065 cmd->SCp.buffers_residual); in NCR5380_information_transfer()
2084 if (!cmd->device->borken && in NCR5380_information_transfer()
2085 (transfersize = NCR5380_dma_xfer_len(instance,cmd,phase)) > 31) { in NCR5380_information_transfer()
2087 cmd->SCp.phase = phase; in NCR5380_information_transfer()
2089 &len, (unsigned char **)&cmd->SCp.ptr)) { in NCR5380_information_transfer()
2096 cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2097 cmd->device->borken = 1; in NCR5380_information_transfer()
2102 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2103 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2114 cmd->SCp.this_residual -= transfersize - len; in NCR5380_information_transfer()
2120 (int *)&cmd->SCp.this_residual, in NCR5380_information_transfer()
2121 (unsigned char **)&cmd->SCp.ptr); in NCR5380_information_transfer()
2128 cmd->SCp.Message = tmp; in NCR5380_information_transfer()
2148 "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2158 if (!cmd->next_link) { in NCR5380_information_transfer()
2161 HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2167 initialize_SCp(cmd->next_link); in NCR5380_information_transfer()
2170 cmd->next_link->tag = cmd->tag; in NCR5380_information_transfer()
2171 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); in NCR5380_information_transfer()
2174 HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2176 collect_stats(hostdata, cmd); in NCR5380_information_transfer()
2178 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2179 cmd = hostdata->connected; in NCR5380_information_transfer()
2190 "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2192 cmd_free_tag(cmd); in NCR5380_information_transfer()
2193 if (status_byte(cmd->SCp.Status) == QUEUE_FULL) { in NCR5380_information_transfer()
2202 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun]; in NCR5380_information_transfer()
2205 HOSTNO, cmd->device->id, cmd->device->lun, in NCR5380_information_transfer()
2211 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
2232 if (cmd->cmnd[0] != REQUEST_SENSE) in NCR5380_information_transfer()
2233 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); in NCR5380_information_transfer()
2234 else if (status_byte(cmd->SCp.Status) != GOOD) in NCR5380_information_transfer()
2235 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); in NCR5380_information_transfer()
2238 if ((cmd->cmnd[0] == REQUEST_SENSE) && in NCR5380_information_transfer()
2240 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in NCR5380_information_transfer()
2244 if ((cmd->cmnd[0] != REQUEST_SENSE) && in NCR5380_information_transfer()
2245 (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) { in NCR5380_information_transfer()
2246 scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0); in NCR5380_information_transfer()
2251 LIST(cmd,hostdata->issue_queue); in NCR5380_information_transfer()
2252 SET_NEXT(cmd, hostdata->issue_queue); in NCR5380_information_transfer()
2253 hostdata->issue_queue = (Scsi_Cmnd *) cmd; in NCR5380_information_transfer()
2256 "issue queue\n", H_NO(cmd)); in NCR5380_information_transfer()
2261 collect_stats(hostdata, cmd); in NCR5380_information_transfer()
2263 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2298 cmd->device->tagged_supported = 0; in NCR5380_information_transfer()
2299 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); in NCR5380_information_transfer()
2300 cmd->tag = TAG_NONE; in NCR5380_information_transfer()
2304 HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2312 cmd->device->disconnect = 1; in NCR5380_information_transfer()
2313 LIST(cmd,hostdata->disconnected_queue); in NCR5380_information_transfer()
2314 SET_NEXT(cmd, hostdata->disconnected_queue); in NCR5380_information_transfer()
2316 hostdata->disconnected_queue = cmd; in NCR5380_information_transfer()
2321 cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2420 HOSTNO, tmp, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2426 cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2441 cmd_free_tag(cmd); in NCR5380_information_transfer()
2443 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
2446 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2448 collect_stats(hostdata, cmd); in NCR5380_information_transfer()
2450 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2458 len = cmd->cmd_len; in NCR5380_information_transfer()
2459 data = cmd->cmnd; in NCR5380_information_transfer()
2471 cmd->SCp.Status = tmp; in NCR5380_information_transfer()
2646 int NCR5380_abort(Scsi_Cmnd *cmd) in NCR5380_abort() argument
2648 struct Scsi_Host *instance = cmd->device->host; in NCR5380_abort()
2654 scsi_print_command(cmd); in NCR5380_abort()
2675 if (hostdata->connected == cmd) { in NCR5380_abort()
2698 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2700 cmd_free_tag(cmd); in NCR5380_abort()
2702 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2705 cmd->scsi_done(cmd); in NCR5380_abort()
2723 if (cmd == tmp) { in NCR5380_abort()
2783 if (cmd == tmp) { in NCR5380_abort()
2787 if (NCR5380_select(instance, cmd, (int)cmd->tag)) in NCR5380_abort()
2798 if (cmd == tmp) { in NCR5380_abort()
2810 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2853 static int NCR5380_bus_reset(Scsi_Cmnd *cmd) in NCR5380_bus_reset() argument
2855 SETUP_HOSTDATA(cmd->device->host); in NCR5380_bus_reset()
2864 H_NO(cmd)); in NCR5380_bus_reset()
2866 NCR5380_print_status(cmd->device->host); in NCR5380_bus_reset()
2913 if ((cmd = connected)) { in NCR5380_bus_reset()
2914 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); in NCR5380_bus_reset()
2915 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16); in NCR5380_bus_reset()
2916 cmd->scsi_done(cmd); in NCR5380_bus_reset()
2919 for (i = 0; (cmd = disconnected_queue); ++i) { in NCR5380_bus_reset()
2920 disconnected_queue = NEXT(cmd); in NCR5380_bus_reset()
2921 SET_NEXT(cmd, NULL); in NCR5380_bus_reset()
2922 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16); in NCR5380_bus_reset()
2923 cmd->scsi_done(cmd); in NCR5380_bus_reset()
2966 ABRT_PRINTK("scsi%d: reset aborted issued command(s)\n", H_NO(cmd)); in NCR5380_bus_reset()
2968 ABRT_PRINTK("scsi%d: reset aborted a connected command\n", H_NO(cmd)); in NCR5380_bus_reset()
2970 ABRT_PRINTK("scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd)); in NCR5380_bus_reset()