^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * zfcp device driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Header file for zfcp qdio interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright IBM Corp. 2010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef ZFCP_QDIO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define ZFCP_QDIO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/qdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define ZFCP_QDIO_SBALE_LEN PAGE_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* Max SBALS for chaining */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define ZFCP_QDIO_MAX_SBALS_PER_REQ 36
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * struct zfcp_qdio - basic qdio data structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * @res_q: response queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * @req_q: request queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * @req_q_idx: index of next free buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * @req_q_free: number of free buffers in queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * @stat_lock: lock to protect req_q_util and req_q_time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * @req_q_lock: lock to serialize access to request queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * @req_q_time: time of last fill level change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * @req_q_util: used for accounting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @req_q_full: queue full incidents
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * @req_q_wq: used to wait for SBAL availability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @adapter: adapter used in conjunction with this qdio structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * @max_sbale_per_sbal: qdio limit per sbal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * @max_sbale_per_req: qdio limit per request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct zfcp_qdio {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct qdio_buffer *res_q[QDIO_MAX_BUFFERS_PER_Q];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct qdio_buffer *req_q[QDIO_MAX_BUFFERS_PER_Q];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) u8 req_q_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) atomic_t req_q_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) spinlock_t stat_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) spinlock_t req_q_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned long long req_q_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) u64 req_q_util;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) atomic_t req_q_full;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) wait_queue_head_t req_q_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct zfcp_adapter *adapter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) u16 max_sbale_per_sbal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) u16 max_sbale_per_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * struct zfcp_qdio_req - qdio queue related values for a request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * @sbtype: sbal type flags for sbale 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * @sbal_number: number of free sbals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * @sbal_first: first sbal for this request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @sbal_last: last sbal for this request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * @sbal_limit: last possible sbal for this request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @sbale_curr: current sbale at creation of this request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @qdio_outb_usage: usage of outbound queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct zfcp_qdio_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u8 sbtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u8 sbal_number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) u8 sbal_first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) u8 sbal_last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u8 sbal_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u8 sbale_curr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) u16 qdio_outb_usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * zfcp_qdio_sbale_req - return pointer to sbale on req_q for a request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @q_req: pointer to struct zfcp_qdio_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * Returns: pointer to qdio_buffer_element (sbale) structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static inline struct qdio_buffer_element *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) zfcp_qdio_sbale_req(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return &qdio->req_q[q_req->sbal_last]->element[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * zfcp_qdio_sbale_curr - return current sbale on req_q for a request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * @q_req: pointer to struct zfcp_qdio_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * Returns: pointer to qdio_buffer_element (sbale) structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static inline struct qdio_buffer_element *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) zfcp_qdio_sbale_curr(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return &qdio->req_q[q_req->sbal_last]->element[q_req->sbale_curr];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * zfcp_qdio_req_init - initialize qdio request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * @qdio: request queue where to start putting the request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @q_req: the qdio request to start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * @req_id: The request id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * @sbtype: type flags to set for all sbals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @data: First data block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * @len: Length of first data block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * This is the start of putting the request into the queue, the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * step is passing the request to zfcp_qdio_send. The request queue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * lock must be held during the whole process from init to send.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) void zfcp_qdio_req_init(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) unsigned long req_id, u8 sbtype, void *data, u32 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct qdio_buffer_element *sbale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int count = min(atomic_read(&qdio->req_q_free),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) ZFCP_QDIO_MAX_SBALS_PER_REQ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) q_req->sbal_first = q_req->sbal_last = qdio->req_q_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) q_req->sbal_number = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) q_req->sbtype = sbtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) q_req->sbale_curr = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) q_req->sbal_limit = (q_req->sbal_first + count - 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) % QDIO_MAX_BUFFERS_PER_Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) sbale = zfcp_qdio_sbale_req(qdio, q_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) sbale->addr = req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) sbale->eflags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) sbale->sflags = SBAL_SFLAGS0_COMMAND | sbtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (unlikely(!data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) sbale++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) sbale->addr = virt_to_phys(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) sbale->length = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * zfcp_qdio_fill_next - Fill next sbale, only for single sbal requests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * @q_req: pointer to struct zfcp_queue_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * @data: pointer to data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * @len: length of data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * This is only required for single sbal requests, calling it when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) * wrapping around to the next sbal is a bug.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) void zfcp_qdio_fill_next(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) void *data, u32 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) struct qdio_buffer_element *sbale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) BUG_ON(q_req->sbale_curr == qdio->max_sbale_per_sbal - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) q_req->sbale_curr++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) sbale = zfcp_qdio_sbale_curr(qdio, q_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) sbale->addr = virt_to_phys(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) sbale->length = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * zfcp_qdio_set_sbale_last - set last entry flag in current sbale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * @q_req: pointer to struct zfcp_queue_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void zfcp_qdio_set_sbale_last(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct zfcp_qdio_req *q_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) struct qdio_buffer_element *sbale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) sbale = zfcp_qdio_sbale_curr(qdio, q_req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) sbale->eflags |= SBAL_EFLAGS_LAST_ENTRY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * zfcp_qdio_sg_one_sbal - check if one sbale is enough for sg data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * @sg: The scatterlist where to check the data size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * Returns: 1 when one sbale is enough for the data in the scatterlist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * 0 if not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int zfcp_qdio_sg_one_sbale(struct scatterlist *sg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) return sg_is_last(sg) && sg->length <= ZFCP_QDIO_SBALE_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * zfcp_qdio_skip_to_last_sbale - skip to last sbale in sbal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * @q_req: The current zfcp_qdio_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) void zfcp_qdio_skip_to_last_sbale(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct zfcp_qdio_req *q_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) q_req->sbale_curr = qdio->max_sbale_per_sbal - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * zfcp_qdio_sbal_limit - set the sbal limit for a request in q_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * @q_req: The current zfcp_qdio_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * @max_sbals: maximum number of SBALs allowed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) void zfcp_qdio_sbal_limit(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct zfcp_qdio_req *q_req, int max_sbals)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) int count = min(atomic_read(&qdio->req_q_free), max_sbals);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) q_req->sbal_limit = (q_req->sbal_first + count - 1) %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) QDIO_MAX_BUFFERS_PER_Q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * zfcp_qdio_set_data_div - set data division count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * @q_req: The current zfcp_qdio_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * @count: The data division count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) void zfcp_qdio_set_data_div(struct zfcp_qdio *qdio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct zfcp_qdio_req *q_req, u32 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct qdio_buffer_element *sbale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) sbale = qdio->req_q[q_req->sbal_first]->element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) sbale->length = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * zfcp_qdio_real_bytes - count bytes used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * @sg: pointer to struct scatterlist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) unsigned int zfcp_qdio_real_bytes(struct scatterlist *sg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) unsigned int real_bytes = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) for (; sg; sg = sg_next(sg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) real_bytes += sg->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) return real_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * zfcp_qdio_set_scount - set SBAL count value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) * @qdio: pointer to struct zfcp_qdio
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * @q_req: The current zfcp_qdio_req
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) void zfcp_qdio_set_scount(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) struct qdio_buffer_element *sbale;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) sbale = qdio->req_q[q_req->sbal_first]->element;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) sbale->scount = q_req->sbal_number - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #endif /* ZFCP_QDIO_H */