diff options
author | James Smart <james.smart@emulex.com> | 2010-02-26 14:15:57 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-03-03 08:40:09 -0500 |
commit | 0c9ab6f5cb28199ef5de84874d135ed44f64d92b (patch) | |
tree | 51140c5edce1250e0c06b5a38b540b533b092247 /drivers/scsi | |
parent | fc2b989be9190f3311a5ae41289828e24897a20e (diff) |
[SCSI] lpfc 8.3.10: Added round robin FCF failover
- Added round robin FCF failover on initial or FCF rediscovery FLOGI failure.
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_crtn.h | 4 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_els.c | 91 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_hbadisc.c | 486 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_init.c | 123 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_logmsg.h | 1 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_mbox.c | 8 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli.c | 218 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_sli4.h | 33 |
8 files changed, 802 insertions, 162 deletions
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index 39739a707ed4..5087c4211b43 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h | |||
@@ -63,6 +63,7 @@ void lpfc_linkdown_port(struct lpfc_vport *); | |||
63 | void lpfc_port_link_failure(struct lpfc_vport *); | 63 | void lpfc_port_link_failure(struct lpfc_vport *); |
64 | void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *); | 64 | void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *); |
65 | void lpfc_init_vpi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *); | 65 | void lpfc_init_vpi_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *); |
66 | void lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *); | ||
66 | void lpfc_retry_pport_discovery(struct lpfc_hba *); | 67 | void lpfc_retry_pport_discovery(struct lpfc_hba *); |
67 | 68 | ||
68 | void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); | 69 | void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *); |
@@ -222,6 +223,9 @@ void lpfc_unregister_unused_fcf(struct lpfc_hba *); | |||
222 | int lpfc_sli4_redisc_fcf_table(struct lpfc_hba *); | 223 | int lpfc_sli4_redisc_fcf_table(struct lpfc_hba *); |
223 | void lpfc_fcf_redisc_wait_start_timer(struct lpfc_hba *); | 224 | void lpfc_fcf_redisc_wait_start_timer(struct lpfc_hba *); |
224 | void lpfc_sli4_fcf_dead_failthrough(struct lpfc_hba *); | 225 | void lpfc_sli4_fcf_dead_failthrough(struct lpfc_hba *); |
226 | uint16_t lpfc_sli4_fcf_rr_next_index_get(struct lpfc_hba *); | ||
227 | int lpfc_sli4_fcf_rr_index_set(struct lpfc_hba *, uint16_t); | ||
228 | void lpfc_sli4_fcf_rr_index_clear(struct lpfc_hba *, uint16_t); | ||
225 | 229 | ||
226 | int lpfc_mem_alloc(struct lpfc_hba *, int align); | 230 | int lpfc_mem_alloc(struct lpfc_hba *, int align); |
227 | void lpfc_mem_free(struct lpfc_hba *); | 231 | void lpfc_mem_free(struct lpfc_hba *); |
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index a81d43306d17..d807f36ba4f9 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c | |||
@@ -771,6 +771,7 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
771 | struct lpfc_nodelist *ndlp = cmdiocb->context1; | 771 | struct lpfc_nodelist *ndlp = cmdiocb->context1; |
772 | struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; | 772 | struct lpfc_dmabuf *pcmd = cmdiocb->context2, *prsp; |
773 | struct serv_parm *sp; | 773 | struct serv_parm *sp; |
774 | uint16_t fcf_index; | ||
774 | int rc; | 775 | int rc; |
775 | 776 | ||
776 | /* Check to see if link went down during discovery */ | 777 | /* Check to see if link went down during discovery */ |
@@ -788,6 +789,54 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
788 | vport->port_state); | 789 | vport->port_state); |
789 | 790 | ||
790 | if (irsp->ulpStatus) { | 791 | if (irsp->ulpStatus) { |
792 | /* | ||
793 | * In case of FIP mode, perform round robin FCF failover | ||
794 | * due to new FCF discovery | ||
795 | */ | ||
796 | if ((phba->hba_flag & HBA_FIP_SUPPORT) && | ||
797 | (phba->fcf.fcf_flag & FCF_DISCOVERY)) { | ||
798 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP | LOG_ELS, | ||
799 | "2611 FLOGI failed on registered " | ||
800 | "FCF record fcf_index:%d, trying " | ||
801 | "to perform round robin failover\n", | ||
802 | phba->fcf.current_rec.fcf_indx); | ||
803 | fcf_index = lpfc_sli4_fcf_rr_next_index_get(phba); | ||
804 | if (fcf_index == LPFC_FCOE_FCF_NEXT_NONE) { | ||
805 | /* | ||
806 | * Exhausted the eligible FCF record list, | ||
807 | * fail through to retry FLOGI on current | ||
808 | * FCF record. | ||
809 | */ | ||
810 | lpfc_printf_log(phba, KERN_WARNING, | ||
811 | LOG_FIP | LOG_ELS, | ||
812 | "2760 FLOGI exhausted FCF " | ||
813 | "round robin failover list, " | ||
814 | "retry FLOGI on the current " | ||
815 | "registered FCF index:%d\n", | ||
816 | phba->fcf.current_rec.fcf_indx); | ||
817 | spin_lock_irq(&phba->hbalock); | ||
818 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; | ||
819 | spin_unlock_irq(&phba->hbalock); | ||
820 | } else { | ||
821 | rc = lpfc_sli4_fcf_rr_read_fcf_rec(phba, | ||
822 | fcf_index); | ||
823 | if (rc) { | ||
824 | lpfc_printf_log(phba, KERN_WARNING, | ||
825 | LOG_FIP | LOG_ELS, | ||
826 | "2761 FLOGI round " | ||
827 | "robin FCF failover " | ||
828 | "read FCF failed " | ||
829 | "rc:x%x, fcf_index:" | ||
830 | "%d\n", rc, | ||
831 | phba->fcf.current_rec.fcf_indx); | ||
832 | spin_lock_irq(&phba->hbalock); | ||
833 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; | ||
834 | spin_unlock_irq(&phba->hbalock); | ||
835 | } else | ||
836 | goto out; | ||
837 | } | ||
838 | } | ||
839 | |||
791 | /* Check for retry */ | 840 | /* Check for retry */ |
792 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) | 841 | if (lpfc_els_retry(phba, cmdiocb, rspiocb)) |
793 | goto out; | 842 | goto out; |
@@ -841,8 +890,18 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, | |||
841 | else | 890 | else |
842 | rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp); | 891 | rc = lpfc_cmpl_els_flogi_nport(vport, ndlp, sp); |
843 | 892 | ||
844 | if (!rc) | 893 | if (!rc) { |
894 | /* Mark the FCF discovery process done */ | ||
895 | lpfc_printf_vlog(vport, KERN_INFO, LOG_FIP | LOG_ELS, | ||
896 | "2769 FLOGI successful on FCF record: " | ||
897 | "current_fcf_index:x%x, terminate FCF " | ||
898 | "round robin failover process\n", | ||
899 | phba->fcf.current_rec.fcf_indx); | ||
900 | spin_lock_irq(&phba->hbalock); | ||
901 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; | ||
902 | spin_unlock_irq(&phba->hbalock); | ||
845 | goto out; | 903 | goto out; |
904 | } | ||
846 | } | 905 | } |
847 | 906 | ||
848 | flogifail: | 907 | flogifail: |
@@ -6075,21 +6134,18 @@ mbox_err_exit: | |||
6075 | } | 6134 | } |
6076 | 6135 | ||
6077 | /** | 6136 | /** |
6078 | * lpfc_retry_pport_discovery - Start timer to retry FLOGI. | 6137 | * lpfc_cancel_all_vport_retry_delay_timer - Cancel all vport retry delay timer |
6079 | * @phba: pointer to lpfc hba data structure. | 6138 | * @phba: pointer to lpfc hba data structure. |
6080 | * | 6139 | * |
6081 | * This routine abort all pending discovery commands and | 6140 | * This routine cancels the retry delay timers to all the vports. |
6082 | * start a timer to retry FLOGI for the physical port | ||
6083 | * discovery. | ||
6084 | **/ | 6141 | **/ |
6085 | void | 6142 | void |
6086 | lpfc_retry_pport_discovery(struct lpfc_hba *phba) | 6143 | lpfc_cancel_all_vport_retry_delay_timer(struct lpfc_hba *phba) |
6087 | { | 6144 | { |
6088 | struct lpfc_vport **vports; | 6145 | struct lpfc_vport **vports; |
6089 | struct lpfc_nodelist *ndlp; | 6146 | struct lpfc_nodelist *ndlp; |
6090 | struct Scsi_Host *shost; | ||
6091 | int i; | ||
6092 | uint32_t link_state; | 6147 | uint32_t link_state; |
6148 | int i; | ||
6093 | 6149 | ||
6094 | /* Treat this failure as linkdown for all vports */ | 6150 | /* Treat this failure as linkdown for all vports */ |
6095 | link_state = phba->link_state; | 6151 | link_state = phba->link_state; |
@@ -6107,13 +6163,30 @@ lpfc_retry_pport_discovery(struct lpfc_hba *phba) | |||
6107 | } | 6163 | } |
6108 | lpfc_destroy_vport_work_array(phba, vports); | 6164 | lpfc_destroy_vport_work_array(phba, vports); |
6109 | } | 6165 | } |
6166 | } | ||
6167 | |||
6168 | /** | ||
6169 | * lpfc_retry_pport_discovery - Start timer to retry FLOGI. | ||
6170 | * @phba: pointer to lpfc hba data structure. | ||
6171 | * | ||
6172 | * This routine abort all pending discovery commands and | ||
6173 | * start a timer to retry FLOGI for the physical port | ||
6174 | * discovery. | ||
6175 | **/ | ||
6176 | void | ||
6177 | lpfc_retry_pport_discovery(struct lpfc_hba *phba) | ||
6178 | { | ||
6179 | struct lpfc_nodelist *ndlp; | ||
6180 | struct Scsi_Host *shost; | ||
6181 | |||
6182 | /* Cancel the all vports retry delay retry timers */ | ||
6183 | lpfc_cancel_all_vport_retry_delay_timer(phba); | ||
6110 | 6184 | ||
6111 | /* If fabric require FLOGI, then re-instantiate physical login */ | 6185 | /* If fabric require FLOGI, then re-instantiate physical login */ |
6112 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); | 6186 | ndlp = lpfc_findnode_did(phba->pport, Fabric_DID); |
6113 | if (!ndlp) | 6187 | if (!ndlp) |
6114 | return; | 6188 | return; |
6115 | 6189 | ||
6116 | |||
6117 | shost = lpfc_shost_from_vport(phba->pport); | 6190 | shost = lpfc_shost_from_vport(phba->pport); |
6118 | mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); | 6191 | mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ); |
6119 | spin_lock_irq(shost->host_lock); | 6192 | spin_lock_irq(shost->host_lock); |
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index f28ce40dc349..c555e3b7f202 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -1481,8 +1481,6 @@ lpfc_match_fcf_conn_list(struct lpfc_hba *phba, | |||
1481 | int | 1481 | int |
1482 | lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | 1482 | lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) |
1483 | { | 1483 | { |
1484 | LPFC_MBOXQ_t *mbox; | ||
1485 | int rc; | ||
1486 | /* | 1484 | /* |
1487 | * If the Link is up and no FCoE events while in the | 1485 | * If the Link is up and no FCoE events while in the |
1488 | * FCF discovery, no need to restart FCF discovery. | 1486 | * FCF discovery, no need to restart FCF discovery. |
@@ -1491,88 +1489,70 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | |||
1491 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) | 1489 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) |
1492 | return 0; | 1490 | return 0; |
1493 | 1491 | ||
1492 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1493 | "2768 Pending link or FCF event during current " | ||
1494 | "handling of the previous event: link_state:x%x, " | ||
1495 | "evt_tag_at_scan:x%x, evt_tag_current:x%x\n", | ||
1496 | phba->link_state, phba->fcoe_eventtag_at_fcf_scan, | ||
1497 | phba->fcoe_eventtag); | ||
1498 | |||
1494 | spin_lock_irq(&phba->hbalock); | 1499 | spin_lock_irq(&phba->hbalock); |
1495 | phba->fcf.fcf_flag &= ~FCF_AVAILABLE; | 1500 | phba->fcf.fcf_flag &= ~FCF_AVAILABLE; |
1496 | spin_unlock_irq(&phba->hbalock); | 1501 | spin_unlock_irq(&phba->hbalock); |
1497 | 1502 | ||
1498 | if (phba->link_state >= LPFC_LINK_UP) | 1503 | if (phba->link_state >= LPFC_LINK_UP) { |
1499 | lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 1504 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
1500 | else { | 1505 | "2780 Restart FCF table scan due to " |
1506 | "pending FCF event:evt_tag_at_scan:x%x, " | ||
1507 | "evt_tag_current:x%x\n", | ||
1508 | phba->fcoe_eventtag_at_fcf_scan, | ||
1509 | phba->fcoe_eventtag); | ||
1510 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | ||
1511 | } else { | ||
1501 | /* | 1512 | /* |
1502 | * Do not continue FCF discovery and clear FCF_DISC_INPROGRESS | 1513 | * Do not continue FCF discovery and clear FCF_DISC_INPROGRESS |
1503 | * flag | 1514 | * flag |
1504 | */ | 1515 | */ |
1505 | spin_lock_irq(&phba->hbalock); | 1516 | spin_lock_irq(&phba->hbalock); |
1506 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1517 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; |
1507 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | | 1518 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | FCF_DISCOVERY); |
1508 | FCF_DEAD_FOVER | | ||
1509 | FCF_CVL_FOVER); | ||
1510 | spin_unlock_irq(&phba->hbalock); | 1519 | spin_unlock_irq(&phba->hbalock); |
1511 | } | 1520 | } |
1512 | 1521 | ||
1522 | /* Unregister the currently registered FCF if required */ | ||
1513 | if (unreg_fcf) { | 1523 | if (unreg_fcf) { |
1514 | spin_lock_irq(&phba->hbalock); | 1524 | spin_lock_irq(&phba->hbalock); |
1515 | phba->fcf.fcf_flag &= ~FCF_REGISTERED; | 1525 | phba->fcf.fcf_flag &= ~FCF_REGISTERED; |
1516 | spin_unlock_irq(&phba->hbalock); | 1526 | spin_unlock_irq(&phba->hbalock); |
1517 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 1527 | lpfc_sli4_unregister_fcf(phba); |
1518 | if (!mbox) { | ||
1519 | lpfc_printf_log(phba, KERN_ERR, | ||
1520 | LOG_DISCOVERY|LOG_MBOX, | ||
1521 | "2610 UNREG_FCFI mbox allocation failed\n"); | ||
1522 | return 1; | ||
1523 | } | ||
1524 | lpfc_unreg_fcfi(mbox, phba->fcf.fcfi); | ||
1525 | mbox->vport = phba->pport; | ||
1526 | mbox->mbox_cmpl = lpfc_unregister_fcfi_cmpl; | ||
1527 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); | ||
1528 | if (rc == MBX_NOT_FINISHED) { | ||
1529 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | ||
1530 | "2611 UNREG_FCFI issue mbox failed\n"); | ||
1531 | mempool_free(mbox, phba->mbox_mem_pool); | ||
1532 | } | ||
1533 | } | 1528 | } |
1534 | |||
1535 | return 1; | 1529 | return 1; |
1536 | } | 1530 | } |
1537 | 1531 | ||
1538 | /** | 1532 | /** |
1539 | * lpfc_mbx_cmpl_read_fcf_record - Completion handler for read_fcf mbox. | 1533 | * lpfc_sli4_fcf_rec_mbox_parse - parse non-embedded fcf record mailbox command |
1540 | * @phba: pointer to lpfc hba data structure. | 1534 | * @phba: pointer to lpfc hba data structure. |
1541 | * @mboxq: pointer to mailbox object. | 1535 | * @mboxq: pointer to mailbox object. |
1536 | * @next_fcf_index: pointer to holder of next fcf index. | ||
1542 | * | 1537 | * |
1543 | * This function iterate through all the fcf records available in | 1538 | * This routine parses the non-embedded fcf mailbox command by performing the |
1544 | * HBA and choose the optimal FCF record for discovery. After finding | 1539 | * necessarily error checking, non-embedded read FCF record mailbox command |
1545 | * the FCF for discovery it register the FCF record and kick start | 1540 | * SGE parsing, and endianness swapping. |
1546 | * discovery. | 1541 | * |
1547 | * If FCF_IN_USE flag is set in currently used FCF, the routine try to | 1542 | * Returns the pointer to the new FCF record in the non-embedded mailbox |
1548 | * use a FCF record which match fabric name and mac address of the | 1543 | * command DMA memory if successfully, other NULL. |
1549 | * currently used FCF record. | ||
1550 | * If the driver support only one FCF, it will try to use the FCF record | ||
1551 | * used by BOOT_BIOS. | ||
1552 | */ | 1544 | */ |
1553 | void | 1545 | static struct fcf_record * |
1554 | lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | 1546 | lpfc_sli4_fcf_rec_mbox_parse(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, |
1547 | uint16_t *next_fcf_index) | ||
1555 | { | 1548 | { |
1556 | void *virt_addr; | 1549 | void *virt_addr; |
1557 | dma_addr_t phys_addr; | 1550 | dma_addr_t phys_addr; |
1558 | uint8_t *bytep; | ||
1559 | struct lpfc_mbx_sge sge; | 1551 | struct lpfc_mbx_sge sge; |
1560 | struct lpfc_mbx_read_fcf_tbl *read_fcf; | 1552 | struct lpfc_mbx_read_fcf_tbl *read_fcf; |
1561 | uint32_t shdr_status, shdr_add_status; | 1553 | uint32_t shdr_status, shdr_add_status; |
1562 | union lpfc_sli4_cfg_shdr *shdr; | 1554 | union lpfc_sli4_cfg_shdr *shdr; |
1563 | struct fcf_record *new_fcf_record; | 1555 | struct fcf_record *new_fcf_record; |
1564 | uint32_t boot_flag, addr_mode; | ||
1565 | uint32_t next_fcf_index; | ||
1566 | struct lpfc_fcf_rec *fcf_rec = NULL; | ||
1567 | unsigned long iflags; | ||
1568 | uint16_t vlan_id; | ||
1569 | int rc; | ||
1570 | |||
1571 | /* If there is pending FCoE event restart FCF table scan */ | ||
1572 | if (lpfc_check_pending_fcoe_event(phba, 0)) { | ||
1573 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1574 | return; | ||
1575 | } | ||
1576 | 1556 | ||
1577 | /* Get the first SGE entry from the non-embedded DMA memory. This | 1557 | /* Get the first SGE entry from the non-embedded DMA memory. This |
1578 | * routine only uses a single SGE. | 1558 | * routine only uses a single SGE. |
@@ -1583,59 +1563,183 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1583 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | 1563 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
1584 | "2524 Failed to get the non-embedded SGE " | 1564 | "2524 Failed to get the non-embedded SGE " |
1585 | "virtual address\n"); | 1565 | "virtual address\n"); |
1586 | goto out; | 1566 | return NULL; |
1587 | } | 1567 | } |
1588 | virt_addr = mboxq->sge_array->addr[0]; | 1568 | virt_addr = mboxq->sge_array->addr[0]; |
1589 | 1569 | ||
1590 | shdr = (union lpfc_sli4_cfg_shdr *)virt_addr; | 1570 | shdr = (union lpfc_sli4_cfg_shdr *)virt_addr; |
1591 | shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); | 1571 | shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); |
1592 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, | 1572 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); |
1593 | &shdr->response); | ||
1594 | /* | ||
1595 | * The FCF Record was read and there is no reason for the driver | ||
1596 | * to maintain the FCF record data or memory. Instead, just need | ||
1597 | * to book keeping the FCFIs can be used. | ||
1598 | */ | ||
1599 | if (shdr_status || shdr_add_status) { | 1573 | if (shdr_status || shdr_add_status) { |
1600 | if (shdr_status == STATUS_FCF_TABLE_EMPTY) { | 1574 | if (shdr_status == STATUS_FCF_TABLE_EMPTY) |
1601 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 1575 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, |
1602 | "2726 READ_FCF_RECORD Indicates empty " | 1576 | "2726 READ_FCF_RECORD Indicates empty " |
1603 | "FCF table.\n"); | 1577 | "FCF table.\n"); |
1604 | } else { | 1578 | else |
1605 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 1579 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, |
1606 | "2521 READ_FCF_RECORD mailbox failed " | 1580 | "2521 READ_FCF_RECORD mailbox failed " |
1607 | "with status x%x add_status x%x, mbx\n", | 1581 | "with status x%x add_status x%x, " |
1608 | shdr_status, shdr_add_status); | 1582 | "mbx\n", shdr_status, shdr_add_status); |
1609 | } | 1583 | return NULL; |
1610 | goto out; | ||
1611 | } | 1584 | } |
1612 | /* Interpreting the returned information of FCF records */ | 1585 | |
1586 | /* Interpreting the returned information of the FCF record */ | ||
1613 | read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr; | 1587 | read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr; |
1614 | lpfc_sli_pcimem_bcopy(read_fcf, read_fcf, | 1588 | lpfc_sli_pcimem_bcopy(read_fcf, read_fcf, |
1615 | sizeof(struct lpfc_mbx_read_fcf_tbl)); | 1589 | sizeof(struct lpfc_mbx_read_fcf_tbl)); |
1616 | next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); | 1590 | *next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); |
1617 | |||
1618 | new_fcf_record = (struct fcf_record *)(virt_addr + | 1591 | new_fcf_record = (struct fcf_record *)(virt_addr + |
1619 | sizeof(struct lpfc_mbx_read_fcf_tbl)); | 1592 | sizeof(struct lpfc_mbx_read_fcf_tbl)); |
1620 | lpfc_sli_pcimem_bcopy(new_fcf_record, new_fcf_record, | 1593 | lpfc_sli_pcimem_bcopy(new_fcf_record, new_fcf_record, |
1621 | sizeof(struct fcf_record)); | 1594 | sizeof(struct fcf_record)); |
1622 | bytep = virt_addr + sizeof(union lpfc_sli4_cfg_shdr); | ||
1623 | 1595 | ||
1596 | return new_fcf_record; | ||
1597 | } | ||
1598 | |||
1599 | /** | ||
1600 | * lpfc_sli4_log_fcf_record_info - Log the information of a fcf record | ||
1601 | * @phba: pointer to lpfc hba data structure. | ||
1602 | * @fcf_record: pointer to the fcf record. | ||
1603 | * @vlan_id: the lowest vlan identifier associated to this fcf record. | ||
1604 | * @next_fcf_index: the index to the next fcf record in hba's fcf table. | ||
1605 | * | ||
1606 | * This routine logs the detailed FCF record if the LOG_FIP loggin is | ||
1607 | * enabled. | ||
1608 | **/ | ||
1609 | static void | ||
1610 | lpfc_sli4_log_fcf_record_info(struct lpfc_hba *phba, | ||
1611 | struct fcf_record *fcf_record, | ||
1612 | uint16_t vlan_id, | ||
1613 | uint16_t next_fcf_index) | ||
1614 | { | ||
1615 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1616 | "2764 READ_FCF_RECORD:\n" | ||
1617 | "\tFCF_Index : x%x\n" | ||
1618 | "\tFCF_Avail : x%x\n" | ||
1619 | "\tFCF_Valid : x%x\n" | ||
1620 | "\tFIP_Priority : x%x\n" | ||
1621 | "\tMAC_Provider : x%x\n" | ||
1622 | "\tLowest VLANID : x%x\n" | ||
1623 | "\tFCF_MAC Addr : x%x:%x:%x:%x:%x:%x\n" | ||
1624 | "\tFabric_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" | ||
1625 | "\tSwitch_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" | ||
1626 | "\tNext_FCF_Index: x%x\n", | ||
1627 | bf_get(lpfc_fcf_record_fcf_index, fcf_record), | ||
1628 | bf_get(lpfc_fcf_record_fcf_avail, fcf_record), | ||
1629 | bf_get(lpfc_fcf_record_fcf_valid, fcf_record), | ||
1630 | fcf_record->fip_priority, | ||
1631 | bf_get(lpfc_fcf_record_mac_addr_prov, fcf_record), | ||
1632 | vlan_id, | ||
1633 | bf_get(lpfc_fcf_record_mac_0, fcf_record), | ||
1634 | bf_get(lpfc_fcf_record_mac_1, fcf_record), | ||
1635 | bf_get(lpfc_fcf_record_mac_2, fcf_record), | ||
1636 | bf_get(lpfc_fcf_record_mac_3, fcf_record), | ||
1637 | bf_get(lpfc_fcf_record_mac_4, fcf_record), | ||
1638 | bf_get(lpfc_fcf_record_mac_5, fcf_record), | ||
1639 | bf_get(lpfc_fcf_record_fab_name_0, fcf_record), | ||
1640 | bf_get(lpfc_fcf_record_fab_name_1, fcf_record), | ||
1641 | bf_get(lpfc_fcf_record_fab_name_2, fcf_record), | ||
1642 | bf_get(lpfc_fcf_record_fab_name_3, fcf_record), | ||
1643 | bf_get(lpfc_fcf_record_fab_name_4, fcf_record), | ||
1644 | bf_get(lpfc_fcf_record_fab_name_5, fcf_record), | ||
1645 | bf_get(lpfc_fcf_record_fab_name_6, fcf_record), | ||
1646 | bf_get(lpfc_fcf_record_fab_name_7, fcf_record), | ||
1647 | bf_get(lpfc_fcf_record_switch_name_0, fcf_record), | ||
1648 | bf_get(lpfc_fcf_record_switch_name_1, fcf_record), | ||
1649 | bf_get(lpfc_fcf_record_switch_name_2, fcf_record), | ||
1650 | bf_get(lpfc_fcf_record_switch_name_3, fcf_record), | ||
1651 | bf_get(lpfc_fcf_record_switch_name_4, fcf_record), | ||
1652 | bf_get(lpfc_fcf_record_switch_name_5, fcf_record), | ||
1653 | bf_get(lpfc_fcf_record_switch_name_6, fcf_record), | ||
1654 | bf_get(lpfc_fcf_record_switch_name_7, fcf_record), | ||
1655 | next_fcf_index); | ||
1656 | } | ||
1657 | |||
1658 | /** | ||
1659 | * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler. | ||
1660 | * @phba: pointer to lpfc hba data structure. | ||
1661 | * @mboxq: pointer to mailbox object. | ||
1662 | * | ||
1663 | * This function iterates through all the fcf records available in | ||
1664 | * HBA and chooses the optimal FCF record for discovery. After finding | ||
1665 | * the FCF for discovery it registers the FCF record and kicks start | ||
1666 | * discovery. | ||
1667 | * If FCF_IN_USE flag is set in currently used FCF, the routine tries to | ||
1668 | * use an FCF record which matches fabric name and mac address of the | ||
1669 | * currently used FCF record. | ||
1670 | * If the driver supports only one FCF, it will try to use the FCF record | ||
1671 | * used by BOOT_BIOS. | ||
1672 | */ | ||
1673 | void | ||
1674 | lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
1675 | { | ||
1676 | struct fcf_record *new_fcf_record; | ||
1677 | uint32_t boot_flag, addr_mode; | ||
1678 | uint16_t fcf_index, next_fcf_index; | ||
1679 | struct lpfc_fcf_rec *fcf_rec = NULL; | ||
1680 | uint16_t vlan_id; | ||
1681 | int rc; | ||
1682 | |||
1683 | /* If there is pending FCoE event restart FCF table scan */ | ||
1684 | if (lpfc_check_pending_fcoe_event(phba, 0)) { | ||
1685 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1686 | return; | ||
1687 | } | ||
1688 | |||
1689 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
1690 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
1691 | &next_fcf_index); | ||
1692 | if (!new_fcf_record) { | ||
1693 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1694 | "2765 Mailbox command READ_FCF_RECORD " | ||
1695 | "failed to retrieve a FCF record.\n"); | ||
1696 | /* Let next new FCF event trigger fast failover */ | ||
1697 | spin_lock_irq(&phba->hbalock); | ||
1698 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1699 | spin_unlock_irq(&phba->hbalock); | ||
1700 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1701 | return; | ||
1702 | } | ||
1703 | |||
1704 | /* Check the FCF record against the connection list */ | ||
1624 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | 1705 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, |
1625 | &addr_mode, &vlan_id); | 1706 | &addr_mode, &vlan_id); |
1707 | |||
1708 | /* Log the FCF record information if turned on */ | ||
1709 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
1710 | next_fcf_index); | ||
1711 | |||
1626 | /* | 1712 | /* |
1627 | * If the fcf record does not match with connect list entries | 1713 | * If the fcf record does not match with connect list entries |
1628 | * read the next entry. | 1714 | * read the next entry; otherwise, this is an eligible FCF |
1715 | * record for round robin FCF failover. | ||
1629 | */ | 1716 | */ |
1630 | if (!rc) | 1717 | if (!rc) { |
1718 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1719 | "2781 FCF record fcf_index:x%x failed FCF " | ||
1720 | "connection list check, fcf_avail:x%x, " | ||
1721 | "fcf_valid:x%x\n", | ||
1722 | bf_get(lpfc_fcf_record_fcf_index, | ||
1723 | new_fcf_record), | ||
1724 | bf_get(lpfc_fcf_record_fcf_avail, | ||
1725 | new_fcf_record), | ||
1726 | bf_get(lpfc_fcf_record_fcf_valid, | ||
1727 | new_fcf_record)); | ||
1631 | goto read_next_fcf; | 1728 | goto read_next_fcf; |
1729 | } else { | ||
1730 | fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | ||
1731 | rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); | ||
1732 | if (rc) | ||
1733 | goto read_next_fcf; | ||
1734 | } | ||
1735 | |||
1632 | /* | 1736 | /* |
1633 | * If this is not the first FCF discovery of the HBA, use last | 1737 | * If this is not the first FCF discovery of the HBA, use last |
1634 | * FCF record for the discovery. The condition that a rescan | 1738 | * FCF record for the discovery. The condition that a rescan |
1635 | * matches the in-use FCF record: fabric name, switch name, mac | 1739 | * matches the in-use FCF record: fabric name, switch name, mac |
1636 | * address, and vlan_id. | 1740 | * address, and vlan_id. |
1637 | */ | 1741 | */ |
1638 | spin_lock_irqsave(&phba->hbalock, iflags); | 1742 | spin_lock_irq(&phba->hbalock); |
1639 | if (phba->fcf.fcf_flag & FCF_IN_USE) { | 1743 | if (phba->fcf.fcf_flag & FCF_IN_USE) { |
1640 | if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, | 1744 | if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, |
1641 | new_fcf_record) && | 1745 | new_fcf_record) && |
@@ -1652,9 +1756,8 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1652 | else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) | 1756 | else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) |
1653 | /* If in fast failover, mark it's completed */ | 1757 | /* If in fast failover, mark it's completed */ |
1654 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | | 1758 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | |
1655 | FCF_DEAD_FOVER | | 1759 | FCF_DISCOVERY); |
1656 | FCF_CVL_FOVER); | 1760 | spin_unlock_irq(&phba->hbalock); |
1657 | spin_unlock_irqrestore(&phba->hbalock, iflags); | ||
1658 | goto out; | 1761 | goto out; |
1659 | } | 1762 | } |
1660 | /* | 1763 | /* |
@@ -1665,7 +1768,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1665 | * next candidate. | 1768 | * next candidate. |
1666 | */ | 1769 | */ |
1667 | if (!(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { | 1770 | if (!(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { |
1668 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1771 | spin_unlock_irq(&phba->hbalock); |
1669 | goto read_next_fcf; | 1772 | goto read_next_fcf; |
1670 | } | 1773 | } |
1671 | } | 1774 | } |
@@ -1688,7 +1791,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1688 | /* Choose this FCF record */ | 1791 | /* Choose this FCF record */ |
1689 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, | 1792 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
1690 | addr_mode, vlan_id, BOOT_ENABLE); | 1793 | addr_mode, vlan_id, BOOT_ENABLE); |
1691 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1794 | spin_unlock_irq(&phba->hbalock); |
1692 | goto read_next_fcf; | 1795 | goto read_next_fcf; |
1693 | } | 1796 | } |
1694 | /* | 1797 | /* |
@@ -1697,7 +1800,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1697 | * the next FCF record. | 1800 | * the next FCF record. |
1698 | */ | 1801 | */ |
1699 | if (!boot_flag && (fcf_rec->flag & BOOT_ENABLE)) { | 1802 | if (!boot_flag && (fcf_rec->flag & BOOT_ENABLE)) { |
1700 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1803 | spin_unlock_irq(&phba->hbalock); |
1701 | goto read_next_fcf; | 1804 | goto read_next_fcf; |
1702 | } | 1805 | } |
1703 | /* | 1806 | /* |
@@ -1709,7 +1812,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1709 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, | 1812 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
1710 | addr_mode, vlan_id, 0); | 1813 | addr_mode, vlan_id, 0); |
1711 | } | 1814 | } |
1712 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1815 | spin_unlock_irq(&phba->hbalock); |
1713 | goto read_next_fcf; | 1816 | goto read_next_fcf; |
1714 | } | 1817 | } |
1715 | /* | 1818 | /* |
@@ -1722,7 +1825,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1722 | BOOT_ENABLE : 0)); | 1825 | BOOT_ENABLE : 0)); |
1723 | phba->fcf.fcf_flag |= FCF_AVAILABLE; | 1826 | phba->fcf.fcf_flag |= FCF_AVAILABLE; |
1724 | } | 1827 | } |
1725 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1828 | spin_unlock_irq(&phba->hbalock); |
1726 | goto read_next_fcf; | 1829 | goto read_next_fcf; |
1727 | 1830 | ||
1728 | read_next_fcf: | 1831 | read_next_fcf: |
@@ -1738,9 +1841,22 @@ read_next_fcf: | |||
1738 | * FCF scan inprogress, and do nothing | 1841 | * FCF scan inprogress, and do nothing |
1739 | */ | 1842 | */ |
1740 | if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { | 1843 | if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { |
1741 | spin_lock_irqsave(&phba->hbalock, iflags); | 1844 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, |
1845 | "2782 No suitable FCF record " | ||
1846 | "found during this round of " | ||
1847 | "post FCF rediscovery scan: " | ||
1848 | "fcf_evt_tag:x%x, fcf_index: " | ||
1849 | "x%x\n", | ||
1850 | phba->fcoe_eventtag_at_fcf_scan, | ||
1851 | bf_get(lpfc_fcf_record_fcf_index, | ||
1852 | new_fcf_record)); | ||
1853 | /* | ||
1854 | * Let next new FCF event trigger fast | ||
1855 | * failover | ||
1856 | */ | ||
1857 | spin_lock_irq(&phba->hbalock); | ||
1742 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1858 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; |
1743 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1859 | spin_unlock_irq(&phba->hbalock); |
1744 | return; | 1860 | return; |
1745 | } | 1861 | } |
1746 | /* | 1862 | /* |
@@ -1752,18 +1868,23 @@ read_next_fcf: | |||
1752 | * record. | 1868 | * record. |
1753 | */ | 1869 | */ |
1754 | 1870 | ||
1755 | /* unregister the current in-use FCF record */ | 1871 | /* Unregister the current in-use FCF record */ |
1756 | lpfc_unregister_fcf(phba); | 1872 | lpfc_unregister_fcf(phba); |
1757 | /* replace in-use record with the new record */ | 1873 | |
1874 | /* Replace in-use record with the new record */ | ||
1758 | memcpy(&phba->fcf.current_rec, | 1875 | memcpy(&phba->fcf.current_rec, |
1759 | &phba->fcf.failover_rec, | 1876 | &phba->fcf.failover_rec, |
1760 | sizeof(struct lpfc_fcf_rec)); | 1877 | sizeof(struct lpfc_fcf_rec)); |
1761 | /* mark the FCF fast failover completed */ | 1878 | /* mark the FCF fast failover completed */ |
1762 | spin_lock_irqsave(&phba->hbalock, iflags); | 1879 | spin_lock_irq(&phba->hbalock); |
1763 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | | 1880 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; |
1764 | FCF_DEAD_FOVER | | 1881 | spin_unlock_irq(&phba->hbalock); |
1765 | FCF_CVL_FOVER); | 1882 | /* |
1766 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1883 | * Set up the initial registered FCF index for FLOGI |
1884 | * round robin FCF failover. | ||
1885 | */ | ||
1886 | phba->fcf.fcf_rr_init_indx = | ||
1887 | phba->fcf.failover_rec.fcf_indx; | ||
1767 | /* Register to the new FCF record */ | 1888 | /* Register to the new FCF record */ |
1768 | lpfc_register_fcf(phba); | 1889 | lpfc_register_fcf(phba); |
1769 | } else { | 1890 | } else { |
@@ -1776,13 +1897,25 @@ read_next_fcf: | |||
1776 | return; | 1897 | return; |
1777 | /* | 1898 | /* |
1778 | * Otherwise, initial scan or post linkdown rescan, | 1899 | * Otherwise, initial scan or post linkdown rescan, |
1779 | * register with the best fit FCF record found so | 1900 | * register with the best FCF record found so far |
1780 | * far through the scanning process. | 1901 | * through the FCF scanning process. |
1902 | */ | ||
1903 | |||
1904 | /* mark the initial FCF discovery completed */ | ||
1905 | spin_lock_irq(&phba->hbalock); | ||
1906 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
1907 | spin_unlock_irq(&phba->hbalock); | ||
1908 | /* | ||
1909 | * Set up the initial registered FCF index for FLOGI | ||
1910 | * round robin FCF failover | ||
1781 | */ | 1911 | */ |
1912 | phba->fcf.fcf_rr_init_indx = | ||
1913 | phba->fcf.current_rec.fcf_indx; | ||
1914 | /* Register to the new FCF record */ | ||
1782 | lpfc_register_fcf(phba); | 1915 | lpfc_register_fcf(phba); |
1783 | } | 1916 | } |
1784 | } else | 1917 | } else |
1785 | lpfc_sli4_read_fcf_record(phba, next_fcf_index); | 1918 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, next_fcf_index); |
1786 | return; | 1919 | return; |
1787 | 1920 | ||
1788 | out: | 1921 | out: |
@@ -1793,6 +1926,141 @@ out: | |||
1793 | } | 1926 | } |
1794 | 1927 | ||
1795 | /** | 1928 | /** |
1929 | * lpfc_mbx_cmpl_fcf_rr_read_fcf_rec - fcf round robin read_fcf mbox cmpl hdler | ||
1930 | * @phba: pointer to lpfc hba data structure. | ||
1931 | * @mboxq: pointer to mailbox object. | ||
1932 | * | ||
1933 | * This is the callback function for FLOGI failure round robin FCF failover | ||
1934 | * read FCF record mailbox command from the eligible FCF record bmask for | ||
1935 | * performing the failover. If the FCF read back is not valid/available, it | ||
1936 | * fails through to retrying FLOGI to the currently registered FCF again. | ||
1937 | * Otherwise, if the FCF read back is valid and available, it will set the | ||
1938 | * newly read FCF record to the failover FCF record, unregister currently | ||
1939 | * registered FCF record, copy the failover FCF record to the current | ||
1940 | * FCF record, and then register the current FCF record before proceeding | ||
1941 | * to trying FLOGI on the new failover FCF. | ||
1942 | */ | ||
1943 | void | ||
1944 | lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
1945 | { | ||
1946 | struct fcf_record *new_fcf_record; | ||
1947 | uint32_t boot_flag, addr_mode; | ||
1948 | uint16_t next_fcf_index; | ||
1949 | uint16_t current_fcf_index; | ||
1950 | uint16_t vlan_id; | ||
1951 | |||
1952 | /* If link state is not up, stop the round robin failover process */ | ||
1953 | if (phba->link_state < LPFC_LINK_UP) { | ||
1954 | spin_lock_irq(&phba->hbalock); | ||
1955 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; | ||
1956 | spin_unlock_irq(&phba->hbalock); | ||
1957 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1958 | return; | ||
1959 | } | ||
1960 | |||
1961 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
1962 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
1963 | &next_fcf_index); | ||
1964 | if (!new_fcf_record) { | ||
1965 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1966 | "2766 Mailbox command READ_FCF_RECORD " | ||
1967 | "failed to retrieve a FCF record.\n"); | ||
1968 | goto out; | ||
1969 | } | ||
1970 | |||
1971 | /* Get the needed parameters from FCF record */ | ||
1972 | lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | ||
1973 | &addr_mode, &vlan_id); | ||
1974 | |||
1975 | /* Log the FCF record information if turned on */ | ||
1976 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
1977 | next_fcf_index); | ||
1978 | |||
1979 | /* Upload new FCF record to the failover FCF record */ | ||
1980 | spin_lock_irq(&phba->hbalock); | ||
1981 | __lpfc_update_fcf_record(phba, &phba->fcf.failover_rec, | ||
1982 | new_fcf_record, addr_mode, vlan_id, | ||
1983 | (boot_flag ? BOOT_ENABLE : 0)); | ||
1984 | spin_unlock_irq(&phba->hbalock); | ||
1985 | |||
1986 | current_fcf_index = phba->fcf.current_rec.fcf_indx; | ||
1987 | |||
1988 | /* Unregister the current in-use FCF record */ | ||
1989 | lpfc_unregister_fcf(phba); | ||
1990 | |||
1991 | /* Replace in-use record with the new record */ | ||
1992 | memcpy(&phba->fcf.current_rec, &phba->fcf.failover_rec, | ||
1993 | sizeof(struct lpfc_fcf_rec)); | ||
1994 | |||
1995 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1996 | "2783 FLOGI round robin FCF failover from FCF " | ||
1997 | "(index:x%x) to FCF (index:x%x).\n", | ||
1998 | current_fcf_index, | ||
1999 | bf_get(lpfc_fcf_record_fcf_index, new_fcf_record)); | ||
2000 | |||
2001 | out: | ||
2002 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
2003 | lpfc_register_fcf(phba); | ||
2004 | } | ||
2005 | |||
2006 | /** | ||
2007 | * lpfc_mbx_cmpl_read_fcf_rec - read fcf completion handler. | ||
2008 | * @phba: pointer to lpfc hba data structure. | ||
2009 | * @mboxq: pointer to mailbox object. | ||
2010 | * | ||
2011 | * This is the callback function of read FCF record mailbox command for | ||
2012 | * updating the eligible FCF bmask for FLOGI failure round robin FCF | ||
2013 | * failover when a new FCF event happened. If the FCF read back is | ||
2014 | * valid/available and it passes the connection list check, it updates | ||
2015 | * the bmask for the eligible FCF record for round robin failover. | ||
2016 | */ | ||
2017 | void | ||
2018 | lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
2019 | { | ||
2020 | struct fcf_record *new_fcf_record; | ||
2021 | uint32_t boot_flag, addr_mode; | ||
2022 | uint16_t fcf_index, next_fcf_index; | ||
2023 | uint16_t vlan_id; | ||
2024 | int rc; | ||
2025 | |||
2026 | /* If link state is not up, no need to proceed */ | ||
2027 | if (phba->link_state < LPFC_LINK_UP) | ||
2028 | goto out; | ||
2029 | |||
2030 | /* If FCF discovery period is over, no need to proceed */ | ||
2031 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) | ||
2032 | goto out; | ||
2033 | |||
2034 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
2035 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
2036 | &next_fcf_index); | ||
2037 | if (!new_fcf_record) { | ||
2038 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
2039 | "2767 Mailbox command READ_FCF_RECORD " | ||
2040 | "failed to retrieve a FCF record.\n"); | ||
2041 | goto out; | ||
2042 | } | ||
2043 | |||
2044 | /* Check the connection list for eligibility */ | ||
2045 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | ||
2046 | &addr_mode, &vlan_id); | ||
2047 | |||
2048 | /* Log the FCF record information if turned on */ | ||
2049 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
2050 | next_fcf_index); | ||
2051 | |||
2052 | if (!rc) | ||
2053 | goto out; | ||
2054 | |||
2055 | /* Update the eligible FCF record index bmask */ | ||
2056 | fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | ||
2057 | rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); | ||
2058 | |||
2059 | out: | ||
2060 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
2061 | } | ||
2062 | |||
2063 | /** | ||
1796 | * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. | 2064 | * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. |
1797 | * @phba: pointer to lpfc hba data structure. | 2065 | * @phba: pointer to lpfc hba data structure. |
1798 | * @mboxq: pointer to mailbox data structure. | 2066 | * @mboxq: pointer to mailbox data structure. |
@@ -2190,10 +2458,20 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
2190 | spin_unlock_irq(&phba->hbalock); | 2458 | spin_unlock_irq(&phba->hbalock); |
2191 | return; | 2459 | return; |
2192 | } | 2460 | } |
2461 | /* This is the initial FCF discovery scan */ | ||
2462 | phba->fcf.fcf_flag |= FCF_INIT_DISC; | ||
2193 | spin_unlock_irq(&phba->hbalock); | 2463 | spin_unlock_irq(&phba->hbalock); |
2194 | rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 2464 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
2195 | if (rc) | 2465 | "2778 Start FCF table scan at linkup\n"); |
2466 | |||
2467 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, | ||
2468 | LPFC_FCOE_FCF_GET_FIRST); | ||
2469 | if (rc) { | ||
2470 | spin_lock_irq(&phba->hbalock); | ||
2471 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
2472 | spin_unlock_irq(&phba->hbalock); | ||
2196 | goto out; | 2473 | goto out; |
2474 | } | ||
2197 | } | 2475 | } |
2198 | 2476 | ||
2199 | return; | 2477 | return; |
@@ -3383,8 +3661,12 @@ lpfc_unreg_hba_rpis(struct lpfc_hba *phba) | |||
3383 | shost = lpfc_shost_from_vport(vports[i]); | 3661 | shost = lpfc_shost_from_vport(vports[i]); |
3384 | spin_lock_irq(shost->host_lock); | 3662 | spin_lock_irq(shost->host_lock); |
3385 | list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { | 3663 | list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { |
3386 | if (ndlp->nlp_flag & NLP_RPI_VALID) | 3664 | if (ndlp->nlp_flag & NLP_RPI_VALID) { |
3665 | /* The mempool_alloc might sleep */ | ||
3666 | spin_unlock_irq(shost->host_lock); | ||
3387 | lpfc_unreg_rpi(vports[i], ndlp); | 3667 | lpfc_unreg_rpi(vports[i], ndlp); |
3668 | spin_lock_irq(shost->host_lock); | ||
3669 | } | ||
3388 | } | 3670 | } |
3389 | spin_unlock_irq(shost->host_lock); | 3671 | spin_unlock_irq(shost->host_lock); |
3390 | } | 3672 | } |
@@ -4770,13 +5052,21 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba) | |||
4770 | (phba->link_state < LPFC_LINK_UP)) | 5052 | (phba->link_state < LPFC_LINK_UP)) |
4771 | return; | 5053 | return; |
4772 | 5054 | ||
4773 | rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 5055 | /* This is considered as the initial FCF discovery scan */ |
5056 | spin_lock_irq(&phba->hbalock); | ||
5057 | phba->fcf.fcf_flag |= FCF_INIT_DISC; | ||
5058 | spin_unlock_irq(&phba->hbalock); | ||
5059 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | ||
4774 | 5060 | ||
4775 | if (rc) | 5061 | if (rc) { |
5062 | spin_lock_irq(&phba->hbalock); | ||
5063 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
5064 | spin_unlock_irq(&phba->hbalock); | ||
4776 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | 5065 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
4777 | "2553 lpfc_unregister_unused_fcf failed " | 5066 | "2553 lpfc_unregister_unused_fcf failed " |
4778 | "to read FCF record HBA state x%x\n", | 5067 | "to read FCF record HBA state x%x\n", |
4779 | phba->pport->port_state); | 5068 | phba->pport->port_state); |
5069 | } | ||
4780 | } | 5070 | } |
4781 | 5071 | ||
4782 | /** | 5072 | /** |
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index ff45e336917a..ea44239eeb33 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -2201,8 +2201,8 @@ __lpfc_sli4_stop_fcf_redisc_wait_timer(struct lpfc_hba *phba) | |||
2201 | { | 2201 | { |
2202 | /* Clear pending FCF rediscovery wait and failover in progress flags */ | 2202 | /* Clear pending FCF rediscovery wait and failover in progress flags */ |
2203 | phba->fcf.fcf_flag &= ~(FCF_REDISC_PEND | | 2203 | phba->fcf.fcf_flag &= ~(FCF_REDISC_PEND | |
2204 | FCF_DEAD_FOVER | | 2204 | FCF_DEAD_DISC | |
2205 | FCF_CVL_FOVER); | 2205 | FCF_ACVL_DISC); |
2206 | /* Now, try to stop the timer */ | 2206 | /* Now, try to stop the timer */ |
2207 | del_timer(&phba->fcf.redisc_wait); | 2207 | del_timer(&phba->fcf.redisc_wait); |
2208 | } | 2208 | } |
@@ -2943,6 +2943,9 @@ lpfc_sli4_fcf_redisc_wait_tmo(unsigned long ptr) | |||
2943 | /* FCF rediscovery event to worker thread */ | 2943 | /* FCF rediscovery event to worker thread */ |
2944 | phba->fcf.fcf_flag |= FCF_REDISC_EVT; | 2944 | phba->fcf.fcf_flag |= FCF_REDISC_EVT; |
2945 | spin_unlock_irq(&phba->hbalock); | 2945 | spin_unlock_irq(&phba->hbalock); |
2946 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
2947 | "2776 FCF rediscover wait timer expired, post " | ||
2948 | "a worker thread event for FCF table scan\n"); | ||
2946 | /* wake up worker thread */ | 2949 | /* wake up worker thread */ |
2947 | lpfc_worker_wake_up(phba); | 2950 | lpfc_worker_wake_up(phba); |
2948 | } | 2951 | } |
@@ -3300,10 +3303,11 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, | |||
3300 | switch (event_type) { | 3303 | switch (event_type) { |
3301 | case LPFC_FCOE_EVENT_TYPE_NEW_FCF: | 3304 | case LPFC_FCOE_EVENT_TYPE_NEW_FCF: |
3302 | case LPFC_FCOE_EVENT_TYPE_FCF_PARAM_MOD: | 3305 | case LPFC_FCOE_EVENT_TYPE_FCF_PARAM_MOD: |
3303 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | 3306 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, |
3304 | "2546 New FCF found index 0x%x tag 0x%x\n", | 3307 | "2546 New FCF found/FCF parameter modified event: " |
3305 | acqe_fcoe->index, | 3308 | "evt_tag:x%x, fcf_index:x%x\n", |
3306 | acqe_fcoe->event_tag); | 3309 | acqe_fcoe->event_tag, acqe_fcoe->index); |
3310 | |||
3307 | spin_lock_irq(&phba->hbalock); | 3311 | spin_lock_irq(&phba->hbalock); |
3308 | if ((phba->fcf.fcf_flag & FCF_SCAN_DONE) || | 3312 | if ((phba->fcf.fcf_flag & FCF_SCAN_DONE) || |
3309 | (phba->hba_flag & FCF_DISC_INPROGRESS)) { | 3313 | (phba->hba_flag & FCF_DISC_INPROGRESS)) { |
@@ -3314,6 +3318,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, | |||
3314 | spin_unlock_irq(&phba->hbalock); | 3318 | spin_unlock_irq(&phba->hbalock); |
3315 | break; | 3319 | break; |
3316 | } | 3320 | } |
3321 | |||
3317 | if (phba->fcf.fcf_flag & FCF_REDISC_EVT) { | 3322 | if (phba->fcf.fcf_flag & FCF_REDISC_EVT) { |
3318 | /* | 3323 | /* |
3319 | * If fast FCF failover rescan event is pending, | 3324 | * If fast FCF failover rescan event is pending, |
@@ -3324,12 +3329,33 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, | |||
3324 | } | 3329 | } |
3325 | spin_unlock_irq(&phba->hbalock); | 3330 | spin_unlock_irq(&phba->hbalock); |
3326 | 3331 | ||
3327 | /* Read the FCF table and re-discover SAN. */ | 3332 | if ((phba->fcf.fcf_flag & FCF_DISCOVERY) && |
3328 | rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 3333 | !(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { |
3334 | /* | ||
3335 | * During period of FCF discovery, read the FCF | ||
3336 | * table record indexed by the event to update | ||
3337 | * FCF round robin failover eligible FCF bmask. | ||
3338 | */ | ||
3339 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | | ||
3340 | LOG_DISCOVERY, | ||
3341 | "2779 Read new FCF record with " | ||
3342 | "fcf_index:x%x for updating FCF " | ||
3343 | "round robin failover bmask\n", | ||
3344 | acqe_fcoe->index); | ||
3345 | rc = lpfc_sli4_read_fcf_rec(phba, acqe_fcoe->index); | ||
3346 | } | ||
3347 | |||
3348 | /* Otherwise, scan the entire FCF table and re-discover SAN */ | ||
3349 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, | ||
3350 | "2770 Start FCF table scan due to new FCF " | ||
3351 | "event: evt_tag:x%x, fcf_index:x%x\n", | ||
3352 | acqe_fcoe->event_tag, acqe_fcoe->index); | ||
3353 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, | ||
3354 | LPFC_FCOE_FCF_GET_FIRST); | ||
3329 | if (rc) | 3355 | if (rc) |
3330 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | 3356 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, |
3331 | "2547 Read FCF record failed 0x%x\n", | 3357 | "2547 Issue FCF scan read FCF mailbox " |
3332 | rc); | 3358 | "command failed 0x%x\n", rc); |
3333 | break; | 3359 | break; |
3334 | 3360 | ||
3335 | case LPFC_FCOE_EVENT_TYPE_FCF_TABLE_FULL: | 3361 | case LPFC_FCOE_EVENT_TYPE_FCF_TABLE_FULL: |
@@ -3340,7 +3366,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, | |||
3340 | break; | 3366 | break; |
3341 | 3367 | ||
3342 | case LPFC_FCOE_EVENT_TYPE_FCF_DEAD: | 3368 | case LPFC_FCOE_EVENT_TYPE_FCF_DEAD: |
3343 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | 3369 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, |
3344 | "2549 FCF disconnected from network index 0x%x" | 3370 | "2549 FCF disconnected from network index 0x%x" |
3345 | " tag 0x%x\n", acqe_fcoe->index, | 3371 | " tag 0x%x\n", acqe_fcoe->index, |
3346 | acqe_fcoe->event_tag); | 3372 | acqe_fcoe->event_tag); |
@@ -3349,21 +3375,32 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, | |||
3349 | break; | 3375 | break; |
3350 | /* We request port to rediscover the entire FCF table for | 3376 | /* We request port to rediscover the entire FCF table for |
3351 | * a fast recovery from case that the current FCF record | 3377 | * a fast recovery from case that the current FCF record |
3352 | * is no longer valid if the last CVL event hasn't already | 3378 | * is no longer valid if we are not in the middle of FCF |
3353 | * triggered process. | 3379 | * failover process already. |
3354 | */ | 3380 | */ |
3355 | spin_lock_irq(&phba->hbalock); | 3381 | spin_lock_irq(&phba->hbalock); |
3356 | if (phba->fcf.fcf_flag & FCF_CVL_FOVER) { | 3382 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) { |
3357 | spin_unlock_irq(&phba->hbalock); | 3383 | spin_unlock_irq(&phba->hbalock); |
3384 | /* Update FLOGI FCF failover eligible FCF bmask */ | ||
3385 | lpfc_sli4_fcf_rr_index_clear(phba, acqe_fcoe->index); | ||
3358 | break; | 3386 | break; |
3359 | } | 3387 | } |
3360 | /* Mark the fast failover process in progress */ | 3388 | /* Mark the fast failover process in progress */ |
3361 | phba->fcf.fcf_flag |= FCF_DEAD_FOVER; | 3389 | phba->fcf.fcf_flag |= FCF_DEAD_DISC; |
3362 | spin_unlock_irq(&phba->hbalock); | 3390 | spin_unlock_irq(&phba->hbalock); |
3391 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, | ||
3392 | "2771 Start FCF fast failover process due to " | ||
3393 | "FCF DEAD event: evt_tag:x%x, fcf_index:x%x " | ||
3394 | "\n", acqe_fcoe->event_tag, acqe_fcoe->index); | ||
3363 | rc = lpfc_sli4_redisc_fcf_table(phba); | 3395 | rc = lpfc_sli4_redisc_fcf_table(phba); |
3364 | if (rc) { | 3396 | if (rc) { |
3397 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | | ||
3398 | LOG_DISCOVERY, | ||
3399 | "2772 Issue FCF rediscover mabilbox " | ||
3400 | "command failed, fail through to FCF " | ||
3401 | "dead event\n"); | ||
3365 | spin_lock_irq(&phba->hbalock); | 3402 | spin_lock_irq(&phba->hbalock); |
3366 | phba->fcf.fcf_flag &= ~FCF_DEAD_FOVER; | 3403 | phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; |
3367 | spin_unlock_irq(&phba->hbalock); | 3404 | spin_unlock_irq(&phba->hbalock); |
3368 | /* | 3405 | /* |
3369 | * Last resort will fail over by treating this | 3406 | * Last resort will fail over by treating this |
@@ -3378,7 +3415,7 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, | |||
3378 | lpfc_sli4_perform_all_vport_cvl(phba); | 3415 | lpfc_sli4_perform_all_vport_cvl(phba); |
3379 | break; | 3416 | break; |
3380 | case LPFC_FCOE_EVENT_TYPE_CVL: | 3417 | case LPFC_FCOE_EVENT_TYPE_CVL: |
3381 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | 3418 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, |
3382 | "2718 Clear Virtual Link Received for VPI 0x%x" | 3419 | "2718 Clear Virtual Link Received for VPI 0x%x" |
3383 | " tag 0x%x\n", acqe_fcoe->index, acqe_fcoe->event_tag); | 3420 | " tag 0x%x\n", acqe_fcoe->index, acqe_fcoe->event_tag); |
3384 | vport = lpfc_find_vport_by_vpid(phba, | 3421 | vport = lpfc_find_vport_by_vpid(phba, |
@@ -3419,21 +3456,31 @@ lpfc_sli4_async_fcoe_evt(struct lpfc_hba *phba, | |||
3419 | * Otherwise, we request port to rediscover | 3456 | * Otherwise, we request port to rediscover |
3420 | * the entire FCF table for a fast recovery | 3457 | * the entire FCF table for a fast recovery |
3421 | * from possible case that the current FCF | 3458 | * from possible case that the current FCF |
3422 | * is no longer valid if the FCF_DEAD event | 3459 | * is no longer valid if we are not already |
3423 | * hasn't already triggered process. | 3460 | * in the FCF failover process. |
3424 | */ | 3461 | */ |
3425 | spin_lock_irq(&phba->hbalock); | 3462 | spin_lock_irq(&phba->hbalock); |
3426 | if (phba->fcf.fcf_flag & FCF_DEAD_FOVER) { | 3463 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) { |
3427 | spin_unlock_irq(&phba->hbalock); | 3464 | spin_unlock_irq(&phba->hbalock); |
3428 | break; | 3465 | break; |
3429 | } | 3466 | } |
3430 | /* Mark the fast failover process in progress */ | 3467 | /* Mark the fast failover process in progress */ |
3431 | phba->fcf.fcf_flag |= FCF_CVL_FOVER; | 3468 | phba->fcf.fcf_flag |= FCF_ACVL_DISC; |
3432 | spin_unlock_irq(&phba->hbalock); | 3469 | spin_unlock_irq(&phba->hbalock); |
3470 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | | ||
3471 | LOG_DISCOVERY, | ||
3472 | "2773 Start FCF fast failover due " | ||
3473 | "to CVL event: evt_tag:x%x\n", | ||
3474 | acqe_fcoe->event_tag); | ||
3433 | rc = lpfc_sli4_redisc_fcf_table(phba); | 3475 | rc = lpfc_sli4_redisc_fcf_table(phba); |
3434 | if (rc) { | 3476 | if (rc) { |
3477 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | | ||
3478 | LOG_DISCOVERY, | ||
3479 | "2774 Issue FCF rediscover " | ||
3480 | "mabilbox command failed, " | ||
3481 | "through to CVL event\n"); | ||
3435 | spin_lock_irq(&phba->hbalock); | 3482 | spin_lock_irq(&phba->hbalock); |
3436 | phba->fcf.fcf_flag &= ~FCF_CVL_FOVER; | 3483 | phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; |
3437 | spin_unlock_irq(&phba->hbalock); | 3484 | spin_unlock_irq(&phba->hbalock); |
3438 | /* | 3485 | /* |
3439 | * Last resort will be re-try on the | 3486 | * Last resort will be re-try on the |
@@ -3537,11 +3584,14 @@ void lpfc_sli4_fcf_redisc_event_proc(struct lpfc_hba *phba) | |||
3537 | spin_unlock_irq(&phba->hbalock); | 3584 | spin_unlock_irq(&phba->hbalock); |
3538 | 3585 | ||
3539 | /* Scan FCF table from the first entry to re-discover SAN */ | 3586 | /* Scan FCF table from the first entry to re-discover SAN */ |
3540 | rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 3587 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
3588 | "2777 Start FCF table scan after FCF " | ||
3589 | "rediscovery quiescent period over\n"); | ||
3590 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | ||
3541 | if (rc) | 3591 | if (rc) |
3542 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY, | 3592 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_DISCOVERY, |
3543 | "2747 Post FCF rediscovery read FCF record " | 3593 | "2747 Issue FCF scan read FCF mailbox " |
3544 | "failed 0x%x\n", rc); | 3594 | "command failed 0x%x\n", rc); |
3545 | } | 3595 | } |
3546 | 3596 | ||
3547 | /** | 3597 | /** |
@@ -3833,6 +3883,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) | |||
3833 | int rc, i, hbq_count, buf_size, dma_buf_size, max_buf_size; | 3883 | int rc, i, hbq_count, buf_size, dma_buf_size, max_buf_size; |
3834 | uint8_t pn_page[LPFC_MAX_SUPPORTED_PAGES] = {0}; | 3884 | uint8_t pn_page[LPFC_MAX_SUPPORTED_PAGES] = {0}; |
3835 | struct lpfc_mqe *mqe; | 3885 | struct lpfc_mqe *mqe; |
3886 | int longs; | ||
3836 | 3887 | ||
3837 | /* Before proceed, wait for POST done and device ready */ | 3888 | /* Before proceed, wait for POST done and device ready */ |
3838 | rc = lpfc_sli4_post_status_check(phba); | 3889 | rc = lpfc_sli4_post_status_check(phba); |
@@ -4009,13 +4060,24 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) | |||
4009 | goto out_free_active_sgl; | 4060 | goto out_free_active_sgl; |
4010 | } | 4061 | } |
4011 | 4062 | ||
4063 | /* Allocate eligible FCF bmask memory for FCF round robin failover */ | ||
4064 | longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; | ||
4065 | phba->fcf.fcf_rr_bmask = kzalloc(longs * sizeof(unsigned long), | ||
4066 | GFP_KERNEL); | ||
4067 | if (!phba->fcf.fcf_rr_bmask) { | ||
4068 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | ||
4069 | "2759 Failed allocate memory for FCF round " | ||
4070 | "robin failover bmask\n"); | ||
4071 | goto out_remove_rpi_hdrs; | ||
4072 | } | ||
4073 | |||
4012 | phba->sli4_hba.fcp_eq_hdl = kzalloc((sizeof(struct lpfc_fcp_eq_hdl) * | 4074 | phba->sli4_hba.fcp_eq_hdl = kzalloc((sizeof(struct lpfc_fcp_eq_hdl) * |
4013 | phba->cfg_fcp_eq_count), GFP_KERNEL); | 4075 | phba->cfg_fcp_eq_count), GFP_KERNEL); |
4014 | if (!phba->sli4_hba.fcp_eq_hdl) { | 4076 | if (!phba->sli4_hba.fcp_eq_hdl) { |
4015 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 4077 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
4016 | "2572 Failed allocate memory for fast-path " | 4078 | "2572 Failed allocate memory for fast-path " |
4017 | "per-EQ handle array\n"); | 4079 | "per-EQ handle array\n"); |
4018 | goto out_remove_rpi_hdrs; | 4080 | goto out_free_fcf_rr_bmask; |
4019 | } | 4081 | } |
4020 | 4082 | ||
4021 | phba->sli4_hba.msix_entries = kzalloc((sizeof(struct msix_entry) * | 4083 | phba->sli4_hba.msix_entries = kzalloc((sizeof(struct msix_entry) * |
@@ -4068,6 +4130,8 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) | |||
4068 | 4130 | ||
4069 | out_free_fcp_eq_hdl: | 4131 | out_free_fcp_eq_hdl: |
4070 | kfree(phba->sli4_hba.fcp_eq_hdl); | 4132 | kfree(phba->sli4_hba.fcp_eq_hdl); |
4133 | out_free_fcf_rr_bmask: | ||
4134 | kfree(phba->fcf.fcf_rr_bmask); | ||
4071 | out_remove_rpi_hdrs: | 4135 | out_remove_rpi_hdrs: |
4072 | lpfc_sli4_remove_rpi_hdrs(phba); | 4136 | lpfc_sli4_remove_rpi_hdrs(phba); |
4073 | out_free_active_sgl: | 4137 | out_free_active_sgl: |
@@ -4113,6 +4177,9 @@ lpfc_sli4_driver_resource_unset(struct lpfc_hba *phba) | |||
4113 | lpfc_sli4_remove_rpi_hdrs(phba); | 4177 | lpfc_sli4_remove_rpi_hdrs(phba); |
4114 | lpfc_sli4_remove_rpis(phba); | 4178 | lpfc_sli4_remove_rpis(phba); |
4115 | 4179 | ||
4180 | /* Free eligible FCF index bmask */ | ||
4181 | kfree(phba->fcf.fcf_rr_bmask); | ||
4182 | |||
4116 | /* Free the ELS sgl list */ | 4183 | /* Free the ELS sgl list */ |
4117 | lpfc_free_active_sgl(phba); | 4184 | lpfc_free_active_sgl(phba); |
4118 | lpfc_free_sgl_list(phba); | 4185 | lpfc_free_sgl_list(phba); |
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h index 954ba57970a3..bb59e9273126 100644 --- a/drivers/scsi/lpfc/lpfc_logmsg.h +++ b/drivers/scsi/lpfc/lpfc_logmsg.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #define LOG_VPORT 0x00004000 /* NPIV events */ | 35 | #define LOG_VPORT 0x00004000 /* NPIV events */ |
36 | #define LOF_SECURITY 0x00008000 /* Security events */ | 36 | #define LOF_SECURITY 0x00008000 /* Security events */ |
37 | #define LOG_EVENT 0x00010000 /* CT,TEMP,DUMP, logging */ | 37 | #define LOG_EVENT 0x00010000 /* CT,TEMP,DUMP, logging */ |
38 | #define LOG_FIP 0x00020000 /* FIP events */ | ||
38 | #define LOG_ALL_MSG 0xffffffff /* LOG all messages */ | 39 | #define LOG_ALL_MSG 0xffffffff /* LOG all messages */ |
39 | 40 | ||
40 | #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \ | 41 | #define lpfc_printf_vlog(vport, level, mask, fmt, arg...) \ |
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index 6c4dce1a30ca..1e61ae3bc4eb 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |||
@@ -1748,7 +1748,7 @@ lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox) | |||
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | /** | 1750 | /** |
1751 | * lpfc_sli4_mbx_read_fcf_record - Allocate and construct read fcf mbox cmd | 1751 | * lpfc_sli4_mbx_read_fcf_rec - Allocate and construct read fcf mbox cmd |
1752 | * @phba: pointer to lpfc hba data structure. | 1752 | * @phba: pointer to lpfc hba data structure. |
1753 | * @fcf_index: index to fcf table. | 1753 | * @fcf_index: index to fcf table. |
1754 | * | 1754 | * |
@@ -1759,9 +1759,9 @@ lpfc_sli4_mbox_opcode_get(struct lpfc_hba *phba, struct lpfcMboxq *mbox) | |||
1759 | * NULL. | 1759 | * NULL. |
1760 | **/ | 1760 | **/ |
1761 | int | 1761 | int |
1762 | lpfc_sli4_mbx_read_fcf_record(struct lpfc_hba *phba, | 1762 | lpfc_sli4_mbx_read_fcf_rec(struct lpfc_hba *phba, |
1763 | struct lpfcMboxq *mboxq, | 1763 | struct lpfcMboxq *mboxq, |
1764 | uint16_t fcf_index) | 1764 | uint16_t fcf_index) |
1765 | { | 1765 | { |
1766 | void *virt_addr; | 1766 | void *virt_addr; |
1767 | dma_addr_t phys_addr; | 1767 | dma_addr_t phys_addr; |
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index bb6a4426d469..fe6660ca6452 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
@@ -11996,15 +11996,19 @@ lpfc_sli4_build_dflt_fcf_record(struct lpfc_hba *phba, | |||
11996 | } | 11996 | } |
11997 | 11997 | ||
11998 | /** | 11998 | /** |
11999 | * lpfc_sli4_read_fcf_record - Read the driver's default FCF Record. | 11999 | * lpfc_sli4_fcf_scan_read_fcf_rec - Read hba fcf record for fcf scan. |
12000 | * @phba: pointer to lpfc hba data structure. | 12000 | * @phba: pointer to lpfc hba data structure. |
12001 | * @fcf_index: FCF table entry offset. | 12001 | * @fcf_index: FCF table entry offset. |
12002 | * | 12002 | * |
12003 | * This routine is invoked to read up to @fcf_num of FCF record from the | 12003 | * This routine is invoked to scan the entire FCF table by reading FCF |
12004 | * device starting with the given @fcf_index. | 12004 | * record and processing it one at a time starting from the @fcf_index |
12005 | * for initial FCF discovery or fast FCF failover rediscovery. | ||
12006 | * | ||
12007 | * Return 0 if the mailbox command is submitted sucessfully, none 0 | ||
12008 | * otherwise. | ||
12005 | **/ | 12009 | **/ |
12006 | int | 12010 | int |
12007 | lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index) | 12011 | lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) |
12008 | { | 12012 | { |
12009 | int rc = 0, error; | 12013 | int rc = 0, error; |
12010 | LPFC_MBOXQ_t *mboxq; | 12014 | LPFC_MBOXQ_t *mboxq; |
@@ -12016,17 +12020,17 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index) | |||
12016 | "2000 Failed to allocate mbox for " | 12020 | "2000 Failed to allocate mbox for " |
12017 | "READ_FCF cmd\n"); | 12021 | "READ_FCF cmd\n"); |
12018 | error = -ENOMEM; | 12022 | error = -ENOMEM; |
12019 | goto fail_fcfscan; | 12023 | goto fail_fcf_scan; |
12020 | } | 12024 | } |
12021 | /* Construct the read FCF record mailbox command */ | 12025 | /* Construct the read FCF record mailbox command */ |
12022 | rc = lpfc_sli4_mbx_read_fcf_record(phba, mboxq, fcf_index); | 12026 | rc = lpfc_sli4_mbx_read_fcf_rec(phba, mboxq, fcf_index); |
12023 | if (rc) { | 12027 | if (rc) { |
12024 | error = -EINVAL; | 12028 | error = -EINVAL; |
12025 | goto fail_fcfscan; | 12029 | goto fail_fcf_scan; |
12026 | } | 12030 | } |
12027 | /* Issue the mailbox command asynchronously */ | 12031 | /* Issue the mailbox command asynchronously */ |
12028 | mboxq->vport = phba->pport; | 12032 | mboxq->vport = phba->pport; |
12029 | mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_record; | 12033 | mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_scan_read_fcf_rec; |
12030 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); | 12034 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); |
12031 | if (rc == MBX_NOT_FINISHED) | 12035 | if (rc == MBX_NOT_FINISHED) |
12032 | error = -EIO; | 12036 | error = -EIO; |
@@ -12034,9 +12038,13 @@ lpfc_sli4_read_fcf_record(struct lpfc_hba *phba, uint16_t fcf_index) | |||
12034 | spin_lock_irq(&phba->hbalock); | 12038 | spin_lock_irq(&phba->hbalock); |
12035 | phba->hba_flag |= FCF_DISC_INPROGRESS; | 12039 | phba->hba_flag |= FCF_DISC_INPROGRESS; |
12036 | spin_unlock_irq(&phba->hbalock); | 12040 | spin_unlock_irq(&phba->hbalock); |
12041 | /* Reset FCF round robin index bmask for new scan */ | ||
12042 | if (fcf_index == LPFC_FCOE_FCF_GET_FIRST) | ||
12043 | memset(phba->fcf.fcf_rr_bmask, 0, | ||
12044 | sizeof(*phba->fcf.fcf_rr_bmask)); | ||
12037 | error = 0; | 12045 | error = 0; |
12038 | } | 12046 | } |
12039 | fail_fcfscan: | 12047 | fail_fcf_scan: |
12040 | if (error) { | 12048 | if (error) { |
12041 | if (mboxq) | 12049 | if (mboxq) |
12042 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | 12050 | lpfc_sli4_mbox_cmd_free(phba, mboxq); |
@@ -12049,6 +12057,181 @@ fail_fcfscan: | |||
12049 | } | 12057 | } |
12050 | 12058 | ||
12051 | /** | 12059 | /** |
12060 | * lpfc_sli4_fcf_rr_read_fcf_rec - Read hba fcf record for round robin fcf. | ||
12061 | * @phba: pointer to lpfc hba data structure. | ||
12062 | * @fcf_index: FCF table entry offset. | ||
12063 | * | ||
12064 | * This routine is invoked to read an FCF record indicated by @fcf_index | ||
12065 | * and to use it for FLOGI round robin FCF failover. | ||
12066 | * | ||
12067 | * Return 0 if the mailbox command is submitted sucessfully, none 0 | ||
12068 | * otherwise. | ||
12069 | **/ | ||
12070 | int | ||
12071 | lpfc_sli4_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) | ||
12072 | { | ||
12073 | int rc = 0, error; | ||
12074 | LPFC_MBOXQ_t *mboxq; | ||
12075 | |||
12076 | mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | ||
12077 | if (!mboxq) { | ||
12078 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_INIT, | ||
12079 | "2763 Failed to allocate mbox for " | ||
12080 | "READ_FCF cmd\n"); | ||
12081 | error = -ENOMEM; | ||
12082 | goto fail_fcf_read; | ||
12083 | } | ||
12084 | /* Construct the read FCF record mailbox command */ | ||
12085 | rc = lpfc_sli4_mbx_read_fcf_rec(phba, mboxq, fcf_index); | ||
12086 | if (rc) { | ||
12087 | error = -EINVAL; | ||
12088 | goto fail_fcf_read; | ||
12089 | } | ||
12090 | /* Issue the mailbox command asynchronously */ | ||
12091 | mboxq->vport = phba->pport; | ||
12092 | mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_rr_read_fcf_rec; | ||
12093 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); | ||
12094 | if (rc == MBX_NOT_FINISHED) | ||
12095 | error = -EIO; | ||
12096 | else | ||
12097 | error = 0; | ||
12098 | |||
12099 | fail_fcf_read: | ||
12100 | if (error && mboxq) | ||
12101 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
12102 | return error; | ||
12103 | } | ||
12104 | |||
12105 | /** | ||
12106 | * lpfc_sli4_read_fcf_rec - Read hba fcf record for update eligible fcf bmask. | ||
12107 | * @phba: pointer to lpfc hba data structure. | ||
12108 | * @fcf_index: FCF table entry offset. | ||
12109 | * | ||
12110 | * This routine is invoked to read an FCF record indicated by @fcf_index to | ||
12111 | * determine whether it's eligible for FLOGI round robin failover list. | ||
12112 | * | ||
12113 | * Return 0 if the mailbox command is submitted sucessfully, none 0 | ||
12114 | * otherwise. | ||
12115 | **/ | ||
12116 | int | ||
12117 | lpfc_sli4_read_fcf_rec(struct lpfc_hba *phba, uint16_t fcf_index) | ||
12118 | { | ||
12119 | int rc = 0, error; | ||
12120 | LPFC_MBOXQ_t *mboxq; | ||
12121 | |||
12122 | mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | ||
12123 | if (!mboxq) { | ||
12124 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP | LOG_INIT, | ||
12125 | "2758 Failed to allocate mbox for " | ||
12126 | "READ_FCF cmd\n"); | ||
12127 | error = -ENOMEM; | ||
12128 | goto fail_fcf_read; | ||
12129 | } | ||
12130 | /* Construct the read FCF record mailbox command */ | ||
12131 | rc = lpfc_sli4_mbx_read_fcf_rec(phba, mboxq, fcf_index); | ||
12132 | if (rc) { | ||
12133 | error = -EINVAL; | ||
12134 | goto fail_fcf_read; | ||
12135 | } | ||
12136 | /* Issue the mailbox command asynchronously */ | ||
12137 | mboxq->vport = phba->pport; | ||
12138 | mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_rec; | ||
12139 | rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_NOWAIT); | ||
12140 | if (rc == MBX_NOT_FINISHED) | ||
12141 | error = -EIO; | ||
12142 | else | ||
12143 | error = 0; | ||
12144 | |||
12145 | fail_fcf_read: | ||
12146 | if (error && mboxq) | ||
12147 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
12148 | return error; | ||
12149 | } | ||
12150 | |||
12151 | /** | ||
12152 | * lpfc_sli4_fcf_rr_next_index_get - Get next eligible fcf record index | ||
12153 | * @phba: pointer to lpfc hba data structure. | ||
12154 | * | ||
12155 | * This routine is to get the next eligible FCF record index in a round | ||
12156 | * robin fashion. If the next eligible FCF record index equals to the | ||
12157 | * initial round robin FCF record index, LPFC_FCOE_FCF_NEXT_NONE (0xFFFF) | ||
12158 | * shall be returned, otherwise, the next eligible FCF record's index | ||
12159 | * shall be returned. | ||
12160 | **/ | ||
12161 | uint16_t | ||
12162 | lpfc_sli4_fcf_rr_next_index_get(struct lpfc_hba *phba) | ||
12163 | { | ||
12164 | uint16_t next_fcf_index; | ||
12165 | |||
12166 | /* Search from the currently registered FCF index */ | ||
12167 | next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, | ||
12168 | LPFC_SLI4_FCF_TBL_INDX_MAX, | ||
12169 | phba->fcf.current_rec.fcf_indx); | ||
12170 | /* Wrap around condition on phba->fcf.fcf_rr_bmask */ | ||
12171 | if (next_fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) | ||
12172 | next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, | ||
12173 | LPFC_SLI4_FCF_TBL_INDX_MAX, 0); | ||
12174 | /* Round robin failover stop condition */ | ||
12175 | if (next_fcf_index == phba->fcf.fcf_rr_init_indx) | ||
12176 | return LPFC_FCOE_FCF_NEXT_NONE; | ||
12177 | |||
12178 | return next_fcf_index; | ||
12179 | } | ||
12180 | |||
12181 | /** | ||
12182 | * lpfc_sli4_fcf_rr_index_set - Set bmask with eligible fcf record index | ||
12183 | * @phba: pointer to lpfc hba data structure. | ||
12184 | * | ||
12185 | * This routine sets the FCF record index in to the eligible bmask for | ||
12186 | * round robin failover search. It checks to make sure that the index | ||
12187 | * does not go beyond the range of the driver allocated bmask dimension | ||
12188 | * before setting the bit. | ||
12189 | * | ||
12190 | * Returns 0 if the index bit successfully set, otherwise, it returns | ||
12191 | * -EINVAL. | ||
12192 | **/ | ||
12193 | int | ||
12194 | lpfc_sli4_fcf_rr_index_set(struct lpfc_hba *phba, uint16_t fcf_index) | ||
12195 | { | ||
12196 | if (fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) { | ||
12197 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, | ||
12198 | "2610 HBA FCF index reached driver's " | ||
12199 | "book keeping dimension: fcf_index:%d, " | ||
12200 | "driver_bmask_max:%d\n", | ||
12201 | fcf_index, LPFC_SLI4_FCF_TBL_INDX_MAX); | ||
12202 | return -EINVAL; | ||
12203 | } | ||
12204 | /* Set the eligible FCF record index bmask */ | ||
12205 | set_bit(fcf_index, phba->fcf.fcf_rr_bmask); | ||
12206 | |||
12207 | return 0; | ||
12208 | } | ||
12209 | |||
12210 | /** | ||
12211 | * lpfc_sli4_fcf_rr_index_set - Clear bmask from eligible fcf record index | ||
12212 | * @phba: pointer to lpfc hba data structure. | ||
12213 | * | ||
12214 | * This routine clears the FCF record index from the eligible bmask for | ||
12215 | * round robin failover search. It checks to make sure that the index | ||
12216 | * does not go beyond the range of the driver allocated bmask dimension | ||
12217 | * before clearing the bit. | ||
12218 | **/ | ||
12219 | void | ||
12220 | lpfc_sli4_fcf_rr_index_clear(struct lpfc_hba *phba, uint16_t fcf_index) | ||
12221 | { | ||
12222 | if (fcf_index >= LPFC_SLI4_FCF_TBL_INDX_MAX) { | ||
12223 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, | ||
12224 | "2762 HBA FCF index goes beyond driver's " | ||
12225 | "book keeping dimension: fcf_index:%d, " | ||
12226 | "driver_bmask_max:%d\n", | ||
12227 | fcf_index, LPFC_SLI4_FCF_TBL_INDX_MAX); | ||
12228 | return; | ||
12229 | } | ||
12230 | /* Clear the eligible FCF record index bmask */ | ||
12231 | clear_bit(fcf_index, phba->fcf.fcf_rr_bmask); | ||
12232 | } | ||
12233 | |||
12234 | /** | ||
12052 | * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table | 12235 | * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table |
12053 | * @phba: pointer to lpfc hba data structure. | 12236 | * @phba: pointer to lpfc hba data structure. |
12054 | * | 12237 | * |
@@ -12069,13 +12252,13 @@ lpfc_mbx_cmpl_redisc_fcf_table(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) | |||
12069 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, | 12252 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, |
12070 | &redisc_fcf->header.cfg_shdr.response); | 12253 | &redisc_fcf->header.cfg_shdr.response); |
12071 | if (shdr_status || shdr_add_status) { | 12254 | if (shdr_status || shdr_add_status) { |
12072 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, | 12255 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, |
12073 | "2746 Requesting for FCF rediscovery failed " | 12256 | "2746 Requesting for FCF rediscovery failed " |
12074 | "status x%x add_status x%x\n", | 12257 | "status x%x add_status x%x\n", |
12075 | shdr_status, shdr_add_status); | 12258 | shdr_status, shdr_add_status); |
12076 | if (phba->fcf.fcf_flag & FCF_CVL_FOVER) { | 12259 | if (phba->fcf.fcf_flag & FCF_ACVL_DISC) { |
12077 | spin_lock_irq(&phba->hbalock); | 12260 | spin_lock_irq(&phba->hbalock); |
12078 | phba->fcf.fcf_flag &= ~FCF_CVL_FOVER; | 12261 | phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; |
12079 | spin_unlock_irq(&phba->hbalock); | 12262 | spin_unlock_irq(&phba->hbalock); |
12080 | /* | 12263 | /* |
12081 | * CVL event triggered FCF rediscover request failed, | 12264 | * CVL event triggered FCF rediscover request failed, |
@@ -12084,7 +12267,7 @@ lpfc_mbx_cmpl_redisc_fcf_table(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) | |||
12084 | lpfc_retry_pport_discovery(phba); | 12267 | lpfc_retry_pport_discovery(phba); |
12085 | } else { | 12268 | } else { |
12086 | spin_lock_irq(&phba->hbalock); | 12269 | spin_lock_irq(&phba->hbalock); |
12087 | phba->fcf.fcf_flag &= ~FCF_DEAD_FOVER; | 12270 | phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; |
12088 | spin_unlock_irq(&phba->hbalock); | 12271 | spin_unlock_irq(&phba->hbalock); |
12089 | /* | 12272 | /* |
12090 | * DEAD FCF event triggered FCF rediscover request | 12273 | * DEAD FCF event triggered FCF rediscover request |
@@ -12093,12 +12276,16 @@ lpfc_mbx_cmpl_redisc_fcf_table(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox) | |||
12093 | */ | 12276 | */ |
12094 | lpfc_sli4_fcf_dead_failthrough(phba); | 12277 | lpfc_sli4_fcf_dead_failthrough(phba); |
12095 | } | 12278 | } |
12096 | } else | 12279 | } else { |
12280 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
12281 | "2775 Start FCF rediscovery quiescent period " | ||
12282 | "wait timer before scaning FCF table\n"); | ||
12097 | /* | 12283 | /* |
12098 | * Start FCF rediscovery wait timer for pending FCF | 12284 | * Start FCF rediscovery wait timer for pending FCF |
12099 | * before rescan FCF record table. | 12285 | * before rescan FCF record table. |
12100 | */ | 12286 | */ |
12101 | lpfc_fcf_redisc_wait_start_timer(phba); | 12287 | lpfc_fcf_redisc_wait_start_timer(phba); |
12288 | } | ||
12102 | 12289 | ||
12103 | mempool_free(mbox, phba->mbox_mem_pool); | 12290 | mempool_free(mbox, phba->mbox_mem_pool); |
12104 | } | 12291 | } |
@@ -12117,6 +12304,9 @@ lpfc_sli4_redisc_fcf_table(struct lpfc_hba *phba) | |||
12117 | struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf; | 12304 | struct lpfc_mbx_redisc_fcf_tbl *redisc_fcf; |
12118 | int rc, length; | 12305 | int rc, length; |
12119 | 12306 | ||
12307 | /* Cancel retry delay timers to all vports before FCF rediscover */ | ||
12308 | lpfc_cancel_all_vport_retry_delay_timer(phba); | ||
12309 | |||
12120 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 12310 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
12121 | if (!mbox) { | 12311 | if (!mbox) { |
12122 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, | 12312 | lpfc_printf_log(phba, KERN_ERR, LOG_SLI, |
diff --git a/drivers/scsi/lpfc/lpfc_sli4.h b/drivers/scsi/lpfc/lpfc_sli4.h index 2169cd24d90c..4a35e7b9bc5b 100644 --- a/drivers/scsi/lpfc/lpfc_sli4.h +++ b/drivers/scsi/lpfc/lpfc_sli4.h | |||
@@ -153,17 +153,27 @@ struct lpfc_fcf { | |||
153 | #define FCF_REGISTERED 0x02 /* FCF registered with FW */ | 153 | #define FCF_REGISTERED 0x02 /* FCF registered with FW */ |
154 | #define FCF_SCAN_DONE 0x04 /* FCF table scan done */ | 154 | #define FCF_SCAN_DONE 0x04 /* FCF table scan done */ |
155 | #define FCF_IN_USE 0x08 /* Atleast one discovery completed */ | 155 | #define FCF_IN_USE 0x08 /* Atleast one discovery completed */ |
156 | #define FCF_DEAD_FOVER 0x10 /* FCF DEAD triggered fast FCF failover */ | 156 | #define FCF_INIT_DISC 0x10 /* Initial FCF discovery */ |
157 | #define FCF_CVL_FOVER 0x20 /* CVL triggered fast FCF failover */ | 157 | #define FCF_DEAD_DISC 0x20 /* FCF DEAD fast FCF failover discovery */ |
158 | #define FCF_REDISC_PEND 0x40 /* FCF rediscovery pending */ | 158 | #define FCF_ACVL_DISC 0x40 /* All CVL fast FCF failover discovery */ |
159 | #define FCF_REDISC_EVT 0x80 /* FCF rediscovery event to worker thread */ | 159 | #define FCF_DISCOVERY (FCF_INIT_DISC | FCF_DEAD_DISC | FCF_ACVL_DISC) |
160 | #define FCF_REDISC_FOV 0x100 /* Post FCF rediscovery fast failover */ | 160 | #define FCF_REDISC_PEND 0x80 /* FCF rediscovery pending */ |
161 | #define FCF_REDISC_EVT 0x100 /* FCF rediscovery event to worker thread */ | ||
162 | #define FCF_REDISC_FOV 0x200 /* Post FCF rediscovery fast failover */ | ||
161 | uint32_t addr_mode; | 163 | uint32_t addr_mode; |
164 | uint16_t fcf_rr_init_indx; | ||
162 | struct lpfc_fcf_rec current_rec; | 165 | struct lpfc_fcf_rec current_rec; |
163 | struct lpfc_fcf_rec failover_rec; | 166 | struct lpfc_fcf_rec failover_rec; |
164 | struct timer_list redisc_wait; | 167 | struct timer_list redisc_wait; |
168 | unsigned long *fcf_rr_bmask; /* Eligible FCF indexes for RR failover */ | ||
165 | }; | 169 | }; |
166 | 170 | ||
171 | /* | ||
172 | * Maximum FCF table index, it is for driver internal book keeping, it | ||
173 | * just needs to be no less than the supported HBA's FCF table size. | ||
174 | */ | ||
175 | #define LPFC_SLI4_FCF_TBL_INDX_MAX 32 | ||
176 | |||
167 | #define LPFC_REGION23_SIGNATURE "RG23" | 177 | #define LPFC_REGION23_SIGNATURE "RG23" |
168 | #define LPFC_REGION23_VERSION 1 | 178 | #define LPFC_REGION23_VERSION 1 |
169 | #define LPFC_REGION23_LAST_REC 0xff | 179 | #define LPFC_REGION23_LAST_REC 0xff |
@@ -472,8 +482,8 @@ void lpfc_sli4_mbox_cmd_free(struct lpfc_hba *, struct lpfcMboxq *); | |||
472 | void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t); | 482 | void lpfc_sli4_mbx_sge_set(struct lpfcMboxq *, uint32_t, dma_addr_t, uint32_t); |
473 | void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t, | 483 | void lpfc_sli4_mbx_sge_get(struct lpfcMboxq *, uint32_t, |
474 | struct lpfc_mbx_sge *); | 484 | struct lpfc_mbx_sge *); |
475 | int lpfc_sli4_mbx_read_fcf_record(struct lpfc_hba *, struct lpfcMboxq *, | 485 | int lpfc_sli4_mbx_read_fcf_rec(struct lpfc_hba *, struct lpfcMboxq *, |
476 | uint16_t); | 486 | uint16_t); |
477 | 487 | ||
478 | void lpfc_sli4_hba_reset(struct lpfc_hba *); | 488 | void lpfc_sli4_hba_reset(struct lpfc_hba *); |
479 | struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t, | 489 | struct lpfc_queue *lpfc_sli4_queue_alloc(struct lpfc_hba *, uint32_t, |
@@ -532,8 +542,13 @@ int lpfc_sli4_init_vpi(struct lpfc_hba *, uint16_t); | |||
532 | uint32_t lpfc_sli4_cq_release(struct lpfc_queue *, bool); | 542 | uint32_t lpfc_sli4_cq_release(struct lpfc_queue *, bool); |
533 | uint32_t lpfc_sli4_eq_release(struct lpfc_queue *, bool); | 543 | uint32_t lpfc_sli4_eq_release(struct lpfc_queue *, bool); |
534 | void lpfc_sli4_fcfi_unreg(struct lpfc_hba *, uint16_t); | 544 | void lpfc_sli4_fcfi_unreg(struct lpfc_hba *, uint16_t); |
535 | int lpfc_sli4_read_fcf_record(struct lpfc_hba *, uint16_t); | 545 | int lpfc_sli4_fcf_scan_read_fcf_rec(struct lpfc_hba *, uint16_t); |
536 | void lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *, LPFC_MBOXQ_t *); | 546 | int lpfc_sli4_fcf_rr_read_fcf_rec(struct lpfc_hba *, uint16_t); |
547 | int lpfc_sli4_read_fcf_rec(struct lpfc_hba *, uint16_t); | ||
548 | void lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *); | ||
549 | void lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *); | ||
550 | void lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *, LPFC_MBOXQ_t *); | ||
551 | int lpfc_sli4_unregister_fcf(struct lpfc_hba *); | ||
537 | int lpfc_sli4_post_status_check(struct lpfc_hba *); | 552 | int lpfc_sli4_post_status_check(struct lpfc_hba *); |
538 | uint8_t lpfc_sli4_mbox_opcode_get(struct lpfc_hba *, struct lpfcMboxq *); | 553 | uint8_t lpfc_sli4_mbox_opcode_get(struct lpfc_hba *, struct lpfcMboxq *); |
539 | 554 | ||