David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 1 | /* Management of Tx window, Tx resend, ACKs and out-of-sequence reception |
| 2 | * |
| 3 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | */ |
| 11 | |
Joe Perches | 9b6d539 | 2016-06-02 12:08:52 -0700 | [diff] [blame] | 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 13 | |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 14 | #include <linux/module.h> |
| 15 | #include <linux/circ_buf.h> |
| 16 | #include <linux/net.h> |
| 17 | #include <linux/skbuff.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 18 | #include <linux/slab.h> |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 19 | #include <linux/udp.h> |
| 20 | #include <net/sock.h> |
| 21 | #include <net/af_rxrpc.h> |
| 22 | #include "ar-internal.h" |
| 23 | |
David Howells | 5873c08 | 2014-02-07 18:58:44 +0000 | [diff] [blame] | 24 | /* |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 25 | * Set the timer |
| 26 | */ |
David Howells | fc7ab6d | 2016-09-23 15:22:36 +0100 | [diff] [blame] | 27 | void rxrpc_set_timer(struct rxrpc_call *call, enum rxrpc_timer_trace why) |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 28 | { |
| 29 | unsigned long t, now = jiffies; |
| 30 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 31 | read_lock_bh(&call->state_lock); |
| 32 | |
| 33 | if (call->state < RXRPC_CALL_COMPLETE) { |
David Howells | 01a88f7 | 2016-09-23 12:39:22 +0100 | [diff] [blame] | 34 | t = call->expire_at; |
| 35 | if (time_before_eq(t, now)) |
| 36 | goto out; |
| 37 | |
| 38 | if (time_after(call->resend_at, now) && |
| 39 | time_before(call->resend_at, t)) |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 40 | t = call->resend_at; |
David Howells | 01a88f7 | 2016-09-23 12:39:22 +0100 | [diff] [blame] | 41 | |
| 42 | if (time_after(call->ack_at, now) && |
| 43 | time_before(call->ack_at, t)) |
| 44 | t = call->ack_at; |
| 45 | |
| 46 | if (call->timer.expires != t || !timer_pending(&call->timer)) { |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 47 | mod_timer(&call->timer, t); |
David Howells | fc7ab6d | 2016-09-23 15:22:36 +0100 | [diff] [blame] | 48 | trace_rxrpc_timer(call, why, now); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 49 | } |
| 50 | } |
David Howells | 01a88f7 | 2016-09-23 12:39:22 +0100 | [diff] [blame] | 51 | |
| 52 | out: |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 53 | read_unlock_bh(&call->state_lock); |
| 54 | } |
| 55 | |
| 56 | /* |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 57 | * propose an ACK be sent |
| 58 | */ |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 59 | static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, |
| 60 | u16 skew, u32 serial, bool immediate, |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 61 | bool background, |
| 62 | enum rxrpc_propose_ack_trace why) |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 63 | { |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 64 | enum rxrpc_propose_ack_outcome outcome = rxrpc_propose_ack_use; |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 65 | unsigned long now, ack_at, expiry = rxrpc_soft_ack_delay; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 66 | s8 prior = rxrpc_ack_priority[ack_reason]; |
| 67 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 68 | /* Update DELAY, IDLE, REQUESTED and PING_RESPONSE ACK serial |
| 69 | * numbers, but we don't alter the timeout. |
| 70 | */ |
| 71 | _debug("prior %u %u vs %u %u", |
| 72 | ack_reason, prior, |
| 73 | call->ackr_reason, rxrpc_ack_priority[call->ackr_reason]); |
| 74 | if (ack_reason == call->ackr_reason) { |
| 75 | if (RXRPC_ACK_UPDATEABLE & (1 << ack_reason)) { |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 76 | outcome = rxrpc_propose_ack_update; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 77 | call->ackr_serial = serial; |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 78 | call->ackr_skew = skew; |
David Howells | 563ea7d | 2016-08-23 15:27:25 +0100 | [diff] [blame] | 79 | } |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 80 | if (!immediate) |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 81 | goto trace; |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 82 | } else if (prior > rxrpc_ack_priority[call->ackr_reason]) { |
| 83 | call->ackr_reason = ack_reason; |
| 84 | call->ackr_serial = serial; |
| 85 | call->ackr_skew = skew; |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 86 | } else { |
| 87 | outcome = rxrpc_propose_ack_subsume; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 88 | } |
| 89 | |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 90 | switch (ack_reason) { |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 91 | case RXRPC_ACK_REQUESTED: |
| 92 | if (rxrpc_requested_ack_delay < expiry) |
| 93 | expiry = rxrpc_requested_ack_delay; |
| 94 | if (serial == 1) |
| 95 | immediate = false; |
| 96 | break; |
| 97 | |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 98 | case RXRPC_ACK_DELAY: |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 99 | if (rxrpc_soft_ack_delay < expiry) |
| 100 | expiry = rxrpc_soft_ack_delay; |
| 101 | break; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 102 | |
| 103 | case RXRPC_ACK_IDLE: |
David Howells | 91c2c7b | 2016-09-13 22:36:21 +0100 | [diff] [blame] | 104 | if (rxrpc_idle_ack_delay < expiry) |
David Howells | 5873c08 | 2014-02-07 18:58:44 +0000 | [diff] [blame] | 105 | expiry = rxrpc_idle_ack_delay; |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 106 | break; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 107 | |
| 108 | default: |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 109 | immediate = true; |
| 110 | break; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 111 | } |
| 112 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 113 | now = jiffies; |
| 114 | if (test_bit(RXRPC_CALL_EV_ACK, &call->events)) { |
| 115 | _debug("already scheduled"); |
| 116 | } else if (immediate || expiry == 0) { |
| 117 | _debug("immediate ACK %lx", call->events); |
| 118 | if (!test_and_set_bit(RXRPC_CALL_EV_ACK, &call->events) && |
| 119 | background) |
| 120 | rxrpc_queue_call(call); |
| 121 | } else { |
| 122 | ack_at = now + expiry; |
| 123 | _debug("deferred ACK %ld < %ld", expiry, call->ack_at - now); |
| 124 | if (time_before(ack_at, call->ack_at)) { |
| 125 | call->ack_at = ack_at; |
David Howells | fc7ab6d | 2016-09-23 15:22:36 +0100 | [diff] [blame] | 126 | rxrpc_set_timer(call, rxrpc_timer_set_for_ack); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 127 | } |
| 128 | } |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 129 | |
| 130 | trace: |
| 131 | trace_rxrpc_propose_ack(call, why, ack_reason, serial, immediate, |
| 132 | background, outcome); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | /* |
| 136 | * propose an ACK be sent, locking the call structure |
| 137 | */ |
David Howells | 4e36a95 | 2009-09-16 00:01:13 -0700 | [diff] [blame] | 138 | void rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 139 | u16 skew, u32 serial, bool immediate, bool background, |
| 140 | enum rxrpc_propose_ack_trace why) |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 141 | { |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 142 | spin_lock_bh(&call->lock); |
| 143 | __rxrpc_propose_ACK(call, ack_reason, skew, serial, |
David Howells | 9c7ad43 | 2016-09-23 13:50:40 +0100 | [diff] [blame^] | 144 | immediate, background, why); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 145 | spin_unlock_bh(&call->lock); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /* |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 149 | * Perform retransmission of NAK'd and unack'd packets. |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 150 | */ |
| 151 | static void rxrpc_resend(struct rxrpc_call *call) |
| 152 | { |
| 153 | struct rxrpc_skb_priv *sp; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 154 | struct sk_buff *skb; |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 155 | rxrpc_seq_t cursor, seq, top; |
David Howells | fc943f67 | 2016-09-22 00:29:32 +0100 | [diff] [blame] | 156 | ktime_t now = ktime_get_real(), max_age, oldest, resend_at; |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 157 | int ix; |
David Howells | f07373e | 2016-09-22 00:29:32 +0100 | [diff] [blame] | 158 | u8 annotation, anno_type; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 159 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 160 | _enter("{%d,%d}", call->tx_hard_ack, call->tx_top); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 161 | |
David Howells | 50235c4 | 2016-09-22 00:29:31 +0100 | [diff] [blame] | 162 | max_age = ktime_sub_ms(now, rxrpc_resend_timeout); |
| 163 | |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 164 | spin_lock_bh(&call->lock); |
| 165 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 166 | cursor = call->tx_hard_ack; |
| 167 | top = call->tx_top; |
| 168 | ASSERT(before_eq(cursor, top)); |
| 169 | if (cursor == top) |
| 170 | goto out_unlock; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 171 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 172 | /* Scan the packet list without dropping the lock and decide which of |
| 173 | * the packets in the Tx buffer we're going to resend and what the new |
| 174 | * resend timeout will be. |
| 175 | */ |
David Howells | 50235c4 | 2016-09-22 00:29:31 +0100 | [diff] [blame] | 176 | oldest = now; |
David Howells | dfa7d92 | 2016-09-17 10:49:12 +0100 | [diff] [blame] | 177 | for (seq = cursor + 1; before_eq(seq, top); seq++) { |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 178 | ix = seq & RXRPC_RXTX_BUFF_MASK; |
| 179 | annotation = call->rxtx_annotations[ix]; |
David Howells | f07373e | 2016-09-22 00:29:32 +0100 | [diff] [blame] | 180 | anno_type = annotation & RXRPC_TX_ANNO_MASK; |
| 181 | annotation &= ~RXRPC_TX_ANNO_MASK; |
| 182 | if (anno_type == RXRPC_TX_ANNO_ACK) |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 183 | continue; |
| 184 | |
| 185 | skb = call->rxtx_buffer[ix]; |
David Howells | 71f3ca4 | 2016-09-17 10:49:14 +0100 | [diff] [blame] | 186 | rxrpc_see_skb(skb, rxrpc_skb_tx_seen); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 187 | sp = rxrpc_skb(skb); |
| 188 | |
David Howells | f07373e | 2016-09-22 00:29:32 +0100 | [diff] [blame] | 189 | if (anno_type == RXRPC_TX_ANNO_UNACK) { |
David Howells | 50235c4 | 2016-09-22 00:29:31 +0100 | [diff] [blame] | 190 | if (ktime_after(skb->tstamp, max_age)) { |
| 191 | if (ktime_before(skb->tstamp, oldest)) |
| 192 | oldest = skb->tstamp; |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 193 | continue; |
| 194 | } |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 195 | } |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 196 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 197 | /* Okay, we need to retransmit a packet. */ |
David Howells | f07373e | 2016-09-22 00:29:32 +0100 | [diff] [blame] | 198 | call->rxtx_annotations[ix] = RXRPC_TX_ANNO_RETRANS | annotation; |
David Howells | dfa7d92 | 2016-09-17 10:49:12 +0100 | [diff] [blame] | 199 | } |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 200 | |
David Howells | 90bd684 | 2016-09-23 12:39:23 +0100 | [diff] [blame] | 201 | resend_at = ktime_sub(ktime_add_ms(oldest, rxrpc_resend_timeout), now); |
David Howells | 50235c4 | 2016-09-22 00:29:31 +0100 | [diff] [blame] | 202 | call->resend_at = jiffies + nsecs_to_jiffies(ktime_to_ns(resend_at)); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 203 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 204 | /* Now go through the Tx window and perform the retransmissions. We |
| 205 | * have to drop the lock for each send. If an ACK comes in whilst the |
| 206 | * lock is dropped, it may clear some of the retransmission markers for |
| 207 | * packets that it soft-ACKs. |
| 208 | */ |
David Howells | dfa7d92 | 2016-09-17 10:49:12 +0100 | [diff] [blame] | 209 | for (seq = cursor + 1; before_eq(seq, top); seq++) { |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 210 | ix = seq & RXRPC_RXTX_BUFF_MASK; |
| 211 | annotation = call->rxtx_annotations[ix]; |
David Howells | f07373e | 2016-09-22 00:29:32 +0100 | [diff] [blame] | 212 | anno_type = annotation & RXRPC_TX_ANNO_MASK; |
| 213 | if (anno_type != RXRPC_TX_ANNO_RETRANS) |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 214 | continue; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 215 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 216 | skb = call->rxtx_buffer[ix]; |
David Howells | 71f3ca4 | 2016-09-17 10:49:14 +0100 | [diff] [blame] | 217 | rxrpc_get_skb(skb, rxrpc_skb_tx_got); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 218 | spin_unlock_bh(&call->lock); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 219 | |
David Howells | 5a924b8 | 2016-09-22 00:29:31 +0100 | [diff] [blame] | 220 | if (rxrpc_send_data_packet(call, skb) < 0) { |
David Howells | 71f3ca4 | 2016-09-17 10:49:14 +0100 | [diff] [blame] | 221 | rxrpc_free_skb(skb, rxrpc_skb_tx_freed); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 222 | return; |
| 223 | } |
| 224 | |
| 225 | if (rxrpc_is_client_call(call)) |
| 226 | rxrpc_expose_client_call(call); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 227 | |
David Howells | 71f3ca4 | 2016-09-17 10:49:14 +0100 | [diff] [blame] | 228 | rxrpc_free_skb(skb, rxrpc_skb_tx_freed); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 229 | spin_lock_bh(&call->lock); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 230 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 231 | /* We need to clear the retransmit state, but there are two |
| 232 | * things we need to be aware of: A new ACK/NAK might have been |
| 233 | * received and the packet might have been hard-ACK'd (in which |
| 234 | * case it will no longer be in the buffer). |
| 235 | */ |
David Howells | f07373e | 2016-09-22 00:29:32 +0100 | [diff] [blame] | 236 | if (after(seq, call->tx_hard_ack)) { |
| 237 | annotation = call->rxtx_annotations[ix]; |
| 238 | anno_type = annotation & RXRPC_TX_ANNO_MASK; |
| 239 | if (anno_type == RXRPC_TX_ANNO_RETRANS || |
| 240 | anno_type == RXRPC_TX_ANNO_NAK) { |
| 241 | annotation &= ~RXRPC_TX_ANNO_MASK; |
| 242 | annotation |= RXRPC_TX_ANNO_UNACK; |
| 243 | } |
| 244 | annotation |= RXRPC_TX_ANNO_RESENT; |
| 245 | call->rxtx_annotations[ix] = annotation; |
| 246 | } |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 247 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 248 | if (after(call->tx_hard_ack, seq)) |
| 249 | seq = call->tx_hard_ack; |
David Howells | dfa7d92 | 2016-09-17 10:49:12 +0100 | [diff] [blame] | 250 | } |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 251 | |
| 252 | out_unlock: |
| 253 | spin_unlock_bh(&call->lock); |
| 254 | _leave(""); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /* |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 258 | * Handle retransmission and deferred ACK/abort generation. |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 259 | */ |
| 260 | void rxrpc_process_call(struct work_struct *work) |
| 261 | { |
| 262 | struct rxrpc_call *call = |
| 263 | container_of(work, struct rxrpc_call, processor); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 264 | unsigned long now; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 265 | |
David Howells | e34d423 | 2016-08-30 09:49:29 +0100 | [diff] [blame] | 266 | rxrpc_see_call(call); |
| 267 | |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 268 | //printk("\n--------------------\n"); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 269 | _enter("{%d,%s,%lx}", |
| 270 | call->debug_id, rxrpc_call_states[call->state], call->events); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 271 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 272 | recheck_state: |
| 273 | if (test_and_clear_bit(RXRPC_CALL_EV_ABORT, &call->events)) { |
| 274 | rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ABORT); |
| 275 | goto recheck_state; |
David Howells | 8d94aa3 | 2016-09-07 09:19:31 +0100 | [diff] [blame] | 276 | } |
| 277 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 278 | if (call->state == RXRPC_CALL_COMPLETE) { |
| 279 | del_timer_sync(&call->timer); |
| 280 | goto out_put; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 281 | } |
| 282 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 283 | now = jiffies; |
| 284 | if (time_after_eq(now, call->expire_at)) { |
David Howells | 5a42976 | 2016-09-06 22:19:51 +0100 | [diff] [blame] | 285 | rxrpc_abort_call("EXP", call, 0, RX_CALL_TIMEOUT, ETIME); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 286 | set_bit(RXRPC_CALL_EV_ABORT, &call->events); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 287 | } |
| 288 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 289 | if (test_and_clear_bit(RXRPC_CALL_EV_ACK, &call->events) || |
| 290 | time_after_eq(now, call->ack_at)) { |
| 291 | call->ack_at = call->expire_at; |
| 292 | if (call->ackr_reason) { |
| 293 | rxrpc_send_call_packet(call, RXRPC_PACKET_TYPE_ACK); |
| 294 | goto recheck_state; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 298 | if (test_and_clear_bit(RXRPC_CALL_EV_RESEND, &call->events) || |
| 299 | time_after_eq(now, call->resend_at)) { |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 300 | rxrpc_resend(call); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 301 | goto recheck_state; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 302 | } |
| 303 | |
David Howells | fc7ab6d | 2016-09-23 15:22:36 +0100 | [diff] [blame] | 304 | rxrpc_set_timer(call, rxrpc_timer_set_for_resend); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 305 | |
| 306 | /* other events may have been raised since we started checking */ |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 307 | if (call->events && call->state < RXRPC_CALL_COMPLETE) { |
David Howells | 8d94aa3 | 2016-09-07 09:19:31 +0100 | [diff] [blame] | 308 | __rxrpc_queue_call(call); |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 309 | goto out; |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 310 | } |
| 311 | |
David Howells | 248f219 | 2016-09-08 11:10:12 +0100 | [diff] [blame] | 312 | out_put: |
| 313 | rxrpc_put_call(call, rxrpc_call_put); |
| 314 | out: |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 315 | _leave(""); |
David Howells | 17926a7 | 2007-04-26 15:48:28 -0700 | [diff] [blame] | 316 | } |