aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_sli.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_sli.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c125
1 files changed, 60 insertions, 65 deletions
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 8d14b28c80b9..1775508ed276 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -1,27 +1,24 @@
1/******************************************************************* 1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for * 2 * This file is part of the Emulex Linux Device Driver for *
3 * Enterprise Fibre Channel Host Bus Adapters. * 3 * Fibre Channel Host Bus Adapters. *
4 * Refer to the README file included with this package for * 4 * Copyright (C) 2004-2005 Emulex. All rights reserved. *
5 * driver version and adapter support. * 5 * EMULEX and SLI are trademarks of Emulex. *
6 * Copyright (C) 2004 Emulex Corporation. *
7 * www.emulex.com * 6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
8 * * 8 * *
9 * This program is free software; you can redistribute it and/or * 9 * This program is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU General Public License * 10 * modify it under the terms of version 2 of the GNU General *
11 * as published by the Free Software Foundation; either version 2 * 11 * Public License as published by the Free Software Foundation. *
12 * of the License, or (at your option) any later version. * 12 * This program is distributed in the hope that it will be useful. *
13 * * 13 * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
14 * This program is distributed in the hope that it will be useful, * 14 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
17 * GNU General Public License for more details, a copy of which * 17 * TO BE LEGALLY INVALID. See the GNU General Public License for *
18 * can be found in the file COPYING included with this package. * 18 * more details, a copy of which can be found in the file COPYING *
19 * included with this package. *
19 *******************************************************************/ 20 *******************************************************************/
20 21
21/*
22 * $Id: lpfc_sli.c 1.232 2005/04/13 11:59:16EDT sf_support Exp $
23 */
24
25#include <linux/blkdev.h> 22#include <linux/blkdev.h>
26#include <linux/pci.h> 23#include <linux/pci.h>
27#include <linux/interrupt.h> 24#include <linux/interrupt.h>
@@ -225,8 +222,7 @@ lpfc_sli_ringtx_get(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
225static IOCB_t * 222static IOCB_t *
226lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring) 223lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
227{ 224{
228 MAILBOX_t *mbox = (MAILBOX_t *)phba->sli.MBhostaddr; 225 struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno];
229 PGP *pgp = (PGP *)&mbox->us.s2.port[pring->ringno];
230 uint32_t max_cmd_idx = pring->numCiocb; 226 uint32_t max_cmd_idx = pring->numCiocb;
231 IOCB_t *iocb = NULL; 227 IOCB_t *iocb = NULL;
232 228
@@ -411,9 +407,7 @@ lpfc_sli_resume_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring)
411static void 407static void
412lpfc_sli_turn_on_ring(struct lpfc_hba * phba, int ringno) 408lpfc_sli_turn_on_ring(struct lpfc_hba * phba, int ringno)
413{ 409{
414 PGP *pgp = 410 struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[ringno];
415 ((PGP *) &
416 (((MAILBOX_t *)phba->sli.MBhostaddr)->us.s2.port[ringno]));
417 411
418 /* If the ring is active, flag it */ 412 /* If the ring is active, flag it */
419 if (phba->sli.ring[ringno].cmdringaddr) { 413 if (phba->sli.ring[ringno].cmdringaddr) {
@@ -537,7 +531,7 @@ lpfc_sli_handle_mb_event(struct lpfc_hba * phba)
537 /* Get a Mailbox buffer to setup mailbox commands for callback */ 531 /* Get a Mailbox buffer to setup mailbox commands for callback */
538 if ((pmb = phba->sli.mbox_active)) { 532 if ((pmb = phba->sli.mbox_active)) {
539 pmbox = &pmb->mb; 533 pmbox = &pmb->mb;
540 mbox = (MAILBOX_t *) phba->sli.MBhostaddr; 534 mbox = &phba->slim2p->mbx;
541 535
542 /* First check out the status word */ 536 /* First check out the status word */
543 lpfc_sli_pcimem_bcopy(mbox, pmbox, sizeof (uint32_t)); 537 lpfc_sli_pcimem_bcopy(mbox, pmbox, sizeof (uint32_t));
@@ -905,10 +899,11 @@ static int
905lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, 899lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
906 struct lpfc_sli_ring * pring, uint32_t mask) 900 struct lpfc_sli_ring * pring, uint32_t mask)
907{ 901{
902 struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno];
908 IOCB_t *irsp = NULL; 903 IOCB_t *irsp = NULL;
904 IOCB_t *entry = NULL;
909 struct lpfc_iocbq *cmdiocbq = NULL; 905 struct lpfc_iocbq *cmdiocbq = NULL;
910 struct lpfc_iocbq rspiocbq; 906 struct lpfc_iocbq rspiocbq;
911 PGP *pgp;
912 uint32_t status; 907 uint32_t status;
913 uint32_t portRspPut, portRspMax; 908 uint32_t portRspPut, portRspMax;
914 int rc = 1; 909 int rc = 1;
@@ -920,10 +915,6 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
920 spin_lock_irqsave(phba->host->host_lock, iflag); 915 spin_lock_irqsave(phba->host->host_lock, iflag);
921 pring->stats.iocb_event++; 916 pring->stats.iocb_event++;
922 917
923 /* The driver assumes SLI-2 mode */
924 pgp = (PGP *) &((MAILBOX_t *) phba->sli.MBhostaddr)
925 ->us.s2.port[pring->ringno];
926
927 /* 918 /*
928 * The next available response entry should never exceed the maximum 919 * The next available response entry should never exceed the maximum
929 * entries. If it does, treat it as an adapter hardware error. 920 * entries. If it does, treat it as an adapter hardware error.
@@ -955,7 +946,17 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
955 946
956 rmb(); 947 rmb();
957 while (pring->rspidx != portRspPut) { 948 while (pring->rspidx != portRspPut) {
958 irsp = (IOCB_t *) IOCB_ENTRY(pring->rspringaddr, pring->rspidx); 949 /*
950 * Fetch an entry off the ring and copy it into a local data
951 * structure. The copy involves a byte-swap since the
952 * network byte order and pci byte orders are different.
953 */
954 entry = (IOCB_t *) IOCB_ENTRY(pring->rspringaddr, pring->rspidx);
955 lpfc_sli_pcimem_bcopy((uint32_t *) entry,
956 (uint32_t *) &rspiocbq.iocb,
957 sizeof (IOCB_t));
958 irsp = &rspiocbq.iocb;
959
959 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); 960 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK);
960 pring->stats.iocb_rsp++; 961 pring->stats.iocb_rsp++;
961 rsp_cmpl++; 962 rsp_cmpl++;
@@ -987,10 +988,6 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
987 break; 988 break;
988 } 989 }
989 990
990 rspiocbq.iocb.un.ulpWord[4] = irsp->un.ulpWord[4];
991 rspiocbq.iocb.ulpStatus = irsp->ulpStatus;
992 rspiocbq.iocb.ulpContext = irsp->ulpContext;
993 rspiocbq.iocb.ulpIoTag = irsp->ulpIoTag;
994 cmdiocbq = lpfc_sli_txcmpl_ring_iotag_lookup(phba, 991 cmdiocbq = lpfc_sli_txcmpl_ring_iotag_lookup(phba,
995 pring, 992 pring,
996 &rspiocbq); 993 &rspiocbq);
@@ -1075,9 +1072,7 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba,
1075 struct lpfc_iocbq *cmdiocbp; 1072 struct lpfc_iocbq *cmdiocbp;
1076 struct lpfc_iocbq *saveq; 1073 struct lpfc_iocbq *saveq;
1077 struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list; 1074 struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list;
1078 HGP *hgp; 1075 struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno];
1079 PGP *pgp;
1080 MAILBOX_t *mbox;
1081 uint8_t iocb_cmd_type; 1076 uint8_t iocb_cmd_type;
1082 lpfc_iocb_type type; 1077 lpfc_iocb_type type;
1083 uint32_t status, free_saveq; 1078 uint32_t status, free_saveq;
@@ -1089,11 +1084,6 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba * phba,
1089 spin_lock_irqsave(phba->host->host_lock, iflag); 1084 spin_lock_irqsave(phba->host->host_lock, iflag);
1090 pring->stats.iocb_event++; 1085 pring->stats.iocb_event++;
1091 1086
1092 /* The driver assumes SLI-2 mode */
1093 mbox = (MAILBOX_t *) phba->sli.MBhostaddr;
1094 pgp = (PGP *) & mbox->us.s2.port[pring->ringno];
1095 hgp = (HGP *) & mbox->us.s2.host[pring->ringno];
1096
1097 /* 1087 /*
1098 * The next available response entry should never exceed the maximum 1088 * The next available response entry should never exceed the maximum
1099 * entries. If it does, treat it as an adapter hardware error. 1089 * entries. If it does, treat it as an adapter hardware error.
@@ -1738,6 +1728,8 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
1738 return; 1728 return;
1739 } 1729 }
1740 1730
1731 phba->work_hba_events &= ~WORKER_MBOX_TMO;
1732
1741 pmbox = phba->sli.mbox_active; 1733 pmbox = phba->sli.mbox_active;
1742 mb = &pmbox->mb; 1734 mb = &pmbox->mb;
1743 1735
@@ -1752,16 +1744,14 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
1752 phba->sli.sli_flag, 1744 phba->sli.sli_flag,
1753 phba->sli.mbox_active); 1745 phba->sli.mbox_active);
1754 1746
1755 if (phba->sli.mbox_active == pmbox) { 1747 phba->sli.mbox_active = NULL;
1756 phba->sli.mbox_active = NULL; 1748 if (pmbox->mbox_cmpl) {
1757 if (pmbox->mbox_cmpl) { 1749 mb->mbxStatus = MBX_NOT_FINISHED;
1758 mb->mbxStatus = MBX_NOT_FINISHED; 1750 spin_unlock_irq(phba->host->host_lock);
1759 spin_unlock_irq(phba->host->host_lock); 1751 (pmbox->mbox_cmpl) (phba, pmbox);
1760 (pmbox->mbox_cmpl) (phba, pmbox); 1752 spin_lock_irq(phba->host->host_lock);
1761 spin_lock_irq(phba->host->host_lock);
1762 }
1763 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
1764 } 1753 }
1754 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;
1765 1755
1766 spin_unlock_irq(phba->host->host_lock); 1756 spin_unlock_irq(phba->host->host_lock);
1767 lpfc_mbox_abort(phba); 1757 lpfc_mbox_abort(phba);
@@ -1771,7 +1761,6 @@ lpfc_mbox_timeout_handler(struct lpfc_hba *phba)
1771int 1761int
1772lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag) 1762lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
1773{ 1763{
1774 MAILBOX_t *mbox;
1775 MAILBOX_t *mb; 1764 MAILBOX_t *mb;
1776 struct lpfc_sli *psli; 1765 struct lpfc_sli *psli;
1777 uint32_t status, evtctr; 1766 uint32_t status, evtctr;
@@ -1901,15 +1890,13 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
1901 mb->mbxOwner = OWN_CHIP; 1890 mb->mbxOwner = OWN_CHIP;
1902 1891
1903 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 1892 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
1904
1905 /* First copy command data to host SLIM area */ 1893 /* First copy command data to host SLIM area */
1906 mbox = (MAILBOX_t *) psli->MBhostaddr; 1894 lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx, MAILBOX_CMD_SIZE);
1907 lpfc_sli_pcimem_bcopy(mb, mbox, MAILBOX_CMD_SIZE);
1908 } else { 1895 } else {
1909 if (mb->mbxCommand == MBX_CONFIG_PORT) { 1896 if (mb->mbxCommand == MBX_CONFIG_PORT) {
1910 /* copy command data into host mbox for cmpl */ 1897 /* copy command data into host mbox for cmpl */
1911 mbox = (MAILBOX_t *) psli->MBhostaddr; 1898 lpfc_sli_pcimem_bcopy(mb, &phba->slim2p->mbx,
1912 lpfc_sli_pcimem_bcopy(mb, mbox, MAILBOX_CMD_SIZE); 1899 MAILBOX_CMD_SIZE);
1913 } 1900 }
1914 1901
1915 /* First copy mbox command data to HBA SLIM, skip past first 1902 /* First copy mbox command data to HBA SLIM, skip past first
@@ -1946,8 +1933,7 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
1946 psli->mbox_active = NULL; 1933 psli->mbox_active = NULL;
1947 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 1934 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
1948 /* First read mbox status word */ 1935 /* First read mbox status word */
1949 mbox = (MAILBOX_t *) psli->MBhostaddr; 1936 word0 = *((volatile uint32_t *)&phba->slim2p->mbx);
1950 word0 = *((volatile uint32_t *)mbox);
1951 word0 = le32_to_cpu(word0); 1937 word0 = le32_to_cpu(word0);
1952 } else { 1938 } else {
1953 /* First read mbox status word */ 1939 /* First read mbox status word */
@@ -1984,8 +1970,8 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
1984 1970
1985 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 1971 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
1986 /* First copy command data */ 1972 /* First copy command data */
1987 mbox = (MAILBOX_t *) psli->MBhostaddr; 1973 word0 = *((volatile uint32_t *)
1988 word0 = *((volatile uint32_t *)mbox); 1974 &phba->slim2p->mbx);
1989 word0 = le32_to_cpu(word0); 1975 word0 = le32_to_cpu(word0);
1990 if (mb->mbxCommand == MBX_CONFIG_PORT) { 1976 if (mb->mbxCommand == MBX_CONFIG_PORT) {
1991 MAILBOX_t *slimmb; 1977 MAILBOX_t *slimmb;
@@ -2009,10 +1995,9 @@ lpfc_sli_issue_mbox(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmbox, uint32_t flag)
2009 } 1995 }
2010 1996
2011 if (psli->sli_flag & LPFC_SLI2_ACTIVE) { 1997 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {
2012 /* First copy command data */
2013 mbox = (MAILBOX_t *) psli->MBhostaddr;
2014 /* copy results back to user */ 1998 /* copy results back to user */
2015 lpfc_sli_pcimem_bcopy(mbox, mb, MAILBOX_CMD_SIZE); 1999 lpfc_sli_pcimem_bcopy(&phba->slim2p->mbx, mb,
2000 MAILBOX_CMD_SIZE);
2016 } else { 2001 } else {
2017 /* First copy command data */ 2002 /* First copy command data */
2018 lpfc_memcpy_from_slim(mb, phba->MBslimaddr, 2003 lpfc_memcpy_from_slim(mb, phba->MBslimaddr,
@@ -2089,8 +2074,6 @@ lpfc_sli_issue_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2089 switch (piocb->iocb.ulpCommand) { 2074 switch (piocb->iocb.ulpCommand) {
2090 case CMD_QUE_RING_BUF_CN: 2075 case CMD_QUE_RING_BUF_CN:
2091 case CMD_QUE_RING_BUF64_CN: 2076 case CMD_QUE_RING_BUF64_CN:
2092 case CMD_CLOSE_XRI_CN:
2093 case CMD_ABORT_XRI_CN:
2094 /* 2077 /*
2095 * For IOCBs, like QUE_RING_BUF, that have no rsp ring 2078 * For IOCBs, like QUE_RING_BUF, that have no rsp ring
2096 * completion, iocb_cmpl MUST be 0. 2079 * completion, iocb_cmpl MUST be 0.
@@ -2573,6 +2556,16 @@ lpfc_sli_sum_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2573 return sum; 2556 return sum;
2574} 2557}
2575 2558
2559void
2560lpfc_sli_abort_fcp_cmpl(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
2561 struct lpfc_iocbq * rspiocb)
2562{
2563 spin_lock_irq(phba->host->host_lock);
2564 list_add_tail(&cmdiocb->list, &phba->lpfc_iocb_list);
2565 spin_unlock_irq(phba->host->host_lock);
2566 return;
2567}
2568
2576int 2569int
2577lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring, 2570lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2578 uint16_t tgt_id, uint64_t lun_id, uint32_t ctx, 2571 uint16_t tgt_id, uint64_t lun_id, uint32_t ctx,
@@ -2622,6 +2615,8 @@ lpfc_sli_abort_iocb(struct lpfc_hba *phba, struct lpfc_sli_ring *pring,
2622 else 2615 else
2623 abtsiocb->iocb.ulpCommand = CMD_CLOSE_XRI_CN; 2616 abtsiocb->iocb.ulpCommand = CMD_CLOSE_XRI_CN;
2624 2617
2618 /* Setup callback routine and issue the command. */
2619 abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl;
2625 ret_val = lpfc_sli_issue_iocb(phba, pring, abtsiocb, 0); 2620 ret_val = lpfc_sli_issue_iocb(phba, pring, abtsiocb, 0);
2626 if (ret_val == IOCB_ERROR) { 2621 if (ret_val == IOCB_ERROR) {
2627 list_add_tail(&abtsiocb->list, lpfc_iocb_list); 2622 list_add_tail(&abtsiocb->list, lpfc_iocb_list);