7af4b8a5262ef38117979df2a6a35ad6763c6a8e
[vpp.git] / src / plugins / hs_apps / echo_client.h
1
2 /*
3  * echo_client.h - built-in application layer echo client
4  *
5  * Copyright (c) 2017-2019 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #ifndef __included_echo_client_h__
19 #define __included_echo_client_h__
20
21 #include <hs_apps/hs_test.h>
22 #include <vnet/session/session.h>
23 #include <vnet/session/application_interface.h>
24
25 typedef struct ec_session_
26 {
27   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
28   app_session_t data;
29   u32 vpp_session_index;
30   u32 thread_index;
31   u64 bytes_to_send;
32   u64 bytes_sent;
33   u64 bytes_to_receive;
34   u64 bytes_received;
35   u64 vpp_session_handle;
36 } ec_session_t;
37
38 typedef struct ec_worker_
39 {
40   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
41   ec_session_t *sessions;       /**< session pool */
42   u8 *rx_buf;                   /**< prealloced rx buffer */
43   u32 *conn_indices;            /**< sessions handled by worker */
44   u32 *conns_this_batch;        /**< sessions handled in batch */
45   svm_msg_q_t *vpp_event_queue; /**< session layer worker mq */
46   u32 thread_index;             /**< thread index for worker */
47 } ec_worker_t;
48
49 typedef struct
50 {
51   ec_worker_t *wrk;              /**< Per-thread state */
52   u8 *connect_test_data;         /**< Pre-computed test data */
53
54   volatile u32 ready_connections;
55   volatile u64 rx_total;
56   volatile u64 tx_total;
57   volatile int run_test; /**< Signal start of test */
58
59   f64 syn_start_time;
60   f64 test_start_time;
61   f64 test_end_time;
62   u32 prev_conns;
63   u32 repeats;
64
65   u32 connect_conn_index; /**< Connects attempted progress */
66
67   /*
68    * Application setup parameters
69    */
70
71   u32 cli_node_index;                   /**< cli process node index */
72   u32 app_index;                        /**< app index after attach */
73   session_handle_t ctrl_session_handle; /**< control session handle */
74
75   /*
76    * Configuration params
77    */
78   hs_test_cfg_t cfg;
79   u32 n_clients;                        /**< Number of clients */
80   u8 *connect_uri;                      /**< URI for slave's connect */
81   session_endpoint_cfg_t connect_sep;   /**< Sever session endpoint */
82   u64 bytes_to_send;                    /**< Bytes to send */
83   u32 configured_segment_size;
84   u32 fifo_size;
85   u32 expected_connections;             /**< Number of clients/connections */
86   u32 connections_per_batch;            /**< Connections to rx/tx at once */
87   u32 private_segment_count;            /**< Number of private fifo segs */
88   u64 private_segment_size;             /**< size of private fifo segs */
89   u32 tls_engine;                       /**< TLS engine mbedtls/openssl */
90   u8 is_dgram;
91   u32 no_copy;                          /**< Don't memcpy data to tx fifo */
92   u32 quic_streams;                     /**< QUIC streams per connection */
93   u32 ckpair_index;                     /**< Cert key pair for tls/quic */
94   u64 attach_flags;                     /**< App attach flags */
95   u8 *appns_id;                         /**< App namespaces id */
96   u64 appns_secret;                     /**< App namespace secret */
97   f64 syn_timeout;                      /**< Test syn timeout (s) */
98   f64 test_timeout;                     /**< Test timeout (s) */
99
100   /*
101    * Flags
102    */
103   u8 app_is_init;
104   u8 test_client_attached;
105   u8 echo_bytes;
106   u8 test_return_packets;
107   int drop_packets;             /**< drop all packets */
108   u8 prealloc_fifos;            /**< Request fifo preallocation */
109   u8 prealloc_sessions;
110   u8 test_failed;
111   u8 transport_proto;
112   u8 barrier_acq_needed;
113
114   vlib_main_t *vlib_main;
115 } ec_main_t;
116
117 typedef enum ec_state_
118 {
119   EC_STARTING,
120   EC_RUNNING,
121   EC_EXITING
122 } ec_state_t;
123
124 typedef enum ec_cli_signal_
125 {
126   EC_CLI_CONNECTS_DONE = 1,
127   EC_CLI_CONNECTS_FAILED,
128   EC_CLI_CFG_SYNC,
129   EC_CLI_START,
130   EC_CLI_STOP,
131   EC_CLI_TEST_DONE
132 } ec_cli_signal_t;
133
134 void ec_program_connects (void);
135
136 #endif /* __included_echo_client_h__ */
137
138 /*
139  * fd.io coding-style-patch-verification: ON
140  *
141  * Local Variables:
142  * eval: (c-set-style "gnu")
143  * End:
144  */