blob: 34cf0bd4764f58a7167cb417f8b7458c8f74ce0f [file] [log] [blame]
Florin Coras6792ec02017-03-13 03:49:51 -07001
2/*
Florin Coras4399c2e2018-01-25 06:34:42 -08003 * echo_client.h - built-in application layer echo client
Florin Coras6792ec02017-03-13 03:49:51 -07004 *
Florin Corasc5df8c72019-04-08 07:42:30 -07005 * Copyright (c) 2017-2019 Cisco and/or its affiliates.
Florin Coras6792ec02017-03-13 03:49:51 -07006 * 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 */
Florin Coras4399c2e2018-01-25 06:34:42 -080018#ifndef __included_echo_client_h__
19#define __included_echo_client_h__
Florin Coras6792ec02017-03-13 03:49:51 -070020
21#include <vnet/vnet.h>
22#include <vnet/ip/ip.h>
23#include <vnet/ethernet/ethernet.h>
24
25#include <vppinfra/hash.h>
26#include <vppinfra/error.h>
Florin Coras6792ec02017-03-13 03:49:51 -070027#include <vnet/session/session.h>
28#include <vnet/session/application_interface.h>
29
30typedef struct
31{
Florin Coras48750892018-05-16 09:28:02 -070032 CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
Florin Coras7fb0fe12018-04-09 09:24:52 -070033 app_session_t data;
Dave Barach0194f1a2017-05-15 10:11:39 -040034 u64 bytes_to_send;
35 u64 bytes_sent;
36 u64 bytes_to_receive;
37 u64 bytes_received;
Florin Coras6cf30ad2017-04-04 23:08:23 -070038 u64 vpp_session_handle;
Florin Coras7fb0fe12018-04-09 09:24:52 -070039 u8 thread_index;
Florin Coras48750892018-05-16 09:28:02 -070040} eclient_session_t;
Florin Coras6792ec02017-03-13 03:49:51 -070041
42typedef struct
43{
Florin Corasf03a59a2017-06-09 21:07:32 -070044 /*
45 * Application setup parameters
46 */
Florin Coras7fb0fe12018-04-09 09:24:52 -070047 svm_queue_t *vl_input_queue; /**< vpe input queue */
Florin Coras3c2fed52018-07-04 04:15:05 -070048 svm_msg_q_t **vpp_event_queue;
Florin Coras6792ec02017-03-13 03:49:51 -070049
Florin Corasf03a59a2017-06-09 21:07:32 -070050 u32 cli_node_index; /**< cli process node index */
51 u32 my_client_index; /**< loopback API client handle */
52 u32 app_index; /**< app index after attach */
Florin Coras6792ec02017-03-13 03:49:51 -070053
Florin Corasf03a59a2017-06-09 21:07:32 -070054 /*
55 * Configuration params
56 */
57 u8 *connect_uri; /**< URI for slave's connect */
58 u64 bytes_to_send; /**< Bytes to send */
59 u32 configured_segment_size;
60 u32 fifo_size;
61 u32 expected_connections; /**< Number of clients/connections */
Dave Barach2c25a622017-06-26 11:35:07 -040062 u32 connections_per_batch; /**< Connections to rx/tx at once */
63 u32 private_segment_count; /**< Number of private fifo segs */
64 u32 private_segment_size; /**< size of private fifo segs */
Florin Coras58d36f02018-03-09 13:05:53 -080065 u32 tls_engine; /**< TLS engine mbedtls/openssl */
Florin Coras7fb0fe12018-04-09 09:24:52 -070066 u8 is_dgram;
Florin Coras8e43d042018-05-04 15:46:57 -070067 u32 no_copy; /**< Don't memcpy data to tx fifo */
Dave Wallace211b28a2019-05-08 20:46:33 -040068 u32 quic_streams; /**< QUIC streams per connection */
Florin Coras8e43d042018-05-04 15:46:57 -070069
Florin Corasf03a59a2017-06-09 21:07:32 -070070 /*
71 * Test state variables
72 */
Florin Coras48750892018-05-16 09:28:02 -070073 eclient_session_t *sessions; /**< Session pool, shared */
Florin Coras68810622017-07-24 17:40:28 -070074 clib_spinlock_t sessions_lock;
75 u8 **rx_buf; /**< intermediate rx buffers */
Florin Corasf03a59a2017-06-09 21:07:32 -070076 u8 *connect_test_data; /**< Pre-computed test data */
Aloys Augustin502785b2019-04-09 11:40:57 +020077 u32 **quic_session_index_by_thread;
Florin Corasf03a59a2017-06-09 21:07:32 -070078 u32 **connection_index_by_thread;
Dave Barach2c25a622017-06-26 11:35:07 -040079 u32 **connections_this_batch_by_thread; /**< active connection batch */
Florin Corasf03a59a2017-06-09 21:07:32 -070080 pthread_t client_thread_handle;
Florin Coras6792ec02017-03-13 03:49:51 -070081
Florin Corasf03a59a2017-06-09 21:07:32 -070082 volatile u32 ready_connections;
83 volatile u32 finished_connections;
84 volatile u64 rx_total;
85 volatile u64 tx_total;
86 volatile int run_test; /**< Signal start of test */
Florin Coras6792ec02017-03-13 03:49:51 -070087
Dave Barach10d8cc62017-05-30 09:30:07 -040088 f64 test_start_time;
89 f64 test_end_time;
Dave Barach2c25a622017-06-26 11:35:07 -040090 u32 prev_conns;
91 u32 repeats;
Florin Corasf03a59a2017-06-09 21:07:32 -070092 /*
93 * Flags
94 */
Florin Coras6cf30ad2017-04-04 23:08:23 -070095 u8 is_init;
Dave Barach10d8cc62017-05-30 09:30:07 -040096 u8 test_client_attached;
Florin Corasf03a59a2017-06-09 21:07:32 -070097 u8 no_return;
98 u8 test_return_packets;
99 int i_am_master;
100 int drop_packets; /**< drop all packets */
101 u8 prealloc_fifos; /**< Request fifo preallocation */
Florin Corasb795bd02017-12-14 11:30:48 -0800102 u8 no_output;
103 u8 test_bytes;
104 u8 test_failed;
Aloys Augustin502785b2019-04-09 11:40:57 +0200105 u8 transport_proto;
Florin Coras6cf30ad2017-04-04 23:08:23 -0700106
Florin Coras6792ec02017-03-13 03:49:51 -0700107 vlib_main_t *vlib_main;
Florin Coras4399c2e2018-01-25 06:34:42 -0800108} echo_client_main_t;
Florin Coras6792ec02017-03-13 03:49:51 -0700109
Florin Coraseb97e5f2018-10-15 21:35:42 -0700110enum
111{
112 ECHO_CLIENTS_STARTING,
113 ECHO_CLIENTS_RUNNING,
114 ECHO_CLIENTS_EXITING
115} echo_clients_test_state_e;
Florin Coras4399c2e2018-01-25 06:34:42 -0800116extern echo_client_main_t echo_client_main;
Florin Coras6792ec02017-03-13 03:49:51 -0700117
Florin Coras4399c2e2018-01-25 06:34:42 -0800118vlib_node_registration_t echo_clients_node;
Florin Coras6792ec02017-03-13 03:49:51 -0700119
Florin Coras4399c2e2018-01-25 06:34:42 -0800120#endif /* __included_echo_client_h__ */
Florin Coras6792ec02017-03-13 03:49:51 -0700121
122/*
123 * fd.io coding-style-patch-verification: ON
124 *
125 * Local Variables:
126 * eval: (c-set-style "gnu")
127 * End:
128 */