]> err.no Git - linux-2.6/blob - include/scsi/scsi_cmnd.h
[SCSI] remove scsi_cmnd->abort_reason
[linux-2.6] / include / scsi / scsi_cmnd.h
1 #ifndef _SCSI_SCSI_CMND_H
2 #define _SCSI_SCSI_CMND_H
3
4 #include <linux/dma-mapping.h>
5 #include <linux/list.h>
6 #include <linux/types.h>
7
8 struct request;
9 struct scatterlist;
10 struct scsi_device;
11 struct scsi_request;
12
13
14 /* embedded in scsi_cmnd */
15 struct scsi_pointer {
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 */
20
21         dma_addr_t dma_handle;
22
23         volatile int Status;
24         volatile int Message;
25         volatile int have_data_in;
26         volatile int sent_command;
27         volatile int phase;
28 };
29
30 struct scsi_cmnd {
31         int     sc_magic;
32
33         struct scsi_device *device;
34         unsigned short state;
35         unsigned short owner;
36         struct scsi_request *sc_request;
37
38         struct list_head list;  /* scsi_cmnd participates in queue lists */
39
40         struct list_head eh_entry; /* entry for the host eh_cmd_q */
41         int eh_eflags;          /* Used by error handlr */
42         void (*done) (struct scsi_cmnd *);      /* Mid-level done function */
43
44         /*
45          * A SCSI Command is assigned a nonzero serial_number before passed
46          * to the driver's queue command function.  The serial_number is
47          * cleared when scsi_done is entered indicating that the command
48          * has been completed.  It currently doesn't have much use other
49          * than printk's.  Some lldd's use this number for other purposes.
50          * It's almost certain that such usages are either incorrect or
51          * meaningless.  Please kill all usages other than printk's.  Also,
52          * as this number is always identical to ->pid, please convert
53          * printk's to use ->pid, so that we can kill this field.
54          */
55         unsigned long serial_number;
56
57         int retries;
58         int allowed;
59         int timeout_per_command;
60         int timeout_total;
61         int timeout;
62
63         unsigned char cmd_len;
64         unsigned char old_cmd_len;
65         enum dma_data_direction sc_data_direction;
66         enum dma_data_direction sc_old_data_direction;
67
68         /* These elements define the operation we are about to perform */
69 #define MAX_COMMAND_SIZE        16
70         unsigned char cmnd[MAX_COMMAND_SIZE];
71         unsigned request_bufflen;       /* Actual request size */
72
73         struct timer_list eh_timeout;   /* Used to time out the command. */
74         void *request_buffer;           /* Actual requested buffer */
75
76         /* These elements define the operation we ultimately want to perform */
77         unsigned char data_cmnd[MAX_COMMAND_SIZE];
78         unsigned short old_use_sg;      /* We save  use_sg here when requesting
79                                          * sense info */
80         unsigned short use_sg;  /* Number of pieces of scatter-gather */
81         unsigned short sglist_len;      /* size of malloc'd scatter-gather list */
82         unsigned bufflen;       /* Size of data buffer */
83         void *buffer;           /* Data buffer */
84
85         unsigned underflow;     /* Return error if less than
86                                    this amount is transferred */
87         unsigned old_underflow; /* save underflow here when reusing the
88                                  * command for error handling */
89
90         unsigned transfersize;  /* How much we are guaranteed to
91                                    transfer with each SCSI transfer
92                                    (ie, between disconnect / 
93                                    reconnects.   Probably == sector
94                                    size */
95
96         int resid;              /* Number of bytes requested to be
97                                    transferred less actual number
98                                    transferred (0 if not supported) */
99
100         struct request *request;        /* The command we are
101                                            working on */
102
103 #define SCSI_SENSE_BUFFERSIZE   96
104         unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE];              /* obtained by REQUEST SENSE
105                                                  * when CHECK CONDITION is
106                                                  * received on original command 
107                                                  * (auto-sense) */
108
109         /* Low-level done function - can be used by low-level driver to point
110          *        to completion function.  Not used by mid/upper level code. */
111         void (*scsi_done) (struct scsi_cmnd *);
112
113         /*
114          * The following fields can be written to by the host specific code. 
115          * Everything else should be left alone. 
116          */
117         struct scsi_pointer SCp;        /* Scratchpad used by some host adapters */
118
119         unsigned char *host_scribble;   /* The host adapter is allowed to
120                                            * call scsi_malloc and get some memory
121                                            * and hang it here.     The host adapter
122                                            * is also expected to call scsi_free
123                                            * to release this memory.  (The memory
124                                            * obtained by scsi_malloc is guaranteed
125                                            * to be at an address < 16Mb). */
126
127         int result;             /* Status code from lower level driver */
128
129         unsigned char tag;      /* SCSI-II queued command tag */
130         unsigned long pid;      /* Process ID, starts at 0. Unique per host. */
131 };
132
133 /*
134  * These are the values that scsi_cmd->state can take.
135  */
136 #define SCSI_STATE_TIMEOUT         0x1000
137 #define SCSI_STATE_FINISHED        0x1001
138 #define SCSI_STATE_FAILED          0x1002
139 #define SCSI_STATE_QUEUED          0x1003
140 #define SCSI_STATE_UNUSED          0x1006
141 #define SCSI_STATE_DISCONNECTING   0x1008
142 #define SCSI_STATE_INITIALIZING    0x1009
143 #define SCSI_STATE_BHQUEUE         0x100a
144 #define SCSI_STATE_MLQUEUE         0x100b
145
146
147 extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, int);
148 extern void scsi_put_command(struct scsi_cmnd *);
149 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int);
150 extern void scsi_finish_command(struct scsi_cmnd *cmd);
151
152 #endif /* _SCSI_SCSI_CMND_H */