Lines Matching +full:rx +full:- +full:sched +full:- +full:sp

1 // SPDX-License-Identifier: GPL-2.0-or-later
13 #include <linux/sched/signal.h>
17 #include "ar-internal.h"
25 struct rxrpc_sock *rx; in rxrpc_notify_socket() local
28 _enter("%d", call->debug_id); in rxrpc_notify_socket()
30 if (!list_empty(&call->recvmsg_link)) in rxrpc_notify_socket()
35 rx = rcu_dereference(call->socket); in rxrpc_notify_socket()
36 sk = &rx->sk; in rxrpc_notify_socket()
37 if (rx && sk->sk_state < RXRPC_CLOSE) { in rxrpc_notify_socket()
38 if (call->notify_rx) { in rxrpc_notify_socket()
39 spin_lock(&call->notify_lock); in rxrpc_notify_socket()
40 call->notify_rx(sk, call, call->user_call_ID); in rxrpc_notify_socket()
41 spin_unlock(&call->notify_lock); in rxrpc_notify_socket()
43 spin_lock(&rx->recvmsg_lock); in rxrpc_notify_socket()
44 if (list_empty(&call->recvmsg_link)) { in rxrpc_notify_socket()
46 list_add_tail(&call->recvmsg_link, &rx->recvmsg_q); in rxrpc_notify_socket()
48 spin_unlock(&rx->recvmsg_lock); in rxrpc_notify_socket()
51 _debug("call %ps", sk->sk_data_ready); in rxrpc_notify_socket()
52 sk->sk_data_ready(sk); in rxrpc_notify_socket()
69 switch (call->completion) { in rxrpc_recvmsg_term()
76 tmp = call->abort_code; in rxrpc_recvmsg_term()
80 tmp = call->abort_code; in rxrpc_recvmsg_term()
84 tmp = -call->error; in rxrpc_recvmsg_term()
88 tmp = -call->error; in rxrpc_recvmsg_term()
92 pr_err("Invalid terminal call state %u\n", call->completion); in rxrpc_recvmsg_term()
98 call->ackr_window - 1, in rxrpc_recvmsg_term()
99 call->rx_pkt_offset, call->rx_pkt_len, ret); in rxrpc_recvmsg_term()
104 * Discard a packet we've used up and advance the Rx window by one.
108 struct rxrpc_skb_priv *sp; in rxrpc_rotate_rx_window() local
111 rxrpc_seq_t old_consumed = call->rx_consumed, tseq; in rxrpc_rotate_rx_window()
115 _enter("%d", call->debug_id); in rxrpc_rotate_rx_window()
117 skb = skb_dequeue(&call->recvmsg_queue); in rxrpc_rotate_rx_window()
120 sp = rxrpc_skb(skb); in rxrpc_rotate_rx_window()
121 tseq = sp->hdr.seq; in rxrpc_rotate_rx_window()
122 serial = sp->hdr.serial; in rxrpc_rotate_rx_window()
123 last = sp->hdr.flags & RXRPC_LAST_PACKET; in rxrpc_rotate_rx_window()
126 if (after(tseq, call->rx_consumed)) in rxrpc_rotate_rx_window()
127 smp_store_release(&call->rx_consumed, tseq); in rxrpc_rotate_rx_window()
132 serial, call->rx_consumed); in rxrpc_rotate_rx_window()
135 set_bit(RXRPC_CALL_RECVMSG_READ_ALL, &call->flags); in rxrpc_rotate_rx_window()
138 acked = atomic_add_return(call->rx_consumed - old_consumed, in rxrpc_rotate_rx_window()
139 &call->ackr_nr_consumed); in rxrpc_rotate_rx_window()
141 !test_and_set_bit(RXRPC_CALL_RX_IS_IDLE, &call->flags)) in rxrpc_rotate_rx_window()
150 struct rxrpc_skb_priv *sp = rxrpc_skb(skb); in rxrpc_verify_data() local
152 if (sp->flags & RXRPC_RX_VERIFIED) in rxrpc_verify_data()
154 return call->security->verify_packet(call, skb); in rxrpc_verify_data()
160 * (returns 1). If more packets are required, it returns -EAGAIN and if the
161 * call has failed it returns -EIO.
167 struct rxrpc_skb_priv *sp; in rxrpc_recvmsg_data() local
172 int copy, ret = -EAGAIN, ret2; in rxrpc_recvmsg_data()
174 rx_pkt_offset = call->rx_pkt_offset; in rxrpc_recvmsg_data()
175 rx_pkt_len = call->rx_pkt_len; in rxrpc_recvmsg_data()
178 seq = call->ackr_window - 1; in rxrpc_recvmsg_data()
179 ret = -EIO; in rxrpc_recvmsg_data()
183 if (test_bit(RXRPC_CALL_RECVMSG_READ_ALL, &call->flags)) { in rxrpc_recvmsg_data()
184 seq = call->ackr_window - 1; in rxrpc_recvmsg_data()
190 * need the Rx lock to walk it. in rxrpc_recvmsg_data()
192 skb = skb_peek(&call->recvmsg_queue); in rxrpc_recvmsg_data()
195 sp = rxrpc_skb(skb); in rxrpc_recvmsg_data()
196 seq = sp->hdr.seq; in rxrpc_recvmsg_data()
200 sp->hdr.serial, seq); in rxrpc_recvmsg_data()
203 sock_recv_timestamp(msg, sock->sk, skb); in rxrpc_recvmsg_data()
208 sp->offset, sp->len, ret2); in rxrpc_recvmsg_data()
214 rx_pkt_offset = sp->offset; in rxrpc_recvmsg_data()
215 rx_pkt_len = sp->len; in rxrpc_recvmsg_data()
221 /* We have to handle short, empty and used-up DATA packets. */ in rxrpc_recvmsg_data()
222 remain = len - *_offset; in rxrpc_recvmsg_data()
236 rx_pkt_len -= copy; in rxrpc_recvmsg_data()
249 if (sp->hdr.flags & RXRPC_LAST_PACKET) in rxrpc_recvmsg_data()
254 skb = skb_peek_next(skb, &call->recvmsg_queue); in rxrpc_recvmsg_data()
262 call->rx_pkt_offset = rx_pkt_offset; in rxrpc_recvmsg_data()
263 call->rx_pkt_len = rx_pkt_len; in rxrpc_recvmsg_data()
268 if (ret == -EAGAIN) in rxrpc_recvmsg_data()
269 set_bit(RXRPC_CALL_RX_IS_IDLE, &call->flags); in rxrpc_recvmsg_data()
275 * - we need to be careful about two or more threads calling recvmsg
282 struct rxrpc_sock *rx = rxrpc_sk(sock->sk); in rxrpc_recvmsg() local
294 return -EOPNOTSUPP; in rxrpc_recvmsg()
296 timeo = sock_rcvtimeo(&rx->sk, flags & MSG_DONTWAIT); in rxrpc_recvmsg()
299 lock_sock(&rx->sk); in rxrpc_recvmsg()
302 if (RB_EMPTY_ROOT(&rx->calls) && in rxrpc_recvmsg()
303 list_empty(&rx->recvmsg_q) && in rxrpc_recvmsg()
304 rx->sk.sk_state != RXRPC_SERVER_LISTENING) { in rxrpc_recvmsg()
305 release_sock(&rx->sk); in rxrpc_recvmsg()
306 return -EAGAIN; in rxrpc_recvmsg()
309 if (list_empty(&rx->recvmsg_q)) { in rxrpc_recvmsg()
310 ret = -EWOULDBLOCK; in rxrpc_recvmsg()
316 release_sock(&rx->sk); in rxrpc_recvmsg()
319 prepare_to_wait_exclusive(sk_sleep(&rx->sk), &wait, in rxrpc_recvmsg()
321 ret = sock_error(&rx->sk); in rxrpc_recvmsg()
325 if (list_empty(&rx->recvmsg_q)) { in rxrpc_recvmsg()
331 finish_wait(sk_sleep(&rx->sk), &wait); in rxrpc_recvmsg()
340 spin_lock(&rx->recvmsg_lock); in rxrpc_recvmsg()
341 l = rx->recvmsg_q.next; in rxrpc_recvmsg()
345 skb_queue_empty(&call->recvmsg_queue)) { in rxrpc_recvmsg()
346 list_del_init(&call->recvmsg_link); in rxrpc_recvmsg()
347 spin_unlock(&rx->recvmsg_lock); in rxrpc_recvmsg()
348 release_sock(&rx->sk); in rxrpc_recvmsg()
349 trace_rxrpc_recvmsg(call->debug_id, rxrpc_recvmsg_unqueue, 0); in rxrpc_recvmsg()
355 list_del_init(&call->recvmsg_link); in rxrpc_recvmsg()
358 spin_unlock(&rx->recvmsg_lock); in rxrpc_recvmsg()
360 call_debug_id = call->debug_id; in rxrpc_recvmsg()
366 if (!mutex_trylock(&call->user_mutex)) { in rxrpc_recvmsg()
367 ret = -EWOULDBLOCK; in rxrpc_recvmsg()
370 ret = -ERESTARTSYS; in rxrpc_recvmsg()
371 if (mutex_lock_interruptible(&call->user_mutex) < 0) in rxrpc_recvmsg()
375 release_sock(&rx->sk); in rxrpc_recvmsg()
377 if (test_bit(RXRPC_CALL_RELEASED, &call->flags)) in rxrpc_recvmsg()
380 if (test_bit(RXRPC_CALL_HAS_USERID, &call->flags)) { in rxrpc_recvmsg()
382 unsigned int id32 = call->user_call_ID; in rxrpc_recvmsg()
387 unsigned long idl = call->user_call_ID; in rxrpc_recvmsg()
396 if (msg->msg_name && call->peer) { in rxrpc_recvmsg()
397 size_t len = sizeof(call->dest_srx); in rxrpc_recvmsg()
399 memcpy(msg->msg_name, &call->dest_srx, len); in rxrpc_recvmsg()
400 msg->msg_namelen = len; in rxrpc_recvmsg()
403 ret = rxrpc_recvmsg_data(sock, call, msg, &msg->msg_iter, len, in rxrpc_recvmsg()
405 if (ret == -EAGAIN) in rxrpc_recvmsg()
407 if (ret == -EIO) in rxrpc_recvmsg()
413 skb_queue_empty(&call->recvmsg_queue)) in rxrpc_recvmsg()
418 if (!skb_queue_empty(&call->recvmsg_queue)) in rxrpc_recvmsg()
423 rxrpc_purge_queue(&call->recvmsg_queue); in rxrpc_recvmsg()
429 rxrpc_release_call(rx, call); in rxrpc_recvmsg()
430 msg->msg_flags |= MSG_EOR; in rxrpc_recvmsg()
435 msg->msg_flags |= MSG_MORE; in rxrpc_recvmsg()
437 msg->msg_flags &= ~MSG_MORE; in rxrpc_recvmsg()
441 mutex_unlock(&call->user_mutex); in rxrpc_recvmsg()
448 spin_lock(&rx->recvmsg_lock); in rxrpc_recvmsg()
449 list_add(&call->recvmsg_link, &rx->recvmsg_q); in rxrpc_recvmsg()
450 spin_unlock(&rx->recvmsg_lock); in rxrpc_recvmsg()
456 release_sock(&rx->sk); in rxrpc_recvmsg()
464 finish_wait(sk_sleep(&rx->sk), &wait); in rxrpc_recvmsg()
470 * rxrpc_kernel_recv_data - Allow a kernel service to receive data/info
476 * @_abort: Where the abort code is stored if -ECONNABORTED is returned
482 * and -EAGAIN if we need more data.
484 * Note that we may return -EAGAIN to drain empty packets at the end of the
496 _enter("{%d},%zu,%d", call->debug_id, *_len, want_more); in rxrpc_kernel_recv_data()
498 mutex_lock(&call->user_mutex); in rxrpc_kernel_recv_data()
501 *_len -= offset; in rxrpc_kernel_recv_data()
502 if (ret == -EIO) in rxrpc_kernel_recv_data()
509 * or have been given -EAGAIN. in rxrpc_kernel_recv_data()
528 *_service = call->dest_srx.srx_service; in rxrpc_kernel_recv_data()
529 mutex_unlock(&call->user_mutex); in rxrpc_kernel_recv_data()
534 trace_rxrpc_abort(call->debug_id, rxrpc_recvmsg_short_data, in rxrpc_kernel_recv_data()
535 call->cid, call->call_id, call->rx_consumed, in rxrpc_kernel_recv_data()
536 0, -EBADMSG); in rxrpc_kernel_recv_data()
537 ret = -EBADMSG; in rxrpc_kernel_recv_data()
540 trace_rxrpc_abort(call->debug_id, rxrpc_recvmsg_excess_data, in rxrpc_kernel_recv_data()
541 call->cid, call->call_id, call->rx_consumed, in rxrpc_kernel_recv_data()
542 0, -EMSGSIZE); in rxrpc_kernel_recv_data()
543 ret = -EMSGSIZE; in rxrpc_kernel_recv_data()
546 *_abort = call->abort_code; in rxrpc_kernel_recv_data()
547 ret = call->error; in rxrpc_kernel_recv_data()
548 if (call->completion == RXRPC_CALL_SUCCEEDED) { in rxrpc_kernel_recv_data()
551 ret = -ECONNRESET; in rxrpc_kernel_recv_data()