Skip to content

Commit

Permalink
[SCSI] zfcp: Separate qdio attributes from zfcp_fsf_req
Browse files Browse the repository at this point in the history
Split all qdio related attributes out of zfcp_fsf_req and put it in
new structure.

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@suse.de>
  • Loading branch information
sswen authored and James Bottomley committed Sep 5, 2009
1 parent 4544683 commit 42428f7
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 115 deletions.
6 changes: 3 additions & 3 deletions drivers/s390/scsi/zfcp_dbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ void _zfcp_hba_dbf_event_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->sbal_first;
response->sbal_last = fsf_req->sbal_last;
response->sbal_response = fsf_req->sbal_response;
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->pool = fsf_req->pool != NULL;
response->erp_action = (unsigned long)fsf_req->erp_action;

Expand Down
84 changes: 56 additions & 28 deletions drivers/s390/scsi/zfcp_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,36 +529,64 @@ struct zfcp_unit {
struct work_struct scsi_work;
};

/* FSF request */
/**
* 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
* @completion: used to signal the completion of the request
* @status: status of the request
* @fsf_command: FSF command issued
* @qtcb: associated QTCB
* @seq_no: sequence number of this request
* @data: private data
* @timer: timer data of this request
* @erp_action: reference to erp action if request issued on behalf of ERP
* @pool: reference to memory pool if used for this request
* @issued: time when request was send (STCK)
* @unit: reference to unit if this request is a SCSI request
* @handler: handler which should be called to process response
*/
struct zfcp_fsf_req {
struct list_head list; /* list of FSF requests */
unsigned long req_id; /* unique request ID */
struct zfcp_adapter *adapter; /* adapter request belongs to */
u8 sbal_number; /* nr of SBALs free for use */
u8 sbal_first; /* first SBAL for this request */
u8 sbal_last; /* last SBAL for this request */
u8 sbal_limit; /* last possible SBAL for
this reuest */
u8 sbale_curr; /* current SBALE during creation
of request */
u8 sbal_response; /* SBAL used in interrupt */
struct completion completion; /* can be used by a routine
to wait for completion */
u32 status; /* status of this request */
u32 fsf_command; /* FSF Command copy */
struct fsf_qtcb *qtcb; /* address of associated QTCB */
u32 seq_no; /* Sequence number 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 */
mempool_t *pool; /* used if request was alloacted
from emergency pool */
unsigned long long issued; /* request sent time (STCK) */
struct zfcp_unit *unit;
struct list_head list;
unsigned long req_id;
struct zfcp_adapter *adapter;
struct zfcp_queue_req queue_req;
struct completion completion;
u32 status;
u32 fsf_command;
struct fsf_qtcb *qtcb;
u32 seq_no;
void *data;
struct timer_list timer;
struct zfcp_erp_action *erp_action;
mempool_t *pool;
unsigned long long issued;
struct zfcp_unit *unit;
void (*handler)(struct zfcp_fsf_req *);
u16 qdio_outb_usage;/* usage of outbound queue */
u16 qdio_inb_usage; /* usage of inbound queue */
};

/* driver data */
Expand Down
11 changes: 7 additions & 4 deletions drivers/s390/scsi/zfcp_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,13 @@ extern void zfcp_fsf_reqid_check(struct zfcp_adapter *, int);
/* zfcp_qdio.c */
extern int zfcp_qdio_allocate(struct zfcp_adapter *);
extern void zfcp_qdio_free(struct zfcp_adapter *);
extern int zfcp_qdio_send(struct zfcp_fsf_req *);
extern struct qdio_buffer_element *zfcp_qdio_sbale_req(struct zfcp_fsf_req *);
extern struct qdio_buffer_element *zfcp_qdio_sbale_curr(struct zfcp_fsf_req *);
extern int zfcp_qdio_sbals_from_sg(struct zfcp_fsf_req *, unsigned long,
extern int zfcp_qdio_send(struct zfcp_adapter *, struct zfcp_queue_req *);
extern struct qdio_buffer_element
*zfcp_qdio_sbale_req(struct zfcp_adapter *, struct zfcp_queue_req *);
extern struct qdio_buffer_element
*zfcp_qdio_sbale_curr(struct zfcp_adapter *, struct zfcp_queue_req *);
extern int zfcp_qdio_sbals_from_sg(struct zfcp_adapter *,
struct zfcp_queue_req *, unsigned long,
struct scatterlist *, int);
extern int zfcp_qdio_open(struct zfcp_adapter *);
extern void zfcp_qdio_close(struct zfcp_adapter *);
Expand Down
79 changes: 42 additions & 37 deletions drivers/s390/scsi/zfcp_fsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,12 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_adapter *adapter,
req->adapter = adapter;
req->fsf_command = fsf_cmd;
req->req_id = adapter->req_no;
req->sbal_number = 1;
req->sbal_first = req_q->first;
req->sbal_last = req_q->first;
req->sbale_curr = 1;
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;

sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].addr = (void *) req->req_id;
sbale[0].flags |= SBAL_FLAGS0_COMMAND;

Expand Down Expand Up @@ -774,9 +774,9 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
list_add_tail(&req->list, &adapter->req_list[idx]);
spin_unlock_irqrestore(&adapter->req_list_lock, flags);

req->qdio_outb_usage = atomic_read(&adapter->req_q.count);
req->queue_req.qdio_outb_usage = atomic_read(&adapter->req_q.count);
req->issued = get_clock();
if (zfcp_qdio_send(req)) {
if (zfcp_qdio_send(adapter, &req->queue_req)) {
del_timer(&req->timer);
spin_lock_irqsave(&adapter->req_list_lock, flags);
/* lookup request again, list might have changed */
Expand Down Expand Up @@ -819,9 +819,9 @@ int zfcp_fsf_status_read(struct zfcp_adapter *adapter)
goto out;
}

sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
req->sbale_curr = 2;
req->queue_req.sbale_curr = 2;

sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC);
if (!sr_buf) {
Expand All @@ -830,7 +830,7 @@ int zfcp_fsf_status_read(struct zfcp_adapter *adapter)
}
memset(sr_buf, 0, sizeof(*sr_buf));
req->data = sr_buf;
sbale = zfcp_qdio_sbale_curr(req);
sbale = zfcp_qdio_sbale_curr(adapter, &req->queue_req);
sbale->addr = (void *) sr_buf;
sbale->length = sizeof(*sr_buf);

Expand Down Expand Up @@ -929,7 +929,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(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1023,8 +1023,10 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
struct scatterlist *sg_resp,
int max_sbals)
{
struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(req);
u32 feat = req->adapter->adapter_features;
struct zfcp_adapter *adapter = req->adapter;
struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter,
&req->queue_req);
u32 feat = adapter->adapter_features;
int bytes;

if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) {
Expand All @@ -1041,14 +1043,16 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
return 0;
}

bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ,
bytes = zfcp_qdio_sbals_from_sg(adapter, &req->queue_req,
SBAL_FLAGS0_TYPE_WRITE_READ,
sg_req, max_sbals);
if (bytes <= 0)
return -EIO;
req->qtcb->bottom.support.req_buf_length = bytes;
req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
req->queue_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;

bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ,
bytes = zfcp_qdio_sbals_from_sg(adapter, &req->queue_req,
SBAL_FLAGS0_TYPE_WRITE_READ,
sg_resp, max_sbals);
if (bytes <= 0)
return -EIO;
Expand Down Expand Up @@ -1241,7 +1245,7 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1283,7 +1287,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
goto out_unlock;
}

sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
req->handler = zfcp_fsf_exchange_config_data_handler;
Expand Down Expand Up @@ -1339,7 +1343,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1388,7 +1392,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
if (data)
req->data = data;

sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1509,7 +1513,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1579,7 +1583,7 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1656,7 +1660,7 @@ int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1711,7 +1715,7 @@ int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1803,7 +1807,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -1976,7 +1980,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -2063,7 +2067,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
}

req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -2140,8 +2144,8 @@ static void zfcp_fsf_trace_latency(struct zfcp_fsf_req *fsf_req)
}
if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
trace.flags |= ZFCP_BLK_REQ_ERROR;
trace.inb_usage = fsf_req->qdio_inb_usage;
trace.outb_usage = fsf_req->qdio_outb_usage;
trace.inb_usage = fsf_req->queue_req.qdio_inb_usage;
trace.outb_usage = fsf_req->queue_req.qdio_outb_usage;

blk_add_driver_data(req->q, req, &trace, sizeof(trace));
}
Expand Down Expand Up @@ -2420,11 +2424,11 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) +
fcp_cmnd_iu->add_fcp_cdb_length + sizeof(u32);

real_bytes = zfcp_qdio_sbals_from_sg(req, sbtype,
real_bytes = zfcp_qdio_sbals_from_sg(adapter, &req->queue_req, sbtype,
scsi_sglist(scsi_cmnd),
FSF_MAX_SBALS_PER_REQ);
if (unlikely(real_bytes < 0)) {
if (req->sbal_number >= FSF_MAX_SBALS_PER_REQ) {
if (req->queue_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",
Expand Down Expand Up @@ -2492,7 +2496,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) +
sizeof(u32);

sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_req);
sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;

Expand Down Expand Up @@ -2555,15 +2559,15 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,

req->handler = zfcp_fsf_control_file_handler;

sbale = zfcp_qdio_sbale_req(req);
sbale = zfcp_qdio_sbale_req(adapter, &req->queue_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(req, direction, fsf_cfdc->sg,
FSF_MAX_SBALS_PER_REQ);
bytes = zfcp_qdio_sbals_from_sg(adapter, &req->queue_req, direction,
fsf_cfdc->sg, FSF_MAX_SBALS_PER_REQ);
if (bytes != ZFCP_CFDC_MAX_SIZE) {
zfcp_fsf_req_free(req);
goto out;
Expand Down Expand Up @@ -2612,8 +2616,9 @@ void zfcp_fsf_reqid_check(struct zfcp_adapter *adapter, int sbal_idx)
list_del(&fsf_req->list);
spin_unlock_irqrestore(&adapter->req_list_lock, flags);

fsf_req->sbal_response = sbal_idx;
fsf_req->qdio_inb_usage = atomic_read(&adapter->resp_q.count);
fsf_req->queue_req.sbal_response = sbal_idx;
fsf_req->queue_req.qdio_inb_usage =
atomic_read(&adapter->resp_q.count);
zfcp_fsf_req_complete(fsf_req);

if (likely(sbale->flags & SBAL_FLAGS_LAST_ENTRY))
Expand Down
Loading

0 comments on commit 42428f7

Please sign in to comment.