Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 1 | /* |
| 2 | *------------------------------------------------------------------ |
| 3 | * Copyright (c) 2018 Cisco and/or its affiliates. |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at: |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | *------------------------------------------------------------------ |
| 16 | */ |
| 17 | |
| 18 | #ifndef SRC_VLIBMEMORY_MEMORY_CLIENT_H_ |
| 19 | #define SRC_VLIBMEMORY_MEMORY_CLIENT_H_ |
| 20 | |
Damjan Marion | b704971 | 2022-05-20 13:05:38 +0200 | [diff] [blame] | 21 | #include <vlibapi/memory_shared.h> |
Dave Barach | 920180e | 2019-11-14 08:03:48 -0500 | [diff] [blame] | 22 | #include <setjmp.h> |
| 23 | |
| 24 | /* |
| 25 | * Exported so folks can code a working custom rx_pthread function |
| 26 | */ |
| 27 | typedef struct |
| 28 | { |
| 29 | u8 rx_thread_jmpbuf_valid; |
| 30 | u8 connected_to_vlib; |
| 31 | jmp_buf rx_thread_jmpbuf; |
| 32 | pthread_t rx_thread_handle; |
| 33 | /* Plugin message base lookup scheme */ |
| 34 | volatile u8 first_msg_id_reply_ready; |
| 35 | u16 first_msg_id_reply; |
| 36 | } memory_client_main_t; |
| 37 | |
| 38 | extern memory_client_main_t memory_client_main; |
Dave Barach | 39d6911 | 2019-11-27 11:42:13 -0500 | [diff] [blame] | 39 | extern __thread memory_client_main_t *my_memory_client_main; |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 40 | |
| 41 | int vl_client_connect (const char *name, int ctx_quota, int input_queue_size); |
Florin Coras | eaec2a6 | 2018-12-04 16:34:05 -0800 | [diff] [blame] | 42 | void vl_client_send_disconnect (u8 do_cleanup); |
Florin Coras | d6c30d9 | 2018-01-29 05:11:24 -0800 | [diff] [blame] | 43 | int vl_client_disconnect (void); |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 44 | int vl_client_api_map (const char *region_name); |
| 45 | void vl_client_api_unmap (void); |
| 46 | void vl_client_disconnect_from_vlib (void); |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 47 | void vl_client_disconnect_from_vlib_no_unmap (void); |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 48 | int vl_client_connect_to_vlib (const char *svm_name, const char *client_name, |
| 49 | int rx_queue_size); |
Dave Barach | 920180e | 2019-11-14 08:03:48 -0500 | [diff] [blame] | 50 | int vl_client_connect_to_vlib_thread_fn (const char *svm_name, |
| 51 | const char *client_name, |
| 52 | int rx_queue_size, |
Dave Barach | 39d6911 | 2019-11-27 11:42:13 -0500 | [diff] [blame] | 53 | void *(*)(void *), void *); |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 54 | int vl_client_connect_to_vlib_no_rx_pthread (const char *svm_name, |
| 55 | const char *client_name, |
| 56 | int rx_queue_size); |
| 57 | int vl_client_connect_to_vlib_no_map (const char *svm_name, |
| 58 | const char *client_name, |
| 59 | int rx_queue_size); |
Tomasz Kulasek | 97dcf5b | 2019-01-31 18:26:32 +0100 | [diff] [blame] | 60 | int vl_client_connect_to_vlib_no_rx_pthread_no_map (const char *svm_name, |
| 61 | const char *client_name, |
| 62 | int rx_queue_size); |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 63 | void vl_client_install_client_message_handlers (void); |
Florin Coras | b384b54 | 2018-01-15 01:08:33 -0800 | [diff] [blame] | 64 | u8 vl_mem_client_is_connected (void); |
Matthew Smith | 57f177d | 2022-12-15 22:18:08 +0000 | [diff] [blame^] | 65 | void vl_client_stop_rx_thread (svm_queue_t *vl_input_queue); |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 66 | |
Dave Barach | 39d6911 | 2019-11-27 11:42:13 -0500 | [diff] [blame] | 67 | always_inline memory_client_main_t * |
| 68 | vlibapi_get_memory_client_main (void) |
| 69 | { |
| 70 | ASSERT (my_memory_client_main); |
| 71 | return my_memory_client_main; |
| 72 | } |
| 73 | |
Florin Coras | 684fb6e | 2019-12-09 16:42:50 -0800 | [diff] [blame] | 74 | always_inline void |
| 75 | vlibapi_set_memory_client_main (memory_client_main_t * mm) |
| 76 | { |
| 77 | my_memory_client_main = mm; |
| 78 | } |
| 79 | |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 80 | #endif /* SRC_VLIBMEMORY_MEMORY_CLIENT_H_ */ |
| 81 | |
| 82 | /* |
| 83 | * fd.io coding-style-patch-verification: ON |
| 84 | * |
| 85 | * Local Variables: |
| 86 | * eval: (c-set-style "gnu") |
| 87 | * End: |
| 88 | */ |