2 *------------------------------------------------------------------
3 * Copyright (c) 2017 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 VAPI_INTERNAL_H
19 #define VAPI_INTERNAL_H
23 #include <vppinfra/types.h>
26 * @file vapi_internal.h
28 * internal vpp api C declarations
30 * This file contains internal vpp api C declarations. It's not intended to be
31 * used by the client programmer and the API defined here might change at any
41 typedef struct __attribute__ ((__packed__))
45 } vapi_type_msg_header1_t;
47 typedef struct __attribute__ ((__packed__))
52 } vapi_type_msg_header2_t;
55 vapi_type_msg_header1_t_hton (vapi_type_msg_header1_t * h)
57 h->_vl_msg_id = htobe16 (h->_vl_msg_id);
61 vapi_type_msg_header1_t_ntoh (vapi_type_msg_header1_t * h)
63 h->_vl_msg_id = be16toh (h->_vl_msg_id);
67 vapi_type_msg_header2_t_hton (vapi_type_msg_header2_t * h)
69 h->_vl_msg_id = htobe16 (h->_vl_msg_id);
73 vapi_type_msg_header2_t_ntoh (vapi_type_msg_header2_t * h)
75 h->_vl_msg_id = be16toh (h->_vl_msg_id);
79 #include <vapi/vapi.h>
81 typedef vapi_error_e (*vapi_cb_t) (struct vapi_ctx_s *, void *, vapi_error_e,
84 typedef void (*generic_swap_fn_t) (void *payload);
90 const char *name_with_crc;
91 size_t name_with_crc_len;
93 unsigned int context_offset;
94 unsigned int payload_offset;
96 generic_swap_fn_t swap_to_be;
97 generic_swap_fn_t swap_to_host;
98 vapi_msg_id_t id; /* assigned at run-time */
99 } vapi_message_desc_t;
106 void (*swap_to_be) (void *payload);
107 void (*swap_to_host) (void *payload);
110 vapi_msg_id_t vapi_register_msg (vapi_message_desc_t * msg);
111 u16 vapi_lookup_vl_msg_id (vapi_ctx_t ctx, vapi_msg_id_t id);
112 vapi_msg_id_t vapi_lookup_vapi_msg_id_t (vapi_ctx_t ctx, u16 vl_msg_id);
113 int vapi_get_client_index (vapi_ctx_t ctx);
114 bool vapi_is_nonblocking (vapi_ctx_t ctx);
115 bool vapi_requests_empty (vapi_ctx_t ctx);
116 bool vapi_requests_full (vapi_ctx_t ctx);
117 size_t vapi_get_request_count (vapi_ctx_t ctx);
118 size_t vapi_get_max_request_count (vapi_ctx_t ctx);
119 u32 vapi_gen_req_context (vapi_ctx_t ctx);
120 void vapi_store_request (vapi_ctx_t ctx, u32 context, bool is_dump,
121 vapi_cb_t callback, void *callback_ctx);
122 int vapi_get_payload_offset (vapi_msg_id_t id);
123 void (*vapi_get_swap_to_host_func (vapi_msg_id_t id)) (void *payload);
124 void (*vapi_get_swap_to_be_func (vapi_msg_id_t id)) (void *payload);
125 size_t vapi_get_message_size (vapi_msg_id_t id);
126 size_t vapi_get_context_offset (vapi_msg_id_t id);
127 bool vapi_msg_is_with_context (vapi_msg_id_t id);
128 size_t vapi_get_message_count();
129 const char *vapi_get_msg_name(vapi_msg_id_t id);
131 vapi_error_e vapi_producer_lock (vapi_ctx_t ctx);
132 vapi_error_e vapi_producer_unlock (vapi_ctx_t ctx);