This source file includes following definitions.
- zfcp_qdio_sbale_req
- zfcp_qdio_sbale_curr
- zfcp_qdio_req_init
- zfcp_qdio_fill_next
- zfcp_qdio_set_sbale_last
- zfcp_qdio_sg_one_sbale
- zfcp_qdio_skip_to_last_sbale
- zfcp_qdio_sbal_limit
- zfcp_qdio_set_data_div
- zfcp_qdio_real_bytes
- zfcp_qdio_set_scount
1
2
3
4
5
6
7
8
9
10 #ifndef ZFCP_QDIO_H
11 #define ZFCP_QDIO_H
12
13 #include <asm/qdio.h>
14
15 #define ZFCP_QDIO_SBALE_LEN PAGE_SIZE
16
17
18 #define ZFCP_QDIO_MAX_SBALS_PER_REQ 36
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 struct zfcp_qdio {
37 struct qdio_buffer *res_q[QDIO_MAX_BUFFERS_PER_Q];
38 struct qdio_buffer *req_q[QDIO_MAX_BUFFERS_PER_Q];
39 u8 req_q_idx;
40 atomic_t req_q_free;
41 spinlock_t stat_lock;
42 spinlock_t req_q_lock;
43 unsigned long long req_q_time;
44 u64 req_q_util;
45 atomic_t req_q_full;
46 wait_queue_head_t req_q_wq;
47 struct zfcp_adapter *adapter;
48 u16 max_sbale_per_sbal;
49 u16 max_sbale_per_req;
50 };
51
52
53
54
55
56
57
58
59
60
61
62 struct zfcp_qdio_req {
63 u8 sbtype;
64 u8 sbal_number;
65 u8 sbal_first;
66 u8 sbal_last;
67 u8 sbal_limit;
68 u8 sbale_curr;
69 u16 qdio_outb_usage;
70 };
71
72
73
74
75
76
77
78 static inline struct qdio_buffer_element *
79 zfcp_qdio_sbale_req(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
80 {
81 return &qdio->req_q[q_req->sbal_last]->element[0];
82 }
83
84
85
86
87
88
89
90 static inline struct qdio_buffer_element *
91 zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
92 {
93 return &qdio->req_q[q_req->sbal_last]->element[q_req->sbale_curr];
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109 static inline
110 void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
111 unsigned long req_id, u8 sbtype, void *data, u32 len)
112 {
113 struct qdio_buffer_element *sbale;
114 int count = min(atomic_read(&qdio->req_q_free),
115 ZFCP_QDIO_MAX_SBALS_PER_REQ);
116
117 q_req->sbal_first = q_req->sbal_last = qdio->req_q_idx;
118 q_req->sbal_number = 1;
119 q_req->sbtype = sbtype;
120 q_req->sbale_curr = 1;
121 q_req->sbal_limit = (q_req->sbal_first + count - 1)
122 % QDIO_MAX_BUFFERS_PER_Q;
123
124 sbale = zfcp_qdio_sbale_req(qdio, q_req);
125 sbale->addr = (void *) req_id;
126 sbale->eflags = 0;
127 sbale->sflags = SBAL_SFLAGS0_COMMAND | sbtype;
128
129 if (unlikely(!data))
130 return;
131 sbale++;
132 sbale->addr = data;
133 sbale->length = len;
134 }
135
136
137
138
139
140
141
142
143
144
145
146 static inline
147 void zfcp_qdio_fill_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
148 void *data, u32 len)
149 {
150 struct qdio_buffer_element *sbale;
151
152 BUG_ON(q_req->sbale_curr == qdio->max_sbale_per_sbal - 1);
153 q_req->sbale_curr++;
154 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
155 sbale->addr = data;
156 sbale->length = len;
157 }
158
159
160
161
162
163
164 static inline
165 void zfcp_qdio_set_sbale_last(struct zfcp_qdio *qdio,
166 struct zfcp_qdio_req *q_req)
167 {
168 struct qdio_buffer_element *sbale;
169
170 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
171 sbale->eflags |= SBAL_EFLAGS_LAST_ENTRY;
172 }
173
174
175
176
177
178
179
180
181 static inline
182 int zfcp_qdio_sg_one_sbale(struct scatterlist *sg)
183 {
184 return sg_is_last(sg) && sg->length <= ZFCP_QDIO_SBALE_LEN;
185 }
186
187
188
189
190
191
192 static inline
193 void zfcp_qdio_skip_to_last_sbale(struct zfcp_qdio *qdio,
194 struct zfcp_qdio_req *q_req)
195 {
196 q_req->sbale_curr = qdio->max_sbale_per_sbal - 1;
197 }
198
199
200
201
202
203
204
205 static inline
206 void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio,
207 struct zfcp_qdio_req *q_req, int max_sbals)
208 {
209 int count = min(atomic_read(&qdio->req_q_free), max_sbals);
210
211 q_req->sbal_limit = (q_req->sbal_first + count - 1) %
212 QDIO_MAX_BUFFERS_PER_Q;
213 }
214
215
216
217
218
219
220
221 static inline
222 void zfcp_qdio_set_data_div(struct zfcp_qdio *qdio,
223 struct zfcp_qdio_req *q_req, u32 count)
224 {
225 struct qdio_buffer_element *sbale;
226
227 sbale = qdio->req_q[q_req->sbal_first]->element;
228 sbale->length = count;
229 }
230
231
232
233
234
235 static inline
236 unsigned int zfcp_qdio_real_bytes(struct scatterlist *sg)
237 {
238 unsigned int real_bytes = 0;
239
240 for (; sg; sg = sg_next(sg))
241 real_bytes += sg->length;
242
243 return real_bytes;
244 }
245
246
247
248
249
250
251 static inline
252 void zfcp_qdio_set_scount(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
253 {
254 struct qdio_buffer_element *sbale;
255
256 sbale = qdio->req_q[q_req->sbal_first]->element;
257 sbale->scount = q_req->sbal_number - 1;
258 }
259
260 #endif