session tcp: handle rxt and acks as custom events
[vpp.git] / src / vnet / tcp / tcp.h
index 2bc6f22..8f2665d 100644 (file)
@@ -183,6 +183,7 @@ typedef struct _sack_scoreboard
   u32 high_rxt;                                /**< Highest retransmitted sequence */
   u32 rescue_rxt;                      /**< Rescue sequence number */
   u32 lost_bytes;                      /**< Bytes lost as per RFC6675 */
+  u32 last_lost_bytes;                 /**< Number of bytes last lost */
   u32 cur_rxt_hole;                    /**< Retransmitting from this hole */
 
 #if TCP_SCOREBOARD_TRACE
@@ -248,18 +249,24 @@ typedef struct tcp_bt_sample_
   u32 prev;                    /**< Previous sample index in list */
   u32 min_seq;                 /**< Min seq number in sample */
   u32 max_seq;                 /**< Max seq number. Set for rxt samples */
-  u64 delivered;               /**< Total delivered when sample taken */
+  u64 delivered;               /**< Total delivered bytes for sample */
   f64 delivered_time;          /**< Delivered time when sample taken */
+  f64 tx_time;                 /**< Transmit time for the burst */
   u64 tx_rate;                 /**< Tx pacing rate */
   tcp_bts_flags_t flags;       /**< Sample flag */
 } tcp_bt_sample_t;
 
 typedef struct tcp_rate_sample_
 {
-  u64 sample_delivered;                /**< Delivered of sample used for rate */
-  u32 delivered;               /**< Bytes delivered in ack time */
-  f64 ack_time;                        /**< Time to ack the bytes delivered */
+  u64 prior_delivered;         /**< Delivered of sample used for rate, i.e.,
+                                    total bytes delivered at prior_time */
+  f64 prior_time;              /**< Delivered time of sample used for rate */
+  f64 interval_time;           /**< Time to ack the bytes delivered */
+  f64 rtt_time;                        /**< RTT for sample */
   u64 tx_rate;                 /**< Tx pacing rate */
+  u32 delivered;               /**< Bytes delivered in interval_time */
+  u32 acked_and_sacked;                /**< Bytes acked + sacked now */
+  u32 lost;                    /**< Bytes lost now */
   tcp_bts_flags_t flags;       /**< Rate sample flags from bt sample */
 } tcp_rate_sample_t;
 
@@ -288,6 +295,11 @@ typedef enum _tcp_cc_ack_t
   TCP_CC_PARTIALACK
 } tcp_cc_ack_t;
 
+typedef enum tcp_cc_event_
+{
+  TCP_CC_EVT_START_TX,
+} tcp_cc_event_t;
+
 typedef struct _tcp_connection
 {
   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
@@ -372,6 +384,7 @@ typedef struct _tcp_connection
 
   u32 last_fib_check;  /**< Last time we checked fib route for peer */
   u16 mss;             /**< Our max seg size that includes options */
+  u32 timestamp_delta;
 } tcp_connection_t;
 
 /* *INDENT-OFF* */
@@ -387,6 +400,8 @@ struct _tcp_cc_algorithm
   void (*congestion) (tcp_connection_t * tc);
   void (*loss) (tcp_connection_t * tc);
   void (*recovered) (tcp_connection_t * tc);
+  void (*undo_recovery) (tcp_connection_t * tc);
+  void (*event) (tcp_connection_t *tc, tcp_cc_event_t evt);
 };
 /* *INDENT-ON* */
 
@@ -449,21 +464,9 @@ typedef struct tcp_worker_ctx_
   /** tx frames for ip 4/6 lookup nodes */
   vlib_frame_t *ip_lookup_tx_frames[2];
 
-  /** vector of connections needing fast rxt */
-  u32 *pending_fast_rxt;
-
-  /** vector of connections now doing fast rxt */
-  u32 *ongoing_fast_rxt;
-
-  /** vector of connections that will do fast rxt */
-  u32 *postponed_fast_rxt;
-
   /** vector of pending ack dequeues */
   u32 *pending_deq_acked;
 
-  /** vector of pending acks */
-  u32 *pending_acks;
-
   /** vector of pending disconnect notifications */
   u32 *pending_disconnects;
 
@@ -685,15 +688,12 @@ void tcp_update_burst_snd_vars (tcp_connection_t * tc);
 void tcp_update_rto (tcp_connection_t * tc);
 void tcp_flush_frame_to_output (tcp_worker_ctx_t * wrk, u8 is_ip4);
 void tcp_flush_frames_to_output (tcp_worker_ctx_t * wrk);
-void tcp_program_fastretransmit (tcp_worker_ctx_t * wrk,
-                                tcp_connection_t * tc);
-void tcp_do_fastretransmits (tcp_worker_ctx_t * wrk);
-
-void tcp_program_ack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc);
-void tcp_program_dupack (tcp_worker_ctx_t * wrk, tcp_connection_t * tc);
-void tcp_send_acks (tcp_worker_ctx_t * wrk);
 void tcp_send_window_update_ack (tcp_connection_t * tc);
 
+void tcp_program_ack (tcp_connection_t * tc);
+void tcp_program_dupack (tcp_connection_t * tc);
+void tcp_program_fastretransmit (tcp_connection_t * tc);
+
 /*
  * Rate estimation
  */
@@ -921,6 +921,16 @@ tcp_time_now_w_thread (u32 thread_index)
   return tcp_main.wrk_ctx[thread_index].time_now;
 }
 
+/**
+ * Generate timestamp for tcp connection
+ */
+always_inline u32
+tcp_tstamp (tcp_connection_t * tc)
+{
+  return (tcp_main.wrk_ctx[tc->c_thread_index].time_now -
+         tc->timestamp_delta);
+}
+
 always_inline f64
 tcp_time_now_us (u32 thread_index)
 {
@@ -936,6 +946,7 @@ tcp_set_time_now (tcp_worker_ctx_t * wrk)
 
 u32 tcp_session_push_header (transport_connection_t * tconn,
                             vlib_buffer_t * b);
+int tcp_session_custom_tx (void *conn, u32 max_burst_size);
 
 void tcp_connection_timers_init (tcp_connection_t * tc);
 void tcp_connection_timers_reset (tcp_connection_t * tc);
@@ -965,6 +976,26 @@ tcp_cc_loss (tcp_connection_t * tc)
   tc->cc_algo->loss (tc);
 }
 
+static inline void
+tcp_cc_recovered (tcp_connection_t * tc)
+{
+  tc->cc_algo->recovered (tc);
+}
+
+static inline void
+tcp_cc_undo_recovery (tcp_connection_t * tc)
+{
+  if (tc->cc_algo->undo_recovery)
+    tc->cc_algo->undo_recovery (tc);
+}
+
+static inline void
+tcp_cc_event (tcp_connection_t * tc, tcp_cc_event_t evt)
+{
+  if (tc->cc_algo->event)
+    tc->cc_algo->event (tc, evt);
+}
+
 always_inline void
 tcp_timer_set (tcp_connection_t * tc, u8 timer_id, u32 interval)
 {