Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 16 | #include <math.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 17 | #include <vlib/vlib.h> |
| 18 | #include <vnet/vnet.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 19 | #include <vppinfra/elog.h> |
Florin Coras | 561af9b | 2017-12-09 10:19:43 -0800 | [diff] [blame] | 20 | #include <vnet/session/transport.h> |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 21 | #include <vnet/session/session.h> |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 22 | #include <vnet/session/application.h> |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 23 | #include <vnet/session/session_debug.h> |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 24 | #include <svm/queue.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 25 | |
| 26 | vlib_node_registration_t session_queue_node; |
| 27 | |
| 28 | typedef struct |
| 29 | { |
| 30 | u32 session_index; |
| 31 | u32 server_thread_index; |
| 32 | } session_queue_trace_t; |
| 33 | |
| 34 | /* packet trace format function */ |
| 35 | static u8 * |
| 36 | format_session_queue_trace (u8 * s, va_list * args) |
| 37 | { |
| 38 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 39 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
| 40 | session_queue_trace_t *t = va_arg (*args, session_queue_trace_t *); |
| 41 | |
| 42 | s = format (s, "SESSION_QUEUE: session index %d, server thread index %d", |
| 43 | t->session_index, t->server_thread_index); |
| 44 | return s; |
| 45 | } |
| 46 | |
| 47 | vlib_node_registration_t session_queue_node; |
| 48 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 49 | #define foreach_session_queue_error \ |
| 50 | _(TX, "Packets transmitted") \ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 51 | _(TIMER, "Timer events") \ |
| 52 | _(NO_BUFFER, "Out of buffers") |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 53 | |
| 54 | typedef enum |
| 55 | { |
| 56 | #define _(sym,str) SESSION_QUEUE_ERROR_##sym, |
| 57 | foreach_session_queue_error |
| 58 | #undef _ |
| 59 | SESSION_QUEUE_N_ERROR, |
| 60 | } session_queue_error_t; |
| 61 | |
| 62 | static char *session_queue_error_strings[] = { |
| 63 | #define _(sym,string) string, |
| 64 | foreach_session_queue_error |
| 65 | #undef _ |
| 66 | }; |
| 67 | |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 68 | always_inline void |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 69 | session_tx_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 70 | u32 next_index, vlib_buffer_t * b, |
| 71 | stream_session_t * s, u32 * n_trace) |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 72 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 73 | session_queue_trace_t *t; |
| 74 | vlib_trace_buffer (vm, node, next_index, b, 1 /* follow_chain */ ); |
| 75 | vlib_set_trace_count (vm, node, --*n_trace); |
| 76 | t = vlib_add_trace (vm, node, b, sizeof (*t)); |
| 77 | t->session_index = s->session_index; |
| 78 | t->server_thread_index = s->thread_index; |
| 79 | } |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 80 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 81 | always_inline void |
| 82 | session_tx_fifo_chain_tail (vlib_main_t * vm, session_tx_context_t * ctx, |
| 83 | vlib_buffer_t * b, u16 * n_bufs, u8 peek_data) |
| 84 | { |
| 85 | session_manager_main_t *smm = &session_manager_main; |
| 86 | vlib_buffer_t *chain_b, *prev_b; |
| 87 | u32 chain_bi0, to_deq, left_from_seg; |
| 88 | u16 len_to_deq, n_bytes_read; |
| 89 | u8 *data, j; |
Florin Coras | b2215d6 | 2017-08-01 16:56:58 -0700 | [diff] [blame] | 90 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 91 | b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID; |
| 92 | b->total_length_not_including_first_buffer = 0; |
| 93 | |
| 94 | chain_b = b; |
| 95 | left_from_seg = clib_min (ctx->snd_mss - b->current_length, |
| 96 | ctx->left_to_snd); |
Florin Coras | b2215d6 | 2017-08-01 16:56:58 -0700 | [diff] [blame] | 97 | to_deq = left_from_seg; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 98 | for (j = 1; j < ctx->n_bufs_per_seg; j++) |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 99 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 100 | prev_b = chain_b; |
| 101 | len_to_deq = clib_min (to_deq, ctx->deq_per_buf); |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 102 | |
| 103 | *n_bufs -= 1; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 104 | chain_bi0 = smm->tx_buffers[ctx->s->thread_index][*n_bufs]; |
| 105 | _vec_len (smm->tx_buffers[ctx->s->thread_index]) = *n_bufs; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 106 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 107 | chain_b = vlib_get_buffer (vm, chain_bi0); |
| 108 | chain_b->current_data = 0; |
| 109 | data = vlib_buffer_get_current (chain_b); |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 110 | if (peek_data) |
| 111 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 112 | n_bytes_read = svm_fifo_peek (ctx->s->server_tx_fifo, |
| 113 | ctx->tx_offset, len_to_deq, data); |
| 114 | ctx->tx_offset += n_bytes_read; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 115 | } |
| 116 | else |
| 117 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 118 | if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 119 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 120 | svm_fifo_t *f = ctx->s->server_tx_fifo; |
| 121 | session_dgram_hdr_t *hdr = &ctx->hdr; |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 122 | u16 deq_now; |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 123 | deq_now = clib_min (hdr->data_length - hdr->data_offset, |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 124 | len_to_deq); |
| 125 | n_bytes_read = svm_fifo_peek (f, hdr->data_offset, deq_now, |
| 126 | data); |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 127 | ASSERT (n_bytes_read > 0); |
| 128 | |
| 129 | hdr->data_offset += n_bytes_read; |
| 130 | if (hdr->data_offset == hdr->data_length) |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 131 | svm_fifo_dequeue_drop (f, hdr->data_length); |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 132 | } |
| 133 | else |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 134 | n_bytes_read = svm_fifo_dequeue_nowait (ctx->s->server_tx_fifo, |
| 135 | len_to_deq, data); |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 136 | } |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 137 | ASSERT (n_bytes_read == len_to_deq); |
| 138 | chain_b->current_length = n_bytes_read; |
| 139 | b->total_length_not_including_first_buffer += chain_b->current_length; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 140 | |
| 141 | /* update previous buffer */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 142 | prev_b->next_buffer = chain_bi0; |
| 143 | prev_b->flags |= VLIB_BUFFER_NEXT_PRESENT; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 144 | |
| 145 | /* update current buffer */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 146 | chain_b->next_buffer = 0; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 147 | |
Florin Coras | b2215d6 | 2017-08-01 16:56:58 -0700 | [diff] [blame] | 148 | to_deq -= n_bytes_read; |
| 149 | if (to_deq == 0) |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 150 | break; |
| 151 | } |
Florin Coras | 1f152cd | 2017-08-18 19:28:03 -0700 | [diff] [blame] | 152 | ASSERT (to_deq == 0 |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 153 | && b->total_length_not_including_first_buffer == left_from_seg); |
| 154 | ctx->left_to_snd -= left_from_seg; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 157 | always_inline int |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 158 | session_output_try_get_buffers (vlib_main_t * vm, |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 159 | session_manager_main_t * smm, |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 160 | u32 thread_index, u16 * n_bufs, u32 wanted) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 161 | { |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 162 | u32 n_alloc; |
| 163 | vec_validate_aligned (smm->tx_buffers[thread_index], wanted - 1, |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 164 | CLIB_CACHE_LINE_BYTES); |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 165 | n_alloc = vlib_buffer_alloc (vm, &smm->tx_buffers[thread_index][*n_bufs], |
| 166 | wanted - *n_bufs); |
| 167 | *n_bufs += n_alloc; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 168 | _vec_len (smm->tx_buffers[thread_index]) = *n_bufs; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 169 | return n_alloc; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | always_inline void |
| 173 | session_tx_fill_buffer (vlib_main_t * vm, session_tx_context_t * ctx, |
| 174 | vlib_buffer_t * b, u16 * n_bufs, u8 peek_data) |
| 175 | { |
| 176 | u32 len_to_deq; |
| 177 | u8 *data0; |
| 178 | int n_bytes_read; |
| 179 | |
| 180 | /* |
| 181 | * Start with the first buffer in chain |
| 182 | */ |
| 183 | b->error = 0; |
| 184 | b->flags = VNET_BUFFER_F_LOCALLY_ORIGINATED; |
| 185 | b->current_data = 0; |
| 186 | b->total_length_not_including_first_buffer = 0; |
| 187 | |
| 188 | data0 = vlib_buffer_make_headroom (b, MAX_HDRS_LEN); |
| 189 | len_to_deq = clib_min (ctx->left_to_snd, ctx->deq_per_first_buf); |
| 190 | |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 191 | if (peek_data) |
| 192 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 193 | n_bytes_read = svm_fifo_peek (ctx->s->server_tx_fifo, ctx->tx_offset, |
| 194 | len_to_deq, data0); |
| 195 | ASSERT (n_bytes_read > 0); |
| 196 | /* Keep track of progress locally, transport is also supposed to |
| 197 | * increment it independently when pushing the header */ |
| 198 | ctx->tx_offset += n_bytes_read; |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 199 | } |
| 200 | else |
| 201 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 202 | if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) |
| 203 | { |
| 204 | session_dgram_hdr_t *hdr = &ctx->hdr; |
| 205 | svm_fifo_t *f = ctx->s->server_tx_fifo; |
| 206 | u16 deq_now; |
| 207 | u32 offset; |
| 208 | |
| 209 | ASSERT (hdr->data_length > hdr->data_offset); |
| 210 | deq_now = clib_min (hdr->data_length - hdr->data_offset, |
| 211 | len_to_deq); |
| 212 | offset = hdr->data_offset + SESSION_CONN_HDR_LEN; |
| 213 | n_bytes_read = svm_fifo_peek (f, offset, deq_now, data0); |
| 214 | ASSERT (n_bytes_read > 0); |
| 215 | |
| 216 | if (ctx->s->session_state == SESSION_STATE_LISTENING) |
| 217 | { |
| 218 | ip_copy (&ctx->tc->rmt_ip, &hdr->rmt_ip, ctx->tc->is_ip4); |
| 219 | ctx->tc->rmt_port = hdr->rmt_port; |
| 220 | } |
| 221 | hdr->data_offset += n_bytes_read; |
| 222 | if (hdr->data_offset == hdr->data_length) |
| 223 | { |
| 224 | offset = hdr->data_length + SESSION_CONN_HDR_LEN; |
| 225 | svm_fifo_dequeue_drop (f, offset); |
| 226 | } |
| 227 | } |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 228 | else |
| 229 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 230 | n_bytes_read = svm_fifo_dequeue_nowait (ctx->s->server_tx_fifo, |
| 231 | len_to_deq, data0); |
| 232 | ASSERT (n_bytes_read > 0); |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 233 | } |
| 234 | } |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 235 | b->current_length = n_bytes_read; |
| 236 | ctx->left_to_snd -= n_bytes_read; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 237 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 238 | /* |
| 239 | * Fill in the remaining buffers in the chain, if any |
| 240 | */ |
| 241 | if (PREDICT_FALSE (ctx->n_bufs_per_seg > 1 && ctx->left_to_snd)) |
| 242 | session_tx_fifo_chain_tail (vm, ctx, b, n_bufs, peek_data); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 243 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 244 | /* *INDENT-OFF* */ |
| 245 | SESSION_EVT_DBG(SESSION_EVT_DEQ, s, ({ |
| 246 | ed->data[0] = e->event_type; |
| 247 | ed->data[1] = max_dequeue; |
| 248 | ed->data[2] = len_to_deq; |
| 249 | ed->data[3] = left_to_snd; |
| 250 | })); |
| 251 | /* *INDENT-ON* */ |
| 252 | } |
| 253 | |
| 254 | always_inline u8 |
| 255 | session_tx_not_ready (stream_session_t * s, u8 peek_data) |
| 256 | { |
| 257 | if (peek_data) |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 258 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 259 | /* Can retransmit for closed sessions but can't send new data if |
| 260 | * session is not ready or closed */ |
| 261 | if (s->session_state < SESSION_STATE_READY) |
| 262 | return 1; |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 263 | if (s->session_state == SESSION_STATE_CLOSED) |
| 264 | return 2; |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 265 | } |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 266 | return 0; |
| 267 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 268 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 269 | always_inline transport_connection_t * |
| 270 | session_tx_get_transport (session_tx_context_t * ctx, u8 peek_data) |
| 271 | { |
| 272 | if (peek_data) |
| 273 | { |
| 274 | return ctx->transport_vft->get_connection (ctx->s->connection_index, |
| 275 | ctx->s->thread_index); |
| 276 | } |
| 277 | else |
| 278 | { |
| 279 | if (ctx->s->session_state == SESSION_STATE_LISTENING) |
| 280 | return ctx->transport_vft->get_listener (ctx->s->connection_index); |
| 281 | else |
| 282 | { |
| 283 | return ctx->transport_vft->get_connection (ctx->s->connection_index, |
| 284 | ctx->s->thread_index); |
| 285 | } |
| 286 | } |
| 287 | } |
Florin Coras | 6a9b68b | 2017-11-21 04:20:42 -0800 | [diff] [blame] | 288 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 289 | always_inline void |
| 290 | session_tx_set_dequeue_params (vlib_main_t * vm, session_tx_context_t * ctx, |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 291 | u32 max_segs, u8 peek_data) |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 292 | { |
| 293 | u32 n_bytes_per_buf, n_bytes_per_seg; |
| 294 | ctx->max_dequeue = svm_fifo_max_dequeue (ctx->s->server_tx_fifo); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 295 | if (peek_data) |
| 296 | { |
Florin Coras | 9d06304 | 2017-09-14 03:08:00 -0400 | [diff] [blame] | 297 | /* Offset in rx fifo from where to peek data */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 298 | ctx->tx_offset = ctx->transport_vft->tx_fifo_offset (ctx->tc); |
| 299 | if (PREDICT_FALSE (ctx->tx_offset >= ctx->max_dequeue)) |
| 300 | { |
| 301 | ctx->max_len_to_snd = 0; |
| 302 | return; |
| 303 | } |
| 304 | ctx->max_dequeue -= ctx->tx_offset; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 305 | } |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 306 | else |
| 307 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 308 | if (ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 309 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 310 | if (ctx->max_dequeue <= sizeof (ctx->hdr)) |
| 311 | { |
| 312 | ctx->max_len_to_snd = 0; |
| 313 | return; |
| 314 | } |
| 315 | svm_fifo_peek (ctx->s->server_tx_fifo, 0, sizeof (ctx->hdr), |
| 316 | (u8 *) & ctx->hdr); |
| 317 | ASSERT (ctx->hdr.data_length > ctx->hdr.data_offset); |
| 318 | ctx->max_dequeue = ctx->hdr.data_length - ctx->hdr.data_offset; |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 319 | } |
| 320 | } |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 321 | ASSERT (ctx->max_dequeue > 0); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 322 | |
| 323 | /* Ensure we're not writing more than transport window allows */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 324 | if (ctx->max_dequeue < ctx->snd_space) |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 325 | { |
| 326 | /* Constrained by tx queue. Try to send only fully formed segments */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 327 | ctx->max_len_to_snd = |
| 328 | (ctx->max_dequeue > ctx->snd_mss) ? |
| 329 | ctx->max_dequeue - ctx->max_dequeue % ctx->snd_mss : ctx->max_dequeue; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 330 | /* TODO Nagle ? */ |
| 331 | } |
| 332 | else |
| 333 | { |
Florin Coras | 1f152cd | 2017-08-18 19:28:03 -0700 | [diff] [blame] | 334 | /* Expectation is that snd_space0 is already a multiple of snd_mss */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 335 | ctx->max_len_to_snd = ctx->snd_space; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 336 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 337 | |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 338 | /* Check if we're tx constrained by the node */ |
| 339 | ctx->n_segs_per_evt = ceil ((f64) ctx->max_len_to_snd / ctx->snd_mss); |
| 340 | if (ctx->n_segs_per_evt > max_segs) |
| 341 | { |
| 342 | ctx->n_segs_per_evt = max_segs; |
| 343 | ctx->max_len_to_snd = max_segs * ctx->snd_mss; |
| 344 | } |
| 345 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 346 | n_bytes_per_buf = vlib_buffer_free_list_buffer_size (vm, |
| 347 | VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); |
Florin Coras | e87216f | 2017-08-17 16:59:22 -0700 | [diff] [blame] | 348 | ASSERT (n_bytes_per_buf > MAX_HDRS_LEN); |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 349 | n_bytes_per_seg = MAX_HDRS_LEN + ctx->snd_mss; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 350 | ctx->n_bufs_per_seg = ceil ((f64) n_bytes_per_seg / n_bytes_per_buf); |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 351 | ctx->deq_per_buf = clib_min (ctx->snd_mss, n_bytes_per_buf); |
| 352 | ctx->deq_per_first_buf = clib_min (ctx->snd_mss, |
| 353 | n_bytes_per_buf - MAX_HDRS_LEN); |
| 354 | } |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 355 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 356 | always_inline int |
| 357 | session_tx_fifo_read_and_snd_i (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 358 | session_fifo_event_t * e, |
| 359 | stream_session_t * s, int *n_tx_packets, |
| 360 | u8 peek_data) |
| 361 | { |
| 362 | u32 next_index, next0, next1, next2, next3, *to_next, n_left_to_next; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 363 | u32 n_trace = vlib_get_trace_count (vm, node), n_bufs_needed = 0; |
| 364 | u32 thread_index = s->thread_index, n_left, pbi; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 365 | session_manager_main_t *smm = &session_manager_main; |
| 366 | session_tx_context_t *ctx = &smm->ctx[thread_index]; |
| 367 | transport_proto_t tp; |
| 368 | vlib_buffer_t *pb; |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 369 | u16 n_bufs, rv; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 370 | |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 371 | if (PREDICT_FALSE ((rv = session_tx_not_ready (s, peek_data)))) |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 372 | { |
Florin Coras | ca1c8f3 | 2018-05-23 21:01:30 -0700 | [diff] [blame] | 373 | if (rv < 2) |
| 374 | vec_add1 (smm->pending_event_vector[thread_index], *e); |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | next_index = smm->session_type_to_next[s->session_type]; |
| 379 | next0 = next1 = next2 = next3 = next_index; |
| 380 | |
| 381 | tp = session_get_transport_proto (s); |
| 382 | ctx->s = s; |
| 383 | ctx->transport_vft = transport_protocol_get_vft (tp); |
| 384 | ctx->tc = session_tx_get_transport (ctx, peek_data); |
| 385 | ctx->snd_mss = ctx->transport_vft->send_mss (ctx->tc); |
| 386 | ctx->snd_space = ctx->transport_vft->send_space (ctx->tc); |
| 387 | if (ctx->snd_space == 0 || ctx->snd_mss == 0) |
| 388 | { |
| 389 | vec_add1 (smm->pending_event_vector[thread_index], *e); |
| 390 | return 0; |
| 391 | } |
| 392 | |
| 393 | /* Allow enqueuing of a new event */ |
| 394 | svm_fifo_unset_event (s->server_tx_fifo); |
| 395 | |
| 396 | /* Check how much we can pull. */ |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 397 | session_tx_set_dequeue_params (vm, ctx, VLIB_FRAME_SIZE - *n_tx_packets, |
| 398 | peek_data); |
| 399 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 400 | if (PREDICT_FALSE (!ctx->max_len_to_snd)) |
| 401 | return 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 402 | |
| 403 | n_bufs = vec_len (smm->tx_buffers[thread_index]); |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 404 | n_bufs_needed = ctx->n_segs_per_evt * ctx->n_bufs_per_seg; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 405 | |
| 406 | /* |
| 407 | * Make sure we have at least one full frame of buffers ready |
| 408 | */ |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 409 | if (n_bufs < n_bufs_needed) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 410 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 411 | session_output_try_get_buffers (vm, smm, thread_index, &n_bufs, |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 412 | ctx->n_bufs_per_seg * VLIB_FRAME_SIZE); |
| 413 | if (PREDICT_FALSE (n_bufs < n_bufs_needed)) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 414 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 415 | vec_add1 (smm->pending_event_vector[thread_index], *e); |
| 416 | return -1; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 417 | } |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 418 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 419 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 420 | /* |
| 421 | * Write until we fill up a frame |
| 422 | */ |
| 423 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 424 | if (PREDICT_FALSE (ctx->n_segs_per_evt > n_left_to_next)) |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 425 | { |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 426 | ctx->n_segs_per_evt = n_left_to_next; |
| 427 | ctx->max_len_to_snd = ctx->snd_mss * n_left_to_next; |
| 428 | } |
| 429 | ctx->left_to_snd = ctx->max_len_to_snd; |
| 430 | n_left = ctx->n_segs_per_evt; |
| 431 | while (n_left) |
| 432 | { |
| 433 | while (n_left >= 4) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 434 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 435 | vlib_buffer_t *b0, *b1; |
| 436 | u32 bi0, bi1; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 437 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 438 | pbi = smm->tx_buffers[thread_index][n_bufs - 3]; |
| 439 | pb = vlib_get_buffer (vm, pbi); |
| 440 | vlib_prefetch_buffer_header (pb, STORE); |
| 441 | pbi = smm->tx_buffers[thread_index][n_bufs - 4]; |
| 442 | pb = vlib_get_buffer (vm, pbi); |
| 443 | vlib_prefetch_buffer_header (pb, STORE); |
Florin Coras | 81a13db | 2018-03-16 08:48:31 -0700 | [diff] [blame] | 444 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 445 | to_next[0] = bi0 = smm->tx_buffers[thread_index][--n_bufs]; |
| 446 | to_next[1] = bi1 = smm->tx_buffers[thread_index][--n_bufs]; |
Florin Coras | f6359c8 | 2017-06-19 12:26:09 -0400 | [diff] [blame] | 447 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 448 | b0 = vlib_get_buffer (vm, bi0); |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 449 | b1 = vlib_get_buffer (vm, bi1); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 450 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 451 | session_tx_fill_buffer (vm, ctx, b0, &n_bufs, peek_data); |
| 452 | session_tx_fill_buffer (vm, ctx, b1, &n_bufs, peek_data); |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 453 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 454 | ctx->transport_vft->push_header (ctx->tc, b0); |
| 455 | ctx->transport_vft->push_header (ctx->tc, b1); |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 456 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 457 | to_next += 2; |
| 458 | n_left_to_next -= 2; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 459 | n_left -= 2; |
Florin Coras | f6d68ed | 2017-05-07 19:12:02 -0700 | [diff] [blame] | 460 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 461 | VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0); |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 462 | VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b1); |
Florin Coras | 4eeeaaf | 2017-09-05 14:03:37 -0400 | [diff] [blame] | 463 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 464 | if (PREDICT_FALSE (n_trace > 0)) |
| 465 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 466 | session_tx_trace_buffer (vm, node, next_index, b0, s, &n_trace); |
| 467 | if (n_trace) |
| 468 | session_tx_trace_buffer (vm, node, next_index, b1, s, |
| 469 | &n_trace); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 470 | } |
| 471 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 472 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, |
| 473 | n_left_to_next, bi0, bi1, |
| 474 | next0, next1); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 475 | } |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 476 | while (n_left) |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 477 | { |
| 478 | vlib_buffer_t *b0; |
| 479 | u32 bi0; |
| 480 | |
| 481 | ASSERT (n_bufs >= 1); |
| 482 | to_next[0] = bi0 = smm->tx_buffers[thread_index][--n_bufs]; |
| 483 | b0 = vlib_get_buffer (vm, bi0); |
| 484 | session_tx_fill_buffer (vm, ctx, b0, &n_bufs, peek_data); |
| 485 | |
| 486 | /* Ask transport to push header after current_length and |
| 487 | * total_length_not_including_first_buffer are updated */ |
| 488 | ctx->transport_vft->push_header (ctx->tc, b0); |
| 489 | |
| 490 | to_next += 1; |
| 491 | n_left_to_next -= 1; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 492 | n_left -= 1; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 493 | |
| 494 | VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0); |
| 495 | if (PREDICT_FALSE (n_trace > 0)) |
| 496 | session_tx_trace_buffer (vm, node, next_index, b0, s, &n_trace); |
| 497 | |
| 498 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, |
| 499 | n_left_to_next, bi0, next0); |
| 500 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 501 | } |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 502 | _vec_len (smm->tx_buffers[thread_index]) = n_bufs; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 503 | *n_tx_packets += ctx->n_segs_per_evt; |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 504 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 505 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 506 | /* If we couldn't dequeue all bytes mark as partially read */ |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 507 | ASSERT (ctx->left_to_snd == 0); |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 508 | if (ctx->max_len_to_snd < ctx->max_dequeue) |
| 509 | if (svm_fifo_set_event (s->server_tx_fifo)) |
| 510 | vec_add1 (smm->pending_event_vector[thread_index], *e); |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 511 | |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 512 | if (!peek_data && ctx->transport_vft->tx_type == TRANSPORT_TX_DGRAM) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 513 | { |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 514 | /* Fix dgram pre header */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 515 | if (ctx->max_len_to_snd < ctx->max_dequeue) |
| 516 | svm_fifo_overwrite_head (s->server_tx_fifo, (u8 *) & ctx->hdr, |
Florin Coras | 7fb0fe1 | 2018-04-09 09:24:52 -0700 | [diff] [blame] | 517 | sizeof (session_dgram_pre_hdr_t)); |
| 518 | /* More data needs to be read */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 519 | else if (svm_fifo_max_dequeue (s->server_tx_fifo) > 0) |
| 520 | if (svm_fifo_set_event (s->server_tx_fifo)) |
| 521 | vec_add1 (smm->pending_event_vector[thread_index], *e); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 522 | } |
| 523 | return 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | int |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 527 | session_tx_fifo_peek_and_snd (vlib_main_t * vm, vlib_node_runtime_t * node, |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 528 | session_fifo_event_t * e0, |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 529 | stream_session_t * s0, int *n_tx_pkts) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 530 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 531 | return session_tx_fifo_read_and_snd_i (vm, node, e0, s0, n_tx_pkts, 1); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | int |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 535 | session_tx_fifo_dequeue_and_snd (vlib_main_t * vm, vlib_node_runtime_t * node, |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 536 | session_fifo_event_t * e0, |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 537 | stream_session_t * s0, int *n_tx_pkts) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 538 | { |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 539 | return session_tx_fifo_read_and_snd_i (vm, node, e0, s0, n_tx_pkts, 0); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 540 | } |
| 541 | |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 542 | int |
| 543 | session_tx_fifo_dequeue_internal (vlib_main_t * vm, |
| 544 | vlib_node_runtime_t * node, |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 545 | session_fifo_event_t * e0, |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 546 | stream_session_t * s0, int *n_tx_pkts) |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 547 | { |
| 548 | application_t *app; |
| 549 | app = application_get (s0->opaque); |
| 550 | svm_fifo_unset_event (s0->server_tx_fifo); |
| 551 | return app->cb_fns.builtin_app_tx_callback (s0); |
| 552 | } |
| 553 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame] | 554 | always_inline stream_session_t * |
| 555 | session_event_get_session (session_fifo_event_t * e, u8 thread_index) |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 556 | { |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 557 | return session_get_if_valid (e->fifo->master_session_index, thread_index); |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 558 | } |
| 559 | |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 560 | void |
| 561 | dump_thread_0_event_queue (void) |
| 562 | { |
| 563 | session_manager_main_t *smm = vnet_get_session_manager_main (); |
| 564 | vlib_main_t *vm = &vlib_global_main; |
| 565 | u32 my_thread_index = vm->thread_index; |
| 566 | session_fifo_event_t _e, *e = &_e; |
| 567 | stream_session_t *s0; |
| 568 | int i, index; |
| 569 | i8 *headp; |
| 570 | |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 571 | svm_queue_t *q; |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 572 | q = smm->vpp_event_queues[my_thread_index]; |
| 573 | |
| 574 | index = q->head; |
| 575 | |
| 576 | for (i = 0; i < q->cursize; i++) |
| 577 | { |
| 578 | headp = (i8 *) (&q->data[0] + q->elsize * index); |
| 579 | clib_memcpy (e, headp, q->elsize); |
| 580 | |
| 581 | switch (e->event_type) |
| 582 | { |
| 583 | case FIFO_EVENT_APP_TX: |
| 584 | s0 = session_event_get_session (e, my_thread_index); |
| 585 | fformat (stdout, "[%04d] TX session %d\n", i, s0->session_index); |
| 586 | break; |
| 587 | |
| 588 | case FIFO_EVENT_DISCONNECT: |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 589 | s0 = session_get_from_handle (e->session_handle); |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 590 | fformat (stdout, "[%04d] disconnect session %d\n", i, |
| 591 | s0->session_index); |
| 592 | break; |
| 593 | |
| 594 | case FIFO_EVENT_BUILTIN_RX: |
| 595 | s0 = session_event_get_session (e, my_thread_index); |
| 596 | fformat (stdout, "[%04d] builtin_rx %d\n", i, s0->session_index); |
| 597 | break; |
| 598 | |
| 599 | case FIFO_EVENT_RPC: |
| 600 | fformat (stdout, "[%04d] RPC call %llx with %llx\n", |
| 601 | i, (u64) (e->rpc_args.fp), (u64) (e->rpc_args.arg)); |
| 602 | break; |
| 603 | |
| 604 | default: |
| 605 | fformat (stdout, "[%04d] unhandled event type %d\n", |
| 606 | i, e->event_type); |
| 607 | break; |
| 608 | } |
| 609 | |
| 610 | index++; |
| 611 | |
| 612 | if (index == q->maxsize) |
| 613 | index = 0; |
| 614 | } |
| 615 | } |
| 616 | |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 617 | static u8 |
| 618 | session_node_cmp_event (session_fifo_event_t * e, svm_fifo_t * f) |
| 619 | { |
| 620 | stream_session_t *s; |
| 621 | switch (e->event_type) |
| 622 | { |
| 623 | case FIFO_EVENT_APP_RX: |
| 624 | case FIFO_EVENT_APP_TX: |
| 625 | case FIFO_EVENT_BUILTIN_RX: |
| 626 | if (e->fifo == f) |
| 627 | return 1; |
| 628 | break; |
| 629 | case FIFO_EVENT_DISCONNECT: |
| 630 | break; |
| 631 | case FIFO_EVENT_RPC: |
Florin Coras | cea194d | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 632 | s = session_get_from_handle (e->session_handle); |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 633 | if (!s) |
| 634 | { |
| 635 | clib_warning ("session has event but doesn't exist!"); |
| 636 | break; |
| 637 | } |
| 638 | if (s->server_rx_fifo == f || s->server_tx_fifo == f) |
| 639 | return 1; |
| 640 | break; |
| 641 | default: |
| 642 | break; |
| 643 | } |
| 644 | return 0; |
| 645 | } |
| 646 | |
| 647 | u8 |
| 648 | session_node_lookup_fifo_event (svm_fifo_t * f, session_fifo_event_t * e) |
| 649 | { |
| 650 | session_manager_main_t *smm = vnet_get_session_manager_main (); |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 651 | svm_queue_t *q; |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 652 | session_fifo_event_t *pending_event_vector, *evt; |
| 653 | int i, index, found = 0; |
| 654 | i8 *headp; |
| 655 | u8 thread_index; |
| 656 | |
| 657 | ASSERT (e); |
| 658 | thread_index = f->master_thread_index; |
| 659 | /* |
| 660 | * Search evt queue |
| 661 | */ |
| 662 | q = smm->vpp_event_queues[thread_index]; |
| 663 | index = q->head; |
| 664 | for (i = 0; i < q->cursize; i++) |
| 665 | { |
| 666 | headp = (i8 *) (&q->data[0] + q->elsize * index); |
| 667 | clib_memcpy (e, headp, q->elsize); |
| 668 | found = session_node_cmp_event (e, f); |
| 669 | if (found) |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 670 | return 1; |
Florin Coras | 6534b7a | 2017-07-18 05:38:03 -0400 | [diff] [blame] | 671 | if (++index == q->maxsize) |
| 672 | index = 0; |
| 673 | } |
| 674 | /* |
| 675 | * Search pending events vector |
| 676 | */ |
| 677 | pending_event_vector = smm->pending_event_vector[thread_index]; |
| 678 | vec_foreach (evt, pending_event_vector) |
| 679 | { |
| 680 | found = session_node_cmp_event (evt, f); |
| 681 | if (found) |
| 682 | { |
| 683 | clib_memcpy (e, evt, sizeof (*evt)); |
| 684 | break; |
| 685 | } |
| 686 | } |
| 687 | return found; |
| 688 | } |
| 689 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 690 | static uword |
| 691 | session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 692 | vlib_frame_t * frame) |
| 693 | { |
| 694 | session_manager_main_t *smm = vnet_get_session_manager_main (); |
Florin Coras | b2371c2 | 2018-05-31 17:14:10 -0700 | [diff] [blame] | 695 | session_fifo_event_t *my_pending_event_vector, *e; |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 696 | session_fifo_event_t *my_fifo_events; |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 697 | u32 n_to_dequeue, n_events; |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 698 | svm_queue_t *q; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 699 | application_t *app; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 700 | int n_tx_packets = 0; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 701 | u32 thread_index = vm->thread_index; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 702 | int i, rv; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 703 | f64 now = vlib_time_now (vm); |
Dave Barach | e5f1d27 | 2017-05-10 13:34:04 -0400 | [diff] [blame] | 704 | void (*fp) (void *); |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 705 | |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 706 | SESSION_EVT_DBG (SESSION_EVT_POLL_GAP_TRACK, smm, thread_index); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 707 | |
| 708 | /* |
Florin Coras | 561af9b | 2017-12-09 10:19:43 -0800 | [diff] [blame] | 709 | * Update transport time |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 710 | */ |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 711 | transport_update_time (now, thread_index); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 712 | |
| 713 | /* |
| 714 | * Get vpp queue events |
| 715 | */ |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 716 | q = smm->vpp_event_queues[thread_index]; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 717 | if (PREDICT_FALSE (q == 0)) |
| 718 | return 0; |
| 719 | |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 720 | my_fifo_events = smm->free_event_vector[thread_index]; |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 721 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 722 | /* min number of events we can dequeue without blocking */ |
| 723 | n_to_dequeue = q->cursize; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 724 | my_pending_event_vector = smm->pending_event_vector[thread_index]; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 725 | |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 726 | if (!n_to_dequeue && !vec_len (my_pending_event_vector) |
Florin Coras | b2371c2 | 2018-05-31 17:14:10 -0700 | [diff] [blame] | 727 | && !vec_len (smm->pending_disconnects[thread_index])) |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 728 | return 0; |
| 729 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 730 | SESSION_EVT_DBG (SESSION_EVT_DEQ_NODE, 0); |
| 731 | |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 732 | /* |
| 733 | * If we didn't manage to process previous events try going |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 734 | * over them again without dequeuing new ones. |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 735 | */ |
| 736 | /* XXX: Block senders to sessions that can't keep up */ |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 737 | if (0 && vec_len (my_pending_event_vector) >= 100) |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 738 | { |
| 739 | clib_warning ("too many fifo events unsolved"); |
| 740 | goto skip_dequeue; |
| 741 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 742 | |
| 743 | /* See you in the next life, don't be late */ |
| 744 | if (pthread_mutex_trylock (&q->mutex)) |
| 745 | return 0; |
| 746 | |
| 747 | for (i = 0; i < n_to_dequeue; i++) |
| 748 | { |
| 749 | vec_add2 (my_fifo_events, e, 1); |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 750 | svm_queue_sub_raw (q, (u8 *) e); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | /* The other side of the connection is not polling */ |
| 754 | if (q->cursize < (q->maxsize / 8)) |
| 755 | (void) pthread_cond_broadcast (&q->condvar); |
| 756 | pthread_mutex_unlock (&q->mutex); |
| 757 | |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 758 | vec_append (my_fifo_events, my_pending_event_vector); |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 759 | vec_append (my_fifo_events, smm->pending_disconnects[thread_index]); |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 760 | |
| 761 | _vec_len (my_pending_event_vector) = 0; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 762 | smm->pending_event_vector[thread_index] = my_pending_event_vector; |
| 763 | _vec_len (smm->pending_disconnects[thread_index]) = 0; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 764 | |
| 765 | skip_dequeue: |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 766 | n_events = vec_len (my_fifo_events); |
| 767 | for (i = 0; i < n_events; i++) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 768 | { |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 769 | stream_session_t *s0; /* $$$ prefetch 1 ahead maybe */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 770 | session_fifo_event_t *e0; |
| 771 | |
| 772 | e0 = &my_fifo_events[i]; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 773 | switch (e0->event_type) |
| 774 | { |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 775 | case FIFO_EVENT_APP_TX: |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 776 | if (n_tx_packets == VLIB_FRAME_SIZE) |
| 777 | { |
| 778 | vec_add1 (smm->pending_event_vector[thread_index], *e0); |
| 779 | break; |
| 780 | } |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 781 | |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 782 | s0 = session_event_get_session (e0, thread_index); |
Florin Coras | 9d06304 | 2017-09-14 03:08:00 -0400 | [diff] [blame] | 783 | if (PREDICT_FALSE (!s0)) |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 784 | { |
| 785 | clib_warning ("It's dead, Jim!"); |
| 786 | continue; |
| 787 | } |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 788 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 789 | /* Spray packets in per session type frames, since they go to |
| 790 | * different nodes */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 791 | rv = (smm->session_tx_fns[s0->session_type]) (vm, node, e0, s0, |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 792 | &n_tx_packets); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 793 | /* Out of buffers */ |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 794 | if (PREDICT_FALSE (rv < 0)) |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 795 | { |
Florin Coras | 93992a9 | 2017-05-24 18:03:56 -0700 | [diff] [blame] | 796 | vlib_node_increment_counter (vm, node->node_index, |
| 797 | SESSION_QUEUE_ERROR_NO_BUFFER, 1); |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 798 | continue; |
| 799 | } |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 800 | break; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 801 | case FIFO_EVENT_DISCONNECT: |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 802 | /* Make sure stream disconnects run after the pending list is drained */ |
Florin Coras | 8e43d04 | 2018-05-04 15:46:57 -0700 | [diff] [blame] | 803 | s0 = session_get_from_handle (e0->session_handle); |
Florin Coras | b2371c2 | 2018-05-31 17:14:10 -0700 | [diff] [blame] | 804 | if (!e0->postponed) |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 805 | { |
| 806 | e0->postponed = 1; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 807 | vec_add1 (smm->pending_disconnects[thread_index], *e0); |
Florin Coras | 3cbc04b | 2017-10-02 00:18:51 -0700 | [diff] [blame] | 808 | continue; |
| 809 | } |
Florin Coras | b2371c2 | 2018-05-31 17:14:10 -0700 | [diff] [blame] | 810 | /* If tx queue is still not empty, wait a bit */ |
| 811 | if (svm_fifo_max_dequeue (s0->server_tx_fifo) |
| 812 | && e0->postponed < 200) |
| 813 | { |
| 814 | e0->postponed += 1; |
| 815 | vec_add1 (smm->pending_disconnects[thread_index], *e0); |
| 816 | continue; |
| 817 | } |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 818 | |
Florin Coras | 2f8d8fa | 2018-01-26 06:36:04 -0800 | [diff] [blame] | 819 | stream_session_disconnect_transport (s0); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 820 | break; |
| 821 | case FIFO_EVENT_BUILTIN_RX: |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 822 | s0 = session_event_get_session (e0, thread_index); |
Florin Coras | c87c91d | 2017-08-16 19:55:49 -0700 | [diff] [blame] | 823 | if (PREDICT_FALSE (!s0)) |
| 824 | continue; |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 825 | svm_fifo_unset_event (s0->server_rx_fifo); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 826 | app = application_get (s0->app_index); |
Florin Coras | 371ca50 | 2018-02-21 12:07:41 -0800 | [diff] [blame] | 827 | app->cb_fns.builtin_app_rx_callback (s0); |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 828 | break; |
Dave Barach | e5f1d27 | 2017-05-10 13:34:04 -0400 | [diff] [blame] | 829 | case FIFO_EVENT_RPC: |
| 830 | fp = e0->rpc_args.fp; |
| 831 | (*fp) (e0->rpc_args.arg); |
| 832 | break; |
| 833 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 834 | default: |
| 835 | clib_warning ("unhandled event type %d", e0->event_type); |
| 836 | } |
| 837 | } |
| 838 | |
Dave Barach | acd2a6a | 2017-05-16 17:41:34 -0400 | [diff] [blame] | 839 | _vec_len (my_fifo_events) = 0; |
Florin Coras | f08f26d | 2018-05-10 13:20:47 -0700 | [diff] [blame] | 840 | smm->free_event_vector[thread_index] = my_fifo_events; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 841 | |
| 842 | vlib_node_increment_counter (vm, session_queue_node.index, |
| 843 | SESSION_QUEUE_ERROR_TX, n_tx_packets); |
| 844 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 845 | SESSION_EVT_DBG (SESSION_EVT_DEQ_NODE, 1); |
| 846 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 847 | return n_tx_packets; |
| 848 | } |
| 849 | |
| 850 | /* *INDENT-OFF* */ |
| 851 | VLIB_REGISTER_NODE (session_queue_node) = |
| 852 | { |
| 853 | .function = session_queue_node_fn, |
| 854 | .name = "session-queue", |
| 855 | .format_trace = format_session_queue_trace, |
| 856 | .type = VLIB_NODE_TYPE_INPUT, |
| 857 | .n_errors = ARRAY_LEN (session_queue_error_strings), |
| 858 | .error_strings = session_queue_error_strings, |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 859 | .state = VLIB_NODE_STATE_DISABLED, |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 860 | }; |
| 861 | /* *INDENT-ON* */ |
| 862 | |
Dave Barach | 2a86391 | 2017-11-28 10:11:42 -0500 | [diff] [blame] | 863 | static clib_error_t * |
| 864 | session_queue_exit (vlib_main_t * vm) |
| 865 | { |
| 866 | if (vec_len (vlib_mains) < 2) |
| 867 | return 0; |
| 868 | |
| 869 | /* |
| 870 | * Shut off (especially) worker-thread session nodes. |
| 871 | * Otherwise, vpp can crash as the main thread unmaps the |
| 872 | * API segment. |
| 873 | */ |
| 874 | vlib_worker_thread_barrier_sync (vm); |
| 875 | session_node_enable_disable (0 /* is_enable */ ); |
| 876 | vlib_worker_thread_barrier_release (vm); |
| 877 | return 0; |
| 878 | } |
| 879 | |
| 880 | VLIB_MAIN_LOOP_EXIT_FUNCTION (session_queue_exit); |
| 881 | |
Florin Coras | fd542f1 | 2018-05-16 19:28:24 -0700 | [diff] [blame] | 882 | static uword |
| 883 | session_queue_process (vlib_main_t * vm, vlib_node_runtime_t * rt, |
| 884 | vlib_frame_t * f) |
| 885 | { |
| 886 | f64 now, timeout = 1.0; |
| 887 | uword *event_data = 0; |
| 888 | uword event_type; |
| 889 | |
| 890 | while (1) |
| 891 | { |
| 892 | vlib_process_wait_for_event_or_clock (vm, timeout); |
| 893 | now = vlib_time_now (vm); |
| 894 | event_type = vlib_process_get_events (vm, (uword **) & event_data); |
| 895 | |
| 896 | switch (event_type) |
| 897 | { |
| 898 | case SESSION_Q_PROCESS_FLUSH_FRAMES: |
| 899 | /* Flush the frames by updating all transports times */ |
| 900 | transport_update_time (now, 0); |
| 901 | break; |
| 902 | case SESSION_Q_PROCESS_STOP: |
| 903 | timeout = 100000.0; |
| 904 | break; |
| 905 | case ~0: |
| 906 | /* Timed out. Update time for all transports to trigger all |
| 907 | * outstanding retransmits. */ |
| 908 | transport_update_time (now, 0); |
| 909 | break; |
| 910 | } |
| 911 | vec_reset_length (event_data); |
| 912 | } |
| 913 | return 0; |
| 914 | } |
| 915 | |
| 916 | /* *INDENT-OFF* */ |
| 917 | VLIB_REGISTER_NODE (session_queue_process_node) = |
| 918 | { |
| 919 | .function = session_queue_process, |
| 920 | .type = VLIB_NODE_TYPE_PROCESS, |
| 921 | .name = "session-queue-process", |
| 922 | .state = VLIB_NODE_STATE_DISABLED, |
| 923 | }; |
| 924 | /* *INDENT-ON* */ |
| 925 | |
| 926 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 927 | /* |
| 928 | * fd.io coding-style-patch-verification: ON |
| 929 | * |
| 930 | * Local Variables: |
| 931 | * eval: (c-set-style "gnu") |
| 932 | * End: |
| 933 | */ |