diff options
-rw-r--r-- | hicn-light/src/CMakeLists.txt | 8 | ||||
-rw-r--r-- | hicn-light/src/utils/CMakeLists.txt | 6 | ||||
-rw-r--r-- | hicn-light/src/utils/commands.h | 87 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.c | 9 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face.h | 25 | ||||
-rw-r--r-- | hicn-plugin/src/faces/face_cli.c | 71 | ||||
-rw-r--r-- | hicn-plugin/src/faces/ip/face_ip.c | 13 | ||||
-rw-r--r-- | hicn-plugin/src/faces/ip/face_ip.h | 7 | ||||
-rw-r--r-- | hicn-plugin/src/faces/ip/face_ip_node.c | 61 | ||||
-rw-r--r-- | hicn-plugin/src/faces/ip/iface_ip_node.c | 81 | ||||
-rw-r--r-- | hicn-plugin/src/faces/udp/face_udp.c | 36 | ||||
-rw-r--r-- | hicn-plugin/src/faces/udp/face_udp_node.c | 65 | ||||
-rw-r--r-- | hicn-plugin/src/faces/udp/iface_udp_node.c | 58 | ||||
-rw-r--r-- | hicn-plugin/src/hicn.api | 41 | ||||
-rw-r--r-- | hicn-plugin/src/hicn_api.c | 63 | ||||
-rw-r--r-- | hicn-plugin/src/hicn_api_test.c | 82 |
16 files changed, 608 insertions, 105 deletions
diff --git a/hicn-light/src/CMakeLists.txt b/hicn-light/src/CMakeLists.txt index 68ef851f1..c7a4b5efd 100644 --- a/hicn-light/src/CMakeLists.txt +++ b/hicn-light/src/CMakeLists.txt @@ -36,18 +36,14 @@ list(INSERT HICN_LIGHT_INCLUDE_DIRS 0 ${CMAKE_CURRENT_SOURCE_DIR}/.. ) -if (INSTALL_HEADER) - set(TO_INSTALL_HEADERS ${HEADER_FILES}) -endif() - build_library(${LIBHICN_LIGHT} STATIC SOURCES ${SOURCE_FILES} - INSTALL_HEADERS ${TO_INSTALL_HEADERS} + INSTALL_HEADERS ${TO_INSTALL_HEADER_FILES} LINK_LIBRARIES ${LIBRARIES} DEPENDS ${DEPENDENCIES} COMPONENT ${LIBHICN_LIGHT} INCLUDE_DIRS ${HICN_LIGHT_INCLUDE_DIRS} - INSTALL_ROOT_DIR hicn/hicn-light + INSTALL_ROOT_DIR hicn/light DEFINITIONS ${COMPILER_DEFINITIONS} ) diff --git a/hicn-light/src/utils/CMakeLists.txt b/hicn-light/src/utils/CMakeLists.txt index 7d438d157..120061211 100644 --- a/hicn-light/src/utils/CMakeLists.txt +++ b/hicn-light/src/utils/CMakeLists.txt @@ -32,5 +32,11 @@ list(APPEND SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/utils.c ) +set(TO_INSTALL_HEADER_FILES + ${TO_INSTALL_HEADER_FILES} + ${CMAKE_CURRENT_SOURCE_DIR}/commands.h + PARENT_SCOPE +) + set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE) set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE)
\ No newline at end of file diff --git a/hicn-light/src/utils/commands.h b/hicn-light/src/utils/commands.h index d4147cbdd..9527e5064 100644 --- a/hicn-light/src/utils/commands.h +++ b/hicn-light/src/utils/commands.h @@ -27,7 +27,6 @@ #include <netinet/in.h> #include <sys/socket.h> #endif -#include <src/config.h> #include <stdint.h> #include <stdlib.h> @@ -41,7 +40,7 @@ union commandAddr { }; typedef enum { - REQUEST_LIGHT = 0xc0, //this is a command + REQUEST_LIGHT = 0xc0, // this is a command RESPONSE_LIGHT, ACK_LIGHT, NACK_LIGHT, @@ -287,47 +286,47 @@ typedef struct { // REMINDER: when a new_command is added, the following switch has to be // updated. static inline int payloadLengthDaemon(command_id id) { - switch (id){ - case ADD_LISTENER: - return sizeof(add_listener_command); - case ADD_CONNECTION: - return sizeof(add_connection_command); - case LIST_CONNECTIONS: - return 0; // list connections: payload always 0 - case ADD_ROUTE: - return sizeof(add_route_command); - case LIST_ROUTES: - return 0; // list routes: payload always 0 - case REMOVE_CONNECTION: - return sizeof(remove_connection_command); - case REMOVE_ROUTE: - return sizeof(remove_route_command); - case CACHE_STORE: - return sizeof(cache_store_command); - case CACHE_SERVE: - return sizeof(cache_serve_command); - case CACHE_CLEAR: - return 0; // cache clear - case SET_STRATEGY: - return sizeof(set_strategy_command); - case SET_WLDR: - return sizeof(set_wldr_command); - case ADD_PUNTING: - return sizeof(add_punting_command); - case LIST_LISTENERS: - return 0; // list listeners: payload always 0 - case MAPME_ENABLE: - return sizeof(mapme_activator_command); - case MAPME_DISCOVERY: - return sizeof(mapme_activator_command); - case MAPME_TIMESCALE: - return sizeof(mapme_timing_command); - case MAPME_RETX: - return sizeof(mapme_timing_command); - case LAST_COMMAND_VALUE: - return 0; - default: - return 0; - } + switch (id) { + case ADD_LISTENER: + return sizeof(add_listener_command); + case ADD_CONNECTION: + return sizeof(add_connection_command); + case LIST_CONNECTIONS: + return 0; // list connections: payload always 0 + case ADD_ROUTE: + return sizeof(add_route_command); + case LIST_ROUTES: + return 0; // list routes: payload always 0 + case REMOVE_CONNECTION: + return sizeof(remove_connection_command); + case REMOVE_ROUTE: + return sizeof(remove_route_command); + case CACHE_STORE: + return sizeof(cache_store_command); + case CACHE_SERVE: + return sizeof(cache_serve_command); + case CACHE_CLEAR: + return 0; // cache clear + case SET_STRATEGY: + return sizeof(set_strategy_command); + case SET_WLDR: + return sizeof(set_wldr_command); + case ADD_PUNTING: + return sizeof(add_punting_command); + case LIST_LISTENERS: + return 0; // list listeners: payload always 0 + case MAPME_ENABLE: + return sizeof(mapme_activator_command); + case MAPME_DISCOVERY: + return sizeof(mapme_activator_command); + case MAPME_TIMESCALE: + return sizeof(mapme_timing_command); + case MAPME_RETX: + return sizeof(mapme_timing_command); + case LAST_COMMAND_VALUE: + return 0; + default: + return 0; + } } #endif diff --git a/hicn-plugin/src/faces/face.c b/hicn-plugin/src/faces/face.c index 26dcf960b..baf90a185 100644 --- a/hicn-plugin/src/faces/face.c +++ b/hicn-plugin/src/faces/face.c @@ -31,6 +31,14 @@ hicn_face_t *hicn_dpoi_face_pool; dpo_type_t first_type = DPO_FIRST; +vlib_combined_counter_main_t *counters; + +const char *HICN_FACE_CTRX_STRING[] = { +#define _(a,b,c) c, + foreach_hicn_face_counter +#undef _ +}; + u8 * face_show (u8 * s, int face_id, u32 indent) { @@ -77,6 +85,7 @@ hicn_face_module_init (vlib_main_t * vm) hicn_iface_ip_init (vm); hicn_face_udp_init (vm); hicn_iface_udp_init (vm); + vec_alloc (counters, 40); } u8 * diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h index 313f8ec86..d4f7f356a 100644 --- a/hicn-plugin/src/faces/face.h +++ b/hicn-plugin/src/faces/face.h @@ -51,6 +51,9 @@ typedef struct __attribute__ ((packed)) hicn_face_shared_s /* And a network or application face (1B) */ hicn_face_flags_t flags; + /* Align the upcoming fields */ + u8 align; + /* Path label (2B) */ u16 pl_id; @@ -82,7 +85,6 @@ typedef struct __attribute__ ((packed)) hicn_face_s /* Additional space to fill with face_type specific information */ u8 data[2 * CLIB_CACHE_LINE_BYTES - sizeof (hicn_face_shared_t)]; hicn_face_shared_t shared; - } hicn_face_t; @@ -140,6 +142,24 @@ typedef struct hicn_face_vft_s void (*hicn_face_get_dpo) (hicn_face_t * face, dpo_id_t * dpo); } hicn_face_vft_t; +#define foreach_hicn_face_counter \ + _(INTEREST_RX, 0, "Interest rx") \ + _(INTEREST_TX, 1, "Interest tx") \ + _(DATA_RX, 2, "Data rx") \ + _(DATA_TX, 3, "Data tx") \ + +typedef enum +{ +#define _(a,b,c) HICN_FACE_COUNTERS_##a = (b), + foreach_hicn_face_counter +#undef _ + HICN_N_COUNTER +} hicn_face_counters_t; + +extern const char *HICN_FACE_CTRX_STRING[]; + +#define get_face_counter_string(ctrxno) (char *)(HICN_FACE_CTRX_STRING[ctrxno]) + /* Vector maintaining a dpo per face */ extern dpo_id_t *face_dpo_vec; @@ -151,6 +171,9 @@ extern char **face_type_names_vec; /* First face type registered in the sytem.*/ extern dpo_type_t first_type; +/* Per-face counters */ +extern vlib_combined_counter_main_t *counters; + /** * @brief Return the face id from the face state * diff --git a/hicn-plugin/src/faces/face_cli.c b/hicn-plugin/src/faces/face_cli.c index 3ddf96beb..b0ed7ddae 100644 --- a/hicn-plugin/src/faces/face_cli.c +++ b/hicn-plugin/src/faces/face_cli.c @@ -28,7 +28,9 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, char *face_type_name = NULL; int found = ~0; int deleted = 0; - + u8 *n = 0; + u8 *s = 0; + vlib_counter_t v; /* Get a line of input. */ unformat_input_t _line_input, *line_input = &_line_input; @@ -74,6 +76,31 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, hicn_face_t *face = hicn_dpoi_get_from_idx (face_id); hicn_face_vft_t *vft = hicn_face_get_vft (face->shared.face_type); vlib_cli_output (vm, "%U\n", vft->format_face, face_id, 0 /*indent */ ); + + u32 indent = 3; + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_get_combined_counter (&counters + [hicn_dpoi_get_index (face) * + HICN_N_COUNTER], i, &v); + s = + format (s, "%U%s", format_white_space, indent, + HICN_FACE_CTRX_STRING[i]); + + if (n) + _vec_len (n) = 0; + n = format (n, "packets"); + s = + format (s, "%U%-16v%16Ld", format_white_space, + 30 - strlen (HICN_FACE_CTRX_STRING[i]), n, v.packets); + + _vec_len (n) = 0; + n = format (n, "bytes"); + s = format (s, "\n%U%-16v%16Ld\n", + format_white_space, indent + 30, n, v.bytes); + } + vlib_cli_output (vm, "%s\n", s); } else { @@ -88,7 +115,28 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, if (!((face->shared.flags & HICN_FACE_FLAGS_DELETED) && !deleted)) { if ((face->shared.face_type == type) && (face->shared.flags)) - vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0); + { + vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0); + u8 * s = 0; + u32 indent = 3; + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_get_combined_counter (&counters[hicn_dpoi_get_index(face) * HICN_N_COUNTER], i, &v); + s = format (s, "%U%s",format_white_space, indent, HICN_FACE_CTRX_STRING[i]); + + if (n) + _vec_len (n) = 0; + n = format (n, "packets"); + s = format (s, "%U%-16v%16Ld", format_white_space, 30-strlen(HICN_FACE_CTRX_STRING[i]), n, v.packets); + + _vec_len (n) = 0; + n = format (n, "bytes"); + s = format (s, "\n%U%-16v%16Ld\n", + format_white_space, indent+30, n, v.bytes); + } + vlib_cli_output (vm, "%s\n", s); + } } }); /* *INDENT-ON* */ @@ -103,6 +151,25 @@ hicn_face_cli_show_command_fn (vlib_main_t * vm, { hicn_face_vft_t * vft = hicn_face_get_vft(face->shared.face_type); vlib_cli_output(vm, "%U\n", vft->format_face, hicn_dpoi_get_index(face), 0); + u32 indent = 3; + u8 * s = 0; + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_get_combined_counter (&counters[hicn_dpoi_get_index(face) * HICN_N_COUNTER], i, &v); + s = format (s, "%U%s",format_white_space, indent, HICN_FACE_CTRX_STRING[i]); + + if (n) + _vec_len (n) = 0; + n = format (n, "packets"); + s = format (s, "%U%-16v%16Ld", format_white_space, 30-strlen(HICN_FACE_CTRX_STRING[i]), n, v.packets); + + _vec_len (n) = 0; + n = format (n, "bytes"); + s = format (s, "\n%U%-16v%16Ld\n", + format_white_space, indent+30, n, v.bytes); + } + vlib_cli_output (vm, "%s\n", s); } }); /* *INDENT-ON* */ diff --git a/hicn-plugin/src/faces/ip/face_ip.c b/hicn-plugin/src/faces/ip/face_ip.c index a7ec95417..e4eb8b665 100644 --- a/hicn-plugin/src/faces/ip/face_ip.c +++ b/hicn-plugin/src/faces/ip/face_ip.c @@ -233,13 +233,20 @@ hicn_face_ip_add (const ip46_address_t * local_addr, hicn_mapme_eventmgr_process_node.index, HICN_MAPME_EVENT_FACE_ADD, 1, sizeof (retx_t)); + + /* *INDENT-OFF* */ *retx = (retx_t) { - .prefix = 0,.dpo = (dpo_id_t) + .prefix = 0, + .dpo = (dpo_id_t) { - .dpoi_type = hicn_face_ip_type,.dpoi_proto = dpo_proto,.dpoi_next_node = - 0,.dpoi_index = *pfaceid,} + .dpoi_type = hicn_face_ip_type, + .dpoi_proto = dpo_proto, + .dpoi_next_node = 0, + .dpoi_index = *pfaceid, + } }; + /* *INDENT-ON* */ return HICN_ERROR_NONE; } diff --git a/hicn-plugin/src/faces/ip/face_ip.h b/hicn-plugin/src/faces/ip/face_ip.h index 8c31f6dd3..852106b70 100644 --- a/hicn-plugin/src/faces/ip/face_ip.h +++ b/hicn-plugin/src/faces/ip/face_ip.h @@ -202,6 +202,13 @@ hicn_iface_ip_add (const ip46_address_t * local_addr, *pfaceid = hicn_dpoi_get_index (face); mhash_set_mem (&hicn_face_ip_remote_hashtb, &key, (uword *) pfaceid, 0); + + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_validate_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], + i); + vlib_zero_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], i); + } } /** diff --git a/hicn-plugin/src/faces/ip/face_ip_node.c b/hicn-plugin/src/faces/ip/face_ip_node.c index 7b32f7355..8d0820604 100644 --- a/hicn-plugin/src/faces/ip/face_ip_node.c +++ b/hicn-plugin/src/faces/ip/face_ip_node.c @@ -151,7 +151,15 @@ typedef enum if ( PREDICT_FALSE(ret != HICN_ERROR_NONE) ) \ next0 = NEXT_ERROR_DROP_IP##ipv; \ else \ - stats.pkts_data_count += 1; \ + { \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index, \ + HICN_FACE_COUNTERS_DATA_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ + stats.pkts_data_count += 1; \ + } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ (b0->flags & VLIB_BUFFER_IS_TRACED))) \ @@ -237,12 +245,28 @@ typedef enum if ( PREDICT_FALSE(ret0 != HICN_ERROR_NONE) ) \ next0 = NEXT_ERROR_DROP_IP##ipv; \ else \ - stats.pkts_data_count += 1; \ + { \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index, \ + HICN_FACE_COUNTERS_DATA_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ + stats.pkts_data_count += 1; \ + } \ \ if ( PREDICT_FALSE(ret1 != HICN_ERROR_NONE) ) \ next1 = NEXT_ERROR_DROP_IP##ipv; \ else \ - stats.pkts_data_count += 1; \ + { \ + vlib_increment_combined_counter ( \ + &counters[hicnb1->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index,\ + HICN_FACE_COUNTERS_DATA_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ + stats.pkts_data_count += 1; \ + } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ (b0->flags & VLIB_BUFFER_IS_TRACED))) \ @@ -288,6 +312,7 @@ hicn_face_ip4_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; while (n_left_from > 0) { @@ -368,6 +393,7 @@ hicn_face_ip6_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; while (n_left_from > 0) { @@ -525,14 +551,21 @@ hicn_face_ip6_output_trace_t; \ b0 = vlib_get_buffer (vm, bi0); \ \ + hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ face = \ - hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx (face_id); \ \ if (PREDICT_TRUE(face != NULL)) \ { \ hicn_face_rewrite_interest \ (vm, b0, face, &next0); \ stats.pkts_interest_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_INTEREST_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -586,16 +619,24 @@ hicn_face_ip6_output_trace_t; b0 = vlib_get_buffer (vm, bi0); \ b1 = vlib_get_buffer (vm, bi1); \ \ + hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ + hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \ face0 = \ - hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx (face_id0); \ face1 = \ - hicn_dpoi_get_from_idx (vnet_buffer (b1)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx (face_id1); \ \ if (PREDICT_TRUE(face0 != NULL)) \ { \ hicn_face_rewrite_interest \ (vm, b0, face0, &next0); \ stats.pkts_interest_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id0 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_INTEREST_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ } \ \ if (PREDICT_TRUE(face1 != NULL)) \ @@ -603,6 +644,12 @@ hicn_face_ip6_output_trace_t; hicn_face_rewrite_interest \ (vm, b1, face1, &next1); \ stats.pkts_interest_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id1 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_INTEREST_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -645,6 +692,7 @@ hicn_face_ip4_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -718,6 +766,7 @@ hicn_face_ip6_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/hicn-plugin/src/faces/ip/iface_ip_node.c b/hicn-plugin/src/faces/ip/iface_ip_node.c index fcf43ebd7..62ccc514d 100644 --- a/hicn-plugin/src/faces/ip/iface_ip_node.c +++ b/hicn-plugin/src/faces/ip/iface_ip_node.c @@ -47,13 +47,11 @@ hicn_iface_ip_init (vlib_main_t * vm) data_fwd_iface_ip4_vlib_edge = vlib_node_add_next (vm, hicn_data_fwd_node.index, - hicn_iface_ip4_output_node. - index); + hicn_iface_ip4_output_node.index); data_fwd_iface_ip6_vlib_edge = vlib_node_add_next (vm, hicn_data_fwd_node.index, - hicn_iface_ip6_output_node. - index); + hicn_iface_ip6_output_node.index); ASSERT (temp_index4 == data_fwd_iface_ip4_vlib_edge); ASSERT (temp_index6 == data_fwd_iface_ip6_vlib_edge); @@ -193,6 +191,12 @@ typedef enum \ } \ \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index, \ + HICN_FACE_COUNTERS_INTEREST_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ \ /* Verify speculative enqueue, maybe switch current next frame */ \ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \ @@ -294,6 +298,20 @@ typedef enum sizeof (t->packet_data)); \ } \ \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index, \ + HICN_FACE_COUNTERS_INTEREST_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ + \ + vlib_increment_combined_counter ( \ + &counters[hicnb1->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index, \ + HICN_FACE_COUNTERS_INTEREST_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ + \ /* Verify speculative enqueue, maybe switch current next frame */ \ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \ to_next, n_left_to_next, \ @@ -311,6 +329,7 @@ hicn_iface_ip4_input_node_fn (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; while (n_left_from > 0) { @@ -347,8 +366,10 @@ hicn_iface_ip4_input_format_trace (u8 * s, va_list * args) hicn_iface_ip4_input_trace_t *t = va_arg (*args, hicn_iface_ip4_input_trace_t *); - s = format (s, "IFACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U", - (int) t->pkt_type, t->sw_if_index, t->next_index, format_ip4_header, t->packet_data, sizeof (t->packet_data)); + s = + format (s, "IFACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U", + (int) t->pkt_type, t->sw_if_index, t->next_index, + format_ip4_header, t->packet_data, sizeof (t->packet_data)); return (s); } @@ -387,6 +408,7 @@ hicn_iface_ip6_input_node_fn (vlib_main_t * vm, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; while (n_left_from > 0) { @@ -424,8 +446,10 @@ hicn_iface_ip6_input_format_trace (u8 * s, va_list * args) hicn_iface_ip6_input_trace_t *t = va_arg (*args, hicn_iface_ip6_input_trace_t *); - s = format (s, "IFACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U", - (int) t->pkt_type, t->sw_if_index, t->next_index, format_ip6_header, t->packet_data, sizeof (t->packet_data)); + s = + format (s, "IFACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U", + (int) t->pkt_type, t->sw_if_index, t->next_index, + format_ip6_header, t->packet_data, sizeof (t->packet_data)); return (s); } @@ -593,8 +617,9 @@ typedef enum \ b0 = vlib_get_buffer (vm, bi0); \ \ + hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ face = \ - hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx (face_id); \ \ if (PREDICT_TRUE(face != NULL)) \ { \ @@ -602,6 +627,12 @@ typedef enum (vm, b0, face); \ next0 = NEXT_DATA_LOOKUP_IP##ipv; \ stats.pkts_data_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_DATA_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0));\ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -657,10 +688,12 @@ typedef enum b0 = vlib_get_buffer (vm, bi0); \ b1 = vlib_get_buffer (vm, bi1); \ \ + hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ + hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \ face0 = \ - hicn_dpoi_get_from_idx (vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx (face_id0); \ face1 = \ - hicn_dpoi_get_from_idx (vnet_buffer (b1)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx (face_id1); \ \ if (PREDICT_TRUE(face0 != NULL)) \ { \ @@ -668,6 +701,12 @@ typedef enum (vm, b0, face0); \ next0 = NEXT_DATA_LOOKUP_IP##ipv; \ stats.pkts_data_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id0 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_DATA_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0));\ } \ \ if (PREDICT_TRUE(face1 != NULL)) \ @@ -676,6 +715,12 @@ typedef enum (vm, b1, face1); \ next1 = NEXT_DATA_LOOKUP_IP##ipv; \ stats.pkts_data_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id1 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_DATA_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -720,6 +765,7 @@ hicn_iface_ip4_output_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -758,8 +804,10 @@ hicn_iface_ip4_output_format_trace (u8 * s, va_list * args) hicn_iface_ip4_output_trace_t *t = va_arg (*args, hicn_iface_ip4_output_trace_t *); - s = format (s, "IFACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U", - (int) t->pkt_type, t->sw_if_index, t->next_index, format_ip4_header, t->packet_data, sizeof (t->packet_data)); + s = + format (s, "IFACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U", + (int) t->pkt_type, t->sw_if_index, t->next_index, + format_ip4_header, t->packet_data, sizeof (t->packet_data)); return (s); } @@ -794,6 +842,7 @@ hicn_iface_ip6_output_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -831,8 +880,10 @@ hicn_iface_ip6_output_format_trace (u8 * s, va_list * args) hicn_iface_ip6_output_trace_t *t = va_arg (*args, hicn_iface_ip6_output_trace_t *); - s = format (s, "IFACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U", - (int) t->pkt_type, t->sw_if_index, t->next_index, format_ip6_header, t->packet_data, sizeof (t->packet_data)); + s = + format (s, "IFACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U", + (int) t->pkt_type, t->sw_if_index, t->next_index, + format_ip6_header, t->packet_data, sizeof (t->packet_data)); return (s); } diff --git a/hicn-plugin/src/faces/udp/face_udp.c b/hicn-plugin/src/faces/udp/face_udp.c index 6f345925b..7858db644 100644 --- a/hicn-plugin/src/faces/udp/face_udp.c +++ b/hicn-plugin/src/faces/udp/face_udp.c @@ -81,15 +81,17 @@ hicn_face_udp_init (vlib_main_t * vm) /* Default Strategy has index 0 and it always exists */ strategy_face_udp4_vlib_edge = vlib_node_add_next (vm, hicn_dpo_get_strategy_vft - (default_dpo.hicn_dpo_get_type - ())->get_strategy_node_index + (default_dpo. + hicn_dpo_get_type ())-> + get_strategy_node_index (), - hicn_face_udp4_output_node.index); + hicn_face_udp4_output_node. + index); strategy_face_udp6_vlib_edge = vlib_node_add_next (vm, - hicn_dpo_get_strategy_vft - (default_dpo.hicn_dpo_get_type - ())->get_strategy_node_index (), + hicn_dpo_get_strategy_vft (default_dpo. + hicn_dpo_get_type ())-> + get_strategy_node_index (), hicn_face_udp6_output_node.index); /* @@ -265,17 +267,31 @@ hicn_face_udp_add (const ip46_address_t * local_addr, return HICN_ERROR_IPS_ADDR_TYPE_NONUNIFORM; } + for (int i = 0; i < HICN_N_COUNTER; i++) + { + vlib_validate_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], + i); + vlib_zero_combined_counter (&counters[(*pfaceid) * HICN_N_COUNTER], i); + } + retx_t *retx = vlib_process_signal_event_data (vlib_get_main (), - hicn_mapme_eventmgr_process_node.index, + hicn_mapme_eventmgr_process_node. + index, HICN_MAPME_EVENT_FACE_ADD, 1, sizeof (retx_t)); + /* *INDENT-OFF* */ *retx = (retx_t) { - .prefix = 0,.dpo = (dpo_id_t) + .prefix = 0, + .dpo = (dpo_id_t) { - .dpoi_type = hicn_face_udp_type,.dpoi_proto = - dpo_proto,.dpoi_next_node = 0,.dpoi_index = *pfaceid,} + .dpoi_type = hicn_face_udp_type, + .dpoi_proto = dpo_proto, + .dpoi_next_node = 0, + .dpoi_index = *pfaceid, + } }; + /* *INDENT-ON* */ return ret; } diff --git a/hicn-plugin/src/faces/udp/face_udp_node.c b/hicn-plugin/src/faces/udp/face_udp_node.c index 5f19eb0af..df24c477f 100644 --- a/hicn-plugin/src/faces/udp/face_udp_node.c +++ b/hicn-plugin/src/faces/udp/face_udp_node.c @@ -161,6 +161,12 @@ typedef enum \ vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \ sizeof(udp_header_t)); \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index, \ + HICN_FACE_COUNTERS_DATA_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -266,6 +272,12 @@ typedef enum \ vlib_buffer_advance(b0, sizeof(IP_HEADER_##ipv) + \ sizeof(udp_header_t)); \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index, \ + HICN_FACE_COUNTERS_DATA_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ } \ \ if ( PREDICT_FALSE(ret1 != HICN_ERROR_NONE) ) \ @@ -280,6 +292,12 @@ typedef enum \ vlib_buffer_advance(b1, sizeof(IP_HEADER_##ipv) + \ sizeof(udp_header_t)); \ + vlib_increment_combined_counter ( \ + &counters[hicnb1->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index,\ + HICN_FACE_COUNTERS_DATA_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -325,6 +343,7 @@ hicn_face_udp4_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; while (n_left_from > 0) { @@ -363,8 +382,9 @@ hicn_face_udp4_input_format_trace (u8 * s, va_list * args) s = format (s, "FACE_UDP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U", (int) t->pkt_type, t->sw_if_index, t->next_index, - (t->packet_data[0] & 0xf0) == 0x40 ? format_ip4_header : format_ip6_header, - t->packet_data, sizeof (t->packet_data)); + (t->packet_data[0] & 0xf0) == + 0x40 ? format_ip4_header : format_ip6_header, t->packet_data, + sizeof (t->packet_data)); return (s); } @@ -403,6 +423,7 @@ hicn_face_udp6_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, n_left_from = frame->n_vectors; next_index = node->cached_next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; while (n_left_from > 0) { @@ -444,8 +465,9 @@ hicn_face_udp6_input_format_trace (u8 * s, va_list * args) s = format (s, "FACE_UDP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U", (int) t->pkt_type, t->sw_if_index, t->next_index, - (t->packet_data[0] & 0xf0) == 0x40 ? format_ip4_header : format_ip6_header, - t->packet_data, sizeof (t->packet_data)); + (t->packet_data[0] & 0xf0) == + 0x40 ? format_ip4_header : format_ip6_header, t->packet_data, + sizeof (t->packet_data)); return (s); } @@ -618,8 +640,9 @@ hicn_face_udp6_output_trace_t; n_left_from -= 1; \ \ b0 = vlib_get_buffer (vm, bi0); \ + hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ face = \ - hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx(face_id); \ \ if (PREDICT_TRUE(face != NULL)) \ { \ @@ -631,6 +654,12 @@ hicn_face_udp6_output_trace_t; HICN_FACE_UDP_ENCAP_IP##ipv \ (vm, b0, face, &next0); \ stats.pkts_interest_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_INTEREST_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0));\ } \ \ \ @@ -692,6 +721,8 @@ hicn_face_udp6_output_trace_t; b0 = vlib_get_buffer (vm, bi0); \ b1 = vlib_get_buffer (vm, bi1); \ \ + hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ + hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \ face0 = \ hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ face1 = \ @@ -707,6 +738,12 @@ hicn_face_udp6_output_trace_t; HICN_FACE_UDP_ENCAP_IP##ipv \ (vm, b0, face0, &next0); \ stats.pkts_interest_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id0 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_INTEREST_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ } \ \ if (PREDICT_TRUE(face1 != NULL)) \ @@ -719,6 +756,12 @@ hicn_face_udp6_output_trace_t; HICN_FACE_UDP_ENCAP_IP##ipv \ (vm, b1, face1, &next1); \ stats.pkts_interest_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id1 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_INTEREST_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ } \ \ \ @@ -764,6 +807,7 @@ hicn_face_udp4_output_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -807,8 +851,9 @@ hicn_face_udp4_output_format_trace (u8 * s, va_list * args) s = format (s, "FACE_UDP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U", (int) t->pkt_type, t->sw_if_index, t->next_index, - (t->packet_data[0] & 0xf0) == 0x40 ? format_ip4_header : format_ip6_header, - t->packet_data, sizeof (t->packet_data)); + (t->packet_data[0] & 0xf0) == + 0x40 ? format_ip4_header : format_ip6_header, t->packet_data, + sizeof (t->packet_data)); return (s); } @@ -841,6 +886,7 @@ hicn_face_udp6_output_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -883,8 +929,9 @@ hicn_face_udp6_output_format_trace (u8 * s, va_list * args) s = format (s, "FACE_UDP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%u", (int) t->pkt_type, t->sw_if_index, t->next_index, - (t->packet_data[0] & 0xf0) == 0x40 ? format_ip4_header : format_ip6_header, - t->packet_data, sizeof (t->packet_data)); + (t->packet_data[0] & 0xf0) == + 0x40 ? format_ip4_header : format_ip6_header, t->packet_data, + sizeof (t->packet_data)); return (s); } diff --git a/hicn-plugin/src/faces/udp/iface_udp_node.c b/hicn-plugin/src/faces/udp/iface_udp_node.c index 9558ebfce..4dc267f85 100644 --- a/hicn-plugin/src/faces/udp/iface_udp_node.c +++ b/hicn-plugin/src/faces/udp/iface_udp_node.c @@ -39,13 +39,11 @@ hicn_iface_udp_init (vlib_main_t * vm) { data_fwd_face_udp4_vlib_edge = vlib_node_add_next (vm, hicn_data_fwd_node.index, - hicn_iface_udp4_output_node. - index); + hicn_iface_udp4_output_node.index); data_fwd_face_udp6_vlib_edge = vlib_node_add_next (vm, hicn_data_fwd_node.index, - hicn_iface_udp6_output_node. - index); + hicn_iface_udp6_output_node.index); u32 temp_index4 = vlib_node_add_next (vm, hicn_interest_hitcs_node.index, @@ -205,6 +203,13 @@ typedef enum vlib_buffer_get_current (b0), \ sizeof (t->packet_data)); \ } \ + \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index,\ + HICN_FACE_COUNTERS_INTEREST_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ \ \ /* Verify speculative enqueue, maybe switch current next frame */ \ @@ -326,6 +331,19 @@ typedef enum sizeof (t->packet_data)); \ } \ \ + vlib_increment_combined_counter ( \ + &counters[hicnb0->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index,\ + HICN_FACE_COUNTERS_INTEREST_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ + \ + vlib_increment_combined_counter ( \ + &counters[hicnb1->face_dpo_id.dpoi_index \ + * HICN_N_COUNTER], thread_index,\ + HICN_FACE_COUNTERS_INTEREST_RX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ \ /* Verify speculative enqueue, maybe switch current next frame */ \ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \ @@ -341,6 +359,7 @@ hicn_iface_udp4_input_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -422,7 +441,7 @@ hicn_iface_udp6_input_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; - + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -657,8 +676,9 @@ typedef enum \ b0 = vlib_get_buffer (vm, bi0); \ \ + hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ face = \ - hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx(face_id); \ \ if (PREDICT_TRUE(face != NULL)) \ { \ @@ -666,6 +686,12 @@ typedef enum (vm, b0, face); \ next0 = NEXT_LOOKUP_UDP##ipv; \ stats.pkts_data_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_DATA_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -720,10 +746,12 @@ typedef enum b0 = vlib_get_buffer (vm, bi0); \ b1 = vlib_get_buffer (vm, bi1); \ \ + hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \ + hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \ face0 = \ - hicn_dpoi_get_from_idx(vnet_buffer (b0)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx(face_id0); \ face1 = \ - hicn_dpoi_get_from_idx(vnet_buffer (b1)->ip.adj_index[VLIB_TX]); \ + hicn_dpoi_get_from_idx(face_id1); \ \ if (PREDICT_TRUE(face0 != NULL)) \ { \ @@ -731,6 +759,12 @@ typedef enum (vm, b0, face0); \ next0 = NEXT_LOOKUP_UDP##ipv; \ stats.pkts_data_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id0 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_DATA_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b0)); \ } \ \ if (PREDICT_TRUE(face1 != NULL)) \ @@ -739,6 +773,12 @@ typedef enum (vm, b1, face1); \ next1 = NEXT_LOOKUP_UDP##ipv; \ stats.pkts_data_count += 1; \ + vlib_increment_combined_counter ( \ + &counters[face_id1 * HICN_N_COUNTER], \ + thread_index, \ + HICN_FACE_COUNTERS_DATA_TX, \ + 1, \ + vlib_buffer_length_in_chain(vm, b1)); \ } \ \ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \ @@ -784,6 +824,7 @@ hicn_iface_udp4_output_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; @@ -864,6 +905,7 @@ hicn_iface_udp6_output_node_fn (vlib_main_t * vm, { u32 n_left_from, *from, *to_next, next_index; vl_api_hicn_api_node_stats_get_reply_t stats = { 0 }; + u32 thread_index = vm->thread_index; from = vlib_frame_vector_args (frame); n_left_from = frame->n_vectors; diff --git a/hicn-plugin/src/hicn.api b/hicn-plugin/src/hicn.api index 46ce177ea..48e2eace5 100644 --- a/hicn-plugin/src/hicn.api +++ b/hicn-plugin/src/hicn.api @@ -223,6 +223,47 @@ define hicn_api_face_ip_params_get u16 faceid; }; +define hicn_api_face_stats_details +{ +/* From the request */ + u32 context; + + /* Return value, zero means all OK */ + i32 retval; + + /* Id of the face */ + u32 faceid; + + /* Interest rx */ + u64 irx_packets; + + u64 irx_bytes; + + /* Interest tx */ + u64 itx_packets; + + u64 itx_bytes; + + /* data rx */ + u64 drx_packets; + + u64 drx_bytes; + + /* data tx */ + u64 dtx_packets; + + u64 dtx_bytes; +}; + +define hicn_api_face_stats_dump +{ +/* Client identifier, set from api_main.my_client_index */ + u32 client_index; + + /* Arbitrary context, so client can match reply to request */ + u32 context; +}; + define hicn_api_face_ip_params_get_reply { /* From the request */ diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c index c532118b3..6249d6e5e 100644 --- a/hicn-plugin/src/hicn_api.c +++ b/hicn-plugin/src/hicn_api.c @@ -68,6 +68,7 @@ _(HICN_API_FACE_IP_ADD, hicn_api_face_ip_add) \ _(HICN_API_FACE_IP_DEL, hicn_api_face_ip_del) \ _(HICN_API_FACE_IP_PARAMS_GET, hicn_api_face_ip_params_get) \ + _(HICN_API_FACE_STATS_DUMP, hicn_api_face_stats_dump) \ _(HICN_API_ROUTE_GET, hicn_api_route_get) \ _(HICN_API_ROUTE_NHOPS_ADD, hicn_api_route_nhops_add) \ _(HICN_API_ROUTE_DEL, hicn_api_route_del) \ @@ -255,6 +256,68 @@ static void /* *INDENT-ON* */ } +static void +send_face_stats_details (vl_api_registration_t * reg, + hicn_face_t * face, u32 context) +{ + vl_api_hicn_api_face_stats_details_t *mp; + hicn_main_t *hm = &hicn_main; + mp = vl_msg_api_alloc (sizeof (*mp)); + memset (mp, 0, sizeof (*mp)); + + mp->_vl_msg_id = + htons (VL_API_HICN_API_FACE_STATS_DETAILS + hm->msg_id_base); + mp->context = context; + + mp->faceid = htonl (hicn_dpoi_get_index (face)); + vlib_counter_t v; + vlib_get_combined_counter (&counters + [hicn_dpoi_get_index (face) * HICN_N_COUNTER], + HICN_FACE_COUNTERS_INTEREST_RX, &v); + mp->irx_packets = clib_net_to_host_u64 (v.packets); + mp->irx_bytes = clib_net_to_host_u64 (v.bytes); + + vlib_get_combined_counter (&counters + [hicn_dpoi_get_index (face) * HICN_N_COUNTER], + HICN_FACE_COUNTERS_INTEREST_TX, &v); + mp->itx_packets = clib_net_to_host_u64 (v.packets); + mp->itx_bytes = clib_net_to_host_u64 (v.bytes); + + vlib_get_combined_counter (&counters + [hicn_dpoi_get_index (face) * HICN_N_COUNTER], + HICN_FACE_COUNTERS_DATA_RX, &v); + mp->drx_packets = clib_net_to_host_u64 (v.packets); + mp->drx_bytes = clib_net_to_host_u64 (v.bytes); + + vlib_get_combined_counter (&counters + [hicn_dpoi_get_index (face) * HICN_N_COUNTER], + HICN_FACE_COUNTERS_DATA_TX, &v); + mp->dtx_packets = clib_net_to_host_u64 (v.packets); + mp->dtx_bytes = clib_net_to_host_u64 (v.bytes); + + vl_api_send_msg (reg, (u8 *) mp); +} + +static void + vl_api_hicn_api_face_stats_dump_t_handler + (vl_api_hicn_api_face_stats_dump_t * mp) +{ + hicn_face_t *face; + vl_api_registration_t *reg; + + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + + /* *INDENT-OFF* */ + pool_foreach (face, hicn_dpoi_face_pool, + ({ + send_face_stats_details (reg, face, mp->context); + })); + /* *INDENT-ON* */ +} + + /****** ROUTE *******/ static void diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c index 2619803b7..909bc540f 100644 --- a/hicn-plugin/src/hicn_api_test.c +++ b/hicn-plugin/src/hicn_api_test.c @@ -27,7 +27,6 @@ #define __plugin_msg_base hicn_test_main.msg_id_base #include <vlibapi/vat_helper_macros.h> - #include <hicn/hicn_api.h> #include "error.h" @@ -36,6 +35,17 @@ /* Declare message IDs */ #include "hicn_msg_enum.h" +/* define message structures */ +#define vl_typedefs +#include <vpp/api/vpe_all_api_h.h> +#include <hicn/hicn_all_api_h.h> +#undef vl_typedefs + +/* Get CRC codes of the messages defined outside of this plugin */ +#define vl_msg_name_crc_list +#include <vpp/api/vpe_all_api_h.h> +#undef vl_msg_name_crc_list + /* declare message handlers for each api */ #define vl_endianfun /* define message structures */ @@ -82,6 +92,7 @@ typedef struct /* API message ID base */ u16 msg_id_base; vat_main_t *vat_main; + u32 ping_id; } hicn_test_main_t; hicn_test_main_t hicn_test_main; @@ -120,6 +131,7 @@ _(HICN_API_NODE_PARAMS_GET_REPLY, hicn_api_node_params_get_reply) \ _(HICN_API_NODE_STATS_GET_REPLY, hicn_api_node_stats_get_reply) \ _(HICN_API_FACE_IP_DEL_REPLY, hicn_api_face_ip_del_reply) \ _(HICN_API_FACE_IP_ADD_REPLY, hicn_api_face_ip_add_reply) \ +_(HICN_API_FACE_STATS_DETAILS, hicn_api_face_stats_details) \ _(HICN_API_ROUTE_NHOPS_ADD_REPLY, hicn_api_route_nhops_add_reply) \ _(HICN_API_FACE_IP_PARAMS_GET_REPLY, hicn_api_face_ip_params_get_reply) \ _(HICN_API_ROUTE_GET_REPLY, hicn_api_route_get_reply) \ @@ -512,6 +524,66 @@ static void clib_net_to_host_i32 (rmp->flags)); } +/* memif-dump API */ +static int +api_hicn_api_face_stats_dump (vat_main_t * vam) +{ + hicn_test_main_t *hm = &hicn_test_main; + vl_api_hicn_api_face_stats_dump_t *mp; + vl_api_control_ping_t *mp_ping; + int ret; + + if (vam->json_output) + { + clib_warning ("JSON output not supported for memif_dump"); + return -99; + } + + M (HICN_API_FACE_STATS_DUMP, mp); + S (mp); + + /* Use a control ping for synchronization */ + mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping)); + mp_ping->_vl_msg_id = htons (hm->ping_id); + mp_ping->client_index = vam->my_client_index; + + fformat (vam->ofp, "Sending ping id=%d\n", hm->ping_id); + + vam->result_ready = 0; + S (mp_ping); + + W (ret); + return ret; +} + +/* memif-details message handler */ +static void +vl_api_hicn_api_face_stats_details_t_handler + (vl_api_hicn_api_face_stats_details_t * mp) +{ + vat_main_t *vam = hicn_test_main.vat_main; + + fformat (vam->ofp, "face id %d\n" + " interest rx packets %16Ld\n" + " bytes %16Ld\n" + " interest tx packets %16Ld\n" + " bytes %16Ld\n" + " data rx packets %16Ld\n" + " bytes %16Ld\n" + " data tx packets %16Ld\n" + " bytes %16Ld\n", + clib_host_to_net_u32 (mp->faceid), + clib_host_to_net_u64 (mp->irx_packets), + clib_host_to_net_u64 (mp->irx_bytes), + clib_host_to_net_u64 (mp->itx_packets), + clib_host_to_net_u64 (mp->itx_bytes), + clib_host_to_net_u64 (mp->drx_packets), + clib_host_to_net_u64 (mp->drx_bytes), + clib_host_to_net_u64 (mp->dtx_packets), + clib_host_to_net_u64 (mp->dtx_bytes)); +} + + static int api_hicn_api_route_get (vat_main_t * vam) { @@ -1000,6 +1072,7 @@ _(hicn_api_node_params_get, "") \ _(hicn_api_node_stats_get, "") \ _(hicn_api_face_ip_del, "face <faceID>") \ _(hicn_api_face_ip_add, "add <swif> <address>") \ +_(hicn_api_face_stats_dump, "") \ _(hicn_api_route_nhops_add, "add prefix <IP4/IP6>/<subnet> face <faceID> weight <weight>") \ _(hicn_api_face_ip_params_get, "face <faceID>") \ _(hicn_api_route_get, "prefix <IP4/IP6>/<subnet>") \ @@ -1049,6 +1122,13 @@ vat_plugin_register (vat_main_t * vam) name = format (0, "hicn_%08x%c", api_version, 0); sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); + /* Get the control ping ID */ +#define _(id,n,crc) \ + const char *id ## _CRC __attribute__ ((unused)) = #n "_" #crc; + foreach_vl_msg_name_crc_vpe; +#undef _ + sm->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); + if (sm->msg_id_base != (u16) ~ 0) hicn_vat_api_hookup (vam); |