tcp: allow registration of new cc algo types 58/20058/3
authorFlorin Coras <fcoras@cisco.com>
Mon, 10 Jun 2019 15:33:50 +0000 (08:33 -0700)
committerDave Barach <openvpp@barachs.net>
Tue, 11 Jun 2019 00:24:05 +0000 (00:24 +0000)
Type: feature

Change-Id: I83e21b508a19df1beb207d961c8f2b52347deca0
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp.h

index 835bd48..f72b957 100644 (file)
@@ -102,6 +102,14 @@ tcp_cc_algo_get (tcp_cc_algorithm_type_e type)
   return &tm->cc_algos[type];
 }
 
+tcp_cc_algorithm_type_e
+tcp_cc_algo_new_type (const tcp_cc_algorithm_t * vft)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+  tcp_cc_algo_register (++tm->cc_last_type, vft);
+  return tm->cc_last_type;
+}
+
 static u32
 tcp_connection_bind (u32 session_index, transport_endpoint_t * lcl)
 {
@@ -1499,7 +1507,7 @@ tcp_main_enable (vlib_main_t * vm)
   tcp_initialize_iss_seed (tm);
 
   tm->bytes_per_buffer = vlib_buffer_get_default_data_size (vm);
-
+  tm->cc_last_type = TCP_CC_LAST;
   return error;
 }
 
index 98808c1..aeae57c 100644 (file)
@@ -235,6 +235,7 @@ typedef enum _tcp_cc_algorithm_type
 {
   TCP_CC_NEWRENO,
   TCP_CC_CUBIC,
+  TCP_CC_LAST = TCP_CC_CUBIC
 } tcp_cc_algorithm_type_e;
 
 typedef struct _tcp_cc_algorithm tcp_cc_algorithm_t;
@@ -448,18 +449,21 @@ typedef struct _tcp_main
   tcp_connection_t *half_open_connections;
   clib_spinlock_t half_open_lock;
 
-  /* Congestion control algorithms registered */
-  tcp_cc_algorithm_t *cc_algos;
-
   /** vlib buffer size */
   u32 bytes_per_buffer;
 
   /* Seed used to generate random iss */
   tcp_iss_seed_t iss_seed;
 
+  /* Congestion control algorithms registered */
+  tcp_cc_algorithm_t *cc_algos;
+
   /** Hash table of cc algorithms by name */
   uword *cc_algo_by_name;
 
+  /** Last cc algo registered */
+  tcp_cc_algorithm_type_e cc_last_type;
+
   /*
    * Configuration
    */
@@ -495,7 +499,6 @@ typedef struct _tcp_main
 
   /** Default congestion control algorithm type */
   tcp_cc_algorithm_type_e cc_algo;
-
 } tcp_main_t;
 
 extern tcp_main_t tcp_main;
@@ -936,9 +939,16 @@ tcp_timer_is_active (tcp_connection_t * tc, tcp_timers_e timer)
 void tcp_rcv_sacks (tcp_connection_t * tc, u32 ack);
 u8 *tcp_scoreboard_replay (u8 * s, tcp_connection_t * tc, u8 verbose);
 
+/**
+ * Register exiting cc algo type
+ */
 void tcp_cc_algo_register (tcp_cc_algorithm_type_e type,
                           const tcp_cc_algorithm_t * vft);
 
+/**
+ * Register new cc algo type
+ */
+tcp_cc_algorithm_type_e tcp_cc_algo_new_type (const tcp_cc_algorithm_t * vft);
 tcp_cc_algorithm_t *tcp_cc_algo_get (tcp_cc_algorithm_type_e type);
 
 static inline void *