Lines Matching +full:read +full:- +full:out
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
68 return ((prod - cons) <= XENSTORE_RING_SIZE); in check_indexes()
75 *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(prod); in get_output_chunk()
76 if ((XENSTORE_RING_SIZE - (prod - cons)) < *len) in get_output_chunk()
77 *len = XENSTORE_RING_SIZE - (prod - cons); in get_output_chunk()
85 *len = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(cons); in get_input_chunk()
86 if ((prod - cons) < *len) in get_input_chunk()
87 *len = prod - cons; in get_input_chunk()
95 return (intf->req_prod - intf->req_cons) != XENSTORE_RING_SIZE && in xb_data_to_write()
100 * xb_write - low level write
104 * Returns number of bytes written or -err.
116 /* Read indexes, then verify. */ in xb_write()
117 cons = intf->req_cons; in xb_write()
118 prod = intf->req_prod; in xb_write()
120 intf->req_cons = intf->req_prod = 0; in xb_write()
121 return -EIO; in xb_write()
129 dst = get_output_chunk(cons, prod, intf->req, &avail); in xb_write()
137 len -= avail; in xb_write()
142 intf->req_prod += avail; in xb_write()
145 if (prod <= intf->req_cons) in xb_write()
155 return (intf->rsp_cons != intf->rsp_prod); in xb_data_to_read()
168 /* Read indexes, then verify. */ in xb_read()
169 cons = intf->rsp_cons; in xb_read()
170 prod = intf->rsp_prod; in xb_read()
175 intf->rsp_cons = intf->rsp_prod = 0; in xb_read()
176 return -EIO; in xb_read()
179 src = get_input_chunk(cons, prod, intf->rsp, &avail); in xb_read()
185 /* Must read data /after/ reading the producer index. */ in xb_read()
190 len -= avail; in xb_read()
193 /* Other side must not see free space until we've copied out */ in xb_read()
195 intf->rsp_cons += avail; in xb_read()
198 if (intf->rsp_prod - cons >= XENSTORE_RING_SIZE) in xb_read()
216 unsigned int read; in process_msg() member
225 state.read = 0; in process_msg()
229 * A partial read across s/r leaves us out of sync with in process_msg()
246 if (state.read != sizeof(state.msg)) { in process_msg()
247 err = xb_read((void *)&state.msg + state.read, in process_msg()
248 sizeof(state.msg) - state.read); in process_msg()
250 goto out; in process_msg()
251 state.read += err; in process_msg()
252 if (state.read != sizeof(state.msg)) in process_msg()
255 err = -EINVAL; in process_msg()
256 goto out; in process_msg()
266 return -ENOMEM; in process_msg()
269 state.body = state.watch->body; in process_msg()
273 state.read = 0; in process_msg()
276 err = xb_read(state.body + state.read, state.msg.len - state.read); in process_msg()
278 goto out; in process_msg()
280 state.read += err; in process_msg()
281 if (state.read != state.msg.len) in process_msg()
287 state.watch->len = state.msg.len; in process_msg()
290 err = -ENOENT; in process_msg()
293 if (req->msg.req_id == state.msg.req_id) { in process_msg()
294 list_del(&req->list); in process_msg()
301 goto out; in process_msg()
303 if (req->state == xb_req_state_wait_reply) { in process_msg()
304 req->msg.req_id = req->caller_req_id; in process_msg()
305 req->msg.type = state.msg.type; in process_msg()
306 req->msg.len = state.msg.len; in process_msg()
307 req->body = state.body; in process_msg()
310 req->state = xb_req_state_got_reply; in process_msg()
311 req->cb(req); in process_msg()
322 out: in process_msg()
349 state.idx = -1; in process_writes()
353 if (state.req->state == xb_req_state_aborted) in process_writes()
356 while (state.idx < state.req->num_vecs) { in process_writes()
358 base = &state.req->msg; in process_writes()
359 len = sizeof(state.req->msg); in process_writes()
361 base = state.req->vec[state.idx].iov_base; in process_writes()
362 len = state.req->vec[state.idx].iov_len; in process_writes()
364 err = xb_write(base + state.written, len - state.written); in process_writes()
369 goto out; in process_writes()
375 list_del(&state.req->list); in process_writes()
376 state.req->state = xb_req_state_wait_reply; in process_writes()
377 list_add_tail(&state.req->list, &xs_reply_list); in process_writes()
380 out: in process_writes()
386 state.req->msg.type = XS_ERROR; in process_writes()
387 state.req->err = err; in process_writes()
388 list_del(&state.req->list); in process_writes()
389 if (state.req->state == xb_req_state_aborted) in process_writes()
394 state.req->state = xb_req_state_got_reply; in process_writes()
395 wake_up(&state.req->wq); in process_writes()
419 if (err == -ENOMEM) in xenbus_thread()
436 * xb_init_comms - Set up interrupt handler off store event channel.
442 if (intf->req_prod != intf->req_cons) in xb_init_comms()
444 intf->req_cons, intf->req_prod); in xb_init_comms()
446 if (intf->rsp_prod != intf->rsp_cons) { in xb_init_comms()
448 intf->rsp_cons, intf->rsp_prod); in xb_init_comms()
451 intf->rsp_cons = intf->rsp_prod; in xb_init_comms()