1 #ifndef _SCSI_SCSI_CMND_H
2 #define _SCSI_SCSI_CMND_H
4 #include <linux/dma-mapping.h>
5 #include <linux/list.h>
6 #include <linux/types.h>
14 /* embedded in scsi_cmnd */
16 char *ptr; /* data pointer */
17 int this_residual; /* left in this buffer */
18 struct scatterlist *buffer; /* which buffer */
19 int buffers_residual; /* how many buffers left */
21 dma_addr_t dma_handle;
25 volatile int have_data_in;
26 volatile int sent_command;
33 struct scsi_device *device;
34 struct scsi_request *sc_request;
36 struct list_head list; /* scsi_cmnd participates in queue lists */
38 struct list_head eh_entry; /* entry for the host eh_cmd_q */
39 int eh_eflags; /* Used by error handlr */
40 void (*done) (struct scsi_cmnd *); /* Mid-level done function */
43 * A SCSI Command is assigned a nonzero serial_number before passed
44 * to the driver's queue command function. The serial_number is
45 * cleared when scsi_done is entered indicating that the command
46 * has been completed. It currently doesn't have much use other
47 * than printk's. Some lldd's use this number for other purposes.
48 * It's almost certain that such usages are either incorrect or
49 * meaningless. Please kill all usages other than printk's. Also,
50 * as this number is always identical to ->pid, please convert
51 * printk's to use ->pid, so that we can kill this field.
53 unsigned long serial_number;
55 * This is set to jiffies as it was when the command was first
56 * allocated. It is used to time how long the command has
59 unsigned long jiffies_at_alloc;
63 int timeout_per_command;
65 unsigned char cmd_len;
66 unsigned char old_cmd_len;
67 enum dma_data_direction sc_data_direction;
68 enum dma_data_direction sc_old_data_direction;
70 /* These elements define the operation we are about to perform */
71 #define MAX_COMMAND_SIZE 16
72 unsigned char cmnd[MAX_COMMAND_SIZE];
73 unsigned request_bufflen; /* Actual request size */
75 struct timer_list eh_timeout; /* Used to time out the command. */
76 void *request_buffer; /* Actual requested buffer */
78 /* These elements define the operation we ultimately want to perform */
79 unsigned char data_cmnd[MAX_COMMAND_SIZE];
80 unsigned short old_use_sg; /* We save use_sg here when requesting
82 unsigned short use_sg; /* Number of pieces of scatter-gather */
83 unsigned short sglist_len; /* size of malloc'd scatter-gather list */
84 unsigned bufflen; /* Size of data buffer */
85 void *buffer; /* Data buffer */
87 unsigned underflow; /* Return error if less than
88 this amount is transferred */
89 unsigned old_underflow; /* save underflow here when reusing the
90 * command for error handling */
92 unsigned transfersize; /* How much we are guaranteed to
93 transfer with each SCSI transfer
94 (ie, between disconnect /
95 reconnects. Probably == sector
98 int resid; /* Number of bytes requested to be
99 transferred less actual number
100 transferred (0 if not supported) */
102 struct request *request; /* The command we are
105 #define SCSI_SENSE_BUFFERSIZE 96
106 unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE]; /* obtained by REQUEST SENSE
107 * when CHECK CONDITION is
108 * received on original command
111 /* Low-level done function - can be used by low-level driver to point
112 * to completion function. Not used by mid/upper level code. */
113 void (*scsi_done) (struct scsi_cmnd *);
116 * The following fields can be written to by the host specific code.
117 * Everything else should be left alone.
119 struct scsi_pointer SCp; /* Scratchpad used by some host adapters */
121 unsigned char *host_scribble; /* The host adapter is allowed to
122 * call scsi_malloc and get some memory
123 * and hang it here. The host adapter
124 * is also expected to call scsi_free
125 * to release this memory. (The memory
126 * obtained by scsi_malloc is guaranteed
127 * to be at an address < 16Mb). */
129 int result; /* Status code from lower level driver */
131 unsigned char tag; /* SCSI-II queued command tag */
132 unsigned long pid; /* Process ID, starts at 0. Unique per host. */
136 * These are the values that scsi_cmd->state can take.
138 #define SCSI_STATE_TIMEOUT 0x1000
139 #define SCSI_STATE_FINISHED 0x1001
140 #define SCSI_STATE_FAILED 0x1002
141 #define SCSI_STATE_QUEUED 0x1003
142 #define SCSI_STATE_UNUSED 0x1006
143 #define SCSI_STATE_DISCONNECTING 0x1008
144 #define SCSI_STATE_INITIALIZING 0x1009
145 #define SCSI_STATE_BHQUEUE 0x100a
146 #define SCSI_STATE_MLQUEUE 0x100b
149 extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, int);
150 extern void scsi_put_command(struct scsi_cmnd *);
151 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int);
152 extern void scsi_finish_command(struct scsi_cmnd *cmd);
154 #endif /* _SCSI_SCSI_CMND_H */