aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/qla_iocb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_iocb.c')
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c258
1 files changed, 134 insertions, 124 deletions
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 85bc0a48598b..0c145c9e0cd9 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -11,8 +11,8 @@
11 11
12#include <scsi/scsi_tcq.h> 12#include <scsi/scsi_tcq.h>
13 13
14static request_t *qla2x00_req_pkt(scsi_qla_host_t *ha); 14static request_t *qla2x00_req_pkt(scsi_qla_host_t *);
15static void qla2x00_isp_cmd(scsi_qla_host_t *ha); 15static void qla2x00_isp_cmd(scsi_qla_host_t *);
16 16
17/** 17/**
18 * qla2x00_get_cmd_direction() - Determine control_flag data direction. 18 * qla2x00_get_cmd_direction() - Determine control_flag data direction.
@@ -30,11 +30,11 @@ qla2x00_get_cmd_direction(srb_t *sp)
30 /* Set transfer direction */ 30 /* Set transfer direction */
31 if (sp->cmd->sc_data_direction == DMA_TO_DEVICE) { 31 if (sp->cmd->sc_data_direction == DMA_TO_DEVICE) {
32 cflags = CF_WRITE; 32 cflags = CF_WRITE;
33 sp->fcport->ha->qla_stats.output_bytes += 33 sp->fcport->vha->hw->qla_stats.output_bytes +=
34 scsi_bufflen(sp->cmd); 34 scsi_bufflen(sp->cmd);
35 } else if (sp->cmd->sc_data_direction == DMA_FROM_DEVICE) { 35 } else if (sp->cmd->sc_data_direction == DMA_FROM_DEVICE) {
36 cflags = CF_READ; 36 cflags = CF_READ;
37 sp->fcport->ha->qla_stats.input_bytes += 37 sp->fcport->vha->hw->qla_stats.input_bytes +=
38 scsi_bufflen(sp->cmd); 38 scsi_bufflen(sp->cmd);
39 } 39 }
40 return (cflags); 40 return (cflags);
@@ -91,20 +91,20 @@ qla2x00_calc_iocbs_64(uint16_t dsds)
91 * Returns a pointer to the Continuation Type 0 IOCB packet. 91 * Returns a pointer to the Continuation Type 0 IOCB packet.
92 */ 92 */
93static inline cont_entry_t * 93static inline cont_entry_t *
94qla2x00_prep_cont_type0_iocb(scsi_qla_host_t *ha) 94qla2x00_prep_cont_type0_iocb(scsi_qla_host_t *vha)
95{ 95{
96 cont_entry_t *cont_pkt; 96 cont_entry_t *cont_pkt;
97 97 struct req_que *req = vha->hw->req;
98 /* Adjust ring index. */ 98 /* Adjust ring index. */
99 ha->req_ring_index++; 99 req->ring_index++;
100 if (ha->req_ring_index == ha->request_q_length) { 100 if (req->ring_index == req->length) {
101 ha->req_ring_index = 0; 101 req->ring_index = 0;
102 ha->request_ring_ptr = ha->request_ring; 102 req->ring_ptr = req->ring;
103 } else { 103 } else {
104 ha->request_ring_ptr++; 104 req->ring_ptr++;
105 } 105 }
106 106
107 cont_pkt = (cont_entry_t *)ha->request_ring_ptr; 107 cont_pkt = (cont_entry_t *)req->ring_ptr;
108 108
109 /* Load packet defaults. */ 109 /* Load packet defaults. */
110 *((uint32_t *)(&cont_pkt->entry_type)) = 110 *((uint32_t *)(&cont_pkt->entry_type)) =
@@ -120,20 +120,21 @@ qla2x00_prep_cont_type0_iocb(scsi_qla_host_t *ha)
120 * Returns a pointer to the continuation type 1 IOCB packet. 120 * Returns a pointer to the continuation type 1 IOCB packet.
121 */ 121 */
122static inline cont_a64_entry_t * 122static inline cont_a64_entry_t *
123qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *ha) 123qla2x00_prep_cont_type1_iocb(scsi_qla_host_t *vha)
124{ 124{
125 cont_a64_entry_t *cont_pkt; 125 cont_a64_entry_t *cont_pkt;
126 struct req_que *req = vha->hw->req;
126 127
127 /* Adjust ring index. */ 128 /* Adjust ring index. */
128 ha->req_ring_index++; 129 req->ring_index++;
129 if (ha->req_ring_index == ha->request_q_length) { 130 if (req->ring_index == req->length) {
130 ha->req_ring_index = 0; 131 req->ring_index = 0;
131 ha->request_ring_ptr = ha->request_ring; 132 req->ring_ptr = req->ring;
132 } else { 133 } else {
133 ha->request_ring_ptr++; 134 req->ring_ptr++;
134 } 135 }
135 136
136 cont_pkt = (cont_a64_entry_t *)ha->request_ring_ptr; 137 cont_pkt = (cont_a64_entry_t *)req->ring_ptr;
137 138
138 /* Load packet defaults. */ 139 /* Load packet defaults. */
139 *((uint32_t *)(&cont_pkt->entry_type)) = 140 *((uint32_t *)(&cont_pkt->entry_type)) =
@@ -155,7 +156,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
155{ 156{
156 uint16_t avail_dsds; 157 uint16_t avail_dsds;
157 uint32_t *cur_dsd; 158 uint32_t *cur_dsd;
158 scsi_qla_host_t *ha; 159 scsi_qla_host_t *vha;
159 struct scsi_cmnd *cmd; 160 struct scsi_cmnd *cmd;
160 struct scatterlist *sg; 161 struct scatterlist *sg;
161 int i; 162 int i;
@@ -172,7 +173,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
172 return; 173 return;
173 } 174 }
174 175
175 ha = sp->ha; 176 vha = sp->vha;
176 177
177 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); 178 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
178 179
@@ -190,7 +191,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
190 * Seven DSDs are available in the Continuation 191 * Seven DSDs are available in the Continuation
191 * Type 0 IOCB. 192 * Type 0 IOCB.
192 */ 193 */
193 cont_pkt = qla2x00_prep_cont_type0_iocb(ha); 194 cont_pkt = qla2x00_prep_cont_type0_iocb(vha);
194 cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address; 195 cur_dsd = (uint32_t *)&cont_pkt->dseg_0_address;
195 avail_dsds = 7; 196 avail_dsds = 7;
196 } 197 }
@@ -214,7 +215,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
214{ 215{
215 uint16_t avail_dsds; 216 uint16_t avail_dsds;
216 uint32_t *cur_dsd; 217 uint32_t *cur_dsd;
217 scsi_qla_host_t *ha; 218 scsi_qla_host_t *vha;
218 struct scsi_cmnd *cmd; 219 struct scsi_cmnd *cmd;
219 struct scatterlist *sg; 220 struct scatterlist *sg;
220 int i; 221 int i;
@@ -231,7 +232,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
231 return; 232 return;
232 } 233 }
233 234
234 ha = sp->ha; 235 vha = sp->vha;
235 236
236 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); 237 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
237 238
@@ -250,7 +251,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
250 * Five DSDs are available in the Continuation 251 * Five DSDs are available in the Continuation
251 * Type 1 IOCB. 252 * Type 1 IOCB.
252 */ 253 */
253 cont_pkt = qla2x00_prep_cont_type1_iocb(ha); 254 cont_pkt = qla2x00_prep_cont_type1_iocb(vha);
254 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; 255 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
255 avail_dsds = 5; 256 avail_dsds = 5;
256 } 257 }
@@ -274,7 +275,7 @@ qla2x00_start_scsi(srb_t *sp)
274{ 275{
275 int ret, nseg; 276 int ret, nseg;
276 unsigned long flags; 277 unsigned long flags;
277 scsi_qla_host_t *ha; 278 scsi_qla_host_t *vha;
278 struct scsi_cmnd *cmd; 279 struct scsi_cmnd *cmd;
279 uint32_t *clr_ptr; 280 uint32_t *clr_ptr;
280 uint32_t index; 281 uint32_t index;
@@ -284,33 +285,36 @@ qla2x00_start_scsi(srb_t *sp)
284 uint16_t req_cnt; 285 uint16_t req_cnt;
285 uint16_t tot_dsds; 286 uint16_t tot_dsds;
286 struct device_reg_2xxx __iomem *reg; 287 struct device_reg_2xxx __iomem *reg;
288 struct qla_hw_data *ha;
289 struct req_que *req;
287 290
288 /* Setup device pointers. */ 291 /* Setup device pointers. */
289 ret = 0; 292 ret = 0;
290 ha = sp->ha; 293 vha = sp->vha;
294 ha = vha->hw;
291 reg = &ha->iobase->isp; 295 reg = &ha->iobase->isp;
292 cmd = sp->cmd; 296 cmd = sp->cmd;
297 req = ha->req;
293 /* So we know we haven't pci_map'ed anything yet */ 298 /* So we know we haven't pci_map'ed anything yet */
294 tot_dsds = 0; 299 tot_dsds = 0;
295 300
296 /* Send marker if required */ 301 /* Send marker if required */
297 if (ha->marker_needed != 0) { 302 if (vha->marker_needed != 0) {
298 if (qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) { 303 if (qla2x00_marker(vha, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS)
299 return (QLA_FUNCTION_FAILED); 304 return (QLA_FUNCTION_FAILED);
300 } 305 vha->marker_needed = 0;
301 ha->marker_needed = 0;
302 } 306 }
303 307
304 /* Acquire ring specific lock */ 308 /* Acquire ring specific lock */
305 spin_lock_irqsave(&ha->hardware_lock, flags); 309 spin_lock_irqsave(&ha->hardware_lock, flags);
306 310
307 /* Check for room in outstanding command list. */ 311 /* Check for room in outstanding command list. */
308 handle = ha->current_outstanding_cmd; 312 handle = req->current_outstanding_cmd;
309 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { 313 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
310 handle++; 314 handle++;
311 if (handle == MAX_OUTSTANDING_COMMANDS) 315 if (handle == MAX_OUTSTANDING_COMMANDS)
312 handle = 1; 316 handle = 1;
313 if (!ha->outstanding_cmds[handle]) 317 if (!req->outstanding_cmds[handle])
314 break; 318 break;
315 } 319 }
316 if (index == MAX_OUTSTANDING_COMMANDS) 320 if (index == MAX_OUTSTANDING_COMMANDS)
@@ -329,25 +333,25 @@ qla2x00_start_scsi(srb_t *sp)
329 333
330 /* Calculate the number of request entries needed. */ 334 /* Calculate the number of request entries needed. */
331 req_cnt = ha->isp_ops->calc_req_entries(tot_dsds); 335 req_cnt = ha->isp_ops->calc_req_entries(tot_dsds);
332 if (ha->req_q_cnt < (req_cnt + 2)) { 336 if (req->cnt < (req_cnt + 2)) {
333 cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg)); 337 cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg));
334 if (ha->req_ring_index < cnt) 338 if (req->ring_index < cnt)
335 ha->req_q_cnt = cnt - ha->req_ring_index; 339 req->cnt = cnt - req->ring_index;
336 else 340 else
337 ha->req_q_cnt = ha->request_q_length - 341 req->cnt = req->length -
338 (ha->req_ring_index - cnt); 342 (req->ring_index - cnt);
339 } 343 }
340 if (ha->req_q_cnt < (req_cnt + 2)) 344 if (req->cnt < (req_cnt + 2))
341 goto queuing_error; 345 goto queuing_error;
342 346
343 /* Build command packet */ 347 /* Build command packet */
344 ha->current_outstanding_cmd = handle; 348 req->current_outstanding_cmd = handle;
345 ha->outstanding_cmds[handle] = sp; 349 req->outstanding_cmds[handle] = sp;
346 sp->ha = ha; 350 sp->vha = vha;
347 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle; 351 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
348 ha->req_q_cnt -= req_cnt; 352 req->cnt -= req_cnt;
349 353
350 cmd_pkt = (cmd_entry_t *)ha->request_ring_ptr; 354 cmd_pkt = (cmd_entry_t *)req->ring_ptr;
351 cmd_pkt->handle = handle; 355 cmd_pkt->handle = handle;
352 /* Zero out remaining portion of packet. */ 356 /* Zero out remaining portion of packet. */
353 clr_ptr = (uint32_t *)cmd_pkt + 2; 357 clr_ptr = (uint32_t *)cmd_pkt + 2;
@@ -373,23 +377,23 @@ qla2x00_start_scsi(srb_t *sp)
373 wmb(); 377 wmb();
374 378
375 /* Adjust ring index. */ 379 /* Adjust ring index. */
376 ha->req_ring_index++; 380 req->ring_index++;
377 if (ha->req_ring_index == ha->request_q_length) { 381 if (req->ring_index == req->length) {
378 ha->req_ring_index = 0; 382 req->ring_index = 0;
379 ha->request_ring_ptr = ha->request_ring; 383 req->ring_ptr = req->ring;
380 } else 384 } else
381 ha->request_ring_ptr++; 385 req->ring_ptr++;
382 386
383 sp->flags |= SRB_DMA_VALID; 387 sp->flags |= SRB_DMA_VALID;
384 388
385 /* Set chip new ring index. */ 389 /* Set chip new ring index. */
386 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), ha->req_ring_index); 390 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), req->ring_index);
387 RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, reg)); /* PCI Posting. */ 391 RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, reg)); /* PCI Posting. */
388 392
389 /* Manage unprocessed RIO/ZIO commands in response queue. */ 393 /* Manage unprocessed RIO/ZIO commands in response queue. */
390 if (ha->flags.process_response_queue && 394 if (vha->flags.process_response_queue &&
391 ha->response_ring_ptr->signature != RESPONSE_PROCESSED) 395 ha->rsp->ring_ptr->signature != RESPONSE_PROCESSED)
392 qla2x00_process_response_queue(ha); 396 qla2x00_process_response_queue(vha);
393 397
394 spin_unlock_irqrestore(&ha->hardware_lock, flags); 398 spin_unlock_irqrestore(&ha->hardware_lock, flags);
395 return (QLA_SUCCESS); 399 return (QLA_SUCCESS);
@@ -415,18 +419,19 @@ queuing_error:
415 * Returns non-zero if a failure occurred, else zero. 419 * Returns non-zero if a failure occurred, else zero.
416 */ 420 */
417int 421int
418__qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun, 422__qla2x00_marker(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t lun,
419 uint8_t type) 423 uint8_t type)
420{ 424{
421 mrk_entry_t *mrk; 425 mrk_entry_t *mrk;
422 struct mrk_entry_24xx *mrk24; 426 struct mrk_entry_24xx *mrk24;
423 scsi_qla_host_t *pha = to_qla_parent(ha); 427 struct qla_hw_data *ha = vha->hw;
428 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
424 429
425 mrk24 = NULL; 430 mrk24 = NULL;
426 mrk = (mrk_entry_t *)qla2x00_req_pkt(pha); 431 mrk = (mrk_entry_t *)qla2x00_req_pkt(base_vha);
427 if (mrk == NULL) { 432 if (mrk == NULL) {
428 DEBUG2_3(printk("%s(%ld): failed to allocate Marker IOCB.\n", 433 DEBUG2_3(printk("%s(%ld): failed to allocate Marker IOCB.\n",
429 __func__, ha->host_no)); 434 __func__, base_vha->host_no));
430 435
431 return (QLA_FUNCTION_FAILED); 436 return (QLA_FUNCTION_FAILED);
432 } 437 }
@@ -440,7 +445,7 @@ __qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
440 mrk24->lun[1] = LSB(lun); 445 mrk24->lun[1] = LSB(lun);
441 mrk24->lun[2] = MSB(lun); 446 mrk24->lun[2] = MSB(lun);
442 host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun)); 447 host_to_fcp_swap(mrk24->lun, sizeof(mrk24->lun));
443 mrk24->vp_index = ha->vp_idx; 448 mrk24->vp_index = vha->vp_idx;
444 } else { 449 } else {
445 SET_TARGET_ID(ha, mrk->target, loop_id); 450 SET_TARGET_ID(ha, mrk->target, loop_id);
446 mrk->lun = cpu_to_le16(lun); 451 mrk->lun = cpu_to_le16(lun);
@@ -448,22 +453,22 @@ __qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
448 } 453 }
449 wmb(); 454 wmb();
450 455
451 qla2x00_isp_cmd(pha); 456 qla2x00_isp_cmd(base_vha);
452 457
453 return (QLA_SUCCESS); 458 return (QLA_SUCCESS);
454} 459}
455 460
456int 461int
457qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun, 462qla2x00_marker(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t lun,
458 uint8_t type) 463 uint8_t type)
459{ 464{
460 int ret; 465 int ret;
461 unsigned long flags = 0; 466 unsigned long flags = 0;
462 scsi_qla_host_t *pha = to_qla_parent(ha); 467 struct qla_hw_data *ha = vha->hw;
463 468
464 spin_lock_irqsave(&pha->hardware_lock, flags); 469 spin_lock_irqsave(&ha->hardware_lock, flags);
465 ret = __qla2x00_marker(ha, loop_id, lun, type); 470 ret = __qla2x00_marker(vha, loop_id, lun, type);
466 spin_unlock_irqrestore(&pha->hardware_lock, flags); 471 spin_unlock_irqrestore(&ha->hardware_lock, flags);
467 472
468 return (ret); 473 return (ret);
469} 474}
@@ -477,18 +482,20 @@ qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
477 * Returns NULL if function failed, else, a pointer to the request packet. 482 * Returns NULL if function failed, else, a pointer to the request packet.
478 */ 483 */
479static request_t * 484static request_t *
480qla2x00_req_pkt(scsi_qla_host_t *ha) 485qla2x00_req_pkt(scsi_qla_host_t *vha)
481{ 486{
487 struct qla_hw_data *ha = vha->hw;
482 device_reg_t __iomem *reg = ha->iobase; 488 device_reg_t __iomem *reg = ha->iobase;
483 request_t *pkt = NULL; 489 request_t *pkt = NULL;
484 uint16_t cnt; 490 uint16_t cnt;
485 uint32_t *dword_ptr; 491 uint32_t *dword_ptr;
486 uint32_t timer; 492 uint32_t timer;
487 uint16_t req_cnt = 1; 493 uint16_t req_cnt = 1;
494 struct req_que *req = ha->req;
488 495
489 /* Wait 1 second for slot. */ 496 /* Wait 1 second for slot. */
490 for (timer = HZ; timer; timer--) { 497 for (timer = HZ; timer; timer--) {
491 if ((req_cnt + 2) >= ha->req_q_cnt) { 498 if ((req_cnt + 2) >= req->cnt) {
492 /* Calculate number of free request entries. */ 499 /* Calculate number of free request entries. */
493 if (IS_FWI2_CAPABLE(ha)) 500 if (IS_FWI2_CAPABLE(ha))
494 cnt = (uint16_t)RD_REG_DWORD( 501 cnt = (uint16_t)RD_REG_DWORD(
@@ -496,16 +503,16 @@ qla2x00_req_pkt(scsi_qla_host_t *ha)
496 else 503 else
497 cnt = qla2x00_debounce_register( 504 cnt = qla2x00_debounce_register(
498 ISP_REQ_Q_OUT(ha, &reg->isp)); 505 ISP_REQ_Q_OUT(ha, &reg->isp));
499 if (ha->req_ring_index < cnt) 506 if (req->ring_index < cnt)
500 ha->req_q_cnt = cnt - ha->req_ring_index; 507 req->cnt = cnt - req->ring_index;
501 else 508 else
502 ha->req_q_cnt = ha->request_q_length - 509 req->cnt = req->length -
503 (ha->req_ring_index - cnt); 510 (req->ring_index - cnt);
504 } 511 }
505 /* If room for request in request ring. */ 512 /* If room for request in request ring. */
506 if ((req_cnt + 2) < ha->req_q_cnt) { 513 if ((req_cnt + 2) < req->cnt) {
507 ha->req_q_cnt--; 514 req->cnt--;
508 pkt = ha->request_ring_ptr; 515 pkt = req->ring_ptr;
509 516
510 /* Zero out packet. */ 517 /* Zero out packet. */
511 dword_ptr = (uint32_t *)pkt; 518 dword_ptr = (uint32_t *)pkt;
@@ -513,7 +520,7 @@ qla2x00_req_pkt(scsi_qla_host_t *ha)
513 *dword_ptr++ = 0; 520 *dword_ptr++ = 0;
514 521
515 /* Set system defined field. */ 522 /* Set system defined field. */
516 pkt->sys_define = (uint8_t)ha->req_ring_index; 523 pkt->sys_define = (uint8_t)req->ring_index;
517 524
518 /* Set entry count. */ 525 /* Set entry count. */
519 pkt->entry_count = 1; 526 pkt->entry_count = 1;
@@ -522,15 +529,14 @@ qla2x00_req_pkt(scsi_qla_host_t *ha)
522 } 529 }
523 530
524 /* Release ring specific lock */ 531 /* Release ring specific lock */
525 spin_unlock(&ha->hardware_lock); 532 spin_unlock_irq(&ha->hardware_lock);
526 533
527 udelay(2); /* 2 us */ 534 udelay(2); /* 2 us */
528 535
529 /* Check for pending interrupts. */ 536 /* Check for pending interrupts. */
530 /* During init we issue marker directly */ 537 /* During init we issue marker directly */
531 if (!ha->marker_needed && !ha->flags.init_done) 538 if (!vha->marker_needed && !vha->flags.init_done)
532 qla2x00_poll(ha); 539 qla2x00_poll(ha->rsp);
533
534 spin_lock_irq(&ha->hardware_lock); 540 spin_lock_irq(&ha->hardware_lock);
535 } 541 }
536 if (!pkt) { 542 if (!pkt) {
@@ -547,28 +553,30 @@ qla2x00_req_pkt(scsi_qla_host_t *ha)
547 * Note: The caller must hold the hardware lock before calling this routine. 553 * Note: The caller must hold the hardware lock before calling this routine.
548 */ 554 */
549static void 555static void
550qla2x00_isp_cmd(scsi_qla_host_t *ha) 556qla2x00_isp_cmd(scsi_qla_host_t *vha)
551{ 557{
558 struct qla_hw_data *ha = vha->hw;
552 device_reg_t __iomem *reg = ha->iobase; 559 device_reg_t __iomem *reg = ha->iobase;
560 struct req_que *req = ha->req;
553 561
554 DEBUG5(printk("%s(): IOCB data:\n", __func__)); 562 DEBUG5(printk("%s(): IOCB data:\n", __func__));
555 DEBUG5(qla2x00_dump_buffer( 563 DEBUG5(qla2x00_dump_buffer(
556 (uint8_t *)ha->request_ring_ptr, REQUEST_ENTRY_SIZE)); 564 (uint8_t *)req->ring_ptr, REQUEST_ENTRY_SIZE));
557 565
558 /* Adjust ring index. */ 566 /* Adjust ring index. */
559 ha->req_ring_index++; 567 req->ring_index++;
560 if (ha->req_ring_index == ha->request_q_length) { 568 if (req->ring_index == req->length) {
561 ha->req_ring_index = 0; 569 req->ring_index = 0;
562 ha->request_ring_ptr = ha->request_ring; 570 req->ring_ptr = req->ring;
563 } else 571 } else
564 ha->request_ring_ptr++; 572 req->ring_ptr++;
565 573
566 /* Set chip new ring index. */ 574 /* Set chip new ring index. */
567 if (IS_FWI2_CAPABLE(ha)) { 575 if (IS_FWI2_CAPABLE(ha)) {
568 WRT_REG_DWORD(&reg->isp24.req_q_in, ha->req_ring_index); 576 WRT_REG_DWORD(&reg->isp24.req_q_in, req->ring_index);
569 RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in); 577 RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in);
570 } else { 578 } else {
571 WRT_REG_WORD(ISP_REQ_Q_IN(ha, &reg->isp), ha->req_ring_index); 579 WRT_REG_WORD(ISP_REQ_Q_IN(ha, &reg->isp), req->ring_index);
572 RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, &reg->isp)); 580 RD_REG_WORD_RELAXED(ISP_REQ_Q_IN(ha, &reg->isp));
573 } 581 }
574 582
@@ -610,7 +618,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
610{ 618{
611 uint16_t avail_dsds; 619 uint16_t avail_dsds;
612 uint32_t *cur_dsd; 620 uint32_t *cur_dsd;
613 scsi_qla_host_t *ha; 621 scsi_qla_host_t *vha;
614 struct scsi_cmnd *cmd; 622 struct scsi_cmnd *cmd;
615 struct scatterlist *sg; 623 struct scatterlist *sg;
616 int i; 624 int i;
@@ -627,18 +635,18 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
627 return; 635 return;
628 } 636 }
629 637
630 ha = sp->ha; 638 vha = sp->vha;
631 639
632 /* Set transfer direction */ 640 /* Set transfer direction */
633 if (cmd->sc_data_direction == DMA_TO_DEVICE) { 641 if (cmd->sc_data_direction == DMA_TO_DEVICE) {
634 cmd_pkt->task_mgmt_flags = 642 cmd_pkt->task_mgmt_flags =
635 __constant_cpu_to_le16(TMF_WRITE_DATA); 643 __constant_cpu_to_le16(TMF_WRITE_DATA);
636 sp->fcport->ha->qla_stats.output_bytes += 644 sp->fcport->vha->hw->qla_stats.output_bytes +=
637 scsi_bufflen(sp->cmd); 645 scsi_bufflen(sp->cmd);
638 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { 646 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
639 cmd_pkt->task_mgmt_flags = 647 cmd_pkt->task_mgmt_flags =
640 __constant_cpu_to_le16(TMF_READ_DATA); 648 __constant_cpu_to_le16(TMF_READ_DATA);
641 sp->fcport->ha->qla_stats.input_bytes += 649 sp->fcport->vha->hw->qla_stats.input_bytes +=
642 scsi_bufflen(sp->cmd); 650 scsi_bufflen(sp->cmd);
643 } 651 }
644 652
@@ -658,7 +666,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
658 * Five DSDs are available in the Continuation 666 * Five DSDs are available in the Continuation
659 * Type 1 IOCB. 667 * Type 1 IOCB.
660 */ 668 */
661 cont_pkt = qla2x00_prep_cont_type1_iocb(ha); 669 cont_pkt = qla2x00_prep_cont_type1_iocb(vha);
662 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address; 670 cur_dsd = (uint32_t *)cont_pkt->dseg_0_address;
663 avail_dsds = 5; 671 avail_dsds = 5;
664 } 672 }
@@ -683,7 +691,7 @@ qla24xx_start_scsi(srb_t *sp)
683{ 691{
684 int ret, nseg; 692 int ret, nseg;
685 unsigned long flags; 693 unsigned long flags;
686 scsi_qla_host_t *ha, *pha; 694 scsi_qla_host_t *vha;
687 struct scsi_cmnd *cmd; 695 struct scsi_cmnd *cmd;
688 uint32_t *clr_ptr; 696 uint32_t *clr_ptr;
689 uint32_t index; 697 uint32_t index;
@@ -693,34 +701,36 @@ qla24xx_start_scsi(srb_t *sp)
693 uint16_t req_cnt; 701 uint16_t req_cnt;
694 uint16_t tot_dsds; 702 uint16_t tot_dsds;
695 struct device_reg_24xx __iomem *reg; 703 struct device_reg_24xx __iomem *reg;
704 struct qla_hw_data *ha;
705 struct req_que *req;
696 706
697 /* Setup device pointers. */ 707 /* Setup device pointers. */
698 ret = 0; 708 ret = 0;
699 ha = sp->ha; 709 vha = sp->vha;
700 pha = to_qla_parent(ha); 710 ha = vha->hw;
701 reg = &ha->iobase->isp24; 711 reg = &ha->iobase->isp24;
702 cmd = sp->cmd; 712 cmd = sp->cmd;
713 req = ha->req;
703 /* So we know we haven't pci_map'ed anything yet */ 714 /* So we know we haven't pci_map'ed anything yet */
704 tot_dsds = 0; 715 tot_dsds = 0;
705 716
706 /* Send marker if required */ 717 /* Send marker if required */
707 if (ha->marker_needed != 0) { 718 if (vha->marker_needed != 0) {
708 if (qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS) { 719 if (qla2x00_marker(vha, 0, 0, MK_SYNC_ALL) != QLA_SUCCESS)
709 return QLA_FUNCTION_FAILED; 720 return QLA_FUNCTION_FAILED;
710 } 721 vha->marker_needed = 0;
711 ha->marker_needed = 0;
712 } 722 }
713 723
714 /* Acquire ring specific lock */ 724 /* Acquire ring specific lock */
715 spin_lock_irqsave(&pha->hardware_lock, flags); 725 spin_lock_irqsave(&ha->hardware_lock, flags);
716 726
717 /* Check for room in outstanding command list. */ 727 /* Check for room in outstanding command list. */
718 handle = ha->current_outstanding_cmd; 728 handle = req->current_outstanding_cmd;
719 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) { 729 for (index = 1; index < MAX_OUTSTANDING_COMMANDS; index++) {
720 handle++; 730 handle++;
721 if (handle == MAX_OUTSTANDING_COMMANDS) 731 if (handle == MAX_OUTSTANDING_COMMANDS)
722 handle = 1; 732 handle = 1;
723 if (!ha->outstanding_cmds[handle]) 733 if (!req->outstanding_cmds[handle])
724 break; 734 break;
725 } 735 }
726 if (index == MAX_OUTSTANDING_COMMANDS) 736 if (index == MAX_OUTSTANDING_COMMANDS)
@@ -738,25 +748,25 @@ qla24xx_start_scsi(srb_t *sp)
738 tot_dsds = nseg; 748 tot_dsds = nseg;
739 749
740 req_cnt = qla24xx_calc_iocbs(tot_dsds); 750 req_cnt = qla24xx_calc_iocbs(tot_dsds);
741 if (ha->req_q_cnt < (req_cnt + 2)) { 751 if (req->cnt < (req_cnt + 2)) {
742 cnt = (uint16_t)RD_REG_DWORD_RELAXED(&reg->req_q_out); 752 cnt = (uint16_t)RD_REG_DWORD_RELAXED(&reg->req_q_out);
743 if (ha->req_ring_index < cnt) 753 if (req->ring_index < cnt)
744 ha->req_q_cnt = cnt - ha->req_ring_index; 754 req->cnt = cnt - req->ring_index;
745 else 755 else
746 ha->req_q_cnt = ha->request_q_length - 756 req->cnt = req->length -
747 (ha->req_ring_index - cnt); 757 (req->ring_index - cnt);
748 } 758 }
749 if (ha->req_q_cnt < (req_cnt + 2)) 759 if (req->cnt < (req_cnt + 2))
750 goto queuing_error; 760 goto queuing_error;
751 761
752 /* Build command packet. */ 762 /* Build command packet. */
753 ha->current_outstanding_cmd = handle; 763 req->current_outstanding_cmd = handle;
754 ha->outstanding_cmds[handle] = sp; 764 req->outstanding_cmds[handle] = sp;
755 sp->ha = ha; 765 sp->vha = vha;
756 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle; 766 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
757 ha->req_q_cnt -= req_cnt; 767 req->cnt -= req_cnt;
758 768
759 cmd_pkt = (struct cmd_type_7 *)ha->request_ring_ptr; 769 cmd_pkt = (struct cmd_type_7 *)req->ring_ptr;
760 cmd_pkt->handle = handle; 770 cmd_pkt->handle = handle;
761 771
762 /* Zero out remaining portion of packet. */ 772 /* Zero out remaining portion of packet. */
@@ -789,32 +799,32 @@ qla24xx_start_scsi(srb_t *sp)
789 wmb(); 799 wmb();
790 800
791 /* Adjust ring index. */ 801 /* Adjust ring index. */
792 ha->req_ring_index++; 802 req->ring_index++;
793 if (ha->req_ring_index == ha->request_q_length) { 803 if (req->ring_index == req->length) {
794 ha->req_ring_index = 0; 804 req->ring_index = 0;
795 ha->request_ring_ptr = ha->request_ring; 805 req->ring_ptr = req->ring;
796 } else 806 } else
797 ha->request_ring_ptr++; 807 req->ring_ptr++;
798 808
799 sp->flags |= SRB_DMA_VALID; 809 sp->flags |= SRB_DMA_VALID;
800 810
801 /* Set chip new ring index. */ 811 /* Set chip new ring index. */
802 WRT_REG_DWORD(&reg->req_q_in, ha->req_ring_index); 812 WRT_REG_DWORD(&reg->req_q_in, req->ring_index);
803 RD_REG_DWORD_RELAXED(&reg->req_q_in); /* PCI Posting. */ 813 RD_REG_DWORD_RELAXED(&reg->req_q_in); /* PCI Posting. */
804 814
805 /* Manage unprocessed RIO/ZIO commands in response queue. */ 815 /* Manage unprocessed RIO/ZIO commands in response queue. */
806 if (ha->flags.process_response_queue && 816 if (vha->flags.process_response_queue &&
807 ha->response_ring_ptr->signature != RESPONSE_PROCESSED) 817 ha->rsp->ring_ptr->signature != RESPONSE_PROCESSED)
808 qla24xx_process_response_queue(ha); 818 qla24xx_process_response_queue(vha);
809 819
810 spin_unlock_irqrestore(&pha->hardware_lock, flags); 820 spin_unlock_irqrestore(&ha->hardware_lock, flags);
811 return QLA_SUCCESS; 821 return QLA_SUCCESS;
812 822
813queuing_error: 823queuing_error:
814 if (tot_dsds) 824 if (tot_dsds)
815 scsi_dma_unmap(cmd); 825 scsi_dma_unmap(cmd);
816 826
817 spin_unlock_irqrestore(&pha->hardware_lock, flags); 827 spin_unlock_irqrestore(&ha->hardware_lock, flags);
818 828
819 return QLA_FUNCTION_FAILED; 829 return QLA_FUNCTION_FAILED;
820} 830}