aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-09-14 18:54:45 -0700
committerOle Tr�an <otroan@employees.org>2021-09-27 07:04:51 +0000
commit248210c6ca1716ee2c5e6c974051218930fa4c26 (patch)
tree5c4e8e1c53800e8ec43da7a8dbc4fbe73e5c9672 /src/vpp
parent1b6c7932a8feb419aae73a00a6784d7c110decdc (diff)
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>
Diffstat (limited to 'src/vpp')
-rw-r--r--src/vpp/CMakeLists.txt2
-rw-r--r--src/vpp/api/api.c367
-rw-r--r--src/vpp/api/vpe.api243
3 files changed, 17 insertions, 595 deletions
diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt
index e15037cccb7..32f702de36d 100644
--- a/src/vpp/CMakeLists.txt
+++ b/src/vpp/CMakeLists.txt
@@ -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()
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index b935c002228..5477ec949ae 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -76,20 +76,11 @@
#undef vl_printfun
#include <vlibapi/api_helper_macros.h>
-#define foreach_vpe_api_msg \
-_(CONTROL_PING, control_ping) \
-_(CLI, cli) \
-_(CLI_INBAND, cli_inband) \
-_(GET_NODE_INDEX, get_node_index) \
-_(ADD_NODE_NEXT, add_node_next) \
-_(SHOW_VERSION, show_version) \
-_(SHOW_THREADS, show_threads) \
-_(GET_NODE_GRAPH, get_node_graph) \
-_(GET_NEXT_INDEX, get_next_index) \
-_(LOG_DUMP, log_dump) \
-_(SHOW_VPE_SYSTEM_TIME, show_vpe_system_time) \
-_(GET_F64_ENDIAN_VALUE, get_f64_endian_value) \
-_(GET_F64_INCREMENT_BY_ONE, get_f64_increment_by_one) \
+#define foreach_vpe_api_msg \
+ _ (CONTROL_PING, control_ping) \
+ _ (SHOW_VERSION, show_version) \
+ _ (SHOW_VPE_SYSTEM_TIME, show_vpe_system_time) \
+ _ (LOG_DUMP, log_dump)
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
@@ -139,108 +130,6 @@ vl_api_control_ping_t_handler (vl_api_control_ping_t * mp)
}
static void
-shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
-{
- u8 **shmem_vecp = (u8 **) arg;
- u8 *shmem_vec;
- void *oldheap;
- u32 offset;
-
- shmem_vec = *shmem_vecp;
-
- offset = vec_len (shmem_vec);
-
- oldheap = vl_msg_push_heap ();
-
- vec_validate (shmem_vec, offset + buffer_bytes - 1);
-
- clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
-
- vl_msg_pop_heap (oldheap);
-
- *shmem_vecp = shmem_vec;
-}
-
-
-static void
-vl_api_cli_t_handler (vl_api_cli_t * mp)
-{
- vl_api_cli_reply_t *rp;
- vl_api_registration_t *reg;
- vlib_main_t *vm = vlib_get_main ();
- unformat_input_t input;
- u8 *shmem_vec = 0;
- void *oldheap;
-
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;;
-
- rp = vl_msg_api_alloc (sizeof (*rp));
- rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
- rp->context = mp->context;
-
- unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
-
- vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
-
- oldheap = vl_msg_push_heap ();
- vec_add1 (shmem_vec, 0);
- vl_msg_pop_heap (oldheap);
-
- rp->reply_in_shmem = (uword) shmem_vec;
-
- vl_api_send_msg (reg, (u8 *) rp);
-}
-
-static void
-inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
-{
- u8 **mem_vecp = (u8 **) arg;
- u8 *mem_vec = *mem_vecp;
- u32 offset = vec_len (mem_vec);
-
- vec_validate (mem_vec, offset + buffer_bytes - 1);
- clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
- *mem_vecp = mem_vec;
-}
-
-static void
-vl_api_cli_inband_t_handler (vl_api_cli_inband_t * mp)
-{
- vl_api_cli_inband_reply_t *rmp;
- int rv = 0;
- vlib_main_t *vm = vlib_get_main ();
- unformat_input_t input;
- u8 *out_vec = 0;
- u8 *cmd_vec = 0;
-
- if (vl_msg_api_get_msg_length (mp) <
- vl_api_string_len (&mp->cmd) + sizeof (*mp))
- {
- rv = -1;
- goto error;
- }
-
- cmd_vec = vl_api_from_api_to_new_vec (mp, &mp->cmd);
-
- unformat_init_string (&input, (char *) cmd_vec,
- vl_api_string_len (&mp->cmd));
- rv = vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
- unformat_free (&input);
-
-error:
- /* *INDENT-OFF* */
- REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, vec_len (out_vec),
- ({
- vl_api_vec_to_api_string(out_vec, &rmp->reply);
- }));
- /* *INDENT-ON* */
- vec_free (out_vec);
- vec_free (cmd_vec);
-}
-
-static void
vl_api_show_version_t_handler (vl_api_show_version_t * mp)
{
vl_api_show_version_reply_t *rmp;
@@ -264,204 +153,14 @@ vl_api_show_version_t_handler (vl_api_show_version_t * mp)
}
static void
-get_thread_data (vl_api_thread_data_t * td, int index)
+vl_api_show_vpe_system_time_t_handler (vl_api_show_vpe_system_time_t *mp)
{
- vlib_worker_thread_t *w = vlib_worker_threads + index;
- td->id = htonl (index);
- if (w->name)
- strncpy ((char *) td->name, (char *) w->name, ARRAY_LEN (td->name) - 1);
- if (w->registration)
- strncpy ((char *) td->type, (char *) w->registration->name,
- ARRAY_LEN (td->type) - 1);
- td->pid = htonl (w->lwp);
- td->cpu_id = htonl (w->cpu_id);
- td->core = htonl (w->core_id);
- td->cpu_socket = htonl (w->numa_id);
-}
-
-static void
-vl_api_show_threads_t_handler (vl_api_show_threads_t * mp)
-{
- int count = 0;
-
-#if !defined(__powerpc64__)
- vl_api_registration_t *reg;
- vl_api_show_threads_reply_t *rmp;
- vl_api_thread_data_t *td;
- int i, msg_size = 0;
- count = vec_len (vlib_worker_threads);
- if (!count)
- return;
-
- msg_size = sizeof (*rmp) + sizeof (rmp->thread_data[0]) * count;
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;
-
- rmp = vl_msg_api_alloc (msg_size);
- clib_memset (rmp, 0, msg_size);
- rmp->_vl_msg_id = htons (VL_API_SHOW_THREADS_REPLY);
- rmp->context = mp->context;
- rmp->count = htonl (count);
- td = rmp->thread_data;
-
- for (i = 0; i < count; i++)
- {
- get_thread_data (&td[i], i);
- }
-
- vl_api_send_msg (reg, (u8 *) rmp);
-#else
-
- /* unimplemented support */
- rv = -9;
- clib_warning ("power pc does not support show threads api");
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_SHOW_THREADS_REPLY,
- ({
- rmp->count = htonl(count);
- }));
- /* *INDENT-ON* */
-#endif
-}
-
-static void
-vl_api_get_node_index_t_handler (vl_api_get_node_index_t * mp)
-{
- vlib_main_t *vm = vlib_get_main ();
- vl_api_get_node_index_reply_t *rmp;
- vlib_node_t *n;
int rv = 0;
- u32 node_index = ~0;
-
- n = vlib_get_node_by_name (vm, mp->node_name);
-
- if (n == 0)
- rv = VNET_API_ERROR_NO_SUCH_NODE;
- else
- node_index = n->index;
-
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
- ({
- rmp->node_index = htonl(node_index);
- }));
- /* *INDENT-ON* */
-}
-
-static void
-vl_api_get_next_index_t_handler (vl_api_get_next_index_t * mp)
-{
- vlib_main_t *vm = vlib_get_main ();
- vl_api_get_next_index_reply_t *rmp;
- vlib_node_t *node, *next_node;
- int rv = 0;
- u32 next_node_index = ~0, next_index = ~0;
- uword *p;
-
- node = vlib_get_node_by_name (vm, mp->node_name);
-
- if (node == 0)
- {
- rv = VNET_API_ERROR_NO_SUCH_NODE;
- goto out;
- }
-
- next_node = vlib_get_node_by_name (vm, mp->next_name);
-
- if (next_node == 0)
- {
- rv = VNET_API_ERROR_NO_SUCH_NODE2;
- goto out;
- }
- else
- next_node_index = next_node->index;
-
- p = hash_get (node->next_slot_by_node, next_node_index);
-
- if (p == 0)
- {
- rv = VNET_API_ERROR_NO_SUCH_ENTRY;
- goto out;
- }
- else
- next_index = p[0];
-
-out:
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
- ({
- rmp->next_index = htonl(next_index);
- }));
- /* *INDENT-ON* */
-}
-
-static void
-vl_api_add_node_next_t_handler (vl_api_add_node_next_t * mp)
-{
- vlib_main_t *vm = vlib_get_main ();
- vl_api_add_node_next_reply_t *rmp;
- vlib_node_t *n, *next;
- int rv = 0;
- u32 next_index = ~0;
-
- n = vlib_get_node_by_name (vm, mp->node_name);
-
- if (n == 0)
- {
- rv = VNET_API_ERROR_NO_SUCH_NODE;
- goto out;
- }
-
- next = vlib_get_node_by_name (vm, mp->next_name);
-
- if (next == 0)
- rv = VNET_API_ERROR_NO_SUCH_NODE2;
- else
- next_index = vlib_node_add_next (vm, n->index, next->index);
-
-out:
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_ADD_NODE_NEXT_REPLY,
- ({
- rmp->next_index = htonl(next_index);
- }));
- /* *INDENT-ON* */
-}
-
-static void
-vl_api_get_node_graph_t_handler (vl_api_get_node_graph_t * mp)
-{
- int rv = 0;
- u8 *vector = 0;
- vlib_main_t *vm = vlib_get_main ();
- void *oldheap;
- vl_api_get_node_graph_reply_t *rmp;
- static vlib_node_t ***node_dups;
- static vlib_main_t **stat_vms;
-
- oldheap = vl_msg_push_heap ();
-
- /*
- * Keep the number of memcpy ops to a minimum (e.g. 1).
- */
- vec_validate (vector, 16384);
- vec_reset_length (vector);
-
- vlib_node_get_nodes (vm, 0 /* main threads */ ,
- 0 /* include stats */ ,
- 1 /* barrier sync */ ,
- &node_dups, &stat_vms);
- vector = vlib_node_serialize (vm, node_dups, vector, 1 /* include nexts */ ,
- 1 /* include stats */ );
-
- vl_msg_pop_heap (oldheap);
-
+ vl_api_show_vpe_system_time_reply_t *rmp;
/* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
- ({
- rmp->reply_in_shmem = (uword) vector;
- }));
+ REPLY_MACRO2 (
+ VL_API_SHOW_VPE_SYSTEM_TIME_REPLY,
+ ({ rmp->vpe_system_time = clib_host_to_net_f64 (unix_time_now ()); }));
/* *INDENT-ON* */
}
@@ -530,51 +229,6 @@ vl_api_log_dump_t_handler (vl_api_log_dump_t * mp)
}
-static void
-vl_api_show_vpe_system_time_t_handler (vl_api_show_vpe_system_time_t * mp)
-{
- int rv = 0;
- vl_api_show_vpe_system_time_reply_t *rmp;
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_SHOW_VPE_SYSTEM_TIME_REPLY,
- ({
- rmp->vpe_system_time = clib_host_to_net_f64 (unix_time_now ());
- }));
- /* *INDENT-ON* */
-}
-
-static void
-vl_api_get_f64_endian_value_t_handler (vl_api_get_f64_endian_value_t * mp)
-{
- int rv = 0;
- f64 one = 1.0;
- vl_api_get_f64_endian_value_reply_t *rmp;
- if (1.0 != clib_net_to_host_f64 (mp->f64_one))
- rv = VNET_API_ERROR_API_ENDIAN_FAILED;
-
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_GET_F64_ENDIAN_VALUE_REPLY,
- ({
- rmp->f64_one_result = clib_host_to_net_f64 (one);
- }));
- /* *INDENT-ON* */
-}
-
-static void
-vl_api_get_f64_increment_by_one_t_handler (vl_api_get_f64_increment_by_one_t *
- mp)
-{
- int rv = 0;
- vl_api_get_f64_increment_by_one_reply_t *rmp;
-
- /* *INDENT-OFF* */
- REPLY_MACRO2(VL_API_GET_F64_INCREMENT_BY_ONE_REPLY,
- ({
- rmp->f64_value = clib_host_to_net_f64 (clib_net_to_host_f64(mp->f64_value) + 1.0);
- }));
- /* *INDENT-ON* */
-}
-
#define BOUNCE_HANDLER(nn) \
static void vl_api_##nn##_t_handler ( \
vl_api_##nn##_t *mp) \
@@ -642,7 +296,6 @@ vpe_api_hookup (vlib_main_t * vm)
am->is_mp_safe[VL_API_CONTROL_PING] = 1;
am->is_mp_safe[VL_API_CONTROL_PING_REPLY] = 1;
am->is_mp_safe[VL_API_IP_ROUTE_ADD_DEL] = 1;
- am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
/*
* Set up the (msg_name, crc, message-id) table
diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api
index 9047d0e1aa9..3c4c0214ad5 100644
--- a/src/vpp/api/vpe.api
+++ b/src/vpp/api/vpe.api
@@ -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,99 +104,26 @@ 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
+/** \brief Show the current system timestamp.
@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
+define show_vpe_system_time
{
u32 client_index;
u32 context;
- string node_name[64];
- string next_name[64];
};
-/** \brief Reply for get next node index
+/** \brief Reply for show vpe system time.
@param context - sender context which was passed in the request
@param retval - return value
- @param next_index - index of the next_node
+ @param vpe_system_time - the time in seconds since epoch of the host system.
*/
-define get_next_index_reply
+define show_vpe_system_time_reply
{
u32 context;
i32 retval;
- u32 next_index;
+ vl_api_timestamp_t vpe_system_time;
};
define log_dump {
@@ -299,76 +140,6 @@ define log_details {
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
-*/
-define show_vpe_system_time
-{
- u32 client_index;
- u32 context;
-};
-
-/** \brief Reply for show vpe system time.
- @param context - sender context which was passed in the request
- @param retval - return value
- @param vpe_system_time - the time in seconds since epoch of the host system.
-*/
-define show_vpe_system_time_reply
-{
- u32 context;
- i32 retval;
- 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
-{
- 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")