aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2010-02-17 05:18:59 -0500
committerJames Bottomley <James.Bottomley@suse.de>2010-02-17 18:46:35 -0500
commit34c2b712992540ca436e97432ffc57c84c8f8c18 (patch)
tree94ee5b92c29c1c79a87c861b8f69de5060bc1f72 /drivers/s390/scsi
parent2d8e62bbf7e83facd5701c100f62fbf0df4ee486 (diff)
[SCSI] zfcp: Introduce header file for qdio structs and inline functions
Move the qdio related structs and some helper functions to a new zfcp_qdio.h header file. While doing this, rename the struct zfcp_queue_req to zfcp_qdio_req to adhere to the naming scheme used in zfcp. This allows a better seperation of the qdio code and inlining the helper functions will save some function calls. 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')
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c6
-rw-r--r--drivers/s390/scsi/zfcp_def.h57
-rw-r--r--drivers/s390/scsi/zfcp_ext.h8
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c71
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c48
-rw-r--r--drivers/s390/scsi/zfcp_qdio.h109
6 files changed, 162 insertions, 137 deletions
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index c8d68fec6334..7a149fd85f6d 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -140,9 +140,9 @@ void _zfcp_dbf_hba_fsf_response(const char *tag2, int level,
140 memcpy(response->fsf_status_qual, 140 memcpy(response->fsf_status_qual,
141 fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); 141 fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE);
142 response->fsf_req_status = fsf_req->status; 142 response->fsf_req_status = fsf_req->status;
143 response->sbal_first = fsf_req->queue_req.sbal_first; 143 response->sbal_first = fsf_req->qdio_req.sbal_first;
144 response->sbal_last = fsf_req->queue_req.sbal_last; 144 response->sbal_last = fsf_req->qdio_req.sbal_last;
145 response->sbal_response = fsf_req->queue_req.sbal_response; 145 response->sbal_response = fsf_req->qdio_req.sbal_response;
146 response->pool = fsf_req->pool != NULL; 146 response->pool = fsf_req->pool != NULL;
147 response->erp_action = (unsigned long)fsf_req->erp_action; 147 response->erp_action = (unsigned long)fsf_req->erp_action;
148 148
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index f43e6d8c9cea..7131c7db1f04 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -33,11 +33,11 @@
33#include <scsi/scsi_transport_fc.h> 33#include <scsi/scsi_transport_fc.h>
34#include <scsi/scsi_bsg_fc.h> 34#include <scsi/scsi_bsg_fc.h>
35#include <asm/ccwdev.h> 35#include <asm/ccwdev.h>
36#include <asm/qdio.h>
37#include <asm/debug.h> 36#include <asm/debug.h>
38#include <asm/ebcdic.h> 37#include <asm/ebcdic.h>
39#include <asm/sysinfo.h> 38#include <asm/sysinfo.h>
40#include "zfcp_fsf.h" 39#include "zfcp_fsf.h"
40#include "zfcp_qdio.h"
41 41
42struct zfcp_reqlist; 42struct zfcp_reqlist;
43 43
@@ -127,12 +127,6 @@ struct zfcp_adapter_mempool {
127 mempool_t *qtcb_pool; 127 mempool_t *qtcb_pool;
128}; 128};
129 129
130struct zfcp_qdio_queue {
131 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
132 u8 first; /* index of next free bfr in queue */
133 atomic_t count; /* number of free buffers in queue */
134};
135
136struct zfcp_erp_action { 130struct zfcp_erp_action {
137 struct list_head list; 131 struct list_head list;
138 int action; /* requested action code */ 132 int action; /* requested action code */
@@ -164,29 +158,6 @@ struct zfcp_latencies {
164 spinlock_t lock; 158 spinlock_t lock;
165}; 159};
166 160
167/** struct zfcp_qdio - basic QDIO data structure
168 * @resp_q: response queue
169 * @req_q: request queue
170 * @stat_lock: lock to protect req_q_util and req_q_time
171 * @req_q_lock; lock to serialize access to request queue
172 * @req_q_time: time of last fill level change
173 * @req_q_util: used for accounting
174 * @req_q_full: queue full incidents
175 * @req_q_wq: used to wait for SBAL availability
176 * @adapter: adapter used in conjunction with this QDIO structure
177 */
178struct zfcp_qdio {
179 struct zfcp_qdio_queue resp_q;
180 struct zfcp_qdio_queue req_q;
181 spinlock_t stat_lock;
182 spinlock_t req_q_lock;
183 unsigned long long req_q_time;
184 u64 req_q_util;
185 atomic_t req_q_full;
186 wait_queue_head_t req_q_wq;
187 struct zfcp_adapter *adapter;
188};
189
190struct zfcp_adapter { 161struct zfcp_adapter {
191 struct kref ref; 162 struct kref ref;
192 u64 peer_wwnn; /* P2P peer WWNN */ 163 u64 peer_wwnn; /* P2P peer WWNN */
@@ -273,33 +244,11 @@ struct zfcp_unit {
273}; 244};
274 245
275/** 246/**
276 * struct zfcp_queue_req - queue related values for a request
277 * @sbal_number: number of free SBALs
278 * @sbal_first: first SBAL for this request
279 * @sbal_last: last SBAL for this request
280 * @sbal_limit: last possible SBAL for this request
281 * @sbale_curr: current SBALE at creation of this request
282 * @sbal_response: SBAL used in interrupt
283 * @qdio_outb_usage: usage of outbound queue
284 * @qdio_inb_usage: usage of inbound queue
285 */
286struct zfcp_queue_req {
287 u8 sbal_number;
288 u8 sbal_first;
289 u8 sbal_last;
290 u8 sbal_limit;
291 u8 sbale_curr;
292 u8 sbal_response;
293 u16 qdio_outb_usage;
294 u16 qdio_inb_usage;
295};
296
297/**
298 * struct zfcp_fsf_req - basic FSF request structure 247 * struct zfcp_fsf_req - basic FSF request structure
299 * @list: list of FSF requests 248 * @list: list of FSF requests
300 * @req_id: unique request ID 249 * @req_id: unique request ID
301 * @adapter: adapter this request belongs to 250 * @adapter: adapter this request belongs to
302 * @queue_req: queue related values 251 * @qdio_req: qdio queue related values
303 * @completion: used to signal the completion of the request 252 * @completion: used to signal the completion of the request
304 * @status: status of the request 253 * @status: status of the request
305 * @fsf_command: FSF command issued 254 * @fsf_command: FSF command issued
@@ -317,7 +266,7 @@ struct zfcp_fsf_req {
317 struct list_head list; 266 struct list_head list;
318 unsigned long req_id; 267 unsigned long req_id;
319 struct zfcp_adapter *adapter; 268 struct zfcp_adapter *adapter;
320 struct zfcp_queue_req queue_req; 269 struct zfcp_qdio_req qdio_req;
321 struct completion completion; 270 struct completion completion;
322 u32 status; 271 u32 status;
323 u32 fsf_command; 272 u32 fsf_command;
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index 85cb135d5e7f..8786a79c7f8f 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -143,13 +143,9 @@ extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int);
143/* zfcp_qdio.c */ 143/* zfcp_qdio.c */
144extern int zfcp_qdio_setup(struct zfcp_adapter *); 144extern int zfcp_qdio_setup(struct zfcp_adapter *);
145extern void zfcp_qdio_destroy(struct zfcp_qdio *); 145extern void zfcp_qdio_destroy(struct zfcp_qdio *);
146extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_queue_req *); 146extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *);
147extern struct qdio_buffer_element
148 *zfcp_qdio_sbale_req(struct zfcp_qdio *, struct zfcp_queue_req *);
149extern struct qdio_buffer_element
150 *zfcp_qdio_sbale_curr(struct zfcp_qdio *, struct zfcp_queue_req *);
151extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, 147extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *,
152 struct zfcp_queue_req *, unsigned long, 148 struct zfcp_qdio_req *, unsigned long,
153 struct scatterlist *, int); 149 struct scatterlist *, int);
154extern int zfcp_qdio_open(struct zfcp_qdio *); 150extern int zfcp_qdio_open(struct zfcp_qdio *);
155extern void zfcp_qdio_close(struct zfcp_qdio *); 151extern void zfcp_qdio_close(struct zfcp_qdio *);
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 8a0705ac52a1..6538742b421a 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -14,6 +14,7 @@
14#include "zfcp_ext.h" 14#include "zfcp_ext.h"
15#include "zfcp_fc.h" 15#include "zfcp_fc.h"
16#include "zfcp_dbf.h" 16#include "zfcp_dbf.h"
17#include "zfcp_qdio.h"
17#include "zfcp_reqlist.h" 18#include "zfcp_reqlist.h"
18 19
19static void zfcp_fsf_request_timeout_handler(unsigned long data) 20static void zfcp_fsf_request_timeout_handler(unsigned long data)
@@ -723,12 +724,12 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
723 req->adapter = adapter; 724 req->adapter = adapter;
724 req->fsf_command = fsf_cmd; 725 req->fsf_command = fsf_cmd;
725 req->req_id = adapter->req_no; 726 req->req_id = adapter->req_no;
726 req->queue_req.sbal_number = 1; 727 req->qdio_req.sbal_number = 1;
727 req->queue_req.sbal_first = req_q->first; 728 req->qdio_req.sbal_first = req_q->first;
728 req->queue_req.sbal_last = req_q->first; 729 req->qdio_req.sbal_last = req_q->first;
729 req->queue_req.sbale_curr = 1; 730 req->qdio_req.sbale_curr = 1;
730 731
731 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 732 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
732 sbale[0].addr = (void *) req->req_id; 733 sbale[0].addr = (void *) req->req_id;
733 sbale[0].flags |= SBAL_FLAGS0_COMMAND; 734 sbale[0].flags |= SBAL_FLAGS0_COMMAND;
734 735
@@ -772,9 +773,9 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
772 773
773 zfcp_reqlist_add(adapter->req_list, req); 774 zfcp_reqlist_add(adapter->req_list, req);
774 775
775 req->queue_req.qdio_outb_usage = atomic_read(&qdio->req_q.count); 776 req->qdio_req.qdio_outb_usage = atomic_read(&qdio->req_q.count);
776 req->issued = get_clock(); 777 req->issued = get_clock();
777 if (zfcp_qdio_send(qdio, &req->queue_req)) { 778 if (zfcp_qdio_send(qdio, &req->qdio_req)) {
778 del_timer(&req->timer); 779 del_timer(&req->timer);
779 /* lookup request again, list might have changed */ 780 /* lookup request again, list might have changed */
780 zfcp_reqlist_find_rm(adapter->req_list, req_id); 781 zfcp_reqlist_find_rm(adapter->req_list, req_id);
@@ -815,9 +816,9 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
815 goto out; 816 goto out;
816 } 817 }
817 818
818 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 819 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
819 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY; 820 sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
820 req->queue_req.sbale_curr = 2; 821 req->qdio_req.sbale_curr = 2;
821 822
822 sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC); 823 sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC);
823 if (!sr_buf) { 824 if (!sr_buf) {
@@ -826,7 +827,7 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
826 } 827 }
827 memset(sr_buf, 0, sizeof(*sr_buf)); 828 memset(sr_buf, 0, sizeof(*sr_buf));
828 req->data = sr_buf; 829 req->data = sr_buf;
829 sbale = zfcp_qdio_sbale_curr(qdio, &req->queue_req); 830 sbale = zfcp_qdio_sbale_curr(qdio, &req->qdio_req);
830 sbale->addr = (void *) sr_buf; 831 sbale->addr = (void *) sr_buf;
831 sbale->length = sizeof(*sr_buf); 832 sbale->length = sizeof(*sr_buf);
832 833
@@ -923,7 +924,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
923 ZFCP_STATUS_COMMON_UNBLOCKED))) 924 ZFCP_STATUS_COMMON_UNBLOCKED)))
924 goto out_error_free; 925 goto out_error_free;
925 926
926 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 927 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
927 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 928 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
928 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 929 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
929 930
@@ -1018,7 +1019,7 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1018{ 1019{
1019 struct zfcp_adapter *adapter = req->adapter; 1020 struct zfcp_adapter *adapter = req->adapter;
1020 struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter->qdio, 1021 struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter->qdio,
1021 &req->queue_req); 1022 &req->qdio_req);
1022 u32 feat = adapter->adapter_features; 1023 u32 feat = adapter->adapter_features;
1023 int bytes; 1024 int bytes;
1024 1025
@@ -1036,15 +1037,15 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1036 return 0; 1037 return 0;
1037 } 1038 }
1038 1039
1039 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req, 1040 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
1040 SBAL_FLAGS0_TYPE_WRITE_READ, 1041 SBAL_FLAGS0_TYPE_WRITE_READ,
1041 sg_req, max_sbals); 1042 sg_req, max_sbals);
1042 if (bytes <= 0) 1043 if (bytes <= 0)
1043 return -EIO; 1044 return -EIO;
1044 req->qtcb->bottom.support.req_buf_length = bytes; 1045 req->qtcb->bottom.support.req_buf_length = bytes;
1045 req->queue_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; 1046 req->qdio_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
1046 1047
1047 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req, 1048 bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req,
1048 SBAL_FLAGS0_TYPE_WRITE_READ, 1049 SBAL_FLAGS0_TYPE_WRITE_READ,
1049 sg_resp, max_sbals); 1050 sg_resp, max_sbals);
1050 req->qtcb->bottom.support.resp_buf_length = bytes; 1051 req->qtcb->bottom.support.resp_buf_length = bytes;
@@ -1240,7 +1241,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1240 } 1241 }
1241 1242
1242 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1243 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1243 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1244 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1244 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1245 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1245 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1246 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1246 1247
@@ -1282,7 +1283,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
1282 goto out_unlock; 1283 goto out_unlock;
1283 } 1284 }
1284 1285
1285 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1286 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1286 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1287 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1287 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1288 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1288 req->handler = zfcp_fsf_exchange_config_data_handler; 1289 req->handler = zfcp_fsf_exchange_config_data_handler;
@@ -1338,7 +1339,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1338 } 1339 }
1339 1340
1340 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1341 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1341 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1342 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1342 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1343 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1343 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1344 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1344 1345
@@ -1387,7 +1388,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
1387 if (data) 1388 if (data)
1388 req->data = data; 1389 req->data = data;
1389 1390
1390 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1391 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1391 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1392 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1392 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1393 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1393 1394
@@ -1502,7 +1503,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1502 } 1503 }
1503 1504
1504 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1505 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1505 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1506 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1506 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1507 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1507 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1508 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1508 1509
@@ -1572,7 +1573,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1572 } 1573 }
1573 1574
1574 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1575 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1575 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1576 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1576 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1577 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1577 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1578 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1578 1579
@@ -1649,7 +1650,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port)
1649 } 1650 }
1650 1651
1651 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1652 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1652 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1653 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1653 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1654 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1654 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1655 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1655 1656
@@ -1704,7 +1705,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port)
1704 } 1705 }
1705 1706
1706 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1707 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1707 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1708 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1708 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1709 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1709 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1710 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1710 1711
@@ -1798,7 +1799,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1798 } 1799 }
1799 1800
1800 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1801 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1801 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1802 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1802 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1803 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1803 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1804 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1804 1805
@@ -1971,7 +1972,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1971 } 1972 }
1972 1973
1973 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 1974 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
1974 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 1975 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
1975 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 1976 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1976 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 1977 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1977 1978
@@ -2057,7 +2058,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
2057 } 2058 }
2058 2059
2059 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; 2060 req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
2060 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 2061 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
2061 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2062 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2062 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2063 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2063 2064
@@ -2100,8 +2101,8 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
2100 blktrc.magic = ZFCP_BLK_DRV_DATA_MAGIC; 2101 blktrc.magic = ZFCP_BLK_DRV_DATA_MAGIC;
2101 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 2102 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
2102 blktrc.flags |= ZFCP_BLK_REQ_ERROR; 2103 blktrc.flags |= ZFCP_BLK_REQ_ERROR;
2103 blktrc.inb_usage = req->queue_req.qdio_inb_usage; 2104 blktrc.inb_usage = req->qdio_req.qdio_inb_usage;
2104 blktrc.outb_usage = req->queue_req.qdio_outb_usage; 2105 blktrc.outb_usage = req->qdio_req.qdio_outb_usage;
2105 2106
2106 if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA) { 2107 if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA) {
2107 blktrc.flags |= ZFCP_BLK_LAT_VALID; 2108 blktrc.flags |= ZFCP_BLK_LAT_VALID;
@@ -2330,11 +2331,11 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
2330 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; 2331 fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
2331 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); 2332 zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd);
2332 2333
2333 real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req, sbtype, 2334 real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sbtype,
2334 scsi_sglist(scsi_cmnd), 2335 scsi_sglist(scsi_cmnd),
2335 FSF_MAX_SBALS_PER_REQ); 2336 FSF_MAX_SBALS_PER_REQ);
2336 if (unlikely(real_bytes < 0)) { 2337 if (unlikely(real_bytes < 0)) {
2337 if (req->queue_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) { 2338 if (req->qdio_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) {
2338 dev_err(&adapter->ccw_device->dev, 2339 dev_err(&adapter->ccw_device->dev,
2339 "Oversize data package, unit 0x%016Lx " 2340 "Oversize data package, unit 0x%016Lx "
2340 "on port 0x%016Lx closed\n", 2341 "on port 0x%016Lx closed\n",
@@ -2399,7 +2400,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
2399 req->qtcb->bottom.io.service_class = FSF_CLASS_3; 2400 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2400 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; 2401 req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
2401 2402
2402 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 2403 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
2403 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE; 2404 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
2404 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2405 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2405 2406
@@ -2462,14 +2463,14 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2462 2463
2463 req->handler = zfcp_fsf_control_file_handler; 2464 req->handler = zfcp_fsf_control_file_handler;
2464 2465
2465 sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); 2466 sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req);
2466 sbale[0].flags |= direction; 2467 sbale[0].flags |= direction;
2467 2468
2468 bottom = &req->qtcb->bottom.support; 2469 bottom = &req->qtcb->bottom.support;
2469 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; 2470 bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
2470 bottom->option = fsf_cfdc->option; 2471 bottom->option = fsf_cfdc->option;
2471 2472
2472 bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req, 2473 bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req,
2473 direction, fsf_cfdc->sg, 2474 direction, fsf_cfdc->sg,
2474 FSF_MAX_SBALS_PER_REQ); 2475 FSF_MAX_SBALS_PER_REQ);
2475 if (bytes != ZFCP_CFDC_MAX_SIZE) { 2476 if (bytes != ZFCP_CFDC_MAX_SIZE) {
@@ -2517,8 +2518,8 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
2517 panic("error: unknown req_id (%lx) on adapter %s.\n", 2518 panic("error: unknown req_id (%lx) on adapter %s.\n",
2518 req_id, dev_name(&adapter->ccw_device->dev)); 2519 req_id, dev_name(&adapter->ccw_device->dev));
2519 2520
2520 fsf_req->queue_req.sbal_response = sbal_idx; 2521 fsf_req->qdio_req.sbal_response = sbal_idx;
2521 fsf_req->queue_req.qdio_inb_usage = 2522 fsf_req->qdio_req.qdio_inb_usage =
2522 atomic_read(&qdio->resp_q.count); 2523 atomic_read(&qdio->resp_q.count);
2523 zfcp_fsf_req_complete(fsf_req); 2524 zfcp_fsf_req_complete(fsf_req);
2524 2525
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index 3d329fa3d094..71b97ff77cf0 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -10,6 +10,7 @@
10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 11
12#include "zfcp_ext.h" 12#include "zfcp_ext.h"
13#include "zfcp_qdio.h"
13 14
14#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer)) 15#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer))
15 16
@@ -28,12 +29,6 @@ static int zfcp_qdio_buffers_enqueue(struct qdio_buffer **sbal)
28 return 0; 29 return 0;
29} 30}
30 31
31static struct qdio_buffer_element *
32zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx)
33{
34 return &q->sbal[sbal_idx]->element[sbale_idx];
35}
36
37static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id) 32static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id)
38{ 33{
39 struct zfcp_adapter *adapter = qdio->adapter; 34 struct zfcp_adapter *adapter = qdio->adapter;
@@ -145,32 +140,8 @@ static void zfcp_qdio_int_resp(struct ccw_device *cdev, unsigned int qdio_err,
145 zfcp_qdio_resp_put_back(qdio, count); 140 zfcp_qdio_resp_put_back(qdio, count);
146} 141}
147 142
148/**
149 * zfcp_qdio_sbale_req - return ptr to SBALE of req_q for a struct zfcp_fsf_req
150 * @qdio: pointer to struct zfcp_qdio
151 * @q_rec: pointer to struct zfcp_queue_rec
152 * Returns: pointer to qdio_buffer_element (SBALE) structure
153 */
154struct qdio_buffer_element *zfcp_qdio_sbale_req(struct zfcp_qdio *qdio,
155 struct zfcp_queue_req *q_req)
156{
157 return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, 0);
158}
159
160/**
161 * zfcp_qdio_sbale_curr - return curr SBALE on req_q for a struct zfcp_fsf_req
162 * @fsf_req: pointer to struct fsf_req
163 * Returns: pointer to qdio_buffer_element (SBALE) structure
164 */
165struct qdio_buffer_element *zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio,
166 struct zfcp_queue_req *q_req)
167{
168 return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last,
169 q_req->sbale_curr);
170}
171
172static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio, 143static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio,
173 struct zfcp_queue_req *q_req, int max_sbals) 144 struct zfcp_qdio_req *q_req, int max_sbals)
174{ 145{
175 int count = atomic_read(&qdio->req_q.count); 146 int count = atomic_read(&qdio->req_q.count);
176 count = min(count, max_sbals); 147 count = min(count, max_sbals);
@@ -179,7 +150,7 @@ static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio,
179} 150}
180 151
181static struct qdio_buffer_element * 152static struct qdio_buffer_element *
182zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, 153zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
183 unsigned long sbtype) 154 unsigned long sbtype)
184{ 155{
185 struct qdio_buffer_element *sbale; 156 struct qdio_buffer_element *sbale;
@@ -214,7 +185,7 @@ zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req,
214} 185}
215 186
216static struct qdio_buffer_element * 187static struct qdio_buffer_element *
217zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, 188zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
218 unsigned int sbtype) 189 unsigned int sbtype)
219{ 190{
220 if (q_req->sbale_curr == ZFCP_LAST_SBALE_PER_SBAL) 191 if (q_req->sbale_curr == ZFCP_LAST_SBALE_PER_SBAL)
@@ -224,7 +195,7 @@ zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req,
224} 195}
225 196
226static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio, 197static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio,
227 struct zfcp_queue_req *q_req) 198 struct zfcp_qdio_req *q_req)
228{ 199{
229 struct qdio_buffer **sbal = qdio->req_q.sbal; 200 struct qdio_buffer **sbal = qdio->req_q.sbal;
230 int first = q_req->sbal_first; 201 int first = q_req->sbal_first;
@@ -235,7 +206,7 @@ static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio,
235} 206}
236 207
237static int zfcp_qdio_fill_sbals(struct zfcp_qdio *qdio, 208static int zfcp_qdio_fill_sbals(struct zfcp_qdio *qdio,
238 struct zfcp_queue_req *q_req, 209 struct zfcp_qdio_req *q_req,
239 unsigned int sbtype, void *start_addr, 210 unsigned int sbtype, void *start_addr,
240 unsigned int total_length) 211 unsigned int total_length)
241{ 212{
@@ -271,8 +242,7 @@ static int zfcp_qdio_fill_sbals(struct zfcp_qdio *qdio,
271 * @max_sbals: upper bound for number of SBALs to be used 242 * @max_sbals: upper bound for number of SBALs to be used
272 * Returns: number of bytes, or error (negativ) 243 * Returns: number of bytes, or error (negativ)
273 */ 244 */
274int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, 245int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
275 struct zfcp_queue_req *q_req,
276 unsigned long sbtype, struct scatterlist *sg, 246 unsigned long sbtype, struct scatterlist *sg,
277 int max_sbals) 247 int max_sbals)
278{ 248{
@@ -304,10 +274,10 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio,
304/** 274/**
305 * zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO 275 * zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO
306 * @qdio: pointer to struct zfcp_qdio 276 * @qdio: pointer to struct zfcp_qdio
307 * @q_req: pointer to struct zfcp_queue_req 277 * @q_req: pointer to struct zfcp_qdio_req
308 * Returns: 0 on success, error otherwise 278 * Returns: 0 on success, error otherwise
309 */ 279 */
310int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req) 280int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
311{ 281{
312 struct zfcp_qdio_queue *req_q = &qdio->req_q; 282 struct zfcp_qdio_queue *req_q = &qdio->req_q;
313 int first = q_req->sbal_first; 283 int first = q_req->sbal_first;
diff --git a/drivers/s390/scsi/zfcp_qdio.h b/drivers/s390/scsi/zfcp_qdio.h
new file mode 100644
index 000000000000..8cca54631e1e
--- /dev/null
+++ b/drivers/s390/scsi/zfcp_qdio.h
@@ -0,0 +1,109 @@
1/*
2 * zfcp device driver
3 *
4 * Header file for zfcp qdio interface
5 *
6 * Copyright IBM Corporation 2010
7 */
8
9#ifndef ZFCP_QDIO_H
10#define ZFCP_QDIO_H
11
12#include <asm/qdio.h>
13
14/**
15 * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count
16 * @sbal: qdio buffers
17 * @first: index of next free buffer in queue
18 * @count: number of free buffers in queue
19 */
20struct zfcp_qdio_queue {
21 struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q];
22 u8 first;
23 atomic_t count;
24};
25
26/**
27 * struct zfcp_qdio - basic qdio data structure
28 * @resp_q: response queue
29 * @req_q: request queue
30 * @stat_lock: lock to protect req_q_util and req_q_time
31 * @req_q_lock: lock to serialize access to request queue
32 * @req_q_time: time of last fill level change
33 * @req_q_util: used for accounting
34 * @req_q_full: queue full incidents
35 * @req_q_wq: used to wait for SBAL availability
36 * @adapter: adapter used in conjunction with this qdio structure
37 */
38struct zfcp_qdio {
39 struct zfcp_qdio_queue resp_q;
40 struct zfcp_qdio_queue req_q;
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};
49
50/**
51 * struct zfcp_qdio_req - qdio queue related values for a request
52 * @sbal_number: number of free sbals
53 * @sbal_first: first sbal for this request
54 * @sbal_last: last sbal for this request
55 * @sbal_limit: last possible sbal for this request
56 * @sbale_curr: current sbale at creation of this request
57 * @sbal_response: sbal used in interrupt
58 * @qdio_outb_usage: usage of outbound queue
59 * @qdio_inb_usage: usage of inbound queue
60 */
61struct zfcp_qdio_req {
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 u16 qdio_inb_usage;
70};
71
72/**
73 * zfcp_qdio_sbale - return pointer to sbale in qdio queue
74 * @q: queue where to find sbal
75 * @sbal_idx: sbal index in queue
76 * @sbale_idx: sbale index in sbal
77 */
78static inline struct qdio_buffer_element *
79zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx)
80{
81 return &q->sbal[sbal_idx]->element[sbale_idx];
82}
83
84/**
85 * zfcp_qdio_sbale_req - return pointer to sbale on req_q for a request
86 * @qdio: pointer to struct zfcp_qdio
87 * @q_rec: pointer to struct zfcp_qdio_req
88 * Returns: pointer to qdio_buffer_element (sbale) structure
89 */
90static inline struct qdio_buffer_element *
91zfcp_qdio_sbale_req(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
92{
93 return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, 0);
94}
95
96/**
97 * zfcp_qdio_sbale_curr - return current sbale on req_q for a request
98 * @qdio: pointer to struct zfcp_qdio
99 * @fsf_req: pointer to struct zfcp_fsf_req
100 * Returns: pointer to qdio_buffer_element (sbale) structure
101 */
102static inline struct qdio_buffer_element *
103zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
104{
105 return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last,
106 q_req->sbale_curr);
107}
108
109#endif /* ZFCP_QDIO_H */