Lines Matching refs:call
23 bool rxrpc_propose_abort(struct rxrpc_call *call, s32 abort_code, int error,
26 _enter("{%d},%d,%d,%u", call->debug_id, abort_code, error, why);
28 if (!call->send_abort && !rxrpc_call_is_complete(call)) {
29 call->send_abort_why = why;
30 call->send_abort_err = error;
31 call->send_abort_seq = 0;
32 trace_rxrpc_abort_call(call, abort_code);
34 smp_store_release(&call->send_abort, abort_code);
35 rxrpc_poke_call(call, rxrpc_call_poke_abort);
43 * Wait for a call to become connected. Interruption here doesn't cause the
44 * call to be aborted.
46 static int rxrpc_wait_to_be_connected(struct rxrpc_call *call, long *timeo)
51 _enter("%d", call->debug_id);
53 if (rxrpc_call_state(call) != RXRPC_CALL_CLIENT_AWAIT_CONN)
56 add_wait_queue_exclusive(&call->waitq, &myself);
59 switch (call->interruptibility) {
70 if (rxrpc_call_state(call) != RXRPC_CALL_CLIENT_AWAIT_CONN)
72 if ((call->interruptibility == RXRPC_INTERRUPTIBLE ||
73 call->interruptibility == RXRPC_PREINTERRUPTIBLE) &&
81 remove_wait_queue(&call->waitq, &myself);
85 if (ret == 0 && rxrpc_call_is_complete(call))
86 ret = call->error;
95 static bool rxrpc_check_tx_space(struct rxrpc_call *call, rxrpc_seq_t *_tx_win)
97 rxrpc_seq_t tx_bottom = READ_ONCE(call->tx_bottom);
101 return call->send_top - tx_bottom < 256;
108 struct rxrpc_call *call,
113 if (rxrpc_check_tx_space(call, NULL))
116 if (rxrpc_call_is_complete(call))
117 return call->error;
122 trace_rxrpc_txqueue(call, rxrpc_txqueue_wait);
132 struct rxrpc_call *call)
137 rtt = READ_ONCE(call->srtt_us) >> 3;
143 tx_start = READ_ONCE(call->tx_bottom);
148 if (rxrpc_check_tx_space(call, &tx_win))
151 if (rxrpc_call_is_complete(call))
152 return call->error;
163 trace_rxrpc_txqueue(call, rxrpc_txqueue_wait);
172 struct rxrpc_call *call,
177 if (rxrpc_check_tx_space(call, NULL))
180 if (rxrpc_call_is_complete(call))
181 return call->error;
183 trace_rxrpc_txqueue(call, rxrpc_txqueue_wait);
193 struct rxrpc_call *call,
201 call->tx_bottom, call->tx_top, call->tx_winsize);
203 add_wait_queue(&call->waitq, &myself);
205 switch (call->interruptibility) {
208 ret = rxrpc_wait_for_tx_window_waitall(rx, call);
210 ret = rxrpc_wait_for_tx_window_intr(rx, call, timeo);
215 ret = rxrpc_wait_for_tx_window_nonintr(rx, call, timeo);
219 remove_wait_queue(&call->waitq, &myself);
226 * Notify the owner of the call that the transmit phase is ended and the last
229 static void rxrpc_notify_end_tx(struct rxrpc_sock *rx, struct rxrpc_call *call,
233 notify_end_tx(&rx->sk, call, call->user_call_ID);
241 static void rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
245 struct rxrpc_txqueue *sq = call->send_queue;
249 rxrpc_inc_stat(call->rxnet, stat_tx_data);
251 ASSERTCMP(txb->seq, ==, call->send_top + 1);
254 trace_rxrpc_txqueue(call, rxrpc_txqueue_queue_last);
256 trace_rxrpc_txqueue(call, rxrpc_txqueue_queue);
259 trace_rxrpc_tq(call, sq, seq, rxrpc_tq_queue_dup);
261 trace_rxrpc_tq(call, sq, seq, rxrpc_tq_queue);
263 /* Add the packet to the call's output buffer */
264 poke = (READ_ONCE(call->tx_bottom) == call->send_top);
267 smp_store_release(&call->send_top, seq);
269 set_bit(RXRPC_CALL_TX_NO_MORE, &call->flags);
270 rxrpc_notify_end_tx(rx, call, notify_end_tx);
271 call->send_queue = NULL;
275 rxrpc_poke_call(call, rxrpc_call_poke_start);
281 static int rxrpc_alloc_txqueue(struct sock *sk, struct rxrpc_call *call)
293 if (call->send_queue) {
294 tq->qbase = call->send_top + 1;
295 call->send_queue->next = tq;
296 call->send_queue = tq;
297 } else if (WARN_ON(call->tx_queue)) {
305 call->tx_qbase = 0;
306 call->send_queue = tq;
307 call->tx_qtail = tq;
308 call->tx_queue = tq;
311 trace_rxrpc_tq(call, tq, call->send_top, rxrpc_tq_alloc);
318 * - The caller holds the call user access mutex, but not the socket lock.
321 struct rxrpc_call *call,
333 if (test_bit(RXRPC_CALL_TX_NO_MORE, &call->flags)) {
334 trace_rxrpc_abort(call->debug_id, rxrpc_sendmsg_late_send,
335 call->cid, call->call_id, call->rx_consumed,
342 ret = rxrpc_wait_to_be_connected(call, &timeo);
346 if (call->conn->state == RXRPC_CONN_CLIENT_UNSECURED) {
347 ret = rxrpc_init_client_conn_security(call->conn);
356 txb = call->tx_pending;
357 call->tx_pending = NULL;
364 state = rxrpc_call_state(call);
372 /* Request phase complete for this client call */
373 trace_rxrpc_abort(call->debug_id, rxrpc_sendmsg_late_send,
374 call->cid, call->call_id, call->rx_consumed,
380 if (call->tx_total_len != -1) {
381 if (len - copied > call->tx_total_len)
383 if (!more && len - copied != call->tx_total_len)
393 if (!rxrpc_check_tx_space(call, NULL))
397 if (!call->send_queue || !((call->send_top + 1) & RXRPC_TXQ_MASK)) {
398 ret = rxrpc_alloc_txqueue(sk, call);
408 txb = call->conn->security->alloc_txbuf(call, remain, sk->sk_allocation);
430 if (call->tx_total_len != -1)
431 call->tx_total_len -= copy;
434 /* check for the far side aborting the call or a network error
436 if (rxrpc_call_is_complete(call))
445 ret = call->security->secure_packet(call, txb);
448 rxrpc_queue_packet(rx, call, txb, notify_end_tx);
455 if (rxrpc_call_is_complete(call) &&
456 call->error < 0)
457 ret = call->error;
459 call->tx_pending = txb;
465 _leave(" = %d", call->error);
466 return call->error;
481 mutex_unlock(&call->user_mutex);
483 ret = rxrpc_wait_for_tx_window(rx, call, &timeo,
487 if (call->interruptibility == RXRPC_INTERRUPTIBLE) {
488 if (mutex_lock_interruptible(&call->user_mutex) < 0) {
493 mutex_lock(&call->user_mutex);
527 p->call.user_call_ID = *(u32 *)CMSG_DATA(cmsg);
531 p->call.user_call_ID = *(unsigned long *)
569 if (p->call.tx_total_len != -1 || len != sizeof(__s64))
571 p->call.tx_total_len = *(__s64 *)CMSG_DATA(cmsg);
572 if (p->call.tx_total_len < 0)
579 memcpy(&p->call.timeouts, CMSG_DATA(cmsg), len);
580 p->call.nr_timeouts = len / 4;
581 if (p->call.timeouts.hard > INT_MAX / HZ)
583 if (p->call.nr_timeouts >= 2 && p->call.timeouts.idle > 60 * 60 * 1000)
585 if (p->call.nr_timeouts >= 3 && p->call.timeouts.normal > 60 * 60 * 1000)
596 if (p->call.tx_total_len != -1 && p->command != RXRPC_CMD_SEND_DATA)
603 * Create a new client call for sendmsg().
605 * - If it returns a call, the call's lock will need releasing by the caller.
611 __acquires(&call->user_mutex)
615 struct rxrpc_call *call;
645 call = rxrpc_new_client_call(rx, &cp, &p->call, GFP_KERNEL,
650 _leave(" = %p\n", call);
651 return call;
655 * send a message forming part of a client call through an RxRPC socket
661 struct rxrpc_call *call;
666 .call.tx_total_len = -1,
667 .call.user_call_ID = 0,
668 .call.nr_timeouts = 0,
669 .call.interruptibility = RXRPC_INTERRUPTIBLE,
686 ret = rxrpc_user_charge_accept(rx, p.call.user_call_ID);
690 call = rxrpc_find_call_by_user_ID(rx, p.call.user_call_ID);
691 if (!call) {
695 call = rxrpc_new_client_call_for_sendmsg(rx, msg, &p);
697 if (IS_ERR(call))
698 return PTR_ERR(call);
699 /* ... and we have the call lock. */
700 p.call.nr_timeouts = 0;
702 if (rxrpc_call_is_complete(call))
705 switch (rxrpc_call_state(call)) {
713 rxrpc_put_call(call, rxrpc_call_put_sendmsg);
720 ret = mutex_lock_interruptible(&call->user_mutex);
727 if (p.call.tx_total_len != -1) {
729 if (call->tx_total_len != -1 ||
730 call->tx_pending ||
731 call->tx_top != 0)
733 call->tx_total_len = p.call.tx_total_len;
737 switch (p.call.nr_timeouts) {
739 WRITE_ONCE(call->next_rx_timo, p.call.timeouts.normal);
742 WRITE_ONCE(call->next_req_timo, p.call.timeouts.idle);
745 if (p.call.timeouts.hard > 0) {
746 ktime_t delay = ms_to_ktime(p.call.timeouts.hard * MSEC_PER_SEC);
748 WRITE_ONCE(call->expect_term_by,
749 ktime_add(p.call.timeouts.hard,
751 trace_rxrpc_timer_set(call, delay, rxrpc_timer_trace_hard);
752 rxrpc_poke_call(call, rxrpc_call_poke_set_timeout);
758 if (rxrpc_call_is_complete(call)) {
759 /* it's too late for this call */
766 rxrpc_propose_abort(call, p.abort_code, -ECONNABORTED,
771 ret = rxrpc_send_data(rx, call, msg, len, NULL, &dropped_lock);
780 mutex_unlock(&call->user_mutex);
782 rxrpc_put_call(call, rxrpc_call_put_sendmsg);
792 * rxrpc_kernel_send_data - Allow a kernel service to send data on a call
793 * @sock: The socket the call is on
794 * @call: The call to send data through
799 * Allow a kernel service to send data on a call. The call must be in an state
806 int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
813 _enter("{%d},", call->debug_id);
818 mutex_lock(&call->user_mutex);
820 ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len,
823 ret = call->error;
826 mutex_unlock(&call->user_mutex);
833 * rxrpc_kernel_abort_call - Allow a kernel service to abort a call
834 * @sock: The socket the call is on
835 * @call: The call to be aborted
840 * Allow a kernel service to abort a call if it's still in an abortable state.
842 * Return: %true if the call was aborted, %false if it was already complete.
844 bool rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call,
849 _enter("{%d},%d,%d,%u", call->debug_id, abort_code, error, why);
851 mutex_lock(&call->user_mutex);
852 aborted = rxrpc_propose_abort(call, abort_code, error, why);
853 mutex_unlock(&call->user_mutex);
859 * rxrpc_kernel_set_tx_length - Set the total Tx length on a call
860 * @sock: The socket the call is on
861 * @call: The call to be informed
862 * @tx_total_len: The amount of data to be transmitted for this call
864 * Allow a kernel service to set the total transmit length on a call. This
868 * request length can be set when beginning the call.
870 void rxrpc_kernel_set_tx_length(struct socket *sock, struct rxrpc_call *call,
873 WARN_ON(call->tx_total_len != -1);
874 call->tx_total_len = tx_total_len;