Print this page
NEX-5717 import QLogic 16G FC drivers
Reviewed by: Steve Peng <steve.peng@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_iocb.c
+++ new/usr/src/uts/common/io/fibre-channel/fca/qlc/ql_iocb.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
|
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 -/* Copyright 2010 QLogic Corporation */
22 +/* Copyright 2015 QLogic Corporation */
23 23
24 24 /*
25 25 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
26 26 */
27 27
28 -#pragma ident "Copyright 2010 QLogic Corporation; ql_iocb.c"
28 +#pragma ident "Copyright 2015 QLogic Corporation; ql_iocb.c"
29 29
30 30 /*
31 31 * ISP2xxx Solaris Fibre Channel Adapter (FCA) driver source file.
32 32 *
33 33 * ***********************************************************************
34 34 * * **
35 35 * * NOTICE **
36 - * * COPYRIGHT (C) 1996-2010 QLOGIC CORPORATION **
36 + * * COPYRIGHT (C) 1996-2015 QLOGIC CORPORATION **
37 37 * * ALL RIGHTS RESERVED **
38 38 * * **
39 39 * ***********************************************************************
40 40 *
41 41 */
42 42
43 43 #include <ql_apps.h>
44 44 #include <ql_api.h>
45 45 #include <ql_debug.h>
46 46 #include <ql_iocb.h>
47 47 #include <ql_isr.h>
48 +#include <ql_nx.h>
48 49 #include <ql_xioctl.h>
50 +#include <ql_fm.h>
49 51
52 +
50 53 /*
51 54 * Local Function Prototypes.
52 55 */
53 -static int ql_req_pkt(ql_adapter_state_t *, request_t **);
54 -static void ql_continuation_iocb(ql_adapter_state_t *, ddi_dma_cookie_t *,
55 - uint16_t, boolean_t);
56 +static int ql_req_pkt(ql_adapter_state_t *, ql_request_q_t *, request_t **);
57 +static void ql_isp_cmd(ql_adapter_state_t *, ql_request_q_t *);
58 +static void ql_continuation_iocb(ql_adapter_state_t *, ql_request_q_t *,
59 + ddi_dma_cookie_t *, uint16_t, boolean_t);
56 60 static void ql_isp24xx_rcvbuf(ql_adapter_state_t *);
57 -static void ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *, ql_srb_t *, void *);
61 +static void ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *, ql_request_q_t *,
62 + ql_srb_t *, void *);
58 63
59 64 /*
60 65 * ql_start_iocb
61 66 * The start IOCB is responsible for building request packets
62 67 * on request ring and modifying ISP input pointer.
63 68 *
64 69 * Input:
65 70 * ha: adapter state pointer.
66 71 * sp: srb structure pointer.
67 72 *
68 73 * Context:
69 74 * Interrupt or Kernel context, no mailbox commands allowed.
70 75 */
71 76 void
72 77 ql_start_iocb(ql_adapter_state_t *vha, ql_srb_t *sp)
73 78 {
74 79 ql_link_t *link;
80 + ql_request_q_t *req_q;
75 81 request_t *pkt;
76 82 uint64_t *ptr64;
77 83 uint32_t cnt;
78 84 ql_adapter_state_t *ha = vha->pha;
79 85
80 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
86 + QL_PRINT_3(ha, "started\n");
81 87
82 88 /* Acquire ring lock. */
83 89 REQUEST_RING_LOCK(ha);
84 90
85 91 if (sp != NULL) {
86 92 /*
87 93 * If the pending queue is not empty maintain order
88 94 * by puting this srb at the tail and geting the head.
89 95 */
90 96 if ((link = ha->pending_cmds.first) != NULL) {
91 97 ql_add_link_b(&ha->pending_cmds, &sp->cmd);
92 98 /* Remove command from pending command queue */
93 99 sp = link->base_address;
94 100 ql_remove_link(&ha->pending_cmds, &sp->cmd);
95 101 }
96 102 } else {
97 103 /* Get command from pending command queue if not empty. */
98 104 if ((link = ha->pending_cmds.first) == NULL) {
99 105 /* Release ring specific lock */
100 106 REQUEST_RING_UNLOCK(ha);
101 - QL_PRINT_3(CE_CONT, "(%d): empty done\n",
102 - ha->instance);
107 + QL_PRINT_3(ha, "empty done\n");
103 108 return;
104 109 }
105 110 /* Remove command from pending command queue */
106 111 sp = link->base_address;
107 112 ql_remove_link(&ha->pending_cmds, &sp->cmd);
108 113 }
109 114
110 115 /* start this request and as many others as possible */
111 116 for (;;) {
112 - if (ha->req_q_cnt < sp->req_cnt) {
117 + if (ha->req_q[1] != NULL && sp->rsp_q_number != 0) {
118 + req_q = ha->req_q[1];
119 + } else {
120 + req_q = ha->req_q[0];
121 + }
122 +
123 + if (req_q->req_q_cnt < sp->req_cnt) {
113 124 /* Calculate number of free request entries. */
114 - cnt = RD16_IO_REG(ha, req_out);
115 - if (ha->req_ring_index < cnt) {
116 - ha->req_q_cnt = (uint16_t)
117 - (cnt - ha->req_ring_index);
125 + if (ha->flags & QUEUE_SHADOW_PTRS) {
126 + (void) ddi_dma_sync(req_q->req_ring.dma_handle,
127 + (off_t)req_q->req_out_shadow_ofst,
128 + SHADOW_ENTRY_SIZE, DDI_DMA_SYNC_FORCPU);
129 + cnt = ddi_get32(req_q->req_ring.acc_handle,
130 + req_q->req_out_shadow_ptr);
131 + } else if (ha->flags & MULTI_QUEUE) {
132 + cnt = RD16_MBAR_REG(ha, req_q->mbar_req_out);
118 133 } else {
119 - ha->req_q_cnt = (uint16_t)(REQUEST_ENTRY_CNT -
120 - (ha->req_ring_index - cnt));
134 + cnt = RD16_IO_REG(ha, req_out);
121 135 }
122 - if (ha->req_q_cnt != 0) {
123 - ha->req_q_cnt--;
136 + if (req_q->req_ring_index < cnt) {
137 + req_q->req_q_cnt = (uint16_t)
138 + (cnt - req_q->req_ring_index);
139 + } else {
140 + req_q->req_q_cnt =
141 + (uint16_t)(req_q->req_entry_cnt -
142 + (req_q->req_ring_index - cnt));
124 143 }
144 + if (req_q->req_q_cnt != 0) {
145 + req_q->req_q_cnt--;
146 + }
125 147
126 148 /*
127 149 * If no room in request ring put this srb at
128 150 * the head of the pending queue and exit.
129 151 */
130 - if (ha->req_q_cnt < sp->req_cnt) {
131 - QL_PRINT_8(CE_CONT, "(%d): request ring full,"
152 + if (req_q->req_q_cnt < sp->req_cnt) {
153 + QL_PRINT_8(ha, "request ring full,"
132 154 " req_q_cnt=%d, req_ring_index=%d\n",
133 - ha->instance, ha->req_q_cnt,
134 - ha->req_ring_index);
155 + req_q->req_q_cnt, req_q->req_ring_index);
135 156 ql_add_link_t(&ha->pending_cmds, &sp->cmd);
136 157 break;
137 158 }
138 159 }
139 160
140 161 /* Check for room in outstanding command list. */
141 - for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
162 + for (cnt = 1; cnt < ha->osc_max_cnt; cnt++) {
142 163 ha->osc_index++;
143 - if (ha->osc_index == MAX_OUTSTANDING_COMMANDS) {
164 + if (ha->osc_index == ha->osc_max_cnt) {
144 165 ha->osc_index = 1;
145 166 }
146 167 if (ha->outstanding_cmds[ha->osc_index] == NULL) {
147 168 break;
148 169 }
149 170 }
150 171 /*
151 172 * If no room in outstanding array put this srb at
152 173 * the head of the pending queue and exit.
153 174 */
154 - if (cnt == MAX_OUTSTANDING_COMMANDS) {
155 - QL_PRINT_8(CE_CONT, "(%d): no room in outstanding "
156 - "array\n", ha->instance);
175 + if (cnt == ha->osc_max_cnt) {
176 + QL_PRINT_8(ha, "no room in outstanding array\n");
157 177 ql_add_link_t(&ha->pending_cmds, &sp->cmd);
158 178 break;
159 179 }
160 180
161 181 /* nothing to stop us now. */
162 182 ha->outstanding_cmds[ha->osc_index] = sp;
163 183 /* create and save a unique response identifier in the srb */
164 184 sp->handle = ha->adapter_stats->ncmds << OSC_INDEX_SHIFT |
165 185 ha->osc_index;
166 - ha->req_q_cnt -= sp->req_cnt;
186 + req_q->req_q_cnt = (uint16_t)(req_q->req_q_cnt - sp->req_cnt);
167 187
168 188 /* build the iocb in the request ring */
169 - pkt = ha->request_ring_ptr;
189 + pkt = req_q->req_ring_ptr;
170 190 sp->request_ring_ptr = pkt;
191 + sp->req_q_number = req_q->req_q_number;
171 192 sp->flags |= SRB_IN_TOKEN_ARRAY;
172 193
173 194 /* Zero out packet. */
174 195 ptr64 = (uint64_t *)pkt;
175 196 *ptr64++ = 0; *ptr64++ = 0;
176 197 *ptr64++ = 0; *ptr64++ = 0;
177 198 *ptr64++ = 0; *ptr64++ = 0;
178 199 *ptr64++ = 0; *ptr64 = 0;
179 200
180 201 /* Setup IOCB common data. */
181 202 pkt->entry_count = (uint8_t)sp->req_cnt;
182 - pkt->sys_define = (uint8_t)ha->req_ring_index;
203 + if (ha->req_q[1] != NULL && sp->rsp_q_number != 0) {
204 + pkt->entry_status = sp->rsp_q_number;
205 + }
206 + pkt->sys_define = (uint8_t)req_q->req_ring_index;
207 +
183 208 /* mark the iocb with the response identifier */
184 - ddi_put32(ha->hba_buf.acc_handle, &pkt->handle,
209 + ddi_put32(req_q->req_ring.acc_handle, &pkt->handle,
185 210 (uint32_t)sp->handle);
186 211
187 212 /* Setup IOCB unique data. */
188 - (sp->iocb)(vha, sp, pkt);
213 + (sp->iocb)(vha, req_q, sp, pkt);
189 214
190 215 sp->flags |= SRB_ISP_STARTED;
191 216
192 - QL_PRINT_5(CE_CONT, "(%d,%d): req packet, sp=%p\n",
193 - ha->instance, vha->vp_index, (void *)sp);
217 + QL_PRINT_5(ha, "req packet, sp=%p\n", (void *)sp);
194 218 QL_DUMP_5((uint8_t *)pkt, 8, REQUEST_ENTRY_SIZE);
195 219
196 220 /* Sync DMA buffer. */
197 - (void) ddi_dma_sync(ha->hba_buf.dma_handle,
198 - (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
199 - REQUEST_Q_BUFFER_OFFSET), (size_t)REQUEST_ENTRY_SIZE,
200 - DDI_DMA_SYNC_FORDEV);
221 + (void) ddi_dma_sync(req_q->req_ring.dma_handle,
222 + (off_t)(req_q->req_ring_index * REQUEST_ENTRY_SIZE),
223 + (size_t)REQUEST_ENTRY_SIZE, DDI_DMA_SYNC_FORDEV);
201 224
202 225 /* Adjust ring index. */
203 - ha->req_ring_index++;
204 - if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
205 - ha->req_ring_index = 0;
206 - ha->request_ring_ptr = ha->request_ring_bp;
226 + req_q->req_ring_index++;
227 + if (req_q->req_ring_index == REQUEST_ENTRY_CNT) {
228 + req_q->req_ring_index = 0;
229 + req_q->req_ring_ptr = req_q->req_ring.bp;
207 230 } else {
208 - ha->request_ring_ptr++;
231 + req_q->req_ring_ptr++;
209 232 }
210 233
211 234 /* Reset watchdog timer */
212 235 sp->wdg_q_time = sp->init_wdg_q_time;
213 236
214 237 /*
215 238 * Send it by setting the new ring index in the ISP Request
216 239 * Ring In Pointer register. This is the mechanism
217 240 * used to notify the isp that a new iocb has been
218 241 * placed on the request ring.
219 242 */
220 - if (CFG_IST(ha, CFG_CTRL_8021)) {
221 - uint32_t w32;
222 -
223 - w32 = ha->req_ring_index << 16 |
224 - ha->function_number << 5 | 4;
225 - do {
226 - ddi_put32(ha->db_dev_handle, ha->nx_req_in,
227 - w32);
228 - } while (RD_REG_DWORD(ha, ha->db_read) != w32);
229 -
243 + if (ha->flags & MULTI_QUEUE) {
244 + WR16_MBAR_REG(ha, req_q->mbar_req_in,
245 + req_q->req_ring_index);
246 + } else if (CFG_IST(ha, CFG_CTRL_82XX)) {
247 + ql_8021_wr_req_in(ha, req_q->req_ring_index);
230 248 } else {
231 - WRT16_IO_REG(ha, req_in, ha->req_ring_index);
249 + WRT16_IO_REG(ha, req_in, req_q->req_ring_index);
232 250 }
233 251
234 252 /* Update outstanding command count statistic. */
235 253 ha->adapter_stats->ncmds++;
236 254
237 255 /* if there is a pending command, try to start it. */
238 256 if ((link = ha->pending_cmds.first) == NULL) {
239 257 break;
240 258 }
241 259
242 260 /* Remove command from pending command queue */
243 261 sp = link->base_address;
244 262 ql_remove_link(&ha->pending_cmds, &sp->cmd);
245 263 }
246 264
265 + if (qlc_fm_check_acc_handle(ha, ha->dev_handle)
266 + != DDI_FM_OK) {
267 + qlc_fm_report_err_impact(ha,
268 + QL_FM_EREPORT_ACC_HANDLE_CHECK);
269 + }
270 +
247 271 /* Release ring specific lock */
248 272 REQUEST_RING_UNLOCK(ha);
249 273
250 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
274 + QL_PRINT_3(ha, "done\n");
251 275 }
252 276
253 277 /*
254 278 * ql_req_pkt
255 279 * Function is responsible for locking ring and
256 280 * getting a zeroed out request packet.
257 281 *
258 282 * Input:
259 283 * ha: adapter state pointer.
284 + * req_q: request queue structure pointer.
260 285 * pkt: address for packet pointer.
261 286 *
262 287 * Returns:
263 288 * ql local function return status code.
264 289 *
265 290 * Context:
266 291 * Interrupt or Kernel context, no mailbox commands allowed.
267 292 */
268 293 static int
269 -ql_req_pkt(ql_adapter_state_t *vha, request_t **pktp)
294 +ql_req_pkt(ql_adapter_state_t *vha, ql_request_q_t *req_q, request_t **pktp)
270 295 {
271 296 uint16_t cnt;
272 - uint32_t *long_ptr;
297 + uint64_t *ptr64;
273 298 uint32_t timer;
274 299 int rval = QL_FUNCTION_TIMEOUT;
275 300 ql_adapter_state_t *ha = vha->pha;
276 301
277 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
302 + QL_PRINT_3(ha, "started\n");
278 303
279 304 /* Wait for 30 seconds for slot. */
280 305 for (timer = 30000; timer != 0; timer--) {
281 306 /* Acquire ring lock. */
282 307 REQUEST_RING_LOCK(ha);
283 308
284 - if (ha->req_q_cnt == 0) {
309 + if (req_q->req_q_cnt == 0) {
285 310 /* Calculate number of free request entries. */
286 - cnt = RD16_IO_REG(ha, req_out);
287 - if (ha->req_ring_index < cnt) {
288 - ha->req_q_cnt = (uint16_t)
289 - (cnt - ha->req_ring_index);
311 + if (ha->flags & QUEUE_SHADOW_PTRS) {
312 + (void) ddi_dma_sync(req_q->req_ring.dma_handle,
313 + (off_t)req_q->req_out_shadow_ofst,
314 + SHADOW_ENTRY_SIZE, DDI_DMA_SYNC_FORCPU);
315 + cnt = ddi_get32(req_q->req_ring.acc_handle,
316 + req_q->req_out_shadow_ptr);
317 + } else if (ha->flags & MULTI_QUEUE) {
318 + cnt = RD16_MBAR_REG(ha, req_q->mbar_req_out);
290 319 } else {
291 - ha->req_q_cnt = (uint16_t)
320 + cnt = RD16_IO_REG(ha, req_out);
321 + }
322 + if (req_q->req_ring_index < cnt) {
323 + req_q->req_q_cnt = (uint16_t)
324 + (cnt - req_q->req_ring_index);
325 + } else {
326 + req_q->req_q_cnt = (uint16_t)
292 327 (REQUEST_ENTRY_CNT -
293 - (ha->req_ring_index - cnt));
328 + (req_q->req_ring_index - cnt));
294 329 }
295 - if (ha->req_q_cnt != 0) {
296 - ha->req_q_cnt--;
330 + if (req_q->req_q_cnt != 0) {
331 + req_q->req_q_cnt--;
297 332 }
298 333 }
299 334
300 335 /* Found empty request ring slot? */
301 - if (ha->req_q_cnt != 0) {
302 - ha->req_q_cnt--;
303 - *pktp = ha->request_ring_ptr;
336 + if (req_q->req_q_cnt != 0) {
337 + req_q->req_q_cnt--;
338 + *pktp = req_q->req_ring_ptr;
304 339
305 340 /* Zero out packet. */
306 - long_ptr = (uint32_t *)ha->request_ring_ptr;
307 - for (cnt = 0; cnt < REQUEST_ENTRY_SIZE/4; cnt++) {
308 - *long_ptr++ = 0;
309 - }
341 + ptr64 = (uint64_t *)req_q->req_ring_ptr;
342 + *ptr64++ = 0; *ptr64++ = 0;
343 + *ptr64++ = 0; *ptr64++ = 0;
344 + *ptr64++ = 0; *ptr64++ = 0;
345 + *ptr64++ = 0; *ptr64 = 0;
310 346
311 347 /* Setup IOCB common data. */
312 - ha->request_ring_ptr->entry_count = 1;
313 - ha->request_ring_ptr->sys_define =
314 - (uint8_t)ha->req_ring_index;
315 - ddi_put32(ha->hba_buf.acc_handle,
316 - &ha->request_ring_ptr->handle,
348 + req_q->req_ring_ptr->entry_count = 1;
349 + req_q->req_ring_ptr->sys_define =
350 + (uint8_t)req_q->req_ring_index;
351 + ddi_put32(req_q->req_ring.acc_handle,
352 + &req_q->req_ring_ptr->handle,
317 353 (uint32_t)QL_FCA_BRAND);
318 354
319 355 rval = QL_SUCCESS;
320 356
321 357 break;
322 358 }
323 359
324 360 /* Release request queue lock. */
325 361 REQUEST_RING_UNLOCK(ha);
326 362
327 363 drv_usecwait(MILLISEC);
328 364
329 365 /* Check for pending interrupts. */
330 366 /*
331 367 * XXX protect interrupt routine from calling itself.
332 368 * Need to revisit this routine. So far we never
333 369 * hit this case as req slot was available
334 370 */
335 371 if ((!(curthread->t_flag & T_INTR_THREAD)) &&
336 372 INTERRUPT_PENDING(ha)) {
337 373 (void) ql_isr((caddr_t)ha);
338 374 INTR_LOCK(ha);
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
339 375 ha->intr_claimed = TRUE;
340 376 INTR_UNLOCK(ha);
341 377 }
342 378 }
343 379
344 380 if (rval != QL_SUCCESS) {
345 381 ql_awaken_task_daemon(ha, NULL, ISP_ABORT_NEEDED, 0);
346 382 EL(ha, "failed, rval = %xh, isp_abort_needed\n", rval);
347 383 } else {
348 384 /*EMPTY*/
349 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
385 + QL_PRINT_3(ha, "done\n");
350 386 }
351 387 return (rval);
352 388 }
353 389
354 390 /*
355 391 * ql_isp_cmd
356 392 * Function is responsible for modifying ISP input pointer.
357 393 * This action notifies the isp that a new request has been
358 394 * added to the request ring.
359 395 *
360 396 * Releases ring lock.
361 397 *
362 398 * Input:
363 - * ha: adapter state pointer.
399 + * vha: adapter state pointer.
400 + * req_q: request queue structure pointer.
364 401 *
365 402 * Context:
366 403 * Interrupt or Kernel context, no mailbox commands allowed.
367 404 */
368 -void
369 -ql_isp_cmd(ql_adapter_state_t *vha)
405 +static void
406 +ql_isp_cmd(ql_adapter_state_t *vha, ql_request_q_t *req_q)
370 407 {
371 408 ql_adapter_state_t *ha = vha->pha;
372 409
373 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
410 + QL_PRINT_3(ha, "started\n");
374 411
375 - QL_PRINT_5(CE_CONT, "(%d): req packet:\n", ha->instance);
376 - QL_DUMP_5((uint8_t *)ha->request_ring_ptr, 8, REQUEST_ENTRY_SIZE);
412 + QL_PRINT_5(ha, "req packet:\n");
413 + QL_DUMP_5((uint8_t *)req_q->req_ring_ptr, 8, REQUEST_ENTRY_SIZE);
377 414
378 415 /* Sync DMA buffer. */
379 - (void) ddi_dma_sync(ha->hba_buf.dma_handle,
380 - (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
381 - REQUEST_Q_BUFFER_OFFSET), (size_t)REQUEST_ENTRY_SIZE,
382 - DDI_DMA_SYNC_FORDEV);
416 + (void) ddi_dma_sync(req_q->req_ring.dma_handle,
417 + (off_t)(req_q->req_ring_index * REQUEST_ENTRY_SIZE),
418 + (size_t)REQUEST_ENTRY_SIZE, DDI_DMA_SYNC_FORDEV);
383 419
384 420 /* Adjust ring index. */
385 - ha->req_ring_index++;
386 - if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
387 - ha->req_ring_index = 0;
388 - ha->request_ring_ptr = ha->request_ring_bp;
421 + req_q->req_ring_index++;
422 + if (req_q->req_ring_index == REQUEST_ENTRY_CNT) {
423 + req_q->req_ring_index = 0;
424 + req_q->req_ring_ptr = req_q->req_ring.bp;
389 425 } else {
390 - ha->request_ring_ptr++;
426 + req_q->req_ring_ptr++;
391 427 }
392 428
393 429 /* Set chip new ring index. */
394 - if (CFG_IST(ha, CFG_CTRL_8021)) {
395 - uint32_t w32;
396 -
397 - w32 = ha->req_ring_index << 16 |
398 - ha->function_number << 5 | 4;
399 - do {
400 - ddi_put32(ha->db_dev_handle, ha->nx_req_in, w32);
401 - } while (RD_REG_DWORD(ha, ha->db_read) != w32);
402 -
430 + if (ha->flags & MULTI_QUEUE) {
431 + WR16_MBAR_REG(ha, req_q->mbar_req_in,
432 + req_q->req_ring_index);
433 + } else if (CFG_IST(ha, CFG_CTRL_82XX)) {
434 + ql_8021_wr_req_in(ha, req_q->req_ring_index);
403 435 } else {
404 - WRT16_IO_REG(ha, req_in, ha->req_ring_index);
436 + WRT16_IO_REG(ha, req_in, req_q->req_ring_index);
405 437 }
406 438
407 439 /* Release ring lock. */
408 440 REQUEST_RING_UNLOCK(ha);
409 441
410 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
442 + QL_PRINT_3(ha, "done\n");
411 443 }
412 444
413 445 /*
414 446 * ql_command_iocb
415 447 * Setup of command IOCB.
416 448 *
417 449 * Input:
418 450 * ha: adapter state pointer.
451 + * req_q: request queue structure pointer.
419 452 * sp: srb structure pointer.
420 - *
421 453 * arg: request queue packet.
422 454 *
423 455 * Context:
424 456 * Interrupt or Kernel context, no mailbox commands allowed.
425 457 */
426 458 void
427 -ql_command_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
459 +ql_command_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
460 + void *arg)
428 461 {
429 462 ddi_dma_cookie_t *cp;
430 463 uint32_t *ptr32, cnt;
431 464 uint16_t seg_cnt;
432 465 fcp_cmd_t *fcp = sp->fcp;
433 466 ql_tgt_t *tq = sp->lun_queue->target_queue;
434 467 cmd_entry_t *pkt = arg;
468 + cmd_3_entry_t *pkt3 = arg;
435 469
436 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
470 + QL_PRINT_3(ha, "started\n");
437 471
438 472 /* Set LUN number */
439 473 pkt->lun_l = LSB(sp->lun_queue->lun_no);
440 474 pkt->lun_h = MSB(sp->lun_queue->lun_no);
441 475
442 476 /* Set target ID */
443 477 if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
444 478 pkt->target_l = LSB(tq->loop_id);
445 479 pkt->target_h = MSB(tq->loop_id);
446 480 } else {
447 481 pkt->target_h = LSB(tq->loop_id);
448 482 }
449 483
450 484 /* Set tag queue control flags */
451 485 if (fcp->fcp_cntl.cntl_qtype == FCP_QTYPE_HEAD_OF_Q) {
452 486 pkt->control_flags_l = (uint8_t)
453 487 (pkt->control_flags_l | CF_HTAG);
|
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
454 488 } else if (fcp->fcp_cntl.cntl_qtype == FCP_QTYPE_ORDERED) {
455 489 pkt->control_flags_l = (uint8_t)
456 490 (pkt->control_flags_l | CF_OTAG);
457 491 /* else if (fcp->fcp_cntl.cntl_qtype == FCP_QTYPE_SIMPLE) */
458 492 } else {
459 493 pkt->control_flags_l = (uint8_t)
460 494 (pkt->control_flags_l | CF_STAG);
461 495 }
462 496
463 497 /* Set ISP command timeout. */
464 - ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
498 + ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout, sp->isp_timeout);
465 499
466 500 /* Load SCSI CDB */
467 - ddi_rep_put8(ha->hba_buf.acc_handle, fcp->fcp_cdb,
501 + ddi_rep_put8(req_q->req_ring.acc_handle, fcp->fcp_cdb,
468 502 pkt->scsi_cdb, MAX_CMDSZ, DDI_DEV_AUTOINCR);
469 503
470 - if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
471 - pkt->entry_type = IOCB_CMD_TYPE_3;
472 - cnt = CMD_TYPE_3_DATA_SEGMENTS;
473 - } else {
474 - pkt->entry_type = IOCB_CMD_TYPE_2;
475 - cnt = CMD_TYPE_2_DATA_SEGMENTS;
476 - }
477 -
478 504 if (fcp->fcp_data_len == 0) {
479 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
505 + QL_PRINT_3(ha, "done\n");
506 + pkt->entry_type = IOCB_CMD_TYPE_2;
480 507 ha->xioctl->IOControlRequests++;
481 508 return;
482 509 }
483 510
484 511 /*
485 512 * Set transfer direction. Load Data segments.
486 513 */
487 514 if (fcp->fcp_cntl.cntl_write_data) {
488 515 pkt->control_flags_l = (uint8_t)
489 516 (pkt->control_flags_l | CF_DATA_OUT);
490 517 ha->xioctl->IOOutputRequests++;
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
491 518 ha->xioctl->IOOutputByteCnt += fcp->fcp_data_len;
492 519 } else if (fcp->fcp_cntl.cntl_read_data) {
493 520 pkt->control_flags_l = (uint8_t)
494 521 (pkt->control_flags_l | CF_DATA_IN);
495 522 ha->xioctl->IOInputRequests++;
496 523 ha->xioctl->IOInputByteCnt += fcp->fcp_data_len;
497 524 }
498 525
499 526 /* Set data segment count. */
500 527 seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
501 - ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
528 + ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
502 529
503 530 /* Load total byte count. */
504 - ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count, fcp->fcp_data_len);
531 + ddi_put32(req_q->req_ring.acc_handle, &pkt->byte_count,
532 + fcp->fcp_data_len);
505 533
506 534 /* Load command data segment. */
507 - ptr32 = (uint32_t *)&pkt->dseg_0_address;
508 535 cp = sp->pkt->pkt_data_cookie;
509 - while (cnt && seg_cnt) {
510 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
511 - if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
512 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
536 +
537 + if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
538 + pkt3->entry_type = IOCB_CMD_TYPE_3;
539 + cnt = CMD_TYPE_3_DATA_SEGMENTS;
540 +
541 + ptr32 = (uint32_t *)&pkt3->dseg;
542 + while (cnt && seg_cnt) {
543 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
544 + cp->dmac_address);
545 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
513 546 cp->dmac_notused);
547 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
548 + (uint32_t)cp->dmac_size);
549 + seg_cnt--;
550 + cnt--;
551 + cp++;
514 552 }
515 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
516 - (uint32_t)cp->dmac_size);
517 - seg_cnt--;
518 - cnt--;
519 - cp++;
553 + } else {
554 + pkt->entry_type = IOCB_CMD_TYPE_2;
555 + cnt = CMD_TYPE_2_DATA_SEGMENTS;
556 +
557 + ptr32 = (uint32_t *)&pkt->dseg;
558 + while (cnt && seg_cnt) {
559 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
560 + cp->dmac_address);
561 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
562 + (uint32_t)cp->dmac_size);
563 + seg_cnt--;
564 + cnt--;
565 + cp++;
566 + }
520 567 }
521 568
522 569 /*
523 570 * Build continuation packets.
524 571 */
525 572 if (seg_cnt) {
526 - ql_continuation_iocb(ha, cp, seg_cnt,
573 + ql_continuation_iocb(ha, req_q, cp, seg_cnt,
527 574 (boolean_t)(CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)));
528 575 }
529 576
530 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
577 + QL_PRINT_3(ha, "done\n");
531 578 }
532 579
533 580 /*
534 581 * ql_continuation_iocb
535 582 * Setup of continuation IOCB.
536 583 *
537 584 * Input:
538 585 * ha: adapter state pointer.
586 + * req_q: request queue structure pointer.
539 587 * cp: cookie list pointer.
540 588 * seg_cnt: number of segments.
541 589 * addr64: 64 bit addresses.
542 590 *
543 591 * Context:
544 592 * Interrupt or Kernel context, no mailbox commands allowed.
545 593 */
594 +/* ARGSUSED */
546 595 static void
547 -ql_continuation_iocb(ql_adapter_state_t *ha, ddi_dma_cookie_t *cp,
548 - uint16_t seg_cnt, boolean_t addr64)
596 +ql_continuation_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q,
597 + ddi_dma_cookie_t *cp, uint16_t seg_cnt, boolean_t addr64)
549 598 {
550 - cont_entry_t *pkt;
551 - uint64_t *ptr64;
552 - uint32_t *ptr32, cnt;
599 + cont_entry_t *pkt;
600 + cont_type_1_entry_t *pkt1;
601 + uint64_t *ptr64;
602 + uint32_t *ptr32, cnt;
553 603
554 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
604 + QL_PRINT_3(ha, "started\n");
555 605
556 606 /*
557 607 * Build continuation packets.
558 608 */
559 609 while (seg_cnt) {
560 610 /* Sync DMA buffer. */
561 - (void) ddi_dma_sync(ha->hba_buf.dma_handle,
562 - (off_t)(ha->req_ring_index * REQUEST_ENTRY_SIZE +
563 - REQUEST_Q_BUFFER_OFFSET), REQUEST_ENTRY_SIZE,
564 - DDI_DMA_SYNC_FORDEV);
611 + (void) ddi_dma_sync(req_q->req_ring.dma_handle,
612 + (off_t)(req_q->req_ring_index * REQUEST_ENTRY_SIZE),
613 + REQUEST_ENTRY_SIZE, DDI_DMA_SYNC_FORDEV);
565 614
566 615 /* Adjust ring pointer, and deal with wrap. */
567 - ha->req_ring_index++;
568 - if (ha->req_ring_index == REQUEST_ENTRY_CNT) {
569 - ha->req_ring_index = 0;
570 - ha->request_ring_ptr = ha->request_ring_bp;
616 + req_q->req_ring_index++;
617 + if (req_q->req_ring_index == REQUEST_ENTRY_CNT) {
618 + req_q->req_ring_index = 0;
619 + req_q->req_ring_ptr = req_q->req_ring.bp;
571 620 } else {
572 - ha->request_ring_ptr++;
621 + req_q->req_ring_ptr++;
573 622 }
574 - pkt = (cont_entry_t *)ha->request_ring_ptr;
623 + pkt = (cont_entry_t *)req_q->req_ring_ptr;
624 + pkt1 = (cont_type_1_entry_t *)req_q->req_ring_ptr;
575 625
576 626 /* Zero out packet. */
577 627 ptr64 = (uint64_t *)pkt;
578 628 *ptr64++ = 0; *ptr64++ = 0;
579 629 *ptr64++ = 0; *ptr64++ = 0;
580 630 *ptr64++ = 0; *ptr64++ = 0;
581 631 *ptr64++ = 0; *ptr64 = 0;
582 632
583 633 /*
584 634 * Build continuation packet.
585 635 */
586 636 pkt->entry_count = 1;
587 - pkt->sys_define = (uint8_t)ha->req_ring_index;
637 + pkt->sys_define = (uint8_t)req_q->req_ring_index;
588 638 if (addr64) {
589 - pkt->entry_type = CONTINUATION_TYPE_1;
639 + pkt1->entry_type = CONTINUATION_TYPE_1;
590 640 cnt = CONT_TYPE_1_DATA_SEGMENTS;
591 - ptr32 = (uint32_t *)
592 - &((cont_type_1_entry_t *)pkt)->dseg_0_address;
641 + ptr32 = (uint32_t *)&pkt1->dseg;
593 642 while (cnt && seg_cnt) {
594 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
643 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
595 644 cp->dmac_address);
596 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
645 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
597 646 cp->dmac_notused);
598 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
647 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
599 648 (uint32_t)cp->dmac_size);
600 649 seg_cnt--;
601 650 cnt--;
602 651 cp++;
603 652 }
604 653 } else {
605 654 pkt->entry_type = CONTINUATION_TYPE_0;
606 655 cnt = CONT_TYPE_0_DATA_SEGMENTS;
607 - ptr32 = (uint32_t *)&pkt->dseg_0_address;
656 + ptr32 = (uint32_t *)&pkt->dseg;
608 657 while (cnt && seg_cnt) {
609 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
658 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
610 659 cp->dmac_address);
611 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
660 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
612 661 (uint32_t)cp->dmac_size);
613 662 seg_cnt--;
614 663 cnt--;
615 664 cp++;
616 665 }
617 666 }
618 667
619 - QL_PRINT_5(CE_CONT, "(%d): packet:\n", ha->instance);
668 + QL_PRINT_5(ha, "packet:\n");
620 669 QL_DUMP_5((uint8_t *)pkt, 8, REQUEST_ENTRY_SIZE);
621 670 }
622 671
623 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
672 + QL_PRINT_3(ha, "done\n");
624 673 }
625 674
626 675 /*
627 676 * ql_command_24xx_iocb
628 677 * Setup of ISP24xx command IOCB.
629 678 *
630 679 * Input:
631 680 * ha: adapter state pointer.
681 + * req_q: request queue structure pointer.
632 682 * sp: srb structure pointer.
633 683 * arg: request queue packet.
634 684 *
635 685 * Context:
636 686 * Interrupt or Kernel context, no mailbox commands allowed.
637 687 */
638 688 void
639 -ql_command_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
689 +ql_command_24xx_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q,
690 + ql_srb_t *sp, void *arg)
640 691 {
641 692 ddi_dma_cookie_t *cp;
642 693 uint32_t *ptr32, cnt;
643 694 uint16_t seg_cnt;
644 695 fcp_cmd_t *fcp = sp->fcp;
645 696 ql_tgt_t *tq = sp->lun_queue->target_queue;
646 697 cmd7_24xx_entry_t *pkt = arg;
647 698 ql_adapter_state_t *pha = ha->pha;
699 + fcp_ent_addr_t *fcp_ent_addr;
648 700
649 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
701 + QL_PRINT_3(ha, "started\n");
650 702
651 703 if (fcp->fcp_data_len != 0 && sp->sg_dma.dma_handle != NULL &&
652 704 sp->pkt->pkt_data_cookie_cnt > 1) {
653 - ql_cmd_24xx_type_6_iocb(ha, sp, arg);
654 - QL_PRINT_3(CE_CONT, "(%d): cmd6 exit\n", ha->instance);
705 + ql_cmd_24xx_type_6_iocb(ha, req_q, sp, arg);
706 + QL_PRINT_3(ha, "cmd6 exit\n");
655 707 return;
656 708 }
657 709
658 710 pkt->entry_type = IOCB_CMD_TYPE_7;
659 711
660 712 /* Set LUN number */
661 - pkt->fcp_lun[2] = LSB(sp->lun_queue->lun_no);
662 - pkt->fcp_lun[3] = MSB(sp->lun_queue->lun_no);
713 + fcp_ent_addr = (fcp_ent_addr_t *)&sp->lun_queue->lun_addr;
714 + pkt->fcp_lun[2] = lobyte(fcp_ent_addr->ent_addr_0);
715 + pkt->fcp_lun[3] = hibyte(fcp_ent_addr->ent_addr_0);
716 + pkt->fcp_lun[0] = lobyte(fcp_ent_addr->ent_addr_1);
717 + pkt->fcp_lun[1] = hibyte(fcp_ent_addr->ent_addr_1);
718 + pkt->fcp_lun[6] = lobyte(fcp_ent_addr->ent_addr_2);
719 + pkt->fcp_lun[7] = hibyte(fcp_ent_addr->ent_addr_2);
720 + pkt->fcp_lun[4] = lobyte(fcp_ent_addr->ent_addr_3);
721 + pkt->fcp_lun[5] = hibyte(fcp_ent_addr->ent_addr_3);
663 722
664 723 /* Set N_port handle */
665 - ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
724 + ddi_put16(req_q->req_ring.acc_handle, &pkt->n_port_hdl, tq->loop_id);
666 725
667 726 /* Set target ID */
668 727 pkt->target_id[0] = tq->d_id.b.al_pa;
669 728 pkt->target_id[1] = tq->d_id.b.area;
670 729 pkt->target_id[2] = tq->d_id.b.domain;
671 730
672 731 pkt->vp_index = ha->vp_index;
673 732
674 733 /* Set ISP command timeout. */
675 734 if (sp->isp_timeout < 0x1999) {
676 - ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
735 + ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout,
677 736 sp->isp_timeout);
678 737 }
679 738
680 739 /* Load SCSI CDB */
681 - ddi_rep_put8(pha->hba_buf.acc_handle, fcp->fcp_cdb, pkt->scsi_cdb,
740 + ddi_rep_put8(req_q->req_ring.acc_handle, fcp->fcp_cdb, pkt->scsi_cdb,
682 741 MAX_CMDSZ, DDI_DEV_AUTOINCR);
683 742 for (cnt = 0; cnt < MAX_CMDSZ; cnt += 4) {
684 743 ql_chg_endian((uint8_t *)&pkt->scsi_cdb + cnt, 4);
685 744 }
686 745
687 746 /*
688 747 * Set tag queue control flags
689 748 * Note:
690 749 * Cannot copy fcp->fcp_cntl.cntl_qtype directly,
691 750 * problem with x86 in 32bit kernel mode
692 751 */
693 752 switch (fcp->fcp_cntl.cntl_qtype) {
694 753 case FCP_QTYPE_SIMPLE:
695 754 pkt->task = TA_STAG;
696 755 break;
697 756 case FCP_QTYPE_HEAD_OF_Q:
698 757 pkt->task = TA_HTAG;
699 758 break;
700 759 case FCP_QTYPE_ORDERED:
701 760 pkt->task = TA_OTAG;
702 761 break;
703 762 case FCP_QTYPE_ACA_Q_TAG:
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
704 763 pkt->task = TA_ACA;
705 764 break;
706 765 case FCP_QTYPE_UNTAGGED:
707 766 pkt->task = TA_UNTAGGED;
708 767 break;
709 768 default:
710 769 break;
711 770 }
712 771
713 772 if (fcp->fcp_data_len == 0) {
714 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
773 + QL_PRINT_3(ha, "done\n");
715 774 pha->xioctl->IOControlRequests++;
716 775 return;
717 776 }
718 777
719 778 /* Set transfer direction. */
720 779 if (fcp->fcp_cntl.cntl_write_data) {
721 780 pkt->control_flags = CF_WR;
722 781 pha->xioctl->IOOutputRequests++;
723 782 pha->xioctl->IOOutputByteCnt += fcp->fcp_data_len;
724 783 } else if (fcp->fcp_cntl.cntl_read_data) {
725 784 pkt->control_flags = CF_RD;
726 785 pha->xioctl->IOInputRequests++;
727 786 pha->xioctl->IOInputByteCnt += fcp->fcp_data_len;
728 787 }
729 788
730 789 /* Set data segment count. */
731 790 seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
732 - ddi_put16(pha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
791 + ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
733 792
734 793 /* Load total byte count. */
735 - ddi_put32(pha->hba_buf.acc_handle, &pkt->total_byte_count,
794 + ddi_put32(req_q->req_ring.acc_handle, &pkt->total_byte_count,
736 795 fcp->fcp_data_len);
737 796
738 797 /* Load command data segment. */
739 - ptr32 = (uint32_t *)&pkt->dseg_0_address;
798 + ptr32 = (uint32_t *)&pkt->dseg;
740 799 cp = sp->pkt->pkt_data_cookie;
741 - ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
742 - ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
743 - ddi_put32(pha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
800 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
801 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
802 + ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
744 803 seg_cnt--;
745 804 cp++;
746 805
747 806 /*
748 807 * Build continuation packets.
749 808 */
750 809 if (seg_cnt) {
751 - ql_continuation_iocb(pha, cp, seg_cnt, B_TRUE);
810 + ql_continuation_iocb(pha, req_q, cp, seg_cnt, B_TRUE);
752 811 }
753 812
754 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
813 + QL_PRINT_3(ha, "done\n");
755 814 }
756 815
757 816 /*
758 817 * ql_cmd_24xx_type_6_iocb
759 818 * Setup of ISP24xx command type 6 IOCB.
760 819 *
761 820 * Input:
762 821 * ha: adapter state pointer.
822 + * req_q: request queue structure pointer.
763 823 * sp: srb structure pointer.
764 824 * arg: request queue packet.
765 825 *
766 826 * Context:
767 827 * Interrupt or Kernel context, no mailbox commands allowed.
768 828 */
769 829 static void
770 -ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
830 +ql_cmd_24xx_type_6_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q,
831 + ql_srb_t *sp, void *arg)
771 832 {
772 833 uint64_t addr;
773 834 ddi_dma_cookie_t *cp;
774 835 uint32_t *ptr32;
775 836 uint16_t seg_cnt;
776 837 fcp_cmd_t *fcp = sp->fcp;
777 838 ql_tgt_t *tq = sp->lun_queue->target_queue;
778 839 cmd6_24xx_entry_t *pkt = arg;
779 840 ql_adapter_state_t *pha = ha->pha;
780 841 dma_mem_t *cmem = &sp->sg_dma;
781 842 cmd6_2400_dma_t *cdma = cmem->bp;
843 + fcp_ent_addr_t *fcp_ent_addr;
782 844
783 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
845 + QL_PRINT_3(ha, "started\n");
784 846
785 847 pkt->entry_type = IOCB_CMD_TYPE_6;
786 848
787 849 bzero(cdma, sizeof (cmd6_2400_dma_t));
788 850
789 851 /* Set LUN number */
790 - pkt->fcp_lun[2] = cdma->cmd.fcp_lun[1] = LSB(sp->lun_queue->lun_no);
791 - pkt->fcp_lun[3] = cdma->cmd.fcp_lun[0] = MSB(sp->lun_queue->lun_no);
852 + fcp_ent_addr = (fcp_ent_addr_t *)&sp->lun_queue->lun_addr;
853 + pkt->fcp_lun[2] = cdma->cmd.fcp_lun[2] =
854 + lobyte(fcp_ent_addr->ent_addr_0);
855 + pkt->fcp_lun[3] = cdma->cmd.fcp_lun[3] =
856 + hibyte(fcp_ent_addr->ent_addr_0);
857 + pkt->fcp_lun[0] = cdma->cmd.fcp_lun[0] =
858 + lobyte(fcp_ent_addr->ent_addr_1);
859 + pkt->fcp_lun[1] = cdma->cmd.fcp_lun[1] =
860 + hibyte(fcp_ent_addr->ent_addr_1);
861 + pkt->fcp_lun[6] = cdma->cmd.fcp_lun[6] =
862 + lobyte(fcp_ent_addr->ent_addr_2);
863 + pkt->fcp_lun[7] = cdma->cmd.fcp_lun[7] =
864 + hibyte(fcp_ent_addr->ent_addr_2);
865 + pkt->fcp_lun[4] = cdma->cmd.fcp_lun[4] =
866 + lobyte(fcp_ent_addr->ent_addr_3);
867 + pkt->fcp_lun[5] = cdma->cmd.fcp_lun[5] =
868 + hibyte(fcp_ent_addr->ent_addr_3);
792 869
793 870 /* Set N_port handle */
794 - ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
871 + ddi_put16(req_q->req_ring.acc_handle, &pkt->n_port_hdl, tq->loop_id);
795 872
796 873 /* Set target ID */
797 874 pkt->target_id[0] = tq->d_id.b.al_pa;
798 875 pkt->target_id[1] = tq->d_id.b.area;
799 876 pkt->target_id[2] = tq->d_id.b.domain;
800 877
801 878 pkt->vp_index = ha->vp_index;
802 879
803 880 /* Set ISP command timeout. */
804 881 if (sp->isp_timeout < 0x1999) {
805 - ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
882 + ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout,
806 883 sp->isp_timeout);
807 884 }
808 885
809 886 /* Load SCSI CDB */
810 887 ddi_rep_put8(cmem->acc_handle, fcp->fcp_cdb, cdma->cmd.scsi_cdb,
811 888 MAX_CMDSZ, DDI_DEV_AUTOINCR);
812 889
813 890 /*
814 891 * Set tag queue control flags
815 892 * Note:
816 893 * Cannot copy fcp->fcp_cntl.cntl_qtype directly,
817 894 * problem with x86 in 32bit kernel mode
818 895 */
819 896 switch (fcp->fcp_cntl.cntl_qtype) {
820 897 case FCP_QTYPE_SIMPLE:
821 898 cdma->cmd.task = TA_STAG;
822 899 break;
823 900 case FCP_QTYPE_HEAD_OF_Q:
824 901 cdma->cmd.task = TA_HTAG;
825 902 break;
826 903 case FCP_QTYPE_ORDERED:
827 904 cdma->cmd.task = TA_OTAG;
828 905 break;
829 906 case FCP_QTYPE_ACA_Q_TAG:
830 907 cdma->cmd.task = TA_ACA;
831 908 break;
832 909 case FCP_QTYPE_UNTAGGED:
|
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
833 910 cdma->cmd.task = TA_UNTAGGED;
834 911 break;
835 912 default:
836 913 break;
837 914 }
838 915
839 916 /*
840 917 * FCP_CMND Payload Data Segment
841 918 */
842 919 cp = cmem->cookies;
843 - ddi_put16(pha->hba_buf.acc_handle, &pkt->cmnd_length,
920 + ddi_put16(req_q->req_ring.acc_handle, &pkt->cmnd_length,
844 921 sizeof (fcp_cmnd_t));
845 - ddi_put32(pha->hba_buf.acc_handle, &pkt->cmnd_address[0],
922 + ddi_put32(req_q->req_ring.acc_handle, &pkt->cmnd_address[0],
846 923 cp->dmac_address);
847 - ddi_put32(pha->hba_buf.acc_handle, &pkt->cmnd_address[1],
924 + ddi_put32(req_q->req_ring.acc_handle, &pkt->cmnd_address[1],
848 925 cp->dmac_notused);
849 926
850 927 /* Set transfer direction. */
851 928 if (fcp->fcp_cntl.cntl_write_data) {
852 929 pkt->control_flags = (uint8_t)(CF_DSD_PTR | CF_WR);
853 930 cdma->cmd.control_flags = CF_WR;
854 931 pha->xioctl->IOOutputRequests++;
855 932 pha->xioctl->IOOutputByteCnt += fcp->fcp_data_len;
856 933 } else if (fcp->fcp_cntl.cntl_read_data) {
857 934 pkt->control_flags = (uint8_t)(CF_DSD_PTR | CF_RD);
858 935 cdma->cmd.control_flags = CF_RD;
859 936 pha->xioctl->IOInputRequests++;
860 937 pha->xioctl->IOInputByteCnt += fcp->fcp_data_len;
861 938 }
862 939
863 940 /*
864 941 * FCP_DATA Data Segment Descriptor.
865 942 */
866 943 addr = cp->dmac_laddress + sizeof (fcp_cmnd_t);
867 - ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_address[0], LSD(addr));
868 - ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_address[1], MSD(addr));
944 + ddi_put32(req_q->req_ring.acc_handle, &pkt->dseg.address[0], LSD(addr));
945 + ddi_put32(req_q->req_ring.acc_handle, &pkt->dseg.address[1], MSD(addr));
869 946
870 947 /* Set data segment count. */
871 948 seg_cnt = (uint16_t)sp->pkt->pkt_data_cookie_cnt;
872 - ddi_put16(pha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
873 - ddi_put32(pha->hba_buf.acc_handle, &pkt->dseg_0_length,
949 + ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
950 + ddi_put32(req_q->req_ring.acc_handle, &pkt->dseg.length,
874 951 seg_cnt * 12 + 12);
875 952
876 953 /* Load total byte count. */
877 - ddi_put32(pha->hba_buf.acc_handle, &pkt->total_byte_count,
954 + ddi_put32(req_q->req_ring.acc_handle, &pkt->total_byte_count,
878 955 fcp->fcp_data_len);
879 956 ddi_put32(cmem->acc_handle, &cdma->cmd.dl, (uint32_t)fcp->fcp_data_len);
880 957 ql_chg_endian((uint8_t *)&cdma->cmd.dl, 4);
881 958
882 959 /* Load command data segments. */
883 960 ptr32 = (uint32_t *)cdma->cookie_list;
884 961 cp = sp->pkt->pkt_data_cookie;
885 962 while (seg_cnt--) {
886 963 ddi_put32(cmem->acc_handle, ptr32++, cp->dmac_address);
887 964 ddi_put32(cmem->acc_handle, ptr32++, cp->dmac_notused);
888 965 ddi_put32(cmem->acc_handle, ptr32++, (uint32_t)cp->dmac_size);
889 966 cp++;
890 967 }
891 968
892 969 /* Sync DMA buffer. */
893 970 (void) ddi_dma_sync(cmem->dma_handle, 0, 0, DDI_DMA_SYNC_FORDEV);
894 971
895 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
972 + QL_PRINT_3(ha, "done\n");
896 973 }
897 974
898 975 /*
899 976 * ql_marker
900 977 * Function issues marker IOCB.
901 978 *
902 979 * Input:
903 980 * ha: adapter state pointer.
904 981 * loop_id: device loop ID
905 - * lun: device LUN
982 + * lq: LUN queue pointer.
906 983 * type: marker modifier
907 984 *
908 985 * Returns:
909 986 * ql local function return status code.
910 987 *
911 988 * Context:
912 989 * Interrupt or Kernel context, no mailbox commands allowed.
913 990 */
914 991 int
915 -ql_marker(ql_adapter_state_t *ha, uint16_t loop_id, uint16_t lun,
992 +ql_marker(ql_adapter_state_t *ha, uint16_t loop_id, ql_lun_t *lq,
916 993 uint8_t type)
917 994 {
918 995 mrk_entry_t *pkt;
919 996 int rval;
997 + ql_request_q_t *req_q = ha->req_q[0];
998 + fcp_ent_addr_t *fcp_ent_addr;
920 999
921 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
1000 + QL_PRINT_3(ha, "started\n");
922 1001
923 - rval = ql_req_pkt(ha, (request_t **)&pkt);
1002 + rval = ql_req_pkt(ha, req_q, (request_t **)&pkt);
924 1003 if (rval == QL_SUCCESS) {
925 1004 pkt->entry_type = MARKER_TYPE;
926 1005
927 - if (CFG_IST(ha, CFG_CTRL_24258081)) {
1006 + if (CFG_IST(ha, CFG_ISP_FW_TYPE_2)) {
928 1007 marker_24xx_entry_t *pkt24 =
929 1008 (marker_24xx_entry_t *)pkt;
930 1009
931 1010 pkt24->modifier = type;
932 1011
933 1012 /* Set LUN number */
934 - pkt24->fcp_lun[2] = LSB(lun);
935 - pkt24->fcp_lun[3] = MSB(lun);
1013 + if (lq) {
1014 + fcp_ent_addr = (fcp_ent_addr_t *)&lq->lun_addr;
1015 + pkt24->fcp_lun[2] =
1016 + lobyte(fcp_ent_addr->ent_addr_0);
1017 + pkt24->fcp_lun[3] =
1018 + hibyte(fcp_ent_addr->ent_addr_0);
1019 + pkt24->fcp_lun[0] =
1020 + lobyte(fcp_ent_addr->ent_addr_1);
1021 + pkt24->fcp_lun[1] =
1022 + hibyte(fcp_ent_addr->ent_addr_1);
1023 + pkt24->fcp_lun[6] =
1024 + lobyte(fcp_ent_addr->ent_addr_2);
1025 + pkt24->fcp_lun[7] =
1026 + hibyte(fcp_ent_addr->ent_addr_2);
1027 + pkt24->fcp_lun[4] =
1028 + lobyte(fcp_ent_addr->ent_addr_3);
1029 + pkt24->fcp_lun[5] =
1030 + hibyte(fcp_ent_addr->ent_addr_3);
1031 + }
936 1032
937 1033 pkt24->vp_index = ha->vp_index;
938 1034
939 1035 /* Set N_port handle */
940 - ddi_put16(ha->pha->hba_buf.acc_handle,
1036 + ddi_put16(req_q->req_ring.acc_handle,
941 1037 &pkt24->n_port_hdl, loop_id);
942 1038
943 1039 } else {
944 1040 pkt->modifier = type;
945 1041
946 - pkt->lun_l = LSB(lun);
947 - pkt->lun_h = MSB(lun);
1042 + if (lq) {
1043 + pkt->lun_l = LSB(lq->lun_no);
1044 + pkt->lun_h = MSB(lq->lun_no);
1045 + }
948 1046
949 1047 if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
950 1048 pkt->target_l = LSB(loop_id);
951 1049 pkt->target_h = MSB(loop_id);
952 1050 } else {
953 1051 pkt->target_h = LSB(loop_id);
954 1052 }
955 1053 }
956 1054
957 1055 /* Issue command to ISP */
958 - ql_isp_cmd(ha);
1056 + ql_isp_cmd(ha, req_q);
959 1057 }
960 1058
961 1059 if (rval != QL_SUCCESS) {
962 1060 EL(ha, "failed, rval = %xh\n", rval);
963 1061 } else {
964 1062 /*EMPTY*/
965 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
1063 + QL_PRINT_3(ha, "done\n");
966 1064 }
967 1065 return (rval);
968 1066 }
969 1067
970 1068 /*
971 1069 * ql_ms_iocb
972 1070 * Setup of name/management server IOCB.
973 1071 *
974 1072 * Input:
975 - * ha = adapter state pointer.
976 - * sp = srb structure pointer.
977 - * arg = request queue packet.
1073 + * ha: adapter state pointer.
1074 + * req_q: request queue structure pointer.
1075 + * sp: srb structure pointer.
1076 + * arg: request queue packet.
978 1077 *
979 1078 * Context:
980 1079 * Interrupt or Kernel context, no mailbox commands allowed.
981 1080 */
982 1081 void
983 -ql_ms_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
1082 +ql_ms_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
1083 + void *arg)
984 1084 {
985 1085 ddi_dma_cookie_t *cp;
986 1086 uint32_t *ptr32;
987 1087 uint16_t seg_cnt;
988 1088 ql_tgt_t *tq = sp->lun_queue->target_queue;
989 1089 ms_entry_t *pkt = arg;
990 1090
991 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
1091 + QL_PRINT_3(ha, "started\n");
992 1092 QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
993 1093 /*
994 1094 * Build command packet.
995 1095 */
996 1096 pkt->entry_type = MS_TYPE;
997 1097
998 1098 /* Set loop ID */
999 1099 if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
1000 1100 pkt->loop_id_l = LSB(tq->loop_id);
1001 1101 pkt->loop_id_h = MSB(tq->loop_id);
1002 1102 } else {
1003 1103 pkt->loop_id_h = LSB(tq->loop_id);
1004 1104 }
1005 1105
1006 1106 /* Set ISP command timeout. */
1007 - ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
1107 + ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout, sp->isp_timeout);
1008 1108
1009 1109 /* Set cmd data segment count. */
1010 1110 pkt->cmd_dseg_count_l = 1;
1011 1111
1012 1112 /* Set total data segment count */
1013 1113 seg_cnt = (uint16_t)(sp->pkt->pkt_resp_cookie_cnt + 1);
1014 - ddi_put16(ha->hba_buf.acc_handle, &pkt->total_dseg_count, seg_cnt);
1114 + ddi_put16(req_q->req_ring.acc_handle, &pkt->total_dseg_count, seg_cnt);
1015 1115
1016 1116 /* Load ct cmd byte count. */
1017 - ddi_put32(ha->hba_buf.acc_handle, &pkt->cmd_byte_count,
1117 + ddi_put32(req_q->req_ring.acc_handle, &pkt->cmd_byte_count,
1018 1118 (uint32_t)sp->pkt->pkt_cmdlen);
1019 1119
1020 1120 /* Load ct rsp byte count. */
1021 - ddi_put32(ha->hba_buf.acc_handle, &pkt->resp_byte_count,
1121 + ddi_put32(req_q->req_ring.acc_handle, &pkt->resp_byte_count,
1022 1122 (uint32_t)sp->pkt->pkt_rsplen);
1023 1123
1024 1124 /* Load MS command data segments. */
1025 - ptr32 = (uint32_t *)&pkt->dseg_0_address;
1125 + ptr32 = (uint32_t *)&pkt->dseg;
1026 1126 cp = sp->pkt->pkt_cmd_cookie;
1027 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
1028 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
1029 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
1127 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
1128 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
1129 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
1030 1130 seg_cnt--;
1031 1131
1032 1132 /* Load MS response entry data segments. */
1033 1133 cp = sp->pkt->pkt_resp_cookie;
1034 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
1035 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
1036 - ddi_put32(ha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
1134 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
1135 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
1136 + ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
1037 1137 seg_cnt--;
1038 1138 cp++;
1039 1139
1040 1140 /*
1041 1141 * Build continuation packets.
1042 1142 */
1043 1143 if (seg_cnt) {
1044 - ql_continuation_iocb(ha, cp, seg_cnt, B_TRUE);
1144 + ql_continuation_iocb(ha, req_q, cp, seg_cnt, B_TRUE);
1045 1145 }
1046 1146
1047 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
1147 + QL_PRINT_3(ha, "done\n");
1048 1148 }
1049 1149
1050 1150 /*
1051 1151 * ql_ms_24xx_iocb
1052 1152 * Setup of name/management server IOCB.
1053 1153 *
1054 1154 * Input:
1055 1155 * ha: adapter state pointer.
1156 + * req_q: request queue structure pointer.
1056 1157 * sp: srb structure pointer.
1057 1158 * arg: request queue packet.
1058 1159 *
1059 1160 * Context:
1060 1161 * Interrupt or Kernel context, no mailbox commands allowed.
1061 1162 */
1062 1163 void
1063 -ql_ms_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
1164 +ql_ms_24xx_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
1165 + void *arg)
1064 1166 {
1065 1167 ddi_dma_cookie_t *cp;
1066 1168 uint32_t *ptr32;
1067 1169 uint16_t seg_cnt;
1068 1170 ql_tgt_t *tq = sp->lun_queue->target_queue;
1069 1171 ct_passthru_entry_t *pkt = arg;
1070 1172 ql_adapter_state_t *pha = ha->pha;
1071 1173
1072 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
1174 + QL_PRINT_3(ha, "started\n");
1073 1175 QL_DUMP_3(sp->pkt->pkt_cmd, 8, sp->pkt->pkt_cmdlen);
1074 1176 /*
1075 1177 * Build command packet.
1076 1178 */
1077 1179 pkt->entry_type = CT_PASSTHRU_TYPE;
1078 1180
1079 1181 /* Set loop ID */
1080 - ddi_put16(pha->hba_buf.acc_handle, &pkt->n_port_hdl, tq->loop_id);
1182 + ddi_put16(req_q->req_ring.acc_handle, &pkt->n_port_hdl, tq->loop_id);
1081 1183
1082 1184 pkt->vp_index = ha->vp_index;
1083 1185
1084 1186 /* Set ISP command timeout. */
1085 1187 if (sp->isp_timeout < 0x1999) {
1086 - ddi_put16(pha->hba_buf.acc_handle, &pkt->timeout,
1188 + ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout,
1087 1189 sp->isp_timeout);
1088 1190 }
1089 1191
1090 1192 /* Set cmd/response data segment counts. */
1091 - ddi_put16(pha->hba_buf.acc_handle, &pkt->cmd_dseg_count, 1);
1193 + ddi_put16(req_q->req_ring.acc_handle, &pkt->cmd_dseg_count, 1);
1092 1194 seg_cnt = (uint16_t)sp->pkt->pkt_resp_cookie_cnt;
1093 - ddi_put16(pha->hba_buf.acc_handle, &pkt->resp_dseg_count, seg_cnt);
1195 + ddi_put16(req_q->req_ring.acc_handle, &pkt->resp_dseg_count, seg_cnt);
1094 1196
1095 1197 /* Load ct cmd byte count. */
1096 - ddi_put32(pha->hba_buf.acc_handle, &pkt->cmd_byte_count,
1198 + ddi_put32(req_q->req_ring.acc_handle, &pkt->cmd_byte_count,
1097 1199 (uint32_t)sp->pkt->pkt_cmdlen);
1098 1200
1099 1201 /* Load ct rsp byte count. */
1100 - ddi_put32(pha->hba_buf.acc_handle, &pkt->resp_byte_count,
1202 + ddi_put32(req_q->req_ring.acc_handle, &pkt->resp_byte_count,
1101 1203 (uint32_t)sp->pkt->pkt_rsplen);
1102 1204
1103 1205 /* Load MS command entry data segments. */
1104 - ptr32 = (uint32_t *)&pkt->dseg_0_address;
1206 + ptr32 = (uint32_t *)&pkt->dseg;
1105 1207 cp = sp->pkt->pkt_cmd_cookie;
1106 - ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
1107 - ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
1108 - ddi_put32(pha->hba_buf.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
1208 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
1209 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
1210 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, (uint32_t)cp->dmac_size);
1109 1211
1110 1212 /* Load MS response entry data segments. */
1111 1213 cp = sp->pkt->pkt_resp_cookie;
1112 - ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
1113 - ddi_put32(pha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
1114 - ddi_put32(pha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
1214 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
1215 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
1216 + ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
1115 1217 seg_cnt--;
1116 1218 cp++;
1117 1219
1118 1220 /*
1119 1221 * Build continuation packets.
1120 1222 */
1121 1223 if (seg_cnt) {
1122 - ql_continuation_iocb(pha, cp, seg_cnt, B_TRUE);
1224 + ql_continuation_iocb(pha, req_q, cp, seg_cnt, B_TRUE);
1123 1225 }
1124 1226
1125 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
1227 + QL_PRINT_3(ha, "done\n");
1126 1228 }
1127 1229
1128 1230 /*
1129 1231 * ql_ip_iocb
1130 1232 * Setup of IP IOCB.
1131 1233 *
1132 1234 * Input:
1133 1235 * ha: adapter state pointer.
1236 + * req_q: request queue structure pointer.
1134 1237 * sp: srb structure pointer.
1135 1238 * arg: request queue packet.
1136 1239 *
1137 1240 * Context:
1138 1241 * Interrupt or Kernel context, no mailbox commands allowed.
1139 1242 */
1140 1243 void
1141 -ql_ip_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
1244 +ql_ip_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
1245 + void *arg)
1142 1246 {
1143 1247 ddi_dma_cookie_t *cp;
1144 1248 uint32_t *ptr32, cnt;
1145 1249 uint16_t seg_cnt;
1146 1250 ql_tgt_t *tq = sp->lun_queue->target_queue;
1147 1251 ip_entry_t *pkt = arg;
1252 + ip_a64_entry_t *pkt64 = arg;
1148 1253
1149 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
1254 + QL_PRINT_3(ha, "started\n");
1150 1255
1151 1256 /* Set loop ID */
1152 1257 if (CFG_IST(ha, CFG_EXT_FW_INTERFACE)) {
1153 1258 pkt->loop_id_l = LSB(tq->loop_id);
1154 1259 pkt->loop_id_h = MSB(tq->loop_id);
1155 1260 } else {
1156 1261 pkt->loop_id_h = LSB(tq->loop_id);
1157 1262 }
1158 1263
1159 1264 /* Set control flags */
1160 1265 pkt->control_flags_l = BIT_6;
1161 1266 if (sp->pkt->pkt_tran_flags & FC_TRAN_HI_PRIORITY) {
1162 1267 pkt->control_flags_h = BIT_7;
1163 1268 }
1164 1269
1165 1270 /* Set ISP command timeout. */
1166 - ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout, sp->isp_timeout);
1271 + ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout, sp->isp_timeout);
1167 1272
1168 1273 /* Set data segment count. */
1169 1274 seg_cnt = (uint16_t)sp->pkt->pkt_cmd_cookie_cnt;
1170 1275 /* Load total byte count. */
1171 - ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count,
1276 + ddi_put32(req_q->req_ring.acc_handle, &pkt->byte_count,
1172 1277 (uint32_t)sp->pkt->pkt_cmdlen);
1173 - ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
1278 + ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
1174 1279
1175 1280 /*
1176 1281 * Build command packet.
1177 1282 */
1283 +
1284 + /* Load command entry data segments. */
1285 + cp = sp->pkt->pkt_cmd_cookie;
1286 +
1178 1287 if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
1179 - pkt->entry_type = IP_A64_TYPE;
1288 + pkt64->entry_type = IP_A64_TYPE;
1180 1289 cnt = IP_A64_DATA_SEGMENTS;
1290 + ptr32 = (uint32_t *)&pkt64->dseg;
1291 + while (cnt && seg_cnt) {
1292 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
1293 + cp->dmac_address);
1294 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
1295 + cp->dmac_notused);
1296 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
1297 + (uint32_t)cp->dmac_size);
1298 + seg_cnt--;
1299 + cnt--;
1300 + cp++;
1301 + }
1181 1302 } else {
1182 1303 pkt->entry_type = IP_TYPE;
1183 1304 cnt = IP_DATA_SEGMENTS;
1184 - }
1185 -
1186 - /* Load command entry data segments. */
1187 - ptr32 = (uint32_t *)&pkt->dseg_0_address;
1188 - cp = sp->pkt->pkt_cmd_cookie;
1189 - while (cnt && seg_cnt) {
1190 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
1191 - if (CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)) {
1192 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
1193 - cp->dmac_notused);
1305 + ptr32 = (uint32_t *)&pkt->dseg;
1306 + while (cnt && seg_cnt) {
1307 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
1308 + cp->dmac_address);
1309 + ddi_put32(req_q->req_ring.acc_handle, ptr32++,
1310 + (uint32_t)cp->dmac_size);
1311 + seg_cnt--;
1312 + cnt--;
1313 + cp++;
1194 1314 }
1195 - ddi_put32(ha->hba_buf.acc_handle, ptr32++,
1196 - (uint32_t)cp->dmac_size);
1197 - seg_cnt--;
1198 - cnt--;
1199 - cp++;
1200 1315 }
1201 1316
1202 1317 /*
1203 1318 * Build continuation packets.
1204 1319 */
1205 1320 if (seg_cnt) {
1206 - ql_continuation_iocb(ha, cp, seg_cnt,
1321 + ql_continuation_iocb(ha, req_q, cp, seg_cnt,
1207 1322 (boolean_t)(CFG_IST(ha, CFG_ENABLE_64BIT_ADDRESSING)));
1208 1323 }
1209 1324
1210 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
1325 + QL_PRINT_3(ha, "done\n");
1211 1326 }
1212 1327
1213 1328 /*
1214 1329 * ql_ip_24xx_iocb
1215 1330 * Setup of IP IOCB for ISP24xx.
1216 1331 *
1217 1332 * Input:
1218 1333 * ha: adapter state pointer.
1334 + * req_q: request queue structure pointer.
1219 1335 * sp: srb structure pointer.
1220 1336 * arg: request queue packet.
1221 1337 *
1222 1338 * Context:
1223 1339 * Interrupt or Kernel context, no mailbox commands allowed.
1224 1340 */
1225 1341 void
1226 -ql_ip_24xx_iocb(ql_adapter_state_t *ha, ql_srb_t *sp, void *arg)
1342 +ql_ip_24xx_iocb(ql_adapter_state_t *ha, ql_request_q_t *req_q, ql_srb_t *sp,
1343 + void *arg)
1227 1344 {
1228 1345 ddi_dma_cookie_t *cp;
1229 1346 uint32_t *ptr32;
1230 1347 uint16_t seg_cnt;
1231 1348 ql_tgt_t *tq = sp->lun_queue->target_queue;
1232 1349 ip_cmd_entry_t *pkt = arg;
1233 1350
1234 1351 pkt->entry_type = IP_CMD_TYPE;
1235 1352
1236 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
1353 + QL_PRINT_3(ha, "started\n");
1237 1354
1238 1355 /* Set N_port handle */
1239 - ddi_put16(ha->hba_buf.acc_handle, &pkt->hdl_status, tq->loop_id);
1356 + ddi_put16(req_q->req_ring.acc_handle, &pkt->hdl_status, tq->loop_id);
1240 1357
1241 1358 /* Set ISP command timeout. */
1242 1359 if (sp->isp_timeout < 0x1999) {
1243 - ddi_put16(ha->hba_buf.acc_handle, &pkt->timeout_hdl,
1360 + ddi_put16(req_q->req_ring.acc_handle, &pkt->timeout_hdl,
1244 1361 sp->isp_timeout);
1245 1362 }
1246 1363
1247 1364 /* Set data segment count. */
1248 1365 seg_cnt = (uint16_t)sp->pkt->pkt_cmd_cookie_cnt;
1249 1366 /* Load total byte count. */
1250 - ddi_put32(ha->hba_buf.acc_handle, &pkt->byte_count,
1367 + ddi_put32(req_q->req_ring.acc_handle, &pkt->byte_count,
1251 1368 (uint32_t)sp->pkt->pkt_cmdlen);
1252 - ddi_put16(ha->hba_buf.acc_handle, &pkt->dseg_count, seg_cnt);
1369 + ddi_put16(req_q->req_ring.acc_handle, &pkt->dseg_count, seg_cnt);
1253 1370
1254 1371 /* Set control flags */
1255 - ddi_put16(ha->hba_buf.acc_handle, &pkt->control_flags,
1372 + ddi_put16(req_q->req_ring.acc_handle, &pkt->control_flags,
1256 1373 (uint16_t)(BIT_0));
1257 1374
1258 1375 /* Set frame header control flags */
1259 - ddi_put16(ha->hba_buf.acc_handle, &pkt->frame_hdr_cntrl_flgs,
1376 + ddi_put16(req_q->req_ring.acc_handle, &pkt->frame_hdr_cntrl_flgs,
1260 1377 (uint16_t)(IPCF_LAST_SEQ | IPCF_FIRST_SEQ));
1261 1378
1262 1379 /* Load command data segment. */
1263 - ptr32 = (uint32_t *)&pkt->dseg_0_address;
1380 + ptr32 = (uint32_t *)&pkt->dseg;
1264 1381 cp = sp->pkt->pkt_cmd_cookie;
1265 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_address);
1266 - ddi_put32(ha->hba_buf.acc_handle, ptr32++, cp->dmac_notused);
1267 - ddi_put32(ha->hba_buf.acc_handle, ptr32, (uint32_t)cp->dmac_size);
1382 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_address);
1383 + ddi_put32(req_q->req_ring.acc_handle, ptr32++, cp->dmac_notused);
1384 + ddi_put32(req_q->req_ring.acc_handle, ptr32, (uint32_t)cp->dmac_size);
1268 1385 seg_cnt--;
1269 1386 cp++;
1270 1387
1271 1388 /*
1272 1389 * Build continuation packets.
1273 1390 */
1274 1391 if (seg_cnt) {
1275 - ql_continuation_iocb(ha, cp, seg_cnt, B_TRUE);
1392 + ql_continuation_iocb(ha, req_q, cp, seg_cnt, B_TRUE);
1276 1393 }
1277 1394
1278 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
1395 + QL_PRINT_3(ha, "done\n");
1279 1396 }
1280 1397
1281 1398 /*
1282 1399 * ql_isp_rcvbuf
1283 1400 * Locates free buffers and places it on the receive buffer queue.
1284 1401 *
1285 1402 * Input:
1286 1403 * ha = adapter state pointer.
1287 1404 *
1288 1405 * Context:
1289 1406 * Interrupt or Kernel context, no mailbox commands allowed.
1290 1407 */
1291 1408 void
1292 1409 ql_isp_rcvbuf(ql_adapter_state_t *ha)
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
1293 1410 {
1294 1411 rcvbuf_t *container;
1295 1412 uint16_t rcv_q_cnt;
1296 1413 uint16_t index = 0;
1297 1414 uint16_t index1 = 1;
1298 1415 int debounce_count = QL_MAX_DEBOUNCE;
1299 1416 ql_srb_t *sp;
1300 1417 fc_unsol_buf_t *ubp;
1301 1418 int ring_updated = FALSE;
1302 1419
1303 - if (CFG_IST(ha, CFG_CTRL_24258081)) {
1420 + if (CFG_IST(ha, CFG_CTRL_24XX)) {
1304 1421 ql_isp24xx_rcvbuf(ha);
1305 1422 return;
1306 1423 }
1307 1424
1308 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
1425 + QL_PRINT_3(ha, "started\n");
1309 1426
1310 1427 /* Acquire adapter state lock. */
1311 1428 ADAPTER_STATE_LOCK(ha);
1312 1429
1313 1430 /* Calculate number of free receive buffer entries. */
1314 1431 index = RD16_IO_REG(ha, mailbox_out[8]);
1315 1432 do {
1316 1433 index1 = RD16_IO_REG(ha, mailbox_out[8]);
1317 1434 if (index1 == index) {
1318 1435 break;
1319 1436 } else {
1320 1437 index = index1;
1321 1438 }
1322 - } while (debounce_count --);
1439 + } while (debounce_count--);
1323 1440
1324 1441 if (debounce_count < 0) {
1325 1442 /* This should never happen */
1326 1443 EL(ha, "max mb8 debounce retries exceeded\n");
1327 1444 }
1328 1445
1329 1446 rcv_q_cnt = (uint16_t)(ha->rcvbuf_ring_index < index ?
1330 1447 index - ha->rcvbuf_ring_index : RCVBUF_CONTAINER_CNT -
1331 1448 (ha->rcvbuf_ring_index - index));
1332 1449
1333 1450 if (rcv_q_cnt == RCVBUF_CONTAINER_CNT) {
1334 1451 rcv_q_cnt--;
1335 1452 }
1336 1453
1337 1454 /* Load all free buffers in ISP receive buffer ring. */
1338 1455 index = 0;
1339 1456 while (rcv_q_cnt > (uint16_t)0 && index < QL_UB_LIMIT) {
1340 1457 /* Locate a buffer to give. */
1341 1458 QL_UB_LOCK(ha);
1342 1459 while (index < QL_UB_LIMIT) {
1343 1460 ubp = ha->ub_array[index];
1344 1461 if (ubp != NULL) {
1345 1462 sp = ubp->ub_fca_private;
1346 1463 if ((sp->ub_type == FC_TYPE_IS8802_SNAP) &&
1347 1464 (ha->flags & IP_INITIALIZED) &&
1348 1465 (sp->flags & SRB_UB_IN_FCA) &&
1349 1466 (!(sp->flags & (SRB_UB_IN_ISP |
1350 1467 SRB_UB_FREE_REQUESTED | SRB_UB_CALLBACK |
1351 1468 SRB_UB_ACQUIRED)))) {
1352 1469 sp->flags |= SRB_UB_IN_ISP;
1353 1470 break;
1354 1471 }
1355 1472 }
1356 1473 index++;
|
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
1357 1474 }
1358 1475
1359 1476 if (index < QL_UB_LIMIT) {
1360 1477 rcv_q_cnt--;
1361 1478 index++;
1362 1479 container = ha->rcvbuf_ring_ptr;
1363 1480
1364 1481 /*
1365 1482 * Build container.
1366 1483 */
1367 - ddi_put32(ha->hba_buf.acc_handle,
1484 + ddi_put32(ha->rcv_ring.acc_handle,
1368 1485 (uint32_t *)(void *)&container->bufp[0],
1369 1486 sp->ub_buffer.cookie.dmac_address);
1370 1487
1371 - ddi_put32(ha->hba_buf.acc_handle,
1488 + ddi_put32(ha->rcv_ring.acc_handle,
1372 1489 (uint32_t *)(void *)&container->bufp[1],
1373 1490 sp->ub_buffer.cookie.dmac_notused);
1374 1491
1375 - ddi_put16(ha->hba_buf.acc_handle, &container->handle,
1492 + ddi_put16(ha->rcv_ring.acc_handle, &container->handle,
1376 1493 LSW(sp->handle));
1377 1494
1378 1495 ha->ub_outcnt++;
1379 1496
1380 1497 /* Adjust ring index. */
1381 1498 ha->rcvbuf_ring_index++;
1382 1499 if (ha->rcvbuf_ring_index == RCVBUF_CONTAINER_CNT) {
1383 1500 ha->rcvbuf_ring_index = 0;
1384 - ha->rcvbuf_ring_ptr = ha->rcvbuf_ring_bp;
1501 + ha->rcvbuf_ring_ptr = ha->rcv_ring.bp;
1385 1502 } else {
1386 1503 ha->rcvbuf_ring_ptr++;
1387 1504 }
1388 1505
1389 1506 ring_updated = TRUE;
1390 1507 }
1391 1508 QL_UB_UNLOCK(ha);
1392 1509 }
1393 1510
1394 1511 if (ring_updated) {
1395 1512 /* Sync queue. */
1396 - (void) ddi_dma_sync(ha->hba_buf.dma_handle,
1397 - (off_t)RCVBUF_Q_BUFFER_OFFSET, (size_t)RCVBUF_QUEUE_SIZE,
1398 - DDI_DMA_SYNC_FORDEV);
1513 + (void) ddi_dma_sync(ha->rcv_ring.dma_handle, 0,
1514 + (size_t)RCVBUF_QUEUE_SIZE, DDI_DMA_SYNC_FORDEV);
1399 1515
1400 1516 /* Set chip new ring index. */
1401 1517 WRT16_IO_REG(ha, mailbox_in[8], ha->rcvbuf_ring_index);
1402 1518 }
1403 1519
1404 1520 /* Release adapter state lock. */
1405 1521 ADAPTER_STATE_UNLOCK(ha);
1406 1522
1407 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
1523 + QL_PRINT_3(ha, "done\n");
1408 1524 }
1409 1525
1410 1526 /*
1411 1527 * ql_isp24xx_rcvbuf
1412 1528 * Locates free buffers and send it to adapter.
1413 1529 *
1414 1530 * Input:
1415 1531 * ha = adapter state pointer.
1416 1532 *
1417 1533 * Context:
1418 1534 * Interrupt or Kernel context, no mailbox commands allowed.
|
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
1419 1535 */
1420 1536 static void
1421 1537 ql_isp24xx_rcvbuf(ql_adapter_state_t *ha)
1422 1538 {
1423 1539 rcvbuf_t *container;
1424 1540 uint16_t index;
1425 1541 ql_srb_t *sp;
1426 1542 fc_unsol_buf_t *ubp;
1427 1543 int rval;
1428 1544 ip_buf_pool_entry_t *pkt = NULL;
1545 + ql_request_q_t *req_q = ha->req_q[0];
1429 1546
1430 - QL_PRINT_3(CE_CONT, "(%d): started\n", ha->instance);
1547 + QL_PRINT_3(ha, "started\n");
1431 1548
1432 1549 for (;;) {
1433 1550 /* Locate a buffer to give. */
1434 1551 QL_UB_LOCK(ha);
1435 1552 for (index = 0; index < QL_UB_LIMIT; index++) {
1436 1553 ubp = ha->ub_array[index];
1437 1554 if (ubp != NULL) {
1438 1555 sp = ubp->ub_fca_private;
1439 1556 if ((sp->ub_type == FC_TYPE_IS8802_SNAP) &&
1440 1557 (ha->flags & IP_INITIALIZED) &&
1441 1558 (sp->flags & SRB_UB_IN_FCA) &&
1442 1559 (!(sp->flags & (SRB_UB_IN_ISP |
1443 1560 SRB_UB_FREE_REQUESTED | SRB_UB_CALLBACK |
1444 1561 SRB_UB_ACQUIRED)))) {
1445 1562 ha->ub_outcnt++;
1446 1563 sp->flags |= SRB_UB_IN_ISP;
1447 1564 break;
|
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
1448 1565 }
1449 1566 }
1450 1567 }
1451 1568 QL_UB_UNLOCK(ha);
1452 1569 if (index == QL_UB_LIMIT) {
1453 1570 break;
1454 1571 }
1455 1572
1456 1573 /* Get IOCB packet for buffers. */
1457 1574 if (pkt == NULL) {
1458 - rval = ql_req_pkt(ha, (request_t **)&pkt);
1575 + rval = ql_req_pkt(ha, req_q, (request_t **)&pkt);
1459 1576 if (rval != QL_SUCCESS) {
1460 1577 EL(ha, "failed, ql_req_pkt=%x\n", rval);
1461 1578 QL_UB_LOCK(ha);
1462 1579 ha->ub_outcnt--;
1463 1580 sp->flags &= ~SRB_UB_IN_ISP;
1464 1581 QL_UB_UNLOCK(ha);
1465 1582 break;
1466 1583 }
1467 1584 pkt->entry_type = IP_BUF_POOL_TYPE;
1468 1585 container = &pkt->buffers[0];
1469 1586 }
1470 1587
1471 1588 /*
1472 1589 * Build container.
1473 1590 */
1474 - ddi_put32(ha->hba_buf.acc_handle, &container->bufp[0],
1591 + ddi_put32(req_q->req_ring.acc_handle, &container->bufp[0],
1475 1592 sp->ub_buffer.cookie.dmac_address);
1476 - ddi_put32(ha->hba_buf.acc_handle, &container->bufp[1],
1593 + ddi_put32(req_q->req_ring.acc_handle, &container->bufp[1],
1477 1594 sp->ub_buffer.cookie.dmac_notused);
1478 - ddi_put16(ha->hba_buf.acc_handle, &container->handle,
1595 + ddi_put16(req_q->req_ring.acc_handle, &container->handle,
1479 1596 LSW(sp->handle));
1480 1597
1481 1598 pkt->buffer_count++;
1482 1599 container++;
1483 1600
1484 1601 if (pkt->buffer_count == IP_POOL_BUFFERS) {
1485 - ql_isp_cmd(ha);
1602 + ql_isp_cmd(ha, req_q);
1486 1603 pkt = NULL;
1487 1604 }
1488 1605 }
1489 1606
1490 1607 if (pkt != NULL) {
1491 - ql_isp_cmd(ha);
1608 + ql_isp_cmd(ha, req_q);
1492 1609 }
1493 1610
1494 - QL_PRINT_3(CE_CONT, "(%d): done\n", ha->instance);
1611 + QL_PRINT_3(ha, "done\n");
1495 1612 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX