diff options
author | Jiri Kosina <jkosina@suse.cz> | 2010-04-22 20:08:44 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-04-22 20:08:44 -0400 |
commit | 6c9468e9eb1252eaefd94ce7f06e1be9b0b641b1 (patch) | |
tree | 797676a336b050bfa1ef879377c07e541b9075d6 /drivers/scsi/lpfc/lpfc_hbadisc.c | |
parent | 4cb3ca7cd7e2cae8d1daf5345ec99a1e8502cf3f (diff) | |
parent | c81eddb0e3728661d1585fbc564449c94165cc36 (diff) |
Merge branch 'master' into for-next
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_hbadisc.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_hbadisc.c | 528 |
1 files changed, 412 insertions, 116 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 2359d0bfb734..e1466eec56b7 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -20,6 +20,7 @@ | |||
20 | *******************************************************************/ | 20 | *******************************************************************/ |
21 | 21 | ||
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/slab.h> | ||
23 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
24 | #include <linux/kthread.h> | 25 | #include <linux/kthread.h> |
25 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
@@ -1481,8 +1482,6 @@ lpfc_match_fcf_conn_list(struct lpfc_hba *phba, | |||
1481 | int | 1482 | int |
1482 | lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | 1483 | lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) |
1483 | { | 1484 | { |
1484 | LPFC_MBOXQ_t *mbox; | ||
1485 | int rc; | ||
1486 | /* | 1485 | /* |
1487 | * If the Link is up and no FCoE events while in the | 1486 | * If the Link is up and no FCoE events while in the |
1488 | * FCF discovery, no need to restart FCF discovery. | 1487 | * FCF discovery, no need to restart FCF discovery. |
@@ -1491,86 +1490,70 @@ lpfc_check_pending_fcoe_event(struct lpfc_hba *phba, uint8_t unreg_fcf) | |||
1491 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) | 1490 | (phba->fcoe_eventtag == phba->fcoe_eventtag_at_fcf_scan)) |
1492 | return 0; | 1491 | return 0; |
1493 | 1492 | ||
1493 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1494 | "2768 Pending link or FCF event during current " | ||
1495 | "handling of the previous event: link_state:x%x, " | ||
1496 | "evt_tag_at_scan:x%x, evt_tag_current:x%x\n", | ||
1497 | phba->link_state, phba->fcoe_eventtag_at_fcf_scan, | ||
1498 | phba->fcoe_eventtag); | ||
1499 | |||
1494 | spin_lock_irq(&phba->hbalock); | 1500 | spin_lock_irq(&phba->hbalock); |
1495 | phba->fcf.fcf_flag &= ~FCF_AVAILABLE; | 1501 | phba->fcf.fcf_flag &= ~FCF_AVAILABLE; |
1496 | spin_unlock_irq(&phba->hbalock); | 1502 | spin_unlock_irq(&phba->hbalock); |
1497 | 1503 | ||
1498 | if (phba->link_state >= LPFC_LINK_UP) | 1504 | if (phba->link_state >= LPFC_LINK_UP) { |
1499 | lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 1505 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
1500 | else { | 1506 | "2780 Restart FCF table scan due to " |
1507 | "pending FCF event:evt_tag_at_scan:x%x, " | ||
1508 | "evt_tag_current:x%x\n", | ||
1509 | phba->fcoe_eventtag_at_fcf_scan, | ||
1510 | phba->fcoe_eventtag); | ||
1511 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | ||
1512 | } else { | ||
1501 | /* | 1513 | /* |
1502 | * Do not continue FCF discovery and clear FCF_DISC_INPROGRESS | 1514 | * Do not continue FCF discovery and clear FCF_DISC_INPROGRESS |
1503 | * flag | 1515 | * flag |
1504 | */ | 1516 | */ |
1505 | spin_lock_irq(&phba->hbalock); | 1517 | spin_lock_irq(&phba->hbalock); |
1506 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1518 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; |
1507 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; | 1519 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | FCF_DISCOVERY); |
1508 | spin_unlock_irq(&phba->hbalock); | 1520 | spin_unlock_irq(&phba->hbalock); |
1509 | } | 1521 | } |
1510 | 1522 | ||
1523 | /* Unregister the currently registered FCF if required */ | ||
1511 | if (unreg_fcf) { | 1524 | if (unreg_fcf) { |
1512 | spin_lock_irq(&phba->hbalock); | 1525 | spin_lock_irq(&phba->hbalock); |
1513 | phba->fcf.fcf_flag &= ~FCF_REGISTERED; | 1526 | phba->fcf.fcf_flag &= ~FCF_REGISTERED; |
1514 | spin_unlock_irq(&phba->hbalock); | 1527 | spin_unlock_irq(&phba->hbalock); |
1515 | mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | 1528 | lpfc_sli4_unregister_fcf(phba); |
1516 | if (!mbox) { | ||
1517 | lpfc_printf_log(phba, KERN_ERR, | ||
1518 | LOG_DISCOVERY|LOG_MBOX, | ||
1519 | "2610 UNREG_FCFI mbox allocation failed\n"); | ||
1520 | return 1; | ||
1521 | } | ||
1522 | lpfc_unreg_fcfi(mbox, phba->fcf.fcfi); | ||
1523 | mbox->vport = phba->pport; | ||
1524 | mbox->mbox_cmpl = lpfc_unregister_fcfi_cmpl; | ||
1525 | rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); | ||
1526 | if (rc == MBX_NOT_FINISHED) { | ||
1527 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | ||
1528 | "2611 UNREG_FCFI issue mbox failed\n"); | ||
1529 | mempool_free(mbox, phba->mbox_mem_pool); | ||
1530 | } | ||
1531 | } | 1529 | } |
1532 | |||
1533 | return 1; | 1530 | return 1; |
1534 | } | 1531 | } |
1535 | 1532 | ||
1536 | /** | 1533 | /** |
1537 | * lpfc_mbx_cmpl_read_fcf_record - Completion handler for read_fcf mbox. | 1534 | * lpfc_sli4_fcf_rec_mbox_parse - parse non-embedded fcf record mailbox command |
1538 | * @phba: pointer to lpfc hba data structure. | 1535 | * @phba: pointer to lpfc hba data structure. |
1539 | * @mboxq: pointer to mailbox object. | 1536 | * @mboxq: pointer to mailbox object. |
1537 | * @next_fcf_index: pointer to holder of next fcf index. | ||
1540 | * | 1538 | * |
1541 | * This function iterate through all the fcf records available in | 1539 | * This routine parses the non-embedded fcf mailbox command by performing the |
1542 | * HBA and choose the optimal FCF record for discovery. After finding | 1540 | * necessarily error checking, non-embedded read FCF record mailbox command |
1543 | * the FCF for discovery it register the FCF record and kick start | 1541 | * SGE parsing, and endianness swapping. |
1544 | * discovery. | 1542 | * |
1545 | * If FCF_IN_USE flag is set in currently used FCF, the routine try to | 1543 | * Returns the pointer to the new FCF record in the non-embedded mailbox |
1546 | * use a FCF record which match fabric name and mac address of the | 1544 | * command DMA memory if successfully, other NULL. |
1547 | * currently used FCF record. | ||
1548 | * If the driver support only one FCF, it will try to use the FCF record | ||
1549 | * used by BOOT_BIOS. | ||
1550 | */ | 1545 | */ |
1551 | void | 1546 | static struct fcf_record * |
1552 | lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | 1547 | lpfc_sli4_fcf_rec_mbox_parse(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq, |
1548 | uint16_t *next_fcf_index) | ||
1553 | { | 1549 | { |
1554 | void *virt_addr; | 1550 | void *virt_addr; |
1555 | dma_addr_t phys_addr; | 1551 | dma_addr_t phys_addr; |
1556 | uint8_t *bytep; | ||
1557 | struct lpfc_mbx_sge sge; | 1552 | struct lpfc_mbx_sge sge; |
1558 | struct lpfc_mbx_read_fcf_tbl *read_fcf; | 1553 | struct lpfc_mbx_read_fcf_tbl *read_fcf; |
1559 | uint32_t shdr_status, shdr_add_status; | 1554 | uint32_t shdr_status, shdr_add_status; |
1560 | union lpfc_sli4_cfg_shdr *shdr; | 1555 | union lpfc_sli4_cfg_shdr *shdr; |
1561 | struct fcf_record *new_fcf_record; | 1556 | struct fcf_record *new_fcf_record; |
1562 | uint32_t boot_flag, addr_mode; | ||
1563 | uint32_t next_fcf_index; | ||
1564 | struct lpfc_fcf_rec *fcf_rec = NULL; | ||
1565 | unsigned long iflags; | ||
1566 | uint16_t vlan_id; | ||
1567 | int rc; | ||
1568 | |||
1569 | /* If there is pending FCoE event restart FCF table scan */ | ||
1570 | if (lpfc_check_pending_fcoe_event(phba, 0)) { | ||
1571 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1572 | return; | ||
1573 | } | ||
1574 | 1557 | ||
1575 | /* Get the first SGE entry from the non-embedded DMA memory. This | 1558 | /* Get the first SGE entry from the non-embedded DMA memory. This |
1576 | * routine only uses a single SGE. | 1559 | * routine only uses a single SGE. |
@@ -1581,59 +1564,183 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1581 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, | 1564 | lpfc_printf_log(phba, KERN_ERR, LOG_MBOX, |
1582 | "2524 Failed to get the non-embedded SGE " | 1565 | "2524 Failed to get the non-embedded SGE " |
1583 | "virtual address\n"); | 1566 | "virtual address\n"); |
1584 | goto out; | 1567 | return NULL; |
1585 | } | 1568 | } |
1586 | virt_addr = mboxq->sge_array->addr[0]; | 1569 | virt_addr = mboxq->sge_array->addr[0]; |
1587 | 1570 | ||
1588 | shdr = (union lpfc_sli4_cfg_shdr *)virt_addr; | 1571 | shdr = (union lpfc_sli4_cfg_shdr *)virt_addr; |
1589 | shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); | 1572 | shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); |
1590 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, | 1573 | shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); |
1591 | &shdr->response); | ||
1592 | /* | ||
1593 | * The FCF Record was read and there is no reason for the driver | ||
1594 | * to maintain the FCF record data or memory. Instead, just need | ||
1595 | * to book keeping the FCFIs can be used. | ||
1596 | */ | ||
1597 | if (shdr_status || shdr_add_status) { | 1574 | if (shdr_status || shdr_add_status) { |
1598 | if (shdr_status == STATUS_FCF_TABLE_EMPTY) { | 1575 | if (shdr_status == STATUS_FCF_TABLE_EMPTY) |
1599 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 1576 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, |
1600 | "2726 READ_FCF_RECORD Indicates empty " | 1577 | "2726 READ_FCF_RECORD Indicates empty " |
1601 | "FCF table.\n"); | 1578 | "FCF table.\n"); |
1602 | } else { | 1579 | else |
1603 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 1580 | lpfc_printf_log(phba, KERN_ERR, LOG_FIP, |
1604 | "2521 READ_FCF_RECORD mailbox failed " | 1581 | "2521 READ_FCF_RECORD mailbox failed " |
1605 | "with status x%x add_status x%x, mbx\n", | 1582 | "with status x%x add_status x%x, " |
1606 | shdr_status, shdr_add_status); | 1583 | "mbx\n", shdr_status, shdr_add_status); |
1607 | } | 1584 | return NULL; |
1608 | goto out; | ||
1609 | } | 1585 | } |
1610 | /* Interpreting the returned information of FCF records */ | 1586 | |
1587 | /* Interpreting the returned information of the FCF record */ | ||
1611 | read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr; | 1588 | read_fcf = (struct lpfc_mbx_read_fcf_tbl *)virt_addr; |
1612 | lpfc_sli_pcimem_bcopy(read_fcf, read_fcf, | 1589 | lpfc_sli_pcimem_bcopy(read_fcf, read_fcf, |
1613 | sizeof(struct lpfc_mbx_read_fcf_tbl)); | 1590 | sizeof(struct lpfc_mbx_read_fcf_tbl)); |
1614 | next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); | 1591 | *next_fcf_index = bf_get(lpfc_mbx_read_fcf_tbl_nxt_vindx, read_fcf); |
1615 | |||
1616 | new_fcf_record = (struct fcf_record *)(virt_addr + | 1592 | new_fcf_record = (struct fcf_record *)(virt_addr + |
1617 | sizeof(struct lpfc_mbx_read_fcf_tbl)); | 1593 | sizeof(struct lpfc_mbx_read_fcf_tbl)); |
1618 | lpfc_sli_pcimem_bcopy(new_fcf_record, new_fcf_record, | 1594 | lpfc_sli_pcimem_bcopy(new_fcf_record, new_fcf_record, |
1619 | sizeof(struct fcf_record)); | 1595 | sizeof(struct fcf_record)); |
1620 | bytep = virt_addr + sizeof(union lpfc_sli4_cfg_shdr); | ||
1621 | 1596 | ||
1597 | return new_fcf_record; | ||
1598 | } | ||
1599 | |||
1600 | /** | ||
1601 | * lpfc_sli4_log_fcf_record_info - Log the information of a fcf record | ||
1602 | * @phba: pointer to lpfc hba data structure. | ||
1603 | * @fcf_record: pointer to the fcf record. | ||
1604 | * @vlan_id: the lowest vlan identifier associated to this fcf record. | ||
1605 | * @next_fcf_index: the index to the next fcf record in hba's fcf table. | ||
1606 | * | ||
1607 | * This routine logs the detailed FCF record if the LOG_FIP loggin is | ||
1608 | * enabled. | ||
1609 | **/ | ||
1610 | static void | ||
1611 | lpfc_sli4_log_fcf_record_info(struct lpfc_hba *phba, | ||
1612 | struct fcf_record *fcf_record, | ||
1613 | uint16_t vlan_id, | ||
1614 | uint16_t next_fcf_index) | ||
1615 | { | ||
1616 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1617 | "2764 READ_FCF_RECORD:\n" | ||
1618 | "\tFCF_Index : x%x\n" | ||
1619 | "\tFCF_Avail : x%x\n" | ||
1620 | "\tFCF_Valid : x%x\n" | ||
1621 | "\tFIP_Priority : x%x\n" | ||
1622 | "\tMAC_Provider : x%x\n" | ||
1623 | "\tLowest VLANID : x%x\n" | ||
1624 | "\tFCF_MAC Addr : x%x:%x:%x:%x:%x:%x\n" | ||
1625 | "\tFabric_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" | ||
1626 | "\tSwitch_Name : x%x:%x:%x:%x:%x:%x:%x:%x\n" | ||
1627 | "\tNext_FCF_Index: x%x\n", | ||
1628 | bf_get(lpfc_fcf_record_fcf_index, fcf_record), | ||
1629 | bf_get(lpfc_fcf_record_fcf_avail, fcf_record), | ||
1630 | bf_get(lpfc_fcf_record_fcf_valid, fcf_record), | ||
1631 | fcf_record->fip_priority, | ||
1632 | bf_get(lpfc_fcf_record_mac_addr_prov, fcf_record), | ||
1633 | vlan_id, | ||
1634 | bf_get(lpfc_fcf_record_mac_0, fcf_record), | ||
1635 | bf_get(lpfc_fcf_record_mac_1, fcf_record), | ||
1636 | bf_get(lpfc_fcf_record_mac_2, fcf_record), | ||
1637 | bf_get(lpfc_fcf_record_mac_3, fcf_record), | ||
1638 | bf_get(lpfc_fcf_record_mac_4, fcf_record), | ||
1639 | bf_get(lpfc_fcf_record_mac_5, fcf_record), | ||
1640 | bf_get(lpfc_fcf_record_fab_name_0, fcf_record), | ||
1641 | bf_get(lpfc_fcf_record_fab_name_1, fcf_record), | ||
1642 | bf_get(lpfc_fcf_record_fab_name_2, fcf_record), | ||
1643 | bf_get(lpfc_fcf_record_fab_name_3, fcf_record), | ||
1644 | bf_get(lpfc_fcf_record_fab_name_4, fcf_record), | ||
1645 | bf_get(lpfc_fcf_record_fab_name_5, fcf_record), | ||
1646 | bf_get(lpfc_fcf_record_fab_name_6, fcf_record), | ||
1647 | bf_get(lpfc_fcf_record_fab_name_7, fcf_record), | ||
1648 | bf_get(lpfc_fcf_record_switch_name_0, fcf_record), | ||
1649 | bf_get(lpfc_fcf_record_switch_name_1, fcf_record), | ||
1650 | bf_get(lpfc_fcf_record_switch_name_2, fcf_record), | ||
1651 | bf_get(lpfc_fcf_record_switch_name_3, fcf_record), | ||
1652 | bf_get(lpfc_fcf_record_switch_name_4, fcf_record), | ||
1653 | bf_get(lpfc_fcf_record_switch_name_5, fcf_record), | ||
1654 | bf_get(lpfc_fcf_record_switch_name_6, fcf_record), | ||
1655 | bf_get(lpfc_fcf_record_switch_name_7, fcf_record), | ||
1656 | next_fcf_index); | ||
1657 | } | ||
1658 | |||
1659 | /** | ||
1660 | * lpfc_mbx_cmpl_fcf_scan_read_fcf_rec - fcf scan read_fcf mbox cmpl handler. | ||
1661 | * @phba: pointer to lpfc hba data structure. | ||
1662 | * @mboxq: pointer to mailbox object. | ||
1663 | * | ||
1664 | * This function iterates through all the fcf records available in | ||
1665 | * HBA and chooses the optimal FCF record for discovery. After finding | ||
1666 | * the FCF for discovery it registers the FCF record and kicks start | ||
1667 | * discovery. | ||
1668 | * If FCF_IN_USE flag is set in currently used FCF, the routine tries to | ||
1669 | * use an FCF record which matches fabric name and mac address of the | ||
1670 | * currently used FCF record. | ||
1671 | * If the driver supports only one FCF, it will try to use the FCF record | ||
1672 | * used by BOOT_BIOS. | ||
1673 | */ | ||
1674 | void | ||
1675 | lpfc_mbx_cmpl_fcf_scan_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
1676 | { | ||
1677 | struct fcf_record *new_fcf_record; | ||
1678 | uint32_t boot_flag, addr_mode; | ||
1679 | uint16_t fcf_index, next_fcf_index; | ||
1680 | struct lpfc_fcf_rec *fcf_rec = NULL; | ||
1681 | uint16_t vlan_id; | ||
1682 | int rc; | ||
1683 | |||
1684 | /* If there is pending FCoE event restart FCF table scan */ | ||
1685 | if (lpfc_check_pending_fcoe_event(phba, 0)) { | ||
1686 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1687 | return; | ||
1688 | } | ||
1689 | |||
1690 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
1691 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
1692 | &next_fcf_index); | ||
1693 | if (!new_fcf_record) { | ||
1694 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1695 | "2765 Mailbox command READ_FCF_RECORD " | ||
1696 | "failed to retrieve a FCF record.\n"); | ||
1697 | /* Let next new FCF event trigger fast failover */ | ||
1698 | spin_lock_irq(&phba->hbalock); | ||
1699 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | ||
1700 | spin_unlock_irq(&phba->hbalock); | ||
1701 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1702 | return; | ||
1703 | } | ||
1704 | |||
1705 | /* Check the FCF record against the connection list */ | ||
1622 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | 1706 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, |
1623 | &addr_mode, &vlan_id); | 1707 | &addr_mode, &vlan_id); |
1708 | |||
1709 | /* Log the FCF record information if turned on */ | ||
1710 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
1711 | next_fcf_index); | ||
1712 | |||
1624 | /* | 1713 | /* |
1625 | * If the fcf record does not match with connect list entries | 1714 | * If the fcf record does not match with connect list entries |
1626 | * read the next entry. | 1715 | * read the next entry; otherwise, this is an eligible FCF |
1716 | * record for round robin FCF failover. | ||
1627 | */ | 1717 | */ |
1628 | if (!rc) | 1718 | if (!rc) { |
1719 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1720 | "2781 FCF record fcf_index:x%x failed FCF " | ||
1721 | "connection list check, fcf_avail:x%x, " | ||
1722 | "fcf_valid:x%x\n", | ||
1723 | bf_get(lpfc_fcf_record_fcf_index, | ||
1724 | new_fcf_record), | ||
1725 | bf_get(lpfc_fcf_record_fcf_avail, | ||
1726 | new_fcf_record), | ||
1727 | bf_get(lpfc_fcf_record_fcf_valid, | ||
1728 | new_fcf_record)); | ||
1629 | goto read_next_fcf; | 1729 | goto read_next_fcf; |
1730 | } else { | ||
1731 | fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | ||
1732 | rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); | ||
1733 | if (rc) | ||
1734 | goto read_next_fcf; | ||
1735 | } | ||
1736 | |||
1630 | /* | 1737 | /* |
1631 | * If this is not the first FCF discovery of the HBA, use last | 1738 | * If this is not the first FCF discovery of the HBA, use last |
1632 | * FCF record for the discovery. The condition that a rescan | 1739 | * FCF record for the discovery. The condition that a rescan |
1633 | * matches the in-use FCF record: fabric name, switch name, mac | 1740 | * matches the in-use FCF record: fabric name, switch name, mac |
1634 | * address, and vlan_id. | 1741 | * address, and vlan_id. |
1635 | */ | 1742 | */ |
1636 | spin_lock_irqsave(&phba->hbalock, iflags); | 1743 | spin_lock_irq(&phba->hbalock); |
1637 | if (phba->fcf.fcf_flag & FCF_IN_USE) { | 1744 | if (phba->fcf.fcf_flag & FCF_IN_USE) { |
1638 | if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, | 1745 | if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, |
1639 | new_fcf_record) && | 1746 | new_fcf_record) && |
@@ -1649,8 +1756,9 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1649 | __lpfc_sli4_stop_fcf_redisc_wait_timer(phba); | 1756 | __lpfc_sli4_stop_fcf_redisc_wait_timer(phba); |
1650 | else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) | 1757 | else if (phba->fcf.fcf_flag & FCF_REDISC_FOV) |
1651 | /* If in fast failover, mark it's completed */ | 1758 | /* If in fast failover, mark it's completed */ |
1652 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; | 1759 | phba->fcf.fcf_flag &= ~(FCF_REDISC_FOV | |
1653 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1760 | FCF_DISCOVERY); |
1761 | spin_unlock_irq(&phba->hbalock); | ||
1654 | goto out; | 1762 | goto out; |
1655 | } | 1763 | } |
1656 | /* | 1764 | /* |
@@ -1661,7 +1769,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1661 | * next candidate. | 1769 | * next candidate. |
1662 | */ | 1770 | */ |
1663 | if (!(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { | 1771 | if (!(phba->fcf.fcf_flag & FCF_REDISC_FOV)) { |
1664 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1772 | spin_unlock_irq(&phba->hbalock); |
1665 | goto read_next_fcf; | 1773 | goto read_next_fcf; |
1666 | } | 1774 | } |
1667 | } | 1775 | } |
@@ -1669,14 +1777,9 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1669 | * Update on failover FCF record only if it's in FCF fast-failover | 1777 | * Update on failover FCF record only if it's in FCF fast-failover |
1670 | * period; otherwise, update on current FCF record. | 1778 | * period; otherwise, update on current FCF record. |
1671 | */ | 1779 | */ |
1672 | if (phba->fcf.fcf_flag & FCF_REDISC_FOV) { | 1780 | if (phba->fcf.fcf_flag & FCF_REDISC_FOV) |
1673 | /* Fast FCF failover only to the same fabric name */ | 1781 | fcf_rec = &phba->fcf.failover_rec; |
1674 | if (lpfc_fab_name_match(phba->fcf.current_rec.fabric_name, | 1782 | else |
1675 | new_fcf_record)) | ||
1676 | fcf_rec = &phba->fcf.failover_rec; | ||
1677 | else | ||
1678 | goto read_next_fcf; | ||
1679 | } else | ||
1680 | fcf_rec = &phba->fcf.current_rec; | 1783 | fcf_rec = &phba->fcf.current_rec; |
1681 | 1784 | ||
1682 | if (phba->fcf.fcf_flag & FCF_AVAILABLE) { | 1785 | if (phba->fcf.fcf_flag & FCF_AVAILABLE) { |
@@ -1689,7 +1792,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1689 | /* Choose this FCF record */ | 1792 | /* Choose this FCF record */ |
1690 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, | 1793 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
1691 | addr_mode, vlan_id, BOOT_ENABLE); | 1794 | addr_mode, vlan_id, BOOT_ENABLE); |
1692 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1795 | spin_unlock_irq(&phba->hbalock); |
1693 | goto read_next_fcf; | 1796 | goto read_next_fcf; |
1694 | } | 1797 | } |
1695 | /* | 1798 | /* |
@@ -1698,20 +1801,19 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1698 | * the next FCF record. | 1801 | * the next FCF record. |
1699 | */ | 1802 | */ |
1700 | if (!boot_flag && (fcf_rec->flag & BOOT_ENABLE)) { | 1803 | if (!boot_flag && (fcf_rec->flag & BOOT_ENABLE)) { |
1701 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1804 | spin_unlock_irq(&phba->hbalock); |
1702 | goto read_next_fcf; | 1805 | goto read_next_fcf; |
1703 | } | 1806 | } |
1704 | /* | 1807 | /* |
1705 | * If the new hba FCF record has lower priority value | 1808 | * If the new hba FCF record has lower priority value |
1706 | * than the driver FCF record, use the new record. | 1809 | * than the driver FCF record, use the new record. |
1707 | */ | 1810 | */ |
1708 | if (lpfc_fab_name_match(fcf_rec->fabric_name, new_fcf_record) && | 1811 | if (new_fcf_record->fip_priority < fcf_rec->priority) { |
1709 | (new_fcf_record->fip_priority < fcf_rec->priority)) { | ||
1710 | /* Choose this FCF record */ | 1812 | /* Choose this FCF record */ |
1711 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, | 1813 | __lpfc_update_fcf_record(phba, fcf_rec, new_fcf_record, |
1712 | addr_mode, vlan_id, 0); | 1814 | addr_mode, vlan_id, 0); |
1713 | } | 1815 | } |
1714 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1816 | spin_unlock_irq(&phba->hbalock); |
1715 | goto read_next_fcf; | 1817 | goto read_next_fcf; |
1716 | } | 1818 | } |
1717 | /* | 1819 | /* |
@@ -1724,7 +1826,7 @@ lpfc_mbx_cmpl_read_fcf_record(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | |||
1724 | BOOT_ENABLE : 0)); | 1826 | BOOT_ENABLE : 0)); |
1725 | phba->fcf.fcf_flag |= FCF_AVAILABLE; | 1827 | phba->fcf.fcf_flag |= FCF_AVAILABLE; |
1726 | } | 1828 | } |
1727 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1829 | spin_unlock_irq(&phba->hbalock); |
1728 | goto read_next_fcf; | 1830 | goto read_next_fcf; |
1729 | 1831 | ||
1730 | read_next_fcf: | 1832 | read_next_fcf: |
@@ -1740,9 +1842,22 @@ read_next_fcf: | |||
1740 | * FCF scan inprogress, and do nothing | 1842 | * FCF scan inprogress, and do nothing |
1741 | */ | 1843 | */ |
1742 | if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { | 1844 | if (!(phba->fcf.failover_rec.flag & RECORD_VALID)) { |
1743 | spin_lock_irqsave(&phba->hbalock, iflags); | 1845 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, |
1846 | "2782 No suitable FCF record " | ||
1847 | "found during this round of " | ||
1848 | "post FCF rediscovery scan: " | ||
1849 | "fcf_evt_tag:x%x, fcf_index: " | ||
1850 | "x%x\n", | ||
1851 | phba->fcoe_eventtag_at_fcf_scan, | ||
1852 | bf_get(lpfc_fcf_record_fcf_index, | ||
1853 | new_fcf_record)); | ||
1854 | /* | ||
1855 | * Let next new FCF event trigger fast | ||
1856 | * failover | ||
1857 | */ | ||
1858 | spin_lock_irq(&phba->hbalock); | ||
1744 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; | 1859 | phba->hba_flag &= ~FCF_DISC_INPROGRESS; |
1745 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1860 | spin_unlock_irq(&phba->hbalock); |
1746 | return; | 1861 | return; |
1747 | } | 1862 | } |
1748 | /* | 1863 | /* |
@@ -1754,16 +1869,23 @@ read_next_fcf: | |||
1754 | * record. | 1869 | * record. |
1755 | */ | 1870 | */ |
1756 | 1871 | ||
1757 | /* unregister the current in-use FCF record */ | 1872 | /* Unregister the current in-use FCF record */ |
1758 | lpfc_unregister_fcf(phba); | 1873 | lpfc_unregister_fcf(phba); |
1759 | /* replace in-use record with the new record */ | 1874 | |
1875 | /* Replace in-use record with the new record */ | ||
1760 | memcpy(&phba->fcf.current_rec, | 1876 | memcpy(&phba->fcf.current_rec, |
1761 | &phba->fcf.failover_rec, | 1877 | &phba->fcf.failover_rec, |
1762 | sizeof(struct lpfc_fcf_rec)); | 1878 | sizeof(struct lpfc_fcf_rec)); |
1763 | /* mark the FCF fast failover completed */ | 1879 | /* mark the FCF fast failover completed */ |
1764 | spin_lock_irqsave(&phba->hbalock, iflags); | 1880 | spin_lock_irq(&phba->hbalock); |
1765 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; | 1881 | phba->fcf.fcf_flag &= ~FCF_REDISC_FOV; |
1766 | spin_unlock_irqrestore(&phba->hbalock, iflags); | 1882 | spin_unlock_irq(&phba->hbalock); |
1883 | /* | ||
1884 | * Set up the initial registered FCF index for FLOGI | ||
1885 | * round robin FCF failover. | ||
1886 | */ | ||
1887 | phba->fcf.fcf_rr_init_indx = | ||
1888 | phba->fcf.failover_rec.fcf_indx; | ||
1767 | /* Register to the new FCF record */ | 1889 | /* Register to the new FCF record */ |
1768 | lpfc_register_fcf(phba); | 1890 | lpfc_register_fcf(phba); |
1769 | } else { | 1891 | } else { |
@@ -1776,13 +1898,25 @@ read_next_fcf: | |||
1776 | return; | 1898 | return; |
1777 | /* | 1899 | /* |
1778 | * Otherwise, initial scan or post linkdown rescan, | 1900 | * Otherwise, initial scan or post linkdown rescan, |
1779 | * register with the best fit FCF record found so | 1901 | * register with the best FCF record found so far |
1780 | * far through the scanning process. | 1902 | * through the FCF scanning process. |
1903 | */ | ||
1904 | |||
1905 | /* mark the initial FCF discovery completed */ | ||
1906 | spin_lock_irq(&phba->hbalock); | ||
1907 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
1908 | spin_unlock_irq(&phba->hbalock); | ||
1909 | /* | ||
1910 | * Set up the initial registered FCF index for FLOGI | ||
1911 | * round robin FCF failover | ||
1781 | */ | 1912 | */ |
1913 | phba->fcf.fcf_rr_init_indx = | ||
1914 | phba->fcf.current_rec.fcf_indx; | ||
1915 | /* Register to the new FCF record */ | ||
1782 | lpfc_register_fcf(phba); | 1916 | lpfc_register_fcf(phba); |
1783 | } | 1917 | } |
1784 | } else | 1918 | } else |
1785 | lpfc_sli4_read_fcf_record(phba, next_fcf_index); | 1919 | lpfc_sli4_fcf_scan_read_fcf_rec(phba, next_fcf_index); |
1786 | return; | 1920 | return; |
1787 | 1921 | ||
1788 | out: | 1922 | out: |
@@ -1793,6 +1927,141 @@ out: | |||
1793 | } | 1927 | } |
1794 | 1928 | ||
1795 | /** | 1929 | /** |
1930 | * lpfc_mbx_cmpl_fcf_rr_read_fcf_rec - fcf round robin read_fcf mbox cmpl hdler | ||
1931 | * @phba: pointer to lpfc hba data structure. | ||
1932 | * @mboxq: pointer to mailbox object. | ||
1933 | * | ||
1934 | * This is the callback function for FLOGI failure round robin FCF failover | ||
1935 | * read FCF record mailbox command from the eligible FCF record bmask for | ||
1936 | * performing the failover. If the FCF read back is not valid/available, it | ||
1937 | * fails through to retrying FLOGI to the currently registered FCF again. | ||
1938 | * Otherwise, if the FCF read back is valid and available, it will set the | ||
1939 | * newly read FCF record to the failover FCF record, unregister currently | ||
1940 | * registered FCF record, copy the failover FCF record to the current | ||
1941 | * FCF record, and then register the current FCF record before proceeding | ||
1942 | * to trying FLOGI on the new failover FCF. | ||
1943 | */ | ||
1944 | void | ||
1945 | lpfc_mbx_cmpl_fcf_rr_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
1946 | { | ||
1947 | struct fcf_record *new_fcf_record; | ||
1948 | uint32_t boot_flag, addr_mode; | ||
1949 | uint16_t next_fcf_index; | ||
1950 | uint16_t current_fcf_index; | ||
1951 | uint16_t vlan_id; | ||
1952 | |||
1953 | /* If link state is not up, stop the round robin failover process */ | ||
1954 | if (phba->link_state < LPFC_LINK_UP) { | ||
1955 | spin_lock_irq(&phba->hbalock); | ||
1956 | phba->fcf.fcf_flag &= ~FCF_DISCOVERY; | ||
1957 | spin_unlock_irq(&phba->hbalock); | ||
1958 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
1959 | return; | ||
1960 | } | ||
1961 | |||
1962 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
1963 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
1964 | &next_fcf_index); | ||
1965 | if (!new_fcf_record) { | ||
1966 | lpfc_printf_log(phba, KERN_WARNING, LOG_FIP, | ||
1967 | "2766 Mailbox command READ_FCF_RECORD " | ||
1968 | "failed to retrieve a FCF record.\n"); | ||
1969 | goto out; | ||
1970 | } | ||
1971 | |||
1972 | /* Get the needed parameters from FCF record */ | ||
1973 | lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | ||
1974 | &addr_mode, &vlan_id); | ||
1975 | |||
1976 | /* Log the FCF record information if turned on */ | ||
1977 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
1978 | next_fcf_index); | ||
1979 | |||
1980 | /* Upload new FCF record to the failover FCF record */ | ||
1981 | spin_lock_irq(&phba->hbalock); | ||
1982 | __lpfc_update_fcf_record(phba, &phba->fcf.failover_rec, | ||
1983 | new_fcf_record, addr_mode, vlan_id, | ||
1984 | (boot_flag ? BOOT_ENABLE : 0)); | ||
1985 | spin_unlock_irq(&phba->hbalock); | ||
1986 | |||
1987 | current_fcf_index = phba->fcf.current_rec.fcf_indx; | ||
1988 | |||
1989 | /* Unregister the current in-use FCF record */ | ||
1990 | lpfc_unregister_fcf(phba); | ||
1991 | |||
1992 | /* Replace in-use record with the new record */ | ||
1993 | memcpy(&phba->fcf.current_rec, &phba->fcf.failover_rec, | ||
1994 | sizeof(struct lpfc_fcf_rec)); | ||
1995 | |||
1996 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
1997 | "2783 FLOGI round robin FCF failover from FCF " | ||
1998 | "(index:x%x) to FCF (index:x%x).\n", | ||
1999 | current_fcf_index, | ||
2000 | bf_get(lpfc_fcf_record_fcf_index, new_fcf_record)); | ||
2001 | |||
2002 | out: | ||
2003 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
2004 | lpfc_register_fcf(phba); | ||
2005 | } | ||
2006 | |||
2007 | /** | ||
2008 | * lpfc_mbx_cmpl_read_fcf_rec - read fcf completion handler. | ||
2009 | * @phba: pointer to lpfc hba data structure. | ||
2010 | * @mboxq: pointer to mailbox object. | ||
2011 | * | ||
2012 | * This is the callback function of read FCF record mailbox command for | ||
2013 | * updating the eligible FCF bmask for FLOGI failure round robin FCF | ||
2014 | * failover when a new FCF event happened. If the FCF read back is | ||
2015 | * valid/available and it passes the connection list check, it updates | ||
2016 | * the bmask for the eligible FCF record for round robin failover. | ||
2017 | */ | ||
2018 | void | ||
2019 | lpfc_mbx_cmpl_read_fcf_rec(struct lpfc_hba *phba, LPFC_MBOXQ_t *mboxq) | ||
2020 | { | ||
2021 | struct fcf_record *new_fcf_record; | ||
2022 | uint32_t boot_flag, addr_mode; | ||
2023 | uint16_t fcf_index, next_fcf_index; | ||
2024 | uint16_t vlan_id; | ||
2025 | int rc; | ||
2026 | |||
2027 | /* If link state is not up, no need to proceed */ | ||
2028 | if (phba->link_state < LPFC_LINK_UP) | ||
2029 | goto out; | ||
2030 | |||
2031 | /* If FCF discovery period is over, no need to proceed */ | ||
2032 | if (phba->fcf.fcf_flag & FCF_DISCOVERY) | ||
2033 | goto out; | ||
2034 | |||
2035 | /* Parse the FCF record from the non-embedded mailbox command */ | ||
2036 | new_fcf_record = lpfc_sli4_fcf_rec_mbox_parse(phba, mboxq, | ||
2037 | &next_fcf_index); | ||
2038 | if (!new_fcf_record) { | ||
2039 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP, | ||
2040 | "2767 Mailbox command READ_FCF_RECORD " | ||
2041 | "failed to retrieve a FCF record.\n"); | ||
2042 | goto out; | ||
2043 | } | ||
2044 | |||
2045 | /* Check the connection list for eligibility */ | ||
2046 | rc = lpfc_match_fcf_conn_list(phba, new_fcf_record, &boot_flag, | ||
2047 | &addr_mode, &vlan_id); | ||
2048 | |||
2049 | /* Log the FCF record information if turned on */ | ||
2050 | lpfc_sli4_log_fcf_record_info(phba, new_fcf_record, vlan_id, | ||
2051 | next_fcf_index); | ||
2052 | |||
2053 | if (!rc) | ||
2054 | goto out; | ||
2055 | |||
2056 | /* Update the eligible FCF record index bmask */ | ||
2057 | fcf_index = bf_get(lpfc_fcf_record_fcf_index, new_fcf_record); | ||
2058 | rc = lpfc_sli4_fcf_rr_index_set(phba, fcf_index); | ||
2059 | |||
2060 | out: | ||
2061 | lpfc_sli4_mbox_cmd_free(phba, mboxq); | ||
2062 | } | ||
2063 | |||
2064 | /** | ||
1796 | * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. | 2065 | * lpfc_init_vpi_cmpl - Completion handler for init_vpi mbox command. |
1797 | * @phba: pointer to lpfc hba data structure. | 2066 | * @phba: pointer to lpfc hba data structure. |
1798 | * @mboxq: pointer to mailbox data structure. | 2067 | * @mboxq: pointer to mailbox data structure. |
@@ -2024,8 +2293,6 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
2024 | int rc; | 2293 | int rc; |
2025 | struct fcf_record *fcf_record; | 2294 | struct fcf_record *fcf_record; |
2026 | 2295 | ||
2027 | sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); | ||
2028 | |||
2029 | spin_lock_irq(&phba->hbalock); | 2296 | spin_lock_irq(&phba->hbalock); |
2030 | switch (la->UlnkSpeed) { | 2297 | switch (la->UlnkSpeed) { |
2031 | case LA_1GHZ_LINK: | 2298 | case LA_1GHZ_LINK: |
@@ -2117,18 +2384,24 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
2117 | spin_unlock_irq(&phba->hbalock); | 2384 | spin_unlock_irq(&phba->hbalock); |
2118 | 2385 | ||
2119 | lpfc_linkup(phba); | 2386 | lpfc_linkup(phba); |
2120 | if (sparam_mbox) { | 2387 | sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); |
2121 | lpfc_read_sparam(phba, sparam_mbox, 0); | 2388 | if (!sparam_mbox) |
2122 | sparam_mbox->vport = vport; | 2389 | goto out; |
2123 | sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; | 2390 | |
2124 | rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); | 2391 | rc = lpfc_read_sparam(phba, sparam_mbox, 0); |
2125 | if (rc == MBX_NOT_FINISHED) { | 2392 | if (rc) { |
2126 | mp = (struct lpfc_dmabuf *) sparam_mbox->context1; | 2393 | mempool_free(sparam_mbox, phba->mbox_mem_pool); |
2127 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | 2394 | goto out; |
2128 | kfree(mp); | 2395 | } |
2129 | mempool_free(sparam_mbox, phba->mbox_mem_pool); | 2396 | sparam_mbox->vport = vport; |
2130 | goto out; | 2397 | sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; |
2131 | } | 2398 | rc = lpfc_sli_issue_mbox(phba, sparam_mbox, MBX_NOWAIT); |
2399 | if (rc == MBX_NOT_FINISHED) { | ||
2400 | mp = (struct lpfc_dmabuf *) sparam_mbox->context1; | ||
2401 | lpfc_mbuf_free(phba, mp->virt, mp->phys); | ||
2402 | kfree(mp); | ||
2403 | mempool_free(sparam_mbox, phba->mbox_mem_pool); | ||
2404 | goto out; | ||
2132 | } | 2405 | } |
2133 | 2406 | ||
2134 | if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) { | 2407 | if (!(phba->hba_flag & HBA_FCOE_SUPPORT)) { |
@@ -2186,10 +2459,20 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la) | |||
2186 | spin_unlock_irq(&phba->hbalock); | 2459 | spin_unlock_irq(&phba->hbalock); |
2187 | return; | 2460 | return; |
2188 | } | 2461 | } |
2462 | /* This is the initial FCF discovery scan */ | ||
2463 | phba->fcf.fcf_flag |= FCF_INIT_DISC; | ||
2189 | spin_unlock_irq(&phba->hbalock); | 2464 | spin_unlock_irq(&phba->hbalock); |
2190 | rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 2465 | lpfc_printf_log(phba, KERN_INFO, LOG_FIP | LOG_DISCOVERY, |
2191 | if (rc) | 2466 | "2778 Start FCF table scan at linkup\n"); |
2467 | |||
2468 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, | ||
2469 | LPFC_FCOE_FCF_GET_FIRST); | ||
2470 | if (rc) { | ||
2471 | spin_lock_irq(&phba->hbalock); | ||
2472 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
2473 | spin_unlock_irq(&phba->hbalock); | ||
2192 | goto out; | 2474 | goto out; |
2475 | } | ||
2193 | } | 2476 | } |
2194 | 2477 | ||
2195 | return; | 2478 | return; |
@@ -3379,8 +3662,12 @@ lpfc_unreg_hba_rpis(struct lpfc_hba *phba) | |||
3379 | shost = lpfc_shost_from_vport(vports[i]); | 3662 | shost = lpfc_shost_from_vport(vports[i]); |
3380 | spin_lock_irq(shost->host_lock); | 3663 | spin_lock_irq(shost->host_lock); |
3381 | list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { | 3664 | list_for_each_entry(ndlp, &vports[i]->fc_nodes, nlp_listp) { |
3382 | if (ndlp->nlp_flag & NLP_RPI_VALID) | 3665 | if (ndlp->nlp_flag & NLP_RPI_VALID) { |
3666 | /* The mempool_alloc might sleep */ | ||
3667 | spin_unlock_irq(shost->host_lock); | ||
3383 | lpfc_unreg_rpi(vports[i], ndlp); | 3668 | lpfc_unreg_rpi(vports[i], ndlp); |
3669 | spin_lock_irq(shost->host_lock); | ||
3670 | } | ||
3384 | } | 3671 | } |
3385 | spin_unlock_irq(shost->host_lock); | 3672 | spin_unlock_irq(shost->host_lock); |
3386 | } | 3673 | } |
@@ -4756,6 +5043,7 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba) | |||
4756 | return; | 5043 | return; |
4757 | /* Reset HBA FCF states after successful unregister FCF */ | 5044 | /* Reset HBA FCF states after successful unregister FCF */ |
4758 | phba->fcf.fcf_flag = 0; | 5045 | phba->fcf.fcf_flag = 0; |
5046 | phba->fcf.current_rec.flag = 0; | ||
4759 | 5047 | ||
4760 | /* | 5048 | /* |
4761 | * If driver is not unloading, check if there is any other | 5049 | * If driver is not unloading, check if there is any other |
@@ -4765,13 +5053,21 @@ lpfc_unregister_fcf_rescan(struct lpfc_hba *phba) | |||
4765 | (phba->link_state < LPFC_LINK_UP)) | 5053 | (phba->link_state < LPFC_LINK_UP)) |
4766 | return; | 5054 | return; |
4767 | 5055 | ||
4768 | rc = lpfc_sli4_read_fcf_record(phba, LPFC_FCOE_FCF_GET_FIRST); | 5056 | /* This is considered as the initial FCF discovery scan */ |
5057 | spin_lock_irq(&phba->hbalock); | ||
5058 | phba->fcf.fcf_flag |= FCF_INIT_DISC; | ||
5059 | spin_unlock_irq(&phba->hbalock); | ||
5060 | rc = lpfc_sli4_fcf_scan_read_fcf_rec(phba, LPFC_FCOE_FCF_GET_FIRST); | ||
4769 | 5061 | ||
4770 | if (rc) | 5062 | if (rc) { |
5063 | spin_lock_irq(&phba->hbalock); | ||
5064 | phba->fcf.fcf_flag &= ~FCF_INIT_DISC; | ||
5065 | spin_unlock_irq(&phba->hbalock); | ||
4771 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, | 5066 | lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY|LOG_MBOX, |
4772 | "2553 lpfc_unregister_unused_fcf failed " | 5067 | "2553 lpfc_unregister_unused_fcf failed " |
4773 | "to read FCF record HBA state x%x\n", | 5068 | "to read FCF record HBA state x%x\n", |
4774 | phba->pport->port_state); | 5069 | phba->pport->port_state); |
5070 | } | ||
4775 | } | 5071 | } |
4776 | 5072 | ||
4777 | /** | 5073 | /** |