Lines Matching refs:cmd

262 #define	NEXT(cmd)		((struct scsi_cmnd *)(cmd)->host_scribble)
263 #define SET_NEXT(cmd, next) ((cmd)->host_scribble = (void *)(next))
264 #define NEXTADDR(cmd) ((struct scsi_cmnd **)&((cmd)->host_scribble))
267 #define H_NO(cmd) (cmd)->device->host->host_no
308 /* -1 for TAG_NONE is not possible with unsigned char cmd->tag */
356 static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)
358 u8 lun = cmd->device->lun;
359 SETUP_HOSTDATA(cmd->device->host);
361 if (hostdata->busy[cmd->device->id] & (1 << lun))
364 !setup_use_tagged_queuing || !cmd->device->tagged_supported)
366 if (TagAlloc[cmd->device->id][lun].nr_allocated >=
367 TagAlloc[cmd->device->id][lun].queue_size ) {
369 H_NO(cmd), cmd->device->id, lun );
381 static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)
383 u8 lun = cmd->device->lun;
384 SETUP_HOSTDATA(cmd->device->host);
390 !setup_use_tagged_queuing || !cmd->device->tagged_supported) {
391 cmd->tag = TAG_NONE;
392 hostdata->busy[cmd->device->id] |= (1 << lun);
394 "command\n", H_NO(cmd), cmd->device->id, lun );
397 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun];
399 cmd->tag = find_first_zero_bit( &ta->allocated, MAX_TAGS );
400 set_bit( cmd->tag, &ta->allocated );
404 H_NO(cmd), cmd->tag, cmd->device->id, lun,
410 /* Mark the tag of command 'cmd' as free, or in case of an untagged command,
414 static void cmd_free_tag(struct scsi_cmnd *cmd)
416 u8 lun = cmd->device->lun;
417 SETUP_HOSTDATA(cmd->device->host);
419 if (cmd->tag == TAG_NONE) {
420 hostdata->busy[cmd->device->id] &= ~(1 << lun);
421 dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d untagged cmd finished\n",
422 H_NO(cmd), cmd->device->id, lun );
424 else if (cmd->tag >= MAX_TAGS) {
426 H_NO(cmd), cmd->tag );
429 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][lun];
430 clear_bit( cmd->tag, &ta->allocated );
433 H_NO(cmd), cmd->tag, cmd->device->id, lun );
459 * Function : void initialize_SCp(struct scsi_cmnd *cmd)
461 * Purpose : initialize the saved data pointers for cmd to point to the
464 * Inputs : cmd - struct scsi_cmnd structure to have pointers reset.
467 static __inline__ void initialize_SCp(struct scsi_cmnd *cmd)
474 if (scsi_bufflen(cmd)) {
475 cmd->SCp.buffer = scsi_sglist(cmd);
476 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
477 cmd->SCp.ptr = (char *) SGADDR(cmd->SCp.buffer);
478 cmd->SCp.this_residual = cmd->SCp.buffer->length;
480 cmd->SCp.buffer = NULL;
481 cmd->SCp.buffers_residual = 0;
482 cmd->SCp.ptr = NULL;
483 cmd->SCp.this_residual = 0;
661 static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd)
666 H_NO(cmd), cmd->device->id, cmd->device->lun);
668 command = cmd->cmnd;
707 static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m)
712 H_NO(cmd), cmd->device->id, cmd->device->lun);
714 command = cmd->cmnd;
816 * Function : int NCR5380_queue_command (struct scsi_cmnd *cmd,
821 * Inputs : cmd - SCSI command, done - function called on completion, with
827 * cmd is added to the per instance issue_queue, with minor
828 * twiddling done to the host specific fields of cmd. If the
834 static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd,
837 SETUP_HOSTDATA(cmd->device->host);
842 switch (cmd->cmnd[0]) {
846 H_NO(cmd));
847 cmd->result = (DID_ERROR << 16);
848 done(cmd);
862 if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
864 switch (cmd->cmnd[0])
869 hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
870 hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
876 hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
877 hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
888 SET_NEXT(cmd, NULL);
889 cmd->scsi_done = done;
891 cmd->result = 0;
895 * Insert the cmd into the issue queue. Note that REQUEST SENSE
914 if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
915 LIST(cmd, hostdata->issue_queue);
916 SET_NEXT(cmd, hostdata->issue_queue);
917 hostdata->issue_queue = cmd;
922 LIST(cmd, tmp);
923 SET_NEXT(tmp, cmd);
928 dprintk(NDEBUG_QUEUES, "scsi%d: command added to %s of queue\n", H_NO(cmd),
929 (cmd->cmnd[0] == REQUEST_SENSE) ? "head" : "tail");
1122 "no connected cmd\n", HOSTNO);
1267 struct scsi_cmnd *cmd)
1270 if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
1272 switch (cmd->cmnd[0])
1277 hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);
1278 /*hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);*/
1284 hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);
1285 /*hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);*/
1294 * struct scsi_cmnd *cmd, int tag);
1301 * target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for
1316 * instance->connected will be set to cmd.
1319 * If failed (no target) : cmd->scsi_done() will be called, and the
1320 * cmd->result host byte set to DID_BAD_TARGET.
1323 static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,
1447 NCR5380_write(OUTPUT_DATA_REG, (hostdata->id_mask | (1 << cmd->device->id)));
1500 dprintk(NDEBUG_SELECTION, "scsi%d: selecting target %d\n", HOSTNO, cmd->device->id);
1551 if (hostdata->targets_present & (1 << cmd->device->id)) {
1559 cmd->result = DID_BAD_TARGET << 16;
1561 collect_stats(hostdata, cmd);
1564 cmd_free_tag( cmd );
1566 cmd->scsi_done(cmd);
1573 hostdata->targets_present |= (1 << cmd->device->id);
1594 HOSTNO, cmd->device->id);
1595 tmp[0] = IDENTIFY(1, cmd->device->lun);
1598 if (cmd->tag != TAG_NONE) {
1600 tmp[2] = cmd->tag;
1606 cmd->tag=0;
1615 hostdata->connected = cmd;
1617 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
1622 initialize_SCp(cmd);
1914 struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
1934 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
1935 count = cmd->SCp.buffer->length;
1936 d = SGADDR(cmd->SCp.buffer);
1938 count = cmd->SCp.this_residual;
1939 d = cmd->SCp.ptr;
1944 != cmd))
1946 if (cmd->request->cmd_type == REQ_TYPE_FS) {
1948 rq_data_dir(cmd->request));
1949 sun3_dma_setup_done = cmd;
1978 cmd->result = DID_ERROR << 16;
1979 cmd->scsi_done(cmd);
1987 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
1988 ++cmd->SCp.buffer;
1989 --cmd->SCp.buffers_residual;
1990 cmd->SCp.this_residual = cmd->SCp.buffer->length;
1991 cmd->SCp.ptr = SGADDR(cmd->SCp.buffer);
1993 HOSTNO, cmd->SCp.this_residual,
1994 cmd->SCp.buffers_residual);
2013 // if (!cmd->device->borken &&
2015 NCR5380_dma_xfer_len(instance,cmd,phase)) > SUN3_DMA_MINSIZE) {
2017 cmd->SCp.phase = phase;
2020 &len, (unsigned char **) &cmd->SCp.ptr)) {
2027 cmd->device->id, cmd->device->lun);
2028 cmd->device->borken = 1;
2033 cmd->result = DID_ERROR << 16;
2034 cmd->scsi_done(cmd);
2045 cmd->SCp.this_residual -= transfersize - len;
2051 (int *) &cmd->SCp.this_residual, (unsigned char **)
2052 &cmd->SCp.ptr);
2055 if(sun3_dma_setup_done == cmd)
2065 cmd->SCp.Message = tmp;
2085 "complete.\n", HOSTNO, cmd->device->id, cmd->device->lun);
2095 if (!cmd->next_link) {
2098 HOSTNO, cmd->device->id, cmd->device->lun);
2104 initialize_SCp(cmd->next_link);
2107 cmd->next_link->tag = cmd->tag;
2108 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
2111 HOSTNO, cmd->device->id, cmd->device->lun);
2113 collect_stats(hostdata, cmd);
2115 cmd->scsi_done(cmd);
2116 cmd = hostdata->connected;
2125 "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);
2127 cmd_free_tag( cmd );
2128 if (status_byte(cmd->SCp.Status) == QUEUE_FULL) {
2137 TAG_ALLOC *ta = &TagAlloc[cmd->device->id][cmd->device->lun];
2140 HOSTNO, cmd->device->id, cmd->device->lun,
2146 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2167 if (cmd->cmnd[0] != REQUEST_SENSE)
2168 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
2169 else if (status_byte(cmd->SCp.Status) != GOOD)
2170 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
2173 if ((cmd->cmnd[0] == REQUEST_SENSE) &&
2175 scsi_eh_restore_cmnd(cmd, &hostdata->ses);
2179 if ((cmd->cmnd[0] != REQUEST_SENSE) &&
2180 (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
2181 scsi_eh_prep_cmnd(cmd, &hostdata->ses, NULL, 0, ~0);
2185 cmd->SCp.buffer = NULL;
2186 cmd->SCp.buffers_residual = 0;
2190 LIST(cmd,hostdata->issue_queue);
2191 SET_NEXT(cmd, hostdata->issue_queue);
2192 hostdata->issue_queue = (struct scsi_cmnd *) cmd;
2195 "issue queue\n", H_NO(cmd));
2200 collect_stats(hostdata, cmd);
2202 cmd->scsi_done(cmd);
2231 cmd->device->tagged_supported = 0;
2232 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
2233 cmd->tag = TAG_NONE;
2237 HOSTNO, cmd->device->id, cmd->device->lun);
2245 cmd->device->disconnect = 1;
2246 LIST(cmd,hostdata->disconnected_queue);
2247 SET_NEXT(cmd, hostdata->disconnected_queue);
2249 hostdata->disconnected_queue = cmd;
2254 cmd->device->id, cmd->device->lun);
2356 HOSTNO, tmp, cmd->device->id, cmd->device->lun);
2362 cmd->device->id, cmd->device->lun);
2378 cmd_free_tag( cmd );
2380 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2383 cmd->result = DID_ERROR << 16;
2385 collect_stats(hostdata, cmd);
2387 cmd->scsi_done(cmd);
2394 len = cmd->cmd_len;
2395 data = cmd->cmnd;
2408 cmd->SCp.Status = tmp;
2588 * Function : int NCR5380_abort(struct scsi_cmnd *cmd)
2592 * Inputs : cmd - the struct scsi_cmnd to abort, code - code to set the
2604 static int NCR5380_abort(struct scsi_cmnd *cmd)
2606 struct Scsi_Host *instance = cmd->device->host;
2612 scsi_print_command(cmd);
2629 if (hostdata->connected == cmd) {
2652 cmd->result = DID_ABORT << 16;
2654 cmd_free_tag( cmd );
2656 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2659 cmd->scsi_done(cmd);
2676 if (cmd == tmp) {
2734 if (cmd == tmp) {
2738 if (NCR5380_select (instance, cmd, (int) cmd->tag))
2749 if (cmd == tmp) {
2761 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
2787 * Function : int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2795 static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
2797 SETUP_HOSTDATA(cmd->device->host);
2805 NCR5380_print_status (cmd->device->host);
2859 if ((cmd = connected)) {
2860 dprintk(NDEBUG_ABORT, "scsi%d: reset aborted a connected command\n", H_NO(cmd));
2861 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16);
2862 cmd->scsi_done( cmd );
2865 for (i = 0; (cmd = disconnected_queue); ++i) {
2866 disconnected_queue = NEXT(cmd);
2867 SET_NEXT(cmd, NULL);
2868 cmd->result = (cmd->result & 0xffff) | (DID_RESET << 16);
2869 cmd->scsi_done( cmd );
2906 dprintk(NDEBUG_ABORT, "scsi%d: reset aborted issued command(s)\n", H_NO(cmd));
2908 dprintk(NDEBUG_ABORT, "scsi%d: reset aborted a connected command\n", H_NO(cmd));
2910 dprintk(NDEBUG_ABORT, "scsi%d: reset aborted disconnected command(s)\n", H_NO(cmd));