Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 2 | * zfcp device driver |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 4 | * Setup and helper functions to access QDIO. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 6 | * Copyright IBM Corporation 2002, 2009 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
Christof Schmitt | ecf39d4 | 2008-12-25 13:39:53 +0100 | [diff] [blame] | 9 | #define KMSG_COMPONENT "zfcp" |
| 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include "zfcp_ext.h" |
| 13 | |
Christof Schmitt | 5d4e226 | 2008-07-02 10:56:34 +0200 | [diff] [blame] | 14 | #define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 16 | static int zfcp_qdio_buffers_enqueue(struct qdio_buffer **sbal) |
Swen Schillig | b4e4459 | 2007-07-18 10:55:13 +0200 | [diff] [blame] | 17 | { |
| 18 | int pos; |
| 19 | |
| 20 | for (pos = 0; pos < QDIO_MAX_BUFFERS_PER_Q; pos += QBUFF_PER_PAGE) { |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 21 | sbal[pos] = (struct qdio_buffer *) get_zeroed_page(GFP_KERNEL); |
| 22 | if (!sbal[pos]) |
Swen Schillig | b4e4459 | 2007-07-18 10:55:13 +0200 | [diff] [blame] | 23 | return -ENOMEM; |
Swen Schillig | b4e4459 | 2007-07-18 10:55:13 +0200 | [diff] [blame] | 24 | } |
| 25 | for (pos = 0; pos < QDIO_MAX_BUFFERS_PER_Q; pos++) |
| 26 | if (pos % QBUFF_PER_PAGE) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 27 | sbal[pos] = sbal[pos - 1] + 1; |
Swen Schillig | b4e4459 | 2007-07-18 10:55:13 +0200 | [diff] [blame] | 28 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 31 | static struct qdio_buffer_element * |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 32 | zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | { |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 34 | return &q->sbal[sbal_idx]->element[sbale_idx]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Volker Sameske | fea9d6c | 2006-08-02 11:05:16 +0200 | [diff] [blame] | 37 | /** |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 38 | * zfcp_qdio_free - free memory used by request- and resposne queue |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 39 | * @qdio: pointer to the zfcp_qdio structure |
Volker Sameske | fea9d6c | 2006-08-02 11:05:16 +0200 | [diff] [blame] | 40 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 41 | void zfcp_qdio_free(struct zfcp_qdio *qdio) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 42 | { |
| 43 | struct qdio_buffer **sbal_req, **sbal_resp; |
| 44 | int p; |
| 45 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 46 | if (qdio->adapter->ccw_device) |
| 47 | qdio_free(qdio->adapter->ccw_device); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 48 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 49 | sbal_req = qdio->req_q.sbal; |
| 50 | sbal_resp = qdio->resp_q.sbal; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 51 | |
| 52 | for (p = 0; p < QDIO_MAX_BUFFERS_PER_Q; p += QBUFF_PER_PAGE) { |
| 53 | free_page((unsigned long) sbal_req[p]); |
| 54 | free_page((unsigned long) sbal_resp[p]); |
| 55 | } |
| 56 | } |
| 57 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 58 | static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 59 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 60 | struct zfcp_adapter *adapter = qdio->adapter; |
| 61 | |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 62 | dev_warn(&adapter->ccw_device->dev, "A QDIO problem occurred\n"); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 63 | |
| 64 | zfcp_erp_adapter_reopen(adapter, |
| 65 | ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED | |
| 66 | ZFCP_STATUS_COMMON_ERP_FAILED, id, NULL); |
| 67 | } |
| 68 | |
Christof Schmitt | 5d4e226 | 2008-07-02 10:56:34 +0200 | [diff] [blame] | 69 | static void zfcp_qdio_zero_sbals(struct qdio_buffer *sbal[], int first, int cnt) |
| 70 | { |
| 71 | int i, sbal_idx; |
| 72 | |
| 73 | for (i = first; i < first + cnt; i++) { |
| 74 | sbal_idx = i % QDIO_MAX_BUFFERS_PER_Q; |
| 75 | memset(sbal[sbal_idx], 0, sizeof(struct qdio_buffer)); |
| 76 | } |
| 77 | } |
| 78 | |
Martin Peschke | 94506fd | 2009-03-02 13:08:56 +0100 | [diff] [blame] | 79 | /* this needs to be called prior to updating the queue fill level */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 80 | static void zfcp_qdio_account(struct zfcp_qdio *qdio) |
Martin Peschke | 94506fd | 2009-03-02 13:08:56 +0100 | [diff] [blame] | 81 | { |
| 82 | ktime_t now; |
| 83 | s64 span; |
| 84 | int free, used; |
| 85 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 86 | spin_lock(&qdio->stat_lock); |
Martin Peschke | 94506fd | 2009-03-02 13:08:56 +0100 | [diff] [blame] | 87 | now = ktime_get(); |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 88 | span = ktime_us_delta(now, qdio->req_q_time); |
| 89 | free = max(0, atomic_read(&qdio->req_q.count)); |
Martin Peschke | 94506fd | 2009-03-02 13:08:56 +0100 | [diff] [blame] | 90 | used = QDIO_MAX_BUFFERS_PER_Q - free; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 91 | qdio->req_q_util += used * span; |
| 92 | qdio->req_q_time = now; |
| 93 | spin_unlock(&qdio->stat_lock); |
Martin Peschke | 94506fd | 2009-03-02 13:08:56 +0100 | [diff] [blame] | 94 | } |
| 95 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 96 | static void zfcp_qdio_int_req(struct ccw_device *cdev, unsigned int qdio_err, |
| 97 | int queue_no, int first, int count, |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 98 | unsigned long parm) |
| 99 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 100 | struct zfcp_qdio *qdio = (struct zfcp_qdio *) parm; |
| 101 | struct zfcp_qdio_queue *queue = &qdio->req_q; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 102 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 103 | if (unlikely(qdio_err)) { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame^] | 104 | zfcp_dbf_hba_qdio(qdio->adapter->dbf, qdio_err, first, |
| 105 | count); |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 106 | zfcp_qdio_handler_error(qdio, "qdireq1"); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 107 | return; |
| 108 | } |
| 109 | |
| 110 | /* cleanup all SBALs being program-owned now */ |
| 111 | zfcp_qdio_zero_sbals(queue->sbal, first, count); |
| 112 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 113 | zfcp_qdio_account(qdio); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 114 | atomic_add(count, &queue->count); |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 115 | wake_up(&qdio->req_q_wq); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 116 | } |
| 117 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 118 | static void zfcp_qdio_resp_put_back(struct zfcp_qdio *qdio, int processed) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 120 | struct zfcp_qdio_queue *queue = &qdio->resp_q; |
| 121 | struct ccw_device *cdev = qdio->adapter->ccw_device; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 122 | u8 count, start = queue->first; |
| 123 | unsigned int retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 125 | count = atomic_read(&queue->count) + processed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 127 | retval = do_QDIO(cdev, QDIO_FLAG_SYNC_INPUT, 0, start, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 129 | if (unlikely(retval)) { |
| 130 | atomic_set(&queue->count, count); |
| 131 | /* FIXME: Recover this with an adapter reopen? */ |
| 132 | } else { |
| 133 | queue->first += count; |
| 134 | queue->first %= QDIO_MAX_BUFFERS_PER_Q; |
| 135 | atomic_set(&queue->count, 0); |
| 136 | } |
| 137 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 139 | static void zfcp_qdio_int_resp(struct ccw_device *cdev, unsigned int qdio_err, |
| 140 | int queue_no, int first, int count, |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 141 | unsigned long parm) |
| 142 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 143 | struct zfcp_qdio *qdio = (struct zfcp_qdio *) parm; |
Swen Schillig | bd63eaf | 2009-08-18 15:43:13 +0200 | [diff] [blame] | 144 | int sbal_idx, sbal_no; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 145 | |
Jan Glauber | 779e6e1 | 2008-07-17 17:16:48 +0200 | [diff] [blame] | 146 | if (unlikely(qdio_err)) { |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame^] | 147 | zfcp_dbf_hba_qdio(qdio->adapter->dbf, qdio_err, first, |
| 148 | count); |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 149 | zfcp_qdio_handler_error(qdio, "qdires1"); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 150 | return; |
| 151 | } |
| 152 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | /* |
| 154 | * go through all SBALs from input queue currently |
| 155 | * returned by QDIO layer |
| 156 | */ |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 157 | for (sbal_no = 0; sbal_no < count; sbal_no++) { |
| 158 | sbal_idx = (first + sbal_no) % QDIO_MAX_BUFFERS_PER_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | /* go through all SBALEs of SBAL */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 160 | zfcp_fsf_reqid_check(qdio, sbal_idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | /* |
| 164 | * put range of SBALs back to response queue |
| 165 | * (including SBALs which have already been free before) |
| 166 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 167 | zfcp_qdio_resp_put_back(qdio, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | /** |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 171 | * zfcp_qdio_sbale_req - return ptr to SBALE of req_q for a struct zfcp_fsf_req |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 172 | * @qdio: pointer to struct zfcp_qdio |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 173 | * @q_rec: pointer to struct zfcp_queue_rec |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 174 | * Returns: pointer to qdio_buffer_element (SBALE) structure |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 176 | struct qdio_buffer_element *zfcp_qdio_sbale_req(struct zfcp_qdio *qdio, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 177 | struct zfcp_queue_req *q_req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 179 | return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | /** |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 183 | * zfcp_qdio_sbale_curr - return curr SBALE on req_q for a struct zfcp_fsf_req |
| 184 | * @fsf_req: pointer to struct fsf_req |
| 185 | * Returns: pointer to qdio_buffer_element (SBALE) structure |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 187 | struct qdio_buffer_element *zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 188 | struct zfcp_queue_req *q_req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 190 | return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 191 | q_req->sbale_curr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 194 | static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 195 | struct zfcp_queue_req *q_req, int max_sbals) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 197 | int count = atomic_read(&qdio->req_q.count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | count = min(count, max_sbals); |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 199 | q_req->sbal_limit = (q_req->sbal_first + count - 1) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 200 | % QDIO_MAX_BUFFERS_PER_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 203 | static struct qdio_buffer_element * |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 204 | zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 205 | unsigned long sbtype) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | { |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 207 | struct qdio_buffer_element *sbale; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | |
| 209 | /* set last entry flag in current SBALE of current SBAL */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 210 | sbale = zfcp_qdio_sbale_curr(qdio, q_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | sbale->flags |= SBAL_FLAGS_LAST_ENTRY; |
| 212 | |
| 213 | /* don't exceed last allowed SBAL */ |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 214 | if (q_req->sbal_last == q_req->sbal_limit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | return NULL; |
| 216 | |
| 217 | /* set chaining flag in first SBALE of current SBAL */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 218 | sbale = zfcp_qdio_sbale_req(qdio, q_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | sbale->flags |= SBAL_FLAGS0_MORE_SBALS; |
| 220 | |
| 221 | /* calculate index of next SBAL */ |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 222 | q_req->sbal_last++; |
| 223 | q_req->sbal_last %= QDIO_MAX_BUFFERS_PER_Q; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
| 225 | /* keep this requests number of SBALs up-to-date */ |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 226 | q_req->sbal_number++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
| 228 | /* start at first SBALE of new SBAL */ |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 229 | q_req->sbale_curr = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
| 231 | /* set storage-block type for new SBAL */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 232 | sbale = zfcp_qdio_sbale_curr(qdio, q_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | sbale->flags |= sbtype; |
| 234 | |
| 235 | return sbale; |
| 236 | } |
| 237 | |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 238 | static struct qdio_buffer_element * |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 239 | zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 240 | unsigned int sbtype) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | { |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 242 | if (q_req->sbale_curr == ZFCP_LAST_SBALE_PER_SBAL) |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 243 | return zfcp_qdio_sbal_chain(qdio, q_req, sbtype); |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 244 | q_req->sbale_curr++; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 245 | return zfcp_qdio_sbale_curr(qdio, q_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | } |
| 247 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 248 | static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 249 | struct zfcp_queue_req *q_req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 251 | struct qdio_buffer **sbal = qdio->req_q.sbal; |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 252 | int first = q_req->sbal_first; |
| 253 | int last = q_req->sbal_last; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 254 | int count = (last - first + QDIO_MAX_BUFFERS_PER_Q) % |
| 255 | QDIO_MAX_BUFFERS_PER_Q + 1; |
| 256 | zfcp_qdio_zero_sbals(sbal, first, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 259 | static int zfcp_qdio_fill_sbals(struct zfcp_qdio *qdio, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 260 | struct zfcp_queue_req *q_req, |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 261 | unsigned int sbtype, void *start_addr, |
| 262 | unsigned int total_length) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | { |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 264 | struct qdio_buffer_element *sbale; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | unsigned long remaining, length; |
| 266 | void *addr; |
| 267 | |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 268 | /* split segment up */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | for (addr = start_addr, remaining = total_length; remaining > 0; |
| 270 | addr += length, remaining -= length) { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 271 | sbale = zfcp_qdio_sbale_next(qdio, q_req, sbtype); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 272 | if (!sbale) { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 273 | atomic_inc(&qdio->req_q_full); |
| 274 | zfcp_qdio_undo_sbals(qdio, q_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | return -EINVAL; |
| 276 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 278 | /* new piece must not exceed next page boundary */ |
| 279 | length = min(remaining, |
| 280 | (PAGE_SIZE - ((unsigned long)addr & |
| 281 | (PAGE_SIZE - 1)))); |
| 282 | sbale->addr = addr; |
| 283 | sbale->length = length; |
| 284 | } |
| 285 | return 0; |
| 286 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
| 288 | /** |
| 289 | * zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list |
| 290 | * @fsf_req: request to be processed |
| 291 | * @sbtype: SBALE flags |
| 292 | * @sg: scatter-gather list |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | * @max_sbals: upper bound for number of SBALs to be used |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 294 | * Returns: number of bytes, or error (negativ) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 296 | int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 297 | struct zfcp_queue_req *q_req, |
| 298 | unsigned long sbtype, struct scatterlist *sg, |
| 299 | int max_sbals) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | { |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 301 | struct qdio_buffer_element *sbale; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 302 | int retval, bytes = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | |
| 304 | /* figure out last allowed SBAL */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 305 | zfcp_qdio_sbal_limit(qdio, q_req, max_sbals); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 307 | /* set storage-block type for this request */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 308 | sbale = zfcp_qdio_sbale_req(qdio, q_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | sbale->flags |= sbtype; |
| 310 | |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 311 | for (; sg; sg = sg_next(sg)) { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 312 | retval = zfcp_qdio_fill_sbals(qdio, q_req, sbtype, |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 313 | sg_virt(sg), sg->length); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 314 | if (retval < 0) |
| 315 | return retval; |
| 316 | bytes += sg->length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | } |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | /* assume that no other SBALEs are to follow in the same SBAL */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 320 | sbale = zfcp_qdio_sbale_curr(qdio, q_req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | sbale->flags |= SBAL_FLAGS_LAST_ENTRY; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 322 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | return bytes; |
| 324 | } |
| 325 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | /** |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 327 | * zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 328 | * @qdio: pointer to struct zfcp_qdio |
| 329 | * @q_req: pointer to struct zfcp_queue_req |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 330 | * Returns: 0 on success, error otherwise |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 332 | int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 334 | struct zfcp_qdio_queue *req_q = &qdio->req_q; |
Swen Schillig | 42428f7 | 2009-08-18 15:43:18 +0200 | [diff] [blame] | 335 | int first = q_req->sbal_first; |
| 336 | int count = q_req->sbal_number; |
Christof Schmitt | 21ddaa5 | 2009-03-02 13:09:05 +0100 | [diff] [blame] | 337 | int retval; |
| 338 | unsigned int qdio_flags = QDIO_FLAG_SYNC_OUTPUT; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 339 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 340 | zfcp_qdio_account(qdio); |
Martin Peschke | 94506fd | 2009-03-02 13:08:56 +0100 | [diff] [blame] | 341 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 342 | retval = do_QDIO(qdio->adapter->ccw_device, qdio_flags, 0, first, |
| 343 | count); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 344 | if (unlikely(retval)) { |
| 345 | zfcp_qdio_zero_sbals(req_q->sbal, first, count); |
| 346 | return retval; |
| 347 | } |
| 348 | |
| 349 | /* account for transferred buffers */ |
| 350 | atomic_sub(count, &req_q->count); |
| 351 | req_q->first += count; |
| 352 | req_q->first %= QDIO_MAX_BUFFERS_PER_Q; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 353 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | } |
| 355 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 356 | |
| 357 | static void zfcp_qdio_setup_init_data(struct qdio_initialize *id, |
| 358 | struct zfcp_qdio *qdio) |
| 359 | { |
| 360 | |
| 361 | id->cdev = qdio->adapter->ccw_device; |
| 362 | id->q_format = QDIO_ZFCP_QFMT; |
| 363 | memcpy(id->adapter_name, dev_name(&id->cdev->dev), 8); |
| 364 | ASCEBC(id->adapter_name, 8); |
| 365 | id->qib_param_field_format = 0; |
| 366 | id->qib_param_field = NULL; |
| 367 | id->input_slib_elements = NULL; |
| 368 | id->output_slib_elements = NULL; |
| 369 | id->no_input_qs = 1; |
| 370 | id->no_output_qs = 1; |
| 371 | id->input_handler = zfcp_qdio_int_resp; |
| 372 | id->output_handler = zfcp_qdio_int_req; |
| 373 | id->int_parm = (unsigned long) qdio; |
| 374 | id->flags = QDIO_INBOUND_0COPY_SBALS | |
| 375 | QDIO_OUTBOUND_0COPY_SBALS | QDIO_USE_OUTBOUND_PCIS; |
| 376 | id->input_sbal_addr_array = (void **) (qdio->resp_q.sbal); |
| 377 | id->output_sbal_addr_array = (void **) (qdio->req_q.sbal); |
| 378 | |
| 379 | } |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 380 | /** |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 381 | * zfcp_qdio_allocate - allocate queue memory and initialize QDIO data |
| 382 | * @adapter: pointer to struct zfcp_adapter |
| 383 | * Returns: -ENOMEM on memory allocation error or return value from |
| 384 | * qdio_allocate |
| 385 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 386 | int zfcp_qdio_allocate(struct zfcp_qdio *qdio, struct ccw_device *ccw_dev) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 387 | { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 388 | struct qdio_initialize init_data; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 389 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 390 | if (zfcp_qdio_buffers_enqueue(qdio->req_q.sbal) || |
| 391 | zfcp_qdio_buffers_enqueue(qdio->resp_q.sbal)) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 392 | return -ENOMEM; |
| 393 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 394 | zfcp_qdio_setup_init_data(&init_data, qdio); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 395 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 396 | return qdio_allocate(&init_data); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | /** |
| 400 | * zfcp_close_qdio - close qdio queues for an adapter |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 401 | * @qdio: pointer to structure zfcp_qdio |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 402 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 403 | void zfcp_qdio_close(struct zfcp_qdio *qdio) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 404 | { |
| 405 | struct zfcp_qdio_queue *req_q; |
| 406 | int first, count; |
| 407 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 408 | if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 409 | return; |
| 410 | |
| 411 | /* clear QDIOUP flag, thus do_QDIO is not called during qdio_shutdown */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 412 | req_q = &qdio->req_q; |
| 413 | spin_lock_bh(&qdio->req_q_lock); |
| 414 | atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &qdio->adapter->status); |
| 415 | spin_unlock_bh(&qdio->req_q_lock); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 416 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 417 | qdio_shutdown(qdio->adapter->ccw_device, |
| 418 | QDIO_FLAG_CLEANUP_USING_CLEAR); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 419 | |
| 420 | /* cleanup used outbound sbals */ |
| 421 | count = atomic_read(&req_q->count); |
| 422 | if (count < QDIO_MAX_BUFFERS_PER_Q) { |
| 423 | first = (req_q->first + count) % QDIO_MAX_BUFFERS_PER_Q; |
| 424 | count = QDIO_MAX_BUFFERS_PER_Q - count; |
| 425 | zfcp_qdio_zero_sbals(req_q->sbal, first, count); |
| 426 | } |
| 427 | req_q->first = 0; |
| 428 | atomic_set(&req_q->count, 0); |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 429 | qdio->resp_q.first = 0; |
| 430 | atomic_set(&qdio->resp_q.count, 0); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /** |
| 434 | * zfcp_qdio_open - prepare and initialize response queue |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 435 | * @qdio: pointer to struct zfcp_qdio |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 436 | * Returns: 0 on success, otherwise -EIO |
| 437 | */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 438 | int zfcp_qdio_open(struct zfcp_qdio *qdio) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 439 | { |
Swen Schillig | 44cc76f | 2008-10-01 12:42:16 +0200 | [diff] [blame] | 440 | struct qdio_buffer_element *sbale; |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 441 | struct qdio_initialize init_data; |
| 442 | struct ccw_device *cdev = qdio->adapter->ccw_device; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 443 | int cc; |
| 444 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 445 | if (atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 446 | return -EIO; |
| 447 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 448 | zfcp_qdio_setup_init_data(&init_data, qdio); |
| 449 | |
| 450 | if (qdio_establish(&init_data)) |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 451 | goto failed_establish; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 452 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 453 | if (qdio_activate(cdev)) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 454 | goto failed_qdio; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 455 | |
| 456 | for (cc = 0; cc < QDIO_MAX_BUFFERS_PER_Q; cc++) { |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 457 | sbale = &(qdio->resp_q.sbal[cc]->element[0]); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 458 | sbale->length = 0; |
| 459 | sbale->flags = SBAL_FLAGS_LAST_ENTRY; |
| 460 | sbale->addr = NULL; |
| 461 | } |
| 462 | |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 463 | if (do_QDIO(cdev, QDIO_FLAG_SYNC_INPUT, 0, 0, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 464 | QDIO_MAX_BUFFERS_PER_Q)) |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 465 | goto failed_qdio; |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 466 | |
| 467 | /* set index of first avalable SBALS / number of available SBALS */ |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 468 | qdio->req_q.first = 0; |
| 469 | atomic_set(&qdio->req_q.count, QDIO_MAX_BUFFERS_PER_Q); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 470 | |
| 471 | return 0; |
| 472 | |
| 473 | failed_qdio: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 474 | qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR); |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 475 | failed_establish: |
Swen Schillig | 564e1c8 | 2009-08-18 15:43:19 +0200 | [diff] [blame] | 476 | dev_err(&cdev->dev, |
Christof Schmitt | ff3b24f | 2008-10-01 12:42:15 +0200 | [diff] [blame] | 477 | "Setting up the QDIO connection to the FCP adapter failed\n"); |
Swen Schillig | 00bab91 | 2008-06-10 18:20:57 +0200 | [diff] [blame] | 478 | return -EIO; |
| 479 | } |