Lines Matching refs:cmd

230 #define	NEXT(cmd)		((struct scsi_cmnd *)(cmd)->host_scribble)  argument
231 #define SET_NEXT(cmd,next) ((cmd)->host_scribble = (void *)(next)) argument
232 #define NEXTADDR(cmd) ((struct scsi_cmnd **)&(cmd)->host_scribble) argument
235 #define H_NO(cmd) (cmd)->device->host->host_no argument
304 static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged) in is_lun_busy() argument
306 u8 lun = cmd->device->lun; in is_lun_busy()
307 SETUP_HOSTDATA(cmd->device->host); in is_lun_busy()
309 if (hostdata->busy[cmd->device->id] & (1 << lun)) in is_lun_busy()
313 !cmd->device->tagged_supported) in is_lun_busy()
315 if (hostdata->TagAlloc[scmd_id(cmd)][lun].nr_allocated >= in is_lun_busy()
316 hostdata->TagAlloc[scmd_id(cmd)][lun].queue_size) { in is_lun_busy()
318 H_NO(cmd), cmd->device->id, lun); in is_lun_busy()
330 static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged) in cmd_get_tag() argument
332 u8 lun = cmd->device->lun; in cmd_get_tag()
333 SETUP_HOSTDATA(cmd->device->host); in cmd_get_tag()
340 !cmd->device->tagged_supported) { in cmd_get_tag()
341 cmd->tag = TAG_NONE; in cmd_get_tag()
342 hostdata->busy[cmd->device->id] |= (1 << lun); in cmd_get_tag()
344 "command\n", H_NO(cmd), cmd->device->id, lun); in cmd_get_tag()
346 struct tag_alloc *ta = &hostdata->TagAlloc[scmd_id(cmd)][lun]; in cmd_get_tag()
348 cmd->tag = find_first_zero_bit(ta->allocated, MAX_TAGS); in cmd_get_tag()
349 set_bit(cmd->tag, ta->allocated); in cmd_get_tag()
353 H_NO(cmd), cmd->tag, cmd->device->id, in cmd_get_tag()
363 static void cmd_free_tag(struct scsi_cmnd *cmd) in cmd_free_tag() argument
365 u8 lun = cmd->device->lun; in cmd_free_tag()
366 SETUP_HOSTDATA(cmd->device->host); in cmd_free_tag()
368 if (cmd->tag == TAG_NONE) { in cmd_free_tag()
369 hostdata->busy[cmd->device->id] &= ~(1 << lun); in cmd_free_tag()
371 H_NO(cmd), cmd->device->id, lun); in cmd_free_tag()
372 } else if (cmd->tag >= MAX_TAGS) { in cmd_free_tag()
374 H_NO(cmd), cmd->tag); in cmd_free_tag()
376 struct tag_alloc *ta = &hostdata->TagAlloc[scmd_id(cmd)][lun]; in cmd_free_tag()
377 clear_bit(cmd->tag, ta->allocated); in cmd_free_tag()
380 H_NO(cmd), cmd->tag, cmd->device->id, lun); in cmd_free_tag()
417 static void merge_contiguous_buffers(struct scsi_cmnd *cmd) in merge_contiguous_buffers() argument
422 unsigned long oldlen = cmd->SCp.this_residual; in merge_contiguous_buffers()
426 for (endaddr = virt_to_phys(cmd->SCp.ptr + cmd->SCp.this_residual - 1) + 1; in merge_contiguous_buffers()
427 cmd->SCp.buffers_residual && in merge_contiguous_buffers()
428 virt_to_phys(sg_virt(&cmd->SCp.buffer[1])) == endaddr;) { in merge_contiguous_buffers()
430 page_address(sg_page(&cmd->SCp.buffer[1])), endaddr); in merge_contiguous_buffers()
434 ++cmd->SCp.buffer; in merge_contiguous_buffers()
435 --cmd->SCp.buffers_residual; in merge_contiguous_buffers()
436 cmd->SCp.this_residual += cmd->SCp.buffer->length; in merge_contiguous_buffers()
437 endaddr += cmd->SCp.buffer->length; in merge_contiguous_buffers()
440 if (oldlen != cmd->SCp.this_residual) in merge_contiguous_buffers()
442 cnt, cmd->SCp.ptr, cmd->SCp.this_residual); in merge_contiguous_buffers()
454 static inline void initialize_SCp(struct scsi_cmnd *cmd) in initialize_SCp() argument
461 if (scsi_bufflen(cmd)) { in initialize_SCp()
462 cmd->SCp.buffer = scsi_sglist(cmd); in initialize_SCp()
463 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1; in initialize_SCp()
464 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); in initialize_SCp()
465 cmd->SCp.this_residual = cmd->SCp.buffer->length; in initialize_SCp()
469 merge_contiguous_buffers(cmd); in initialize_SCp()
471 cmd->SCp.buffer = NULL; in initialize_SCp()
472 cmd->SCp.buffers_residual = 0; in initialize_SCp()
473 cmd->SCp.ptr = NULL; in initialize_SCp()
474 cmd->SCp.this_residual = 0; in initialize_SCp()
663 static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd) in lprint_Scsi_Cmnd() argument
668 H_NO(cmd), cmd->device->id, cmd->device->lun); in lprint_Scsi_Cmnd()
670 command = cmd->cmnd; in lprint_Scsi_Cmnd()
708 static void show_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m) in show_Scsi_Cmnd() argument
713 H_NO(cmd), cmd->device->id, cmd->device->lun); in show_Scsi_Cmnd()
715 command = cmd->cmnd; in show_Scsi_Cmnd()
828 struct scsi_cmnd *cmd) in NCR5380_queue_command() argument
835 switch (cmd->cmnd[0]) { in NCR5380_queue_command()
839 H_NO(cmd)); in NCR5380_queue_command()
840 cmd->result = (DID_ERROR << 16); in NCR5380_queue_command()
841 cmd->scsi_done(cmd); in NCR5380_queue_command()
851 SET_NEXT(cmd, NULL); in NCR5380_queue_command()
852 cmd->result = 0; in NCR5380_queue_command()
885 if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) { in NCR5380_queue_command()
886 LIST(cmd, hostdata->issue_queue); in NCR5380_queue_command()
887 SET_NEXT(cmd, hostdata->issue_queue); in NCR5380_queue_command()
888 hostdata->issue_queue = cmd; in NCR5380_queue_command()
893 LIST(cmd, tmp); in NCR5380_queue_command()
894 SET_NEXT(tmp, cmd); in NCR5380_queue_command()
898 dprintk(NDEBUG_QUEUES, "scsi%d: command added to %s of queue\n", H_NO(cmd), in NCR5380_queue_command()
899 (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail"); in NCR5380_queue_command()
1307 static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd) in NCR5380_select() argument
1429 NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id))); in NCR5380_select()
1482 dprintk(NDEBUG_SELECTION, "scsi%d: selecting target %d\n", HOSTNO, cmd->device->id); in NCR5380_select()
1534 if (hostdata->targets_present & (1 << cmd->device->id)) { in NCR5380_select()
1542 cmd->result = DID_BAD_TARGET << 16; in NCR5380_select()
1544 cmd_free_tag(cmd); in NCR5380_select()
1546 cmd->scsi_done(cmd); in NCR5380_select()
1553 hostdata->targets_present |= (1 << cmd->device->id); in NCR5380_select()
1575 HOSTNO, cmd->device->id); in NCR5380_select()
1576 tmp[0] = IDENTIFY(1, cmd->device->lun); in NCR5380_select()
1579 if (cmd->tag != TAG_NONE) { in NCR5380_select()
1581 tmp[2] = cmd->tag; in NCR5380_select()
1587 cmd->tag = 0; in NCR5380_select()
1596 hostdata->connected = cmd; in NCR5380_select()
1598 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); in NCR5380_select()
1604 initialize_SCp(cmd); in NCR5380_select()
1956 struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected; in NCR5380_information_transfer() local
1977 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { in NCR5380_information_transfer()
1978 count = cmd->SCp.buffer->length; in NCR5380_information_transfer()
1979 d = sg_virt(cmd->SCp.buffer); in NCR5380_information_transfer()
1981 count = cmd->SCp.this_residual; in NCR5380_information_transfer()
1982 d = cmd->SCp.ptr; in NCR5380_information_transfer()
1985 if ((count >= DMA_MIN_SIZE) && (sun3_dma_setup_done != cmd)) { in NCR5380_information_transfer()
1986 if (cmd->request->cmd_type == REQ_TYPE_FS) { in NCR5380_information_transfer()
1988 rq_data_dir(cmd->request)); in NCR5380_information_transfer()
1989 sun3_dma_setup_done = cmd; in NCR5380_information_transfer()
2019 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2020 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2029 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { in NCR5380_information_transfer()
2030 ++cmd->SCp.buffer; in NCR5380_information_transfer()
2031 --cmd->SCp.buffers_residual; in NCR5380_information_transfer()
2032 cmd->SCp.this_residual = cmd->SCp.buffer->length; in NCR5380_information_transfer()
2033 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); in NCR5380_information_transfer()
2037 merge_contiguous_buffers(cmd); in NCR5380_information_transfer()
2039 HOSTNO, cmd->SCp.this_residual, in NCR5380_information_transfer()
2040 cmd->SCp.buffers_residual); in NCR5380_information_transfer()
2061 !cmd->device->borken && in NCR5380_information_transfer()
2063 (transfersize = NCR5380_dma_xfer_len(instance, cmd, phase)) >= DMA_MIN_SIZE) { in NCR5380_information_transfer()
2065 cmd->SCp.phase = phase; in NCR5380_information_transfer()
2067 &len, (unsigned char **)&cmd->SCp.ptr)) { in NCR5380_information_transfer()
2072 scmd_printk(KERN_INFO, cmd, in NCR5380_information_transfer()
2074 cmd->device->borken = 1; in NCR5380_information_transfer()
2079 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2080 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2091 cmd->SCp.this_residual -= transfersize - len; in NCR5380_information_transfer()
2097 (int *)&cmd->SCp.this_residual, in NCR5380_information_transfer()
2098 (unsigned char **)&cmd->SCp.ptr); in NCR5380_information_transfer()
2101 if (sun3_dma_setup_done == cmd) in NCR5380_information_transfer()
2110 cmd->SCp.Message = tmp; in NCR5380_information_transfer()
2130 "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2140 if (!cmd->next_link) { in NCR5380_information_transfer()
2143 HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2149 initialize_SCp(cmd->next_link); in NCR5380_information_transfer()
2152 cmd->next_link->tag = cmd->tag; in NCR5380_information_transfer()
2153 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); in NCR5380_information_transfer()
2156 HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2157 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2158 cmd = hostdata->connected; in NCR5380_information_transfer()
2166 "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2172 cmd_free_tag(cmd); in NCR5380_information_transfer()
2173 if (status_byte(cmd->SCp.Status) == QUEUE_FULL) { in NCR5380_information_transfer()
2182 struct tag_alloc *ta = &hostdata->TagAlloc[scmd_id(cmd)][cmd->device->lun]; in NCR5380_information_transfer()
2185 HOSTNO, cmd->device->id, cmd->device->lun, in NCR5380_information_transfer()
2191 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
2212 if (cmd->cmnd[0] != REQUEST_SENSE) in NCR5380_information_transfer()
2213 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8); in NCR5380_information_transfer()
2214 else if (status_byte(cmd->SCp.Status) != GOOD) in NCR5380_information_transfer()
2215 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); in NCR5380_information_transfer()
2217 if ((cmd->cmnd[0] == REQUEST_SENSE) && in NCR5380_information_transfer()
2219 scsi_eh_restore_cmnd(cmd, &hostdata->ses); in NCR5380_information_transfer()
2223 if ((cmd->cmnd[0] != REQUEST_SENSE) && in NCR5380_information_transfer()
2224 (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) { in NCR5380_information_transfer()
2225 scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0); in NCR5380_information_transfer()
2229 LIST(cmd,hostdata->issue_queue); in NCR5380_information_transfer()
2230 SET_NEXT(cmd, hostdata->issue_queue); in NCR5380_information_transfer()
2231 hostdata->issue_queue = (struct scsi_cmnd *) cmd; in NCR5380_information_transfer()
2233 "issue queue\n", H_NO(cmd)); in NCR5380_information_transfer()
2235 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2274 cmd->device->tagged_supported = 0; in NCR5380_information_transfer()
2275 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); in NCR5380_information_transfer()
2276 cmd->tag = TAG_NONE; in NCR5380_information_transfer()
2280 HOSTNO, cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2288 cmd->device->disconnect = 1; in NCR5380_information_transfer()
2289 LIST(cmd,hostdata->disconnected_queue); in NCR5380_information_transfer()
2290 SET_NEXT(cmd, hostdata->disconnected_queue); in NCR5380_information_transfer()
2292 hostdata->disconnected_queue = cmd; in NCR5380_information_transfer()
2297 cmd->device->id, cmd->device->lun); in NCR5380_information_transfer()
2398 scmd_printk(KERN_INFO, cmd, in NCR5380_information_transfer()
2402 scmd_printk(KERN_INFO, cmd, in NCR5380_information_transfer()
2419 cmd_free_tag(cmd); in NCR5380_information_transfer()
2421 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_information_transfer()
2424 cmd->result = DID_ERROR << 16; in NCR5380_information_transfer()
2428 cmd->scsi_done(cmd); in NCR5380_information_transfer()
2434 len = cmd->cmd_len; in NCR5380_information_transfer()
2435 data = cmd->cmnd; in NCR5380_information_transfer()
2447 cmd->SCp.Status = tmp; in NCR5380_information_transfer()
2671 int NCR5380_abort(struct scsi_cmnd *cmd) in NCR5380_abort() argument
2673 struct Scsi_Host *instance = cmd->device->host; in NCR5380_abort()
2678 scmd_printk(KERN_NOTICE, cmd, "aborting command\n"); in NCR5380_abort()
2695 if (hostdata->connected == cmd) { in NCR5380_abort()
2718 cmd->result = DID_ABORT << 16; in NCR5380_abort()
2720 cmd_free_tag(cmd); in NCR5380_abort()
2722 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2726 cmd->scsi_done(cmd); in NCR5380_abort()
2743 if (cmd == tmp) { in NCR5380_abort()
2803 if (cmd == tmp) { in NCR5380_abort()
2807 if (NCR5380_select(instance, cmd)) in NCR5380_abort()
2818 if (cmd == tmp) { in NCR5380_abort()
2830 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); in NCR5380_abort()
2873 static int NCR5380_bus_reset(struct scsi_cmnd *cmd) in NCR5380_bus_reset() argument
2875 struct Scsi_Host *instance = cmd->device->host; in NCR5380_bus_reset()
2904 dprintk(NDEBUG_ABORT, "scsi%d: reset aborted issued command(s)\n", H_NO(cmd)); in NCR5380_bus_reset()
2906 dprintk(NDEBUG_ABORT, "scsi%d: reset aborted a connected command\n", H_NO(cmd)); in NCR5380_bus_reset()
2908 dprintk(NDEBUG_ABORT, "scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd)); in NCR5380_bus_reset()