[SCSI] update fc_transport for removal of block/unblock functions
[linux-2.6.git] / drivers / scsi / lpfc / lpfc_hbadisc.c
index d546206..6c846ad 100644 (file)
@@ -1,32 +1,30 @@
 /*******************************************************************
  * 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-2005 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_hbadisc.c 1.266 2005/04/13 11:59:06EDT sf_support Exp  $
- */
-
 #include <linux/blkdev.h>
 #include <linux/pci.h>
 #include <linux/kthread.h>
 #include <linux/interrupt.h>
 
+#include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_transport_fc.h>
@@ -61,14 +59,7 @@ static void lpfc_disc_timeout_handler(struct lpfc_hba *);
 static void
 lpfc_process_nodev_timeout(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
 {
-       if (!(ndlp->nlp_type & NLP_FABRIC)) {
-               /* Nodev timeout on NPort <nlp_DID> */
-               lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY,
-                       "%d:0203 Nodev timeout on NPort x%x "
-                       "Data: x%x x%x x%x\n",
-                       phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,
-                       ndlp->nlp_state, ndlp->nlp_rpi);
-       }
+       int warn_on = 0;
 
        spin_lock_irq(phba->host->host_lock);
        if (!(ndlp->nlp_flag & NLP_NODEV_TMO)) {
@@ -79,12 +70,27 @@ lpfc_process_nodev_timeout(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
        ndlp->nlp_flag &= ~NLP_NODEV_TMO;
 
        if (ndlp->nlp_sid != NLP_NO_SID) {
+               warn_on = 1;
                /* flush the target */
                lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
                        ndlp->nlp_sid, 0, 0, LPFC_CTX_TGT);
        }
        spin_unlock_irq(phba->host->host_lock);
 
+       if (warn_on) {
+               lpfc_printf_log(phba, KERN_ERR, LOG_DISCOVERY,
+                               "%d:0203 Nodev timeout on NPort x%x "
+                               "Data: x%x x%x x%x\n",
+                               phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,
+                               ndlp->nlp_state, ndlp->nlp_rpi);
+       } else {
+               lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,
+                               "%d:0204 Nodev timeout on NPort x%x "
+                               "Data: x%x x%x x%x\n",
+                               phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,
+                               ndlp->nlp_state, ndlp->nlp_rpi);
+       }
+
        lpfc_disc_state_machine(phba, ndlp, NULL, NLP_EVT_DEVICE_RM);
        return;
 }
@@ -1011,13 +1017,10 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        struct fc_rport *rport;
        struct lpfc_rport_data *rdata;
        struct fc_rport_identifiers rport_ids;
-       uint64_t wwn;
 
        /* Remote port has reappeared. Re-register w/ FC transport */
-       memcpy(&wwn, &ndlp->nlp_nodename, sizeof(uint64_t));
-       rport_ids.node_name = be64_to_cpu(wwn);
-       memcpy(&wwn, &ndlp->nlp_portname, sizeof(uint64_t));
-       rport_ids.port_name = be64_to_cpu(wwn);
+       rport_ids.node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
+       rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
        rport_ids.port_id = ndlp->nlp_DID;
        rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
        if (ndlp->nlp_type & NLP_FCP_TARGET)
@@ -1025,6 +1028,7 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        if (ndlp->nlp_type & NLP_FCP_INITIATOR)
                rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
 
+       scsi_block_requests(phba->host);
        ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids);
        if (!rport) {
                dev_printk(KERN_WARNING, &phba->pcidev->dev,
@@ -1041,6 +1045,23 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
        }
        rdata = rport->dd_data;
        rdata->pnode = ndlp;
+       scsi_unblock_requests(phba->host);
+
+       return;
+}
+
+static void
+lpfc_unregister_remote_port(struct lpfc_hba * phba,
+                           struct lpfc_nodelist * ndlp)
+{
+       struct fc_rport *rport = ndlp->rport;
+       struct lpfc_rport_data *rdata = rport->dd_data;
+
+       ndlp->rport = NULL;
+       rdata->pnode = NULL;
+       scsi_block_requests(phba->host);
+       fc_remote_port_delete(rport);
+       scsi_unblock_requests(phba->host);
 
        return;
 }
@@ -1130,6 +1151,8 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
        switch(list) {
        case NLP_NO_LIST: /* No list, just remove it */
                lpfc_nlp_remove(phba, nlp);
+               /* as node removed - stop further transport calls */
+               rport_del = none;
                break;
        case NLP_UNUSED_LIST:
                spin_lock_irq(phba->host->host_lock);
@@ -1255,7 +1278,7 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                 * may have removed the remote port.
                 */
                if ((rport_del != none) && nlp->rport)
-                       fc_remote_port_block(nlp->rport);
+                       lpfc_unregister_remote_port(phba, nlp);
 
                if (rport_add != none) {
                        /*
@@ -1265,8 +1288,6 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list)
                         */
                        if (!nlp->rport)
                                lpfc_register_remote_port(phba, nlp);
-                       else
-                               fc_remote_port_unblock(nlp->rport);
 
                        /*
                         * if we added to Mapped list, but the remote port
@@ -1485,7 +1506,6 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
        LPFC_MBOXQ_t       *mb;
        LPFC_MBOXQ_t       *nextmb;
        struct lpfc_dmabuf *mp;
-       struct fc_rport *rport;
 
        /* Cleanup node for NPort <nlp_DID> */
        lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
@@ -1502,10 +1522,7 @@ lpfc_freenode(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp)
         * and flush cache's w/o generating flush errors.
         */
        if ((ndlp->rport) && !(phba->fc_flag & FC_UNLOADING)) {
-               rport = ndlp->rport;
-               ndlp->rport = NULL;
-               fc_remote_port_unblock(rport);
-               fc_remote_port_delete(rport);
+               lpfc_unregister_remote_port(phba, ndlp);
                ndlp->nlp_sid = NLP_NO_SID;
        }