diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2010-04-30 12:09:34 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-05-02 15:42:30 -0400 |
commit | 1674b4054744c2cfd6573e43eca45d86ff581d0e (patch) | |
tree | 6a59f4f00b15b30313c330e9636b36c88c93a1c9 /drivers/s390/scsi/zfcp_qdio.h | |
parent | 683229845f1780b10041ee7a1043fc8f10061455 (diff) |
[SCSI] zfcp: Move sbale handling to zfcp_qdio files
Move the code accessing the qdio sbales and zfcp_qdio_req struct to
the zfcp_qdio files and provide helper functions for accessing the
qdio related parts.
Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_qdio.h')
-rw-r--r-- | drivers/s390/scsi/zfcp_qdio.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/drivers/s390/scsi/zfcp_qdio.h b/drivers/s390/scsi/zfcp_qdio.h index f2b5a363bb84..138fba577b48 100644 --- a/drivers/s390/scsi/zfcp_qdio.h +++ b/drivers/s390/scsi/zfcp_qdio.h | |||
@@ -13,6 +13,12 @@ | |||
13 | 13 | ||
14 | #define ZFCP_QDIO_SBALE_LEN PAGE_SIZE | 14 | #define ZFCP_QDIO_SBALE_LEN PAGE_SIZE |
15 | 15 | ||
16 | /* DMQ bug workaround: don't use last SBALE */ | ||
17 | #define ZFCP_QDIO_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1) | ||
18 | |||
19 | /* index of last SBALE (with respect to DMQ bug workaround) */ | ||
20 | #define ZFCP_QDIO_LAST_SBALE_PER_SBAL (ZFCP_QDIO_MAX_SBALES_PER_SBAL - 1) | ||
21 | |||
16 | /** | 22 | /** |
17 | * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count | 23 | * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count |
18 | * @sbal: qdio buffers | 24 | * @sbal: qdio buffers |
@@ -51,6 +57,7 @@ struct zfcp_qdio { | |||
51 | 57 | ||
52 | /** | 58 | /** |
53 | * struct zfcp_qdio_req - qdio queue related values for a request | 59 | * struct zfcp_qdio_req - qdio queue related values for a request |
60 | * @sbtype: sbal type flags for sbale 0 | ||
54 | * @sbal_number: number of free sbals | 61 | * @sbal_number: number of free sbals |
55 | * @sbal_first: first sbal for this request | 62 | * @sbal_first: first sbal for this request |
56 | * @sbal_last: last sbal for this request | 63 | * @sbal_last: last sbal for this request |
@@ -61,6 +68,7 @@ struct zfcp_qdio { | |||
61 | * @qdio_inb_usage: usage of inbound queue | 68 | * @qdio_inb_usage: usage of inbound queue |
62 | */ | 69 | */ |
63 | struct zfcp_qdio_req { | 70 | struct zfcp_qdio_req { |
71 | u32 sbtype; | ||
64 | u8 sbal_number; | 72 | u8 sbal_number; |
65 | u8 sbal_first; | 73 | u8 sbal_first; |
66 | u8 sbal_last; | 74 | u8 sbal_last; |
@@ -108,4 +116,98 @@ zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) | |||
108 | q_req->sbale_curr); | 116 | q_req->sbale_curr); |
109 | } | 117 | } |
110 | 118 | ||
119 | /** | ||
120 | * zfcp_qdio_req_init - initialize qdio request | ||
121 | * @qdio: request queue where to start putting the request | ||
122 | * @q_req: the qdio request to start | ||
123 | * @req_id: The request id | ||
124 | * @sbtype: type flags to set for all sbals | ||
125 | * @data: First data block | ||
126 | * @len: Length of first data block | ||
127 | * | ||
128 | * This is the start of putting the request into the queue, the last | ||
129 | * step is passing the request to zfcp_qdio_send. The request queue | ||
130 | * lock must be held during the whole process from init to send. | ||
131 | */ | ||
132 | static inline | ||
133 | void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, | ||
134 | unsigned long req_id, u32 sbtype, void *data, u32 len) | ||
135 | { | ||
136 | struct qdio_buffer_element *sbale; | ||
137 | |||
138 | q_req->sbal_first = q_req->sbal_last = qdio->req_q.first; | ||
139 | q_req->sbal_number = 1; | ||
140 | q_req->sbtype = sbtype; | ||
141 | |||
142 | sbale = zfcp_qdio_sbale_req(qdio, q_req); | ||
143 | sbale->addr = (void *) req_id; | ||
144 | sbale->flags |= SBAL_FLAGS0_COMMAND; | ||
145 | sbale->flags |= sbtype; | ||
146 | |||
147 | q_req->sbale_curr = 1; | ||
148 | sbale++; | ||
149 | sbale->addr = data; | ||
150 | if (likely(data)) | ||
151 | sbale->length = len; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * zfcp_qdio_fill_next - Fill next sbale, only for single sbal requests | ||
156 | * @qdio: pointer to struct zfcp_qdio | ||
157 | * @q_req: pointer to struct zfcp_queue_req | ||
158 | * | ||
159 | * This is only required for single sbal requests, calling it when | ||
160 | * wrapping around to the next sbal is a bug. | ||
161 | */ | ||
162 | static inline | ||
163 | void zfcp_qdio_fill_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, | ||
164 | void *data, u32 len) | ||
165 | { | ||
166 | struct qdio_buffer_element *sbale; | ||
167 | |||
168 | BUG_ON(q_req->sbale_curr == ZFCP_QDIO_LAST_SBALE_PER_SBAL); | ||
169 | q_req->sbale_curr++; | ||
170 | sbale = zfcp_qdio_sbale_curr(qdio, q_req); | ||
171 | sbale->addr = data; | ||
172 | sbale->length = len; | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * zfcp_qdio_set_sbale_last - set last entry flag in current sbale | ||
177 | * @qdio: pointer to struct zfcp_qdio | ||
178 | * @q_req: pointer to struct zfcp_queue_req | ||
179 | */ | ||
180 | static inline | ||
181 | void zfcp_qdio_set_sbale_last(struct zfcp_qdio *qdio, | ||
182 | struct zfcp_qdio_req *q_req) | ||
183 | { | ||
184 | struct qdio_buffer_element *sbale; | ||
185 | |||
186 | sbale = zfcp_qdio_sbale_curr(qdio, q_req); | ||
187 | sbale->flags |= SBAL_FLAGS_LAST_ENTRY; | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * zfcp_qdio_sg_one_sbal - check if one sbale is enough for sg data | ||
192 | * @sg: The scatterlist where to check the data size | ||
193 | * | ||
194 | * Returns: 1 when one sbale is enough for the data in the scatterlist, | ||
195 | * 0 if not. | ||
196 | */ | ||
197 | static inline | ||
198 | int zfcp_qdio_sg_one_sbale(struct scatterlist *sg) | ||
199 | { | ||
200 | return sg_is_last(sg) && sg->length <= ZFCP_QDIO_SBALE_LEN; | ||
201 | } | ||
202 | |||
203 | /** | ||
204 | * zfcp_qdio_skip_to_last_sbale - skip to last sbale in sbal | ||
205 | * @q_req: The current zfcp_qdio_req | ||
206 | */ | ||
207 | static inline | ||
208 | void zfcp_qdio_skip_to_last_sbale(struct zfcp_qdio_req *q_req) | ||
209 | { | ||
210 | q_req->sbale_curr = ZFCP_QDIO_LAST_SBALE_PER_SBAL; | ||
211 | } | ||
212 | |||
111 | #endif /* ZFCP_QDIO_H */ | 213 | #endif /* ZFCP_QDIO_H */ |