Exemplo n.º 1
0
/**
 * zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list
 * @fsf_req: request to be processed
 * @sbtype: SBALE flags
 * @sg: scatter-gather list
 * @sg_count: number of elements in scatter-gather list
 * @max_sbals: upper bound for number of SBALs to be used
 */
int
zfcp_qdio_sbals_from_sg(struct zfcp_fsf_req *fsf_req, unsigned long sbtype,
                        struct scatterlist *sgl, int sg_count, int max_sbals)
{
	int sg_index;
	struct scatterlist *sg_segment;
	int retval;
	volatile struct qdio_buffer_element *sbale;
	int bytes = 0;

	/* figure out last allowed SBAL */
	zfcp_qdio_sbal_limit(fsf_req, max_sbals);

	/* set storage-block type for current SBAL */
	sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
	sbale->flags |= sbtype;

	/* process all segements of scatter-gather list */
	for_each_sg(sgl, sg_segment, sg_count, sg_index) {
		retval = zfcp_qdio_sbals_from_segment(
				fsf_req,
				sbtype,
				zfcp_sg_to_address(sg_segment),
				sg_segment->length);
		if (retval < 0) {
			bytes = retval;
			goto out;
		} else
                        bytes += retval;
	}
Exemplo n.º 2
0
/**
 * zfcp_qdio_sbals_from_sg - fill SBALs from scatter-gather list
 * @fsf_req: request to be processed
 * @sbtype: SBALE flags
 * @sg: scatter-gather list
 * @sg_count: number of elements in scatter-gather list
 * @max_sbals: upper bound for number of SBALs to be used
 */
inline int
zfcp_qdio_sbals_from_sg(struct zfcp_fsf_req *fsf_req, unsigned long sbtype,
                        struct scatterlist *sg,	int sg_count, int max_sbals)
{
    int sg_index;
    struct scatterlist *sg_segment;
    int retval;
    volatile struct qdio_buffer_element *sbale;
    int bytes = 0;

    /* figure out last allowed SBAL */
    zfcp_qdio_sbal_limit(fsf_req, max_sbals);

    /* set storage-block type for current SBAL */
    sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
    sbale->flags |= sbtype;

    /* process all segements of scatter-gather list */
    for (sg_index = 0, sg_segment = sg, bytes = 0;
            sg_index < sg_count;
            sg_index++, sg_segment++) {
        retval = zfcp_qdio_sbals_from_segment(
                     fsf_req,
                     sbtype,
                     zfcp_sg_to_address(sg_segment),
                     sg_segment->length);
        if (retval < 0) {
            bytes = retval;
            goto out;
        } else
            bytes += retval;
    }
    /* assume that no other SBALEs are to follow in the same SBAL */
    sbale = zfcp_qdio_sbale_curr(fsf_req);
    sbale->flags |= SBAL_FLAGS_LAST_ENTRY;

out:
#ifdef ZFCP_STAT_REQSIZES
    if (sbtype == SBAL_FLAGS0_TYPE_READ) {
        zfcp_statistics_inc(&zfcp_data.read_sguse_head, sg_count);
        zfcp_statistics_inc(&zfcp_data.read_req_head, bytes);
    } else	{
        zfcp_statistics_inc(&zfcp_data.write_sguse_head, sg_count);
        zfcp_statistics_inc(&zfcp_data.write_req_head, bytes);
    }
#endif

    return bytes;
}