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