2 * Copyright (c) 2016-2019 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_tcp_timer_h__
16 #define __included_tcp_timer_h__
18 #include <vnet/tcp/tcp_types.h>
21 tcp_timer_set (tcp_timer_wheel_t * tw, tcp_connection_t * tc, u8 timer_id,
24 ASSERT (tc->c_thread_index == vlib_get_thread_index ());
25 ASSERT (tc->timers[timer_id] == TCP_TIMER_HANDLE_INVALID);
26 tc->timers[timer_id] = tw_timer_start_16t_2w_512sl (tw, tc->c_c_index,
31 tcp_timer_reset (tcp_timer_wheel_t * tw, tcp_connection_t * tc, u8 timer_id)
33 ASSERT (tc->c_thread_index == vlib_get_thread_index ());
34 tc->pending_timers &= ~(1 << timer_id);
35 if (tc->timers[timer_id] == TCP_TIMER_HANDLE_INVALID)
38 tw_timer_stop_16t_2w_512sl (tw, tc->timers[timer_id]);
39 tc->timers[timer_id] = TCP_TIMER_HANDLE_INVALID;
43 tcp_timer_update (tcp_timer_wheel_t * tw, tcp_connection_t * tc, u8 timer_id,
46 ASSERT (tc->c_thread_index == vlib_get_thread_index ());
47 if (tc->timers[timer_id] != TCP_TIMER_HANDLE_INVALID)
48 tw_timer_update_16t_2w_512sl (tw, tc->timers[timer_id], interval);
50 tc->timers[timer_id] = tw_timer_start_16t_2w_512sl (tw, tc->c_c_index,
55 tcp_retransmit_timer_set (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
57 ASSERT (tc->snd_una != tc->snd_una_max);
58 tcp_timer_set (tw, tc, TCP_TIMER_RETRANSMIT,
59 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
63 tcp_retransmit_timer_reset (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
65 tcp_timer_reset (tw, tc, TCP_TIMER_RETRANSMIT);
69 tcp_retransmit_timer_force_update (tcp_timer_wheel_t * tw,
70 tcp_connection_t * tc)
72 tcp_timer_update (tw, tc, TCP_TIMER_RETRANSMIT,
73 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
77 tcp_persist_timer_set (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
79 /* Reuse RTO. It's backed off in handler */
80 tcp_timer_set (tw, tc, TCP_TIMER_PERSIST,
81 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
85 tcp_persist_timer_update (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
89 if (seq_leq (tc->snd_una, tc->snd_congestion + tc->burst_acked))
92 interval = clib_max (tc->rto * TCP_TO_TIMER_TICK, 1);
94 tcp_timer_update (tw, tc, TCP_TIMER_PERSIST, interval);
98 tcp_persist_timer_reset (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
100 tcp_timer_reset (tw, tc, TCP_TIMER_PERSIST);
104 tcp_retransmit_timer_update (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
106 if (tc->snd_una == tc->snd_nxt)
108 tcp_retransmit_timer_reset (tw, tc);
109 if (tc->snd_wnd < tc->snd_mss)
110 tcp_persist_timer_update (tw, tc);
113 tcp_timer_update (tw, tc, TCP_TIMER_RETRANSMIT,
114 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
118 tcp_timer_is_active (tcp_connection_t * tc, tcp_timers_e timer)
120 return tc->timers[timer] != TCP_TIMER_HANDLE_INVALID;
123 #endif /* __included_tcp_timer_h__ */
126 * fd.io coding-style-patch-verification: ON
129 * eval: (c-set-style "gnu")