FD.io VPP  v19.01.2-3-gf61a1a8
Vector Packet Processing
api.h
Go to the documentation of this file.
1 /*
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:
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 included_vlibmemory_api_common_h
19 #define included_vlibmemory_api_common_h
20 
21 #include <svm/svm_common.h>
22 #include <vlibapi/api.h>
23 #include <vlibmemory/memory_api.h>
25 #include <vlibmemory/socket_api.h>
27 
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);
32 
33 always_inline void
35 {
37  {
38  vl_socket_api_send (rp, elem);
39  }
40  else
41  {
42  vl_msg_api_send_shmem (rp->vl_input_queue, (u8 *) & elem);
43  }
44 }
45 
46 always_inline int
48 {
50  return 1;
51  else
53 }
54 
57 {
59  return vl_socket_api_client_handle_to_registration (ntohl (index));
61 }
62 
65 {
66  return reg->clib_file_index;
67 }
68 
71 {
73 }
74 
75 always_inline void
77 {
79  if (cf)
80  clib_file_del (&file_main, cf);
81 }
82 
84 vl_api_send_fd_msg (vl_api_registration_t * reg, int fds[], int n_fds)
85 {
87  if (cf)
88  return vl_sock_api_send_fd_msg (cf->file_descriptor, fds, n_fds);
89  return 0;
90 }
91 
93 vl_api_recv_fd_msg (vl_api_registration_t * reg, int fds[], int n_fds,
94  u32 wait)
95 {
97  if (cf)
98  return vl_sock_api_recv_fd_msg (cf->file_descriptor, fds, n_fds, wait);
99  return 0;
100 }
101 
102 /*
103  * vl_api_clnt process data used by transports (socket api in particular)
104  */
106 extern volatile int **vl_api_queue_cursizes;
107 
109 {
113 
114 #define foreach_histogram_bucket \
115 _(400) \
116 _(200) \
117 _(100) \
118 _(10)
119 
120 typedef enum
121 {
122 #define _(n) SLEEP_##n##_US,
124 #undef _
127 
128 extern u64 vector_rate_histogram[];
129 
130 /*
131  * sockclnt APIs XXX are these actually used anywhere?
132  */
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);
142 
143 #endif /* included_vlibmemory_api_common_h */
144 
145 /*
146  * fd.io coding-style-patch-verification: ON
147  *
148  * Local Variables:
149  * eval: (c-set-style "gnu")
150  * End:
151  */
static void clib_file_del(clib_file_main_t *um, clib_file_t *f)
Definition: file.h:109
u64 vector_rate_histogram[]
Definition: vlib_api.c:202
static void vl_api_registration_del_file(vl_api_registration_t *reg)
Definition: api.h:76
void vl_socket_api_send(vl_api_registration_t *rp, u8 *elem)
Definition: socket_api.c:114
volatile int ** vl_api_queue_cursizes
Definition: memory_api.c:61
static clib_file_t * vl_api_registration_file(vl_api_registration_t *reg)
Definition: api.h:70
unsigned long u64
Definition: types.h:89
enum vl_api_clnt_process_events vl_api_clnt_process_events_t
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:34
u32 file_descriptor
Definition: file.h:54
int vl_mem_api_can_send(svm_queue_t *q)
unsigned char u8
Definition: types.h:56
void sockclnt_close_index(u32 index)
void vl_client_msg_api_send(vl_api_registration_t *cm, u8 *elem)
clib_error_t * vl_sock_api_recv_fd_msg(int socket_fd, int fds[], int n_fds, u32 wait)
static int vl_api_can_send_msg(vl_api_registration_t *rp)
Definition: api.h:47
u32 clib_file_index
Socket only: file index.
Definition: api_common.h:65
static clib_file_t * clib_file_get(clib_file_main_t *fm, u32 file_index)
Definition: file.h:152
#define always_inline
Definition: clib.h:98
static clib_error_t * vl_api_recv_fd_msg(vl_api_registration_t *reg, int fds[], int n_fds, u32 wait)
Definition: api.h:93
vl_api_registration_t * vl_mem_api_client_index_to_registration(u32 handle)
Definition: memory_api.c:770
#define foreach_histogram_bucket
Definition: api.h:114
vlib_node_registration_t vl_api_clnt_node
(constructor) VLIB_REGISTER_NODE (vl_api_clnt_node)
Definition: vlib_api.c:438
void vl_api_rpc_call_main_thread(void *fp, u8 *data, u32 data_length)
Definition: vlib_api.c:623
clib_file_main_t file_main
Definition: main.c:63
vl_api_registration_t * sockclnt_get_registration(u32 index)
unsigned int u32
Definition: types.h:88
vl_registration_type_t registration_type
type
Definition: api_common.h:47
svm_queue_t * vl_input_queue
shared memory only: pointer to client input queue
Definition: api_common.h:60
unsigned short u16
Definition: types.h:57
vl_api_clnt_process_events
Definition: api.h:108
u16 vl_client_get_first_plugin_msg_id(const char *plugin_name)
#define PREDICT_FALSE(x)
Definition: clib.h:111
signed char i8
Definition: types.h:45
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:202
u32 sockclnt_open_index(char *client_name, char *hostname, int port)
An API client registration, only in vpp/vlib.
Definition: api_common.h:45
void vl_msg_api_send_shmem(svm_queue_t *q, u8 *elem)
Shared memory connection.
Definition: api_common.h:37
vlib_main_t * vm
Definition: buffer.c:301
vl_api_registration_t * vl_socket_api_client_handle_to_registration(u32 handle)
Definition: socket_api.c:99
u8 * vl_api_serialize_message_table(api_main_t *am, u8 *vector)
Definition: vlib_api.c:72
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:56
static clib_error_t * vl_api_send_fd_msg(vl_api_registration_t *reg, int fds[], int n_fds)
Definition: api.h:84
static u32 vl_api_registration_file_index(vl_api_registration_t *reg)
Definition: api.h:64
void vl_api_send_pending_rpc_requests(vlib_main_t *vm)
Definition: main.c:1641
u8 vl_socket_api_registration_handle_is_valid(u32 reg_handle)
Definition: socket_api.c:66
struct _vlib_node_registration vlib_node_registration_t
clib_error_t * vl_sock_api_send_fd_msg(int socket_fd, int fds[], int n_fds)
Definition: socket_api.c:495
u64 uword
Definition: types.h:112
Definition: file.h:51
histogram_index_t
Definition: api.h:120
void vl_socket_process_msg(struct clib_file *uf, struct vl_api_registration_ *rp, i8 *input_v)
void socksvr_add_pending_output(struct clib_file *uf, struct vl_api_registration_ *cf, u8 *buffer, uword buffer_bytes)