2 *------------------------------------------------------------------
3 * Copyright (c) 2009 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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
18 #ifndef included_vlibmemory_api_common_h
19 #define included_vlibmemory_api_common_h
21 #include <svm/svm_common.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/memory_api.h>
24 #include <vlibmemory/memory_client.h>
25 #include <vlibmemory/socket_api.h>
26 #include <vlibmemory/socket_client.h>
28 void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length);
29 u16 vl_client_get_first_plugin_msg_id (const char *plugin_name);
30 void vl_api_send_pending_rpc_requests (vlib_main_t * vm);
31 u8 *vl_api_serialize_message_table (api_main_t * am, u8 * vector);
34 vl_api_send_msg (vl_api_registration_t * rp, u8 * elem)
36 if (PREDICT_FALSE (rp->registration_type > REGISTRATION_TYPE_SHMEM))
38 vl_socket_api_send (rp, elem);
42 vl_msg_api_send_shmem (rp->vl_input_queue, (u8 *) & elem);
47 vl_api_can_send_msg (vl_api_registration_t * rp)
49 if (PREDICT_FALSE (rp->registration_type > REGISTRATION_TYPE_SHMEM))
52 return vl_mem_api_can_send (rp->vl_input_queue);
55 always_inline vl_api_registration_t *
56 vl_api_client_index_to_registration (u32 index)
58 if (PREDICT_FALSE (socket_main.current_rp != 0))
59 return socket_main.current_rp;
61 return (vl_mem_api_client_index_to_registration (index));
65 vl_api_registration_file_index (vl_api_registration_t * reg)
67 return reg->clib_file_index;
70 always_inline clib_file_t *
71 vl_api_registration_file (vl_api_registration_t * reg)
73 return clib_file_get (&file_main, vl_api_registration_file_index (reg));
77 vl_api_registration_del_file (vl_api_registration_t * reg)
79 clib_file_t *cf = vl_api_registration_file (reg);
81 clib_file_del (&file_main, cf);
84 always_inline clib_error_t *
85 vl_api_send_fd_msg (vl_api_registration_t * reg, int fd_to_send)
87 clib_file_t *cf = vl_api_registration_file (reg);
89 return vl_sock_api_send_fd_msg (cf->file_descriptor, fd_to_send);
93 always_inline clib_error_t *
94 vl_api_recv_fd_msg (vl_api_registration_t * reg, int *fd_to_recv, u32 wait)
96 clib_file_t *cf = vl_api_registration_file (reg);
98 return vl_sock_api_recv_fd_msg (cf->file_descriptor, fd_to_recv, wait);
103 * vl_api_clnt process data used by transports (socket api in particular)
105 extern vlib_node_registration_t vl_api_clnt_node;
106 extern volatile int **vl_api_queue_cursizes;
108 typedef enum vl_api_clnt_process_events
110 QUEUE_SIGNAL_EVENT = 1,
112 } vl_api_clnt_process_events_t;
114 #define foreach_histogram_bucket \
122 #define _(n) SLEEP_##n##_US,
123 foreach_histogram_bucket
128 extern u64 vector_rate_histogram[];
131 * sockclnt APIs XXX are these actually used anywhere?
133 vl_api_registration_t *sockclnt_get_registration (u32 index);
134 void socksvr_add_pending_output (struct clib_file *uf,
135 struct vl_api_registration_ *cf,
136 u8 * buffer, uword buffer_bytes);
137 void vl_socket_process_msg (struct clib_file *uf,
138 struct vl_api_registration_ *rp, i8 * input_v);
139 u32 sockclnt_open_index (char *client_name, char *hostname, int port);
140 void sockclnt_close_index (u32 index);
141 void vl_client_msg_api_send (vl_api_registration_t * cm, u8 * elem);
143 #endif /* included_vlibmemory_api_common_h */
146 * fd.io coding-style-patch-verification: ON
149 * eval: (c-set-style "gnu")