Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this |
| 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 | #include <vcl/vcl_private.h> |
| 17 | |
Florin Coras | 3348a4c | 2018-09-07 17:09:35 -0700 | [diff] [blame] | 18 | static pthread_key_t vcl_worker_stop_key; |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 19 | |
| 20 | static const char * |
| 21 | vppcom_app_state_str (app_state_t state) |
| 22 | { |
| 23 | char *st; |
| 24 | |
| 25 | switch (state) |
| 26 | { |
| 27 | case STATE_APP_START: |
| 28 | st = "STATE_APP_START"; |
| 29 | break; |
| 30 | |
| 31 | case STATE_APP_CONN_VPP: |
| 32 | st = "STATE_APP_CONN_VPP"; |
| 33 | break; |
| 34 | |
| 35 | case STATE_APP_ENABLED: |
| 36 | st = "STATE_APP_ENABLED"; |
| 37 | break; |
| 38 | |
| 39 | case STATE_APP_ATTACHED: |
| 40 | st = "STATE_APP_ATTACHED"; |
| 41 | break; |
| 42 | |
| 43 | default: |
| 44 | st = "UNKNOWN_APP_STATE"; |
| 45 | break; |
| 46 | } |
| 47 | |
| 48 | return st; |
| 49 | } |
| 50 | |
| 51 | int |
| 52 | vcl_wait_for_app_state_change (app_state_t app_state) |
| 53 | { |
| 54 | vcl_worker_t *wrk = vcl_worker_get_current (); |
| 55 | f64 timeout = clib_time_now (&wrk->clib_time) + vcm->cfg.app_timeout; |
| 56 | |
| 57 | while (clib_time_now (&wrk->clib_time) < timeout) |
| 58 | { |
| 59 | if (vcm->app_state == app_state) |
| 60 | return VPPCOM_OK; |
| 61 | if (vcm->app_state == STATE_APP_FAILED) |
| 62 | return VPPCOM_ECONNABORTED; |
| 63 | } |
| 64 | VDBG (0, "VCL<%d>: timeout waiting for state %s (%d)", getpid (), |
| 65 | vppcom_app_state_str (app_state), app_state); |
| 66 | vcl_evt (VCL_EVT_SESSION_TIMEOUT, vcm, app_state); |
| 67 | |
| 68 | return VPPCOM_ETIMEDOUT; |
| 69 | } |
| 70 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 71 | vcl_mq_evt_conn_t * |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 72 | vcl_mq_evt_conn_alloc (vcl_worker_t * wrk) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 73 | { |
| 74 | vcl_mq_evt_conn_t *mqc; |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 75 | pool_get (wrk->mq_evt_conns, mqc); |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 76 | memset (mqc, 0, sizeof (*mqc)); |
| 77 | return mqc; |
| 78 | } |
| 79 | |
| 80 | u32 |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 81 | vcl_mq_evt_conn_index (vcl_worker_t * wrk, vcl_mq_evt_conn_t * mqc) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 82 | { |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 83 | return (mqc - wrk->mq_evt_conns); |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | vcl_mq_evt_conn_t * |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 87 | vcl_mq_evt_conn_get (vcl_worker_t * wrk, u32 mq_conn_idx) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 88 | { |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 89 | return pool_elt_at_index (wrk->mq_evt_conns, mq_conn_idx); |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | int |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 93 | vcl_mq_epoll_add_evfd (vcl_worker_t * wrk, svm_msg_q_t * mq) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 94 | { |
| 95 | struct epoll_event e = { 0 }; |
| 96 | vcl_mq_evt_conn_t *mqc; |
| 97 | u32 mqc_index; |
| 98 | int mq_fd; |
| 99 | |
| 100 | mq_fd = svm_msg_q_get_consumer_eventfd (mq); |
| 101 | |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 102 | if (wrk->mqs_epfd < 0 || mq_fd == -1) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 103 | return -1; |
| 104 | |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 105 | mqc = vcl_mq_evt_conn_alloc (wrk); |
| 106 | mqc_index = vcl_mq_evt_conn_index (wrk, mqc); |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 107 | mqc->mq_fd = mq_fd; |
| 108 | mqc->mq = mq; |
| 109 | |
| 110 | e.events = EPOLLIN; |
| 111 | e.data.u32 = mqc_index; |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 112 | if (epoll_ctl (wrk->mqs_epfd, EPOLL_CTL_ADD, mq_fd, &e) < 0) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 113 | { |
| 114 | clib_warning ("failed to add mq eventfd to mq epoll fd"); |
| 115 | return -1; |
| 116 | } |
| 117 | |
| 118 | return mqc_index; |
| 119 | } |
| 120 | |
| 121 | int |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 122 | vcl_mq_epoll_del_evfd (vcl_worker_t * wrk, u32 mqc_index) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 123 | { |
| 124 | vcl_mq_evt_conn_t *mqc; |
| 125 | |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 126 | if (wrk->mqs_epfd || mqc_index == ~0) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 127 | return -1; |
| 128 | |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 129 | mqc = vcl_mq_evt_conn_get (wrk, mqc_index); |
| 130 | if (epoll_ctl (wrk->mqs_epfd, EPOLL_CTL_DEL, mqc->mq_fd, 0) < 0) |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 131 | { |
| 132 | clib_warning ("failed to del mq eventfd to mq epoll fd"); |
| 133 | return -1; |
| 134 | } |
| 135 | return 0; |
| 136 | } |
| 137 | |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 138 | static vcl_worker_t * |
| 139 | vcl_worker_alloc (void) |
| 140 | { |
| 141 | vcl_worker_t *wrk; |
| 142 | pool_get (vcm->workers, wrk); |
| 143 | memset (wrk, 0, sizeof (*wrk)); |
| 144 | wrk->wrk_index = wrk - vcm->workers; |
Florin Coras | 01f3f89 | 2018-12-02 12:45:53 -0800 | [diff] [blame] | 145 | wrk->forked_child = ~0; |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 146 | return wrk; |
| 147 | } |
| 148 | |
| 149 | static void |
| 150 | vcl_worker_free (vcl_worker_t * wrk) |
| 151 | { |
| 152 | pool_put (vcm->workers, wrk); |
| 153 | } |
| 154 | |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 155 | void |
Florin Coras | 01f3f89 | 2018-12-02 12:45:53 -0800 | [diff] [blame] | 156 | vcl_worker_cleanup (vcl_worker_t * wrk, u8 notify_vpp) |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 157 | { |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 158 | clib_spinlock_lock (&vcm->workers_lock); |
Florin Coras | 940f78f | 2018-11-30 12:11:20 -0800 | [diff] [blame] | 159 | if (notify_vpp) |
Florin Coras | 01f3f89 | 2018-12-02 12:45:53 -0800 | [diff] [blame] | 160 | { |
| 161 | if (wrk->wrk_index == vcl_get_worker_index ()) |
| 162 | vcl_send_app_worker_add_del (0 /* is_add */ ); |
| 163 | else |
| 164 | vcl_send_child_worker_del (wrk); |
| 165 | } |
Florin Coras | 940f78f | 2018-11-30 12:11:20 -0800 | [diff] [blame] | 166 | if (wrk->mqs_epfd > 0) |
| 167 | close (wrk->mqs_epfd); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 168 | hash_free (wrk->session_index_by_vpp_handles); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 169 | vec_free (wrk->mq_events); |
| 170 | vec_free (wrk->mq_msg_vector); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 171 | vcl_worker_free (wrk); |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 172 | clib_spinlock_unlock (&vcm->workers_lock); |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | static void |
| 176 | vcl_worker_cleanup_cb (void *arg) |
| 177 | { |
Florin Coras | 01f3f89 | 2018-12-02 12:45:53 -0800 | [diff] [blame] | 178 | vcl_worker_t *wrk = vcl_worker_get_current (); |
| 179 | u32 wrk_index = wrk->wrk_index; |
| 180 | vcl_worker_cleanup (wrk, 1 /* notify vpp */ ); |
| 181 | vcl_set_worker_index (~0); |
Florin Coras | 940f78f | 2018-11-30 12:11:20 -0800 | [diff] [blame] | 182 | VDBG (0, "cleaned up worker %u", wrk_index); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | vcl_worker_t * |
| 186 | vcl_worker_alloc_and_init () |
| 187 | { |
| 188 | vcl_worker_t *wrk; |
| 189 | |
| 190 | /* This was initialized already */ |
| 191 | if (vcl_get_worker_index () != ~0) |
| 192 | return 0; |
| 193 | |
Florin Coras | de9f08b | 2018-09-07 14:32:58 -0700 | [diff] [blame] | 194 | if (pool_elts (vcm->workers) == vcm->cfg.max_workers) |
| 195 | { |
| 196 | VDBG (0, "max-workers %u limit reached", vcm->cfg.max_workers); |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | clib_spinlock_lock (&vcm->workers_lock); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 201 | wrk = vcl_worker_alloc (); |
| 202 | vcl_set_worker_index (wrk->wrk_index); |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 203 | wrk->thread_id = pthread_self (); |
| 204 | wrk->current_pid = getpid (); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 205 | |
| 206 | wrk->mqs_epfd = -1; |
| 207 | if (vcm->cfg.use_mq_eventfd) |
| 208 | { |
| 209 | wrk->mqs_epfd = epoll_create (1); |
| 210 | if (wrk->mqs_epfd < 0) |
| 211 | { |
| 212 | clib_unix_warning ("epoll_create() returned"); |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 213 | goto done; |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | |
| 217 | wrk->session_index_by_vpp_handles = hash_create (0, sizeof (uword)); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 218 | clib_time_init (&wrk->clib_time); |
| 219 | vec_validate (wrk->mq_events, 64); |
| 220 | vec_validate (wrk->mq_msg_vector, 128); |
| 221 | vec_reset_length (wrk->mq_msg_vector); |
Florin Coras | 86f0450 | 2018-09-12 16:08:01 -0700 | [diff] [blame] | 222 | vec_validate (wrk->unhandled_evts_vector, 128); |
| 223 | vec_reset_length (wrk->unhandled_evts_vector); |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 224 | clib_spinlock_unlock (&vcm->workers_lock); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 225 | |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 226 | done: |
| 227 | return wrk; |
| 228 | } |
| 229 | |
| 230 | int |
| 231 | vcl_worker_register_with_vpp (void) |
| 232 | { |
| 233 | vcl_worker_t *wrk = vcl_worker_get_current (); |
| 234 | |
| 235 | clib_spinlock_lock (&vcm->workers_lock); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 236 | |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 237 | vcm->app_state = STATE_APP_ADDING_WORKER; |
| 238 | vcl_send_app_worker_add_del (1 /* is_add */ ); |
| 239 | if (vcl_wait_for_app_state_change (STATE_APP_READY)) |
| 240 | { |
| 241 | clib_warning ("failed to add worker to vpp"); |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 242 | return -1; |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 243 | } |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 244 | if (pthread_key_create (&vcl_worker_stop_key, vcl_worker_cleanup_cb)) |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 245 | clib_warning ("failed to add pthread cleanup function"); |
Florin Coras | 3348a4c | 2018-09-07 17:09:35 -0700 | [diff] [blame] | 246 | if (pthread_setspecific (vcl_worker_stop_key, &wrk->thread_id)) |
| 247 | clib_warning ("failed to setup key value"); |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 248 | |
Florin Coras | de9f08b | 2018-09-07 14:32:58 -0700 | [diff] [blame] | 249 | clib_spinlock_unlock (&vcm->workers_lock); |
| 250 | |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 251 | VDBG (0, "added worker %u", wrk->wrk_index); |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 252 | return 0; |
| 253 | } |
Florin Coras | 134a996 | 2018-08-28 11:32:04 -0700 | [diff] [blame] | 254 | |
Florin Coras | 47c40e2 | 2018-11-26 17:01:36 -0800 | [diff] [blame] | 255 | int |
| 256 | vcl_worker_set_bapi (void) |
| 257 | { |
| 258 | vcl_worker_t *wrk = vcl_worker_get_current (); |
| 259 | int i; |
| 260 | |
| 261 | /* Find the first worker with the same pid */ |
| 262 | for (i = 0; i < vec_len (vcm->workers); i++) |
| 263 | { |
| 264 | if (i == wrk->wrk_index) |
| 265 | continue; |
| 266 | if (vcm->workers[i].current_pid == wrk->current_pid) |
| 267 | { |
| 268 | wrk->vl_input_queue = vcm->workers[i].vl_input_queue; |
| 269 | wrk->my_client_index = vcm->workers[i].my_client_index; |
| 270 | return 0; |
| 271 | } |
| 272 | } |
| 273 | return -1; |
| 274 | } |
| 275 | |
Florin Coras | d85de68 | 2018-11-29 17:02:29 -0800 | [diff] [blame] | 276 | void |
| 277 | vcl_segment_table_add (u64 segment_handle, u32 svm_segment_index) |
| 278 | { |
| 279 | clib_rwlock_writer_lock (&vcm->segment_table_lock); |
| 280 | hash_set (vcm->segment_table, segment_handle, svm_segment_index); |
| 281 | clib_rwlock_writer_unlock (&vcm->segment_table_lock); |
| 282 | } |
| 283 | |
| 284 | u32 |
| 285 | vcl_segment_table_lookup (u64 segment_handle) |
| 286 | { |
| 287 | uword *seg_indexp; |
| 288 | |
| 289 | clib_rwlock_reader_lock (&vcm->segment_table_lock); |
| 290 | seg_indexp = hash_get (vcm->segment_table, segment_handle); |
| 291 | clib_rwlock_reader_unlock (&vcm->segment_table_lock); |
| 292 | |
| 293 | if (!seg_indexp) |
| 294 | return VCL_INVALID_SEGMENT_INDEX; |
| 295 | return ((u32) * seg_indexp); |
| 296 | } |
| 297 | |
| 298 | void |
| 299 | vcl_segment_table_del (u64 segment_handle) |
| 300 | { |
| 301 | clib_rwlock_writer_lock (&vcm->segment_table_lock); |
| 302 | hash_unset (vcm->segment_table, segment_handle); |
| 303 | clib_rwlock_writer_unlock (&vcm->segment_table_lock); |
| 304 | } |
| 305 | |
Florin Coras | f9240dc | 2019-01-15 08:03:17 -0800 | [diff] [blame] | 306 | void |
| 307 | vcl_cleanup_bapi (void) |
| 308 | { |
| 309 | socket_client_main_t *scm = &socket_client_main; |
| 310 | api_main_t *am = &api_main; |
| 311 | |
| 312 | am->my_client_index = ~0; |
| 313 | am->my_registration = 0; |
| 314 | am->vl_input_queue = 0; |
| 315 | am->msg_index_by_name_and_crc = 0; |
| 316 | scm->socket_fd = 0; |
| 317 | |
| 318 | vl_client_api_unmap (); |
| 319 | } |
| 320 | |
Florin Coras | 0ef8ef2 | 2019-01-18 08:37:13 -0800 | [diff] [blame] | 321 | int |
| 322 | vcl_session_read_ready (vcl_session_t * session) |
| 323 | { |
| 324 | /* Assumes caller has acquired spinlock: vcm->sessions_lockp */ |
| 325 | if (PREDICT_FALSE (session->is_vep)) |
| 326 | { |
| 327 | VDBG (0, "ERROR: session %u: cannot read from an epoll session!", |
| 328 | session->session_index); |
| 329 | return VPPCOM_EBADFD; |
| 330 | } |
| 331 | |
| 332 | if (PREDICT_FALSE (!(session->session_state & (STATE_OPEN | STATE_LISTEN)))) |
| 333 | { |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 334 | vcl_session_state_t state = session->session_state; |
Florin Coras | 0ef8ef2 | 2019-01-18 08:37:13 -0800 | [diff] [blame] | 335 | int rv; |
| 336 | |
| 337 | rv = ((state & STATE_DISCONNECT) ? VPPCOM_ECONNRESET : VPPCOM_ENOTCONN); |
| 338 | |
| 339 | VDBG (1, "session %u [0x%llx]: not open! state 0x%x (%s), ret %d (%s)", |
| 340 | session->session_index, session->vpp_handle, state, |
| 341 | vppcom_session_state_str (state), rv, vppcom_retval_str (rv)); |
| 342 | return rv; |
| 343 | } |
| 344 | |
| 345 | if (session->session_state & STATE_LISTEN) |
| 346 | return clib_fifo_elts (session->accept_evts_fifo); |
| 347 | |
Florin Coras | 653e43f | 2019-03-04 10:56:23 -0800 | [diff] [blame] | 348 | if (vcl_session_is_ct (session)) |
| 349 | return svm_fifo_max_dequeue (session->ct_rx_fifo); |
| 350 | |
Florin Coras | 0ef8ef2 | 2019-01-18 08:37:13 -0800 | [diff] [blame] | 351 | return svm_fifo_max_dequeue (session->rx_fifo); |
| 352 | } |
| 353 | |
| 354 | int |
| 355 | vcl_session_write_ready (vcl_session_t * session) |
| 356 | { |
| 357 | /* Assumes caller has acquired spinlock: vcm->sessions_lockp */ |
| 358 | if (PREDICT_FALSE (session->is_vep)) |
| 359 | { |
| 360 | VDBG (0, "session %u [0x%llx]: cannot write to an epoll session!", |
| 361 | session->session_index, session->vpp_handle); |
| 362 | return VPPCOM_EBADFD; |
| 363 | } |
| 364 | |
| 365 | if (PREDICT_FALSE (session->session_state & STATE_LISTEN)) |
| 366 | { |
| 367 | if (session->tx_fifo) |
| 368 | return svm_fifo_max_enqueue (session->tx_fifo); |
| 369 | else |
| 370 | return VPPCOM_EBADFD; |
| 371 | } |
| 372 | |
| 373 | if (PREDICT_FALSE (!(session->session_state & STATE_OPEN))) |
| 374 | { |
Florin Coras | 288eaab | 2019-02-03 15:26:14 -0800 | [diff] [blame] | 375 | vcl_session_state_t state = session->session_state; |
Florin Coras | 0ef8ef2 | 2019-01-18 08:37:13 -0800 | [diff] [blame] | 376 | int rv; |
| 377 | |
| 378 | rv = ((state & STATE_DISCONNECT) ? VPPCOM_ECONNRESET : VPPCOM_ENOTCONN); |
| 379 | VDBG (0, "session %u [0x%llx]: not open! state 0x%x (%s), ret %d (%s)", |
| 380 | session->session_index, session->vpp_handle, state, |
| 381 | vppcom_session_state_str (state), rv, vppcom_retval_str (rv)); |
| 382 | return rv; |
| 383 | } |
| 384 | |
Florin Coras | 653e43f | 2019-03-04 10:56:23 -0800 | [diff] [blame] | 385 | if (vcl_session_is_ct (session)) |
| 386 | return svm_fifo_max_enqueue (session->ct_tx_fifo); |
| 387 | |
Florin Coras | 0ef8ef2 | 2019-01-18 08:37:13 -0800 | [diff] [blame] | 388 | return svm_fifo_max_enqueue (session->tx_fifo); |
| 389 | } |
| 390 | |
Florin Coras | 9936831 | 2018-08-02 10:45:44 -0700 | [diff] [blame] | 391 | /* |
| 392 | * fd.io coding-style-patch-verification: ON |
| 393 | * |
| 394 | * Local Variables: |
| 395 | * eval: (c-set-style "gnu") |
| 396 | * End: |
| 397 | */ |