tcp: explicit use of timer wheel in timer apis

Type: refactor

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I06120d43c15b2fa3f437ef235bf5f83ec2beb45e
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index 708d756..f8c8cb3 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -115,17 +115,14 @@
   tcp_cleanup_req_t *pending_cleanups;
 
   /** worker timer wheel */
-  tw_timer_wheel_16t_2w_512sl_t timer_wheel;
+  tcp_timer_wheel_t timer_wheel;
 
     CLIB_CACHE_LINE_ALIGN_MARK (cacheline2);
 
   tcp_wrk_stats_t stats;
 } tcp_worker_ctx_t;
 
-#define tcp_worker_stats_inc(_ti,_stat,_val) 		\
-  tcp_main.wrk_ctx[_ti].stats._stat += _val
-
-#define tcp_workerp_stats_inc(_wrk,_stat,_val) 		\
+#define tcp_worker_stats_inc(_wrk,_stat,_val) 		\
   _wrk->stats._stat += _val
 
 typedef struct tcp_iss_seed_
@@ -356,113 +353,6 @@
 format_function_t format_tcp_connection;
 format_function_t format_tcp_connection_id;
 
-always_inline void
-tcp_timer_set (tcp_connection_t * tc, u8 timer_id, u32 interval)
-{
-  ASSERT (tc->c_thread_index == vlib_get_thread_index ());
-  ASSERT (tc->timers[timer_id] == TCP_TIMER_HANDLE_INVALID);
-  tc->timers[timer_id] =
-    tw_timer_start_16t_2w_512sl (&tcp_main.
-				 wrk_ctx[tc->c_thread_index].timer_wheel,
-				 tc->c_c_index, timer_id, interval);
-}
-
-always_inline void
-tcp_timer_reset (tcp_connection_t * tc, u8 timer_id)
-{
-  ASSERT (tc->c_thread_index == vlib_get_thread_index ());
-  if (tc->timers[timer_id] == TCP_TIMER_HANDLE_INVALID)
-    return;
-
-  tw_timer_stop_16t_2w_512sl (&tcp_main.
-			      wrk_ctx[tc->c_thread_index].timer_wheel,
-			      tc->timers[timer_id]);
-  tc->timers[timer_id] = TCP_TIMER_HANDLE_INVALID;
-}
-
-always_inline void
-tcp_timer_update (tcp_connection_t * tc, u8 timer_id, u32 interval)
-{
-  ASSERT (tc->c_thread_index == vlib_get_thread_index ());
-  if (tc->timers[timer_id] != TCP_TIMER_HANDLE_INVALID)
-    tw_timer_update_16t_2w_512sl (&tcp_main.
-				  wrk_ctx[tc->c_thread_index].timer_wheel,
-				  tc->timers[timer_id], interval);
-  else
-    tc->timers[timer_id] =
-      tw_timer_start_16t_2w_512sl (&tcp_main.
-				   wrk_ctx[tc->c_thread_index].timer_wheel,
-				   tc->c_c_index, timer_id, interval);
-}
-
-always_inline void
-tcp_retransmit_timer_set (tcp_connection_t * tc)
-{
-  ASSERT (tc->snd_una != tc->snd_una_max);
-  tcp_timer_set (tc, TCP_TIMER_RETRANSMIT,
-		 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
-}
-
-always_inline void
-tcp_retransmit_timer_reset (tcp_connection_t * tc)
-{
-  tcp_timer_reset (tc, TCP_TIMER_RETRANSMIT);
-}
-
-always_inline void
-tcp_retransmit_timer_force_update (tcp_connection_t * tc)
-{
-  tcp_timer_update (tc, TCP_TIMER_RETRANSMIT,
-		    clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
-}
-
-always_inline void
-tcp_persist_timer_set (tcp_connection_t * tc)
-{
-  /* Reuse RTO. It's backed off in handler */
-  tcp_timer_set (tc, TCP_TIMER_PERSIST,
-		 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
-}
-
-always_inline void
-tcp_persist_timer_update (tcp_connection_t * tc)
-{
-  u32 interval;
-
-  if (seq_leq (tc->snd_una, tc->snd_congestion + tc->burst_acked))
-    interval = 1;
-  else
-    interval = clib_max (tc->rto * TCP_TO_TIMER_TICK, 1);
-
-  tcp_timer_update (tc, TCP_TIMER_PERSIST, interval);
-}
-
-always_inline void
-tcp_persist_timer_reset (tcp_connection_t * tc)
-{
-  tcp_timer_reset (tc, TCP_TIMER_PERSIST);
-}
-
-always_inline void
-tcp_retransmit_timer_update (tcp_connection_t * tc)
-{
-  if (tc->snd_una == tc->snd_nxt)
-    {
-      tcp_retransmit_timer_reset (tc);
-      if (tc->snd_wnd < tc->snd_mss)
-	tcp_persist_timer_update (tc);
-    }
-  else
-    tcp_timer_update (tc, TCP_TIMER_RETRANSMIT,
-		      clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
-}
-
-always_inline u8
-tcp_timer_is_active (tcp_connection_t * tc, tcp_timers_e timer)
-{
-  return tc->timers[timer] != TCP_TIMER_HANDLE_INVALID;
-}
-
 #define tcp_validate_txf_size(_tc, _a) 					\
   ASSERT(_tc->state != TCP_STATE_ESTABLISHED 				\
 	 || transport_max_tx_dequeue (&_tc->connection) >= _a)