aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_sli.c
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2008-08-24 21:49:55 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-10-13 09:28:53 -0400
commit34b02dcdcf1865405f4762b991965c0c3b8a3ae0 (patch)
tree00829334c2813d30e574a5f1290fbf7dd210d1cb /drivers/scsi/lpfc/lpfc_sli.c
parent90160e010b6f3a91a9bb044bbe6723731e6f366c (diff)
[SCSI] lpfc 8.2.8 : Update driver for new SLI-3 features
Update driver for new SLI-3 features: - interrupt enhancements - lose adapter doorbell writes - inlining support for FCP_Ixx cmds Signed-off-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c122
1 files changed, 66 insertions, 56 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 3cf488496d86..77afa2ba6a2b 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -406,11 +406,8 @@ lpfc_sli_ringtx_get(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
406static IOCB_t * 406static IOCB_t *
407lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) 407lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
408{ 408{
409 struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? 409 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno];
410 &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] :
411 &phba->slim2p->mbx.us.s2.port[pring->ringno];
412 uint32_t max_cmd_idx = pring->numCiocb; 410 uint32_t max_cmd_idx = pring->numCiocb;
413
414 if ((pring->next_cmdidx == pring->cmdidx) && 411 if ((pring->next_cmdidx == pring->cmdidx) &&
415 (++pring->next_cmdidx >= max_cmd_idx)) 412 (++pring->next_cmdidx >= max_cmd_idx))
416 pring->next_cmdidx = 0; 413 pring->next_cmdidx = 0;
@@ -625,9 +622,11 @@ lpfc_sli_update_ring(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
625 /* 622 /*
626 * Tell the HBA that there is work to do in this ring. 623 * Tell the HBA that there is work to do in this ring.
627 */ 624 */
628 wmb(); 625 if (!(phba->sli3_options & LPFC_SLI3_CRP_ENABLED)) {
629 writel(CA_R0ATT << (ringno * 4), phba->CAregaddr); 626 wmb();
630 readl(phba->CAregaddr); /* flush */ 627 writel(CA_R0ATT << (ringno * 4), phba->CAregaddr);
628 readl(phba->CAregaddr); /* flush */
629 }
631} 630}
632 631
633/** 632/**
@@ -1654,9 +1653,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
1654static void 1653static void
1655lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring) 1654lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
1656{ 1655{
1657 struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? 1656 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno];
1658 &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] :
1659 &phba->slim2p->mbx.us.s2.port[pring->ringno];
1660 /* 1657 /*
1661 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then 1658 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then
1662 * rsp ring <portRspMax> 1659 * rsp ring <portRspMax>
@@ -1704,7 +1701,7 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba)
1704 IOCB_t *entry = NULL; 1701 IOCB_t *entry = NULL;
1705 struct lpfc_iocbq *cmdiocbq = NULL; 1702 struct lpfc_iocbq *cmdiocbq = NULL;
1706 struct lpfc_iocbq rspiocbq; 1703 struct lpfc_iocbq rspiocbq;
1707 struct lpfc_pgp *pgp; 1704 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno];
1708 uint32_t status; 1705 uint32_t status;
1709 uint32_t portRspPut, portRspMax; 1706 uint32_t portRspPut, portRspMax;
1710 int type; 1707 int type;
@@ -1714,11 +1711,6 @@ void lpfc_sli_poll_fcp_ring(struct lpfc_hba *phba)
1714 1711
1715 pring->stats.iocb_event++; 1712 pring->stats.iocb_event++;
1716 1713
1717 pgp = (phba->sli_rev == 3) ?
1718 &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] :
1719 &phba->slim2p->mbx.us.s2.port[pring->ringno];
1720
1721
1722 /* 1714 /*
1723 * The next available response entry should never exceed the maximum 1715 * The next available response entry should never exceed the maximum
1724 * entries. If it does, treat it as an adapter hardware error. 1716 * entries. If it does, treat it as an adapter hardware error.
@@ -1870,9 +1862,7 @@ static int
1870lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba, 1862lpfc_sli_handle_fast_ring_event(struct lpfc_hba *phba,
1871 struct lpfc_sli_ring *pring, uint32_t mask) 1863 struct lpfc_sli_ring *pring, uint32_t mask)
1872{ 1864{
1873 struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? 1865 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno];
1874 &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] :
1875 &phba->slim2p->mbx.us.s2.port[pring->ringno];
1876 IOCB_t *irsp = NULL; 1866 IOCB_t *irsp = NULL;
1877 IOCB_t *entry = NULL; 1867 IOCB_t *entry = NULL;
1878 struct lpfc_iocbq *cmdiocbq = NULL; 1868 struct lpfc_iocbq *cmdiocbq = NULL;
@@ -2064,9 +2054,7 @@ int
2064lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba, 2054lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
2065 struct lpfc_sli_ring *pring, uint32_t mask) 2055 struct lpfc_sli_ring *pring, uint32_t mask)
2066{ 2056{
2067 struct lpfc_pgp *pgp = (phba->sli_rev == 3) ? 2057 struct lpfc_pgp *pgp;
2068 &phba->slim2p->mbx.us.s3_pgp.port[pring->ringno] :
2069 &phba->slim2p->mbx.us.s2.port[pring->ringno];
2070 IOCB_t *entry; 2058 IOCB_t *entry;
2071 IOCB_t *irsp = NULL; 2059 IOCB_t *irsp = NULL;
2072 struct lpfc_iocbq *rspiocbp = NULL; 2060 struct lpfc_iocbq *rspiocbp = NULL;
@@ -2080,6 +2068,7 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
2080 int rc = 1; 2068 int rc = 1;
2081 unsigned long iflag; 2069 unsigned long iflag;
2082 2070
2071 pgp = &phba->port_gp[pring->ringno];
2083 spin_lock_irqsave(&phba->hbalock, iflag); 2072 spin_lock_irqsave(&phba->hbalock, iflag);
2084 pring->stats.iocb_event++; 2073 pring->stats.iocb_event++;
2085 2074
@@ -2990,13 +2979,15 @@ lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode)
2990 if (rc == -ERESTART) { 2979 if (rc == -ERESTART) {
2991 phba->link_state = LPFC_LINK_UNKNOWN; 2980 phba->link_state = LPFC_LINK_UNKNOWN;
2992 continue; 2981 continue;
2993 } else if (rc) { 2982 } else if (rc)
2994 break; 2983 break;
2995 }
2996
2997 phba->link_state = LPFC_INIT_MBX_CMDS; 2984 phba->link_state = LPFC_INIT_MBX_CMDS;
2998 lpfc_config_port(phba, pmb); 2985 lpfc_config_port(phba, pmb);
2999 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL); 2986 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_POLL);
2987 phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED |
2988 LPFC_SLI3_HBQ_ENABLED |
2989 LPFC_SLI3_CRP_ENABLED |
2990 LPFC_SLI3_INB_ENABLED);
3000 if (rc != MBX_SUCCESS) { 2991 if (rc != MBX_SUCCESS) {
3001 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 2992 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
3002 "0442 Adapter failed to init, mbxCmd x%x " 2993 "0442 Adapter failed to init, mbxCmd x%x "
@@ -3006,25 +2997,44 @@ lpfc_do_config_port(struct lpfc_hba *phba, int sli_mode)
3006 phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE; 2997 phba->sli.sli_flag &= ~LPFC_SLI2_ACTIVE;
3007 spin_unlock_irq(&phba->hbalock); 2998 spin_unlock_irq(&phba->hbalock);
3008 rc = -ENXIO; 2999 rc = -ENXIO;
3009 } else { 3000 } else
3010 done = 1; 3001 done = 1;
3011 phba->max_vpi = (phba->max_vpi &&
3012 pmb->mb.un.varCfgPort.gmv) != 0
3013 ? pmb->mb.un.varCfgPort.max_vpi
3014 : 0;
3015 }
3016 } 3002 }
3017
3018 if (!done) { 3003 if (!done) {
3019 rc = -EINVAL; 3004 rc = -EINVAL;
3020 goto do_prep_failed; 3005 goto do_prep_failed;
3021 } 3006 }
3022 3007 if (pmb->mb.un.varCfgPort.sli_mode == 3) {
3023 if ((pmb->mb.un.varCfgPort.sli_mode == 3) && 3008 if (!pmb->mb.un.varCfgPort.cMA) {
3024 (!pmb->mb.un.varCfgPort.cMA)) { 3009 rc = -ENXIO;
3025 rc = -ENXIO; 3010 goto do_prep_failed;
3011 }
3012 if (phba->max_vpi && pmb->mb.un.varCfgPort.gmv) {
3013 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED;
3014 phba->max_vpi = pmb->mb.un.varCfgPort.max_vpi;
3015 } else
3016 phba->max_vpi = 0;
3017 if (pmb->mb.un.varCfgPort.gerbm)
3018 phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED;
3019 if (pmb->mb.un.varCfgPort.gcrp)
3020 phba->sli3_options |= LPFC_SLI3_CRP_ENABLED;
3021 if (pmb->mb.un.varCfgPort.ginb) {
3022 phba->sli3_options |= LPFC_SLI3_INB_ENABLED;
3023 phba->port_gp = phba->mbox->us.s3_inb_pgp.port;
3024 phba->inb_ha_copy = &phba->mbox->us.s3_inb_pgp.ha_copy;
3025 phba->inb_counter = &phba->mbox->us.s3_inb_pgp.counter;
3026 phba->inb_last_counter =
3027 phba->mbox->us.s3_inb_pgp.counter;
3028 } else {
3029 phba->port_gp = phba->mbox->us.s3_pgp.port;
3030 phba->inb_ha_copy = NULL;
3031 phba->inb_counter = NULL;
3032 }
3033 } else {
3034 phba->port_gp = phba->mbox->us.s2.port;
3035 phba->inb_ha_copy = NULL;
3036 phba->inb_counter = NULL;
3026 } 3037 }
3027
3028do_prep_failed: 3038do_prep_failed:
3029 mempool_free(pmb, phba->mbox_mem_pool); 3039 mempool_free(pmb, phba->mbox_mem_pool);
3030 return rc; 3040 return rc;
@@ -3085,9 +3095,6 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba)
3085 if (phba->sli_rev == 3) { 3095 if (phba->sli_rev == 3) {
3086 phba->iocb_cmd_size = SLI3_IOCB_CMD_SIZE; 3096 phba->iocb_cmd_size = SLI3_IOCB_CMD_SIZE;
3087 phba->iocb_rsp_size = SLI3_IOCB_RSP_SIZE; 3097 phba->iocb_rsp_size = SLI3_IOCB_RSP_SIZE;
3088 phba->sli3_options |= LPFC_SLI3_ENABLED;
3089 phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED;
3090
3091 } else { 3098 } else {
3092 phba->iocb_cmd_size = SLI2_IOCB_CMD_SIZE; 3099 phba->iocb_cmd_size = SLI2_IOCB_CMD_SIZE;
3093 phba->iocb_rsp_size = SLI2_IOCB_RSP_SIZE; 3100 phba->iocb_rsp_size = SLI2_IOCB_RSP_SIZE;
@@ -3255,7 +3262,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
3255 int i; 3262 int i;
3256 unsigned long timeout; 3263 unsigned long timeout;
3257 unsigned long drvr_flag = 0; 3264 unsigned long drvr_flag = 0;
3258 volatile uint32_t word0, ldata; 3265 uint32_t word0, ldata;
3259 void __iomem *to_slim; 3266 void __iomem *to_slim;
3260 int processing_queue = 0; 3267 int processing_queue = 0;
3261 3268
@@ -3415,12 +3422,11 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
3415 3422
3416 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 3423 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
3417 /* First copy command data to host SLIM area */ 3424 /* First copy command data to host SLIM area */
3418 lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx, MAILBOX_CMD_SIZE); 3425 lpfc_sli_pcimem_bcopy(mb, phba->mbox, MAILBOX_CMD_SIZE);
3419 } else { 3426 } else {
3420 if (mb->mbxCommand == MBX_CONFIG_PORT) { 3427 if (mb->mbxCommand == MBX_CONFIG_PORT) {
3421 /* copy command data into host mbox for cmpl */ 3428 /* copy command data into host mbox for cmpl */
3422 lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx, 3429 lpfc_sli_pcimem_bcopy(mb, phba->mbox, MAILBOX_CMD_SIZE);
3423 MAILBOX_CMD_SIZE);
3424 } 3430 }
3425 3431
3426 /* First copy mbox command data to HBA SLIM, skip past first 3432 /* First copy mbox command data to HBA SLIM, skip past first
@@ -3430,7 +3436,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
3430 MAILBOX_CMD_SIZE - sizeof (uint32_t)); 3436 MAILBOX_CMD_SIZE - sizeof (uint32_t));
3431 3437
3432 /* Next copy over first word, with mbxOwner set */ 3438 /* Next copy over first word, with mbxOwner set */
3433 ldata = *((volatile uint32_t *)mb); 3439 ldata = *((uint32_t *)mb);
3434 to_slim = phba->MBslimaddr; 3440 to_slim = phba->MBslimaddr;
3435 writel(ldata, to_slim); 3441 writel(ldata, to_slim);
3436 readl(to_slim); /* flush */ 3442 readl(to_slim); /* flush */
@@ -3462,7 +3468,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
3462 3468
3463 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 3469 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
3464 /* First read mbox status word */ 3470 /* First read mbox status word */
3465 word0 = *((volatile uint32_t *)&phba->slim2p->mbx); 3471 word0 = *((uint32_t *)phba->mbox);
3466 word0 = le32_to_cpu(word0); 3472 word0 = le32_to_cpu(word0);
3467 } else { 3473 } else {
3468 /* First read mbox status word */ 3474 /* First read mbox status word */
@@ -3501,12 +3507,11 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
3501 3507
3502 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 3508 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
3503 /* First copy command data */ 3509 /* First copy command data */
3504 word0 = *((volatile uint32_t *) 3510 word0 = *((uint32_t *)phba->mbox);
3505 &phba->slim2p->mbx);
3506 word0 = le32_to_cpu(word0); 3511 word0 = le32_to_cpu(word0);
3507 if (mb->mbxCommand == MBX_CONFIG_PORT) { 3512 if (mb->mbxCommand == MBX_CONFIG_PORT) {
3508 MAILBOX_t *slimmb; 3513 MAILBOX_t *slimmb;
3509 volatile uint32_t slimword0; 3514 uint32_t slimword0;
3510 /* Check real SLIM for any errors */ 3515 /* Check real SLIM for any errors */
3511 slimword0 = readl(phba->MBslimaddr); 3516 slimword0 = readl(phba->MBslimaddr);
3512 slimmb = (MAILBOX_t *) & slimword0; 3517 slimmb = (MAILBOX_t *) & slimword0;
@@ -3527,8 +3532,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmbox, uint32_t flag)
3527 3532
3528 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 3533 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
3529 /* copy results back to user */ 3534 /* copy results back to user */
3530 lpfc_sli_pcimem_bcopy(&phba->slim2p->mbx, mb, 3535 lpfc_sli_pcimem_bcopy(phba->mbox, mb, MAILBOX_CMD_SIZE);
3531 MAILBOX_CMD_SIZE);
3532 } else { 3536 } else {
3533 /* First copy command data */ 3537 /* First copy command data */
3534 lpfc_memcpy_from_slim(mb, phba->MBslimaddr, 3538 lpfc_memcpy_from_slim(mb, phba->MBslimaddr,
@@ -5095,7 +5099,16 @@ lpfc_intr_handler(int irq, void *dev_id)
5095 * preserve status) and Link Attention 5099 * preserve status) and Link Attention
5096 */ 5100 */
5097 spin_lock(&phba->hbalock); 5101 spin_lock(&phba->hbalock);
5098 ha_copy = readl(phba->HAregaddr); 5102 if (phba->sli3_options & LPFC_SLI3_INB_ENABLED &&
5103 (phba->inb_last_counter != *phba->inb_counter)) {
5104 phba->inb_last_counter = *phba->inb_counter;
5105 ha_copy = le32_to_cpu(*phba->inb_ha_copy);
5106 } else
5107 ha_copy = readl(phba->HAregaddr);
5108 if (unlikely(!ha_copy)) {
5109 spin_unlock(&phba->hbalock);
5110 return IRQ_NONE;
5111 }
5099 /* If somebody is waiting to handle an eratt don't process it 5112 /* If somebody is waiting to handle an eratt don't process it
5100 * here. The brdkill function will do this. 5113 * here. The brdkill function will do this.
5101 */ 5114 */
@@ -5105,9 +5118,6 @@ lpfc_intr_handler(int irq, void *dev_id)
5105 readl(phba->HAregaddr); /* flush */ 5118 readl(phba->HAregaddr); /* flush */
5106 spin_unlock(&phba->hbalock); 5119 spin_unlock(&phba->hbalock);
5107 5120
5108 if (unlikely(!ha_copy))
5109 return IRQ_NONE;
5110
5111 work_ha_copy = ha_copy & phba->work_ha_mask; 5121 work_ha_copy = ha_copy & phba->work_ha_mask;
5112 5122
5113 if (unlikely(work_ha_copy)) { 5123 if (unlikely(work_ha_copy)) {
@@ -5194,7 +5204,7 @@ lpfc_intr_handler(int irq, void *dev_id)
5194 (phba->sli.mbox_active)) { 5204 (phba->sli.mbox_active)) {
5195 pmb = phba->sli.mbox_active; 5205 pmb = phba->sli.mbox_active;
5196 pmbox = &pmb->mb; 5206 pmbox = &pmb->mb;
5197 mbox = &phba->slim2p->mbx; 5207 mbox = phba->mbox;
5198 vport = pmb->vport; 5208 vport = pmb->vport;
5199 5209
5200 /* First check out the status word */ 5210 /* First check out the status word */