[SCSI] zfcp: zfcp_fsf cleanup.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, July 15, 2008 - 8:04 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c41f8c...
Commit:     c41f8cbddd4e0e72951e0575165dea8ea26f1c4b
Parent:     60221920706a01bef89af2577f9a90a8eeb4e662
Author:     Swen Schillig <swen@vnet.ibm.com>
AuthorDate: Wed Jul 2 10:56:39 2008 +0200
Committer:  James Bottomley <James.Bottomley@HansenPartnership.com>
CommitDate: Sat Jul 12 08:22:35 2008 -0500

    [SCSI] zfcp: zfcp_fsf cleanup.
    
    Code cleanup for the zfcp_fsf.c file.
    
    Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
    Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
    Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 drivers/s390/scsi/zfcp_aux.c  |    4 +-
 drivers/s390/scsi/zfcp_dbf.c  |    2 +-
 drivers/s390/scsi/zfcp_def.h  |   31 +-
 drivers/s390/scsi/zfcp_ext.h  |   12 +-
 drivers/s390/scsi/zfcp_fc.c   |   11 +-
 drivers/s390/scsi/zfcp_fsf.c  | 5913 +++++++++++++++++------------------------
 drivers/s390/scsi/zfcp_fsf.h  |   31 +-
 drivers/s390/scsi/zfcp_qdio.c |    6 +-
 drivers/s390/scsi/zfcp_scsi.c |    5 +-
 9 files changed, 2474 insertions(+), 3541 deletions(-)

diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 5b9ca3c..90abfd0 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -433,7 +433,7 @@ static void zfcp_dummy_release(struct device *dev)
 int zfcp_status_read_refill(struct zfcp_adapter *adapter)
 {
 	while (atomic_read(&adapter->stat_miss) > 0)
-		if (zfcp_fsf_status_read(adapter, ZFCP_WAIT_FOR_SBAL)) {
+		if (zfcp_fsf_status_read(adapter)) {
 			if (atomic_read(&adapter->stat_miss) >= 16) {
 				zfcp_erp_adapter_reopen(adapter, 0, 103, NULL);
 				return 1;
@@ -518,10 +518,10 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
 	spin_lock_init(&adapter->san_dbf_lock);
 	spin_lock_init(&adapter->scsi_dbf_lock);
 	spin_lock_init(&adapter->rec_dbf_lock);
+	spin_lock_init(&adapter->req_q.lock);
 
 	rwlock_init(&adapter->erp_lock);
 	rwlock_init(&adapter->abort_lock);
-	rwlock_init(&adapter->req_q.lock);
 
 	sema_init(&adapter->erp_ready_sem, 0);
 
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 566627f..36169c6 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -961,7 +961,7 @@ void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req)
 
 	zfcp_san_dbf_event_els("iels", 1, fsf_req, buf->d_id,
 			       fc_host_port_id(adapter->scsi_host),
-			       *(u8 *)buf->payload, (void *)buf->payload,
+			       buf->payload.data[0], (void *)buf->payload.data,
 			       length);
 }
 
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 2af043a..206b6e7 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -76,11 +76,6 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size)
 #define ZFCP_DEVICE_MODEL       0x03
 #define ZFCP_DEVICE_MODEL_PRIV	0x04
 
-/* allow as many chained SBALs as are supported by hardware */
-#define ZFCP_MAX_SBALS_PER_REQ		FSF_MAX_SBALS_PER_REQ
-#define ZFCP_MAX_SBALS_PER_CT_REQ	FSF_MAX_SBALS_PER_REQ
-#define ZFCP_MAX_SBALS_PER_ELS_REQ	FSF_MAX_SBALS_PER_ELS_REQ
-
 /* DMQ bug workaround: don't use last SBALE */
 #define ZFCP_MAX_SBALES_PER_SBAL	(QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
 
@@ -89,21 +84,17 @@ zfcp_address_to_sg(void *address, struct scatterlist *list, unsigned int size)
 
 /* max. number of (data buffer) SBALEs in largest SBAL chain */
 #define ZFCP_MAX_SBALES_PER_REQ		\
-	(ZFCP_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
+	(FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
         /* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
 
 #define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
         /* max. number of (data buffer) SBALEs in largest SBAL chain
            multiplied with number of sectors per 4k block */
 
-#define ZFCP_SBAL_TIMEOUT               (5*HZ)
-
 #define ZFCP_TYPE2_RECOVERY_TIME        8	/* seconds */
 
 /********************* FSF SPECIFIC DEFINES *********************************/
 
-#define ZFCP_ULP_INFO_VERSION                   26
-#define ZFCP_QTCB_VERSION	FSF_QTCB_CURRENT_VERSION
 /* ATTENTION: value must not be used by hardware */
 #define FSF_QTCB_UNSOLICITED_STATUS		0x6305
 
@@ -121,8 +112,6 @@ typedef unsigned long long fcp_lun_t;
 /* data length field may be at variable position in FCP-2 FCP_CMND IU */
 typedef unsigned int       fcp_dl_t;
 
-#define ZFCP_FC_SERVICE_CLASS_DEFAULT	FSF_CLASS_3
-
 /* timeout for name-server lookup (in seconds) */
 #define ZFCP_NS_GID_PN_TIMEOUT		10
 
@@ -228,7 +217,6 @@ struct fcp_logo {
  * FC-FS stuff
  */
 #define R_A_TOV				10 /* seconds */
-#define ZFCP_ELS_TIMEOUT		(2 * R_A_TOV)
 
 #define ZFCP_LS_RLS			0x0f
 #define ZFCP_LS_ADISC			0x52
@@ -521,7 +509,7 @@ struct zfcp_qdio_queue {
 						 in queue (free_count>0) */
 	atomic_t           count;	      /* number of free buffers
 						 in queue */
-	rwlock_t	   lock;	      /* lock for operations on queue */
+	spinlock_t	   lock;	      /* lock for operations on queue */
 	int                pci_batch;	      /* SBALs since PCI indication
 						 was last set */
 };
@@ -686,7 +674,7 @@ struct zfcp_fsf_req {
 	u32		       fsf_command;    /* FSF Command copy */
 	struct fsf_qtcb	       *qtcb;	       /* address of associated QTCB */
 	u32		       seq_no;         /* Sequence number of request */
-	unsigned long	       data;           /* private data of request */
+	void			*data;           /* private data of request */
 	struct timer_list     timer;	       /* used for erp or scsi er */
 	struct zfcp_erp_action *erp_action;    /* used if this request is
 						  issued on behalf of erp */
@@ -694,10 +682,9 @@ struct zfcp_fsf_req {
 						  from emergency pool */
 	unsigned long long     issued;         /* request sent time (STCK) */
 	struct zfcp_unit       *unit;
+	void			(*handler)(struct zfcp_fsf_req *);
 };
 
-typedef void zfcp_fsf_req_handler_t(struct zfcp_fsf_req*);
-
 /* driver data */
 struct zfcp_data {
 	struct scsi_host_template scsi_host_template;
@@ -730,7 +717,6 @@ struct zfcp_fsf_req_qtcb {
 /********************** ZFCP SPECIFIC DEFINES ********************************/
 
 #define ZFCP_REQ_AUTO_CLEANUP	0x00000002
-#define ZFCP_WAIT_FOR_SBAL	0x00000004
 #define ZFCP_REQ_NO_QTCB	0x00000008
 
 #define ZFCP_SET                0x00000100
@@ -753,15 +739,6 @@ static inline int zfcp_reqlist_hash(unsigned long req_id)
 	return req_id % REQUEST_LIST_SIZE;
 }
 
-static inline void zfcp_reqlist_add(struct zfcp_adapter *adapter,
-				    struct zfcp_fsf_req *fsf_req)
-{
-	unsigned int idx;
-
-	idx = zfcp_reqlist_hash(fsf_req->req_id);
-	list_add_tail(&fsf_req->list, &adapter->req_list[idx]);
-}
-
 static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter,
 				       struct zfcp_fsf_req *fsf_req)
 {
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index f0d6947..2845693 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -70,21 +70,19 @@ extern struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
 extern void zfcp_fsf_start_timer(struct zfcp_fsf_req *, unsigned long);
 extern void zfcp_erp_start_timer(struct zfcp_fsf_req *);
 extern void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *);
-extern int  zfcp_fsf_status_read(struct zfcp_adapter *, int);
+extern int  zfcp_fsf_status_read(struct zfcp_adapter *);
 extern int zfcp_status_read_refill(struct zfcp_adapter *adapter);
-extern int zfcp_fsf_req_create(struct zfcp_adapter *, u32, int, mempool_t *,
-			       unsigned long *, struct zfcp_fsf_req **)
-	__acquires(adapter->req_q.lock);
 extern int zfcp_fsf_send_ct(struct zfcp_send_ct *, mempool_t *,
 			    struct zfcp_erp_action *);
 extern int zfcp_fsf_send_els(struct zfcp_send_els *);
 extern int  zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *,
 					   struct zfcp_unit *,
 					   struct scsi_cmnd *, int, int);
-extern int  zfcp_fsf_req_complete(struct zfcp_fsf_req *);
+extern void zfcp_fsf_req_complete(struct zfcp_fsf_req *);
 extern void zfcp_fsf_req_free(struct zfcp_fsf_req *);
-extern struct zfcp_fsf_req *zfcp_fsf_send_fcp_command_task_management(
-	struct zfcp_adapter *, struct zfcp_unit *, u8, int);
+extern struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *,
+						     struct zfcp_unit *, u8,
+						     int);
 extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(
 	unsigned long, struct zfcp_adapter *, struct zfcp_unit *, int);
 
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index fbe2c76..e984469 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -83,8 +83,8 @@ static void zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req)
 	u16 no_entries;
 	u32 range_mask;
 
-	fcp_rscn_head = (struct fcp_rscn_head *) status_buffer->payload;
-	fcp_rscn_element = (struct fcp_rscn_element *) status_buffer->payload;
+	fcp_rscn_head = (struct fcp_rscn_head *) status_buffer->payload.data;
+	fcp_rscn_element = (struct fcp_rscn_element *) fcp_rscn_head;
 
 	/* see FC-FS */
 	no_entries = fcp_rscn_head->payload_len /
@@ -135,7 +135,7 @@ static void zfcp_fc_incoming_plogi(struct zfcp_fsf_req *req)
 	struct fsf_status_read_buffer *status_buffer =
 		(struct fsf_status_read_buffer *)req->data;
 	struct fsf_plogi *els_plogi =
-		(struct fsf_plogi *) status_buffer->payload;
+		(struct fsf_plogi *) status_buffer->payload.data;
 
 	zfcp_fc_incoming_wwpn(req, els_plogi->serv_param.wwpn);
 }
@@ -144,7 +144,8 @@ static void zfcp_fc_incoming_logo(struct zfcp_fsf_req *req)
 {
 	struct fsf_status_read_buffer *status_buffer =
 		(struct fsf_status_read_buffer *)req->data;
-	struct fcp_logo *els_logo = (struct fcp_logo *) status_buffer->payload;
+	struct fcp_logo *els_logo =
+		(struct fcp_logo *) status_buffer->payload.data;
 
 	zfcp_fc_incoming_wwpn(req, els_logo->nport_wwpn);
 }
@@ -157,7 +158,7 @@ void zfcp_fc_incoming_els(struct zfcp_fsf_req *fsf_req)
 {
 	struct fsf_status_read_buffer *status_buffer =
 		(struct fsf_status_read_buffer *) fsf_req->data;
-	unsigned int els_type = status_buffer->payload[0];
+	unsigned int els_type = status_buffer->payload.data[0];
 
 	zfcp_san_dbf_event_incoming_els(fsf_req);
 	if (els_type == LS_PLOGI)
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
dissimilarity index 69%
index 22e3aa6..e6d8155 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -1,3480 +1,2433 @@
-/*
- * zfcp device driver
- *
- * Implementation of FSF commands.
- *
- * Copyright IBM Corporation 2002, 2008
- */
-
-#include "zfcp_ext.h"
-
-static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *);
-static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_open_port_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_close_port_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_send_fcp_command_task_management_handler(
-	struct zfcp_fsf_req *);
-static int zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_status_read_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *);
-static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *);
-static void zfcp_fsf_control_file_handler(struct zfcp_fsf_req *);
-static inline int zfcp_fsf_req_sbal_check(
-	unsigned long *, struct zfcp_qdio_queue *, int);
-static inline int zfcp_use_one_sbal(
-	struct scatterlist *, int, struct scatterlist *, int);
-static struct zfcp_fsf_req *zfcp_fsf_req_alloc(mempool_t *, int);
-static int zfcp_fsf_req_send(struct zfcp_fsf_req *);
-static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *);
-static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *);
-static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *);
-static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *, u8,
-	struct fsf_link_down_info *);
-static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *);
-
-/* association between FSF command and FSF QTCB type */
-static u32 fsf_qtcb_type[] = {
-	[FSF_QTCB_FCP_CMND] =             FSF_IO_COMMAND,
-	[FSF_QTCB_ABORT_FCP_CMND] =       FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_OPEN_PORT_WITH_DID] =   FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_OPEN_LUN] =             FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_CLOSE_LUN] =            FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_CLOSE_PORT] =           FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_CLOSE_PHYSICAL_PORT] =  FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_SEND_ELS] =             FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_SEND_GENERIC] =         FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND,
-	[FSF_QTCB_EXCHANGE_PORT_DATA] =   FSF_PORT_COMMAND,
-	[FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND,
-	[FSF_QTCB_UPLOAD_CONTROL_FILE] =  FSF_SUPPORT_COMMAND
-};
-
-static const char zfcp_act_subtable_type[5][8] = {
-	"unknown", "OS", "WWPN", "DID", "LUN"
-};
-
-static void zfcp_act_eval_err(struct zfcp_adapter *adapter, u32 table)
-{
-	u16 subtable = (table & 0xffff0000) >> 16;
-	u16 rule = table & 0xffff;
-
-	if (subtable > 0 &&
-	    subtable < ARRAY_SIZE(zfcp_act_subtable_type)) {
-		dev_warn(&adapter->ccw_device->dev,
-			 "Access denied in subtable %s, rule %d.\n",
-			 zfcp_act_subtable_type[subtable], rule);
-	}
-}
-
-static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req,
-					struct zfcp_port *port)
-{
-	struct fsf_qtcb_header *header = &req->qtcb->header;
-	dev_warn(&req->adapter->ccw_device->dev,
-		 "Access denied, cannot send command to port 0x%016Lx.\n",
-		 port->wwpn);
-	zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
-	zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
-	zfcp_erp_port_access_denied(port, 55, req);
-	req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-}
-
-static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req,
-					struct zfcp_unit *unit)
-{
-	struct fsf_qtcb_header *header = &req->qtcb->header;
-	dev_warn(&req->adapter->ccw_device->dev,
-		 "Access denied for unit 0x%016Lx on port 0x%016Lx.\n",
-		 unit->fcp_lun, unit->port->wwpn);
-	zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
-	zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
-	zfcp_erp_unit_access_denied(unit, 59, req);
-	req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-}
-
-static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
-{
-	dev_err(&req->adapter->ccw_device->dev,
-		"Required FC class not supported by adapter, "
-		"shutting down adapter.\n");
-	zfcp_erp_adapter_shutdown(req->adapter, 0, 123, req);
-	req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-}
-
-/****************************************************************/
-/*************** FSF related Functions  *************************/
-/****************************************************************/
-
-/*
- * function:	zfcp_fsf_req_alloc
- *
- * purpose:     Obtains an fsf_req and potentially a qtcb (for all but
- *              unsolicited requests) via helper functions
- *              Does some initial fsf request set-up.
- *
- * returns:	pointer to allocated fsf_req if successfull
- *              NULL otherwise
- *
- * locks:       none
- *
- */
-static struct zfcp_fsf_req *
-zfcp_fsf_req_alloc(mempool_t *pool, int req_flags)
-{
-	size_t size;
-	void *ptr;
-	struct zfcp_fsf_req *fsf_req = NULL;
-
-	if (req_flags & ZFCP_REQ_NO_QTCB)
-		size = sizeof(struct zfcp_fsf_req);
-	else
-		size = sizeof(struct zfcp_fsf_req_qtcb);
-
-	if (likely(pool))
-		ptr = mempool_alloc(pool, GFP_ATOMIC);
-	else {
-		if (req_flags & ZFCP_REQ_NO_QTCB)
-			ptr = kmalloc(size, GFP_ATOMIC);
-		else
-			ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache,
-					       GFP_ATOMIC);
-	}
-
-	if (unlikely(!ptr))
-		goto out;
-
-	memset(ptr, 0, size);
-
-	if (req_flags & ZFCP_REQ_NO_QTCB) {
-		fsf_req = (struct zfcp_fsf_req *) ptr;
-	} else {
-		fsf_req = &((struct zfcp_fsf_req_qtcb *) ptr)->fsf_req;
-		fsf_req->qtcb =	&((struct zfcp_fsf_req_qtcb *) ptr)->qtcb;
-	}
-
-	fsf_req->pool = pool;
-
- out:
-	return fsf_req;
-}
-
-/*
- * function:	zfcp_fsf_req_free
- *
- * purpose:     Frees the memory of an fsf_req (and potentially a qtcb) or
- *              returns it into the pool via helper functions.
- *
- * returns:     sod all
- *
- * locks:       none
- */
-void
-zfcp_fsf_req_free(struct zfcp_fsf_req *fsf_req)
-{
-	if (likely(fsf_req->pool)) {
-		mempool_free(fsf_req, fsf_req->pool);
-		return;
-	}
-
-	if (fsf_req->qtcb) {
-		kmem_cache_free(zfcp_data.fsf_req_qtcb_cache, fsf_req);
-		return;
-	}
-
-	kfree(fsf_req);
-}
-
-/*
- * Never ever call this without shutting down the adapter first.
- * Otherwise the adapter would continue using and corrupting s390 storage.
- * Included BUG_ON() call to ensure this is done.
- * ERP is supposed to be the only user of this function.
- */
-void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
-{
-	struct zfcp_fsf_req *fsf_req, *tmp;
-	unsigned long flags;
-	LIST_HEAD(remove_queue);
-	unsigned int i;
-
-	BUG_ON(atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status));
-	spin_lock_irqsave(&adapter->req_list_lock, flags);
-	for (i = 0; i < REQUEST_LIST_SIZE; i++)
-		list_splice_init(&adapter->req_list[i], &remove_queue);
-	spin_unlock_irqrestore(&adapter->req_list_lock, flags);
-
-	list_for_each_entry_safe(fsf_req, tmp, &remove_queue, list) {
-		list_del(&fsf_req->list);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
-		zfcp_fsf_req_complete(fsf_req);
-	}
-}
-
-/*
- * function:    zfcp_fsf_req_complete
- *
- * purpose:	Updates active counts and timers for openfcp-reqs
- *              May cleanup request after req_eval returns
- *
- * returns:	0 - success
- *		!0 - failure
- *
- * context:
- */
-int
-zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req)
-{
-	int retval = 0;
-	int cleanup;
-
-	if (unlikely(fsf_req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) {
-		/*
-		 * Note: all cleanup handling is done in the callchain of
-		 * the function call-chain below.
-		 */
-		zfcp_fsf_status_read_handler(fsf_req);
-		goto out;
-	} else {
-		del_timer(&fsf_req->timer);
-		zfcp_fsf_protstatus_eval(fsf_req);
-	}
-
-	/*
-	 * fsf_req may be deleted due to waking up functions, so
-	 * cleanup is saved here and used later
-	 */
-	if (likely(fsf_req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
-		cleanup = 1;
-	else
-		cleanup = 0;
-
-	fsf_req->status |= ZFCP_STATUS_FSFREQ_COMPLETED;
-
-	/* cleanup request if requested by initiator */
-	if (likely(cleanup)) {
-		/*
-		 * lock must not be held here since it will be
-		 * grabed by the called routine, too
-		 */
-		zfcp_fsf_req_free(fsf_req);
-	} else {
-		/* notify initiator waiting for the requests completion */
-		/*
-		 * FIXME: Race! We must not access fsf_req here as it might have been
-		 * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
-		 * flag. It's an improbable case. But, we have the same paranoia for
-		 * the cleanup flag already.
-		 * Might better be handled using complete()?
-		 * (setting the flag and doing wakeup ought to be atomic
-		 *  with regard to checking the flag as long as waitqueue is
-		 *  part of the to be released structure)
-		 */
-		wake_up(&fsf_req->completion_wq);
-	}
-
- out:
-	return retval;
-}
-
-/*
- * function:    zfcp_fsf_protstatus_eval
- *
- * purpose:	evaluates the QTCB of the finished FSF request
- *		and initiates appropriate actions
- *		(usually calling FSF command specific handlers)
- *
- * returns:
- *
- * context:
- *
- * locks:
- */
-static int
-zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
-{
-	int retval = 0;
-	struct zfcp_adapter *adapter = fsf_req->adapter;
-	struct fsf_qtcb *qtcb = fsf_req->qtcb;
-	union fsf_prot_status_qual *prot_status_qual =
-		&qtcb->prefix.prot_status_qual;
-
-	zfcp_hba_dbf_event_fsf_response(fsf_req);
-
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
-			ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */
-		goto skip_protstatus;
-	}
-
-	/* evaluate FSF Protocol Status */
-	switch (qtcb->prefix.prot_status) {
-
-	case FSF_PROT_GOOD:
-	case FSF_PROT_FSF_STATUS_PRESENTED:
-		break;
-
-	case FSF_PROT_QTCB_VERSION_ERROR:
-		dev_err(&adapter->ccw_device->dev,
-			"The QTCB version requested by zfcp (0x%x) is not "
-			"supported by the FCP adapter (lowest supported 0x%x, "
-			"highest supported 0x%x).\n",
-			ZFCP_QTCB_VERSION, prot_status_qual->word[0],
-			prot_status_qual->word[1]);
-		zfcp_erp_adapter_shutdown(adapter, 0, 117, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_PROT_SEQ_NUMB_ERROR:
-		zfcp_erp_adapter_reopen(adapter, 0, 98, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_PROT_UNSUPP_QTCB_TYPE:
-		dev_err(&adapter->ccw_device->dev,
-			"Packet header type used by the device driver is "
-			"incompatible with that used on the adapter.\n");
-		zfcp_erp_adapter_shutdown(adapter, 0, 118, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_PROT_HOST_CONNECTION_INITIALIZING:
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
-				&(adapter->status));
-		break;
-
-	case FSF_PROT_DUPLICATE_REQUEST_ID:
-		dev_err(&adapter->ccw_device->dev,
-			"The request identifier 0x%Lx is ambiguous.\n",
-			(unsigned long long)qtcb->bottom.support.req_handle);
-		zfcp_erp_adapter_shutdown(adapter, 0, 78, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_PROT_LINK_DOWN:
-		zfcp_fsf_link_down_info_eval(fsf_req, 37,
-					     &prot_status_qual->link_down_info);
-		/* FIXME: reopening adapter now? better wait for link up */
-		zfcp_erp_adapter_reopen(adapter, 0, 79, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_PROT_REEST_QUEUE:
-		/* All ports should be marked as ready to run again */
-		zfcp_erp_modify_adapter_status(adapter, 28, NULL,
-					       ZFCP_STATUS_COMMON_RUNNING,
-					       ZFCP_SET);
-		zfcp_erp_adapter_reopen(adapter,
-					ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
-					| ZFCP_STATUS_COMMON_ERP_FAILED,
-					99, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_PROT_ERROR_STATE:
-		zfcp_erp_adapter_reopen(adapter, 0, 100, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	default:
-		dev_err(&adapter->ccw_device->dev,
-			"Transfer protocol status information"
-			"provided by the adapter (0x%x) "
-			"is not compatible with the device driver.\n",
-			qtcb->prefix.prot_status);
-		zfcp_erp_adapter_shutdown(adapter, 0, 119, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-	}
-
- skip_protstatus:
-	/*
-	 * always call specific handlers to give them a chance to do
-	 * something meaningful even in error cases
-	 */
-	zfcp_fsf_fsfstatus_eval(fsf_req);
-	return retval;
-}
-
-/*
- * function:	zfcp_fsf_fsfstatus_eval
- *
- * purpose:	evaluates FSF status of completed FSF request
- *		and acts accordingly
- *
- * returns:
- */
-static int
-zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *fsf_req)
-{
-	int retval = 0;
-
-	if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
-		goto skip_fsfstatus;
-	}
-
-	/* evaluate FSF Status */
-	switch (fsf_req->qtcb->header.fsf_status) {
-	case FSF_UNKNOWN_COMMAND:
-		dev_err(&fsf_req->adapter->ccw_device->dev,
-			"Command issued by the device driver (0x%x) is "
-			"not known by the adapter.\n",
-			fsf_req->qtcb->header.fsf_command);
-		zfcp_erp_adapter_shutdown(fsf_req->adapter, 0, 120, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_ADAPTER_STATUS_AVAILABLE:
-		zfcp_fsf_fsfstatus_qual_eval(fsf_req);
-		break;
-	}
-
- skip_fsfstatus:
-	/*
-	 * always call specific handlers to give them a chance to do
-	 * something meaningful even in error cases
-	 */
-	zfcp_fsf_req_dispatch(fsf_req);
-
-	return retval;
-}
-
-/*
- * function:	zfcp_fsf_fsfstatus_qual_eval
- *
- * purpose:	evaluates FSF status-qualifier of completed FSF request
- *		and acts accordingly
- *
- * returns:
- */
-static int
-zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
-{
-	int retval = 0;
-
-	switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
-	case FSF_SQ_FCP_RSP_AVAILABLE:
-		break;
-	case FSF_SQ_RETRY_IF_POSSIBLE:
-		/* The SCSI-stack may now issue retries or escalate */
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-	case FSF_SQ_COMMAND_ABORTED:
-		/* Carry the aborted state on to upper layer */
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTED;
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-	case FSF_SQ_NO_RECOM:
-		dev_err(&fsf_req->adapter->ccw_device->dev,
-			"No recommendation could be given for a "
-			"problem on the adapter.\n");
-		zfcp_erp_adapter_shutdown(fsf_req->adapter, 0, 121, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-	case FSF_SQ_ULP_PROGRAMMING_ERROR:
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-	case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-	case FSF_SQ_NO_RETRY_POSSIBLE:
-	case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
-		/* dealt with in the respective functions */
-		break;
-	default:
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-	}
-
-	return retval;
-}
-
-/**
- * zfcp_fsf_link_down_info_eval - evaluate link down information block
- */
-static void
-zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *fsf_req, u8 id,
-			     struct fsf_link_down_info *link_down)
-{
-	struct zfcp_adapter *adapter = fsf_req->adapter;
-
-	if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
-	                     &adapter->status))
-		return;
-
-	atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
-
-	if (link_down == NULL)
-		goto out;
-
-	switch (link_down->error_code) {
-	case FSF_PSQ_LINK_NO_LIGHT:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "no light detected.\n");
-		break;
-	case FSF_PSQ_LINK_WRAP_PLUG:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "wrap plug detected.\n");
-		break;
-	case FSF_PSQ_LINK_NO_FCP:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "adjacent node on link does not support FCP.\n");
-		break;
-	case FSF_PSQ_LINK_FIRMWARE_UPDATE:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "firmware update in progress.\n");
-		break;
-	case FSF_PSQ_LINK_INVALID_WWPN:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "duplicate or invalid WWPN detected.\n");
-		break;
-	case FSF_PSQ_LINK_NO_NPIV_SUPPORT:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "no support for NPIV by Fabric.\n");
-		break;
-	case FSF_PSQ_LINK_NO_FCP_RESOURCES:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "out of resource in FCP daughtercard.\n");
-		break;
-	case FSF_PSQ_LINK_NO_FABRIC_RESOURCES:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "out of resource in Fabric.\n");
-		break;
-	case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link is down: "
-			 "unable to login to Fabric.\n");
-		break;
-	case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "WWPN assignment file corrupted on adapter.\n");
-		break;
-	case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "Mode table corrupted on adapter.\n");
-		break;
-	case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "No WWPN for assignment table on adapter.\n");
-		break;
-	default:
-		dev_warn(&fsf_req->adapter->ccw_device->dev,
-			 "The local link to adapter is down.\n");
-	}
-
- out:
-	zfcp_erp_adapter_failed(adapter, id, fsf_req);
-}
-
-/*
- * function:	zfcp_fsf_req_dispatch
- *
- * purpose:	calls the appropriate command specific handler
- *
- * returns:
- */
-static int
-zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req)
-{
-	struct zfcp_erp_action *erp_action = fsf_req->erp_action;
-	int retval = 0;
-
-
-	switch (fsf_req->fsf_command) {
-
-	case FSF_QTCB_FCP_CMND:
-		zfcp_fsf_send_fcp_command_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_ABORT_FCP_CMND:
-		zfcp_fsf_abort_fcp_command_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_SEND_GENERIC:
-		zfcp_fsf_send_ct_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_OPEN_PORT_WITH_DID:
-		zfcp_fsf_open_port_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_OPEN_LUN:
-		zfcp_fsf_open_unit_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_CLOSE_LUN:
-		zfcp_fsf_close_unit_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_CLOSE_PORT:
-		zfcp_fsf_close_port_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_CLOSE_PHYSICAL_PORT:
-		zfcp_fsf_close_physical_port_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_EXCHANGE_CONFIG_DATA:
-		zfcp_fsf_exchange_config_data_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_EXCHANGE_PORT_DATA:
-		zfcp_fsf_exchange_port_data_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_SEND_ELS:
-		zfcp_fsf_send_els_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
-		zfcp_fsf_control_file_handler(fsf_req);
-		break;
-
-	case FSF_QTCB_UPLOAD_CONTROL_FILE:
-		zfcp_fsf_control_file_handler(fsf_req);
-		break;
-	}
-
-	if (!erp_action)
-		return retval;
-
-	zfcp_erp_async_handler(erp_action, 0);
-
-	return retval;
-}
-
-/*
- * function:    zfcp_fsf_status_read
- *
- * purpose:	initiates a Status Read command at the specified adapter
- *
- * returns:
- */
-int
-zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
-{
-	struct zfcp_fsf_req *fsf_req;
-	struct fsf_status_read_buffer *status_buffer;
-	unsigned long lock_flags;
-	volatile struct qdio_buffer_element *sbale;
-	int retval;
-
-	/* setup new FSF request */
-	retval = zfcp_fsf_req_create(adapter, FSF_QTCB_UNSOLICITED_STATUS,
-				     req_flags | ZFCP_REQ_NO_QTCB,
-				     adapter->pool.fsf_req_status_read,
-				     &lock_flags, &fsf_req);
-	if (retval < 0)
-		goto failed_req_create;
-
-	sbale = zfcp_qdio_sbale_req(fsf_req);
-        sbale[0].flags |= SBAL_FLAGS0_TYPE_STATUS;
-        sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
-        fsf_req->sbale_curr = 2;
-
-	retval = -ENOMEM;
-	status_buffer =
-		mempool_alloc(adapter->pool.data_status_read, GFP_ATOMIC);
-	if (!status_buffer)
-		goto failed_buf;
-	memset(status_buffer, 0, sizeof (struct fsf_status_read_buffer));
-	fsf_req->data = (unsigned long) status_buffer;
-
-	/* insert pointer to respective buffer */
-	sbale = zfcp_qdio_sbale_curr(fsf_req);
-	sbale->addr = (void *) status_buffer;
-	sbale->length = sizeof(struct fsf_status_read_buffer);
-
-	retval = zfcp_fsf_req_send(fsf_req);
-	if (retval)
-		goto failed_req_send;
-
-	goto out;
-
- failed_req_send:
-	mempool_free(status_buffer, adapter->pool.data_status_read);
-
- failed_buf:
-	zfcp_fsf_req_free(fsf_req);
- failed_req_create:
-	zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL);
- out:
-	write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-	return retval;
-}
-
-static int
-zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req)
-{
-	struct fsf_status_read_buffer *status_buffer;
-	struct zfcp_adapter *adapter;
-	struct zfcp_port *port;
-	unsigned long flags;
-
-	status_buffer = (struct fsf_status_read_buffer *) fsf_req->data;
-	adapter = fsf_req->adapter;
-
-	read_lock_irqsave(&zfcp_data.config_lock, flags);
-	list_for_each_entry(port, &adapter->port_list_head, list)
-	    if (port->d_id == (status_buffer->d_id & ZFCP_DID_MASK))
-		break;
-	read_unlock_irqrestore(&zfcp_data.config_lock, flags);
-
-	if (!port || (port->d_id != (status_buffer->d_id & ZFCP_DID_MASK)))
-		goto out;
-
-	switch (status_buffer->status_subtype) {
-
-	case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT:
-		zfcp_erp_port_reopen(port, 0, 101, fsf_req);
-		break;
-
-	case FSF_STATUS_READ_SUB_ERROR_PORT:
-		zfcp_erp_port_shutdown(port, 0, 122, fsf_req);
-		break;
-	}
- out:
-	return 0;
-}
-
-static void zfcp_fsf_bit_error_threshold(struct zfcp_fsf_req *req)
-{
-	struct zfcp_adapter *adapter = req->adapter;
-	struct fsf_status_read_buffer *buf =
-		(struct fsf_status_read_buffer *) req->data;
-	struct fsf_bit_error_payload *err =
-		(struct fsf_bit_error_payload *) buf->payload;
-	dev_warn(&adapter->ccw_device->dev,
-		 "Warning: bit error threshold data "
-		 "received for the adapter: "
-		 "link failures = %i, loss of sync errors = %i, "
-		 "loss of signal errors = %i, "
-		 "primitive sequence errors = %i, "
-		 "invalid transmission word errors = %i, "
-		 "CRC errors = %i).\n",
-		 err->link_failure_error_count,
-		 err->loss_of_sync_error_count,
-		 err->loss_of_signal_error_count,
-		 err->primitive_sequence_error_count,
-		 err->invalid_transmission_word_error_count,
-		 err->crc_error_count);
-	dev_warn(&adapter->ccw_device->dev,
-		 "Additional bit error threshold data of the adapter: "
-		 "primitive sequence event time-outs = %i, "
-		 "elastic buffer overrun errors = %i, "
-		 "advertised receive buffer-to-buffer credit = %i, "
-		 "current receice buffer-to-buffer credit = %i, "
-		 "advertised transmit buffer-to-buffer credit = %i, "
-		 "current transmit buffer-to-buffer credit = %i).\n",
-		 err->primitive_sequence_event_timeout_count,
-		 err->elastic_buffer_overrun_error_count,
-		 err->advertised_receive_b2b_credit,
-		 err->current_receive_b2b_credit,
-		 err->advertised_transmit_b2b_credit,
-		 err->current_transmit_b2b_credit);
-}
-
-/*
- * function:    zfcp_fsf_status_read_handler
- *
- * purpose:	is called for finished Open Port command
- *
- * returns:
- */
-static int
-zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
-{
-	int retval = 0;
-	struct zfcp_adapter *adapter = fsf_req->adapter;
-	struct fsf_status_read_buffer *status_buffer =
-		(struct fsf_status_read_buffer *) fsf_req->data;
-
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
-		zfcp_hba_dbf_event_fsf_unsol("dism", adapter, status_buffer);
-		mempool_free(status_buffer, adapter->pool.data_status_read);
-		zfcp_fsf_req_free(fsf_req);
-		goto out;
-	}
-
-	zfcp_hba_dbf_event_fsf_unsol("read", adapter, status_buffer);
-
-	switch (status_buffer->status_type) {
-
-	case FSF_STATUS_READ_PORT_CLOSED:
-		zfcp_fsf_status_read_port_closed(fsf_req);
-		break;
-
-	case FSF_STATUS_READ_INCOMING_ELS:
-		zfcp_fc_incoming_els(fsf_req);
-		break;
-
-	case FSF_STATUS_READ_SENSE_DATA_AVAIL:
-		break;
-
-	case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
-		zfcp_fsf_bit_error_threshold(fsf_req);
-		break;
-
-	case FSF_STATUS_READ_LINK_DOWN:
-		switch (status_buffer->status_subtype) {
-		case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
-			dev_warn(&adapter->ccw_device->dev,
-				 "Physical link is down.\n");
-			zfcp_fsf_link_down_info_eval(fsf_req, 38,
-				(struct fsf_link_down_info *)
-				&status_buffer->payload);
-			break;
-		case FSF_STATUS_READ_SUB_FDISC_FAILED:
-			dev_warn(&adapter->ccw_device->dev,
-				 "Local link is down "
-				 "due to failed FDISC login.\n");
-			zfcp_fsf_link_down_info_eval(fsf_req, 39,
-				(struct fsf_link_down_info *)
-				&status_buffer->payload);
-			break;
-		case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
-			dev_warn(&adapter->ccw_device->dev,
-				 "Local link is down "
-				 "due to firmware update on adapter.\n");
-			zfcp_fsf_link_down_info_eval(fsf_req, 40, NULL);
-			break;
-		default:
-			dev_warn(&adapter->ccw_device->dev,
-				 "Local link is down.\n");
-			zfcp_fsf_link_down_info_eval(fsf_req, 41, NULL);
-		};
-		break;
-
-	case FSF_STATUS_READ_LINK_UP:
-		dev_info(&adapter->ccw_device->dev,
-			 "Local link was replugged.\n");
-		/* All ports should be marked as ready to run again */
-		zfcp_erp_modify_adapter_status(adapter, 30, NULL,
-					       ZFCP_STATUS_COMMON_RUNNING,
-					       ZFCP_SET);
-		zfcp_erp_adapter_reopen(adapter,
-					ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
-					| ZFCP_STATUS_COMMON_ERP_FAILED,
-					102, fsf_req);
-		break;
-
-	case FSF_STATUS_READ_NOTIFICATION_LOST:
-		if (status_buffer->status_subtype &
-		    FSF_STATUS_READ_SUB_ACT_UPDATED)
-			zfcp_erp_adapter_access_changed(adapter, 135, fsf_req);
-		if (status_buffer->status_subtype &
-		    FSF_STATUS_READ_SUB_INCOMING_ELS)
-			schedule_work(&adapter->scan_work);
-		break;
-
-	case FSF_STATUS_READ_CFDC_UPDATED:
-		zfcp_erp_adapter_access_changed(adapter, 136, fsf_req);
-		break;
-
-	case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
-		adapter->adapter_features = *(u32*) status_buffer->payload;
-		break;
-	}
-	mempool_free(status_buffer, adapter->pool.data_status_read);
-	zfcp_fsf_req_free(fsf_req);
-	/*
-	 * recycle buffer and start new request repeat until outbound
-	 * queue is empty or adapter shutdown is requested
-	 */
-	/*
-	 * FIXME(qdio):
-	 * we may wait in the req_create for 5s during shutdown, so
-	 * qdio_cleanup will have to wait at least that long before returning
-	 * with failure to allow us a proper cleanup under all circumstances
-	 */
-	/*
-	 * FIXME:
-	 * allocation failure possible? (Is this code needed?)
-	 */
-
-	atomic_inc(&adapter->stat_miss);
-	schedule_work(&adapter->stat_work);
- out:
-	return retval;
-}
-
-/*
- * function:    zfcp_fsf_abort_fcp_command
- *
- * purpose:	tells FSF to abort a running SCSI command
- *
- * returns:	address of initiated FSF request
- *		NULL - request could not be initiated
- *
- * FIXME(design): should be watched by a timeout !!!
- * FIXME(design) shouldn't this be modified to return an int
- *               also...don't know how though
- */
-struct zfcp_fsf_req *
-zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
-			   struct zfcp_adapter *adapter,
-			   struct zfcp_unit *unit, int req_flags)
-{
-	volatile struct qdio_buffer_element *sbale;
-	struct zfcp_fsf_req *fsf_req = NULL;
-	unsigned long lock_flags;
-	int retval = 0;
-
-	/* setup new FSF request */
-	retval = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND,
-				     req_flags, adapter->pool.fsf_req_abort,
-				     &lock_flags, &fsf_req);
-	if (retval < 0)
-		goto out;
-
-	if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
-			&unit->status)))
-		goto unit_blocked;
-
-	sbale = zfcp_qdio_sbale_req(fsf_req);
-        sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
-        sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
-
-	fsf_req->data = (unsigned long) unit;
-
-	/* set handles of unit and its parent port in QTCB */
-	fsf_req->qtcb->header.lun_handle = unit->handle;
-	fsf_req->qtcb->header.port_handle = unit->port->handle;
-
-	/* set handle of request which should be aborted */
-	fsf_req->qtcb->bottom.support.req_handle = (u64) old_req_id;
-
-	zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
-	retval = zfcp_fsf_req_send(fsf_req);
-	if (!retval)
-		goto out;
-
- unit_blocked:
-		zfcp_fsf_req_free(fsf_req);
-		fsf_req = NULL;
-
- out:
-	write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-	return fsf_req;
-}
-
-/*
- * function:    zfcp_fsf_abort_fcp_command_handler
- *
- * purpose:	is called for finished Abort FCP Command request
- *
- * returns:
- */
-static int
-zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
-{
-	int retval = -EINVAL;
-	struct zfcp_unit *unit;
-	union fsf_status_qual *fsf_stat_qual =
-		&new_fsf_req->qtcb->header.fsf_status_qual;
-
-	if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
-		/* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
-		goto skip_fsfstatus;
-	}
-
-	unit = (struct zfcp_unit *) new_fsf_req->data;
-
-	/* evaluate FSF status in QTCB */
-	switch (new_fsf_req->qtcb->header.fsf_status) {
-
-	case FSF_PORT_HANDLE_NOT_VALID:
-		if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
-			/*
-			 * In this case a command that was sent prior to a port
-			 * reopen was aborted (handles are different). This is
-			 * fine.
-			 */
-		} else {
-			/* Let's hope this sorts out the mess */
-			zfcp_erp_adapter_reopen(unit->port->adapter, 0, 104,
-						new_fsf_req);
-			new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		}
-		break;
-
-	case FSF_LUN_HANDLE_NOT_VALID:
-		if (fsf_stat_qual->word[0] != fsf_stat_qual->word[1]) {
-			/*
-			 * In this case a command that was sent prior to a unit
-			 * reopen was aborted (handles are different).
-			 * This is fine.
-			 */
-		} else {
-			/* Let's hope this sorts out the mess */
-			zfcp_erp_port_reopen(unit->port, 0, 105, new_fsf_req);
-			new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		}
-		break;
-
-	case FSF_FCP_COMMAND_DOES_NOT_EXIST:
-		retval = 0;
-		new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
-		break;
-
-	case FSF_PORT_BOXED:
-		zfcp_erp_port_boxed(unit->port, 47, new_fsf_req);
-		new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
-		    | ZFCP_STATUS_FSFREQ_RETRY;
-		break;
-
-	case FSF_LUN_BOXED:
-		zfcp_erp_unit_boxed(unit, 48, new_fsf_req);
-                new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
-                        | ZFCP_STATUS_FSFREQ_RETRY;
-                break;
-
-	case FSF_ADAPTER_STATUS_AVAILABLE:
-		switch (new_fsf_req->qtcb->header.fsf_status_qual.word[0]) {
-		case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-			zfcp_test_link(unit->port);
-			new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-			break;
-		case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
-			/* SCSI stack will escalate */
-			new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-			break;
-		}
-		break;
-
-	case FSF_GOOD:
-		retval = 0;
-		new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
-		break;
-	}
- skip_fsfstatus:
-	return retval;
-}
-
-/**
- * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
- *	one SBALE
- * Two scatter-gather lists are passed, one for the reqeust and one for the
- * response.
- */
-static inline int
-zfcp_use_one_sbal(struct scatterlist *req, int req_count,
-                  struct scatterlist *resp, int resp_count)
-{
-        return ((req_count == 1) &&
-		(resp_count == 1) &&
-                (((unsigned long) zfcp_sg_to_address(&req[0]) &
-		  PAGE_MASK) ==
-		 ((unsigned long) (zfcp_sg_to_address(&req[0]) +
-				   req[0].length - 1) & PAGE_MASK)) &&
-                (((unsigned long) zfcp_sg_to_address(&resp[0]) &
-		  PAGE_MASK) ==
-                 ((unsigned long) (zfcp_sg_to_address(&resp[0]) +
-				   resp[0].length - 1) & PAGE_MASK)));
-}
-
-/**
- * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
- * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
- *	the request
- * @pool: pointer to memory pool, if non-null this pool is used to allocate
- *	a struct zfcp_fsf_req
- * @erp_action: pointer to erp_action, if non-null the Generic Service request
- *	is sent within error recovery
- */
-int
-zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
-		 struct zfcp_erp_action *erp_action)
-{
-	volatile struct qdio_buffer_element *sbale;
-	struct zfcp_port *port;
-	struct zfcp_adapter *adapter;
-        struct zfcp_fsf_req *fsf_req;
-        unsigned long lock_flags;
-        int bytes;
-	int ret = 0;
-
-	port = ct->port;
-	adapter = port->adapter;
-
-	ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_GENERIC,
-				  ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
-				  pool, &lock_flags, &fsf_req);
-	if (ret < 0)
-		goto failed_req;
-
-	sbale = zfcp_qdio_sbale_req(fsf_req);
-        if (zfcp_use_one_sbal(ct->req, ct->req_count,
-                              ct->resp, ct->resp_count)){
-                /* both request buffer and response buffer
-                   fit into one sbale each */
-                sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
-                sbale[2].addr = zfcp_sg_to_address(&ct->req[0]);
-                sbale[2].length = ct->req[0].length;
-                sbale[3].addr = zfcp_sg_to_address(&ct->resp[0]);
-                sbale[3].length = ct->resp[0].length;
-                sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
-	} else if (adapter->adapter_features &
-                   FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
-                /* try to use chained SBALs */
-                bytes = zfcp_qdio_sbals_from_sg(fsf_req,
-                                                SBAL_FLAGS0_TYPE_WRITE_READ,
-						ct->req,
-                                                ZFCP_MAX_SBALS_PER_CT_REQ);
-                if (bytes <= 0) {
-                        if (bytes == 0)
-                                ret = -ENOMEM;
-                        else
-                                ret = bytes;
-
-                        goto failed_send;
-                }
-                fsf_req->qtcb->bottom.support.req_buf_length = bytes;
-                fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
-                bytes = zfcp_qdio_sbals_from_sg(fsf_req,
-                                                SBAL_FLAGS0_TYPE_WRITE_READ,
-						ct->resp,
-                                                ZFCP_MAX_SBALS_PER_CT_REQ);
-                if (bytes <= 0) {
-                        if (bytes == 0)
-                                ret = -ENOMEM;
-                        else
-                                ret = bytes;
-
-                        goto failed_send;
-                }
-                fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
-        } else {
-                /* reject send generic request */
-                ret = -EOPNOTSUPP;
-                goto failed_send;
-        }
-
-	/* settings in QTCB */
-	fsf_req->qtcb->header.port_handle = port->handle;
-	fsf_req->qtcb->bottom.support.service_class =
-		ZFCP_FC_SERVICE_CLASS_DEFAULT;
-	fsf_req->qtcb->bottom.support.timeout = ct->timeout;
-        fsf_req->data = (unsigned long) ct;
-
-	zfcp_san_dbf_event_ct_request(fsf_req);
-
-	if (erp_action) {
-		erp_action->fsf_req = fsf_req;
-		fsf_req->erp_action = erp_action;
-		zfcp_erp_start_timer(fsf_req);
-	} else
-		zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
-
-	ret = zfcp_fsf_req_send(fsf_req);
-	if (ret)
-		goto failed_send;
-
-	goto out;
-
- failed_send:
-	zfcp_fsf_req_free(fsf_req);
-        if (erp_action != NULL) {
-                erp_action->fsf_req = NULL;
-        }
- failed_req:
- out:
-	write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-	return ret;
-}
-
-/**
- * zfcp_fsf_send_ct_handler - handler for Generic Service requests
- * @fsf_req: pointer to struct zfcp_fsf_req
- *
- * Data specific for the Generic Service request is passed using
- * fsf_req->data. There we find the pointer to struct zfcp_send_ct.
- * Usually a specific handler for the CT request is called which is
- * found in this structure.
- */
-static int
-zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
-{
-	struct zfcp_port *port;
-	struct zfcp_adapter *adapter;
-	struct zfcp_send_ct *send_ct;
-	struct fsf_qtcb_header *header;
-	struct fsf_qtcb_bottom_support *bottom;
-	int retval = -EINVAL;
-
-	adapter = fsf_req->adapter;
-	send_ct = (struct zfcp_send_ct *) fsf_req->data;
-	port = send_ct->port;
-	header = &fsf_req->qtcb->header;
-	bottom = &fsf_req->qtcb->bottom.support;
-
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
-		goto skip_fsfstatus;
-
-	/* evaluate FSF status in QTCB */
-	switch (header->fsf_status) {
-
-        case FSF_GOOD:
-		zfcp_san_dbf_event_ct_response(fsf_req);
-                retval = 0;
-		break;
-
-        case FSF_SERVICE_CLASS_NOT_SUPPORTED:
-		zfcp_fsf_class_not_supp(fsf_req);
-		break;
-
-        case FSF_ADAPTER_STATUS_AVAILABLE:
-                switch (header->fsf_status_qual.word[0]){
-                case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-			/* reopening link to port */
-			zfcp_test_link(port);
-			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-			break;
-                case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
-			/* ERP strategy will escalate */
-			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-			break;
-                }
-                break;
-
-	case FSF_ACCESS_DENIED:
-		zfcp_fsf_access_denied_port(fsf_req, port);
-		break;
-
-        case FSF_GENERIC_COMMAND_REJECTED:
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-        case FSF_PORT_HANDLE_NOT_VALID:
-		zfcp_erp_adapter_reopen(adapter, 0, 106, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-        case FSF_PORT_BOXED:
-		zfcp_erp_port_boxed(port, 49, fsf_req);
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
-		    | ZFCP_STATUS_FSFREQ_RETRY;
-		break;
-
-	/* following states should never occure, all cases avoided
-	   in zfcp_fsf_send_ct - but who knows ... */
-	case FSF_PAYLOAD_SIZE_MISMATCH:
-	case FSF_REQUEST_SIZE_TOO_LARGE:
-	case FSF_RESPONSE_SIZE_TOO_LARGE:
-	case FSF_SBAL_MISMATCH:
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-       default:
-		break;
-	}
-
-skip_fsfstatus:
-	send_ct->status = retval;
-
-	if (send_ct->handler != NULL)
-		send_ct->handler(send_ct->handler_data);
-
-	return retval;
-}
-
-/**
- * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
- * @els: pointer to struct zfcp_send_els which contains all needed data for
- *	the command.
- */
-int
-zfcp_fsf_send_els(struct zfcp_send_els *els)
-{
-	volatile struct qdio_buffer_element *sbale;
-	struct zfcp_fsf_req *fsf_req;
-	u32 d_id;
-	struct zfcp_adapter *adapter;
-	unsigned long lock_flags;
-        int bytes;
-	int ret = 0;
-
-	d_id = els->d_id;
-	adapter = els->adapter;
-
-        ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
-				  ZFCP_REQ_AUTO_CLEANUP,
-				  NULL, &lock_flags, &fsf_req);
-	if (ret < 0)
-                goto failed_req;
-
-	if (unlikely(!atomic_test_mask(ZFCP_STATUS_COMMON_UNBLOCKED,
-			&els->port->status))) {
-		ret = -EBUSY;
-		goto port_blocked;
-	}
-
-	sbale = zfcp_qdio_sbale_req(fsf_req);
-        if (zfcp_use_one_sbal(els->req, els->req_count,
-                              els->resp, els->resp_count)){
-                /* both request buffer and response buffer
-                   fit into one sbale each */
-                sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
-                sbale[2].addr = zfcp_sg_to_address(&els->req[0]);
-                sbale[2].length = els->req[0].length;
-                sbale[3].addr = zfcp_sg_to_address(&els->resp[0]);
-                sbale[3].length = els->resp[0].length;
-                sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
-	} else if (adapter->adapter_features &
-                   FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
-                /* try to use chained SBALs */
-                bytes = zfcp_qdio_sbals_from_sg(fsf_req,
-                                                SBAL_FLAGS0_TYPE_WRITE_READ,
-						els->req,
-                                                ZFCP_MAX_SBALS_PER_ELS_REQ);
-                if (bytes <= 0) {
-                        if (bytes == 0) {
-                                ret = -ENOMEM;
-                        } else {
-                                ret = bytes;
-                        }
-                        goto failed_send;
-                }
-                fsf_req->qtcb->bottom.support.req_buf_length = bytes;
-                fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
-                bytes = zfcp_qdio_sbals_from_sg(fsf_req,
-                                                SBAL_FLAGS0_TYPE_WRITE_READ,
-						els->resp,
-                                                ZFCP_MAX_SBALS_PER_ELS_REQ);
-                if (bytes <= 0) {
-                        if (bytes == 0) {
-                                ret = -ENOMEM;
-                        } else {
-                                ret = bytes;
-                        }
-                        goto failed_send;
-                }
-                fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
-        } else {
-                /* reject request */
-                ret = -EOPNOTSUPP;
-                goto failed_send;
-        }
-
-	/* settings in QTCB */
-	fsf_req->qtcb->bottom.support.d_id = d_id;
-	fsf_req->qtcb->bottom.support.service_class =
-		ZFCP_FC_SERVICE_CLASS_DEFAULT;
-	fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT;
-	fsf_req->data = (unsigned long) els;
-
-	sbale = zfcp_qdio_sbale_req(fsf_req);
-
-	zfcp_san_dbf_event_els_request(fsf_req);
-
-	zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
-	ret = zfcp_fsf_req_send(fsf_req);
-	if (ret)
-		goto failed_send;
-
-	goto out;
-
- port_blocked:
- failed_send:
-	zfcp_fsf_req_free(fsf_req);
-
- failed_req:
- out:
-	write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-
-        return ret;
-}
-
-/**
- * zfcp_fsf_send_els_handler - handler for ELS commands
- * @fsf_req: pointer to struct zfcp_fsf_req
- *
- * Data specific for the ELS command is passed using
- * fsf_req->data. There we find the pointer to struct zfcp_send_els.
- * Usually a specific handler for the ELS command is called which is
- * found in this structure.
- */
-static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
-{
-	struct zfcp_adapter *adapter;
-	struct zfcp_port *port;
-	u32 d_id;
-	struct fsf_qtcb_header *header;
-	struct fsf_qtcb_bottom_support *bottom;
-	struct zfcp_send_els *send_els;
-	int retval = -EINVAL;
-
-	send_els = (struct zfcp_send_els *) fsf_req->data;
-	adapter = send_els->adapter;
-	port = send_els->port;
-	d_id = send_els->d_id;
-	header = &fsf_req->qtcb->header;
-	bottom = &fsf_req->qtcb->bottom.support;
-
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
-		goto skip_fsfstatus;
-
-	switch (header->fsf_status) {
-
-	case FSF_GOOD:
-		zfcp_san_dbf_event_els_response(fsf_req);
-		retval = 0;
-		break;
-
-	case FSF_SERVICE_CLASS_NOT_SUPPORTED:
-		zfcp_fsf_class_not_supp(fsf_req);
-		break;
-
-	case FSF_ADAPTER_STATUS_AVAILABLE:
-		switch (header->fsf_status_qual.word[0]){
-		case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
-			if (port && (send_els->ls_code != ZFCP_LS_ADISC))
-				zfcp_test_link(port);
-			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-			break;
-		case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
-			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-			break;
-		case FSF_SQ_RETRY_IF_POSSIBLE:
-			fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-			break;
-		}
-		break;
-
-	case FSF_ELS_COMMAND_REJECTED:
-	case FSF_PAYLOAD_SIZE_MISMATCH:
-	case FSF_REQUEST_SIZE_TOO_LARGE:
-	case FSF_RESPONSE_SIZE_TOO_LARGE:
-		break;
-
-	case FSF_SBAL_MISMATCH:
-		/* should never occure, avoided in zfcp_fsf_send_els */
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-
-	case FSF_ACCESS_DENIED:
-		zfcp_fsf_access_denied_port(fsf_req, port);
-		break;
-
-	default:
-		fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
-		break;
-	}
-
-skip_fsfstatus:
-	send_els->status = retval;
-
-	if (send_els->handler)
-		send_els->handler(send_els->handler_data);
-
-	return retval;
-}
-
-int
-zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
-{
-	volatile struct qdio_buffer_element *sbale;
-	struct zfcp_fsf_req *fsf_req;
-	struct zfcp_adapter *adapter = erp_action->adapter;
-	unsigned long lock_flags;
-	int retval;
-
-	/* setup new FSF request */
-	retval = zfcp_fsf_req_create(adapter,
-				     FSF_QTCB_EXCHANGE_CONFIG_DATA,
-				     ZFCP_REQ_AUTO_CLEANUP,
-				     adapter->pool.fsf_req_erp,
-				     &lock_flags, &fsf_req);
-	if (retval) {
-		write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-		return retval;
-	}
-
-	sbale = zfcp_qdio_sbale_req(fsf_req);
-	sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
-	sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
-
-	fsf_req->qtcb->bottom.config.feature_selection =
-			FSF_FEATURE_CFDC |
-			FSF_FEATURE_LUN_SHARING |
-			FSF_FEATURE_NOTIFICATION_LOST |
-			FSF_FEATURE_UPDATE_ALERT;
-	fsf_req->erp_action = erp_action;
-	erp_action->fsf_req = fsf_req;
-
-	zfcp_erp_start_timer(fsf_req);
-	retval = zfcp_fsf_req_send(fsf_req);
-	write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-	if (retval) {
-		zfcp_fsf_req_free(fsf_req);
-		erp_action->fsf_req = NULL;
-	}
-
-	return retval;
-}
-
-int
-zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
-				struct fsf_qtcb_bottom_config *data)
-{
-	volatile struct qdio_buffer_element *sbale;
-	struct zfcp_fsf_req *fsf_req;
-	unsigned long lock_flags;
-	int retval;
-
-	/* setup new FSF request */
-	retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_CONFIG_DATA,
-				     ZFCP_WAIT_FOR_SBAL, NULL, &lock_flags,
-				     &fsf_req);
-	if (retval) {
-		write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-		return retval;
-	}
-
-	sbale = zfcp_qdio_sbale_req(fsf_req);
-	sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
-	sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
-
-	fsf_req->qtcb->bottom.config.feature_selection =
-			FSF_FEATURE_CFDC |
-			FSF_FEATURE_LUN_SHARING |
-			FSF_FEATURE_NOTIFICATION_LOST |
-			FSF_FEATURE_UPDATE_ALERT;
-
-	if (data)
-		fsf_req->data = (unsigned long) data;
-
-	zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
-	retval = zfcp_fsf_req_send(fsf_req);
-	write_unlock_irqrestore(&adapter->req_q.lock, lock_flags);
-	if (!retval)
-		wait_event(fsf_req->completion_wq,
-			   fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
-
-	zfcp_fsf_req_free(fsf_req);
-
-	return retval;
-}
-
-/**
- * zfcp_fsf_exchange_config_evaluate
- * @fsf_req: fsf_req which belongs to xchg config data request
- * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
- *
- * returns: -EIO on error, 0 otherwise
- */
-static int
-zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
-{
-	struct fsf_qtcb_bottom_config *bottom;
-	struct zfcp_adapter *adapter = fsf_req->adapter;
-	struct Scsi_Host *shost = adapter->scsi_host;
-
-	bottom = &fsf_req->qtcb->bottom.config;
-	adapter->fsf_lic_version = bottom->lic_version;
-	adapter->adapter_features = bottom->adapter_features;
-	adapter->connection_features = bottom->connection_features;
-	adapter->peer_wwpn = 0;
-	adapter->peer_wwnn = 0;
-	adapter->peer_d_id = 0;
-
-	if (xchg_ok) {
-
-		if (fsf_req->data)
-			memcpy((struct fsf_qtcb_bottom_config *) fsf_req->data,
-				bottom, sizeof (struct fsf_qtcb_bottom_config));
-
-		fc_host_node_name(shost) = bottom->nport_serv_param.wwnn;
-		fc_host_port_name(shost) = bottom->nport_serv_param.wwpn;
-		fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK;
-		fc_host_speed(shost) = bottom->fc_link_speed;
-		fc_host_supported_classes(shost) =
-				FC_COS_CLASS2 | FC_COS_CLASS3;
-		adapter->hydra_version = bottom->adapter_type;
-		adapter->timer_ticks = bottom->timer_interval;
-		if (fc_host_permanent_port_name(shost) == -1)
-			fc_host_permanent_port_name(shost) =
-				fc_host_port_name(shost);
-		if (bottom->fc_topology == FSF_TOPO_P2P) {
-			adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
-			adapter->peer_wwpn = bottom->plogi_payload.wwpn;
-			adapter->peer_wwnn = bottom->plogi_payload.wwnn;
-			fc_host_port_type(shost) = FC_PORTTYPE_PTP;
-		} else if (bottom->fc_topology == FSF_TOPO_FABRIC)
-			fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
-		else if (bottom->fc_topology == FSF_TOPO_AL)
-			fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
-		else
-			fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
-	} else {
-		fc_host_node_name(shost) = 0;
-		fc_host_port_name(shost) = 0;
-		fc_host_port_id(shost) = 0;
-		fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
-		fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
-		adapter->hydra_version = 0;
-	}
-
-	if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
-		adapter->hardware_version = bottom->hardware_version;
-		memcpy(fc_host_serial_number(shost), bottom->serial_number,
-		       min(FC_SERIAL_NUMBER_SIZE, 17));
-		EBCASC(fc_host_serial_number(shost),
-		       min(FC_SERIAL_NUMBER_SIZE, 17));
-	}
-
-	if (ZFCP_QTCB_VERSION < bottom->low_qtcb_version) {
-		dev_err(&adapter->ccw_device->dev,
-			"The adapter only supports newer control block "
-			"versions, try updated device driver.\n");
-		zfcp_erp_adapter_shutdown(adapter, 0, 125, fsf_req);
-		return -EIO;
-	}
-	if (ZFCP_QTCB_VERSION > bottom->high_qtcb_version) {
-		dev_err(&adapter->ccw_device->dev,
-			"The adapter only supports older control block "
-			"versions, consider a microcode upgrade.\n");
-		zfcp_erp_adapter_shutdown(adapter, 0, 126, fsf_req);
-		return -EIO;
-	}
-	return 0;
-}
-
-/**
- * function:    zfcp_fsf_exchange_config_data_handler
- *
- * purpose:     is called for finished Exchange Configuration Data command
- *
- * returns:
- */
-static int
-zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
-{
-	struct fsf_qtcb_bottom_config *bottom;
-	struct zfcp_adapter *adapter = fsf_req->adapter;
-	struct fsf_qtcb *qtcb = fsf_req->qtcb;
-
-	if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
-		return -EIO;
-
-	switch (qtcb->header.fsf_status) {
-
-	case FSF_GOOD:
-		if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1))
-			return -EIO;
-
-		switch (fc_host_port_type(adapter->scsi_host)) {
-		case FC_PORTTYPE_PTP:
-			if (fsf_req->erp_action)
-				dev_info(&adapter->ccw_device->dev,
-					 "Point-to-Point fibrechannel "
-					 "configuration detected.\n");
-			break;
-		case FC_PORTTYPE_NLPORT:
-			dev_err(&adapter->ccw_device->dev,
-				"Unsupported arbitrated loop fibrechannel "
-				"topology detected, shutting down adapter\n");
-			zfcp_erp_adapter_shutdown(adapter, 0, 127, fsf_req);
-			return -EIO;
-		case FC_PORTTYPE_NPORT:
-			if (fsf_req->erp_action)
-				dev_info(&adapter->ccw_device->dev,
-					 "Switched fabric fibrechannel "
-					 "network detected.\n");
-			break;
-		default:
-			dev_err(&adapter->ccw_device->dev,
-				"The fibrechannel topology reported by the "
-				"adapter is not known by the zfcp driver, "
-				"shutting down adapter.\n");
-			zfcp_erp_adapter_shutdown(adapter, 0, 128, fsf_req);
-			return -EIO;
-		}
-		bottom = &qtcb->bottom.config;
-		if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
-			dev_err(&adapter->ccw_device->dev,
-				"Maximum QTCB size (%d bytes) allowed by "
-				"the adapter is lower than the minimum "
-				"required by the driver (%ld bytes).\n",
-				bottom->max_qtcb_size, sizeof(struct fsf_qtcb));
-			zfcp_erp_adapter_shutdown(adapter, 0, 129, fsf_req);
-			return -EIO;
-		}
-		atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
-				&adapter->status);
-		break;
-	case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
-		if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0))
-			return -EIO;
-
-		atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
-				&adapter->status);
-
-		zfcp_fsf_link_down_info_eval(fsf_req, 42,
-			&qtcb->header.fsf_status_qual.link_down_info);
-		break;
-	default:
-		zfcp_erp_adapter_shutdown(adapter, 0, 130, fsf_req);
-		return -EIO;
-	}
-	return 0;
-}
-
-/**
- * zfcp_fsf_exchange_port_data - request information about local port
- * @erp_action: ERP action for the adapter for which port data is requested
- */
-int
-zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
-{
-	volatile struct qdio_buffer_element *sbale;
-	struct zfcp_fsf_req *fsf_req;
-	struct zfcp_adapter *adapter = erp_action->adapter;
-	unsigned long lock_flags;
-	int retval;
-
-	if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
-		return -EOPNOTSUPP;
-
-	/* setup new FSF request */
-	retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
-				     ZFCP_REQ_AUTO_CLEANUP,
-				     adapter->pool.fsf_
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[SCSI] zfcp: zfcp_fsf cleanup., Linux Kernel Mailing ..., (Tue Jul 15, 8:04 pm)