misc: move part of vpe apis to vlibmemory

VPE apis are actually vlib apis. This moves those that are not tightly
coupled with vapi to vlib_api

Type: refactor

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I456a64ce49a0cdeff4a0931c6ea513cb639f683e
Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:
Florin Coras
2021-09-14 18:54:45 -07:00
committed by Ole Tr�an
parent 1b6c7932a8
commit 248210c6ca
17 changed files with 1785 additions and 1806 deletions

View File

@ -108,6 +108,36 @@ function (add_vpp_headers path)
endforeach()
endfunction()
macro(add_vat_test_library lib)
cmake_parse_arguments(TEST
""
""
${ARGN}
)
foreach(file ${ARGN})
get_filename_component(name ${file} NAME_WE)
set(test_lib ${lib}_${name}_plugin)
add_library(${test_lib} SHARED ${file})
target_compile_options(${test_lib} PUBLIC ${VPP_DEFAULT_MARCH_FLAGS})
if(NOT VPP_EXTERNAL_PROJECT)
add_dependencies(${test_lib} api_headers)
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(${test_lib} PROPERTIES NO_SONAME 1)
set_target_properties(${test_lib} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vpp_api_test_plugins)
# install .so
install(
TARGETS ${test_lib}
DESTINATION ${VPP_LIBRARY_DIR}/vpp_api_test_plugins
COMPONENT ${ARG_COMPONENT}
)
endforeach()
endmacro()
macro(add_vpp_test_library lib)
cmake_parse_arguments(TEST
""

View File

@ -1478,11 +1478,7 @@ def generate_c_test_boilerplate(services, defines, file_crc, module, plugin,
.format(n=e, ID=e.upper()))
write('}\n')
if plugin:
write('clib_error_t * vat_plugin_register (vat_main_t *vam)\n')
else:
write('clib_error_t * vat_{}_plugin_register (vat_main_t *vam)\n'
.format(module))
write('clib_error_t * vat_plugin_register (vat_main_t *vam)\n')
write('{\n')
write(' {n}_test_main_t * mainp = &{n}_test_main;\n'.format(n=module))
write(' mainp->vat_main = vam;\n')

View File

@ -32,7 +32,6 @@ add_vpp_executable(vpp_api_test ENABLE_EXPORTS
ip_types_api.c
ip_types.c
protocols.def
../vnet/arp/arp_test.c
DEPENDS api_headers

File diff suppressed because it is too large Load Diff

View File

@ -271,12 +271,8 @@ do { \
/* "trust, but verify" */
static inline uword
vnet_sw_if_index_is_api_valid (u32 sw_if_index)
{
return vnet_sw_interface_is_api_valid (vnet_get_main (), sw_if_index);
}
#define vnet_sw_if_index_is_api_valid(sw_if_index) \
vnet_sw_interface_is_api_valid (vnet_get_main (), sw_if_index)
#define VALIDATE_SW_IF_INDEX(mp) \
do { u32 __sw_if_index = ntohl((mp)->sw_if_index); \
@ -423,7 +419,7 @@ typedef struct
/* convenience */
vlib_main_t *vlib_main;
vnet_main_t *vnet_main;
struct vnet_main_t *vnet_main;
} vpe_api_main_t;
extern vpe_api_main_t vpe_api_main;

View File

@ -18,8 +18,9 @@ add_vpp_library (vlibmemory
memory_client.c
socket_client.c
socket_api.c
vlib_api.c
memclnt_api.c
vlib_api_cli.c
vlib_api.c
../vlibapi/api_shared.c
../vlibapi/node_serialize.c
@ -35,6 +36,7 @@ add_vpp_library (vlibmemory
API_FILES
memclnt.api
vlib.api
LINK_LIBRARIES vppinfra svm vlib
)
@ -51,3 +53,7 @@ add_vpp_library (vlibmemoryclient
LINK_LIBRARIES vppinfra svm
)
add_dependencies(vlibmemoryclient vlibmemory_api_headers)
add_vat_test_library(vlib
vlibapi_test.c
)

File diff suppressed because it is too large Load Diff

250
src/vlibmemory/vlib.api Normal file
View File

@ -0,0 +1,250 @@
/*
* Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
option version = "1.0.0";
/** \brief Process a vpe parser cli string request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param cmd_in_shmem - pointer to cli command string
*/
define cli
{
u32 client_index;
u32 context;
u64 cmd_in_shmem;
};
define cli_inband
{
u32 client_index;
u32 context;
string cmd[];
};
/** \brief vpe parser cli string response
@param context - sender context, to match reply w/ request
@param retval - return code for request
@param reply_in_shmem - Reply string from cli processing if any
*/
define cli_reply
{
u32 context;
i32 retval;
u64 reply_in_shmem;
};
define cli_inband_reply
{
u32 context;
i32 retval;
string reply[];
};
/** \brief Get node index using name request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param node_name[] - name of the node
*/
define get_node_index
{
u32 client_index;
u32 context;
string node_name[64];
};
/** \brief Get node index using name request
@param context - sender context, to match reply w/ request
@param retval - return code for the request
@param node_index - index of the desired node if found, else ~0
*/
define get_node_index_reply
{
u32 context;
i32 retval;
u32 node_index;
};
/** \brief Set the next node for a given node request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param node_name[] - node to add the next node to
@param next_name[] - node to add as the next node
*/
define add_node_next
{
u32 client_index;
u32 context;
string node_name[64];
string next_name[64];
};
/** \brief IP Set the next node for a given node response
@param context - sender context, to match reply w/ request
@param retval - return code for the add next node request
@param next_index - the index of the next node if success, else ~0
*/
define add_node_next_reply
{
u32 context;
i32 retval;
u32 next_index;
};
/** \brief show_threads display the information about vpp
threads running on system along with their process id,
cpu id, physical core and cpu socket.
*/
define show_threads
{
u32 client_index;
u32 context;
};
/** \brief thread data
@param id - thread index
@param name - thread name i.e. vpp_main or vpp_wk_0
@param type - thread type i.e. workers or stats
@param pid - thread Process Id
@param cpu_id - thread pinned to cpu.
"CPUs or Logical cores are the number of physical cores times
the number of threads that can run on each core through
the use of hyperthreading." (from unix.stackexchange.com)
@param core - thread pinned to actual physical core.
@param cpu_socket - thread is running on which cpu socket.
*/
typedef thread_data
{
u32 id;
string name[64];
string type[64];
u32 pid;
u32 cpu_id;
u32 core;
u32 cpu_socket;
};
/** \brief show_threads_reply
@param context - returned sender context, to match reply w/ request
@param retval - return code
@param count - number of threads in thread_data array
@param thread_data - array of thread data
*/
define show_threads_reply
{
u32 context;
i32 retval;
u32 count;
vl_api_thread_data_t thread_data[count];
};
define get_node_graph
{
u32 client_index;
u32 context;
};
/** \brief get_node_graph_reply
@param context - returned sender context, to match reply w/ request
@param retval - return code
@param reply_in_shmem - result from vlib_node_serialize, in shared
memory. Process with vlib_node_unserialize, remember to switch
heaps and free the result.
*/
define get_node_graph_reply
{
u32 context;
i32 retval;
u64 reply_in_shmem;
};
/** \brief Query relative index via node names
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param node_name - name of node to find relative index from
@param next_name - next node from node_name to find relative index of
*/
define get_next_index
{
u32 client_index;
u32 context;
string node_name[64];
string next_name[64];
};
/** \brief Reply for get next node index
@param context - sender context which was passed in the request
@param retval - return value
@param next_index - index of the next_node
*/
define get_next_index_reply
{
u32 context;
i32 retval;
u32 next_index;
};
/** \brief f64 types are not standardized across the wire. Sense wire format in each direction by sending the f64 value 1.0.
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param f64_one - The constant of 1.0. If you send a different value, expect an rv=VNET_API_ERROR_API_ENDIAN_FAILED.
*/
define get_f64_endian_value
{
u32 client_index;
u32 context;
f64 f64_one [default=1.0];
};
/** \brief get_f64_endian_value reply message
@param context - sender context which was passed in the request
@param retval - return value - VNET_API_ERROR_API_ENDIAN_FAILED if f64_one != 1.0
@param f64_one_result - The value of 'f64 1.0'
*/
define get_f64_endian_value_reply
{
u32 context;
u32 retval;
f64 f64_one_result;
};
/** \brief Verify f64 wire format by sending a value and receiving the value + 1.0
@param client_index - opaque cookie to identify the sender.
@param context - sender context, to match reply w/ request.
@param f64_value - The value you want to test. Default: 1.0.
*/
define get_f64_increment_by_one
{
u32 client_index;
u32 context;
f64 f64_value [default=1.0];
};
/** \brief get_f64_increment_by_one reply
@param client_index - opaque cookie to identify the sender.
@param context - sender context, to match reply w/ request.
@param f64_value - The input f64_value incremented by 1.0.
*/
define get_f64_increment_by_one_reply
{
u32 context;
u32 retval;
f64 f64_value;
};
/*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1520,6 +1520,12 @@ add_vpp_library (vatclient
DEPENDS api_headers
)
add_vat_test_library(vnet
ip/ip_test.c
arp/arp_test.c
ip6-nd/ip6_nd_test.c
)
##############################################################################
# VAT2 plugins
##############################################################################

View File

@ -158,8 +158,6 @@ api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
#include <vnet/arp/arp.api_test.c>
VAT_REGISTER_FEATURE_FUNCTION (vat_arp_plugin_register);
/*
* fd.io coding-style-patch-verification: ON
*

View File

@ -1547,8 +1547,6 @@ vl_api_ip_details_t_handler (vl_api_ip_details_t *mp)
#include <vnet/ip/ip.api_test.c>
VAT_REGISTER_FEATURE_FUNCTION (vat_ip_plugin_register);
/*
* fd.io coding-style-patch-verification: ON
*

View File

@ -318,6 +318,12 @@ api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
W (ret);
return ret;
}
static int
api_ip6nd_proxy_enable_disable (vat_main_t *vam)
{
// not yet implemented
return -1;
}
#include <ip6-nd/ip6_nd.api_test.c>

View File

@ -73,8 +73,6 @@ if(VPP_API_TEST_BUILTIN)
api/api_main.c
api/plugin.c
api/types.c
../vnet/arp/arp_test.c
../vnet/ip/ip_test.c
)
add_definitions(-DVPP_API_TEST_BUILTIN=1)
endif()

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
called through a shared memory interface.
*/
option version = "1.6.1";
option version = "1.7.0";
import "vpp/api/vpe_types.api";
@ -77,92 +77,6 @@ define control_ping_reply
u32 vpe_pid;
};
/** \brief Process a vpe parser cli string request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param cmd_in_shmem - pointer to cli command string
*/
define cli
{
u32 client_index;
u32 context;
u64 cmd_in_shmem;
};
define cli_inband
{
u32 client_index;
u32 context;
string cmd[];
};
/** \brief vpe parser cli string response
@param context - sender context, to match reply w/ request
@param retval - return code for request
@param reply_in_shmem - Reply string from cli processing if any
*/
define cli_reply
{
u32 context;
i32 retval;
u64 reply_in_shmem;
};
define cli_inband_reply
{
u32 context;
i32 retval;
string reply[];
};
/** \brief Get node index using name request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param node_name[] - name of the node
*/
define get_node_index
{
u32 client_index;
u32 context;
string node_name[64];
};
/** \brief Get node index using name request
@param context - sender context, to match reply w/ request
@param retval - return code for the request
@param node_index - index of the desired node if found, else ~0
*/
define get_node_index_reply
{
u32 context;
i32 retval;
u32 node_index;
};
/** \brief Set the next node for a given node request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param node_name[] - node to add the next node to
@param next_name[] - node to add as the next node
*/
define add_node_next
{
u32 client_index;
u32 context;
string node_name[64];
string next_name[64];
};
/** \brief IP Set the next node for a given node response
@param context - sender context, to match reply w/ request
@param retval - return code for the add next node request
@param next_index - the index of the next node if success, else ~0
*/
define add_node_next_reply
{
u32 context;
i32 retval;
u32 next_index;
};
/** \brief show version
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@ -190,115 +104,6 @@ define show_version_reply
string build_directory[256];
};
/** \brief show_threads display the information about vpp
threads running on system along with their process id,
cpu id, physical core and cpu socket.
*/
define show_threads
{
u32 client_index;
u32 context;
};
/** \brief thread data
@param id - thread index
@param name - thread name i.e. vpp_main or vpp_wk_0
@param type - thread type i.e. workers or stats
@param pid - thread Process Id
@param cpu_id - thread pinned to cpu.
"CPUs or Logical cores are the number of physical cores times
the number of threads that can run on each core through
the use of hyperthreading." (from unix.stackexchange.com)
@param core - thread pinned to actual physical core.
@param cpu_socket - thread is running on which cpu socket.
*/
typedef thread_data
{
u32 id;
string name[64];
string type[64];
u32 pid;
u32 cpu_id;
u32 core;
u32 cpu_socket;
};
/** \brief show_threads_reply
@param context - returned sender context, to match reply w/ request
@param retval - return code
@param count - number of threads in thread_data array
@param thread_data - array of thread data
*/
define show_threads_reply
{
u32 context;
i32 retval;
u32 count;
vl_api_thread_data_t thread_data[count];
};
define get_node_graph
{
u32 client_index;
u32 context;
};
/** \brief get_node_graph_reply
@param context - returned sender context, to match reply w/ request
@param retval - return code
@param reply_in_shmem - result from vlib_node_serialize, in shared
memory. Process with vlib_node_unserialize, remember to switch
heaps and free the result.
*/
define get_node_graph_reply
{
u32 context;
i32 retval;
u64 reply_in_shmem;
};
/** \brief Query relative index via node names
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param node_name - name of node to find relative index from
@param next_name - next node from node_name to find relative index of
*/
define get_next_index
{
u32 client_index;
u32 context;
string node_name[64];
string next_name[64];
};
/** \brief Reply for get next node index
@param context - sender context which was passed in the request
@param retval - return value
@param next_index - index of the next_node
*/
define get_next_index_reply
{
u32 context;
i32 retval;
u32 next_index;
};
define log_dump {
u32 client_index;
u32 context;
vl_api_timestamp_t start_timestamp;
};
define log_details {
u32 context;
vl_api_timestamp_t timestamp;
vl_api_log_level_t level;
string msg_class[32];
string message[256];
};
/** \brief Show the current system timestamp.
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@ -321,52 +126,18 @@ define show_vpe_system_time_reply
vl_api_timestamp_t vpe_system_time;
};
/** \brief f64 types are not standardized across the wire. Sense wire format in each direction by sending the f64 value 1.0.
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param f64_one - The constant of 1.0. If you send a different value, expect an rv=VNET_API_ERROR_API_ENDIAN_FAILED.
*/
define get_f64_endian_value
{
define log_dump {
u32 client_index;
u32 context;
f64 f64_one [default=1.0];
vl_api_timestamp_t start_timestamp;
};
/** \brief get_f64_endian_value reply message
@param context - sender context which was passed in the request
@param retval - return value - VNET_API_ERROR_API_ENDIAN_FAILED if f64_one != 1.0
@param f64_one_result - The value of 'f64 1.0'
*/
define get_f64_endian_value_reply
{
define log_details {
u32 context;
u32 retval;
f64 f64_one_result;
};
/** \brief Verify f64 wire format by sending a value and receiving the value + 1.0
@param client_index - opaque cookie to identify the sender.
@param context - sender context, to match reply w/ request.
@param f64_value - The value you want to test. Default: 1.0.
*/
define get_f64_increment_by_one
{
u32 client_index;
u32 context;
f64 f64_value [default=1.0];
};
/** \brief get_f64_increment_by_one reply
@param client_index - opaque cookie to identify the sender.
@param context - sender context, to match reply w/ request.
@param f64_value - The input f64_value incremented by 1.0.
*/
define get_f64_increment_by_one_reply
{
u32 context;
u32 retval;
f64 f64_value;
vl_api_timestamp_t timestamp;
vl_api_log_level_t level;
string msg_class[32];
string message[256];
};
/*