svm_fifo rework to avoid contention on cursize
[vpp.git] / src / plugins / unittest / tcp_test.c
index d065787..c8d9d5f 100644 (file)
@@ -83,7 +83,7 @@ tcp_test_sack_rx (vlib_main_t * vm, unformat_input_t * input)
        return tcp_test_scoreboard_replay (vm, input);
     }
 
-  memset (tc, 0, sizeof (*tc));
+  clib_memset (tc, 0, sizeof (*tc));
 
   tc->snd_una = 0;
   tc->snd_una_max = 1000;
@@ -239,7 +239,7 @@ tcp_test_sack_rx (vlib_main_t * vm, unformat_input_t * input)
    */
   vec_reset_length (tc->rcv_opts.sacks);
   tc->snd_una += sb->snd_una_adv;
-  tc->snd_una_max = 1900;
+  tc->snd_nxt = tc->snd_una_max = 1900;
   for (i = 0; i < 5; i++)
     {
       block.start = i * 100 + 1200;
@@ -416,7 +416,7 @@ tcp_test_sack_rx (vlib_main_t * vm, unformat_input_t * input)
    * snd_una = 1000 and snd_una_max = 1600
    */
   tc->snd_una = 1000;
-  tc->snd_una_max = 1600;
+  tc->snd_nxt = tc->snd_una_max = 1600;
   vec_reset_length (tc->rcv_opts.sacks);
   block.start = 1200;
   block.end = 1500;
@@ -458,7 +458,7 @@ tcp_test_sack_tx (vlib_main_t * vm, unformat_input_t * input)
        }
     }
 
-  memset (tc, 0, sizeof (*tc));
+  clib_memset (tc, 0, sizeof (*tc));
 
   /*
    * Add odd sack block pairs
@@ -740,7 +740,7 @@ fifo_prepare (u32 fifo_size)
   f = svm_fifo_create (fifo_size);
 
   /* Paint fifo data vector with -1's */
-  memset (f->data, 0xFF, fifo_size);
+  clib_memset (f->data, 0xFF, fifo_size);
 
   return f;
 }
@@ -1221,8 +1221,7 @@ tcp_test_fifo3 (vlib_main_t * vm, unformat_input_t * input)
 
   /* manually set head and tail pointers to validate modular arithmetic */
   fifo_initial_offset = fifo_initial_offset % fifo_size;
-  f->head = fifo_initial_offset;
-  f->tail = fifo_initial_offset;
+  svm_fifo_init_pointers (f, fifo_initial_offset);
 
   for (i = !randomize; i < vec_len (generate); i++)
     {
@@ -1635,23 +1634,23 @@ tcp_test_fifo (vlib_main_t * vm, unformat_input_t * input)
 static int
 tcp_test_lookup (vlib_main_t * vm, unformat_input_t * input)
 {
-  session_manager_main_t *smm = &session_manager_main;
+  session_main_t *smm = &session_main;
   tcp_main_t *tm = &tcp_main;
   transport_connection_t _tc1, *tc1 = &_tc1, _tc2, *tc2 = &_tc2, *tconn;
   tcp_connection_t *tc;
-  stream_session_t *s, *s1;
+  session_t *s, *s1;
   u8 cmp = 0, is_filtered = 0;
   u32 sidx;
 
   /*
    * Allocate fake session and connection 1
    */
-  pool_get (smm->sessions[0], s);
-  memset (s, 0, sizeof (*s));
-  s->session_index = sidx = s - smm->sessions[0];
+  pool_get (smm->wrk[0].sessions, s);
+  clib_memset (s, 0, sizeof (*s));
+  s->session_index = sidx = s - smm->wrk[0].sessions;
 
   pool_get (tm->connections[0], tc);
-  memset (tc, 0, sizeof (*tc));
+  clib_memset (tc, 0, sizeof (*tc));
   tc->connection.c_index = tc - tm->connections[0];
   tc->connection.s_index = s->session_index;
   s->connection_index = tc->connection.c_index;
@@ -1662,17 +1661,17 @@ tcp_test_lookup (vlib_main_t * vm, unformat_input_t * input)
   tc->connection.rmt_port = 53764;
   tc->connection.proto = TRANSPORT_PROTO_TCP;
   tc->connection.is_ip4 = 1;
-  clib_memcpy (tc1, &tc->connection, sizeof (*tc1));
+  clib_memcpy_fast (tc1, &tc->connection, sizeof (*tc1));
 
   /*
    * Allocate fake session and connection 2
    */
-  pool_get (session_manager_main.sessions[0], s);
-  memset (s, 0, sizeof (*s));
-  s->session_index = s - smm->sessions[0];
+  pool_get (smm->wrk[0].sessions, s);
+  clib_memset (s, 0, sizeof (*s));
+  s->session_index = s - smm->wrk[0].sessions;
 
   pool_get (tm->connections[0], tc);
-  memset (tc, 0, sizeof (*tc));
+  clib_memset (tc, 0, sizeof (*tc));
   tc->connection.c_index = tc - tm->connections[0];
   tc->connection.s_index = s->session_index;
   s->connection_index = tc->connection.c_index;
@@ -1683,13 +1682,13 @@ tcp_test_lookup (vlib_main_t * vm, unformat_input_t * input)
   tc->connection.rmt_port = 53764;
   tc->connection.proto = TRANSPORT_PROTO_TCP;
   tc->connection.is_ip4 = 1;
-  clib_memcpy (tc2, &tc->connection, sizeof (*tc2));
+  clib_memcpy_fast (tc2, &tc->connection, sizeof (*tc2));
 
   /*
    * Confirm that connection lookup works
    */
 
-  s1 = pool_elt_at_index (smm->sessions[0], sidx);
+  s1 = pool_elt_at_index (smm->wrk[0].sessions, sidx);
   session_lookup_add_connection (tc1, session_handle (s1));
   tconn = session_lookup_connection_wt4 (0, &tc1->lcl_ip.ip4,
                                         &tc1->rmt_ip.ip4,
@@ -1769,7 +1768,7 @@ tcp_test_session (vlib_main_t * vm, unformat_input_t * input)
       remote_port = clib_host_to_net_u16 (11234);
 
       pool_get (tm->connections[0], tc0);
-      memset (tc0, 0, sizeof (*tc0));
+      clib_memset (tc0, 0, sizeof (*tc0));
 
       tc0->state = TCP_STATE_ESTABLISHED;
       tc0->rcv_las = 1;
@@ -1785,17 +1784,17 @@ tcp_test_session (vlib_main_t * vm, unformat_input_t * input)
 
       TCP_EVT_DBG (TCP_EVT_OPEN, tc0);
 
-      if (stream_session_accept (&tc0->connection, 0 /* listener index */ ,
+      if (session_stream_accept (&tc0->connection, 0 /* listener index */ ,
                                 0 /* notify */ ))
        clib_warning ("stream_session_accept failed");
 
-      stream_session_accept_notify (&tc0->connection);
+      session_stream_accept_notify (&tc0->connection);
     }
   else
     {
       tc0 = tcp_connection_get (0 /* connection index */ , 0 /* thread */ );
       tc0->state = TCP_STATE_CLOSED;
-      stream_session_disconnect_notify (&tc0->connection);
+      session_transport_closing_notify (&tc0->connection);
     }
 
   return rv;