tcp: remove snd_una_max

Type: improvement

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I03f923053499f219035c9b7b6640fc575568d474
diff --git a/src/plugins/unittest/tcp_test.c b/src/plugins/unittest/tcp_test.c
index 3e5ba9c..0d85408 100644
--- a/src/plugins/unittest/tcp_test.c
+++ b/src/plugins/unittest/tcp_test.c
@@ -88,7 +88,6 @@
 
   tc->flags |= TCP_CONN_FAST_RECOVERY | TCP_CONN_RECOVERY;
   tc->snd_una = 0;
-  tc->snd_una_max = 1000;
   tc->snd_nxt = 1000;
   tc->rcv_opts.flags |= TCP_OPTS_FLAG_SACK;
   tc->snd_mss = 150;
@@ -317,7 +316,6 @@
   block.end = 1300;
   vec_add1 (tc->rcv_opts.sacks, block);
 
-  tc->snd_una_max = 1500;
   tc->snd_una = 1000;
   tc->snd_nxt = 1500;
   tcp_rcv_sacks (tc, 1000);
@@ -366,7 +364,7 @@
    */
   vec_reset_length (tc->rcv_opts.sacks);
   tc->snd_una = 1300;
-  tc->snd_nxt = tc->snd_una_max = 1900;
+  tc->snd_nxt = 1900;
   for (i = 0; i < 5; i++)
     {
       block.start = i * 100 + 1200;
@@ -390,7 +388,6 @@
    */
 
   tc->snd_una = 0;
-  tc->snd_una_max = 1000;
   tc->snd_nxt = 1000;
   vec_reset_length (tc->rcv_opts.sacks);
   for (i = 0; i < 5; i++)
@@ -434,7 +431,6 @@
    */
 
   tc->snd_una = 0;
-  tc->snd_una_max = 1000;
   tc->snd_nxt = 1000;
 
   block.start = 100;
@@ -472,7 +468,6 @@
    */
   scoreboard_clear (sb);
   tc->snd_una = 0;
-  tc->snd_una_max = 1000;
   tc->snd_nxt = 1000;
 
   block.start = 500;
@@ -575,7 +570,7 @@
    * snd_una = 1000 and snd_una_max = 1600
    */
   tc->snd_una = 1000;
-  tc->snd_nxt = tc->snd_una_max = 1600;
+  tc->snd_nxt = 1600;
   vec_reset_length (tc->rcv_opts.sacks);
   block.start = 1200;
   block.end = 1500;
@@ -609,7 +604,6 @@
 
   tc->flags |= TCP_CONN_FAST_RECOVERY | TCP_CONN_RECOVERY;
   tc->snd_una = 0;
-  tc->snd_una_max = 1000;
   tc->snd_nxt = 1000;
   sb->high_rxt = 0;
 
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index b04bbe5..407ba95 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -680,7 +680,6 @@
   tc->iss = tcp_generate_random_iss (tc);
   tc->snd_una = tc->iss;
   tc->snd_nxt = tc->iss + 1;
-  tc->snd_una_max = tc->snd_nxt;
   tc->srtt = 0.1 * THZ;		/* 100 ms */
 
   if (!tcp_cfg.csum_offload)
diff --git a/src/vnet/tcp/tcp_cli.c b/src/vnet/tcp/tcp_cli.c
index e2c1396..21634df 100644
--- a/src/vnet/tcp/tcp_cli.c
+++ b/src/vnet/tcp/tcp_cli.c
@@ -188,9 +188,8 @@
   s = format (s, " index: %u cfg: %U flags: %U timers: %U\n", tc->c_c_index,
 	      format_tcp_cfg_flags, tc, format_tcp_connection_flags, tc,
 	      format_tcp_timers, tc);
-  s = format (s, " snd_una %u snd_nxt %u snd_una_max %u",
-	      tc->snd_una - tc->iss, tc->snd_nxt - tc->iss,
-	      tc->snd_una_max - tc->iss);
+  s = format (s, " snd_una %u snd_nxt %u", tc->snd_una - tc->iss,
+	      tc->snd_nxt - tc->iss);
   s = format (s, " rcv_nxt %u rcv_las %u\n",
 	      tc->rcv_nxt - tc->irs, tc->rcv_las - tc->irs);
   s = format (s, " snd_wnd %u rcv_wnd %u rcv_wscale %u ",
@@ -717,7 +716,7 @@
       if (trace[i].ack != 0)
 	{
 	  placeholder_tc->snd_una = trace[i].ack - 1448;
-	  placeholder_tc->snd_una_max = trace[i].ack;
+	  placeholder_tc->snd_nxt = trace[i].ack;
 	}
     }
 
@@ -733,8 +732,8 @@
 	    {
 	      if (verbose)
 		s = format (s, "Adding ack %u, snd_una_max %u, segs: ",
-			    trace[left].ack, trace[left].snd_una_max);
-	      placeholder_tc->snd_una_max = trace[left].snd_una_max;
+			    trace[left].ack, trace[left].snd_nxt);
+	      placeholder_tc->snd_nxt = trace[left].snd_nxt;
 	      next_ack = trace[left].ack;
 	      has_new_ack = 1;
 	    }
diff --git a/src/vnet/tcp/tcp_inlines.h b/src/vnet/tcp/tcp_inlines.h
index cb00ca4..25bf738 100644
--- a/src/vnet/tcp/tcp_inlines.h
+++ b/src/vnet/tcp/tcp_inlines.h
@@ -182,7 +182,7 @@
 always_inline u8
 tcp_is_lost_fin (tcp_connection_t * tc)
 {
-  if ((tc->flags & TCP_CONN_FINSNT) && (tc->snd_una_max - tc->snd_una == 1))
+  if ((tc->flags & TCP_CONN_FINSNT) && (tc->snd_nxt - tc->snd_una == 1))
     return 1;
   return 0;
 }
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index 91a4fca..ce1c9d5 100644
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -404,7 +404,7 @@
   if (!(seq_leq (tc->snd_una, vnet_buffer (b)->tcp.ack_number)
 	&& seq_leq (vnet_buffer (b)->tcp.ack_number, tc->snd_nxt)))
     {
-      if (seq_leq (vnet_buffer (b)->tcp.ack_number, tc->snd_una_max)
+      if (seq_leq (vnet_buffer (b)->tcp.ack_number, tc->snd_nxt)
 	  && seq_gt (vnet_buffer (b)->tcp.ack_number, tc->snd_una))
 	{
 	  tc->snd_nxt = vnet_buffer (b)->tcp.ack_number;
@@ -580,7 +580,7 @@
 
       /* Dequeue the newly ACKed bytes */
       session_tx_fifo_dequeue_drop (&tc->connection, tc->burst_acked);
-      tcp_validate_txf_size (tc, tc->snd_una_max - tc->snd_una);
+      tcp_validate_txf_size (tc, tc->snd_nxt - tc->snd_una);
 
       if (PREDICT_FALSE (tc->flags & TCP_CONN_PSH_PENDING))
 	{
@@ -999,7 +999,7 @@
     {
       /* We've probably entered recovery and the peer still has some
        * of the data we've sent. Update snd_nxt and accept the ack */
-      if (seq_leq (vnet_buffer (b)->tcp.ack_number, tc->snd_una_max)
+      if (seq_leq (vnet_buffer (b)->tcp.ack_number, tc->snd_nxt)
 	  && seq_gt (vnet_buffer (b)->tcp.ack_number, tc->snd_una))
 	{
 	  tc->snd_nxt = vnet_buffer (b)->tcp.ack_number;
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index 5d8bd80..b40cdbe 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -902,7 +902,6 @@
     {
       tc->flags |= TCP_CONN_FINSNT;
       tc->flags &= ~TCP_CONN_FINPNDG;
-      tc->snd_una_max = seq_max (tc->snd_una_max, tc->snd_nxt);
     }
 }
 
@@ -994,8 +993,7 @@
   tcp_push_hdr_i (tc, b, tc->snd_nxt, /* compute opts */ 0, /* burst */ 1,
 		  /* update_snd_nxt */ 1);
 
-  tc->snd_una_max = seq_max (tc->snd_nxt, tc->snd_una_max);
-  tcp_validate_txf_size (tc, tc->snd_una_max - tc->snd_una);
+  tcp_validate_txf_size (tc, tc->snd_nxt - tc->snd_una);
   /* If not tracking an ACK, start tracking */
   if (tc->rtt_ts == 0 && !tcp_in_cong_recovery (tc))
     {
@@ -1560,7 +1558,7 @@
 					max_snd_bytes);
   b->current_length = n_bytes;
   ASSERT (n_bytes != 0 && (tcp_timer_is_active (tc, TCP_TIMER_RETRANSMIT)
-			   || tc->snd_nxt == tc->snd_una_max
+			   || tc->snd_una == tc->snd_nxt
 			   || tc->rto_boff > 1));
 
   if (tc->cfg_flags & TCP_CFG_F_RATE_SAMPLE)
@@ -1571,8 +1569,7 @@
 
   tcp_push_hdr_i (tc, b, tc->snd_nxt, /* compute opts */ 0,
 		  /* burst */ 0, /* update_snd_nxt */ 1);
-  tc->snd_una_max = seq_max (tc->snd_nxt, tc->snd_una_max);
-  tcp_validate_txf_size (tc, tc->snd_una_max - tc->snd_una);
+  tcp_validate_txf_size (tc, tc->snd_nxt - tc->snd_una);
   tcp_enqueue_to_output (wrk, b, bi, tc->c_is_ip4);
 
   /* Just sent new data, enable retransmit */
@@ -1638,7 +1635,6 @@
 	tcp_bt_track_tx (tc, n_written);
 
       tc->snd_nxt += n_written;
-      tc->snd_una_max = seq_max (tc->snd_nxt, tc->snd_una_max);
     }
 
 done:
diff --git a/src/vnet/tcp/tcp_timer.h b/src/vnet/tcp/tcp_timer.h
index 45cf382..4668c79 100644
--- a/src/vnet/tcp/tcp_timer.h
+++ b/src/vnet/tcp/tcp_timer.h
@@ -54,7 +54,7 @@
 always_inline void
 tcp_retransmit_timer_set (tcp_timer_wheel_t * tw, tcp_connection_t * tc)
 {
-  ASSERT (tc->snd_una != tc->snd_una_max);
+  ASSERT (tc->snd_una != tc->snd_nxt);
   tcp_timer_set (tw, tc, TCP_TIMER_RETRANSMIT,
 		 clib_max (tc->rto * TCP_TO_TIMER_TICK, 1));
 }
diff --git a/src/vnet/tcp/tcp_types.h b/src/vnet/tcp/tcp_types.h
index d1dc717..2575156 100644
--- a/src/vnet/tcp/tcp_types.h
+++ b/src/vnet/tcp/tcp_types.h
@@ -156,7 +156,7 @@
   u32 start;
   u32 end;
   u32 ack;
-  u32 snd_una_max;
+  u32 snd_nxt;
   u32 group;
 } scoreboard_trace_elt_t;
 
@@ -293,7 +293,6 @@
 
   /** Send sequence variables RFC793 */
   u32 snd_una;		/**< oldest unacknowledged sequence number */
-  u32 snd_una_max;	/**< newest unacknowledged sequence number + 1*/
   u32 snd_wnd;		/**< send window */
   u32 snd_wl1;		/**< seq number used for last snd.wnd update */
   u32 snd_wl2;		/**< ack number used for last snd.wnd update */
@@ -345,7 +344,7 @@
   u32 rxt_delivered;	/**< Rxt bytes delivered during current cc event */
   u32 rxt_head;		/**< snd_una last time we re rxted the head */
   u32 tsecr_last_ack;	/**< Timestamp echoed to us in last healthy ACK */
-  u32 snd_congestion;	/**< snd_una_max when congestion is detected */
+  u32 snd_congestion;	/**< snd_nxt when congestion is detected */
   u32 tx_fifo_size;	/**< Tx fifo size. Used to constrain cwnd */
   tcp_cc_algorithm_t *cc_algo;	/**< Congestion control algorithm */
   u8 cc_data[TCP_CC_DATA_SZ];	/**< Congestion control algo private data */