Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / scsi / lpfc / lpfc_mbox.c
index 8712a80..e42f22a 100644 (file)
@@ -1,31 +1,33 @@
 /*******************************************************************
  * This file is part of the Emulex Linux Device Driver for         *
- * Enterprise Fibre Channel Host Bus Adapters.                     *
- * Refer to the README file included with this package for         *
- * driver version and adapter support.                             *
- * Copyright (C) 2004 Emulex Corporation.                          *
+ * Fibre Channel Host Bus Adapters.                                *
+ * Copyright (C) 2004-2006 Emulex.  All rights reserved.           *
+ * EMULEX and SLI are trademarks of Emulex.                        *
  * www.emulex.com                                                  *
+ * Portions Copyright (C) 2004-2005 Christoph Hellwig              *
  *                                                                 *
  * This program is free software; you can redistribute it and/or   *
- * modify it under the terms of the GNU General Public License     *
- * as published by the Free Software Foundation; either version 2  *
- * of the License, or (at your option) any later version.          *
- *                                                                 *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of  *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *
- * GNU General Public License for more details, a copy of which    *
- * can be found in the file COPYING included with this package.    *
+ * modify it under the terms of version 2 of the GNU General       *
+ * Public License as published by the Free Software Foundation.    *
+ * This program is distributed in the hope that it will be useful. *
+ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND          *
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,  *
+ * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE      *
+ * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
+ * TO BE LEGALLY INVALID.  See the GNU General Public License for  *
+ * more details, a copy of which can be found in the file COPYING  *
+ * included with this package.                                     *
  *******************************************************************/
 
-/*
- * $Id: lpfc_mbox.c 1.85 2005/04/13 11:59:11EDT sf_support Exp  $
- */
-
 #include <linux/blkdev.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_transport_fc.h>
+
+#include <scsi/scsi.h>
+
 #include "lpfc_hw.h"
 #include "lpfc_sli.h"
 #include "lpfc_disc.h"
@@ -193,8 +195,14 @@ lpfc_init_link(struct lpfc_hba * phba,
                mb->un.varInitLnk.link_flags = FLAGS_TOPOLOGY_MODE_PT_PT;
                mb->un.varInitLnk.link_flags |= FLAGS_TOPOLOGY_FAILOVER;
                break;
+       case FLAGS_LOCAL_LB:
+               mb->un.varInitLnk.link_flags = FLAGS_LOCAL_LB;
+               break;
        }
 
+       /* Enable asynchronous ABTS responses from firmware */
+       mb->un.varInitLnk.link_flags |= FLAGS_IMED_ABORT;
+
        /* NEW_FEATURE
         * Setting up the link speed
         */
@@ -246,8 +254,7 @@ lpfc_read_sparam(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
 
        if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == 0) ||
            ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) {
-               if (mp)
-                       kfree(mp);
+               kfree(mp);
                mb->mbxCommand = MBX_READ_SPARM64;
                /* READ_SPARAM: no buffers */
                lpfc_printf_log(phba,
@@ -288,49 +295,36 @@ lpfc_unreg_did(struct lpfc_hba * phba, uint32_t did, LPFC_MBOXQ_t * pmb)
        return;
 }
 
-/***********************************************/
-
-/*                  command to write slim      */
-/***********************************************/
+/**********************************************/
+/*  lpfc_read_nv  Issue a READ CONFIG         */
+/*                mailbox command             */
+/**********************************************/
 void
-lpfc_set_slim(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint32_t addr,
-             uint32_t value)
+lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
 {
        MAILBOX_t *mb;
 
        mb = &pmb->mb;
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
 
-       /* addr = 0x090597 is AUTO ABTS disable for ELS commands */
-       /* addr = 0x052198 is DELAYED ABTS enable for ELS commands */
-
-       /*
-        * Always turn on DELAYED ABTS for ELS timeouts
-        */
-       if ((addr == 0x052198) && (value == 0))
-               value = 1;
-
-       mb->un.varWords[0] = addr;
-       mb->un.varWords[1] = value;
-
-       mb->mbxCommand = MBX_SET_SLIM;
+       mb->mbxCommand = MBX_READ_CONFIG;
        mb->mbxOwner = OWN_HOST;
        return;
 }
 
-/**********************************************/
-/*  lpfc_read_nv  Issue a READ CONFIG         */
-/*                mailbox command             */
-/**********************************************/
+/*************************************************/
+/*  lpfc_read_lnk_stat  Issue a READ LINK STATUS */
+/*                mailbox command                */
+/*************************************************/
 void
-lpfc_read_config(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
+lpfc_read_lnk_stat(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
 {
        MAILBOX_t *mb;
 
        mb = &pmb->mb;
        memset(pmb, 0, sizeof (LPFC_MBOXQ_t));
 
-       mb->mbxCommand = MBX_READ_CONFIG;
+       mb->mbxCommand = MBX_READ_LNK_STAT;
        mb->mbxOwner = OWN_HOST;
        return;
 }
@@ -361,9 +355,7 @@ lpfc_reg_login(struct lpfc_hba * phba,
        /* Get a buffer to hold NPorts Service Parameters */
        if (((mp = kmalloc(sizeof (struct lpfc_dmabuf), GFP_KERNEL)) == NULL) ||
            ((mp->virt = lpfc_mbuf_alloc(phba, 0, &(mp->phys))) == 0)) {
-               if (mp)
-                       kfree(mp);
-
+               kfree(mp);
                mb->mbxCommand = MBX_REG_LOGIN64;
                /* REG_LOGIN: no buffers */
                lpfc_printf_log(phba,
@@ -422,7 +414,6 @@ lpfc_config_pcb_setup(struct lpfc_hba * phba)
        uint32_t iocbCnt;
        int i;
 
-       psli->MBhostaddr = (uint32_t *)&phba->slim2p->mbx;
        pcbp->maxRing = (psli->num_rings - 1);
 
        iocbCnt = 0;
@@ -528,8 +519,9 @@ lpfc_config_port(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
        dma_addr_t pdma_addr;
        uint32_t bar_low, bar_high;
        size_t offset;
-       HGP hgp;
+       struct lpfc_hgp hgp;
        void __iomem *to_slim;
+       int i;
 
        memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
        mb->mbxCommand = MBX_CONFIG_PORT;
@@ -584,9 +576,13 @@ lpfc_config_port(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
        else
                phba->slim2p->pcb.hgpAddrHigh = 0;
        /* write HGP data to SLIM at the required longword offset */
-       memset(&hgp, 0, sizeof(HGP));
+       memset(&hgp, 0, sizeof(struct lpfc_hgp));
        to_slim = phba->MBslimaddr + (SLIMOFF*sizeof (uint32_t));
-       lpfc_memcpy_to_slim(to_slim, &hgp, sizeof (HGP));
+
+       for (i=0; i < phba->sli.num_rings; i++) {
+               lpfc_memcpy_to_slim(to_slim, &hgp, sizeof(struct lpfc_hgp));
+               to_slim += sizeof (struct lpfc_hgp);
+       }
 
        /* Setup Port Group ring pointer */
        offset = (uint8_t *)&phba->slim2p->mbx.us.s2.port -
@@ -616,6 +612,17 @@ lpfc_config_port(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
                        phba->brd_no);
 }
 
+void
+lpfc_kill_board(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
+{
+       MAILBOX_t *mb = &pmb->mb;
+
+       memset(pmb, 0, sizeof(LPFC_MBOXQ_t));
+       mb->mbxCommand = MBX_KILL_BOARD;
+       mb->mbxOwner = OWN_HOST;
+       return;
+}
+
 void
 lpfc_mbox_put(struct lpfc_hba * phba, LPFC_MBOXQ_t * mbq)
 {