diff options
author | Anirban Chakraborty <anirban.chakraborty@qlogic.com> | 2008-12-09 19:45:39 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-12-29 12:24:33 -0500 |
commit | 73208dfd7ab19f379d73e8a0fbf30f92c203e5e8 (patch) | |
tree | f69be5e89817d17b066ece4dbe04e395339c0754 /drivers/scsi/qla2xxx/qla_mid.c | |
parent | 85b4aa4926a50210b683ac89326e338e7d131211 (diff) |
[SCSI] qla2xxx: add support for multi-queue adapter
Following changes have been made.
1. qla_hw_data structure holds an array for request queue pointers,
and an array for response queue pointers.
2. The base request and response queues are created by default.
3. Additional request and response queues are created at the time of vport
creation. If queue resources are exhausted during vport creation, newly
created vports use the default queue.
4. Requests are sent to the request queue that the vport was assigned
in the beginning.
5. Responses are completed on the response queue with which the request queue
is associated with.
[fixup memcpy argument reversal spotted by davej@redhat.com]
Signed-off-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_mid.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_mid.c | 349 |
1 files changed, 343 insertions, 6 deletions
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index da3db3abb82..386ffeae5b5 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c | |||
@@ -101,6 +101,7 @@ qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha) | |||
101 | "loop_id=0x%04x :%x\n", | 101 | "loop_id=0x%04x :%x\n", |
102 | vha->host_no, fcport->loop_id, fcport->vp_idx)); | 102 | vha->host_no, fcport->loop_id, fcport->vp_idx)); |
103 | 103 | ||
104 | atomic_set(&fcport->state, FCS_DEVICE_DEAD); | ||
104 | qla2x00_mark_device_lost(vha, fcport, 0, 0); | 105 | qla2x00_mark_device_lost(vha, fcport, 0, 0); |
105 | atomic_set(&fcport->state, FCS_UNCONFIGURED); | 106 | atomic_set(&fcport->state, FCS_UNCONFIGURED); |
106 | } | 107 | } |
@@ -191,9 +192,10 @@ qla24xx_configure_vp(scsi_qla_host_t *vha) | |||
191 | } | 192 | } |
192 | 193 | ||
193 | void | 194 | void |
194 | qla2x00_alert_all_vps(struct qla_hw_data *ha, uint16_t *mb) | 195 | qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb) |
195 | { | 196 | { |
196 | scsi_qla_host_t *vha; | 197 | scsi_qla_host_t *vha; |
198 | struct qla_hw_data *ha = rsp->hw; | ||
197 | int i = 0; | 199 | int i = 0; |
198 | 200 | ||
199 | list_for_each_entry(vha, &ha->vp_list, list) { | 201 | list_for_each_entry(vha, &ha->vp_list, list) { |
@@ -210,7 +212,7 @@ qla2x00_alert_all_vps(struct qla_hw_data *ha, uint16_t *mb) | |||
210 | DEBUG15(printk("scsi(%ld)%s: Async_event for" | 212 | DEBUG15(printk("scsi(%ld)%s: Async_event for" |
211 | " VP[%d], mb = 0x%x, vha=%p\n", | 213 | " VP[%d], mb = 0x%x, vha=%p\n", |
212 | vha->host_no, __func__, i, *mb, vha)); | 214 | vha->host_no, __func__, i, *mb, vha)); |
213 | qla2x00_async_event(vha, mb); | 215 | qla2x00_async_event(vha, rsp, mb); |
214 | break; | 216 | break; |
215 | } | 217 | } |
216 | } | 218 | } |
@@ -282,8 +284,7 @@ qla2x00_do_dpc_vp(scsi_qla_host_t *vha) | |||
282 | clear_bit(RESET_ACTIVE, &vha->dpc_flags); | 284 | clear_bit(RESET_ACTIVE, &vha->dpc_flags); |
283 | } | 285 | } |
284 | 286 | ||
285 | if (atomic_read(&vha->vp_state) == VP_ACTIVE && | 287 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
286 | test_and_clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { | ||
287 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))) { | 288 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))) { |
288 | qla2x00_loop_resync(vha); | 289 | qla2x00_loop_resync(vha); |
289 | clear_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags); | 290 | clear_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags); |
@@ -367,7 +368,6 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) | |||
367 | 368 | ||
368 | host = vha->host; | 369 | host = vha->host; |
369 | fc_vport->dd_data = vha; | 370 | fc_vport->dd_data = vha; |
370 | |||
371 | /* New host info */ | 371 | /* New host info */ |
372 | u64_to_wwn(fc_vport->node_name, vha->node_name); | 372 | u64_to_wwn(fc_vport->node_name, vha->node_name); |
373 | u64_to_wwn(fc_vport->port_name, vha->port_name); | 373 | u64_to_wwn(fc_vport->port_name, vha->port_name); |
@@ -396,7 +396,9 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) | |||
396 | 396 | ||
397 | qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL); | 397 | qla2x00_start_timer(vha, qla2x00_timer, WATCH_INTERVAL); |
398 | 398 | ||
399 | host->can_queue = ha->req->length + 128; | 399 | memset(vha->req_ques, 0, sizeof(vha->req_ques) * QLA_MAX_HOST_QUES); |
400 | vha->req_ques[0] = ha->req_q_map[0]->id; | ||
401 | host->can_queue = ha->req_q_map[0]->length + 128; | ||
400 | host->this_id = 255; | 402 | host->this_id = 255; |
401 | host->cmd_per_lun = 3; | 403 | host->cmd_per_lun = 3; |
402 | host->max_cmd_len = MAX_CMDSZ; | 404 | host->max_cmd_len = MAX_CMDSZ; |
@@ -416,3 +418,338 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) | |||
416 | create_vhost_failed: | 418 | create_vhost_failed: |
417 | return NULL; | 419 | return NULL; |
418 | } | 420 | } |
421 | |||
422 | static void | ||
423 | qla25xx_free_req_que(struct scsi_qla_host *vha, struct req_que *req) | ||
424 | { | ||
425 | struct qla_hw_data *ha = vha->hw; | ||
426 | uint16_t que_id = req->id; | ||
427 | |||
428 | dma_free_coherent(&ha->pdev->dev, (req->length + 1) * | ||
429 | sizeof(request_t), req->ring, req->dma); | ||
430 | req->ring = NULL; | ||
431 | req->dma = 0; | ||
432 | if (que_id) { | ||
433 | ha->req_q_map[que_id] = NULL; | ||
434 | mutex_lock(&ha->vport_lock); | ||
435 | clear_bit(que_id, ha->req_qid_map); | ||
436 | mutex_unlock(&ha->vport_lock); | ||
437 | } | ||
438 | kfree(req); | ||
439 | req = NULL; | ||
440 | } | ||
441 | |||
442 | static void | ||
443 | qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) | ||
444 | { | ||
445 | struct qla_hw_data *ha = vha->hw; | ||
446 | uint16_t que_id = rsp->id; | ||
447 | |||
448 | if (rsp->msix && rsp->msix->have_irq) { | ||
449 | free_irq(rsp->msix->vector, rsp); | ||
450 | rsp->msix->have_irq = 0; | ||
451 | rsp->msix->rsp = NULL; | ||
452 | } | ||
453 | dma_free_coherent(&ha->pdev->dev, (rsp->length + 1) * | ||
454 | sizeof(response_t), rsp->ring, rsp->dma); | ||
455 | rsp->ring = NULL; | ||
456 | rsp->dma = 0; | ||
457 | if (que_id) { | ||
458 | ha->rsp_q_map[que_id] = NULL; | ||
459 | mutex_lock(&ha->vport_lock); | ||
460 | clear_bit(que_id, ha->rsp_qid_map); | ||
461 | mutex_unlock(&ha->vport_lock); | ||
462 | } | ||
463 | kfree(rsp); | ||
464 | rsp = NULL; | ||
465 | } | ||
466 | |||
467 | int | ||
468 | qla25xx_delete_req_que(struct scsi_qla_host *vha, struct req_que *req) | ||
469 | { | ||
470 | int ret = -1; | ||
471 | |||
472 | if (req) { | ||
473 | req->options |= BIT_0; | ||
474 | ret = qla25xx_init_req_que(vha, req, req->options); | ||
475 | } | ||
476 | if (ret == QLA_SUCCESS) | ||
477 | qla25xx_free_req_que(vha, req); | ||
478 | |||
479 | return ret; | ||
480 | } | ||
481 | |||
482 | int | ||
483 | qla25xx_delete_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp) | ||
484 | { | ||
485 | int ret = -1; | ||
486 | |||
487 | if (rsp) { | ||
488 | rsp->options |= BIT_0; | ||
489 | ret = qla25xx_init_rsp_que(vha, rsp, rsp->options); | ||
490 | } | ||
491 | if (ret == QLA_SUCCESS) | ||
492 | qla25xx_free_rsp_que(vha, rsp); | ||
493 | |||
494 | return ret; | ||
495 | } | ||
496 | |||
497 | int qla25xx_update_req_que(struct scsi_qla_host *vha, uint8_t que, uint8_t qos) | ||
498 | { | ||
499 | int ret = 0; | ||
500 | struct qla_hw_data *ha = vha->hw; | ||
501 | struct req_que *req = ha->req_q_map[que]; | ||
502 | |||
503 | req->options |= BIT_3; | ||
504 | req->qos = qos; | ||
505 | ret = qla25xx_init_req_que(vha, req, req->options); | ||
506 | if (ret != QLA_SUCCESS) | ||
507 | DEBUG2_17(printk(KERN_WARNING "%s failed\n", __func__)); | ||
508 | /* restore options bit */ | ||
509 | req->options &= ~BIT_3; | ||
510 | return ret; | ||
511 | } | ||
512 | |||
513 | |||
514 | /* Delete all queues for a given vhost */ | ||
515 | int | ||
516 | qla25xx_delete_queues(struct scsi_qla_host *vha, uint8_t que_no) | ||
517 | { | ||
518 | int cnt, ret = 0; | ||
519 | struct req_que *req = NULL; | ||
520 | struct rsp_que *rsp = NULL; | ||
521 | struct qla_hw_data *ha = vha->hw; | ||
522 | |||
523 | if (que_no) { | ||
524 | /* Delete request queue */ | ||
525 | req = ha->req_q_map[que_no]; | ||
526 | if (req) { | ||
527 | rsp = req->rsp; | ||
528 | ret = qla25xx_delete_req_que(vha, req); | ||
529 | if (ret != QLA_SUCCESS) { | ||
530 | qla_printk(KERN_WARNING, ha, | ||
531 | "Couldn't delete req que %d\n", req->id); | ||
532 | return ret; | ||
533 | } | ||
534 | /* Delete associated response queue */ | ||
535 | if (rsp) { | ||
536 | ret = qla25xx_delete_rsp_que(vha, rsp); | ||
537 | if (ret != QLA_SUCCESS) { | ||
538 | qla_printk(KERN_WARNING, ha, | ||
539 | "Couldn't delete rsp que %d\n", | ||
540 | rsp->id); | ||
541 | return ret; | ||
542 | } | ||
543 | } | ||
544 | } | ||
545 | } else { /* delete all queues of this host */ | ||
546 | for (cnt = 0; cnt < QLA_MAX_HOST_QUES; cnt++) { | ||
547 | /* Delete request queues */ | ||
548 | req = ha->req_q_map[vha->req_ques[cnt]]; | ||
549 | if (req && req->id) { | ||
550 | rsp = req->rsp; | ||
551 | ret = qla25xx_delete_req_que(vha, req); | ||
552 | if (ret != QLA_SUCCESS) { | ||
553 | qla_printk(KERN_WARNING, ha, | ||
554 | "Couldn't delete req que %d\n", | ||
555 | vha->req_ques[cnt]); | ||
556 | return ret; | ||
557 | } | ||
558 | vha->req_ques[cnt] = ha->req_q_map[0]->id; | ||
559 | /* Delete associated response queue */ | ||
560 | if (rsp && rsp->id) { | ||
561 | ret = qla25xx_delete_rsp_que(vha, rsp); | ||
562 | if (ret != QLA_SUCCESS) { | ||
563 | qla_printk(KERN_WARNING, ha, | ||
564 | "Couldn't delete rsp que %d\n", | ||
565 | rsp->id); | ||
566 | return ret; | ||
567 | } | ||
568 | } | ||
569 | } | ||
570 | } | ||
571 | } | ||
572 | qla_printk(KERN_INFO, ha, "Queues deleted for vport:%d\n", | ||
573 | vha->vp_idx); | ||
574 | return ret; | ||
575 | } | ||
576 | |||
577 | int | ||
578 | qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options, | ||
579 | uint8_t vp_idx, uint16_t rid, uint8_t rsp_que, uint8_t qos) | ||
580 | { | ||
581 | int ret = 0; | ||
582 | struct req_que *req = NULL; | ||
583 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); | ||
584 | uint16_t que_id = 0; | ||
585 | |||
586 | req = kzalloc(sizeof(struct req_que), GFP_KERNEL); | ||
587 | if (req == NULL) { | ||
588 | qla_printk(KERN_WARNING, ha, "could not allocate memory" | ||
589 | "for request que\n"); | ||
590 | goto que_failed; | ||
591 | } | ||
592 | |||
593 | req->length = REQUEST_ENTRY_CNT_24XX; | ||
594 | req->ring = dma_alloc_coherent(&ha->pdev->dev, | ||
595 | (req->length + 1) * sizeof(request_t), | ||
596 | &req->dma, GFP_KERNEL); | ||
597 | if (req->ring == NULL) { | ||
598 | qla_printk(KERN_WARNING, ha, | ||
599 | "Memory Allocation failed - request_ring\n"); | ||
600 | goto que_failed; | ||
601 | } | ||
602 | |||
603 | mutex_lock(&ha->vport_lock); | ||
604 | que_id = find_first_zero_bit(ha->req_qid_map, ha->max_queues); | ||
605 | if (que_id >= ha->max_queues) { | ||
606 | mutex_unlock(&ha->vport_lock); | ||
607 | qla_printk(KERN_INFO, ha, "No resources to create " | ||
608 | "additional request queue\n"); | ||
609 | goto que_failed; | ||
610 | } | ||
611 | set_bit(que_id, ha->req_qid_map); | ||
612 | ha->req_q_map[que_id] = req; | ||
613 | req->rid = rid; | ||
614 | req->vp_idx = vp_idx; | ||
615 | req->qos = qos; | ||
616 | |||
617 | if (ha->rsp_q_map[rsp_que]) | ||
618 | req->rsp = ha->rsp_q_map[rsp_que]; | ||
619 | /* Use alternate PCI bus number */ | ||
620 | if (MSB(req->rid)) | ||
621 | options |= BIT_4; | ||
622 | /* Use alternate PCI devfn */ | ||
623 | if (LSB(req->rid)) | ||
624 | options |= BIT_5; | ||
625 | req->options = options; | ||
626 | req->ring_ptr = req->ring; | ||
627 | req->ring_index = 0; | ||
628 | req->cnt = req->length; | ||
629 | req->id = que_id; | ||
630 | mutex_unlock(&ha->vport_lock); | ||
631 | |||
632 | ret = qla25xx_init_req_que(base_vha, req, options); | ||
633 | if (ret != QLA_SUCCESS) { | ||
634 | qla_printk(KERN_WARNING, ha, "%s failed\n", __func__); | ||
635 | mutex_lock(&ha->vport_lock); | ||
636 | clear_bit(que_id, ha->req_qid_map); | ||
637 | mutex_unlock(&ha->vport_lock); | ||
638 | goto que_failed; | ||
639 | } | ||
640 | |||
641 | return req->id; | ||
642 | |||
643 | que_failed: | ||
644 | qla25xx_free_req_que(base_vha, req); | ||
645 | return 0; | ||
646 | } | ||
647 | |||
648 | /* create response queue */ | ||
649 | int | ||
650 | qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, | ||
651 | uint8_t vp_idx, uint16_t rid) | ||
652 | { | ||
653 | int ret = 0; | ||
654 | struct rsp_que *rsp = NULL; | ||
655 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); | ||
656 | uint16_t que_id = 0;; | ||
657 | |||
658 | rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); | ||
659 | if (rsp == NULL) { | ||
660 | qla_printk(KERN_WARNING, ha, "could not allocate memory for" | ||
661 | " response que\n"); | ||
662 | goto que_failed; | ||
663 | } | ||
664 | |||
665 | rsp->length = RESPONSE_ENTRY_CNT_2300; | ||
666 | rsp->ring = dma_alloc_coherent(&ha->pdev->dev, | ||
667 | (rsp->length + 1) * sizeof(response_t), | ||
668 | &rsp->dma, GFP_KERNEL); | ||
669 | if (rsp->ring == NULL) { | ||
670 | qla_printk(KERN_WARNING, ha, | ||
671 | "Memory Allocation failed - response_ring\n"); | ||
672 | goto que_failed; | ||
673 | } | ||
674 | |||
675 | mutex_lock(&ha->vport_lock); | ||
676 | que_id = find_first_zero_bit(ha->rsp_qid_map, ha->max_queues); | ||
677 | if (que_id >= ha->max_queues) { | ||
678 | mutex_unlock(&ha->vport_lock); | ||
679 | qla_printk(KERN_INFO, ha, "No resources to create " | ||
680 | "additional response queue\n"); | ||
681 | goto que_failed; | ||
682 | } | ||
683 | set_bit(que_id, ha->rsp_qid_map); | ||
684 | |||
685 | if (ha->flags.msix_enabled) | ||
686 | rsp->msix = &ha->msix_entries[que_id + 1]; | ||
687 | else | ||
688 | qla_printk(KERN_WARNING, ha, "msix not enabled\n"); | ||
689 | |||
690 | ha->rsp_q_map[que_id] = rsp; | ||
691 | rsp->rid = rid; | ||
692 | rsp->vp_idx = vp_idx; | ||
693 | rsp->hw = ha; | ||
694 | /* Use alternate PCI bus number */ | ||
695 | if (MSB(rsp->rid)) | ||
696 | options |= BIT_4; | ||
697 | /* Use alternate PCI devfn */ | ||
698 | if (LSB(rsp->rid)) | ||
699 | options |= BIT_5; | ||
700 | rsp->options = options; | ||
701 | rsp->ring_ptr = rsp->ring; | ||
702 | rsp->ring_index = 0; | ||
703 | rsp->id = que_id; | ||
704 | mutex_unlock(&ha->vport_lock); | ||
705 | |||
706 | ret = qla25xx_request_irq(rsp); | ||
707 | if (ret) | ||
708 | goto que_failed; | ||
709 | |||
710 | ret = qla25xx_init_rsp_que(base_vha, rsp, options); | ||
711 | if (ret != QLA_SUCCESS) { | ||
712 | qla_printk(KERN_WARNING, ha, "%s failed\n", __func__); | ||
713 | mutex_lock(&ha->vport_lock); | ||
714 | clear_bit(que_id, ha->rsp_qid_map); | ||
715 | mutex_unlock(&ha->vport_lock); | ||
716 | goto que_failed; | ||
717 | } | ||
718 | |||
719 | qla2x00_init_response_q_entries(rsp); | ||
720 | |||
721 | return rsp->id; | ||
722 | |||
723 | que_failed: | ||
724 | qla25xx_free_rsp_que(base_vha, rsp); | ||
725 | return 0; | ||
726 | } | ||
727 | |||
728 | int | ||
729 | qla25xx_create_queues(struct scsi_qla_host *vha, uint8_t qos) | ||
730 | { | ||
731 | uint16_t options = 0; | ||
732 | uint8_t ret = 0; | ||
733 | struct qla_hw_data *ha = vha->hw; | ||
734 | |||
735 | options |= BIT_1; | ||
736 | ret = qla25xx_create_rsp_que(ha, options, vha->vp_idx, 0); | ||
737 | if (!ret) { | ||
738 | qla_printk(KERN_WARNING, ha, "Response Que create failed\n"); | ||
739 | return ret; | ||
740 | } else | ||
741 | qla_printk(KERN_INFO, ha, "Response Que:%d created.\n", ret); | ||
742 | |||
743 | options = 0; | ||
744 | if (qos & BIT_7) | ||
745 | options |= BIT_8; | ||
746 | ret = qla25xx_create_req_que(ha, options, vha->vp_idx, 0, ret, | ||
747 | qos & ~BIT_7); | ||
748 | if (ret) { | ||
749 | vha->req_ques[0] = ret; | ||
750 | qla_printk(KERN_INFO, ha, "Request Que:%d created.\n", ret); | ||
751 | } else | ||
752 | qla_printk(KERN_WARNING, ha, "Request Que create failed\n"); | ||
753 | |||
754 | return ret; | ||
755 | } | ||