FD.io VPP  v21.01.1
Vector Packet Processing
vcl_test.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2019 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __vcl_test_h__
17 #define __vcl_test_h__
18 
19 #include <netdb.h>
20 #include <errno.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <vcl/vppcom.h>
24 
25 #define vtfail(_fn, _rv) \
26 { \
27  errno = -_rv; \
28  perror ("ERROR when calling " _fn); \
29  fprintf (stderr, "\nERROR: " _fn " failed (errno = %d)!\n", -_rv); \
30  exit (1); \
31 }
32 
33 #define vterr(_fn, _rv) \
34 { \
35  errno = -_rv; \
36  fprintf (stderr, "\nERROR: " _fn " failed (errno = %d)!\n", -_rv); \
37 }
38 
39 #define vtwrn(_fmt, _args...) \
40  fprintf (stderr, "\nERROR: " _fmt "\n", ##_args) \
41 
42 #define vtinf(_fmt, _args...) \
43  fprintf (stdout, "vt<w%u>: " _fmt "\n", __wrk_index, ##_args)
44 
45 #define vt_atomic_add(_ptr, _val) \
46  __atomic_fetch_add (_ptr, _val, __ATOMIC_RELEASE)
47 
48 #define VCL_TEST_TOKEN_HELP "#H"
49 #define VCL_TEST_TOKEN_EXIT "#X"
50 #define VCL_TEST_TOKEN_VERBOSE "#V"
51 #define VCL_TEST_TOKEN_TXBUF_SIZE "#T:"
52 #define VCL_TEST_TOKEN_NUM_TEST_SESS "#I:"
53 #define VCL_TEST_TOKEN_NUM_WRITES "#N:"
54 #define VCL_TEST_TOKEN_RXBUF_SIZE "#R:"
55 #define VCL_TEST_TOKEN_SHOW_CFG "#C"
56 #define VCL_TEST_TOKEN_RUN_UNI "#U"
57 #define VCL_TEST_TOKEN_RUN_BI "#B"
58 
59 #define VCL_TEST_SERVER_PORT 22000
60 #define VCL_TEST_LOCALHOST_IPADDR "127.0.0.1"
61 
62 #define VCL_TEST_CFG_CTRL_MAGIC 0xfeedface
63 #define VCL_TEST_CFG_NUM_WRITES_DEF 1000000
64 #define VCL_TEST_CFG_TXBUF_SIZE_DEF 8192
65 #define VCL_TEST_CFG_RXBUF_SIZE_DEF (64*VCL_TEST_CFG_TXBUF_SIZE_DEF)
66 #define VCL_TEST_CFG_BUF_SIZE_MIN 128
67 #define VCL_TEST_CFG_MAX_TEST_SESS 32
68 #define VCL_TEST_CFG_MAX_EPOLL_EVENTS 16
69 
70 #define VCL_TEST_DELAY_DISCONNECT 1
71 #define VCL_TEST_SEPARATOR_STRING \
72  " -----------------------------\n"
73 typedef enum
74 {
80 } vcl_test_t;
81 
82 typedef struct __attribute__ ((packed))
83 {
84  uint32_t magic;
85  uint32_t seq_num;
86  uint32_t test;
87  uint32_t ctrl_handle;
91  uint32_t verbose;
92  uint32_t address_ip6;
93  uint32_t transport_udp;
94  uint64_t rxbuf_size;
95  uint64_t txbuf_size;
96  uint64_t num_writes;
97  uint64_t total_bytes;
99 
100 typedef struct
101 {
102  uint64_t rx_xacts;
103  uint64_t rx_bytes;
104  uint32_t rx_eagain;
105  uint32_t rx_incomp;
106  uint64_t tx_xacts;
107  uint64_t tx_bytes;
108  uint32_t tx_eagain;
109  uint32_t tx_incomp;
110  struct timespec start;
111  struct timespec stop;
113 
114 typedef struct
115 {
116  int fd;
117  uint32_t txbuf_size;
118  char *txbuf;
119  uint32_t rxbuf_size;
120  char *rxbuf;
125 
126 
127 /*
128  * TLS server cert and keys to be used for testing only
129  */
131  "-----BEGIN CERTIFICATE-----\r\n"
132  "MIID5zCCAs+gAwIBAgIJALeMYCEHrTtJMA0GCSqGSIb3DQEBCwUAMIGJMQswCQYD\r\n"
133  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w0BAQsFAAOCAQEAoUht13W4ya27NVzQuCMvqPWL3VM4\r\n"
148  "3xbPFk02FaGz/WupPu276zGlzJAZrbuDcQowwwU1Ni1Yygxl96s1c2M5rHDTrOKG\r\n"
149  "rK0hbkSFBo+i6I8u4HiiQ4rYmG0Hv6+sXn3of0HsbtDPGgWZoipPWDljPYEURu3e\r\n"
150  "3HRe/Dtsj9CakBoSDzs8ndWaBR+f4sM9Tk1cjD46Gq2T/qpSPXqKxEUXlzhdCAn4\r\n"
151  "twub17Bq2kykHpppCwPg5M+v30tHG/R2Go15MeFWbEJthFk3TZMjKL7UFs7fH+x2\r\n"
152  "wSonXb++jY+KmCb93C+soABBizE57g/KmiR2IxQ/LMjDik01RSUIaM0lLA==\r\n"
153  "-----END CERTIFICATE-----\r\n";
155 
157  "-----BEGIN PRIVATE KEY-----\r\n"
158  "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDgLWTxrUO5K2CC\r\n"
159  "CpPijT18/2wnZ0LnhvGFL9eTZUR9ohnbbZZKjhf+zJFV9XL1hqFykjXMn9EPFplI\r\n"
160  "WGAD6c9kGsUyytQuSt0A6k5WPx4MSn0m5Z07Y4NKgWcK8vFxhYFhzmQevImkRoYm\r\n"
161  "XWwVBJ6yfMwW3L/n21rSy2TQWnyvk2EiNa9Ki8bM+joGHP5VLZx5shmHjHW3aEdo\r\n"
162  "VyCbSomgnoNx5F5YJbzD7I5Wi9OiUYar5ulvYefsydFJnYrY10v5otemRltL8A4M\r\n"
163  "/UUXa9M7WZgvb3Qs7v/nW8mY9c0pINgzLkS8guvn9Wq2OwULBEtDiNwz/4Z4dIAV\r\n"
164  "bHioi/QHAgMBAAECggEBAMzGipP8+oT166U+NlJXRFifFVN1DvdhG9PWnOxGL+c3\r\n"
165  "ILmBBC08WQzmHshPemBvR6DZkA1H23cV5JTiLWrFtC00CvhXsLRMrE5+uWotI6yE\r\n"
166  "iofybMroHvD6/X5R510UX9hQ6MHu5ShLR5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NWv+iVM1WyFjbe++vfKZCrOJiyiqhDeEqgrP3AuNMlaaduC3VRC3G5oV\r\n"
182  "Mj1tlhDWQ/qhvKdCKNdIVQYDE75nw+FRWV8yYkHAnXYW3tNoweDIwixE0hkPR1bc\r\n"
183  "oEjPLVNtx8SOj/M4rhaPT3I=\r\n" "-----END PRIVATE KEY-----\r\n";
185 
186 static inline void
188 {
189  accum->rx_xacts += incr->rx_xacts;
190  accum->rx_bytes += incr->rx_bytes;
191  accum->rx_eagain += incr->rx_eagain;
192  accum->rx_incomp += incr->rx_incomp;
193  accum->tx_xacts += incr->tx_xacts;
194  accum->tx_bytes += incr->tx_bytes;
195  accum->tx_eagain += incr->tx_eagain;
196  accum->tx_incomp += incr->tx_incomp;
197 }
198 
199 static inline void
201 {
203  cfg->test = VCL_TEST_TYPE_NONE;
204  cfg->ctrl_handle = ~0;
205  cfg->num_test_sessions = 1;
206  cfg->num_test_sessions_perq = 1;
207  cfg->verbose = 0;
211  cfg->total_bytes = cfg->num_writes * cfg->txbuf_size;
212 }
213 
214 static inline int
216 {
217  /* Note: txbuf & rxbuf on server are the same buffer,
218  * so txbuf_size is not included in this check.
219  */
220  return ((cfg->magic == valid_cfg->magic)
221  && (cfg->test == valid_cfg->test)
222  && (cfg->verbose == valid_cfg->verbose)
223  && (cfg->rxbuf_size == valid_cfg->rxbuf_size)
224  && (cfg->num_writes == valid_cfg->num_writes)
225  && (cfg->total_bytes == valid_cfg->total_bytes));
226 }
227 
228 static inline void
229 vcl_test_buf_alloc (vcl_test_cfg_t * cfg, uint8_t is_rxbuf, uint8_t ** buf,
230  uint32_t * bufsize)
231 {
232  uint32_t alloc_size = is_rxbuf ? cfg->rxbuf_size : cfg->txbuf_size;
233  uint8_t *lb = realloc (*buf, (size_t) alloc_size);
234 
235  if (lb)
236  {
237  if (is_rxbuf)
238  cfg->rxbuf_size = *bufsize = alloc_size;
239  else
240  cfg->txbuf_size = *bufsize = alloc_size;
241 
242  *buf = lb;
243  }
244  else
245  {
246  vtwrn ("realloc failed. using buffer size %d instead of %u",
247  *bufsize, alloc_size);
248  }
249 }
250 
251 static inline void
253 {
254  socket->rxbuf_size = socket->cfg.rxbuf_size;
255  socket->txbuf_size = socket->cfg.txbuf_size;
256  vcl_test_buf_alloc (&socket->cfg, 0 /* is_rxbuf */ ,
257  (uint8_t **) & socket->txbuf, &socket->txbuf_size);
258  vcl_test_buf_alloc (&socket->cfg, 1 /* is_rxbuf */ ,
259  (uint8_t **) & socket->rxbuf, &socket->rxbuf_size);
260 }
261 
262 static inline char *
264 {
265  switch (t)
266  {
267  case VCL_TEST_TYPE_NONE:
268  return "NONE";
269 
270  case VCL_TEST_TYPE_ECHO:
271  return "ECHO";
272 
273  case VCL_TEST_TYPE_UNI:
274  return "UNI";
275 
276  case VCL_TEST_TYPE_BI:
277  return "BI";
278 
279  case VCL_TEST_TYPE_EXIT:
280  return "EXIT";
281 
282  default:
283  return "Unknown";
284  }
285 }
286 
287 static inline void
288 vcl_test_cfg_dump (vcl_test_cfg_t * cfg, uint8_t is_client)
289 {
290  char *spc = " ";
291 
292  printf (" test config (%p):\n"
294  " magic: 0x%08x\n"
295  " seq_num: 0x%08x\n"
296  "%-5s test: %s (%d)\n"
297  " ctrl handle: %d (0x%x)\n"
298  "%-5s num test sockets: %u (0x%08x)\n"
299  "%-5s verbose: %s (%d)\n"
300  "%-5s rxbuf size: %lu (0x%08lx)\n"
301  "%-5s txbuf size: %lu (0x%08lx)\n"
302  "%-5s num writes: %lu (0x%08lx)\n"
303  " client tx bytes: %lu (0x%08lx)\n"
305  (void *) cfg, cfg->magic, cfg->seq_num,
306  is_client && (cfg->test == VCL_TEST_TYPE_UNI) ?
307  "'" VCL_TEST_TOKEN_RUN_UNI "'" :
308  is_client && (cfg->test == VCL_TEST_TYPE_BI) ?
309  "'" VCL_TEST_TOKEN_RUN_BI "'" : spc,
310  vcl_test_type_str (cfg->test), cfg->test,
311  cfg->ctrl_handle, cfg->ctrl_handle,
312  is_client ? "'" VCL_TEST_TOKEN_NUM_TEST_SESS "'" : spc,
313  cfg->num_test_sessions, cfg->num_test_sessions,
314  is_client ? "'" VCL_TEST_TOKEN_VERBOSE "'" : spc,
315  cfg->verbose ? "on" : "off", cfg->verbose,
316  is_client ? "'" VCL_TEST_TOKEN_RXBUF_SIZE "'" : spc,
317  cfg->rxbuf_size, cfg->rxbuf_size,
318  is_client ? "'" VCL_TEST_TOKEN_TXBUF_SIZE "'" : spc,
319  cfg->txbuf_size, cfg->txbuf_size,
320  is_client ? "'" VCL_TEST_TOKEN_NUM_WRITES "'" : spc,
321  cfg->num_writes, cfg->num_writes,
322  cfg->total_bytes, cfg->total_bytes);
323 }
324 
325 static inline void
326 vcl_test_stats_dump (char *header, vcl_test_stats_t * stats,
327  uint8_t show_rx, uint8_t show_tx, uint8_t verbose)
328 {
329  struct timespec diff;
330  double duration, rate;
331  uint64_t total_bytes;
332 
333  if ((stats->stop.tv_nsec - stats->start.tv_nsec) < 0)
334  {
335  diff.tv_sec = stats->stop.tv_sec - stats->start.tv_sec - 1;
336  diff.tv_nsec = stats->stop.tv_nsec - stats->start.tv_nsec + 1e9;
337  }
338  else
339  {
340  diff.tv_sec = stats->stop.tv_sec - stats->start.tv_sec;
341  diff.tv_nsec = stats->stop.tv_nsec - stats->start.tv_nsec;
342  }
343  duration = (double) diff.tv_sec + (1e-9 * diff.tv_nsec);
344 
345  total_bytes = stats->tx_bytes + stats->rx_bytes;
346  rate = (double) total_bytes *8 / duration / 1e9;
347  printf ("\n%s: Streamed %lu bytes\n"
348  " in %lf seconds (%lf Gbps %s-duplex)!\n",
349  header, total_bytes, duration, rate,
350  (show_rx && show_tx) ? "full" : "half");
351 
352  if (show_tx)
353  {
355  " tx stats (0x%p):\n"
357  " writes: %lu (0x%08lx)\n"
358  " tx bytes: %lu (0x%08lx)\n"
359  " tx eagain: %u (0x%08x)\n"
360  " tx incomplete: %u (0x%08x)\n",
361  (void *) stats, stats->tx_xacts, stats->tx_xacts,
362  stats->tx_bytes, stats->tx_bytes,
363  stats->tx_eagain, stats->tx_eagain,
364  stats->tx_incomp, stats->tx_incomp);
365  }
366  if (show_rx)
367  {
369  " rx stats (0x%p):\n"
371  " reads: %lu (0x%08lx)\n"
372  " rx bytes: %lu (0x%08lx)\n"
373  " rx eagain: %u (0x%08x)\n"
374  " rx incomplete: %u (0x%08x)\n",
375  (void *) stats, stats->rx_xacts, stats->rx_xacts,
376  stats->rx_bytes, stats->rx_bytes,
377  stats->rx_eagain, stats->rx_eagain,
378  stats->rx_incomp, stats->rx_incomp);
379  }
380  if (verbose)
381  printf (" start.tv_sec: %ld\n"
382  " start.tv_nsec: %ld\n"
383  " stop.tv_sec: %ld\n"
384  " stop.tv_nsec: %ld\n",
385  stats->start.tv_sec, stats->start.tv_nsec,
386  stats->stop.tv_sec, stats->stop.tv_nsec);
387 
388  printf (VCL_TEST_SEPARATOR_STRING);
389 }
390 
391 static inline int
392 vcl_comp_tspec (struct timespec *a, struct timespec *b)
393 {
394  if (a->tv_sec < b->tv_sec)
395  return -1;
396  else if (a->tv_sec > b->tv_sec)
397  return 1;
398  else if (a->tv_nsec < b->tv_nsec)
399  return -1;
400  else if (a->tv_nsec > b->tv_nsec)
401  return 1;
402  else
403  return 0;
404 }
405 
406 static inline int
407 vcl_test_read (int fd, uint8_t * buf, uint32_t nbytes,
408  vcl_test_stats_t * stats)
409 {
410  int rx_bytes;
411 
412  do
413  {
414  if (stats)
415  stats->rx_xacts++;
416  rx_bytes = vppcom_session_read (fd, buf, nbytes);
417 
418  if (rx_bytes < 0)
419  {
420  errno = -rx_bytes;
421  rx_bytes = -1;
422  }
423  if (stats)
424  {
425  if ((rx_bytes == 0) ||
426  ((rx_bytes < 0)
427  && ((errno == EAGAIN) || (errno == EWOULDBLOCK))))
428  stats->rx_eagain++;
429  else if (rx_bytes < nbytes)
430  stats->rx_incomp++;
431  }
432  }
433  while ((rx_bytes == 0) ||
434  ((rx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))));
435 
436  if (rx_bytes < 0)
437  {
438  vterr ("vppcom_session_read()", -errno);
439  }
440  else if (stats)
441  stats->rx_bytes += rx_bytes;
442 
443  return (rx_bytes);
444 }
445 
446 static inline int
447 vcl_test_read_ds (int fd, vppcom_data_segment_t * ds,
448  vcl_test_stats_t * stats)
449 {
450  int rx_bytes;
451 
452  do
453  {
454  if (stats)
455  stats->rx_xacts++;
456  rx_bytes = vppcom_session_read_segments (fd, ds, 2, ~0);
457 
458  if (rx_bytes < 0)
459  {
460  errno = -rx_bytes;
461  rx_bytes = -1;
462  }
463  if (stats)
464  {
465  if ((rx_bytes == 0) ||
466  ((rx_bytes < 0)
467  && ((errno == EAGAIN) || (errno == EWOULDBLOCK))))
468  stats->rx_eagain++;
469  }
470  }
471  while ((rx_bytes == 0) ||
472  ((rx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))));
473 
474  if (rx_bytes < 0)
475  {
476  vterr ("vppcom_session_read()", -errno);
477  }
478  else if (stats)
479  stats->rx_bytes += rx_bytes;
480 
481  return (rx_bytes);
482 }
483 
484 static inline int
485 vcl_test_write (int fd, uint8_t * buf, uint32_t nbytes,
486  vcl_test_stats_t * stats, uint32_t verbose)
487 {
488  int tx_bytes = 0, nbytes_left = nbytes, rv;
489 
490  do
491  {
492  if (stats)
493  stats->tx_xacts++;
494  rv = vppcom_session_write (fd, buf, nbytes_left);
495  if (rv < 0)
496  {
497  errno = -rv;
498  if ((errno == EAGAIN || errno == EWOULDBLOCK) && stats)
499  stats->tx_eagain++;
500  break;
501  }
502  tx_bytes += rv;
503 
504  nbytes_left = nbytes_left - rv;
505  buf += rv;
506  if (stats)
507  stats->tx_incomp++;
508 
509  }
510  while (tx_bytes != nbytes);
511 
512  if (tx_bytes < 0)
513  {
514  vterr ("vpcom_session_write", -errno);
515  }
516  else if (stats)
517  stats->tx_bytes += tx_bytes;
518 
519  return (tx_bytes);
520 }
521 
522 static inline void
523 dump_help (void)
524 {
525 #define INDENT "\n "
526 
527  printf ("CLIENT: Test configuration commands:"
529  "\t\t\tDisplay help."
531  "\t\t\tExit test client & server."
533  "\t\t\tShow the current test cfg."
535  "\t\t\tRun the Uni-directional test."
537  "\t\t\tRun the Bi-directional test."
539  "\t\t\tToggle verbose setting."
541  "<rxbuf size>\tRx buffer size (bytes)."
543  "<txbuf size>\tTx buffer size (bytes)."
545  "<# of writes>\tNumber of txbuf writes to server." "\n");
546 }
547 
548 #endif /* __vcl_test_h__ */
549 
550 /*
551  * fd.io coding-style-patch-verification: ON
552  *
553  * Local Variables:
554  * eval: (c-set-style "gnu")
555  * End:
556  */
#define VCL_TEST_TOKEN_RXBUF_SIZE
Definition: vcl_test.h:54
a
Definition: bitmap.h:544
uint32_t vcl_test_crt_rsa_len
Definition: vcl_test.h:154
struct timespec stop
Definition: vcl_test.h:111
Optimized string handling code, including c11-compliant "safe C library" variants.
uint32_t num_test_qsessions
Definition: vcl_test.h:90
static void dump_help(void)
Definition: vcl_test.h:523
static int vcl_test_read_ds(int fd, vppcom_data_segment_t *ds, vcl_test_stats_t *stats)
Definition: vcl_test.h:447
uint32_t num_test_sessions
Definition: vcl_test.h:88
uint32_t transport_udp
Definition: vcl_test.h:93
uint32_t rx_eagain
Definition: vcl_test.h:104
struct timespec start
Definition: vcl_test.h:110
#define VCL_TEST_TOKEN_NUM_WRITES
Definition: vcl_test.h:53
uint64_t num_writes
Definition: vcl_test.h:96
#define VCL_TEST_TOKEN_SHOW_CFG
Definition: vcl_test.h:55
vcl_test_t
Definition: vcl_test.h:73
#define INDENT
uint64_t txbuf_size
Definition: vcl_test.h:95
const cJSON *const b
Definition: cJSON.h:255
static void vcl_test_stats_dump(char *header, vcl_test_stats_t *stats, uint8_t show_rx, uint8_t show_tx, uint8_t verbose)
Definition: vcl_test.h:326
#define vterr(_fn, _rv)
Definition: vcl_test.h:33
uint32_t txbuf_size
Definition: vcl_test.h:117
char vcl_test_key_rsa[]
Definition: vcl_test.h:156
static char * vcl_test_type_str(vcl_test_t t)
Definition: vcl_test.h:263
uint32_t seq_num
Definition: vcl_test.h:85
vcl_test_cfg_t cfg
Definition: vcl_test.h:121
uint32_t verbose
Definition: vcl_test.h:91
#define VCL_TEST_SEPARATOR_STRING
Definition: vcl_test.h:71
static void vcl_test_session_buf_alloc(vcl_test_session_t *socket)
Definition: vcl_test.h:252
static void vcl_test_cfg_dump(vcl_test_cfg_t *cfg, uint8_t is_client)
Definition: vcl_test.h:288
#define VCL_TEST_CFG_CTRL_MAGIC
Definition: vcl_test.h:62
#define VCL_TEST_TOKEN_RUN_BI
Definition: vcl_test.h:57
uint32_t address_ip6
Definition: vcl_test.h:92
uint64_t rxbuf_size
Definition: vcl_test.h:94
static void vcl_test_cfg_init(vcl_test_cfg_t *cfg)
Definition: vcl_test.h:200
#define VCL_TEST_TOKEN_TXBUF_SIZE
Definition: vcl_test.h:51
#define VCL_TEST_TOKEN_VERBOSE
Definition: vcl_test.h:50
char vcl_test_crt_rsa[]
Definition: vcl_test.h:130
uint32_t num_test_sessions_perq
Definition: vcl_test.h:89
#define VCL_TEST_TOKEN_HELP
Definition: vcl_test.h:48
uint32_t magic
Definition: vcl_test.h:84
static void vcl_test_buf_alloc(vcl_test_cfg_t *cfg, uint8_t is_rxbuf, uint8_t **buf, uint32_t *bufsize)
Definition: vcl_test.h:229
static int vcl_test_read(int fd, uint8_t *buf, uint32_t nbytes, vcl_test_stats_t *stats)
Definition: vcl_test.h:407
uint32_t ctrl_handle
Definition: vcl_test.h:87
vcl_test_stats_t stats
Definition: vcl_test.h:122
uint32_t rx_incomp
Definition: vcl_test.h:105
void * realloc(void *p, size_t size)
Definition: mem.c:67
static int vcl_test_write(int fd, uint8_t *buf, uint32_t nbytes, vcl_test_stats_t *stats, uint32_t verbose)
Definition: vcl_test.h:485
uint64_t tx_bytes
Definition: vcl_test.h:107
uint32_t vcl_test_key_rsa_len
Definition: vcl_test.h:184
uint64_t tx_xacts
Definition: vcl_test.h:106
uint32_t tx_eagain
Definition: vcl_test.h:108
#define VCL_TEST_CFG_NUM_WRITES_DEF
Definition: vcl_test.h:63
#define VCL_TEST_TOKEN_RUN_UNI
Definition: vcl_test.h:56
uint32_t rxbuf_size
Definition: vcl_test.h:119
uint32_t test
Definition: vcl_test.h:86
static int vcl_comp_tspec(struct timespec *a, struct timespec *b)
Definition: vcl_test.h:392
static void vcl_test_stats_accumulate(vcl_test_stats_t *accum, vcl_test_stats_t *incr)
Definition: vcl_test.h:187
#define VCL_TEST_CFG_RXBUF_SIZE_DEF
Definition: vcl_test.h:65
#define VCL_TEST_CFG_TXBUF_SIZE_DEF
Definition: vcl_test.h:64
#define VCL_TEST_TOKEN_NUM_TEST_SESS
Definition: vcl_test.h:52
#define VCL_TEST_TOKEN_EXIT
Definition: vcl_test.h:49
uint32_t tx_incomp
Definition: vcl_test.h:109
static int vcl_test_cfg_verify(vcl_test_cfg_t *cfg, vcl_test_cfg_t *valid_cfg)
Definition: vcl_test.h:215
uint64_t rx_bytes
Definition: vcl_test.h:103
uint64_t total_bytes
Definition: vcl_test.h:97
uint64_t rx_xacts
Definition: vcl_test.h:102
#define vtwrn(_fmt, _args...)
Definition: vcl_test.h:39