]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
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; | |
1da177e4 LT |
34 | struct scsi_request *sc_request; |
35 | ||
36 | struct list_head list; /* scsi_cmnd participates in queue lists */ | |
37 | ||
38 | struct list_head eh_entry; /* entry for the host eh_cmd_q */ | |
1da177e4 LT |
39 | int eh_eflags; /* Used by error handlr */ |
40 | void (*done) (struct scsi_cmnd *); /* Mid-level done function */ | |
41 | ||
42 | /* | |
c6295cdf TH |
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. | |
1da177e4 LT |
52 | */ |
53 | unsigned long serial_number; | |
b21a4138 JB |
54 | /* |
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 | |
57 | * been outstanding | |
58 | */ | |
59 | unsigned long jiffies_at_alloc; | |
1da177e4 LT |
60 | |
61 | int retries; | |
62 | int allowed; | |
63 | int timeout_per_command; | |
1da177e4 | 64 | |
1da177e4 LT |
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; | |
69 | ||
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 */ | |
74 | ||
75 | struct timer_list eh_timeout; /* Used to time out the command. */ | |
76 | void *request_buffer; /* Actual requested buffer */ | |
77 | ||
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 | |
81 | * sense info */ | |
82 | unsigned short use_sg; /* Number of pieces of scatter-gather */ | |
83 | unsigned short sglist_len; /* size of malloc'd scatter-gather list */ | |
1da177e4 LT |
84 | unsigned bufflen; /* Size of data buffer */ |
85 | void *buffer; /* Data buffer */ | |
86 | ||
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 */ | |
91 | ||
92 | unsigned transfersize; /* How much we are guaranteed to | |
93 | transfer with each SCSI transfer | |
94 | (ie, between disconnect / | |
95 | reconnects. Probably == sector | |
96 | size */ | |
97 | ||
98 | int resid; /* Number of bytes requested to be | |
99 | transferred less actual number | |
100 | transferred (0 if not supported) */ | |
101 | ||
102 | struct request *request; /* The command we are | |
103 | working on */ | |
104 | ||
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 | |
109 | * (auto-sense) */ | |
110 | ||
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 *); | |
114 | ||
115 | /* | |
116 | * The following fields can be written to by the host specific code. | |
117 | * Everything else should be left alone. | |
118 | */ | |
119 | struct scsi_pointer SCp; /* Scratchpad used by some host adapters */ | |
120 | ||
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). */ | |
128 | ||
129 | int result; /* Status code from lower level driver */ | |
130 | ||
131 | unsigned char tag; /* SCSI-II queued command tag */ | |
132 | unsigned long pid; /* Process ID, starts at 0. Unique per host. */ | |
133 | }; | |
134 | ||
135 | /* | |
136 | * These are the values that scsi_cmd->state can take. | |
137 | */ | |
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 | |
147 | ||
148 | ||
c53033f6 | 149 | extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); |
1da177e4 LT |
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); | |
153 | ||
154 | #endif /* _SCSI_SCSI_CMND_H */ |