From e60a6d69f1f84c2ef1cc63aefaadfe7ae9f12934 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:49 +0100 Subject: [SCSI] zfcp: Remove function zfcp_reqlist_find_safe Always use the FSF request id as a reference to the FSF request. With this change the function zfcp_reqlist_find_safe is no longer needed and can be removed. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_dbf.c | 2 +- drivers/s390/scsi/zfcp_def.h | 17 +---------------- drivers/s390/scsi/zfcp_erp.c | 17 +++++++++-------- drivers/s390/scsi/zfcp_fsf.c | 34 ++++++++++++++++++---------------- 4 files changed, 29 insertions(+), 41 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index 7369c8911bc..818b6ad935a 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c @@ -668,7 +668,7 @@ void zfcp_dbf_rec_action(char *id2, struct zfcp_erp_action *erp_action) r->u.action.action = (unsigned long)erp_action; r->u.action.status = erp_action->status; r->u.action.step = erp_action->step; - r->u.action.fsf_req = (unsigned long)erp_action->fsf_req; + r->u.action.fsf_req = erp_action->fsf_req_id; debug_event(dbf->rec, 5, r, sizeof(*r)); spin_unlock_irqrestore(&dbf->rec_lock, flags); } diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index e1b5b88e2dd..6ed48654c29 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h @@ -143,8 +143,7 @@ struct zfcp_erp_action { struct zfcp_unit *unit; u32 status; /* recovery status */ u32 step; /* active step of this erp action */ - struct zfcp_fsf_req *fsf_req; /* fsf request currently pending - for this action */ + unsigned long fsf_req_id; struct timer_list timer; }; @@ -379,18 +378,4 @@ zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) return NULL; } -static inline struct zfcp_fsf_req * -zfcp_reqlist_find_safe(struct zfcp_adapter *adapter, struct zfcp_fsf_req *req) -{ - struct zfcp_fsf_req *request; - unsigned int idx; - - for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) { - list_for_each_entry(request, &adapter->req_list[idx], list) - if (request == req) - return request; - } - return NULL; -} - #endif /* ZFCP_DEF_H */ diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index b51a11a82e6..d40d5b0f263 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -478,25 +478,26 @@ static void zfcp_erp_action_to_running(struct zfcp_erp_action *erp_action) static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) { struct zfcp_adapter *adapter = act->adapter; + struct zfcp_fsf_req *req; - if (!act->fsf_req) + if (!act->fsf_req_id) return; spin_lock(&adapter->req_list_lock); - if (zfcp_reqlist_find_safe(adapter, act->fsf_req) && - act->fsf_req->erp_action == act) { + req = zfcp_reqlist_find(adapter, act->fsf_req_id); + if (req && req->erp_action == act) { if (act->status & (ZFCP_STATUS_ERP_DISMISSED | ZFCP_STATUS_ERP_TIMEDOUT)) { - act->fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; + req->status |= ZFCP_STATUS_FSFREQ_DISMISSED; zfcp_dbf_rec_action("erscf_1", act); - act->fsf_req->erp_action = NULL; + req->erp_action = NULL; } if (act->status & ZFCP_STATUS_ERP_TIMEDOUT) zfcp_dbf_rec_action("erscf_2", act); - if (act->fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) - act->fsf_req = NULL; + if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) + act->fsf_req_id = 0; } else - act->fsf_req = NULL; + act->fsf_req_id = 0; spin_unlock(&adapter->req_list_lock); } diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index e8fb4d9baa8..fd2371b6948 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -773,10 +773,11 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) unsigned long flags; int idx; int with_qtcb = (req->qtcb != NULL); + int req_id = req->req_id; /* put allocated FSF request into hash table */ spin_lock_irqsave(&adapter->req_list_lock, flags); - idx = zfcp_reqlist_hash(req->req_id); + idx = zfcp_reqlist_hash(req_id); list_add_tail(&req->list, &adapter->req_list[idx]); spin_unlock_irqrestore(&adapter->req_list_lock, flags); @@ -786,7 +787,8 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) del_timer(&req->timer); spin_lock_irqsave(&adapter->req_list_lock, flags); /* lookup request again, list might have changed */ - if (zfcp_reqlist_find_safe(adapter, req)) + req = zfcp_reqlist_find(adapter, req_id); + if (req) zfcp_reqlist_remove(adapter, req); spin_unlock_irqrestore(&adapter->req_list_lock, flags); zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1", req); @@ -1262,13 +1264,13 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) FSF_FEATURE_UPDATE_ALERT; req->erp_action = erp_action; req->handler = zfcp_fsf_exchange_config_data_handler; - erp_action->fsf_req = req; + erp_action->fsf_req_id = req->req_id; zfcp_fsf_start_erp_timer(req); retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); - erp_action->fsf_req = NULL; + erp_action->fsf_req_id = 0; } out: spin_unlock_bh(&qdio->req_q_lock); @@ -1355,13 +1357,13 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) req->handler = zfcp_fsf_exchange_port_data_handler; req->erp_action = erp_action; - erp_action->fsf_req = req; + erp_action->fsf_req_id = req->req_id; zfcp_fsf_start_erp_timer(req); retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); - erp_action->fsf_req = NULL; + erp_action->fsf_req_id = 0; } out: spin_unlock_bh(&qdio->req_q_lock); @@ -1521,14 +1523,14 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) hton24(req->qtcb->bottom.support.d_id, port->d_id); req->data = port; req->erp_action = erp_action; - erp_action->fsf_req = req; + erp_action->fsf_req_id = req->req_id; get_device(&port->sysfs_device); zfcp_fsf_start_erp_timer(req); retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); - erp_action->fsf_req = NULL; + erp_action->fsf_req_id = 0; put_device(&port->sysfs_device); } out: @@ -1591,13 +1593,13 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) req->data = erp_action->port; req->erp_action = erp_action; req->qtcb->header.port_handle = erp_action->port->handle; - erp_action->fsf_req = req; + erp_action->fsf_req_id = req->req_id; zfcp_fsf_start_erp_timer(req); retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); - erp_action->fsf_req = NULL; + erp_action->fsf_req_id = 0; } out: spin_unlock_bh(&qdio->req_q_lock); @@ -1817,13 +1819,13 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) req->qtcb->header.port_handle = erp_action->port->handle; req->erp_action = erp_action; req->handler = zfcp_fsf_close_physical_port_handler; - erp_action->fsf_req = req; + erp_action->fsf_req_id = req->req_id; zfcp_fsf_start_erp_timer(req); retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); - erp_action->fsf_req = NULL; + erp_action->fsf_req_id = 0; } out: spin_unlock_bh(&qdio->req_q_lock); @@ -1991,7 +1993,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) req->handler = zfcp_fsf_open_unit_handler; req->data = erp_action->unit; req->erp_action = erp_action; - erp_action->fsf_req = req; + erp_action->fsf_req_id = req->req_id; if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE)) req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING; @@ -2000,7 +2002,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); - erp_action->fsf_req = NULL; + erp_action->fsf_req_id = 0; } out: spin_unlock_bh(&qdio->req_q_lock); @@ -2077,13 +2079,13 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) req->handler = zfcp_fsf_close_unit_handler; req->data = erp_action->unit; req->erp_action = erp_action; - erp_action->fsf_req = req; + erp_action->fsf_req_id = req->req_id; zfcp_fsf_start_erp_timer(req); retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); - erp_action->fsf_req = NULL; + erp_action->fsf_req_id = 0; } out: spin_unlock_bh(&qdio->req_q_lock); -- cgit v1.2.3 From b6bd2fb92a7bb9f1f3feecd9945c21e6c227dd51 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:50 +0100 Subject: [SCSI] zfcp: Move FSF request tracking code to new file Move the code for tracking FSF requests to new file to have this code in one place. The functions for adding and removing requests on the I/O path are already inline. The alloc and free functions are only called once, so it does not hurt to inline them and add them to the same file. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_aux.c | 36 +------- drivers/s390/scsi/zfcp_ccw.c | 3 +- drivers/s390/scsi/zfcp_def.h | 34 +------- drivers/s390/scsi/zfcp_erp.c | 7 +- drivers/s390/scsi/zfcp_ext.h | 1 - drivers/s390/scsi/zfcp_fsf.c | 32 ++----- drivers/s390/scsi/zfcp_reqlist.h | 183 +++++++++++++++++++++++++++++++++++++++ drivers/s390/scsi/zfcp_scsi.c | 5 +- 8 files changed, 203 insertions(+), 98 deletions(-) create mode 100644 drivers/s390/scsi/zfcp_reqlist.h (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index 9d0c941b7d3..f42da9d5709 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c @@ -32,6 +32,7 @@ #include #include "zfcp_ext.h" #include "zfcp_fc.h" +#include "zfcp_reqlist.h" #define ZFCP_BUS_ID_SIZE 20 @@ -49,36 +50,6 @@ static struct kmem_cache *zfcp_cache_hw_align(const char *name, return kmem_cache_create(name, size, roundup_pow_of_two(size), 0, NULL); } -static int zfcp_reqlist_alloc(struct zfcp_adapter *adapter) -{ - int idx; - - adapter->req_list = kcalloc(REQUEST_LIST_SIZE, sizeof(struct list_head), - GFP_KERNEL); - if (!adapter->req_list) - return -ENOMEM; - - for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) - INIT_LIST_HEAD(&adapter->req_list[idx]); - return 0; -} - -/** - * zfcp_reqlist_isempty - is the request list empty - * @adapter: pointer to struct zfcp_adapter - * - * Returns: true if list is empty, false otherwise - */ -int zfcp_reqlist_isempty(struct zfcp_adapter *adapter) -{ - unsigned int idx; - - for (idx = 0; idx < REQUEST_LIST_SIZE; idx++) - if (!list_empty(&adapter->req_list[idx])) - return 0; - return 1; -} - static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun) { struct ccw_device *cdev; @@ -539,7 +510,8 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device) if (zfcp_allocate_low_mem_buffers(adapter)) goto failed; - if (zfcp_reqlist_alloc(adapter)) + adapter->req_list = zfcp_reqlist_alloc(); + if (!adapter->req_list) goto failed; if (zfcp_dbf_adapter_register(adapter)) @@ -560,8 +532,6 @@ struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *ccw_device) INIT_LIST_HEAD(&adapter->erp_ready_head); INIT_LIST_HEAD(&adapter->erp_running_head); - spin_lock_init(&adapter->req_list_lock); - rwlock_init(&adapter->erp_lock); rwlock_init(&adapter->abort_lock); diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c index c22cb72a5ae..6f65a217953 100644 --- a/drivers/s390/scsi/zfcp_ccw.c +++ b/drivers/s390/scsi/zfcp_ccw.c @@ -10,6 +10,7 @@ #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt #include "zfcp_ext.h" +#include "zfcp_reqlist.h" #define ZFCP_MODEL_PRIV 0x4 @@ -162,7 +163,7 @@ static int zfcp_ccw_set_online(struct ccw_device *cdev) } /* initialize request counter */ - BUG_ON(!zfcp_reqlist_isempty(adapter)); + BUG_ON(!zfcp_reqlist_isempty(adapter->req_list)); adapter->req_no = 0; zfcp_erp_modify_adapter_status(adapter, "ccsonl1", NULL, diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index 6ed48654c29..ff4e2ca19be 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h @@ -39,9 +39,7 @@ #include #include "zfcp_fsf.h" -/********************* GENERAL DEFINES *********************************/ - -#define REQUEST_LIST_SIZE 128 +struct zfcp_reqlist; /********************* SCSI SPECIFIC DEFINES *********************************/ #define ZFCP_SCSI_ER_TIMEOUT (10*HZ) @@ -206,8 +204,7 @@ struct zfcp_adapter { struct list_head port_list; /* remote port list */ rwlock_t port_list_lock; /* port list lock */ unsigned long req_no; /* unique FSF req number */ - struct list_head *req_list; /* list of pending reqs */ - spinlock_t req_list_lock; /* request list lock */ + struct zfcp_reqlist *req_list; u32 fsf_req_seq_no; /* FSF cmnd seq number */ rwlock_t abort_lock; /* Protects against SCSI stack abort/command @@ -351,31 +348,4 @@ struct zfcp_data { #define ZFCP_SET 0x00000100 #define ZFCP_CLEAR 0x00000200 -/* - * Helper functions for request ID management. - */ -static inline int zfcp_reqlist_hash(unsigned long req_id) -{ - return req_id % REQUEST_LIST_SIZE; -} - -static inline void zfcp_reqlist_remove(struct zfcp_adapter *adapter, - struct zfcp_fsf_req *fsf_req) -{ - list_del(&fsf_req->list); -} - -static inline struct zfcp_fsf_req * -zfcp_reqlist_find(struct zfcp_adapter *adapter, unsigned long req_id) -{ - struct zfcp_fsf_req *request; - unsigned int idx; - - idx = zfcp_reqlist_hash(req_id); - list_for_each_entry(request, &adapter->req_list[idx], list) - if (request->req_id == req_id) - return request; - return NULL; -} - #endif /* ZFCP_DEF_H */ diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index d40d5b0f263..fe8e4c2b956 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -11,6 +11,7 @@ #include #include "zfcp_ext.h" +#include "zfcp_reqlist.h" #define ZFCP_MAX_ERPS 3 @@ -483,8 +484,8 @@ static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) if (!act->fsf_req_id) return; - spin_lock(&adapter->req_list_lock); - req = zfcp_reqlist_find(adapter, act->fsf_req_id); + spin_lock(&adapter->req_list->lock); + req = _zfcp_reqlist_find(adapter->req_list, act->fsf_req_id); if (req && req->erp_action == act) { if (act->status & (ZFCP_STATUS_ERP_DISMISSED | ZFCP_STATUS_ERP_TIMEDOUT)) { @@ -498,7 +499,7 @@ static void zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *act) act->fsf_req_id = 0; } else act->fsf_req_id = 0; - spin_unlock(&adapter->req_list_lock); + spin_unlock(&adapter->req_list->lock); } /** diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index 66bdb34143c..85cb135d5e7 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h @@ -21,7 +21,6 @@ extern struct zfcp_adapter *zfcp_adapter_enqueue(struct ccw_device *); extern struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *, u64, u32, u32); extern struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *, u64); -extern int zfcp_reqlist_isempty(struct zfcp_adapter *); extern void zfcp_sg_free_table(struct scatterlist *, int); extern int zfcp_sg_setup_table(struct scatterlist *, int); extern void zfcp_device_unregister(struct device *, diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index fd2371b6948..36a6f4a7b8d 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -14,6 +14,7 @@ #include "zfcp_ext.h" #include "zfcp_fc.h" #include "zfcp_dbf.h" +#include "zfcp_reqlist.h" static void zfcp_fsf_request_timeout_handler(unsigned long data) { @@ -457,15 +458,10 @@ static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req) void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter) { struct zfcp_fsf_req *req, *tmp; - unsigned long flags; LIST_HEAD(remove_queue); - unsigned int i; BUG_ON(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP); - 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); + zfcp_reqlist_move(adapter->req_list, &remove_queue); list_for_each_entry_safe(req, tmp, &remove_queue, list) { list_del(&req->list); @@ -770,27 +766,17 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) { struct zfcp_adapter *adapter = req->adapter; struct zfcp_qdio *qdio = adapter->qdio; - unsigned long flags; - int idx; - int with_qtcb = (req->qtcb != NULL); + int with_qtcb = (req->qtcb != NULL); int req_id = req->req_id; - /* put allocated FSF request into hash table */ - spin_lock_irqsave(&adapter->req_list_lock, flags); - idx = zfcp_reqlist_hash(req_id); - list_add_tail(&req->list, &adapter->req_list[idx]); - spin_unlock_irqrestore(&adapter->req_list_lock, flags); + zfcp_reqlist_add(adapter->req_list, req); req->queue_req.qdio_outb_usage = atomic_read(&qdio->req_q.count); req->issued = get_clock(); if (zfcp_qdio_send(qdio, &req->queue_req)) { del_timer(&req->timer); - spin_lock_irqsave(&adapter->req_list_lock, flags); /* lookup request again, list might have changed */ - req = zfcp_reqlist_find(adapter, req_id); - if (req) - zfcp_reqlist_remove(adapter, req); - spin_unlock_irqrestore(&adapter->req_list_lock, flags); + zfcp_reqlist_find_rm(adapter->req_list, req_id); zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1", req); return -EIO; } @@ -2518,15 +2504,14 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx) struct qdio_buffer *sbal = qdio->resp_q.sbal[sbal_idx]; struct qdio_buffer_element *sbale; struct zfcp_fsf_req *fsf_req; - unsigned long flags, req_id; + unsigned long req_id; int idx; for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) { sbale = &sbal->element[idx]; req_id = (unsigned long) sbale->addr; - spin_lock_irqsave(&adapter->req_list_lock, flags); - fsf_req = zfcp_reqlist_find(adapter, req_id); + fsf_req = zfcp_reqlist_find_rm(adapter->req_list, req_id); if (!fsf_req) /* @@ -2536,9 +2521,6 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx) panic("error: unknown req_id (%lx) on adapter %s.\n", req_id, dev_name(&adapter->ccw_device->dev)); - list_del(&fsf_req->list); - spin_unlock_irqrestore(&adapter->req_list_lock, flags); - fsf_req->queue_req.sbal_response = sbal_idx; fsf_req->queue_req.qdio_inb_usage = atomic_read(&qdio->resp_q.count); diff --git a/drivers/s390/scsi/zfcp_reqlist.h b/drivers/s390/scsi/zfcp_reqlist.h new file mode 100644 index 00000000000..a72d1b730ab --- /dev/null +++ b/drivers/s390/scsi/zfcp_reqlist.h @@ -0,0 +1,183 @@ +/* + * zfcp device driver + * + * Data structure and helper functions for tracking pending FSF + * requests. + * + * Copyright IBM Corporation 2009 + */ + +#ifndef ZFCP_REQLIST_H +#define ZFCP_REQLIST_H + +/* number of hash buckets */ +#define ZFCP_REQ_LIST_BUCKETS 128 + +/** + * struct zfcp_reqlist - Container for request list (reqlist) + * @lock: Spinlock for protecting the hash list + * @list: Array of hashbuckets, each is a list of requests in this bucket + */ +struct zfcp_reqlist { + spinlock_t lock; + struct list_head buckets[ZFCP_REQ_LIST_BUCKETS]; +}; + +static inline int zfcp_reqlist_hash(unsigned long req_id) +{ + return req_id % ZFCP_REQ_LIST_BUCKETS; +} + +/** + * zfcp_reqlist_alloc - Allocate and initialize reqlist + * + * Returns pointer to allocated reqlist on success, or NULL on + * allocation failure. + */ +static inline struct zfcp_reqlist *zfcp_reqlist_alloc(void) +{ + unsigned int i; + struct zfcp_reqlist *rl; + + rl = kzalloc(sizeof(struct zfcp_reqlist), GFP_KERNEL); + if (!rl) + return NULL; + + spin_lock_init(&rl->lock); + + for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++) + INIT_LIST_HEAD(&rl->buckets[i]); + + return rl; +} + +/** + * zfcp_reqlist_isempty - Check whether the request list empty + * @rl: pointer to reqlist + * + * Returns: 1 if list is empty, 0 if not + */ +static inline int zfcp_reqlist_isempty(struct zfcp_reqlist *rl) +{ + unsigned int i; + + for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++) + if (!list_empty(&rl->buckets[i])) + return 0; + return 1; +} + +/** + * zfcp_reqlist_free - Free allocated memory for reqlist + * @rl: The reqlist where to free memory + */ +static inline void zfcp_reqlist_free(struct zfcp_reqlist *rl) +{ + /* sanity check */ + BUG_ON(!zfcp_reqlist_isempty(rl)); + + kfree(rl); +} + +static inline struct zfcp_fsf_req * +_zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id) +{ + struct zfcp_fsf_req *req; + unsigned int i; + + i = zfcp_reqlist_hash(req_id); + list_for_each_entry(req, &rl->buckets[i], list) + if (req->req_id == req_id) + return req; + return NULL; +} + +/** + * zfcp_reqlist_find - Lookup FSF request by its request id + * @rl: The reqlist where to lookup the FSF request + * @req_id: The request id to look for + * + * Returns a pointer to the FSF request with the specified request id + * or NULL if there is no known FSF request with this id. + */ +static inline struct zfcp_fsf_req * +zfcp_reqlist_find(struct zfcp_reqlist *rl, unsigned long req_id) +{ + unsigned long flags; + struct zfcp_fsf_req *req; + + spin_lock_irqsave(&rl->lock, flags); + req = _zfcp_reqlist_find(rl, req_id); + spin_unlock_irqrestore(&rl->lock, flags); + + return req; +} + +/** + * zfcp_reqlist_find_rm - Lookup request by id and remove it from reqlist + * @rl: reqlist where to search and remove entry + * @req_id: The request id of the request to look for + * + * This functions tries to find the FSF request with the specified + * id and then removes it from the reqlist. The reqlist lock is held + * during both steps of the operation. + * + * Returns: Pointer to the FSF request if the request has been found, + * NULL if it has not been found. + */ +static inline struct zfcp_fsf_req * +zfcp_reqlist_find_rm(struct zfcp_reqlist *rl, unsigned long req_id) +{ + unsigned long flags; + struct zfcp_fsf_req *req; + + spin_lock_irqsave(&rl->lock, flags); + req = _zfcp_reqlist_find(rl, req_id); + if (req) + list_del(&req->list); + spin_unlock_irqrestore(&rl->lock, flags); + + return req; +} + +/** + * zfcp_reqlist_add - Add entry to reqlist + * @rl: reqlist where to add the entry + * @req: The entry to add + * + * The request id always increases. As an optimization new requests + * are added here with list_add_tail at the end of the bucket lists + * while old requests are looked up starting at the beginning of the + * lists. + */ +static inline void zfcp_reqlist_add(struct zfcp_reqlist *rl, + struct zfcp_fsf_req *req) +{ + unsigned int i; + unsigned long flags; + + i = zfcp_reqlist_hash(req->req_id); + + spin_lock_irqsave(&rl->lock, flags); + list_add_tail(&req->list, &rl->buckets[i]); + spin_unlock_irqrestore(&rl->lock, flags); +} + +/** + * zfcp_reqlist_move - Move all entries from reqlist to simple list + * @rl: The zfcp_reqlist where to remove all entries + * @list: The list where to move all entries + */ +static inline void zfcp_reqlist_move(struct zfcp_reqlist *rl, + struct list_head *list) +{ + unsigned int i; + unsigned long flags; + + spin_lock_irqsave(&rl->lock, flags); + for (i = 0; i < ZFCP_REQ_LIST_BUCKETS; i++) + list_splice_init(&rl->buckets[i], list); + spin_unlock_irqrestore(&rl->lock, flags); +} + +#endif /* ZFCP_REQLIST_H */ diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 8e6fc68d6bd..e1e56f52311 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -15,6 +15,7 @@ #include "zfcp_ext.h" #include "zfcp_dbf.h" #include "zfcp_fc.h" +#include "zfcp_reqlist.h" static unsigned int default_depth = 32; module_param_named(queue_depth, default_depth, uint, 0600); @@ -189,9 +190,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt) /* avoid race condition between late normal completion and abort */ write_lock_irqsave(&adapter->abort_lock, flags); - spin_lock(&adapter->req_list_lock); - old_req = zfcp_reqlist_find(adapter, old_reqid); - spin_unlock(&adapter->req_list_lock); + old_req = zfcp_reqlist_find(adapter->req_list, old_reqid); if (!old_req) { write_unlock_irqrestore(&adapter->abort_lock, flags); zfcp_dbf_scsi_abort("lte1", adapter->dbf, scpnt, NULL, -- cgit v1.2.3 From 452b505c5ada345103bdfdb39dc550df3ffe9eea Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:51 +0100 Subject: [SCSI] zfcp: Remove two FIXME comments On a link down, the adapter reopen is not strictly necessary, but it helps flushing pending requests as quickly as possible. Add a comment mentioning this. qdio returning a problem on the response queue is an unlikely event. The recovery mentioned in the comment might resolve it, so implement it. This also has the advantage that it creates an entry in the recovery trace to see if and when this is occurring. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_fsf.c | 2 +- drivers/s390/scsi/zfcp_qdio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 36a6f4a7b8d..e5ff45fbb8a 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -394,7 +394,7 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req) case FSF_PROT_LINK_DOWN: zfcp_fsf_link_down_info_eval(req, "fspse_5", &psq->link_down_info); - /* FIXME: reopening adapter now? better wait for link up */ + /* go through reopen to flush pending requests */ zfcp_erp_adapter_reopen(adapter, 0, "fspse_6", req); break; case FSF_PROT_REEST_QUEUE: diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 6c5228b627f..3d329fa3d09 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c @@ -106,7 +106,7 @@ static void zfcp_qdio_resp_put_back(struct zfcp_qdio *qdio, int processed) if (unlikely(retval)) { atomic_set(&queue->count, count); - /* FIXME: Recover this with an adapter reopen? */ + zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdrpb_1", NULL); } else { queue->first += count; queue->first %= QDIO_MAX_BUFFERS_PER_Q; -- cgit v1.2.3 From 67feeebaa7038129ad58ae0dcece8142186b36a9 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:52 +0100 Subject: [SCSI] zfcp: Remove unused payload field from zfcp_dbf_san_record Remove the unused payload field from the struct zfcp_dbf_san_record, saving some space in the SAN trace. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_dbf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h index 8b7fd9a1033..e4b5317fe90 100644 --- a/drivers/s390/scsi/zfcp_dbf.h +++ b/drivers/s390/scsi/zfcp_dbf.h @@ -192,10 +192,10 @@ struct zfcp_dbf_san_record { struct zfcp_dbf_san_record_ct_response ct_resp; struct zfcp_dbf_san_record_els els; } u; -#define ZFCP_DBF_SAN_MAX_PAYLOAD 1024 - u8 payload[32]; } __attribute__ ((packed)); +#define ZFCP_DBF_SAN_MAX_PAYLOAD 1024 + struct zfcp_dbf_scsi_record { u8 tag[ZFCP_DBF_TAG_SIZE]; u8 tag2[ZFCP_DBF_TAG_SIZE]; -- cgit v1.2.3 From 22ed130719987d1081831dc1481160b216224ffd Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:53 +0100 Subject: [SCSI] zfcp: Fix warnings from smatch The smatch tool from http://repo.or.cz/w/smatch.git warns about this: drivers/s390/scsi/zfcp_scsi.c +64 zfcp_scsi_command_fail(5) warn: variable dereferenced before check 'scpnt->device' drivers/s390/scsi/zfcp_scsi.c +64 zfcp_scsi_command_fail(5) warn: variable dereferenced before check 'scpnt->device->host' drivers/s390/scsi/zfcp_scsi.c +93 zfcp_scsi_queuecommand(23) warn: variable dereferenced before check 'unit' Fix the first two warnings by removing the checks for scpnt->device and -> host: As long as the SCSI command exists, there is also a scsi_device and a Scsi_Host. Fix the last warning by removing the BUG_ON checks in zfcp_scsi_queuecommand, they are leftovers from previous paranoia about wrong pointers between data structures. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_scsi.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index e1e56f52311..1fce8a49fc6 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -60,10 +60,9 @@ static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result) { struct zfcp_adapter *adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; + set_host_byte(scpnt, result); - if ((scpnt->device != NULL) && (scpnt->device->host != NULL)) - zfcp_dbf_scsi_result("fail", 4, adapter->dbf, scpnt, NULL); - /* return directly */ + zfcp_dbf_scsi_result("fail", 4, adapter->dbf, scpnt, NULL); scpnt->scsi_done(scpnt); } @@ -87,14 +86,6 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt, adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; unit = scpnt->device->hostdata; - BUG_ON(!adapter || (adapter != unit->port->adapter)); - BUG_ON(!scpnt->scsi_done); - - if (unlikely(!unit)) { - zfcp_scsi_command_fail(scpnt, DID_NO_CONNECT); - return 0; - } - scsi_result = fc_remote_port_chkready(rport); if (unlikely(scsi_result)) { scpnt->result = scsi_result; -- cgit v1.2.3 From d21e9daa63e009ce5b87bbcaa6d11ce48e07bbbe Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:54 +0100 Subject: [SCSI] zfcp: Dont use 0 to indicate invalid LUN in rec trace 0 is a valid value for a LUN. It is slightly confusing to also see 0 in the trace entries relating to adapter and port. Change this to use 0xFFFFFFFFFFFFFFFF in the LUN field when the trace entry does not relate to a LUN or unit. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_dbf.c | 12 ++++++------ drivers/s390/scsi/zfcp_dbf.h | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index 818b6ad935a..c8d68fec633 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c @@ -576,7 +576,8 @@ void zfcp_dbf_rec_adapter(char *id, void *ref, struct zfcp_dbf *dbf) struct zfcp_adapter *adapter = dbf->adapter; zfcp_dbf_rec_target(id, ref, dbf, &adapter->status, - &adapter->erp_counter, 0, 0, 0); + &adapter->erp_counter, 0, 0, + ZFCP_DBF_INVALID_LUN); } /** @@ -590,8 +591,8 @@ void zfcp_dbf_rec_port(char *id, void *ref, struct zfcp_port *port) struct zfcp_dbf *dbf = port->adapter->dbf; zfcp_dbf_rec_target(id, ref, dbf, &port->status, - &port->erp_counter, port->wwpn, port->d_id, - 0); + &port->erp_counter, port->wwpn, port->d_id, + ZFCP_DBF_INVALID_LUN); } /** @@ -642,10 +643,9 @@ void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action, r->u.trigger.ps = atomic_read(&port->status); r->u.trigger.wwpn = port->wwpn; } - if (unit) { + if (unit) r->u.trigger.us = atomic_read(&unit->status); - r->u.trigger.fcp_lun = unit->fcp_lun; - } + r->u.trigger.fcp_lun = unit ? unit->fcp_lun : ZFCP_DBF_INVALID_LUN; debug_event(dbf->rec, action ? 1 : 4, r, sizeof(*r)); spin_unlock_irqrestore(&dbf->rec_lock, flags); } diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h index e4b5317fe90..ca841ee44c1 100644 --- a/drivers/s390/scsi/zfcp_dbf.h +++ b/drivers/s390/scsi/zfcp_dbf.h @@ -30,6 +30,8 @@ #define ZFCP_DBF_TAG_SIZE 4 #define ZFCP_DBF_ID_SIZE 7 +#define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull + struct zfcp_dbf_dump { u8 tag[ZFCP_DBF_TAG_SIZE]; u32 total_size; /* size of total dump data */ -- cgit v1.2.3 From 5bdecd2248d4af6f3b311b4d8ca7f3f5f83a7191 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:55 +0100 Subject: [SCSI] zfcp: Remove duplicate assignment of req_seq_no zfcp_fsf_req_create assigns the same value twice to req_seq_no. Remove one assignment and move the req_id and seq_no assignments to one place. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_fsf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index e5ff45fbb8a..69393b8c50d 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -741,6 +741,7 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio, return ERR_PTR(-ENOMEM); } + req->seq_no = adapter->fsf_req_seq_no; req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no; req->qtcb->prefix.req_id = req->req_id; req->qtcb->prefix.ulp_info = 26; @@ -748,8 +749,6 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio, req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION; req->qtcb->header.req_handle = req->req_id; req->qtcb->header.fsf_command = req->fsf_command; - req->seq_no = adapter->fsf_req_seq_no; - req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no; sbale[1].addr = (void *) req->qtcb; sbale[1].length = sizeof(struct fsf_qtcb); } -- cgit v1.2.3 From 615f59e0daaf56e43dcaaf3ea228967d9bc21584 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:56 +0100 Subject: [SCSI] zfcp: Rename sysfs_device attribute to dev in zfcp_unit and zfcp_port Kernel code uses dev as short name for the struct device. Rename the sysfs_device in zfcp_unit and zfcp_port to match this convention. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_aux.c | 54 +++++++++++++++++++----------------------- drivers/s390/scsi/zfcp_ccw.c | 8 +++---- drivers/s390/scsi/zfcp_def.h | 6 ++--- drivers/s390/scsi/zfcp_erp.c | 14 +++++------ drivers/s390/scsi/zfcp_fc.c | 23 +++++++++--------- drivers/s390/scsi/zfcp_fsf.c | 14 +++++------ drivers/s390/scsi/zfcp_scsi.c | 18 +++++++------- drivers/s390/scsi/zfcp_sysfs.c | 37 +++++++++++++---------------- 8 files changed, 81 insertions(+), 93 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index f42da9d5709..66d6c01fcf3 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c @@ -3,7 +3,7 @@ * * Module interface and handling of zfcp data structures. * - * Copyright IBM Corporation 2002, 2009 + * Copyright IBM Corporation 2002, 2010 */ /* @@ -81,7 +81,7 @@ static void __init zfcp_init_device_configure(char *busid, u64 wwpn, u64 lun) flush_work(&unit->scsi_work); out_unit: - put_device(&port->sysfs_device); + put_device(&port->dev); out_port: zfcp_ccw_adapter_put(adapter); out_ccw_device: @@ -226,7 +226,7 @@ struct zfcp_unit *zfcp_get_unit_by_lun(struct zfcp_port *port, u64 fcp_lun) read_lock_irqsave(&port->unit_list_lock, flags); list_for_each_entry(unit, &port->unit_list, list) if (unit->fcp_lun == fcp_lun) { - if (!get_device(&unit->sysfs_device)) + if (!get_device(&unit->dev)) unit = NULL; read_unlock_irqrestore(&port->unit_list_lock, flags); return unit; @@ -251,7 +251,7 @@ struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter, read_lock_irqsave(&adapter->port_list_lock, flags); list_for_each_entry(port, &adapter->port_list, list) if (port->wwpn == wwpn) { - if (!get_device(&port->sysfs_device)) + if (!get_device(&port->dev)) port = NULL; read_unlock_irqrestore(&adapter->port_list_lock, flags); return port; @@ -269,10 +269,9 @@ struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter, */ static void zfcp_unit_release(struct device *dev) { - struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, - sysfs_device); + struct zfcp_unit *unit = container_of(dev, struct zfcp_unit, dev); - put_device(&unit->port->sysfs_device); + put_device(&unit->port->dev); kfree(unit); } @@ -289,11 +288,11 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun) struct zfcp_unit *unit; int retval = -ENOMEM; - get_device(&port->sysfs_device); + get_device(&port->dev); unit = zfcp_get_unit_by_lun(port, fcp_lun); if (unit) { - put_device(&unit->sysfs_device); + put_device(&unit->dev); retval = -EEXIST; goto err_out; } @@ -304,10 +303,10 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun) unit->port = port; unit->fcp_lun = fcp_lun; - unit->sysfs_device.parent = &port->sysfs_device; - unit->sysfs_device.release = zfcp_unit_release; + unit->dev.parent = &port->dev; + unit->dev.release = zfcp_unit_release; - if (dev_set_name(&unit->sysfs_device, "0x%016llx", + if (dev_set_name(&unit->dev, "0x%016llx", (unsigned long long) fcp_lun)) { kfree(unit); goto err_out; @@ -324,13 +323,12 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun) unit->latencies.cmd.channel.min = 0xFFFFFFFF; unit->latencies.cmd.fabric.min = 0xFFFFFFFF; - if (device_register(&unit->sysfs_device)) { - put_device(&unit->sysfs_device); + if (device_register(&unit->dev)) { + put_device(&unit->dev); goto err_out; } - if (sysfs_create_group(&unit->sysfs_device.kobj, - &zfcp_sysfs_unit_attrs)) + if (sysfs_create_group(&unit->dev.kobj, &zfcp_sysfs_unit_attrs)) goto err_out_put; write_lock_irq(&port->unit_list_lock); @@ -342,9 +340,9 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun) return unit; err_out_put: - device_unregister(&unit->sysfs_device); + device_unregister(&unit->dev); err_out: - put_device(&port->sysfs_device); + put_device(&port->dev); return ERR_PTR(retval); } @@ -610,8 +608,7 @@ void zfcp_device_unregister(struct device *dev, static void zfcp_port_release(struct device *dev) { - struct zfcp_port *port = container_of(dev, struct zfcp_port, - sysfs_device); + struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); zfcp_ccw_adapter_put(port->adapter); kfree(port); @@ -639,7 +636,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, port = zfcp_get_port_by_wwpn(adapter, wwpn); if (port) { - put_device(&port->sysfs_device); + put_device(&port->dev); retval = -EEXIST; goto err_out; } @@ -659,22 +656,21 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, port->d_id = d_id; port->wwpn = wwpn; port->rport_task = RPORT_NONE; - port->sysfs_device.parent = &adapter->ccw_device->dev; - port->sysfs_device.release = zfcp_port_release; + port->dev.parent = &adapter->ccw_device->dev; + port->dev.release = zfcp_port_release; - if (dev_set_name(&port->sysfs_device, "0x%016llx", - (unsigned long long)wwpn)) { + if (dev_set_name(&port->dev, "0x%016llx", (unsigned long long)wwpn)) { kfree(port); goto err_out; } retval = -EINVAL; - if (device_register(&port->sysfs_device)) { - put_device(&port->sysfs_device); + if (device_register(&port->dev)) { + put_device(&port->dev); goto err_out; } - if (sysfs_create_group(&port->sysfs_device.kobj, + if (sysfs_create_group(&port->dev.kobj, &zfcp_sysfs_port_attrs)) goto err_out_put; @@ -687,7 +683,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn, return port; err_out_put: - device_unregister(&port->sysfs_device); + device_unregister(&port->dev); err_out: zfcp_ccw_adapter_put(adapter); return ERR_PTR(retval); diff --git a/drivers/s390/scsi/zfcp_ccw.c b/drivers/s390/scsi/zfcp_ccw.c index 6f65a217953..ce1cc7a11fb 100644 --- a/drivers/s390/scsi/zfcp_ccw.c +++ b/drivers/s390/scsi/zfcp_ccw.c @@ -3,7 +3,7 @@ * * Registration and callback for the s390 common I/O layer. * - * Copyright IBM Corporation 2002, 2009 + * Copyright IBM Corporation 2002, 2010 */ #define KMSG_COMPONENT "zfcp" @@ -123,12 +123,10 @@ static void zfcp_ccw_remove(struct ccw_device *cdev) zfcp_ccw_adapter_put(adapter); /* put from zfcp_ccw_adapter_by_cdev */ list_for_each_entry_safe(unit, u, &unit_remove_lh, list) - zfcp_device_unregister(&unit->sysfs_device, - &zfcp_sysfs_unit_attrs); + zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs); list_for_each_entry_safe(port, p, &port_remove_lh, list) - zfcp_device_unregister(&port->sysfs_device, - &zfcp_sysfs_port_attrs); + zfcp_device_unregister(&port->dev, &zfcp_sysfs_port_attrs); zfcp_adapter_unregister(adapter); } diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index ff4e2ca19be..f43e6d8c9ce 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h @@ -3,7 +3,7 @@ * * Global definitions for the zfcp device driver. * - * Copyright IBM Corporation 2002, 2009 + * Copyright IBM Corporation 2002, 2010 */ #ifndef ZFCP_DEF_H @@ -237,7 +237,7 @@ struct zfcp_adapter { }; struct zfcp_port { - struct device sysfs_device; /* sysfs device */ + struct device dev; struct fc_rport *rport; /* rport of fc transport class */ struct list_head list; /* list of remote ports */ struct zfcp_adapter *adapter; /* adapter used to access port */ @@ -259,7 +259,7 @@ struct zfcp_port { }; struct zfcp_unit { - struct device sysfs_device; /* sysfs device */ + struct device dev; struct list_head list; /* list of logical units */ struct zfcp_port *port; /* remote port of unit */ atomic_t status; /* status of this logical unit */ diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c index fe8e4c2b956..0be5e7ea282 100644 --- a/drivers/s390/scsi/zfcp_erp.c +++ b/drivers/s390/scsi/zfcp_erp.c @@ -3,7 +3,7 @@ * * Error Recovery Procedures (ERP). * - * Copyright IBM Corporation 2002, 2009 + * Copyright IBM Corporation 2002, 2010 */ #define KMSG_COMPONENT "zfcp" @@ -175,7 +175,7 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, switch (need) { case ZFCP_ERP_ACTION_REOPEN_UNIT: - if (!get_device(&unit->sysfs_device)) + if (!get_device(&unit->dev)) return NULL; atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status); erp_action = &unit->erp_action; @@ -185,7 +185,7 @@ static struct zfcp_erp_action *zfcp_erp_setup_act(int need, case ZFCP_ERP_ACTION_REOPEN_PORT: case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: - if (!get_device(&port->sysfs_device)) + if (!get_device(&port->dev)) return NULL; zfcp_erp_action_dismiss_port(port); atomic_set_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &port->status); @@ -1181,19 +1181,19 @@ static void zfcp_erp_action_cleanup(struct zfcp_erp_action *act, int result) switch (act->action) { case ZFCP_ERP_ACTION_REOPEN_UNIT: if ((result == ZFCP_ERP_SUCCEEDED) && !unit->device) { - get_device(&unit->sysfs_device); + get_device(&unit->dev); if (scsi_queue_work(unit->port->adapter->scsi_host, &unit->scsi_work) <= 0) - put_device(&unit->sysfs_device); + put_device(&unit->dev); } - put_device(&unit->sysfs_device); + put_device(&unit->dev); break; case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: case ZFCP_ERP_ACTION_REOPEN_PORT: if (result == ZFCP_ERP_SUCCEEDED) zfcp_scsi_schedule_rport_register(port); - put_device(&port->sysfs_device); + put_device(&port->dev); break; case ZFCP_ERP_ACTION_REOPEN_ADAPTER: diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index 0f7b493fb10..f28700a03d7 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c @@ -3,7 +3,7 @@ * * Fibre Channel related functions for the zfcp device driver. * - * Copyright IBM Corporation 2008, 2009 + * Copyright IBM Corporation 2008, 2010 */ #define KMSG_COMPONENT "zfcp" @@ -316,7 +316,7 @@ void zfcp_fc_port_did_lookup(struct work_struct *work) zfcp_erp_port_reopen(port, 0, "fcgpn_3", NULL); out: - put_device(&port->sysfs_device); + put_device(&port->dev); } /** @@ -325,9 +325,9 @@ out: */ void zfcp_fc_trigger_did_lookup(struct zfcp_port *port) { - get_device(&port->sysfs_device); + get_device(&port->dev); if (!queue_work(port->adapter->work_queue, &port->gid_pn_work)) - put_device(&port->sysfs_device); + put_device(&port->dev); } /** @@ -389,7 +389,7 @@ static void zfcp_fc_adisc_handler(void *data) zfcp_scsi_schedule_rport_register(port); out: atomic_clear_mask(ZFCP_STATUS_PORT_LINK_TEST, &port->status); - put_device(&port->sysfs_device); + put_device(&port->dev); kmem_cache_free(zfcp_data.adisc_cache, adisc); } @@ -436,7 +436,7 @@ void zfcp_fc_link_test_work(struct work_struct *work) container_of(work, struct zfcp_port, test_link_work); int retval; - get_device(&port->sysfs_device); + get_device(&port->dev); port->rport_task = RPORT_DEL; zfcp_scsi_rport_work(&port->rport_work); @@ -455,7 +455,7 @@ void zfcp_fc_link_test_work(struct work_struct *work) zfcp_erp_port_forced_reopen(port, 0, "fcltwk1", NULL); out: - put_device(&port->sysfs_device); + put_device(&port->dev); } /** @@ -468,9 +468,9 @@ out: */ void zfcp_fc_test_link(struct zfcp_port *port) { - get_device(&port->sysfs_device); + get_device(&port->dev); if (!queue_work(port->adapter->work_queue, &port->test_link_work)) - put_device(&port->sysfs_device); + put_device(&port->dev); } static void zfcp_free_sg_env(struct zfcp_fc_gpn_ft *gpn_ft, int buf_num) @@ -617,8 +617,7 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, list_for_each_entry_safe(port, tmp, &remove_lh, list) { zfcp_erp_port_shutdown(port, 0, "fcegpf2", NULL); - zfcp_device_unregister(&port->sysfs_device, - &zfcp_sysfs_port_attrs); + zfcp_device_unregister(&port->dev, &zfcp_sysfs_port_attrs); } return ret; @@ -732,7 +731,7 @@ static int zfcp_fc_exec_els_job(struct fc_bsg_job *job, return -EINVAL; d_id = port->d_id; - put_device(&port->sysfs_device); + put_device(&port->dev); } else d_id = ntoh24(job->request->rqst_data.h_els.port_id); diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 69393b8c50d..bd4d71cdcac 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -3,7 +3,7 @@ * * Implementation of FSF commands. * - * Copyright IBM Corporation 2002, 2009 + * Copyright IBM Corporation 2002, 2010 */ #define KMSG_COMPONENT "zfcp" @@ -1471,7 +1471,7 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req) } out: - put_device(&port->sysfs_device); + put_device(&port->dev); } /** @@ -1509,14 +1509,14 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) req->data = port; req->erp_action = erp_action; erp_action->fsf_req_id = req->req_id; - get_device(&port->sysfs_device); + get_device(&port->dev); zfcp_fsf_start_erp_timer(req); retval = zfcp_fsf_req_send(req); if (retval) { zfcp_fsf_req_free(req); erp_action->fsf_req_id = 0; - put_device(&port->sysfs_device); + put_device(&port->dev); } out: spin_unlock_bh(&qdio->req_q_lock); @@ -2261,7 +2261,7 @@ skip_fsfstatus: else { zfcp_fsf_send_fcp_command_task_handler(req); req->unit = NULL; - put_device(&unit->sysfs_device); + put_device(&unit->dev); } } @@ -2299,7 +2299,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - get_device(&unit->sysfs_device); + get_device(&unit->dev); req->unit = unit; req->data = scsi_cmnd; req->handler = zfcp_fsf_send_fcp_command_handler; @@ -2356,7 +2356,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, goto out; failed_scsi_cmnd: - put_device(&unit->sysfs_device); + put_device(&unit->dev); zfcp_fsf_req_free(req); scsi_cmnd->host_scribble = NULL; out: diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 1fce8a49fc6..0d580b2fc4d 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -3,7 +3,7 @@ * * Interface to Linux SCSI midlayer. * - * Copyright IBM Corporation 2002, 2009 + * Copyright IBM Corporation 2002, 2010 */ #define KMSG_COMPONENT "zfcp" @@ -44,7 +44,7 @@ static void zfcp_scsi_slave_destroy(struct scsi_device *sdpnt) { struct zfcp_unit *unit = (struct zfcp_unit *) sdpnt->hostdata; unit->device = NULL; - put_device(&unit->sysfs_device); + put_device(&unit->dev); } static int zfcp_scsi_slave_configure(struct scsi_device *sdp) @@ -511,7 +511,7 @@ static void zfcp_scsi_terminate_rport_io(struct fc_rport *rport) if (port) { zfcp_erp_port_reopen(port, 0, "sctrpi1", NULL); - put_device(&port->sysfs_device); + put_device(&port->dev); } } @@ -553,23 +553,23 @@ static void zfcp_scsi_rport_block(struct zfcp_port *port) void zfcp_scsi_schedule_rport_register(struct zfcp_port *port) { - get_device(&port->sysfs_device); + get_device(&port->dev); port->rport_task = RPORT_ADD; if (!queue_work(port->adapter->work_queue, &port->rport_work)) - put_device(&port->sysfs_device); + put_device(&port->dev); } void zfcp_scsi_schedule_rport_block(struct zfcp_port *port) { - get_device(&port->sysfs_device); + get_device(&port->dev); port->rport_task = RPORT_DEL; if (port->rport && queue_work(port->adapter->work_queue, &port->rport_work)) return; - put_device(&port->sysfs_device); + put_device(&port->dev); } void zfcp_scsi_schedule_rports_block(struct zfcp_adapter *adapter) @@ -598,7 +598,7 @@ void zfcp_scsi_rport_work(struct work_struct *work) } } - put_device(&port->sysfs_device); + put_device(&port->dev); } @@ -616,7 +616,7 @@ void zfcp_scsi_scan(struct work_struct *work) scsilun_to_int((struct scsi_lun *) &unit->fcp_lun), 0); - put_device(&unit->sysfs_device); + put_device(&unit->dev); } struct fc_function_template zfcp_transport_functions = { diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c index f539e006683..a43035d4bd7 100644 --- a/drivers/s390/scsi/zfcp_sysfs.c +++ b/drivers/s390/scsi/zfcp_sysfs.c @@ -3,7 +3,7 @@ * * sysfs attributes. * - * Copyright IBM Corporation 2008, 2009 + * Copyright IBM Corporation 2008, 2010 */ #define KMSG_COMPONENT "zfcp" @@ -19,8 +19,7 @@ static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \ struct device_attribute *at,\ char *buf) \ { \ - struct _feat_def *_feat = container_of(dev, struct _feat_def, \ - sysfs_device); \ + struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \ \ return sprintf(buf, _format, _value); \ } \ @@ -87,8 +86,7 @@ static ssize_t zfcp_sysfs_##_feat##_failed_show(struct device *dev, \ struct device_attribute *attr, \ char *buf) \ { \ - struct _feat_def *_feat = container_of(dev, struct _feat_def, \ - sysfs_device); \ + struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \ \ if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_ERP_FAILED) \ return sprintf(buf, "1\n"); \ @@ -99,12 +97,11 @@ static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \ struct device_attribute *attr,\ const char *buf, size_t count)\ { \ - struct _feat_def *_feat = container_of(dev, struct _feat_def, \ - sysfs_device); \ + struct _feat_def *_feat = container_of(dev, struct _feat_def, dev); \ unsigned long val; \ int retval = 0; \ \ - if (!(_feat && get_device(&_feat->sysfs_device))) \ + if (!(_feat && get_device(&_feat->dev))) \ return -EBUSY; \ \ if (strict_strtoul(buf, 0, &val) || val != 0) { \ @@ -118,7 +115,7 @@ static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \ _reopen_id, NULL); \ zfcp_erp_wait(_adapter); \ out: \ - put_device(&_feat->sysfs_device); \ + put_device(&_feat->dev); \ return retval ? retval : (ssize_t) count; \ } \ static ZFCP_DEV_ATTR(_feat, failed, S_IWUSR | S_IRUGO, \ @@ -224,10 +221,10 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev, list_del(&port->list); write_unlock_irq(&adapter->port_list_lock); - put_device(&port->sysfs_device); + put_device(&port->dev); zfcp_erp_port_shutdown(port, 0, "syprs_1", NULL); - zfcp_device_unregister(&port->sysfs_device, &zfcp_sysfs_port_attrs); + zfcp_device_unregister(&port->dev, &zfcp_sysfs_port_attrs); out: zfcp_ccw_adapter_put(adapter); return retval ? retval : (ssize_t) count; @@ -258,13 +255,12 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct zfcp_port *port = container_of(dev, struct zfcp_port, - sysfs_device); + struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); struct zfcp_unit *unit; u64 fcp_lun; int retval = -EINVAL; - if (!(port && get_device(&port->sysfs_device))) + if (!(port && get_device(&port->dev))) return -EBUSY; if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) @@ -280,7 +276,7 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev, zfcp_erp_wait(unit->port->adapter); flush_work(&unit->scsi_work); out: - put_device(&port->sysfs_device); + put_device(&port->dev); return retval ? retval : (ssize_t) count; } static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store); @@ -289,13 +285,12 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct zfcp_port *port = container_of(dev, struct zfcp_port, - sysfs_device); + struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); struct zfcp_unit *unit; u64 fcp_lun; int retval = -EINVAL; - if (!(port && get_device(&port->sysfs_device))) + if (!(port && get_device(&port->dev))) return -EBUSY; if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) @@ -314,12 +309,12 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, list_del(&unit->list); write_unlock_irq(&port->unit_list_lock); - put_device(&unit->sysfs_device); + put_device(&unit->dev); zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL); - zfcp_device_unregister(&unit->sysfs_device, &zfcp_sysfs_unit_attrs); + zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs); out: - put_device(&port->sysfs_device); + put_device(&port->dev); return retval ? retval : (ssize_t) count; } static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store); -- cgit v1.2.3 From ab72528a4498251a702fa7693b51b9311b2432f8 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:57 +0100 Subject: [SCSI] zfcp: Move scsi result tracing decision to zfcp_dbf.h Move the decision which trace tag and trace level to use for the scsi result trace to zfcp_dbf.h. zfcp_dbf_scsi_result is already an inline function, so move the trace code there, simplifying the response handling in zfcp_fsf.c. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_dbf.h | 28 +++++++++++++++++++++------- drivers/s390/scsi/zfcp_fsf.c | 7 +------ drivers/s390/scsi/zfcp_scsi.c | 4 ++-- 3 files changed, 24 insertions(+), 15 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_dbf.h b/drivers/s390/scsi/zfcp_dbf.h index ca841ee44c1..457e046f2d2 100644 --- a/drivers/s390/scsi/zfcp_dbf.h +++ b/drivers/s390/scsi/zfcp_dbf.h @@ -303,17 +303,31 @@ void zfcp_dbf_scsi(const char *tag, const char *tag2, int level, /** * zfcp_dbf_scsi_result - trace event for SCSI command completion - * @tag: tag indicating success or failure of SCSI command - * @level: trace level applicable for this event - * @adapter: adapter that has been used to issue the SCSI command + * @dbf: adapter dbf trace * @scmd: SCSI command pointer - * @fsf_req: request used to issue SCSI command (might be NULL) + * @req: FSF request used to issue SCSI command */ static inline -void zfcp_dbf_scsi_result(const char *tag, int level, struct zfcp_dbf *dbf, - struct scsi_cmnd *scmd, struct zfcp_fsf_req *fsf_req) +void zfcp_dbf_scsi_result(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd, + struct zfcp_fsf_req *req) { - zfcp_dbf_scsi("rslt", tag, level, dbf, scmd, fsf_req, 0); + if (scmd->result != 0) + zfcp_dbf_scsi("rslt", "erro", 3, dbf, scmd, req, 0); + else if (scmd->retries > 0) + zfcp_dbf_scsi("rslt", "retr", 4, dbf, scmd, req, 0); + else + zfcp_dbf_scsi("rslt", "norm", 6, dbf, scmd, req, 0); +} + +/** + * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command + * @dbf: adapter dbf trace + * @scmd: SCSI command pointer + */ +static inline +void zfcp_dbf_scsi_fail_send(struct zfcp_dbf *dbf, struct scsi_cmnd *scmd) +{ + zfcp_dbf_scsi("rslt", "fail", 4, dbf, scmd, NULL, 0); } /** diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index bd4d71cdcac..1c47c495d69 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -2156,12 +2156,7 @@ static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req) zfcp_fsf_req_trace(req, scpnt); skip_fsfstatus: - if (scpnt->result != 0) - zfcp_dbf_scsi_result("erro", 3, req->adapter->dbf, scpnt, req); - else if (scpnt->retries > 0) - zfcp_dbf_scsi_result("retr", 4, req->adapter->dbf, scpnt, req); - else - zfcp_dbf_scsi_result("norm", 6, req->adapter->dbf, scpnt, req); + zfcp_dbf_scsi_result(req->adapter->dbf, scpnt, req); scpnt->host_scribble = NULL; (scpnt->scsi_done) (scpnt); diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 0d580b2fc4d..c3c4178888a 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -62,7 +62,7 @@ static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result) (struct zfcp_adapter *) scpnt->device->host->hostdata[0]; set_host_byte(scpnt, result); - zfcp_dbf_scsi_result("fail", 4, adapter->dbf, scpnt, NULL); + zfcp_dbf_scsi_fail_send(adapter->dbf, scpnt); scpnt->scsi_done(scpnt); } @@ -89,7 +89,7 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt, scsi_result = fc_remote_port_chkready(rport); if (unlikely(scsi_result)) { scpnt->result = scsi_result; - zfcp_dbf_scsi_result("fail", 4, adapter->dbf, scpnt, NULL); + zfcp_dbf_scsi_fail_send(adapter->dbf, scpnt); scpnt->scsi_done(scpnt); return 0; } -- cgit v1.2.3 From 2d8e62bbf7e83facd5701c100f62fbf0df4ee486 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:58 +0100 Subject: [SCSI] zfcp: Replace FC4 constants with information from exchange port The FC4 types are already available from exchange port. Use this for reporting the FC4 types, instead of having the value hardcoded in zfcp. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_fsf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 1c47c495d69..8a0705ac52a 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -491,8 +491,6 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req) fc_host_port_id(shost) = ntoh24(bottom->s_id); fc_host_speed(shost) = bottom->fc_link_speed; fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3; - fc_host_supported_fc4s(shost)[2] = 1; /* FCP */ - fc_host_active_fc4s(shost)[2] = 1; /* FCP */ adapter->hydra_version = bottom->adapter_type; adapter->timer_ticks = bottom->timer_interval; @@ -615,6 +613,10 @@ static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req) fc_host_permanent_port_name(shost) = fc_host_port_name(shost); fc_host_maxframe_size(shost) = bottom->maximum_frame_size; fc_host_supported_speeds(shost) = bottom->supported_speed; + memcpy(fc_host_supported_fc4s(shost), bottom->supported_fc4_types, + FC_FC4_LIST_SIZE); + memcpy(fc_host_active_fc4s(shost), bottom->active_fc4_types, + FC_FC4_LIST_SIZE); } static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req) -- cgit v1.2.3 From 34c2b712992540ca436e97432ffc57c84c8f8c18 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 17 Feb 2010 11:18:59 +0100 Subject: [SCSI] zfcp: Introduce header file for qdio structs and inline functions Move the qdio related structs and some helper functions to a new zfcp_qdio.h header file. While doing this, rename the struct zfcp_queue_req to zfcp_qdio_req to adhere to the naming scheme used in zfcp. This allows a better seperation of the qdio code and inlining the helper functions will save some function calls. Reviewed-by: Swen Schillig Signed-off-by: Christof Schmitt Signed-off-by: James Bottomley --- drivers/s390/scsi/zfcp_dbf.c | 6 +-- drivers/s390/scsi/zfcp_def.h | 57 ++-------------------- drivers/s390/scsi/zfcp_ext.h | 8 +--- drivers/s390/scsi/zfcp_fsf.c | 71 +++++++++++++-------------- drivers/s390/scsi/zfcp_qdio.c | 48 ++++--------------- drivers/s390/scsi/zfcp_qdio.h | 109 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 162 insertions(+), 137 deletions(-) create mode 100644 drivers/s390/scsi/zfcp_qdio.h (limited to 'drivers/s390/scsi') diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c index c8d68fec633..7a149fd85f6 100644 --- a/drivers/s390/scsi/zfcp_dbf.c +++ b/drivers/s390/scsi/zfcp_dbf.c @@ -140,9 +140,9 @@ void _zfcp_dbf_hba_fsf_response(const char *tag2, int level, memcpy(response->fsf_status_qual, fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE); response->fsf_req_status = fsf_req->status; - response->sbal_first = fsf_req->queue_req.sbal_first; - response->sbal_last = fsf_req->queue_req.sbal_last; - response->sbal_response = fsf_req->queue_req.sbal_response; + response->sbal_first = fsf_req->qdio_req.sbal_first; + response->sbal_last = fsf_req->qdio_req.sbal_last; + response->sbal_response = fsf_req->qdio_req.sbal_response; response->pool = fsf_req->pool != NULL; response->erp_action = (unsigned long)fsf_req->erp_action; diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h index f43e6d8c9ce..7131c7db1f0 100644 --- a/drivers/s390/scsi/zfcp_def.h +++ b/drivers/s390/scsi/zfcp_def.h @@ -33,11 +33,11 @@ #include #include #include -#include #include #include #include #include "zfcp_fsf.h" +#include "zfcp_qdio.h" struct zfcp_reqlist; @@ -127,12 +127,6 @@ struct zfcp_adapter_mempool { mempool_t *qtcb_pool; }; -struct zfcp_qdio_queue { - struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; - u8 first; /* index of next free bfr in queue */ - atomic_t count; /* number of free buffers in queue */ -}; - struct zfcp_erp_action { struct list_head list; int action; /* requested action code */ @@ -164,29 +158,6 @@ struct zfcp_latencies { spinlock_t lock; }; -/** struct zfcp_qdio - basic QDIO data structure - * @resp_q: response queue - * @req_q: request queue - * @stat_lock: lock to protect req_q_util and req_q_time - * @req_q_lock; lock to serialize access to request queue - * @req_q_time: time of last fill level change - * @req_q_util: used for accounting - * @req_q_full: queue full incidents - * @req_q_wq: used to wait for SBAL availability - * @adapter: adapter used in conjunction with this QDIO structure - */ -struct zfcp_qdio { - struct zfcp_qdio_queue resp_q; - struct zfcp_qdio_queue req_q; - spinlock_t stat_lock; - spinlock_t req_q_lock; - unsigned long long req_q_time; - u64 req_q_util; - atomic_t req_q_full; - wait_queue_head_t req_q_wq; - struct zfcp_adapter *adapter; -}; - struct zfcp_adapter { struct kref ref; u64 peer_wwnn; /* P2P peer WWNN */ @@ -272,34 +243,12 @@ struct zfcp_unit { struct work_struct scsi_work; }; -/** - * struct zfcp_queue_req - queue related values for a request - * @sbal_number: number of free SBALs - * @sbal_first: first SBAL for this request - * @sbal_last: last SBAL for this request - * @sbal_limit: last possible SBAL for this request - * @sbale_curr: current SBALE at creation of this request - * @sbal_response: SBAL used in interrupt - * @qdio_outb_usage: usage of outbound queue - * @qdio_inb_usage: usage of inbound queue - */ -struct zfcp_queue_req { - u8 sbal_number; - u8 sbal_first; - u8 sbal_last; - u8 sbal_limit; - u8 sbale_curr; - u8 sbal_response; - u16 qdio_outb_usage; - u16 qdio_inb_usage; -}; - /** * struct zfcp_fsf_req - basic FSF request structure * @list: list of FSF requests * @req_id: unique request ID * @adapter: adapter this request belongs to - * @queue_req: queue related values + * @qdio_req: qdio queue related values * @completion: used to signal the completion of the request * @status: status of the request * @fsf_command: FSF command issued @@ -317,7 +266,7 @@ struct zfcp_fsf_req { struct list_head list; unsigned long req_id; struct zfcp_adapter *adapter; - struct zfcp_queue_req queue_req; + struct zfcp_qdio_req qdio_req; struct completion completion; u32 status; u32 fsf_command; diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h index 85cb135d5e7..8786a79c7f8 100644 --- a/drivers/s390/scsi/zfcp_ext.h +++ b/drivers/s390/scsi/zfcp_ext.h @@ -143,13 +143,9 @@ extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int); /* zfcp_qdio.c */ extern int zfcp_qdio_setup(struct zfcp_adapter *); extern void zfcp_qdio_destroy(struct zfcp_qdio *); -extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_queue_req *); -extern struct qdio_buffer_element - *zfcp_qdio_sbale_req(struct zfcp_qdio *, struct zfcp_queue_req *); -extern struct qdio_buffer_element - *zfcp_qdio_sbale_curr(struct zfcp_qdio *, struct zfcp_queue_req *); +extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_qdio_req *); extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, - struct zfcp_queue_req *, unsigned long, + struct zfcp_qdio_req *, unsigned long, struct scatterlist *, int); extern int zfcp_qdio_open(struct zfcp_qdio *); extern void zfcp_qdio_close(struct zfcp_qdio *); diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c index 8a0705ac52a..6538742b421 100644 --- a/drivers/s390/scsi/zfcp_fsf.c +++ b/drivers/s390/scsi/zfcp_fsf.c @@ -14,6 +14,7 @@ #include "zfcp_ext.h" #include "zfcp_fc.h" #include "zfcp_dbf.h" +#include "zfcp_qdio.h" #include "zfcp_reqlist.h" static void zfcp_fsf_request_timeout_handler(unsigned long data) @@ -723,12 +724,12 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio, req->adapter = adapter; req->fsf_command = fsf_cmd; req->req_id = adapter->req_no; - req->queue_req.sbal_number = 1; - req->queue_req.sbal_first = req_q->first; - req->queue_req.sbal_last = req_q->first; - req->queue_req.sbale_curr = 1; + req->qdio_req.sbal_number = 1; + req->qdio_req.sbal_first = req_q->first; + req->qdio_req.sbal_last = req_q->first; + req->qdio_req.sbale_curr = 1; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].addr = (void *) req->req_id; sbale[0].flags |= SBAL_FLAGS0_COMMAND; @@ -772,9 +773,9 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req) zfcp_reqlist_add(adapter->req_list, req); - req->queue_req.qdio_outb_usage = atomic_read(&qdio->req_q.count); + req->qdio_req.qdio_outb_usage = atomic_read(&qdio->req_q.count); req->issued = get_clock(); - if (zfcp_qdio_send(qdio, &req->queue_req)) { + if (zfcp_qdio_send(qdio, &req->qdio_req)) { del_timer(&req->timer); /* lookup request again, list might have changed */ zfcp_reqlist_find_rm(adapter->req_list, req_id); @@ -815,9 +816,9 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio) goto out; } - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY; - req->queue_req.sbale_curr = 2; + req->qdio_req.sbale_curr = 2; sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC); if (!sr_buf) { @@ -826,7 +827,7 @@ int zfcp_fsf_status_read(struct zfcp_qdio *qdio) } memset(sr_buf, 0, sizeof(*sr_buf)); req->data = sr_buf; - sbale = zfcp_qdio_sbale_curr(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_curr(qdio, &req->qdio_req); sbale->addr = (void *) sr_buf; sbale->length = sizeof(*sr_buf); @@ -923,7 +924,7 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id, ZFCP_STATUS_COMMON_UNBLOCKED))) goto out_error_free; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1018,7 +1019,7 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, { struct zfcp_adapter *adapter = req->adapter; struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter->qdio, - &req->queue_req); + &req->qdio_req); u32 feat = adapter->adapter_features; int bytes; @@ -1036,15 +1037,15 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, return 0; } - bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req, + bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, SBAL_FLAGS0_TYPE_WRITE_READ, sg_req, max_sbals); if (bytes <= 0) return -EIO; req->qtcb->bottom.support.req_buf_length = bytes; - req->queue_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; + req->qdio_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; - bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req, + bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->qdio_req, SBAL_FLAGS0_TYPE_WRITE_READ, sg_resp, max_sbals); req->qtcb->bottom.support.resp_buf_length = bytes; @@ -1240,7 +1241,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1282,7 +1283,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio, goto out_unlock; } - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; req->handler = zfcp_fsf_exchange_config_data_handler; @@ -1338,7 +1339,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1387,7 +1388,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio, if (data) req->data = data; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1502,7 +1503,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1572,7 +1573,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1649,7 +1650,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_fc_wka_port *wka_port) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1704,7 +1705,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_fc_wka_port *wka_port) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1798,7 +1799,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -1971,7 +1972,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -2057,7 +2058,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) } req->status |= ZFCP_STATUS_FSFREQ_CLEANUP; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -2100,8 +2101,8 @@ static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi) blktrc.magic = ZFCP_BLK_DRV_DATA_MAGIC; if (req->status & ZFCP_STATUS_FSFREQ_ERROR) blktrc.flags |= ZFCP_BLK_REQ_ERROR; - blktrc.inb_usage = req->queue_req.qdio_inb_usage; - blktrc.outb_usage = req->queue_req.qdio_outb_usage; + blktrc.inb_usage = req->qdio_req.qdio_inb_usage; + blktrc.outb_usage = req->qdio_req.qdio_outb_usage; if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA) { blktrc.flags |= ZFCP_BLK_LAT_VALID; @@ -2330,11 +2331,11 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit, fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd; zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd); - real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req, sbtype, + real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, sbtype, scsi_sglist(scsi_cmnd), FSF_MAX_SBALS_PER_REQ); if (unlikely(real_bytes < 0)) { - if (req->queue_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) { + if (req->qdio_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) { dev_err(&adapter->ccw_device->dev, "Oversize data package, unit 0x%016Lx " "on port 0x%016Lx closed\n", @@ -2399,7 +2400,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags) req->qtcb->bottom.io.service_class = FSF_CLASS_3; req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE; sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; @@ -2462,14 +2463,14 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, req->handler = zfcp_fsf_control_file_handler; - sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req); + sbale = zfcp_qdio_sbale_req(qdio, &req->qdio_req); sbale[0].flags |= direction; bottom = &req->qtcb->bottom.support; bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE; bottom->option = fsf_cfdc->option; - bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req, + bytes = zfcp_qdio_sbals_from_sg(qdio, &req->qdio_req, direction, fsf_cfdc->sg, FSF_MAX_SBALS_PER_REQ); if (bytes != ZFCP_CFDC_MAX_SIZE) { @@ -2517,8 +2518,8 @@ void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx) panic("error: unknown req_id (%lx) on adapter %s.\n", req_id, dev_name(&adapter->ccw_device->dev)); - fsf_req->queue_req.sbal_response = sbal_idx; - fsf_req->queue_req.qdio_inb_usage = + fsf_req->qdio_req.sbal_response = sbal_idx; + fsf_req->qdio_req.qdio_inb_usage = atomic_read(&qdio->resp_q.count); zfcp_fsf_req_complete(fsf_req); diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c index 3d329fa3d09..71b97ff77cf 100644 --- a/drivers/s390/scsi/zfcp_qdio.c +++ b/drivers/s390/scsi/zfcp_qdio.c @@ -10,6 +10,7 @@ #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt #include "zfcp_ext.h" +#include "zfcp_qdio.h" #define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer)) @@ -28,12 +29,6 @@ static int zfcp_qdio_buffers_enqueue(struct qdio_buffer **sbal) return 0; } -static struct qdio_buffer_element * -zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx) -{ - return &q->sbal[sbal_idx]->element[sbale_idx]; -} - static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id) { struct zfcp_adapter *adapter = qdio->adapter; @@ -145,32 +140,8 @@ static void zfcp_qdio_int_resp(struct ccw_device *cdev, unsigned int qdio_err, zfcp_qdio_resp_put_back(qdio, count); } -/** - * zfcp_qdio_sbale_req - return ptr to SBALE of req_q for a struct zfcp_fsf_req - * @qdio: pointer to struct zfcp_qdio - * @q_rec: pointer to struct zfcp_queue_rec - * Returns: pointer to qdio_buffer_element (SBALE) structure - */ -struct qdio_buffer_element *zfcp_qdio_sbale_req(struct zfcp_qdio *qdio, - struct zfcp_queue_req *q_req) -{ - return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, 0); -} - -/** - * zfcp_qdio_sbale_curr - return curr SBALE on req_q for a struct zfcp_fsf_req - * @fsf_req: pointer to struct fsf_req - * Returns: pointer to qdio_buffer_element (SBALE) structure - */ -struct qdio_buffer_element *zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, - struct zfcp_queue_req *q_req) -{ - return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, - q_req->sbale_curr); -} - static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio, - struct zfcp_queue_req *q_req, int max_sbals) + struct zfcp_qdio_req *q_req, int max_sbals) { int count = atomic_read(&qdio->req_q.count); count = min(count, max_sbals); @@ -179,7 +150,7 @@ static void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio, } static struct qdio_buffer_element * -zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, +zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, unsigned long sbtype) { struct qdio_buffer_element *sbale; @@ -214,7 +185,7 @@ zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, } static struct qdio_buffer_element * -zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, +zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, unsigned int sbtype) { if (q_req->sbale_curr == ZFCP_LAST_SBALE_PER_SBAL) @@ -224,7 +195,7 @@ zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req, } static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio, - struct zfcp_queue_req *q_req) + struct zfcp_qdio_req *q_req) { struct qdio_buffer **sbal = qdio->req_q.sbal; int first = q_req->sbal_first; @@ -235,7 +206,7 @@ static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio, } static int zfcp_qdio_fill_sbals(struct zfcp_qdio *qdio, - struct zfcp_queue_req *q_req, + struct zfcp_qdio_req *q_req, unsigned int sbtype, void *start_addr, unsigned int total_length) { @@ -271,8 +242,7 @@ static int zfcp_qdio_fill_sbals(struct zfcp_qdio *qdio, * @max_sbals: upper bound for number of SBALs to be used * Returns: number of bytes, or error (negativ) */ -int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, - struct zfcp_queue_req *q_req, +int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req, unsigned long sbtype, struct scatterlist *sg, int max_sbals) { @@ -304,10 +274,10 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, /** * zfcp_qdio_send - set PCI flag in first SBALE and send req to QDIO * @qdio: pointer to struct zfcp_qdio - * @q_req: pointer to struct zfcp_queue_req + * @q_req: pointer to struct zfcp_qdio_req * Returns: 0 on success, error otherwise */ -int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_queue_req *q_req) +int zfcp_qdio_send(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) { struct zfcp_qdio_queue *req_q = &qdio->req_q; int first = q_req->sbal_first; diff --git a/drivers/s390/scsi/zfcp_qdio.h b/drivers/s390/scsi/zfcp_qdio.h new file mode 100644 index 00000000000..8cca54631e1 --- /dev/null +++ b/drivers/s390/scsi/zfcp_qdio.h @@ -0,0 +1,109 @@ +/* + * zfcp device driver + * + * Header file for zfcp qdio interface + * + * Copyright IBM Corporation 2010 + */ + +#ifndef ZFCP_QDIO_H +#define ZFCP_QDIO_H + +#include + +/** + * struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count + * @sbal: qdio buffers + * @first: index of next free buffer in queue + * @count: number of free buffers in queue + */ +struct zfcp_qdio_queue { + struct qdio_buffer *sbal[QDIO_MAX_BUFFERS_PER_Q]; + u8 first; + atomic_t count; +}; + +/** + * struct zfcp_qdio - basic qdio data structure + * @resp_q: response queue + * @req_q: request queue + * @stat_lock: lock to protect req_q_util and req_q_time + * @req_q_lock: lock to serialize access to request queue + * @req_q_time: time of last fill level change + * @req_q_util: used for accounting + * @req_q_full: queue full incidents + * @req_q_wq: used to wait for SBAL availability + * @adapter: adapter used in conjunction with this qdio structure + */ +struct zfcp_qdio { + struct zfcp_qdio_queue resp_q; + struct zfcp_qdio_queue req_q; + spinlock_t stat_lock; + spinlock_t req_q_lock; + unsigned long long req_q_time; + u64 req_q_util; + atomic_t req_q_full; + wait_queue_head_t req_q_wq; + struct zfcp_adapter *adapter; +}; + +/** + * struct zfcp_qdio_req - qdio queue related values for a request + * @sbal_number: number of free sbals + * @sbal_first: first sbal for this request + * @sbal_last: last sbal for this request + * @sbal_limit: last possible sbal for this request + * @sbale_curr: current sbale at creation of this request + * @sbal_response: sbal used in interrupt + * @qdio_outb_usage: usage of outbound queue + * @qdio_inb_usage: usage of inbound queue + */ +struct zfcp_qdio_req { + u8 sbal_number; + u8 sbal_first; + u8 sbal_last; + u8 sbal_limit; + u8 sbale_curr; + u8 sbal_response; + u16 qdio_outb_usage; + u16 qdio_inb_usage; +}; + +/** + * zfcp_qdio_sbale - return pointer to sbale in qdio queue + * @q: queue where to find sbal + * @sbal_idx: sbal index in queue + * @sbale_idx: sbale index in sbal + */ +static inline struct qdio_buffer_element * +zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx) +{ + return &q->sbal[sbal_idx]->element[sbale_idx]; +} + +/** + * zfcp_qdio_sbale_req - return pointer to sbale on req_q for a request + * @qdio: pointer to struct zfcp_qdio + * @q_rec: pointer to struct zfcp_qdio_req + * Returns: pointer to qdio_buffer_element (sbale) structure + */ +static inline struct qdio_buffer_element * +zfcp_qdio_sbale_req(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) +{ + return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, 0); +} + +/** + * zfcp_qdio_sbale_curr - return current sbale on req_q for a request + * @qdio: pointer to struct zfcp_qdio + * @fsf_req: pointer to struct zfcp_fsf_req + * Returns: pointer to qdio_buffer_element (sbale) structure + */ +static inline struct qdio_buffer_element * +zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req) +{ + return zfcp_qdio_sbale(&qdio->req_q, q_req->sbal_last, + q_req->sbale_curr); +} + +#endif /* ZFCP_QDIO_H */ -- cgit v1.2.3