Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
drivers
s390
scsi
zfcp_qdio.h
Go to the documentation of this file.
1
/*
2
* zfcp device driver
3
*
4
* Header file for zfcp qdio interface
5
*
6
* Copyright IBM Corp. 2010
7
*/
8
9
#ifndef ZFCP_QDIO_H
10
#define ZFCP_QDIO_H
11
12
#include <
asm/qdio.h
>
13
14
#define ZFCP_QDIO_SBALE_LEN PAGE_SIZE
15
16
/* Max SBALS for chaining */
17
#define ZFCP_QDIO_MAX_SBALS_PER_REQ 36
18
33
struct
zfcp_qdio
{
34
struct
qdio_buffer
*
res_q
[
QDIO_MAX_BUFFERS_PER_Q
];
35
struct
qdio_buffer
*
req_q
[
QDIO_MAX_BUFFERS_PER_Q
];
36
u8
req_q_idx
;
37
atomic_t
req_q_free
;
38
spinlock_t
stat_lock
;
39
spinlock_t
req_q_lock
;
40
unsigned
long
long
req_q_time
;
41
u64
req_q_util
;
42
atomic_t
req_q_full
;
43
wait_queue_head_t
req_q_wq
;
44
struct
zfcp_adapter
*
adapter
;
45
u16
max_sbale_per_sbal
;
46
u16
max_sbale_per_req
;
47
};
48
60
struct
zfcp_qdio_req
{
61
u8
sbtype
;
62
u8
sbal_number
;
63
u8
sbal_first
;
64
u8
sbal_last
;
65
u8
sbal_limit
;
66
u8
sbale_curr
;
67
u8
sbal_response
;
68
u16
qdio_outb_usage
;
69
};
70
77
static
inline
struct
qdio_buffer_element
*
78
zfcp_qdio_sbale_req(
struct
zfcp_qdio
*qdio,
struct
zfcp_qdio_req
*q_req)
79
{
80
return
&qdio->
req_q
[q_req->
sbal_last
]->element[0];
81
}
82
89
static
inline
struct
qdio_buffer_element
*
90
zfcp_qdio_sbale_curr(
struct
zfcp_qdio
*qdio,
struct
zfcp_qdio_req
*q_req)
91
{
92
return
&qdio->
req_q
[q_req->
sbal_last
]->element[q_req->
sbale_curr
];
93
}
94
108
static
inline
109
void
zfcp_qdio_req_init(
struct
zfcp_qdio
*qdio,
struct
zfcp_qdio_req
*q_req,
110
unsigned
long
req_id
,
u8
sbtype,
void
*
data
,
u32
len)
111
{
112
struct
qdio_buffer_element
*sbale;
113
int
count
=
min
(
atomic_read
(&qdio->
req_q_free
),
114
ZFCP_QDIO_MAX_SBALS_PER_REQ
);
115
116
q_req->
sbal_first
= q_req->
sbal_last
= qdio->
req_q_idx
;
117
q_req->
sbal_number
= 1;
118
q_req->
sbtype
= sbtype;
119
q_req->
sbale_curr
= 1;
120
q_req->
sbal_limit
= (q_req->
sbal_first
+ count - 1)
121
%
QDIO_MAX_BUFFERS_PER_Q
;
122
123
sbale = zfcp_qdio_sbale_req(qdio, q_req);
124
sbale->
addr
= (
void
*) req_id;
125
sbale->
eflags
= 0;
126
sbale->
sflags
=
SBAL_SFLAGS0_COMMAND
| sbtype;
127
128
if
(
unlikely
(!data))
129
return
;
130
sbale++;
131
sbale->
addr
=
data
;
132
sbale->
length
= len;
133
}
134
143
static
inline
144
void
zfcp_qdio_fill_next(
struct
zfcp_qdio
*qdio,
struct
zfcp_qdio_req
*q_req,
145
void
*data,
u32
len)
146
{
147
struct
qdio_buffer_element
*sbale;
148
149
BUG_ON
(q_req->
sbale_curr
== qdio->
max_sbale_per_sbal
- 1);
150
q_req->
sbale_curr
++;
151
sbale = zfcp_qdio_sbale_curr(qdio, q_req);
152
sbale->
addr
=
data
;
153
sbale->
length
= len;
154
}
155
161
static
inline
162
void
zfcp_qdio_set_sbale_last(
struct
zfcp_qdio
*qdio,
163
struct
zfcp_qdio_req
*q_req)
164
{
165
struct
qdio_buffer_element
*sbale;
166
167
sbale = zfcp_qdio_sbale_curr(qdio, q_req);
168
sbale->
eflags
|=
SBAL_EFLAGS_LAST_ENTRY
;
169
}
170
178
static
inline
179
int
zfcp_qdio_sg_one_sbale(
struct
scatterlist
*
sg
)
180
{
181
return
sg_is_last
(sg) && sg->
length
<=
ZFCP_QDIO_SBALE_LEN
;
182
}
183
188
static
inline
189
void
zfcp_qdio_skip_to_last_sbale(
struct
zfcp_qdio
*qdio,
190
struct
zfcp_qdio_req
*q_req)
191
{
192
q_req->
sbale_curr
= qdio->
max_sbale_per_sbal
- 1;
193
}
194
201
static
inline
202
void
zfcp_qdio_sbal_limit(
struct
zfcp_qdio
*qdio,
203
struct
zfcp_qdio_req
*q_req,
int
max_sbals)
204
{
205
int
count =
min
(
atomic_read
(&qdio->
req_q_free
), max_sbals);
206
207
q_req->
sbal_limit
= (q_req->
sbal_first
+ count - 1) %
208
QDIO_MAX_BUFFERS_PER_Q
;
209
}
210
217
static
inline
218
void
zfcp_qdio_set_data_div(
struct
zfcp_qdio
*qdio,
219
struct
zfcp_qdio_req
*q_req,
u32
count)
220
{
221
struct
qdio_buffer_element
*sbale;
222
223
sbale = qdio->
req_q
[q_req->
sbal_first
]->element;
224
sbale->
length
=
count
;
225
}
226
231
static
inline
232
unsigned
int
zfcp_qdio_sbale_count(
struct
scatterlist
*
sg
)
233
{
234
unsigned
int
count = 0;
235
236
for
(;
sg
; sg =
sg_next
(sg))
237
count++;
238
239
return
count
;
240
}
241
246
static
inline
247
unsigned
int
zfcp_qdio_real_bytes(
struct
scatterlist
*sg)
248
{
249
unsigned
int
real_bytes = 0;
250
251
for
(;
sg
; sg =
sg_next
(sg))
252
real_bytes += sg->
length
;
253
254
return
real_bytes;
255
}
256
262
static
inline
263
void
zfcp_qdio_set_scount(
struct
zfcp_qdio
*qdio,
struct
zfcp_qdio_req
*q_req)
264
{
265
struct
qdio_buffer_element
*sbale;
266
267
sbale = qdio->
req_q
[q_req->
sbal_first
]->element;
268
sbale->
scount
= q_req->
sbal_number
- 1;
269
}
270
271
#endif
/* ZFCP_QDIO_H */
Generated on Thu Jan 10 2013 14:18:26 for Linux Kernel by
1.8.2