Horizontal (nSessions) scaling draft
[vpp.git] / src / vnet / session / transport.h
index 421121d..9c38bab 100644 (file)
@@ -30,15 +30,19 @@ typedef struct _transport_connection
   ip46_address_t lcl_ip;       /**< Local IP */
   u16 lcl_port;                        /**< Local port */
   u16 rmt_port;                        /**< Remote port */
-  u8 proto;                    /**< Transport protocol id */
+  u8 proto;                    /**< Protocol id (also session type) */
 
   u32 s_index;                 /**< Parent session index */
   u32 c_index;                 /**< Connection index in transport pool */
   u8 is_ip4;                   /**< Flag if IP4 connection */
   u32 thread_index;            /**< Worker-thread index */
 
+  fib_node_index_t rmt_fei;    /**< FIB entry index for rmt */
+  dpo_id_t rmt_dpo;            /**< Forwarding DPO for rmt */
+
 #if TRANSPORT_DEBUG
-  elog_track_t elog_track;     /**< Debug purposes */
+  elog_track_t elog_track;     /**< Event logging */
+  u32 cc_stat_tstamp;          /**< CC stats timestamp */
 #endif
 
   /** Macros for 'derived classes' where base is named "connection" */
@@ -57,6 +61,9 @@ typedef struct _transport_connection
 #define c_is_ip4 connection.is_ip4
 #define c_thread_index connection.thread_index
 #define c_elog_track connection.elog_track
+#define c_cc_stat_tstamp connection.cc_stat_tstamp
+#define c_rmt_fei connection.rmt_fei
+#define c_rmt_dpo connection.rmt_dpo
 } transport_connection_t;
 
 /*
@@ -103,7 +110,8 @@ typedef CLIB_PACKED (struct {
     {
       struct
        {
-         ip4_address_t src; ip4_address_t dst;
+         ip4_address_t src;
+         ip4_address_t dst;
          u16 src_port;
          u16 dst_port;
          /* align by making this 4 octets even though its a 1-bit field
@@ -122,10 +130,14 @@ typedef CLIB_PACKED (struct {
       struct
        {
          /* 48 octets */
-         ip6_address_t src; ip6_address_t dst;
+         ip6_address_t src;
+         ip6_address_t dst;
          u16 src_port;
-         u16 dst_port; u32 proto; u8 unused_for_now[8];
-       }; u64 as_u64[6];
+         u16 dst_port;
+         u32 proto;
+         u64 unused;
+       };
+      u64 as_u64[6];
     };
 }) v6_connection_key_t;
 /* *INDENT-ON* */
@@ -137,17 +149,14 @@ always_inline void
 make_v4_ss_kv (session_kv4_t * kv, ip4_address_t * lcl, ip4_address_t * rmt,
               u16 lcl_port, u16 rmt_port, u8 proto)
 {
-  v4_connection_key_t key;
-  memset (&key, 0, sizeof (v4_connection_key_t));
+  v4_connection_key_t *key = (v4_connection_key_t *) kv->key;
 
-  key.src.as_u32 = lcl->as_u32;
-  key.dst.as_u32 = rmt->as_u32;
-  key.src_port = lcl_port;
-  key.dst_port = rmt_port;
-  key.proto = proto;
+  key->src.as_u32 = lcl->as_u32;
+  key->dst.as_u32 = rmt->as_u32;
+  key->src_port = lcl_port;
+  key->dst_port = rmt_port;
+  key->proto = proto;
 
-  kv->key[0] = key.as_u64[0];
-  kv->key[1] = key.as_u64[1];
   kv->value = ~0ULL;
 }
 
@@ -155,17 +164,14 @@ always_inline void
 make_v4_listener_kv (session_kv4_t * kv, ip4_address_t * lcl, u16 lcl_port,
                     u8 proto)
 {
-  v4_connection_key_t key;
-  memset (&key, 0, sizeof (v4_connection_key_t));
+  v4_connection_key_t *key = (v4_connection_key_t *) kv->key;
 
-  key.src.as_u32 = lcl->as_u32;
-  key.dst.as_u32 = 0;
-  key.src_port = lcl_port;
-  key.dst_port = 0;
-  key.proto = proto;
+  key->src.as_u32 = lcl->as_u32;
+  key->dst.as_u32 = 0;
+  key->src_port = lcl_port;
+  key->dst_port = 0;
+  key->proto = proto;
 
-  kv->key[0] = key.as_u64[0];
-  kv->key[1] = key.as_u64[1];
   kv->value = ~0ULL;
 }
 
@@ -180,23 +186,17 @@ always_inline void
 make_v6_ss_kv (session_kv6_t * kv, ip6_address_t * lcl, ip6_address_t * rmt,
               u16 lcl_port, u16 rmt_port, u8 proto)
 {
-  v6_connection_key_t key;
-  memset (&key, 0, sizeof (v6_connection_key_t));
-
-  key.src.as_u64[0] = lcl->as_u64[0];
-  key.src.as_u64[1] = lcl->as_u64[1];
-  key.dst.as_u64[0] = rmt->as_u64[0];
-  key.dst.as_u64[1] = rmt->as_u64[1];
-  key.src_port = lcl_port;
-  key.dst_port = rmt_port;
-  key.proto = proto;
-
-  kv->key[0] = key.as_u64[0];
-  kv->key[1] = key.as_u64[1];
-  kv->key[2] = 0;
-  kv->key[3] = 0;
-  kv->key[4] = 0;
-  kv->key[5] = 0;
+  v6_connection_key_t *key = (v6_connection_key_t *) kv->key;
+
+  key->src.as_u64[0] = lcl->as_u64[0];
+  key->src.as_u64[1] = lcl->as_u64[1];
+  key->dst.as_u64[0] = rmt->as_u64[0];
+  key->dst.as_u64[1] = rmt->as_u64[1];
+  key->src_port = lcl_port;
+  key->dst_port = rmt_port;
+  key->proto = proto;
+  key->unused = 0;
+
   kv->value = ~0ULL;
 }
 
@@ -204,23 +204,17 @@ always_inline void
 make_v6_listener_kv (session_kv6_t * kv, ip6_address_t * lcl, u16 lcl_port,
                     u8 proto)
 {
-  v6_connection_key_t key;
-  memset (&key, 0, sizeof (v6_connection_key_t));
-
-  key.src.as_u64[0] = lcl->as_u64[0];
-  key.src.as_u64[1] = lcl->as_u64[1];
-  key.dst.as_u64[0] = 0;
-  key.dst.as_u64[1] = 0;
-  key.src_port = lcl_port;
-  key.dst_port = 0;
-  key.proto = proto;
-
-  kv->key[0] = key.as_u64[0];
-  kv->key[1] = key.as_u64[1];
-  kv->key[2] = 0;
-  kv->key[3] = 0;
-  kv->key[4] = 0;
-  kv->key[5] = 0;
+  v6_connection_key_t *key = (v6_connection_key_t *) kv->key;
+
+  key->src.as_u64[0] = lcl->as_u64[0];
+  key->src.as_u64[1] = lcl->as_u64[1];
+  key->dst.as_u64[0] = 0;
+  key->dst.as_u64[1] = 0;
+  key->src_port = lcl_port;
+  key->dst_port = 0;
+  key->proto = proto;
+  key->unused = 0;
+
   kv->value = ~0ULL;
 }
 
@@ -231,12 +225,18 @@ make_v6_ss_kv_from_tc (session_kv6_t * kv, transport_connection_t * t)
                 t->rmt_port, t->proto);
 }
 
+typedef enum _transport_proto
+{
+  TRANSPORT_PROTO_TCP,
+  TRANSPORT_PROTO_UDP
+} transport_proto_t;
+
 typedef struct _transport_endpoint
 {
-  ip46_address_t ip;
-  u16 port;
-  u8 is_ip4;
-  u32 vrf;
+  ip46_address_t ip;   /** ip address */
+  u16 port;            /** port in host order */
+  u8 is_ip4;           /** 1 if ip4 */
+  u32 vrf;             /** fib table the endpoint is associated with */
 } transport_endpoint_t;
 
 typedef clib_bihash_24_8_t transport_endpoint_table_t;