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 / qla2xxx / qla_rscn.c
index f2050f9..b70bebe 100644 (file)
@@ -1,20 +1,8 @@
 /*
- *                  QLOGIC LINUX SOFTWARE
- *
- * QLogic ISP2x00 device driver for Linux 2.6.x
- * Copyright (C) 2003-2004 QLogic Corporation
- * (www.qlogic.com)
- *
- * 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, 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.
+ * QLogic Fibre Channel HBA Driver
+ * Copyright (c)  2003-2005 QLogic Corporation
  *
+ * See LICENSE.qla2xxx for copyright and licensing details.
  */
 #include "qla_def.h"
 
@@ -47,8 +35,6 @@
 /* Local Prototypes. */
 static inline uint32_t qla2x00_to_handle(uint16_t, uint16_t, uint16_t);
 static inline uint16_t qla2x00_handle_to_idx(uint32_t);
-static inline uint16_t qla2x00_handle_to_iter(uint32_t);
-static inline uint16_t qla2x00_handle_to_type(uint32_t);
 static inline uint32_t qla2x00_iodesc_to_handle(struct io_descriptor *);
 static inline struct io_descriptor *qla2x00_handle_to_iodesc(scsi_qla_host_t *,
     uint32_t);
@@ -84,10 +70,10 @@ static int qla2x00_send_login_iocb(scsi_qla_host_t *, struct io_descriptor *,
 static int qla2x00_send_login_iocb_cb(scsi_qla_host_t *, struct io_descriptor *,
     struct mbx_entry *);
 
-/** 
+/**
  * Mailbox IOCB callback array.
  **/
-int (*iocb_function_cb_list[LAST_IOCB_CB])
+static int (*iocb_function_cb_list[LAST_IOCB_CB])
        (scsi_qla_host_t *, struct io_descriptor *, struct mbx_entry *) = {
 
        qla2x00_send_abort_iocb_cb,
@@ -97,7 +83,7 @@ int (*iocb_function_cb_list[LAST_IOCB_CB])
 };
 
 
-/** 
+/**
  * Generic IO descriptor handle routines.
  **/
 
@@ -129,30 +115,6 @@ qla2x00_handle_to_idx(uint32_t handle)
        return ((uint16_t)(((handle) >> HDL_INDEX_SHIFT) & HDL_INDEX_MASK));
 }
 
-/**
- * qla2x00_handle_to_type() - Retrive the descriptor type for a given handle.
- * @handle: descriptor handle
- *
- * Returns the descriptor type specified by the @handle.
- */
-static inline uint16_t
-qla2x00_handle_to_type(uint32_t handle)
-{
-       return ((uint16_t)(((handle) >> HDL_TYPE_SHIFT) & HDL_TYPE_MASK));
-}
-
-/**
- * qla2x00_handle_to_iter() - Retrive the rolling signature for a given handle.
- * @handle: descriptor handle
- *
- * Returns the signature specified by the @handle.
- */
-static inline uint16_t
-qla2x00_handle_to_iter(uint32_t handle)
-{
-       return ((uint16_t)(((handle) >> HDL_ITER_SHIFT) & HDL_ITER_MASK));
-}
-
 /**
  * qla2x00_iodesc_to_handle() - Convert an IO descriptor to a unique handle.
  * @iodesc: io descriptor
@@ -195,7 +157,7 @@ qla2x00_handle_to_iodesc(scsi_qla_host_t *ha, uint32_t handle)
 }
 
 
-/** 
+/**
  * IO descriptor allocation routines.
  **/
 
@@ -241,6 +203,20 @@ qla2x00_free_iodesc(struct io_descriptor *iodesc)
        iodesc->signature = 0;
 }
 
+/**
+ * qla2x00_remove_iodesc_timer() - Remove an active timer from an IO descriptor.
+ * @iodesc: io descriptor
+ */
+static inline void
+qla2x00_remove_iodesc_timer(struct io_descriptor *iodesc)
+{
+       if (iodesc->timer.function != NULL) {
+               del_timer_sync(&iodesc->timer);
+               iodesc->timer.data = (unsigned long) NULL;
+               iodesc->timer.function = NULL;
+       }
+}
+
 /**
  * qla2x00_init_io_descriptors() - Initialize the pool of IO descriptors.
  * @ha: HA context
@@ -260,7 +236,7 @@ qla2x00_init_io_descriptors(scsi_qla_host_t *ha)
 }
 
 
-/** 
+/**
  * IO descriptor timer routines.
  **/
 
@@ -312,20 +288,6 @@ qla2x00_add_iodesc_timer(struct io_descriptor *iodesc)
 }
 
 /**
- * qla2x00_remove_iodesc_timer() - Remove an active timer from an IO descriptor.
- * @iodesc: io descriptor
- */
-static inline void
-qla2x00_remove_iodesc_timer(struct io_descriptor *iodesc)
-{
-       if (iodesc->timer.function != NULL) {
-               del_timer_sync(&iodesc->timer);
-               iodesc->timer.data = (unsigned long) NULL;
-               iodesc->timer.function = NULL;
-       }
-}
-
-/** 
  * IO descriptor support routines.
  **/
 
@@ -356,10 +318,11 @@ qla2x00_update_login_fcport(scsi_qla_host_t *ha, struct mbx_entry *mbxstat,
        fcport->flags &= ~FCF_FAILOVER_NEEDED;
        fcport->iodesc_idx_sent = IODESC_INVALID_INDEX;
        atomic_set(&fcport->state, FCS_ONLINE);
+       schedule_work(&fcport->rport_add_work);
 }
 
 
-/** 
+/**
  * Mailbox IOCB commands.
  **/
 
@@ -374,10 +337,9 @@ static inline struct mbx_entry *
 qla2x00_get_mbx_iocb_entry(scsi_qla_host_t *ha, uint32_t handle)
 {
        uint16_t cnt;
-       device_reg_t *reg;
+       struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
        struct mbx_entry *mbxentry;
 
-       reg = ha->iobase;
        mbxentry = NULL;
 
        if (ha->req_q_cnt < 3) {
@@ -410,7 +372,7 @@ qla2x00_get_mbx_iocb_entry(scsi_qla_host_t *ha, uint32_t handle)
  * Returns QLA_SUCCESS if the IOCB was issued.
  */
 static int
-qla2x00_send_abort_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc, 
+qla2x00_send_abort_iocb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
     uint32_t handle_to_abort, int ha_locked)
 {
        unsigned long flags = 0;
@@ -747,7 +709,7 @@ qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
        /* Only process the last command. */
        if (remote_fcport->iodesc_idx_sent != iodesc->idx) {
                DEBUG14(printk("scsi(%ld): Login IOCB -- ignoring, sent to "
-                   "[%02x%02x%02x], expected %x, received %x.\n", 
+                   "[%02x%02x%02x], expected %x, received %x.\n",
                    ha->host_no, iodesc->d_id.b.domain, iodesc->d_id.b.area,
                    iodesc->d_id.b.al_pa, remote_fcport->iodesc_idx_sent,
                    iodesc->idx));
@@ -781,9 +743,9 @@ qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
 
                DEBUG14(printk("scsi(%ld): Login IOCB -- status=%x mb1=%x pn="
                    "%02x%02x%02x%02x%02x%02x%02x%02x.\n", ha->host_no, status,
-                   mb[1], mbxstat->port_name[0], mbxstat->port_name[1], 
-                   mbxstat->port_name[2], mbxstat->port_name[3], 
-                   mbxstat->port_name[4], mbxstat->port_name[5], 
+                   mb[1], mbxstat->port_name[0], mbxstat->port_name[1],
+                   mbxstat->port_name[2], mbxstat->port_name[3],
+                   mbxstat->port_name[4], mbxstat->port_name[5],
                    mbxstat->port_name[6], mbxstat->port_name[7]));
 
                memcpy(remote_fcport->node_name, mbxstat->node_name, WWN_SIZE);
@@ -1079,7 +1041,7 @@ qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
 }
 
 
-/** 
+/**
  * IO descriptor processing routines.
  **/
 
@@ -1091,7 +1053,7 @@ qla2x00_send_login_iocb_cb(scsi_qla_host_t *ha, struct io_descriptor *iodesc,
  * Returns a pointer to the allocated RSCN fcport, or NULL, if none available.
  */
 fc_port_t *
-qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, int flags)
+qla2x00_alloc_rscn_fcport(scsi_qla_host_t *ha, gfp_t flags)
 {
        fc_port_t *fcport;
 
@@ -1163,7 +1125,7 @@ qla2x00_handle_port_rscn(scsi_qla_host_t *ha, uint32_t rscn_entry,
                    remote_fcport = rscn_fcport;
        }
 
-       /* 
+       /*
         * If the port is already in our fcport list and online, send an ADISC
         * to see if it's still alive.  Issue login if a new fcport or the known
         * fcport is currently offline.
@@ -1218,7 +1180,7 @@ qla2x00_handle_port_rscn(scsi_qla_host_t *ha, uint32_t rscn_entry,
                        }
                        return (QLA_SUCCESS);
                }
-               
+
                /* Send ADISC if the fcport is online */
                if (atomic_read(&remote_fcport->state) == FCS_ONLINE ||
                    remote_fcport->iodesc_idx_sent == IODESC_ADISC_NEEDED) {
@@ -1256,7 +1218,7 @@ qla2x00_handle_port_rscn(scsi_qla_host_t *ha, uint32_t rscn_entry,
                         * abort.
                         */
                        uint32_t handle_to_abort;
-                       
+
                        iodesc = &ha->io_descriptors[
                                remote_fcport->iodesc_idx_sent];
                        qla2x00_remove_iodesc_timer(iodesc);