9 #define KMSG_COMPONENT "zfcp"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/slab.h>
13 #include <linux/module.h>
17 #define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer))
19 static bool enable_multibuffer;
34 sbal[
pos] = sbal[pos - 1] + 1;
38 static void zfcp_qdio_handler_error(
struct zfcp_qdio *qdio,
char *
id,
39 unsigned int qdio_err)
59 for (i = first; i < first +
cnt; i++) {
66 static inline void zfcp_qdio_account(
struct zfcp_qdio *qdio)
68 unsigned long long now, span;
71 now = get_clock_monotonic();
78 static void zfcp_qdio_int_req(
struct ccw_device *
cdev,
unsigned int qdio_err,
85 zfcp_qdio_handler_error(qdio,
"qdireq1", qdio_err);
90 zfcp_qdio_zero_sbals(qdio->
req_q, idx, count);
93 zfcp_qdio_account(qdio);
99 static void zfcp_qdio_int_resp(
struct ccw_device *cdev,
unsigned int qdio_err,
100 int queue_no,
int idx,
int count,
105 int sbal_no, sbal_idx;
108 if (zfcp_adapter_multi_buffer_active(adapter)) {
122 for (sbal_no = 0; sbal_no <
scount; sbal_no++) {
123 sbal_idx = (idx + sbal_no) %
124 QDIO_MAX_BUFFERS_PER_Q;
125 pl[sbal_no] = qdio->
res_q[sbal_idx];
129 zfcp_qdio_handler_error(qdio,
"qdires1", qdio_err);
137 for (sbal_no = 0; sbal_no <
count; sbal_no++) {
138 sbal_idx = (idx + sbal_no) % QDIO_MAX_BUFFERS_PER_Q;
156 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
164 sbale = zfcp_qdio_sbale_req(qdio, q_req);
179 sbale = zfcp_qdio_sbale_curr(qdio, q_req);
189 return zfcp_qdio_sbal_chain(qdio, q_req);
191 return zfcp_qdio_sbale_curr(qdio, q_req);
208 sbale = zfcp_qdio_sbale_req(qdio, q_req);
212 sbale = zfcp_qdio_sbale_next(qdio, q_req);
219 sbale->
addr = sg_virt(sg);
225 static int zfcp_qdio_sbal_check(
struct zfcp_qdio *qdio)
251 zfcp_qdio_sbal_check(qdio), 5 *
HZ);
281 zfcp_qdio_account(qdio);
305 memset(
id, 0,
sizeof(*
id));
306 id->cdev = qdio->
adapter->ccw_device;
311 if (enable_multibuffer)
314 id->no_output_qs = 1;
315 id->input_handler = zfcp_qdio_int_resp;
316 id->output_handler = zfcp_qdio_int_req;
317 id->int_parm = (
unsigned long) qdio;
318 id->input_sbal_addr_array = (
void **) (qdio->
res_q);
319 id->output_sbal_addr_array = (
void **) (qdio->
req_q);
330 static int zfcp_qdio_allocate(
struct zfcp_qdio *qdio)
334 if (zfcp_qdio_buffers_enqueue(qdio->
req_q) ||
335 zfcp_qdio_buffers_enqueue(qdio->
res_q))
338 zfcp_qdio_setup_init_data(&init_data, qdio);
367 if (count < QDIO_MAX_BUFFERS_PER_Q) {
369 count = QDIO_MAX_BUFFERS_PER_Q -
count;
370 zfcp_qdio_zero_sbals(qdio->
req_q, idx, count);
396 zfcp_qdio_setup_init_data(&init_data, qdio);
399 goto failed_establish;
423 sbale = &(qdio->
res_q[
cc]->element[0]);
449 "Setting up the QDIO connection to the FCP adapter failed\n");
481 if (zfcp_qdio_allocate(qdio)) {
489 adapter->
qdio = qdio;