Lines Matching refs:call
23 static bool rxrpc_check_tx_space(struct rxrpc_call *call, rxrpc_seq_t *_tx_win)
26 min_t(unsigned int, call->tx_winsize,
27 call->cong_cwnd + call->cong_extra);
28 rxrpc_seq_t tx_win = READ_ONCE(call->tx_hard_ack);
32 return call->tx_top - tx_win < win_size;
39 struct rxrpc_call *call,
44 if (rxrpc_check_tx_space(call, NULL))
47 if (call->state >= RXRPC_CALL_COMPLETE)
48 return call->error;
53 trace_rxrpc_transmit(call, rxrpc_transmit_wait);
63 struct rxrpc_call *call)
68 rtt = READ_ONCE(call->peer->srtt_us) >> 3;
74 tx_start = READ_ONCE(call->tx_hard_ack);
79 tx_win = READ_ONCE(call->tx_hard_ack);
80 if (rxrpc_check_tx_space(call, &tx_win))
83 if (call->state >= RXRPC_CALL_COMPLETE)
84 return call->error;
95 trace_rxrpc_transmit(call, rxrpc_transmit_wait);
104 struct rxrpc_call *call,
109 if (rxrpc_check_tx_space(call, NULL))
112 if (call->state >= RXRPC_CALL_COMPLETE)
113 return call->error;
115 trace_rxrpc_transmit(call, rxrpc_transmit_wait);
125 struct rxrpc_call *call,
133 call->tx_hard_ack, call->tx_top, call->tx_winsize);
135 add_wait_queue(&call->waitq, &myself);
137 switch (call->interruptibility) {
140 ret = rxrpc_wait_for_tx_window_waitall(rx, call);
142 ret = rxrpc_wait_for_tx_window_intr(rx, call, timeo);
147 ret = rxrpc_wait_for_tx_window_nonintr(rx, call, timeo);
151 remove_wait_queue(&call->waitq, &myself);
160 static inline void rxrpc_instant_resend(struct rxrpc_call *call, int ix)
162 spin_lock_bh(&call->lock);
164 if (call->state < RXRPC_CALL_COMPLETE) {
165 call->rxtx_annotations[ix] =
166 (call->rxtx_annotations[ix] & RXRPC_TX_ANNO_LAST) |
168 if (!test_and_set_bit(RXRPC_CALL_EV_RESEND, &call->events))
169 rxrpc_queue_call(call);
172 spin_unlock_bh(&call->lock);
176 * Notify the owner of the call that the transmit phase is ended and the last
179 static void rxrpc_notify_end_tx(struct rxrpc_sock *rx, struct rxrpc_call *call,
183 notify_end_tx(&rx->sk, call, call->user_call_ID);
191 static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
203 ASSERTCMP(seq, ==, call->tx_top + 1);
215 call->rxtx_annotations[ix] = annotation;
217 call->rxtx_buffer[ix] = skb;
218 call->tx_top = seq;
220 trace_rxrpc_transmit(call, rxrpc_transmit_queue_last);
222 trace_rxrpc_transmit(call, rxrpc_transmit_queue);
224 if (last || call->state == RXRPC_CALL_SERVER_ACK_REQUEST) {
226 write_lock_bh(&call->state_lock);
227 switch (call->state) {
229 call->state = RXRPC_CALL_CLIENT_AWAIT_REPLY;
230 rxrpc_notify_end_tx(rx, call, notify_end_tx);
233 call->state = RXRPC_CALL_SERVER_SEND_REPLY;
235 WRITE_ONCE(call->ack_at, now + MAX_JIFFY_OFFSET);
236 if (call->ackr_reason == RXRPC_ACK_DELAY)
237 call->ackr_reason = 0;
238 trace_rxrpc_timer(call, rxrpc_timer_init_for_send_reply, now);
243 call->state = RXRPC_CALL_SERVER_AWAIT_ACK;
244 rxrpc_notify_end_tx(rx, call, notify_end_tx);
249 write_unlock_bh(&call->state_lock);
252 if (seq == 1 && rxrpc_is_client_call(call))
253 rxrpc_expose_client_call(call);
255 ret = rxrpc_send_data_packet(call, skb, false);
261 rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR,
266 rxrpc_instant_resend(call, ix);
269 unsigned long resend_at = now + call->peer->rto_j;
271 WRITE_ONCE(call->resend_at, resend_at);
272 rxrpc_reduce_call_timer(call, resend_at, now,
285 * - The caller holds the call user access mutex, but not the socket lock.
288 struct rxrpc_call *call,
310 state = READ_ONCE(call->state);
321 if (call->tx_total_len != -1) {
322 if (len - copied > call->tx_total_len)
324 if (!more && len - copied != call->tx_total_len)
328 skb = call->tx_pending;
329 call->tx_pending = NULL;
334 if (call->ackr_reason == RXRPC_ACK_PING_RESPONSE)
335 rxrpc_send_ack_packet(call, false, NULL);
342 if (!rxrpc_check_tx_space(call, NULL))
346 max -= call->conn->security_size;
347 max &= ~(call->conn->size_align - 1UL);
353 space = chunk + call->conn->size_align;
354 space &= ~(call->conn->size_align - 1UL);
356 size = space + call->conn->security_size;
374 _debug("HS: %u", call->conn->security_size);
375 skb_reserve(skb, call->conn->security_size);
376 skb->len += call->conn->security_size;
411 if (call->tx_total_len != -1)
412 call->tx_total_len -= copy;
415 /* check for the far side aborting the call or a network error
417 if (call->state == RXRPC_CALL_COMPLETE)
423 struct rxrpc_connection *conn = call->conn;
437 seq = call->tx_top + 1;
445 else if (call->tx_top - call->tx_hard_ack <
446 call->tx_winsize)
449 ret = call->security->secure_packet(
450 call, skb, skb->mark, skb->head);
454 ret = rxrpc_queue_packet(rx, call, skb,
464 if (READ_ONCE(call->state) == RXRPC_CALL_COMPLETE) {
465 read_lock_bh(&call->state_lock);
466 if (call->error < 0)
467 ret = call->error;
468 read_unlock_bh(&call->state_lock);
471 call->tx_pending = skb;
477 _leave(" = %d", call->error);
478 return call->error;
493 mutex_unlock(&call->user_mutex);
495 ret = rxrpc_wait_for_tx_window(rx, call, &timeo,
499 if (call->interruptibility == RXRPC_INTERRUPTIBLE) {
500 if (mutex_lock_interruptible(&call->user_mutex) < 0) {
505 mutex_lock(&call->user_mutex);
539 p->call.user_call_ID = *(u32 *)CMSG_DATA(cmsg);
543 p->call.user_call_ID = *(unsigned long *)
581 if (p->call.tx_total_len != -1 || len != sizeof(__s64))
583 p->call.tx_total_len = *(__s64 *)CMSG_DATA(cmsg);
584 if (p->call.tx_total_len < 0)
591 memcpy(&p->call.timeouts, CMSG_DATA(cmsg), len);
592 p->call.nr_timeouts = len / 4;
593 if (p->call.timeouts.hard > INT_MAX / HZ)
595 if (p->call.nr_timeouts >= 2 && p->call.timeouts.idle > 60 * 60 * 1000)
597 if (p->call.nr_timeouts >= 3 && p->call.timeouts.normal > 60 * 60 * 1000)
608 if (p->call.tx_total_len != -1 && p->command != RXRPC_CMD_SEND_DATA)
615 * Create a new client call for sendmsg().
617 * - If it returns a call, the call's lock will need releasing by the caller.
623 __acquires(&call->user_mutex)
626 struct rxrpc_call *call;
649 call = rxrpc_new_client_call(rx, &cp, srx, &p->call, GFP_KERNEL,
654 _leave(" = %p\n", call);
655 return call;
659 * send a message forming part of a client call through an RxRPC socket
665 __releases(&call->user_mutex)
668 struct rxrpc_call *call;
674 .call.tx_total_len = -1,
675 .call.user_call_ID = 0,
676 .call.nr_timeouts = 0,
677 .call.interruptibility = RXRPC_INTERRUPTIBLE,
694 ret = rxrpc_user_charge_accept(rx, p.call.user_call_ID);
698 call = rxrpc_find_call_by_user_ID(rx, p.call.user_call_ID);
699 if (!call) {
703 call = rxrpc_new_client_call_for_sendmsg(rx, msg, &p);
705 if (IS_ERR(call))
706 return PTR_ERR(call);
707 /* ... and we have the call lock. */
709 if (READ_ONCE(call->state) == RXRPC_CALL_COMPLETE)
712 switch (READ_ONCE(call->state)) {
717 rxrpc_put_call(call, rxrpc_call_put);
724 ret = mutex_lock_interruptible(&call->user_mutex);
731 if (p.call.tx_total_len != -1) {
733 if (call->tx_total_len != -1 ||
734 call->tx_pending ||
735 call->tx_top != 0)
737 call->tx_total_len = p.call.tx_total_len;
741 switch (p.call.nr_timeouts) {
743 j = msecs_to_jiffies(p.call.timeouts.normal);
744 if (p.call.timeouts.normal > 0 && j == 0)
746 WRITE_ONCE(call->next_rx_timo, j);
749 j = msecs_to_jiffies(p.call.timeouts.idle);
750 if (p.call.timeouts.idle > 0 && j == 0)
752 WRITE_ONCE(call->next_req_timo, j);
755 if (p.call.timeouts.hard > 0) {
756 j = p.call.timeouts.hard * HZ;
759 WRITE_ONCE(call->expect_term_by, j);
760 rxrpc_reduce_call_timer(call, j, now,
766 state = READ_ONCE(call->state);
768 call->debug_id, call->user_call_ID, state, call->conn);
771 /* it's too late for this call */
775 if (rxrpc_abort_call("CMD", call, 0, p.abort_code, -ECONNABORTED))
776 ret = rxrpc_send_abort_packet(call);
780 ret = rxrpc_send_data(rx, call, msg, len, NULL, &dropped_lock);
785 mutex_unlock(&call->user_mutex);
787 rxrpc_put_call(call, rxrpc_call_put);
797 * rxrpc_kernel_send_data - Allow a kernel service to send data on a call
798 * @sock: The socket the call is on
799 * @call: The call to send data through
804 * Allow a kernel service to send data on a call. The call must be in an state
809 int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
816 _enter("{%d,%s},", call->debug_id, rxrpc_call_states[call->state]);
821 mutex_lock(&call->user_mutex);
824 call->debug_id, call->user_call_ID, call->state, call->conn);
826 switch (READ_ONCE(call->state)) {
830 ret = rxrpc_send_data(rxrpc_sk(sock->sk), call, msg, len,
834 read_lock_bh(&call->state_lock);
835 ret = call->error;
836 read_unlock_bh(&call->state_lock);
839 /* Request phase complete for this client call */
840 trace_rxrpc_rx_eproto(call, 0, tracepoint_string("late_send"));
846 mutex_unlock(&call->user_mutex);
853 * rxrpc_kernel_abort_call - Allow a kernel service to abort a call
854 * @sock: The socket the call is on
855 * @call: The call to be aborted
860 * Allow a kernel service to abort a call, if it's still in an abortable state
861 * and return true if the call was aborted, false if it was already complete.
863 bool rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call,
868 _enter("{%d},%d,%d,%s", call->debug_id, abort_code, error, why);
870 mutex_lock(&call->user_mutex);
872 aborted = rxrpc_abort_call(why, call, 0, abort_code, error);
874 rxrpc_send_abort_packet(call);
876 mutex_unlock(&call->user_mutex);
882 * rxrpc_kernel_set_tx_length - Set the total Tx length on a call
883 * @sock: The socket the call is on
884 * @call: The call to be informed
885 * @tx_total_len: The amount of data to be transmitted for this call
887 * Allow a kernel service to set the total transmit length on a call. This
891 * request length can be set when beginning the call.
893 void rxrpc_kernel_set_tx_length(struct socket *sock, struct rxrpc_call *call,
896 WARN_ON(call->tx_total_len != -1);
897 call->tx_total_len = tx_total_len;