You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[SCSI] zfcp: Move sbale handling to zfcp_qdio files
Move the code accessing the qdio sbales and zfcp_qdio_req struct to the zfcp_qdio files and provide helper functions for accessing the qdio related parts. Reviewed-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>
This commit is contained in:
committed by
James Bottomley
parent
683229845f
commit
1674b40547
@@ -44,23 +44,6 @@ struct zfcp_reqlist;
|
||||
/********************* SCSI SPECIFIC DEFINES *********************************/
|
||||
#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)
|
||||
|
||||
/********************* CIO/QDIO SPECIFIC DEFINES *****************************/
|
||||
|
||||
/* DMQ bug workaround: don't use last SBALE */
|
||||
#define ZFCP_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
|
||||
|
||||
/* index of last SBALE (with respect to DMQ bug workaround) */
|
||||
#define ZFCP_LAST_SBALE_PER_SBAL (ZFCP_MAX_SBALES_PER_SBAL - 1)
|
||||
|
||||
/* max. number of (data buffer) SBALEs in largest SBAL chain */
|
||||
#define ZFCP_MAX_SBALES_PER_REQ \
|
||||
(FSF_MAX_SBALS_PER_REQ * ZFCP_MAX_SBALES_PER_SBAL - 2)
|
||||
/* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
|
||||
|
||||
#define ZFCP_MAX_SECTORS (ZFCP_MAX_SBALES_PER_REQ * 8)
|
||||
/* max. number of (data buffer) SBALEs in largest SBAL chain
|
||||
multiplied with number of sectors per 4k block */
|
||||
|
||||
/********************* FSF SPECIFIC DEFINES *********************************/
|
||||
|
||||
/* ATTENTION: value must not be used by hardware */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* External function declarations.
|
||||
*
|
||||
* Copyright IBM Corporation 2002, 2009
|
||||
* Copyright IBM Corporation 2002, 2010
|
||||
*/
|
||||
|
||||
#ifndef ZFCP_EXT_H
|
||||
@@ -144,8 +144,7 @@ extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int);
|
||||
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_qdio_req *);
|
||||
extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *,
|
||||
struct zfcp_qdio_req *, unsigned long,
|
||||
extern int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *, struct zfcp_qdio_req *,
|
||||
struct scatterlist *, int);
|
||||
extern int zfcp_qdio_open(struct zfcp_qdio *);
|
||||
extern void zfcp_qdio_close(struct zfcp_qdio *);
|
||||
|
||||
+67
-113
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Interface to the FSF support functions.
|
||||
*
|
||||
* Copyright IBM Corporation 2002, 2009
|
||||
* Copyright IBM Corporation 2002, 2010
|
||||
*/
|
||||
|
||||
#ifndef FSF_H
|
||||
@@ -152,7 +152,12 @@
|
||||
#define FSF_CLASS_3 0x00000003
|
||||
|
||||
/* SBAL chaining */
|
||||
#define FSF_MAX_SBALS_PER_REQ 36
|
||||
#define ZFCP_FSF_MAX_SBALS_PER_REQ 36
|
||||
|
||||
/* max. number of (data buffer) SBALEs in largest SBAL chain
|
||||
* request ID + QTCB in SBALE 0 + 1 of first SBAL in chain */
|
||||
#define ZFCP_FSF_MAX_SBALES_PER_REQ \
|
||||
(ZFCP_FSF_MAX_SBALS_PER_REQ * ZFCP_QDIO_MAX_SBALES_PER_SBAL - 2)
|
||||
|
||||
/* logging space behind QTCB */
|
||||
#define FSF_QTCB_LOG_SIZE 1024
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Setup and helper functions to access QDIO.
|
||||
*
|
||||
* Copyright IBM Corporation 2002, 2009
|
||||
* Copyright IBM Corporation 2002, 2010
|
||||
*/
|
||||
|
||||
#define KMSG_COMPONENT "zfcp"
|
||||
@@ -151,8 +151,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_qdio_req *q_req,
|
||||
unsigned long sbtype)
|
||||
zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
|
||||
{
|
||||
struct qdio_buffer_element *sbale;
|
||||
|
||||
@@ -180,17 +179,16 @@ zfcp_qdio_sbal_chain(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
|
||||
|
||||
/* set storage-block type for new SBAL */
|
||||
sbale = zfcp_qdio_sbale_curr(qdio, q_req);
|
||||
sbale->flags |= sbtype;
|
||||
sbale->flags |= q_req->sbtype;
|
||||
|
||||
return sbale;
|
||||
}
|
||||
|
||||
static struct qdio_buffer_element *
|
||||
zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
|
||||
unsigned int sbtype)
|
||||
zfcp_qdio_sbale_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
|
||||
{
|
||||
if (q_req->sbale_curr == ZFCP_LAST_SBALE_PER_SBAL)
|
||||
return zfcp_qdio_sbal_chain(qdio, q_req, sbtype);
|
||||
if (q_req->sbale_curr == ZFCP_QDIO_LAST_SBALE_PER_SBAL)
|
||||
return zfcp_qdio_sbal_chain(qdio, q_req);
|
||||
q_req->sbale_curr++;
|
||||
return zfcp_qdio_sbale_curr(qdio, q_req);
|
||||
}
|
||||
@@ -208,15 +206,14 @@ static void zfcp_qdio_undo_sbals(struct zfcp_qdio *qdio,
|
||||
|
||||
/**
|
||||
* zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list
|
||||
* @fsf_req: request to be processed
|
||||
* @sbtype: SBALE flags
|
||||
* @qdio: pointer to struct zfcp_qdio
|
||||
* @q_req: pointer to struct zfcp_qdio_req
|
||||
* @sg: scatter-gather list
|
||||
* @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_qdio_req *q_req,
|
||||
unsigned long sbtype, struct scatterlist *sg,
|
||||
int max_sbals)
|
||||
struct scatterlist *sg, int max_sbals)
|
||||
{
|
||||
struct qdio_buffer_element *sbale;
|
||||
int bytes = 0;
|
||||
@@ -226,10 +223,10 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
|
||||
|
||||
/* set storage-block type for this request */
|
||||
sbale = zfcp_qdio_sbale_req(qdio, q_req);
|
||||
sbale->flags |= sbtype;
|
||||
sbale->flags |= q_req->sbtype;
|
||||
|
||||
for (; sg; sg = sg_next(sg)) {
|
||||
sbale = zfcp_qdio_sbale_next(qdio, q_req, sbtype);
|
||||
sbale = zfcp_qdio_sbale_next(qdio, q_req);
|
||||
if (!sbale) {
|
||||
atomic_inc(&qdio->req_q_full);
|
||||
zfcp_qdio_undo_sbals(qdio, q_req);
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
|
||||
#define ZFCP_QDIO_SBALE_LEN PAGE_SIZE
|
||||
|
||||
/* DMQ bug workaround: don't use last SBALE */
|
||||
#define ZFCP_QDIO_MAX_SBALES_PER_SBAL (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)
|
||||
|
||||
/* index of last SBALE (with respect to DMQ bug workaround) */
|
||||
#define ZFCP_QDIO_LAST_SBALE_PER_SBAL (ZFCP_QDIO_MAX_SBALES_PER_SBAL - 1)
|
||||
|
||||
/**
|
||||
* struct zfcp_qdio_queue - qdio queue buffer, zfcp index and free count
|
||||
* @sbal: qdio buffers
|
||||
@@ -51,6 +57,7 @@ struct zfcp_qdio {
|
||||
|
||||
/**
|
||||
* struct zfcp_qdio_req - qdio queue related values for a request
|
||||
* @sbtype: sbal type flags for sbale 0
|
||||
* @sbal_number: number of free sbals
|
||||
* @sbal_first: first sbal for this request
|
||||
* @sbal_last: last sbal for this request
|
||||
@@ -61,6 +68,7 @@ struct zfcp_qdio {
|
||||
* @qdio_inb_usage: usage of inbound queue
|
||||
*/
|
||||
struct zfcp_qdio_req {
|
||||
u32 sbtype;
|
||||
u8 sbal_number;
|
||||
u8 sbal_first;
|
||||
u8 sbal_last;
|
||||
@@ -108,4 +116,98 @@ zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
|
||||
q_req->sbale_curr);
|
||||
}
|
||||
|
||||
/**
|
||||
* zfcp_qdio_req_init - initialize qdio request
|
||||
* @qdio: request queue where to start putting the request
|
||||
* @q_req: the qdio request to start
|
||||
* @req_id: The request id
|
||||
* @sbtype: type flags to set for all sbals
|
||||
* @data: First data block
|
||||
* @len: Length of first data block
|
||||
*
|
||||
* This is the start of putting the request into the queue, the last
|
||||
* step is passing the request to zfcp_qdio_send. The request queue
|
||||
* lock must be held during the whole process from init to send.
|
||||
*/
|
||||
static inline
|
||||
void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
|
||||
unsigned long req_id, u32 sbtype, void *data, u32 len)
|
||||
{
|
||||
struct qdio_buffer_element *sbale;
|
||||
|
||||
q_req->sbal_first = q_req->sbal_last = qdio->req_q.first;
|
||||
q_req->sbal_number = 1;
|
||||
q_req->sbtype = sbtype;
|
||||
|
||||
sbale = zfcp_qdio_sbale_req(qdio, q_req);
|
||||
sbale->addr = (void *) req_id;
|
||||
sbale->flags |= SBAL_FLAGS0_COMMAND;
|
||||
sbale->flags |= sbtype;
|
||||
|
||||
q_req->sbale_curr = 1;
|
||||
sbale++;
|
||||
sbale->addr = data;
|
||||
if (likely(data))
|
||||
sbale->length = len;
|
||||
}
|
||||
|
||||
/**
|
||||
* zfcp_qdio_fill_next - Fill next sbale, only for single sbal requests
|
||||
* @qdio: pointer to struct zfcp_qdio
|
||||
* @q_req: pointer to struct zfcp_queue_req
|
||||
*
|
||||
* This is only required for single sbal requests, calling it when
|
||||
* wrapping around to the next sbal is a bug.
|
||||
*/
|
||||
static inline
|
||||
void zfcp_qdio_fill_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
|
||||
void *data, u32 len)
|
||||
{
|
||||
struct qdio_buffer_element *sbale;
|
||||
|
||||
BUG_ON(q_req->sbale_curr == ZFCP_QDIO_LAST_SBALE_PER_SBAL);
|
||||
q_req->sbale_curr++;
|
||||
sbale = zfcp_qdio_sbale_curr(qdio, q_req);
|
||||
sbale->addr = data;
|
||||
sbale->length = len;
|
||||
}
|
||||
|
||||
/**
|
||||
* zfcp_qdio_set_sbale_last - set last entry flag in current sbale
|
||||
* @qdio: pointer to struct zfcp_qdio
|
||||
* @q_req: pointer to struct zfcp_queue_req
|
||||
*/
|
||||
static inline
|
||||
void zfcp_qdio_set_sbale_last(struct zfcp_qdio *qdio,
|
||||
struct zfcp_qdio_req *q_req)
|
||||
{
|
||||
struct qdio_buffer_element *sbale;
|
||||
|
||||
sbale = zfcp_qdio_sbale_curr(qdio, q_req);
|
||||
sbale->flags |= SBAL_FLAGS_LAST_ENTRY;
|
||||
}
|
||||
|
||||
/**
|
||||
* zfcp_qdio_sg_one_sbal - check if one sbale is enough for sg data
|
||||
* @sg: The scatterlist where to check the data size
|
||||
*
|
||||
* Returns: 1 when one sbale is enough for the data in the scatterlist,
|
||||
* 0 if not.
|
||||
*/
|
||||
static inline
|
||||
int zfcp_qdio_sg_one_sbale(struct scatterlist *sg)
|
||||
{
|
||||
return sg_is_last(sg) && sg->length <= ZFCP_QDIO_SBALE_LEN;
|
||||
}
|
||||
|
||||
/**
|
||||
* zfcp_qdio_skip_to_last_sbale - skip to last sbale in sbal
|
||||
* @q_req: The current zfcp_qdio_req
|
||||
*/
|
||||
static inline
|
||||
void zfcp_qdio_skip_to_last_sbale(struct zfcp_qdio_req *q_req)
|
||||
{
|
||||
q_req->sbale_curr = ZFCP_QDIO_LAST_SBALE_PER_SBAL;
|
||||
}
|
||||
|
||||
#endif /* ZFCP_QDIO_H */
|
||||
|
||||
@@ -677,11 +677,11 @@ struct zfcp_data zfcp_data = {
|
||||
.eh_host_reset_handler = zfcp_scsi_eh_host_reset_handler,
|
||||
.can_queue = 4096,
|
||||
.this_id = -1,
|
||||
.sg_tablesize = ZFCP_MAX_SBALES_PER_REQ,
|
||||
.sg_tablesize = ZFCP_FSF_MAX_SBALES_PER_REQ,
|
||||
.cmd_per_lun = 1,
|
||||
.use_clustering = 1,
|
||||
.sdev_attrs = zfcp_sysfs_sdev_attrs,
|
||||
.max_sectors = (ZFCP_MAX_SBALES_PER_REQ * 8),
|
||||
.max_sectors = (ZFCP_FSF_MAX_SBALES_PER_REQ * 8),
|
||||
.dma_boundary = ZFCP_QDIO_SBALE_LEN - 1,
|
||||
.shost_attrs = zfcp_sysfs_shost_attrs,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user